From 979e652f46bd6f1492161d753d47fde25e86e394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=97=E5=B9=B3?= Date: Wed, 10 Jun 2026 21:35:52 +0800 Subject: [PATCH] add missing skills --- skills/goal-driven-loop/SKILL.md | 59 +++++++++++++++ .../references/error-handling.md | 75 +++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 skills/goal-driven-loop/SKILL.md create mode 100644 skills/goal-driven-loop/references/error-handling.md diff --git a/skills/goal-driven-loop/SKILL.md b/skills/goal-driven-loop/SKILL.md new file mode 100644 index 0000000..bbe5779 --- /dev/null +++ b/skills/goal-driven-loop/SKILL.md @@ -0,0 +1,59 @@ +--- +name: goal-driven-loop +description: Use when the user sets a current goal with phrases like "设定当前目标为", "当前目标是", "current goal is", or "my goal is", and the task is not a trivial fix, hotfix, tweak, or quoted text +--- + +# Goal-Driven Loop + +Keep the current session focused on a user-defined goal with explicit acceptance criteria. Iterate until all criteria pass, or genuine stagnation is detected. + +## When to Activate + +**Trigger phrases (any language, semantic variants):** +- Chinese: 设定当前目标为 / 当前目标是 / 把当前目标设为 / 我的目标是 +- English: set current goal to / current goal is / my goal is / the goal is +- Other: semantically equivalent phrasings + concrete deliverable + +**Do NOT activate when:** +- Trigger phrase inside markdown quote (`>`) or code block, or same sentence as reported speech (he said / 他说) +- Message contains trivial-task keywords: hotfix, tweak, quick fix, 修个bug, 小改 +- Goal description ≤ 10 chars without architectural keywords, or agent estimates < 5 min without architectural keywords +- `.agents/goal/GOAL.md` exists → extension prompts: continue / replace / abandon (10s timeout → continue) + +**Granularity:** Coarse (file count > 5, multi-module, architectural) → extension invokes `comet-open`. Fine (single concern, ≤ 5 files) → this skill. Fallback: if comet unavailable, auto-split into phases. + +## Core Loop + +1. **Initialize** — If `GOAL.md` exists, extension prompts with timed default. If no criteria provided, auto-generate (verifiability red line). Write `GOAL.md`. + +2. **Execute** — Read `GOAL.md`, pick next unpassed criterion (least dependent), implement, verify, record in Progress Log. + +3. **Verify** — Check each criterion against fresh evidence. Update checkboxes, iteration counter, timestamp. + +4. **Loop** — All ✅ → exit. Stagnation → extension auto-injects strategy change (2x before user notification). Otherwise → step 2. + +5. **Exit** — Deslop pass on modified files (failure doesn't block). Delete `GOAL.md`. Output summary. + +## Acceptance Criteria Verifiability + +Auto-generated criteria must be verifiable. Examples: +- ❌ "Implement rate limiting" → not verifiable +- ✅ "Rate limiter middleware mounts on auth routes, excess requests return 429" → verifiable +- ❌ "Code quality is good" → not verifiable +- ✅ "Related files lint clean, typecheck passes" → verifiable + +Agent cannot unilaterally delete or skip criteria. Material modifications require logged reason; safe adjustments (typos, splitting compounds) may be auto-applied. + +## Goal State File + +Path: `.agents/goal/GOAL.md` — frontmatter with `goal`, `created`, `updated`, `iteration`, `status` (in-progress | blocked | complete). Body has Acceptance Criteria (checkboxes), Progress Log (per-iteration), Blocked section. + +## Error Handling + +See `references/error-handling.md` for retry strategy, exception classification, stagnation rules, and red flags. + +**Context tension:** Extension detects via `ctx.getContextUsage() > 0.8`. Auto-injects "save progress now" directive into next turn. + +**Mid-loop granularity upgrade:** If execution reveals the goal is more complex than estimated, extension auto-invokes `comet-open` with `GOAL.md` state. User is informed via UI notification, not asked for confirmation. + +**Explicit abandon:** User says "abandon / cancel / 不要了" → extension deletes `GOAL.md`, outputs brief summary, terminates. diff --git a/skills/goal-driven-loop/references/error-handling.md b/skills/goal-driven-loop/references/error-handling.md new file mode 100644 index 0000000..b6d77a9 --- /dev/null +++ b/skills/goal-driven-loop/references/error-handling.md @@ -0,0 +1,75 @@ +# Error Handling Reference + +Detailed retry strategy, exception classification, and recovery rules for the `goal-driven-loop` skill. + +## Retry Strategy (Automatic, No Human Intervention) + +All recoverable exceptions use exponential backoff. Counter is **per-iteration** — resets at the start of each new iteration. + +| Parameter | Value | +|-----------|-------| +| Max retries | 10 per iteration | +| Initial delay | 30s | +| Backoff factor | ×2 | +| Max delay | 300s (5min) | + +**Backoff sequence:** + +| Retry | Delay | Cumulative | +|-------|-------|------------| +| 1 | 30s | 0.5min | +| 2 | 60s | 1.5min | +| 3 | 120s | 3.5min | +| 4 | 240s | 7.5min | +| 5 | 300s | 12.5min | +| 6 | 300s | 17.5min | +| 7 | 300s | 22.5min | +| 8 | 300s | 27.5min | +| 9 | 300s | 32.5min | +| 10 | 300s | 37.5min | + +**Formula:** `delay = min(30 * 2^(retry-1), 300)` seconds. + +**Execution:** Before retry, run `bash -c "sleep && echo done"` with `timeout` parameter set to `delay + 30`. If sleep is interrupted, treat as tool failure, enter retry. + +**After 10 retries exhausted:** `status = blocked`, write Blocked section to `GOAL.md`, extension auto-attempts alternative approach. If still blocked after auto-attempt, then notify user. + +## Exception Classification + +| Exception | Detection signal | Recoverable? | Response | +|-----------|------------------|--------------|----------| +| Tool execution failure | bash returns non-zero exit | Yes | Exponential backoff retry | +| LLM API exception | subagent timeout/error | Yes | Exponential backoff retry | +| Context tension | Extension detects `getContextUsage() > 0.8` | No | Extension auto-saves state, injects continuation directive | +| User interruption | User sends new message mid-loop | No | Extension auto-pauses, responds, resumes on next trigger | +| Stale state | `GOAL.md` exists with `status = in-progress` | No | Extension prompts: continue / replace / abandon (10s timeout → continue) | + +## Stagnation Detection + +Both signals must be present: + +1. Acceptance criteria passing count unchanged for 3 consecutive iterations, AND +2. Progress Log last 3 iterations contain no progress keywords (found / fixed / implemented / added / refactored / verified) + +Only both conditions together trigger stagnation. Extension auto-injects strategy-change prompt. After 2 consecutive auto-recoveries with no progress, extension notifies user. + +## Continuation Prompt Format (Fixed) + +When context is tight, output exactly this format: + +``` +🔄 目标状态已保存至 .agents/goal/GOAL.md +当前进度:X/Y criteria 通过,第 N 轮迭代。 +``` + +The extension injects the full state summary on every `before_agent_start`, so the next prompt automatically re-loads the goal. + +## Red Flags — These Do NOT Count as Completion + +- "LLM call failed, goal should be considered complete" → retry or blocked +- "Tests don't run but code looks fine" → must have test evidence +- "Context full, let me summarize" → save state, extension auto-injects continuation, do not declare done +- "Too many retries, skip this criterion" → exhausted retries → blocked, do not skip +- "This criterion is too hard to verify, skip it" → agent may auto-rewrite, logged as material change +- "All criteria basically met, close enough" → each criterion must have explicit pass evidence +- "Deslop pass would take too long, skip" → deslop failure does not block, but agent should still attempt it