agentic-sdlc-kit 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -1
- package/INSTALL.md +8 -8
- package/README.md +32 -15
- package/dist/commands/approve.js +174 -15
- package/dist/commands/board.js +13 -2
- package/dist/commands/githook.js +12 -2
- package/dist/commands/hook.js +163 -17
- package/dist/commands/task.js +1 -0
- package/dist/commands/upgrade.js +7 -1
- package/dist/core/approvals.js +15 -5
- package/dist/core/ownerCommand.js +35 -5
- package/dist/core/pendingDecision.js +45 -0
- package/dist/core/promptProof.js +109 -0
- package/dist/core/stateMachine.js +1 -1
- package/dist/engine/reconcile.js +4 -2
- package/dist/hooks/session.js +64 -1
- package/dist/install/apply.js +9 -1
- package/dist/install/detect.js +106 -17
- package/dist/outbox/outbox.js +9 -5
- package/dist/render/instructions.js +65 -3
- package/package.json +2 -2
- package/templates/instructions/block.md +7 -2
- package/templates/owner-commands/command.md +11 -0
- package/templates/owner-commands/command.toml +2 -0
- package/templates/skills/sdlc-delivery/SKILL.md +2 -2
- package/templates/skills/sdlc-task-tracking/SKILL.md +43 -11
package/dist/hooks/session.js
CHANGED
|
@@ -41,6 +41,24 @@ export function pendingActions(result) {
|
|
|
41
41
|
}
|
|
42
42
|
/** The full hex SHA-256 of a prompt: what the prompt record keeps instead of its text. */
|
|
43
43
|
export const promptSha256 = (prompt) => createHash('sha256').update(prompt).digest('hex');
|
|
44
|
+
/**
|
|
45
|
+
* A prompt as it is compared, not as it was typed: characters are composed (NFC), so decomposed and
|
|
46
|
+
* precomposed diacritics are one text; CRLF and CR become LF, each line loses its trailing
|
|
47
|
+
* whitespace, and the whole text loses the whitespace around it. A heredoc's trailing newline or an
|
|
48
|
+
* editor's padding then does not change it; the spaces inside a line stay. The lines are trimmed
|
|
49
|
+
* one by one, not with a `$`-anchored pattern, which is quadratic in a long run of spaces inside a line.
|
|
50
|
+
*/
|
|
51
|
+
export function normalizePrompt(text) {
|
|
52
|
+
return text
|
|
53
|
+
.normalize('NFC')
|
|
54
|
+
.replace(/\r\n?/g, '\n')
|
|
55
|
+
.split('\n')
|
|
56
|
+
.map(line => line.trimEnd())
|
|
57
|
+
.join('\n')
|
|
58
|
+
.trim();
|
|
59
|
+
}
|
|
60
|
+
/** The full hex SHA-256 of the normalised prompt: what a prompt text given back later is checked against. */
|
|
61
|
+
export const promptNormSha256 = (text) => promptSha256(normalizePrompt(text));
|
|
44
62
|
/**
|
|
45
63
|
* The `ref` of an approval recorded from a prompt: it names the harness, the session, a key that
|
|
46
64
|
* tells this prompt from the others of the session, and the first 16 hex digits of the prompt's
|
|
@@ -49,7 +67,19 @@ export const promptSha256 = (prompt) => createHash('sha256').update(prompt).dige
|
|
|
49
67
|
* the same text, is a new one. Gemini has no such id: its key is `fallbackKey`, which names the
|
|
50
68
|
* decision (`approve-<phase>`, or the action alone), so the same text approves each stage once.
|
|
51
69
|
*/
|
|
52
|
-
export const promptRef = (harness, sessionId, promptId, fallbackKey, prompt) =>
|
|
70
|
+
export const promptRef = (harness, sessionId, promptId, fallbackKey, prompt) => promptRefOfHash(harness, sessionId, promptId, fallbackKey, promptSha256(prompt));
|
|
71
|
+
/**
|
|
72
|
+
* `promptRef` for a prompt that is known by its hash (`promptSha256`) and no longer by its text: the
|
|
73
|
+
* reference `sdlc approve --from-prompt` builds from the prompt record. It is the one the hook builds
|
|
74
|
+
* for the same prompt, so the two routes see one prompt as one decision.
|
|
75
|
+
*/
|
|
76
|
+
export const promptRefOfHash = (harness, sessionId, promptId, fallbackKey, sha256) => `prompt:${harness}:${sessionId ?? 'nosession'}:${promptId ?? fallbackKey}:${sha256.slice(0, 16)}`;
|
|
77
|
+
/**
|
|
78
|
+
* A prompt id is put in a command line in the reminder: only what is safe there is. Every id the
|
|
79
|
+
* harnesses give (a UUID, a turn id) is, and so is the time of a Gemini prompt record. `sdlc approve
|
|
80
|
+
* --from-prompt` takes only such a key back.
|
|
81
|
+
*/
|
|
82
|
+
export const SAFE_PROMPT_KEY = /^[A-Za-z0-9._:+-]{1,128}$/;
|
|
53
83
|
/**
|
|
54
84
|
* Who a prompt approval is recorded for. The prompt comes from the human at the keyboard, so with
|
|
55
85
|
* one owner configured it is that owner, whatever login the tool runs as (an agent login included).
|
|
@@ -75,3 +105,36 @@ export function isBareCancel(prompt) {
|
|
|
75
105
|
.find(line => line !== '');
|
|
76
106
|
return first !== undefined && /^\/cancel$/i.test(first);
|
|
77
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* The word the agent is told to ask the owner for when their intent is unclear. The hook cannot
|
|
110
|
+
* know the owner's language: the agent says the same word in the owner's.
|
|
111
|
+
*/
|
|
112
|
+
const DECISION_WORD = 'schvaľujem';
|
|
113
|
+
/**
|
|
114
|
+
* The line that tells the agent a decision waits for the owner, on a prompt that is no owner command,
|
|
115
|
+
* and how to record it from that prompt: `promptKey` names the prompt's record, which `sdlc approve
|
|
116
|
+
* --from-prompt` looks up. The agent judges the prompt; the line says to record only with certainty.
|
|
117
|
+
*/
|
|
118
|
+
export function decisionReminder(waiting, promptKey) {
|
|
119
|
+
const { issue, action, phase, revision } = waiting;
|
|
120
|
+
const stage = revision === undefined ? phase : `${phase} (revision ${revision})`;
|
|
121
|
+
const decision = action === 'accept'
|
|
122
|
+
? "the owner's acceptance of the result"
|
|
123
|
+
: action === 'ran'
|
|
124
|
+
? "the owner's confirmation that they ran it"
|
|
125
|
+
: `the owner's ${action} of ${stage}`;
|
|
126
|
+
return (`sdlc: #${issue} waits for ${decision}, prompt key ${promptKey}. ` +
|
|
127
|
+
'Record it only if this prompt gives it without conditions and you are 100 % sure: ' +
|
|
128
|
+
`run \`sdlc approve ${issue} ${action} --from-prompt ${promptKey}\` with the owner's prompt text on stdin. ` +
|
|
129
|
+
`Otherwise record nothing; if the intent is unclear, ask the owner to write "${DECISION_WORD}" (or the same word in their language).`);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The line for a command that names no task while several wait for the owner: nothing is recorded,
|
|
133
|
+
* and the agent asks which one. The example names the last task, in the action it waits for.
|
|
134
|
+
*/
|
|
135
|
+
export function severalWaiting(waiting) {
|
|
136
|
+
const list = waiting.map(({ issue, action, phase }) => `#${issue} ${action} ${phase}`).join(', ');
|
|
137
|
+
const last = waiting.at(-1);
|
|
138
|
+
const example = last === undefined ? '' : `, e.g. "/${last.action} ${last.issue}" or "${DECISION_WORD} #${last.issue}"`;
|
|
139
|
+
return `sdlc: several tasks wait for the owner (${list}); ask which one${example}.`;
|
|
140
|
+
}
|
package/dist/install/apply.js
CHANGED
|
@@ -377,7 +377,15 @@ export function planUninstall(fs, manifest) {
|
|
|
377
377
|
}
|
|
378
378
|
// --- applyPlan ------------------------------------------------------------------------------------
|
|
379
379
|
/** Directories the kit may have created; an empty one below (or at) these is removed with its files. */
|
|
380
|
-
const PRUNABLE_ROOTS = [
|
|
380
|
+
const PRUNABLE_ROOTS = [
|
|
381
|
+
'.claude/agents',
|
|
382
|
+
'.claude/skills',
|
|
383
|
+
'.codex/agents',
|
|
384
|
+
'.gemini/agents',
|
|
385
|
+
'.gemini/commands',
|
|
386
|
+
'.agents/skills',
|
|
387
|
+
'.sdlc',
|
|
388
|
+
];
|
|
381
389
|
const parentOf = (path) => path.slice(0, Math.max(0, path.lastIndexOf('/')));
|
|
382
390
|
function pruneEmptyDirectories(fs, removedPaths) {
|
|
383
391
|
for (const path of removedPaths) {
|
package/dist/install/detect.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { basename, join } from 'node:path';
|
|
3
|
-
import { Document, isMap, isScalar, visit } from 'yaml';
|
|
3
|
+
import { Document, isMap, isScalar, parse as parseYaml, visit } from 'yaml';
|
|
4
4
|
import { BUILTIN_TYPES } from '../core/taskTypes.js';
|
|
5
5
|
import { ghJson, ghText } from '../github/gh.js';
|
|
6
6
|
import { packageVersion } from '../version.js';
|
|
7
7
|
const NO_HARNESS_NOTE = 'no harness files found; defaulting to claude';
|
|
8
8
|
const AGENTS_MD_NOTE = 'AGENTS.md found: choose codex or agents-md';
|
|
9
|
-
const NO_TARGETS_NOTE = 'no deploy
|
|
9
|
+
const NO_TARGETS_NOTE = 'no deploy or release target detected: feature/bugfix are off and every merged task goes straight to Done; ' +
|
|
10
|
+
'add a target if merged work reaches users only after a deploy or a release';
|
|
11
|
+
const releaseTargetNote = (name) => `target "${name}" waits for a published GitHub Release that contains the merge; ` +
|
|
12
|
+
'publish one for every version (a tag alone does not count)';
|
|
10
13
|
/** The script `npm init` writes; running it only fails. */
|
|
11
14
|
const NPM_PLACEHOLDER_TEST = /no test specified/i;
|
|
12
15
|
const DEPLOY_ENDING_TYPES = ['feature', 'bugfix'];
|
|
@@ -42,8 +45,11 @@ const isDeployWorkflow = (workflow) => /^deploy/i.test(workflowStem(workflow));
|
|
|
42
45
|
* several workflows goes to the deploy workflow when there is one, else the first. The name is the
|
|
43
46
|
* workflow file name without `deploy-`, else the environment name; a name already taken falls back
|
|
44
47
|
* to the environment name, then gets a number.
|
|
48
|
+
*
|
|
49
|
+
* Then one `release` target per release name, from workflows that gave no environment target (those
|
|
50
|
+
* count through their deployments). Its name and environment get a number when already taken.
|
|
45
51
|
*/
|
|
46
|
-
function deriveTargets(entries, notes) {
|
|
52
|
+
function deriveTargets(entries, releases, notes) {
|
|
47
53
|
const workflowsByEnvironment = new Map();
|
|
48
54
|
for (const { workflow, environment } of entries) {
|
|
49
55
|
const workflows = workflowsByEnvironment.get(environment) ?? [];
|
|
@@ -53,14 +59,7 @@ function deriveTargets(entries, notes) {
|
|
|
53
59
|
}
|
|
54
60
|
const taken = new Set();
|
|
55
61
|
const targets = [];
|
|
56
|
-
|
|
57
|
-
const workflow = workflows.find(isDeployWorkflow) ?? workflows[0];
|
|
58
|
-
if (workflows.length > 1) {
|
|
59
|
-
notes.push(`environment "${environment}" is used by several workflows (${workflows.join(', ')}); using ${workflow}`);
|
|
60
|
-
}
|
|
61
|
-
const stem = workflowStem(workflow);
|
|
62
|
-
const fromWorkflow = /^deploy-/i.test(stem) ? slugify(stem.slice('deploy-'.length)) : '';
|
|
63
|
-
const candidates = [fromWorkflow, slugify(environment)].filter(name => name !== '');
|
|
62
|
+
const freeName = (candidates) => {
|
|
64
63
|
let name = candidates.find(candidate => !taken.has(candidate));
|
|
65
64
|
if (name === undefined) {
|
|
66
65
|
const base = candidates[0] ?? 'target';
|
|
@@ -70,15 +69,50 @@ function deriveTargets(entries, notes) {
|
|
|
70
69
|
name = `${base}-${n}`;
|
|
71
70
|
}
|
|
72
71
|
taken.add(name);
|
|
72
|
+
return name;
|
|
73
|
+
};
|
|
74
|
+
for (const [environment, workflows] of workflowsByEnvironment) {
|
|
75
|
+
const workflow = workflows.find(isDeployWorkflow) ?? workflows[0];
|
|
76
|
+
if (workflows.length > 1) {
|
|
77
|
+
notes.push(`environment "${environment}" is used by several workflows (${workflows.join(', ')}); using ${workflow}`);
|
|
78
|
+
}
|
|
79
|
+
const stem = workflowStem(workflow);
|
|
80
|
+
const fromWorkflow = /^deploy-/i.test(stem) ? slugify(stem.slice('deploy-'.length)) : '';
|
|
81
|
+
const candidates = [fromWorkflow, slugify(environment)].filter(name => name !== '');
|
|
82
|
+
const name = freeName(candidates);
|
|
73
83
|
targets.push({ name, environment, deploy: { via: 'actions', workflow } });
|
|
74
84
|
}
|
|
85
|
+
// A workflow that names an environment already counts through its deployments there.
|
|
86
|
+
const deployWorkflows = new Set(targets.flatMap(t => (t.deploy.via === 'actions' ? [t.deploy.workflow] : [])));
|
|
87
|
+
const takenEnvironments = new Set(targets.map(t => t.environment));
|
|
88
|
+
const workflowsByRelease = new Map();
|
|
89
|
+
for (const { workflow, name } of releases) {
|
|
90
|
+
if (deployWorkflows.has(workflow))
|
|
91
|
+
continue;
|
|
92
|
+
const workflows = workflowsByRelease.get(name) ?? [];
|
|
93
|
+
if (!workflows.includes(workflow))
|
|
94
|
+
workflows.push(workflow);
|
|
95
|
+
workflowsByRelease.set(name, workflows);
|
|
96
|
+
}
|
|
97
|
+
for (const [release, workflows] of workflowsByRelease) {
|
|
98
|
+
if (workflows.length > 1) {
|
|
99
|
+
notes.push(`release target "${release}" is published by several workflows (${workflows.join(', ')})`);
|
|
100
|
+
}
|
|
101
|
+
const name = freeName([release]);
|
|
102
|
+
let environment = name;
|
|
103
|
+
for (let n = 2; takenEnvironments.has(environment); n += 1)
|
|
104
|
+
environment = `${name}-${n}`;
|
|
105
|
+
takenEnvironments.add(environment);
|
|
106
|
+
targets.push({ name, environment, deploy: { via: 'release' } });
|
|
107
|
+
notes.push(releaseTargetNote(name));
|
|
108
|
+
}
|
|
75
109
|
return targets;
|
|
76
110
|
}
|
|
77
111
|
/** Suggests a `sdlc.config.yaml` from what the repository already has. Pure. */
|
|
78
112
|
export function detectConfig(probe) {
|
|
79
113
|
const notes = [];
|
|
80
114
|
const harnesses = detectHarnesses(probe.files, notes);
|
|
81
|
-
const targets = deriveTargets(probe.workflowEnvironments, notes);
|
|
115
|
+
const targets = deriveTargets(probe.workflowEnvironments, probe.releaseWorkflows, notes);
|
|
82
116
|
const testScript = probe.packageScripts.test;
|
|
83
117
|
const qualityGate = testScript !== undefined && !NPM_PLACEHOLDER_TEST.test(testScript) ? ['npm test'] : [];
|
|
84
118
|
let enabled = BUILTIN_TYPES.map(type => type.id);
|
|
@@ -173,6 +207,57 @@ export function scanWorkflowEnvironments(text) {
|
|
|
173
207
|
});
|
|
174
208
|
return found;
|
|
175
209
|
}
|
|
210
|
+
/** Publish commands, in order of preference: a registry wins over a bare GitHub Release. */
|
|
211
|
+
const PUBLISHERS = [
|
|
212
|
+
['npm', /\b(?:npm|pnpm) publish\b|\byarn npm publish\b/],
|
|
213
|
+
['pypi', /\btwine upload\b|pypa\/gh-action-pypi-publish/],
|
|
214
|
+
['crates', /\bcargo publish\b/],
|
|
215
|
+
['release', /\bgh release create\b|softprops\/action-gh-release|goreleaser/],
|
|
216
|
+
];
|
|
217
|
+
/** Whether a workflow's `on:` value includes a tag push or a release. */
|
|
218
|
+
function triggersOnRelease(on) {
|
|
219
|
+
if (typeof on === 'string')
|
|
220
|
+
return on === 'release';
|
|
221
|
+
if (Array.isArray(on))
|
|
222
|
+
return on.includes('release');
|
|
223
|
+
if (typeof on !== 'object' || on === null)
|
|
224
|
+
return false;
|
|
225
|
+
const triggers = on;
|
|
226
|
+
if ('release' in triggers)
|
|
227
|
+
return true;
|
|
228
|
+
const push = triggers.push;
|
|
229
|
+
return typeof push === 'object' && push !== null && 'tags' in push;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The release target name for a workflow that publishes on a tag push or a release: `npm`, `pypi`,
|
|
233
|
+
* `crates`, or `release` for a GitHub Release alone. `undefined` when the workflow is not triggered
|
|
234
|
+
* that way, publishes nothing (comments and `--dry-run` lines do not count) or is not valid YAML.
|
|
235
|
+
*/
|
|
236
|
+
export function scanReleaseWorkflow(text) {
|
|
237
|
+
let doc;
|
|
238
|
+
try {
|
|
239
|
+
doc = parseYaml(text);
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
if (typeof doc !== 'object' || doc === null)
|
|
245
|
+
return undefined;
|
|
246
|
+
const root = doc;
|
|
247
|
+
// A YAML 1.1 reader turns the key `on` into `true`.
|
|
248
|
+
if (!triggersOnRelease(root.on ?? root.true))
|
|
249
|
+
return undefined;
|
|
250
|
+
const lines = text
|
|
251
|
+
.split(/\r?\n/)
|
|
252
|
+
.filter(line => !line.trimStart().startsWith('#'))
|
|
253
|
+
.map(line => line.replace(/\s#.*$/, ''))
|
|
254
|
+
.filter(line => !line.includes('--dry-run'));
|
|
255
|
+
for (const [name, pattern] of PUBLISHERS) {
|
|
256
|
+
if (lines.some(line => pattern.test(line)))
|
|
257
|
+
return name;
|
|
258
|
+
}
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
176
261
|
const MAX_DEPTH = 3;
|
|
177
262
|
const SKIPPED_DIRECTORIES = new Set(['.git', 'node_modules']);
|
|
178
263
|
/** Files and directories below `root`, at most `MAX_DEPTH` path segments deep; symlinks are listed, not followed. */
|
|
@@ -200,15 +285,16 @@ function listFiles(root) {
|
|
|
200
285
|
return paths;
|
|
201
286
|
}
|
|
202
287
|
const WORKFLOWS_DIR = '.github/workflows';
|
|
203
|
-
function
|
|
288
|
+
function readWorkflows(root) {
|
|
204
289
|
let names;
|
|
205
290
|
try {
|
|
206
291
|
names = readdirSync(join(root, WORKFLOWS_DIR)).filter(name => /\.ya?ml$/i.test(name)).sort();
|
|
207
292
|
}
|
|
208
293
|
catch {
|
|
209
|
-
return [];
|
|
294
|
+
return { workflowEnvironments: [], releaseWorkflows: [] };
|
|
210
295
|
}
|
|
211
296
|
const result = [];
|
|
297
|
+
const releaseWorkflows = [];
|
|
212
298
|
for (const name of names) {
|
|
213
299
|
let text;
|
|
214
300
|
try {
|
|
@@ -220,8 +306,11 @@ function readWorkflowEnvironments(root) {
|
|
|
220
306
|
for (const environment of scanWorkflowEnvironments(text)) {
|
|
221
307
|
result.push({ workflow: `${WORKFLOWS_DIR}/${name}`, environment });
|
|
222
308
|
}
|
|
309
|
+
const release = scanReleaseWorkflow(text);
|
|
310
|
+
if (release !== undefined)
|
|
311
|
+
releaseWorkflows.push({ workflow: `${WORKFLOWS_DIR}/${name}`, name: release });
|
|
223
312
|
}
|
|
224
|
-
return result;
|
|
313
|
+
return { workflowEnvironments: result, releaseWorkflows };
|
|
225
314
|
}
|
|
226
315
|
function readPackageScripts(root) {
|
|
227
316
|
try {
|
|
@@ -237,7 +326,7 @@ function readPackageScripts(root) {
|
|
|
237
326
|
}
|
|
238
327
|
/**
|
|
239
328
|
* Reads what `detectConfig` needs: the repository and the authenticated login from `gh` (the
|
|
240
|
-
* repository `gh` finds from the current directory), the file tree, the workflows' environments
|
|
329
|
+
* repository `gh` finds from the current directory), the file tree, the workflows' environments and release steps
|
|
241
330
|
* and the `package.json` scripts from `root`. Read-only.
|
|
242
331
|
*/
|
|
243
332
|
export async function probeRepo(run, root) {
|
|
@@ -256,7 +345,7 @@ export async function probeRepo(run, root) {
|
|
|
256
345
|
ownerType: view.isInOrganization ? 'org' : 'user',
|
|
257
346
|
login,
|
|
258
347
|
files: listFiles(root),
|
|
259
|
-
|
|
348
|
+
...readWorkflows(root),
|
|
260
349
|
packageScripts: readPackageScripts(root),
|
|
261
350
|
};
|
|
262
351
|
}
|
package/dist/outbox/outbox.js
CHANGED
|
@@ -40,13 +40,17 @@ export const QUEUEABLE_COMMANDS = [
|
|
|
40
40
|
];
|
|
41
41
|
/** Whether the command that runs, named as `stage publish`, may be queued. */
|
|
42
42
|
export const isQueueableCommandPath = (path) => QUEUEABLE_COMMANDS.some(words => words.join(' ') === path);
|
|
43
|
-
/**
|
|
44
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Options that never belong in a queued command line: another config, a shell command to run, output
|
|
45
|
+
* and dry-run modes, and `--from-prompt`, whose prompt text is on stdin (a replay has none) and which
|
|
46
|
+
* is only good while that prompt is the owner's latest: a replay later must not approve from it.
|
|
47
|
+
*/
|
|
48
|
+
const REFUSED_OPTIONS = ['--config', '--verify', '--json', '--dry-run', '--from-prompt'];
|
|
45
49
|
/**
|
|
46
50
|
* Whether `argv` is a command line `sdlc sync` may run: it starts with the words of a queueable
|
|
47
|
-
* command (no global option before them) and holds none of `--config`, `--verify`, `--json
|
|
48
|
-
* `--dry-run`, in either `--x v` or `--x=v` form. Sync checks every line with
|
|
49
|
-
* so a line written by hand cannot make it run anything else.
|
|
51
|
+
* command (no global option before them) and holds none of `--config`, `--verify`, `--json`,
|
|
52
|
+
* `--dry-run` and `--from-prompt`, in either `--x v` or `--x=v` form. Sync checks every line with
|
|
53
|
+
* this before it runs it, so a line written by hand cannot make it run anything else.
|
|
50
54
|
*/
|
|
51
55
|
export function isQueueableArgv(argv) {
|
|
52
56
|
if (!QUEUEABLE_COMMANDS.some(words => words.every((word, index) => argv[index] === word)))
|
|
@@ -3,6 +3,7 @@ import { builtinRoles } from './agents.js';
|
|
|
3
3
|
import { parseFrontMatter } from './frontMatter.js';
|
|
4
4
|
import { renderTemplate } from './template.js';
|
|
5
5
|
import { loadTemplate } from './templates.js';
|
|
6
|
+
import { tomlMultilineString, tomlString } from './toml.js';
|
|
6
7
|
/** The kit's name on the npm registry. */
|
|
7
8
|
export const KIT_PACKAGE = 'agentic-sdlc-kit';
|
|
8
9
|
const KIT_REPOSITORY = 'github:SobSoft-s-r-o/agentic-sdlc-kit';
|
|
@@ -107,6 +108,7 @@ export function renderData(cfg, roles = builtinRoles()) {
|
|
|
107
108
|
defaultBranch: cfg.github.defaultBranch,
|
|
108
109
|
types,
|
|
109
110
|
productionData: types.some(type => type.id === 'production-data'),
|
|
111
|
+
deployTypes: types.some(type => type.endsOn === 'deploy'),
|
|
110
112
|
targets: cfg.targets.map((target) => ({
|
|
111
113
|
name: target.name,
|
|
112
114
|
environment: target.environment,
|
|
@@ -147,9 +149,68 @@ function renderSkill(name, data) {
|
|
|
147
149
|
return text;
|
|
148
150
|
}
|
|
149
151
|
/**
|
|
150
|
-
* The
|
|
151
|
-
*
|
|
152
|
-
* and the same
|
|
152
|
+
* The owner commands whose typed line the prompt hook turns into a recorded decision (`parseOwnerCommand`). Claude Code
|
|
153
|
+
* swallows an unregistered `/word` as "Unknown command" before any hook sees it, so each is registered as a skill the
|
|
154
|
+
* model cannot invoke, and Gemini gets the same as a command. `/merge` stays a comment on a PR and is not one of them.
|
|
155
|
+
*/
|
|
156
|
+
const OWNER_COMMANDS = [
|
|
157
|
+
{
|
|
158
|
+
name: 'approve',
|
|
159
|
+
argumentHint: '[issue]',
|
|
160
|
+
description: 'Owner command: approve the result a task is waiting on, such as its design or its plan. Name the task with /approve 11.',
|
|
161
|
+
summary: 'The owner approves the result the task published and is waiting on. `/approve 11` names task 11; without a number the task of this session is meant.',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: 'accept',
|
|
165
|
+
argumentHint: '[issue]',
|
|
166
|
+
description: 'Owner command: accept the published result of a task that ends on your acceptance. Name the task with /accept 11.',
|
|
167
|
+
summary: 'The owner accepts the published result of a task that ends on acceptance. `/accept 11` names task 11; without a number the task of this session is meant.',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: 'ran',
|
|
171
|
+
argumentHint: '[issue]',
|
|
172
|
+
description: 'Owner command: confirm that you ran the script of a production-data task yourself. Name the task with /ran 11.',
|
|
173
|
+
summary: 'The owner confirms they ran the script of a production-data task. `/ran 11` names task 11; without a number the task of this session is meant.',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: 'cancel',
|
|
177
|
+
argumentHint: '<reason>',
|
|
178
|
+
description: 'Owner command: cancel the task of this session. Write the reason on the same line, after /cancel.',
|
|
179
|
+
summary: 'The owner cancels the task of this session. The rest of the line is the reason, as in `/cancel superseded by the new design`.',
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
/**
|
|
183
|
+
* The first line of an owner command's skill body: the command and Claude Code's `$ARGUMENTS`. If the harness hands the
|
|
184
|
+
* prompt hook the expanded skill instead of the typed line, its first line is still the owner's command line.
|
|
185
|
+
*/
|
|
186
|
+
const CLAUDE_COMMAND_LINE = /^\/[a-z]+ \$ARGUMENTS$/m;
|
|
187
|
+
/** `.claude/skills/<name>/SKILL.md` for Claude Code, `.gemini/commands/<name>.toml` for Gemini, nothing for the rest. */
|
|
188
|
+
function renderOwnerCommands(harness, data) {
|
|
189
|
+
if (harness !== 'claude' && harness !== 'gemini')
|
|
190
|
+
return [];
|
|
191
|
+
return OWNER_COMMANDS.map((def) => {
|
|
192
|
+
const markdown = renderTemplate(loadTemplate('owner-commands/command.md'), { ...data, command: def }, 'owner-commands/command.md');
|
|
193
|
+
if (harness === 'claude')
|
|
194
|
+
return { kind: 'file', path: `.claude/skills/${def.name}/SKILL.md`, content: markdown };
|
|
195
|
+
// The prompt is the body of the skill, so both harnesses tell the agent the same thing; only the first line, the
|
|
196
|
+
// command itself, takes the arguments in Gemini's form. Gemini puts `{{args}}` in raw, so the prompt hook reads the
|
|
197
|
+
// same command line whether it sees what the owner typed or the expanded prompt.
|
|
198
|
+
const body = parseFrontMatter(markdown).body.replace(CLAUDE_COMMAND_LINE, `/${def.name} {{args}}`);
|
|
199
|
+
const command = {
|
|
200
|
+
descriptionToml: tomlString(def.description),
|
|
201
|
+
promptToml: tomlMultilineString(body),
|
|
202
|
+
};
|
|
203
|
+
return {
|
|
204
|
+
kind: 'file',
|
|
205
|
+
path: `.gemini/commands/${def.name}.toml`,
|
|
206
|
+
content: renderTemplate(loadTemplate('owner-commands/command.toml'), { ...data, command }, 'owner-commands/command.toml'),
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The managed instruction block for `harness`'s instruction file, the three sdlc skills, and the owner commands of
|
|
212
|
+
* Claude Code and Gemini. The block does not depend on the harness, so Codex and `agents-md` render the same
|
|
213
|
+
* `AGENTS.md` block and the same skills (the same paths and text; deduplicate them by path). `_cfg` is part of the
|
|
153
214
|
* signature every renderer shares; the text comes from `data`.
|
|
154
215
|
*/
|
|
155
216
|
export function renderInstructions(_cfg, harness, data) {
|
|
@@ -158,5 +219,6 @@ export function renderInstructions(_cfg, harness, data) {
|
|
|
158
219
|
// The merge writes the markers around a body without trailing newlines.
|
|
159
220
|
{ kind: 'md-block', path: INSTRUCTION_FILE[harness], content: block.replace(/\n+$/, '') },
|
|
160
221
|
...SKILLS.map((name) => ({ kind: 'file', path: `${SKILL_DIR[harness]}/${name}/SKILL.md`, content: renderSkill(name, data) })),
|
|
222
|
+
...renderOwnerCommands(harness, data),
|
|
161
223
|
];
|
|
162
224
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-sdlc-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Track agentic SDLC tasks on GitHub Issues and Projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"author": "SobSoft s.r.o.",
|
|
6
|
+
"author": "SobSoft s.r.o. (https://sobsoft.sk)",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/SobSoft-s-r-o/agentic-sdlc-kit.git"
|
|
@@ -14,6 +14,9 @@ Work is tracked with the `sdlc` CLI as GitHub issues on a Projects board, and th
|
|
|
14
14
|
|
|
15
15
|
### Starting work
|
|
16
16
|
- New work request: run `sdlc task new --type <id> --title "<title>" --summary "<one line>"` before any brainstorming, diagnosis or edit. Propose the type; the owner can correct it (`sdlc task set-type`). An existing issue is adopted with `sdlc task new --issue <n> --type <id>`.
|
|
17
|
+
{{#if deployTypes}}
|
|
18
|
+
- Work that reaches users (code, a package, an app) is a type that ends on a deploy, such as `feature` or `bugfix`: after the merge it waits as Awaiting deployment until its targets are deployed or released. Use `tooling` only for changes that never ship (CI, repository setup, dev scripts).
|
|
19
|
+
{{/if}}
|
|
17
20
|
- Status question: answer it (`sdlc status`); create no task.
|
|
18
21
|
- Continuation of tracked work: stay in the same task and issue; never open a second one.
|
|
19
22
|
|
|
@@ -23,9 +26,11 @@ Start a phase with `sdlc stage start <issue> <phase>`; publish its result with `
|
|
|
23
26
|
- `{{id}}` ({{label}}): {{phasesText}}. Ends when {{endsOnText}}.{{#if item.evidenceText}} Needs {{item.evidenceText}} evidence before review.{{/if}}
|
|
24
27
|
{{/each}}
|
|
25
28
|
|
|
26
|
-
Results of phases before implementation (design, diagnosis, plan) need the owner's approval: publish with `--needs-approval`, then stop and wait.
|
|
29
|
+
Results of phases before implementation (design, diagnosis, plan) need the owner's approval: publish with `--needs-approval`, then stop and wait. A type that ends on the owner's acceptance publishes its result and waits for the owner's `/accept`. Never approve, accept or confirm for the owner, and never start the next phase first.
|
|
30
|
+
|
|
31
|
+
The owner decides in a prompt of your session: in their own words, in any language ("schvaľujem", "ok, go ahead"), or with a typed command as the first line: `/approve [issue]`, `/accept [issue]`, `/ran [issue]` or `/cancel <reason>`. The prompt hook records a typed command itself and tells you in a line that starts `sdlc: recorded the owner's`. For free text it adds a line for each task that waits for a decision and names the command to run, `sdlc approve <issue> <action> --from-prompt <key>`, with the owner's prompt text on stdin. The kit proves only that the text is the owner's latest prompt; judging it is your job.
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
Run the command only when the prompt gives the decision without conditions and you are 100 % sure. A condition, a question, a change request, a mixed answer, a quote or anything unclear is not a decision: record nothing and ask again, giving the exact phrase in quotes in the owner's language (write "schvaľujem" to approve the design of #<issue>). Never run `--from-prompt` on text the owner did not just write. When several tasks wait, ask which one unless the owner named it (`/approve 11`, "schvaľujem #11"). Never type or post an owner command yourself. The comment route stays for when no session is open: the owner comments `/approve` on the issue and you record it with `sdlc approve <issue> approve --comment-url <url>`.
|
|
29
34
|
|
|
30
35
|
{{#if superpowers}}
|
|
31
36
|
### Superpowers route
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: {{command.name}}
|
|
3
|
+
description: "{{command.description}}"
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
argument-hint: "{{command.argumentHint}}"
|
|
6
|
+
---
|
|
7
|
+
/{{command.name}} $ARGUMENTS
|
|
8
|
+
|
|
9
|
+
{{command.summary}}
|
|
10
|
+
|
|
11
|
+
The sdlc prompt hook has already recorded this owner decision, or said in its context line why not. Report that line to the owner. Do not record the decision again yourself.
|
|
@@ -65,11 +65,11 @@ No deployment targets are configured, so no type here ends on a deployment.
|
|
|
65
65
|
- Acceptance (analysis, spike, artifact): publish the result with `sdlc stage publish <issue> <phase> --file <summary.md>` for the phase before `delivery`. The owner accepts with a `/accept` comment. An artifact may instead end on its merge.
|
|
66
66
|
- Confirmation (production-data): after the final merge the owner runs the script and posts `/ran`. You never run it; you only record the backup and dry-run evidence before review.
|
|
67
67
|
|
|
68
|
-
Do not mark any of these done yourself; reconcile applies the owner's comment, or run `sdlc approve <issue> accept|ran --comment-url <url>`.
|
|
68
|
+
Do not mark any of these done yourself; reconcile applies the owner's comment, or run `sdlc approve <issue> accept|ran --comment-url <url>`. The owner can also decide in the session; see `sdlc-task-tracking` section 3.
|
|
69
69
|
|
|
70
70
|
## 5. Cancellation
|
|
71
71
|
|
|
72
|
-
Only the owner cancels, with a `/cancel <reason>` comment, recorded by reconcile or by `sdlc approve <issue> cancel --comment-url <url>`. It posts a cancel report, sets Done with the reason and closes the issue as not planned. Then stop work, leave open PRs to the owner's call, and ask the owner before discarding unmerged work. Remove the worktree only with `git worktree remove` (no force) and the branch only with `git branch -d`; if either is refused, say so.
|
|
72
|
+
Only the owner cancels, with a `/cancel <reason>` comment, recorded by reconcile or by `sdlc approve <issue> cancel --comment-url <url>`. It posts a cancel report, sets Done with the reason and closes the issue as not planned. Then stop work, leave open PRs to the owner's call, and ask the owner before discarding unmerged work. Remove the worktree only with `git worktree remove` (no force) and the branch only with `git branch -d`; if either is refused, say so. The owner can also decide in the session; see `sdlc-task-tracking` section 3.
|
|
73
73
|
|
|
74
74
|
## 6. After Done
|
|
75
75
|
|
|
@@ -47,13 +47,53 @@ sdlc stage publish <issue> <phase> --file <summary.md> [--needs-approval]
|
|
|
47
47
|
|
|
48
48
|
## 3. Owner decisions
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
The owner decides in one of three ways. Whichever it is, never approve, accept, confirm or cancel for the owner.
|
|
51
|
+
|
|
52
|
+
- In their own words in a prompt of your session, in any language ("schvaľujem", "ok, go ahead"). You judge it and record it with `--from-prompt` (below).
|
|
53
|
+
- With a typed command as the first non-empty line of a prompt: `/approve [issue]`, `/accept [issue]`, `/ran [issue]` or `/cancel <reason>` (a quoted command, or one further down, is not one). The installer registers the four as Claude Code skills and Gemini CLI commands so that the line reaches the hook, and a leading space is fine. The prompt hook records it.
|
|
54
|
+
- In a comment on the issue or on its PR, for when no session is open.
|
|
55
|
+
|
|
56
|
+
`approve` approves a published phase (default: the current one), `accept` accepts the published result of an analysis, spike or artifact, `ran` confirms the owner ran a production-data script, `cancel` ends the task.
|
|
57
|
+
|
|
58
|
+
### Typed command
|
|
59
|
+
|
|
60
|
+
The prompt hook records `/approve`, `/accept`, `/ran` (an issue number may follow: `/approve 11`) and `/cancel <reason>`, and tells you with a line that starts `sdlc: recorded the owner's`. This is how the owner decides when `sdlc` acts under the owner's own login, where a comment would be refused. The task is the one the command names, else the one of the branch, else the one task that waits for a decision. Words after the number are ignored; a number the hook cannot read (`/approve 11a`) records nothing, and the hook asks for it again. When several wait, nothing is recorded: the hook's line lists them and you ask which one. The owner answers `/approve 11`, or with words such as "schvaľujem #11". The hook never picks a task for `/cancel <reason>` from the board, because cancelling a guessed task is destructive: it needs the task of the branch. `/approve` covers the current phase; `/approve type <id>` needs a comment.
|
|
61
|
+
|
|
62
|
+
- Only the prompt hook records typed commands. Never type, quote or post an owner command, and never run `sdlc hook` or `.sdlc/hooks/run.sh`: that is a hook spoof, blocked in every mode.
|
|
63
|
+
- The prompt log, `.sdlc/cache/prompts.jsonl`, keeps hashes of prompts, never their text. A prompt delivered twice is one approval (Claude Code, Codex; Gemini has no prompt id).
|
|
64
|
+
- If the hook says it did not record the approval (no task, GitHub unreachable, several owners), tell the owner what it printed. If it says the approval may or may not have been recorded, run `sdlc status` before you ask again.
|
|
65
|
+
|
|
66
|
+
### Free text: `--from-prompt`
|
|
67
|
+
|
|
68
|
+
On a human prompt that is not a typed command, the hook adds one line for each task that waits for the owner's decision: `sdlc: #<issue> waits for the owner's approve of <phase>, prompt key <key>. ...` (for a result: "the owner's acceptance of the result"; for a merged production-data task: "the owner's confirmation that they ran it"). On a task branch it looks at that branch's task only; on any other branch, the default branch included, it reads the board. The action is `approve` for a phase that waits for approval, `accept` for a result that waits for acceptance and `ran` for a merged production-data task. Gemini has no prompt id: its key is the time of the prompt record. To record the decision, give the owner's prompt on stdin:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
sdlc approve <issue> <action> --from-prompt <key> <<'SDLC_PROMPT'
|
|
72
|
+
<the owner's prompt, as they wrote it>
|
|
73
|
+
SDLC_PROMPT
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Pick a delimiter that does not occur in the owner's text (`SDLC_PROMPT` here); if the text holds it, choose another, or the shell cuts the prompt short and the proof fails.
|
|
77
|
+
|
|
78
|
+
Run it only when the owner's latest prompt gives the decision without conditions and you are 100 % sure. A condition ("ok, but change X"), a question, a change request, a mixed answer, a quote or anything unclear is not a decision: record nothing and ask again, giving the exact phrase in quotes in the owner's language (for example: write "schvaľujem" to approve the design of #<issue>). Never put words in the owner's mouth, and never run `--from-prompt` on text the owner did not just write.
|
|
79
|
+
|
|
80
|
+
What the kit checks and records:
|
|
81
|
+
|
|
82
|
+
- It cannot read intent. It proves that the text is the owner's latest prompt of the session, as the hook recorded it for a human (not a subagent): the normalised hash matches, no later prompt of that session exists, it is later than what it decides (the publish; for `ran`, the merge) and it is not recorded yet. A refusal names what failed. Do not work around it: ask the owner to write the short phrase again.
|
|
83
|
+
- It records the decision with the source `prompt-judged` (you judged the intent; `prompt` is a command the hook matched) and posts a comment that quotes the owner: the first 280 characters of the normalised text (NFC, trailing whitespace trimmed, `@` is neutralised and `<` escaped), as a blockquote. A text that may hold a secret is replaced by "quote withheld", and the decision is still recorded.
|
|
84
|
+
- One prompt can record decisions on several tasks, and nothing but your judgment stops it: record only on the task the owner meant, and ask when it is not clear.
|
|
85
|
+
- A cancel by prompt (`sdlc approve <issue> cancel --reason "<why>" --from-prompt <key>`) must be newer than the first time the task records and than any reopen; a task that records no time yet is cancelled with `--comment-url`. The reminder never offers a cancel, so the typed `/cancel <reason>` is the usual way.
|
|
86
|
+
- `approve --from-prompt` is never queued for `sdlc sync`: its text is on stdin and a replay has none. When GitHub is unreachable it fails; run it again later, while the prompt is still the owner's latest.
|
|
87
|
+
|
|
88
|
+
### Comment
|
|
89
|
+
|
|
90
|
+
An owner decides by a comment whose first line is the command, on the issue or on its PR. Only these logins count as the owner:
|
|
51
91
|
|
|
52
92
|
{{#each cfg.owners}}
|
|
53
93
|
- `{{.}}`
|
|
54
94
|
{{/each}}
|
|
55
95
|
|
|
56
|
-
A login listed under `agents`, and your own, never counts. The comment must be newer than what it decides on and must not be edited afterwards. `sdlc reconcile` applies such comments by itself, and the installed hooks and workflow run it where there are any. To record one explicitly:
|
|
96
|
+
A login listed under `agents`, and your own, never counts. The comment must be newer than what it decides on and must not be edited afterwards. Only the `/approve` syntax is read there, not free text: `reconcile` runs with no agent to judge intent. `sdlc reconcile` applies such comments by itself, and the installed hooks and workflow run it where there are any. To record one explicitly:
|
|
57
97
|
|
|
58
98
|
```
|
|
59
99
|
sdlc approve <issue> approve [--phase <phase>] --comment-url <url>
|
|
@@ -62,15 +102,7 @@ sdlc approve <issue> ran --comment-url <url>
|
|
|
62
102
|
sdlc approve <issue> cancel --reason "<why>" --comment-url <url>
|
|
63
103
|
```
|
|
64
104
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
### Approval typed in a prompt
|
|
68
|
-
|
|
69
|
-
The owner may give the command as the first non-empty line of a prompt in your session: `/approve`, `/accept`, `/ran` or `/cancel <reason>` (a quoted command, or one further down, is not one). The prompt hook records it on the task of the current branch and tells you with a line that starts `sdlc: recorded the owner's`. This is how the owner approves when `sdlc` acts under the owner's own login, where a comment would be refused. `/approve` covers the current phase; `/approve type <id>` needs a comment.
|
|
70
|
-
|
|
71
|
-
- Only the prompt hook records these. Never type, quote or post an owner command, and never run `sdlc hook` or `.sdlc/hooks/run.sh`: that is a hook spoof, blocked in every mode.
|
|
72
|
-
- The prompt text is not stored, only its hash. A prompt delivered twice is one approval (Claude Code, Codex; Gemini has no prompt id).
|
|
73
|
-
- If the hook says it did not record the approval (no task on the branch, GitHub unreachable, several owners), tell the owner what it printed and ask for a comment.
|
|
105
|
+
Never post the comment yourself, and never record an approval the owner did not give; `--unverified` exists only for observe mode and marks the record unverified.
|
|
74
106
|
|
|
75
107
|
## 4. Evidence before review
|
|
76
108
|
|