sdtk-code-kit 0.1.3 → 0.2.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.
Files changed (64) hide show
  1. package/README.md +202 -185
  2. package/assets/manifest/toolkit-bundle.manifest.json +49 -49
  3. package/assets/manifest/toolkit-bundle.sha256.txt +24 -24
  4. package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +78 -78
  5. package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +150 -150
  6. package/assets/toolkit/toolkit/scripts/uninstall-claude-skills.ps1 +62 -62
  7. package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +82 -82
  8. package/assets/toolkit/toolkit/sdtk-spec.config.profiles.example.json +12 -12
  9. package/assets/toolkit/toolkit/skills/code-brainstorm/SKILL.md +55 -55
  10. package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +1 -1
  11. package/assets/toolkit/toolkit/skills/code-debug/references/root-cause-tracing.md +68 -68
  12. package/assets/toolkit/toolkit/skills/code-execute/SKILL.md +74 -74
  13. package/assets/toolkit/toolkit/skills/code-finish/SKILL.md +205 -205
  14. package/assets/toolkit/toolkit/skills/code-parallel/SKILL.md +64 -64
  15. package/assets/toolkit/toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md +26 -26
  16. package/assets/toolkit/toolkit/skills/code-parallel/references/implementer-prompt.md +113 -113
  17. package/assets/toolkit/toolkit/skills/code-parallel/references/spec-reviewer-prompt.md +61 -61
  18. package/assets/toolkit/toolkit/skills/code-plan/SKILL.md +85 -85
  19. package/assets/toolkit/toolkit/skills/code-review/SKILL.md +79 -79
  20. package/assets/toolkit/toolkit/skills/code-review/references/checklist.md +125 -125
  21. package/assets/toolkit/toolkit/skills/code-review/references/code-reviewer.md +146 -146
  22. package/assets/toolkit/toolkit/skills/code-ship/SKILL.md +52 -52
  23. package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +1 -1
  24. package/assets/toolkit/toolkit/skills/code-tdd/references/testing-anti-patterns.md +299 -299
  25. package/assets/toolkit/toolkit/skills/code-verify/SKILL.md +144 -144
  26. package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +13 -13
  27. package/assets/toolkit/toolkit/templates/CODE_WORKFLOW_TEMPLATE.md +140 -112
  28. package/bin/sdtk-code.js +14 -14
  29. package/package.json +4 -4
  30. package/src/commands/build.js +53 -53
  31. package/src/commands/doctor.js +52 -0
  32. package/src/commands/generate.js +11 -11
  33. package/src/commands/guardrails.js +123 -0
  34. package/src/commands/help.js +28 -4
  35. package/src/commands/plan.js +53 -53
  36. package/src/commands/readiness.js +77 -0
  37. package/src/commands/resume.js +62 -0
  38. package/src/commands/runtime.js +224 -224
  39. package/src/commands/ship.js +59 -59
  40. package/src/commands/start.js +89 -89
  41. package/src/commands/status.js +78 -0
  42. package/src/commands/verify.js +71 -66
  43. package/src/index.js +32 -1
  44. package/src/lib/args.js +107 -107
  45. package/src/lib/errors.js +41 -41
  46. package/src/lib/powershell.js +65 -65
  47. package/src/lib/scope.js +72 -72
  48. package/src/lib/ship-readiness.js +281 -0
  49. package/src/lib/toolkit-payload.js +72 -72
  50. package/src/lib/trust-events.js +166 -0
  51. package/src/lib/trust-file-scope.js +154 -0
  52. package/src/lib/trust-policy.js +212 -0
  53. package/src/lib/trust-redact.js +35 -0
  54. package/src/lib/trust-trace.js +179 -0
  55. package/src/lib/workflow-artifact.js +503 -496
  56. package/src/lib/workflow-build.js +127 -127
  57. package/src/lib/workflow-doctor.js +84 -0
  58. package/src/lib/workflow-handoff.js +1029 -937
  59. package/src/lib/workflow-intake.js +101 -101
  60. package/src/lib/workflow-plan.js +193 -193
  61. package/src/lib/workflow-review-packet.js +89 -0
  62. package/src/lib/workflow-ship.js +213 -213
  63. package/src/lib/workflow-state.js +439 -0
  64. package/src/lib/workflow-verify.js +43 -6
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "sdtk-code-kit",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "Workflow-first coding process toolkit: start, plan, build, verify, ship, and runtime setup.",
5
5
  "bin": {
6
- "sdtk-code": "./bin/sdtk-code.js"
6
+ "sdtk-code": "bin/sdtk-code.js"
7
7
  },
