sdtk-code-kit 0.3.0 → 0.3.2

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 (58) hide show
  1. package/README.md +204 -204
  2. package/assets/manifest/toolkit-bundle.manifest.json +147 -147
  3. package/assets/manifest/toolkit-bundle.sha256.txt +5 -5
  4. package/bin/sdtk-code.js +14 -14
  5. package/package.json +44 -44
  6. package/src/commands/agent-team.js +479 -174
  7. package/src/commands/build.js +53 -53
  8. package/src/commands/doctor.js +51 -51
  9. package/src/commands/generate.js +11 -11
  10. package/src/commands/guardrails.js +215 -215
  11. package/src/commands/help.js +266 -257
  12. package/src/commands/init.js +98 -98
  13. package/src/commands/plan.js +53 -53
  14. package/src/commands/readiness.js +77 -77
  15. package/src/commands/resume.js +61 -61
  16. package/src/commands/runtime.js +224 -224
  17. package/src/commands/ship.js +59 -59
  18. package/src/commands/sleep.js +132 -132
  19. package/src/commands/start.js +89 -89
  20. package/src/commands/status.js +77 -77
  21. package/src/commands/update.js +11 -11
  22. package/src/commands/verify.js +71 -71
  23. package/src/index.js +112 -112
  24. package/src/lib/agent-team-author.js +552 -0
  25. package/src/lib/agent-team-evidence.js +302 -0
  26. package/src/lib/agent-team-execute.js +892 -0
  27. package/src/lib/agent-team-export.js +411 -409
  28. package/src/lib/agent-team-plan.js +514 -514
  29. package/src/lib/agent-team-readiness.js +161 -0
  30. package/src/lib/agent-team-report.js +165 -0
  31. package/src/lib/agent-team-sleep-execute.js +524 -0
  32. package/src/lib/agent-team-sleep-session.js +278 -0
  33. package/src/lib/args.js +107 -107
  34. package/src/lib/errors.js +41 -41
  35. package/src/lib/model-provider.js +219 -0
  36. package/src/lib/powershell.js +65 -65
  37. package/src/lib/project-target-guard.js +53 -53
  38. package/src/lib/scope.js +72 -72
  39. package/src/lib/ship-readiness.js +281 -281
  40. package/src/lib/sleep-plan.js +175 -175
  41. package/src/lib/sleep-report.js +229 -229
  42. package/src/lib/toolkit-payload.js +72 -72
  43. package/src/lib/trust-events.js +264 -185
  44. package/src/lib/trust-file-scope.js +154 -154
  45. package/src/lib/trust-policy.js +212 -212
  46. package/src/lib/trust-redact.js +58 -35
  47. package/src/lib/trust-trace.js +179 -179
  48. package/src/lib/update.js +344 -344
  49. package/src/lib/workflow-artifact.js +503 -503
  50. package/src/lib/workflow-build.js +127 -127
  51. package/src/lib/workflow-doctor.js +83 -83
  52. package/src/lib/workflow-handoff.js +1029 -1029
  53. package/src/lib/workflow-intake.js +101 -101
  54. package/src/lib/workflow-plan.js +193 -193
  55. package/src/lib/workflow-review-packet.js +650 -650
  56. package/src/lib/workflow-ship.js +213 -213
  57. package/src/lib/workflow-state.js +438 -438
  58. package/src/lib/workflow-verify.js +393 -393
