@trieungoctam/speckit 0.2.2 → 0.3.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 (55) hide show
  1. package/README.md +43 -6
  2. package/dist/adapters/antigravity-adapter.js +4 -4
  3. package/dist/adapters/claude-code-adapter.js +23 -5
  4. package/dist/adapters/codex-adapter.js +7 -3
  5. package/dist/adapters/cursor-adapter.js +30 -3
  6. package/dist/adapters/opencode-adapter.js +1 -1
  7. package/dist/cli.js +41 -0
  8. package/dist/commands/doctor.js +12 -4
  9. package/dist/commands/graph.d.ts +7 -0
  10. package/dist/commands/graph.js +51 -0
  11. package/dist/commands/init.js +3 -1
  12. package/dist/commands/memory.d.ts +6 -0
  13. package/dist/commands/memory.js +11 -0
  14. package/dist/commands/permissions.d.ts +8 -0
  15. package/dist/commands/permissions.js +18 -0
  16. package/dist/commands/session.d.ts +9 -0
  17. package/dist/commands/session.js +49 -0
  18. package/dist/commands/sprint.d.ts +7 -0
  19. package/dist/commands/sprint.js +54 -0
  20. package/dist/commands/start.js +4 -3
  21. package/dist/commands/sync.js +3 -0
  22. package/dist/commands/triage.js +2 -15
  23. package/dist/commands/validate.d.ts +6 -0
  24. package/dist/commands/validate.js +17 -0
  25. package/dist/core/agent-scaffold.d.ts +2 -0
  26. package/dist/core/agent-scaffold.js +57 -0
  27. package/dist/core/beads-mirror.d.ts +3 -0
  28. package/dist/core/beads-mirror.js +46 -0
  29. package/dist/core/memory.d.ts +1 -0
  30. package/dist/core/memory.js +47 -0
  31. package/dist/core/permission-auditor.d.ts +10 -0
  32. package/dist/core/permission-auditor.js +65 -0
  33. package/dist/core/permission-policy.d.ts +6 -0
  34. package/dist/core/permission-policy.js +93 -0
  35. package/dist/core/scaffold.js +35 -63
  36. package/dist/core/session-manager.d.ts +15 -0
  37. package/dist/core/session-manager.js +139 -0
  38. package/dist/core/skill-catalog.d.ts +3 -0
  39. package/dist/core/skill-catalog.js +180 -0
  40. package/dist/core/synced-stories.d.ts +8 -0
  41. package/dist/core/synced-stories.js +17 -0
  42. package/dist/core/templates.d.ts +2 -0
  43. package/dist/core/templates.js +54 -0
  44. package/dist/core/workflow-contract.d.ts +7 -0
  45. package/dist/core/workflow-contract.js +38 -0
  46. package/dist/core/workflow-validator.d.ts +6 -0
  47. package/dist/core/workflow-validator.js +133 -0
  48. package/docs/development-roadmap.md +9 -5
  49. package/docs/permission-rules-research.md +265 -0
  50. package/docs/product-contract.md +9 -4
  51. package/docs/project-changelog.md +46 -0
  52. package/docs/spec-enterprise-harness-plan.md +18 -1
  53. package/docs/use-cases.md +206 -0
  54. package/docs/workflow-model.md +23 -0
  55. package/package.json +1 -1
package/README.md CHANGED
@@ -4,15 +4,27 @@ Speckit is a local-first Agile + TDD workflow compiler for agentic IDEs. It turn
4
4
 
5
5
  Speckit owns the workflow contract and generates adapters for the tools you already use. The public product vocabulary is Speckit-only: Agile shaping, TDD execution, task graph triage, and IDE adapter compilation.
6
6
 
7
+ Speckit also ships a portable skill catalog and super-agent router. IDE-specific agents read `.speckit/agents/super-agent.md` and `.speckit/skills/catalog.md` first, then load only the focused skill needed for the current phase.
8
+
9
+ The curated skill set is intentionally small: `spec-shape`, `spec-research`, `spec-plan`, `spec-context`, `spec-graph`, `spec-session`, `spec-tdd`, `spec-test`, `spec-debug`, `spec-review`, `spec-docs`, and `spec-ship`. These are adapted from proven orchestration patterns without importing a broad domain-specific catalog.
10
+
7
11
  ## Quickstart
8
12
 
9
13
  ```bash
14
+ npx @trieungoctam/speckit@latest init --ide cursor
10
15
  npx @trieungoctam/speckit@latest init --ide all
11
16
  npx @trieungoctam/speckit@latest init --enterprise --ide all
17
+ npx @trieungoctam/speckit@latest memory refresh
18
+ npx @trieungoctam/speckit@latest session start "Add checkout validation"
12
19
  npx @trieungoctam/speckit@latest quick "Add checkout validation"
13
20
  npx @trieungoctam/speckit@latest context .speckit/stories/<story>.md
14
21
  npx @trieungoctam/speckit@latest sync
22
+ npx @trieungoctam/speckit@latest sprint plan
23
+ npx @trieungoctam/speckit@latest graph triage --json
24
+ npx @trieungoctam/speckit@latest validate --json
25
+ npx @trieungoctam/speckit@latest permissions audit --path .env --json
15
26
  npx @trieungoctam/speckit@latest ready .speckit/stories/<story>.md
27
+ npx @trieungoctam/speckit@latest session checkpoint --note "red complete"
16
28
  npx @trieungoctam/speckit@latest review
17
29
  ```
