@planu/cli 5.7.22 → 5.7.23

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 (40) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/.planu-build.json +1 -1
  3. package/dist/cli/commands/release.js +23 -10
  4. package/dist/config/registries/error-recovery.json +18 -18
  5. package/dist/config/registries/legacy-guidance.json +33 -1
  6. package/dist/config/server-instructions.js +16 -20
  7. package/dist/config/skill-templates/planu-release.md +3 -3
  8. package/dist/config/token-waste-autopilot.json +1 -1
  9. package/dist/engine/errors/registry-loader.js +3 -2
  10. package/dist/engine/evidence-gates/artifact-reader.d.ts +78 -0
  11. package/dist/engine/evidence-gates/artifact-reader.js +19 -7
  12. package/dist/engine/health/auto-fixer.js +2 -2
  13. package/dist/engine/telemetry/health-checker.js +1 -1
  14. package/dist/engine/validation-evidence-ledger.d.ts +1 -0
  15. package/dist/engine/validation-evidence-ledger.js +44 -3
  16. package/dist/hosts/codex/config-scaffold.js +1 -1
  17. package/dist/hosts/gemini/config-scaffold.js +1 -1
  18. package/dist/storage/spec-index.js +8 -3
  19. package/dist/tools/create-spec/post-creation.d.ts +1 -1
  20. package/dist/tools/create-spec/post-creation.js +7 -49
  21. package/dist/tools/create-spec.js +1 -1
  22. package/dist/tools/facilitate.js +6 -6
  23. package/dist/tools/init-project/result-builder.js +4 -4
  24. package/dist/tools/safe-handler.js +1 -1
  25. package/dist/tools/status-handler.js +1 -1
  26. package/dist/tools/tool-registry/core-tools.js +3 -1
  27. package/dist/tools/update-status/evidence-payload.d.ts +180 -0
  28. package/dist/tools/update-status/evidence-payload.js +76 -0
  29. package/dist/tools/update-status/index.js +30 -0
  30. package/dist/tools/validate.js +1 -1
  31. package/dist/types/evidence-gates.d.ts +9 -0
  32. package/dist/types/lifecycle.d.ts +1 -10
  33. package/dist/types/spec/inputs.d.ts +2 -1
  34. package/package.json +1 -1
  35. package/planu-plugin.json +14 -4
  36. package/src/i18n/messages/en.json +2 -2
  37. package/src/i18n/messages/es.json +2 -2
  38. package/src/i18n/messages/pt.json +2 -2
  39. package/dist/engine/detectors/cicd-detector.d.ts +0 -7
  40. package/dist/engine/detectors/cicd-detector.js +0 -170
package/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ ## [5.7.23] - 2026-09-09
2
+
3
+ ### Bug Fixes
4
+ - fix(update-status): keep the evidence transport contract under the tools/list compactor budget
5
+ - fix(update-status): stop leaking internal artifact constraints in the evidence input schema
6
+ - fix(tool-registry): drop retired tool names from the registry and i18n descriptions
7
+ - fix(storage): report and resolve duplicate spec ids deterministically
8
+ - fix(evidence-gates): require a non-empty capability in receipt identities and simplify the test cast
9
+ - fix(evidence-gates): compare repository identity fields, not the full key, for command evidence
10
+ - fix(evidence-gates): split ledger receipt check and export readPassedValidationReceipt
11
+ - fix(scripts): fail local smoke when the server is killed by the timeout (SPEC-1827 B5)
12
+ - fix(cli): treat develop and release as optional mirrors in release check (SPEC-1827 B4)
13
+ - fix(config): name the host fallback for AskUserQuestion (SPEC-1827 B3)
14
+ - fix(tools): persist evidence payload through update_status (SPEC-1827 B1)
15
+ - fix(errors): resolve error-recovery registry from installed package (SPEC-1827 B2)
16
+ - fix(config): mirror the Gemini bullet and plugin manifest to real registries (SPEC-1826 G/H)
17
+ - fix(tools): rewrite nine runtime hints to name official tools (SPEC-1826 F)
18
+ - fix(config): point error-recovery rules at official tools (SPEC-1826 E)
19
+ - fix(config): describe the real git flow and approval gates (SPEC-1826 D)
20
+ - fix(tools): route facilitate and post-creation hints to official tools (SPEC-1826 B/C)
21
+
22
+ ### Chores
23
+ - chore(planu): remove the re-created historical duplicate SPEC-766 folder
24
+
25
+
1
26
  ## [5.7.22] - 2026-09-09
2
27
 
3
28
  ### Features
@@ -1 +1 @@
1
- {"schemaVersion":1,"commit":"7da5da1293b997c72492696106fd3eb613196ce9"}
1
+ {"schemaVersion":1,"commit":"ce91ee7289dc55598ba5d20c4d6e63ce410a0fd1"}
@@ -3,7 +3,8 @@ import { execFile } from 'node:child_process';
3
3
  import { promisify } from 'node:util';
