sdtk-spec-kit 0.8.0 → 0.9.0
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/README.md +13 -12
- package/assets/manifest/toolkit-bundle.manifest.json +8 -8
- package/assets/manifest/toolkit-bundle.sha256.txt +3 -3
- package/assets/toolkit/toolkit/skills/sdtk-evolve/SKILL.md +2 -2
- package/assets/toolkit/toolkit/skills-claude/evolve/SKILL.md +2 -2
- package/assets/toolkit/toolkit/templates/QUALITY_CHECKLIST.md +1 -1
- package/package.json +1 -1
- package/src/commands/atlas.js +55 -344
- package/src/commands/help.js +12 -35
- package/src/commands/init.js +13 -0
- package/src/lib/atlas-delegate.js +109 -0
- package/src/lib/update.js +2 -0
- package/assets/atlas/build_atlas.py +0 -880
- package/assets/atlas/doc_atlas_viewer_template.html +0 -3796
- package/assets/atlas/vendor/mermaid.min.js +0 -2029
- package/src/lib/atlas-config.js +0 -200
- package/src/lib/atlas-runner.js +0 -435
- package/src/lib/browser-open.js +0 -39
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
It exposes the `sdtk-spec` CLI as the primary upstream command surface.
|
|
6
6
|
|
|
7
|
-
Package version in this source snapshot: `0.
|
|
7
|
+
Package version in this source snapshot: `0.9.0`
|
|
8
8
|
Full usage guide: `products/sdtk-spec/governance/SDTK_SPEC_USAGE_GUIDE.md`
|
|
9
9
|
|
|
10
10
|
Wraps the `SDTK-SPEC` PowerShell toolkit for portable, reproducible feature documentation scaffolding.
|
|
@@ -201,9 +201,9 @@ sdtk-spec analyze --source <requirements.md> --feature-key <UPPER_SNAKE_CASE> --
|
|
|
201
201
|
Build and browse a local document graph for your project.
|
|
202
202
|
|
|
203
203
|
Atlas is a free local compatibility feature in `sdtk-spec-kit`. No
|
|
204
|
-
authentication or entitlement is required.
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
authentication or entitlement is required. `sdtk-wiki` owns the graph builder
|
|
205
|
+
and the canonical `.sdtk/wiki` storage; `sdtk-spec atlas` remains the R1
|
|
206
|
+
compatibility namespace and forwards every subcommand to it.
|
|
207
207
|
|
|
208
208
|
#### Subcommands
|
|
209
209
|
|
|
@@ -222,7 +222,7 @@ cd <project>
|
|
|
222
222
|
sdtk-spec atlas init
|
|
223
223
|
```
|
|
224
224
|
|
|
225
|
-
This creates `.sdtk/
|
|
225
|
+
This delegates to `sdtk-wiki init`: it creates the graph workspace under `.sdtk/wiki`, scans local markdown, builds the document graph and static viewer, and opens the viewer in your browser by default.
|
|
226
226
|
|
|
227
227
|
#### Common flows
|
|
228
228
|
|
|
@@ -252,10 +252,11 @@ sdtk-spec atlas init [--project-path <path>] [--output-dir <path>] [--scan-root
|
|
|
252
252
|
|
|
253
253
|
#### Key facts
|
|
254
254
|
|
|
255
|
-
-
|
|
256
|
-
-
|
|
255
|
+
- `sdtk-spec atlas` is the R1 compatibility namespace. Every subcommand delegates to `sdtk-wiki`, which owns the graph builder; flags are forwarded verbatim.
|
|
256
|
+
- Requires `sdtk-wiki-kit`, which the SDTK suite installer brings in alongside this package. Without it, `atlas` exits 2 and prints the install steps.
|
|
257
|
+
- The builder is pure Node. No interpreter or extra runtime is required.
|
|
258
|
+
- Generated artifacts are written to `<project>/.sdtk/wiki/graph/` (project-local, not global). A legacy `<project>/.sdtk/atlas/` from an older release is left alone, never auto-deleted.
|
|
257
259
|
- The viewer server binds to `127.0.0.1` by default (loopback only).
|
|
258
|
-
- Python 3.8+ must be available in `PATH` for `atlas init`, `build`, and `watch`.
|
|
259
260
|
- Free Atlas scans local markdown files only and does not upload document content to external services.
|
|
260
261
|
- `sdtk-spec auth` and `sdtk-spec entitlement` are separate capability-management surfaces; they are not required for free Atlas commands.
|
|
261
262
|
- The old SPEC ask command path is not supported. Native Ask is owned by `sdtk-wiki ask` and capability `wiki.ask`.
|
|
@@ -362,7 +363,7 @@ sdtk-spec --version
|
|
|
362
363
|
|
|
363
364
|
- Node.js >= 18.13.0
|
|
364
365
|
- PowerShell (Windows PowerShell 5.1+ or PowerShell Core)
|
|
365
|
-
-
|
|
366
|
+
- `sdtk-wiki-kit` for the `atlas` commands
|
|
366
367
|
|
|
367
368
|
## Troubleshooting
|
|
368
369
|
|
|
@@ -386,9 +387,9 @@ sdtk-spec --version
|
|
|
386
387
|
**Payload hash mismatch**
|
|
387
388
|
- The bundled toolkit payload may be corrupted. Reinstall the package.
|
|
388
389
|
|
|
389
|
-
**Atlas
|
|
390
|
-
-
|
|
391
|
-
-
|
|
390
|
+
**Atlas exits 2 with "sdtk-wiki is not installed"**
|
|
391
|
+
- `sdtk-spec atlas` delegates to `sdtk-wiki`. Install it with `npm install -g sdtk-wiki-kit`.
|
|
392
|
+
- Then rerun `sdtk-spec atlas build`, or call `sdtk-wiki atlas build` directly.
|
|
392
393
|
|
|
393
394
|
## Development
|
|
394
395
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
3
|
-
"sourceCommit": "
|
|
2
|
+
"version": "0.9.0",
|
|
3
|
+
"sourceCommit": "7d819293a4fe710f43582c6d7b49757713e4d76c",
|
|
4
4
|
"fileCount": 100,
|
|
5
5
|
"files": [
|
|
6
6
|
{
|
|
@@ -140,8 +140,8 @@
|
|
|
140
140
|
},
|
|
141
141
|
{
|
|
142
142
|
"path": "toolkit/skills-claude/evolve/SKILL.md",
|
|
143
|
-
"sha256": "
|
|
144
|
-
"size":
|
|
143
|
+
"sha256": "caab483c02ff355634dd3e94c2d3d585ba6469c092ce5ab4bee97357da40be99",
|
|
144
|
+
"size": 7532
|
|
145
145
|
},
|
|
146
146
|
{
|
|
147
147
|
"path": "toolkit/skills-claude/mailbox-dispatch/SKILL.md",
|
|
@@ -240,8 +240,8 @@
|
|
|
240
240
|
},
|
|
241
241
|
{
|
|
242
242
|
"path": "toolkit/skills/sdtk-evolve/SKILL.md",
|
|
243
|
-
"sha256": "
|
|
244
|
-
"size":
|
|
243
|
+
"sha256": "691e7a0dd50262f247ad8a4c8ca05892c1240245de20580cc411c2d063bf9a1f",
|
|
244
|
+
"size": 7861
|
|
245
245
|
},
|
|
246
246
|
{
|
|
247
247
|
"path": "toolkit/skills/sdtk-mailbox-dispatch/SKILL.md",
|
|
@@ -490,8 +490,8 @@
|
|
|
490
490
|
},
|
|
491
491
|
{
|
|
492
492
|
"path": "toolkit/templates/QUALITY_CHECKLIST.md",
|
|
493
|
-
"sha256": "
|
|
494
|
-
"size":
|
|
493
|
+
"sha256": "1cc6c9e0fbbbd545da9750e6f13e09ad968d9b23bff3a69a36a46a2be57d5ea2",
|
|
494
|
+
"size": 7039
|
|
495
495
|
},
|
|
496
496
|
{
|
|
497
497
|
"path": "toolkit/templates/README.md",
|
|
@@ -25,7 +25,7 @@ c17bb4faff318032ee99ead56e5fa182811c7bcaa176e463d0377cefde213ac1 toolkit/skills
|
|
|
25
25
|
b4de86bc4730c4fcfe4f1bde8f9f64f03fd517825bb699e911199825cc3d4249 toolkit/skills-claude/dev-backend/SKILL.md
|
|
26
26
|
37b3ae11db18bc3f64a76b22bca95cea778d6cfbb8b038d46851bd44ff8ff8f1 toolkit/skills-claude/dev-frontend/SKILL.md
|
|
27
27
|
a4f326e2cafff865aaaed8f8de9407f3baa3cfebe33979528a15eb26d2e8482b toolkit/skills-claude/dev/SKILL.md
|
|
28
|
-
|
|
28
|
+
caab483c02ff355634dd3e94c2d3d585ba6469c092ce5ab4bee97357da40be99 toolkit/skills-claude/evolve/SKILL.md
|
|
29
29
|
6fa2283aa1ebb7bf5b6e84d5d5d9d9ddf71082091b108bd46895923a5fca3e09 toolkit/skills-claude/mailbox-dispatch/SKILL.md
|
|
30
30
|
aa086be1038e34b1b29f7f65bacf254b5c1bfdc1203bd3e643c27acca4f9c2fa toolkit/skills-claude/orchestrator/SKILL.md
|
|
31
31
|
e9e346ff0e1fc66236ceabf64a043c9a28926e7ff06296b26dd5836cf045802a toolkit/skills-claude/pm/SKILL.md
|
|
@@ -45,7 +45,7 @@ ce5af79e5c4902b9c8ceb7e8dae848a6a5a26d5b845eee94ee8aafff88990256 toolkit/skills
|
|
|
45
45
|
6c866b7f8dec193a4c26066e8ac43004ff809f6407ead467a3cb72d90425af52 toolkit/skills/sdtk-dev/prompts/implementer.md
|
|
46
46
|
55dd53b1ccbedd271ad23ca8df01afc317eced27ee17af3b37f31f0b9176ca8b toolkit/skills/sdtk-dev/prompts/spec-reviewer.md
|
|
47
47
|
749f0ff0865d8940cec9b16859706fd46f111a4d9bf54b6ccba381fe9db7a90e toolkit/skills/sdtk-dev/SKILL.md
|
|
48
|
-
|
|
48
|
+
691e7a0dd50262f247ad8a4c8ca05892c1240245de20580cc411c2d063bf9a1f toolkit/skills/sdtk-evolve/SKILL.md
|
|
49
49
|
df593d5ab4e7c5f4b05ac9ddb5078189b25bd954e546ab65c0147d024e4f4d59 toolkit/skills/sdtk-mailbox-dispatch/SKILL.md
|
|
50
50
|
66ddb66fee3b12b008ea269baa57acde77f8614ac15a9f87cc994eae64ca63dc toolkit/skills/sdtk-orchestrator/SKILL.md
|
|
51
51
|
ae53d96b6a4fb4ea60fb5de6578b2620c3adb43e1d722a0469cdfa5a90b92903 toolkit/skills/sdtk-pm/SKILL.md
|
|
@@ -95,6 +95,6 @@ e65192c4e72d86d27452c89f7be2d3bfe1118af550f71e3eee9db92e20f96cea toolkit/templa
|
|
|
95
95
|
6ee91d4307ec0fc6dbdee281f2a3f99efa552de55b535ff46cf498689572f9f7 toolkit/templates/handoffs/QA_RELEASE_DECISION.md
|
|
96
96
|
54ae1612b6e95af0f19bd0ea897ceb1df72d366dc20485c91ba3261484e88cf2 toolkit/templates/mailbox/AGENT_REPORT_TEMPLATE.md
|
|
97
97
|
3fd748061615802c8cd5a4978396a782f59404662339ee18f732352cb79b4f84 toolkit/templates/mailbox/AGENT_TASK_TEMPLATE.md
|
|
98
|
-
|
|
98
|
+
1cc6c9e0fbbbd545da9750e6f13e09ad968d9b23bff3a69a36a46a2be57d5ea2 toolkit/templates/QUALITY_CHECKLIST.md
|
|
99
99
|
2ba15299f149dca87d182ca65d8dccc3b27335c6ac31e01cc42afd02476d5dad toolkit/templates/README.md
|
|
100
100
|
bc778c499c534c3a0c4547c35d2fed02e745cefe743c1ed8a1074e1e0a88a8b2 toolkit/templates/SHARED_PLANNING.md
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sdtk-evolve
|
|
3
|
-
description: "Local self-improvement loop for SDTK
|
|
3
|
+
description: "Local self-improvement loop for SDTK. Harvest your own past agent sessions for recurring friction and stage at most 4 bounded, evidence-backed lesson edits to .sdtk/evolve/LEARNED.md for explicit human adoption. Use at the end of a substantial session or when the same correction keeps repeating."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# SDTK Evolve — learn from your own sessions, behind a human gate
|
|
@@ -63,5 +63,5 @@ Every turn produced while executing this skill is part of an evolve cycle. Begin
|
|
|
63
63
|
## Runtime Entrypoint Truth (Codex)
|
|
64
64
|
- Project-local Codex support is bounded to explicit `CODEX_HOME=<project>/.codex`; presence of `sdtk-evolve` under `.codex/skills` does not prove direct built-in exposure. Invoke via "Use the sdtk-evolve skill." when no direct syntax is validated.
|
|
65
65
|
|
|
66
|
-
## Effectiveness discipline
|
|
66
|
+
## Effectiveness discipline
|
|
67
67
|
The loop measures itself: recurrence verdicts are the metric, FAILING lessons get culled, and `sdtk evolve status` reminds the operator when the dogfood checkpoint (4 weeks / 20 sessions) is due. Never claim a lesson "works" without the recurrence evidence — flat/noisy results are reported as exactly that.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: evolve
|
|
3
|
-
description: Local self-improvement loop for SDTK
|
|
3
|
+
description: "Local self-improvement loop for SDTK. Harvest your own past agent sessions for recurring friction and stage at most 4 bounded, evidence-backed lesson edits to .sdtk/evolve/LEARNED.md for explicit human adoption. Use at the end of a substantial session or when the same correction keeps repeating."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# SDTK Evolve — learn from your own sessions, behind a human gate
|
|
@@ -60,5 +60,5 @@ Every turn produced while executing this skill is part of an evolve cycle. Begin
|
|
|
60
60
|
- It is **not** yours to edit directly, not a scratchpad, not a place for secrets or project data — lessons are about *how to work*, not *what the code is*.
|
|
61
61
|
- Git posture is the operator's choice (commit to share with a team, ignore for personal habits); `sdtk evolve status` shows the current posture.
|
|
62
62
|
|
|
63
|
-
## Effectiveness discipline
|
|
63
|
+
## Effectiveness discipline
|
|
64
64
|
The loop measures itself: recurrence verdicts are the metric, FAILING lessons get culled, and `sdtk evolve status` reminds the operator when the dogfood checkpoint (4 weeks / 20 sessions) is due. Never claim a lesson "works" without the recurrence evidence — flat/noisy results are reported as exactly that.
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
| 4 | Test obligations are explicit enough for downstream verification | [ ] Pending | Dev Agent | | |
|
|
75
75
|
| 5 | Readiness decision is explicit (`READY_FOR_SDTK_CODE` or `BLOCKED_FOR_SDTK_CODE`) | [ ] Pending | Dev Agent | | |
|
|
76
76
|
| 6 | `CODE_HANDOFF_[FEATURE_KEY].json` generated or validated successfully | [ ] Pending | Dev Agent | | |
|
|
77
|
-
| 7 | `sdtk-spec config check` passes (no UPDATE_ME placeholders
|
|
77
|
+
| 7 | `sdtk-spec config check` passes (no UPDATE_ME placeholders - stack/test commands are real) | [ ] Pending | Dev Agent | Run `sdtk-spec config apply-profile <name>` if unfilled | |
|
|
78
78
|
| **8** | **DEV READY FOR SDTK-CODE** | [ ] Pending | **Dev Gate** | **If ready: suggest `sdtk-code start ...`; if blocked: keep blockers visible** | |
|
|
79
79
|
|
|
80
80
|
---
|
package/package.json
CHANGED
package/src/commands/atlas.js
CHANGED
|
@@ -1,368 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const { parseFlags } = require("../lib/args");
|
|
3
|
+
const { spawn } = require("child_process");
|
|
6
4
|
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} = require("../lib/
|
|
14
|
-
const { runBuild, openViewer } = require("../lib/atlas-runner");
|
|
15
|
-
const { ValidationError } = require("../lib/errors");
|
|
16
|
-
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
// Shared flag definitions
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
const BASE_FLAG_DEFS = {
|
|
21
|
-
"project-path": { type: "string" },
|
|
22
|
-
"output-dir": { type: "string" },
|
|
23
|
-
"scan-root": { type: "string" },
|
|
24
|
-
verbose: { type: "boolean" },
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const OPEN_FLAG_DEFS = {
|
|
28
|
-
...BASE_FLAG_DEFS,
|
|
29
|
-
host: { type: "string" },
|
|
30
|
-
port: { type: "string" },
|
|
31
|
-
"no-open": { type: "boolean" },
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const INIT_FLAG_DEFS = {
|
|
35
|
-
...OPEN_FLAG_DEFS,
|
|
36
|
-
force: { type: "boolean" },
|
|
37
|
-
"no-build": { type: "boolean" },
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const WATCH_FLAG_DEFS = {
|
|
41
|
-
...BASE_FLAG_DEFS,
|
|
42
|
-
port: { type: "string" },
|
|
43
|
-
"no-open": { type: "boolean" },
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// ---------------------------------------------------------------------------
|
|
47
|
-
// Flag parsing with repeatable --scan-root support
|
|
48
|
-
// ---------------------------------------------------------------------------
|
|
5
|
+
USAGE_LINES,
|
|
6
|
+
WIKI_BIN,
|
|
7
|
+
WIKI_MISSING_LINES,
|
|
8
|
+
planDelegation,
|
|
9
|
+
resolveWikiBin,
|
|
10
|
+
} = require("../lib/atlas-delegate");
|
|
11
|
+
const { CliError } = require("../lib/errors");
|
|
49
12
|
|
|
50
13
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
14
|
+
* Spawn the resolved sdtk-wiki entry script with the current Node binary rather
|
|
15
|
+
* than the installed shim, so Windows never has to resolve a .cmd through
|
|
16
|
+
* PATHEXT (BK-F).
|
|
17
|
+
*
|
|
18
|
+
* @param {string} binPath - Absolute path to the sdtk-wiki entry script.
|
|
19
|
+
* @param {string[]} argv - Args to forward.
|
|
20
|
+
* @returns {Promise<number>} Child exit code.
|
|
54
21
|
*/
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
22
|
+
function runWiki(binPath, argv) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const child = spawn(process.execPath, [binPath, ...argv], {
|
|
25
|
+
stdio: "inherit",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
child.on("error", (err) => {
|
|
29
|
+
reject(new CliError(`Failed to start ${WIKI_BIN}: ${err.message}`));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
child.on("close", (code, signal) => {
|
|
33
|
+
if (signal) {
|
|
34
|
+
// Ctrl+C on a long-lived `open` / `watch` run is a normal exit here.
|
|
35
|
+
resolve(0);
|
|
36
|
+
return;
|
|
67
37
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
} else {
|
|
72
|
-
filteredArgs.push(arg);
|
|
73
|
-
i++;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const { flags, positional } = parseFlags(filteredArgs, defs);
|
|
78
|
-
// Inject the collected scan roots as an array
|
|
79
|
-
flags["scan-root"] = scanRoots.length > 0 ? scanRoots : undefined;
|
|
80
|
-
return { flags, positional };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// ---------------------------------------------------------------------------
|
|
84
|
-
// atlas init
|
|
85
|
-
// ---------------------------------------------------------------------------
|
|
86
|
-
async function cmdAtlasInit(args) {
|
|
87
|
-
const { flags } = parseAtlasFlags(args, INIT_FLAG_DEFS);
|
|
88
|
-
const config = resolveAtlasConfig(flags);
|
|
89
|
-
|
|
90
|
-
if (isAtlasInitialized(config.outputDir) && !flags.force) {
|
|
91
|
-
console.log(`[atlas] Atlas already initialized at: ${config.outputDir}`);
|
|
92
|
-
console.log("[atlas] Use --force to overwrite existing config.");
|
|
93
|
-
} else {
|
|
94
|
-
writeAtlasConfig(config);
|
|
95
|
-
console.log(`[atlas] Initialized Atlas config: ${config.configPath}`);
|
|
96
|
-
console.log(`[atlas] Project root: ${config.projectPath}`);
|
|
97
|
-
console.log(`[atlas] Output dir: ${config.outputDir}`);
|
|
98
|
-
console.log(`[atlas] Scan roots: ${config.scanRoots.join(", ")}`);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (flags["no-build"]) {
|
|
102
|
-
console.log("[atlas] --no-build specified; skipping initial build.");
|
|
103
|
-
return 0;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
console.log("");
|
|
107
|
-
const buildResult = await runBuild(config);
|
|
108
|
-
console.log(`[atlas] Build complete: ${buildResult.docCount} docs, ${buildResult.nodeCount} nodes, ${buildResult.edgeCount} edges.`);
|
|
109
|
-
|
|
110
|
-
if (flags["no-open"]) {
|
|
111
|
-
console.log("[atlas] --no-open specified; skipping viewer launch.");
|
|
112
|
-
return 0;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const { url } = await openViewer(config, false);
|
|
116
|
-
console.log(`[atlas] Viewer: ${url}`);
|
|
117
|
-
return 0;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// ---------------------------------------------------------------------------
|
|
121
|
-
// atlas build
|
|
122
|
-
// ---------------------------------------------------------------------------
|
|
123
|
-
async function cmdAtlasBuild(args) {
|
|
124
|
-
const { flags } = parseAtlasFlags(args, BASE_FLAG_DEFS);
|
|
125
|
-
const config = resolveAtlasConfig(flags);
|
|
126
|
-
|
|
127
|
-
if (!isAtlasInitialized(config.outputDir)) {
|
|
128
|
-
console.log("[atlas] Atlas not initialized. Run: sdtk-spec atlas init");
|
|
129
|
-
console.log(`[atlas] Output dir: ${config.outputDir}`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const startMs = Date.now();
|
|
133
|
-
const buildResult = await runBuild(config);
|
|
134
|
-
const durationMs = Date.now() - startMs;
|
|
135
|
-
|
|
136
|
-
console.log("");
|
|
137
|
-
console.log("[atlas] Build summary:");
|
|
138
|
-
console.log(` Documents: ${buildResult.docCount}`);
|
|
139
|
-
console.log(` Graph nodes: ${buildResult.nodeCount}`);
|
|
140
|
-
console.log(` Graph edges: ${buildResult.edgeCount}`);
|
|
141
|
-
console.log(` Output dir: ${config.outputDir}`);
|
|
142
|
-
console.log(` Duration: ${(durationMs / 1000).toFixed(1)}s`);
|
|
143
|
-
if (buildResult.generated) {
|
|
144
|
-
console.log(` Generated: ${buildResult.generated}`);
|
|
145
|
-
}
|
|
146
|
-
return 0;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// ---------------------------------------------------------------------------
|
|
150
|
-
// atlas open
|
|
151
|
-
// ---------------------------------------------------------------------------
|
|
152
|
-
async function cmdAtlasOpen(args) {
|
|
153
|
-
const { flags } = parseAtlasFlags(args, OPEN_FLAG_DEFS);
|
|
154
|
-
const config = resolveAtlasConfig(flags);
|
|
155
|
-
|
|
156
|
-
if (!isAtlasBuilt(config.outputDir)) {
|
|
157
|
-
console.error("[atlas] No atlas build found.");
|
|
158
|
-
console.error(` Expected: ${config.outputDir}/viewer.html`);
|
|
159
|
-
console.error(" Run: sdtk-spec atlas init");
|
|
160
|
-
console.error(" Or: sdtk-spec atlas build");
|
|
161
|
-
return 1;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const noOpen = !!flags["no-open"];
|
|
165
|
-
const { url } = await openViewer(config, noOpen);
|
|
166
|
-
|
|
167
|
-
if (!noOpen) {
|
|
168
|
-
// If the server was started inline, keep it alive until user exits
|
|
169
|
-
console.log("[atlas] Press Ctrl+C to stop the viewer server.");
|
|
170
|
-
await new Promise(() => {}); // keep alive
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return 0;
|
|
38
|
+
resolve(code === null ? 1 : code);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
174
41
|
}
|
|
175
42
|
|
|
176
|
-
//
|
|
177
|
-
//
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
const config = resolveAtlasConfig(flags);
|
|
182
|
-
|
|
183
|
-
if (!isAtlasInitialized(config.outputDir)) {
|
|
184
|
-
console.log("[atlas] Atlas not initialized. Running init first...");
|
|
185
|
-
writeAtlasConfig(config);
|
|
186
|
-
console.log(`[atlas] Initialized Atlas config: ${config.configPath}`);
|
|
187
|
-
}
|
|
43
|
+
// `deps` = { resolveWikiBin, runWiki } — injected by tests so both the resolved
|
|
44
|
+
// and the not-installed branch are exercisable without a real install.
|
|
45
|
+
async function cmdAtlas(args, deps = {}) {
|
|
46
|
+
const resolve = deps.resolveWikiBin || resolveWikiBin;
|
|
47
|
+
const run = deps.runWiki || runWiki;
|
|
188
48
|
|
|
189
|
-
const
|
|
190
|
-
let debounceTimer = null;
|
|
191
|
-
let rebuilding = false;
|
|
49
|
+
const plan = planDelegation(args);
|
|
192
50
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
console.log(`\n[atlas] Change detected (${reason}). Rebuilding...`);
|
|
197
|
-
try {
|
|
198
|
-
const buildResult = await runBuild(config);
|
|
199
|
-
console.log(`[atlas] Rebuild complete: ${buildResult.docCount} docs, ${buildResult.nodeCount} nodes.`);
|
|
200
|
-
} catch (err) {
|
|
201
|
-
console.error(`[atlas] Rebuild failed: ${err.message}`);
|
|
202
|
-
} finally {
|
|
203
|
-
rebuilding = false;
|
|
51
|
+
if (plan.usage) {
|
|
52
|
+
for (const line of USAGE_LINES) {
|
|
53
|
+
console.error(line);
|
|
204
54
|
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Initial build
|
|
208
|
-
console.log("[atlas] Running initial build...");
|
|
209
|
-
try {
|
|
210
|
-
const buildResult = await runBuild(config);
|
|
211
|
-
console.log(`[atlas] Initial build complete: ${buildResult.docCount} docs.`);
|
|
212
|
-
} catch (err) {
|
|
213
|
-
console.error(`[atlas] Initial build failed: ${err.message}`);
|
|
214
|
-
// Continue watching even if initial build fails
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Open viewer unless --no-open
|
|
218
|
-
let viewerServer = null;
|
|
219
|
-
if (!flags["no-open"] && isAtlasBuilt(config.outputDir)) {
|
|
220
|
-
const result = await openViewer(config, false);
|
|
221
|
-
viewerServer = result.server;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Watch each scan root for markdown changes
|
|
225
|
-
const watchers = [];
|
|
226
|
-
for (const scanRoot of config.scanRoots) {
|
|
227
|
-
if (!fs.existsSync(scanRoot)) {
|
|
228
|
-
console.log(`[atlas] Warning: scan root does not exist, skipping watch: ${scanRoot}`);
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
try {
|
|
233
|
-
const watcher = fs.watch(scanRoot, { recursive: true }, (eventType, filename) => {
|
|
234
|
-
if (!filename || !filename.endsWith(".md")) return;
|
|
235
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
236
|
-
debounceTimer = setTimeout(() => {
|
|
237
|
-
rebuild(`${eventType}: ${filename}`);
|
|
238
|
-
}, DEBOUNCE_MS);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
watcher.on("error", (err) => {
|
|
242
|
-
console.error(`[atlas] Watch error on ${scanRoot}: ${err.message}`);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
watchers.push(watcher);
|
|
246
|
-
console.log(`[atlas] Watching: ${scanRoot}`);
|
|
247
|
-
} catch (err) {
|
|
248
|
-
console.error(`[atlas] Could not watch ${scanRoot}: ${err.message}`);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (watchers.length === 0) {
|
|
253
|
-
console.error("[atlas] No scan roots could be watched. Exiting.");
|
|
254
55
|
return 1;
|
|
255
56
|
}
|
|
256
57
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
console.log("\n[atlas] Stopping watch...");
|
|
262
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
263
|
-
for (const w of watchers) {
|
|
264
|
-
try { w.close(); } catch (_) {}
|
|
265
|
-
}
|
|
266
|
-
if (viewerServer) {
|
|
267
|
-
try { viewerServer.close(); } catch (_) {}
|
|
58
|
+
const binPath = resolve();
|
|
59
|
+
if (!binPath) {
|
|
60
|
+
for (const line of WIKI_MISSING_LINES) {
|
|
61
|
+
console.error(line);
|
|
268
62
|
}
|
|
269
|
-
|
|
63
|
+
return 2;
|
|
270
64
|
}
|
|
271
65
|
|
|
272
|
-
|
|
273
|
-
|
|
66
|
+
console.log(
|
|
67
|
+
`[atlas] Delegating to "${WIKI_BIN} ${plan.argv.join(" ")}" — sdtk-wiki owns the graph builder.`
|
|
68
|
+
);
|
|
69
|
+
console.log(
|
|
70
|
+
"[atlas] Graph output defaults to .sdtk/wiki/graph; pass --output-dir to choose another location."
|
|
71
|
+
);
|
|
274
72
|
|
|
275
|
-
|
|
276
|
-
await new Promise(() => {});
|
|
277
|
-
return 0;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// ---------------------------------------------------------------------------
|
|
281
|
-
// atlas status
|
|
282
|
-
// ---------------------------------------------------------------------------
|
|
283
|
-
async function cmdAtlasStatus(args) {
|
|
284
|
-
const { flags } = parseAtlasFlags(args, BASE_FLAG_DEFS);
|
|
285
|
-
|
|
286
|
-
// Use defaults-only resolution (no validation errors for status)
|
|
287
|
-
let config;
|
|
288
|
-
try {
|
|
289
|
-
config = resolveAtlasConfig(flags);
|
|
290
|
-
} catch (err) {
|
|
291
|
-
console.error(`[atlas] Config error: ${err.message}`);
|
|
292
|
-
return 1;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const initialized = isAtlasInitialized(config.outputDir);
|
|
296
|
-
const built = isAtlasBuilt(config.outputDir);
|
|
297
|
-
|
|
298
|
-
console.log("[atlas] Status");
|
|
299
|
-
console.log("=".repeat(40));
|
|
300
|
-
console.log(` Initialized: ${initialized ? "yes" : "no"}`);
|
|
301
|
-
console.log(` Built: ${built ? "yes" : "no"}`);
|
|
302
|
-
console.log(` Project root: ${config.projectPath}`);
|
|
303
|
-
console.log(` Output dir: ${config.outputDir}`);
|
|
304
|
-
console.log(` Scan roots: ${config.scanRoots.join(", ")}`);
|
|
305
|
-
console.log(` Viewer host: ${config.host}:${config.port}`);
|
|
306
|
-
|
|
307
|
-
if (built) {
|
|
308
|
-
const meta = readBuildMeta(config.outputDir);
|
|
309
|
-
const graphMeta = readGraphMeta(config.outputDir);
|
|
310
|
-
if (meta) {
|
|
311
|
-
console.log(` Last build: ${meta.generated || "unknown"}`);
|
|
312
|
-
console.log(` Documents: ${meta.count}`);
|
|
313
|
-
}
|
|
314
|
-
if (graphMeta) {
|
|
315
|
-
console.log(` Graph nodes: ${graphMeta.nodeCount}`);
|
|
316
|
-
console.log(` Graph edges: ${graphMeta.edgeCount}`);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (!initialized) {
|
|
321
|
-
console.log("");
|
|
322
|
-
console.log("[atlas] Hint: run 'sdtk-spec atlas init' to initialize Atlas for this project.");
|
|
323
|
-
} else if (!built) {
|
|
324
|
-
console.log("");
|
|
325
|
-
console.log("[atlas] Hint: run 'sdtk-spec atlas build' to build the local document graph.");
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
return 0;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// ---------------------------------------------------------------------------
|
|
332
|
-
// Top-level atlas dispatcher
|
|
333
|
-
// ---------------------------------------------------------------------------
|
|
334
|
-
const ATLAS_SUBCOMMANDS = new Set(["init", "build", "open", "watch", "status"]);
|
|
335
|
-
|
|
336
|
-
async function cmdAtlas(args) {
|
|
337
|
-
if (!args || args.length === 0) {
|
|
338
|
-
console.error("[atlas] Usage: sdtk-spec atlas <subcommand> [options]");
|
|
339
|
-
console.error(" Subcommands: init, build, open, watch, status");
|
|
340
|
-
console.error(" Run 'sdtk-spec --help' for full usage.");
|
|
341
|
-
return 1;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
const [subcommand, ...rest] = args;
|
|
345
|
-
|
|
346
|
-
if (!ATLAS_SUBCOMMANDS.has(subcommand)) {
|
|
347
|
-
throw new ValidationError(
|
|
348
|
-
`Unknown atlas subcommand: "${subcommand}". Valid subcommands: init, build, open, watch, status.`
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
switch (subcommand) {
|
|
353
|
-
case "init":
|
|
354
|
-
return cmdAtlasInit(rest);
|
|
355
|
-
case "build":
|
|
356
|
-
return cmdAtlasBuild(rest);
|
|
357
|
-
case "open":
|
|
358
|
-
return cmdAtlasOpen(rest);
|
|
359
|
-
case "watch":
|
|
360
|
-
return cmdAtlasWatch(rest);
|
|
361
|
-
case "status":
|
|
362
|
-
return cmdAtlasStatus(rest);
|
|
363
|
-
}
|
|
73
|
+
return run(binPath, plan.argv);
|
|
364
74
|
}
|
|
365
75
|
|
|
366
76
|
module.exports = {
|
|
367
77
|
cmdAtlas,
|
|
78
|
+
runWiki,
|
|
368
79
|
};
|