18
30
 
@@ -29,16 +41,22 @@ speckit doctor
29
41
  ```text
30
42
  intent
31
43
  -> start session
44
+ -> super agent routing
45
+ -> refresh project memory
32
46
  -> shape
33
47
  -> plan
48
+ -> sprint plan
34
49
  -> context
35
50
  -> story with acceptance criteria
36
- -> sync / triage
51
+ -> sync / graph triage
37
52
  -> readiness gate
38
53
  -> red test evidence
54
+ -> session checkpoint
39
55
  -> minimal implementation
40
56
  -> green test evidence
57
+ -> session checkpoint
41
58
  -> refactor validation
59
+ -> session compact
42
60
  -> review
43
61
  ```
44
62
 
@@ -48,19 +66,32 @@ For implementation stories, red-green-refactor evidence is mandatory. A story is
48
66
 
49
67
  | Command | Purpose |
50
68
  | --- | --- |
51
- | `speckit init` | Create `.speckit/` core rules and all IDE adapters. |
52
- | `speckit init --enterprise` | Add flow, tool policy, and prompt harness files. |
53
- | `speckit init --ide <name>` | Generate one adapter: `claude-code`, `codex`, `antigravity`, `opencode`, or `cursor`. |
69
+ | `speckit init` | Create `.speckit/` core runtime, super-agent, skill catalog, and all IDE adapters. |
70
+ | `speckit init --enterprise` | Add flow, tool policy, and prompt harness files on top of the shared runtime. |
71
+ | `speckit init --ide <name>` | Generate shared Speckit runtime plus one adapter: `claude-code`, `codex`, `antigravity`, `opencode`, or `cursor`. |
54
72
  | `speckit doctor` | Report required tools, optional integrations, test commands, and adapter readiness. |
55
- | `speckit doctor --deep` | Verify core enterprise harness files. |
73
+ | `speckit doctor --deep` | Verify core enterprise harness files and workflow contract checks. |
74
+ | `speckit validate` | Validate flow order, core skills, super-agent routing, prompts, and installed adapter contracts. |
56
75
  | `speckit start "<idea>"` | Create a durable session handoff and current context. |
76
+ | `speckit memory refresh` | Create durable project memory files for long-running agent work. |
77
+ | `speckit permissions audit` | Check a path or command against the Speckit permission policy. |
78
+ | `speckit session start` | Create or resume the active session state. |
79
+ | `speckit session checkpoint` | Append a long-session checkpoint and artifact log entry. |
80
+ | `speckit session compact` | Create an anchored summary for resume or handoff. |
81
+ | `speckit session resume` | Mark a session as active and print its handoff path. |
82
+ | `speckit session status` | Print active session state paths. |
57
83
  | `speckit shape "<intent>"` | Create a short spec contract. |
58
84
  | `speckit context <story>` | Build the current implementation context from a story. |
59
85
  | `speckit quick "<intent>"` | Create one story plus matching TDD evidence file. |
60
86
  | `speckit plan "<intent>"` | Create PRD, architecture, story, and evidence skeletons. |
61
87
  | `speckit triage` | Summarize synced story state without interactive graph commands. |
62
88
  | `speckit next` | Safely wraps `bv --robot-next --format json`. |
63
- | `speckit sync` | Export Speckit stories as beads-compatible JSONL metadata. |
89
+ | `speckit sprint plan` | Build a sprint plan and status file from synced stories. |
90
+ | `speckit sprint next` | Pick the next selectable story from sprint state. |
91
+ | `speckit graph triage` | Run Beads Viewer robot triage, or local JSON fallback if `bv` is missing. |
92
+ | `speckit graph plan` | Run Beads Viewer robot plan, or local JSON fallback if `bv` is missing. |
93
+ | `speckit graph insights` | Run Beads Viewer robot insights, or local JSON fallback if `bv` is missing. |
94
+ | `speckit sync` | Export Speckit stories as `.speckit/sync/beads-sync.jsonl` and prepare `.beads/beads.jsonl` for Beads Viewer. |
64
95
  | `speckit ready <story>` | Validate story status, context, evidence, graph sync, and safety policy before implementation. |
65
96
  | `speckit run <story>` | Print the TDD execution handoff for a story. |
66
97
  | `speckit review` | Print the review checklist and current diff summary. |
@@ -78,6 +109,12 @@ Speckit generates native instruction/config files for:
78
109
 
79
110
  See `docs/adapters.md` for exact output paths.
80
111
 
112
+ ## Guides
113
+
114
+ - `docs/use-cases.md` covers setup, migration, quick changes, full planning, long sessions, TDD, graph automation, review, CI, and troubleshooting.
115
+ - `docs/workflow-model.md` describes the quick and full workflow lanes.
116
+ - `docs/spec-quality-gates.md` describes validation gates for release readiness.
117
+
81
118
  ## Validation
