sdtk-code-kit 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/assets/manifest/toolkit-bundle.manifest.json +57 -57
- package/assets/manifest/toolkit-bundle.sha256.txt +28 -28
- package/assets/toolkit/toolkit/AGENTS.md +219 -219
- package/assets/toolkit/toolkit/install.ps1 +156 -156
- package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +78 -78
- package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +150 -150
- package/assets/toolkit/toolkit/scripts/uninstall-claude-skills.ps1 +62 -62
- package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +82 -82
- package/assets/toolkit/toolkit/sdtk-spec.config.json +6 -6
- package/assets/toolkit/toolkit/sdtk-spec.config.profiles.example.json +12 -12
- package/assets/toolkit/toolkit/skills/code-brainstorm/SKILL.md +55 -55
- package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +296 -296
- package/assets/toolkit/toolkit/skills/code-debug/references/root-cause-tracing.md +68 -68
- package/assets/toolkit/toolkit/skills/code-discover/SKILL.md +54 -54
- package/assets/toolkit/toolkit/skills/code-execute/SKILL.md +74 -74
- package/assets/toolkit/toolkit/skills/code-finish/SKILL.md +205 -205
- package/assets/toolkit/toolkit/skills/code-parallel/SKILL.md +64 -64
- package/assets/toolkit/toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md +26 -26
- package/assets/toolkit/toolkit/skills/code-parallel/references/implementer-prompt.md +113 -113
- package/assets/toolkit/toolkit/skills/code-parallel/references/spec-reviewer-prompt.md +61 -61
- package/assets/toolkit/toolkit/skills/code-plan/SKILL.md +85 -85
- package/assets/toolkit/toolkit/skills/code-review/SKILL.md +79 -79
- package/assets/toolkit/toolkit/skills/code-review/references/checklist.md +125 -125
- package/assets/toolkit/toolkit/skills/code-review/references/code-reviewer.md +146 -146
- package/assets/toolkit/toolkit/skills/code-ship/SKILL.md +52 -52
- package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +378 -378
- package/assets/toolkit/toolkit/skills/code-tdd/references/testing-anti-patterns.md +299 -299
- package/assets/toolkit/toolkit/skills/code-verify/SKILL.md +144 -144
- package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +228 -228
- package/assets/toolkit/toolkit/templates/CODE_WORKFLOW_TEMPLATE.md +140 -140
- package/package.json +2 -2
- package/src/commands/agent-team.js +174 -0
- package/src/commands/guardrails.js +94 -2
- package/src/commands/help.js +13 -0
- package/src/commands/sleep.js +132 -0
- package/src/index.js +8 -0
- package/src/lib/agent-team-export.js +409 -0
- package/src/lib/agent-team-plan.js +514 -0
- package/src/lib/sleep-plan.js +175 -0
- package/src/lib/sleep-report.js +229 -0
- package/src/lib/trust-events.js +20 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { ValidationError } = require("./errors");
|
|
6
|
+
const { computeReadiness, gatherSignals } = require("./ship-readiness");
|
|
7
|
+
|
|
8
|
+
const REPORT_SCHEMA = "sdtk.sleep-report.v1";
|
|
9
|
+
const PLAN_SCHEMA = "sdtk.sleep-plan.v1";
|
|
10
|
+
const SCOPE_BLOCKER =
|
|
11
|
+
"Scope not declared — the agent could touch any file; `scope_lock` has nothing to enforce.";
|
|
12
|
+
const DRY_RUN_DISCLAIMER =
|
|
13
|
+
"This is a pre-flight projection of the plan — nothing was executed.";
|
|
14
|
+
|
|
15
|
+
function list(value) {
|
|
16
|
+
return Array.isArray(value) ? [...value] : [];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function planScope(plan) {
|
|
20
|
+
return plan && plan.scope && typeof plan.scope === "object" ? plan.scope : {};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function readinessComponentNotes(readiness) {
|
|
24
|
+
if (!readiness || !Array.isArray(readiness.components)) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
return readiness.components
|
|
28
|
+
.filter((component) => component && typeof component.note === "string" && component.note.length > 0)
|
|
29
|
+
.map((component) => `${component.name}: ${component.note}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function failingComponentNames(readiness) {
|
|
33
|
+
if (!readiness || !Array.isArray(readiness.components)) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
return readiness.components
|
|
37
|
+
.filter((component) => Number(component.points) < Number(component.max))
|
|
38
|
+
.map((component) => component.name)
|
|
39
|
+
.filter((name) => typeof name === "string" && name.length > 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function projectSleepReport(plan, signals) {
|
|
43
|
+
const readiness = computeReadiness(signals);
|
|
44
|
+
const blockers = [];
|
|
45
|
+
const notes = [];
|
|
46
|
+
const scope = planScope(plan);
|
|
47
|
+
const orderedSteps = list(plan && plan.ordered_steps);
|
|
48
|
+
const testObligations = list(plan && plan.test_obligations);
|
|
49
|
+
const deployConfirmPoints = list(plan && plan.deploy_confirm_points);
|
|
50
|
+
|
|
51
|
+
if (!plan || plan.schema_version !== PLAN_SCHEMA || orderedSteps.length === 0) {
|
|
52
|
+
blockers.push("Invalid sleep plan — expected sdtk.sleep-plan.v1 with at least one ordered step.");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (scope.declared !== true) {
|
|
56
|
+
blockers.push(SCOPE_BLOCKER);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (readiness.verdict === "FAIL") {
|
|
60
|
+
const failing = failingComponentNames(readiness);
|
|
61
|
+
blockers.push(
|
|
62
|
+
failing.length > 0
|
|
63
|
+
? `Ship-readiness FAIL. Failing components: ${failing.join(", ")}.`
|
|
64
|
+
: "Ship-readiness FAIL."
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (readiness.verdict === "ENV_BLOCKED") {
|
|
69
|
+
blockers.push("Readiness signals unavailable (ENV_BLOCKED).");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (testObligations.length === 0) {
|
|
73
|
+
notes.push("No test obligations carried — `test_evidence_required` has nothing to check.");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (readiness.verdict === "PASS_WITH_NOTES") {
|
|
77
|
+
const warnings = Array.isArray(readiness.warnings) ? readiness.warnings : [];
|
|
78
|
+
if (warnings.length > 0) {
|
|
79
|
+
notes.push(...warnings);
|
|
80
|
+
} else {
|
|
81
|
+
notes.push("Ship-readiness PASS_WITH_NOTES.");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const verdict = blockers.length > 0
|
|
86
|
+
? "NOT_READY"
|
|
87
|
+
: notes.length > 0
|
|
88
|
+
? "READY_WITH_NOTES"
|
|
89
|
+
: "READY_TO_SLEEP";
|
|
90
|
+
|
|
91
|
+
const reason = blockers.length > 0
|
|
92
|
+
? blockers[0]
|
|
93
|
+
: notes.length > 0
|
|
94
|
+
? notes[0]
|
|
95
|
+
: "The sleep plan is bounded, readiness is PASS, and test obligations are present.";
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
schema_version: REPORT_SCHEMA,
|
|
99
|
+
feature_key: plan && plan.feature_key,
|
|
100
|
+
verdict,
|
|
101
|
+
reason,
|
|
102
|
+
readiness,
|
|
103
|
+
sections: {
|
|
104
|
+
can_i_sleep: { verdict, reason },
|
|
105
|
+
what_it_can_touch: {
|
|
106
|
+
declared: scope.declared === true,
|
|
107
|
+
allowed_file_scopes: list(scope.allowed_file_scopes),
|
|
108
|
+
blocked_file_scopes: list(scope.blocked_file_scopes),
|
|
109
|
+
warning: scope.declared === true ? null : "scope_lock cannot enforce undeclared scope.",
|
|
110
|
+
},
|
|
111
|
+
when_it_will_stop: {
|
|
112
|
+
stop_conditions: list(plan && plan.stop_conditions).map((condition) => {
|
|
113
|
+
if (condition && typeof condition === "object" && typeof condition.id === "string") {
|
|
114
|
+
return condition.id;
|
|
115
|
+
}
|
|
116
|
+
return condition;
|
|
117
|
+
}),
|
|
118
|
+
budgets: plan && plan.budgets && typeof plan.budgets === "object" ? { ...plan.budgets } : {},
|
|
119
|
+
},
|
|
120
|
+
what_proves_done: {
|
|
121
|
+
test_obligations: testObligations,
|
|
122
|
+
readiness_components: readinessComponentNotes(readiness),
|
|
123
|
+
},
|
|
124
|
+
what_needs_you: {
|
|
125
|
+
deploy_confirm_points: deployConfirmPoints,
|
|
126
|
+
blockers: [...blockers],
|
|
127
|
+
notes: [...notes],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
blockers,
|
|
131
|
+
notes,
|
|
132
|
+
dry_run: true,
|
|
133
|
+
generated_at: new Date().toISOString(),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function bulletList(items, fallback) {
|
|
138
|
+
if (!Array.isArray(items) || items.length === 0) {
|
|
139
|
+
return `- ${fallback}`;
|
|
140
|
+
}
|
|
141
|
+
return items.map((item) => `- ${String(item)}`).join("\n");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function renderSleepReportMarkdown(report) {
|
|
145
|
+
const touch = report.sections.what_it_can_touch;
|
|
146
|
+
const stop = report.sections.when_it_will_stop;
|
|
147
|
+
const proves = report.sections.what_proves_done;
|
|
148
|
+
const needs = report.sections.what_needs_you;
|
|
149
|
+
|
|
150
|
+
return [
|
|
151
|
+
`# Sleep Readiness Report — ${report.feature_key}`,
|
|
152
|
+
"",
|
|
153
|
+
DRY_RUN_DISCLAIMER,
|
|
154
|
+
"",
|
|
155
|
+
"## Can I sleep?",
|
|
156
|
+
"",
|
|
157
|
+
`- Verdict: ${report.verdict}`,
|
|
158
|
+
`- Reason: ${report.reason}`,
|
|
159
|
+
`- Readiness: ${report.readiness.score}/${report.readiness.max} — ${report.readiness.verdict}`,
|
|
160
|
+
"",
|
|
161
|
+
"## What it can touch",
|
|
162
|
+
"",
|
|
163
|
+
`- Scope declared: ${touch.declared ? "yes" : "no"}`,
|
|
164
|
+
"- Allowed file scopes:",
|
|
165
|
+
bulletList(touch.allowed_file_scopes, "none declared"),
|
|
166
|
+
"- Blocked file scopes:",
|
|
167
|
+
bulletList(touch.blocked_file_scopes, "none declared"),
|
|
168
|
+
touch.warning ? `- Warning: ${touch.warning}` : "- Warning: none",
|
|
169
|
+
"",
|
|
170
|
+
"## When it will stop",
|
|
171
|
+
"",
|
|
172
|
+
"- Stop conditions:",
|
|
173
|
+
bulletList(stop.stop_conditions, "none declared"),
|
|
174
|
+
"- Budgets:",
|
|
175
|
+
`- max_actions: ${stop.budgets.max_actions !== undefined ? stop.budgets.max_actions : "not declared"}`,
|
|
176
|
+
`- max_iterations: ${stop.budgets.max_iterations !== undefined ? stop.budgets.max_iterations : "not declared"}`,
|
|
177
|
+
"",
|
|
178
|
+
"## What proves it's done",
|
|
179
|
+
"",
|
|
180
|
+
"- Test obligations:",
|
|
181
|
+
bulletList(proves.test_obligations, "none carried"),
|
|
182
|
+
"- Readiness components:",
|
|
183
|
+
bulletList(proves.readiness_components, "none"),
|
|
184
|
+
"",
|
|
185
|
+
"## What needs you",
|
|
186
|
+
"",
|
|
187
|
+
"- Deploy confirm points:",
|
|
188
|
+
bulletList(needs.deploy_confirm_points, "none declared"),
|
|
189
|
+
"- Blockers:",
|
|
190
|
+
bulletList(needs.blockers, "none"),
|
|
191
|
+
"- Notes:",
|
|
192
|
+
bulletList(needs.notes, "none"),
|
|
193
|
+
"",
|
|
194
|
+
].join("\n");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function loadSleepPlan(projectPath) {
|
|
198
|
+
const resolved = path.resolve(projectPath || ".");
|
|
199
|
+
const planPath = path.join(resolved, ".sdtk", "trust", "sleep-plan.json");
|
|
200
|
+
try {
|
|
201
|
+
return JSON.parse(fs.readFileSync(planPath, "utf8"));
|
|
202
|
+
} catch (_error) {
|
|
203
|
+
throw new ValidationError(
|
|
204
|
+
`NEEDS_PLAN: no sleep plan found at ${planPath}; ` +
|
|
205
|
+
"run `sdtk-code sleep plan --feature-key <KEY>` first."
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function gatherReportSignals(projectPath, featureKey) {
|
|
211
|
+
return gatherSignals(projectPath, featureKey);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function writeSleepReport(projectPath, featureKey, markdown) {
|
|
215
|
+
const resolved = path.resolve(projectPath || ".");
|
|
216
|
+
const outDir = path.join(resolved, "docs", "trust");
|
|
217
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
218
|
+
const outPath = path.join(outDir, `SLEEP_REPORT_${featureKey}.md`);
|
|
219
|
+
fs.writeFileSync(outPath, markdown, "utf8");
|
|
220
|
+
return outPath;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
module.exports = {
|
|
224
|
+
projectSleepReport,
|
|
225
|
+
renderSleepReportMarkdown,
|
|
226
|
+
loadSleepPlan,
|
|
227
|
+
gatherReportSignals,
|
|
228
|
+
writeSleepReport,
|
|
229
|
+
};
|
package/src/lib/trust-events.js
CHANGED
|
@@ -84,7 +84,23 @@ function buildEvent(raw) {
|
|
|
84
84
|
const sessionId = nullableString(source.session_id);
|
|
85
85
|
const toolkit = nullableString(source.toolkit);
|
|
86
86
|
const eventType = inferEventType(source);
|
|
87
|
-
|
|
87
|
+
// Agent-team traceability (BK-260). Redacted like any other string field and
|
|
88
|
+
// folded into the dedup identity so distinct runs/roles emitting the same
|
|
89
|
+
// command are not collapsed into a single event. Existing callers omit these,
|
|
90
|
+
// so the fields default to null and keep dedup deterministic.
|
|
91
|
+
const runId = source.run_id != null ? redact(String(source.run_id)) : null;
|
|
92
|
+
const agentRole = source.agent_role != null ? redact(String(source.agent_role)) : null;
|
|
93
|
+
const taskId = source.task_id != null ? redact(String(source.task_id)) : null;
|
|
94
|
+
const canonical = [
|
|
95
|
+
sessionId || "",
|
|
96
|
+
toolkit || "",
|
|
97
|
+
eventType || "",
|
|
98
|
+
command || "",
|
|
99
|
+
runId || "",
|
|
100
|
+
agentRole || "",
|
|
101
|
+
taskId || "",
|
|
102
|
+
timestamp,
|
|
103
|
+
].join("|");
|
|
88
104
|
|
|
89
105
|
return {
|
|
90
106
|
event_id: fingerprintId("evt", canonical),
|
|
@@ -93,6 +109,9 @@ function buildEvent(raw) {
|
|
|
93
109
|
phase: nullableString(source.phase),
|
|
94
110
|
event_type: eventType,
|
|
95
111
|
command,
|
|
112
|
+
run_id: runId,
|
|
113
|
+
agent_role: agentRole,
|
|
114
|
+
task_id: taskId,
|
|
96
115
|
status: normalizeStatus(source.status),
|
|
97
116
|
cwd: typeof source.cwd === "string" ? redact(source.cwd) : null,
|
|
98
117
|
files: normalizeFiles(source.files),
|