@elvis1513/auto-coding-skill 2.0.6 → 2.1.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/README.md +144 -34
- package/cli/assets/agents/explorer.toml +8 -6
- package/cli/assets/agents/fixer.toml +8 -7
- package/cli/assets/agents/reviewer.toml +8 -6
- package/cli/assets/skill/SKILL.md +70 -29
- package/cli/assets/skill/data/templates/ENGINEERING.md +134 -36
- package/cli/assets/skill/data/templates/bridges/{CLAUDE.md → AGENTS.md} +6 -2
- package/cli/assets/skill/data/templates/docs/architecture/structure-standard.md +24 -0
- package/cli/assets/skill/data/templates/docs/deployment/deploy-records/_TEMPLATE-DEPLOY-RECORD.md +1 -1
- package/cli/assets/skill/data/templates/docs/deployment/deploy-runbook.md +1 -1
- package/cli/assets/skill/data/templates/docs/reviews/_TEMPLATE-REVIEW.md +6 -4
- package/cli/assets/skill/data/templates/docs/reviews/optimization-backlog.md +1 -0
- package/cli/assets/skill/data/templates/docs/reviews/project-health-baseline.md +4 -1
- package/cli/assets/skill/data/templates/docs/tasks/closure-log.md +7 -6
- package/cli/assets/skill/data/templates/docs/tasks/summaries/_TEMPLATE-TASK-SUMMARY.md +4 -2
- package/cli/assets/skill/data/templates/docs/tasks/taskbook.md +7 -6
- package/cli/assets/skill/scripts/ap.py +1589 -77
- package/cli/src/index.js +303 -53
- package/cli/tests/index.test.js +146 -0
- package/package.json +7 -7
- package/cli/assets/skill/data/templates/bridges/CODEX.md +0 -8
package/cli/src/index.js
CHANGED
|
@@ -16,7 +16,7 @@ function takeValue(rest, index, flag){
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function parseArgs(argv){
|
|
19
|
-
const args = { cmd: null, ai: null, mode: "project", dest: null, force: false };
|
|
19
|
+
const args = { cmd: null, ai: null, mode: "project", dest: null, force: false, dryRun: false, json: false, projects: [] };
|
|
20
20
|
const [,, cmd, ...rest] = argv;
|
|
21
21
|
args.cmd = (!cmd || cmd === "-h" || cmd === "--help") ? "help" : cmd;
|
|
22
22
|
for (let i = 0; i < rest.length; i++) {
|
|
@@ -33,8 +33,15 @@ function parseArgs(argv){
|
|
|
33
33
|
args.dest = takeValue(rest, i, a);
|
|
34
34
|
i += 1;
|
|
35
35
|
}
|
|
36
|
+
else if (a === "--projects") {
|
|
37
|
+
args.projects.push(...takeValue(rest, i, a).split(",").map(x => x.trim()).filter(Boolean));
|
|
38
|
+
i += 1;
|
|
39
|
+
}
|
|
40
|
+
else if (a === "--dry-run") args.dryRun = true;
|
|
41
|
+
else if (a === "--json") args.json = true;
|
|
36
42
|
else if (a === "--force") args.force = true;
|
|
37
43
|
else if (a === "-h" || a === "--help") args.cmd = "help";
|
|
44
|
+
else if (!a.startsWith("--")) args.projects.push(a);
|
|
38
45
|
else die(`unknown argument: ${a}`);
|
|
39
46
|
}
|
|
40
47
|
return args;
|
|
@@ -57,37 +64,258 @@ function copyDir(src, dst){
|
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
|
|
60
|
-
function
|
|
67
|
+
function listFiles(root, base = root){
|
|
68
|
+
if (!exists(root)) return [];
|
|
69
|
+
const out = [];
|
|
70
|
+
for (const ent of fs.readdirSync(root, { withFileTypes: true })) {
|
|
71
|
+
if (shouldSkip(ent.name)) continue;
|
|
72
|
+
const p = path.join(root, ent.name);
|
|
73
|
+
if (ent.isDirectory()) out.push(...listFiles(p, base));
|
|
74
|
+
else out.push(path.relative(base, p));
|
|
75
|
+
}
|
|
76
|
+
return out.sort();
|
|
77
|
+
}
|
|
61
78
|
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
79
|
+
function compareDirs(src, dst, options = {}){
|
|
80
|
+
const includeExtra = options.includeExtra ?? true;
|
|
81
|
+
const diffs = [];
|
|
82
|
+
const srcFiles = listFiles(src);
|
|
83
|
+
const dstFiles = listFiles(dst);
|
|
84
|
+
const srcSet = new Set(srcFiles);
|
|
85
|
+
const dstSet = new Set(dstFiles);
|
|
86
|
+
for (const rel of srcFiles) {
|
|
87
|
+
if (!dstSet.has(rel)) {
|
|
88
|
+
diffs.push({ path: rel, status: "missing" });
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const srcBuf = fs.readFileSync(path.join(src, rel));
|
|
92
|
+
const dstBuf = fs.readFileSync(path.join(dst, rel));
|
|
93
|
+
if (!srcBuf.equals(dstBuf)) diffs.push({ path: rel, status: "stale" });
|
|
94
|
+
}
|
|
95
|
+
if (includeExtra) {
|
|
96
|
+
for (const rel of dstFiles) {
|
|
97
|
+
if (!srcSet.has(rel)) diffs.push({ path: rel, status: "extra" });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return diffs;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function copyMissingDocs(assetSkill, project){
|
|
104
|
+
const srcDocs = path.join(assetSkill, "data", "templates", "docs");
|
|
105
|
+
const dstDocs = path.join(project, "docs");
|
|
106
|
+
const copied = [];
|
|
107
|
+
for (const rel of listFiles(srcDocs)) {
|
|
108
|
+
const src = path.join(srcDocs, rel);
|
|
109
|
+
const dst = path.join(dstDocs, rel);
|
|
110
|
+
if (!exists(dst)) {
|
|
111
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
112
|
+
fs.copyFileSync(src, dst);
|
|
113
|
+
copied.push(path.join("docs", rel));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return copied;
|
|
117
|
+
}
|
|
65
118
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
119
|
+
function readPackageVersion(){
|
|
120
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
121
|
+
const pkgPath = path.resolve(here, "..", "..", "package.json");
|
|
122
|
+
try {
|
|
123
|
+
return JSON.parse(fs.readFileSync(pkgPath, "utf8")).version ?? "unknown";
|
|
124
|
+
} catch {
|
|
125
|
+
return "unknown";
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function extractFrontmatter(text){
|
|
130
|
+
const match = text.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
|
131
|
+
return match ? match[1] : "";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function frontmatterHasPath(text, keyPath){
|
|
135
|
+
const frontmatter = extractFrontmatter(text);
|
|
136
|
+
if (!frontmatter) return false;
|
|
137
|
+
|
|
138
|
+
const stack = [];
|
|
139
|
+
for (const rawLine of frontmatter.split(/\r?\n/)) {
|
|
140
|
+
if (!rawLine.trim() || rawLine.trim().startsWith("#")) continue;
|
|
141
|
+
const match = rawLine.match(/^(\s*)(["']?[^:"']+["']?)\s*:/);
|
|
142
|
+
if (!match) continue;
|
|
143
|
+
|
|
144
|
+
const indent = match[1].replace(/\t/g, " ").length;
|
|
145
|
+
const key = match[2].replace(/^["']|["']$/g, "").trim();
|
|
146
|
+
while (stack.length && stack[stack.length - 1].indent >= indent) stack.pop();
|
|
147
|
+
const currentPath = [...stack.map(item => item.key), key];
|
|
148
|
+
if (currentPath.length === keyPath.length && currentPath.every((part, index) => part === keyPath[index])) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
stack.push({ indent, key });
|
|
70
152
|
}
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
71
155
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
156
|
+
function projectStatus(project, assetSkill, assetAgents){
|
|
157
|
+
const root = path.resolve(project);
|
|
158
|
+
const skillDir = path.join(root, ".agents", "skills", "auto-coding-skill");
|
|
159
|
+
const agentsDir = path.join(root, ".agents", "agents");
|
|
160
|
+
const toolDir = path.join(root, "docs", "tools", "autopipeline");
|
|
161
|
+
const engineering = path.join(root, "docs", "ENGINEERING.md");
|
|
162
|
+
const engineeringMissing = !exists(engineering);
|
|
163
|
+
const requiredConfigPaths = [
|
|
164
|
+
{ label: "structure", path: ["structure"] },
|
|
165
|
+
{ label: "optimization", path: ["optimization"] },
|
|
166
|
+
{ label: "verification.target_env_required", path: ["verification", "target_env_required"] },
|
|
167
|
+
{ label: "verification.jenkins_required", path: ["verification", "jenkins_required"] },
|
|
168
|
+
{ label: "docs.evidence_log", path: ["docs", "evidence_log"] },
|
|
169
|
+
{ label: "docs.task_archive_dir", path: ["docs", "task_archive_dir"] },
|
|
170
|
+
{ label: "docs.design_archive_dir", path: ["docs", "design_archive_dir"] },
|
|
171
|
+
{ label: "docs.archive_index", path: ["docs", "archive_index"] },
|
|
172
|
+
{ label: "docs.active_taskbook_max_lines", path: ["docs", "active_taskbook_max_lines"] },
|
|
173
|
+
{ label: "docs.active_closure_log_max_lines", path: ["docs", "active_closure_log_max_lines"] },
|
|
174
|
+
{ label: "docs.active_design_max_files", path: ["docs", "active_design_max_files"] },
|
|
175
|
+
{ label: "docs.health_baseline", path: ["docs", "health_baseline"] },
|
|
176
|
+
{ label: "docs.optimization_backlog", path: ["docs", "optimization_backlog"] },
|
|
177
|
+
{ label: "docs.structure_standard", path: ["docs", "structure_standard"] },
|
|
178
|
+
];
|
|
179
|
+
let missingConfigTokens = requiredConfigPaths.map(item => item.label);
|
|
180
|
+
if (!engineeringMissing) {
|
|
181
|
+
const text = fs.readFileSync(engineering, "utf8");
|
|
182
|
+
missingConfigTokens = requiredConfigPaths
|
|
183
|
+
.filter(item => !frontmatterHasPath(text, item.path))
|
|
184
|
+
.map(item => item.label);
|
|
185
|
+
}
|
|
186
|
+
const scriptDiffs = [];
|
|
187
|
+
for (const name of ["ap.py", "core.py", "http_checks.py"]) {
|
|
188
|
+
const src = path.join(assetSkill, "scripts", name);
|
|
189
|
+
const dst = path.join(toolDir, name);
|
|
190
|
+
if (!exists(dst)) scriptDiffs.push({ path: path.join("docs/tools/autopipeline", name), status: "missing" });
|
|
191
|
+
else if (!fs.readFileSync(src).equals(fs.readFileSync(dst))) scriptDiffs.push({ path: path.join("docs/tools/autopipeline", name), status: "stale" });
|
|
192
|
+
}
|
|
193
|
+
const missingDocs = [];
|
|
194
|
+
const srcDocs = path.join(assetSkill, "data", "templates", "docs");
|
|
195
|
+
for (const rel of listFiles(srcDocs)) {
|
|
196
|
+
if (!exists(path.join(root, "docs", rel))) missingDocs.push(path.join("docs", rel));
|
|
76
197
|
}
|
|
198
|
+
const skillDiffs = exists(skillDir) ? compareDirs(assetSkill, skillDir) : [{ path: ".agents/skills/auto-coding-skill", status: "missing" }];
|
|
199
|
+
const agentDiffs = exists(agentsDir) ? compareDirs(assetAgents, agentsDir, { includeExtra: false }) : [{ path: ".agents/agents", status: "missing" }];
|
|
200
|
+
const ok = skillDiffs.length === 0 && agentDiffs.length === 0 && scriptDiffs.length === 0 && missingDocs.length === 0 && missingConfigTokens.length === 0;
|
|
201
|
+
let next = "";
|
|
202
|
+
if (!exists(skillDir) || !exists(agentsDir)) {
|
|
203
|
+
next = "run autocoding init --force";
|
|
204
|
+
} else if (skillDiffs.length || agentDiffs.length) {
|
|
205
|
+
next = "run autocoding sync --projects <repo>";
|
|
206
|
+
} else if (engineeringMissing || scriptDiffs.length || missingDocs.length) {
|
|
207
|
+
next = "run autocoding sync --projects <repo> or python3 .agents/skills/auto-coding-skill/scripts/ap.py --repo . install";
|
|
208
|
+
} else if (missingConfigTokens.length) {
|
|
209
|
+
next = "run project-local ap.py upgrade --write to merge docs/ENGINEERING.md safely";
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
project: root,
|
|
213
|
+
ok,
|
|
214
|
+
skillDiffs,
|
|
215
|
+
agentDiffs,
|
|
216
|
+
scriptDiffs,
|
|
217
|
+
missingDocs,
|
|
218
|
+
missingConfigTokens,
|
|
219
|
+
next,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
77
222
|
|
|
78
|
-
|
|
223
|
+
function printProjectStatus(result){
|
|
224
|
+
console.log(`[autocoding] project=${result.project}`);
|
|
225
|
+
console.log(`[autocoding] ok=${result.ok}`);
|
|
226
|
+
for (const [label, items] of [["skill", result.skillDiffs], ["agents", result.agentDiffs], ["scripts", result.scriptDiffs]]) {
|
|
227
|
+
for (const item of items) console.log(`[autocoding] ${label} ${item.status}: ${item.path}`);
|
|
228
|
+
}
|
|
229
|
+
for (const item of result.missingDocs) console.log(`[autocoding] doc missing: ${item}`);
|
|
230
|
+
for (const item of result.missingConfigTokens) console.log(`[autocoding] config missing path: ${item}`);
|
|
231
|
+
if (result.next) console.log(`[autocoding] next: ${result.next}`);
|
|
79
232
|
}
|
|
80
233
|
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
234
|
+
function syncProject(project, assetSkill, assetAgents, dryRun){
|
|
235
|
+
const root = path.resolve(project);
|
|
236
|
+
const actions = [];
|
|
237
|
+
const skillDir = path.join(root, ".agents", "skills", "auto-coding-skill");
|
|
238
|
+
const agentsDir = path.join(root, ".agents", "agents");
|
|
239
|
+
const toolDir = path.join(root, "docs", "tools", "autopipeline");
|
|
240
|
+
const engineering = path.join(root, "docs", "ENGINEERING.md");
|
|
241
|
+
const engineeringWasMissing = !exists(engineering);
|
|
242
|
+
const templateEngineering = path.join(assetSkill, "data", "templates", "ENGINEERING.md");
|
|
243
|
+
actions.push({ action: dryRun ? "would-sync" : "sync", path: path.relative(root, skillDir) });
|
|
244
|
+
actions.push({ action: dryRun ? "would-sync" : "sync", path: path.relative(root, agentsDir) });
|
|
245
|
+
for (const name of ["ap.py", "core.py", "http_checks.py"]) {
|
|
246
|
+
actions.push({ action: dryRun ? "would-sync" : "sync", path: path.join("docs/tools/autopipeline", name) });
|
|
86
247
|
}
|
|
248
|
+
if (!dryRun) {
|
|
249
|
+
rmrf(skillDir);
|
|
250
|
+
copyDir(assetSkill, skillDir);
|
|
251
|
+
copyDir(assetAgents, agentsDir);
|
|
252
|
+
fs.mkdirSync(toolDir, { recursive: true });
|
|
253
|
+
for (const name of ["ap.py", "core.py", "http_checks.py"]) {
|
|
254
|
+
fs.copyFileSync(path.join(assetSkill, "scripts", name), path.join(toolDir, name));
|
|
255
|
+
}
|
|
256
|
+
for (const copied of copyMissingDocs(assetSkill, root)) actions.push({ action: "create", path: copied });
|
|
257
|
+
if (engineeringWasMissing) {
|
|
258
|
+
fs.mkdirSync(path.dirname(engineering), { recursive: true });
|
|
259
|
+
fs.copyFileSync(templateEngineering, engineering);
|
|
260
|
+
actions.push({ action: "create", path: path.join("docs", "ENGINEERING.md") });
|
|
261
|
+
}
|
|
262
|
+
} else {
|
|
263
|
+
const srcDocs = path.join(assetSkill, "data", "templates", "docs");
|
|
264
|
+
for (const rel of listFiles(srcDocs)) {
|
|
265
|
+
if (!exists(path.join(root, "docs", rel))) actions.push({ action: "would-create", path: path.join("docs", rel) });
|
|
266
|
+
}
|
|
267
|
+
if (engineeringWasMissing) actions.push({ action: "would-create", path: path.join("docs", "ENGINEERING.md") });
|
|
268
|
+
}
|
|
269
|
+
if (!engineeringWasMissing) {
|
|
270
|
+
actions.push({ action: "manual", path: "docs/ENGINEERING.md", detail: "merge existing files with ap.py upgrade --write" });
|
|
271
|
+
}
|
|
272
|
+
return { project: root, dryRun, actions };
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function projectRoot(){ return process.cwd(); }
|
|
276
|
+
|
|
277
|
+
function resolveInstallDirs(mode, destOverride){
|
|
87
278
|
if (mode !== "project" && mode !== "global") die(`--mode must be 'project' or 'global'`);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
279
|
+
|
|
280
|
+
if (destOverride) {
|
|
281
|
+
const dest = path.resolve(destOverride);
|
|
282
|
+
const parent = path.dirname(dest);
|
|
283
|
+
const grandparent = path.dirname(parent);
|
|
284
|
+
if (path.basename(dest) === "auto-coding-skill" && path.basename(parent) === "skills" && path.basename(grandparent) === ".agents") {
|
|
285
|
+
return {
|
|
286
|
+
skillDir: dest,
|
|
287
|
+
agentsDir: path.join(grandparent, "agents"),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
if (path.basename(dest) === "skills" && path.basename(parent) === ".agents") {
|
|
291
|
+
return {
|
|
292
|
+
skillDir: path.join(dest, "auto-coding-skill"),
|
|
293
|
+
agentsDir: path.join(parent, "agents"),
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
if (path.basename(dest) === "agents" && path.basename(parent) === ".agents") {
|
|
297
|
+
return {
|
|
298
|
+
skillDir: path.join(parent, "skills", "auto-coding-skill"),
|
|
299
|
+
agentsDir: dest,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
if (path.basename(dest) === ".agents") {
|
|
303
|
+
return {
|
|
304
|
+
skillDir: path.join(dest, "skills", "auto-coding-skill"),
|
|
305
|
+
agentsDir: path.join(dest, "agents"),
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
skillDir: path.join(dest, ".agents", "skills", "auto-coding-skill"),
|
|
310
|
+
agentsDir: path.join(dest, ".agents", "agents"),
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const root = mode === "project" ? projectRoot() : os.homedir();
|
|
315
|
+
return {
|
|
316
|
+
skillDir: path.join(root, ".agents", "skills", "auto-coding-skill"),
|
|
317
|
+
agentsDir: path.join(root, ".agents", "agents"),
|
|
318
|
+
};
|
|
91
319
|
}
|
|
92
320
|
|
|
93
321
|
function main(){
|
|
@@ -95,54 +323,76 @@ function main(){
|
|
|
95
323
|
|
|
96
324
|
if (args.cmd === "help" || !args.cmd) {
|
|
97
325
|
console.log(`
|
|
98
|
-
autocoding - install auto-coding-skill
|
|
326
|
+
autocoding - install auto-coding-skill into generic .agents paths
|
|
99
327
|
|
|
100
328
|
Usage:
|
|
101
|
-
autocoding init
|
|
329
|
+
autocoding init [--mode project|global] [--dest <repo-root|.agents-dir|skill-dir>] [--force]
|
|
330
|
+
autocoding status --projects <path[,path...]> [--json]
|
|
331
|
+
autocoding sync --projects <path[,path...]> [--dry-run] [--json]
|
|
102
332
|
|
|
103
333
|
Examples:
|
|
104
|
-
autocoding init
|
|
105
|
-
autocoding
|
|
106
|
-
autocoding
|
|
107
|
-
|
|
334
|
+
autocoding init
|
|
335
|
+
autocoding status --projects /Users/elvis/Product/xjmate,/Users/elvis/Product/geesight
|
|
336
|
+
autocoding sync --projects /Users/elvis/Product/xjmate --dry-run
|
|
337
|
+
|
|
338
|
+
Compatibility:
|
|
339
|
+
--ai <value> is accepted for old scripts and ignored.
|
|
108
340
|
`);
|
|
109
341
|
process.exit(0);
|
|
110
342
|
}
|
|
111
343
|
|
|
112
|
-
if (args.cmd !== "init") die(`unknown command: ${args.cmd}`);
|
|
113
|
-
|
|
114
|
-
const ai = (args.ai ?? "").toLowerCase();
|
|
115
|
-
const targets = ai === "all" ? ["claude", "codex"] : [ai];
|
|
116
|
-
if (!(["claude", "codex", "all"].includes(ai))) die(`--ai must be claude|codex|all`);
|
|
117
|
-
|
|
118
344
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
119
345
|
const assetSkill = path.resolve(here, "..", "assets", "skill");
|
|
120
346
|
const assetAgents = path.resolve(here, "..", "assets", "agents");
|
|
121
347
|
if (!exists(assetSkill)) die(`missing assets at ${assetSkill}`);
|
|
122
348
|
if (!exists(assetAgents)) die(`missing assets at ${assetAgents}`);
|
|
123
349
|
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
350
|
+
if (args.cmd === "status") {
|
|
351
|
+
const projects = args.projects.length ? args.projects : [projectRoot()];
|
|
352
|
+
const results = projects.map(project => projectStatus(project, assetSkill, assetAgents));
|
|
353
|
+
if (args.json) console.log(JSON.stringify({ version: readPackageVersion(), results }, null, 2));
|
|
354
|
+
else {
|
|
355
|
+
console.log(`[autocoding] version=${readPackageVersion()}`);
|
|
356
|
+
for (const result of results) printProjectStatus(result);
|
|
357
|
+
}
|
|
358
|
+
process.exit(results.every(result => result.ok) ? 0 : 2);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (args.cmd === "sync") {
|
|
362
|
+
const projects = args.projects.length ? args.projects : [projectRoot()];
|
|
363
|
+
const results = projects.map(project => syncProject(project, assetSkill, assetAgents, args.dryRun));
|
|
364
|
+
if (args.json) console.log(JSON.stringify({ version: readPackageVersion(), results }, null, 2));
|
|
365
|
+
else {
|
|
366
|
+
console.log(`[autocoding] version=${readPackageVersion()}`);
|
|
367
|
+
for (const result of results) {
|
|
368
|
+
console.log(`[autocoding] project=${result.project}`);
|
|
369
|
+
console.log(`[autocoding] dryRun=${result.dryRun}`);
|
|
370
|
+
for (const item of result.actions) {
|
|
371
|
+
const detail = item.detail ? ` - ${item.detail}` : "";
|
|
372
|
+
console.log(`[autocoding] ${item.action}: ${item.path}${detail}`);
|
|
373
|
+
}
|
|
141
374
|
}
|
|
142
|
-
copyDir(assetAgents, agentsDst);
|
|
143
|
-
console.log(`[autocoding] installed Codex agents to: ${agentsDst}`);
|
|
144
375
|
}
|
|
376
|
+
process.exit(0);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (args.cmd !== "init") die(`unknown command: ${args.cmd}`);
|
|
380
|
+
|
|
381
|
+
if (args.ai) console.warn("[autocoding] --ai is deprecated and ignored; installing generic .agents.");
|
|
382
|
+
|
|
383
|
+
const { skillDir, agentsDir } = resolveInstallDirs(args.mode, args.dest);
|
|
384
|
+
const existingTargets = [skillDir, agentsDir].filter(target => exists(target));
|
|
385
|
+
if (existingTargets.length && !args.force) {
|
|
386
|
+
die(`target exists: ${existingTargets.join(", ")}\nRe-run with --force to overwrite managed templates.`);
|
|
145
387
|
}
|
|
388
|
+
if (exists(skillDir)) {
|
|
389
|
+
rmrf(skillDir);
|
|
390
|
+
}
|
|
391
|
+
copyDir(assetSkill, skillDir);
|
|
392
|
+
console.log(`[autocoding] installed skill to: ${skillDir}`);
|
|
393
|
+
|
|
394
|
+
copyDir(assetAgents, agentsDir);
|
|
395
|
+
console.log(`[autocoding] installed agents to: ${agentsDir}`);
|
|
146
396
|
|
|
147
397
|
console.log("[autocoding] done.");
|
|
148
398
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
8
|
+
const cli = path.join(repoRoot, "cli", "src", "index.js");
|
|
9
|
+
const assetAp = path.join(repoRoot, "cli", "assets", "skill", "scripts", "ap.py");
|
|
10
|
+
|
|
11
|
+
function assert(condition, message) {
|
|
12
|
+
if (!condition) throw new Error(message);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function exists(p) {
|
|
16
|
+
return fs.existsSync(p);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function tmpdir(name) {
|
|
20
|
+
return fs.mkdtempSync(path.join(os.tmpdir(), `autocoding-${name}.`));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function run(command, args, options = {}) {
|
|
24
|
+
const result = spawnSync(command, args, {
|
|
25
|
+
cwd: options.cwd ?? repoRoot,
|
|
26
|
+
encoding: "utf8",
|
|
27
|
+
stdio: "pipe",
|
|
28
|
+
});
|
|
29
|
+
if (options.check !== false && result.status !== 0) {
|
|
30
|
+
throw new Error([
|
|
31
|
+
`command failed: ${command} ${args.join(" ")}`,
|
|
32
|
+
`cwd=${options.cwd ?? repoRoot}`,
|
|
33
|
+
`status=${result.status}`,
|
|
34
|
+
result.stdout,
|
|
35
|
+
result.stderr,
|
|
36
|
+
].join("\n"));
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function writeFile(file, text) {
|
|
42
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
43
|
+
fs.writeFileSync(file, text);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function assertStatusOk(repo) {
|
|
47
|
+
const result = run("node", [cli, "status", "--projects", repo, "--json"]);
|
|
48
|
+
const parsed = JSON.parse(result.stdout);
|
|
49
|
+
assert(parsed.results[0].ok === true, `status should be ok: ${result.stdout}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function testPreflightAvoidsPartialInstall() {
|
|
53
|
+
const repo = tmpdir("partial-init");
|
|
54
|
+
writeFile(path.join(repo, ".agents", "agents", "custom.toml"), 'name = "custom"\n');
|
|
55
|
+
const result = run("node", [cli, "init"], { cwd: repo, check: false });
|
|
56
|
+
assert(result.status !== 0, "init should fail when agents target exists without --force");
|
|
57
|
+
assert(!exists(path.join(repo, ".agents", "skills", "auto-coding-skill")), "failed init must not leave a partial skill copy");
|
|
58
|
+
assert(exists(path.join(repo, ".agents", "agents", "custom.toml")), "existing custom agent should remain");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function testDestVariants() {
|
|
62
|
+
const variants = [
|
|
63
|
+
{
|
|
64
|
+
name: "repo-root",
|
|
65
|
+
dest(root) { return root; },
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "agents-root",
|
|
69
|
+
dest(root) { return path.join(root, ".agents"); },
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "skills-dir",
|
|
73
|
+
dest(root) { return path.join(root, ".agents", "skills"); },
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "agents-dir",
|
|
77
|
+
dest(root) { return path.join(root, ".agents", "agents"); },
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "direct-skill",
|
|
81
|
+
dest(root) { return path.join(root, ".agents", "skills", "auto-coding-skill"); },
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
for (const variant of variants) {
|
|
86
|
+
const root = tmpdir(`dest-${variant.name}`);
|
|
87
|
+
const dest = variant.dest(root);
|
|
88
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
89
|
+
run("node", [cli, "init", "--dest", dest, "--force"]);
|
|
90
|
+
assert(exists(path.join(root, ".agents", "skills", "auto-coding-skill", "SKILL.md")), `${variant.name}: missing skill`);
|
|
91
|
+
assert(exists(path.join(root, ".agents", "agents", "explorer.toml")), `${variant.name}: missing agent`);
|
|
92
|
+
assert(!exists(path.join(root, ".agents", ".agents")), `${variant.name}: nested .agents should not be created`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function testSyncCreatesScaffoldAndStatusConverges() {
|
|
97
|
+
const repo = tmpdir("sync-converges");
|
|
98
|
+
run("node", [cli, "init"], { cwd: repo });
|
|
99
|
+
const before = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
|
|
100
|
+
assert(before.status !== 0, "status should fail before docs/tooling scaffold exists");
|
|
101
|
+
assert(before.stdout.includes("autocoding sync"), "status should point to sync for missing scaffold");
|
|
102
|
+
run("node", [cli, "sync", "--projects", repo]);
|
|
103
|
+
assert(exists(path.join(repo, "docs", "ENGINEERING.md")), "sync should create docs/ENGINEERING.md when missing");
|
|
104
|
+
assertStatusOk(repo);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function testForcePreservesCustomAgents() {
|
|
108
|
+
const repo = tmpdir("custom-agent");
|
|
109
|
+
run("node", [cli, "init", "--force"], { cwd: repo });
|
|
110
|
+
const custom = path.join(repo, ".agents", "agents", "custom-local.toml");
|
|
111
|
+
writeFile(custom, 'name = "custom-local"\ndescription = "custom"\nmodel = "gpt-5.5"\n');
|
|
112
|
+
run("node", [cli, "init", "--force"], { cwd: repo });
|
|
113
|
+
assert(exists(custom), "custom agent should be preserved");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function testBridgeIsGeneric() {
|
|
117
|
+
const repo = tmpdir("bridge");
|
|
118
|
+
run("node", [cli, "init", "--force"], { cwd: repo });
|
|
119
|
+
const ap = path.join(repo, ".agents", "skills", "auto-coding-skill", "scripts", "ap.py");
|
|
120
|
+
run("python3", [ap, "--repo", repo, "install", "--bridges"]);
|
|
121
|
+
assert(exists(path.join(repo, "AGENTS.md")), "generic bridge should be created");
|
|
122
|
+
for (const filename of [`CO${"DEX.md"}`, `CLA${"UDE.md"}`]) {
|
|
123
|
+
assert(!exists(path.join(repo, filename)), "client-named bridge should not be created");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function testUpgradeCleansManagedBridgeExtrasOnly() {
|
|
128
|
+
const repo = tmpdir("upgrade-extra");
|
|
129
|
+
run("git", ["init", "-q"], { cwd: repo });
|
|
130
|
+
run("node", [cli, "init", "--force"], { cwd: repo });
|
|
131
|
+
run("node", [cli, "sync", "--projects", repo]);
|
|
132
|
+
writeFile(path.join(repo, ".agents", "skills", "auto-coding-skill", "data", "templates", "bridges", "OLD.md"), "old\n");
|
|
133
|
+
writeFile(path.join(repo, ".agents", "skills", "auto-coding-skill", "custom.txt"), "custom\n");
|
|
134
|
+
run("python3", [assetAp, "--repo", repo, "upgrade", "--write"]);
|
|
135
|
+
assert(!exists(path.join(repo, ".agents", "skills", "auto-coding-skill", "data", "templates", "bridges", "OLD.md")), "managed bridge extra should be removed");
|
|
136
|
+
assert(exists(path.join(repo, ".agents", "skills", "auto-coding-skill", "custom.txt")), "non-managed extra should remain");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
testPreflightAvoidsPartialInstall();
|
|
140
|
+
testDestVariants();
|
|
141
|
+
testSyncCreatesScaffoldAndStatusConverges();
|
|
142
|
+
testForcePreservesCustomAgents();
|
|
143
|
+
testBridgeIsGeneric();
|
|
144
|
+
testUpgradeCleansManagedBridgeExtrasOnly();
|
|
145
|
+
|
|
146
|
+
console.log("cli-installer-regression-ok");
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elvis1513/auto-coding-skill",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "CLI installer for
|
|
3
|
+
"version": "2.1.1",
|
|
4
|
+
"description": "CLI installer for a generic .agents engineering workflow with optional CI/Jenkins and target-environment verification.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"autocoding": "cli/src/index.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"cli/src",
|
|
11
|
+
"cli/tests",
|
|
11
12
|
"cli/assets/skill",
|
|
12
13
|
"cli/assets/agents",
|
|
13
14
|
"README.md",
|
|
14
15
|
"LICENSE"
|
|
15
16
|
],
|
|
16
17
|
"scripts": {
|
|
17
|
-
"test": "node -c cli/src/index.js && node -c cli/src/sync-assets.js && python3 -c \"import ast, pathlib; files = ['
|
|
18
|
+
"test": "node -c cli/src/index.js && node -c cli/src/sync-assets.js && node -c cli/tests/index.test.js && node cli/tests/index.test.js && python3 -c \"import ast, pathlib; files = ['cli/assets/skill/scripts/ap.py', 'cli/assets/skill/scripts/core.py', 'cli/assets/skill/scripts/http_checks.py']; [ast.parse(pathlib.Path(rel).read_text(encoding='utf-8'), filename=rel, feature_version=(3, 11)) for rel in files]; print('python311-asset-grammar-ok')\" && python3 -m py_compile cli/assets/skill/scripts/ap.py cli/assets/skill/scripts/core.py cli/assets/skill/scripts/http_checks.py && python3 -c \"import pathlib, tomllib; files = sorted(pathlib.Path('cli/assets/agents').glob('*.toml')); [tomllib.loads(path.read_text(encoding='utf-8')) for path in files]; print('asset-agent-toml-ok')\" && find cli -type d -name '__pycache__' -prune -exec rm -rf {} +",
|
|
19
|
+
"test:src": "python3 -c \"import ast, pathlib; files = ['src/auto-coding-skill/scripts/ap.py', 'src/auto-coding-skill/scripts/core.py', 'src/auto-coding-skill/scripts/http_checks.py']; [ast.parse(pathlib.Path(rel).read_text(encoding='utf-8'), filename=rel, feature_version=(3, 11)) for rel in files]; print('python311-src-grammar-ok')\" && python3 -m py_compile src/auto-coding-skill/scripts/ap.py src/auto-coding-skill/scripts/core.py src/auto-coding-skill/scripts/http_checks.py && python3 -c \"import pathlib, tomllib; files = sorted(pathlib.Path('src/agents').glob('*.toml')); [tomllib.loads(path.read_text(encoding='utf-8')) for path in files]; print('src-agent-toml-ok')\" && find src -type d -name '__pycache__' -prune -exec rm -rf {} +",
|
|
18
20
|
"check:assets": "node cli/src/sync-assets.js --check",
|
|
19
21
|
"sync-assets": "node cli/src/sync-assets.js",
|
|
20
|
-
"release:check": "npm run sync-assets && npm run test && npm pack --dry-run"
|
|
22
|
+
"release:check": "npm run sync-assets && npm run check:assets && npm run test:src && npm run test && npm pack --dry-run"
|
|
21
23
|
},
|
|
22
24
|
"license": "MIT",
|
|
23
25
|
"publishConfig": {
|
|
24
26
|
"access": "public"
|
|
25
27
|
},
|
|
26
28
|
"keywords": [
|
|
27
|
-
"
|
|
28
|
-
"codex",
|
|
29
|
+
"agents",
|
|
29
30
|
"skill",
|
|
30
31
|
"automation",
|
|
31
32
|
"engineering",
|
|
32
33
|
"workflow",
|
|
33
34
|
"ci",
|
|
34
35
|
"jenkins",
|
|
35
|
-
"go",
|
|
36
36
|
"monorepo",
|
|
37
37
|
"docker",
|
|
38
38
|
"local-testing"
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
Follow `docs/ENGINEERING.md` strictly. Source of truth: `docs/ENGINEERING.md`.
|
|
2
|
-
Before code changes, read the configured structure standard and place new code in the correct layer; do not add new responsibilities to already-large files.
|
|
3
|
-
Before optimization reviews, read the project health baseline and optimization backlog, and report only new, worsened, unrecorded P0/P1, or upgraded-priority items.
|
|
4
|
-
Route work through already available MCP servers, installed skills, plugins, and app connectors when they provide current docs, design context, browser evidence, GitHub/CI state, security review, or artifact rendering.
|
|
5
|
-
Use the `.agents/agents` role model when available: explorer, docs_researcher, browser_debugger, fixer, reviewer. If the client cannot run subagents, execute the same roles sequentially in the main agent.
|
|
6
|
-
Default to the lightweight local gate first; when `structure.enabled` is true, the gate includes `structure-check`.
|
|
7
|
-
Use Jenkins build verification and real target-environment verification as the primary completion gate in verify mode.
|
|
8
|
-
Local Docker Compose and full local regression are on-demand diagnostic tools, not the default gate for every small change.
|