@elvis1513/auto-coding-skill 2.1.4 → 2.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.
Files changed (30) hide show
  1. package/README.md +163 -554
  2. package/cli/assets/agents/browser-debugger.toml +0 -1
  3. package/cli/assets/agents/docs-researcher.toml +0 -1
  4. package/cli/assets/agents/explorer.toml +1 -2
  5. package/cli/assets/agents/fixer.toml +2 -3
  6. package/cli/assets/agents/reviewer.toml +1 -2
  7. package/cli/assets/skill/SKILL.md +98 -207
  8. package/cli/assets/skill/data/templates/ENGINEERING.md +113 -468
  9. package/cli/assets/skill/data/templates/docs/tasks/closure-log.md +11 -22
  10. package/cli/assets/skill/data/templates/docs/tasks/taskbook.md +16 -39
  11. package/cli/assets/skill/data/templates/tools/ap.py +16 -0
  12. package/cli/assets/skill/scripts/ap.py +703 -138
  13. package/cli/assets/skill/scripts/scaffold_templates.py +136 -0
  14. package/cli/src/index.js +317 -42
  15. package/cli/tests/ap_profiles_test.py +428 -0
  16. package/cli/tests/index.test.js +376 -87
  17. package/package.json +3 -3
  18. package/cli/assets/skill/data/templates/docs/architecture/adr/_TEMPLATE-ADR.md +0 -38
  19. package/cli/assets/skill/data/templates/docs/architecture/structure-standard.md +0 -92
  20. package/cli/assets/skill/data/templates/docs/bugs/bug-list.md +0 -5
  21. package/cli/assets/skill/data/templates/docs/deployment/deploy-records/_TEMPLATE-DEPLOY-RECORD.md +0 -19
  22. package/cli/assets/skill/data/templates/docs/deployment/deploy-runbook.md +0 -11
  23. package/cli/assets/skill/data/templates/docs/design/_TEMPLATE-DD.md +0 -49
  24. package/cli/assets/skill/data/templates/docs/interfaces/api-change-log.md +0 -11
  25. package/cli/assets/skill/data/templates/docs/interfaces/api.md +0 -36
  26. package/cli/assets/skill/data/templates/docs/reviews/_TEMPLATE-REVIEW.md +0 -36
  27. package/cli/assets/skill/data/templates/docs/reviews/optimization-backlog.md +0 -25
  28. package/cli/assets/skill/data/templates/docs/reviews/project-health-baseline.md +0 -66
  29. package/cli/assets/skill/data/templates/docs/tasks/summaries/_TEMPLATE-TASK-SUMMARY.md +0 -35
  30. package/cli/assets/skill/data/templates/docs/testing/regression-matrix.md +0 -11
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env python3
2
+ """Optional documentation templates materialized on demand."""
3
+
4
+ from __future__ import annotations
5
+
6
+
7
+ TEMPLATES: dict[str, dict[str, str]] = {
8
+ "api": {
9
+ "docs/interfaces/api.md": """# API Contract
10
+
11
+ Record only current, externally relevant endpoints or events.
12
+
13
+ | Method | Path / Event | Request | Response | Auth | Notes |
14
+ | --- | --- | --- | --- | --- | --- |
15
+ """,
16
+ "docs/interfaces/api-change-log.md": """# API Change Log
17
+
18
+ ## YYYY-MM-DD — <Task ID>
19
+
20
+ - Change:
21
+ - Compatibility:
22
+ - Migration / rollback:
23
+ """,
24
+ },
25
+ "design": {
26
+ "docs/design/_TEMPLATE-DD.md": """# DD — <Task ID> <Title>
27
+
28
+ - Status: Draft | Reviewed | Approved
29
+ - Related task: `docs/tasks/taskbook.md`
30
+
31
+ ## Context and goal
32
+ ## Scope and non-goals
33
+ ## Existing behavior and reuse points
34
+ ## Decision and alternatives
35
+ ## Interfaces / data changes
36
+ ## Validation and acceptance
37
+ ## Risks and rollback
38
+
39
+ Add sequence, ER, or component diagrams only when they clarify the change.
40
+ """,
41
+ },
42
+ "architecture": {
43
+ "docs/architecture/structure-standard.md": """# Project Structure Standard
44
+
45
+ Project conventions are authoritative. The generic checker is advisory unless
46
+ `structure.enforcement: blocking` is explicitly configured.
47
+
48
+ - Keep business, orchestration, external adapters, interfaces, and shared code
49
+ separated according to the repository's existing architecture.
50
+ - Search for reusable helpers, components, clients, and tests before adding new ones.
51
+ - Treat file-size and regex import findings as review signals, not proof.
52
+ - Split code only when cohesion, ownership, and testability improve.
53
+ - Record accepted legacy debt in the health baseline or optimization backlog.
54
+ """,
55
+ "docs/architecture/adr/_TEMPLATE-ADR.md": """# ADR-0000 — <Decision>
56
+
57
+ - Status: Proposed | Accepted | Superseded
58
+ - Date: YYYY-MM-DD
59
+ - Related task: <task id>
60
+
61
+ ## Context
62
+ ## Decision
63
+ ## Alternatives
64
+ ## Consequences
65
+ ## Validation
66
+ ## Rollback / supersession
67
+ """,
68
+ },
69
+ "review": {
70
+ "docs/reviews/_TEMPLATE-REVIEW.md": """# Review — <Task ID>
71
+
72
+ - Scope:
73
+ - Evidence:
74
+ - Gate:
75
+
76
+ ## Findings
77
+
78
+ List P0/P1/P2/P3 findings with impact, evidence, and remediation.
79
+
80
+ ## Verdict
81
+
82
+ PASS | PARTIAL | FAIL
83
+ """,
84
+ },
85
+ "testing": {
86
+ "docs/testing/regression-matrix.md": """# Regression Matrix
87
+
88
+ Only executed checks may be marked PASS.
89
+
90
+ | ID | Area | Feature | Test Type | Steps / Command | Expected | Status | Evidence |
91
+ | --- | --- | --- | --- | --- | --- | --- | --- |
92
+ | R-001 | <area> | <feature> | <manual/smoke/regression> | <steps/command> | <expected> | TODO | <evidence> |
93
+ """,
94
+ },
95
+ "deployment": {
96
+ "docs/deployment/deploy-runbook.md": """# Deployment Runbook
97
+
98
+ ## Preconditions
99
+ ## Deploy steps
100
+ ## Health and business checks
101
+ ## Rollback
102
+ ## Owners and escalation
103
+ """,
104
+ "docs/deployment/deploy-records/_TEMPLATE-DEPLOY-RECORD.md": """# Deployment Record — <Task ID>
105
+
106
+ - Environment:
107
+ - Commit / artifact:
108
+ - Pipeline:
109
+ - Verification:
110
+ - Result: PASS | FAIL | PARTIAL
111
+ - Rollback / follow-up:
112
+ """,
113
+ },
114
+ "bugs": {
115
+ "docs/bugs/bug-list.md": """# Bug List
116
+
117
+ | ID | Severity | Symptom | Reproduction | Owner | Status |
118
+ | --- | --- | --- | --- | --- | --- |
119
+ """,
120
+ },
121
+ }
122
+
123
+
124
+ def scaffold_groups() -> list[str]:
125
+ return sorted(TEMPLATES)
126
+
127
+
128
+ def templates_for(group: str) -> dict[str, str]:
129
+ if group == "all":
130
+ merged: dict[str, str] = {}
131
+ for name in scaffold_groups():
132
+ merged.update(TEMPLATES[name])
133
+ return merged
134
+ if group not in TEMPLATES:
135
+ raise KeyError(group)
136
+ return dict(TEMPLATES[group])
package/cli/src/index.js CHANGED
@@ -16,37 +16,94 @@ 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, dryRun: false, json: false, projects: [] };
19
+ const args = {
20
+ cmd: null,
21
+ ai: null,
22
+ mode: "project",
23
+ dest: null,
24
+ force: false,
25
+ dryRun: false,
26
+ json: false,
27
+ resetAgentModels: false,
28
+ projects: [],
29
+ provided: new Set(),
30
+ };
20
31
  const [,, cmd, ...rest] = argv;
