slicekit 0.6.1 → 0.7.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 -1
- package/package.json +1 -1
- package/src/brief.js +221 -0
- package/src/check/rules/layout.js +1 -1
- package/src/cli/brief.js +90 -0
- package/src/cli/index.js +2 -0
- package/src/cli/stage.js +7 -6
- package/src/hooks/pre-edit.js +4 -4
- package/src/init.js +1 -0
- package/src/instructions.js +1 -1
- package/src/paths.js +1 -0
- package/src/stage.js +27 -0
- package/templates/brief/blank.md +29 -0
- package/templates/claude-code/commands/slicekit-brief.md +7 -0
- package/templates/claude-code/commands/slicekit.md +1 -1
- package/templates/claude-code/manifest.json +9 -0
- package/templates/docs/brief/.keep +0 -0
- package/templates/instructions/commands/brief.md +60 -0
- package/templates/instructions/commands/intake.md +2 -0
package/README.md
CHANGED
|
@@ -70,6 +70,7 @@ walkthrough on `examples/backend`, except the review's `verdict` line: it is the
|
|
|
70
70
|
| Stage | Command | What you get |
|
|
71
71
|
|---|---|---|
|
|
72
72
|
| Any | `/slicekit` | any procedure below by name, for example `/slicekit build` |
|
|
73
|
+
| Brief | `/slicekit brief` | a brief written from the person's own answers, when there is only an idea and no requirement document |
|
|
73
74
|
| Intake | `/slicekit intake` | a frozen snapshot of the requirement document and one decision row per answer |
|
|
74
75
|
| Specify | `/slicekit specify` | spec files in which every requirement cites its source, and the spec pull request |
|
|
75
76
|
| Gaps | `/slicekit gaps` | each place the spec is silent, vague or in conflict with the intake, asked about and closed |
|
|
@@ -90,7 +91,8 @@ npm install --save-dev slicekit
|
|
|
90
91
|
npx slicekit init --shape backend --name <your-project>
|
|
91
92
|
```
|
|
92
93
|
|
|
93
|
-
Then open Claude Code in the project and type `/slicekit intake <your requirement document>`.
|
|
94
|
+
Then open Claude Code in the project and type `/slicekit intake <your requirement document>`. A person with only an idea types
|
|
95
|
+
`/slicekit brief` first, then the `/slicekit intake` command it prints. To
|
|
94
96
|
see each step run on a sample project first, follow
|
|
95
97
|
[the ten-minute walkthrough](https://github.com/adityapandya1/agentic-slicekit/blob/main/docs/walkthrough.md)
|
|
96
98
|
from a clone of this repository.
|
package/package.json
CHANGED
package/src/brief.js
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// `slicekit brief` (REQ-2.15, D-99): the interview that writes `<docsRoot>/brief/<slug>.md` from a
|
|
2
|
+
// person's answers alone, one topic per question in the order of REQ-2.15. An answer the person
|
|
3
|
+
// cannot give is listed under `## Open questions` by its topic's name and nowhere else. The brief
|
|
4
|
+
// holds only the seven headings, the answers and those topic names; `brief done` commits it.
|
|
5
|
+
//
|
|
6
|
+
// The session lives in this worktree's own git directory, `<git-dir>/slicekit/brief.json`, as
|
|
7
|
+
// {slug, startedAt, specFiles, pending, asked}: never in the work tree, so `git add -A` cannot stage
|
|
8
|
+
// it, and one per worktree. pre-edit denies the file, so an agent cannot rewrite it by hand.
|
|
9
|
+
import crypto from 'node:crypto';
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { listFiles } from './fs.js';
|
|
13
|
+
import { commitPaths, currentBranch, git } from './git.js';
|
|
14
|
+
import { kitPaths } from './paths.js';
|
|
15
|
+
|
|
16
|
+
// `code` 1: refused. `code` 2: bad input.
|
|
17
|
+
export class BriefError extends Error {
|
|
18
|
+
constructor(code, message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = 'BriefError';
|
|
21
|
+
this.code = code;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// The topics of REQ-2.15 in their order, each with the heading its answers go under. An answer to
|
|
26
|
+
// `unknowns` is an open question the person named; it goes under `## Open questions`.
|
|
27
|
+
export const SECTIONS = [
|
|
28
|
+
{ topic: 'problem', heading: 'Problem and who has it' },
|
|
29
|
+
{ topic: 'today', heading: 'What they do today' },
|
|
30
|
+
{ topic: 'use-cases', heading: 'Use cases' },
|
|
31
|
+
{ topic: 'out-of-scope', heading: 'Out of scope' },
|
|
32
|
+
{ topic: 'success-measures', heading: 'Success measures' },
|
|
33
|
+
{ topic: 'constraints', heading: 'Constraints' },
|
|
34
|
+
{ topic: 'unknowns', heading: 'Open questions' },
|
|
35
|
+
];
|
|
36
|
+
export const BRIEF_HEADINGS = SECTIONS.map((s) => s.heading);
|
|
37
|
+
const TOPICS = SECTIONS.map((s) => s.topic);
|
|
38
|
+
const OPEN = 'Open questions';
|
|
39
|
+
const SLUG = /^[a-z0-9][a-z0-9-]{0,59}$/;
|
|
40
|
+
|
|
41
|
+
const posix = (p) => p.split(path.sep).join('/');
|
|
42
|
+
const sha256 = (bytes) => crypto.createHash('sha256').update(bytes).digest('hex');
|
|
43
|
+
|
|
44
|
+
// The `## ` headings of a brief that are missing from `text`, in the order of REQ-2.15.
|
|
45
|
+
export function missingHeadings(text) {
|
|
46
|
+
const present = new Set(text.split(/\r?\n/).map((l) => l.trim()));
|
|
47
|
+
return BRIEF_HEADINGS.filter((h) => !present.has(`## ${h}`));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// The topic headings of a brief whose section holds no line and whose name is not listed under
|
|
51
|
+
// `## Open questions`, in the order of REQ-2.15: each such topic was neither answered nor left open.
|
|
52
|
+
export function unlistedEmptySections(text) {
|
|
53
|
+
const under = {};
|
|
54
|
+
let at = null;
|
|
55
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
56
|
+
const line = raw.trim();
|
|
57
|
+
if (line.startsWith('## ')) {
|
|
58
|
+
at = line.slice(3).trim();
|
|
59
|
+
under[at] ??= [];
|
|
60
|
+
} else if (at !== null && line !== '') under[at].push(line);
|
|
61
|
+
}
|
|
62
|
+
const open = new Set((under[OPEN] ?? []).map((l) => l.toLowerCase()));
|
|
63
|
+
return BRIEF_HEADINGS.filter((h) => h !== OPEN && Object.hasOwn(under, h) && under[h].length === 0 && !open.has(h.toLowerCase()));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function onWorkBranch(root, cfg, what) {
|
|
67
|
+
const branch = currentBranch(root);
|
|
68
|
+
if (branch === null || branch === cfg.defaultBranch || cfg.protectedBranches.includes(branch)) {
|
|
69
|
+
throw new BriefError(1, `${what} on a work branch; run slicekit branch spec <slug>`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function sessionPath(root) {
|
|
74
|
+
return path.join(git(root, ['rev-parse', '--path-format=absolute', '--git-dir']), 'slicekit', 'brief.json');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function readSession(root) {
|
|
78
|
+
const file = sessionPath(root);
|
|
79
|
+
if (!fs.existsSync(file)) return null;
|
|
80
|
+
try {
|
|
81
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
82
|
+
} catch {
|
|
83
|
+
throw new BriefError(1, `${posix(file)} is not valid JSON; delete it to start the brief again`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function writeSession(root, session) {
|
|
88
|
+
const file = sessionPath(root);
|
|
89
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
90
|
+
fs.writeFileSync(file, `${JSON.stringify(session, null, 2)}\n`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const needSession = (root) => {
|
|
94
|
+
const session = readSession(root);
|
|
95
|
+
if (!session) throw new BriefError(1, 'no brief is under way; run slicekit brief start <slug> first');
|
|
96
|
+
return session;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Each file under the spec directory, root-relative and POSIX, with the SHA-256 of its bytes.
|
|
100
|
+
function specFilesNow(root, cfg) {
|
|
101
|
+
const dir = kitPaths(root, cfg).spec;
|
|
102
|
+
if (!fs.existsSync(dir)) return {};
|
|
103
|
+
const base = posix(path.relative(root, dir));
|
|
104
|
+
return Object.fromEntries(listFiles(dir).map((f) => [`${base}/${f}`, sha256(fs.readFileSync(path.join(dir, f)))]));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const briefFile = (root, cfg, slug) => path.join(kitPaths(root, cfg).brief, `${slug}.md`);
|
|
108
|
+
const briefRel = (root, cfg, slug) => posix(path.relative(root, briefFile(root, cfg, slug)));
|
|
109
|
+
|
|
110
|
+
// The brief as the session holds it, rebuilt from every recorded answer: each heading, then the
|
|
111
|
+
// answers under it in the order given. A topic with only unknown answers is its heading name under
|
|
112
|
+
// Open questions, once; a topic with a real answer is answered and not listed as open.
|
|
113
|
+
export function renderBrief(asked) {
|
|
114
|
+
const under = Object.fromEntries(BRIEF_HEADINGS.map((h) => [h, []]));
|
|
115
|
+
const answered = new Set(asked.filter((a) => a.answer !== null).map((a) => a.topic));
|
|
116
|
+
const open = new Set();
|
|
117
|
+
for (const a of asked) {
|
|
118
|
+
const { heading } = SECTIONS.find((s) => s.topic === a.topic);
|
|
119
|
+
if (a.answer !== null) under[heading].push(a.answer);
|
|
120
|
+
else if (a.topic !== 'unknowns' && !answered.has(a.topic)) open.add(heading);
|
|
121
|
+
}
|
|
122
|
+
under[OPEN].unshift(...open);
|
|
123
|
+
return `${BRIEF_HEADINGS.map((h) => [`## ${h}`, ...under[h]].join('\n\n')).join('\n\n')}\n`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Opens the session for `slug` and writes the brief with its seven empty headings.
|
|
127
|
+
export function start(root, cfg, { slug, now = new Date() } = {}) {
|
|
128
|
+
if (typeof slug !== 'string' || !SLUG.test(slug)) {
|
|
129
|
+
throw new BriefError(2, `slug '${slug}' must be lowercase letters, digits and dashes, at most 60, not starting with a dash`);
|
|
130
|
+
}
|
|
131
|
+
onWorkBranch(root, cfg, 'the brief');
|
|
132
|
+
const existing = readSession(root);
|
|
133
|
+
if (existing) {
|
|
134
|
+
throw new BriefError(1, `the brief ${existing.slug} is under way; run slicekit brief done, or delete ${posix(sessionPath(root))} to drop it`);
|
|
135
|
+
}
|
|
136
|
+
const file = briefFile(root, cfg, slug);
|
|
137
|
+
const rel = briefRel(root, cfg, slug);
|
|
138
|
+
if (fs.existsSync(file)) throw new BriefError(1, `${rel} exists; choose another slug`);
|
|
139
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
140
|
+
fs.writeFileSync(file, renderBrief([]));
|
|
141
|
+
writeSession(root, { slug, startedAt: now.toISOString(), specFiles: specFilesNow(root, cfg), pending: null, asked: [] });
|
|
142
|
+
return { file: rel };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function oneLine(field, value) {
|
|
146
|
+
if (typeof value !== 'string' || value.trim() === '') throw new BriefError(2, `${field} is required`);
|
|
147
|
+
if (/[\r\n]/.test(value)) throw new BriefError(2, `${field} must be one line`);
|
|
148
|
+
return value.trim();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Holds `question` on `topic` as the one waiting for an answer; returns its number. The topic is the
|
|
152
|
+
// one last asked (a follow-up) or the next in the order of REQ-2.15.
|
|
153
|
+
export function ask(root, cfg, { topic, question } = {}) {
|
|
154
|
+
if (!TOPICS.includes(topic)) throw new BriefError(2, `topic must be one of ${TOPICS.join(', ')}, not '${topic}'`);
|
|
155
|
+
const q = oneLine('question', question);
|
|
156
|
+
const session = needSession(root);
|
|
157
|
+
if (session.pending) throw new BriefError(1, `answer the last question first: "${session.pending.question}" has no answer`);
|
|
158
|
+
const last = session.asked.length === 0 ? -1 : TOPICS.indexOf(session.asked.at(-1).topic);
|
|
159
|
+
const at = TOPICS.indexOf(topic);
|
|
160
|
+
if (at !== last && at !== last + 1) {
|
|
161
|
+
throw new BriefError(1, `topic ${topic} is out of order; ask ${last === -1 ? TOPICS[0] : `${TOPICS[last]} or ${TOPICS[last + 1] ?? 'nothing more'}`}`);
|
|
162
|
+
}
|
|
163
|
+
session.pending = { topic, question: q };
|
|
164
|
+
writeSession(root, session);
|
|
165
|
+
return { n: session.asked.length + 1 };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Writes the waiting question's answer into the brief, then clears it: the brief first, so the
|
|
169
|
+
// answer is recorded before the next question can be asked. `unknown` lists the topic under Open
|
|
170
|
+
// questions instead, and is refused on a topic the person already answered.
|
|
171
|
+
export function answer(root, cfg, { answer: text, unknown = false } = {}) {
|
|
172
|
+
const session = needSession(root);
|
|
173
|
+
if (!session.pending) throw new BriefError(1, 'no question is waiting for an answer');
|
|
174
|
+
let value = null;
|
|
175
|
+
if (unknown) {
|
|
176
|
+
const { topic } = session.pending;
|
|
177
|
+
if (topic !== 'unknowns' && session.asked.some((a) => a.topic === topic && a.answer !== null)) {
|
|
178
|
+
throw new BriefError(1, `topic ${topic} is already answered, so it cannot be open; record what the person says to this question with slicekit brief answer --answer <a>`);
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
if (typeof text !== 'string' || text.trim() === '') throw new BriefError(2, 'answer is required');
|
|
182
|
+
value = text.trim().replace(/\r\n/g, '\n');
|
|
183
|
+
if (value.split('\n').some((l) => /^#{1,6}\s/.test(l.trim()))) throw new BriefError(2, 'an answer holds no heading line');
|
|
184
|
+
}
|
|
185
|
+
const asked = [...session.asked, { ...session.pending, answer: value }];
|
|
186
|
+
fs.mkdirSync(kitPaths(root, cfg).brief, { recursive: true });
|
|
187
|
+
fs.writeFileSync(briefFile(root, cfg, session.slug), renderBrief(asked));
|
|
188
|
+
writeSession(root, { ...session, pending: null, asked });
|
|
189
|
+
return { file: briefRel(root, cfg, session.slug) };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Ends the brief: refuses while a question waits, on the default or a protected branch, while a
|
|
193
|
+
// topic was never asked and answered (an unknown answer counts), while a heading is missing from the brief, or when a file under the spec directory appeared, changed or
|
|
194
|
+
// went since `brief start`; otherwise commits the brief alone.
|
|
195
|
+
export function done(root, cfg) {
|
|
196
|
+
const session = needSession(root);
|
|
197
|
+
if (session.pending) throw new BriefError(1, `answer the last question first: "${session.pending.question}" has no answer`);
|
|
198
|
+
onWorkBranch(root, cfg, 'the brief');
|
|
199
|
+
const answered = new Set(session.asked.map((a) => a.topic));
|
|
200
|
+
const unasked = TOPICS.find((t) => !answered.has(t));
|
|
201
|
+
if (unasked) {
|
|
202
|
+
throw new BriefError(1, `topic ${unasked} was never asked and answered; run slicekit brief ask --topic ${unasked} --question <q>, then slicekit brief answer`);
|
|
203
|
+
}
|
|
204
|
+
const file = briefFile(root, cfg, session.slug);
|
|
205
|
+
const rel = briefRel(root, cfg, session.slug);
|
|
206
|
+
if (!fs.existsSync(file)) throw new BriefError(1, `${rel} is missing; run slicekit brief start ${session.slug} again`);
|
|
207
|
+
const missing = missingHeadings(fs.readFileSync(file, 'utf8'));
|
|
208
|
+
if (missing.length > 0) throw new BriefError(1, `${rel} has no section ## ${missing[0]}`);
|
|
209
|
+
const known = session.specFiles ?? {};
|
|
210
|
+
const now = specFilesNow(root, cfg);
|
|
211
|
+
for (const [f, digest] of Object.entries(now)) {
|
|
212
|
+
if (!Object.hasOwn(known, f)) throw new BriefError(1, `the brief writes no spec text; remove ${f}`);
|
|
213
|
+
if (known[f] !== digest) throw new BriefError(1, `the brief writes no spec text; ${f} changed during the interview`);
|
|
214
|
+
}
|
|
215
|
+
for (const f of Object.keys(known)) {
|
|
216
|
+
if (!Object.hasOwn(now, f)) throw new BriefError(1, `the brief writes no spec text; ${f} was removed during the interview`);
|
|
217
|
+
}
|
|
218
|
+
const commit = commitPaths(root, [rel], `docs(brief): ${session.slug}`);
|
|
219
|
+
fs.rmSync(sessionPath(root), { force: true });
|
|
220
|
+
return { file: rel, commit };
|
|
221
|
+
}
|
|
@@ -13,7 +13,7 @@ export const ratchet = false;
|
|
|
13
13
|
|
|
14
14
|
const CONFIG = '.slicekit/config.json';
|
|
15
15
|
const FILES = ['decisions', 'gaps', 'stack', 'platform', 'observability', 'runbook', 'build', 'workflow'];
|
|
16
|
-
const DIRS = ['kit', 'state', 'baselines', 'docs', 'intake', 'spec', 'contracts', 'phases', 'releases', 'githooks', 'claude'];
|
|
16
|
+
const DIRS = ['kit', 'state', 'baselines', 'docs', 'brief', 'intake', 'spec', 'contracts', 'phases', 'releases', 'githooks', 'claude'];
|
|
17
17
|
|
|
18
18
|
const toPosix = (p) => p.split(path.sep).join('/');
|
|
19
19
|
|
package/src/cli/brief.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// `slicekit brief start | ask | answer | done` (REQ-2.15, D-99): the brief interview. `start` prints
|
|
2
|
+
// the brief's path, `ask` prints `question <n>`, `answer` the brief's path, and `done` the path it
|
|
3
|
+
// committed and then, as its last line, the intake command that takes the brief as its source.
|
|
4
|
+
import { parseArgs } from 'node:util';
|
|
5
|
+
import { ConfigError, loadConfig } from '../config.js';
|
|
6
|
+
import { BriefError, answer, ask, done, start } from '../brief.js';
|
|
7
|
+
import { GitError } from '../git.js';
|
|
8
|
+
|
|
9
|
+
const SUBCOMMANDS = ['start', 'ask', 'answer', 'done'];
|
|
10
|
+
const ISO = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;
|
|
11
|
+
const USAGE =
|
|
12
|
+
'brief start <slug>\n' +
|
|
13
|
+
' brief ask --topic <problem|today|use-cases|out-of-scope|success-measures|constraints|unknowns> --question <q>\n' +
|
|
14
|
+
' brief answer (--answer <a> | --unknown)\n' +
|
|
15
|
+
' brief done';
|
|
16
|
+
|
|
17
|
+
const SPEC = {
|
|
18
|
+
start: { options: [], positionals: 1 },
|
|
19
|
+
ask: { options: ['topic', 'question'], positionals: 0 },
|
|
20
|
+
answer: { options: ['answer', 'unknown'], positionals: 0 },
|
|
21
|
+
done: { options: [], positionals: 0 },
|
|
22
|
+
};
|
|
23
|
+
const OPTIONS = { topic: { type: 'string' }, question: { type: 'string' }, answer: { type: 'string' }, unknown: { type: 'boolean' } };
|
|
24
|
+
|
|
25
|
+
const usage = (io, why) => {
|
|
26
|
+
io.stderr(`${why ? `slicekit: ${why}\n` : ''}usage: slicekit ${USAGE}\n`);
|
|
27
|
+
return 2;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// SLICEKIT_NOW is for tests only: it fixes the instant the session records as its start.
|
|
31
|
+
function clock(io) {
|
|
32
|
+
const fixed = (io.env ?? process.env).SLICEKIT_NOW;
|
|
33
|
+
if (fixed === undefined || fixed === '') return new Date();
|
|
34
|
+
const now = new Date(fixed);
|
|
35
|
+
return ISO.test(fixed) && !Number.isNaN(now.getTime()) ? now : null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function perform(sub, root, cfg, values, rest, now, io) {
|
|
39
|
+
if (sub === 'start') {
|
|
40
|
+
io.stdout(`${start(root, cfg, { slug: rest[0], now }).file}\n`);
|
|
41
|
+
} else if (sub === 'ask') {
|
|
42
|
+
io.stdout(`question ${ask(root, cfg, { topic: values.topic, question: values.question }).n}\n`);
|
|
43
|
+
} else if (sub === 'answer') {
|
|
44
|
+
io.stdout(`${answer(root, cfg, { answer: values.answer, unknown: Boolean(values.unknown) }).file}\n`);
|
|
45
|
+
} else {
|
|
46
|
+
const { file } = done(root, cfg);
|
|
47
|
+
io.stdout(`${file}\n/slicekit intake ${file}\n`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function run(args, io) {
|
|
52
|
+
let values;
|
|
53
|
+
let positionals;
|
|
54
|
+
try {
|
|
55
|
+
({ values, positionals } = parseArgs({ args, options: OPTIONS, allowPositionals: true }));
|
|
56
|
+
} catch (e) {
|
|
57
|
+
return usage(io, e.message);
|
|
58
|
+
}
|
|
59
|
+
const [sub, ...rest] = positionals;
|
|
60
|
+
const spec = Object.hasOwn(SPEC, sub ?? '') ? SPEC[sub] : undefined;
|
|
61
|
+
if (!spec || rest.length !== spec.positionals) return usage(io);
|
|
62
|
+
const extra = Object.keys(values).filter((k) => !spec.options.includes(k));
|
|
63
|
+
if (extra.length > 0) return usage(io, `${sub} does not take --${extra[0]}`);
|
|
64
|
+
if (sub === 'ask' && (values.topic === undefined || values.question === undefined)) return usage(io);
|
|
65
|
+
if (sub === 'answer' && (values.answer === undefined) === !values.unknown) return usage(io, 'answer takes one of --answer and --unknown');
|
|
66
|
+
const now = clock(io);
|
|
67
|
+
if (now === null) return usage(io, `SLICEKIT_NOW '${(io.env ?? process.env).SLICEKIT_NOW}' is not an ISO time`);
|
|
68
|
+
const root = io.cwd;
|
|
69
|
+
try {
|
|
70
|
+
const cfg = loadConfig(root);
|
|
71
|
+
perform(sub, root, cfg, values, rest, now, io);
|
|
72
|
+
return 0;
|
|
73
|
+
} catch (e) {
|
|
74
|
+
if (e instanceof BriefError) {
|
|
75
|
+
io.stderr(`slicekit: ${e.message}\n`);
|
|
76
|
+
return e.code;
|
|
77
|
+
}
|
|
78
|
+
if (e instanceof ConfigError) {
|
|
79
|
+
io.stderr(`slicekit: ${e.message}\n`);
|
|
80
|
+
return 2;
|
|
81
|
+
}
|
|
82
|
+
if (e instanceof GitError) {
|
|
83
|
+
io.stderr(`slicekit: ${e.message}\n`);
|
|
84
|
+
return 1;
|
|
85
|
+
}
|
|
86
|
+
throw e;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const briefCommand = { run, usage: USAGE, subcommands: SUBCOMMANDS };
|
package/src/cli/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { findSliceFiles, parseSliceFile } from '../slicefile.js';
|
|
|
7
7
|
import { auditCommand } from './audit.js';
|
|
8
8
|
import { baselineCommand } from './baseline.js';
|
|
9
9
|
import { branchCommand } from './branch.js';
|
|
10
|
+
import { briefCommand } from './brief.js';
|
|
10
11
|
import { buildCommand } from './build.js';
|
|
11
12
|
import { checkCommand } from './check.js';
|
|
12
13
|
import { ciCommand } from './ci.js';
|
|
@@ -43,6 +44,7 @@ export const COMMANDS = {
|
|
|
43
44
|
audit: auditCommand,
|
|
44
45
|
baseline: baselineCommand,
|
|
45
46
|
branch: branchCommand,
|
|
47
|
+
brief: briefCommand,
|
|
46
48
|
build: buildCommand,
|
|
47
49
|
check: checkCommand,
|
|
48
50
|
ci: ciCommand,
|
package/src/cli/stage.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// `slicekit stage require <stage>` (REQ-1.7): a command's gate. Exit 0 with `ready: <stage>` when
|
|
2
2
|
// the stage and every one before it are complete; exit 1 with the first blocker and the command
|
|
3
|
-
// that clears it. Pending rows that do not block follow, one per line.
|
|
3
|
+
// that clears it. Pending rows that do not block follow, one per line. `brief` (D-99) is the optional
|
|
4
|
+
// stage before intake: judged alone, and no stage of STAGES reads it.
|
|
4
5
|
import { ConfigError, loadConfig } from '../config.js';
|
|
5
|
-
import { STAGES, StageError, programStage } from '../stage.js';
|
|
6
|
+
import { STAGES, StageError, briefStage, programStage } from '../stage.js';
|
|
6
7
|
|
|
7
|
-
const USAGE = 'stage require <stage>';
|
|
8
|
+
const USAGE = 'stage require <stage|brief>';
|
|
8
9
|
|
|
9
10
|
async function run(args, io) {
|
|
10
11
|
const [sub, stage, ...rest] = args;
|
|
@@ -12,8 +13,8 @@ async function run(args, io) {
|
|
|
12
13
|
io.stderr(`usage: slicekit ${USAGE}\n`);
|
|
13
14
|
return 2;
|
|
14
15
|
}
|
|
15
|
-
if (!STAGES.includes(stage)) {
|
|
16
|
-
io.stderr(`slicekit: unknown stage '${stage}'; one of ${STAGES.join(', ')}\n`);
|
|
16
|
+
if (stage !== 'brief' && !STAGES.includes(stage)) {
|
|
17
|
+
io.stderr(`slicekit: unknown stage '${stage}'; one of ${STAGES.join(', ')}, or brief\n`);
|
|
17
18
|
return 2;
|
|
18
19
|
}
|
|
19
20
|
let cfg;
|
|
@@ -24,7 +25,7 @@ async function run(args, io) {
|
|
|
24
25
|
io.stderr(`slicekit: ${e.message}\n`);
|
|
25
26
|
return 2;
|
|
26
27
|
}
|
|
27
|
-
const now = programStage(io.cwd, cfg, { upTo: stage });
|
|
28
|
+
const now = stage === 'brief' ? briefStage(io.cwd, cfg) : programStage(io.cwd, cfg, { upTo: stage });
|
|
28
29
|
const pending = (now.pending ?? []).map((line) => `${line}\n`).join('');
|
|
29
30
|
if (!now.complete) {
|
|
30
31
|
io.stderr(`${new StageError(now.stage, now.blockers[0]).message}\n${pending}`);
|
package/src/hooks/pre-edit.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// `.slicekit/baselines/`, `.slicekit/.subagent-*`, `.slicekit/.retry-*` or `.slicekit/.agents-*` segment
|
|
7
7
|
// under any root, or a `slicekit/subagent-*` marker, `slicekit/retry-*` retry state or `slicekit/agents-*`
|
|
8
8
|
// started-agents record in a git directory (`.git` or `*.git`), or the `slicekit/interview.json` intake
|
|
9
|
-
// session in one (a linked worktree's included)
|
|
9
|
+
// session or the `slicekit/brief.json` brief session in one (a linked worktree's included)
|
|
10
10
|
// — always; (4) a path that matches a pattern of the root's `agents.denyPaths` (REQ-3.13) — always;
|
|
11
11
|
// then, only while
|
|
12
12
|
// the file's own root has an active slice (a `slice/*` branch with a state file) in `tests-red` or
|
|
@@ -86,9 +86,9 @@ function kitOwned(abs) {
|
|
|
86
86
|
}) || segs.some((s, i) => i > 0 && (segs[i - 1] === '.git' || segs[i - 1].endsWith('.git'))
|
|
87
87
|
&& s === 'slicekit' && (segs[i + 1] === 'clone-id'
|
|
88
88
|
|| ['subagent-', 'retry-', 'agents-'].some((p) => segs[i + 1]?.startsWith(p))))
|
|
89
|
-
// The intake interview
|
|
90
|
-
// (`<.git>/worktrees/<name>/slicekit/interview.json`).
|
|
91
|
-
|| segs.some((s, i) => s === 'slicekit' && segs[i + 1] === 'interview.json'
|
|
89
|
+
// The intake interview and brief sessions, also in a linked worktree's own git directory
|
|
90
|
+
// (`<.git>/worktrees/<name>/slicekit/interview.json`, `.../slicekit/brief.json`).
|
|
91
|
+
|| segs.some((s, i) => s === 'slicekit' && (segs[i + 1] === 'interview.json' || segs[i + 1] === 'brief.json')
|
|
92
92
|
&& segs.slice(0, i).some((p) => p === '.git' || p.endsWith('.git')));
|
|
93
93
|
}
|
|
94
94
|
|
package/src/init.js
CHANGED
|
@@ -137,6 +137,7 @@ const TEMPLATE_DEST = {
|
|
|
137
137
|
'spec/00-overview.md': (p) => path.join(p.spec, '00-overview.md'),
|
|
138
138
|
'spec/gaps.md': (p) => p.gaps,
|
|
139
139
|
'spec/stack.md': (p) => p.stack,
|
|
140
|
+
'brief/.keep': (p) => path.join(p.brief, '.keep'),
|
|
140
141
|
'intake/.keep': (p) => path.join(p.intake, '.keep'),
|
|
141
142
|
'spec/contracts/.keep': (p) => path.join(p.contracts, '.keep'),
|
|
142
143
|
'phases/.keep': (p) => path.join(p.phases, '.keep'),
|
package/src/instructions.js
CHANGED
|
@@ -16,7 +16,7 @@ import { kitPaths } from './paths.js';
|
|
|
16
16
|
import { findSliceFiles } from './slicefile.js';
|
|
17
17
|
import { reqBlocks } from './stage.js';
|
|
18
18
|
|
|
19
|
-
export const PROCEDURES = ['
|
|
19
|
+
export const PROCEDURES = ['brief', 'intake','specify', 'gaps', 'plan', 'build', 'review', 'release', 'ops', 'audit'];
|
|
20
20
|
export const TEMPLATES = fileURLToPath(new URL('../templates/instructions', import.meta.url));
|
|
21
21
|
|
|
22
22
|
const KIT_SKILL = fileURLToPath(new URL('../templates/claude-code/skills/slicekit-writing/SKILL.md', import.meta.url));
|
package/src/paths.js
CHANGED
|
@@ -14,6 +14,7 @@ export function kitPaths(root, cfg) {
|
|
|
14
14
|
reports: path.join(kit, 'reports'),
|
|
15
15
|
workspace: path.join(kit, 'workspace.json'),
|
|
16
16
|
docs,
|
|
17
|
+
brief: path.join(docs, 'brief'),
|
|
17
18
|
intake: path.join(docs, 'intake'),
|
|
18
19
|
decisions: path.join(docs, 'decisions.md'),
|
|
19
20
|
spec,
|
package/src/stage.js
CHANGED
|
@@ -6,6 +6,7 @@ import { GitError, assertRef, git, hasCommits, isRepo } from './git.js';
|
|
|
6
6
|
import { readDecisions } from './decisions.js';
|
|
7
7
|
import { blankCodeSpans, headings, lines, prose, refs, tables } from './markdown.js';
|
|
8
8
|
import { re } from './ids.js';
|
|
9
|
+
import { missingHeadings, unlistedEmptySections } from './brief.js';
|
|
9
10
|
import { kitPaths } from './paths.js';
|
|
10
11
|
import { findSliceFiles, parseSliceFile } from './slicefile.js';
|
|
11
12
|
import { listSlices } from './state/index.js';
|
|
@@ -14,6 +15,7 @@ export const STAGES = ['intake', 'clarify', 'specify', 'spec-review', 'gap-scan'
|
|
|
14
15
|
|
|
15
16
|
// The slash command that does each stage, named in the refusal.
|
|
16
17
|
const COMMANDS = {
|
|
18
|
+
brief: 'brief',
|
|
17
19
|
intake: 'intake',
|
|
18
20
|
clarify: 'intake (clarify)',
|
|
19
21
|
specify: 'specify',
|
|
@@ -27,6 +29,7 @@ const COMMANDS = {
|
|
|
27
29
|
|
|
28
30
|
// The display name of each stage, used in messages; the ids stay in code.
|
|
29
31
|
const LABELS = {
|
|
32
|
+
brief: 'brief',
|
|
30
33
|
intake: 'intake',
|
|
31
34
|
clarify: 'clarify',
|
|
32
35
|
specify: 'specify',
|
|
@@ -298,6 +301,30 @@ function release(root, cfg) {
|
|
|
298
301
|
.map((id) => `${id} has no releases/${id}.md`);
|
|
299
302
|
}
|
|
300
303
|
|
|
304
|
+
// The optional brief stage (REQ-1.7, D-99), outside STAGES: no stage after it reads the brief folder.
|
|
305
|
+
// Complete when there is a brief and every file under `<docsRoot>/brief/` other than `.keep` has
|
|
306
|
+
// every section of REQ-2.15, each topic section filled or listed under Open questions; the blockers
|
|
307
|
+
// name each file and its first missing section, or else its first empty section not listed there.
|
|
308
|
+
export function briefStage(root, cfg) {
|
|
309
|
+
const dir = kitPaths(root, cfg).brief;
|
|
310
|
+
const files = exists(dir) ? listFiles(dir).filter((f) => path.posix.basename(f) !== '.keep') : [];
|
|
311
|
+
if (files.length === 0) return { stage: 'brief', complete: false, blockers: [`no brief under ${rel(root, dir)}/`] };
|
|
312
|
+
const blockers = [];
|
|
313
|
+
for (const f of files.sort()) {
|
|
314
|
+
const text = readText(path.join(dir, f));
|
|
315
|
+
const missing = missingHeadings(text);
|
|
316
|
+
if (missing.length > 0) {
|
|
317
|
+
blockers.push(`${rel(root, path.join(dir, f))} has no section ## ${missing[0]}`);
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
const empty = unlistedEmptySections(text);
|
|
321
|
+
if (empty.length > 0) {
|
|
322
|
+
blockers.push(`${rel(root, path.join(dir, f))} has an empty section ## ${empty[0]} that is not listed under ## Open questions`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return { stage: 'brief', complete: blockers.length === 0, blockers };
|
|
326
|
+
}
|
|
327
|
+
|
|
301
328
|
const CHECKS = { intake, clarify, specify, 'spec-review': specReview, 'gap-scan': gapScan, stack, plan, build, release };
|
|
302
329
|
|
|
303
330
|
// Evaluates the stages in order and stops after `upTo` (default: all), so later stages cost nothing.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Brief: <name>
|
|
2
|
+
|
|
3
|
+
## Problem and who has it
|
|
4
|
+
|
|
5
|
+
The problem in one or two sentences, and the people or systems who have it.
|
|
6
|
+
|
|
7
|
+
## What they do today
|
|
8
|
+
|
|
9
|
+
How those people handle the problem now, and where that falls short.
|
|
10
|
+
|
|
11
|
+
## Use cases
|
|
12
|
+
|
|
13
|
+
One line per thing a user does with what is built, as "a <user> <does what>".
|
|
14
|
+
|
|
15
|
+
## Out of scope
|
|
16
|
+
|
|
17
|
+
What this work does not do, one line per item, so the spec leaves it out.
|
|
18
|
+
|
|
19
|
+
## Success measures
|
|
20
|
+
|
|
21
|
+
How you will tell it works: a number, an observable behaviour or a check someone can run.
|
|
22
|
+
|
|
23
|
+
## Constraints
|
|
24
|
+
|
|
25
|
+
Limits the work must keep, such as a deadline, a platform, a language or a rule it must follow.
|
|
26
|
+
|
|
27
|
+
## Open questions
|
|
28
|
+
|
|
29
|
+
One line per question nobody can answer yet; a topic you cannot fill goes here by its heading.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Interview a person about an idea, one topic per question, and write the brief /slicekit intake takes as its source.
|
|
3
|
+
argument-hint: "[<slug>]"
|
|
4
|
+
---
|
|
5
|
+
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
|
+
Writing rules: `.claude/skills/slicekit-writing/SKILL.md`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Run a slicekit command: intake, specify, gaps, plan, build, review, release, ops or audit. /slicekit <command> [args]"
|
|
2
|
+
description: "Run a slicekit command: brief, intake, specify, gaps, plan, build, review, release, ops or audit. /slicekit <command> [args]"
|
|
3
3
|
argument-hint: "<command> [args]"
|
|
4
4
|
---
|
|
5
5
|
Run `{{cli}} instructions --command $ARGUMENTS` and follow the procedure it prints. The procedure is the only source of this command's rules.
|
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
"data"
|
|
9
9
|
]
|
|
10
10
|
},
|
|
11
|
+
{
|
|
12
|
+
"src": "commands/slicekit-brief.md",
|
|
13
|
+
"dest": ".claude/commands/slicekit-brief.md",
|
|
14
|
+
"shapes": [
|
|
15
|
+
"backend",
|
|
16
|
+
"fullstack",
|
|
17
|
+
"data"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
11
20
|
{
|
|
12
21
|
"src": "commands/slicekit-intake.md",
|
|
13
22
|
"dest": ".claude/commands/slicekit-intake.md",
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# /slicekit brief
|
|
2
|
+
|
|
3
|
+
You interview a person who has an idea but no requirement document, and write their brief from their answers alone. You end with `<docsRoot>/brief/<slug>.md` committed on the spec branch, and the intake command that takes it as its source. The slug is: {{args}}
|
|
4
|
+
|
|
5
|
+
`<docsRoot>` below is the `docsRoot` in `.slicekit/config.json`.
|
|
6
|
+
|
|
7
|
+
This command writes no spec text and no file under `<docsRoot>/spec/`. Writing the spec is `/slicekit specify`, after `/slicekit intake`. Every git step is in the CLI: the branch and the brief commit are `{{cli}}` subcommands. You run no git command yourself.
|
|
8
|
+
|
|
9
|
+
When a `{{cli}}` step exits with a code other than 0, stop and show the person its message. Do not work around it.
|
|
10
|
+
|
|
11
|
+
## 1. The slug and the work branch
|
|
12
|
+
|
|
13
|
+
When the slug above is `(none)`, ask the person for a short name for the idea, and make the slug from it: lower-cased, each run of characters other than `a-z0-9` turned into one `-`, dashes trimmed from both ends, at most 60 characters. Then run:
|
|
14
|
+
|
|
15
|
+
`{{cli}} branch spec <slug>`
|
|
16
|
+
|
|
17
|
+
## 2. Start the brief
|
|
18
|
+
|
|
19
|
+
`{{cli}} brief start <slug>`
|
|
20
|
+
|
|
21
|
+
It prints the brief's path, for example `docs/brief/payments-retry.md`. Call it `<brief>` below. It holds the seven headings and nothing else yet.
|
|
22
|
+
|
|
23
|
+
## 3. The interview
|
|
24
|
+
|
|
25
|
+
Ask one question at a time, one topic per question, in this order:
|
|
26
|
+
|
|
27
|
+
1. `problem`: the problem and who has it
|
|
28
|
+
2. `today`: what they do today
|
|
29
|
+
3. `use-cases`: the use cases
|
|
30
|
+
4. `out-of-scope`: what is out of scope
|
|
31
|
+
5. `success-measures`: the success measures
|
|
32
|
+
6. `constraints`: the constraints
|
|
33
|
+
7. `unknowns`: what they know they do not know
|
|
34
|
+
|
|
35
|
+
A topic may take more than one question; do not mix two topics in one question, and do not go back to an earlier topic. Ask in the person's terms. Offer no answer of your own: the brief holds only what the person says.
|
|
36
|
+
|
|
37
|
+
For each question:
|
|
38
|
+
|
|
39
|
+
1. Before you ask it, run `{{cli}} brief ask --topic=<topic> --question=<the question>`. It prints `question <n>`.
|
|
40
|
+
2. Ask the person, and wait for the answer.
|
|
41
|
+
3. Record the answer in the person's own words with `{{cli}} brief answer --answer=<the answer>`. It writes the answer under the topic's heading in `<brief>`.
|
|
42
|
+
- When the person says they do not know, or cannot answer, run `{{cli}} brief answer --unknown`. It lists the topic under `## Open questions` and writes nothing under the topic's heading. Never write a guess in its place. A later answer on the same topic takes the topic off `## Open questions`. Once a topic has an answer, `--unknown` on it is refused: record what the person says with `--answer=<the answer>`.
|
|
43
|
+
4. Ask the next question only after the answer step exits 0. The CLI refuses a new question while the last one has no answer, and a topic out of the order above.
|
|
44
|
+
|
|
45
|
+
Always write a value as `--option=<text>`, with the `=`, so a value that starts with `-` is read as text and not as an option.
|
|
46
|
+
|
|
47
|
+
## 4. Finish
|
|
48
|
+
|
|
49
|
+
`{{cli}} brief done`
|
|
50
|
+
|
|
51
|
+
It commits `<brief>` alone on the spec branch. Its last line is the next command, for example `/slicekit intake docs/brief/payments-retry.md`. Show the person that line as it is: `/slicekit intake` takes the brief as its source like any other document.
|
|
52
|
+
|
|
53
|
+
`{{cli}} brief done` refuses when no brief is under way, while a question has no answer, on the default branch or a protected branch, while a topic was never asked and answered (an answer given with `--unknown` counts as answered), naming the first such topic, when `<brief>` is missing, while a heading is missing from `<brief>`, or when a file under `<docsRoot>/spec/` appeared, changed or was removed during the interview. Show the person the message. Never delete or edit a spec file to get past it.
|
|
54
|
+
|
|
55
|
+
## You never
|
|
56
|
+
|
|
57
|
+
- Write or edit a file under `<docsRoot>/spec/`.
|
|
58
|
+
- Edit `<brief>` by hand, or add text the person did not give. Answers are written only by `{{cli}} brief answer`.
|
|
59
|
+
- Edit the brief session file.
|
|
60
|
+
- Run a git or gh command. The CLI does every git step.
|
|
@@ -4,6 +4,8 @@ You bring a requirement document into the project and interview the human about
|
|
|
4
4
|
|
|
5
5
|
`<docsRoot>` below is the `docsRoot` in `.slicekit/config.json`.
|
|
6
6
|
|
|
7
|
+
A brief at `<docsRoot>/brief/<slug>.md`, written by `/slicekit brief`, is a valid source: snapshot it in step 2 as you would any other document.
|
|
8
|
+
|
|
7
9
|
This command writes no file under `<docsRoot>/spec/`. Writing the spec is `/slicekit specify`, later. Every git step is in the CLI: the branch, the snapshot commit and the answers commit are all `{{cli}}` subcommands. You run no git command yourself.
|
|
8
10
|
|
|
9
11
|
When a `{{cli}}` step exits with a code other than 0, stop and show the human its message. Do not work around it.
|