@esneiderbravo/speclaw 1.0.1 → 2.0.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.
Files changed (48) hide show
  1. package/README.md +76 -59
  2. package/dist/cli/commands/cortex.js +49 -0
  3. package/dist/cli/commands/init.js +23 -16
  4. package/dist/cli/commands/lawbook.js +34 -1
  5. package/dist/cli/commands/update.js +66 -58
  6. package/dist/cli/index.js +12 -3
  7. package/dist/cli/lib/update-check.js +8 -5
  8. package/dist/modules/cortex/brief.js +75 -0
  9. package/dist/modules/cortex/harness.js +270 -0
  10. package/dist/modules/cortex/register.js +49 -0
  11. package/dist/modules/foundation/assets/AGENTS.template.md +13 -6
  12. package/dist/modules/foundation/assets/CLAUDE.template.md +15 -11
  13. package/dist/modules/foundation/assets/docs/standards/lawbook.template.md +24 -37
  14. package/dist/modules/foundation/assets/workflows/speclaw.yml +1 -1
  15. package/dist/modules/foundation/context-budget.js +2 -0
  16. package/dist/modules/foundation/setup-tool.js +3 -2
  17. package/dist/modules/lawbook/assets/agents/archiver.md +19 -0
  18. package/dist/modules/lawbook/assets/agents/explorer.md +24 -0
  19. package/dist/modules/lawbook/assets/agents/implementer.md +20 -0
  20. package/dist/modules/lawbook/assets/agents/planner.md +27 -0
  21. package/dist/modules/lawbook/assets/agents/reviewer.md +25 -0
  22. package/dist/modules/lawbook/assets/agents/tester.md +21 -0
  23. package/dist/modules/lawbook/assets/commands/cortex.md +11 -0
  24. package/dist/modules/lawbook/assets/rules/spec-tasks-mandatory-steps.md +11 -10
  25. package/dist/modules/lawbook/assets/skills/build/steps/03-implement.md +1 -1
  26. package/dist/modules/lawbook/assets/skills/build/steps/04-hand-off.md +17 -0
  27. package/dist/modules/lawbook/assets/skills/cortex/SKILL.md +13 -0
  28. package/dist/modules/lawbook/assets/skills/cortex/steps/01-load-or-start.md +25 -0
  29. package/dist/modules/lawbook/assets/skills/cortex/steps/02-dispatch-loop.md +19 -0
  30. package/dist/modules/lawbook/assets/skills/cortex/steps/03-complete.md +10 -0
  31. package/dist/modules/lawbook/assets/skills/test/SKILL.md +11 -0
  32. package/dist/modules/lawbook/assets/skills/{build/steps/04-quality-gates.md → test/steps/01-quality-gates.md} +1 -1
  33. package/dist/modules/lawbook/assets/skills/{build/steps/05-manual-verification.md → test/steps/02-manual-verification.md} +1 -1
  34. package/dist/modules/lawbook/assets/skills/{build/steps/06-discipline-reports.md → test/steps/03-discipline-reports.md} +5 -2
  35. package/dist/modules/lawbook/change-tool.js +22 -0
  36. package/dist/modules/lawbook/engine.js +4 -0
  37. package/dist/modules/lawbook/levels.js +9 -3
  38. package/dist/modules/lawbook/register.js +7 -0
  39. package/dist/modules/tools/assets/packs.json +1 -6
  40. package/dist/server.js +4 -1
  41. package/dist/shared/agents.js +3 -3
  42. package/dist/shared/exposure.js +2 -2
  43. package/dist/shared/tool-catalog.js +3 -2
  44. package/package.json +2 -2
  45. package/dist/modules/lawbook/assets/skills/build/steps/07-hand-off.md +0 -9
  46. package/dist/modules/tools/assets/packs/agents/backend-developer.md +0 -61
  47. package/dist/modules/tools/assets/packs/agents/frontend-developer.md +0 -62
  48. package/dist/modules/tools/assets/packs/agents/product-strategy-analyst.md +0 -56
@@ -18,7 +18,7 @@ jobs:
18
18
  with:
19
19
  fetch-depth: 0
20
20
  - name: ⚖️ Verify
21
- uses: esneiderbravo/speclaw@v1
21
+ uses: esneiderbravo/speclaw@v2
22
22
  - name: 🛡️ Upload SARIF
23
23
  uses: github/codeql-action/upload-sarif@v4
