sdtk-code-kit 0.3.1 → 0.3.3
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/assets/manifest/toolkit-bundle.manifest.json +31 -26
- package/assets/manifest/toolkit-bundle.sha256.txt +7 -6
- package/assets/toolkit/toolkit/AGENTS.md +162 -218
- package/assets/toolkit/toolkit/SDTKCODE_TOOLKIT.md +197 -0
- package/package.json +1 -1
- package/src/commands/agent-team.js +57 -3
- package/src/commands/help.js +3 -1
- package/src/lib/agent-team-author.js +71 -40
- package/src/lib/agent-team-sleep-execute.js +524 -0
- package/src/lib/agent-team-sleep-session.js +278 -0
- package/src/lib/trust-events.js +12 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Software Development Toolkit - Code (SDTK-CODE)
|
|
2
|
+
|
|
3
|
+
## Document Role
|
|
4
|
+
This file is the architecture and product-boundary document for `SDTK-CODE`.
|
|
5
|
+
|
|
6
|
+
Use this file to understand:
|
|
7
|
+
- how `SDTK-CODE` fits inside the `SDTK-SPEC -> SDTK-CODE -> SDTK-OPS` family
|
|
8
|
+
- what the workflow-first layer owns
|
|
9
|
+
- how the workflow layer maps to the existing `code-*` specialist engine
|
|
10
|
+
- what stays outside `SDTK-CODE` scope
|
|
11
|
+
|
|
12
|
+
Do not use this file as the primary install or onboarding guide.
|
|
13
|
+
|
|
14
|
+
Canonical end-user guide:
|
|
15
|
+
- `products/sdtk-code/governance/SDTKCODE_TOOLKIT_USAGE_GUIDE.md`
|
|
16
|
+
|
|
17
|
+
## 1. Overview
|
|
18
|
+
|
|
19
|
+
`SDTK-CODE` is the coding-process product in the `SDTK-SPEC -> SDTK-CODE -> SDTK-OPS` family.
|
|
20
|
+
|
|
21
|
+
It is workflow-first:
|
|
22
|
+
- `start`
|
|
23
|
+
- `plan`
|
|
24
|
+
- `build`
|
|
25
|
+
- `verify`
|
|
26
|
+
- `ship`
|
|
27
|
+
|
|
28
|
+
It still keeps the existing specialist engine:
|
|
29
|
+
- the 12 `code-*` skills remain intact
|
|
30
|
+
- expert mode remains direct raw `code-*` usage inside Claude or Codex
|
|
31
|
+
|
|
32
|
+
`SDTK-OPS` now exists as a public downstream operations product via the `sdtk-ops-kit` package. Its install and usage truth is documented in the `products/sdtk-ops/` docs rather than in this file.
|
|
33
|
+
|
|
34
|
+
## 2. Boundary With SDTK-SPEC
|
|
35
|
+
|
|
36
|
+
`SDTK-SPEC` is upstream and remains the docs-first system.
|
|
37
|
+
|
|
38
|
+
`SDTK-SPEC` owns:
|
|
39
|
+
- PM, BA, and ARCH artifact generation
|
|
40
|
+
- docs-first SDLC orchestration
|
|
41
|
+
- upstream handoff generation
|
|
42
|
+
- QA artifact and release-governance flow
|
|
43
|
+
|
|
44
|
+
`SDTK-CODE` owns:
|
|
45
|
+
- implementation workflow after handoff
|
|
46
|
+
- execution-slice refinement and coding-plan discipline after valid intake
|
|
47
|
+
- TDD, debugging, verification, review, and ship discipline
|
|
48
|
+
- canonical `CODE -> OPS` bridge production from completed formal closeout
|
|
49
|
+
|
|
50
|
+
`SDTK-CODE` begins only after upstream handoff inputs already exist.
|
|
51
|
+
|
|
52
|
+
Task-breakdown truth:
|
|
53
|
+
- upstream `SDTK-SPEC` `/dev` still owns implementation-readiness planning and formal handoff scope
|
|
54
|
+
- `FEATURE_IMPL_PLAN_[FEATURE_KEY].md` remains the upstream readiness plan
|
|
55
|
+
- `sdtk-code plan` refines downstream execution slices only after intake succeeds
|
|
56
|
+
|
|
57
|
+
Preferred intake artifact:
|
|
58
|
+
- `docs/dev/CODE_HANDOFF_[FEATURE_KEY].json`
|
|
59
|
+
|
|
60
|
+
Bounded compatibility fallback when the formal handoff file is missing:
|
|
61
|
+
- `docs/dev/FEATURE_IMPL_PLAN_[FEATURE_KEY].md`
|
|
62
|
+
- `sdtk-spec.config.json`
|
|
63
|
+
- relevant architecture, API, database, and flow/screen specs for the current slice when applicable
|
|
64
|
+
|
|
65
|
+
Completed formal closeout also produces:
|
|
66
|
+
- `docs/dev/OPS_HANDOFF_[FEATURE_KEY].json`
|
|
67
|
+
|
|
68
|
+
Compatibility fallback does not replace the formal `CODE_HANDOFF -> OPS_HANDOFF` bridge chain.
|
|
69
|
+
|
|
70
|
+
## 3. Two-Layer Product Model
|
|
71
|
+
|
|
72
|
+
### 3.1 Workflow layer
|
|
73
|
+
The workflow layer is the default documented surface.
|
|
74
|
+
|
|
75
|
+
Its job is to:
|
|
76
|
+
- validate required inputs
|
|
77
|
+
- validate lane and phase state
|
|
78
|
+
- create or update the workflow artifact
|
|
79
|
+
- route users to the next legal step
|
|
80
|
+
- keep execution traceable
|
|
81
|
+
|
|
82
|
+
### 3.2 Specialist engine
|
|
83
|
+
The 12 existing `code-*` skills remain the internal execution engine.
|
|
84
|
+
|
|
85
|
+
They remain:
|
|
86
|
+
- the specialist building blocks behind the workflow layer
|
|
87
|
+
- the direct expert-mode entrypoints
|
|
88
|
+
- unchanged in identity for this implementation wave
|
|
89
|
+
|
|
90
|
+
## 4. Lane Model
|
|
91
|
+
|
|
92
|
+
V1 supports exactly two lanes:
|
|
93
|
+
- `feature`
|
|
94
|
+
- `bugfix`
|
|
95
|
+
|
|
96
|
+
Expected lane progression:
|
|
97
|
+
- feature: `start -> plan -> build -> verify -> ship`
|
|
98
|
+
- bugfix: `start -> build -> verify -> ship`
|
|
99
|
+
|
|
100
|
+
`code-debug` remains cross-cutting and reactive, not a top-level linear phase.
|
|
101
|
+
|
|
102
|
+
## 5. Workflow Artifact
|
|
103
|
+
|
|
104
|
+
Canonical workflow artifact:
|
|
105
|
+
- `docs/dev/CODE_WORKFLOW_[FEATURE_KEY].md`
|
|
106
|
+
|
|
107
|
+
Canonical template path:
|
|
108
|
+
- `products/sdtk-code/toolkit/templates/CODE_WORKFLOW_TEMPLATE.md`
|
|
109
|
+
|
|
110
|
+
The workflow artifact stores:
|
|
111
|
+
- metadata
|
|
112
|
+
- lane and phase state
|
|
113
|
+
- intake outcome
|
|
114
|
+
- slice summary
|
|
115
|
+
- summarized evidence and review notes
|
|
116
|
+
- final ship or finish decision
|
|
117
|
+
|
|
118
|
+
The workflow artifact does not inline full raw command output.
|
|
119
|
+
|
|
120
|
+
## 6. Runtime Truth
|
|
121
|
+
|
|
122
|
+
### Claude
|
|
123
|
+
- supports project and user scope
|
|
124
|
+
- installs `code-*` skills
|
|
125
|
+
|
|
126
|
+
### Codex
|
|
127
|
+
- defaults to user scope
|
|
128
|
+
- installs `sdtk-code-*` skills
|
|
129
|
+
- supports project-local installs only through the explicit local `CODEX_HOME=<project>/.codex` contract
|
|
130
|
+
- native `.codex/skills` auto-discovery is not claimed
|
|
131
|
+
- routing assumptions must not depend on unavailable multi-agent behavior
|
|
132
|
+
|
|
133
|
+
## 7. Documentation Map
|
|
134
|
+
|
|
135
|
+
Use these documents by role:
|
|
136
|
+
|
|
137
|
+
- Canonical end-user install and usage guide:
|
|
138
|
+
- `products/sdtk-code/governance/SDTKCODE_TOOLKIT_USAGE_GUIDE.md`
|
|
139
|
+
- Install-truth and smoke appendix:
|
|
140
|
+
- `products/sdtk-code/governance/installation-runbook.md`
|
|
141
|
+
- Workflow/boundary companion:
|
|
142
|
+
- `products/sdtk-code/governance/usage-guide.md`
|
|
143
|
+
- npm package landing page:
|
|
144
|
+
- `products/sdtk-code/distribution/sdtk-code-kit/README.md`
|
|
145
|
+
- Contract details:
|
|
146
|
+
- `products/sdtk-code/governance/workflow-contract.md`
|
|
147
|
+
- `products/sdtk-code/governance/workflow-routing-matrix.md`
|
|
148
|
+
- `products/sdtk-code/governance/workflow-state-model.md`
|
|
149
|
+
|
|
150
|
+
## 8. Upstream Boundary With SDTK-SPEC
|
|
151
|
+
|
|
152
|
+
`SDTK-SPEC` is the upstream docs-first system. `SDTK-CODE` begins only after valid upstream handoff inputs already exist.
|
|
153
|
+
|
|
154
|
+
Preferred upstream intake artifact:
|
|
155
|
+
- `docs/dev/CODE_HANDOFF_[FEATURE_KEY].json`
|
|
156
|
+
|
|
157
|
+
Compatibility fallback when the formal handoff file is missing:
|
|
158
|
+
- fall back to `FEATURE_IMPL_PLAN + sdtk-spec.config.json` only when the formal handoff file is missing
|
|
159
|
+
|
|
160
|
+
Task-breakdown truth:
|
|
161
|
+
- upstream `SDTK-SPEC` `/dev` owns implementation-readiness planning and formal handoff scope
|
|
162
|
+
- `FEATURE_IMPL_PLAN_[FEATURE_KEY].md` remains the upstream readiness plan
|
|
163
|
+
- `sdtk-code plan` refines downstream execution slices only after intake succeeds
|
|
164
|
+
|
|
165
|
+
`SDTK-CODE` expected outputs include:
|
|
166
|
+
- code changes
|
|
167
|
+
- test changes
|
|
168
|
+
- summarized verification evidence
|
|
169
|
+
- `docs/dev/REVIEW_PACKET_[FEATURE_KEY].md` from `verify` as downstream QA/controller input — not as final approval
|
|
170
|
+
- `docs/dev/OPS_HANDOFF_[FEATURE_KEY].json` on completed formal-handoff-backed closeout
|
|
171
|
+
|
|
172
|
+
## 9. Expert Mode And Deviation Recording
|
|
173
|
+
|
|
174
|
+
Expert mode is direct raw `code-*` usage inside the runtime.
|
|
175
|
+
|
|
176
|
+
Normal mode is workflow-first (`start -> plan -> build -> verify -> ship`). Expert mode is the direct raw entrypoint for advanced use.
|
|
177
|
+
|
|
178
|
+
Expert mode rules:
|
|
179
|
+
- v1 does not require a dedicated CLI expert-mode flag
|
|
180
|
+
- if a workflow artifact already exists and you bypass the normal workflow command path, record the deviation under `## 6. Evidence And Review Notes` in the workflow artifact using a lightweight note that captures:
|
|
181
|
+
- date/time
|
|
182
|
+
- current phase
|
|
183
|
+
- raw skill used
|
|
184
|
+
- reason for bypass
|
|
185
|
+
- evidence refs
|
|
186
|
+
- outcome or next action
|
|
187
|
+
|
|
188
|
+
## 10. Runtime And Codex Fallback Truth
|
|
189
|
+
|
|
190
|
+
| Runtime | Current truth |
|
|
191
|
+
|---|---|
|
|
192
|
+
| Claude | strongest intended runtime for v1; full workflow direction is designed with Claude in mind |
|
|
193
|
+
| Codex | defaults to user scope; project-local installs require the explicit `CODEX_HOME=<project>/.codex` contract |
|
|
194
|
+
|
|
195
|
+
Codex notes:
|
|
196
|
+
- workflow routing must not assume runtime capabilities that Codex cannot reliably support
|
|
197
|
+
- sequential fallback applies when parallel dispatch is unavailable: keep the same slice boundaries but execute sequentially
|
package/package.json
CHANGED
|
@@ -35,6 +35,7 @@ const {
|
|
|
35
35
|
confirmExecute,
|
|
36
36
|
} = require("../lib/agent-team-execute");
|
|
37
37
|
const { runAuthor } = require("../lib/agent-team-author");
|
|
38
|
+
const { runSleepExecute } = require("../lib/agent-team-sleep-execute");
|
|
38
39
|
const { appendEvent } = require("../lib/trust-events");
|
|
39
40
|
|
|
40
41
|
const FLAG_DEFS = {
|
|
@@ -75,6 +76,14 @@ const AUTHOR_FLAG_DEFS = {
|
|
|
75
76
|
"dry-run": { type: "boolean" },
|
|
76
77
|
};
|
|
77
78
|
|
|
79
|
+
const SLEEP_EXECUTE_FLAG_DEFS = {
|
|
80
|
+
"feature-key": { type: "string" },
|
|
81
|
+
"project-path": { type: "string" },
|
|
82
|
+
"patch-file": { type: "string" },
|
|
83
|
+
execute: { type: "boolean" },
|
|
84
|
+
"dry-run": { type: "boolean" },
|
|
85
|
+
};
|
|
86
|
+
|
|
78
87
|
function resolveProjectPath(flags) {
|
|
79
88
|
return flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
80
89
|
}
|
|
@@ -382,10 +391,53 @@ async function cmdAgentTeamAuthor(args) {
|
|
|
382
391
|
return result.exitCode;
|
|
383
392
|
}
|
|
384
393
|
|
|
394
|
+
async function cmdAgentTeamSleepExecute(args) {
|
|
395
|
+
const { flags, positional } = parseFlags(args, SLEEP_EXECUTE_FLAG_DEFS);
|
|
396
|
+
if (positional.length > 0) {
|
|
397
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "agent-team sleep-execute".');
|
|
398
|
+
}
|
|
399
|
+
if (flags.execute && flags["dry-run"]) {
|
|
400
|
+
throw new ValidationError('Use either --execute or --dry-run, not both.');
|
|
401
|
+
}
|
|
402
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
403
|
+
const projectPath = resolveProjectPath(flags);
|
|
404
|
+
const mode = flags.execute ? "execute" : "dry-run";
|
|
405
|
+
|
|
406
|
+
const result = await runSleepExecute(projectPath, featureKey, {
|
|
407
|
+
mode,
|
|
408
|
+
patchFile: flags["patch-file"],
|
|
409
|
+
confirmInput: {
|
|
410
|
+
isTTY: process.stdin.isTTY === true,
|
|
411
|
+
readLine: readLineFromStdin,
|
|
412
|
+
},
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
appendEvent(projectPath, {
|
|
416
|
+
toolkit: "sdtk-code",
|
|
417
|
+
event_type: mode === "execute" ? "agent_team_sleep_session" : "agent_team_sleep_planned",
|
|
418
|
+
command: `sdtk-code agent-team sleep-execute --feature-key ${featureKey}${flags["patch-file"] ? ` --patch-file ${flags["patch-file"]}` : ""}${mode === "execute" ? " --execute" : ""}`,
|
|
419
|
+
status: result.status,
|
|
420
|
+
feature_key: result.feature_key,
|
|
421
|
+
run_id: result.run_id,
|
|
422
|
+
session_id: result.session_id,
|
|
423
|
+
readiness_verdict: result.readiness_verdict,
|
|
424
|
+
stop_condition_hit: result.stop_condition_hit,
|
|
425
|
+
worktree_path: result.worktree_path,
|
|
426
|
+
actions_executed: result.actions_executed,
|
|
427
|
+
execution_mode: result.execution_mode,
|
|
428
|
+
workflow_type: result.workflow_type,
|
|
429
|
+
session_cost_usd: result.session_cost_usd,
|
|
430
|
+
session_output_tokens: result.session_output_tokens,
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
console.log(result.stdout || `Agent Team Sleep Execute: ${result.status}`);
|
|
434
|
+
return result.exitCode;
|
|
435
|
+
}
|
|
436
|
+
|
|
385
437
|
function cmdAgentTeam(args) {
|
|
386
438
|
if (!args || args.length === 0) {
|
|
387
439
|
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.)"
|
|
440
|
+
"Usage: sdtk-code agent-team <subcommand> [flags]\nSubcommands: plan, preview, export, evidence, readiness, report, execute, author, sleep-execute\n(run is not available; execute is bounded docs-only; author is attended D-2b; sleep-execute is attended Phase E Preview.)"
|
|
389
441
|
);
|
|
390
442
|
}
|
|
391
443
|
|
|
@@ -411,13 +463,15 @@ function cmdAgentTeam(args) {
|
|
|
411
463
|
return cmdAgentTeamExecute(rest);
|
|
412
464
|
case "author":
|
|
413
465
|
return cmdAgentTeamAuthor(rest);
|
|
466
|
+
case "sleep-execute":
|
|
467
|
+
return cmdAgentTeamSleepExecute(rest);
|
|
414
468
|
case "run":
|
|
415
469
|
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).`
|
|
470
|
+
`"agent-team run" is not available in this phase. Supported: plan, preview, export, evidence, readiness, report, execute (bounded docs-only), author (attended D-2b), sleep-execute (attended Phase E Preview).`
|
|
417
471
|
);
|
|
418
472
|
default:
|
|
419
473
|
throw new ValidationError(
|
|
420
|
-
`Unknown agent-team subcommand: "${subcommand}". Available: plan, preview, export, evidence, readiness, report, execute, author`
|
|
474
|
+
`Unknown agent-team subcommand: "${subcommand}". Available: plan, preview, export, evidence, readiness, report, execute, author, sleep-execute`
|
|
421
475
|
);
|
|
422
476
|
}
|
|
423
477
|
}
|
package/src/commands/help.js
CHANGED
|
@@ -19,7 +19,7 @@ function cmdHelp() {
|
|
|
19
19
|
" update Refresh the npm package and optionally re-apply managed project/runtime assets",
|
|
20
20
|
" init Initialize SDTK-CODE workspace",
|
|
21
21
|
" runtime Manage runtime asset installation (install, uninstall, status)",
|
|
22
|
-
" agent-team Plan/preview/export/evidence plus bounded docs/governance Markdown execute/author",
|
|
22
|
+
" agent-team Plan/preview/export/evidence plus bounded docs/governance Markdown execute/author/sleep-execute",
|
|
23
23
|
"",
|
|
24
24
|
"Workflow status:",
|
|
25
25
|
" Implemented now: start, plan, build, verify, ship, status, doctor, resume",
|
|
@@ -165,11 +165,13 @@ function cmdHelp() {
|
|
|
165
165
|
" sdtk-code agent-team report --feature-key <KEY> [--project-path <path>]",
|
|
166
166
|
" sdtk-code agent-team execute --feature-key <KEY> --patch-file <path> [--dry-run|--execute] [--project-path <path>]",
|
|
167
167
|
" sdtk-code agent-team author --feature-key <KEY> [--dry-run|--execute] [--project-path <path>]",
|
|
168
|
+
" sdtk-code agent-team sleep-execute --feature-key <KEY> [--patch-file <path>] [--dry-run|--execute] [--project-path <path>]",
|
|
168
169
|
" evidence submit validates and stores agent-submitted evidence under .sdtk/agent-team/evidence/<KEY>/",
|
|
169
170
|
" readiness scores all roles and declares READY_TO_SLEEP or NOT_READY",
|
|
170
171
|
" report writes morning_report.md from evidence + readiness",
|
|
171
172
|
" execute is docs/governance Markdown Flow B: dry-run default; --execute requires exact TTY confirmation",
|
|
172
173
|
" author is attended D-2b: dry-run makes no model call; --execute makes one model call then uses the same bounded harness; no auto-merge",
|
|
174
|
+
" sleep-execute is attended single-session Phase E Preview: free/MIT; model/API cost is user-provided via your own provider key, not SDTK-hosted; bounded to <=3 author iterations into one worktree for one human review; not unattended autonomy",
|
|
173
175
|
" READY_TO_SLEEP indicates evidence is present and well-formed — it does NOT verify",
|
|
174
176
|
" implementation correctness. Human review required before acting on this verdict.",
|
|
175
177
|
" run is not available in this phase; execute never spawns LLM agents and never auto-merges.",
|
|
@@ -335,6 +335,49 @@ async function withTimeout(promise, timeoutMs) {
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
+
async function produceAuthorPatch(projectPath, featureKey, opts) {
|
|
339
|
+
const options = opts || {};
|
|
340
|
+
const ctx = loadExecuteContext(projectPath, featureKey);
|
|
341
|
+
const worktreeRoot = options.worktreeRoot;
|
|
342
|
+
if (!worktreeRoot) {
|
|
343
|
+
throw new ValidationError("FAIL_CONTEXT_EMPTY: produceAuthorPatch requires a provided worktreeRoot");
|
|
344
|
+
}
|
|
345
|
+
const context = assembleContext(ctx, {
|
|
346
|
+
worktreeRoot,
|
|
347
|
+
runControlledProcess: options.runControlledProcess,
|
|
348
|
+
});
|
|
349
|
+
let modelCallCount = 0;
|
|
350
|
+
const provider = options.callModelProvider || callModelProvider;
|
|
351
|
+
const modelResult = await withTimeout(Promise.resolve().then(() => {
|
|
352
|
+
modelCallCount += 1;
|
|
353
|
+
if (modelCallCount > MODEL_MAX_CALLS_PER_RUN) {
|
|
354
|
+
throw new ValidationError("FAIL_MODEL_CALL_LIMIT: only one model call is allowed per run");
|
|
355
|
+
}
|
|
356
|
+
return provider({
|
|
357
|
+
prompt: context.prompt,
|
|
358
|
+
model_id: MODEL_ID,
|
|
359
|
+
max_output_tokens: MODEL_MAX_OUTPUT_TOKENS,
|
|
360
|
+
input_token_estimate: context.input_token_estimate,
|
|
361
|
+
call_count: modelCallCount,
|
|
362
|
+
}, options.providerDeps || {});
|
|
363
|
+
}), MODEL_WALLCLOCK_TIMEOUT_MS);
|
|
364
|
+
const patchText = String(modelResult.patch || "");
|
|
365
|
+
const patchHash = sha256(patchText);
|
|
366
|
+
const contentStop = scanProducedPatchForSecrets(patchText);
|
|
367
|
+
return {
|
|
368
|
+
patchText,
|
|
369
|
+
patchHash,
|
|
370
|
+
prompt_sha256: context.prompt_sha256,
|
|
371
|
+
context_manifest: context.context_manifest,
|
|
372
|
+
model_provider: modelResult.provider,
|
|
373
|
+
model_id: modelResult.model_id,
|
|
374
|
+
model_call_count: modelResult.model_call_count || modelCallCount,
|
|
375
|
+
tokens_used: modelResult.tokens_used || null,
|
|
376
|
+
projected_cost_usd: modelResult.projected_cost_usd,
|
|
377
|
+
...(contentStop ? { stop: contentStop } : {}),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
338
381
|
async function executeAuthor(projectPath, featureKey, opts) {
|
|
339
382
|
const options = opts || {};
|
|
340
383
|
const ctx = loadExecuteContext(projectPath, featureKey);
|
|
@@ -347,42 +390,29 @@ async function executeAuthor(projectPath, featureKey, opts) {
|
|
|
347
390
|
created = createWorktree(ctx.projectPath, ctx.featureKey, ctx.runId);
|
|
348
391
|
ctx.worktreeRoot = created.worktreeRoot;
|
|
349
392
|
ctx.branch = created.branch;
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
throw new ValidationError("FAIL_MODEL_CALL_LIMIT: only one model call is allowed per run");
|
|
357
|
-
}
|
|
358
|
-
return provider({
|
|
359
|
-
prompt: context.prompt,
|
|
360
|
-
model_id: MODEL_ID,
|
|
361
|
-
max_output_tokens: MODEL_MAX_OUTPUT_TOKENS,
|
|
362
|
-
input_token_estimate: context.input_token_estimate,
|
|
363
|
-
call_count: modelCallCount,
|
|
364
|
-
}, options.providerDeps || {});
|
|
365
|
-
}), MODEL_WALLCLOCK_TIMEOUT_MS);
|
|
366
|
-
const patchText = String(modelResult.patch || "");
|
|
367
|
-
const patchHash = sha256(patchText);
|
|
368
|
-
const contentStop = scanProducedPatchForSecrets(patchText);
|
|
393
|
+
const produced = await produceAuthorPatch(projectPath, featureKey, {
|
|
394
|
+
...options,
|
|
395
|
+
worktreeRoot: created.worktreeRoot,
|
|
396
|
+
});
|
|
397
|
+
const patchText = produced.patchText;
|
|
398
|
+
const patchHash = produced.patchHash;
|
|
369
399
|
patchPath = writeProducedPatch(ctx.projectPath, ctx.featureKey, patchText);
|
|
370
400
|
const patchSummary = readPatchSummary(patchPath);
|
|
371
|
-
if (
|
|
372
|
-
const bundle = submitStopEvidence(ctx, patchSummary,
|
|
401
|
+
if (produced.stop) {
|
|
402
|
+
const bundle = submitStopEvidence(ctx, patchSummary, produced.stop);
|
|
373
403
|
return stopResult(ctx, {
|
|
374
|
-
...
|
|
404
|
+
...produced.stop,
|
|
375
405
|
evidence_path: bundle.evidenceResult.outputPath,
|
|
376
406
|
readiness_path: bundle.readinessBundle.readinessPath,
|
|
377
407
|
readiness_verdict: bundle.readinessBundle.readiness.overall_verdict,
|
|
378
408
|
report_path: bundle.readinessBundle.reportPath,
|
|
379
|
-
prompt_sha256:
|
|
380
|
-
context_manifest:
|
|
409
|
+
prompt_sha256: produced.prompt_sha256,
|
|
410
|
+
context_manifest: produced.context_manifest,
|
|
381
411
|
produced_patch_sha256: patchHash,
|
|
382
|
-
model_provider:
|
|
383
|
-
model_id:
|
|
384
|
-
model_call_count:
|
|
385
|
-
tokens_used:
|
|
412
|
+
model_provider: produced.model_provider,
|
|
413
|
+
model_id: produced.model_id,
|
|
414
|
+
model_call_count: produced.model_call_count,
|
|
415
|
+
tokens_used: produced.tokens_used,
|
|
386
416
|
});
|
|
387
417
|
}
|
|
388
418
|
const patchStop = guardPatchTargets(patchSummary, ctx.worktreeRoot, ctx.allowedFileScopes);
|
|
@@ -394,13 +424,13 @@ async function executeAuthor(projectPath, featureKey, opts) {
|
|
|
394
424
|
readiness_path: bundle.readinessBundle.readinessPath,
|
|
395
425
|
readiness_verdict: bundle.readinessBundle.readiness.overall_verdict,
|
|
396
426
|
report_path: bundle.readinessBundle.reportPath,
|
|
397
|
-
prompt_sha256:
|
|
398
|
-
context_manifest:
|
|
427
|
+
prompt_sha256: produced.prompt_sha256,
|
|
428
|
+
context_manifest: produced.context_manifest,
|
|
399
429
|
produced_patch_sha256: patchHash,
|
|
400
|
-
model_provider:
|
|
401
|
-
model_id:
|
|
402
|
-
model_call_count:
|
|
403
|
-
tokens_used:
|
|
430
|
+
model_provider: produced.model_provider,
|
|
431
|
+
model_id: produced.model_id,
|
|
432
|
+
model_call_count: produced.model_call_count,
|
|
433
|
+
tokens_used: produced.tokens_used,
|
|
404
434
|
});
|
|
405
435
|
}
|
|
406
436
|
applyPatch(ctx.worktreeRoot, patchPath);
|
|
@@ -438,13 +468,13 @@ async function executeAuthor(projectPath, featureKey, opts) {
|
|
|
438
468
|
readiness_verdict: readinessBundle.readiness.overall_verdict,
|
|
439
469
|
report_path: readinessBundle.reportPath,
|
|
440
470
|
cleanup_command: plannedCleanupCommand(ctx),
|
|
441
|
-
prompt_sha256:
|
|
442
|
-
context_manifest:
|
|
471
|
+
prompt_sha256: produced.prompt_sha256,
|
|
472
|
+
context_manifest: produced.context_manifest,
|
|
443
473
|
produced_patch_sha256: patchHash,
|
|
444
|
-
model_provider:
|
|
445
|
-
model_id:
|
|
446
|
-
model_call_count:
|
|
447
|
-
tokens_used:
|
|
474
|
+
model_provider: produced.model_provider,
|
|
475
|
+
model_id: produced.model_id,
|
|
476
|
+
model_call_count: produced.model_call_count,
|
|
477
|
+
tokens_used: produced.tokens_used,
|
|
448
478
|
stdout: [
|
|
449
479
|
`Agent Team Author: ${stopHit ? "STOPPED" : "COMPLETED"}`,
|
|
450
480
|
` feature_key: ${ctx.featureKey}`,
|
|
@@ -515,6 +545,7 @@ module.exports = {
|
|
|
515
545
|
addedPatchContent,
|
|
516
546
|
scanProducedPatchForSecrets,
|
|
517
547
|
renderDryRunAuthorPlan,
|
|
548
|
+
produceAuthorPatch,
|
|
518
549
|
dryRunAuthor,
|
|
519
550
|
executeAuthor,
|
|
520
551
|
runAuthor,
|