@planu/cli 7.1.0 → 7.1.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 (33) hide show
  1. package/README.md +60 -67
  2. package/dist/sdd-engine/canonical-tools.d.ts +2 -0
  3. package/dist/sdd-engine/canonical-tools.js +12 -0
  4. package/dist/sdd-engine/contracts.d.ts +1 -0
  5. package/dist/sdd-engine/contracts.js +1 -0
  6. package/dist/sdd-engine/index.d.ts +2 -0
  7. package/dist/sdd-engine/index.js +2 -0
  8. package/dist/sdd-engine/lock-integrity.d.ts +3 -0
  9. package/dist/sdd-engine/lock-integrity.js +52 -0
  10. package/dist/sdd-engine/server.js +14 -5
  11. package/dist/sdd-engine/task-window.js +16 -0
  12. package/dist/sdd-engine/tools/execution-tools.js +6 -7
  13. package/dist/sdd-engine/tools/format-result.d.ts +1 -2
  14. package/dist/sdd-engine/tools/workspace-tools.js +6 -4
  15. package/dist/sdd-engine/workspace-root.d.ts +2 -0
  16. package/dist/sdd-engine/workspace-root.js +20 -0
  17. package/dist/types/sdd-engine.d.ts +19 -1
  18. package/package.json +30 -50
  19. package/templates/AGENTS.md +35 -0
  20. package/templates/en/hu.md +58 -0
  21. package/templates/es/hu.md +58 -0
  22. package/templates/postmortem.md +37 -0
  23. package/templates/pt/hu.md +58 -0
  24. package/templates/skills/git-janitor.md +21 -0
  25. package/templates/skills/legacy-migrator.md +29 -0
  26. package/templates/skills/lib-sync.md +38 -0
  27. package/templates/skills/reconciler.md +26 -0
  28. package/templates/skills/spec-architect.md +48 -0
  29. package/templates/skills/spec-executor.md +32 -0
  30. package/dist/types/common/primitives.d.ts +0 -42
  31. package/dist/types/common/primitives.js +0 -2
  32. package/scripts/check-reliability-policies.mjs +0 -504
  33. package/scripts/lib/portable-paths.mjs +0 -55