21
32
  args.cmd = (!cmd || cmd === "-h" || cmd === "--help") ? "help" : cmd;
22
33
  for (let i = 0; i < rest.length; i++) {
23
34
  const a = rest[i];
24
35
  if (a === "--ai") {
25
36
  args.ai = takeValue(rest, i, a);
37
+ args.provided.add("ai");
26
38
  i += 1;
27
39
  }
28
40
  else if (a === "--mode") {
29
41
  args.mode = takeValue(rest, i, a);
42
+ args.provided.add("mode");
30
43
  i += 1;
31
44
  }
32
45
  else if (a === "--dest") {
33
46
  args.dest = takeValue(rest, i, a);
47
+ args.provided.add("dest");
34
48
  i += 1;
35
49
  }
36
50
  else if (a === "--projects") {
37
51
  args.projects.push(...takeValue(rest, i, a).split(",").map(x => x.trim()).filter(Boolean));
52
+ args.provided.add("projects");
38
53
  i += 1;
39
54
  }
40
- else if (a === "--dry-run") args.dryRun = true;
41
- else if (a === "--json") args.json = true;
42
- else if (a === "--force") args.force = true;
55
+ else if (a === "--dry-run") {
56
+ args.dryRun = true;
57
+ args.provided.add("dryRun");
58
+ }
59
+ else if (a === "--json") {
60
+ args.json = true;
61
+ args.provided.add("json");
62
+ }
63
+ else if (a === "--reset-agent-models") {
64
+ args.resetAgentModels = true;
65
+ args.provided.add("resetAgentModels");
66
+ }
67
+ else if (a === "--force") {
68
+ args.force = true;
69
+ args.provided.add("force");
70
+ }
43
71
  else if (a === "-h" || a === "--help") args.cmd = "help";
44
- else if (!a.startsWith("--")) args.projects.push(a);
72
+ else if (!a.startsWith("--")) {
73
+ args.projects.push(a);
74
+ args.provided.add("projects");
75
+ }
45
76
  else die(`unknown argument: ${a}`);
46
77
  }
