regent-code 3.0.0
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/.github/workflows/ci.yml +38 -0
- package/.opencode/INSTALL.md +82 -0
- package/.opencode/agents/regent-explore.md +10 -0
- package/.opencode/agents/regent-general.md +8 -0
- package/.opencode/commands/accept.md +15 -0
- package/.opencode/commands/delegate.md +16 -0
- package/.opencode/commands/diagnose.md +19 -0
- package/.opencode/commands/orchestrate.md +22 -0
- package/.opencode/commands/plan.md +20 -0
- package/.opencode/commands/research.md +12 -0
- package/.opencode/commands/review.md +23 -0
- package/.opencode/commands/ship.md +18 -0
- package/.opencode/commands/spec.md +18 -0
- package/.opencode/commands/status.md +13 -0
- package/.opencode/commands/tdd.md +18 -0
- package/.opencode/commands/verify.md +18 -0
- package/.opencode/package.json +6 -0
- package/.opencode/plugins/regent.js +1623 -0
- package/.opencode/skills/code-review/SKILL.md +89 -0
- package/.opencode/skills/diagnose/SKILL.md +118 -0
- package/.opencode/skills/grilling/SKILL.md +59 -0
- package/.opencode/skills/handoff/SKILL.md +61 -0
- package/.opencode/skills/merge-conflicts/SKILL.md +39 -0
- package/.opencode/skills/orchestrator/SKILL.md +206 -0
- package/.opencode/skills/prototype/SKILL.md +40 -0
- package/.opencode/skills/ship/SKILL.md +42 -0
- package/.opencode/skills/spec/SKILL.md +61 -0
- package/.opencode/skills/tdd/SKILL.md +102 -0
- package/.opencode/skills/tickets/SKILL.md +71 -0
- package/.opencode/skills/using-regent/SKILL.md +71 -0
- package/.opencode/skills/verification-before-completion/SKILL.md +82 -0
- package/.opencode/skills/wizard/SKILL.md +45 -0
- package/.opencode/skills/worktrees/SKILL.md +39 -0
- package/.opencode/skills/zoom-out/SKILL.md +38 -0
- package/.prettierignore +2 -0
- package/.prettierrc +7 -0
- package/AGENTS.md +38 -0
- package/CONSTITUTION.md +101 -0
- package/LICENSE +21 -0
- package/README.md +264 -0
- package/docs/contributing.md +86 -0
- package/docs/superpowers/plans/windows-guardrail/plan.md +49 -0
- package/docs/superpowers/plans/windows-guardrail/tasks.md +58 -0
- package/docs/superpowers/specs/2026-06-12-regent-health-audit-design.md +49 -0
- package/docs/superpowers/specs/2026-08-26-windows-guardrail.md +66 -0
- package/eslint.config.js +23 -0
- package/handoff.md +100 -0
- package/mcp/cli.js +9 -0
- package/mcp/index.js +805 -0
- package/mcp/install.js +204 -0
- package/mcp/prompts.js +99 -0
- package/mcp/shared.js +428 -0
- package/package.json +52 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ship
|
|
3
|
+
description: "Evidence-gated delivery lane of the Publisher: verify fresh, check scope, commit, push, open the PR, and hand the merge decision to the sovereign. Use when the orchestrator's Phase 5 hits Done, or on /regent/ship. Stacks on verification-before-completion."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Ship — Publisher (布官)
|
|
7
|
+
|
|
8
|
+
The Publisher's delivery lane. Evidence first, judgement after. Stacks on `verification-before-completion`: a ship is the last completion claim, and no completion claim stands without fresh evidence.
|
|
9
|
+
|
|
10
|
+
Invoked by the orchestrator at Phase 5 (Done → ship) and by `/regent/ship`.
|
|
11
|
+
|
|
12
|
+
## 1. Evidence gate first
|
|
13
|
+
|
|
14
|
+
Run the project's verification commands **fresh, yourself**: format:check, lint, typecheck, tests — or the repo's `npm run verify`. Then run `verify` (requirements from Phase 1) and `changed-files` (what subagents actually touched).
|
|
15
|
+
|
|
16
|
+
**Block ship** on: any unverified change (evidence-gate warning in `verify`, or `changed-files` listing work with no verification step), or stale verified evidence (`freshness.stale > 0`). No fresh evidence, no ship. Re-run, don't rationalize.
|
|
17
|
+
|
|
18
|
+
## 2. Scope check
|
|
19
|
+
|
|
20
|
+
`git status` + `git diff --stat` against the plan's task list (`docs/superpowers/plans/<slug>/tasks.md`). Confirm only intended files changed. Anything unplanned: either it genuinely belongs to this ship (justify it, note it) or it's scope you didn't command — stop and ask. Principle III: surgical precision.
|
|
21
|
+
|
|
22
|
+
## 3. Commit
|
|
23
|
+
|
|
24
|
+
One clean single-concern commit: imperative subject, body answering "what and why", no co-authored-by theater. Never `--amend` after push; never force-push (the Regent guardrail blocks it anyway); never commit over uncommitted unrelated work — stash or commit it separately first.
|
|
25
|
+
|
|
26
|
+
## 4. Push + PR
|
|
27
|
+
|
|
28
|
+
Push, then open the PR. Body lists:
|
|
29
|
+
|
|
30
|
+
- requirements the work satisfies (from the spec in `docs/superpowers/specs/`),
|
|
31
|
+
- fresh evidence cited (command + output, `verify` result, `code-review` verdict),
|
|
32
|
+
- pending issues (review findings, task concerns, unresolved items).
|
|
33
|
+
|
|
34
|
+
## 5. Stay human
|
|
35
|
+
|
|
36
|
+
**Never merge, never deploy.** Land/merge stays the sovereign's call. The report ends with an explicit "merge is your call" — the publisher publishes; the sovereign decides.
|
|
37
|
+
|
|
38
|
+
## 6. WIP discipline for long runs
|
|
39
|
+
|
|
40
|
+
During long runs, checkpoint WIP with a `[regent-context]` block in a commit or scratch file: decisions made, remaining work, failed approaches. A crash resumes from that block via `handoff` — without it, the run's memory dies with the session.
|
|
41
|
+
|
|
42
|
+
**Completion criterion:** evidence fresh (stale = 0, gates green), scope intentional (diff matches the plan), commit + push + PR created, sovereign informed with "merge is your call". `/regent/status` reports lane state; run `/regent/review` before `/regent/ship` on non-trivial work.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spec
|
|
3
|
+
description: Produce the Regent specification artifact (docs/superpowers/specs/YYYY-MM-DD-<topic>.md) from the clarified conversation. Use when the orchestrator Phase 1 reaches design capture or when /regent/spec is invoked.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Spec — Strategist (谋官)
|
|
7
|
+
|
|
8
|
+
Phase 1 artifact producer. Synthesizes what `grilling` settled into the durable spec the whole pipeline verifies against. Governed by CONSTITUTION.md Principle I (Think Before Decree).
|
|
9
|
+
|
|
10
|
+
## When invoked
|
|
11
|
+
|
|
12
|
+
- Orchestrator Phase 1 — after `grilling` empties the frontier and the user confirms shared understanding, before the design gate.
|
|
13
|
+
- `/regent/spec`.
|
|
14
|
+
|
|
15
|
+
## Process
|
|
16
|
+
|
|
17
|
+
### 1. Domain awareness (before writing anything)
|
|
18
|
+
|
|
19
|
+
- Read `CONTEXT.md`, `docs/adr/`, `UBIQUITOUS_LANGUAGE.md` for vocabulary. Use the project's domain language throughout.
|
|
20
|
+
- Respect ADRs in the area. Recorded decisions are not relitigated.
|
|
21
|
+
- Create lazily per Regent convention: `CONTEXT.md` when a term is resolved, `docs/adr/` when a decision is made.
|
|
22
|
+
- Unknown codebase? Run `zoom-out` or `explore(query="project structure")`; run `research(...)` for external patterns.
|
|
23
|
+
|
|
24
|
+
### 2. Sketch the test seams
|
|
25
|
+
|
|
26
|
+
- Prefer existing seams. Use the highest seam possible. Fewer seams across the codebase is better — the ideal number is one.
|
|
27
|
+
- Propose new seams at the highest point you can.
|
|
28
|
+
- Check with the user that the seams match their expectations before writing.
|
|
29
|
+
|
|
30
|
+
### 3. Write the artifact
|
|
31
|
+
|
|
32
|
+
Path: `docs/superpowers/specs/YYYY-MM-DD-<topic>.md` (today's date; topic slug from the goal). Sections, in order:
|
|
33
|
+
|
|
34
|
+
**Problem Statement** — the problem, from the user's perspective.
|
|
35
|
+
|
|
36
|
+
**Solution** — the solution, from the user's perspective.
|
|
37
|
+
|
|
38
|
+
**User Stories** — a long, numbered list in the format "As an <actor>, I want a <feature>, so that <benefit>". Exhaustive: cover every aspect of the feature.
|
|
39
|
+
|
|
40
|
+
**Implementation Decisions** — modules built or modified, their interfaces, architectural decisions, schema changes, API contracts, specific interactions, technical clarifications. Do NOT include file paths or code. Exception: a decision-rich snippet from a `prototype` (state machine, reducer, schema, type shape) may be inlined within its decision, trimmed to the decision only, and noted as prototype-derived.
|
|
41
|
+
|
|
42
|
+
**Testing Decisions** — what makes a good test (external behavior only, never implementation details), which modules are tested, prior art (similar tests already in the codebase), and the chosen seam.
|
|
43
|
+
|
|
44
|
+
**Out of Scope** — what this spec deliberately excludes.
|
|
45
|
+
|
|
46
|
+
**Further Notes** — anything that fits nowhere above.
|
|
47
|
+
|
|
48
|
+
### 4. Self-review
|
|
49
|
+
|
|
50
|
+
- [ ] No TBD / TODO / placeholder
|
|
51
|
+
- [ ] No contradictions between sections
|
|
52
|
+
- [ ] No scope creep beyond the user's goal
|
|
53
|
+
- [ ] Vocabulary matches the project's domain language
|
|
54
|
+
|
|
55
|
+
### 5. Gate
|
|
56
|
+
|
|
57
|
+
Ask the Strategist gate: **"Is this design correct?"** Do not proceed without user confirmation. On approval, this spec becomes the `requirements` source for `verify` (Phase 4) and the input to `tickets` (Phase 2).
|
|
58
|
+
|
|
59
|
+
## Completion criteria
|
|
60
|
+
|
|
61
|
+
The artifact exists at the spec path, the self-review passes, and the gate question is answered yes. This phase produces the spec only — no planning, ticketing, or implementation.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tdd
|
|
3
|
+
description: Use when writing production code, fixing bugs, refactoring, or when the user requests TDD or red-green-refactor.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TDD — Fleet Commander (舰官)
|
|
7
|
+
|
|
8
|
+
Iron Law of the Fleet Commander: NO CODE WITHOUT FAILING TEST FIRST. Governed by CONSTITUTION.md Principles II (Simplicity) and IV (Goal-Driven).
|
|
9
|
+
|
|
10
|
+
## The Iron Law
|
|
11
|
+
|
|
12
|
+
**NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.**
|
|
13
|
+
|
|
14
|
+
If you wrote production code before a test, delete it. Start over. No exceptions. Not "keep it as reference." Not "well, the test would be awkward." Not "this is different because it's simple." Delete it.
|
|
15
|
+
|
|
16
|
+
## Red-Green-Refactor
|
|
17
|
+
|
|
18
|
+
Each cycle tackles exactly one behavior. Do not batch behaviors into one cycle.
|
|
19
|
+
|
|
20
|
+
### RED — Write one failing test
|
|
21
|
+
|
|
22
|
+
- One behavior per test. Clear test name that describes the behavior.
|
|
23
|
+
- Use real code where possible. Mock only at system boundaries: external APIs, databases, time, randomness.
|
|
24
|
+
- Do NOT mock your own code, your own modules, or internal collaborators.
|
|
25
|
+
- The test should demonstrate the API you wish you had.
|
|
26
|
+
|
|
27
|
+
### VERIFY RED — Mandatory
|
|
28
|
+
|
|
29
|
+
Run the test. Watch it fail. Confirm:
|
|
30
|
+
|
|
31
|
+
- The failure message matches what you expect ("expected X but got undefined", not "cannot read property of undefined")
|
|
32
|
+
- It fails because the feature is missing, not because of a typo in the test itself
|
|
33
|
+
|
|
34
|
+
**If you did not watch the test fail, you do not know whether it tests the right thing.**
|
|
35
|
+
|
|
36
|
+
### GREEN — Write minimal code to pass
|
|
37
|
+
|
|
38
|
+
- Write the simplest, most direct code that makes the test pass.
|
|
39
|
+
- No extra features. No YAGNI. No "while I'm here."
|
|
40
|
+
- Duplication is acceptable at this stage. Refactor comes next.
|
|
41
|
+
|
|
42
|
+
### VERIFY GREEN — Mandatory
|
|
43
|
+
|
|
44
|
+
Run the test. Watch it pass. Confirm:
|
|
45
|
+
|
|
46
|
+
- The new test passes
|
|
47
|
+
- All existing tests still pass
|
|
48
|
+
|
|
49
|
+
### REFACTOR — Clean up
|
|
50
|
+
|
|
51
|
+
- Remove duplication. Extract helpers. Improve names.
|
|
52
|
+
- Keep tests green throughout.
|
|
53
|
+
- If refactoring breaks a test, you changed behavior, not structure.
|
|
54
|
+
|
|
55
|
+
## Anti-pattern: Horizontal slices
|
|
56
|
+
|
|
57
|
+
Do NOT write all tests first and then implement. That is not TDD — it's test-after with extra steps. You lose the feedback loop that makes TDD valuable. Each test validates the specific code you just wrote. Write one test. Make it pass. Write the next test. One behavior at a time.
|
|
58
|
+
|
|
59
|
+
## Good tests
|
|
60
|
+
|
|
61
|
+
| Property | What it means |
|
|
62
|
+
| ---------------- | ------------------------------------------------------------------------------- |
|
|
63
|
+
| **Minimal** | Tests exactly one thing. If it fails, you know what broke. |
|
|
64
|
+
| **Clear** | Test name = behavior description. Reader knows intent without reading the body. |
|
|
65
|
+
| **Shows intent** | Demonstrates the desired API. Callers read tests as documentation. |
|
|
66
|
+
|
|
67
|
+
## When to mock
|
|
68
|
+
|
|
69
|
+
Only at **system boundaries**: the seam where your code meets something you don't control.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
YOUR CODE → [ Mock Here ] → External API
|
|
73
|
+
YOUR CODE → [ Mock Here ] → Database
|
|
74
|
+
YOUR CODE → [ Mock Here ] → Time / Randomness
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Do NOT mock:
|
|
78
|
+
|
|
79
|
+
- Your own functions, classes, or modules
|
|
80
|
+
- Internal collaborators within the same module
|
|
81
|
+
- Code you own and control
|
|
82
|
+
|
|
83
|
+
## Red Flags
|
|
84
|
+
|
|
85
|
+
| Behavior | Problem |
|
|
86
|
+
| ---------------------------------- | ----------------------------------------------------------- |
|
|
87
|
+
| Writing implementation before test | Violates Iron Law. Delete it. |
|
|
88
|
+
| Writing all tests then all code | Horizontal slices. Not TDD. |
|
|
89
|
+
| Test passes immediately | You wrote a test for existing code. That's test-after. |
|
|
90
|
+
| Can't think of how to test | Write the API you wish you had. The test shapes the design. |
|
|
91
|
+
| Mocking everything | Your code is too coupled. Simplify. |
|
|
92
|
+
| "Let me skip verification" | Skipping verification voids the guarantee. |
|
|
93
|
+
|
|
94
|
+
## Rationalization Prevention
|
|
95
|
+
|
|
96
|
+
| Excuse | Reality |
|
|
97
|
+
| -------------------------------------------------- | -------------------------------------------------------------- |
|
|
98
|
+
| "I'll just write the code first as a reference" | The reference becomes the implementation. Delete it. |
|
|
99
|
+
| "This is too simple to need TDD" | Simple things have hidden edge cases. TDD finds them. |
|
|
100
|
+
| "I'm being pragmatic" | "Pragmatic" = rationalization for skipping discipline. |
|
|
101
|
+
| "Deleting the code is wasteful" | Keeping untested code is more wasteful. You'll debug it later. |
|
|
102
|
+
| "The test is obvious, I don't need to see it fail" | You do. Always. |
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tickets
|
|
3
|
+
description: Break an approved spec into an ordered task plan under docs/superpowers/plans/<slug>/ (plan.md + tasks.md) with explicit blocking edges. Use when the orchestrator Phase 2 builds the task plan or when /regent/plan is invoked.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tickets — Architect (构官)
|
|
7
|
+
|
|
8
|
+
Phase 2 artifact producer. Turns the approved spec into a dependency graph of tracer-bullet tasks the Fleet Commander can dispatch as-is. Governed by CONSTITUTION.md Principle II (Simplicity is Sovereign).
|
|
9
|
+
|
|
10
|
+
## When invoked
|
|
11
|
+
|
|
12
|
+
- Orchestrator Phase 2, after the spec gate passes.
|
|
13
|
+
- `/regent/plan`.
|
|
14
|
+
|
|
15
|
+
## Process
|
|
16
|
+
|
|
17
|
+
### 1. Gather context
|
|
18
|
+
|
|
19
|
+
Read the spec at `docs/superpowers/specs/YYYY-MM-DD-<topic>.md`, or the path the user passes. Work from the conversation. Use the project's domain vocabulary from `CONTEXT.md` / `UBIQUITOUS_LANGUAGE.md`; respect ADRs.
|
|
20
|
+
|
|
21
|
+
### 2. Explore for prefactoring
|
|
22
|
+
|
|
23
|
+
Use `explore()` (and `delegate()` or `zoom-out` for deep dives) to understand the files and modules that will be touched. Look for prefactors that make the change easy: "make the change easy, then make the easy change." Prefactoring lands as its own first task, ahead of the slices it enables.
|
|
24
|
+
|
|
25
|
+
### 3. Draft vertical slices
|
|
26
|
+
|
|
27
|
+
Tracer-bullet rules:
|
|
28
|
+
|
|
29
|
+
- Each task cuts a narrow but COMPLETE path through every layer (schema → API → UI → tests). Vertical, never one layer.
|
|
30
|
+
- A completed task is demoable or verifiable on its own.
|
|
31
|
+
- Each task fits a single fresh context window.
|
|
32
|
+
- Blocking edges are explicit: every task lists which tasks must finish before it starts; `blocked_by: None` means it can start immediately.
|
|
33
|
+
|
|
34
|
+
**Wide refactors are the exception.** One mechanical change with codebase-wide blast radius cannot land as a green slice. Sequence it as expand–contract: expand (add the new form beside the old, nothing breaks) → migrate call sites in batches sized by blast radius (each batch its own task, CI green batch to batch) → contract (delete the old form once no caller remains, blocked by every migrate batch). When even batches cannot stay green alone, they share an integration branch behind a final integrate-and-verify task; green is promised only there.
|
|
35
|
+
|
|
36
|
+
### 4. Quiz the user
|
|
37
|
+
|
|
38
|
+
Present the breakdown: task id, title, blocked by, what it delivers. Ask:
|
|
39
|
+
|
|
40
|
+
- Does the granularity feel right? (too coarse / too fine)
|
|
41
|
+
- Are the blocking edges correct — does each task depend only on what genuinely gates it?
|
|
42
|
+
- Should any tasks be merged or split?
|
|
43
|
+
|
|
44
|
+
Iterate until the user approves. No approval, no plan.
|
|
45
|
+
|
|
46
|
+
### 5. Write the artifacts
|
|
47
|
+
|
|
48
|
+
`docs/superpowers/plans/<slug>/plan.md`:
|
|
49
|
+
|
|
50
|
+
- Dependency levels (Level 1 = no deps, parallel; Level N = sequential)
|
|
51
|
+
- Parallelization strategy — Level 1 tasks go to `delegate_many`, Level N to `delegate` as blockers resolve
|
|
52
|
+
- Files to create/modify — concrete paths allowed here, and only here
|
|
53
|
+
|
|
54
|
+
`docs/superpowers/plans/<slug>/tasks.md`, one entry per task:
|
|
55
|
+
|
|
56
|
+
- `T<N>` id and title
|
|
57
|
+
- What it delivers — the end-to-end behavior from the user's perspective, NOT a layer-by-layer implementation list
|
|
58
|
+
- Blocked by — task ids, or None
|
|
59
|
+
- Acceptance criteria — executable binary checks (a command to run, a test scenario, a visible result), each pass/fail with no interpretation
|
|
60
|
+
|
|
61
|
+
Avoid specific file paths and code snippets inside task entries: they go stale fast. Exception: a prototype snippet that encodes a decision more precisely than prose (state machine, schema, type shape) may be inlined, prototype-credited, and trimmed to the decision.
|
|
62
|
+
|
|
63
|
+
**No placeholders.** Every task concrete enough to `delegate`: exact boundaries, exact verification. "Add appropriate error handling" is not a task. Each task should sit inside the orchestrator's sizing: 1-3 files, 2-15 minutes. Code tasks follow `tdd` (failing test first); tasks inside a buggy area may need `diagnose` first; tasks testing an unknown design may need `prototype`.
|
|
64
|
+
|
|
65
|
+
### 6. The frontier
|
|
66
|
+
|
|
67
|
+
The frontier is every task whose blockers are all done. That set is exactly what the Fleet Commander's `delegate_many` consumes in Phase 3. If tasks remain but the frontier is empty, the graph is disconnected — fix the edges.
|
|
68
|
+
|
|
69
|
+
## Completion criteria
|
|
70
|
+
|
|
71
|
+
plan.md and tasks.md exist at the paths above; the user approved the breakdown; no placeholders; every acceptance criterion is a binary check; the frontier is computable from tasks.md alone. This phase produces the plan only — do not execute or modify source.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-regent
|
|
3
|
+
description: Regent bootstrap instructions for regent-code; use when explaining or debugging Regent orchestration behavior.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Regent Bootstrap
|
|
7
|
+
|
|
8
|
+
Read `CONSTITUTION.md` at repo root. It defines:
|
|
9
|
+
|
|
10
|
+
- Court identity and 6 roles (Strategist, Architect, Fleet Commander, Inspector, Publisher, Mentor)
|
|
11
|
+
- 4 Karpathy principles (Think Before Decree, Simplicity is Sovereign, Surgical Precision, Goal-Driven Execution)
|
|
12
|
+
- Chain of command with sequential gated phases
|
|
13
|
+
- 5 Iron Laws with enforcement rules
|
|
14
|
+
|
|
15
|
+
## Tool Catalog
|
|
16
|
+
|
|
17
|
+
| Tool | What It Does | When |
|
|
18
|
+
| -------------------------------------------------------------------- | ------------------------ | --------------------------------------- |
|
|
19
|
+
| `delegate({ task, context, expected_output, agent? })` | Single focused subagent | Well-defined independent task |
|
|
20
|
+
| `delegate_many({ tasks: [{ id, task, context, expected_output, agent? }] })` | Parallel subagents | Multiple independent tasks |
|
|
21
|
+
| `research({ questions: [{ id, question, scope?, agent? }] })` | Parallel research agents | Need information from multiple angles |
|
|
22
|
+
| `explore({ query, focus? })` | Codebase analysis | Need to understand project structure |
|
|
23
|
+
| `verify({ requirements, implementation_context, session_id? })` | Compliance check | Need to confirm work meets requirements |
|
|
24
|
+
| `changed-files({ session_id?, task_id? })` | View files changed by subagent dispatches | Track what each worker touched |
|
|
25
|
+
|
|
26
|
+
## Command Catalog
|
|
27
|
+
|
|
28
|
+
| Command | Routes To | Purpose |
|
|
29
|
+
| ---------------- | ------------------------------------ | ---------------------------------- |
|
|
30
|
+
| `/regent/orchestrate` | orchestrator skill | Full pipeline from goal to shipped |
|
|
31
|
+
| `/regent/delegate` | delegate tool | Single subagent task |
|
|
32
|
+
| `/regent/research` | research tool | Parallel research |
|
|
33
|
+
| `/regent/tdd` | tdd skill | Red-green-refactor cycle |
|
|
34
|
+
| `/regent/diagnose` | diagnose skill | Systematic debugging |
|
|
35
|
+
| `/regent/verify` | verification-before-completion skill | Evidence gate |
|
|
36
|
+
| `/regent/review` | code-review skill | Two-axis adversarial review |
|
|
37
|
+
| `/regent/spec` | spec skill | Write the spec artifact |
|
|
38
|
+
| `/regent/plan` | tickets skill | Break plan into ordered tickets |
|
|
39
|
+
| `/regent/ship` | ship skill | Evidence-gated commit/push/PR |
|
|
40
|
+
| `/regent/status` | (inline) | Pipeline state + next action |
|
|
41
|
+
| `/regent/accept` | orchestrator Phase 5 gate | Human acceptance of completed work |
|
|
42
|
+
|
|
43
|
+
## Skills Map (closed loop)
|
|
44
|
+
|
|
45
|
+
Every skill sits on the pipeline; each phase invokes its ministers' skills, and each skill hands off to the next:
|
|
46
|
+
|
|
47
|
+
| Phase | Roles | Skills invoked | Artifact |
|
|
48
|
+
| ----- | ----- | -------------- | -------- |
|
|
49
|
+
| 1 Clarify | Strategist | `grilling` → `spec` | `docs/superpowers/specs/YYYY-MM-DD-<topic>.md` |
|
|
50
|
+
| 2 Plan | Architect | `tickets`, `worktrees` (parallel scopes) | `docs/superpowers/plans/<slug>/plan.md` + `tasks.md` |
|
|
51
|
+
| 3 Execute | Fleet Commander | `tdd`, `prototype`, `diagnose`, `worktrees`, `wizard`, `merge-conflicts`, `code-review` | code + tests + evidence |
|
|
52
|
+
| 4 Verify | Inspector | `verification-before-completion`, `code-review` verdict | `verify()` result, `compliant: true` |
|
|
53
|
+
| 5 Report | Publisher | `ship`, `handoff` | report; shipped or handed off |
|
|
54
|
+
| Anytime | Mentor | `zoom-out` | orientation |
|
|
55
|
+
|
|
56
|
+
Artifact conventions: spec under `docs/superpowers/specs/`, plan under `docs/superpowers/plans/`, run state at `docs/superpowers/run/state.json` (phase, spec, plan, acceptance). The Regent shell guardrail blocks destructive commands (`rm -rf` on root/home, force-push, `git clean -f`, `git reset --hard`, DB drop/truncate) before they execute.
|
|
57
|
+
|
|
58
|
+
`agent` is an optional child-capable agent ID override on dispatching tools. V2 `subtask: true` metadata does not create child sessions; Regent dispatch creates real child sessions through the plugin API. Worker routing falls back to the built-in `general` when no configured child-capable worker is available.
|
|
59
|
+
|
|
60
|
+
## Red Flags
|
|
61
|
+
|
|
62
|
+
| Thought | Reality |
|
|
63
|
+
| ----------------------------------- | --------------------------------------------------- |
|
|
64
|
+
| "This is just a simple question" | Questions are tasks. Check for skills. |
|
|
65
|
+
| "I need context before deciding" | Skills tell you how to gather context. Check first. |
|
|
66
|
+
| "Let me explore the codebase first" | Skill check comes before exploration. |
|
|
67
|
+
| "This doesn't need a formal skill" | If a skill exists, use it. |
|
|
68
|
+
| "The skill is overkill for this" | The skills exist because the alternative is worse. |
|
|
69
|
+
| "I'll just do this one thing first" | No. Check first. |
|
|
70
|
+
| "I remember what the skill says" | Skills evolve. Read the current version. |
|
|
71
|
+
| "This feels productive" | Undisciplined action is waste. Skills prevent this. |
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: verification-before-completion
|
|
3
|
+
description: Use before claiming work is done, fixed, ready, passing, complete, or successful; requires fresh verification evidence.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Verification Before Completion — Inspector (监官)
|
|
7
|
+
|
|
8
|
+
Iron Law of the Inspector: NO COMPLETION WITHOUT FRESH EVIDENCE. Governed by CONSTITUTION.md Iron Law 4.
|
|
9
|
+
|
|
10
|
+
## The Iron Law
|
|
11
|
+
|
|
12
|
+
**NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE.**
|
|
13
|
+
|
|
14
|
+
Fresh means run right now, not "it was working earlier." Verification means you have the output in front of you, not "I remember it passing." Evidence means test output showing 0 failures, not "seems fine."
|
|
15
|
+
|
|
16
|
+
## The Gate Function
|
|
17
|
+
|
|
18
|
+
### 1. IDENTIFY
|
|
19
|
+
|
|
20
|
+
What command proves the claim?
|
|
21
|
+
|
|
22
|
+
- "Tests pass" → requires test output showing 0 failures
|
|
23
|
+
- "Linter clean" → requires linter output showing 0 errors
|
|
24
|
+
- "Build succeeds" → requires build command with exit code 0
|
|
25
|
+
- "Bug is fixed" → requires the original reproducing scenario to pass
|
|
26
|
+
- "Feature is complete" → requires the acceptance criteria to be met
|
|
27
|
+
|
|
28
|
+
### 2. RUN
|
|
29
|
+
|
|
30
|
+
Execute the full command. Not a subset. Not "the relevant tests." Not a dry run. The actual command that proves the claim.
|
|
31
|
+
|
|
32
|
+
### 3. READ
|
|
33
|
+
|
|
34
|
+
Read the full output. Check the exit code. Count failures, errors, warnings, and any unexpected output.
|
|
35
|
+
|
|
36
|
+
### 4. VERIFY
|
|
37
|
+
|
|
38
|
+
Does the output confirm the claim?
|
|
39
|
+
|
|
40
|
+
- Tests: "Tests: 12 passed, 0 failed" → verified
|
|
41
|
+
- Linter: "No errors found" → verified
|
|
42
|
+
- Build: exit code 0 → verified
|
|
43
|
+
|
|
44
|
+
### 5. CLAIM
|
|
45
|
+
|
|
46
|
+
Only now may you say it works, it's done, or proceed to the next step.
|
|
47
|
+
|
|
48
|
+
## Common Failures
|
|
49
|
+
|
|
50
|
+
| Claim | Required Evidence | Not Sufficient |
|
|
51
|
+
| ------------------- | -------------------------------------- | -------------------------------- |
|
|
52
|
+
| Tests pass | Full test output: "X passed, 0 failed" | "All tests should pass now" |
|
|
53
|
+
| Linter clean | Linter output: "0 errors, 0 warnings" | "I fixed the lint issues" |
|
|
54
|
+
| Build succeeds | Build command exit code 0 | "Build was working earlier" |
|
|
55
|
+
| Bug fixed | Original repro scenario passes | "I changed the relevant code" |
|
|
56
|
+
| Feature complete | Acceptance criteria met, one by one | "I implemented the main parts" |
|
|
57
|
+
| Coverage sufficient | Coverage report above threshold | "I added tests for the new code" |
|
|
58
|
+
|
|
59
|
+
## Red Flags
|
|
60
|
+
|
|
61
|
+
| Says | Actually Means |
|
|
62
|
+
| ----------------------- | ---------------------------------- |
|
|
63
|
+
| "should pass now" | Not verified |
|
|
64
|
+
| "probably works" | Not verified |
|
|
65
|
+
| "seems correct" | Not verified |
|
|
66
|
+
| "I think it's fixed" | Not verified |
|
|
67
|
+
| "it was working before" | Not fresh evidence |
|
|
68
|
+
| "the tests look right" | Not run |
|
|
69
|
+
| "the change is trivial" | Most likely to break something |
|
|
70
|
+
| "just this once" | The exception that proves the rule |
|
|
71
|
+
|
|
72
|
+
## When to apply
|
|
73
|
+
|
|
74
|
+
- Before saying "it works"
|
|
75
|
+
- Before saying "it's done"
|
|
76
|
+
- Before committing
|
|
77
|
+
- Before creating a PR
|
|
78
|
+
- Before marking a task complete
|
|
79
|
+
- Before moving to the next task
|
|
80
|
+
- Before expressing satisfaction with results
|
|
81
|
+
|
|
82
|
+
Every time. No exceptions. No shortcuts. Fresh evidence or it did not happen.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wizard
|
|
3
|
+
description: "Generate an interactive bash wizard that walks a human through steps only they can perform: provisioning infrastructure, credentials or CI secrets, unfamiliar third-party dashboards, one-off migrations or cutovers. Use when the orchestrator's Phase 1 clarify asks how secrets will be provisioned, when Phase 3 execution is blocked on human steps, or during /regent/plan planning. Do not invoke for steps the agent can perform itself."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Wizard — Strategist (谋官) / Fleet Commander (舰官)
|
|
7
|
+
|
|
8
|
+
A **wizard** is a bash script that walks a human step by step through a manual procedure that's tedious to do by hand and tedious to re-explain to an AI every time. It opens each URL, says exactly what to click and copy, captures the values, writes them where they belong (`.env`, GitHub secrets), confirms at every stage, and shows how many stages are left.
|
|
9
|
+
|
|
10
|
+
The delightful UX is already solved by `template.sh` — the library above the `STAGES` marker is identical in every wizard; that consistency is the point: **never hand-edit it**. Helpers: `stage`, `say`/`step`, `open_url`, `ask`/`ask_secret`, `write_env`, `set_secret`/`set_var`, `pause`/`confirm`, `TOTAL_STAGES`. Your job is only to scope the procedure and author its stages.
|
|
11
|
+
|
|
12
|
+
A wizard is ephemeral by default: built for one run, saved to a scratch or `scripts/` path, deleted when the job's done. Commit it only when the sovereign wants a repeatable setup path that should live in the repo.
|
|
13
|
+
|
|
14
|
+
## Process
|
|
15
|
+
|
|
16
|
+
### 1. Scope the procedure
|
|
17
|
+
|
|
18
|
+
Work out every manual step the human must take and every value captured along the way. Read the repo first, don't ask cold:
|
|
19
|
+
|
|
20
|
+
- For setup: `.env`, `.env.example`, `.env.*`, `README`, `docker-compose*`, framework config, and `.github/workflows/*` (every `secrets.*` / `vars.*` reference is a value the wizard must produce).
|
|
21
|
+
- For a migration or transition: the current state, the target state, and the irreversible actions between them.
|
|
22
|
+
|
|
23
|
+
Then show the sovereign the ordered list of stages and the values each produces, and confirm: they may add, drop, or reorder.
|
|
24
|
+
|
|
25
|
+
**Done when:** every stage is named in order, and for each captured value you know (a) where the human gets it, (b) where it's written (`.env`, a GitHub secret, both, or nowhere; some stages are pure actions), and (c) whether it's secret (hidden entry) or public.
|
|
26
|
+
|
|
27
|
+
### 2. Map each stage's journey
|
|
28
|
+
|
|
29
|
+
For each stage, write the precise path a human follows: which URL to open, what to do there, where a value is shown, which variable it fills: e.g. "Dashboard → Developers → API keys → Reveal test key → copy". Where you don't actually know the current UI or the exact command, say so and ask the sovereign or check the docs: **never invent steps that may not exist.**
|
|
30
|
+
|
|
31
|
+
**Done when:** every stage traces to concrete instructions a stranger could follow.
|
|
32
|
+
|
|
33
|
+
### 3. Author the wizard
|
|
34
|
+
|
|
35
|
+
Copy `template.sh` to the target path. Replace the example stage with one `stage` per step, in dependency order. Set `TOTAL_STAGES` to the number of stages you wrote. Hold the bar the template sets: open the URL before asking for its value, `ask_secret` for anything secret, `write_env` every persisted value, `set_secret` only the values CI actually needs, and `confirm` before any irreversible action. Each `stage` clears the screen so only the current step is visible: keep a stage to one focused task so nothing the human needs scrolls away. Don't touch the library above the marker.
|
|
36
|
+
|
|
37
|
+
### 4. Verify and hand off
|
|
38
|
+
|
|
39
|
+
- `bash -n <script>`; run `shellcheck` if available; `chmod +x <script>`.
|
|
40
|
+
- Don't run it end-to-end yourself: it opens browsers and blocks on human input. Trace it statically instead: every value from step 1 is captured and lands where step 1 said, and every `set_secret` name exactly matches a `secrets.*` reference in CI.
|
|
41
|
+
- Hand to the sovereign with run instructions. If it's a repeatable setup path, commit it and link it from the README so the next person runs the script instead of asking an AI.
|
|
42
|
+
|
|
43
|
+
## Regent frame
|
|
44
|
+
|
|
45
|
+
Invoked by the orchestrator in Phase 1 clarify ("how will secrets be provisioned?"), Phase 3 execute (blocked-on-human steps, provisioning dashboards, one-off migrations/cutovers), and `/regent/plan` planning. While the wizard runs, the lane pauses: mark the stage in `docs/superpowers/run/state.json`; once the human returns the values, resume via `handoff` and feed them into the run.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: worktrees
|
|
3
|
+
description: "Parallel-isolation protocol for the Fleet Commander: run Level-1 plan tasks with disjoint file scopes in separate git worktrees, then integrate one at a time. Use in the orchestrator's Phase 2 planning (when the plan has two or more parallelizable tasks) and Phase 3 execution (before delegate_many dispatch)."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Worktrees — Fleet Commander (舰官)
|
|
7
|
+
|
|
8
|
+
Parallel isolation: every parallel task runs in its own worktree, so no subagent steps on another's working tree. One task, one branch, one checkout.
|
|
9
|
+
|
|
10
|
+
## When to isolate
|
|
11
|
+
|
|
12
|
+
Two or more **Level-1** tasks (no dependencies) with **disjoint file scopes** in `docs/superpowers/plans/<slug>/tasks.md`. If two tasks share or overlap any file, they never run in parallel — sequence them. Overlap first, parallelism second.
|
|
13
|
+
|
|
14
|
+
## How
|
|
15
|
+
|
|
16
|
+
1. **Create**: from the repo root, `git worktree add .worktrees/<taskId> -b regent/<taskId>` where `<taskId>` is the plan's `T<N>` id. Never inside another worktree. The repo root's `.worktrees/` is git-ignored. **Cap: at most 3 concurrent worktrees** — the plan's Level-1 set must fit it.
|
|
17
|
+
2. **Bootstrap** each worktree: copy `.env*` if the task needs them, install dependencies, run the repo's setup. A worktree that can't build is not dispatchable.
|
|
18
|
+
3. **Dispatch**: `delegate`/`delegate_many` with `location.directory` (or tool context directory) pointing at the worktree. The subagent commits onto `regent/<taskId>`; it never touches the main checkout's branch. Feed it the task text from the plan.
|
|
19
|
+
|
|
20
|
+
## Overlap oracle
|
|
21
|
+
|
|
22
|
+
Before any parallel dispatch, compare the per-task file lists (each task's scope, straight from the plan) side by side. Any overlap → sequence those tasks, however small the overlap. Run the oracle once, before dispatch — not after conflicts appear.
|
|
23
|
+
|
|
24
|
+
## Integrate
|
|
25
|
+
|
|
26
|
+
1. On the main worktree, merge each branch back: `git merge regent/<taskId>`.
|
|
27
|
+
2. Run the project's checks after each merge.
|
|
28
|
+
3. Any conflict → load `merge-conflicts`. Resolve, never discard.
|
|
29
|
+
4. **Serialize the finish.** Parallel work only: integration and PR creation are a queue of one.
|
|
30
|
+
|
|
31
|
+
## Cleanup
|
|
32
|
+
|
|
33
|
+
After a green merge, `git worktree remove .worktrees/<taskId>` (with `--force` only after confirming the merge landed). **Crash safety:** never delete a worktree with uncommitted work — commit or stash first, or the subagent's output is lost.
|
|
34
|
+
|
|
35
|
+
## Evidence
|
|
36
|
+
|
|
37
|
+
Record per task: worktree id, branch, commits, merge result. `changed-files` confirms what each lane touched; `verify` re-checks the merged tree; the Inspector's `code-review` reviews the integrated diff against the spec.
|
|
38
|
+
|
|
39
|
+
**Completion criterion:** every parallel task ran in isolation on its own branch, merged green onto the main worktree, worktrees removed, evidence recorded for Phase 4.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: zoom-out
|
|
3
|
+
description: Use when entering an unfamiliar code area or when broader structure, dependencies, and data flow need explanation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Zoom Out — Mentor (教官)
|
|
7
|
+
|
|
8
|
+
Regent court's senior engineer on orientation duty. Builds mental models, transfers codebase literacy. Governed by CONSTITUTION.md Principle I (Think Before Decree).
|
|
9
|
+
|
|
10
|
+
## What to look for
|
|
11
|
+
|
|
12
|
+
Answer these questions, in order:
|
|
13
|
+
|
|
14
|
+
1. **What does this directory contain?** Read the top-level files and subdirectories. Look for README, package.json, index files.
|
|
15
|
+
|
|
16
|
+
2. **What is the entry point?** How is the code in this area invoked? Find the callers, the exports, the route registrations.
|
|
17
|
+
|
|
18
|
+
3. **What are the key modules and their responsibilities?** For each module in the area, summarize its purpose in one sentence. If you cannot do that in one sentence, the module may need splitting.
|
|
19
|
+
|
|
20
|
+
4. **How do they communicate?** Direct calls? Events? Shared state? A database? Network?
|
|
21
|
+
|
|
22
|
+
5. **What are the data flows?** Trace a complete request/operation through the modules. Where does data enter, transform, persist, and exit?
|
|
23
|
+
|
|
24
|
+
6. **What tests exist?** Check `*.test.*`, `*.spec.*`, `__tests__/`, `test/`. The test files tell you what the authors considered important.
|
|
25
|
+
|
|
26
|
+
## Techniques
|
|
27
|
+
|
|
28
|
+
- **Start broad, then narrow.** Read the top-level directory first. Then the relevant subdirectory. Then the relevant file. Do not dive into a single file until you know where it sits.
|
|
29
|
+
|
|
30
|
+
- **Follow the imports.** Start at the entry point (route handler, main function, exported API). Follow the imports to understand the dependency graph.
|
|
31
|
+
|
|
32
|
+
- **Run the tests.** If tests exist, run them. They confirm your understanding of expected behavior.
|
|
33
|
+
|
|
34
|
+
- **Check the docs.** Read CONTEXT.md for domain vocabulary, `docs/adr/` for architectural decisions, any README files in the area.
|
|
35
|
+
|
|
36
|
+
## Output
|
|
37
|
+
|
|
38
|
+
Provide a structural summary: the directory layout, the key modules, the data flow, and where tests live. Use the project's domain language from CONTEXT.md. Cover only what the immediate task needs — do not write a full architectural document for a small change.
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/AGENTS.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Regent — Agent Guide
|
|
2
|
+
|
|
3
|
+
Before any work: read [`CONSTITUTION.md`](CONSTITUTION.md) — it defines Regent identity, court roles, principles, and iron laws.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd .opencode
|
|
9
|
+
npm install
|
|
10
|
+
node --test tests/regent.test.js tests/regent.live-test.js tests/regent.v2.test.js tests/regent.hybrid.v2.6.1.test.js tests/regent.runtime.v2.6.1.test.js
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
All 108 tests across the five suites must pass before committing.
|
|
14
|
+
|
|
15
|
+
## Development
|
|
16
|
+
|
|
17
|
+
- **Plugin entry:** `.opencode/plugins/regent.js` — default `Plugin.define` export; `setup` registers 6 custom tools, the destructive-command shell guardrail hook, and the v2 context hook; runtime-registers packaged skills and `/regent/...` commands; scopes bootstrap/evidence state (including freshness fingerprints) to root sessions; hides orchestration tools in worker contexts; Regent does not select or require a named root agent — the host's configured primary agent remains authoritative, with dispatch using available child-capable workers or built-in `general` fallback
|
|
18
|
+
- **Plugin API:** OpenCode v2 beta with `@opencode-ai/plugin@0.0.0-beta-18155`; server-side compaction mutation and `client.tui.showToast` are unavailable
|
|
19
|
+
- **Skills:** `.opencode/skills/<name>/SKILL.md` with frontmatter (`name:`, `description:`); file-discovered by OpenCode v2 and added at runtime when absent
|
|
20
|
+
- **Commands:** `.opencode/commands/<name>.md` with static frontmatter (`description:`, `subtask:`, `agent:`) for file-discovery compatibility; runtime registration is namespaced under `/regent/...`
|
|
21
|
+
- **Agents:** `.opencode/agents/<name>.md` with frontmatter (`description:`, `mode:`, `color:`); auto-discovered by OpenCode v2
|
|
22
|
+
- **Tests:** `.opencode/tests/` — `regent.test.js`, `regent.live-test.js`, `regent.v2.test.js`, `regent.hybrid.v2.6.1.test.js`, and `regent.runtime.v2.6.1.test.js` (108 tests total)
|
|
23
|
+
|
|
24
|
+
## Code style
|
|
25
|
+
|
|
26
|
+
- ESM only (`import`/`export`, no `require`)
|
|
27
|
+
- No comments — let code speak
|
|
28
|
+
- Error paths produce structured JSON, never throw
|
|
29
|
+
- `context.directory` → `process.cwd()` fallback
|
|
30
|
+
|
|
31
|
+
## Verdict gates
|
|
32
|
+
|
|
33
|
+
Before committing:
|
|
34
|
+
1. Run `npm run verify` — format, lint, typecheck, all unit tests pass
|
|
35
|
+
2. Read `CONSTITUTION.md` — ensure changes align with identity and iron laws
|
|
36
|
+
3. Add new skill? Update `README.md` skill table. Add new tool or command? Update tool/command tables.
|
|
37
|
+
4. Adding features? Update project-level dispatch, rate-limit, circuit-breaker, and evidence state in regent.js.
|
|
38
|
+
5. No phase skip. No gate bypass.
|