sdtk-code-kit 0.3.0 → 0.3.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 +204 -204
- package/assets/manifest/toolkit-bundle.manifest.json +147 -147
- package/assets/manifest/toolkit-bundle.sha256.txt +5 -5
- package/bin/sdtk-code.js +14 -14
- package/package.json +44 -44
- package/src/commands/agent-team.js +425 -174
- package/src/commands/build.js +53 -53
- package/src/commands/doctor.js +51 -51
- package/src/commands/generate.js +11 -11
- package/src/commands/guardrails.js +215 -215
- package/src/commands/help.js +264 -257
- package/src/commands/init.js +98 -98
- package/src/commands/plan.js +53 -53
- package/src/commands/readiness.js +77 -77
- package/src/commands/resume.js +61 -61
- package/src/commands/runtime.js +224 -224
- package/src/commands/ship.js +59 -59
- package/src/commands/sleep.js +132 -132
- package/src/commands/start.js +89 -89
- package/src/commands/status.js +77 -77
- package/src/commands/update.js +11 -11
- package/src/commands/verify.js +71 -71
- package/src/index.js +112 -112
- package/src/lib/agent-team-author.js +521 -0
- package/src/lib/agent-team-evidence.js +302 -0
- package/src/lib/agent-team-execute.js +892 -0
- package/src/lib/agent-team-export.js +411 -409
- package/src/lib/agent-team-plan.js +514 -514
- package/src/lib/agent-team-readiness.js +161 -0
- package/src/lib/agent-team-report.js +165 -0
- package/src/lib/args.js +107 -107
- package/src/lib/errors.js +41 -41
- package/src/lib/model-provider.js +219 -0
- package/src/lib/powershell.js +65 -65
- package/src/lib/project-target-guard.js +53 -53
- package/src/lib/scope.js +72 -72
- package/src/lib/ship-readiness.js +281 -281
- package/src/lib/sleep-plan.js +175 -175
- package/src/lib/sleep-report.js +229 -229
- package/src/lib/toolkit-payload.js +72 -72
- package/src/lib/trust-events.js +252 -185
- package/src/lib/trust-file-scope.js +154 -154
- package/src/lib/trust-policy.js +212 -212
- package/src/lib/trust-redact.js +58 -35
- package/src/lib/trust-trace.js +179 -179
- package/src/lib/update.js +344 -344
- package/src/lib/workflow-artifact.js +503 -503
- package/src/lib/workflow-build.js +127 -127
- package/src/lib/workflow-doctor.js +83 -83
- package/src/lib/workflow-handoff.js +1029 -1029
- package/src/lib/workflow-intake.js +101 -101
- package/src/lib/workflow-plan.js +193 -193
- package/src/lib/workflow-review-packet.js +650 -650
- package/src/lib/workflow-ship.js +213 -213
- package/src/lib/workflow-state.js +438 -438
- package/src/lib/workflow-verify.js +393 -393
|
@@ -1,174 +1,425 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const path = require("path");
|
|
4
|
-
const
|
|
5
|
-
const {
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
console.log(
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const readline = require("readline");
|
|
5
|
+
const { parseFlags, requireFlag, validateChoice } = require("../lib/args");
|
|
6
|
+
const { ValidationError } = require("../lib/errors");
|
|
7
|
+
const {
|
|
8
|
+
assembleAgentTeamPlan,
|
|
9
|
+
writeAgentTeamPlan,
|
|
10
|
+
writeTaskPackets,
|
|
11
|
+
loadAgentTeamPlan,
|
|
12
|
+
projectAgentTeamPreview,
|
|
13
|
+
renderPreviewMarkdown,
|
|
14
|
+
writeAgentTeamPreview,
|
|
15
|
+
gatherPreviewReadiness,
|
|
16
|
+
} = require("../lib/agent-team-plan");
|
|
17
|
+
const {
|
|
18
|
+
EXPORT_RUNTIMES,
|
|
19
|
+
projectExport,
|
|
20
|
+
writeExportBundle,
|
|
21
|
+
} = require("../lib/agent-team-export");
|
|
22
|
+
const { submitEvidence } = require("../lib/agent-team-evidence");
|
|
23
|
+
const {
|
|
24
|
+
READINESS_NOTE,
|
|
25
|
+
computeReadiness,
|
|
26
|
+
writeReadiness,
|
|
27
|
+
} = require("../lib/agent-team-readiness");
|
|
28
|
+
const {
|
|
29
|
+
buildMorningReport,
|
|
30
|
+
writeReport,
|
|
31
|
+
} = require("../lib/agent-team-report");
|
|
32
|
+
const {
|
|
33
|
+
loadExecuteContext,
|
|
34
|
+
runExecute,
|
|
35
|
+
confirmExecute,
|
|
36
|
+
} = require("../lib/agent-team-execute");
|
|
37
|
+
const { runAuthor } = require("../lib/agent-team-author");
|
|
38
|
+
const { appendEvent } = require("../lib/trust-events");
|
|
39
|
+
|
|
40
|
+
const FLAG_DEFS = {
|
|
41
|
+
"feature-key": { type: "string" },
|
|
42
|
+
"project-path": { type: "string" },
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const EXPORT_FLAG_DEFS = {
|
|
46
|
+
"feature-key": { type: "string" },
|
|
47
|
+
"project-path": { type: "string" },
|
|
48
|
+
runtime: { type: "string" },
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const EVIDENCE_FLAG_DEFS = {
|
|
52
|
+
"feature-key": { type: "string" },
|
|
53
|
+
"project-path": { type: "string" },
|
|
54
|
+
role: { type: "string" },
|
|
55
|
+
"evidence-file": { type: "string" },
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const READINESS_REPORT_FLAG_DEFS = {
|
|
59
|
+
"feature-key": { type: "string" },
|
|
60
|
+
"project-path": { type: "string" },
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const EXECUTE_FLAG_DEFS = {
|
|
64
|
+
"feature-key": { type: "string" },
|
|
65
|
+
"project-path": { type: "string" },
|
|
66
|
+
"patch-file": { type: "string" },
|
|
67
|
+
execute: { type: "boolean" },
|
|
68
|
+
"dry-run": { type: "boolean" },
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const AUTHOR_FLAG_DEFS = {
|
|
72
|
+
"feature-key": { type: "string" },
|
|
73
|
+
"project-path": { type: "string" },
|
|
74
|
+
execute: { type: "boolean" },
|
|
75
|
+
"dry-run": { type: "boolean" },
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
function resolveProjectPath(flags) {
|
|
79
|
+
return flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function cmdAgentTeamPlan(args) {
|
|
83
|
+
const { flags, positional } = parseFlags(args, FLAG_DEFS);
|
|
84
|
+
if (positional.length > 0) {
|
|
85
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "agent-team plan".');
|
|
86
|
+
}
|
|
87
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
88
|
+
const projectPath = resolveProjectPath(flags);
|
|
89
|
+
|
|
90
|
+
const plan = assembleAgentTeamPlan(projectPath, featureKey);
|
|
91
|
+
const planPath = writeAgentTeamPlan(projectPath, plan);
|
|
92
|
+
const packetPaths = writeTaskPackets(projectPath, plan);
|
|
93
|
+
|
|
94
|
+
appendEvent(projectPath, {
|
|
95
|
+
toolkit: "sdtk-code",
|
|
96
|
+
event_type: "agent_team_plan",
|
|
97
|
+
command: `sdtk-code agent-team plan --feature-key ${featureKey}`,
|
|
98
|
+
status: "ok",
|
|
99
|
+
feature_key: featureKey,
|
|
100
|
+
run_id: plan.run_id,
|
|
101
|
+
output_path: planPath,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
console.log(`agent-team plan written: ${planPath}`);
|
|
105
|
+
console.log(` feature_key: ${plan.feature_key}`);
|
|
106
|
+
console.log(` run_id: ${plan.run_id}`);
|
|
107
|
+
console.log(` roles: ${plan.roles.map((role) => role.role).join(", ")}`);
|
|
108
|
+
console.log(` task packets: ${packetPaths.length}`);
|
|
109
|
+
console.log(` stop_conditions: ${plan.stop_conditions.length}`);
|
|
110
|
+
console.log(" preview only — agents are not executed and Sleep execution is not available in this phase.");
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function cmdAgentTeamPreview(args) {
|
|
115
|
+
const { flags, positional } = parseFlags(args, FLAG_DEFS);
|
|
116
|
+
if (positional.length > 0) {
|
|
117
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "agent-team preview".');
|
|
118
|
+
}
|
|
119
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
120
|
+
const projectPath = resolveProjectPath(flags);
|
|
121
|
+
|
|
122
|
+
const plan = loadAgentTeamPlan(projectPath, featureKey);
|
|
123
|
+
if (plan.feature_key !== featureKey) {
|
|
124
|
+
throw new ValidationError(
|
|
125
|
+
`agent-team plan feature_key "${plan.feature_key}" does not match --feature-key "${featureKey}".`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const readiness = gatherPreviewReadiness(projectPath, featureKey);
|
|
130
|
+
const preview = projectAgentTeamPreview(plan, readiness);
|
|
131
|
+
const markdown = renderPreviewMarkdown(plan, preview);
|
|
132
|
+
const outPath = writeAgentTeamPreview(projectPath, featureKey, markdown);
|
|
133
|
+
|
|
134
|
+
appendEvent(projectPath, {
|
|
135
|
+
toolkit: "sdtk-code",
|
|
136
|
+
event_type: "agent_team_preview",
|
|
137
|
+
command: `sdtk-code agent-team preview --feature-key ${featureKey}`,
|
|
138
|
+
status: preview.verdict,
|
|
139
|
+
feature_key: featureKey,
|
|
140
|
+
run_id: plan.run_id,
|
|
141
|
+
output_path: outPath,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
console.log(`Agent Team Preview: ${preview.verdict}`);
|
|
145
|
+
console.log(` run_id: ${preview.run_id}`);
|
|
146
|
+
console.log(` roles: ${preview.roles.map((role) => role.role).join(", ")}`);
|
|
147
|
+
console.log(` report: ${outPath}`);
|
|
148
|
+
console.log(" preview only — agents are not executed and Sleep execution is not available in this phase.");
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function cmdAgentTeamExport(args) {
|
|
153
|
+
const { flags, positional } = parseFlags(args, EXPORT_FLAG_DEFS);
|
|
154
|
+
if (positional.length > 0) {
|
|
155
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "agent-team export".');
|
|
156
|
+
}
|
|
157
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
158
|
+
const runtime = requireFlag(flags, "runtime", "runtime");
|
|
159
|
+
validateChoice(runtime, EXPORT_RUNTIMES, "runtime");
|
|
160
|
+
const projectPath = resolveProjectPath(flags);
|
|
161
|
+
|
|
162
|
+
const plan = loadAgentTeamPlan(projectPath, featureKey);
|
|
163
|
+
if (plan.feature_key !== featureKey) {
|
|
164
|
+
throw new ValidationError(
|
|
165
|
+
`agent-team plan feature_key "${plan.feature_key}" does not match --feature-key "${featureKey}".`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const exported = projectExport(plan, runtime);
|
|
170
|
+
const written = writeExportBundle(projectPath, exported);
|
|
171
|
+
|
|
172
|
+
appendEvent(projectPath, {
|
|
173
|
+
toolkit: "sdtk-code",
|
|
174
|
+
event_type: "agent_team_export",
|
|
175
|
+
command: `sdtk-code agent-team export --feature-key ${featureKey} --runtime ${runtime}`,
|
|
176
|
+
status: "ok",
|
|
177
|
+
feature_key: featureKey,
|
|
178
|
+
run_id: exported.run_id,
|
|
179
|
+
output_path: written[written.length - 1],
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
console.log(`agent-team export written (${runtime}): ${path.dirname(written[0])}`);
|
|
183
|
+
console.log(` feature_key: ${exported.feature_key}`);
|
|
184
|
+
console.log(` run_id: ${exported.run_id}`);
|
|
185
|
+
console.log(` roles: ${exported.roles.map((role) => role.role).join(", ")}`);
|
|
186
|
+
console.log(` files: ${written.length}`);
|
|
187
|
+
console.log(" export/preview only — agents are not executed and Sleep execution is not available in this phase.");
|
|
188
|
+
return 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function cmdAgentTeamEvidenceSubmit(args) {
|
|
192
|
+
const { flags, positional } = parseFlags(args, EVIDENCE_FLAG_DEFS);
|
|
193
|
+
if (positional.length > 0) {
|
|
194
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "agent-team evidence submit".');
|
|
195
|
+
}
|
|
196
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
197
|
+
const role = requireFlag(flags, "role", "role");
|
|
198
|
+
const evidenceFile = requireFlag(flags, "evidence-file", "evidence-file");
|
|
199
|
+
const projectPath = resolveProjectPath(flags);
|
|
200
|
+
const evidenceFilePath = path.resolve(evidenceFile);
|
|
201
|
+
|
|
202
|
+
const result = submitEvidence(projectPath, featureKey, role, evidenceFilePath);
|
|
203
|
+
|
|
204
|
+
appendEvent(projectPath, {
|
|
205
|
+
toolkit: "sdtk-code",
|
|
206
|
+
event_type: "agent_team_evidence_submit",
|
|
207
|
+
command: `sdtk-code agent-team evidence submit --feature-key ${featureKey} --role ${result.role}`,
|
|
208
|
+
status: "ok",
|
|
209
|
+
feature_key: featureKey,
|
|
210
|
+
run_id: result.run_id,
|
|
211
|
+
agent_role: result.role,
|
|
212
|
+
stop_condition_hit: result.stop_condition_hit,
|
|
213
|
+
evidence_quality_ok: true,
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
console.log(`agent-team evidence written: ${result.outputPath}`);
|
|
217
|
+
console.log(` feature_key: ${featureKey}`);
|
|
218
|
+
console.log(` role: ${result.role}`);
|
|
219
|
+
console.log(` run_id: ${result.run_id}`);
|
|
220
|
+
console.log(` stop_condition_hit: ${result.stop_condition_hit || "none"}`);
|
|
221
|
+
console.log(" evidence storage only — agents are not executed and no runtime hooks are installed.");
|
|
222
|
+
return 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function cmdAgentTeamReadiness(args) {
|
|
226
|
+
const { flags, positional } = parseFlags(args, READINESS_REPORT_FLAG_DEFS);
|
|
227
|
+
if (positional.length > 0) {
|
|
228
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "agent-team readiness".');
|
|
229
|
+
}
|
|
230
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
231
|
+
const projectPath = resolveProjectPath(flags);
|
|
232
|
+
|
|
233
|
+
const readiness = computeReadiness(projectPath, featureKey);
|
|
234
|
+
const readinessPath = writeReadiness(projectPath, featureKey, readiness);
|
|
235
|
+
const rolesNotReadyCount = readiness.roles.filter((role) => role.verdict !== "READY").length;
|
|
236
|
+
|
|
237
|
+
appendEvent(projectPath, {
|
|
238
|
+
toolkit: "sdtk-code",
|
|
239
|
+
event_type: "agent_team_readiness",
|
|
240
|
+
command: `sdtk-code agent-team readiness --feature-key ${featureKey}`,
|
|
241
|
+
status: readiness.overall_verdict,
|
|
242
|
+
feature_key: featureKey,
|
|
243
|
+
run_id: readiness.run_id,
|
|
244
|
+
overall_verdict: readiness.overall_verdict,
|
|
245
|
+
roles_not_ready_count: rolesNotReadyCount,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
console.log(`Agent Team Readiness: ${readiness.overall_verdict}`);
|
|
249
|
+
console.log(` run_id: ${readiness.run_id}`);
|
|
250
|
+
console.log(` report: ${readinessPath}`);
|
|
251
|
+
console.log(` note: ${READINESS_NOTE}`);
|
|
252
|
+
console.log(" roles:");
|
|
253
|
+
for (const role of readiness.roles) {
|
|
254
|
+
console.log(` ${role.role}: ${role.verdict}${role.reason ? ` — ${role.reason}` : ""}`);
|
|
255
|
+
}
|
|
256
|
+
return 0;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function cmdAgentTeamReport(args) {
|
|
260
|
+
const { flags, positional } = parseFlags(args, READINESS_REPORT_FLAG_DEFS);
|
|
261
|
+
if (positional.length > 0) {
|
|
262
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "agent-team report".');
|
|
263
|
+
}
|
|
264
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
265
|
+
const projectPath = resolveProjectPath(flags);
|
|
266
|
+
|
|
267
|
+
const built = buildMorningReport(projectPath, featureKey);
|
|
268
|
+
const reportPath = writeReport(projectPath, featureKey, built.markdown);
|
|
269
|
+
|
|
270
|
+
appendEvent(projectPath, {
|
|
271
|
+
toolkit: "sdtk-code",
|
|
272
|
+
event_type: "agent_team_report",
|
|
273
|
+
command: `sdtk-code agent-team report --feature-key ${featureKey}`,
|
|
274
|
+
status: built.readinessJson.overall_verdict,
|
|
275
|
+
feature_key: featureKey,
|
|
276
|
+
run_id: built.plan.run_id,
|
|
277
|
+
report_path: reportPath,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
console.log(`agent-team report written: ${reportPath}`);
|
|
281
|
+
console.log(` feature_key: ${built.plan.feature_key}`);
|
|
282
|
+
console.log(` run_id: ${built.plan.run_id}`);
|
|
283
|
+
console.log(` verdict: ${built.readinessJson.overall_verdict}`);
|
|
284
|
+
console.log(` note: ${READINESS_NOTE}`);
|
|
285
|
+
console.log(" report only — no agents are executed and implementation correctness is not verified.");
|
|
286
|
+
return 0;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
function readLineFromStdin(prompt) {
|
|
291
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
292
|
+
return new Promise((resolve) => {
|
|
293
|
+
rl.question(prompt, (answer) => {
|
|
294
|
+
rl.close();
|
|
295
|
+
resolve(answer);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async function cmdAgentTeamExecute(args) {
|
|
301
|
+
const { flags, positional } = parseFlags(args, EXECUTE_FLAG_DEFS);
|
|
302
|
+
if (positional.length > 0) {
|
|
303
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "agent-team execute".');
|
|
304
|
+
}
|
|
305
|
+
if (flags.execute && flags["dry-run"]) {
|
|
306
|
+
throw new ValidationError('Use either --execute or --dry-run, not both.');
|
|
307
|
+
}
|
|
308
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
309
|
+
const patchFile = requireFlag(flags, "patch-file", "patch-file");
|
|
310
|
+
const projectPath = resolveProjectPath(flags);
|
|
311
|
+
const mode = flags.execute ? "execute" : "dry-run";
|
|
312
|
+
|
|
313
|
+
if (mode === "execute") {
|
|
314
|
+
const ctx = loadExecuteContext(projectPath, featureKey);
|
|
315
|
+
await confirmExecute({
|
|
316
|
+
isTTY: process.stdin.isTTY === true,
|
|
317
|
+
readLine: readLineFromStdin,
|
|
318
|
+
}, featureKey, ctx.runId);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const result = runExecute(projectPath, featureKey, { mode, patchFile });
|
|
322
|
+
appendEvent(projectPath, {
|
|
323
|
+
toolkit: "sdtk-code",
|
|
324
|
+
event_type: mode === "execute" ? "agent_team_execute_ran" : "agent_team_execute_planned",
|
|
325
|
+
command: `sdtk-code agent-team execute --feature-key ${featureKey} --patch-file ${patchFile}${mode === "execute" ? " --execute" : ""}`,
|
|
326
|
+
status: result.status,
|
|
327
|
+
feature_key: result.feature_key,
|
|
328
|
+
run_id: result.run_id,
|
|
329
|
+
stop_condition_hit: result.stop_condition_hit,
|
|
330
|
+
worktree_path: result.worktree_path,
|
|
331
|
+
actions_executed: result.actions_executed,
|
|
332
|
+
execution_mode: result.execution_mode,
|
|
333
|
+
workflow_type: result.workflow_type,
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
console.log(result.stdout || `Agent Team Execute: ${result.status}`);
|
|
337
|
+
return result.exitCode;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async function cmdAgentTeamAuthor(args) {
|
|
341
|
+
const { flags, positional } = parseFlags(args, AUTHOR_FLAG_DEFS);
|
|
342
|
+
if (positional.length > 0) {
|
|
343
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "agent-team author".');
|
|
344
|
+
}
|
|
345
|
+
if (flags.execute && flags["dry-run"]) {
|
|
346
|
+
throw new ValidationError('Use either --execute or --dry-run, not both.');
|
|
347
|
+
}
|
|
348
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
349
|
+
const projectPath = resolveProjectPath(flags);
|
|
350
|
+
const mode = flags.execute ? "execute" : "dry-run";
|
|
351
|
+
|
|
352
|
+
const result = await runAuthor(projectPath, featureKey, {
|
|
353
|
+
mode,
|
|
354
|
+
confirmInput: {
|
|
355
|
+
isTTY: process.stdin.isTTY === true,
|
|
356
|
+
readLine: readLineFromStdin,
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
appendEvent(projectPath, {
|
|
361
|
+
toolkit: "sdtk-code",
|
|
362
|
+
event_type: "agent_team_d2b_authored",
|
|
363
|
+
command: `sdtk-code agent-team author --feature-key ${featureKey}${mode === "execute" ? " --execute" : ""}`,
|
|
364
|
+
status: result.status,
|
|
365
|
+
feature_key: result.feature_key,
|
|
366
|
+
run_id: result.run_id,
|
|
367
|
+
stop_condition_hit: result.stop_condition_hit,
|
|
368
|
+
worktree_path: result.worktree_path,
|
|
369
|
+
actions_executed: result.actions_executed,
|
|
370
|
+
execution_mode: result.execution_mode,
|
|
371
|
+
workflow_type: result.workflow_type,
|
|
372
|
+
model_provider: result.model_provider,
|
|
373
|
+
model_id: result.model_id,
|
|
374
|
+
prompt_sha256: result.prompt_sha256,
|
|
375
|
+
context_manifest: result.context_manifest,
|
|
376
|
+
produced_patch_sha256: result.produced_patch_sha256,
|
|
377
|
+
model_call_count: result.model_call_count,
|
|
378
|
+
tokens_used: result.tokens_used,
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
console.log(result.stdout || `Agent Team Author: ${result.status}`);
|
|
382
|
+
return result.exitCode;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function cmdAgentTeam(args) {
|
|
386
|
+
if (!args || args.length === 0) {
|
|
387
|
+
throw new ValidationError(
|
|
388
|
+
"Usage: sdtk-code agent-team <subcommand> [flags]\nSubcommands: plan, preview, export, evidence, readiness, report, execute, author\n(run is not available; execute is bounded docs-only; author is attended D-2b.)"
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const [subcommand, ...rest] = args;
|
|
393
|
+
|
|
394
|
+
switch (subcommand) {
|
|
395
|
+
case "plan":
|
|
396
|
+
return cmdAgentTeamPlan(rest);
|
|
397
|
+
case "preview":
|
|
398
|
+
return cmdAgentTeamPreview(rest);
|
|
399
|
+
case "export":
|
|
400
|
+
return cmdAgentTeamExport(rest);
|
|
401
|
+
case "evidence":
|
|
402
|
+
if (!rest[0] || rest[0] !== "submit") {
|
|
403
|
+
throw new ValidationError('Usage: sdtk-code agent-team evidence submit --feature-key <KEY> --role <pm|dev|qa> --evidence-file <path>');
|
|
404
|
+
}
|
|
405
|
+
return cmdAgentTeamEvidenceSubmit(rest.slice(1));
|
|
406
|
+
case "readiness":
|
|
407
|
+
return cmdAgentTeamReadiness(rest);
|
|
408
|
+
case "report":
|
|
409
|
+
return cmdAgentTeamReport(rest);
|
|
410
|
+
case "execute":
|
|
411
|
+
return cmdAgentTeamExecute(rest);
|
|
412
|
+
case "author":
|
|
413
|
+
return cmdAgentTeamAuthor(rest);
|
|
414
|
+
case "run":
|
|
415
|
+
throw new ValidationError(
|
|
416
|
+
`"agent-team run" is not available in this phase. Supported: plan, preview, export, evidence, readiness, report, execute (bounded docs-only), author (attended D-2b).`
|
|
417
|
+
);
|
|
418
|
+
default:
|
|
419
|
+
throw new ValidationError(
|
|
420
|
+
`Unknown agent-team subcommand: "${subcommand}". Available: plan, preview, export, evidence, readiness, report, execute, author`
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
module.exports = { cmdAgentTeam };
|