sdtk-spec-kit 0.6.0 → 0.7.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 +12 -3
- package/assets/manifest/toolkit-bundle.manifest.json +6 -6
- package/assets/manifest/toolkit-bundle.sha256.txt +2 -2
- package/assets/toolkit/toolkit/skills/sdtk-evolve/SKILL.md +4 -4
- package/assets/toolkit/toolkit/skills-claude/evolve/SKILL.md +4 -4
- package/package.json +1 -1
- package/src/commands/help.js +4 -0
- package/src/commands/project-help.js +120 -0
- package/src/commands/project.js +18 -0
- package/src/lib/project-promote.js +44 -9
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.7.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.
|
|
@@ -268,8 +268,11 @@ Run premium project intelligence workflows against an existing consumer reposito
|
|
|
268
268
|
sdtk-spec project ingest # Build deterministic project foundation + staged docs baseline (Pro)
|
|
269
269
|
sdtk-spec project audit # Read-only readiness / risk / gap audit (Pro)
|
|
270
270
|
sdtk-spec project refresh # Incrementally refresh managed .sdtk/project/ artifacts (Pro)
|
|
271
|
+
sdtk-spec project promote # Publish reviewed staged docs into docs/ for sdtk-wiki (free; dry-run by default)
|
|
271
272
|
```
|
|
272
273
|
|
|
274
|
+
Every verb accepts `--help` for verb-scoped usage, e.g. `sdtk-spec project promote --help`.
|
|
275
|
+
|
|
273
276
|
Examples:
|
|
274
277
|
|
|
275
278
|
```bash
|
|
@@ -281,17 +284,23 @@ sdtk-spec project audit --project-path ./my-project --json
|
|
|
281
284
|
|
|
282
285
|
# Incrementally refresh foundation, evidence packs, and staged docs baseline
|
|
283
286
|
sdtk-spec project refresh --project-path ./my-project
|
|
287
|
+
|
|
288
|
+
# Publish the reviewed staged docs baseline into docs/ (dry-run first, then apply)
|
|
289
|
+
sdtk-spec project promote --project-path ./my-project
|
|
290
|
+
sdtk-spec project promote --project-path ./my-project --apply
|
|
284
291
|
```
|
|
285
292
|
|
|
286
293
|
Key facts:
|
|
287
294
|
|
|
288
295
|
- `project ingest`, `project audit`, and `project refresh` are Pro features.
|
|
289
296
|
- All three commands require a valid Pro entitlement (unlock with `sdtk-spec activate --license`) and a cached premium pack.
|
|
290
|
-
-
|
|
297
|
+
- `project promote` is **free**: it only copies the already-generated staged docs baseline into live `docs/`. No entitlement or premium pack is required.
|
|
298
|
+
- All Pro artifacts stay project-local under `<project>/.sdtk/project/`.
|
|
291
299
|
- `project ingest` writes reusable foundation artifacts such as census, source inventory, profile, module graph, runtime markers, evidence packs, and a staged docs baseline.
|
|
292
300
|
- `project audit` is read-only. It does not mutate live `/docs/`, write new staged docs, or refresh ingest artifacts in place.
|
|
293
301
|
- `project refresh` is incremental and requires an existing managed ingest baseline.
|
|
294
|
-
-
|
|
302
|
+
- `project promote` is a dry-run by default; it classifies existing live docs as identical (`=`) or differing (`≠`) from staged, skips differing docs unless `--force` is given, and only writes on `--apply`.
|
|
303
|
+
- None of the Pro project commands modify live `/docs/`; draft outputs remain under `.sdtk/project/`. `promote` is the one verb that writes into `docs/`, and only with `--apply`.
|
|
295
304
|
- Maintainer-root guardrails block using the SDTK maintainer monorepo root as a premium project target.
|
|
296
305
|
|
|
297
306
|
### `sdtk-spec runtime`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
3
|
-
"sourceCommit": "
|
|
2
|
+
"version": "0.6.1",
|
|
3
|
+
"sourceCommit": "958c734ede338089150af3f802b3e2a407c78748",
|
|
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": "d345ac17251f28a3a7b428a20aa8d6a8675bf8c2cfd1c03c5ca35e22fb8f0041",
|
|
144
|
+
"size": 7660
|
|
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": "6fe9b6657f11dd4b9a9ecf2a40a1fefab80b9a743e1c1af057ca541be390421a",
|
|
244
|
+
"size": 7987
|
|
245
245
|
},
|
|
246
246
|
{
|
|
247
247
|
"path": "toolkit/skills/sdtk-mailbox-dispatch/SKILL.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
|
+
d345ac17251f28a3a7b428a20aa8d6a8675bf8c2cfd1c03c5ca35e22fb8f0041 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
|
+
6fe9b6657f11dd4b9a9ecf2a40a1fefab80b9a743e1c1af057ca541be390421a 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
|
|
@@ -5,14 +5,14 @@ description: "Local self-improvement loop for SDTK (BK-316). Harvest the operato
|
|
|
5
5
|
|
|
6
6
|
# SDTK Evolve — learn from your own sessions, behind a human gate
|
|
7
7
|
|
|
8
|
-
Every turn produced while executing this skill is part of an
|
|
8
|
+
Every turn produced while executing this skill is part of an evolve cycle. Begin your first reply with the literal, versioned marker line `<!-- sdtk-evolve:harvest-session:v1 -->` — future harvests use it to skip evolve-generated content, so the loop never mines itself. (Harvest filters must also skip content carrying the legacy `SDTK-EVOLVE CYCLE` marker from older sessions.)
|
|
9
9
|
|
|
10
10
|
## Critical Constraints
|
|
11
11
|
- I propose **at most 4** bounded edits per cycle — `add`, `delete`, or `replace` of single bullets — and I never rewrite the learned document wholesale.
|
|
12
12
|
- I **never edit** `.sdtk/evolve/LEARNED.md`, `state.json`, or any live file myself. `sdtk evolve stage` is the only writer of staging; only the human's `sdtk evolve adopt` applies it (there is **no auto-adopt** — the flag does not exist), and `sdtk evolve revert` restores the pre-adopt backup.
|
|
13
13
|
- Every proposed edit carries **evidence** (which sessions, how many occurrences) and a pre-registered falsifiable **bet** ("friction signature X stops appearing"). No measurable bet → the edit is dropped, not softened.
|
|
14
14
|
- Redaction is **fail-closed**: secrets, tokens, PII, prompts, and full transcripts never enter a draft. When unsure whether content is sensitive, describe it — never copy it. (`sdtk evolve stage` re-scans and refuses on any hit.)
|
|
15
|
-
- I never guess the Codex session-log format: the Codex harvest path follows the
|
|
15
|
+
- I never guess the Codex session-log format: the Codex harvest path follows the format validated by the issue #247 report only, and stays **gated** until the marker-persistence integration proof exists — the Claude path proceeds regardless.
|
|
16
16
|
- Opinion-only lessons (no falsifiable claim) may enter only as preference bullets and never override correctness lessons.
|
|
17
17
|
|
|
18
18
|
## When to run
|
|
@@ -25,8 +25,8 @@ Every turn produced while executing this skill is part of an **SDTK-EVOLVE CYCLE
|
|
|
25
25
|
1. **Load state.** Run `sdtk evolve status`. Read `.sdtk/evolve/state.json` (last harvest time, adopted lessons with signatures) and `.sdtk/evolve/LEARNED.md` (current lessons + line count vs the **150**-line cap). If the CLI is unavailable, stop and tell the operator to update `sdtk-kit` (the `evolve` CLI ships with sdtk-kit ≥ 1.16.0) — do **not** hand-write staging files.
|
|
26
26
|
2. **Harvest.** Scan sessions since the last harvest:
|
|
27
27
|
- **Claude Code (if present on this machine):** `~/.claude/projects/<project-slug>/*.jsonl` — extract per-session digests: user intents, tool usage, and correction signals (negative: "vẫn sai", "làm lại", "that's wrong", "I told you", "again"; positive: "perfect", "đúng rồi", "great").
|
|
28
|
-
- **Codex:**
|
|
29
|
-
- **Filters (both sources):** skip meta prompts (bare skill invocations, pasted-text stubs, system noise) and skip any content carrying the `SDTK-EVOLVE CYCLE` marker (self-pollution guard).
|
|
28
|
+
- **Codex — format validated, harvest GATED:** the on-disk format is ground-truthed by `governance/ai/reviews/shared/SDTK_BK316_CODEX_HARVEST_VALIDATION_R1_20260710.md` (Codex CLI 0.144.1). When enabled, follow its rules exactly: scan `$CODEX_HOME/sessions/**/*.jsonl` recursively as the primary source (CODEX_HOME defaults to `~/.codex`) plus `archived_sessions/*.jsonl` as legacy input deduped by session id; extract ONLY canonical `response_item` records with `payload.type=="message" && payload.role=="user"`, taking `content[]` blocks of type `input_text` — never `event_msg` duplicates of the same turn, never developer-role records, never `<environment_context>`/AGENTS wrappers; require a filename-matching `session_meta` with non-empty `cwd` (project attribution) or skip the file fail-closed; pre-scan the WHOLE file for the self-pollution marker (v1 or legacy) and exclude the entire file on a match; never read tool `arguments`/`output`; stream large files rather than loading them whole. **Codex harvest remains gated until an integration proof shows the marker persists in a real Codex evolve session (report §7 condition 6)** — until then, note "codex: gated (marker persistence proof pending)" in the report and harvest Claude only.
|
|
29
|
+
- **Filters (both sources):** skip meta prompts (bare skill invocations, pasted-text stubs, system noise) and skip any content carrying the `<!-- sdtk-evolve:harvest-session:v1 -->` marker or the legacy `SDTK-EVOLVE CYCLE` marker (self-pollution guard).
|
|
30
30
|
3. **Score recurrence** for every adopted lesson: did its signature re-appear in post-adoption sessions? Render the verdict table — `WORKING` (no recurrence) or `FAILING` (recurred). A lesson FAILING for 2 consecutive cycles **must** get a `replace` or `delete` proposal before any new `add`. The same rule applies when `LEARNED.md` is over the 150-line cap.
|
|
31
31
|
4. **Reflect.** From the harvested friction, draft **at most 4** edits targeting the lane sections of `LEARNED.md` (`## Chung`, `## SPEC`, `## CODE`, `## OPS`, `## DESIGN`). Prefer one excellent lesson over four mediocre ones. Write the draft to a scratch file using this contract:
|
|
32
32
|
|
|
@@ -5,14 +5,14 @@ description: Local self-improvement loop for SDTK (BK-316). Harvest the operator
|
|
|
5
5
|
|
|
6
6
|
# SDTK Evolve — learn from your own sessions, behind a human gate
|
|
7
7
|
|
|
8
|
-
Every turn produced while executing this skill is part of an
|
|
8
|
+
Every turn produced while executing this skill is part of an evolve cycle. Begin your first reply with the literal, versioned marker line `<!-- sdtk-evolve:harvest-session:v1 -->` — future harvests use it to skip evolve-generated content, so the loop never mines itself. (Harvest filters must also skip content carrying the legacy `SDTK-EVOLVE CYCLE` marker from older sessions.)
|
|
9
9
|
|
|
10
10
|
## Critical Constraints
|
|
11
11
|
- I propose **at most 4** bounded edits per cycle — `add`, `delete`, or `replace` of single bullets — and I never rewrite the learned document wholesale.
|
|
12
12
|
- I **never edit** `.sdtk/evolve/LEARNED.md`, `state.json`, or any live file myself. `sdtk evolve stage` is the only writer of staging; only the human's `sdtk evolve adopt` applies it (there is **no auto-adopt** — the flag does not exist), and `sdtk evolve revert` restores the pre-adopt backup.
|
|
13
13
|
- Every proposed edit carries **evidence** (which sessions, how many occurrences) and a pre-registered falsifiable **bet** ("friction signature X stops appearing"). No measurable bet → the edit is dropped, not softened.
|
|
14
14
|
- Redaction is **fail-closed**: secrets, tokens, PII, prompts, and full transcripts never enter a draft. When unsure whether content is sensitive, describe it — never copy it. (`sdtk evolve stage` re-scans and refuses on any hit.)
|
|
15
|
-
- I never guess the Codex session-log format: the Codex harvest path follows the
|
|
15
|
+
- I never guess the Codex session-log format: the Codex harvest path follows the format validated by the issue #247 report only, and stays **gated** until the marker-persistence integration proof exists — the Claude path proceeds regardless.
|
|
16
16
|
- Opinion-only lessons (no falsifiable claim) may enter only as preference bullets and never override correctness lessons.
|
|
17
17
|
|
|
18
18
|
## When to run
|
|
@@ -25,8 +25,8 @@ Every turn produced while executing this skill is part of an **SDTK-EVOLVE CYCLE
|
|
|
25
25
|
1. **Load state.** Run `sdtk evolve status`. Read `.sdtk/evolve/state.json` (last harvest time, adopted lessons with signatures) and `.sdtk/evolve/LEARNED.md` (current lessons + line count vs the **150**-line cap). If the CLI is unavailable, stop and tell the operator to update `sdtk-kit` (the `evolve` CLI ships with sdtk-kit ≥ 1.16.0) — do **not** hand-write staging files.
|
|
26
26
|
2. **Harvest.** Scan sessions since the last harvest:
|
|
27
27
|
- **Claude Code:** `~/.claude/projects/<project-slug>/*.jsonl` — extract per-session digests: user intents, tool usage, and correction signals (negative: "vẫn sai", "làm lại", "that's wrong", "I told you", "again"; positive: "perfect", "đúng rồi", "great").
|
|
28
|
-
- **Codex:**
|
|
29
|
-
- **Filters (both sources):** skip meta prompts (bare slash commands, pasted-text stubs, system noise) and skip any content carrying the `SDTK-EVOLVE CYCLE` marker (self-pollution guard).
|
|
28
|
+
- **Codex — format validated, harvest GATED:** the on-disk format is ground-truthed by `governance/ai/reviews/shared/SDTK_BK316_CODEX_HARVEST_VALIDATION_R1_20260710.md` (Codex CLI 0.144.1). When enabled, follow its rules exactly: scan `$CODEX_HOME/sessions/**/*.jsonl` recursively as the primary source (CODEX_HOME defaults to `~/.codex`) plus `archived_sessions/*.jsonl` as legacy input deduped by session id; extract ONLY canonical `response_item` records with `payload.type=="message" && payload.role=="user"`, taking `content[]` blocks of type `input_text` — never `event_msg` duplicates of the same turn, never developer-role records, never `<environment_context>`/AGENTS wrappers; require a filename-matching `session_meta` with non-empty `cwd` (project attribution) or skip the file fail-closed; pre-scan the WHOLE file for the self-pollution marker (v1 or legacy) and exclude the entire file on a match; never read tool `arguments`/`output`; stream large files rather than loading them whole. **Codex harvest remains gated until an integration proof shows the marker persists in a real Codex evolve session (report §7 condition 6)** — until then, note "codex: gated (marker persistence proof pending)" in the report and harvest Claude only.
|
|
29
|
+
- **Filters (both sources):** skip meta prompts (bare slash commands, pasted-text stubs, system noise) and skip any content carrying the `<!-- sdtk-evolve:harvest-session:v1 -->` marker or the legacy `SDTK-EVOLVE CYCLE` marker (self-pollution guard).
|
|
30
30
|
3. **Score recurrence** for every adopted lesson: did its signature re-appear in post-adoption sessions? Render the verdict table — `WORKING` (no recurrence) or `FAILING` (recurred). A lesson FAILING for 2 consecutive cycles **must** get a `replace` or `delete` proposal before any new `add`. The same rule applies when `LEARNED.md` is over the 150-line cap.
|
|
31
31
|
4. **Reflect.** From the harvested friction, draft **at most 4** edits targeting the lane sections of `LEARNED.md` (`## Chung`, `## SPEC`, `## CODE`, `## OPS`, `## DESIGN`). Prefer one excellent lesson over four mediocre ones. Write the draft to a scratch file using this contract:
|
|
32
32
|
|
package/package.json
CHANGED
package/src/commands/help.js
CHANGED
|
@@ -284,6 +284,10 @@ function cmdHelp() {
|
|
|
284
284
|
" sdtk-spec project audit --project-path ./my-project --json",
|
|
285
285
|
" sdtk-spec project refresh --project-path ./my-project",
|
|
286
286
|
" sdtk-spec project refresh --project-path ./my-project --json",
|
|
287
|
+
" sdtk-spec project promote --project-path ./my-project",
|
|
288
|
+
" sdtk-spec project promote --project-path ./my-project --apply",
|
|
289
|
+
" sdtk-spec project promote --project-path ./my-project --apply --force",
|
|
290
|
+
" sdtk-spec project promote --project-path ./my-project --json",
|
|
287
291
|
"",
|
|
288
292
|
" # Override entitlement repo (bash/zsh):",
|
|
289
293
|
" export SDTK_ENTITLEMENT_REPO=owner/repo",
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// BK-338: per-verb help for `sdtk-spec project <verb> --help`.
|
|
4
|
+
//
|
|
5
|
+
// Before this, every project verb rejected `--help` ("Unknown flag") because
|
|
6
|
+
// the flag was not in its FLAG_DEFS. Help is centralized (not command-local
|
|
7
|
+
// like sdtk-wiki), so this module renders one help block per verb. The flag
|
|
8
|
+
// lists here MUST match each verb's *_FLAG_DEFS; the parity test
|
|
9
|
+
// (test_sdtk_spec_project_help_parity.py) fails the build if they drift.
|
|
10
|
+
|
|
11
|
+
const PROJECT_VERB_HELP = {
|
|
12
|
+
ingest: {
|
|
13
|
+
summary: "Build reusable project census and profile foundation from an existing repo (Pro).",
|
|
14
|
+
usage: "sdtk-spec project ingest [options]",
|
|
15
|
+
tier: "Pro",
|
|
16
|
+
flags: [
|
|
17
|
+
["--project-path <path>", "Target project directory to ingest (default: cwd)"],
|
|
18
|
+
["--output-dir <path>", "Foundation output directory (default: <project>/.sdtk/project)"],
|
|
19
|
+
["--json", "Print result summary as JSON"],
|
|
20
|
+
],
|
|
21
|
+
notes: [
|
|
22
|
+
"Requires a valid Pro entitlement and a cached premium pack.",
|
|
23
|
+
"Stages a draft SDTK docs baseline under .sdtk/project/DOC_SYNTHESIS_BASELINE/.",
|
|
24
|
+
"Live project /docs/ is not modified by project ingest.",
|
|
25
|
+
"Maintainer-root guard: refuses the SDTK maintainer monorepo root as an ingest target.",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
audit: {
|
|
29
|
+
summary: "Read-only audit: readiness score, gap list, risk list, next steps (Pro).",
|
|
30
|
+
usage: "sdtk-spec project audit [options]",
|
|
31
|
+
tier: "Pro",
|
|
32
|
+
flags: [
|
|
33
|
+
["--project-path <path>", "Target project directory to audit (default: cwd)"],
|
|
34
|
+
["--output-dir <path>", "Foundation read path (default: <project>/.sdtk/project)"],
|
|
35
|
+
["--json", "Print audit result as deterministic JSON"],
|
|
36
|
+
],
|
|
37
|
+
notes: [
|
|
38
|
+
"Requires a valid Pro entitlement and a cached premium pack.",
|
|
39
|
+
"Read-only: does not modify live /docs/ or write new staged/foundation artifacts.",
|
|
40
|
+
"Uses cached ingest artifacts when present; otherwise bounded ephemeral analysis.",
|
|
41
|
+
"Maintainer-root guard: refuses the SDTK maintainer monorepo root as an audit target.",
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
refresh: {
|
|
45
|
+
summary: "Incremental managed refresh of .sdtk/project/ artifacts (Pro).",
|
|
46
|
+
usage: "sdtk-spec project refresh [options]",
|
|
47
|
+
tier: "Pro",
|
|
48
|
+
flags: [
|
|
49
|
+
["--project-path <path>", "Target project directory to refresh (default: cwd)"],
|
|
50
|
+
["--output-dir <path>", "Foundation output directory (default: <project>/.sdtk/project)"],
|
|
51
|
+
["--json", "Print result summary as JSON"],
|
|
52
|
+
],
|
|
53
|
+
notes: [
|
|
54
|
+
"Requires a valid Pro entitlement and a cached premium pack.",
|
|
55
|
+
"Incremental: requires an existing managed ingest baseline (run 'project ingest' first).",
|
|
56
|
+
"Updates only .sdtk/project/ artifacts; does not modify live /docs/.",
|
|
57
|
+
"Maintainer-root guard: refuses the SDTK maintainer monorepo root as a refresh target.",
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
promote: {
|
|
61
|
+
summary: "Publish reviewed staged docs into /docs/ for sdtk-wiki (free; dry-run by default).",
|
|
62
|
+
usage: "sdtk-spec project promote [options]",
|
|
63
|
+
tier: "free",
|
|
64
|
+
flags: [
|
|
65
|
+
["--project-path <path>", "Target project directory (default: cwd)"],
|
|
66
|
+
["--output-dir <path>", "Foundation read path (default: <project>/.sdtk/project)"],
|
|
67
|
+
["--apply", "Perform the copy (default is a dry-run plan only)"],
|
|
68
|
+
["--force", "Overwrite existing live docs (default: skip existing)"],
|
|
69
|
+
["--json", "Print the promote plan/result as JSON"],
|
|
70
|
+
],
|
|
71
|
+
notes: [
|
|
72
|
+
"Free: publishes staged docs from .sdtk/project/DOC_SYNTHESIS_BASELINE/docs/ into <project>/docs/.",
|
|
73
|
+
"Default is a dry-run that prints the plan and writes nothing; add --apply to publish.",
|
|
74
|
+
"Existing live docs are classified as identical (=) or differing (≠) from staged;",
|
|
75
|
+
" differing docs are skipped unless --force is given (human-review-first).",
|
|
76
|
+
"After promote, run 'sdtk-wiki atlas build' to index the docs into the knowledge graph.",
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
function renderProjectVerbHelp(verb) {
|
|
82
|
+
const h = PROJECT_VERB_HELP[verb];
|
|
83
|
+
if (!h) return null;
|
|
84
|
+
const lines = [
|
|
85
|
+
`sdtk-spec project ${verb} — ${h.summary}`,
|
|
86
|
+
"",
|
|
87
|
+
"Usage:",
|
|
88
|
+
` ${h.usage}`,
|
|
89
|
+
"",
|
|
90
|
+
`Options (${h.tier}):`,
|
|
91
|
+
];
|
|
92
|
+
for (const [flag, desc] of h.flags) {
|
|
93
|
+
lines.push(` ${flag.padEnd(26)} ${desc}`);
|
|
94
|
+
}
|
|
95
|
+
lines.push("", "Notes:");
|
|
96
|
+
for (const note of h.notes) lines.push(` - ${note}`);
|
|
97
|
+
return lines.join("\n");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function renderProjectOverview() {
|
|
101
|
+
const lines = [
|
|
102
|
+
"sdtk-spec project — existing-project intelligence subcommands",
|
|
103
|
+
"",
|
|
104
|
+
"Usage:",
|
|
105
|
+
" sdtk-spec project <subcommand> [options]",
|
|
106
|
+
" sdtk-spec project <subcommand> --help Show verb-specific help",
|
|
107
|
+
"",
|
|
108
|
+
"Subcommands:",
|
|
109
|
+
];
|
|
110
|
+
for (const [verb, h] of Object.entries(PROJECT_VERB_HELP)) {
|
|
111
|
+
lines.push(` ${verb.padEnd(9)} ${h.summary}`);
|
|
112
|
+
}
|
|
113
|
+
return lines.join("\n");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
module.exports = {
|
|
117
|
+
PROJECT_VERB_HELP,
|
|
118
|
+
renderProjectVerbHelp,
|
|
119
|
+
renderProjectOverview,
|
|
120
|
+
};
|
package/src/commands/project.js
CHANGED
|
@@ -4,10 +4,15 @@ const { runProjectIngest } = require("../lib/project-ingest");
|
|
|
4
4
|
const { runProjectAudit } = require("../lib/project-audit");
|
|
5
5
|
const { runProjectRefresh } = require("../lib/project-refresh");
|
|
6
6
|
const { runProjectPromote } = require("../lib/project-promote");
|
|
7
|
+
const { renderProjectVerbHelp, renderProjectOverview } = require("./project-help");
|
|
7
8
|
const { ValidationError } = require("../lib/errors");
|
|
8
9
|
|
|
9
10
|
const PROJECT_SUBCOMMANDS = new Set(["ingest", "audit", "refresh", "promote"]);
|
|
10
11
|
|
|
12
|
+
function wantsHelp(args) {
|
|
13
|
+
return args.some((a) => a === "-h" || a === "--help");
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
/**
|
|
12
17
|
* Top-level dispatcher for `sdtk-spec project <subcommand>`.
|
|
13
18
|
*
|
|
@@ -34,12 +39,25 @@ async function cmdProject(args) {
|
|
|
34
39
|
|
|
35
40
|
const [subcommand, ...rest] = args;
|
|
36
41
|
|
|
42
|
+
// BK-338: `sdtk-spec project --help` / `-h` prints the verb overview (exit 0).
|
|
43
|
+
if (subcommand === "-h" || subcommand === "--help") {
|
|
44
|
+
console.log(renderProjectOverview());
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
37
48
|
if (!PROJECT_SUBCOMMANDS.has(subcommand)) {
|
|
38
49
|
throw new ValidationError(
|
|
39
50
|
`Unknown project subcommand: "${subcommand}". Valid subcommands: ingest, audit, refresh, promote.`
|
|
40
51
|
);
|
|
41
52
|
}
|
|
42
53
|
|
|
54
|
+
// BK-338: `sdtk-spec project <verb> --help` prints verb-scoped help (exit 0),
|
|
55
|
+
// never touching entitlement or the filesystem.
|
|
56
|
+
if (wantsHelp(rest)) {
|
|
57
|
+
console.log(renderProjectVerbHelp(subcommand));
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
43
61
|
switch (subcommand) {
|
|
44
62
|
case "ingest":
|
|
45
63
|
return runProjectIngest(rest);
|
|
@@ -37,6 +37,17 @@ function listFilesRel(root) {
|
|
|
37
37
|
return out;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Byte-exact comparison of two files. Returns false if either is unreadable.
|
|
42
|
+
*/
|
|
43
|
+
function filesIdentical(a, b) {
|
|
44
|
+
try {
|
|
45
|
+
return fs.readFileSync(a).equals(fs.readFileSync(b));
|
|
46
|
+
} catch (_e) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
40
51
|
/**
|
|
41
52
|
* Promote reviewed staged docs (.sdtk/project/DOC_SYNTHESIS_BASELINE/docs/**)
|
|
42
53
|
* into the live <project>/docs/** tree so sdtk-wiki can index them.
|
|
@@ -72,11 +83,25 @@ async function runProjectPromote(args) {
|
|
|
72
83
|
const liveDocsRoot = path.join(config.projectPath, "docs");
|
|
73
84
|
const relFiles = listFilesRel(stagedDocsRoot);
|
|
74
85
|
|
|
75
|
-
|
|
86
|
+
// BK-337: classify each existing live doc as identical or differing from the
|
|
87
|
+
// staged version, so a returning user is not silently left with stale docs.
|
|
88
|
+
// `skipExisting` is retained (= identical ∪ differs) for backward compatibility.
|
|
89
|
+
const plan = {
|
|
90
|
+
create: [],
|
|
91
|
+
overwrite: [],
|
|
92
|
+
skipExisting: [],
|
|
93
|
+
identical: [],
|
|
94
|
+
differs: [],
|
|
95
|
+
};
|
|
76
96
|
for (const rel of relFiles) {
|
|
77
97
|
const target = path.join(liveDocsRoot, rel);
|
|
78
|
-
if (!fs.existsSync(target))
|
|
79
|
-
|
|
98
|
+
if (!fs.existsSync(target)) {
|
|
99
|
+
plan.create.push(rel);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const same = filesIdentical(path.join(stagedDocsRoot, rel), target);
|
|
103
|
+
(same ? plan.identical : plan.differs).push(rel);
|
|
104
|
+
if (flags.force) plan.overwrite.push(rel);
|
|
80
105
|
else plan.skipExisting.push(rel);
|
|
81
106
|
}
|
|
82
107
|
|
|
@@ -113,13 +138,23 @@ async function runProjectPromote(args) {
|
|
|
113
138
|
console.log("");
|
|
114
139
|
console.log(` New files: ${plan.create.length}`);
|
|
115
140
|
plan.create.forEach((r) => console.log(` + docs/${r}`));
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
141
|
+
if (!flags.force) {
|
|
142
|
+
if (plan.identical.length) {
|
|
143
|
+
console.log(` Unchanged (identical, skipped): ${plan.identical.length}`);
|
|
144
|
+
plan.identical.forEach((r) => console.log(` = docs/${r}`));
|
|
145
|
+
}
|
|
146
|
+
if (plan.differs.length) {
|
|
147
|
+
console.log(
|
|
148
|
+
` Differs from staged (skipped — use --force to update): ${plan.differs.length}`
|
|
149
|
+
);
|
|
150
|
+
plan.differs.forEach((r) => console.log(` ≠ docs/${r}`));
|
|
151
|
+
}
|
|
152
|
+
} else if (plan.overwrite.length) {
|
|
121
153
|
console.log(` Will overwrite: ${plan.overwrite.length}`);
|
|
122
|
-
plan.overwrite.forEach((r) =>
|
|
154
|
+
plan.overwrite.forEach((r) => {
|
|
155
|
+
const state = plan.differs.includes(r) ? "differs" : "identical";
|
|
156
|
+
console.log(` ~ docs/${r} (${state})`);
|
|
157
|
+
});
|
|
123
158
|
}
|
|
124
159
|
console.log("");
|
|
125
160
|
|