82
119
 
83
120
  ```bash
@@ -12,12 +12,12 @@ export const antigravityAdapter = {
12
12
  ],
13
13
  render() {
14
14
  return [
15
- rule("agile", "Follow Speckit Agile: shape intent, read .speckit/context/current.md, create stories with ACs, preserve session handoff, and emit artifacts for review."),
16
- rule("tdd", "For code changes, use TDD: confirm acceptance criteria, use red-green-refactor, and record evidence for each step."),
15
+ rule("agile", "Follow Speckit Agile: shape intent, read .speckit/agents/super-agent.md, .speckit/skills/catalog.md, .speckit/memory/project-context.md, .speckit/sessions/active.md, and .speckit/context/current.md, create stories with ACs, preserve session handoff, and emit artifacts for review."),
16
+ rule("tdd", "For code changes, use TDD: confirm acceptance criteria, use red-green-refactor, checkpoint each boundary, compact before handoff, and record evidence for each step."),
17
17
  rule("enterprise-safety", "Require human approval for destructive commands, production changes, secrets access, and deployment."),
18
18
  workflow("plan", "Create a Speckit plan artifact with PRD, architecture, stories, risks, dependencies, and graph sync notes."),
19
- workflow("tdd-run", "Run a story with TDD from .speckit/context/current.md and .speckit/context/subagent-handoff.md. Require speckit ready <story> first. Emit artifact sections: Test Intent, Red, Green, Refactor. Use only robot-safe graph commands."),
20
- workflow("review", "Review the produced artifacts and code diff. Flag AC gaps, TDD gaps, security issues, docs needs, and session handoff gaps."),
19
+ workflow("tdd-run", "Run a story with TDD from the Speckit super agent router, skill catalog, .speckit/memory/project-context.md, .speckit/context/current.md, .speckit/context/subagent-handoff.md, and active session summary. Require speckit ready <story> first. Emit artifact sections: Test Intent, Red, Green, Refactor. Use only robot-safe graph commands."),
20
+ workflow("review", "Review the produced artifacts and code diff. Flag AC gaps, TDD gaps, security issues, docs needs, session checkpoint freshness, and session handoff gaps."),
21
21
  ];
22
22
  },
23
23
  };
@@ -1,5 +1,5 @@
1
1
  import { json, markdown } from "../core/managed-files.js";
2
- const skillIntro = `Follow Speckit: Agile story flow plus mandatory TDD evidence. Read .speckit/context/current.md first, preserve session handoff, use red-green-refactor, and use robot-safe graph commands only.`;
2
+ const skillIntro = `Follow Speckit: Agile story flow plus mandatory TDD evidence. Read .speckit/memory/project-context.md, .speckit/context/current.md, and active session summary first. Preserve session handoff, checkpoint long work, use red-green-refactor, and use robot-safe graph commands only.`;
3
3
  export const claudeCodeAdapter = {
4
4
  name: "claude-code",
5
5
  displayName: "Claude Code",
@@ -21,8 +21,10 @@ Use Speckit for Agile + TDD work.
21
21
  - Start from \`.speckit/rules/agile-policy.md\`.
22
22
  - For implementation, follow \`.speckit/rules/tdd-policy.md\`.
23
23
  - For safety, follow \`.speckit/rules/enterprise-safety.md\`.
24
- - Prefer \`speckit start\`, \`speckit context\`, \`speckit sync\`, \`speckit triage\`, \`speckit run\`, and \`speckit review\` over ad hoc prompts.
24
+ - Prefer \`speckit start\`, \`speckit memory refresh\`, \`speckit session checkpoint\`, \`speckit context\`, \`speckit sync\`, \`speckit graph triage\`, \`speckit run\`, and \`speckit review\` over ad hoc prompts.
25
+ - Read \`.speckit/agents/super-agent.md\`, \`.speckit/skills/catalog.md\`, \`.speckit/memory/project-context.md\`, and \`.speckit/sessions/active.md\` before long-running work.
25
26
  - Run \`speckit ready <story>\` before implementation; story status must be \`ready-for-dev\` and context status must be \`fresh\`.
27
+ - Run \`speckit session compact\` before context gets noisy or before handoff.
26
28
  - For code stories, confirm acceptance criteria and record red-green-refactor evidence before handoff.
27
29
  - Never run bare \`bv\`; use robot flags such as \`bv --robot-next --format json\`.
28
30
  `),
@@ -32,13 +34,29 @@ Use Speckit for Agile + TDD work.
32
34
  content: json({
33
35
  permissions: {
34
36
  defaultMode: "ask",
37
+ deny: [
38
+ "Read(.env*)",
39
+ "Read(**/*.pem)",
40
+ "Read(**/*.key)",
41
+ "Read(**/id_rsa)",
42
+ "Read(**/id_ed25519)",
43
+ "Write(.env*)",
44
+ "Write(**/*.pem)",
45
+ "Write(**/*.key)",
46
+ "Bash(rm -rf*)",
47
+ "Bash(git reset --hard*)",
48
+ "Bash(git clean -fd*)",
49
+ "Bash(git push --force*)",
50
+ "Bash(sudo *)",
51
+ ],
52
+ ask: ["Bash(git push*)", "Bash(npm publish*)", "Bash(* deploy*)"],
35
53
  },
36
54
  includeCoAuthoredBy: false,
37
55
  }),
