fix(ext): spec compliance fixes — stagnation recovery, comet fallback, quote anti-trigger, types, package.json

- trigger-detector: fix quote anti-trigger (only block if trigger exclusively in quotes)
- trigger-detector: add uncertainty fallback pattern (goal is/为 + deliverable)
- trigger-detector: add 'fix bug' to trivial keywords
- index.ts: implement stagnation auto-recovery injection
- index.ts: implement comet fallback when openspec not available
- index.ts: replace 'any' types with ExtensionContext
- index.ts: wire consecutiveStagnations counter
- Add package.json for extension discovery
This commit is contained in:
张宗平
2026-06-10 18:32:18 +08:00
parent b5cabceb72
commit 0dd652948e
3 changed files with 116 additions and 37 deletions
@@ -25,12 +25,15 @@ const TRIGGER_PATTERNS: RegExp[] = [
/current\s+goal\s+is\s+(.+)/i,
/my\s+goal\s+is\s+(.+)/i,
/the\s+goal\s+is\s+(.+)/i,
// Uncertainty fallback: commitment language + deliverable
/(?:goal|目标)\s*(?:is|为|是)\s+(?:(?:to|去)\s+)?(.+)/i,
];
const TRIVIAL_KEYWORDS = [
"hotfix",
"tweak",
"fix a bug",
"fix bug",
"small change",
"quick fix",
"修个bug",
@@ -72,15 +75,14 @@ export function detectTrigger(input: string): TriggerMatch | null {
return null;
}
// Anti-trigger: markdown quote block
const lines = input.split("\n");
for (const line of lines) {
if (/^\s*>/.test(line)) {
const triggerInQuote = TRIGGER_PATTERNS.some((p) => p.test(line));
if (triggerInQuote) {
return null;
}
}
// Anti-trigger: markdown quote block — only block if trigger phrase appears
// exclusively inside quote lines (no trigger in non-quote content)
const nonQuoteLines = input.split("\n").filter((line) => !/^\s*>/.test(line));
const nonQuoteContent = nonQuoteLines.join("\n");
const hasTriggerOutsideQuote = TRIGGER_PATTERNS.some((p) => p.test(nonQuoteContent));
if (!hasTriggerOutsideQuote) {
// All trigger phrases are inside quotes — block
return null;
}
// Anti-trigger: reported speech