4
4
  import { green, red, yellow } from '../colors.js';
5
5
  const execFileAsync = promisify(execFile);
6
- const RELEASE_BRANCHES = ['main', 'develop', 'release'];
6
+ const CANONICAL_BRANCH = 'main';
7
+ const MIRROR_BRANCHES = ['develop', 'release'];
7
8
  export const releaseCommand = {
8
9
  name: 'release',
9
10
  description: 'Check lightweight release readiness',
@@ -39,16 +40,26 @@ async function checkReleaseReadiness(cwd) {
39
40
  }
40
41
  const head = (await git(cwd, ['rev-parse', 'HEAD'])).trim() || null;
41
42
  const branches = {};
42
- for (const branch of RELEASE_BRANCHES) {
43
- branches[branch] = await resolveRef(cwd, branch);
43
+ branches[CANONICAL_BRANCH] = await resolveRef(cwd, CANONICAL_BRANCH);
44
+ for (const mirror of MIRROR_BRANCHES) {
45
+ branches[mirror] = await resolveRef(cwd, mirror);
44
46
  }
45
- const branchValues = Object.values(branches);
46
- const synced = head !== null &&
47
- branchValues.every((value) => value !== null) &&
48
- branchValues.every((value) => value === head);
49
- if (!synced) {
50
- problems.push('main, develop, and release are not all synced to HEAD');
47
+ const mainRef = branches[CANONICAL_BRANCH];
48
+ if (mainRef === null) {
49
+ problems.push('main branch not found');
50
+ }
51
+ else if (mainRef !== head) {
52
+ problems.push('main is not at HEAD');
51
53
  }
54
+ for (const mirror of MIRROR_BRANCHES) {
55
+ const ref = branches[mirror];
56
+ if (ref !== null && ref !== head) {
57
+ problems.push(`${mirror} mirror is not at HEAD`);
58
+ }
59
+ }
60
+ const synced = head !== null &&
61
+ mainRef === head &&
62
+ MIRROR_BRANCHES.every((mirror) => branches[mirror] === null || branches[mirror] === head);
52
63
  return { clean, synced, head, branches, problems };
53
64
  }
54
65
  async function resolveRef(cwd, branch) {
@@ -76,7 +87,9 @@ async function git(cwd, args) {
76
87
  }
77
88
  function writeReleaseCheck(result) {
78
89
  if (result.clean && result.synced) {
79
- process.stdout.write(`${green('Release ready.')} main, develop, and release match HEAD.\n`);
90
+ const resolvedMirrors = MIRROR_BRANCHES.filter((mirror) => result.branches[mirror] !== null);
91
+ const mirrors = resolvedMirrors.length === 0 ? '' : ` with mirrors ${resolvedMirrors.join(', ')}`;
92
+ process.stdout.write(`${green('Release ready.')} main matches HEAD${mirrors}.\n`);
80
93
  return;
81
94
  }
82
95
  process.stdout.write(`${yellow('Release not ready.')}\n`);
@@ -19,9 +19,9 @@
19
19
  "what": "Permission denied",
20
20
  "why": "Planu cannot read or write the requested path.",
21
21
  "nextAction": {
22
- "tool": "workspace_alerts",
22
+ "tool": "planu_status",
23
23
  "args": {},
24
- "rationale": "Check workspace permissions before retrying."
24
+ "rationale": "No Planu tool can change filesystem permissions: fix them in the shell, then call planu_status with projectPath to confirm the project loads before retrying."
25
25
  }
26
26
  },
27
27
  {
@@ -30,9 +30,9 @@
30
30
  "what": "Resource temporarily unavailable",
31
31
  "why": "The file or socket is busy. This is usually transient.",
32
32
  "nextAction": {
33
- "tool": "workspace_alerts",
33
+ "tool": "planu_status",
34
34
  "args": {},
35
- "rationale": "Retry the operation — the resource should free up shortly."
35
+ "rationale": "The resource is temporarily busy: wait a moment, call planu_status with projectPath to confirm the project still loads, then retry the original call."
36
36
  }
37
37
  },
38
38
  {
@@ -41,9 +41,9 @@
41
41
  "what": "Connection refused",
42
42
  "why": "The remote service is not accepting connections.",
43
43
  "nextAction": {
44
- "tool": "verify_integrations",
44
+ "tool": "planu_status",
45
45
  "args": {},
46
- "rationale": "Check that the target service is running and reachable."
46
+ "rationale": "No Planu tool can start an external service: start it, then call planu_status with projectPath to confirm the project loads before retrying the integration."
47
47
  }
48
48
  },
49
49
  {
@@ -52,9 +52,9 @@
52
52
  "what": "Operation timed out",
53
53
  "why": "The request exceeded the allowed execution time.",
54
54
  "nextAction": {
55
- "tool": "workspace_alerts",
55
+ "tool": "get_job",
56
56
  "args": {},
57
- "rationale": "The operation may complete if retried. Check network connectivity."
57
+ "rationale": "If the timed-out call returned an operationId, poll it with get_job (operationId plus projectPath) instead of re-issuing the call; otherwise retry once."
58
58
  }
59
59
  },
60
60
  {
@@ -63,9 +63,9 @@
63
63
  "what": "Resource is locked",
64
64
  "why": "Another session or agent holds a lock on this spec.",
65
65
  "nextAction": {
66
- "tool": "list_locks",
66
+ "tool": "planu_status",
67
67
  "args": {},
68
- "rationale": "List active locks and wait for them to be released."
68
+ "rationale": "Another session holds the lock: call planu_status with projectPath to see the active spec, then wait or coordinate before retrying."
69
69
  }
70
70
  },
71
71
  {
@@ -74,9 +74,9 @@
74
74
  "what": "Version conflict detected",
75
75
  "why": "The spec version in your request does not match the current version.",
76
76
  "nextAction": {
77
- "tool": "sync_spec_state",
77
+ "tool": "list_specs",
78
78
  "args": {},
79
- "rationale": "Sync spec state to resolve the version mismatch."
79
+ "rationale": "Reload the specs from disk with list_specs and repeat the request against the state it returns."
80
80
  }
81
81
  },
82
82
  {
@@ -85,9 +85,9 @@
85
85
  "what": "Schema validation failed",
86
86
  "why": "The provided data does not conform to the expected schema.",
87
87
  "nextAction": {
88
- "tool": "workspace_alerts",
88
+ "tool": "facilitate",
89
89
  "args": {},
90
- "rationale": "Review the input data against the schema documentation."
90
+ "rationale": "Call facilitate with description set to what you were trying to do: it recommends which Planu tool fits the request."
91
91
  }
92
92
  },
93
93
  {
@@ -95,9 +95,9 @@
95
95
  "match": { "code": "RUNTIME_SCHEMA_AHEAD" },
96
96
  "what": "Runtime store schema is newer than this server supports",
97
97
  "nextAction": {
98
- "tool": "inspect",
98
+ "tool": "planu_status",
99
99
  "args": {},
100
- "rationale": "Restart the MCP server so it loads the current dist; a newer Planu migrated the local store."
100
+ "rationale": "Restart the MCP server so it loads the current dist, then call planu_status with projectPath to confirm it answers before retrying."
101
101
  }
102
102
  },
103
103
  {
@@ -105,9 +105,9 @@
105
105
  "match": { "code": "LOCK_SCHEMA_AHEAD" },
106
106
  "what": "Lock store schema is newer than this server supports",
107
107
  "nextAction": {
108
- "tool": "inspect",
108
+ "tool": "planu_status",
109
109
  "args": {},
110
- "rationale": "Restart the MCP server so it loads the current dist; a newer Planu migrated the local store."
110
+ "rationale": "Restart the MCP server so it loads the current dist, then call planu_status with projectPath to confirm it answers before retrying."
111
111
  }
112
112
  }
113
113
  ]
@@ -81,6 +81,38 @@
81
81
  "generate_orchestration_plan",
82
82
  "capture_idea",
83
83
  "log_lesson",
84
- "security_scan"
84
+ "security_scan",
85
+ "ai_ecosystem_status",
86
+ "apply_template",
87
+ "branch_spec",
88
+ "configure_telemetry",
89
+ "define_ui_contract",
90
+ "delete_spec",
91
+ "design_schema",
92
+ "detect_contradictions",
93
+ "detect_drift",
94
+ "federate_specs",
95
+ "federation_status",
96
+ "generate_adr",
97
+ "generate_checklist",
98
+ "generate_docs",
99
+ "generate_execution_plan",
100
+ "generate_planu_ci",
101
+ "inject_component_context",
102
+ "list_locks",
103
+ "manage_git",
104
+ "merge_spec_branch",
105
+ "reality_check",
106
+ "scan_project",
107
+ "search_specs",
108
+ "security_check",
109
+ "session_handoff",
110
+ "set_locale",
111
+ "skill_install",
112
+ "sync_ai_configs",
113
+ "sync_spec_state",
114
+ "verify_integrations",
115
+ "verify_versions",
116
+ "workspace_alerts"
85
117
  ]
86
118
  }