38
56
  },
39
- skill("speckit-plan", "Create or update a Speckit Agile plan.", "Read `.speckit/workflows/shape.md`, preserve the session id, then create PRD, architecture, and story artifacts with acceptance criteria."),
40
- skill("speckit-tdd", "Execute a Speckit story with TDD.", "Read `.speckit/context/current.md`, `.speckit/context/subagent-handoff.md`, and `.speckit/workflows/tdd-run.md`. Do not implement before `speckit ready <story>` passes, test intent is clear, and red evidence is recorded."),
41
- skill("speckit-review", "Review a Speckit change.", "Read `.speckit/workflows/review.md`. Prioritize AC coverage, TDD evidence gaps, security, docs impact, and graph sync status."),
57
+ skill("speckit-plan", "Create or update a Speckit Agile plan.", "Read `.speckit/agents/super-agent.md`, `.speckit/skills/catalog.md`, and `.speckit/workflows/shape.md`, preserve the session id, then create PRD, architecture, and story artifacts with acceptance criteria."),
58
+ skill("speckit-tdd", "Execute a Speckit story with TDD.", "Read `.speckit/memory/project-context.md`, `.speckit/context/current.md`, `.speckit/context/subagent-handoff.md`, active session summary, and `.speckit/workflows/tdd-run.md`. Do not implement before `speckit ready <story>` passes, test intent is clear, and red evidence is recorded. Checkpoint after red, green, and refactor."),
59
+ skill("speckit-review", "Review a Speckit change.", "Read `.speckit/workflows/review.md` and the active session artifact log. Prioritize AC coverage, TDD evidence gaps, security, docs impact, session checkpoint freshness, and graph sync status."),
42
60
  ];
43
61
  },
44
62
  };
@@ -19,8 +19,10 @@ This repository uses Speckit: Agile + TDD for agentic development.
19
19
 
20
20
  Rules:
21
21
  - Shape intent before implementation.
22
+ - Read \`.speckit/agents/super-agent.md\`, \`.speckit/skills/catalog.md\`, \`.speckit/memory/project-context.md\`, and \`.speckit/sessions/active.md\` before long-running work.
22
23
  - Read \`.speckit/context/current.md\` before running code changes.
23
24
  - Run \`speckit ready <story>\` before implementation; story status must be \`ready-for-dev\` and context status must be \`fresh\`.
25
+ - Use \`speckit session checkpoint\` at red, green, refactor, and review boundaries; use \`speckit session compact\` before handoff.
24
26
  - For code stories, write test intent and capture red/green/refactor evidence.
25
27
  - Never call bare \`bv\`; use \`bv --robot-*\`.
26
28
  - Do not weaken approval or sandbox settings.
@@ -32,6 +34,8 @@ Rules:
32
34
  content: text(`model = "gpt-5.4"
33
35
  approval_policy = "on-request"
34
36
  sandbox_mode = "workspace-write"
37
+ allowed_approval_policies = ["untrusted", "on-request"]
38
+ allowed_sandbox_modes = ["read-only", "workspace-write"]
35
39
 
36
40
  [tools]
37
41
  web_search = true
@@ -39,9 +43,9 @@ web_search = true
39
43
  [features]