8
8
  "main": "src/index.js",
9
9
  "type": "commonjs",
@@ -13,7 +13,7 @@
13
13
  "assets/"
14
14
  ],
15
15
  "scripts": {
16
- "test": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; Set-Location '..\\..\\..\\..'; python -m unittest tests.test_sdtk_code_cli tests.test_sdtk_code_product tests.test_sdtk_code_workflow_regressions\"",
16
+ "test": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; Set-Location '..\\..\\..\\..'; python -m unittest tests.test_sdtk_code_cli tests.test_sdtk_code_product tests.test_sdtk_code_workflow_regressions tests.test_sdtk_code_trust_events tests.test_sdtk_code_guardrails tests.test_sdtk_code_file_scope tests.test_sdtk_code_trust_trace tests.test_sdtk_code_readiness\"",
17
17
  "build:payload": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; & 'scripts/sync-toolkit-assets.ps1'; & 'scripts/build-toolkit-manifest.ps1'\"",
18
18
  "verify:payload": "node -e \"require('./src/lib/toolkit-payload').verify()\"",
19
19
  "pack:smoke": "npm pack --dry-run",
@@ -31,7 +31,7 @@
31
31
  "license": "MIT",
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "https://github.com/codexsdtk/sdtk-toolkit.git",
34
+ "url": "git+https://github.com/codexsdtk/sdtk-toolkit.git",
35
35
  "directory": "products/sdtk-code/distribution/sdtk-code-kit"
36
36
  },
37
37
  "homepage": "https://github.com/codexsdtk/sdtk-toolkit/tree/main/products/sdtk-code/distribution/sdtk-code-kit",
