M005: Tiered Context Injection - Scoped knowledge queries & roadmap excerpts

- Added queryKnowledge() for keyword-based KNOWLEDGE.md section filtering
- Added formatRoadmapExcerpt() for slice-scoped roadmap excerpts
- Added inlineKnowledgeScoped() and inlineRoadmapExcerpt() to auto-prompts
- Context reduction: ~65% for knowledge, ~67% for roadmap excerpts
- Also includes deriveSliceScope() fix for unit IDs and process words

Squash merge of milestone/M005
This commit is contained in:
OfficialDelta 2026-04-07 23:48:06 -04:00
parent e4f94fa5fb
commit c3ba64d56b

View file

@ -363,8 +363,14 @@ const GENERIC_WORDS = new Set([
'fix', 'fixes', 'add', 'adds', 'remove', 'removes',
'create', 'creates', 'build', 'builds', 'deploy', 'deployment',
'refactor', 'refactoring', 'cleanup', 'polish', 'review',
// Process/activity words that describe what you're doing, not what domain
'hardening', 'validation', 'verification', 'optimization',
'improvement', 'enhancement', 'infrastructure',
]);
// Pattern to match slice/milestone/task IDs (e.g., S01, M001, T03)
const UNIT_ID_PATTERN = /^[smt]\d+$/i;
/**
* Derive a scope keyword from slice title and optional description.
* Returns the most specific noun (first non-generic keyword) for decision scoping.
@ -394,17 +400,18 @@ export function deriveSliceScope(sliceTitle: string, sliceDescription?: string):
// Find the first word that is:
// 1. Not a stopword
// 2. Not a generic word
// 3. At least 3 characters (meaningful scope)
// 3. Not a unit ID (S01, M001, T03)
// 4. At least 3 characters (meaningful scope)
for (const word of words) {
if (STOPWORDS.has(word)) continue;
if (GENERIC_WORDS.has(word)) continue;
if (UNIT_ID_PATTERN.test(word)) continue;
if (word.length < 3) continue;
return word;
}
return undefined;
}
/**
* Extract keywords from a slice title for scoped knowledge queries.
* Splits on whitespace, filters stopwords, lowercases.