40
44
  child_agents_md = true`),
41
45
  },
42
- prompt("plan", "Create a Speckit plan from the user intent. Preserve session context, include PRD, architecture, stories, ACs, TDD checklist, risks, and graph sync notes."),
43
- prompt("tdd-run", "Execute the selected Speckit story using .speckit/context/current.md, .speckit/context/subagent-handoff.md, and red-green-refactor. Require speckit ready <story>, confirm ACs, record command evidence, and use only robot-safe graph commands."),
44
- prompt("review", "Review the current diff against Speckit ACs, TDD evidence, security, docs impact, session handoff, and graph sync status."),
46
+ prompt("plan", "Create a Speckit plan from the user intent. Use the Speckit super agent router and skill catalog. Preserve session context, project memory, PRD, architecture, stories, ACs, TDD checklist, risks, and graph sync notes."),
47
+ prompt("tdd-run", "Execute the selected Speckit story using .speckit/memory/project-context.md, .speckit/context/current.md, .speckit/context/subagent-handoff.md, active session summary, and red-green-refactor. Require speckit ready <story>, confirm ACs, checkpoint each boundary, record command evidence, and use only robot-safe graph commands."),
48
+ prompt("review", "Review the current diff against Speckit ACs, TDD evidence, security, docs impact, session handoff, session checkpoint freshness, and graph sync status."),
45
49
  ];
46
50
  },
47
51
  };
@@ -8,13 +8,14 @@ export const cursorAdapter = {
8
8
  ".cursor/rules/speckit-review.mdc",
9
9
  ".cursor/rules/speckit-enterprise-safety.mdc",
10
10
  ".cursor/mcp.json",
11
+ ".cursor/cli.json",
11
12
  "AGENTS.md",
12
13
  ],
13
14
  render() {
14
15
  return [
15
- rule("agile", "alwaysApply: true", "Use Speckit Agile flow. Read .speckit/context/current.md and .speckit/context/subagent-handoff.md, preserve session handoff, create stories with ACs, and keep work scoped."),
16
- rule("tdd", "description: Apply when implementing or modifying code", "Use red-green-refactor. Run speckit ready <story>, confirm acceptance criteria, and record TDD evidence before review-ready."),
17
- rule("review", "description: Apply when reviewing code or preparing a PR", "Review AC coverage, TDD evidence, security, docs impact, and graph sync status."),
16
+ rule("agile", "alwaysApply: true", "Use Speckit Agile flow. Read .speckit/agents/super-agent.md, .speckit/skills/catalog.md, .speckit/memory/project-context.md, .speckit/sessions/active.md, .speckit/context/current.md, and .speckit/context/subagent-handoff.md. Preserve session handoff, create stories with ACs, and keep work scoped."),
17
+ rule("tdd", "description: Apply when implementing or modifying code", "Use red-green-refactor. Run speckit ready <story>, confirm acceptance criteria, checkpoint each TDD boundary, and record TDD evidence before review-ready."),
18
+ rule("review", "description: Apply when reviewing code or preparing a PR", "Review AC coverage, TDD evidence, security, docs impact, session checkpoint freshness, and graph sync status."),
18
19
  rule("enterprise-safety", "alwaysApply: true", "Do not expose secrets. Ask before destructive commands, deployment, or production changes."),
19
20
  {
20
21
  path: ".cursor/mcp.json",
@@ -22,6 +23,28 @@ export const cursorAdapter = {
22
23
  mcpServers: {},
23
24
  }),
24
25
  },
26
+ {
27
+ path: ".cursor/cli.json",
28
+ content: json({
29
+ permissions: {
30
+ allow: ["Shell(git)", "Shell(npm)", "Shell(node)", "Read(.speckit/**)", "Read(src/**)", "Read(tests/**)"],
31
+ deny: [
32
+ "Read(.env*)",
33
+ "Read(**/*.pem)",
34
+ "Read(**/*.key)",
35
+ "Read(**/id_rsa)",
36
+ "Read(**/id_ed25519)",
37
+ "Write(.env*)",
38
+ "Write(**/*.pem)",
39
+ "Write(**/*.key)",
40
+ "Shell(rm)",
41
+ "Shell(sudo)",
42
+ "Shell(chmod)",
43
+ "Shell(chown)",
44
+ ],
45
+ },
46
+ }),
47
+ },
25
48
  {
26
49
  path: "AGENTS.md",
27
50
  content: markdown(`# Speckit Agent Instructions
@@ -30,9 +53,13 @@ Use Speckit for Agile + TDD work. Cursor-specific rules live in \`.cursor/rules/
30
53
 
31
54
  - Follow \`.speckit/rules/agile-policy.md\`.
32
55
  - Follow \`.speckit/rules/tdd-policy.md\` for code stories.
56
+ - Read \`.speckit/agents/super-agent.md\` and \`.speckit/skills/catalog.md\` before selecting an execution mode.
57
+ - Read \`.speckit/memory/project-context.md\` before long-running work.
58
+ - Read \`.speckit/sessions/active.md\` before resuming or compacting work.
33
59
  - Read \`.speckit/context/current.md\` before implementation work.
34
60
  - Read \`.speckit/context/subagent-handoff.md\` before implementation work.
35
61
  - Run \`speckit ready <story>\` before code changes.
62
+ - Run \`speckit session checkpoint\` at task boundaries and \`speckit session compact\` before handoff.
36
63
  - Never run bare \`bv\`; use robot commands only.
37
64
  `),
38
65
  },
@@ -53,7 +53,7 @@ permission: ${JSON.stringify(permission)}
53
53
  # speckit-${name}
54
54
 
55
55
  Follow \`.speckit/rules/agile-policy.md\`, \`.speckit/rules/tdd-policy.md\`, and \`.speckit/rules/enterprise-safety.md\`.
56
- Read \`.speckit/context/current.md\` and \`.speckit/context/subagent-handoff.md\` before implementation work, require \`speckit ready <story>\`, confirm acceptance criteria, preserve session handoff, record red-green-refactor evidence, and use only robot-safe graph commands.
56
+ Read \`.speckit/agents/super-agent.md\`, \`.speckit/skills/catalog.md\`, \`.speckit/memory/project-context.md\`, \`.speckit/sessions/active.md\`, \`.speckit/context/current.md\`, and \`.speckit/context/subagent-handoff.md\` before implementation work. Select the smallest matching Speckit skill. Require \`speckit ready <story>\`, confirm acceptance criteria, preserve session handoff, checkpoint red-green-refactor boundaries, compact before handoff, and use only robot-safe graph commands.
57
57
  `),
