sdtk-code-kit 0.1.3 → 0.2.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/README.md +17 -0
- package/assets/manifest/toolkit-bundle.manifest.json +147 -147
- package/assets/manifest/toolkit-bundle.sha256.txt +10 -10
- package/assets/toolkit/toolkit/AGENTS.md +219 -219
- package/assets/toolkit/toolkit/install.ps1 +156 -156
- package/assets/toolkit/toolkit/sdtk-spec.config.json +6 -6
- package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +295 -295
- package/assets/toolkit/toolkit/skills/code-discover/SKILL.md +54 -54
- package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +377 -377
- package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +215 -215
- package/assets/toolkit/toolkit/templates/CODE_WORKFLOW_TEMPLATE.md +28 -0
- package/package.json +44 -44
- package/src/commands/doctor.js +52 -0
- package/src/commands/guardrails.js +215 -0
- package/src/commands/help.js +244 -220
- package/src/commands/init.js +98 -98
- package/src/commands/readiness.js +77 -0
- package/src/commands/resume.js +62 -0
- package/src/commands/sleep.js +132 -0
- package/src/commands/status.js +78 -0
- package/src/commands/update.js +11 -11
- package/src/commands/verify.js +5 -0
- package/src/index.js +108 -73
- package/src/lib/project-target-guard.js +53 -53
- package/src/lib/ship-readiness.js +281 -0
- package/src/lib/sleep-plan.js +175 -0
- package/src/lib/sleep-report.js +229 -0
- package/src/lib/trust-events.js +166 -0
- package/src/lib/trust-file-scope.js +154 -0
- package/src/lib/trust-policy.js +212 -0
- package/src/lib/trust-redact.js +35 -0
- package/src/lib/trust-trace.js +179 -0
- package/src/lib/update.js +344 -344
- package/src/lib/workflow-artifact.js +9 -2
- package/src/lib/workflow-doctor.js +84 -0
- package/src/lib/workflow-handoff.js +111 -19
- package/src/lib/workflow-review-packet.js +650 -561
- package/src/lib/workflow-state.js +439 -0
- package/src/lib/workflow-verify.js +393 -356
package/src/commands/init.js
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const path = require("path");
|
|
4
|
-
const { parseFlags, validateChoice } = require("../lib/args");
|
|
5
|
-
const { verify, resolvePayloadFile } = require("../lib/toolkit-payload");
|
|
6
|
-
const { runScript } = require("../lib/powershell");
|
|
7
|
-
const { ValidationError } = require("../lib/errors");
|
|
8
|
-
const { VALID_SCOPES, defaultScope, isProjectScopeSupported } = require("../lib/scope");
|
|
9
|
-
const { assertProjectRefreshTargetAllowed } = require("../lib/project-target-guard");
|
|
10
|
-
|
|
11
|
-
const FLAG_DEFS = {
|
|
12
|
-
runtime: { type: "string" },
|
|
13
|
-
"project-path": { type: "string" },
|
|
14
|
-
"runtime-scope": { type: "string" },
|
|
15
|
-
force: { type: "boolean" },
|
|
16
|
-
"skip-skills": { type: "boolean" },
|
|
17
|
-
"skip-runtime-assets": { type: "boolean" },
|
|
18
|
-
verbose: { type: "boolean" },
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const VALID_RUNTIMES = ["codex", "claude"];
|
|
22
|
-
|
|
23
|
-
async function cmdInit(args) {
|
|
24
|
-
const { flags } = parseFlags(args, FLAG_DEFS);
|
|
25
|
-
|
|
26
|
-
const runtime = flags.runtime || "codex";
|
|
27
|
-
validateChoice(runtime, VALID_RUNTIMES, "runtime");
|
|
28
|
-
|
|
29
|
-
const scope = flags["runtime-scope"] || defaultScope(runtime);
|
|
30
|
-
validateChoice(scope, VALID_SCOPES, "runtime-scope");
|
|
31
|
-
if (scope === "project" && !isProjectScopeSupported(runtime)) {
|
|
32
|
-
throw new ValidationError(
|
|
33
|
-
`${runtime} does not support project-local runtime assets. Use --runtime-scope user instead.`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const skipAssets = flags["skip-runtime-assets"] || flags["skip-skills"];
|
|
38
|
-
if (flags["skip-skills"] && !flags["skip-runtime-assets"]) {
|
|
39
|
-
console.warn("Warning: --skip-skills is deprecated. Use --skip-runtime-assets instead.");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
43
|
-
|
|
44
|
-
assertProjectRefreshTargetAllowed("sdtk-code", "init", projectPath);
|
|
45
|
-
|
|
46
|
-
verify();
|
|
47
|
-
|
|
48
|
-
const installScript = resolvePayloadFile("toolkit/install.ps1");
|
|
49
|
-
const params = {
|
|
50
|
-
ProjectPath: projectPath,
|
|
51
|
-
Runtime: runtime,
|
|
52
|
-
Scope: scope,
|
|
53
|
-
};
|
|
54
|
-
if (flags.force) {
|
|
55
|
-
params.Force = true;
|
|
56
|
-
}
|
|
57
|
-
if (skipAssets) {
|
|
58
|
-
params.SkipRuntimeAssets = true;
|
|
59
|
-
}
|
|
60
|
-
if (!flags.verbose) {
|
|
61
|
-
params.Quiet = true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
console.log("Initializing SDTK-CODE workspace...");
|
|
65
|
-
console.log(` Runtime: ${runtime}`);
|
|
66
|
-
console.log(` Scope: ${scope}`);
|
|
67
|
-
console.log(` Project: ${projectPath}`);
|
|
68
|
-
if (runtime === "codex" && scope === "project") {
|
|
69
|
-
console.log(` Codex home contract: ${path.join(projectPath, ".codex")}`);
|
|
70
|
-
console.log(" Note: Launch Codex with CODEX_HOME=<project>/.codex to use project-local skills.");
|
|
71
|
-
console.log(" Note: This CLI does not claim native .codex/skills auto-discovery.");
|
|
72
|
-
}
|
|
73
|
-
console.log("");
|
|
74
|
-
|
|
75
|
-
const result = await runScript(installScript, params, { silent: !flags.verbose });
|
|
76
|
-
if (result.exitCode !== 0) {
|
|
77
|
-
if (result.stderr) {
|
|
78
|
-
console.error(result.stderr);
|
|
79
|
-
}
|
|
80
|
-
throw new ValidationError(`Initialization failed (exit code ${result.exitCode}).`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
console.log("");
|
|
84
|
-
console.log("SDTK-CODE workspace initialized successfully.");
|
|
85
|
-
if (runtime === "codex" && scope === "project") {
|
|
86
|
-
console.log(`Project-local Codex skills were installed into ${path.join(projectPath, ".codex", "skills")}.`);
|
|
87
|
-
console.log("Launch Codex with CODEX_HOME=<project>/.codex to activate that local runtime home.");
|
|
88
|
-
}
|
|
89
|
-
console.log("");
|
|
90
|
-
console.log("Next steps:");
|
|
91
|
-
console.log(" 1. Review and customize sdtk-spec.config.json for your project stack.");
|
|
92
|
-
console.log(" 2. Start the workflow with sdtk-code start once the upstream SDTK-SPEC handoff is ready.");
|
|
93
|
-
return 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
module.exports = {
|
|
97
|
-
cmdInit,
|
|
98
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { parseFlags, validateChoice } = require("../lib/args");
|
|
5
|
+
const { verify, resolvePayloadFile } = require("../lib/toolkit-payload");
|
|
6
|
+
const { runScript } = require("../lib/powershell");
|
|
7
|
+
const { ValidationError } = require("../lib/errors");
|
|
8
|
+
const { VALID_SCOPES, defaultScope, isProjectScopeSupported } = require("../lib/scope");
|
|
9
|
+
const { assertProjectRefreshTargetAllowed } = require("../lib/project-target-guard");
|
|
10
|
+
|
|
11
|
+
const FLAG_DEFS = {
|
|
12
|
+
runtime: { type: "string" },
|
|
13
|
+
"project-path": { type: "string" },
|
|
14
|
+
"runtime-scope": { type: "string" },
|
|
15
|
+
force: { type: "boolean" },
|
|
16
|
+
"skip-skills": { type: "boolean" },
|
|
17
|
+
"skip-runtime-assets": { type: "boolean" },
|
|
18
|
+
verbose: { type: "boolean" },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const VALID_RUNTIMES = ["codex", "claude"];
|
|
22
|
+
|
|
23
|
+
async function cmdInit(args) {
|
|
24
|
+
const { flags } = parseFlags(args, FLAG_DEFS);
|
|
25
|
+
|
|
26
|
+
const runtime = flags.runtime || "codex";
|
|
27
|
+
validateChoice(runtime, VALID_RUNTIMES, "runtime");
|
|
28
|
+
|
|
29
|
+
const scope = flags["runtime-scope"] || defaultScope(runtime);
|
|
30
|
+
validateChoice(scope, VALID_SCOPES, "runtime-scope");
|
|
31
|
+
if (scope === "project" && !isProjectScopeSupported(runtime)) {
|
|
32
|
+
throw new ValidationError(
|
|
33
|
+
`${runtime} does not support project-local runtime assets. Use --runtime-scope user instead.`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const skipAssets = flags["skip-runtime-assets"] || flags["skip-skills"];
|
|
38
|
+
if (flags["skip-skills"] && !flags["skip-runtime-assets"]) {
|
|
39
|
+
console.warn("Warning: --skip-skills is deprecated. Use --skip-runtime-assets instead.");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
43
|
+
|
|
44
|
+
assertProjectRefreshTargetAllowed("sdtk-code", "init", projectPath);
|
|
45
|
+
|
|
46
|
+
verify();
|
|
47
|
+
|
|
48
|
+
const installScript = resolvePayloadFile("toolkit/install.ps1");
|
|
49
|
+
const params = {
|
|
50
|
+
ProjectPath: projectPath,
|
|
51
|
+
Runtime: runtime,
|
|
52
|
+
Scope: scope,
|
|
53
|
+
};
|
|
54
|
+
if (flags.force) {
|
|
55
|
+
params.Force = true;
|
|
56
|
+
}
|
|
57
|
+
if (skipAssets) {
|
|
58
|
+
params.SkipRuntimeAssets = true;
|
|
59
|
+
}
|
|
60
|
+
if (!flags.verbose) {
|
|
61
|
+
params.Quiet = true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log("Initializing SDTK-CODE workspace...");
|
|
65
|
+
console.log(` Runtime: ${runtime}`);
|
|
66
|
+
console.log(` Scope: ${scope}`);
|
|
67
|
+
console.log(` Project: ${projectPath}`);
|
|
68
|
+
if (runtime === "codex" && scope === "project") {
|
|
69
|
+
console.log(` Codex home contract: ${path.join(projectPath, ".codex")}`);
|
|
70
|
+
console.log(" Note: Launch Codex with CODEX_HOME=<project>/.codex to use project-local skills.");
|
|
71
|
+
console.log(" Note: This CLI does not claim native .codex/skills auto-discovery.");
|
|
72
|
+
}
|
|
73
|
+
console.log("");
|
|
74
|
+
|
|
75
|
+
const result = await runScript(installScript, params, { silent: !flags.verbose });
|
|
76
|
+
if (result.exitCode !== 0) {
|
|
77
|
+
if (result.stderr) {
|
|
78
|
+
console.error(result.stderr);
|
|
79
|
+
}
|
|
80
|
+
throw new ValidationError(`Initialization failed (exit code ${result.exitCode}).`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.log("");
|
|
84
|
+
console.log("SDTK-CODE workspace initialized successfully.");
|
|
85
|
+
if (runtime === "codex" && scope === "project") {
|
|
86
|
+
console.log(`Project-local Codex skills were installed into ${path.join(projectPath, ".codex", "skills")}.`);
|
|
87
|
+
console.log("Launch Codex with CODEX_HOME=<project>/.codex to activate that local runtime home.");
|
|
88
|
+
}
|
|
89
|
+
console.log("");
|
|
90
|
+
console.log("Next steps:");
|
|
91
|
+
console.log(" 1. Review and customize sdtk-spec.config.json for your project stack.");
|
|
92
|
+
console.log(" 2. Start the workflow with sdtk-code start once the upstream SDTK-SPEC handoff is ready.");
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
module.exports = {
|
|
97
|
+
cmdInit,
|
|
98
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { parseFlags, requireFlag } = require("../lib/args");
|
|
5
|
+
const { ValidationError } = require("../lib/errors");
|
|
6
|
+
const { assembleSleepPlan, writeSleepPlan } = require("../lib/sleep-plan");
|
|
7
|
+
const {
|
|
8
|
+
loadSleepPlan,
|
|
9
|
+
gatherReportSignals,
|
|
10
|
+
projectSleepReport,
|
|
11
|
+
renderSleepReportMarkdown,
|
|
12
|
+
writeSleepReport,
|
|
13
|
+
} = require("../lib/sleep-report");
|
|
14
|
+
const { appendEvent } = require("../lib/trust-events");
|
|
15
|
+
|
|
16
|
+
const FLAG_DEFS = {
|
|
17
|
+
"feature-key": { type: "string" },
|
|
18
|
+
"project-path": { type: "string" },
|
|
19
|
+
"max-actions": { type: "string" },
|
|
20
|
+
"max-iterations": { type: "string" },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function cmdSleepPlan(args) {
|
|
24
|
+
const { flags, positional } = parseFlags(args, FLAG_DEFS);
|
|
25
|
+
if (positional.length > 0) {
|
|
26
|
+
throw new ValidationError(
|
|
27
|
+
'Unexpected positional arguments. Use flags only for "sleep plan".'
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
32
|
+
const projectPath = flags["project-path"]
|
|
33
|
+
? path.resolve(flags["project-path"])
|
|
34
|
+
: process.cwd();
|
|
35
|
+
|
|
36
|
+
const opts = {};
|
|
37
|
+
if (flags["max-actions"] !== undefined) {
|
|
38
|
+
opts.maxActions = flags["max-actions"];
|
|
39
|
+
}
|
|
40
|
+
if (flags["max-iterations"] !== undefined) {
|
|
41
|
+
opts.maxIterations = flags["max-iterations"];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const plan = assembleSleepPlan(projectPath, featureKey, opts);
|
|
45
|
+
const outPath = writeSleepPlan(projectPath, plan);
|
|
46
|
+
|
|
47
|
+
appendEvent(projectPath, {
|
|
48
|
+
event_type: "sleep_plan",
|
|
49
|
+
feature_key: featureKey,
|
|
50
|
+
status: "ok",
|
|
51
|
+
output_path: outPath,
|
|
52
|
+
steps_count: plan.ordered_steps.length,
|
|
53
|
+
scope_declared: plan.scope.declared,
|
|
54
|
+
stop_conditions_count: plan.stop_conditions.length,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
console.log(`sleep-plan written: ${outPath}`);
|
|
58
|
+
console.log(` feature_key: ${plan.feature_key}`);
|
|
59
|
+
console.log(` steps: ${plan.ordered_steps.length}`);
|
|
60
|
+
console.log(` scope: ${plan.scope.declared ? "declared" : "undeclared"}`);
|
|
61
|
+
console.log(
|
|
62
|
+
` budgets: max_actions=${plan.budgets.max_actions}, max_iterations=${plan.budgets.max_iterations}`
|
|
63
|
+
);
|
|
64
|
+
console.log(` stop_conditions: ${plan.stop_conditions.length}`);
|
|
65
|
+
console.log(` policy_profile: ${plan.policy_profile}`);
|
|
66
|
+
console.log(` runtime: ${plan.runtime}`);
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function cmdSleepReport(args) {
|
|
71
|
+
const { flags, positional } = parseFlags(args, FLAG_DEFS);
|
|
72
|
+
if (positional.length > 0) {
|
|
73
|
+
throw new ValidationError(
|
|
74
|
+
'Unexpected positional arguments. Use flags only for "sleep report".'
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
79
|
+
const projectPath = flags["project-path"]
|
|
80
|
+
? path.resolve(flags["project-path"])
|
|
81
|
+
: process.cwd();
|
|
82
|
+
|
|
83
|
+
const plan = loadSleepPlan(projectPath);
|
|
84
|
+
if (plan.feature_key !== featureKey) {
|
|
85
|
+
throw new ValidationError(
|
|
86
|
+
`sleep-plan feature_key "${plan.feature_key}" does not match --feature-key "${featureKey}".`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const signals = gatherReportSignals(projectPath, featureKey);
|
|
91
|
+
const report = projectSleepReport(plan, signals);
|
|
92
|
+
const markdown = renderSleepReportMarkdown(report);
|
|
93
|
+
const outPath = writeSleepReport(projectPath, featureKey, markdown);
|
|
94
|
+
|
|
95
|
+
appendEvent(projectPath, {
|
|
96
|
+
toolkit: "sdtk-code",
|
|
97
|
+
event_type: "sleep_report",
|
|
98
|
+
command: `sdtk-code sleep report --feature-key ${featureKey}`,
|
|
99
|
+
status: report.verdict,
|
|
100
|
+
output_path: outPath,
|
|
101
|
+
feature_key: featureKey,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
console.log(`Sleep Readiness: ${report.verdict}`);
|
|
105
|
+
console.log(` reason: ${report.reason}`);
|
|
106
|
+
console.log(` readiness: ${report.readiness.score}/${report.readiness.max} — ${report.readiness.verdict}`);
|
|
107
|
+
console.log(` report: ${outPath}`);
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function cmdSleep(args) {
|
|
112
|
+
if (!args || args.length === 0) {
|
|
113
|
+
throw new ValidationError(
|
|
114
|
+
'Usage: sdtk-code sleep <subcommand> [flags]\nSubcommands: plan, report'
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const [subcommand, ...rest] = args;
|
|
119
|
+
|
|
120
|
+
switch (subcommand) {
|
|
121
|
+
case "plan":
|
|
122
|
+
return cmdSleepPlan(rest);
|
|
123
|
+
case "report":
|
|
124
|
+
return cmdSleepReport(rest);
|
|
125
|
+
default:
|
|
126
|
+
throw new ValidationError(
|
|
127
|
+
`Unknown sleep subcommand: "${subcommand}". Available: plan, report`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
module.exports = { cmdSleep };
|
|
@@ -0,0 +1,78 @@
|
|
|
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 { loadWorkflowState } = require("../lib/workflow-state");
|
|
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 formatNextPhase(nextPhase) {
|
|
16
|
+
return nextPhase === "none" ? "none (workflow closed)" : nextPhase;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function cmdStatus(args) {
|
|
20
|
+
const { flags, positional } = parseFlags(args, FLAG_DEFS);
|
|
21
|
+
if (positional.length > 0) {
|
|
22
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "status".');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
26
|
+
validatePattern(
|
|
27
|
+
featureKey,
|
|
28
|
+
FEATURE_KEY_RE,
|
|
29
|
+
"feature-key",
|
|
30
|
+
"Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
34
|
+
const state = loadWorkflowState(projectPath, featureKey);
|
|
35
|
+
|
|
36
|
+
console.log("SDTK-CODE workflow status");
|
|
37
|
+
console.log(` Feature key: ${featureKey}`);
|
|
38
|
+
console.log(` Artifact: ${state.exists ? state.artifactPath : "missing"}`);
|
|
39
|
+
|
|
40
|
+
if (!state.exists) {
|
|
41
|
+
console.log(" Lifecycle: not_started");
|
|
42
|
+
console.log(` Next action: ${state.commandTemplates.start}`);
|
|
43
|
+
console.log(" Resume: unavailable");
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(` Lane: ${state.lane}`);
|
|
48
|
+
console.log(` Current: ${state.currentPhase}`);
|
|
49
|
+
console.log(` Status: ${state.phaseStatus}`);
|
|
50
|
+
console.log(` Next: ${formatNextPhase(state.nextPhase)}`);
|
|
51
|
+
console.log(` Blocking: ${state.blockingState}`);
|
|
52
|
+
|
|
53
|
+
if (state.contradictions.length > 0) {
|
|
54
|
+
console.log(" Health: invalid");
|
|
55
|
+
state.contradictions.forEach((issue) => {
|
|
56
|
+
console.log(` Warning: ${issue}`);
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
console.log(" Health: valid");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (state.resumeDecision && state.resumeDecision.allowed) {
|
|
63
|
+
console.log(" Resume: auto_build");
|
|
64
|
+
console.log(` Action: ${state.resumeDecision.dispatchCommand}`);
|
|
65
|
+
} else if (state.resumeDecision) {
|
|
66
|
+
console.log(` Resume: ${state.resumeDecision.mode}`);
|
|
67
|
+
console.log(` Resume note: ${state.resumeDecision.reason}`);
|
|
68
|
+
if (state.resumeDecision.nextCommand) {
|
|
69
|
+
console.log(` Action: ${state.resumeDecision.nextCommand}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = {
|
|
77
|
+
cmdStatus,
|
|
78
|
+
};
|
package/src/commands/update.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { executeUpdate } = require("../lib/update");
|
|
4
|
-
|
|
5
|
-
async function cmdUpdate(args) {
|
|
6
|
-
return executeUpdate(args);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
cmdUpdate,
|
|
11
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { executeUpdate } = require("../lib/update");
|
|
4
|
+
|
|
5
|
+
async function cmdUpdate(args) {
|
|
6
|
+
return executeUpdate(args);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
cmdUpdate,
|
|
11
|
+
};
|
package/src/commands/verify.js
CHANGED
|
@@ -57,6 +57,11 @@ function cmdVerify(args) {
|
|
|
57
57
|
);
|
|
58
58
|
console.log(` Next phase: ${result.nextPhase}`);
|
|
59
59
|
console.log(` Engine: ${result.suggestedEngineSkills.join(", ")}`);
|
|
60
|
+
if (Array.isArray(result.provenanceWarnings) && result.provenanceWarnings.length > 0) {
|
|
61
|
+
result.provenanceWarnings.forEach((warning) => {
|
|
62
|
+
console.log(` Warning: provenance: ${warning}`);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
60
65
|
|
|
61
66
|
return 0;
|
|
62
67
|
}
|