47
78
  return args;
48
79
  }
49
80
 
81
+ const ARG_FLAGS = {
82
+ ai: "--ai",
83
+ mode: "--mode",
84
+ dest: "--dest",
85
+ force: "--force",
86
+ dryRun: "--dry-run",
87
+ json: "--json",
88
+ resetAgentModels: "--reset-agent-models",
89
+ projects: "--projects/positional project",
90
+ };
91
+
92
+ const COMMAND_ARGS = {
93
+ init: new Set(["ai", "mode", "dest", "force", "resetAgentModels"]),
94
+ status: new Set(["projects", "json"]),
95
+ sync: new Set(["projects", "dryRun", "json", "resetAgentModels"]),
96
+ };
97
+
98
+ function validateCommandArgs(args){
99
+ const allowed = COMMAND_ARGS[args.cmd];
100
+ if (!allowed) return;
101
+ const invalid = [...args.provided].filter(name => !allowed.has(name));
102
+ if (invalid.length) {
103
+ die(`${invalid.map(name => ARG_FLAGS[name] || name).join(", ")} not valid for '${args.cmd}'`);
104
+ }
105
+ }
106
+
50
107
  function exists(p){ try { fs.accessSync(p); return true; } catch { return false; } }
51
108
  function rmrf(p){ fs.rmSync(p, { recursive: true, force: true }); }