@@ -58,34 +58,30 @@ export const SERVER_INSTRUCTIONS = [
58
58
  '',
59
59
  'INTERACTIVE QUESTIONS — HARD GATE enforcement (SPEC-584):',
60
60
  'GENERAL RULE: Whenever you would ask the user ANY question — follow-up after a tool call, clarification,',
61
- '"what do you want to do next?", or any decision — you MUST use AskUserQuestion. NEVER write a question',
62
- 'as plain text. No exceptions.',
61
+ '"what do you want to do next?", or any decision — you MUST present it as a structured choice with 2-4 options.',
62
+ 'In Claude Code that means AskUserQuestion. In hosts without AskUserQuestion (Codex, Gemini CLI, Cursor,',
63
+ 'Windsurf) present the same options as a numbered list, mark the recommended one, and wait for the answer',
64
+ 'before any other action. NEVER write an open-ended question as plain prose.',
63
65
  'When ANY tool response includes structuredContent.interactiveQuestions[]:',
64
- '- You MUST call AskUserQuestion immediately — NEVER output the question as plain text.',
65
- '- Map each interactiveQuestion to AskUserQuestion: use question as the prompt, options[].label as choices.',
66
- '- Do NOT summarize or paraphrase the question. Relay it verbatim via AskUserQuestion.',
66
+ '- Relay it immediately through AskUserQuestion, or the numbered-list fallback in hosts without it.',
67
+ '- Map each interactiveQuestion to the prompt: use question as the prompt, options[].label as the choices.',
68
+ '- Do NOT summarize or paraphrase the question. Relay it verbatim.',
67
69
  '- Do NOT continue with any other action until the user answers.',
68
70
  '- After the user answers, retry the same tool with clarificationAnswers: { <questionKey>: <selectedLabel>, ... }.',
69
71
  '- WARNING: Calling a tool again WITHOUT clarificationAnswers when a pending clarification exists returns isError: true.',
70
72
  ' The server will block the call until you provide answers. There is no way to bypass this gate.',
71
73
  '',
72
- 'GIT WORKFLOW — automatic branch management:',
73
- '- Planu automatically detects your git workflow (gitflow, github-flow, or trunk-based) by checking which branches exist.',
74
- '- When creating a spec, Planu auto-creates a feature branch from the correct base branch (develop for gitflow, main for github-flow).',
75
- '- The base branch is fetched and updated before creating the feature branch — no manual git pull needed.',
76
- '- If there are uncommitted changes, Planu warns instead of risking data loss.',
77
- '- Use manage_git with action "auto-setup" to manually trigger branch setup for an existing spec.',
78
- '- Available git actions: create-branch, generate-pr, link-commits, generate-changelog, setup-hooks, check-branch, status, sync-branch, check-gitflow, resolve-conflict, breaking-check, release, hotfix, promote, auto-setup.',
79
- '- Branch naming convention: feat/SPEC-XXX-short-name for features, fix/SPEC-XXX-short-name for fixes.',
80
- '- Explain why: "Working in a separate branch keeps your main code safe while you build this feature. When it is ready, you merge it back."',
74
+ 'GIT WORKFLOW:',
75
+ '- When a spec is created, Planu queues a git-setup task that creates feat/SPEC-XXX-short-name (or fix/…) from the detected base branch without touching the working tree; if the branch cannot be created the task records why and the spec is still usable.',
76
+ "- There is no git tool in the MCP surface: commit, push and merge with your host's git commands, and mention the spec ID in commit messages.",
81
77
  '',
82
78
  'SPEC APPROVAL FLOW — MANDATORY after every create_spec:',
83
- '- After creating a spec, ALWAYS present a clear summary to the user and ask: "Do you approve this spec, or do you have changes/observations?"',
84
- '- If the user APPROVES: call update_status to move the spec from "draft" to "review", then to "approved".',
85
- '- If the user has OBSERVATIONS or wants changes: call update_status with status="draft" and include their feedback in the reviewNotes field. Then revise the spec and ask again.',
86
- '- NEVER start implementing a spec without explicit user approval. The spec is a contract — both sides must agree.',
87
- '- When creating multiple specs at once, present ALL specs for review and let the user approve/reject each one individually.',
88
- '- The reviewNotes field stores a history of all feedback — implementers can see what was requested and why.',
79
+ '- Present a clear summary and ask whether the user approves the spec or has observations.',
80
+ '- Before approval run challenge_spec and check_readiness, and record independent planu-spec-reviewer evidence; update_status enforces these gates and refuses to approve without them.',
81
+ '- If the user APPROVES: call update_status with status="review", then status="approved" with modelTierUsed="max".',
82
+ '- If the user has OBSERVATIONS: call update_status with status="draft" and their feedback in reviewNotes, revise, and ask again.',
83
+ '- NEVER start implementing before the spec is approved; the spec is the contract.',
84
+ '- When creating several specs, present all of them and let the user approve or reject each one.',
89
85
  '',
90
86
  'RESPONSE FORMAT — MANDATORY for all tool results:',
91
87
  '- NEVER show raw JSON.stringify output to the user — always format as readable markdown',
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: planu-release
3
- description: Create a Planu release — bumps the version, generates changelog, publishes to npm, and tags the git commit. For projects using Planu as a library.
3
+ description: Release with Planu — runs the local gates and, with --publish, bumps, tags and publishes through the canonical release orchestrator.
4
4
  triggers:
5
5
  - let's release
6
6
  - create a release
@@ -32,7 +32,7 @@ Use this skill when all done specs are merged to main and you want to publish a
32
32
  1. **Check state** — calls `planu_status` to confirm no specs are `implementing` or `review`
33
33
  2. **Determine version bump** — analyzes commits since last release: `feat` → minor, `fix` → patch, breaking changes → major
34
34
  3. **Run the local gate** — run `pnpm check:preflight` and fix anything it flags
35
- 4. **Release** — run `pnpm release:local`, which bumps `package.json`, writes the `CHANGELOG.md` entry, tags the commit, publishes to npm, and pushes the tag
35
+ 4. **Release** — run `pnpm release:local` to rerun the local gates (typecheck, lint, build, tests, dist smoke); it does not bump, tag or publish. To publish, run `pnpm release:local --publish`, which delegates to `scripts/release.sh` (version bump, CHANGELOG entry, tag, npm publish, push).
36
36
  5. **Confirm** — reports the published version and npm URL
37
37
 
38
38
  ## Usage
@@ -42,7 +42,7 @@ User: "let's release"
42
42
  → Planu: "3 specs done since last release. Suggested bump: minor (v1.5.0 → v1.6.0).
43
43
  Changelog: [preview]. Proceed?"
44
44
  → User: confirms
45
- → Planu: publishes and tags
45
+ → Planu: runs pnpm release:local --publish and reports the published version
46
46
  ```
47
47
 
48
48
  ## Notes
@@ -36,7 +36,7 @@
36
36
  "tools": {
37
37
  "groups": {
38
38
  "spec": ["create_spec", "check_readiness", "challenge_spec", "update_status"],
39
- "handoff": ["package_handoff", "generate_execution_plan"],
39
+ "handoff": ["package_handoff"],
40
40
  "status": ["planu_status", "session_checkpoint"],
41
41
  "token": ["token_intelligence", "tokens", "context_budget"]
42
42
  },
@@ -1,7 +1,8 @@
1
1
  // engine/errors/registry-loader.ts — SPEC-902: Singleton error recovery registry
2
- import { join } from 'node:path';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
3
4
  import { RecoveryRegistry } from './recovery-registry.js';
4
- const PACKAGE_REGISTRY_PATH = join(process.cwd(), 'src', 'config', 'registries', 'error-recovery.json');
5
+ const PACKAGE_REGISTRY_PATH = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'config', 'registries', 'error-recovery.json');
5
6
  let cachedRegistry;
6
7
  let loadPromise;
7
8
  function getErrorRecoveryRegistry() {
@@ -30,6 +30,84 @@ export declare const DiscoverySchema: z.ZodObject<{
30
30
  }, z.core.$strict>>;
31
31
  }, z.core.$strict>;
32
32
  export declare const DISCOVERY_TEMPLATE_OVERRIDES: Record<string, unknown>;
33
+ export declare const TaskPlanSchema: z.ZodObject<{
34
+ version: z.ZodLiteral<1>;
35
+ provenance: z.ZodOptional<z.ZodObject<{
36
+ receiptId: z.ZodString;
37
+ artifactDigest: z.ZodString;
38
+ specId: z.ZodString;
39
+ issuerId: z.ZodString;
40
+ }, z.core.$strict>>;
41
+ generatedBy: z.ZodOptional<z.ZodLiteral<"planu-evidence-skeleton">>;
42
+ tasks: z.ZodArray<z.ZodObject<{
43
+ id: z.ZodString;
44
+ title: z.ZodString;
45
+ acceptanceCriteria: z.ZodArray<z.ZodString>;
46
+ status: z.ZodEnum<{
47
+ doing: "doing";
48
+ done: "done";
49
+ pending: "pending";
50
+ }>;
51
+ }, z.core.$strict>>;
52
+ }, z.core.$strict>;
53
+ export declare const TraceabilityMatrixSchema: z.ZodObject<{
54
+ version: z.ZodLiteral<1>;
55
+ provenance: z.ZodOptional<z.ZodObject<{
56
+ receiptId: z.ZodString;
57
+ artifactDigest: z.ZodString;
58
+ specId: z.ZodString;
59
+ issuerId: z.ZodString;
60
+ }, z.core.$strict>>;
61
+ rows: z.ZodArray<z.ZodObject<{
62
+ acceptanceCriterion: z.ZodString;
63
+ scenario: z.ZodOptional<z.ZodString>;
64
+ testEvidence: z.ZodOptional<z.ZodArray<z.ZodString>>;
65
+ contractEvidence: z.ZodOptional<z.ZodArray<z.ZodString>>;
66
+ manualEvidence: z.ZodOptional<z.ZodString>;
67
+ changedFiles: z.ZodArray<z.ZodString>;
68
+ validationEvidence: z.ZodOptional<z.ZodString>;
69
+ reviewerEvidence: z.ZodOptional<z.ZodString>;
70
+ commandEvidence: z.ZodOptional<z.ZodObject<{
71
+ capability: z.ZodEnum<{
72
+ contract: "contract";
73
+ coverage: "coverage";
74
+ "fault-injection": "fault-injection";
75
+ lint: "lint";
76
+ migration: "migration";
77
+ native: "native";
78
+ reproducibility: "reproducibility";
79
+ security: "security";
80
+ "test-full": "test-full";
81
+ "test-related": "test-related";
82
+ typecheck: "typecheck";
83
+ website: "website";
84
+ }>;
85
+ command: z.ZodString;
86
+ scope: z.ZodArray<z.ZodString>;
87
+ relevantPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
88
+ evidenceKey: z.ZodString;
89
+ }, z.core.$strict>>;
90
+ }, z.core.$strict>>;
91
+ }, z.core.$strict>;
92
+ export declare const ContractValidationSchema: z.ZodObject<{
93
+ version: z.ZodLiteral<1>;
94
+ provenance: z.ZodOptional<z.ZodObject<{
95
+ receiptId: z.ZodString;
96
+ artifactDigest: z.ZodString;
97
+ specId: z.ZodString;
98
+ issuerId: z.ZodString;
99
+ }, z.core.$strict>>;
100
+ kind: z.ZodEnum<{
101
+ api: "api";
102
+ event: "event";
103
+ graphql: "graphql";
104
+ mcp: "mcp";
105
+ ui: "ui";
106
+ }>;
107
+ passed: z.ZodBoolean;
108
+ reportPath: z.ZodOptional<z.ZodString>;
109
+ summary: z.ZodOptional<z.ZodString>;
110
+ }, z.core.$strict>;
33
111
  /** Digest of canonical artifact content; the provenance envelope is excluded. */
34
112
  export declare function evidenceArtifactDigest(artifact: unknown): string;
35
113
  export declare function evidenceArtifactCollectionDigest(artifacts: readonly {
@@ -6,7 +6,7 @@ import { isAbsolute, join, relative, resolve } from 'node:path';
6
6
  import { z } from 'zod';
7
7
  // eslint-disable-next-line no-restricted-imports -- grandfathered layer violation, remediation SPEC-1661 SPEC-1662 SPEC-1663
8
8
  import { projectDataDir } from '../../storage/base-store.js';
9
- import { computeValidationEvidenceIdentity, computeValidationEvidenceKey, normalizeValidationCommand, readMatchingValidationEvidence, } from '../validation-evidence-ledger.js';
9
+ import { computeValidationEvidenceIdentity, normalizeValidationCommand, readPassedValidationReceipt, } from '../validation-evidence-ledger.js';
10
10
  import { VALIDATION_COMMANDS } from '../validation-impact-planner.js';
11
11
  import { renderSchemaSkeleton } from '../handoff-artifacts/schema-skeleton.js';
12
12
  import { isExecutableTestPath } from '../spec-format/executable-test-path.js';
@@ -62,7 +62,7 @@ export const DiscoverySchema = z
62
62
  export const DISCOVERY_TEMPLATE_OVERRIDES = {
63
63
  'openQuestions[].status': 'resolved',
64
64
  };
65
- const TaskPlanSchema = z
65
+ export const TaskPlanSchema = z
66
66
  .object({
67
67
  version: z.literal(1),
68
68
  provenance: ProvenanceSchema.optional(),
@@ -81,7 +81,7 @@ const TaskPlanSchema = z
81
81
  .strict();
82
82
  const MAX_CHANGED_FILES_PER_ROW = 200;
83
83
  const CHANGED_FILES_OVERFLOW_MESSAGE = `changedFiles holds at most ${MAX_CHANGED_FILES_PER_ROW} entries per row. For a wider change, list each containing directory as a repository-relative path without a trailing slash (for example "tests") and declare that same directory path under the spec "## Files" ownership, through reconcile_spec when the spec is already approved, so the done drift check matches it.`;
84
- const TraceabilityMatrixSchema = z
84
+ export const TraceabilityMatrixSchema = z
85
85
  .object({
86
86
  version: z.literal(1),
87
87
  provenance: ProvenanceSchema.optional(),
@@ -113,7 +113,7 @@ const TraceabilityMatrixSchema = z
113
113
  .max(1000),
114
114
  })
115
115
  .strict();
116
- const ContractValidationSchema = z
116
+ export const ContractValidationSchema = z
117
117
  .object({
118
118
  version: z.literal(1),
119
119
  provenance: ProvenanceSchema.optional(),
@@ -235,10 +235,22 @@ export function traceabilityRowHasCurrentCommandEvidence(row, args) {
235
235
  scope: evidence.scope,
236
236
  ...(evidence.relevantPaths === undefined ? {} : { relevantPaths: evidence.relevantPaths }),
237
237
  };
238
- const currentKey = computeValidationEvidenceKey(computeValidationEvidenceIdentity(input));
239
- return (currentKey === evidence.evidenceKey &&
240
- readMatchingValidationEvidence(args.projectId, input)?.status === 'passed');
238
+ const receipt = readPassedValidationReceipt(args.projectId, evidence.evidenceKey);
239
+ if (!receipt) {
240
+ return false;
241
+ }
242
+ const currentIdentity = computeValidationEvidenceIdentity(input);
243
+ return REPOSITORY_IDENTITY_FIELDS.every((field) => receipt.identity[field] === currentIdentity[field]);
241
244
  }
245
+ const REPOSITORY_IDENTITY_FIELDS = [
246
+ 'schemaVersion',
247
+ 'capability',
248
+ 'normalizedCommand',
249
+ 'sourceTreeDigest',
250
+ 'lockDigest',
251
+ 'configDigest',
252
+ 'selectedScopeDigest',
253
+ ];
242
254
  const ARTIFACT_HINTS = {
243
255
  'Discovery evidence': 'Expected discovery.json with { version: 1, rules: string[], examples: [{ rule, example }], openQuestions: [{ question, status, resolution? }], outOfScope: string[], glossary: [{ term, meaning }] }.',
244
256
  'Task plan evidence': 'Expected task-plan.json with { version: 1, tasks: [{ id, title, acceptanceCriteria: string[], status: "pending"|"doing"|"done" }] }. Acceptance criteria may be full text or stable IDs such as AC1 when they map to the canonical criteria order.',
@@ -37,7 +37,7 @@ function buildSkipForIncompleteSpec(specId) {
37
37
  manualSteps: [
38
38
  `Open planu/specs/${specId}/spec.md`,
39
39
  'Add title, description, and at least one acceptance criterion',
40
- 'Re-run health_check_all to verify',
40
+ 'Re-run check_readiness to verify',
41
41
  ],
42
42
  };
43
43
  }
@@ -57,7 +57,7 @@ function buildSkipForDrift(specId) {
57
57
  issue: `drift-detected: ${specId}`,
58
58
  reason: 'Drift requires manual reconciliation between spec and implementation',
59
59
  manualSteps: [
60
- `Run detect_drift with specId: "${specId}" for a detailed report`,
60
+ `Run reconcile_spec with specId: "${specId}" to record the drift`,
61
61
  'Review which criteria are no longer implemented',
62
62
  'Either update the spec or fix the code to match',
63
63
  ],
@@ -217,7 +217,7 @@ function sendTestDiagnosticEvent() {
217
217
  function buildRecommendation(status) {
218
218
  switch (status) {
219
219
  case 'disabled':
220
- return 'Run configure_telemetry to enable usage tracking';
220
+ return 'Set PLANU_TELEMETRY=on and PLANU_TELEMETRY_CONSENT_VERSION=1 to enable usage tracking';
221
221
  case 'misconfigured':
222
222
  return 'Set valid PLANU_TELEMETRY_ENDPOINT and PLANU_TELEMETRY_TOKEN values.';
223
223
  case 'degraded':
@@ -26,4 +26,5 @@ export declare function recordValidationOutcome(args: {
26
26
  reason: string;
27
27
  source?: string;
28
28
  }): void;
29
+ export declare function readPassedValidationReceipt(projectId: string, key: string): ValidationEvidenceReceipt | null;
29
30
  //# sourceMappingURL=validation-evidence-ledger.d.ts.map
@@ -258,7 +258,29 @@ function writeReceiptAtomically(projectId, receipt) {
258
258
  }
259
259
  }
260
260
  }
261
- function isMatchingSuccessfulReceipt(value, key, identity) {
261
+ function isValidationEvidenceIdentity(value) {
262
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
263
+ return false;
264
+ }
265
+ const identity = value;
266
+ const hexDigest = /^[a-f0-9]{64}$/;
267
+ return (identity.schemaVersion === VALIDATION_EVIDENCE_SCHEMA_VERSION &&
268
+ typeof identity.capability === 'string' &&
269
+ identity.capability.trim() !== '' &&
270
+ typeof identity.normalizedCommand === 'string' &&
271
+ identity.normalizedCommand.trim() !== '' &&
272
+ typeof identity.sourceTreeDigest === 'string' &&
273
+ hexDigest.test(identity.sourceTreeDigest) &&
274
+ typeof identity.lockDigest === 'string' &&
275
+ hexDigest.test(identity.lockDigest) &&
276
+ typeof identity.configDigest === 'string' &&
277
+ hexDigest.test(identity.configDigest) &&
278
+ typeof identity.toolchainDigest === 'string' &&
279
+ hexDigest.test(identity.toolchainDigest) &&
280
+ typeof identity.selectedScopeDigest === 'string' &&
281
+ hexDigest.test(identity.selectedScopeDigest));
282
+ }
283
+ function isWellFormedPassedReceipt(value, key) {
262
284
  if (!value || typeof value !== 'object' || Array.isArray(value)) {
263
285
  return false;
264
286
  }
@@ -266,8 +288,7 @@ function isMatchingSuccessfulReceipt(value, key, identity) {
266
288
  if (receipt.schemaVersion !== VALIDATION_EVIDENCE_SCHEMA_VERSION ||
267
289
  receipt.key !== key ||
268
290
  receipt.status !== 'passed' ||
269
- !receipt.identity ||
270
- digestJson(receipt.identity) !== digestJson(identity) ||
291
+ !isValidationEvidenceIdentity(receipt.identity) ||
271
292
  typeof receipt.producer !== 'string' ||
272
293
  receipt.producer.trim() === '' ||
273
294
  typeof receipt.durationMs !== 'number' ||
@@ -285,6 +306,26 @@ function isMatchingSuccessfulReceipt(value, key, identity) {
285
306
  }
286
307
  return computeValidationEvidenceKey(receipt.identity) === key;
287
308
  }
309
+ function isMatchingSuccessfulReceipt(value, key, identity) {
310
+ return (isWellFormedPassedReceipt(value, key) && digestJson(value.identity) === digestJson(identity));
311
+ }
312
+ export function readPassedValidationReceipt(projectId, key) {
313
+ try {
314
+ const path = validationReceiptPath(projectId, key);
315
+ const stat = lstatSync(path);
316
+ if (!stat.isFile() || stat.size <= 0 || stat.size > MAX_RECEIPT_BYTES) {
317
+ return null;
318
+ }
319
+ const parsed = JSON.parse(readFileSync(path, 'utf-8'));
320
+ if (!isWellFormedPassedReceipt(parsed, key)) {
321
+ return null;
322
+ }
323
+ return parsed;
324
+ }
325
+ catch {
326
+ return null;
327
+ }
328
+ }
288
329
  function normalizeRelativePath(path) {
289
330
  return path.trim().replaceAll('\\', '/').replace(/^\.\//, '');
290
331
  }
@@ -34,7 +34,7 @@ startup_timeout_sec = 120
34
34
  spec_path = "planu/specs"
35
35
 
36
36
  [access]
37
- # Role required to invoke destructive Planu tools (delete_spec, update_status).
37
+ # Role required to invoke destructive Planu tools (update_status).
38
38
  # Valid values: owner, admin, member, viewer
39
39
  min_role_for_mutations = "member"
40
40
  `;
@@ -84,7 +84,7 @@ function buildPlanuMultimodalSkillMd() {
84
84
  '1. Attach the image/PDF/Figma export to your message',
85
85
  '2. Say "create a spec from this design"',
86
86
  '3. Planu automatically chains:',
87
- ' - `inject_component_context` — extracts visual component hints',
87
+ ' - component hints are extracted from the frames automatically',
88
88
  ' - Figma token extraction (if tokens file detected)',
89
89
  ' - `create_spec` — creates the spec with visual context',
90
90
  '',
@@ -98,11 +98,16 @@ async function parseSpecRecord(projectPath, specMdPath) {
98
98
  export async function loadSpecIndex(projectPath) {
99
99
  const specFiles = await glob(join(projectPath, 'planu', 'specs', '*', 'spec.md'));
100
100
  const parsed = await Promise.all(specFiles.map((specMdPath) => parseSpecRecord(projectPath, specMdPath)));
101
+ const records = parsed.filter((record) => record !== null);
102
+ records.sort((left, right) => (left.specPath < right.specPath ? -1 : 1));
101
103
  const specs = {};
102
- for (const record of parsed) {
103
- if (record) {
104
- specs[record.id] = record;
104
+ for (const record of records) {
105
+ const existing = specs[record.id];
106
+ if (existing) {
107
+ reportClassifiedDegradation('SPEC_INDEX_DUPLICATE_ID', new Error(`${record.id}: ${record.specPath} shadowed by ${existing.specPath}`));
108
+ continue;
105
109
  }
110
+ specs[record.id] = record;
106
111
  }
107
112
  const index = { generatedAt: new Date().toISOString(), specs };
108
113
  // A read-only checkout (or a concurrent writer) must not turn a successful