24
24
  if: always()
@@ -1,4 +1,5 @@
1
1
  import { registerCompass } from "../compass/register.js";
2
+ import { registerCortex } from "../cortex/register.js";
2
3
  import { registerSpec } from "../lawbook/register.js";
3
4
  import { registerTools } from "../tools/register.js";
4
5
  import { registerFoundationCore } from "./register-core.js";
@@ -25,6 +26,7 @@ export function collectRegisteredTools(minimal) {
25
26
  registerFoundationCore(stub, opts);
26
27
  registerSpec(stub, opts);
27
28
  registerCompass(stub, opts);
29
+ registerCortex(stub, opts);
28
30
  registerTools(stub, opts);
29
31
  return tools;
30
32
  }
@@ -64,12 +64,13 @@ export function handleSpeclawSetup(args) {
64
64
  return {
65
65
  instructions: [
66
66
  "1. Analyze the repository at projectPath and fill profile fields from the real codebase.",
67
- "2. Call speclaw_setup with action configure-agent / add-pack as needed.",
67
+ "2. Call speclaw_setup with action configure-agent as needed (packs catalog may be empty).",
68
68
  "3. Run lawbook_change action init and compass_index when scaffold completes via CLI if needed.",
69
+ "4. Non-trivial work uses Cortex: cortex skill / speclaw cortex (MCP tool cortex).",
69
70
  ],
70
71
  profileFields: profileFieldHelp,
71
72
  packs: loadPacks(),
72
- note: "Full scaffold runs via CLI: speclaw init — not MCP.",
73
+ note: "Full scaffold runs via CLI: speclaw init — not MCP. Role agents install with the lawbook workflow.",
73
74
  };
74
75
  case "configure-agent": {
75
76
  if (!args.agent)
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: archiver
3
+ description: Reconcile specs, sync, and archive a change when Cortex stage is archiving. No new feature implementation.
4
+ tools: Read, Grep, Glob, Write, Edit, Bash, CallMcpTool, mcp__speclaw__compass_explore, mcp__speclaw__lawbook_change, mcp__speclaw__lawbook_validate, mcp__speclaw__lawbook_sync, mcp__speclaw__lawbook_archive, mcp__speclaw__cortex
5
+ ---
6
+
7
+ You are the **archiver** role in speclaw's **Cortex** (One brain. Many agents.).
8
+
9
+ ## Goal
10
+
11
+ Follow the `sync` then `archive` skills: reconcile delta specs to built code,
12
+ `lawbook_change` action sync when needed, then archive. Advance Cortex to
13
+ `done` after a successful archive.
14
+
15
+ ## Hard constraints
16
+
17
+ - Do **not** start new feature work outside reconciliation.
18
+ - If archive is gated, report blockers to the coordinator — do not bypass the
19
+ engine.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: explorer
3
+ description: Read-only codebase investigation for a lawbook change. Use when the Cortex stage is exploring (or investigate for bugs). Compass-first; writes nothing under lawbook/ or src/.
4
+ tools: Read, Grep, Glob, CallMcpTool, mcp__speclaw__compass_explore, mcp__speclaw__compass_find, mcp__speclaw__compass_impact, mcp__speclaw__compass_trace, mcp__speclaw__compass_index, mcp__speclaw__lawbook_investigate
5
+ disallowedTools: Write, Edit, MultiEdit, Bash, NotebookEdit
6
+ ---
7
+
8
+ You are the **explorer** role in speclaw's **Cortex** (One brain. Many agents.).
9
+
10
+ ## Goal
11
+
12
+ Investigate the idea or bug with Compass **before** any grep/read. Produce a
13
+ short brief for the planner: relevant symbols, blast radius, risks, and open
14
+ questions. Do **not** draft change artifacts or edit source.
15
+
16
+ ## Skill
17
+
18
+ Follow the `explore` skill (or `investigate` when `changeType` is bug).
19
+
20
+ ## Hard constraints
21
+
22
+ - No Write / StrReplace / git writes / draft / archive / Cortex advance to
23
+ implementing.
24
+ - When finished, return the brief to the coordinator and stop.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: implementer
3
+ description: Implement drafted lawbook tasks in source and tests. Use when Cortex stage is implementing. Does not run final quality gates, review, sync, or archive.
4
+ tools: Read, Grep, Glob, Write, Edit, Bash, CallMcpTool, mcp__speclaw__compass_explore, mcp__speclaw__compass_find, mcp__speclaw__compass_impact, mcp__speclaw__compass_index, mcp__speclaw__lawbook_change, mcp__speclaw__cortex
5
+ disallowedTools: NotebookEdit
6
+ ---
7
+
8
+ You are the **implementer** role in speclaw's **Cortex** (One brain. Many agents.).
9
+
10
+ ## Goal
11
+
12
+ Work `tasks.md` in order using the `build` skill through implementation only.
13
+ Keep code and delta specs in agreement. Check off completed tasks.
14
+
15
+ ## Hard constraints
16
+
17
+ - Do **not** archive, push, or `laws accept`.
18
+ - Do **not** skip the reviewer by "quietly fixing" after a FAIL — wait for
19
+ Cortex `rework` from the coordinator.
20
+ - Stop after implementation hand-off; tester owns gates and discipline reports.
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: planner
3
+ description: Draft lawbook change artifacts and ceremony level. Use when Cortex stage is planning. Asks clarifying questions via the coordinator; never edits src/.
4
+ tools: Read, Grep, Glob, Write, Edit, CallMcpTool, mcp__speclaw__compass_explore, mcp__speclaw__compass_find, mcp__speclaw__lawbook_change, mcp__speclaw__lawbook_level
5
+ disallowedTools: Bash, NotebookEdit
6
+ ---
7
+
8
+ You are the **planner** role in speclaw's **Cortex** (One brain. Many agents.).
9
+
10
+ ## Goal
11
+
12
+ Turn the explorer brief + user intent into a reviewable change under
13
+ `lawbook/changes/<name>/` at the confirmed ceremony level. Prefer `draft` /
14
+ `quick` skills.
15
+
16
+ ## Questions
17
+
18
+ If anything material is ambiguous, **stop**. Return numbered questions to the
19
+ coordinator (do not invent answers). The coordinator advances Cortex with
20
+ `pauseForQuestions`. After human answers, continue drafting.
21
+
22
+ ## Hard constraints
23
+
24
+ - May write only under `lawbook/changes/<name>/` (and related lawbook paths).
25
+ - Do **not** edit `src/`, run archive, or implement code.
26
+ - When the draft is complete, tell the coordinator to `cortex advance` toward
27
+ implementing.
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: reviewer
3
+ description: Deep review of implemented change without patching code. Writes reports/review.md with PASS or FAIL. Use when Cortex stage is reviewing.
4
+ tools: Read, Grep, Glob, Write, CallMcpTool, mcp__speclaw__compass_explore, mcp__speclaw__compass_find, mcp__speclaw__compass_impact, mcp__speclaw__compass_trace, mcp__speclaw__lawbook_change, mcp__speclaw__cortex
5
+ disallowedTools: Edit, MultiEdit, Bash, NotebookEdit
6
+ ---
7
+
8
+ You are the **reviewer** role in speclaw's **Cortex** (One brain. Many agents.).
9
+
10
+ ## Goal
11
+
12
+ Review the branch/diff against proposal, tasks, delta specs, and
13
+ `docs/standards/*`. Write `lawbook/changes/<name>/reports/review.md` with:
14
+
15
+ - Verdict: `PASS` or `FAIL`
16
+ - Findings anchored to file paths / symbols
17
+ - Rework guidance if FAIL
18
+
19
+ You may create/overwrite **only** `reports/review.md` (and read everything else).
20
+
21
+ ## Hard constraints
22
+
23
+ - Do **not** patch application source to "make it pass".
24
+ - Return the verdict to the coordinator for `cortex advance` (PASS) or
25
+ `cortex rework` (FAIL).
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: tester
3
+ description: Run quality gates and manual verification; write discipline reports. Use when Cortex stage is testing. May add missing tests only — not features.
4
+ tools: Read, Grep, Glob, Write, Edit, Bash, CallMcpTool, mcp__speclaw__compass_explore, mcp__speclaw__compass_affected_tests, mcp__speclaw__lawbook_change, mcp__speclaw__cortex
5
+ ---
6
+
7
+ You are the **tester** role in speclaw's **Cortex** (One brain. Many agents.).
8
+
9
+ ## Goal
10
+
11
+ Follow the `test` skill: quality gates, manual verification, discipline
12
+ reports. Record verdict PASS or FAIL for the coordinator.
13
+
14
+ You MAY add or fix **tests** that are missing for covered requirements. You
15
+ MUST NOT implement new product features.
16
+
17
+ ## Hard constraints
18
+
19
+ - Do not archive or sync.
20
+ - On FAIL, return findings for Cortex `rework`; on PASS, coordinator advances
21
+ to archiving.
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: Coordinate Cortex (One brain. Many agents.) for a lawbook change until archive.
3
+ ---
4
+
5
+ Cortex the change: $ARGUMENTS
6
+
7
+ Follow the `cortex` skill. You are the coordinator — spawn or adopt
8
+ explorer → planner → implementer → reviewer → tester → archiver. Drive state
9
+ with the `cortex` MCP tool (`status`/`start`/`advance`/`rework`/`brief`) or
10
+ `speclaw cortex …`. Surface planner questions to the human. Do not implement
11
+ product code yourself.
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Enforce the mandatory steps from lawbook/config.yaml when creating tasks.md, and ensure the agent executes all manual verification itself.
2
+ description: Enforce the mandatory steps from lawbook/config.yaml when creating tasks.md, and ensure the tester role executes all manual verification itself.
3
3
  alwaysApply: true
4
4
  ---
5
5
 
@@ -19,7 +19,7 @@ steps, branch convention, and testing/documentation requirements.
19
19
  - Review and update the affected tests.
20
20
  - Run the quality gates and verify they pass
21
21
  (see `docs/standards/testing-standards.md`).
22
- - Perform manual verification of the behavior — **the agent executes this
22
+ - Perform manual verification of the behavior — **the tester role executes this
23
23
  itself, never the user.**
24
24
  - Produce the discipline reports under `reports/` — one per discipline the change
25
25
  touched, from an open set (`backend.md`, `frontend.md`, `api.md`, `database.md`,
@@ -28,13 +28,13 @@ steps, branch convention, and testing/documentation requirements.
28
28
  for what the feature touched.
29
29
  - Update the technical documentation the change touches.
30
30
  - Archive the change within the same PR (the `archive` command / `lawbook_archive`
31
- tool).
31
+ tool) after Cortex review/test PASS.
32
32
 
33
- ## 3. Manual verification — the agent must execute it
33
+ ## 3. Manual verification — the tester must execute it
34
34
 
35
- The coding agent performs all manual testing itself (exercise the endpoint, UI,
36
- or CLI). Never delegate it to the user. A task that requires verification is
37
- not complete until the agent has verified it.
35
+ Under Cortex, the **tester** role performs all manual testing
36
+ (exercise the endpoint, UI, or CLI). Never delegate it to the user. A task that
37
+ requires verification is not complete until the tester has verified it.
38
38
 
39
39
  ## 4. Archiving is part of the change
40
40
 
@@ -42,6 +42,7 @@ A change is not done until it is archived with `lawbook_archive` (never a manual
42
42
  `mv`). The archive lands in the same PR that implements the change.
43
43
 
44
44
  `lawbook_archive` is gated: it refuses to archive while any task is unchecked,
45
- while `reports/` has no discipline report, or while the delta specs are not yet
46
- synced into the canonical specs. Resolve those first — the gate is enforced in
47
- the engine, so a manual `mv` only hides an incomplete change.
45
+ while `reports/` has no discipline report, while the delta specs are not yet
46
+ synced into the canonical specs, or while harness review/test verdicts are not
47
+ PASS. Resolve those first — the gate is enforced in the engine, so a manual `mv`
48
+ only hides an incomplete change.
@@ -8,4 +8,4 @@
8
8
  spec, update the spec in the change (not silently) — the two must agree.
9
9
  - Check off each task in `tasks.md` as you complete it.
10
10
 
11
- Next: read `steps/04-quality-gates.md` and do only what it says.
11
+ Next: read `steps/04-hand-off.md` and do only what it says.
@@ -0,0 +1,17 @@
1
+ # Hand off to review / test
2
+
3
+ Implementation for this role stops here. Do **not** run the full quality-gate
4
+ suite, write discipline reports, sync, or archive — those belong to the
5
+ **tester** and **archiver** roles under Cortex.
6
+
7
+ Tell the coordinator:
8
+
9
+ 1. Which tasks are done
10
+ 2. Notable spec reconciliations still needed
11
+ 3. To `cortex advance` from `implementing` (→ reviewing at level ≥1, or
12
+ testing at level 0)
13
+
14
+ The **tester** role follows the `test` skill for gates, manual verification,
15
+ and discipline reports.
16
+
17
+ No further steps remain — build workflow complete.
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: cortex
3
+ description: Coordinate Cortex — One brain. Many agents. Spawn or adopt explorer, planner, implementer, reviewer, tester, archiver until archive. Use for non-trivial work: "build X", "implement the change", "run cortex", "orchestrate X".
4
+ ---
5
+
6
+ # Cortex — One brain. Many agents.
7
+
8
+ You are the **coordinator**. Do not implement product code yourself.
9
+
10
+ Drive state with the `cortex` MCP tool (`status` / `start` / `advance` /
11
+ `rework` / `brief`) or `speclaw cortex …`. Command: `/lawbook/cortex`.
12
+
13
+ Read `steps/01-load-or-start.md` and do only what it says.
@@ -0,0 +1,25 @@
1
+ # Load or start Cortex
2
+
3
+ - Confirm the change name with the user (or draft/quick first if none exists).
4
+ - Run the `cortex` MCP tool with `action: status` (or
5
+ `speclaw cortex status --change <name>`). Prefer `action: brief` when you
6
+ need the role + skill hints for the current stage.
7
+ - If missing, `action: start`.
8
+ - Read `ai-specs/agents/<role>.md` for the current stage's permission contract.
9
+ - If the host can spawn subagents (Claude Task / Cursor Task), spawn that role
10
+ with the contract in the prompt. If not, **adopt the role** in this session
11
+ but obey its allow/deny list strictly.
12
+
13
+ Stage → role:
14
+
15
+ | Stage | Role |
16
+ |-------|------|
17
+ | exploring | explorer (`explore` / `investigate` for bugs) |
18
+ | planning / questions | planner (`draft` / `quick`); questions always go to the human |
19
+ | implementing | implementer (`build` through implement hand-off) |
20
+ | reviewing | reviewer |
21
+ | testing | tester |
22
+ | archiving | archiver (`sync` + `archive`) |
23
+ | done | stop — report success |
24
+
25
+ Next: read `steps/02-dispatch-loop.md` and do only what it says.
@@ -0,0 +1,19 @@
1
+ # Dispatch loop
2
+
3
+ For the current Cortex stage (`cortex` action `brief` or `status`):
4
+
5
+ 1. Dispatch (spawn or adopt) the matching role with a clear handoff brief.
6
+ 2. On role completion, call the matching Cortex op:
7
+ - exploring → `advance`
8
+ - planning with questions → `advance` + `pauseForQuestions` + `openQuestions`
9
+ - questions after human answers → `advance` (back to planning)
10
+ - planning complete → `advance` (to implementing)
11
+ - implementing done → `advance` (reviewing, or testing at level 0)
12
+ - reviewing PASS → `advance` + `verdict: PASS`; FAIL → `rework` + `verdict: FAIL`
13
+ - testing PASS → `advance` + `verdict: PASS`; FAIL → `rework` + `verdict: FAIL`
14
+ - archiving success → `advance` (to done)
15
+ 3. Max rework is 3; if the engine rejects further rework, **ask the human**.
16
+ 4. Coordinator never edits `src/`, never archives, never pushes, never runs
17
+ `laws accept`.
18
+
19
+ Next: read `steps/03-complete.md` and do only what it says.
@@ -0,0 +1,10 @@
1
+ # Complete
2
+
3
+ When Cortex stage is `done` (or the human stops the run), summarize:
4
+
5
+ - Change name and final stage
6
+ - Review/test verdicts and iteration count
7
+ - Archive path if archived
8
+ - Anything still open for the human
9
+
10
+ No further steps remain — Cortex workflow complete.
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: test
3
+ description: Run quality gates, manual verification, and discipline reports for a change. Used by the tester Cortex role after implementation. Use when Cortex stage is testing or the user asks to verify/test a change.
4
+ ---
5
+
6
+ # test — Verify a change
7
+
8
+ Run gates, manual verification, and write discipline reports. You may add
9
+ missing tests; do not implement new features.
10
+
11
+ Read `steps/01-quality-gates.md` and do only what it says.
@@ -7,4 +7,4 @@ Run the repo's gates from `docs/standards/testing-standards.md`:
7
7
 
8
8
  Run them yourself and report real output. A red gate blocks completion.
9
9
 
10
- Next: read `steps/05-manual-verification.md` and do only what it says.
10
+ Next: read `steps/02-manual-verification.md` and do only what it says.
@@ -19,4 +19,4 @@ and proceed only after explicit authorization. A backup is not a substitute for
19
19
  authorization. Record in the report how verification stayed isolated (or the
20
20
  authorization you obtained).
21
21
 
22
- Next: read `steps/06-discipline-reports.md` and do only what it says.
22
+ Next: read `steps/03-discipline-reports.md` and do only what it says.
@@ -35,10 +35,13 @@ the evidence trustworthy and reproducible, rather than left to improvisation:
35
35
  change, with proof it is pre-existing (e.g. it reproduces with the change
36
36
  stashed) — or state "none".
37
37
  6. **Pending manual steps** — anything not automated, stated plainly — or "none".
38
- 7. **Verdict** — one line.
38
+ 7. **Verdict** — one line (`PASS` or `FAIL` for Cortex).
39
39
 
40
40
  If a test kind does not yet apply (e.g. no unit runner), the report says so in
41
41
  place of that evidence and records the gates and manual verification that stood
42
42
  in.
43
43
 
44
- Next: read `steps/07-hand-off.md` and do only what it says.
44
+ Tell the coordinator the Cortex verdict so they can `advance` (PASS) or
45
+ `rework` (FAIL).
46
+
47
+ No further steps remain — test workflow complete.
@@ -3,6 +3,7 @@ import { specInit, specValidate, specSync, specArchive, specList } from "./engin
3
3
  import { handleLevel } from "./quick.js";
4
4
  import { buildCoverageReport, loadCoverageConfig, renderCoverageAgent } from "./coverage.js";
5
5
  import { buildDriftReport, renderDriftAgent } from "./drift.js";
6
+ import { handleHarness, harnessOps } from "../cortex/harness.js";
6
7
  export const lawbookChangeActions = [
7
8
  "init",
8
9
  "list",
@@ -12,6 +13,7 @@ export const lawbookChangeActions = [
12
13
  "level",
13
14
  "coverage",
14
15
  "drift",
16
+ "harness",
15
17
  ];
16
18
  export const lawbookChangeSchema = {
17
19
  projectPath: z.string(),
@@ -31,6 +33,11 @@ export const lawbookChangeSchema = {
31
33
  capability: z.string().optional(),
32
34
  includeReverse: z.boolean().optional(),
33
35
  maxItems: z.number().int().min(1).max(50).optional(),
36
+ harnessOp: z.enum(harnessOps).optional(),
37
+ verdict: z.enum(["PASS", "FAIL"]).optional(),
38
+ openQuestions: z.array(z.string()).optional(),
39
+ pauseForQuestions: z.boolean().optional(),
40
+ note: z.string().optional(),
34
41
  };
35
42
  function requireField(args, field) {
36
43
  const v = args[field];
@@ -84,6 +91,21 @@ export function handleLawbookChange(args) {
84
91
  return report;
85
92
  return renderDriftAgent(report, args.maxItems ?? 10);
86
93
  }
94
+ case "harness": {
95
+ // Deprecated alias — prefer MCP tool `cortex` / `speclaw cortex`.
96
+ if (!args.harnessOp) {
97
+ throw new Error(`lawbook_change: action 'harness' requires 'harnessOp'`);
98
+ }
99
+ return handleHarness({
100
+ projectPath: args.projectPath,
101
+ change: requireField(args, "change"),
102
+ harnessOp: args.harnessOp,
103
+ verdict: args.verdict ?? null,
104
+ openQuestions: args.openQuestions,
105
+ pauseForQuestions: args.pauseForQuestions,
106
+ note: args.note ?? args.reason,
107
+ });
108
+ }
87
109
  default:
88
110
  throw new Error(`lawbook_change: unknown action '${String(args.action)}'`);
89
111
  }
@@ -5,6 +5,7 @@ import { sealCapability } from "./anchors.js";
5
5
  import { classifyEars, diagnoseEars, extractNormativeBody, loadEarsConfig, splitRequirementBlocks, } from "./ears.js";
6
6
  import { artifactNeeds, confirmedLevel, countUncheckedTasks, gatherSignals, hasDisciplineReport, loadCeremonyConfig, proposeLevel, readChangeType, readCeremonyRecord, } from "./levels.js";
7
7
  import { inferBugResolution, preventionRequiresDelta, validateBugfixContent } from "./bugfix.js";
8
+ import { harnessArchiveBlockers } from "../cortex/harness.js";
8
9
  // speclaw's own spec-driven workflow engine. Inspired by OpenSpec's model
9
10
  // (proposals, delta specs, changes, archive) but implemented from scratch and
10
11
  // deliberately simpler: a change's specs/ holds the full intended spec for each
@@ -430,6 +431,9 @@ export function specArchivePreconditions(projectPath, change) {
430
431
  }
431
432
  // 4. Opt-in coverage gate: only when the change's delta specs declare ids.
432
433
  blockers.push(...coverageArchiveBlockers(projectPath, change));
434
+ // 5. Multi-agent harness: review/test PASS and stage archiving|done.
435
+ // Covers: req~harness-archive-gate~1
436
+ blockers.push(...harnessArchiveBlockers(projectPath, change));
433
437
  return blockers;
434
438
  }
435
439
  /**
@@ -462,7 +462,13 @@ export function hasDisciplineReport(changeDir) {
462
462
  const reportsDir = path.join(changeDir, "reports");
463
463
  if (!fs.existsSync(reportsDir))
464
464
  return false;
465
- return fs
466
- .readdirSync(reportsDir)
467
- .some((n) => n.endsWith(".md") && n.toLowerCase() !== "readme.md");
465
+ return fs.readdirSync(reportsDir).some((n) => {
466
+ if (!n.endsWith(".md"))
467
+ return false;
468
+ const lower = n.toLowerCase();
469
+ // README scaffold and reviewer harness verdict are not discipline evidence.
470
+ if (lower === "readme.md" || lower === "review.md")
471
+ return false;
472
+ return true;
473
+ });
468
474
  }
@@ -1,3 +1,4 @@
1
+ import fs from "node:fs";
1
2
  import path from "node:path";
2
3
  import { z } from "zod";
3
4
  import { defineTool, defineAliasTool, text } from "../../shared/mcp.js";
@@ -17,6 +18,12 @@ export function installWorkflow(projectPath, vars, report, opts) {
17
18
  copyRendered(path.join(ASSETS, "skills"), path.join(aiSpecs, "skills"), vars, report, opts);
18
19
  copyRendered(path.join(ASSETS, "commands"), path.join(aiSpecs, "commands", "lawbook"), vars, report, opts);
19
20
  copyRendered(path.join(ASSETS, "rules"), path.join(aiSpecs, "rules"), vars, report, opts);
21
+ // Role agents (explorer/planner/implementer/reviewer/tester/archiver) — always on.
22
+ // Covers: req~role-agents-default~1
23
+ const agentsSrc = path.join(ASSETS, "agents");
24
+ if (fs.existsSync(agentsSrc)) {
25
+ copyRendered(agentsSrc, path.join(aiSpecs, "agents"), vars, report, opts);
26
+ }
20
27
  }
21
28
  /** Register the spec workflow MCP tools. */
22
29
  export function registerSpec(server, opts = {}) {
@@ -1,6 +1 @@
1
- {
2
- "agents": {
3
- "description": "Subagent definitions rendered with the project profile: backend-developer, frontend-developer, product-strategy-analyst. They read the project's standards (docs/standards/*) for the stack, so they stay accurate as the standards are filled.",
4
- "path": "agents"
5
- }
6
- }
1
+ {}
package/dist/server.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
3
  import { registerCompass } from "./modules/compass/register.js";
4
+ import { registerCortex } from "./modules/cortex/register.js";
4
5
  import { registerSpec } from "./modules/lawbook/register.js";
5
6
  import { registerFoundation } from "./modules/foundation/register.js";
6
7
  import { registerTools } from "./modules/tools/register.js";
7
8
  import { isMinimalMode } from "./shared/exposure.js";
9
+ import { pkgVersion } from "./shared/version.js";
8
10
  /**
9
11
  * Build the speclaw MCP server with every module's tools registered.
10
12
  *
@@ -12,11 +14,12 @@ import { isMinimalMode } from "./shared/exposure.js";
12
14
  */
13
15
  export function buildServer(opts = {}) {
14
16
  const minimal = opts.minimal ?? isMinimalMode();
15
- const server = new McpServer({ name: "speclaw", version: "0.1.0" });
17
+ const server = new McpServer({ name: "speclaw", version: pkgVersion() });
16
18
  const reg = { minimal };
17
19
  registerFoundation(server, reg);
18
20
  registerSpec(server, reg);
19
21
  registerCompass(server, reg);
22
+ registerCortex(server, reg);
20
23
  registerTools(server, reg);
21
24
  return server;
22
25
  }
@@ -15,21 +15,21 @@ export const AGENTS = [
15
15
  id: "cursor",
16
16
  label: "Cursor",
17
17
  ideDir: ".cursor",
18
- linkTargets: ["skills", "commands", "rules"],
18
+ linkTargets: ["skills", "commands", "rules", "agents"],
19
19
  mcpFile: ".cursor/mcp.json",
20
20
  },
21
21
  {
22
22
  id: "codex",
23
23
  label: "Codex",
24
24
  ideDir: ".codex",
25
- linkTargets: ["skills", "commands"],
25
+ linkTargets: ["skills", "commands", "agents"],
26
26
  mcpFile: ".codex/mcp.json",
27
27
  },
28
28
  {
29
29
  id: "windsurf",
30
30
  label: "Windsurf",
31
31
  ideDir: ".windsurf",
32
- linkTargets: ["skills", "commands"],
32
+ linkTargets: ["skills", "commands", "agents"],
33
33
  mcpFile: ".windsurf/mcp.json",
34
34
  },
35
35
  {
@@ -4,8 +4,8 @@ import { fileURLToPath } from "node:url";
4
4
  import { readManifest } from "./manifest.js";
5
5
  /**
6
6
  * Tools omitted when the exposure profile is `minimal`. Kept tools are the
7
- * discovery + law loop: compass_explore/find/diff_context, lawbook_change.
8
- * Deprecated aliases are never registered in minimal mode.
7
+ * discovery + law loop: compass_explore/find/diff_context, lawbook_change,
8
+ * cortex. Deprecated aliases are never registered in minimal mode.
9
9
  */
10
10
  export const MINIMAL_OMIT = new Set([
11
11
  "compass_index",
@@ -4,12 +4,13 @@ export const CANONICAL_TOOLS = [
4
4
  "compass_find",
5
5
  "compass_diff_context",
6
6
  "compass_index",
7
+ "cortex",
7
8
  "lawbook_change",
8
9
  "lawbook_investigate",
9
10
  "speclaw_setup",
10
11
  "speclaw_check",
11
12
  ];
12
- export const MAX_CANONICAL_TOOLS = 8;
13
+ export const MAX_CANONICAL_TOOLS = 9;
13
14
  /** Retired MCP names → canonical replacement hint for deprecation notices. */
14
15
  export const ALIAS_TARGETS = {
15
16
  compass_search: "compass_find (mode: exact)",
@@ -35,7 +36,7 @@ export const ALIAS_TARGETS = {
35
36
  };
36
37
  export const ALIAS_NAMES = Object.keys(ALIAS_TARGETS);
37
38
  const ALIAS_SET = new Set(ALIAS_NAMES);
38
- /** True when `name` is one of the eight canonical tools. */
39
+ /** True when `name` is one of the nine canonical tools. */
39
40
  export function isCanonicalTool(name) {
40
41
  return CANONICAL_TOOLS.includes(name);
41
42
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@esneiderbravo/speclaw",
3
- "version": "1.0.1",
3
+ "version": "2.0.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "description": "Where specs become law. A self-contained MCP suite that turns any repo into a spec-driven, agent-ready project: its own constitution (foundation), its own local code graph (Compass), its own spec-driven workflow (Lawbook), and opt-in skill packs (Tools). No external CLIs, no LLM to install.",
7
+ "description": "Where specs become law. A self-contained MCP suite that turns any repo into a spec-driven, multi-agent-ready project: its own constitution (Foundation), local code graph (Compass), spec workflow (Lawbook), and multi-agent brain (Cortex). No external CLIs, no LLM to install.",
8
8
  "keywords": [
9
9
  "mcp",
10
10
  "mcp-server",
@@ -1,9 +0,0 @@
1
- # Hand off
2
-
3
- When every task is checked and gates are green, tell the user the change is
4
- ready to `sync` and `archive`. Keep the delta specs current as you build, but
5
- know that `sync` formally reconciles the delta specs against what was actually
6
- built — so behavior that drifted past the original spec is caught there, not
7
- left to chance.
8
-
9
- No further steps remain — build workflow complete.