52
109
  function shouldSkip(name){
@@ -100,11 +157,195 @@ function compareDirs(src, dst, options = {}){
100
157
  return diffs;
101
158
  }
102
159
 
160
+ const CORE_DOCS = ["tasks/taskbook.md", "tasks/closure-log.md"];
161
+
162
+ function isEscapedAt(text, index){
163
+ let slashes = 0;
164
+ for (let i = index - 1; i >= 0 && text[i] === "\\"; i -= 1) slashes += 1;
165
+ return slashes % 2 === 1;
166
+ }
167
+
168
+ function nextMultilineState(line, initialState){
169
+ let state = initialState;
170
+ let quote = "";
171
+ for (let i = 0; i < line.length;) {
172
+ if (state) {
173
+ const close = line.indexOf(state, i);
174
+ if (close < 0) return state;
175
+ if (state === '"""' && isEscapedAt(line, close)) {
176
+ i = close + state.length;
177
+ continue;
178
+ }
179
+ state = "";
180
+ i = close + 3;
181
+ continue;
182
+ }
183
+ if (quote) {
184
+ if (line[i] === quote && (quote === "'" || !isEscapedAt(line, i))) quote = "";
185
+ i += 1;
186
+ continue;
187
+ }
188
+ if (line[i] === "#") return state;
189
+ if (line.startsWith('"""', i) || line.startsWith("'''", i)) {
190
+ state = line.slice(i, i + 3);
191
+ i += 3;
192
+ continue;
193
+ }
194
+ if (line[i] === '"' || line[i] === "'") quote = line[i];
195
+ i += 1;
196
+ }
197
+ return state;
198
+ }
199
+
200
+ function parseTomlStringValue(raw){
201
+ const value = raw.trimStart();
202
+ if (!value || (value[0] !== '"' && value[0] !== "'")) {
203
+ return { valid: false, error: "model must be a TOML string" };
204
+ }
205
+ const quote = value[0];
206
+ let decoded = "";
207
+ let end = -1;
208
+ for (let i = 1; i < value.length; i += 1) {
209
+ const ch = value[i];
210
+ if (ch === quote) {
211
+ end = i;
212
+ break;
213
+ }
214
+ if (quote === "'" || ch !== "\\") {
215
+ if (ch.charCodeAt(0) < 0x20) return { valid: false, error: "model contains a control character" };
216
+ decoded += ch;
217
+ continue;
218
+ }
219
+ i += 1;
220
+ if (i >= value.length) return { valid: false, error: "model has an incomplete escape" };
221
+ const escaped = value[i];
222
+ const simpleEscapes = { b: "\b", t: "\t", n: "\n", f: "\f", r: "\r", '"': '"', "\\": "\\" };
223
+ if (Object.hasOwn(simpleEscapes, escaped)) {
224
+ decoded += simpleEscapes[escaped];
225
+ continue;
226
+ }
227
+ if (escaped === "u" || escaped === "U") {
228
+ const length = escaped === "u" ? 4 : 8;
229
+ const hex = value.slice(i + 1, i + 1 + length);
230
+ if (hex.length !== length || !/^[0-9A-Fa-f]+$/.test(hex)) {
231
+ return { valid: false, error: `model has an invalid \\${escaped} escape` };
232
+ }
233
+ const codepoint = Number.parseInt(hex, 16);
234
+ if (codepoint > 0x10ffff || (codepoint >= 0xd800 && codepoint <= 0xdfff)) {
235
+ return { valid: false, error: "model has an invalid Unicode codepoint" };
236
+ }
237
+ decoded += String.fromCodePoint(codepoint);
238
+ i += length;
239
+ continue;
240
+ }
241
+ return { valid: false, error: `model has an unsupported escape \\${escaped}` };
242
+ }
243
+ if (end < 0) return { valid: false, error: "model string is not terminated" };
244
+ const trailing = value.slice(end + 1).trimStart();
245
+ if (trailing && !trailing.startsWith("#")) {
246
+ return { valid: false, error: "model must contain only one TOML string value" };
247
+ }
248
+ if (!decoded.trim()) return { valid: false, error: "model must be a non-empty string" };
249
+ return { valid: true, value: decoded };
250
+ }
251
+
252
+ function inspectTopLevelModel(text){
253
+ const lines = text.replace(/\r\n/g, "\n").split("\n");
254
+ const matches = [];
255
+ let multiline = "";
256
+ let inTable = false;
257
+ for (let index = 0; index < lines.length; index += 1) {
258
+ const line = lines[index];
259
+ if (!multiline) {
260
+ const trimmed = line.trimStart();
261
+ if (trimmed.startsWith("[") && !trimmed.startsWith("[#")) inTable = true;
262
+ if (!inTable) {
263
+ const match = line.match(/^\s*(?:model|"model"|'model')\s*=\s*(.*)$/);
264
+ if (match) {
265
+ const parsed = parseTomlStringValue(match[1]);
266
+ matches.push({ lineIndex: index, rawLine: line, ...parsed });
267
+ }
268
+ }
269
+ }
270
+ multiline = nextMultilineState(line, multiline);
271
+ }
272
+ if (matches.length > 1) {
273
+ return { valid: false, error: "model is defined more than once", matches };
274
+ }
275
+ if (!matches.length) return { valid: true, present: false, matches };
276
+ const model = matches[0];
277
+ if (!model.valid) return { valid: false, error: model.error, matches };
278
+ return { valid: true, present: true, value: model.value, rawLine: model.rawLine, lineIndex: model.lineIndex, matches };
279
+ }
280
+
281
+ function normalizeManagedAgent(text, modelInfo = inspectTopLevelModel(text)){
282
+ const lines = text.replace(/\r\n/g, "\n").split("\n");
283
+ if (modelInfo.valid && modelInfo.present) lines.splice(modelInfo.lineIndex, 1);
284
+ return lines.join("\n");
285
+ }
286
+
287
+ function renderManagedAgent(templateText, existingText, resetModel){
288
+ const existingModel = inspectTopLevelModel(existingText || "");
289
+ const modelLine = !resetModel && existingModel.valid && existingModel.present ? existingModel.rawLine : "";
290
+ let rendered = normalizeManagedAgent(templateText);
291
+ if (!modelLine) return rendered;
292
+ const lines = rendered.split("\n");
293
+ const descriptionIndex = lines.findIndex(line => line.startsWith("description = "));
294
+ lines.splice(descriptionIndex >= 0 ? descriptionIndex + 1 : 0, 0, modelLine);
295
+ return lines.join("\n");
296
+ }
297
+
298
+ function compareManagedAgents(assetAgents, agentsDir){
299
+ const diffs = [];
300
+ const bindings = [];
301
+ for (const rel of listFiles(assetAgents)) {
302
+ const src = path.join(assetAgents, rel);
303
+ const dst = path.join(agentsDir, rel);
304
+ if (!exists(dst)) {
305
+ diffs.push({ path: rel, status: "missing" });
306
+ bindings.push({ agent: rel, model: "inherit" });
307
+ continue;
308
+ }
309
+ const srcText = fs.readFileSync(src, "utf8");
310
+ const dstText = fs.readFileSync(dst, "utf8");
311
+ const srcModel = inspectTopLevelModel(srcText);
312
+ const dstModel = inspectTopLevelModel(dstText);
313
+ if (!srcModel.valid) throw new Error(`invalid managed agent template ${rel}: ${srcModel.error}`);
314
+ if (!dstModel.valid) {
315
+ diffs.push({ path: rel, status: "invalid-model", detail: dstModel.error });
316
+ } else if (normalizeManagedAgent(srcText, srcModel) !== normalizeManagedAgent(dstText, dstModel)) {
317
+ diffs.push({ path: rel, status: "stale" });
318
+ }
319
+ bindings.push({
320
+ agent: rel,
321
+ model: !dstModel.valid ? "invalid" : (dstModel.present ? dstModel.value : "inherit"),
322
+ });
323
+ }
324
+ return { diffs, bindings };
325
+ }
326
+
327
+ function syncManagedAgents(assetAgents, agentsDir, options = {}){
328
+ fs.mkdirSync(agentsDir, { recursive: true });
329
+ const bindings = [];
330
+ for (const rel of listFiles(assetAgents)) {
331
+ const src = path.join(assetAgents, rel);
332
+ const dst = path.join(agentsDir, rel);
333
+ const templateText = fs.readFileSync(src, "utf8");
334
+ const existingText = exists(dst) ? fs.readFileSync(dst, "utf8") : "";
335
+ const rendered = renderManagedAgent(templateText, existingText, options.resetModel === true);
336
+ fs.mkdirSync(path.dirname(dst), { recursive: true });
337
+ fs.writeFileSync(dst, rendered);
338
+ const model = inspectTopLevelModel(rendered);
339
+ bindings.push({ agent: rel, model: model.present ? model.value : "inherit" });
340
+ }
341
+ return bindings;
342
+ }
343
+
103
344
  function copyMissingDocs(assetSkill, project){
104
345
  const srcDocs = path.join(assetSkill, "data", "templates", "docs");
105
346
  const dstDocs = path.join(project, "docs");
106
347
  const copied = [];
107
- for (const rel of listFiles(srcDocs)) {
348
+ for (const rel of CORE_DOCS) {
108
349
  const src = path.join(srcDocs, rel);
109
350
  const dst = path.join(dstDocs, rel);
110
351
  if (!exists(dst)) {
@@ -116,6 +357,42 @@ function copyMissingDocs(assetSkill, project){
116
357
  return copied;
117
358
  }
118
359
 
360
+ function inferredGateCommands(project){
361
+ const pkg = path.join(project, "package.json");
362
+ if (!exists(pkg)) return {};
363
+ try {
364
+ const parsed = JSON.parse(fs.readFileSync(pkg, "utf8"));
365
+ const scripts = parsed?.scripts;
366
+ if (!scripts || typeof scripts !== "object") return {};
367
+ const inferred = {};
368
+ if (typeof scripts.test === "string" && scripts.test.trim()) {
369
+ inferred.gate_changed = typeof scripts["test:changed"] === "string" && scripts["test:changed"].trim()
370
+ ? "npm run test:changed"
371
+ : "npm test";
372
+ inferred.gate_standard = typeof scripts["test:standard"] === "string" && scripts["test:standard"].trim()
373
+ ? "npm run test:standard"
374
+ : "npm test";
375
+ }
376
+ if (typeof scripts["test:full"] === "string" && scripts["test:full"].trim()) {
377
+ inferred.gate_full = "npm run test:full";
378
+ }
379
+ return inferred;
380
+ } catch {
381
+ return {};
382
+ }
383
+ }
384
+
385
+ function renderEngineeringTemplate(templateText, project){
386
+ let rendered = templateText.replace(
387
+ 'project:\n name: ""',
388
+ `project:\n name: ${JSON.stringify(path.basename(path.resolve(project)))}`,
389
+ );
390
+ for (const [key, gate] of Object.entries(inferredGateCommands(project))) {
391
+ rendered = rendered.replace(` ${key}: ""`, ` ${key}: ${JSON.stringify(gate)}`);
392
+ }
393
+ return rendered;
394
+ }
395
+
119
396
  function readPackageVersion(){
120
397
  const here = path.dirname(fileURLToPath(import.meta.url));
121
398
  const pkgPath = path.resolve(here, "..", "..", "package.json");
@@ -161,20 +438,12 @@ function projectStatus(project, assetSkill, assetAgents){
161
438
  const engineering = path.join(root, "docs", "ENGINEERING.md");
162
439
  const engineeringMissing = !exists(engineering);
163
440
  const requiredConfigPaths = [
164
- { label: "structure", path: ["structure"] },
165
- { label: "optimization", path: ["optimization"] },
441
+ { label: "workflow.mode", path: ["workflow", "mode"] },
442
+ { label: "project.name", path: ["project", "name"] },
166
443
  { label: "verification.target_env_required", path: ["verification", "target_env_required"] },
167
444
  { 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"] },
445
+ { label: "docs.taskbook", path: ["docs", "taskbook"] },
446
+ { label: "docs.closure_log", path: ["docs", "closure_log"] },
178
447
  ];
179
448
  let missingConfigTokens = requiredConfigPaths.map(item => item.label);
180
449
  if (!engineeringMissing) {
@@ -184,19 +453,22 @@ function projectStatus(project, assetSkill, assetAgents){
184
453
  .map(item => item.label);
185
454
  }
186
455
  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" });
456
+ const launcherSrc = path.join(assetSkill, "data", "templates", "tools", "ap.py");
457
+ const launcherDst = path.join(toolDir, "ap.py");
458
+ if (!exists(launcherDst)) scriptDiffs.push({ path: "docs/tools/autopipeline/ap.py", status: "missing" });
459
+ else if (!fs.readFileSync(launcherSrc).equals(fs.readFileSync(launcherDst))) {
460
+ scriptDiffs.push({ path: "docs/tools/autopipeline/ap.py", status: "stale" });
192
461
  }
193
462
  const missingDocs = [];
194
463
  const srcDocs = path.join(assetSkill, "data", "templates", "docs");
195
- for (const rel of listFiles(srcDocs)) {
464
+ for (const rel of CORE_DOCS) {
196
465
  if (!exists(path.join(root, "docs", rel))) missingDocs.push(path.join("docs", rel));
197
466
  }
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" }];
467
+ const skillDiffs = exists(skillDir) ? compareDirs(assetSkill, skillDir, { includeExtra: false }) : [{ path: ".agents/skills/auto-coding-skill", status: "missing" }];
468
+ const agentStatus = exists(agentsDir)
469
+ ? compareManagedAgents(assetAgents, agentsDir)
470
+ : { diffs: [{ path: ".agents/agents", status: "missing" }], bindings: [] };
471
+ const agentDiffs = agentStatus.diffs;
200
472
  const ok = skillDiffs.length === 0 && agentDiffs.length === 0 && scriptDiffs.length === 0 && missingDocs.length === 0 && missingConfigTokens.length === 0;
201
473
  let next = "";
202
474
  if (!exists(skillDir) || !exists(agentsDir)) {
@@ -213,6 +485,7 @@ function projectStatus(project, assetSkill, assetAgents){
213
485
  ok,
214
486
  skillDiffs,
215
487
  agentDiffs,
488
+ agentBindings: agentStatus.bindings,
216
489
  scriptDiffs,
217
490
  missingDocs,
218
491
  missingConfigTokens,
@@ -224,14 +497,18 @@ function printProjectStatus(result){
224
497
  console.log(`[autocoding] project=${result.project}`);
225
498
  console.log(`[autocoding] ok=${result.ok}`);
226
499
  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}`);
500
+ for (const item of items) {
501
+ const detail = item.detail ? ` - ${item.detail}` : "";
502
+ console.log(`[autocoding] ${label} ${item.status}: ${item.path}${detail}`);
503
+ }
228
504
  }
229
505
  for (const item of result.missingDocs) console.log(`[autocoding] doc missing: ${item}`);
230
506
  for (const item of result.missingConfigTokens) console.log(`[autocoding] config missing path: ${item}`);
507
+ for (const item of result.agentBindings || []) console.log(`[autocoding] agent model: ${item.agent} -> ${item.model}`);
231
508
  if (result.next) console.log(`[autocoding] next: ${result.next}`);
232
509
  }
233
510
 
234
- function syncProject(project, assetSkill, assetAgents, dryRun){
511
+ function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels = false){
235
512
  const root = path.resolve(project);
236
513
  const actions = [];
237
514
  const skillDir = path.join(root, ".agents", "skills", "auto-coding-skill");
@@ -242,26 +519,21 @@ function syncProject(project, assetSkill, assetAgents, dryRun){
242
519
  const templateEngineering = path.join(assetSkill, "data", "templates", "ENGINEERING.md");
243
520
  actions.push({ action: dryRun ? "would-sync" : "sync", path: path.relative(root, skillDir) });
244
521
  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) });
247
- }
522
+ actions.push({ action: dryRun ? "would-sync" : "sync", path: "docs/tools/autopipeline/ap.py" });
248
523
  if (!dryRun) {
249
524
  rmrf(skillDir);
250
525
  copyDir(assetSkill, skillDir);
251
- copyDir(assetAgents, agentsDir);
526
+ syncManagedAgents(assetAgents, agentsDir, { resetModel: resetAgentModels });
252
527
  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
- }
528
+ fs.copyFileSync(path.join(assetSkill, "data", "templates", "tools", "ap.py"), path.join(toolDir, "ap.py"));
256
529
  for (const copied of copyMissingDocs(assetSkill, root)) actions.push({ action: "create", path: copied });
257
530
  if (engineeringWasMissing) {
258
531
  fs.mkdirSync(path.dirname(engineering), { recursive: true });
259
- fs.copyFileSync(templateEngineering, engineering);
532
+ fs.writeFileSync(engineering, renderEngineeringTemplate(fs.readFileSync(templateEngineering, "utf8"), root));
260
533
  actions.push({ action: "create", path: path.join("docs", "ENGINEERING.md") });
261
534
  }
262
535
  } else {
263
- const srcDocs = path.join(assetSkill, "data", "templates", "docs");
264
- for (const rel of listFiles(srcDocs)) {
536
+ for (const rel of CORE_DOCS) {
265
537
  if (!exists(path.join(root, "docs", rel))) actions.push({ action: "would-create", path: path.join("docs", rel) });
266
538
  }
267
539
  if (engineeringWasMissing) actions.push({ action: "would-create", path: path.join("docs", "ENGINEERING.md") });
@@ -326,9 +598,9 @@ function main(){
326
598
  autocoding - install auto-coding-skill into generic .agents paths
327
599
 
328
600
  Usage:
329
- autocoding init [--mode project|global] [--dest <repo-root|.agents-dir|skill-dir>] [--force]
601
+ autocoding init [--mode project|global] [--dest <repo-root|.agents-dir|skill-dir>] [--force] [--reset-agent-models]
330
602
  autocoding status --projects <path[,path...]> [--json]
331
- autocoding sync --projects <path[,path...]> [--dry-run] [--json]
603
+ autocoding sync --projects <path[,path...]> [--dry-run] [--json] [--reset-agent-models]
332
604
 
333
605
  Examples:
334
606
  autocoding init
@@ -337,10 +609,13 @@ Examples:
337
609
 
338
610
  Compatibility:
339
611
  --ai <value> is accepted for old scripts and ignored.
612
+ Existing managed-agent model lines are preserved unless --reset-agent-models is used.
340
613
  `);
341
614
  process.exit(0);
342
615
  }
343
616
 
617
+ validateCommandArgs(args);
618
+
344
619
  const here = path.dirname(fileURLToPath(import.meta.url));
345
620
  const assetSkill = path.resolve(here, "..", "assets", "skill");
346
621
  const assetAgents = path.resolve(here, "..", "assets", "agents");
@@ -360,7 +635,7 @@ Compatibility:
360
635
 
361
636
  if (args.cmd === "sync") {
362
637
  const projects = args.projects.length ? args.projects : [projectRoot()];
363
- const results = projects.map(project => syncProject(project, assetSkill, assetAgents, args.dryRun));
638
+ const results = projects.map(project => syncProject(project, assetSkill, assetAgents, args.dryRun, args.resetAgentModels));
364
639
  if (args.json) console.log(JSON.stringify({ version: readPackageVersion(), results }, null, 2));
365
640
  else {
366
641
  console.log(`[autocoding] version=${readPackageVersion()}`);
@@ -391,7 +666,7 @@ Compatibility:
391
666
  copyDir(assetSkill, skillDir);
392
667
  console.log(`[autocoding] installed skill to: ${skillDir}`);
393
668
 
394
- copyDir(assetAgents, agentsDir);
669
+ syncManagedAgents(assetAgents, agentsDir, { resetModel: args.resetAgentModels });
395
670
  console.log(`[autocoding] installed agents to: ${agentsDir}`);
396
671
 
397
672
  console.log("[autocoding] done.");