58
58
  };
59
59
  }
package/dist/cli.js CHANGED
@@ -5,6 +5,12 @@ import { shapeCommand } from "./commands/shape.js";
5
5
  import { contextCommand } from "./commands/context.js";
6
6
  import { quickCommand } from "./commands/quick.js";
7
7
  import { planCommand } from "./commands/plan.js";
8
+ import { memoryCommand } from "./commands/memory.js";
9
+ import { permissionsCommand } from "./commands/permissions.js";
10
+ import { sessionCommand } from "./commands/session.js";
11
+ import { sprintCommand } from "./commands/sprint.js";
12
+ import { graphCommand } from "./commands/graph.js";
13
+ import { validateCommand } from "./commands/validate.js";
8
14
  import { triageCommand } from "./commands/triage.js";
9
15
  import { nextCommand } from "./commands/next.js";
10
16
  import { syncCommand } from "./commands/sync.js";
@@ -35,6 +41,29 @@ export async function main(argv = process.argv.slice(2), root = process.cwd()) {
35
41
  return quickCommand({ root, intent: requiredIntent(parsed) });
36
42
  case "plan":
37
43
  return planCommand({ root, intent: requiredIntent(parsed) });
44
+ case "memory":
45
+ return memoryCommand({ root, action: requiredAction(parsed) });
46
+ case "permissions":
47
+ return permissionsCommand({
48
+ action: requiredAction(parsed),
49
+ path: value(parsed, "path"),
50
+ command: value(parsed, "command"),
51
+ json: has(parsed, "json"),
52
+ });
53
+ case "session":
54
+ return sessionCommand({
55
+ root,
56
+ action: requiredAction(parsed),
57
+ target: parsed.args.slice(1).join(" ").trim() || undefined,
58
+ note: value(parsed, "note"),
59
+ json: has(parsed, "json"),
60
+ });
61
+ case "sprint":
62
+ return sprintCommand({ root, action: requiredAction(parsed), json: has(parsed, "json") });
63
+ case "graph":
64
+ return graphCommand({ root, action: requiredAction(parsed), json: has(parsed, "json") });
65
+ case "validate":
66
+ return validateCommand({ root, json: has(parsed, "json") });
38
67
  case "triage":
39
68
  return triageCommand({ root, json: has(parsed, "json") });
40
69
  case "next":
@@ -92,6 +121,12 @@ function requiredIntent(parsed) {
92
121
  throw new Error(`Command "${parsed.command}" requires a target or intent.`);
93
122
  return intent;
94
123
  }
124
+ function requiredAction(parsed) {
125
+ const action = parsed.args[0]?.trim();
126
+ if (!action)
127
+ throw new Error(`Command "${parsed.command}" requires an action.`);
128
+ return action;
129
+ }
95
130
  function value(parsed, name) {
96
131
  const found = parsed.flags.get(name);
97
132
  return typeof found === "string" ? found : undefined;
@@ -111,6 +146,12 @@ Usage:
111
146
  speckit context <story-path-or-id>
112
147
  speckit quick "<intent>"
113
148
  speckit plan "<intent>"
149
+ speckit memory refresh
150
+ speckit permissions audit [--path <path>] [--command <command>] [--json]
151
+ speckit session start|checkpoint|compact|resume|status [target] [--note "..."] [--json]
152
+ speckit sprint plan|next [--json]
153
+ speckit graph triage|plan|insights [--json]
154
+ speckit validate [--json]
114
155
  speckit triage [--json]
115
156
  speckit next
116
157
  speckit sync
@@ -4,11 +4,14 @@ import { getAdapters } from "../config/adapter-registry.js";
4
4
  import { checkTools } from "../adapters/tool-checks.js";
5
5
  import { detectTestCommands } from "../core/test-detection.js";
6
6
  import { coreFiles, enterpriseFiles } from "../core/scaffold.js";
7
+ import { agentFiles } from "../core/agent-scaffold.js";
8
+ import { validateWorkflowContract } from "../core/workflow-validator.js";
7
9
  export async function doctorCommand(options) {
8
10
  const stdout = options.stdout ?? console;
9
11
  const tools = checkTools();
10
12
  const tests = await detectTestCommands(options.root);
11
13
  const deepChecks = options.deep ? await runDeepChecks(options.root) : [];
14
+ const contractChecks = options.deep ? await validateWorkflowContract(options.root) : [];
12
15
  const adapters = await Promise.all(getAdapters("all").map(async (adapter) => ({
13
16
  name: adapter.name,
14
17
  ...(await adapterStatus(options.root, adapter.outputPaths)),
@@ -18,8 +21,9 @@ export async function doctorCommand(options) {
18
21
  tools,
19
22
  tests,
20
23
  deepChecks,
24
+ contractChecks,
21
25
  adapters,
22
- status: statusFor(tools, deepChecks),
26
+ status: statusFor(tools, deepChecks, contractChecks),
23
27
  };
24
28
  if (options.json) {
25
29
  stdout.log(JSON.stringify(report, null, 2));
@@ -32,6 +36,9 @@ export async function doctorCommand(options) {
32
36
  for (const check of deepChecks) {
33
37
  stdout.log(`Deep ${check.name}: ${check.ok ? "ok" : "missing"}`);
34
38
  }
39
+ for (const check of contractChecks) {
40
+ stdout.log(`Contract ${check.name}: ${check.ok ? "ok" : check.detail}`);
41
+ }
35
42
  for (const adapter of adapters) {
36
43
  stdout.log(`Adapter ${adapter.name}: ${adapter.present}/${adapter.total} files present`);
37
44
  }
@@ -39,7 +46,7 @@ export async function doctorCommand(options) {
39
46
  return report.status === "ok" ? 0 : 1;
40
47
  }
41
48
  async function runDeepChecks(root) {
42
- const requiredFiles = [...coreFiles(), ...enterpriseFiles()];
49
+ const requiredFiles = [...coreFiles(), ...enterpriseFiles(), ...agentFiles()];
43
50
  return Promise.all(requiredFiles.map(async (file) => ({
44
51
  name: file.path,
45
52
  path: file.path,
@@ -55,10 +62,11 @@ async function fileExists(root, path) {
55
62
  return false;
56
63
  }
57
64
  }
58
- function statusFor(tools, deepChecks) {
65
+ function statusFor(tools, deepChecks, contractChecks) {
59
66
  const requiredToolsMissing = tools.some((tool) => tool.required && !tool.available);
60
67
  const deepChecksMissing = deepChecks.some((check) => !check.ok);
61
- return requiredToolsMissing || deepChecksMissing ? "needs-attention" : "ok";
68
+ const contractChecksFailed = contractChecks.some((check) => !check.ok);
69
+ return requiredToolsMissing || deepChecksMissing || contractChecksFailed ? "needs-attention" : "ok";
62
70
  }
63
71
  async function adapterStatus(root, paths) {
64
72
  const missing = [];
@@ -0,0 +1,7 @@
1
+ export type GraphOptions = {
2
+ root: string;
3
+ action: string;
4
+ json?: boolean;
5
+ stdout?: Pick<typeof console, "log" | "error">;
6
+ };
7
+ export declare function graphCommand(options: GraphOptions): Promise<number>;
@@ -0,0 +1,51 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { commandExists } from "../adapters/tool-checks.js";
3
+ import { prepareBeadsMirror } from "../core/beads-mirror.js";
4
+ import { readSyncedStories, selectableStories } from "../core/synced-stories.js";
5
+ const robotActions = new Map([
6
+ ["triage", "--robot-triage"],
7
+ ["plan", "--robot-plan"],
8
+ ["insights", "--robot-insights"],
9
+ ]);
10
+ export async function graphCommand(options) {
11
+ const stdout = options.stdout ?? console;
12
+ const robotFlag = robotActions.get(options.action);
13
+ if (!robotFlag) {
14
+ stdout.error("Usage: speckit graph triage|plan|insights [--json]");
15
+ return 1;
16
+ }
17
+ if (commandExists("bv")) {
18
+ await prepareBeadsMirror(options.root);
19
+ const result = spawnSync("bv", [robotFlag, "--format", options.json ? "json" : "toon"], {
20
+ encoding: "utf8",
21
+ cwd: options.root,
22
+ });
23
+ if ((result.status ?? 1) === 0) {
24
+ if (result.stdout)
25
+ stdout.log(result.stdout.trim());
26
+ if (result.stderr)
27
+ stdout.error(result.stderr.trim());
28
+ return 0;
29
+ }
30
+ }
31
+ const fallback = await localGraphFallback(options.root, options.action);
32
+ stdout.log(JSON.stringify(fallback, null, 2));
33
+ return 0;
34
+ }
35
+ async function localGraphFallback(root, action) {
36
+ const stories = await readSyncedStories(root);
37
+ const selectable = selectableStories(stories);
38
+ return {
39
+ source: ".speckit/sync/beads-sync.jsonl",
40
+ provider: "speckit-local-fallback",
41
+ action,
42
+ status: "bv-unavailable-or-failed",
43
+ quick_ref: {
44
+ total: stories.length,
45
+ selectable: selectable.length,
46
+ top_pick: selectable[0] ?? null,
47
+ },
48
+ recommendations: selectable.slice(0, 3),
49
+ command: "Install Beads Viewer for graph metrics: bv --robot-triage --format json",
50
+ };
51
+ }
@@ -1,10 +1,12 @@
1
1
  import { coreFiles, enterpriseFiles } from "../core/scaffold.js";
2
+ import { agentFiles } from "../core/agent-scaffold.js";
2
3
  import { writeManagedFiles } from "../core/managed-files.js";
3
4
  import { getAdapters } from "../config/adapter-registry.js";
4
5
  export async function initCommand(options) {
5
6
  const stdout = options.stdout ?? console;
6
7
  const selectedIde = options.ide ?? "all";
7
- const baseFiles = options.enterprise ? [...coreFiles(), ...enterpriseFiles()] : coreFiles();
8
+ const sharedFiles = [...coreFiles(), ...agentFiles()];
9
+ const baseFiles = options.enterprise ? [...sharedFiles, ...enterpriseFiles()] : sharedFiles;
8
10
  const adapterFiles = getAdapters(selectedIde).flatMap((adapter) => adapter.render());
9
11
  const results = await writeManagedFiles(options.root, [...baseFiles, ...adapterFiles], options.force ?? false);
10
12
  const created = results.filter((result) => result.status === "created").length;
@@ -0,0 +1,6 @@
1
+ export type MemoryOptions = {
2
+ root: string;
3
+ action: string;
4
+ stdout?: Pick<typeof console, "log" | "error">;
5
+ };
6
+ export declare function memoryCommand(options: MemoryOptions): Promise<number>;
@@ -0,0 +1,11 @@
1
+ import { refreshMemory } from "../core/memory.js";
2
+ export async function memoryCommand(options) {
3
+ const stdout = options.stdout ?? console;
4
+ if (options.action !== "refresh") {
5
+ stdout.error("Usage: speckit memory refresh");
6
+ return 1;
7
+ }
8
+ const files = await refreshMemory(options.root);
9
+ stdout.log(`Refreshed Speckit memory: ${files.join(", ")}`);
10
+ return 0;
11
+ }
@@ -0,0 +1,8 @@
1
+ export type PermissionsOptions = {
2
+ action: string;
3
+ path?: string;
4
+ command?: string;
5
+ json?: boolean;
6
+ stdout?: Pick<typeof console, "log" | "error">;
7
+ };
8
+ export declare function permissionsCommand(options: PermissionsOptions): Promise<number>;
@@ -0,0 +1,18 @@
1
+ import { auditPermission } from "../core/permission-auditor.js";
2
+ export async function permissionsCommand(options) {
3
+ const stdout = options.stdout ?? console;
4
+ if (options.action !== "audit") {
5
+ stdout.error?.(`Unknown permissions action: ${options.action}`);
6
+ return 1;
7
+ }
8
+ const result = auditPermission({ path: options.path, command: options.command });
9
+ if (options.json) {
10
+ stdout.log(JSON.stringify(result, null, 2));
11
+ }
12
+ else {
13
+ stdout.log(`Speckit permission audit: ${result.status}`);
14
+ for (const reason of result.reasons)
15
+ stdout.log(`- ${reason}`);
16
+ }
17
+ return result.status === "deny" ? 1 : 0;
18
+ }
@@ -0,0 +1,9 @@
1
+ export type SessionOptions = {
2
+ root: string;
3
+ action: string;
4
+ target?: string;
5
+ note?: string;
6
+ json?: boolean;
7
+ stdout?: Pick<typeof console, "log" | "error">;
8
+ };
9
+ export declare function sessionCommand(options: SessionOptions): Promise<number>;
@@ -0,0 +1,49 @@
1
+ import { checkpointSession, compactSession, ensureSession, resumeSession, sessionStatus, } from "../core/session-manager.js";
2
+ export async function sessionCommand(options) {
3
+ const stdout = options.stdout ?? console;
4
+ switch (options.action) {
5
+ case "start": {
6
+ const session = await ensureSession(options.root, options.note ?? options.target ?? "long session");
7
+ stdout.log(session.id);
8
+ stdout.log(`${session.dir}/handoff.md`);
9
+ return 0;
10
+ }
11
+ case "checkpoint": {
12
+ const session = await checkpointSession({
13
+ root: options.root,
14
+ note: options.note ?? options.target,
15
+ story: options.target,
16
+ });
17
+ stdout.log(`Checkpointed ${session.id}`);
18
+ return 0;
19
+ }
20
+ case "compact": {
21
+ const session = await compactSession(options.root);
22
+ stdout.log(`${session.dir}/summary.md`);
23
+ return 0;
24
+ }
25
+ case "resume": {
26
+ const session = await resumeSession(options.root, options.target);
27
+ if (!session) {
28
+ stdout.error("No Speckit session to resume.");
29
+ return 1;
30
+ }
31
+ stdout.log(session.id);
32
+ stdout.log(`${session.dir}/handoff.md`);
33
+ return 0;
34
+ }
35
+ case "status": {
36
+ const status = await sessionStatus(options.root);
37
+ stdout.log(options.json ? JSON.stringify(status, null, 2) : renderStatus(status));
38
+ return status.status === "missing" ? 1 : 0;
39
+ }
40
+ default:
41
+ stdout.error("Usage: speckit session start|checkpoint|compact|resume|status");
42
+ return 1;
43
+ }
44
+ }
45
+ function renderStatus(status) {
46
+ if (status.status === "missing")
47
+ return "Spec session: missing";
48
+ return `Spec session: ${status.id}\nState: ${status.state}\nSummary: ${status.summary}\nHandoff: ${status.handoff}`;
49
+ }
@@ -0,0 +1,7 @@
1
+ export type SprintOptions = {
2
+ root: string;
3
+ action: string;
4
+ json?: boolean;
5
+ stdout?: Pick<typeof console, "log" | "error">;
6
+ };
7
+ export declare function sprintCommand(options: SprintOptions): Promise<number>;