Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions skills/diagnose/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
name: diagnose
description: "Parallel root-cause analysis for bugs and failing tests. Use when a test fails, a bug is reported, or behavior is unexplained — dispatches sub-agents to form and validate hypotheses in isolated worktrees."
context: fork
category: Debug & fix
---

Gather context: read the failing test or bug description, relevant error output, and recent git changes. If no failing test exists yet, write a minimal reproducer test (or identify a concrete verification command) before proceeding — hypotheses need a pass/fail signal to validate against. Dispatch two sub-agents in parallel — one to search the codebase for code paths involved in the failure (`subagent_type: research-agent`, read-only), and one to check recent commits and diffs that could have introduced the regression (`subagent_type: general-purpose` — requires Bash for `git log`/`git diff`/`git show`). When both return, synthesize findings into 2–4 ranked hypotheses, each with a specific code location and proposed cause.

**TUI label convention.** Set `id_prefix` on each Agent dispatch to a short, descriptive label so the live progress view shows the agent's role:
- Codebase search agent: `id_prefix: "codebase search"`
- Git history agent: `id_prefix: "git history"`
- Each hypothesis-testing agent: `id_prefix: "hypothesis: <one-phrase cause>"` (e.g. `"hypothesis: null deref in parser"`)

For each hypothesis, dispatch a sub-agent with `isolation: "worktree"` to apply a minimal speculative fix, run the test or verification command, and then run the broader related test suite to check for regressions. Run all hypothesis-testing agents in parallel. Collect results: which fixes passed, which didn't, and any regressions surfaced by the broader suite.

Report the validated root cause (the hypothesis whose fix passed), the speculative fix diff, and regression status from the broader test run. If no hypothesis passes, synthesize what was learned and form a second round of hypotheses. If the user approves the fix, apply it to the main worktree.
87 changes: 76 additions & 11 deletions skills/fix-pr/SKILL.md

Large diffs are not rendered by default.

38 changes: 34 additions & 4 deletions skills/ground-state/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ If the survey reveals a fix that's tempting to apply, **return it as a recommend

## Inline reconnaissance

Run the three surveys below **directly using your own tools**. Do NOT dispatch any sub-agents via the `agent` or `skill` tools — every lookup in this phase is a deterministic read that you execute yourself using `bash`, `glob`, `read_file`, `grep`, `list_directory`, and `memory_search`. Issue all three surveys in a single batched tool-use round where possible.
Run the four surveys below **directly using your own tools**. Do NOT dispatch any sub-agents via the `agent` or `skill` tools — every lookup in this phase is a deterministic read that you execute yourself using `bash`, `glob`, `read_file`, `grep`, `list_directory`, and `memory_search`. Issue all four surveys in a single batched tool-use round where possible.

### State survey *(bash)*

Expand Down Expand Up @@ -62,21 +62,51 @@ Call the **`memory_search` tool** with keywords from the user's current request

Return: relevant facts with 1-line summaries, **plus the stores actually consulted** — e.g. `memory_search: 3 queries, 0 hits; HOT.md: read; AFK.md: read` — so the orchestrator can tell "no relevant memory exists" from "the fork never looked." If `memory_search` is unavailable on this surface, say so explicitly.

### Spine survey *(read_file)*

Read `SPINE.md` from the repo root (same directory as `AFK.md`). If the file does not exist or is empty, skip silently -- do not mention it in the snapshot. If it exists and has entries, extract its invariant (INV-*), rejected-pattern (REJ-*), and taste entries (TST-*) and include them in the snapshot so architectural constraints are visible before proposing changes.

### Eval-pipeline recency survey *(bash — software domain only)*

For software-domain sessions, check whether the eval-run pipeline is current. This guard catches silent regressions that accumulate when the pipeline goes unrun during high-velocity sprints.

Run:
```
tail -1 ~/.afk/agent-framework/improve/eval-runs/.index.jsonl 2>/dev/null
```

Parse the `timestamp` field from the output. Then compute the age in days relative to today's date.

**Threshold**: Read `AFK_EVAL_STALENESS_DAYS` from the environment (default: 7). If the env var is `0`, skip this check silently.

