@warnyin/sdlc 0.8.0 → 0.9.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/CHANGELOG.md +274 -258
- package/LICENSE +21 -21
- package/README.md +92 -92
- package/bin/cli.mjs +682 -682
- package/lib/active.mjs +199 -199
- package/lib/caps.mjs +46 -46
- package/lib/config.mjs +41 -41
- package/lib/delta.mjs +227 -227
- package/lib/frontmatter.mjs +59 -59
- package/lib/glob.mjs +29 -29
- package/lib/lenses.mjs +48 -48
- package/lib/manifest.mjs +99 -99
- package/lib/settings-merge.mjs +63 -63
- package/lib/skills.mjs +148 -148
- package/lib/validate.mjs +198 -198
- package/package.json +42 -42
- package/payload/adapters/agents-md.md +8 -8
- package/payload/adapters/claude/agents/sdlc-architect.md +12 -12
- package/payload/adapters/claude/agents/sdlc-builder.md +14 -14
- package/payload/adapters/claude/agents/sdlc-contractor.md +13 -13
- package/payload/adapters/claude/agents/sdlc-evaluator.md +13 -13
- package/payload/adapters/claude/agents/sdlc-learner.md +16 -16
- package/payload/adapters/claude/agents/sdlc-ops.md +11 -11
- package/payload/adapters/claude/agents/sdlc-quality.md +13 -13
- package/payload/adapters/claude/agents/sdlc-security.md +12 -12
- package/payload/adapters/claude/commands/sdlc/converge.md +5 -5
- package/payload/adapters/claude/commands/sdlc/init.md +4 -4
- package/payload/adapters/claude/commands/sdlc/next.md +4 -4
- package/payload/adapters/claude/commands/sdlc/observe.md +4 -4
- package/payload/adapters/claude/commands/sdlc/steer.md +4 -4
- package/payload/adapters/claude/skills/contract-writing/SKILL.md +26 -26
- package/payload/adapters/claude/skills/delta-spec-format/SKILL.md +36 -36
- package/payload/adapters/claude/skills/sdlc-conventions/SKILL.md +30 -30
- package/payload/adapters/cline.md +8 -8
- package/payload/adapters/copilot.md +8 -8
- package/payload/adapters/cursor.mdc +7 -7
- package/payload/adapters/gemini.md +8 -8
- package/payload/adapters/windsurf.md +4 -4
- package/payload/hooks/_shared.mjs +138 -138
- package/payload/hooks/guard-writes.mjs +87 -87
- package/payload/hooks/inject-context.mjs +57 -57
- package/payload/hooks/journal.mjs +66 -66
- package/payload/hooks/session-summary.mjs +52 -52
- package/payload/hooks/validate-artifact.mjs +84 -84
- package/payload/playbook/README.md +32 -32
- package/payload/playbook/context.md +26 -26
- package/payload/playbook/contract.md +29 -29
- package/payload/playbook/converge.md +19 -19
- package/payload/playbook/design.md +28 -28
- package/payload/playbook/init.md +22 -22
- package/payload/playbook/lenses.md +64 -64
- package/payload/playbook/new.md +41 -33
- package/payload/playbook/next.md +24 -24
- package/payload/playbook/observe.md +20 -20
- package/payload/playbook/principles.md +28 -28
- package/payload/playbook/review.md +31 -31
- package/payload/playbook/routing.md +19 -19
- package/payload/playbook/rules-card.md +17 -16
- package/payload/playbook/ship.md +35 -35
- package/payload/playbook/steer.md +21 -21
- package/payload/playbook/verify.md +42 -42
- package/payload/templates/change-deep.md +29 -29
- package/payload/templates/change-standard.md +28 -28
- package/payload/templates/change-vibe.md +19 -19
- package/payload/templates/config.yaml +8 -8
- package/payload/templates/constitution.md +14 -14
- package/payload/templates/contract-evals.md +9 -9
- package/payload/templates/contract-tests.md +9 -9
- package/payload/templates/harness.md +34 -34
- package/payload/templates/spec.md +14 -14
- package/payload/templates/steering.md +9 -9
- package/scripts/validate.mjs +47 -47
package/lib/skills.mjs
CHANGED
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
// Skill/agent inventory — what expertise is already installed for this project and user.
|
|
2
|
-
// Used by: CLI (`warnyin-sdlc skills`), which the opening playbook reads to resolve lenses.
|
|
3
|
-
//
|
|
4
|
-
// Skill files are third-party content, so the inventory is deliberately shallow: it reads a
|
|
5
|
-
// bounded prefix of each file, keeps only frontmatter `name` + `description`, and never
|
|
6
|
-
// emits body text. Project entries whose real location leaves the project are skipped (a
|
|
7
|
-
// repo can ship a link); the user's own home may link wherever the user put their skills.
|
|
8
|
-
|
|
9
|
-
import fs from 'node:fs';
|
|
10
|
-
import os from 'node:os';
|
|
11
|
-
import path from 'node:path';
|
|
12
|
-
import { parseFrontmatter } from './frontmatter.mjs';
|
|
13
|
-
import { containedIn } from './manifest.mjs';
|
|
14
|
-
import { SKILL_NAME_RE } from './lenses.mjs';
|
|
15
|
-
|
|
16
|
-
export { SKILL_NAME_RE };
|
|
17
|
-
export const INVENTORY_CEILING = 200;
|
|
18
|
-
// Per-directory bound on how many candidates are opened at all: a checked-out repo can plant
|
|
19
|
-
// thousands of folders, and the ceiling alone would still pay to read every one of them.
|
|
20
|
-
export const SCAN_LIMIT_PER_DIR = 1000;
|
|
21
|
-
export const DESCRIPTION_MAX = 160;
|
|
22
|
-
export const READ_PREFIX_BYTES = 8 * 1024;
|
|
23
|
-
|
|
24
|
-
const KINDS = Object.freeze(['skill', 'agent']);
|
|
25
|
-
// Built from code points so the source file itself carries no invisible characters: C0, DEL,
|
|
26
|
-
// C1, zero-width and bidi marks/overrides, line/paragraph separators, BOM — anything that
|
|
27
|
-
// can move a terminal cursor or visually reorder the line a human or model reads.
|
|
28
|
-
const cp = (n) => String.fromCharCode(n);
|
|
29
|
-
const CONTROL_CHARS = new RegExp(
|
|
30
|
-
`[${cp(0)}-${cp(0x1f)}${cp(0x7f)}-${cp(0x9f)}${cp(0x200b)}-${cp(0x200f)}${cp(0x2028)}-${cp(0x202e)}${cp(0x2066)}-${cp(0x2069)}${cp(0xfeff)}]+`,
|
|
31
|
-
'g');
|
|
32
|
-
const LEADING_BOM = new RegExp(`^${String.fromCharCode(0xfeff)}`);
|
|
33
|
-
|
|
34
|
-
// Reads at most READ_PREFIX_BYTES; a frontmatter that does not close inside that prefix is
|
|
35
|
-
// treated as absent rather than read further. The open is non-blocking where the platform
|
|
36
|
-
// has it, and the descriptor itself must be a regular file, so a FIFO or device swapped in
|
|
37
|
-
// after the earlier checks can neither hang nor feed the read.
|
|
38
|
-
function readPrefix(file) {
|
|
39
|
-
let fd;
|
|
40
|
-
try {
|
|
41
|
-
fd = fs.openSync(file, fs.constants.O_RDONLY | (fs.constants.O_NONBLOCK ?? 0));
|
|
42
|
-
if (!fs.fstatSync(fd).isFile()) return null;
|
|
43
|
-
const buf = Buffer.alloc(READ_PREFIX_BYTES);
|
|
44
|
-
const n = fs.readSync(fd, buf, 0, READ_PREFIX_BYTES, 0);
|
|
45
|
-
return buf.subarray(0, n).toString('utf8').replace(LEADING_BOM, '');
|
|
46
|
-
} catch {
|
|
47
|
-
return null;
|
|
48
|
-
} finally {
|
|
49
|
-
if (fd !== undefined) fs.closeSync(fd);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// One line, no control characters (terminal escapes included), cut with a visible marker.
|
|
54
|
-
export function cleanDescription(raw) {
|
|
55
|
-
const flat = String(raw).replace(CONTROL_CHARS, ' ').replace(/\s+/g, ' ').trim();
|
|
56
|
-
if (flat.length <= DESCRIPTION_MAX) return { description: flat, truncated: false };
|
|
57
|
-
return { description: `${flat.slice(0, DESCRIPTION_MAX - 1).trimEnd()}…`, truncated: true };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function readEntry(file) {
|
|
61
|
-
const text = readPrefix(file);
|
|
62
|
-
if (text === null) return null;
|
|
63
|
-
const { data } = parseFrontmatter(text);
|
|
64
|
-
const name = typeof data.name === 'string' ? data.name.trim() : '';
|
|
65
|
-
if (!SKILL_NAME_RE.test(name)) return null;
|
|
66
|
-
if (typeof data.description !== 'string' || data.description.trim() === '') return null;
|
|
67
|
-
return { name, ...cleanDescription(data.description) };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function isInside(rootReal, target) {
|
|
71
|
-
try {
|
|
72
|
-
return containedIn(rootReal, fs.realpathSync.native(target));
|
|
73
|
-
} catch {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// The first SCAN_LIMIT_PER_DIR names (sorted), and how many were left unopened.
|
|
79
|
-
function listDir(dir) {
|
|
80
|
-
let names;
|
|
81
|
-
try {
|
|
82
|
-
names = fs.readdirSync(dir).sort();
|
|
83
|
-
} catch {
|
|
84
|
-
return { names: [], unscanned: 0 };
|
|
85
|
-
}
|
|
86
|
-
return { names: names.slice(0, SCAN_LIMIT_PER_DIR), unscanned: Math.max(0, names.length - SCAN_LIMIT_PER_DIR) };
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function isFile(p) {
|
|
90
|
-
try { return fs.statSync(p).isFile(); } catch { return false; }
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Candidate files for one `.claude` root, each paired with every path that must stay contained.
|
|
94
|
-
function candidates(claudeDir, kind) {
|
|
95
|
-
if (kind === 'skill') {
|
|
96
|
-
const skillsDir = path.join(claudeDir, 'skills');
|
|
97
|
-
const { names, unscanned } = listDir(skillsDir);
|
|
98
|
-
const items = names.map((d) => {
|
|
99
|
-
const folder = path.join(skillsDir, d);
|
|
100
|
-
const file = path.join(folder, 'SKILL.md');
|
|
101
|
-
return { file, checks: [folder, file] };
|
|
102
|
-
});
|
|
103
|
-
return { items, unscanned };
|
|
104
|
-
}
|
|
105
|
-
const agentsDir = path.join(claudeDir, 'agents');
|
|
106
|
-
const { names, unscanned } = listDir(agentsDir);
|
|
107
|
-
const items = names
|
|
108
|
-
.filter((f) => f.endsWith('.md'))
|
|
109
|
-
.map((f) => ({ file: path.join(agentsDir, f), checks: [path.join(agentsDir, f)] }));
|
|
110
|
-
return { items, unscanned };
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function scanRoot(claudeDir, source, containRoot) {
|
|
114
|
-
const entries = [];
|
|
115
|
-
let unscanned = 0;
|
|
116
|
-
for (const kind of KINDS) {
|
|
117
|
-
const found = candidates(claudeDir, kind);
|
|
118
|
-
unscanned += found.unscanned;
|
|
119
|
-
for (const { file, checks } of found.items) {
|
|
120
|
-
if (containRoot && !checks.every((c) => isInside(containRoot, c))) continue;
|
|
121
|
-
if (!isFile(file)) continue;
|
|
122
|
-
const entry = readEntry(file);
|
|
123
|
-
if (entry) entries.push({ source, kind, ...entry });
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
entries.sort((a, b) => KINDS.indexOf(a.kind) - KINDS.indexOf(b.kind) || a.name.localeCompare(b.name));
|
|
127
|
-
return { entries, unscanned };
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function scanInventory(projectRoot, { home = os.homedir() } = {}) {
|
|
131
|
-
let projectReal = null;
|
|
132
|
-
try { projectReal = fs.realpathSync.native(projectRoot); } catch { /* unreadable root → no project entries */ }
|
|
133
|
-
const none = { entries: [], unscanned: 0 };
|
|
134
|
-
const project = projectReal ? scanRoot(path.join(projectRoot, '.claude'), 'project', projectReal) : none;
|
|
135
|
-
const user = home ? scanRoot(path.join(home, '.claude'), 'user', null) : none;
|
|
136
|
-
const all = [...project.entries, ...user.entries];
|
|
137
|
-
// `omitted` = valid entries past the ceiling + candidates never opened (scan limit).
|
|
138
|
-
return {
|
|
139
|
-
entries: all.slice(0, INVENTORY_CEILING),
|
|
140
|
-
omitted: Math.max(0, all.length - INVENTORY_CEILING) + project.unscanned + user.unscanned,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function renderInventory({ entries, omitted }) {
|
|
145
|
-
const lines = entries.map((e) => `${e.source} ${e.kind} ${e.name} ${e.description}`);
|
|
146
|
-
if (omitted > 0) lines.push(`… ${omitted} more not listed`);
|
|
147
|
-
return lines.join('\n');
|
|
148
|
-
}
|
|
1
|
+
// Skill/agent inventory — what expertise is already installed for this project and user.
|
|
2
|
+
// Used by: CLI (`warnyin-sdlc skills`), which the opening playbook reads to resolve lenses.
|
|
3
|
+
//
|
|
4
|
+
// Skill files are third-party content, so the inventory is deliberately shallow: it reads a
|
|
5
|
+
// bounded prefix of each file, keeps only frontmatter `name` + `description`, and never
|
|
6
|
+
// emits body text. Project entries whose real location leaves the project are skipped (a
|
|
7
|
+
// repo can ship a link); the user's own home may link wherever the user put their skills.
|
|
8
|
+
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import os from 'node:os';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { parseFrontmatter } from './frontmatter.mjs';
|
|
13
|
+
import { containedIn } from './manifest.mjs';
|
|
14
|
+
import { SKILL_NAME_RE } from './lenses.mjs';
|
|
15
|
+
|
|
16
|
+
export { SKILL_NAME_RE };
|
|
17
|
+
export const INVENTORY_CEILING = 200;
|
|
18
|
+
// Per-directory bound on how many candidates are opened at all: a checked-out repo can plant
|
|
19
|
+
// thousands of folders, and the ceiling alone would still pay to read every one of them.
|
|
20
|
+
export const SCAN_LIMIT_PER_DIR = 1000;
|
|
21
|
+
export const DESCRIPTION_MAX = 160;
|
|
22
|
+
export const READ_PREFIX_BYTES = 8 * 1024;
|
|
23
|
+
|
|
24
|
+
const KINDS = Object.freeze(['skill', 'agent']);
|
|
25
|
+
// Built from code points so the source file itself carries no invisible characters: C0, DEL,
|
|
26
|
+
// C1, zero-width and bidi marks/overrides, line/paragraph separators, BOM — anything that
|
|
27
|
+
// can move a terminal cursor or visually reorder the line a human or model reads.
|
|
28
|
+
const cp = (n) => String.fromCharCode(n);
|
|
29
|
+
const CONTROL_CHARS = new RegExp(
|
|
30
|
+
`[${cp(0)}-${cp(0x1f)}${cp(0x7f)}-${cp(0x9f)}${cp(0x200b)}-${cp(0x200f)}${cp(0x2028)}-${cp(0x202e)}${cp(0x2066)}-${cp(0x2069)}${cp(0xfeff)}]+`,
|
|
31
|
+
'g');
|
|
32
|
+
const LEADING_BOM = new RegExp(`^${String.fromCharCode(0xfeff)}`);
|
|
33
|
+
|
|
34
|
+
// Reads at most READ_PREFIX_BYTES; a frontmatter that does not close inside that prefix is
|
|
35
|
+
// treated as absent rather than read further. The open is non-blocking where the platform
|
|
36
|
+
// has it, and the descriptor itself must be a regular file, so a FIFO or device swapped in
|
|
37
|
+
// after the earlier checks can neither hang nor feed the read.
|
|
38
|
+
function readPrefix(file) {
|
|
39
|
+
let fd;
|
|
40
|
+
try {
|
|
41
|
+
fd = fs.openSync(file, fs.constants.O_RDONLY | (fs.constants.O_NONBLOCK ?? 0));
|
|
42
|
+
if (!fs.fstatSync(fd).isFile()) return null;
|
|
43
|
+
const buf = Buffer.alloc(READ_PREFIX_BYTES);
|
|
44
|
+
const n = fs.readSync(fd, buf, 0, READ_PREFIX_BYTES, 0);
|
|
45
|
+
return buf.subarray(0, n).toString('utf8').replace(LEADING_BOM, '');
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
} finally {
|
|
49
|
+
if (fd !== undefined) fs.closeSync(fd);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// One line, no control characters (terminal escapes included), cut with a visible marker.
|
|
54
|
+
export function cleanDescription(raw) {
|
|
55
|
+
const flat = String(raw).replace(CONTROL_CHARS, ' ').replace(/\s+/g, ' ').trim();
|
|
56
|
+
if (flat.length <= DESCRIPTION_MAX) return { description: flat, truncated: false };
|
|
57
|
+
return { description: `${flat.slice(0, DESCRIPTION_MAX - 1).trimEnd()}…`, truncated: true };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function readEntry(file) {
|
|
61
|
+
const text = readPrefix(file);
|
|
62
|
+
if (text === null) return null;
|
|
63
|
+
const { data } = parseFrontmatter(text);
|
|
64
|
+
const name = typeof data.name === 'string' ? data.name.trim() : '';
|
|
65
|
+
if (!SKILL_NAME_RE.test(name)) return null;
|
|
66
|
+
if (typeof data.description !== 'string' || data.description.trim() === '') return null;
|
|
67
|
+
return { name, ...cleanDescription(data.description) };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function isInside(rootReal, target) {
|
|
71
|
+
try {
|
|
72
|
+
return containedIn(rootReal, fs.realpathSync.native(target));
|
|
73
|
+
} catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// The first SCAN_LIMIT_PER_DIR names (sorted), and how many were left unopened.
|
|
79
|
+
function listDir(dir) {
|
|
80
|
+
let names;
|
|
81
|
+
try {
|
|
82
|
+
names = fs.readdirSync(dir).sort();
|
|
83
|
+
} catch {
|
|
84
|
+
return { names: [], unscanned: 0 };
|
|
85
|
+
}
|
|
86
|
+
return { names: names.slice(0, SCAN_LIMIT_PER_DIR), unscanned: Math.max(0, names.length - SCAN_LIMIT_PER_DIR) };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function isFile(p) {
|
|
90
|
+
try { return fs.statSync(p).isFile(); } catch { return false; }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Candidate files for one `.claude` root, each paired with every path that must stay contained.
|
|
94
|
+
function candidates(claudeDir, kind) {
|
|
95
|
+
if (kind === 'skill') {
|
|
96
|
+
const skillsDir = path.join(claudeDir, 'skills');
|
|
97
|
+
const { names, unscanned } = listDir(skillsDir);
|
|
98
|
+
const items = names.map((d) => {
|
|
99
|
+
const folder = path.join(skillsDir, d);
|
|
100
|
+
const file = path.join(folder, 'SKILL.md');
|
|
101
|
+
return { file, checks: [folder, file] };
|
|
102
|
+
});
|
|
103
|
+
return { items, unscanned };
|
|
104
|
+
}
|
|
105
|
+
const agentsDir = path.join(claudeDir, 'agents');
|
|
106
|
+
const { names, unscanned } = listDir(agentsDir);
|
|
107
|
+
const items = names
|
|
108
|
+
.filter((f) => f.endsWith('.md'))
|
|
109
|
+
.map((f) => ({ file: path.join(agentsDir, f), checks: [path.join(agentsDir, f)] }));
|
|
110
|
+
return { items, unscanned };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function scanRoot(claudeDir, source, containRoot) {
|
|
114
|
+
const entries = [];
|
|
115
|
+
let unscanned = 0;
|
|
116
|
+
for (const kind of KINDS) {
|
|
117
|
+
const found = candidates(claudeDir, kind);
|
|
118
|
+
unscanned += found.unscanned;
|
|
119
|
+
for (const { file, checks } of found.items) {
|
|
120
|
+
if (containRoot && !checks.every((c) => isInside(containRoot, c))) continue;
|
|
121
|
+
if (!isFile(file)) continue;
|
|
122
|
+
const entry = readEntry(file);
|
|
123
|
+
if (entry) entries.push({ source, kind, ...entry });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
entries.sort((a, b) => KINDS.indexOf(a.kind) - KINDS.indexOf(b.kind) || a.name.localeCompare(b.name));
|
|
127
|
+
return { entries, unscanned };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function scanInventory(projectRoot, { home = os.homedir() } = {}) {
|
|
131
|
+
let projectReal = null;
|
|
132
|
+
try { projectReal = fs.realpathSync.native(projectRoot); } catch { /* unreadable root → no project entries */ }
|
|
133
|
+
const none = { entries: [], unscanned: 0 };
|
|
134
|
+
const project = projectReal ? scanRoot(path.join(projectRoot, '.claude'), 'project', projectReal) : none;
|
|
135
|
+
const user = home ? scanRoot(path.join(home, '.claude'), 'user', null) : none;
|
|
136
|
+
const all = [...project.entries, ...user.entries];
|
|
137
|
+
// `omitted` = valid entries past the ceiling + candidates never opened (scan limit).
|
|
138
|
+
return {
|
|
139
|
+
entries: all.slice(0, INVENTORY_CEILING),
|
|
140
|
+
omitted: Math.max(0, all.length - INVENTORY_CEILING) + project.unscanned + user.unscanned,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function renderInventory({ entries, omitted }) {
|
|
145
|
+
const lines = entries.map((e) => `${e.source} ${e.kind} ${e.name} ${e.description}`);
|
|
146
|
+
if (omitted > 0) lines.push(`… ${omitted} more not listed`);
|
|
147
|
+
return lines.join('\n');
|
|
148
|
+
}
|