slicekit 0.8.0 → 0.8.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.
- package/package.json +1 -1
- package/src/adapters/githost/fixture.js +2 -2
- package/src/adapters/githost/gh-json.js +21 -7
- package/src/adapters/githost/github.js +2 -2
- package/src/build/finish.js +7 -3
- package/src/build/verdict.js +20 -2
- package/src/cli/build.js +2 -0
- package/src/cli/index.js +2 -0
- package/src/cli/models.js +90 -0
- package/src/config.js +20 -0
- package/src/next.js +12 -1
- package/src/render/entry.js +21 -2
- package/templates/claude-code/agents/auditor.md +1 -1
- package/templates/claude-code/agents/designer.md +1 -1
- package/templates/claude-code/agents/developer.md +1 -1
- package/templates/claude-code/agents/fixer.md +1 -1
- package/templates/claude-code/agents/ops.md +1 -1
- package/templates/claude-code/agents/reviewer.md +1 -1
- package/templates/claude-code/commands/slicekit-brief.md +1 -0
- package/templates/claude-code/commands/slicekit-intake.md +1 -0
- package/templates/claude-code/commands/slicekit-next.md +1 -0
- package/templates/claude-code/commands/slicekit-plan.md +1 -0
- package/templates/claude-code/commands/slicekit-specify.md +1 -0
- package/templates/instructions/commands/intake.md +1 -1
- package/templates/instructions/commands/specify.md +6 -4
package/package.json
CHANGED
|
@@ -177,9 +177,9 @@ export function fixtureHost(dir) {
|
|
|
177
177
|
const since = assertDate(isoDate);
|
|
178
178
|
return filterMergedSince(readJson(path.join(dir, 'merged-since.json')) ?? [], since);
|
|
179
179
|
},
|
|
180
|
-
ciStatus(sha) {
|
|
180
|
+
ciStatus(sha, { skipCancelled = false } = {}) {
|
|
181
181
|
assertSha(sha);
|
|
182
|
-
return reduceRuns(readJson(path.join(dir, `ci-${sha}.json`)) ?? []);
|
|
182
|
+
return reduceRuns(readJson(path.join(dir, `ci-${sha}.json`)) ?? [], { skipCancelled });
|
|
183
183
|
},
|
|
184
184
|
// As the GitHub host (decidedSlicekitRun): ci-<sha>.json narrowed to the slicekit workflow's
|
|
185
185
|
// pull_request runs, each completed one's jobs read from jobs-<databaseId>.json (none when the file
|
|
@@ -108,25 +108,39 @@ const hasId = (r) => r.workflowDatabaseId !== undefined && r.workflowDatabaseId
|
|
|
108
108
|
// re-run after a newer one is the newer answer (issue #42). createdAt for a run with no startedAt.
|
|
109
109
|
const startOf = (r) => String(r.startedAt || r.createdAt || '');
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
// With `skipCancelled` (issue #225), a cancelled run is no result while its group holds a run that
|
|
112
|
+
// was not cancelled: the workflow's concurrency cancelled it beside a live run on the same head.
|
|
113
|
+
function dropCancelled(runs, keyOf) {
|
|
114
|
+
const live = new Set(runs.filter((r) => r.conclusion !== 'cancelled').map(keyOf));
|
|
115
|
+
return runs.filter((r) => r.conclusion !== 'cancelled' || !live.has(keyOf(r)));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function newestPerWorkflow(all, { skipCancelled = false } = {}) {
|
|
119
|
+
const byId = all.every(hasId);
|
|
120
|
+
const grouped = byId || all.every((r) => r.workflowName && r.event);
|
|
121
|
+
const keyOf = (r) => (!grouped ? 'all' : JSON.stringify(byId ? ['id', r.workflowDatabaseId, r.event ?? null] : ['name', r.workflowName, r.event]));
|
|
122
|
+
const runs = skipCancelled ? dropCancelled(all, keyOf) : all;
|
|
123
|
+
if (!grouped) return runs;
|
|
114
124
|
const newest = new Map();
|
|
115
125
|
for (const r of runs) {
|
|
116
|
-
const key =
|
|
126
|
+
const key = keyOf(r);
|
|
117
127
|
const held = newest.get(key);
|
|
118
128
|
if (!held || startOf(r) > startOf(held)) newest.set(key, r);
|
|
119
129
|
}
|
|
120
130
|
return [...newest.values()];
|
|
121
131
|
}
|
|
122
132
|
|
|
123
|
-
export function reduceRuns(all) {
|
|
133
|
+
export function reduceRuns(all, { skipCancelled = false } = {}) {
|
|
124
134
|
if (!Array.isArray(all) || all.length === 0) return { status: 'unknown', url: null };
|
|
125
|
-
const runs = newestPerWorkflow(all);
|
|
135
|
+
const runs = newestPerWorkflow(all, { skipCancelled });
|
|
126
136
|
const going = runs.find((r) => r.status !== 'completed');
|
|
127
137
|
if (going) return { status: 'pending', url: going.url ?? null };
|
|
128
|
-
|
|
138
|
+
// With `skipCancelled`, a cancelled run left standing (no other run of its workflow on the head,
|
|
139
|
+
// as when it was cancelled by hand) is `cancelled`, not a failure, unless another run failed (D-132).
|
|
140
|
+
const failed = runs.find((r) => !OK_CONCLUSIONS.has(r.conclusion) && !(skipCancelled && r.conclusion === 'cancelled'));
|
|
129
141
|
if (failed) return { status: 'failure', url: failed.url ?? null };
|
|
142
|
+
const cancelled = skipCancelled ? runs.find((r) => r.conclusion === 'cancelled') : undefined;
|
|
143
|
+
if (cancelled) return { status: 'cancelled', url: cancelled.url ?? null };
|
|
130
144
|
return { status: 'success', url: runs[0].url ?? null };
|
|
131
145
|
}
|
|
132
146
|
|
|
@@ -199,9 +199,9 @@ export function githubHost(env = process.env, root = process.cwd(), exec = execF
|
|
|
199
199
|
const args = ['pr', 'list', '--state', 'merged', '--search', `merged:>=${day}`, '--limit', '200', '--json', LIST_FIELDS];
|
|
200
200
|
return filterMergedSince(ghJson(args), since);
|
|
201
201
|
},
|
|
202
|
-
ciStatus(sha) {
|
|
202
|
+
ciStatus(sha, { skipCancelled = false } = {}) {
|
|
203
203
|
assertSha(sha);
|
|
204
|
-
return reduceRuns(ghJson(['run', 'list', '--commit', sha, '--limit', '20', '--json', RUN_FIELDS]));
|
|
204
|
+
return reduceRuns(ghJson(['run', 'list', '--commit', sha, '--limit', '20', '--json', RUN_FIELDS]), { skipCancelled });
|
|
205
205
|
},
|
|
206
206
|
// D-49: the newest pull_request run of the slicekit workflow on a commit whose team command jobs
|
|
207
207
|
// were decided, and its jobs, or null (decidedSlicekitRun). One `gh run list`, then one `gh run
|
package/src/build/finish.js
CHANGED
|
@@ -54,12 +54,13 @@ function setProof(cfg, host, number, ci) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// ciStatus(sha) until it is success or failure, or `wait` seconds are spent, sleeping `interval`
|
|
57
|
-
// seconds (the last nap cut to what is left) between asks.
|
|
57
|
+
// seconds (the last nap cut to what is left) between asks. A cancelled run beside another run of the
|
|
58
|
+
// same workflow on the head is skipped, so the live one is waited on (issue #225).
|
|
58
59
|
function pollCi(host, sha, { wait, interval, sleep }) {
|
|
59
60
|
let waited = 0;
|
|
60
61
|
for (;;) {
|
|
61
|
-
const status = host.ciStatus(sha);
|
|
62
|
-
if (
|
|
62
|
+
const status = host.ciStatus(sha, { skipCancelled: true });
|
|
63
|
+
if (['success', 'failure', 'cancelled'].includes(status.status) || waited >= wait) return status;
|
|
63
64
|
const nap = Math.min(interval, wait - waited);
|
|
64
65
|
sleep(nap);
|
|
65
66
|
waited += nap;
|
|
@@ -123,6 +124,9 @@ export function finish(root, cfg, host, id, { worktree, wait = FINISH_WAIT, inte
|
|
|
123
124
|
|
|
124
125
|
const status = pollCi(host, live, { wait, interval, sleep });
|
|
125
126
|
if (status.status === 'failure') throw new BuildError(`CI failed on ${short(live)}${status.url ? `: ${status.url}` : ''}`);
|
|
127
|
+
if (status.status === 'cancelled') {
|
|
128
|
+
throw new BuildError(`CI run cancelled on ${short(live)}${status.url ? `: ${status.url}` : ''}; re-run it, then run slicekit build finish ${id} again`);
|
|
129
|
+
}
|
|
126
130
|
if (status.status === 'unknown') throw new BuildError(`no CI run found for ${short(live)}; check that the workflow ran`);
|
|
127
131
|
if (status.status !== 'success') throw new BuildError(`CI still running on ${short(live)}; run slicekit build finish ${id} again`);
|
|
128
132
|
|
package/src/build/verdict.js
CHANGED
|
@@ -187,6 +187,20 @@ export function extraRounds(root, cfg, id) {
|
|
|
187
187
|
return readDecisions(text).rows.filter((r) => r.table === 'settled' && names.test(r.answer) && /\bone more round\b/i.test(r.answer)).length;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
// The default branch fetched from origin, as `review start` fetches it, so the decision rows
|
|
191
|
+
// extraRounds counts include one merged on origin since the last fetch (issue #215, D-101). -> null,
|
|
192
|
+
// or the line saying the fetch failed and the local copy is counted.
|
|
193
|
+
export function fetchDefaultBranch(root, cfg) {
|
|
194
|
+
const branch = cfg.defaultBranch;
|
|
195
|
+
try {
|
|
196
|
+
git(root, ['fetch', '-q', 'origin', `+refs/heads/${branch}:refs/remotes/origin/${branch}`]);
|
|
197
|
+
return null;
|
|
198
|
+
} catch (e) {
|
|
199
|
+
if (!(e instanceof GitError)) throw e;
|
|
200
|
+
return `could not fetch ${branch} from origin; the decision rows are counted from the local copy, ${defaultRef(root, cfg).replace(/^refs\/(?:remotes|heads)\//, '')}`;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
190
204
|
// Whether one more independent round may start after the independent verdicts recorded, given as
|
|
191
205
|
// their blocker counts in round order: the first always; a second only when the first left a blocker;
|
|
192
206
|
// any later one only with a decision row for it (`extra` rows allow `extra` rounds beyond those).
|
|
@@ -498,6 +512,10 @@ export function recordVerdict(root, cfg, host, id, file, { worktree, independent
|
|
|
498
512
|
onFetchFail: resuming ? 'last-fetch' : `could not reach origin to check ${held.branch}; a new verdict needs a fresh fetch`,
|
|
499
513
|
});
|
|
500
514
|
|
|
515
|
+
// An independent round counts the decision rows on the default branch as origin has it now.
|
|
516
|
+
const fetchNote = independent ? fetchDefaultBranch(root, cfg) : null;
|
|
517
|
+
const noted = (r) => (fetchNote ? { ...r, fetchNote } : r);
|
|
518
|
+
|
|
501
519
|
if (resuming) {
|
|
502
520
|
assertBuilt(wt, id, current);
|
|
503
521
|
// The round as committed: a hand edit of the working copy since does not change what it says.
|
|
@@ -508,7 +526,7 @@ export function recordVerdict(root, cfg, host, id, file, { worktree, independent
|
|
|
508
526
|
}
|
|
509
527
|
const v = checked(text, rel, name, independent);
|
|
510
528
|
const result = outcomeOf(root, cfg, id, current.pr.number, k, v, verdicts, independent, rounds);
|
|
511
|
-
return withNextPath(root, id, finish(wt, cfg, host, id, current, result, verdicts, independent), verdicts, independent);
|
|
529
|
+
return noted(withNextPath(root, id, finish(wt, cfg, host, id, current, result, verdicts, independent), verdicts, independent));
|
|
512
530
|
}
|
|
513
531
|
|
|
514
532
|
// D-18: two in-loop rounds, one for a quick slice (D-103); independent verdicts (D-39) do not count against them.
|
|
@@ -547,5 +565,5 @@ export function recordVerdict(root, cfg, host, id, file, { worktree, independent
|
|
|
547
565
|
commitBookkeeping(wt, id, `verdict r${k}`, [rel]);
|
|
548
566
|
const state = recordState(wt, cfg, id, 'in-review', { verdict: { round: k, path: rel, blockers: blockerCount, independent } });
|
|
549
567
|
const result = outcomeOf(root, cfg, id, state.pr.number, k, v, state.verdicts, independent, rounds);
|
|
550
|
-
return withNextPath(root, id, finish(wt, cfg, host, id, state, result, state.verdicts, independent), state.verdicts, independent);
|
|
568
|
+
return noted(withNextPath(root, id, finish(wt, cfg, host, id, state, result, state.verdicts, independent), state.verdicts, independent));
|
|
551
569
|
}
|
package/src/cli/build.js
CHANGED
|
@@ -178,6 +178,8 @@ function verdictStep(root, io, positionals, values) {
|
|
|
178
178
|
if (r.verdictPath) out.push(`verdict ${r.verdictPath}`);
|
|
179
179
|
// D-101: the command of the next independent round, when one is left after a blocker.
|
|
180
180
|
if (r.reviewStart) out.push(`review: ${r.reviewStart}`);
|
|
181
|
+
// Issue #215: the default branch could not be fetched, so its rows were counted from the local copy.
|
|
182
|
+
if (r.fetchNote) io.stderr(`slicekit: ${r.fetchNote}\n`);
|
|
181
183
|
io.stdout(out.map((l) => `${l}\n`).join(''));
|
|
182
184
|
if (r.next === 'stuck') {
|
|
183
185
|
io.stderr(`slicekit: stopped: ${r.blockers.join(', ')} survive round ${r.round}; the pull request stays draft\n${r.stop ? `${r.stop}\n` : ''}`);
|
package/src/cli/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import { intakeCommand } from './intake.js';
|
|
|
21
21
|
import { prCommand } from './pr.js';
|
|
22
22
|
import { instructionsCommand } from './instructions.js';
|
|
23
23
|
import { journalCommand } from './journal.js';
|
|
24
|
+
import { modelsCommand } from './models.js';
|
|
24
25
|
import { nextCommand } from './next.js';
|
|
25
26
|
import { opsCommand } from './ops.js';
|
|
26
27
|
import { planCommand } from './plan.js';
|
|
@@ -59,6 +60,7 @@ export const COMMANDS = {
|
|
|
59
60
|
instructions: instructionsCommand,
|
|
60
61
|
hook: hookCommand,
|
|
61
62
|
journal: journalCommand,
|
|
63
|
+
models: modelsCommand,
|
|
62
64
|
next: nextCommand,
|
|
63
65
|
ops: opsCommand,
|
|
64
66
|
plan: planCommand,
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// `slicekit models apply` (REQ-6.7, D-109, D-115, D-130): renders the agent files and the main-session
|
|
2
|
+
// command files from the models map in .slicekit/config.json, and prints one line per file whose
|
|
3
|
+
// model: changed, as `<file> <old> -> <new>`, or `no change`. It writes no other file: a file whose
|
|
4
|
+
// fresh render differs in more than its model: line (a kit upgrade slicekit update has not applied
|
|
5
|
+
// yet), one edited since slicekit wrote it, or one that is missing, is left as it is and named, and
|
|
6
|
+
// so is a mapped role whose file the project's shape does not render; either exits 1.
|
|
7
|
+
// The change reaches the default branch in a pull request, as any other change does (D-109).
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { parseArgs } from 'node:util';
|
|
10
|
+
import { AGENT_ROLES, ConfigError, loadConfig } from '../config.js';
|
|
11
|
+
import { writeText } from '../fs.js';
|
|
12
|
+
import { RENDERED, installedVersion, kitVersion } from '../render/index.js';
|
|
13
|
+
import { modelFor } from '../render/entry.js';
|
|
14
|
+
import { entriesForShape } from '../render/manifest.js';
|
|
15
|
+
import { readSettings } from '../render/settings.js';
|
|
16
|
+
import { planUpdate } from '../render/update.js';
|
|
17
|
+
|
|
18
|
+
const USAGE = 'models apply';
|
|
19
|
+
|
|
20
|
+
// The value of model: in a file's front matter, or null when the file or the line is absent.
|
|
21
|
+
export function frontMatterModel(text) {
|
|
22
|
+
if (text === null) return null;
|
|
23
|
+
const lines = text.split('\n');
|
|
24
|
+
if (lines[0] !== '---') return null;
|
|
25
|
+
const end = lines.indexOf('---', 1);
|
|
26
|
+
const line = lines.slice(1, end < 0 ? 1 : end).find((l) => /^model:/.test(l));
|
|
27
|
+
return line === undefined ? null : line.slice('model:'.length).trim();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const withoutModel = (text) => text.replace(/^model:.*\n/m, '');
|
|
31
|
+
|
|
32
|
+
async function run(args, io) {
|
|
33
|
+
let positionals;
|
|
34
|
+
try {
|
|
35
|
+
({ positionals } = parseArgs({ args, options: {}, allowPositionals: true }));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
io.stderr(`slicekit: ${e.message}\nusage: slicekit ${USAGE}\n`);
|
|
38
|
+
return 2;
|
|
39
|
+
}
|
|
40
|
+
if (positionals.length !== 1 || positionals[0] !== 'apply') {
|
|
41
|
+
io.stderr(`usage: slicekit ${USAGE}\n`);
|
|
42
|
+
return 2;
|
|
43
|
+
}
|
|
44
|
+
const root = io.cwd;
|
|
45
|
+
let cfg;
|
|
46
|
+
try {
|
|
47
|
+
cfg = loadConfig(root);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
if (!(e instanceof ConfigError)) throw e;
|
|
50
|
+
io.stderr(`slicekit: ${e.message}\n`);
|
|
51
|
+
return 2;
|
|
52
|
+
}
|
|
53
|
+
// Rendered at the version whose reference copies the project holds, so the managed marker and
|
|
54
|
+
// every other reference copy stay as slicekit update left them.
|
|
55
|
+
const version = installedVersion(path.join(root, RENDERED), readSettings(root)) ?? kitVersion();
|
|
56
|
+
const entries = entriesForShape(cfg.shape).filter((e) => modelFor(cfg, e.dest) !== null);
|
|
57
|
+
const plan = planUpdate(root, cfg, { version, entries, settings: false });
|
|
58
|
+
|
|
59
|
+
const changed = [];
|
|
60
|
+
const left = [];
|
|
61
|
+
// A role the map names whose file the project's shape does not render (designer in a backend
|
|
62
|
+
// project) carries its model in no file; it is named so the exit is not 0.
|
|
63
|
+
const rendered = new Set(entries.map((e) => e.dest));
|
|
64
|
+
for (const role of Object.keys(cfg.models ?? {})) {
|
|
65
|
+
const dest = AGENT_ROLES.includes(role) ? `.claude/agents/${role}.md` : `.claude/commands/slicekit-${role}.md`;
|
|
66
|
+
if (!rendered.has(dest)) left.push(`models.${role}: the ${cfg.shape} shape renders no ${dest}; the model is written nowhere`);
|
|
67
|
+
}
|
|
68
|
+
for (const item of plan) {
|
|
69
|
+
if (item.status === 'same') continue;
|
|
70
|
+
if (item.status !== 'changed') {
|
|
71
|
+
left.push(`${item.dest} is ${item.status === 'missing' ? 'missing' : item.status === 'drifted' ? 'edited since slicekit wrote it' : 'not managed by slicekit'}; left as it is (slicekit update writes it)`);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (withoutModel(item.next) !== withoutModel(item.current)) {
|
|
75
|
+
left.push(`${item.dest} differs from the kit's templates in more than its model: line; left as it is (run slicekit update first)`);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
changed.push(item);
|
|
79
|
+
}
|
|
80
|
+
for (const item of changed) {
|
|
81
|
+
writeText(path.join(root, item.dest), item.next);
|
|
82
|
+
writeText(path.join(root, RENDERED, version, item.dest), item.refText);
|
|
83
|
+
io.stdout(`${item.dest} ${frontMatterModel(item.current) ?? 'none'} -> ${frontMatterModel(item.next) ?? 'none'}\n`);
|
|
84
|
+
}
|
|
85
|
+
if (changed.length === 0) io.stdout('no change\n');
|
|
86
|
+
for (const line of left) io.stderr(`slicekit: ${line}\n`);
|
|
87
|
+
return left.length > 0 ? 1 : 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const modelsCommand = { run, usage: USAGE, subcommands: ['apply'] };
|
package/src/config.js
CHANGED
|
@@ -281,6 +281,26 @@ export function validateConfig(cfg) {
|
|
|
281
281
|
errors.push(...testFilesErrors(cfg.testFiles));
|
|
282
282
|
errors.push(...agentsErrors(cfg.agents));
|
|
283
283
|
errors.push(...releaseErrors(cfg.release));
|
|
284
|
+
errors.push(...modelsErrors(cfg.models));
|
|
285
|
+
return errors;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// REQ-6.7, D-115, D-130: models is optional, a map from a role to the model ID it runs on. The agent
|
|
289
|
+
// roles are written into the model: field of .claude/agents/<role>.md, the main-session roles into
|
|
290
|
+
// the front matter of .claude/commands/slicekit-<role>.md.
|
|
291
|
+
export const AGENT_ROLES = ['auditor', 'designer', 'developer', 'fixer', 'ops', 'reviewer'];
|
|
292
|
+
export const COMMAND_ROLES = ['brief', 'intake', 'specify', 'plan', 'next'];
|
|
293
|
+
export const MODEL_ROLES = [...AGENT_ROLES, ...COMMAND_ROLES];
|
|
294
|
+
|
|
295
|
+
function modelsErrors(models) {
|
|
296
|
+
if (models === undefined) return [];
|
|
297
|
+
if (!isObject(models)) return ['models: must be an object from a role to a model ID'];
|
|
298
|
+
const errors = [];
|
|
299
|
+
for (const [role, model] of Object.entries(models)) {
|
|
300
|
+
if (!MODEL_ROLES.includes(role)) errors.push(`models.${role}: unknown role; use ${MODEL_ROLES.join(', ')}`);
|
|
301
|
+
// The value is written as is into a front matter line, so it holds no space or line break.
|
|
302
|
+
else if (typeof model !== 'string' || model === '' || /\s/.test(model)) errors.push(`models.${role}: must be a non-empty string with no spaces`);
|
|
303
|
+
}
|
|
284
304
|
return errors;
|
|
285
305
|
}
|
|
286
306
|
|
package/src/next.js
CHANGED
|
@@ -192,8 +192,19 @@ function sliceStep(root, cfg, slice, rows) {
|
|
|
192
192
|
reviewThen,
|
|
193
193
|
);
|
|
194
194
|
}
|
|
195
|
-
case 'in-review':
|
|
195
|
+
case 'in-review': {
|
|
196
|
+
// build verdict leaves an in-loop blocker at in-review while a round is left (issue #230): the
|
|
197
|
+
// fixer answers it, as at changes-requested; build finish would refuse the open blocker.
|
|
198
|
+
const latest = verdicts.at(-1);
|
|
199
|
+
const blockers = latest && !latest.independent ? latestBlockers(root, wt, latest, reviewWt) : [];
|
|
200
|
+
if (blockers.length > 0 && inLoop < rounds) {
|
|
201
|
+
return agent(
|
|
202
|
+
`${id} has open blockers ${blockers.join(', ')} on #${n}: the fixer answers them, then build commit and build pr open the round ${verdicts.length + 1} review (/slicekit build, step 7)`,
|
|
203
|
+
`${cli} instructions fixer ${id} --worktree ${wt}`,
|
|
204
|
+
);
|
|
205
|
+
}
|
|
196
206
|
return agent(`${id} is in-review on #${n}: wait for green CI and mark the pull request ready (/slicekit build, step 9)`, `${cli} build finish ${id} --worktree ${wt}`);
|
|
207
|
+
}
|
|
197
208
|
case 'changes-requested': {
|
|
198
209
|
const latest = verdicts.at(-1);
|
|
199
210
|
const blockers = latestBlockers(root, wt, latest, reviewWt);
|
package/src/render/entry.js
CHANGED
|
@@ -5,13 +5,14 @@ import { exists, readText } from '../fs.js';
|
|
|
5
5
|
import { compareManaged } from './compare.js';
|
|
6
6
|
import { markerStyle, replaceManaged, wrapManaged } from './managed.js';
|
|
7
7
|
import { readSettings } from './settings.js';
|
|
8
|
+
import { AGENT_ROLES, COMMAND_ROLES } from '../config.js';
|
|
8
9
|
|
|
9
10
|
export const TEMPLATES = fileURLToPath(new URL('../../templates/claude-code/', import.meta.url));
|
|
10
11
|
export const SETTINGS = '.claude/settings.json';
|
|
11
12
|
export const RENDERED = '.slicekit/rendered';
|
|
12
13
|
const VERSION_RE = /^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/;
|
|
13
14
|
|
|
14
|
-
const TEMPLATE_KEYS = ['version', 'name', 'docsRoot', 'cli'];
|
|
15
|
+
const TEMPLATE_KEYS = ['version', 'name', 'docsRoot', 'cli', 'model'];
|
|
15
16
|
|
|
16
17
|
// {{key}} for each key in keys; any other {{…}} (and GitHub's ${{ … }}) is left as written.
|
|
17
18
|
export function substitute(text, vars, keys = TEMPLATE_KEYS) {
|
|
@@ -20,6 +21,23 @@ export function substitute(text, vars, keys = TEMPLATE_KEYS) {
|
|
|
20
21
|
|
|
21
22
|
export const varsFor = (cfg, version) => ({ version, name: cfg.name, docsRoot: cfg.docsRoot, cli: cfg.cli });
|
|
22
23
|
|
|
24
|
+
// REQ-6.7, D-115, D-130: the model a rendered file names in its front matter, from the models map.
|
|
25
|
+
// An agent file (.claude/agents/<role>.md) gets inherit when the map names none; a main-session
|
|
26
|
+
// command file (.claude/commands/slicekit-<role>.md) gets '' and so no model: line; any other file null.
|
|
27
|
+
export function modelFor(cfg, dest) {
|
|
28
|
+
const agent = /^\.claude\/agents\/([a-z]+)\.md$/.exec(dest);
|
|
29
|
+
if (agent && AGENT_ROLES.includes(agent[1])) return cfg.models?.[agent[1]] ?? 'inherit';
|
|
30
|
+
const command = /^\.claude\/commands\/slicekit-([a-z]+)\.md$/.exec(dest);
|
|
31
|
+
if (command && COMMAND_ROLES.includes(command[1])) return cfg.models?.[command[1]] ?? '';
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The file's text with {{model}} filled; a `model: {{model}}` line with no model is dropped.
|
|
36
|
+
function fillModel(text, model) {
|
|
37
|
+
if (model === null) return text;
|
|
38
|
+
return model === '' ? text.replace(/^model: \{\{model\}\}\n/m, '') : text;
|
|
39
|
+
}
|
|
40
|
+
|
|
23
41
|
// hooks.json parsed first, then {{…}} filled inside each string, so a quote or backslash in a value
|
|
24
42
|
// (a Windows path in cli) stays a string and never breaks the JSON.
|
|
25
43
|
export function loadHooks(templates, vars) {
|
|
@@ -85,7 +103,8 @@ export function loadReference(root, dest) {
|
|
|
85
103
|
// The one place a manifest entry is rendered and judged; planUpdate and renderAll both come through here.
|
|
86
104
|
// next: the whole file as it would be written (null for an unmanaged file, which is never written).
|
|
87
105
|
export function renderEntry(root, cfg, { src, dest }, { version, templates = TEMPLATES }) {
|
|
88
|
-
const
|
|
106
|
+
const model = modelFor(cfg, dest);
|
|
107
|
+
const rendered = substitute(fillModel(readText(path.join(templates, src)), model), { ...varsFor(cfg, version), model: model ?? '' });
|
|
89
108
|
const style = markerStyle(dest, rendered);
|
|
90
109
|
const fresh = wrapManaged(rendered, { version, style });
|
|
91
110
|
const file = path.join(root, dest);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
name: auditor
|
|
3
3
|
description: Compares claims with evidence and writes a gaps file or audit report with a citation on both sides.
|
|
4
4
|
tools: Read, Grep, Glob, Write, Bash
|
|
5
|
-
model:
|
|
5
|
+
model: {{model}}
|
|
6
6
|
---
|
|
7
7
|
Brief: run `{{cli}} instructions auditor` and follow it. You never run a git command that commits, pushes or moves a branch; report and the command commits. End every reply with "Skipped:" and "Not checked:" lines.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
name: designer
|
|
3
3
|
description: Gives a verdict on a screen against the team's design rules; writes no code.
|
|
4
4
|
tools: Read, Grep, Glob, Write, Bash
|
|
5
|
-
model:
|
|
5
|
+
model: {{model}}
|
|
6
6
|
---
|
|
7
7
|
Brief: run `{{cli}} instructions designer` and follow it. You never run a git command that commits, pushes or moves a branch; report and the command commits. End every reply with "Skipped:" and "Not checked:" lines.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
name: developer
|
|
3
3
|
description: Writes the slice's tests, then the code that passes them, in the worktree.
|
|
4
4
|
tools: Read, Grep, Glob, Edit, Write, Bash
|
|
5
|
-
model:
|
|
5
|
+
model: {{model}}
|
|
6
6
|
---
|
|
7
7
|
Brief: run `{{cli}} instructions developer` and follow it. You never run a git command that commits, pushes or moves a branch; report and the command commits. End every reply with "Skipped:" and "Not checked:" lines.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
name: fixer
|
|
3
3
|
description: Changes code to answer named review findings and nothing else.
|
|
4
4
|
tools: Read, Grep, Glob, Edit, Write, Bash
|
|
5
|
-
model:
|
|
5
|
+
model: {{model}}
|
|
6
6
|
---
|
|
7
7
|
Brief: run `{{cli}} instructions fixer` and follow it. You never run a git command that commits, pushes or moves a branch; report and the command commits. End every reply with "Skipped:" and "Not checked:" lines.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
name: ops
|
|
3
3
|
description: Reads the runbook and history for a symptom and replies with a proposed-actions report; changes nothing.
|
|
4
4
|
tools: Read, Grep, Glob
|
|
5
|
-
model:
|
|
5
|
+
model: {{model}}
|
|
6
6
|
---
|
|
7
7
|
Brief: run `{{cli}} instructions ops` and follow it. The start hook gives you that brief, since you hold no tool that runs a command or writes a file. Your reply is the report; you take no action you propose. End every reply with "Skipped:" and "Not checked:" lines.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
name: reviewer
|
|
3
3
|
description: Reviews a slice and writes a verdict file; writes no code.
|
|
4
4
|
tools: Read, Grep, Glob, Write, Bash
|
|
5
|
-
model:
|
|
5
|
+
model: {{model}}
|
|
6
6
|
---
|
|
7
7
|
Brief: run `{{cli}} instructions reviewer` and follow it. You never run a git command that commits, pushes or moves a branch; report and the command commits. End every reply with "Skipped:" and "Not checked:" lines.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Interview a person about an idea, one topic per question, and write the brief /slicekit intake takes as its source.
|
|
3
3
|
argument-hint: "[<slug>]"
|
|
4
|
+
model: {{model}}
|
|
4
5
|
---
|
|
5
6
|
Run `{{cli}} instructions --command brief $ARGUMENTS` and follow the procedure it prints. The procedure is the only source of this command's rules.
|
|
6
7
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Snapshot a requirement document and interview the human, writing one decision row per answer.
|
|
3
3
|
argument-hint: "<file or URL>"
|
|
4
|
+
model: {{model}}
|
|
4
5
|
---
|
|
5
6
|
Run `{{cli}} instructions --command intake $ARGUMENTS` and follow the procedure it prints. The procedure is the only source of this command's rules.
|
|
6
7
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Run the one next step of the program that slicekit next prints, then stop. Under /loop, one step per iteration.
|
|
3
3
|
argument-hint: ""
|
|
4
|
+
model: {{model}}
|
|
4
5
|
---
|
|
5
6
|
Run `{{cli}} instructions --command next $ARGUMENTS` and follow the procedure it prints. The procedure is the only source of this command's rules.
|
|
6
7
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Write the phases, slice files and BUILD.md, then open the plan pull request.
|
|
3
|
+
model: {{model}}
|
|
3
4
|
---
|
|
4
5
|
Run `{{cli}} instructions --command plan $ARGUMENTS` and follow the procedure it prints. The procedure is the only source of this command's rules.
|
|
5
6
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Write the spec files from the intake snapshots and decisions, then open the spec pull request.
|
|
3
|
+
model: {{model}}
|
|
3
4
|
---
|
|
4
5
|
Run `{{cli}} instructions --command specify $ARGUMENTS` and follow the procedure it prints. The procedure is the only source of this command's rules.
|
|
5
6
|
|
|
@@ -12,7 +12,7 @@ When a `{{cli}}` step exits with a code other than 0, stop and show the human it
|
|
|
12
12
|
|
|
13
13
|
## 1. The work branch
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
When the source is a brief at `<docsRoot>/brief/<slug>.md`, the branch takes the brief's slug, the `<slug>` of that path, because `/slicekit brief` committed the brief on `spec/<slug>` and the snapshot, the answers and the spec land on that one branch. Otherwise, for any other source, the slug is the program name (`name` in `.slicekit/config.json`) lower-cased, with each run of characters other than `a-z0-9` turned into one `-`, dashes trimmed from both ends, cut to 60 characters, then dashes trimmed again; it is `source` if nothing is left. The snapshot in step 2 names its file by the same rule, applied to the source's base name without its extension. Then run:
|
|
16
16
|
|
|
17
17
|
`{{cli}} branch spec <slug>`
|
|
18
18
|
|
|
@@ -9,10 +9,12 @@ repository's history goes through `{{cli}}`; run no git or gh command yourself.
|
|
|
9
9
|
|
|
10
10
|
## Steps
|
|
11
11
|
|
|
12
|
-
1. Run `{{cli}} branch spec <slug>`.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
1. Run `{{cli}} branch spec <slug>`. Take the slug of the `spec/<slug>` branch that holds the
|
|
13
|
+
newest snapshot under `<docsRoot>/intake/`: intake named it after the brief's slug when its
|
|
14
|
+
source was a brief at `<docsRoot>/brief/<slug>.md`, and after the program name otherwise. The
|
|
15
|
+
program's slug is `name` in `.slicekit/config.json` lower-cased, with each run of characters
|
|
16
|
+
other than `a-z0-9` turned into one `-`, dashes trimmed from both ends, cut to 60 characters. The
|
|
17
|
+
spec then lands on the branch that holds the brief, the intake snapshot and the answers.
|
|
16
18
|
2. Run `{{cli}} stage require clarify`. On exit 1, print what it says and stop: the spec waits for
|
|
17
19
|
intake and clarify.
|
|
18
20
|
3. Read every snapshot under `<docsRoot>/intake/` and every row of `<docsRoot>/decisions.md`. These
|