@@ -1,132 +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 };
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 };
@@ -1,89 +1,89 @@
1
- "use strict";
2
-
3
- const path = require("path");
4
- const { parseFlags, requireFlag, validateChoice, validatePattern } = require("../lib/args");
5
- const { ValidationError } = require("../lib/errors");
6
- const { runIntake } = require("../lib/workflow-intake");
7
- const { createOrUpdateWorkflowArtifact } = require("../lib/workflow-artifact");
8
-
9
- const FLAG_DEFS = {
10
- lane: { type: "string" },
11
- "feature-key": { type: "string" },
12
- "project-path": { type: "string" },
13
- force: { type: "boolean" },
14
- };
15
-
16
- const VALID_LANES = ["feature", "bugfix"];
17
- const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
18
-
19
- function formatIntakeSource(intake) {
20
- return intake.intakeSource === "formal_handoff"
21
- ? "formal SDTK-SPEC handoff"
22
- : "legacy compatibility intake";
23
- }
24
-
25
- function buildBlockedIntakeMessage(intake, artifactPath) {
26
- if (intake.blockingState === "blocked_upstream_handoff") {
27
- const details = intake.blockingDetails.map((entry) => `- ${entry}`).join("\n");
28
- return `${intake.blockingMessage}\n${details}\nArtifact written to: ${artifactPath}`;
29
- }
30
-
31
- if (intake.blockingState === "invalid_handoff_contract") {
32
- return `${intake.blockingMessage}\nArtifact written to: ${artifactPath}`;
33
- }
34
-
35
- const details = intake.missingInputs.map((entry) => `- ${entry.key}: ${entry.path}`).join("\n");
36
- return `Workflow intake blocked. Missing required inputs:\n${details}\nArtifact written to: ${artifactPath}`;
37
- }
38
-
39
- function cmdStart(args) {
40
- const { flags, positional } = parseFlags(args, FLAG_DEFS);
41
- if (positional.length > 0) {
42
- throw new ValidationError('Unexpected positional arguments. Use flags only for "start".');
43
- }
44
-
45
- const lane = requireFlag(flags, "lane", "lane");
46
- validateChoice(lane, VALID_LANES, "lane");
47
-
48
- const featureKey = requireFlag(flags, "feature-key", "feature-key");
49
- validatePattern(
50
- featureKey,
51
- FEATURE_KEY_RE,
52
- "feature-key",
53
- "Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
54
- );
55
-
56
- const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
57
- const intake = runIntake(projectPath, featureKey, lane);
58
- const artifactPath = createOrUpdateWorkflowArtifact({
59
- featureKey,
60
- lane,
61
- projectPath,
62
- force: flags.force,
63
- managedBlocks: ["METADATA", "INPUTS", "STATUS"],
64
- ...intake,
65
- });
66
-
67
- console.log("SDTK-CODE workflow start");
68
- console.log(` Feature key: ${featureKey}`);
69
- console.log(` Lane: ${lane}`);
70
- console.log(` Intake: ${formatIntakeSource(intake)}`);
71
- console.log(` Handoff: ${intake.handoffStatus}`);
72
- console.log(` Outcome: ${intake.intakeOutcome}`);
73
- console.log(` Artifact: ${artifactPath}`);
74
- console.log(` Next phase: ${intake.nextPhase}`);
75
- console.log(` Engine: ${intake.suggestedEngineSkills.join(", ")}`);
76
- for (const warning of intake.compatibilityWarnings || []) {
77
- console.log(` Note: ${warning}`);
78
- }
79
-
80
- if (intake.blocked) {
81
- throw new ValidationError(buildBlockedIntakeMessage(intake, artifactPath));
82
- }
83
-
84
- return 0;
85
- }
86
-
87
- module.exports = {
88
- cmdStart,
89
- };
1
+ "use strict";
2
+
3
+ const path = require("path");
4
+ const { parseFlags, requireFlag, validateChoice, validatePattern } = require("../lib/args");
5
+ const { ValidationError } = require("../lib/errors");
6
+ const { runIntake } = require("../lib/workflow-intake");
7
+ const { createOrUpdateWorkflowArtifact } = require("../lib/workflow-artifact");
8
+
9
+ const FLAG_DEFS = {
10
+ lane: { type: "string" },
11
+ "feature-key": { type: "string" },
12
+ "project-path": { type: "string" },
13
+ force: { type: "boolean" },
14
+ };
15
+
16
+ const VALID_LANES = ["feature", "bugfix"];
17
+ const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
18
+
19
+ function formatIntakeSource(intake) {
20
+ return intake.intakeSource === "formal_handoff"
21
+ ? "formal SDTK-SPEC handoff"
22
+ : "legacy compatibility intake";
23
+ }
24
+
25
+ function buildBlockedIntakeMessage(intake, artifactPath) {
26
+ if (intake.blockingState === "blocked_upstream_handoff") {
27
+ const details = intake.blockingDetails.map((entry) => `- ${entry}`).join("\n");
28
+ return `${intake.blockingMessage}\n${details}\nArtifact written to: ${artifactPath}`;
29
+ }
30
+
31
+ if (intake.blockingState === "invalid_handoff_contract") {
32
+ return `${intake.blockingMessage}\nArtifact written to: ${artifactPath}`;
33
+ }
34
+
35
+ const details = intake.missingInputs.map((entry) => `- ${entry.key}: ${entry.path}`).join("\n");
36
+ return `Workflow intake blocked. Missing required inputs:\n${details}\nArtifact written to: ${artifactPath}`;
37
+ }
38
+
39
+ function cmdStart(args) {
40
+ const { flags, positional } = parseFlags(args, FLAG_DEFS);
41
+ if (positional.length > 0) {
42
+ throw new ValidationError('Unexpected positional arguments. Use flags only for "start".');
43
+ }
44
+
45
+ const lane = requireFlag(flags, "lane", "lane");
46
+ validateChoice(lane, VALID_LANES, "lane");
47
+
48
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
49
+ validatePattern(
50
+ featureKey,
51
+ FEATURE_KEY_RE,
52
+ "feature-key",
53
+ "Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
54
+ );
55
+
56
+ const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
57
+ const intake = runIntake(projectPath, featureKey, lane);
58
+ const artifactPath = createOrUpdateWorkflowArtifact({
59
+ featureKey,
60
+ lane,
61
+ projectPath,
62
+ force: flags.force,
63
+ managedBlocks: ["METADATA", "INPUTS", "STATUS"],
64
+ ...intake,
65
+ });
66
+
67
+ console.log("SDTK-CODE workflow start");
68
+ console.log(` Feature key: ${featureKey}`);
69
+ console.log(` Lane: ${lane}`);
70
+ console.log(` Intake: ${formatIntakeSource(intake)}`);
71
+ console.log(` Handoff: ${intake.handoffStatus}`);
72
+ console.log(` Outcome: ${intake.intakeOutcome}`);
73
+ console.log(` Artifact: ${artifactPath}`);
74
+ console.log(` Next phase: ${intake.nextPhase}`);
75
+ console.log(` Engine: ${intake.suggestedEngineSkills.join(", ")}`);
76
+ for (const warning of intake.compatibilityWarnings || []) {
77
+ console.log(` Note: ${warning}`);
78
+ }
79
+
80
+ if (intake.blocked) {
81
+ throw new ValidationError(buildBlockedIntakeMessage(intake, artifactPath));
82
+ }
83
+
84
+ return 0;
85
+ }
86
+
87
+ module.exports = {
88
+ cmdStart,
89
+ };
@@ -1,78 +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,
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
78
  };
@@ -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
+ };