@fabersep/spec 0.0.0-stage → 0.2.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/.claude-plugin/plugin.json +10 -0
- package/CHANGELOG.md +29 -0
- package/LICENSE +202 -0
- package/README.md +132 -2
- package/package.json +53 -4
- package/plugin.json +17 -0
- package/rules/documentation-rules.md +76 -0
- package/skills/faber-discuss/SKILL.md +147 -0
- package/skills/faber-discuss/discuss_log.py +286 -0
- package/skills/faber-discuss/discuss_round.py +379 -0
- package/skills/faber-extract-features/SKILL.md +46 -0
- package/skills/faber-init-arch/SKILL.md +44 -0
- package/skills/faber-init-prd/SKILL.md +38 -0
- package/skills/faber-new-feature/SKILL.md +51 -0
- package/src/cli.mjs +314 -0
- package/src/installer.mjs +471 -0
- package/src/prompt.mjs +114 -0
- package/templates/architecture.md +93 -0
- package/templates/feature-bdd.md +54 -0
- package/templates/feature-prd.md +80 -0
- package/templates/master-prd.md +114 -0
package/src/cli.mjs
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getPackageVersion,
|
|
4
|
+
getStatus,
|
|
5
|
+
installEngines,
|
|
6
|
+
uninstallEngines,
|
|
7
|
+
} from './installer.mjs';
|
|
8
|
+
import { promptMultiSelect } from './prompt.mjs';
|
|
9
|
+
|
|
10
|
+
const ESC = '\x1b';
|
|
11
|
+
const useColor = Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
|
|
12
|
+
const bold = (s) => (useColor ? `${ESC}[1m${s}${ESC}[0m` : s);
|
|
13
|
+
const green = (s) => (useColor ? `${ESC}[32m${s}${ESC}[0m` : s);
|
|
14
|
+
const yellow = (s) => (useColor ? `${ESC}[33m${s}${ESC}[0m` : s);
|
|
15
|
+
const dim = (s) => (useColor ? `${ESC}[2m${s}${ESC}[0m` : s);
|
|
16
|
+
const red = (s) => (useColor ? `${ESC}[31m${s}${ESC}[0m` : s);
|
|
17
|
+
|
|
18
|
+
function printHelp() {
|
|
19
|
+
const version = getPackageVersion();
|
|
20
|
+
console.log(`${bold(`FaberSEP Spec v${version}`)} — Spec-driven templates & faber-* skills for AI coding agents
|
|
21
|
+
|
|
22
|
+
${bold('Usage:')}
|
|
23
|
+
npx @fabersep/spec init [options] Detect installed AI tools and install faber-* skills
|
|
24
|
+
npx @fabersep/spec status Show installed version, skills, and connected tools
|
|
25
|
+
npx @fabersep/spec uninstall [options] Remove FaberSEP Spec links/files from AI tools
|
|
26
|
+
|
|
27
|
+
${bold('Init options:')}
|
|
28
|
+
-y, --yes Skip interactive prompt and install into all detected tools
|
|
29
|
+
--engine <list> Comma-separated tools: antigravity,claude-code,codex,cursor
|
|
30
|
+
--preview, --dry-run Show what would change without modifying disk
|
|
31
|
+
--apply Accepted for compatibility; init applies by default
|
|
32
|
+
--link Link directly to this local checkout (for contributors)
|
|
33
|
+
--undo Alias for uninstall
|
|
34
|
+
|
|
35
|
+
${bold('Examples:')}
|
|
36
|
+
npx @fabersep/spec init
|
|
37
|
+
npx @fabersep/spec init --yes
|
|
38
|
+
npx @fabersep/spec init --engine antigravity,claude-code
|
|
39
|
+
npx @fabersep/spec init --preview
|
|
40
|
+
npx @fabersep/spec status
|
|
41
|
+
npx @fabersep/spec uninstall
|
|
42
|
+
`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function parseArgs(argv) {
|
|
46
|
+
const args = argv.slice(2);
|
|
47
|
+
let command = null;
|
|
48
|
+
const flags = {
|
|
49
|
+
yes: false,
|
|
50
|
+
dryRun: false,
|
|
51
|
+
link: false,
|
|
52
|
+
undo: false,
|
|
53
|
+
help: false,
|
|
54
|
+
version: false,
|
|
55
|
+
engines: null,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < args.length; i++) {
|
|
59
|
+
const arg = args[i];
|
|
60
|
+
if (arg === '-h' || arg === '--help') {
|
|
61
|
+
flags.help = true;
|
|
62
|
+
} else if (arg === '-v' || arg === '--version') {
|
|
63
|
+
flags.version = true;
|
|
64
|
+
} else if (arg === '-y' || arg === '--yes') {
|
|
65
|
+
flags.yes = true;
|
|
66
|
+
} else if (arg === '--dry-run' || arg === '--preview') {
|
|
67
|
+
flags.dryRun = true;
|
|
68
|
+
} else if (arg === '--apply') {
|
|
69
|
+
// Backwards-compatible alias: init applies by default.
|
|
70
|
+
} else if (arg === '--link') {
|
|
71
|
+
flags.link = true;
|
|
72
|
+
} else if (arg === '--undo') {
|
|
73
|
+
flags.undo = true;
|
|
74
|
+
} else if (arg === '--engine' || arg === '--engines') {
|
|
75
|
+
const val = args[++i];
|
|
76
|
+
if (!val) throw new Error(`${arg} requires a comma-separated list of engines`);
|
|
77
|
+
flags.engines = val
|
|
78
|
+
.split(',')
|
|
79
|
+
.map((s) => s.trim())
|
|
80
|
+
.filter(Boolean);
|
|
81
|
+
} else if (arg.startsWith('--engine=')) {
|
|
82
|
+
flags.engines = arg
|
|
83
|
+
.slice('--engine='.length)
|
|
84
|
+
.split(',')
|
|
85
|
+
.map((s) => s.trim())
|
|
86
|
+
.filter(Boolean);
|
|
87
|
+
} else if (!arg.startsWith('-') && !command) {
|
|
88
|
+
command = arg;
|
|
89
|
+
} else {
|
|
90
|
+
throw new Error(`Unknown argument: ${arg}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (flags.engines && flags.engines.length === 0) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
'the tool list is empty. Supported tools: antigravity, claude-code, codex, cursor',
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return { command, flags };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function runInit(flags) {
|
|
104
|
+
if (flags.undo) {
|
|
105
|
+
return runUninstall(flags);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const version = getPackageVersion();
|
|
109
|
+
const statusBefore = getStatus();
|
|
110
|
+
const detectedList = statusBefore.engines;
|
|
111
|
+
const availableList = detectedList.filter((e) => e.detected || e.installed);
|
|
112
|
+
let selectedIds = flags.engines;
|
|
113
|
+
let deselectedIds = [];
|
|
114
|
+
|
|
115
|
+
if (!selectedIds) {
|
|
116
|
+
if (flags.yes || !process.stdin.isTTY) {
|
|
117
|
+
selectedIds = detectedList.filter((e) => e.detected).map((e) => e.id);
|
|
118
|
+
if (selectedIds.length === 0) {
|
|
119
|
+
console.log(
|
|
120
|
+
yellow(
|
|
121
|
+
'No supported AI coding tools were auto-detected (~/.gemini, ~/.claude, ~/.codex, ~/.cursor).',
|
|
122
|
+
),
|
|
123
|
+
);
|
|
124
|
+
console.log(
|
|
125
|
+
'Specify targets explicitly, e.g.: npx @fabersep/spec init --engine claude-code,antigravity',
|
|
126
|
+
);
|
|
127
|
+
return 1;
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
const promptList = availableList.length > 0 ? availableList : detectedList;
|
|
131
|
+
console.log('');
|
|
132
|
+
selectedIds = await promptMultiSelect({
|
|
133
|
+
title: `FaberSEP Spec v${version} — Select AI coding tools to install into:`,
|
|
134
|
+
subtitle:
|
|
135
|
+
availableList.length > 0
|
|
136
|
+
? 'Detected tools are pre-selected. Uncheck any tool to skip or remove it, then press Enter.'
|
|
137
|
+
: 'No AI coding tools were auto-detected. Select any tool to install into, then press Enter.',
|
|
138
|
+
items: promptList.map((e) => ({
|
|
139
|
+
id: e.id,
|
|
140
|
+
label: e.label,
|
|
141
|
+
hint: e.installed
|
|
142
|
+
? `(installed: ${e.detectHint})`
|
|
143
|
+
: e.detected
|
|
144
|
+
? `(detected: ${e.detectHint})`
|
|
145
|
+
: `(${e.detectHint})`,
|
|
146
|
+
checked: e.detected || e.installed,
|
|
147
|
+
})),
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
if (selectedIds === null) {
|
|
151
|
+
console.log(dim('Cancelled. Nothing was modified.'));
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const selectedSet = new Set(selectedIds);
|
|
156
|
+
deselectedIds = promptList
|
|
157
|
+
.filter((e) => e.installed && !selectedSet.has(e.id))
|
|
158
|
+
.map((e) => e.id);
|
|
159
|
+
|
|
160
|
+
if (selectedIds.length === 0 && deselectedIds.length === 0) {
|
|
161
|
+
console.log(yellow('No tools selected. Nothing was installed.'));
|
|
162
|
+
return 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (deselectedIds.length > 0) {
|
|
168
|
+
const removed = uninstallEngines({
|
|
169
|
+
engines: deselectedIds,
|
|
170
|
+
dryRun: flags.dryRun,
|
|
171
|
+
});
|
|
172
|
+
const prefix = flags.dryRun ? '[dry-run] Would remove' : 'Removed';
|
|
173
|
+
for (const item of removed.removed) {
|
|
174
|
+
console.log(` ${green('✓')} ${prefix} (${item.label}): ${item.path}`);
|
|
175
|
+
}
|
|
176
|
+
if (removed.removedCanonical) {
|
|
177
|
+
console.log(` ${green('✓')} ${prefix} canonical store: ${removed.canonicalRoot}`);
|
|
178
|
+
}
|
|
179
|
+
if (selectedIds.length === 0) {
|
|
180
|
+
console.log(dim('\nProject docs/ folders in your repositories were not touched.'));
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const summary = installEngines({
|
|
186
|
+
engines: selectedIds,
|
|
187
|
+
linkDev: flags.link,
|
|
188
|
+
dryRun: flags.dryRun,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
if (flags.dryRun) {
|
|
192
|
+
console.log(bold(`[dry-run] Would install FaberSEP Spec v${summary.version}`));
|
|
193
|
+
console.log(` Canonical store: ${summary.canonicalRoot}`);
|
|
194
|
+
console.log(` Skills (${summary.skills.length}): ${summary.skills.join(', ')}`);
|
|
195
|
+
for (const r of summary.results) {
|
|
196
|
+
console.log(` • ${r.label}: ${r.targets.join(', ')}`);
|
|
197
|
+
for (const stale of r.staleRemoved || []) {
|
|
198
|
+
console.log(` would remove skill no longer shipped: ${stale}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
console.log(green(`✓ Installed FaberSEP Spec v${summary.version}`));
|
|
205
|
+
console.log(dim(` Source: ${summary.canonicalRoot}`));
|
|
206
|
+
console.log(dim(` Skills (${summary.skills.length}): ${summary.skills.join(', ')}`));
|
|
207
|
+
console.log('');
|
|
208
|
+
for (const r of summary.results) {
|
|
209
|
+
const targetSummary =
|
|
210
|
+
r.mode === 'plugin' ? r.targets[0] : `${r.targets.length} skills -> ${r.targets[0].replace(/\/faber-[^/]+$/, '')}`;
|
|
211
|
+
console.log(` ${green('✓')} ${bold(r.label.padEnd(22))} ${targetSummary} ${dim(`(${r.method})`)}`);
|
|
212
|
+
if (r.backedUpTo) {
|
|
213
|
+
const backups = Array.isArray(r.backedUpTo) ? r.backedUpTo : [r.backedUpTo];
|
|
214
|
+
for (const b of backups) console.log(yellow(` backed up previous directory to: ${b}`));
|
|
215
|
+
}
|
|
216
|
+
for (const stale of r.staleRemoved || []) {
|
|
217
|
+
console.log(dim(` removed skill no longer shipped: ${stale}`));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
console.log('');
|
|
221
|
+
console.log(bold('Next step:'));
|
|
222
|
+
console.log(' Open any project in your AI coding tool and ask:');
|
|
223
|
+
console.log(dim(' "Run faber-init-arch to document this repository\'s architecture."'));
|
|
224
|
+
console.log('');
|
|
225
|
+
return 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function runStatus() {
|
|
229
|
+
const st = getStatus();
|
|
230
|
+
console.log(bold(`FaberSEP Spec Status`));
|
|
231
|
+
if (st.canonicalExists || !st.linkedRoot) {
|
|
232
|
+
console.log(
|
|
233
|
+
` Canonical store: ${st.canonicalRoot} ${
|
|
234
|
+
st.canonicalExists ? green(`(v${st.installedVersion || '?'})`) : yellow('(not installed)')
|
|
235
|
+
}`,
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
if (st.linkedRoot) {
|
|
239
|
+
console.log(` Linked checkout: ${st.linkedRoot} ${green(`(v${st.linkedVersion || '?'})`)}`);
|
|
240
|
+
}
|
|
241
|
+
console.log(` Skills (${st.skills.length}): ${st.skills.join(', ')}`);
|
|
242
|
+
console.log('');
|
|
243
|
+
for (const e of st.engines) {
|
|
244
|
+
const state = e.installed
|
|
245
|
+
? green('installed')
|
|
246
|
+
: e.unmanaged
|
|
247
|
+
? yellow('not managed (not ours)')
|
|
248
|
+
: e.detected
|
|
249
|
+
? yellow('detected (not linked)')
|
|
250
|
+
: dim('not detected');
|
|
251
|
+
const detail = e.installed
|
|
252
|
+
? e.mode === 'plugin'
|
|
253
|
+
? e.targetHint
|
|
254
|
+
: `${e.installedSkills.length}/${st.skills.length} skills in ${e.targetHint}`
|
|
255
|
+
: e.unmanaged
|
|
256
|
+
? `${e.targetHint} holds files FaberSEP Spec did not create; init backs them up`
|
|
257
|
+
: e.detectHint;
|
|
258
|
+
console.log(` ${e.label.padEnd(23)} ${state.padEnd(28)} ${dim(detail)}`);
|
|
259
|
+
}
|
|
260
|
+
return 0;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function runUninstall(flags) {
|
|
264
|
+
const res = uninstallEngines({
|
|
265
|
+
engines: flags.engines || undefined,
|
|
266
|
+
dryRun: flags.dryRun,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
if (res.removed.length === 0 && !res.removedCanonical) {
|
|
270
|
+
console.log(dim('Nothing to uninstall — FaberSEP Spec was not installed.'));
|
|
271
|
+
return 0;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const prefix = flags.dryRun ? '[dry-run] Would remove' : 'Removed';
|
|
275
|
+
for (const item of res.removed) {
|
|
276
|
+
console.log(` ${green('✓')} ${prefix} (${item.label}): ${item.path}`);
|
|
277
|
+
}
|
|
278
|
+
if (res.removedCanonical) {
|
|
279
|
+
console.log(` ${green('✓')} ${prefix} canonical store: ${res.canonicalRoot}`);
|
|
280
|
+
}
|
|
281
|
+
console.log(dim('\nProject docs/ folders in your repositories were not touched.'));
|
|
282
|
+
return 0;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async function main() {
|
|
286
|
+
try {
|
|
287
|
+
const { command, flags } = parseArgs(process.argv);
|
|
288
|
+
if (flags.version) {
|
|
289
|
+
console.log(getPackageVersion());
|
|
290
|
+
return 0;
|
|
291
|
+
}
|
|
292
|
+
if (flags.help || !command) {
|
|
293
|
+
printHelp();
|
|
294
|
+
return 0;
|
|
295
|
+
}
|
|
296
|
+
if (command === 'init') {
|
|
297
|
+
return await runInit(flags);
|
|
298
|
+
}
|
|
299
|
+
if (command === 'status') {
|
|
300
|
+
return runStatus();
|
|
301
|
+
}
|
|
302
|
+
if (command === 'uninstall' || command === 'remove') {
|
|
303
|
+
return runUninstall(flags);
|
|
304
|
+
}
|
|
305
|
+
console.error(red(`Unknown command: ${command}`));
|
|
306
|
+
printHelp();
|
|
307
|
+
return 1;
|
|
308
|
+
} catch (err) {
|
|
309
|
+
console.error(red(`Error: ${err.message}`));
|
|
310
|
+
return 1;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
process.exitCode = await main();
|