@planu/cli 7.1.7 → 8.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.
- package/CHANGELOG.md +37 -2
- package/README.md +10 -10
- package/dist/sdd-engine/contracts.d.ts +4 -2
- package/dist/sdd-engine/contracts.js +3 -2
- package/dist/sdd-engine/patch-sandbox.d.ts +12 -5
- package/dist/sdd-engine/patch-sandbox.js +147 -21
- package/dist/sdd-engine/server.js +2 -2
- package/dist/sdd-engine/tools/execution-tools.js +22 -1
- package/dist/sdd-engine/tools/workspace-tools.js +111 -23
- package/dist/sdd-engine/workspace-root.d.ts +3 -1
- package/dist/sdd-engine/workspace-root.js +17 -0
- package/dist/types/sdd-engine.d.ts +8 -18
- package/package.json +4 -3
- package/templates/AGENTS.md +21 -5
- package/templates/skills/git-janitor.md +9 -0
- package/templates/skills/legacy-sunset.md +70 -0
- package/templates/skills/lib-sync.md +12 -0
- package/templates/skills/preflight-guardian.md +56 -0
- package/templates/skills/reconciler.md +8 -0
- package/templates/skills/spec-architect.md +14 -0
- package/templates/skills/spec-executor.md +10 -0
- package/templates/skills/verification-auditor.md +56 -0
- package/dist/sdd-engine/legacy-catalog.d.ts +0 -11
- package/dist/sdd-engine/legacy-catalog.js +0 -112
- package/templates/skills/legacy-migrator.md +0 -74
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs/promises';
|
|
2
|
-
import * as path from 'node:path';
|
|
3
|
-
const LEGACY_SPEC_ROOTS = ['planu/specs', 'legacy-specs'];
|
|
4
|
-
const ARCHIVE_STATUSES = new Set(['done', 'completed', 'complete', 'discarded']);
|
|
5
|
-
const ACTIVE_STATUSES = new Set([
|
|
6
|
-
'implementing',
|
|
7
|
-
'approved',
|
|
8
|
-
'review',
|
|
9
|
-
'validating',
|
|
10
|
-
'draft',
|
|
11
|
-
'planning',
|
|
12
|
-
]);
|
|
13
|
-
export function classifyLegacyStatus(status) {
|
|
14
|
-
if (!status) {
|
|
15
|
-
return 'unknown';
|
|
16
|
-
}
|
|
17
|
-
const normalized = status.trim().toLowerCase();
|
|
18
|
-
if (ARCHIVE_STATUSES.has(normalized)) {
|
|
19
|
-
return 'archive';
|
|
20
|
-
}
|
|
21
|
-
if (ACTIVE_STATUSES.has(normalized)) {
|
|
22
|
-
return 'active';
|
|
23
|
-
}
|
|
24
|
-
return 'unknown';
|
|
25
|
-
}
|
|
26
|
-
export function parseLegacyFrontmatter(content) {
|
|
27
|
-
const head = content.slice(0, 4000);
|
|
28
|
-
const fence = /^---\r?\n([\s\S]*?)\r?\n---/.exec(head);
|
|
29
|
-
const block = head.startsWith('---') ? (fence?.[1] ?? head) : head;
|
|
30
|
-
return {
|
|
31
|
-
id: matchField(block, 'id'),
|
|
32
|
-
title: matchField(block, 'title'),
|
|
33
|
-
status: matchField(block, 'status'),
|
|
34
|
-
migratedTo: matchField(block, 'sdd_migrated_to'),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export function inferredFeatId(legacyId) {
|
|
38
|
-
return `FEAT-${legacyId}`;
|
|
39
|
-
}
|
|
40
|
-
export async function collectLegacyCatalog(workspaceRoot, sddDir) {
|
|
41
|
-
const specs = [];
|
|
42
|
-
const seen = new Set();
|
|
43
|
-
for (const relativeRoot of LEGACY_SPEC_ROOTS) {
|
|
44
|
-
const absRoot = path.join(workspaceRoot, relativeRoot);
|
|
45
|
-
const folders = await listSpecFolders(absRoot);
|
|
46
|
-
for (const folder of folders) {
|
|
47
|
-
const specPath = path.join(folder, 'spec.md');
|
|
48
|
-
let content;
|
|
49
|
-
try {
|
|
50
|
-
content = await fs.readFile(specPath, 'utf-8');
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
const meta = parseLegacyFrontmatter(content);
|
|
56
|
-
const folderName = path.basename(folder);
|
|
57
|
-
const idMatch = /^SPEC[-_]\d+/i.exec(folderName);
|
|
58
|
-
const id = meta.id ?? idMatch?.[0]?.toUpperCase() ?? folderName;
|
|
59
|
-
if (seen.has(id)) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
seen.add(id);
|
|
63
|
-
const featAlias = inferredFeatId(id);
|
|
64
|
-
const featExists = await pathExists(path.join(sddDir, 'features', featAlias));
|
|
65
|
-
specs.push({
|
|
66
|
-
id,
|
|
67
|
-
title: meta.title ?? folderName,
|
|
68
|
-
lifecycle: classifyLegacyStatus(meta.status),
|
|
69
|
-
legacyStatus: meta.status,
|
|
70
|
-
path: path.relative(workspaceRoot, specPath).split(path.sep).join('/'),
|
|
71
|
-
migratedTo: meta.migratedTo ?? (featExists ? featAlias : null),
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
specs.sort((a, b) => a.id.localeCompare(b.id));
|
|
76
|
-
return {
|
|
77
|
-
total: specs.length,
|
|
78
|
-
active: specs.filter((spec) => spec.lifecycle === 'active').length,
|
|
79
|
-
archive: specs.filter((spec) => spec.lifecycle === 'archive').length,
|
|
80
|
-
unknown: specs.filter((spec) => spec.lifecycle === 'unknown').length,
|
|
81
|
-
specs,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function matchField(block, key) {
|
|
85
|
-
const match = new RegExp(`^${key}:\\s*(.+)$`, 'im').exec(block);
|
|
86
|
-
if (!match?.[1]) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
return match[1].trim().replace(/^['"]|['"]$/g, '') || null;
|
|
90
|
-
}
|
|
91
|
-
async function listSpecFolders(absRoot) {
|
|
92
|
-
const found = [];
|
|
93
|
-
try {
|
|
94
|
-
const entries = await fs.readdir(absRoot, { withFileTypes: true });
|
|
95
|
-
for (const entry of entries) {
|
|
96
|
-
if (entry.isDirectory()) {
|
|
97
|
-
found.push(path.join(absRoot, entry.name));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
return [];
|
|
103
|
-
}
|
|
104
|
-
return found;
|
|
105
|
-
}
|
|
106
|
-
async function pathExists(target) {
|
|
107
|
-
return fs
|
|
108
|
-
.access(target)
|
|
109
|
-
.then(() => true)
|
|
110
|
-
.catch(() => false);
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=legacy-catalog.js.map
|
|
@@ -1,74 +0,0 @@
|
|
|
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
|
-
Old Planu v6 specs (`planu/specs/SPEC-*`, `legacy-specs/SPEC-*`) stay on disk. `sdd_list_features` returns them in `data.legacy` (id, path, lifecycle, `migratedTo`). They are **not** executable. `sdd_lock_spec` / `sdd_apply_file_patch` still require a `FEAT-*` trinity.
|
|
10
|
-
|
|
11
|
-
Read a legacy spec with `sdd_read_file_slice` using `legacy.specs[].path`. Then follow this skill to create `FEAT-SPEC-{n}` and stamp `sdd_migrated_to`.
|
|
12
|
-
|
|
13
|
-
There is no MCP tool `migrate_spec`. Migration is cognitive: read the old artifact, emit a Holy Trinity, lock it.
|
|
14
|
-
|
|
15
|
-
## Do not bulk-convert the archive
|
|
16
|
-
|
|
17
|
-
A host app may have hundreds of `SPEC-*` files. Most are finished history. Copying every `done` spec into `.sdd/features/` creates empty locked features and noise.
|
|
18
|
-
|
|
19
|
-
Triage first, migrate only what still governs work.
|
|
20
|
-
|
|
21
|
-
### Inventory (run in the target repo)
|
|
22
|
-
|
|
23
|
-
Count `status:` in each `planu/specs/**/spec.md` (or `legacy-specs/**/spec.md`). Bucket:
|
|
24
|
-
|
|
25
|
-
| Bucket | Typical v6 `status` | Action |
|
|
26
|
-
|---|---|---|
|
|
27
|
-
| Archive | `done`, `completed`, `complete`, `discarded` | Keep the folder. Do not create a `FEAT-*` unless the work is being reopened. |
|
|
28
|
-
| Active | `implementing`, `approved`, `review`, `validating`, `draft` | Migrate one spec at a time before more product code. |
|
|
29
|
-
| Unknown | missing `status` | Open the file. If the code already shipped, archive. If work remains, treat as Active. |
|
|
30
|
-
|
|
31
|
-
Never invent requirements. If the old spec is too thin to lock, mark it archive or rewrite as a **new** `FEAT-*` with the user, not as a fake migration.
|
|
32
|
-
|
|
33
|
-
## ID mapping
|
|
34
|
-
|
|
35
|
-
- Legacy id `SPEC-1047` stays on disk as history.
|
|
36
|
-
- v7 id MUST be `FEAT-*` (example: `FEAT-SPEC-1047` or `FEAT-PAYMENTS-1047`).
|
|
37
|
-
- Put `Legacy-Spec: SPEC-1047` plus the old path in the new `spec.md` frontmatter or header so the two remain traceable.
|
|
38
|
-
- After a successful lock, add to the **old** spec (do not rewrite its body):
|
|
39
|
-
|
|
40
|
-
```yaml
|
|
41
|
-
sdd_migrated_to: FEAT-SPEC-1047
|
|
42
|
-
sdd_migrated_at: <ISO date>
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## One-spec workflow (mandatory order)
|
|
46
|
-
|
|
47
|
-
1. Adopt this skill. Adopt `spec-architect.md` for quality of the new trinity.
|
|
48
|
-
2. `sdd_init_workspace` if `.sdd/` is missing (`scope: project`).
|
|
49
|
-
3. Read the entire legacy `spec.md` (and `technical.md` / `progress.md` if they still exist).
|
|
50
|
-
4. `sdd_create_feature` with the `FEAT-*` id and the legacy title.
|
|
51
|
-
5. Rewrite into:
|
|
52
|
-
- `spec.md` — BDD, Out-of-Scope, typed contracts, error matrix, `Legacy-Spec` pointer.
|
|
53
|
-
- `plan.md` — decisions, frozen dependencies, exhaustive File Manifest (`CREATE` / `MODIFY` / `READ_ONLY`).
|
|
54
|
-
- `tasks.md` — atomic `- [ ] TASK-N:` lines with `Verification:` commands. Check off only work that is already true in the tree.
|
|
55
|
-
6. If the legacy spec is already implemented, tasks may all be `[x]` **only** when each verification command still passes. Otherwise leave remaining work `[ ]`.
|
|
56
|
-
7. Five architect laws in `spec-architect.md` must hold. Do not lock an empty skeleton.
|
|
57
|
-
8. `sdd_lock_spec`.
|
|
58
|
-
9. Stamp `sdd_migrated_to` on the old spec.
|
|
59
|
-
10. Continue execution with `spec-executor.md` if tasks remain. Do not use native Write during execution.
|
|
60
|
-
|
|
61
|
-
Language: Technical English in all new SDD artifacts.
|
|
62
|
-
|
|
63
|
-
## Preservation rules
|
|
64
|
-
|
|
65
|
-
- Copy constraints, edge cases, and error behavior. Do not add product scope.
|
|
66
|
-
- Out-of-Scope is mandatory even if the old spec never had it.
|
|
67
|
-
- File Manifest must match the real tree (paths that no longer exist are not `MODIFY`).
|
|
68
|
-
- Leave `planu/specs/` in place. v7 does not delete or import that directory.
|
|
69
|
-
|
|
70
|
-
## Host notes (CONKER-scale)
|
|
71
|
-
|
|
72
|
-
Typical shape: majority `done` = archive; tens of `implementing`/`approved`/`draft` = the real queue; a large `status`-less set = triage, not a dump into `.sdd`.
|
|
73
|
-
|
|
74
|
-
New work in that repo starts with `sdd_create_feature`, never with a new `planu/specs/SPEC-*`.
|