**Surface as a warning finding when any of these are true:**
- The index file does not exist → `⚠ Eval-pipeline has NEVER run. Run \`afk improve eval-run\` to establish a baseline.`
- The file exists but the timestamp is absent or unparseable → `⚠ Eval-pipeline recency guard: index unreadable.`
- Age in days ≥ threshold → `⚠ Eval-pipeline is STALE: last eval-run was N days ago (exceeds AFK_EVAL_STALENESS_DAYS=N threshold). Run \`afk improve eval-run\`.`

Skip this check silently when:
- Domain is not `software`, OR
- Working directory has no `package.json` / `pyproject.toml` / `Cargo.toml` / `go.mod` at root level (heuristic that this is not a software project), OR
- `AFK_EVAL_STALENESS_DAYS=0`.

Include the result (fresh or warning) in the Implementation risks line of the snapshot.

## Synthesis

Assemble the survey results into a **6-line ground-truth snapshot**:
Assemble the survey results into a ground-truth snapshot (6 lines minimum, 7 when SPINE.md has entries):
- Branch: `<current>`, `<clean|diverged>`, upstream: `<fresh|stale>`
- Recent work: last 3 commits or stash items
- Infrastructure: CI present? package scripts? authoritative configs for this task
- Memory hits: facts (1-line each) + which stores were consulted, or `none (consulted: …)`
- Implementation risks: e.g. "branch is `main`, don't edit directly"; "CI runs on push"; "memory says prior attempt used approach X"
- Spine constraints *(only when SPINE.md exists with entries)*: INV-*, REJ-*, TST-* entries. Omit this line entirely when SPINE.md is absent or empty.
- Implementation risks: e.g. "branch is `main`, don't edit directly"; "CI runs on push"; "memory says prior attempt used approach X"; include any eval-pipeline staleness warning here.
- Epistemic confidence: `<high|medium|low>` — based on how much state could be verified. Flag if working directory is sparse, if domain is unfamiliar, or if key artifacts may be missing.

Surface the snapshot and stop. The orchestrator then uses these verified facts — not assumptions — to decide the next step. This skill never edits files.

## Brief Anchor (auto-runs after synthesis)

After the 6-line snapshot is assembled, construct the **Brief Anchor** — a path-verified grounding preamble the orchestrator pastes verbatim into every subsequent sub-agent brief.
After the snapshot is assembled, construct the **Brief Anchor** — a path-verified grounding preamble the orchestrator pastes verbatim into every subsequent sub-agent brief.

**Construction procedure:**

Expand Down
1 change: 1 addition & 0 deletions skills/refactor/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: refactor
description: "Orchestrates safe, large-scale structural changes across a codebase — symbol renames, API migrations, pattern standardizations, layer restructurings. Enumerates all affected sites, groups them into dependency layers via the DAG executor, applies changes in parallel per layer with worktree isolation, and verifies behavioral preservation at each layer boundary before proceeding. Exits immediately on first regression, surfacing the exact site, diff, and behavioral delta before any commit."
when-to-use: "Large-scope structural refactors across multiple files or layers."
argument-hint: "<refactor goal> [--scope <glob-or-path>]"
failure_modes:
- bad decomposition
Expand Down
4 changes: 4 additions & 0 deletions skills/research/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ context: load

Dispatch two sub-agents in parallel using the Agent tool. Prefer `subagent_type: "research-agent"`; fall back to `subagent_type: "Explore"` with thoroughness "very thorough" if the research-agent is not available. One researches the web for external context relevant to the current task. The other inspects the local working directory for domain-relevant artifacts. Return a concise merged research brief highlighting relevant findings, conflicts, risks, and implications for the task.

**TUI label convention.** Set `id_prefix` on each Agent dispatch to a short, descriptive task label so the live progress view shows the agent's job rather than a generic identifier:
- Web agent: `id_prefix: "web research"`
- Local inspection agent: `id_prefix: "local inspection"`

**Web research agent** — always the same: search for external context, prior art, patterns, APIs, and comparable approaches relevant to the task. Domain-agnostic.

**Local inspection agent** — adapt to the domain:
Expand Down
Loading
Loading