shipgate-cli 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/LICENSE +21 -0
- package/README.md +258 -2
- package/agents/context-builder.md +158 -0
- package/agents/debug-executor.md +234 -0
- package/assets/gates/classifier.js +245 -0
- package/assets/gates/dsh/index.js +767 -0
- package/assets/gates/dsh/policy.json +93 -0
- package/assets/gates/index.js +3 -0
- package/assets/gates/pi/index.js +1121 -0
- package/assets/gates/pi/policy.json +93 -0
- package/assets/gates/policy.js +4199 -0
- package/assets/gates/profiles/ai4s-dry-lab.json +64 -0
- package/assets/gates/profiles/ai4s-quant.json +36 -0
- package/assets/pi-extensions/auto-continue.ts +176 -0
- package/assets/pi-extensions/goal-mode.ts +313 -0
- package/bin/shipgate.mjs +9 -0
- package/commands/ai-spec.md +9 -0
- package/commands/api-first.md +33 -0
- package/commands/code-review.md +7 -0
- package/commands/codebase-context.md +19 -0
- package/commands/debug-ui.md +147 -0
- package/commands/debug.md +101 -0
- package/commands/dev-env-scan.md +18 -0
- package/commands/dev-host-init.md +28 -0
- package/commands/discover-skill-opportunities.md +33 -0
- package/commands/fork-sync.md +17 -0
- package/commands/gh-actions.md +26 -0
- package/commands/goal-driven-development.md +7 -0
- package/commands/intent-grill.md +7 -0
- package/commands/iteration-manager.md +7 -0
- package/commands/loop-engineer.md +21 -0
- package/commands/nodejs-npm-auto-release.md +12 -0
- package/commands/prd.md +7 -0
- package/commands/project-health-audit.md +7 -0
- package/commands/ralph-yolo.md +346 -0
- package/commands/ralph.md +226 -0
- package/commands/security-audit.md +7 -0
- package/commands/ux-experience-audit.md +133 -0
- package/docs/ARCHITECTURE.md +63 -0
- package/docs/GATES.md +106 -0
- package/docs/HARNESS.md +215 -0
- package/package.json +48 -4
- package/references/ADR-FORMAT.md +67 -0
- package/references/CONTEXT-FORMAT.md +62 -0
- package/references/mcp-config-template.json +54 -0
- package/scripts/fix-skill-frontmatter.mjs +66 -0
- package/scripts/migrate-skillpack.mjs +257 -0
- package/skills/ai-spec/SKILL.md +90 -0
- package/skills/api-first-modular/SKILL.md +411 -0
- package/skills/code-debugger/SKILL.md +379 -0
- package/skills/code-review/SKILL.md +62 -0
- package/skills/codebase-context/SKILL.md +139 -0
- package/skills/debug-ui/SKILL.md +220 -0
- package/skills/dev-env-scan/SKILL.md +147 -0
- package/skills/dev-host-init/SKILL.md +198 -0
- package/skills/dev-host-init/scripts/fill-placeholders.py +226 -0
- package/skills/dev-host-init/scripts/host-scan.ps1 +159 -0
- package/skills/dev-host-init/scripts/host-scan.sh +201 -0
- package/skills/dev-host-init/scripts/render-now.py +488 -0
- package/skills/dev-host-init/scripts/tools-catalog.py +229 -0
- package/skills/dev-host-init/templates/graph-first-gate.ts +291 -0
- package/skills/dev-host-init/templates/host-injection.template.md +725 -0
- package/skills/discover-skill-opportunities/SKILL.md +145 -0
- package/skills/discover-skill-opportunities/references/accounting-finance-ops.md +24 -0
- package/skills/discover-skill-opportunities/references/business-consulting.md +24 -0
- package/skills/discover-skill-opportunities/references/evidence-and-privacy.md +39 -0
- package/skills/discover-skill-opportunities/references/finance-investment.md +24 -0
- package/skills/discover-skill-opportunities/references/legal-and-compliance.md +24 -0
- package/skills/discover-skill-opportunities/references/output-contract.md +75 -0
- package/skills/discover-skill-opportunities/references/product-and-operations.md +24 -0
- package/skills/discover-skill-opportunities/references/quant-trading.md +24 -0
- package/skills/discover-skill-opportunities/references/scientific-research.md +24 -0
- package/skills/discover-skill-opportunities/references/scoring-rubric.md +45 -0
- package/skills/discover-skill-opportunities/references/session-skill-review.md +78 -0
- package/skills/discover-skill-opportunities/references/software-development.md +24 -0
- package/skills/fork-sync/SKILL.md +86 -0
- package/skills/gh-actions-architect/SKILL.md +395 -0
- package/skills/goal-driven-development/SKILL.md +132 -0
- package/skills/intent-grill/SKILL.md +46 -0
- package/skills/iteration-manager/SKILL.md +53 -0
- package/skills/loop-engineer/SKILL.md +108 -0
- package/skills/nodejs-npm-auto-release/SKILL.md +141 -0
- package/skills/prd/SKILL.md +63 -0
- package/skills/project-health-audit/SKILL.md +64 -0
- package/skills/ralph/SKILL.md +329 -0
- package/skills/ralph-yolo/SKILL.md +623 -0
- package/skills/security-audit/SKILL.md +114 -0
- package/skills/security-audit/references/audit-checklist.md +135 -0
- package/skills/security-audit/references/evidence-conventions.md +54 -0
- package/skills/security-audit/references/findings-schema.md +37 -0
- package/skills/security-audit/references/stack-signatures.md +66 -0
- package/skills/shipgate/SKILL.md +40 -0
- package/skills/shipgate-install/SKILL.md +87 -0
- package/skills/shipgate-quality/SKILL.md +80 -0
- package/skills/shipgate-security/SKILL.md +97 -0
- package/skills/shipgate-spec/SKILL.md +67 -0
- package/skills/ux-experience-audit/SKILL.md +202 -0
- package/src/cli.mjs +117 -0
- package/src/commands/ask.mjs +82 -0
- package/src/commands/deploy.mjs +589 -0
- package/src/commands/gates.mjs +83 -0
- package/src/commands/policy.mjs +67 -0
- package/src/gates/quality.mjs +123 -0
- package/src/gates/security.mjs +92 -0
- package/src/gates/ship.mjs +74 -0
- package/src/gates/spec.mjs +88 -0
- package/src/harness/index.mjs +203 -0
- package/src/inject/render.mjs +75 -0
- package/src/lib/cfg.mjs +66 -0
- package/src/lib/engines.mjs +182 -0
- package/src/lib/exec.mjs +80 -0
- package/src/lib/fsx.mjs +119 -0
- package/src/lib/gate.mjs +288 -0
- package/src/lib/log.mjs +31 -0
- package/src/lib/skills.mjs +347 -0
- package/src/lib/state.mjs +41 -0
- package/src/lib/update.mjs +67 -0
- package/src/version.mjs +14 -0
- package/templates/agents-snippet.md +82 -0
- package/templates/dev-profile.schema.json +119 -0
- package/templates/prd.json.example +64 -0
- package/templates/rule.json.example +28 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Adds the `name:` field to SKILL.md frontmatter when it is missing.
|
|
4
|
+
*
|
|
5
|
+
* Why: the source skill package relied on the file name being the skill name.
|
|
6
|
+
* After distribution the file is always `SKILL.md`, so the harness has no way
|
|
7
|
+
* to derive the name — a skill without `name:` loads but never triggers.
|
|
8
|
+
* Run after migrate-skillpack, then `--check` must be clean.
|
|
9
|
+
*/
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
|
|
14
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
15
|
+
const SKILLS = path.join(ROOT, 'skills');
|
|
16
|
+
|
|
17
|
+
function firstSentence(text) {
|
|
18
|
+
const body = text.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '');
|
|
19
|
+
const line = body
|
|
20
|
+
.split(/\r?\n/)
|
|
21
|
+
.map((l) => l.trim())
|
|
22
|
+
.find((l) => l && !l.startsWith('#') && !l.startsWith('>'));
|
|
23
|
+
return (line ?? '').slice(0, 180).replace(/\s+/g, ' ');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function fixOne(name) {
|
|
27
|
+
const file = path.join(SKILLS, name, 'SKILL.md');
|
|
28
|
+
if (!fs.existsSync(file)) return null;
|
|
29
|
+
const text = fs.readFileSync(file, 'utf8');
|
|
30
|
+
const front = text.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
31
|
+
|
|
32
|
+
if (!front) {
|
|
33
|
+
const description = firstSentence(text) || `Use when working on ${name}.`;
|
|
34
|
+
fs.writeFileSync(file, `---\nname: ${name}\ndescription: ${description}\n---\n\n${text}`);
|
|
35
|
+
return 'inserted-frontmatter';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let body = front[1];
|
|
39
|
+
let changed = false;
|
|
40
|
+
|
|
41
|
+
if (!/^name\s*:/m.test(body)) {
|
|
42
|
+
body = `name: ${name}\n${body}`;
|
|
43
|
+
changed = true;
|
|
44
|
+
}
|
|
45
|
+
if (!/^description\s*:/m.test(body)) {
|
|
46
|
+
body = `${body}\ndescription: ${firstSentence(text) || `Use when working on ${name}.`}`;
|
|
47
|
+
changed = true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!changed) return null;
|
|
51
|
+
fs.writeFileSync(file, text.replace(front[0], `---\n${body}\n---`));
|
|
52
|
+
return 'filled-fields';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const report = [];
|
|
56
|
+
for (const entry of fs.readdirSync(SKILLS, { withFileTypes: true })) {
|
|
57
|
+
if (!entry.isDirectory()) continue;
|
|
58
|
+
const result = fixOne(entry.name);
|
|
59
|
+
if (result) report.push(`${entry.name}: ${result}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (report.length === 0) console.log('✔ 所有 SKILL.md 的 frontmatter 已完整,无需修改');
|
|
63
|
+
else {
|
|
64
|
+
console.log(`✔ 修正 ${report.length} 个:`);
|
|
65
|
+
for (const line of report) console.log(` - ${line}`);
|
|
66
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* One-shot migration of the private full-dev skill package into ShipGate's
|
|
4
|
+
* distributable layout: every skill becomes skills/<name>/SKILL.md, and the
|
|
5
|
+
* slash commands / subagents / shared references come along.
|
|
6
|
+
*
|
|
7
|
+
* `--apply` is the complete, repeatable operation: copy → fix broken command
|
|
8
|
+
* references → fill missing frontmatter → verify. Splitting those steps let a
|
|
9
|
+
* re-run clobber post-migration fixes, so they live together by design.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* node scripts/migrate-skillpack.mjs --apply [--src <dir>]
|
|
13
|
+
* node scripts/migrate-skillpack.mjs --check
|
|
14
|
+
*/
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
|
|
19
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
20
|
+
const DEFAULT_SRC = '/mnt/500G-1/Development/Claude_skill_pool/package/full-dev-脚手架/.claude';
|
|
21
|
+
const SRC = process.argv.includes('--src')
|
|
22
|
+
? process.argv[process.argv.indexOf('--src') + 1]
|
|
23
|
+
: process.env.SKILLPACK_SRC ?? DEFAULT_SRC;
|
|
24
|
+
|
|
25
|
+
const SKIP_SKILLS = new Set([
|
|
26
|
+
'_archived',
|
|
27
|
+
'shipgate',
|
|
28
|
+
'shipgate-spec',
|
|
29
|
+
'shipgate-quality',
|
|
30
|
+
'shipgate-security',
|
|
31
|
+
'shipgate-install',
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
// The source wraps the path in backticks (`` `.claude/skills/x.md` ``); the
|
|
35
|
+
// replacement must consume those too, otherwise the rewrite nests backticks and
|
|
36
|
+
// produces broken markdown.
|
|
37
|
+
const LEGACY_REF = /`\.claude\/skills\/([a-z0-9-]+)\.md`/g;
|
|
38
|
+
|
|
39
|
+
function frontmatterIssue(text) {
|
|
40
|
+
const match = text.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
41
|
+
if (!match) return 'no-frontmatter';
|
|
42
|
+
if (!/^name\s*:/m.test(match[1])) return 'missing-name';
|
|
43
|
+
if (!/^description\s*:/m.test(match[1])) return 'missing-description';
|
|
44
|
+
// Presence is not enough: an over-long description or an illegal name loads
|
|
45
|
+
// with a warning in pi and is rejected by stricter harnesses, so the package
|
|
46
|
+
// would ship a skill that cannot trigger. Check the values, not the keys.
|
|
47
|
+
const fields = parseFrontmatter(match[1]);
|
|
48
|
+
const name = fields.name ?? '';
|
|
49
|
+
if (!/^[a-z0-9-]+$/.test(name)) return `name 非法(只能用 a-z、0-9、-):${name}`;
|
|
50
|
+
if (name.length > 64) return `name 超过 64 字符(${name.length})`;
|
|
51
|
+
if (/^-|-$/.test(name) || name.includes('--')) return `name 不能以 - 开头/结尾,也不能含 --:${name}`;
|
|
52
|
+
const description = fields.description ?? '';
|
|
53
|
+
if (description.length > 1024) return `description 超过 1024 字符(${description.length})`;
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function parseFrontmatter(body) {
|
|
58
|
+
const fields = {};
|
|
59
|
+
const lines = body.split(/\r?\n/);
|
|
60
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
61
|
+
const hit = /^([A-Za-z0-9_-]+):[ \t]*(.*)$/.exec(lines[i]);
|
|
62
|
+
if (!hit) continue;
|
|
63
|
+
let value = hit[2].trim();
|
|
64
|
+
if (/^[|>][-+]?\d*$/.test(value)) {
|
|
65
|
+
const block = [];
|
|
66
|
+
while (i + 1 < lines.length && /^\s+\S/.test(lines[i + 1])) block.push(lines[++i].trim());
|
|
67
|
+
value = value.startsWith('|') ? block.join('\n') : block.join(' ');
|
|
68
|
+
}
|
|
69
|
+
fields[hit[1]] = value.replace(/^(['"])([\s\S]*)\1$/, '$2');
|
|
70
|
+
}
|
|
71
|
+
return fields;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function listMigratedSkills() {
|
|
75
|
+
const dir = path.join(ROOT, 'skills');
|
|
76
|
+
if (!fs.existsSync(dir)) return [];
|
|
77
|
+
return fs
|
|
78
|
+
.readdirSync(dir, { withFileTypes: true })
|
|
79
|
+
.filter((e) => e.isDirectory() && !SKIP_SKILLS.has(e.name))
|
|
80
|
+
.map((e) => e.name)
|
|
81
|
+
.sort();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function countOf(dir) {
|
|
85
|
+
const p = path.join(ROOT, dir);
|
|
86
|
+
return fs.existsSync(p) ? fs.readdirSync(p).length : 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function copyFromSource() {
|
|
90
|
+
const srcSkills = path.join(SRC, 'skills');
|
|
91
|
+
if (!fs.existsSync(srcSkills)) throw new Error(`源技能目录不存在:${srcSkills}`);
|
|
92
|
+
|
|
93
|
+
const copied = [];
|
|
94
|
+
for (const entry of fs.readdirSync(srcSkills, { withFileTypes: true })) {
|
|
95
|
+
if (SKIP_SKILLS.has(entry.name)) continue;
|
|
96
|
+
const from = path.join(srcSkills, entry.name);
|
|
97
|
+
|
|
98
|
+
if (entry.isFile() && entry.name.endsWith('.md')) {
|
|
99
|
+
const name = entry.name.replace(/\.md$/, '');
|
|
100
|
+
const dest = path.join(ROOT, 'skills', name, 'SKILL.md');
|
|
101
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
102
|
+
fs.copyFileSync(from, dest);
|
|
103
|
+
copied.push(`skill: ${name}`);
|
|
104
|
+
} else if (entry.isDirectory()) {
|
|
105
|
+
fs.cpSync(from, path.join(ROOT, 'skills', entry.name), { recursive: true });
|
|
106
|
+
copied.push(`skill-dir: ${entry.name}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
for (const name of ['commands', 'agents', 'references']) {
|
|
111
|
+
const from = path.join(SRC, name);
|
|
112
|
+
if (!fs.existsSync(from)) continue;
|
|
113
|
+
fs.cpSync(from, path.join(ROOT, name), { recursive: true });
|
|
114
|
+
copied.push(`${name}: ${fs.readdirSync(from).length} files`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
for (const file of ['dev-profile.schema.json', 'prd.json.example', 'rule.json.example']) {
|
|
118
|
+
const from = path.join(SRC, 'templates', file);
|
|
119
|
+
if (!fs.existsSync(from)) continue;
|
|
120
|
+
fs.mkdirSync(path.join(ROOT, 'templates'), { recursive: true });
|
|
121
|
+
fs.copyFileSync(from, path.join(ROOT, 'templates', file));
|
|
122
|
+
copied.push(`template: ${file}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return copied;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Commands were authored against the old single-file layout
|
|
130
|
+
* (`.claude/skills/ai-spec.md`). After migration every skill is a directory and
|
|
131
|
+
* the installed path differs per harness, so a hardcoded path is guaranteed to
|
|
132
|
+
* break somewhere. Rewrite the reference to resolve by skill name instead.
|
|
133
|
+
*/
|
|
134
|
+
function fixCommandRefs() {
|
|
135
|
+
const dir = path.join(ROOT, 'commands');
|
|
136
|
+
if (!fs.existsSync(dir)) return [];
|
|
137
|
+
const fixed = [];
|
|
138
|
+
|
|
139
|
+
for (const file of fs.readdirSync(dir).filter((f) => f.endsWith('.md'))) {
|
|
140
|
+
const full = path.join(dir, file);
|
|
141
|
+
const before = fs.readFileSync(full, 'utf8');
|
|
142
|
+
const after = before.replace(LEGACY_REF, (_, name) => `skill \`${name}\``);
|
|
143
|
+
if (after !== before) {
|
|
144
|
+
fs.writeFileSync(full, after);
|
|
145
|
+
fixed.push(file);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return fixed;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function firstSentence(text) {
|
|
152
|
+
const body = text.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '');
|
|
153
|
+
const line = body
|
|
154
|
+
.split(/\r?\n/)
|
|
155
|
+
.map((l) => l.trim())
|
|
156
|
+
.find((l) => l && !l.startsWith('#') && !l.startsWith('>'));
|
|
157
|
+
return (line ?? '').slice(0, 180).replace(/\s+/g, ' ');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The source package relied on the file name being the skill name. After
|
|
162
|
+
* distribution the file is always SKILL.md, so a skill without `name:` loads
|
|
163
|
+
* but never triggers — the silent failure this migration must prevent.
|
|
164
|
+
*/
|
|
165
|
+
function fixFrontmatter() {
|
|
166
|
+
const fixed = [];
|
|
167
|
+
|
|
168
|
+
for (const name of listMigratedSkills()) {
|
|
169
|
+
const file = path.join(ROOT, 'skills', name, 'SKILL.md');
|
|
170
|
+
if (!fs.existsSync(file)) continue;
|
|
171
|
+
const text = fs.readFileSync(file, 'utf8');
|
|
172
|
+
const front = text.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
173
|
+
|
|
174
|
+
if (!front) {
|
|
175
|
+
const description = firstSentence(text) || `Use when working on ${name}.`;
|
|
176
|
+
fs.writeFileSync(file, `---\nname: ${name}\ndescription: ${description}\n---\n\n${text}`);
|
|
177
|
+
fixed.push(name);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let body = front[1];
|
|
182
|
+
let changed = false;
|
|
183
|
+
if (!/^name\s*:/m.test(body)) {
|
|
184
|
+
body = `name: ${name}\n${body}`;
|
|
185
|
+
changed = true;
|
|
186
|
+
}
|
|
187
|
+
if (!/^description\s*:/m.test(body)) {
|
|
188
|
+
body = `${body}\ndescription: ${firstSentence(text) || `Use when working on ${name}.`}`;
|
|
189
|
+
changed = true;
|
|
190
|
+
}
|
|
191
|
+
if (!changed) continue;
|
|
192
|
+
|
|
193
|
+
fs.writeFileSync(file, text.replace(front[0], `---\n${body}\n---`));
|
|
194
|
+
fixed.push(name);
|
|
195
|
+
}
|
|
196
|
+
return fixed;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function apply() {
|
|
200
|
+
const copied = copyFromSource();
|
|
201
|
+
console.log(`从 ${SRC} 迁移 ${copied.length} 项`);
|
|
202
|
+
|
|
203
|
+
const refs = fixCommandRefs();
|
|
204
|
+
if (refs.length) console.log(` 修复命令内断裂引用 ${refs.length} 个:${refs.join(', ')}`);
|
|
205
|
+
|
|
206
|
+
const fm = fixFrontmatter();
|
|
207
|
+
if (fm.length) console.log(` 补齐 frontmatter ${fm.length} 个:${fm.join(', ')}`);
|
|
208
|
+
|
|
209
|
+
return check();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function check() {
|
|
213
|
+
const migrated = listMigratedSkills();
|
|
214
|
+
const problems = [];
|
|
215
|
+
|
|
216
|
+
for (const name of migrated) {
|
|
217
|
+
const file = path.join(ROOT, 'skills', name, 'SKILL.md');
|
|
218
|
+
if (!fs.existsSync(file)) {
|
|
219
|
+
problems.push(`${name}: 缺少 SKILL.md`);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const issue = frontmatterIssue(fs.readFileSync(file, 'utf8'));
|
|
223
|
+
if (issue) problems.push(`${name}: ${issue}`);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
for (const dir of ['commands', 'agents']) {
|
|
227
|
+
if (countOf(dir) === 0) problems.push(`${dir}/ 为空`);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// A command pointing at the pre-migration single-file skill path is broken at
|
|
231
|
+
// runtime: the skill is a directory now and lives elsewhere per harness.
|
|
232
|
+
const cmdDir = path.join(ROOT, 'commands');
|
|
233
|
+
if (fs.existsSync(cmdDir)) {
|
|
234
|
+
for (const file of fs.readdirSync(cmdDir).filter((f) => f.endsWith('.md'))) {
|
|
235
|
+
const hit = fs.readFileSync(path.join(cmdDir, file), 'utf8').match(/\.claude\/skills\/[a-z0-9-]+\.md/);
|
|
236
|
+
if (hit) problems.push(`commands/${file}: 仍在引用旧路径 ${hit[0]}`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
console.log(
|
|
241
|
+
`\n技能目录 ${migrated.length + 5} 个(${migrated.length} full-dev + 5 shipgate);命令 ${countOf('commands')};subagent ${countOf('agents')}`,
|
|
242
|
+
);
|
|
243
|
+
if (problems.length === 0) {
|
|
244
|
+
console.log('✔ 迁移体检通过');
|
|
245
|
+
return 0;
|
|
246
|
+
}
|
|
247
|
+
console.error(`✖ ${problems.length} 处问题:`);
|
|
248
|
+
for (const p of problems) console.error(` - ${p}`);
|
|
249
|
+
return 1;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const mode = process.argv.includes('--apply') ? 'apply' : process.argv.includes('--check') ? 'check' : null;
|
|
253
|
+
if (!mode) {
|
|
254
|
+
console.error('用法:node scripts/migrate-skillpack.mjs --apply | --check [--src <dir>]');
|
|
255
|
+
process.exit(2);
|
|
256
|
+
}
|
|
257
|
+
process.exit(mode === 'apply' ? apply() : check());
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ai-spec
|
|
3
|
+
description: Lead full-development routing and convert an aligned change request, project-health baseline, and approved PRD into a versioned engineering SPEC with architecture decisions, milestones, acceptance traceability, checks, rollout, rollback, and authorization boundaries. Use for architectural or cross-layer changes and before goal-driven implementation. Do not implement code or mark a SPEC approved without explicit user approval.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AI Spec
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Act as the full-dev lead router and engineering-contract author. Route incomplete inputs to the correct preparation skill, then produce a versioned SPEC that `goal-driven-development` can execute without inventing requirements. `/ai-spec init` or a new-machine bootstrap request is delegated to `dev-host-init`, which generates a layered injection system: rules doc (AGENTS.md + per-agent mirrors) + external `agent-reference/` refs + pi reinforcement layer (`.pi/agent/APPEND_SYSTEM.md` + `graph-first-gate.ts` extension; pi fully inherits .claude skills at the skill layer).
|
|
11
|
+
|
|
12
|
+
## Routing
|
|
13
|
+
|
|
14
|
+
| Condition | Route |
|
|
15
|
+
|---|---|
|
|
16
|
+
| Intent or scope is ambiguous | `intent-grill` |
|
|
17
|
+
| Existing project lacks a health/debt baseline | `project-health-audit` |
|
|
18
|
+
| Host machine initialization required (`/ai-spec init`) | `dev-host-init` |
|
|
19
|
+
| Product goals, users, scope, or acceptance are undefined | `prd` |
|
|
20
|
+
| Approved PRD needs an engineering contract | continue in `ai-spec` |
|
|
21
|
+
| SPEC is approved and implementation is requested | `goal-driven-development` |
|
|
22
|
+
| Bug without contract change | `codebase-context` → `code-debugger` |
|
|
23
|
+
| Delivered work needs feedback routing | `iteration-manager` |
|
|
24
|
+
|
|
25
|
+
## Workflow
|
|
26
|
+
|
|
27
|
+
1. Read repository entry instructions, Git state, project context, Change Brief, HEALTH, PRD, existing SPEC/amendments, and relevant code.
|
|
28
|
+
2. Confirm the PRD is `APPROVED`; otherwise produce a gap list and stop before engineering finalization.
|
|
29
|
+
3. Compare at least two viable designs when a real architectural tradeoff exists. Record the selected option, rejected options, rationale, reversibility, and consequences in ADR form.
|
|
30
|
+
4. Define interfaces, data contracts, migrations, compatibility, security, observability, failure/degraded modes, performance budgets, rollout, rollback, and operational ownership as applicable.
|
|
31
|
+
5. Split work into dependency-ordered milestones that each fit one implement/check/review loop.
|
|
32
|
+
6. Map every PRD requirement and acceptance criterion to SPEC sections, milestones, and verification evidence in `TRACEABILITY.md`.
|
|
33
|
+
7. Discover repository-native test/lint/type/build/security commands. Do not invent unavailable commands as facts.
|
|
34
|
+
8. Define review policy, debt treatment, commit authorization, and push authorization separately.
|
|
35
|
+
9. Write the contract under `tasks/<change-id>/`; keep previous approved versions and create amendments instead of overwriting history.
|
|
36
|
+
10. Present unresolved questions and request approval. Set `status: approved` only after explicit user approval.
|
|
37
|
+
|
|
38
|
+
## SPEC contract
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
---
|
|
42
|
+
change_id: CHG-000
|
|
43
|
+
version: 1
|
|
44
|
+
status: draft
|
|
45
|
+
prd_ref: PRD.md
|
|
46
|
+
health_ref: HEALTH.md
|
|
47
|
+
supersedes: null
|
|
48
|
+
approved_by: null
|
|
49
|
+
approved_at: null
|
|
50
|
+
---
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Required sections:
|
|
54
|
+
|
|
55
|
+
1. Context, goal, non-goals, constraints, assumptions, and unresolved questions.
|
|
56
|
+
2. Current architecture and debt impact.
|
|
57
|
+
3. Selected design and ADR/tradeoffs.
|
|
58
|
+
4. Interfaces, data, security, compatibility, migration, observability, rollout, and rollback.
|
|
59
|
+
5. Milestones with dependencies, files/modules, acceptance, checks, risks, and rollback.
|
|
60
|
+
6. Definition of Ready and Definition of Done.
|
|
61
|
+
7. Review and delivery Gates.
|
|
62
|
+
8. Traceability and evidence plan.
|
|
63
|
+
|
|
64
|
+
## Approval and execution rules
|
|
65
|
+
|
|
66
|
+
- `SPEC_READY` means the document is complete enough to review; it is not approval.
|
|
67
|
+
- `SPEC_APPROVED` requires explicit approval and a recorded version.
|
|
68
|
+
- Material scope or architecture changes require an amendment/version bump.
|
|
69
|
+
- Implementation defaults to `goal-driven-development`; Ralph remains a legacy compatibility option only when explicitly selected.
|
|
70
|
+
- Commit and push are separate authorization Gates.
|
|
71
|
+
|
|
72
|
+
## Output Contract
|
|
73
|
+
|
|
74
|
+
Produce or update:
|
|
75
|
+
|
|
76
|
+
- `tasks/<change-id>/CHANGE.md`
|
|
77
|
+
- `tasks/<change-id>/SPEC.md`
|
|
78
|
+
- `tasks/<change-id>/TRACEABILITY.md`
|
|
79
|
+
- approval decision, gaps, and the exact next route
|
|
80
|
+
|
|
81
|
+
Do not claim readiness when required PRD, health, verification, migration, rollback, or approval information is missing.
|
|
82
|
+
|
|
83
|
+
## Related skills
|
|
84
|
+
|
|
85
|
+
| Relation | Skill | Scenario |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| Receives | intent-grill / project-health-audit / prd | Prepared change inputs |
|
|
88
|
+
| Calls | codebase-context / api-first-modular | Architecture and cross-layer decomposition |
|
|
89
|
+
| Hands off | goal-driven-development | Approved SPEC execution |
|
|
90
|
+
| Receives back | iteration-manager | SPEC amendment or new change |
|