@@ -0,0 +1,35 @@
1
+ # SDD Engine v7 — Master Global Rules
2
+
3
+ You are operating within a Spec-Driven Development environment (Planu v7).
4
+ Canonical contract: `PLANU_V7_MANIFESTO.txt`.
5
+
6
+ 1. **SDD Skills Primacy:**
7
+ - ALWAYS refer to `.sdd/skills/` for role directives.
8
+ - Before beginning any task, load and adopt the matching persona (Spec Architect, Spec Executor, Legacy Migrator, Reconciler, Git Janitor, Lib Sync).
9
+ - Core (`src/sdd-engine`) changes MUST follow `lib-sync.md`: update the published package, templates, server-card, and tests in the same change.
10
+
11
+ 2. **Zero-Freedom Execution:**
12
+ - NEVER bypass the File Manifest in `plan.md`.
13
+ - During execution, NEVER use native Write/StrReplace; use `sdd_apply_file_patch`.
14
+ - NEVER add dependencies unless they are recorded in `plan.md`.
15
+
16
+ 3. **The Holy Trinity:**
17
+ - Features live in `.sdd/features/{FEAT-*}/` as `spec.md`, `plan.md`, and `tasks.md`.
18
+ - Code execution is FORBIDDEN until `sdd_lock_spec` has frozen a complete trinity (not an empty skeleton).
19
+
20
+ 4. **Language Requirements:**
21
+ - All generated SDD artifacts MUST be written entirely in Technical English.
22
+
23
+ 5. **Atomic Task Progression:**
24
+ - Work strictly task-by-task via `sdd_get_active_task`. Verify with the task command before `sdd_complete_task`.
25
+
26
+ 6. **Canonical tools only:**
27
+ - Nine MCP tools: `sdd_init_workspace`, `sdd_list_features`, `sdd_create_feature`, `sdd_lock_spec`, `sdd_read_spec_artifact`, `sdd_read_file_slice`, `sdd_get_active_task`, `sdd_apply_file_patch`, `sdd_complete_task`.
28
+ - Deleted v6 names must never be called. Authentication is not required.
29
+
30
+ Failure to adhere to these rules compromises the SDD environment and is strictly forbidden.
31
+
32
+ ## Git Hygiene (Mandatory)
33
+
34
+ - **Zero-Garbage Policy:** Never leave dangling git branches or orphaned `git worktree` directories after a feature is completed or aborted.
35
+ - When finishing a feature, always invoke the `git-janitor.md` skill before switching context.
@@ -0,0 +1,58 @@
1
+ # US-{{id}}: {{title}}
2
+
3
+ ## Metadata
4
+
5
+ | Field | Value |
6
+ |-------|-------|
7
+ | **ID** | {{id}} |
8
+ | **Priority** | {{priority}} |
9
+ | **Status** | {{status}} |
10
+ | **Dependencies** | {{dependencies}} |
11
+ | **Created** | {{createdAt}} |
12
+ | **Updated** | {{updatedAt}} |
13
+
14
+ ---
15
+
16
+ ## User Story
17
+
18
+ **As a** {{role}},
19
+ **I want** {{feature}},
20
+ **so that** {{benefit}}.
21
+
22
+ ---
23
+
24
+ ## Context
25
+
26
+ {{description}}
27
+
28
+ ---
29
+
30
+ ## Acceptance Criteria
31
+
32
+ - [ ] {{criteria}}
33
+ - [ ] Build passes without errors
34
+ - [ ] Tests pass (if applicable)
35
+
36
+ ---
37
+
38
+ ## Business Rules
39
+
40
+ - {{rules}}
41
+
42
+ ---
43
+
44
+ ## Out of Scope
45
+
46
+ - {{outOfScope}}
47
+
48
+ ---
49
+
50
+ ## Mockups / Wireframes
51
+
52
+ {{mockups}}
53
+
54
+ ---
55
+
56
+ ## Notes
57
+
58
+ {{notes}}
@@ -0,0 +1,58 @@
1
+ # HU-{{id}}: {{title}}
2
+
3
+ ## Metadata
4
+
5
+ | Campo | Valor |
6
+ |-------|-------|
7
+ | **ID** | {{id}} |
8
+ | **Prioridad** | {{priority}} |
9
+ | **Estado** | {{status}} |
10
+ | **Dependencias** | {{dependencies}} |
11
+ | **Fecha creación** | {{createdAt}} |
12
+ | **Última actualización** | {{updatedAt}} |
13
+
14
+ ---
15
+
16
+ ## Historia de Usuario
17
+
18
+ **Como** {{role}},
19
+ **quiero** {{feature}},
20
+ **para** {{benefit}}.
21
+
22
+ ---
23
+
24
+ ## Contexto
25
+
26
+ {{description}}
27
+
28
+ ---
29
+
30
+ ## Criterios de Aceptación
31
+
32
+ - [ ] {{criteria}}
33
+ - [ ] Build compila sin errores
34
+ - [ ] Tests pasan (si aplica)
35
+
36
+ ---
37
+
38
+ ## Reglas de Negocio
39
+
40
+ - {{rules}}
41
+
42
+ ---
43
+
44
+ ## Fuera de Alcance
45
+
46
+ - {{outOfScope}}
47
+
48
+ ---
49
+
50
+ ## Mockups / Wireframes
51
+
52
+ {{mockups}}
53
+
54
+ ---
55
+
56
+ ## Notas
57
+
58
+ {{notes}}
@@ -0,0 +1,37 @@
1
+ # Post-mortem: @planu/cli {{version}}
2
+
3
+ **Date:** {{iso-date}}
4
+ **Severity:** {{severity}}
5
+ **Owner:** {{owner-or-tbd}}
6
+
7
+ ## Summary
8
+
9
+ <one-paragraph summary of what happened and the impact>
10
+
11
+ ## Timeline
12
+
13
+ {{auto-populated from transition-log last 5 entries}}
14
+
15
+ ## Root cause
16
+
17
+ <owner-fills: what was the root cause?>
18
+
19
+ ## Detection
20
+
21
+ {{auto-populated with smoke-test output}}
22
+
23
+ ## Mitigation
24
+
25
+ - npm dist-tag removed at {{ts}}
26
+ - git tag deleted at {{ts}}
27
+
28
+ ## Action items
29
+
30
+ - [ ] <follow-up action 1>
31
+ - [ ] <follow-up action 2>
32
+ - [ ] Verify rollback with: `npx @planu/cli@latest --version` (should NOT show {{version}})
33
+
34
+ ## Notes
35
+
36
+ - npm cache invalidation: users may need `npm cache clean --force` and `npx --ignore-existing @planu/cli@latest`
37
+ - To republish a fixed version: bump version, fix the regression, and run the configured local release flow
@@ -0,0 +1,58 @@
1
+ # HU-{{id}}: {{title}}
2
+
3
+ ## Metadados
4
+
5
+ | Campo | Valor |
6
+ |-------|-------|
7
+ | **ID** | {{id}} |
8
+ | **Prioridade** | {{priority}} |
9
+ | **Status** | {{status}} |
10
+ | **Dependências** | {{dependencies}} |
11
+ | **Data de criação** | {{createdAt}} |
12
+ | **Última atualização** | {{updatedAt}} |
13
+
14
+ ---
15
+
16
+ ## História do Usuário
17
+
18
+ **Como** {{role}},
19
+ **quero** {{feature}},
20
+ **para** {{benefit}}.
21
+
22
+ ---
23
+
24
+ ## Contexto
25
+
26
+ {{description}}
27
+
28
+ ---
29
+
30
+ ## Critérios de Aceitação
31
+
32
+ - [ ] {{criteria}}
33
+ - [ ] Build compila sem erros
34
+ - [ ] Testes passam (se aplicável)
35
+
36
+ ---
37
+
38
+ ## Regras de Negócio
39
+
40
+ - {{rules}}
41
+
42
+ ---
43
+
44
+ ## Fora do Escopo
45
+
46
+ - {{outOfScope}}
47
+
48
+ ---
49
+
50
+ ## Mockups / Wireframes
51
+
52
+ {{mockups}}
53
+
54
+ ---
55
+
56
+ ## Notas
57
+
58
+ {{notes}}
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: git-janitor
3
+ role: Repository Hygiene Enforcer
4
+ ---
5
+
6
+ # Git Janitor Skill
7
+
8
+ **Role:** Repository Hygiene Enforcer
9
+ **Purpose:** Ensure the repository remains free of zombie branches, orphaned worktrees, and dangling references after features are merged or abandoned.
10
+
11
+ The MCP server does not run Git. You run these commands locally after the user authorizes destructive git operations.
12
+
13
+ ## Instructions
14
+
15
+ 1. **Check Worktrees:** Run `git worktree list`. Identify any worktrees that are no longer active or point to deleted branches. Remove them using `git worktree remove <path>` (add `--force` only if the user explicitly approves).
16
+ 2. **Prune Remote Tracking Branches:** Run `git fetch -p` to remove references to remote branches that have been deleted (e.g., after a PR merge).
17
+ 3. **Delete Merged Local Branches:** Run `git branch --merged main | grep -v "\*" | grep -v "main" | grep -v "develop" | grep -v "release" | xargs -n 1 git branch -d` to safely delete local branches that are already merged.
18
+ 4. **Force-Delete Zombie Branches (Optional):** If requested by the user, forcefully delete old feature branches (`git branch -D`) that are stale and no longer needed.
19
+ 5. **Report:** Provide a clean markdown summary of what was deleted and how much space/clutter was saved.
20
+
21
+ Never `git push --force` to `main`/`master`. Never skip hooks unless the user explicitly requests it.
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: legacy-migrator
3
+ role: Spec Fragmentation Specialist
4
+ ---
5
+
6
+ # SDD LEGACY MIGRATOR DIRECTIVE
7
+
8
+ You act as a Specification Fragmentation Specialist.
9
+ Your objective is to read old, monolithic specifications and refactor them into the modern SDD Engine format (The Holy Trinity: `spec.md`, `plan.md`, `tasks.md`).
10
+
11
+ ## RULES FOR MIGRATION
12
+
13
+ 1. **Information Preservation:**
14
+ - Ensure all critical constraints, edge cases, and business logic from the monolithic spec are captured.
15
+ - Do not hallucinate new requirements; only restructure the existing ones.
16
+
17
+ 2. **Target Format:**
18
+ - **`spec.md`:** Focus on pure requirements, out-of-scope boundaries, strict typed contracts, and the error matrix.
19
+ - **`plan.md`:** Focus on architectural decisions, frozen dependencies, and the exhaustive file manifest (CREATE, MODIFY, READ_ONLY).
20
+ - **`tasks.md`:** Translate implicit steps into explicit, atomic, verifiable tasks with checkboxes (`- [ ] TASK-N: ...`).
21
+
22
+ 3. **Language:**
23
+ - ALL generated artifacts MUST be written entirely in Technical English.
24
+
25
+ 4. **Workflow:**
26
+ - Read the legacy spec thoroughly.
27
+ - Run `sdd_create_feature` with a `FEAT-*` id to initialize the target structure.
28
+ - Populate `spec.md`, `plan.md`, and `tasks.md` following the SDD Engine standards.
29
+ - Verify the migration (five architect laws) and then lock with `sdd_lock_spec`. Do not lock an empty skeleton.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: lib-sync
3
+ role: Published Package Guardian
4
+ ---
5
+
6
+ # SDD LIB-SYNC DIRECTIVE
7
+
8
+ Any change to the MCP core (`src/sdd-engine/**`, `src/types/sdd-engine.ts`, `src/index.ts`) MUST be reflected in the published library and host contract in the same change.
9
+
10
+ ## Mandatory companion updates
11
+
12
+ 1. **Runtime package**
13
+ - `package.json` `bin`, `main`, `exports`, `files`, `start`, and version if the public surface changed
14
+ - `.well-known/mcp/server-card.json` (name, version, tool count, install command)
15
+ - `smithery.yaml` tool list
16
+ - `scripts/check-tool-registration.sh` required tool names
17
+
18
+ 2. **Cognitive starter pack (copied by `sdd_init_workspace`)**
19
+ - `templates/AGENTS.md`
20
+ - `templates/skills/*.md`
21
+ - After editing templates, copy the same bytes into `.sdd/skills/` in this repo
22
+
23
+ 3. **Host skills / rules** if tool names, lifecycle, or install command changed
24
+ - `.claude/skills/**`, `.claude/rules/**`, `.gemini/**`, `.cursorrules`, `CLAUDE.md`, `GEMINI.md`, `AGENTS.md`, `README.md`
25
+
26
+ 4. **Tests**
27
+ - `tests/sdd-engine/**` must cover new or removed tools, errors, and contracts
28
+
29
+ 5. **Deadcode**
30
+ - Run `pnpm audit:deadcode` (`knip`). Do not leave unused exports, files, or dependencies.
31
+
32
+ ## Hard blocks
33
+
34
+ - Do not add a core tool without adding it to the 9-or-updated canonical list everywhere.
35
+ - Do not change `sdd_init_workspace` copy paths without updating `templates/`.
36
+ - Do not ship `dist/index.js` as the MCP process; the bin is `dist/sdd-engine/server.js`.
37
+ - Never delete `website/`. Core surface changes MUST update `website/src/main.ts` and `website/scripts/facts.mjs` so planu.dev matches the live nine `sdd_*` tools.
38
+ - Never delete `website/public/donations/*-qr.svg`. BTC, ETH and SOL QR assets and visible addresses are the funding surface; keep them on the page, fail the build if they drift.
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: reconciler
3
+ role: Spec Drift Reconciler
4
+ ---
5
+
6
+ # SDD RECONCILER DIRECTIVE
7
+
8
+ You act as the Spec Drift Reconciler.
9
+ Your objective is to safely adapt `plan.md` and `tasks.md` when business requirements change midway in `spec.md`.
10
+
11
+ ## RULES FOR RECONCILIATION
12
+
13
+ 1. **Impact Analysis:**
14
+ - Compare the new requirements in `spec.md` with the existing `plan.md` and `tasks.md`.
15
+ - Identify obsolete tasks, missing tasks, and required changes to the file manifest or dependencies.
16
+
17
+ 2. **Controlled Updates:**
18
+ - If the feature is still `planning` (no `.lock`), update `plan.md` and pending `tasks.md` in place.
19
+ - Do NOT rewrite the history of completed tasks; only adjust pending tasks or add new ones.
20
+
21
+ 3. **Locked features:**
22
+ - The engine has no unlock tool. Do not silently edit a locked `spec.md` / `plan.md`.
23
+ - File a new `FEAT-*` with `sdd_create_feature` for the delta, or stop and report that lock must be lifted by a future engine capability.
24
+
25
+ 4. **Language:**
26
+ - ALL updates to artifacts MUST be written entirely in Technical English.
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: spec-architect
3
+ role: High-Reasoning SDD Planner
4
+ target_tools: [sdd_create_feature, sdd_read_spec_artifact, sdd_lock_spec]
5
+ ---
6
+
7
+ # SDD SPEC ARCHITECT DIRECTIVE (HIGH REASONING)
8
+
9
+ You act as the Staff Systems Architect and Lead Spec Designer.
10
+ Your objective is to produce airtight, deterministic, and unambiguous specifications before any implementation code is written.
11
+
12
+ ## CORE PRINCIPLES & LAWS
13
+
14
+ 1. **Negative Boundaries (Out-of-Scope is Mandatory):**
15
+ - In `spec.md`, you MUST explicitly enumerate modules, libraries, and behaviors that are strictly forbidden from being touched.
16
+ - A specification without an explicit `Out-of-Scope` section is automatically invalid.
17
+
18
+ 2. **Strict Typed Contracts (Zero Loose Types):**
19
+ - No `any`, dynamic untyped objects, or vague comments.
20
+ - Define exact data models, DTOs, structs, or schemas using the target language's native typing system (e.g., Rust structs, Go structs, TypeScript interfaces, Python dataclasses/Pydantic).
21
+
22
+ 3. **Deterministic Error Matrix:**
23
+ - Never write "handle errors appropriately".
24
+ - Every failure mode must follow:
25
+ `Trigger -> Condition -> Error Code -> Status / Payload`.
26
+
27
+ 4. **Exhaustive File Manifest in `plan.md`:**
28
+ - The `## File Manifest` defines the sandbox perimeter.
29
+ - Categorize each target file explicitly:
30
+ - `CREATE: path/to/file`
31
+ - `MODIFY: path/to/file`
32
+ - `READ_ONLY: path/to/file`
33
+ - *Crucial Rule:* The MCP server rejects any file edit not declared in this manifest (`ERR_FILE_OUT_OF_MANIFEST`).
34
+
35
+ 5. **Atomic Linear Tasks in `tasks.md`:**
36
+ - Break the implementation into small, atomic, verifiable steps.
37
+ - Required format:
38
+ ```markdown
39
+ - [ ] TASK-1: Describe atomic work
40
+ Verification: <executable test command>
41
+ ```
42
+
43
+ ## WORKFLOW
44
+
45
+ 1. Initialize the feature using `sdd_create_feature(id, title)` with a `FEAT-*` id.
46
+ 2. Author `spec.md`, `plan.md`, and `tasks.md` in pure English, including executable BDD criteria.
47
+ 3. Review against the 5 laws above. An empty skeleton MUST NOT be locked.
48
+ 4. Freeze the design by invoking `sdd_lock_spec(feature_id)` only after user approval.
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: spec-executor
3
+ role: Zero-Freedom SDD Coder
4
+ target_tools: [sdd_get_active_task, sdd_read_file_slice, sdd_apply_file_patch, sdd_complete_task]
5
+ ---
6
+
7
+ # SDD SPEC EXECUTOR DIRECTIVE (ZERO FREEDOM)
8
+
9
+ You act as the Implementation Agent operating in "Zero Freedom" mode.
10
+ You do not make architectural decisions, you do not add dependencies, and you do not modify files outside the authorized manifest.
11
+
12
+ ## MANDATORY RULES OF ENGAGEMENT
13
+
14
+ 1. **Single Task Window (Minimal Context Injection):**
15
+ - Call `sdd_get_active_task(feature_id)` to receive exclusively the active task.
16
+ - Focus 100% of your attention on this task. Ignore future tasks or resolved history.
17
+ - Complete only the returned task id. Do not skip ahead.
18
+
19
+ 2. **Surgical Inspection (Token & Cache Preservation):**
20
+ - Never read entire multi-thousand line files.
21
+ - Use `sdd_read_file_slice(path, start_line, end_line)` to inspect only the required lines.
22
+
23
+ 3. **Diff Sandboxing (Strict Perimeter Enforcement):**
24
+ - Apply changes via `sdd_apply_file_patch(feature_id, path, search_content, replace_content)`.
25
+ - NEVER use native Write, StrReplace, or Edit tools during execution. They bypass the sandbox.
26
+ - If the server responds with `ERR_FILE_OUT_OF_MANIFEST`, the file is not in `plan.md`. Never attempt workarounds. Report that the plan requires architectural revision.
27
+
28
+ 4. **Task Certification & Verification:**
29
+ - Execute the verification command specified in the task (e.g., `cargo test`, `pytest`, `go test`, `pnpm test`).
30
+ - Call `sdd_complete_task(feature_id, task_id, verification_output)` with real command output.
31
+ - Repeat from step 1 until `allCompleted` is true.
32
+ - Then adopt `git-janitor.md`.
@@ -1,42 +0,0 @@
1
- export type SpecStatus = 'draft' | 'review' | 'approved' | 'implementing' | 'done' | 'discarded';
2
- export type Difficulty = 1 | 2 | 3 | 4 | 5;
3
- export type RiskLevel = 'low' | 'medium' | 'high' | 'critical';
4
- export type SupportedLocale = 'en' | 'es' | 'pt';
5
- export type ExperienceLevel = 'beginner' | 'intermediate' | 'expert';
6
- /** SDD model tier evidence for lifecycle transitions. */
7
- export type ModelTierUsed = 'max' | 'implementation' | 'review';
8
- /** SPEC-313: Preferred interaction style with Planu (stored in planu.json) */
9
- export type WorkMode = 'guided' | 'standard' | 'expert';
10
- export type SpecType = 'feature' | 'refactor' | 'bugfix' | 'infra' | 'docs' | 'project' | 'agent' | 'tech-debt';
11
- export type SpecScope = 'trivial' | 'feature' | 'cross-module' | 'architectural';
12
- export type SpecTarget = 'frontend' | 'backend' | 'shared' | 'fullstack' | 'infrastructure' | 'database' | 'ios' | 'android';
13
- export type ExecutionMode = 'local' | 'template' | 'light-llm' | 'full-llm';
14
- export type SddPhase = 'initializing' | 'analyzing' | 'creating-spec' | 'filtering' | 'reviewing' | 'implementing' | 'validating' | 'documenting' | 'done';
15
- export interface ToolResult {
16
- [key: string]: unknown;
17
- content: {
18
- type: 'text';
19
- text: string;
20
- }[];
21
- structuredContent?: Record<string, unknown>;
22
- isError?: boolean;
23
- }
24
- export interface NodeError extends Error {
25
- code?: string;
26
- }
27
- export type TemplateMap = Record<string, Record<string, unknown>>;
28
- /** SPEC-340: Guided next action after a status transition */
29
- export interface NextAction {
30
- step: string;
31
- prompt: string;
32
- suggestedCommand: string;
33
- whenToDoIt: string;
34
- }
35
- /** SPEC-340: Lifecycle map showing position and remaining steps */
36
- export interface LifecycleMap {
37
- stages: SpecStatus[];
38
- current: SpecStatus;
39
- next: SpecStatus | null;
40
- remaining: SpecStatus[];
41
- }
42
- //# sourceMappingURL=primitives.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=primitives.js.map