@@ -1,53 +1,53 @@
1
- "use strict";
2
-
3
- const path = require("path");
4
- const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
5
- const { ValidationError } = require("../lib/errors");
6
- const { runBuild } = require("../lib/workflow-build");
7
-
8
- const FLAG_DEFS = {
9
- "feature-key": { type: "string" },
10
- "project-path": { type: "string" },
11
- "active-slice": { type: "string", multiple: true },
12
- note: { type: "string", multiple: true },
13
- "debug-note": { type: "string", multiple: true },
14
- "parallel-reason": { type: "string" },
15
- complete: { type: "boolean" },
16
- blocked: { type: "boolean" },
17
- };
18
-
19
- const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
20
-
21
- function cmdBuild(args) {
22
- const { flags, positional } = parseFlags(args, FLAG_DEFS);
23
- if (positional.length > 0) {
24
- throw new ValidationError('Unexpected positional arguments. Use flags only for "build".');
25
- }
26
-
27
- const featureKey = requireFlag(flags, "feature-key", "feature-key");
28
- validatePattern(
29
- featureKey,
30
- FEATURE_KEY_RE,
31
- "feature-key",
32
- "Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
33
- );
34
-
35
- const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
36
- const result = runBuild(projectPath, featureKey, flags);
37
-
38
- console.log("SDTK-CODE workflow build");
39
- console.log(` Feature key: ${featureKey}`);
40
- console.log(` Lane: ${result.lane}`);
41
- console.log(` Status: ${result.phaseStatus}`);
42
- console.log(` Artifact: ${result.artifactPath}`);
43
- console.log(` Slices: ${result.activeSliceCount}`);
44
- console.log(` Mode: ${result.executionMode}`);
45
- console.log(` Next phase: ${result.nextPhase}`);
46
- console.log(` Engine: ${result.suggestedEngineSkills.join(", ")}`);
47
-
48
- return 0;
49
- }
50
-
51
- module.exports = {
52
- cmdBuild,
53
- };
1
+ "use strict";
2
+
3
+ const path = require("path");
4
+ const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
5
+ const { ValidationError } = require("../lib/errors");
6
+ const { runBuild } = require("../lib/workflow-build");
7
+
8
+ const FLAG_DEFS = {
9
+ "feature-key": { type: "string" },
10
+ "project-path": { type: "string" },
11
+ "active-slice": { type: "string", multiple: true },
12
+ note: { type: "string", multiple: true },
13
+ "debug-note": { type: "string", multiple: true },
14
+ "parallel-reason": { type: "string" },
15
+ complete: { type: "boolean" },
16
+ blocked: { type: "boolean" },
17
+ };
18
+
19
+ const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
20
+
21
+ function cmdBuild(args) {
22
+ const { flags, positional } = parseFlags(args, FLAG_DEFS);
23
+ if (positional.length > 0) {
24
+ throw new ValidationError('Unexpected positional arguments. Use flags only for "build".');
25
+ }
26
+
27
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
28
+ validatePattern(
29
+ featureKey,
30
+ FEATURE_KEY_RE,
31
+ "feature-key",
32
+ "Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
33
+ );
34
+
35
+ const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
36
+ const result = runBuild(projectPath, featureKey, flags);
37
+
38
+ console.log("SDTK-CODE workflow build");
39
+ console.log(` Feature key: ${featureKey}`);
40
+ console.log(` Lane: ${result.lane}`);
41
+ console.log(` Status: ${result.phaseStatus}`);
42
+ console.log(` Artifact: ${result.artifactPath}`);
43
+ console.log(` Slices: ${result.activeSliceCount}`);
44
+ console.log(` Mode: ${result.executionMode}`);
45
+ console.log(` Next phase: ${result.nextPhase}`);
46
+ console.log(` Engine: ${result.suggestedEngineSkills.join(", ")}`);
47
+
48
+ return 0;
49
+ }
50
+
51
+ module.exports = {
52
+ cmdBuild,
53
+ };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ const path = require("path");
4
+ const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
5
+ const { ValidationError } = require("../lib/errors");
6
+ const { runWorkflowDoctor } = require("../lib/workflow-doctor");
7
+
8
+ const FLAG_DEFS = {
9
+ "feature-key": { type: "string" },
10
+ "project-path": { type: "string" },
11
+ };
12
+
13
+ const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
14
+
15
+ function cmdDoctor(args) {
16
+ const { flags, positional } = parseFlags(args, FLAG_DEFS);
17
+ if (positional.length > 0) {
18
+ throw new ValidationError('Unexpected positional arguments. Use flags only for "doctor".');
19
+ }
20
+
21
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
22
+ validatePattern(
23
+ featureKey,
24
+ FEATURE_KEY_RE,
25
+ "feature-key",
26
+ "Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
27
+ );
28
+
29
+ const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
30
+ const report = runWorkflowDoctor(projectPath, featureKey);
31
+
32
+ console.log("SDTK-CODE workflow doctor");
33
+ console.log(` Feature key: ${featureKey}`);
34
+ console.log(` Artifact: ${report.state.exists ? report.state.artifactPath : "missing"}`);
35
+ console.log(` Result: ${report.result}`);
36
+
37
+ if (report.issues.length === 0) {
38
+ console.log(" Issues: none");
39
+ return 0;
40
+ }
41
+
42
+ report.issues.forEach((issue, index) => {
43
+ console.log(` Issue ${index + 1}: ${issue}`);
44
+ });
45
+
46
+ console.log(" Repair: diagnostic only in BK-047-lite (no auto-repair)");
47
+ return 1;
48
+ }
49
+
50
+ module.exports = {
51
+ cmdDoctor,
52
+ };
@@ -1,11 +1,11 @@
1
- "use strict";
2
-
3
- const { ValidationError } = require("../lib/errors");
4
-
5
- function cmdGenerate() {
6
- throw new ValidationError("generate command is not available in SDTK-CODE.");
7
- }
8
-
9
- module.exports = {
10
- cmdGenerate,
11
- };
1
+ "use strict";
2
+
3
+ const { ValidationError } = require("../lib/errors");
4
+
5
+ function cmdGenerate() {
6
+ throw new ValidationError("generate command is not available in SDTK-CODE.");
7
+ }
8
+
9
+ module.exports = {
10
+ cmdGenerate,
11
+ };
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { parseFlags, requireFlag } = require("../lib/args");
6
+ const { ValidationError } = require("../lib/errors");
7
+ const { DEFAULT_POLICY, loadPolicy, classifyCommand, policyFile } = require("../lib/trust-policy");
8
+ const { appendEvent } = require("../lib/trust-events");
9
+
10
+ const CHECK_FLAG_DEFS = {
11
+ command: { type: "string" },
12
+ "project-path": { type: "string" },
13
+ "action-count": { type: "string" },
14
+ };
15
+
16
+ const INIT_FLAG_DEFS = {
17
+ "project-path": { type: "string" },
18
+ force: { type: "boolean" },
19
+ };
20
+
21
+ // allow/ask are advisory observations (info); deny is recorded as blocked.
22
+ function statusForVerdict(verdict) {
23
+ return verdict === "deny" ? "blocked" : "info";
24
+ }
25
+
26
+ function resolveProjectPath(flags) {
27
+ return flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
28
+ }
29
+
30
+ function parseActionCount(raw) {
31
+ if (raw === undefined || raw === null || raw === "") {
32
+ return undefined;
33
+ }
34
+ const value = Number(raw);
35
+ if (!Number.isInteger(value) || value < 0) {
36
+ throw new ValidationError(
37
+ `Invalid value for --action-count: "${raw}". Must be a non-negative integer.`
38
+ );
39
+ }
40
+ return value;
41
+ }
42
+
43
+ function runCheck(args) {
44
+ const { flags, positional } = parseFlags(args, CHECK_FLAG_DEFS);
45
+ if (positional.length > 0) {
46
+ throw new ValidationError('Unexpected positional arguments for "guardrails check".');
47
+ }
48
+
49
+ const command = requireFlag(flags, "command", "command");
50
+ const projectPath = resolveProjectPath(flags);
51
+ const actionCount = parseActionCount(flags["action-count"]);
52
+
53
+ const policy = loadPolicy(projectPath);
54
+ const result = classifyCommand(policy, command, { actionCount });
55
+
56
+ // Record a redacted trust event (BK-239 buildEvent redacts the command).
57
+ appendEvent(projectPath, {
58
+ toolkit: "sdtk-code",
59
+ event_type: "guardrail_check",
60
+ command,
61
+ status: statusForVerdict(result.verdict),
62
+ });
63
+
64
+ console.log("SDTK-CODE guardrails check");
65
+ console.log(` Verdict: ${result.verdict}`);
66
+ console.log(` Reason: ${result.reason}`);
67
+ console.log(
68
+ ` Matched: ${result.matchedRule ? `${result.matchedRule.bucket}:${result.matchedRule.pattern}` : "none"}`
69
+ );
70
+ // Advisory classifier: deny is reported in stdout, not enforced via exit code.
71
+ return 0;
72
+ }
73
+
74
+ function runInit(args) {
75
+ const { flags, positional } = parseFlags(args, INIT_FLAG_DEFS);
76
+ if (positional.length > 0) {
77
+ throw new ValidationError('Unexpected positional arguments for "guardrails init".');
78
+ }
79
+
80
+ const projectPath = resolveProjectPath(flags);
81
+ const target = policyFile(projectPath);
82
+
83
+ if (fs.existsSync(target) && !flags.force) {
84
+ throw new ValidationError(
85
+ [
86
+ `Refusing to overwrite existing trust policy: ${target}`,
87
+ "Re-run with --force to replace it with the default policy pack.",
88
+ ].join("\n")
89
+ );
90
+ }
91
+
92
+ fs.mkdirSync(path.dirname(target), { recursive: true });
93
+ fs.writeFileSync(target, `${JSON.stringify(DEFAULT_POLICY, null, 2)}\n`, "utf8");
94
+
95
+ console.log("SDTK-CODE guardrails init");
96
+ console.log(` Policy: ${target}`);
97
+ console.log(` Rules: deny=${DEFAULT_POLICY.deny.length}, ask=${DEFAULT_POLICY.ask.length}, allow=${DEFAULT_POLICY.allow.length}`);
98
+ return 0;
99
+ }
100
+
101
+ function cmdGuardrails(args) {
102
+ const list = Array.isArray(args) ? args : [];
103
+ const subcommand = list[0];
104
+ if (!subcommand || subcommand.startsWith("-")) {
105
+ throw new ValidationError('Missing guardrails subcommand. Use one of: check, init.');
106
+ }
107
+
108
+ const rest = list.slice(1);
109
+ switch (subcommand) {
110
+ case "check":
111
+ return runCheck(rest);
112
+ case "init":
113
+ return runInit(rest);
114
+ default:
115
+ throw new ValidationError(
116
+ `Unknown guardrails subcommand: "${subcommand}". Use one of: check, init.`
117
+ );
118
+ }
119
+ }
120
+
121
+ module.exports = {
122
+ cmdGuardrails,
123
+ };
@@ -13,12 +13,15 @@ function cmdHelp() {
13
13
  " build Record build progress and route the next coding engine step",
14
14
  " verify Record summarized evidence, write REVIEW_PACKET, and update ordered review gates",
15
15
  " ship Record final ship or finish decision and emit OPS_HANDOFF on formal closeout",
16
+ " status Inspect current workflow lifecycle state and next legal action",
17
+ " doctor Diagnose missing or contradictory workflow state (diagnostic only)",
18
+ " resume Continue only when resume is machine-safe; otherwise fail closed",
16
19
  " update Refresh the npm package and optionally re-apply managed project/runtime assets",
17
20
  " init Initialize SDTK-CODE workspace",
18
21
  " runtime Manage runtime asset installation (install, uninstall, status)",
19
22
  "",
20
23
  "Workflow status:",
21
- " Implemented now: start, plan, build, verify, ship",
24
+ " Implemented now: start, plan, build, verify, ship, status, doctor, resume",
22
25
  "",
23
26
  "Package status:",
24
27
  " Public package: sdtk-code-kit",
@@ -111,6 +114,21 @@ function cmdHelp() {
111
114
  " Completed closeout backed by docs/dev/CODE_HANDOFF_[FEATURE_KEY].json writes docs/dev/OPS_HANDOFF_[FEATURE_KEY].json",
112
115
  " Compatibility fallback workflows do not emit a fake OPS handoff without the current formal CODE_HANDOFF",
113
116
  "",
117
+ "Status options:",
118
+ " --feature-key <KEY> Feature key in UPPER_SNAKE_CASE (required)",
119
+ " --project-path <path> Target project directory (default: cwd)",
120
+ "",
121
+ "Doctor options:",
122
+ " --feature-key <KEY> Feature key in UPPER_SNAKE_CASE (required)",
123
+ " --project-path <path> Target project directory (default: cwd)",
124
+ " Doctor is diagnostic-only in BK-047-lite and does not auto-repair workflow files.",
125
+ "",
126
+ "Resume options:",
127
+ " --feature-key <KEY> Feature key in UPPER_SNAKE_CASE (required)",
128
+ " --project-path <path> Target project directory (default: cwd)",
129
+ " Resume auto-dispatch is currently bounded to machine-safe build transitions only.",
130
+ " Resume fails closed for plan, verify, and ship because explicit operator inputs are required.",
131
+ "",
114
132
  "Init options:",
115
133
  " --runtime <codex|claude> Runtime adapter (default: codex)",
116
134
  " --runtime-scope <project|user> Install scope (default: project for claude, user for codex)",
@@ -185,6 +203,9 @@ function cmdHelp() {
185
203
  " sdtk-code verify --feature-key LOGIN_FIX --evidence \"npm test|Bugfix regression passes|pass|docs/dev/evidence/LOGIN_FIX/regression.txt\" --spec-status pass --quality-status pass --complete",
186
204
  " sdtk-code ship --feature-key ORDER_MGMT --decision ship --preflight \"npm pack --dry-run|Package smoke passed|pass|docs/dev/evidence/ORDER_MGMT/pack.txt\" --preflight \"release checklist|Operator handoff reviewed|pass|docs/dev/evidence/ORDER_MGMT/release-checklist.txt\" --follow-up \"Monitor first-release support tickets\"",
187
205
  " sdtk-code ship --feature-key LOGIN_FIX --decision finish --preflight \"git diff --check|No whitespace issues remain|pass|docs/dev/evidence/LOGIN_FIX/diff-check.txt\"",
206
+ " sdtk-code status --feature-key ORDER_MGMT --project-path ./my-project",
207
+ " sdtk-code doctor --feature-key ORDER_MGMT --project-path ./my-project",
208
+ " sdtk-code resume --feature-key ORDER_MGMT --project-path ./my-project",
188
209
  " sdtk-code init",
189
210
  " sdtk-code init --runtime codex --runtime-scope project --project-path ./my-project",
190
211
  " sdtk-code init --runtime claude --project-path ./my-project",
@@ -205,10 +226,13 @@ function cmdHelp() {
205
226
  " Preferred input: CODE_HANDOFF_[FEATURE_KEY].json; compatibility fallback is bounded to missing-handoff cases.",
206
227
  " 3. For feature work, either confirm seeded handoff slices with --use-seeded-candidates or refine them with explicit --slice entries.",
207
228
  " 4. Record build progress with sdtk-code build while execution is in motion.",
208
- " 5. Capture summarized evidence and review gates with sdtk-code verify before closure.",
229
+ " 5. Use sdtk-code status for a fast lifecycle snapshot before resuming interrupted work.",
230
+ " 6. Use sdtk-code doctor when state looks contradictory or blocks unexpectedly (diagnostic only).",
231
+ " 7. Use sdtk-code resume only when a machine-safe resume path is available.",
232
+ " 8. Capture summarized evidence and review gates with sdtk-code verify before closure.",
209
233
  " Verify also emits docs/dev/REVIEW_PACKET_[FEATURE_KEY].md for downstream QA/controller review.",
210
- " 6. Record final ship or finish decision with sdtk-code ship; completed formal closeout writes OPS_HANDOFF for DEV-Run intake.",
211
- " 7. Use raw code-* skills directly when you intentionally choose expert mode.",
234
+ " 9. Record final ship or finish decision with sdtk-code ship; completed formal closeout writes OPS_HANDOFF for DEV-Run intake.",
235
+ " 10. Use raw code-* skills directly when you intentionally choose expert mode.",
212
236
  ];
213
237
 
214
238
  console.log(text.join("\n"));
@@ -1,53 +1,53 @@
1
- "use strict";
2
-
3
- const path = require("path");
4
- const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
5
- const { ValidationError } = require("../lib/errors");
6
- const { runPlan } = require("../lib/workflow-plan");
7
-
8
- const FLAG_DEFS = {
9
- "feature-key": { type: "string" },
10
- "project-path": { type: "string" },
11
- "in-scope": { type: "string", multiple: true },
12
- "out-scope": { type: "string", multiple: true },
13
- slice: { type: "string", multiple: true },
14
- "use-seeded-candidates": { type: "boolean" },
15
- assumption: { type: "string", multiple: true },
16
- risk: { type: "string", multiple: true },
17
- note: { type: "string", multiple: true },
18
- };
19
-
20
- const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
21
-
22
- function cmdPlan(args) {
23
- const { flags, positional } = parseFlags(args, FLAG_DEFS);
24
- if (positional.length > 0) {
25
- throw new ValidationError('Unexpected positional arguments. Use flags only for "plan".');
26
- }
27
-
28
- const featureKey = requireFlag(flags, "feature-key", "feature-key");
29
- validatePattern(
30
- featureKey,
31
- FEATURE_KEY_RE,
32
- "feature-key",
33
- "Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
34
- );
35
-
36
- const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
37
- const result = runPlan(projectPath, featureKey, flags);
38
-
39
- console.log("SDTK-CODE workflow plan");
40
- console.log(` Feature key: ${featureKey}`);
41
- console.log(` Lane: ${result.lane}`);
42
- console.log(` Mode: ${result.planningMode}`);
43
- console.log(` Artifact: ${result.artifactPath}`);
44
- console.log(` Slices: ${result.sliceCount}`);
45
- console.log(` Next phase: ${result.nextPhase}`);
46
- console.log(` Engine: ${result.suggestedEngineSkills.join(", ")}`);
47
-
48
- return 0;
49
- }
50
-
51
- module.exports = {
52
- cmdPlan,
53
- };
1
+ "use strict";
2
+
3
+ const path = require("path");
4
+ const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
5
+ const { ValidationError } = require("../lib/errors");
6
+ const { runPlan } = require("../lib/workflow-plan");
7
+
8
+ const FLAG_DEFS = {
9
+ "feature-key": { type: "string" },
10
+ "project-path": { type: "string" },
11
+ "in-scope": { type: "string", multiple: true },
12
+ "out-scope": { type: "string", multiple: true },
13
+ slice: { type: "string", multiple: true },
14
+ "use-seeded-candidates": { type: "boolean" },
15
+ assumption: { type: "string", multiple: true },
16
+ risk: { type: "string", multiple: true },
17
+ note: { type: "string", multiple: true },
18
+ };
19
+
20
+ const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
21
+
22
+ function cmdPlan(args) {
23
+ const { flags, positional } = parseFlags(args, FLAG_DEFS);
24
+ if (positional.length > 0) {
25
+ throw new ValidationError('Unexpected positional arguments. Use flags only for "plan".');
26
+ }
27
+
28
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
29
+ validatePattern(
30
+ featureKey,
31
+ FEATURE_KEY_RE,
32
+ "feature-key",
33
+ "Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
34
+ );
35
+
36
+ const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
37
+ const result = runPlan(projectPath, featureKey, flags);
38
+
39
+ console.log("SDTK-CODE workflow plan");
40
+ console.log(` Feature key: ${featureKey}`);
41
+ console.log(` Lane: ${result.lane}`);
42
+ console.log(` Mode: ${result.planningMode}`);
43
+ console.log(` Artifact: ${result.artifactPath}`);
44
+ console.log(` Slices: ${result.sliceCount}`);
45
+ console.log(` Next phase: ${result.nextPhase}`);
46
+ console.log(` Engine: ${result.suggestedEngineSkills.join(", ")}`);
47
+
48
+ return 0;
49
+ }
50
+
51
+ module.exports = {
52
+ cmdPlan,
53
+ };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ const path = require("path");
4
+ const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
5
+ const { ValidationError } = require("../lib/errors");
6
+ const { computeReadiness, gatherSignals } = require("../lib/ship-readiness");
7
+ const { appendEvent } = require("../lib/trust-events");
8
+
9
+ const FLAG_DEFS = {
10
+ "feature-key": { type: "string" },
11
+ "project-path": { type: "string" },
12
+ };
13
+
14
+ const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
15
+
16
+ function verdictStatus(verdict) {
17
+ if (verdict === "FAIL") return "blocked";
18
+ if (verdict === "ENV_BLOCKED") return "blocked";
19
+ return "info";
20
+ }
21
+
22
+ function cmdReadiness(args) {
23
+ const { flags, positional } = parseFlags(args, FLAG_DEFS);
24
+ if (positional.length > 0) {
25
+ throw new ValidationError('Unexpected positional arguments. Use flags only for "readiness".');
26
+ }
27
+
28
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
29
+ validatePattern(
30
+ featureKey,
31
+ FEATURE_KEY_RE,
32
+ "feature-key",
33
+ "Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
34
+ );
35
+
36
+ const projectPath = flags["project-path"]
37
+ ? path.resolve(flags["project-path"])
38
+ : process.cwd();
39
+
40
+ const signals = gatherSignals(projectPath, featureKey);
41
+ const result = computeReadiness(signals);
42
+
43
+ // Record a trust event for observability (command is safe to always record).
44
+ appendEvent(projectPath, {
45
+ toolkit: "sdtk-code",
46
+ event_type: "readiness_check",
47
+ command: `sdtk-code readiness --feature-key ${featureKey}`,
48
+ status: verdictStatus(result.verdict),
49
+ });
50
+
51
+ // Founder-readable one-line summary
52
+ console.log(`Ship Readiness: ${result.score}/${result.max} — ${result.verdict}`);
53
+ console.log("");
54
+
55
+ // Component table
56
+ console.log(" Components:");
57
+ for (const comp of result.components) {
58
+ const bar = comp.max > 0 ? `${comp.points}/${comp.max}` : "n/a";
59
+ console.log(` ${comp.name.padEnd(12)} ${bar.padStart(5)} ${comp.note}`);
60
+ }
61
+
62
+ if (result.blockers.length > 0) {
63
+ console.log("");
64
+ console.log(" Blockers:");
65
+ result.blockers.forEach((b) => console.log(` [FAIL] ${b}`));
66
+ }
67
+
68
+ if (result.warnings.length > 0) {
69
+ console.log("");
70
+ console.log(" Warnings:");
71
+ result.warnings.forEach((w) => console.log(` [WARN] ${w}`));
72
+ }
73
+
74
+ return 0;
75
+ }
76
+
77
+ module.exports = { cmdReadiness };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ const path = require("path");
4
+ const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
5
+ const { ValidationError } = require("../lib/errors");
6
+ const { runBuild } = require("../lib/workflow-build");
7
+ const { loadWorkflowState } = require("../lib/workflow-state");
8
+
9
+ const FLAG_DEFS = {
10
+ "feature-key": { type: "string" },
11
+ "project-path": { type: "string" },
12
+ };
13
+
14
+ const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
15
+
16
+ function cmdResume(args) {
17
+ const { flags, positional } = parseFlags(args, FLAG_DEFS);
18
+ if (positional.length > 0) {
19
+ throw new ValidationError('Unexpected positional arguments. Use flags only for "resume".');
20
+ }
21
+
22
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
23
+ validatePattern(
24
+ featureKey,
25
+ FEATURE_KEY_RE,
26
+ "feature-key",
27
+ "Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
28
+ );
29
+
30
+ const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
31
+ const state = loadWorkflowState(projectPath, featureKey);
32
+ const decision = state.resumeDecision;
33
+
34
+ if (!decision || !decision.allowed) {
35
+ const lines = [decision ? decision.reason : "Resume is unavailable for this workflow state."];
36
+ if (decision && decision.nextCommand) {
37
+ lines.push(`Next command: ${decision.nextCommand}`);
38
+ }
39
+ throw new ValidationError(lines.join("\n"));
40
+ }
41
+
42
+ const resumeBuildSlices = Array.isArray(decision.resumeBuildSlices) ? decision.resumeBuildSlices : [];
43
+ const result = runBuild(projectPath, featureKey, {
44
+ "active-slice": resumeBuildSlices,
45
+ });
46
+
47
+ console.log("SDTK-CODE workflow resume");
48
+ console.log(` Feature key: ${featureKey}`);
49
+ console.log(" Decision: auto-dispatch build");
50
+ console.log(` Command: ${decision.dispatchCommand}`);
51
+ console.log(` Slices: ${resumeBuildSlices.length}`);
52
+ console.log(` Artifact: ${result.artifactPath}`);
53
+ console.log(` Status: ${result.phaseStatus}`);
54
+ console.log(` Next phase: ${result.nextPhase}`);
55
+ console.log(` Engine: ${result.suggestedEngineSkills.join(", ")}`);
56
+
57
+ return 0;
58
+ }
59
+
60
+ module.exports = {
61
+ cmdResume,
62
+ };