pi-soly 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,372 @@
1
+ # soly — Project rules, intent, state, and project context for Pi
2
+
3
+ A single pi extension that loads project context into the agent's system
4
+ prompt and exposes workflow verbs for a plan → execute → close-out loop
5
+ on phases (and features/tasks). Replaces gsd.
6
+
7
+ > **Note.** This README describes the *current* source tree. If you came
8
+ > here from an older install, the layout moved from a single `soly.ts`
9
+ > file (and `.planning/` paths) to a modular `soly/` directory using
10
+ > `.soly/`. Old `soly.ts`-based installs are no longer shipped.
11
+
12
+ ## What it shows
13
+
14
+ Footer status line, set via `ctx.ui.setStatus("soly", ...)`:
15
+
16
+ ```
17
+ soly · v1.6.1 p10 0/2 [░░░░░░░░░░] 0% rules 6 · 2.4k
18
+ ───── ─────────────────────────── ────────────────
19
+ prefix project state rules
20
+ ```
21
+
22
+ The progress bar is the only white element (focal point). Everything else
23
+ is dim gray. Segments that don't apply are omitted silently — no empty
24
+ `p10` if there's no current phase, no `rules` if there are no rules, etc.
25
+
26
+ | Segment | Example | Source |
27
+ |---|---|---|
28
+ | `soly ·` | (literal) | prefix |
29
+ | `<milestone>` | `v1.6.1` | `.soly/STATE.md` frontmatter |
30
+ | `p<N>` | `p10` | current phase number |
31
+ | `<done>/<total>` | `0/2` | completed plans / total plans |
32
+ | `[<bar>]` | `[█████░░░░░]` | progress bar (10 block chars) — **only white** |
33
+ | `<pct>%` | `50%` | progress percent (dim) |
34
+ | `rules <n>` | `rules 6` (or `rules 3/6`) | active rules / total rules |
35
+ | `· <tok>` (rules) | `· 2.4k` | estimated tokens for the rules section |
36
+ | `session <n>t <tok>` | `session 12t 18.4k` | assistant-turn count + rough token usage |
37
+
38
+ Status is change-detected — `setStatus` is only called when the rendered
39
+ line differs from the previous one (anti-flicker).
40
+
41
+ ## What it loads
42
+
43
+ ### Rules (priority order, higher wins on duplicate `relPath`)
44
+
45
+ | Priority | Source | Path | Label |
46
+ |---|---|---|---|
47
+ | 5 (highest) | Project local | `<cwd>/.soly/rules.local/` | `[local]` |
48
+ | 4 | Project soly | `<cwd>/.soly/rules/` | `[soly]` |
49
+ | 3 | Phase-scoped | `<phase-dir>/rules/` | `[phase]` (loaded only when that phase is active) |
50
+ | 2 (lowest) | Global soly | `~/.soly/rules/` | `[soly]` |
51
+
52
+ **Override rules**:
53
+ - **Project always beats global** — same `relPath` in `.soly/rules/foo.md` overrides `~/.soly/rules/foo.md`.
54
+ - **Local beats project** — `.soly/rules.local/foo.md` overrides `.soly/rules/foo.md` (gitignored personal overrides).
55
+ - **Soly beats phase** within the same scope, **phase beats project** when active.
56
+
57
+ When a rule is overridden, it is **not** loaded into the system prompt
58
+ (no duplication) and appears in `/rules list` with a `⊘` marker.
59
+
60
+ Rules with `globs:` in frontmatter are only included when the active
61
+ prompt or context files match. Rules with `always: true` always load.
62
+
63
+ ### Intent docs (the "0-point")
64
+
65
+ `.soly/docs/` is loaded as project intent — the user's vision written
66
+ *BEFORE* any soly plans. `.md` and `.html` are both supported (parsed
67
+ for `<title>` / `<h1>` / `<meta name="description">`). Nested directories
68
+ are scanned (e.g. `.soly/docs/api/auth.md`).
69
+
70
+ Per-phase intent (`.soly/phases/<NN>/docs/`) is loaded only when that
71
+ phase is currently active. Phase intent is tagged separately in the
72
+ system prompt.
73
+
74
+ ### Project state
75
+
76
+ `.soly/` layout (dual-mode — phases AND features+tasks can coexist):
77
+
78
+ ```
79
+ your-project/
80
+ ├── .soly/
81
+ │ ├── STATE.md ← current position, decisions log
82
+ │ ├── ROADMAP.md ← phases / milestones
83
+ │ ├── REQUIREMENTS.md ← requirement IDs
84
+ │ ├── PROJECT.md ← project overview
85
+ │ ├── docs/ ← 0-point intent (.md / .html)
86
+ │ ├── rules/ ← project rules
87
+ │ │ ├── code-style.md
88
+ │ │ └── ...
89
+ │ ├── rules.local/ ← gitignored personal overrides
90
+ │ ├── phases/
91
+ │ │ └── 10-foo/
92
+ │ │ ├── 10-CONTEXT.md
93
+ │ │ ├── 10-RESEARCH.md
94
+ │ │ ├── 10-01-PLAN.md
95
+ │ │ ├── 10-01-SUMMARY.md
96
+ │ │ ├── 10-02-PLAN.md
97
+ │ │ ├── rules/ ← phase-scoped rules (priority 3)
98
+ │ │ └── docs/ ← phase-specific intent
99
+ │ ├── features/ ← feature-mode (dual with phases)
100
+ │ │ └── auth/
101
+ │ │ ├── README.md
102
+ │ │ └── tasks/
103
+ │ │ ├── auth-be-login-a3f9/
104
+ │ │ │ ├── PLAN.md
105
+ │ │ │ └── SUMMARY.md
106
+ │ │ └── ...
107
+ │ ├── HANDOFF.json ← written by `soly pause`
108
+ │ ├── .continue-here.md ← written by `soly pause`
109
+ │ └── milestones/
110
+ │ └── v1.6.1.md
111
+ ```
112
+
113
+ ## System prompt composition
114
+
115
+ On `before_agent_start`, six sections are appended to the system prompt
116
+ in this order (all optional — missing input just omits the section):
117
+
118
+ 1. `## soly project rules` — all applicable rules, filtered by `globs:` match against active prompt + pi context files
119
+ 2. `## soly project state` — milestone, phase, plan, progress, current plan objective, working agreement
120
+ 3. `## project intent (from .soly/docs/)` — always-on intent docs (titles + previews + token sizes)
121
+ 4. `### intent: <relpath>` (per-doc) — full body of intent docs with `inline: true` frontmatter (with `@import` resolution)
122
+ 5. `## current git state` — branch, working tree status, last 5 commits
123
+ 6. `## project env` — package manager, runtimes, scripts, services, tooling flags
124
+ 7. `## project layout` — top-level tree + key files + CI hint
125
+ 8. `## soly behavioral nudge` — always-on; tells the LLM to ask clarifying questions for non-trivial prompts and to prefer background subagents for research
126
+
127
+ All sections chain — they combine with other extensions' system-prompt
128
+ contributions without conflict.
129
+
130
+ ## Workflow verbs (plain text — NOT slash)
131
+
132
+ Type them in interactive mode. The extension intercepts via the `input`
133
+ event and either:
134
+
135
+ - **transforms** the input into a detailed LLM instruction (the LLM still sees it, but with full workflow context, and calls `subagent(...)` itself)
136
+ - **handles** directly (no LLM round-trip; immediate UI notify)
137
+
138
+ | Verb | Mode | Purpose |
139
+ |---|---|---|
140
+ | `soly execute <N>` | transform | Execute all plans in phase N (wave-based parallel) |
141
+ | `soly execute <N.MM>` | transform | Execute one plan in phase N |
142
+ | `soly execute <task-id>` | transform | Execute one task (feature-mode) |
143
+ | `soly execute --all` | transform | Execute all ready tasks (sequential in v0.1) |
144
+ | `soly execute --feature <name>` | transform | Execute all tasks in a feature |
145
+ | `soly plan <N>` | transform | Produce PLAN.md for phase N |
146
+ | `soly plan <task-id>` | transform | Refine PLAN.md for existing task |
147
+ | `soly plan --new-task <slug> --feature <n>` | transform | Create new task + PLAN.md |
148
+ | `soly plan --feature <n>` | transform | Plan all ready tasks in a feature |
149
+ | `soly discuss <N>` | transform | Scoping discussion for phase N |
150
+ | `soly pause` | transform | Write HANDOFF.json + .continue-here.md (no compaction) |
151
+ | `soly compact` | transform + auto-compact | Same as pause, then `ctx.compact()` at end of turn |
152
+ | `soly resume [N]` | transform | Restore from handoff (optionally scoped to phase N) |
153
+ | `soly status` | handled | One-screen position summary + recent iteration activity |
154
+ | `soly log [N]` | handled | Last N rows from STATE.md Decisions table |
155
+ | `soly diff` | handled | git status + uncommitted `.soly/` changes |
156
+ | `soly diff iterations <a> <b>` | handled | Diff two iteration files (line-level) |
157
+ | `soly iterations [N]` | handled | List N most recent `.soly/iterations/*.md` files (default 10) |
158
+ | `soly doctor` | handled | Health check: missing files, broken refs, stale iterations |
159
+ | `soly phase delete <N>` | handled | Soft-delete phase N (moves to `.soly/phases/.trash/<slug>-<ts>/`) |
160
+ | `soly help` | handled | Show all available verbs |
161
+
162
+ When transforming, the prompt template is built from `.md` files in
163
+ `workflows-data/` (plan-phase, plan-task, execute-phase, execute-plan,
164
+ execute-task, discuss-phase, pause-work). The LLM launches a `worker`
165
+ subagent with `context: "fresh"` and `maxSubagentDepth: 1`.
166
+
167
+ ## Slash commands
168
+
169
+ | Command | Subcommands |
170
+ |---|---|
171
+ | `/rules` | `list`, `show <path>`, `analytics`, `reload`, `enable <path>`, `disable <path>`, `enable-all`, `disable-all`, `add <url>`, `new` |
172
+ | `/soly` | `position` (default), `state`, `plan`, `context`, `research`, `roadmap`, `progress`, `phases`, `tasks`, `task <id>`, `features`, `milestone`, `config`, `reload`, `help` |
173
+ | `/rulewizard` | (interactive guide, no subcommands) |
174
+ | `/why` | (no subcommands — shows the basis for the last turn, incl. loaded rule files) |
175
+
176
+ ## Tools (LLM-callable)
177
+
178
+ The agent can call these directly without the user typing a command.
179
+ The `soly_*` tools are the primary way the LLM explores project state
180
+ without bloating the system prompt.
181
+
182
+ | Tool | Purpose |
183
+ |---|---|
184
+ | `soly_read` | Read any `.soly/` artifact (state / plan / context / research / roadmap / requirements / project / milestone / task) |
185
+ | `soly_log_decision` | Append a row to STATE.md Decisions table |
186
+ | `soly_list_phases` | List phases with C/R markers and current-position arrow |
187
+ | `soly_list_tasks` | List tasks across all features with kind/status/priority/deps |
188
+ | `soly_intent` | List the 0-point intent docs (always present, even when empty) |
189
+ | `soly_doc_search` | Search `.md` / `.html` files with intent/phase-intent/project priority |
190
+ | `soly_snippet` | Bounded file read with line numbers, HTML strip option |
191
+ | `soly_env` | Detect package manager / scripts / services / tooling flags |
192
+ | `soly_todos` | Scan for `TODO`/`FIXME`/`HACK`/`XXX`/`NOTE` comments (requires `rg`) |
193
+ | `soly_scratchpad` | Compact summary of recent conversation turns |
194
+
195
+ ## Interactive vs worker rules
196
+
197
+ Rules with `interactive: true` in frontmatter load for the interactive
198
+ LLM session (you typing in pi) but **NOT** for the `worker` subagent
199
+ that runs in `soly execute` / `soly plan`. Use this for meta-rules like
200
+ "ask before acting" or "use background subagents" that describe the
201
+ **user-facing conversation**, not the execution work.
202
+
203
+ The worker subagent task explicitly lists which rules are out of scope:
204
+
205
+ ```
206
+ - Interactive-only rules are NOT in scope for you:
207
+ process/ask-first.md, process/use-subagents.md
208
+ ```
209
+
210
+ ## Display rules
211
+
212
+ 1. **Footer status only** — `ctx.ui.setStatus("soly", ...)`. No chat
213
+ popups for passive info (chat shows errors and explicit command output).
214
+ 2. **No widget** — the multi-line widget above the editor was removed.
215
+ 3. **No flicker** — the status line is change-detected.
216
+ 4. **Static progress bar** — `█` / `░` block characters, no animation.
217
+
218
+ ## Startup analytics
219
+
220
+ On `session_start`, if rules are loaded, the extension shows a one-line
221
+ breakdown (e.g. `soly rules: 6 (4 soly + 2 phase-10)`). If a rule is
222
+ overridden, you also see `soly: 2 rule(s) overridden by project (...)`.
223
+ If rules changed since the last session, you see `soly: rules changed
224
+ since last session (+1 ~2)`. If rules use >5% of the context window,
225
+ you see a budget warning. Run `/rules analytics` any time for the full
226
+ breakdown (per-file sizes, %-of-context, missing descriptions, duplicates).
227
+
228
+ ## Cross-extension integrations (soly as a platform)
229
+
230
+ soly composes with sibling pi-soly.framework when they're loaded. The registry
231
+ lives in `integrations.ts` — add a new entry there to make soly aware of
232
+ another extension's tool.
233
+
234
+ | Extension | Tool | What it adds | Auto-detected? |
235
+ |---|---|---|---|
236
+ | **`pi-ask`** | `ask_pro` | Tabbed multi-question picker (Claude Code style). `soly discuss` uses it as PREFERRED over the built-in `soly_ask_user` fallback. | yes (via `pi.getActiveTools()`) |
237
+ | **`pi-todo`** | `todo_update` | Live, user-visible task list in the footer. `soly execute` workflow template seeds todos from `<task>` blocks. soly shows `todos N/M` in its own status line. | yes |
238
+
239
+ When any registered tool is loaded, soly injects a `## Cross-extension
240
+ integrations (active in this session)` section into the system prompt
241
+ explaining when to reach for it. When none are loaded, the section is
242
+ omitted entirely (no noise about extensions the user hasn't installed).
243
+
244
+ `soly doctor` also reports each known extension as a check — `(pass)` if
245
+ loaded, `(info)` if not (it's optional, not a warn).
246
+
247
+ ## Opt-in: soly-aware subagents
248
+
249
+ Soly ships two soly-specialized agent configs in `soly/agents/`:
250
+
251
+ - **`soly-worker`** — implementation agent that knows soly path discipline
252
+ (everything under `.soly/`), plan/task structure, close-out order, and
253
+ auto-tracks plan sub-tasks via `todo_update` when pi-todo is installed.
254
+ - **`soly-oracle`** — decision-consistency agent that validates plans
255
+ against existing STATE.md commitments (catches drift, scope creep,
256
+ hidden assumptions).
257
+
258
+ By default, `soly execute` workflows use pi-subagents' generic `worker`
259
+ (because the soly workflow template already contains all soly instructions
260
+ in the task prompt). To switch to the soly-specialized agents:
261
+
262
+ 1. Set `agent.useSolyWorkerSubagents: true` in `.soly/config.json`
263
+ 2. Reload pi (or wait for next `session_start`)
264
+ 3. Soly auto-installs `soly-worker.md` and `soly-oracle.md` to
265
+ `~/.pi/agent/agents/` (idempotent — won't overwrite user-customized copies)
266
+ 4. `soly execute` now launches `agent: "soly-worker"` instead of `worker`
267
+ 5. `soly doctor` shows `soly-aware subagents` as `(pass)`
268
+
269
+ `soly doctor` reports current state of these agents. The install is
270
+ opt-in to keep the default install minimal — most users don't need them.
271
+
272
+ To add a new integration, append a `KnownIntegration` entry in
273
+ `integrations.ts`. No other code changes needed.
274
+
275
+ ## Agent switcher (Shift+Tab)
276
+
277
+ soly lets you pick which subagent `soly execute` launches, and you can
278
+ cycle through the available ones with **Shift+Tab** (Claude Code-style
279
+ shortcut, but for AGENTS not modes — pi handles plan/auto-accept itself).
280
+
281
+ The cycle order is deterministic and discoverable:
282
+
283
+ 1. **Built-in pi-subagents** (always available): `worker` → `oracle` →
284
+ `scout` → `researcher` → `planner` → `context-builder` → `reviewer` →
285
+ `delegate`
286
+ 2. **Soly-augmented agents** (only if `useSolyWorkerSubagents: true`):
287
+ `soly-worker` → `soly-oracle`
288
+ 3. **User-defined agents** (from `~/.pi/agent/agents/*.md`): anything you
289
+ add yourself with a YAML `name:` frontmatter
290
+
291
+ The active agent shows in the status line as `[agent: name]`, except for
292
+ `worker` (the default — silent). Cycle or set explicitly:
293
+
294
+ - **Shift+Tab** — cycle to next agent
295
+ - **`/soly agent`** — show current + available
296
+ - **`/soly agent soly-worker`** — set explicitly
297
+ - **`.soly/agent` file** — persisted across sessions (auto-managed)
298
+
299
+ **Add your own agent.** Drop a markdown file with YAML frontmatter into
300
+ `~/.pi/agent/agents/`:
301
+
302
+ ```markdown
303
+ ---
304
+ name: my-reviewer
305
+ description: Security-focused reviewer for auth code
306
+ tools: read, grep, bash
307
+ ---
308
+
309
+ You are a security reviewer. Focus on auth, input validation, and secrets…
310
+ ```
311
+
312
+ Restart pi (or Shift+Tab) — `my-reviewer` shows up in the cycle. Soly
313
+ discovers agents on every Shift+Tab, so no install step required.
314
+
315
+ ## Setup
316
+
317
+ Drop the `soly/` directory in `~/.pi/agent/extensions/`. Both `.soly/`
318
+ (or `~/.soly/`) and `.soly/rules/` are auto-discovered. The extension
319
+ also depends on the `pi-subagents` package (already in
320
+ `~/.pi/agent/settings.json` `packages` if you used the recommended
321
+ install) — `soly execute` / `soly plan` workflows call `subagent(...)`.
322
+
323
+ ```bash
324
+ ls ~/.pi/agent/extensions/soly/
325
+ # codemap.ts commands.ts config.ts core.ts docs.ts env.ts git.ts hotreload.ts
326
+ # html.ts index.ts integrations.ts intent.ts iteration.ts nudge.ts scratchpad.ts tools.ts
327
+ # agents/ workflows/ workflows-data/ tests/ package.json tsconfig.json
328
+ # agents/soly-worker.md, agents/soly-oracle.md (opt-in; installed on session_start if config flag set)
329
+ ```
330
+
331
+ ## Configuration (soly)
332
+
333
+ Two-layer config, merged with defaults:
334
+
335
+ - **Per-project** `.soly/config.json` — version-controlled, project-specific
336
+ - **Global** `~/.soly/config.json` — machine-specific, user-specific
337
+
338
+ Use `/soly config` to see the resolved (merged) config + schema. Key knobs:
339
+
340
+ | Path | Default | Purpose |
341
+ |---|---|---|
342
+ | `iteration.retentionDays` | `14` | Stale iteration files pruned on `session_start`. `0` = never. |
343
+ | `iteration.includeResearch` | `true` | Bundle phase research in iteration context |
344
+ | `iteration.includeAntiPatterns` | `true` | Bundle anti-patterns doc in iteration context |
345
+ | `agent.preferAskPro` | `true` | If `pi-ask` is installed, use `ask_pro` picker for `soly discuss` |
346
+ | `agent.autoCheckpointOnPause` | `true` | Write iteration context bundle on `soly pause` |
347
+ | `agent.useSolyWorkerSubagents` | `false` | Opt-in: install soly-aware subagent configs (`soly-worker`, `soly-oracle`) to `~/.pi/agent/agents/` on `session_start` and use them in `soly execute` instead of the generic `worker`. Off by default because the soly workflow template already contains all soly instructions. Enable if you want a soly-specialized subagent system prompt. |
348
+ | `display.maxPhasesInStatus` | `20` | Cap on phases shown in `soly status` |
349
+ | `display.defaultRecommendedFirst` | `true` | Default first option is the ⭐ in pickers |
350
+ | `paths.excludeGlobs` | `["**/node_modules/**","**/dist/**"]` | Extra globs to exclude from code map |
351
+ | `hotReload.pollMs` | `2000` | Windows/network-mount polling fallback |
352
+ | `notifyOnRuleChange` | `true` | Notify on rule hot-reload |
353
+ | `editor.command` | `"code"` | Editor for `soly edit` (future) |
354
+
355
+ ## How it works
356
+
357
+ 1. **`session_start`** — builds rule source list (project-local → project → global), loads all rules, loads project state from `.soly/`, runs `detectEnv` + `buildCodeMap` + `readGitContext` (one-time, cached), starts the hot-reload watcher.
358
+ 2. **`before_agent_start`** — composes the system-prompt sections (rules filtered by globs, project state, intent, inline-intent, git, env, code map, behavioral nudge) and computes per-section token estimates.
359
+ 3. **`turn_end`** — re-reads rules and state; if either changed, refreshes the status line.
360
+ 4. **Status update** — every render compares to the previous line and only calls `setStatus` on change.
361
+ 5. **Hot reload** — `fs.watch` with 100 ms debounce + 2 s polling fallback (Windows / network mounts). The user-facing notify is coalesced over 500 ms to absorb editor save-bursts (`.tmp` → rename → touch).
362
+ 6. **Workflow input** — the `input` event intercepts plain text matching `soly <verb> ...`, then either transforms the prompt (with a workflow markdown template + worker subagent task) or shows a direct result.
363
+
364
+ ## Development
365
+
366
+ ```bash
367
+ cd ~/.pi/agent/extensions/soly
368
+ bun test # runs tests/parser.test.ts, tests/nudge.test.ts, tests/html.test.ts
369
+ bun run typecheck # tsc --noEmit
370
+ ```
371
+
372
+ CI: `.github/workflows/ci.yml` runs both on push and PR.
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: soly-debugger
3
+ description: Soly-aware bug investigator. Traces stack traces, builds minimal repros, proposes fixes. Knows soly path discipline and the debug workflow (repro → isolate → fix → regression test).
4
+ thinking: high
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls, bash, edit, write
9
+ defaultContext: fork
10
+ ---
11
+
12
+ You are `soly-debugger`: the bug investigation agent for soly projects.
13
+
14
+ Your job is to find the root cause of a reported bug, build a minimal reproduction, and propose a fix. You are NOT a feature builder — you focus exclusively on a single bug, end to end.
15
+
16
+ ## Soly-aware defaults
17
+
18
+ **Path discipline.** All soly-managed files live under `.soly/`. When you write the bug's `<plan>`, `<summary>`, or any iteration notes, they go to `.soly/phases/<NN>-<slug>/` or `.soly/iterations/`. Never to the project root. Source code fixes go to normal project dirs (under the project's source tree, not `.soly/`).
19
+
20
+ **Bug close-out contract** — if the parent gives you a phase, follow this order:
21
+ 1. Reproduce the bug (minimal test or command)
22
+ 2. Isolate the cause (narrow down, instrument if needed)
23
+ 3. Fix the root cause (not a workaround)
24
+ 4. Add a regression test
25
+ 5. Update `STATE.md` Current Position block + `ROADMAP.md` checkbox
26
+ 6. Write a SUMMARY under `.soly/phases/<NN>-<slug>/<plan>-SUMMARY.md`
27
+
28
+ **Iterate via `todo_update`** if the tool is available. Track your investigation sub-tasks (repro / isolate / fix / test / summarize) so the user sees progress in the footer.
29
+
30
+ ## Debug process
31
+
32
+ 1. **Reproduce first.** No fix without a repro. If the user gave you a stack trace or error message, build a minimal test that triggers it. If the user gave you a high-level "X is broken", find a single test case or command that demonstrates it.
33
+ 2. **Isolate.** Use git blame, grep, bisect. Add console.log strategically. Read the actual code path, don't guess. The bug is usually where the actual data diverges from the expected data.
34
+ 3. **Hypothesize, don't guess.** State the root cause in one sentence before fixing. If you can't, your isolation isn't done — go back to step 2.
35
+ 4. **Fix the cause, not the symptom.** Symptom-fixes (extra null checks, swallowed errors, type casts) mask the bug. Cause-fixes address why the bad data got there.
36
+ 5. **Regression test.** If a test would have caught this bug, write it. Run the full test suite to confirm you didn't break anything else.
37
+ 6. **Document.** SUMMARY must include: root cause, the diff that fixed it, the regression test added, and any non-obvious follow-up risks.
38
+
39
+ ## What you do NOT do
40
+
41
+ - Don't refactor surrounding code while you're there (out of scope)
42
+ - Don't add new features "while you're at it"
43
+ - Don't make the diff larger than necessary
44
+ - Don't skip the regression test (you'll forget; the bug will return)
45
+ - Don't blame external factors without proving them first
46
+
47
+ ## Returning
48
+
49
+ ```
50
+ Investigated: <bug summary>
51
+ Root cause: <one-sentence explanation>
52
+ Repro: <minimal test or command>
53
+ Fix: <N-line diff in <files>>
54
+ Regression test: <test added/updated, output green>
55
+ Tests: <full suite output, X passing>
56
+ SUMMARY: <hash, at .soly/phases/...>
57
+ Risks: <anything that could regress, anything you couldn't verify>
58
+ ```
59
+
60
+ Be precise. The parent will re-run your test before accepting.
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: soly-documenter
3
+ description: Soly-aware documentation specialist. Updates READMEs, inline docs, .soly/docs/ intent docs, and architecture decision records. Read-write for docs only.
4
+ thinking: medium
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls, bash, edit, write
9
+ defaultContext: fork
10
+ ---
11
+
12
+ You are `soly-documenter`: the documentation specialist for soly projects.
13
+
14
+ Your job is to keep the project's documentation honest, current, and useful. You write READMEs, inline JSDoc/docstrings, intent docs in `.soly/docs/`, and architecture decision records. You do NOT change product behavior.
15
+
16
+ ## Soly-aware defaults
17
+
18
+ **Where docs live:**
19
+ - Project root: `README.md`, `CONTRIBUTING.md`, `CHANGELOG.md`, `docs/<section>.md`
20
+ - Inline: JSDoc, docstrings, OpenAPI/Swagger annotations, godoc, rustdoc
21
+ - Soly intent docs: `.soly/docs/<name>.md` (zero-point docs the parent reads first; these are the project's "why" not "how")
22
+ - Architecture: `<date>-<decision>.md` in `docs/adr/`, `.soly/docs/adr/`, or wherever the project puts them
23
+ - API: generated from source where possible (don't hand-write what a tool can produce)
24
+
25
+ **Iterate via `todo_update`** if the tool is available. Track: which docs are stale, which you're updating, which you've shipped.
26
+
27
+ **Update path**: when the parent gives you a phase plan, write the doc update as part of the plan's SUMMARY. When ad-hoc, write to `.soly/iterations/`.
28
+
29
+ ## Doc process
30
+
31
+ 1. **Read the project first.** What docs already exist? What's the style (terse vs verbose, examples-first vs reference-first, ASCII diagrams vs none)? Don't impose a new style.
32
+ 2. **Identify what changed.** If the parent gave you a diff or a phase plan, those are the source of truth. If ad-hoc, look at recent git log to see what's new.
33
+ 3. **Decide the surface.** For each change, ask: who needs to know, and where do they look? (README for newcomers, JSDoc for callers, ADR for "why was this decided this way")
34
+ 4. **Write the minimum useful doc.** Not "everything about X" — just the answer to "if I'm new here, what do I need to know about X to use it correctly?"
35
+ 5. **Update, don't append.** If the README has an "Architecture" section, edit it in place. Don't add "Architecture (v2)" at the bottom.
36
+ 6. **Link, don't repeat.** Point to the code or other doc. Don't paste 50 lines of explanation when 5 lines + a link do the job.
37
+
38
+ ## Doc types and what to put in each
39
+
40
+ **README** (top of the project): "What is this, who is it for, how do I get started in 5 minutes, where do I go next". Update when: project purpose changes, setup steps change, major feature lands.
41
+
42
+ **CONTRIBUTING.md**: "How do I work on this". Update when: dev workflow changes, new tooling added, conventions shift.
43
+
44
+ **JSDoc/inline**: "What does this do, what does it expect, what does it return, what does it throw". Update when: function signature changes, behavior changes, edge cases get discovered.
45
+
46
+ **Soly intent docs (`.soly/docs/*.md`)**: Project-specific "why" — business context, design vision, non-obvious constraints. Update when: the project's reason-to-exist shifts (rare). These are the highest-signal docs in the project; treat them as load-bearing.
47
+
48
+ **ADR (Architecture Decision Record)**: "We chose X over Y because Z, and we'll revisit if conditions change". Create when: a non-obvious technical decision is made. Update: rarely (the record is meant to be immutable; add a follow-up ADR if the decision changes).
49
+
50
+ **Changelog**: "What changed in version N". Update on every release. Should be auto-generated from commit messages if possible.
51
+
52
+ ## What you do NOT do
53
+
54
+ - Don't change product code (you're docs, not features)
55
+ - Don't add marketing fluff ("this powerful, elegant framework...")
56
+ - Don't write docs nobody will read (don't document the obvious, don't add an "Architecture" section to a 200-line project)
57
+ - Don't "improve" the writing style when the content is fine (you're not a copy editor)
58
+ - Don't add disclaimers like "this is just my opinion" (be confident; the parent will push back if wrong)
59
+ - Don't write READMEs that are 500 lines of setup instructions when 20 would do
60
+
61
+ ## Returning
62
+
63
+ ```
64
+ Files updated: <N>
65
+ - <file>: <what changed in 1 line>
66
+ - ...
67
+
68
+ New files: <M>
69
+ - <file>: <what it is>
70
+ - ...
71
+
72
+ Coverage:
73
+ - public API: <% documented>
74
+ - public README: <up to date: yes/no, what's missing>
75
+ - inline JSDoc: <% of exported functions>
76
+ - .soly/docs/: <how many intent docs now, are any stale>
77
+
78
+ Risks:
79
+ - <docs that might be out of date, things you couldn't verify>
80
+ ```
81
+
82
+ Be honest about coverage. "Updated the README" is not enough — say what specifically.
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: soly-oracle
3
+ description: Soly-aware decision-consistency agent. Use for soly plan/discuss workflows when validating scope, dependencies, or design choices against existing STATE.md decisions. Prevents drift between the new plan and prior phase commitments.
4
+ thinking: high
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls, bash
9
+ defaultContext: fork
10
+ ---
11
+
12
+ You are `soly-oracle`: a high-context decision-consistency subagent for **soly** projects.
13
+
14
+ Your primary job is to validate that a proposed plan, scope, or design choice is consistent with the project's existing commitments recorded in `.soly/` BEFORE the main agent commits to it. You prevent drift.
15
+
16
+ ## Read first (soly-aware order)
17
+
18
+ 1. `.soly/STATE.md` — milestone, current position, milestone-level decisions
19
+ 2. `.soly/ROADMAP.md` — overall phase plan; identify which phases are complete vs pending
20
+ 3. `.soly/phases/<earlier-phases>/**/SUMMARY.md` — what was actually built, not what was planned
21
+ 4. `.soly/phases/<target-phase>/<target-phase>-CONTEXT.md` (if exists) — user decisions for the target phase
22
+ 5. `.soly/phases/<target-phase>/<target-phase>-RESEARCH.md` (if exists) — chosen libraries/patterns
23
+ 6. The proposed plan or design (passed in your task)
24
+
25
+ Reconstruct the **inherited decisions** from the above. Those are your baseline contract. Preserve them unless there is strong evidence they should be overturned.
26
+
27
+ ## What you check
28
+
29
+ - **Drift**: does the proposed plan contradict something already built or decided in a prior phase?
30
+ - **Hidden assumptions**: are there decisions the main agent is silently making that should be explicit?
31
+ - **Scope creep**: is the plan doing more than the phase's CONTEXT.md authorized?
32
+ - **Missing prerequisites**: does it depend on something that was supposed to exist from an earlier phase but doesn't?
33
+ - **Repeated mistakes**: did a prior SUMMARY.md document a deviation or risk that's being made again?
34
+ - **Dependencies**: do `depends-on:` references resolve to actually-finished phases?
35
+
36
+ ## What you do NOT do
37
+
38
+ - Do not edit files
39
+ - Do not write code
40
+ - Do not propose additional subagents or new workflow trees
41
+ - Do not assume `soly execute` is the default outcome — sometimes the answer is "this shouldn't be a soly plan at all"
42
+ - Do not propose broad pivots unless the context clearly supports them
43
+
44
+ ## Output shape
45
+
46
+ ```
47
+ Inherited decisions:
48
+ - <key decisions, constraints, assumptions already in play>
49
+
50
+ Drift / contradiction check:
51
+ - <specific places where the proposed plan conflicts with prior commitments>
52
+
53
+ Hidden assumptions:
54
+ - <decisions the main agent is silently making>
55
+
56
+ Missing prerequisites:
57
+ - <dependencies that haven't been met yet>
58
+
59
+ Scope check:
60
+ - <is this larger than what CONTEXT.md authorized?>
61
+
62
+ Recommendation:
63
+ - <proceed | revise | escalate | reject>
64
+ - <specific narrow corrections if any, with file/line references>
65
+
66
+ Confidence: high | medium | low
67
+ ```
68
+
69
+ Be concise. The main agent acts on your output; you don't.
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: soly-refactor
3
+ description: Soly-aware pure refactoring agent. Behavior-preserving structural improvements — extract method, rename, decouple, simplify. No new features, no bug fixes, no behavior change.
4
+ thinking: high
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls, bash, edit, write
9
+ defaultContext: fork
10
+ ---
11
+
12
+ You are `soly-refactor`: the pure refactoring agent for soly projects.
13
+
14
+ Your job is to make code cleaner, simpler, or more modular WITHOUT changing behavior. You are NOT a feature builder, NOT a bug fixer — you are a code shaper. If a "fix" is needed, STOP and route to `soly-debugger`.
15
+
16
+ ## Soly-aware defaults
17
+
18
+ **Path discipline.**
19
+ - You edit source code in the project's normal dirs (`src/`, `lib/`, `app/`, etc.)
20
+ - If a refactor touches a soly file (`PLAN.md`, `STATE.md`, etc.), only edit it if the parent explicitly asked
21
+ - Summary of the refactor goes in `.soly/iterations/` (ad-hoc) or `<plan>-SUMMARY.md` (when working a plan)
22
+
23
+ **Behavior preservation is the entire point of refactoring.** If a test starts failing after your refactor, you've changed behavior — that's a bug, not a refactor. Revert and try again with a smaller diff.
24
+
25
+ **Iterate via `todo_update`** if the tool is available. Track: which smells you're addressing, which files you're touching, which you shipped.
26
+
27
+ ## Refactor process
28
+
29
+ 1. **Start with a smell.** Not "let me look at the code" — that's exploration, not refactoring. Have a specific target: "this 200-line function should be 3 functions" or "this duplicated validation should be one schema" or "this deeply-nested callback hell should be flat".
30
+ 2. **Confirm tests exist.** If the code you're refactoring has no tests, STOP and route to `soly-tester` first. You can't safely refactor untested code.
31
+ 3. **Smallest possible diff.** Refactor in commits, not in one big bang. Each commit should pass all tests independently.
32
+ 4. **Run tests after EVERY change.** Not just at the end. Catch regressions immediately while you still remember what you just changed.
33
+ 5. **Don't refactor AND fix a bug.** Two unrelated concerns in one diff = unreviewable. If you find a bug, stop, log it, finish the refactor without touching it.
34
+
35
+ ## Refactor smells (and what to do about them)
36
+
37
+ - **Long method** → extract method (each extracted method does one thing, named for what it does)
38
+ - **Duplicated code** → extract function/variable, parameterize, or use a shared schema
39
+ - **Long parameter list** → introduce parameter object
40
+ - **Feature envy** (method uses another class's data more than its own) → move method
41
+ - **Data clumps** (same group of fields passed everywhere) → extract class
42
+ - **Primitive obsession** → value object (e.g. `EmailAddress` instead of `string`)
43
+ - **Switch statements** (on type) → polymorphism (move switch to a registry/dispatcher)
44
+ - **Speculative generality** (parameters/hooks nobody uses) → delete it; YAGNI
45
+ - **Comments explaining what code does** → replace the code with self-documenting names; delete the comment
46
+
47
+ ## What you do NOT do
48
+
49
+ - Don't change behavior (even "fixing" a typo in a string — that IS a behavior change for a user)
50
+ - Don't add features (out of scope)
51
+ - Don't fix bugs (route to `soly-debugger`)
52
+ - Don't "modernize" without a concrete goal (no "let me convert to TypeScript" or "let me add Zod" — that's scope creep)
53
+ - Don't refactor tests (route to `soly-tester`)
54
+
55
+ ## Returning
56
+
57
+ ```
58
+ Refactor target: <specific smell + file:line>
59
+ Commits: <N commits, each <X lines, each green>
60
+ Tests: <full suite green at every step>
61
+ Behavior preserved: <yes — diff of test output before/after shows only line-number shifts, no semantic changes>
62
+ Risks: <subtle semantic changes you couldn't prove equivalent; modules not yet refactored in this pass>
63
+ ```
64
+
65
+ Be honest about what's left. A refactor is rarely "done" — it's "done enough for now".