@elvis1513/auto-coding-skill 2.1.3 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +154 -548
  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 +666 -129
  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 +373 -62
  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
@@ -7,6 +7,13 @@ import { fileURLToPath } from "node:url";
7
7
  const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
8
8
  const cli = path.join(repoRoot, "cli", "src", "index.js");
9
9
  const assetAp = path.join(repoRoot, "cli", "assets", "skill", "scripts", "ap.py");
10
+ const managedAgentEfforts = {
11
+ "browser-debugger.toml": "xhigh",
12
+ "docs-researcher.toml": "medium",
13
+ "explorer.toml": "medium",
14
+ "fixer.toml": "medium",
15
+ "reviewer.toml": "xhigh",
16
+ };
10
17
 
11
18
  function assert(condition, message) {
12
19
  if (!condition) throw new Error(message);
@@ -23,6 +30,7 @@ function tmpdir(name) {
23
30
  function run(command, args, options = {}) {
24
31
  const result = spawnSync(command, args, {
25
32
  cwd: options.cwd ?? repoRoot,
33
+ env: options.env ? { ...process.env, ...options.env } : process.env,
26
34
  encoding: "utf8",
27
35
  stdio: "pipe",
28
36
  });
@@ -38,11 +46,57 @@ function run(command, args, options = {}) {
38
46
  return result;
39
47
  }
40
48
 
49
+ function pythonEnvWithHome(home) {
50
+ const yamlSite = run(
51
+ "python3",
52
+ ["-c", "import pathlib, yaml; print(pathlib.Path(yaml.__file__).resolve().parent.parent)"],
53
+ ).stdout.trim();
54
+ return {
55
+ HOME: home,
56
+ PYTHONPATH: [yamlSite, process.env.PYTHONPATH].filter(Boolean).join(path.delimiter),
57
+ };
58
+ }
59
+
41
60
  function writeFile(file, text) {
42
61
  fs.mkdirSync(path.dirname(file), { recursive: true });
43
62
  fs.writeFileSync(file, text);
44
63
  }
45
64
 
65
+ function readTomlString(text, key, file) {
66
+ const match = text.match(new RegExp(`^${key}\\s*=\\s*"([^"]+)"\\s*$`, "m"));
67
+ assert(match, `${file}: missing ${key}`);
68
+ return match[1];
69
+ }
70
+
71
+ function managedAgentHeader(text) {
72
+ return text.split(/^developer_instructions\s*=\s*(?:"""|''')/m, 1)[0];
73
+ }
74
+
75
+ function assertManagedAgents(agentsDir, expectedModel = null) {
76
+ for (const [filename, effort] of Object.entries(managedAgentEfforts)) {
77
+ const file = path.join(agentsDir, filename);
78
+ assert(exists(file), `missing managed agent: ${filename}`);
79
+ const text = fs.readFileSync(file, "utf8");
80
+ assert(readTomlString(text, "model_reasoning_effort", file) === effort, `${filename}: unexpected effort`);
81
+ const model = managedAgentHeader(text).match(/^model\s*=\s*"([^"]+)"\s*$/m)?.[1] ?? null;
82
+ assert(model === expectedModel, `${filename}: expected model ${expectedModel ?? "inherit"}, got ${model}`);
83
+ }
84
+ }
85
+
86
+ function listProjectFiles(root) {
87
+ const out = [];
88
+ function walk(current) {
89
+ for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
90
+ if (entry.name === ".git" || entry.name === "__pycache__" || entry.name.endsWith(".pyc")) continue;
91
+ const file = path.join(current, entry.name);
92
+ if (entry.isDirectory()) walk(file);
93
+ else out.push(file);
94
+ }
95
+ }
96
+ walk(root);
97
+ return out;
98
+ }
99
+
46
100
  function assertStatusOk(repo) {
47
101
  const result = run("node", [cli, "status", "--projects", repo, "--json"]);
48
102
  const parsed = JSON.parse(result.stdout);
@@ -60,26 +114,11 @@ function testPreflightAvoidsPartialInstall() {
60
114
 
61
115
  function testDestVariants() {
62
116
  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
- },
117
+ { name: "repo-root", dest(root) { return root; } },
118
+ { name: "agents-root", dest(root) { return path.join(root, ".agents"); } },
119
+ { name: "skills-dir", dest(root) { return path.join(root, ".agents", "skills"); } },
120
+ { name: "agents-dir", dest(root) { return path.join(root, ".agents", "agents"); } },
121
+ { name: "direct-skill", dest(root) { return path.join(root, ".agents", "skills", "auto-coding-skill"); } },
83
122
  ];
84
123
 
85
124
  for (const variant of variants) {
@@ -93,31 +132,187 @@ function testDestVariants() {
93
132
  }
94
133
  }
95
134
 
96
- function testSyncCreatesScaffoldAndStatusConverges() {
97
- const repo = tmpdir("sync-converges");
135
+ function testLauncherFallsBackToGlobalRuntime() {
136
+ const fakeHome = tmpdir("global-runtime-home");
137
+ const project = tmpdir("global-runtime-project");
138
+ const env = pythonEnvWithHome(fakeHome);
139
+ run("node", [cli, "init", "--mode", "global", "--dest", fakeHome, "--force"]);
140
+ const globalAp = path.join(fakeHome, ".agents", "skills", "auto-coding-skill", "scripts", "ap.py");
141
+ run("python3", [globalAp, "--repo", project, "install"], { env });
142
+ assert(!exists(path.join(project, ".agents", "skills", "auto-coding-skill")), "fixture should rely on the global runtime only");
143
+ const launcher = path.join(project, "docs", "tools", "autopipeline", "ap.py");
144
+ const help = run("python3", [launcher, "--help"], { env });
145
+ assert(help.stdout.includes("autopipeline"), "project launcher should execute the global runtime when no project copy exists");
146
+ }
147
+
148
+ function testMinimalSyncConvergesWithinBudget() {
149
+ const repo = tmpdir("minimal-sync");
98
150
  run("node", [cli, "init"], { cwd: repo });
99
151
  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");
152
+ assert(before.status !== 0, "status should fail before core scaffold exists");
102
153
  run("node", [cli, "sync", "--projects", repo]);
103
- assert(exists(path.join(repo, "docs", "ENGINEERING.md")), "sync should create docs/ENGINEERING.md when missing");
154
+
155
+ for (const rel of ["docs/ENGINEERING.md", "docs/tasks/taskbook.md", "docs/tasks/closure-log.md", "docs/tools/autopipeline/ap.py"]) {
156
+ assert(exists(path.join(repo, rel)), `missing core scaffold file: ${rel}`);
157
+ }
158
+ for (const rel of ["docs/interfaces/api.md", "docs/design/_TEMPLATE-DD.md", "docs/testing/regression-matrix.md", "docs/tools/autopipeline/core.py", "docs/tools/autopipeline/http_checks.py"]) {
159
+ assert(!exists(path.join(repo, rel)), `optional/duplicate file should not be installed: ${rel}`);
160
+ }
161
+
162
+ const files = listProjectFiles(repo);
163
+ const lines = files.reduce((total, file) => total + fs.readFileSync(file, "utf8").split(/\r?\n/).length, 0);
164
+ assert(files.length <= 20, `minimal scaffold file budget exceeded: ${files.length}`);
165
+ assert(lines <= 5500, `minimal scaffold line budget exceeded: ${lines}`);
166
+ const engineering = fs.readFileSync(path.join(repo, "docs", "ENGINEERING.md"), "utf8");
167
+ assert(engineering.includes("profile: \"auto\""), "engineering should enable adaptive profiles");
168
+ assert(engineering.includes("target_env_required: false"), "target verification should be opt-in in generic scaffold");
169
+ assert(engineering.includes(`name: "${path.basename(repo)}"`), "project name should be initialized automatically");
104
170
  assertStatusOk(repo);
171
+
172
+ const doctor = run("python3", [path.join(repo, "docs", "tools", "autopipeline", "ap.py"), "--repo", repo, "doctor"], { check: false });
173
+ const doctorOutput = `${doctor.stdout}\n${doctor.stderr}`;
174
+ assert(doctor.status !== 0 && doctorOutput.includes("gate command"), "empty generic repo should require only a real gate command");
175
+ for (const unexpected of ["target_env.name", "backend_root", "jenkins.base_url", "docs.api_doc"]) {
176
+ assert(!doctorOutput.includes(unexpected), `default doctor should not require optional field: ${unexpected}`);
177
+ }
178
+ }
179
+
180
+ function testOrdinaryNodeTestIsNotPromotedToFullGate() {
181
+ const repo = tmpdir("node-gate-inference");
182
+ writeFile(path.join(repo, "package.json"), JSON.stringify({ scripts: { test: "node --test" } }, null, 2) + "\n");
183
+ run("node", [cli, "init"], { cwd: repo });
184
+ run("node", [cli, "sync", "--projects", repo]);
185
+ const engineering = fs.readFileSync(path.join(repo, "docs", "ENGINEERING.md"), "utf8");
186
+ assert(engineering.includes('gate_changed: "npm test"'), "ordinary test should seed the changed gate");
187
+ assert(engineering.includes('gate_standard: "npm test"'), "ordinary test should seed the standard gate");
188
+ assert(engineering.includes('gate_full: ""'), "ordinary test must not be promoted to the full gate");
189
+
190
+ run("git", ["init", "-q"], { cwd: repo });
191
+ run("git", ["config", "user.email", "test@example.com"], { cwd: repo });
192
+ run("git", ["config", "user.name", "Auto Coding Test"], { cwd: repo });
193
+ run("git", ["add", "-A"], { cwd: repo });
194
+ run("git", ["commit", "-qm", "baseline"], { cwd: repo });
195
+ writeFile(path.join(repo, "migrations", "001.sql"), "-- migration\n");
196
+ const launcher = path.join(repo, "docs", "tools", "autopipeline", "ap.py");
197
+ const doctor = run("python3", [launcher, "--repo", repo, "doctor"], { check: false });
198
+ assert(doctor.status !== 0 && `${doctor.stdout}\n${doctor.stderr}`.includes("full gate command"), "high-risk work should block until a dedicated full gate is configured");
105
199
  }
106
200
 
107
- function testForcePreservesCustomAgents() {
108
- const repo = tmpdir("custom-agent");
201
+ function testManagedAgentModelsInheritAndOverridesSurvive() {
202
+ const repo = tmpdir("agent-models");
203
+ run("node", [cli, "init"], { cwd: repo });
204
+ const agentsDir = path.join(repo, ".agents", "agents");
205
+ assertManagedAgents(agentsDir);
206
+
207
+ const custom = path.join(agentsDir, "custom-local.toml");
208
+ const customText = 'name = "custom-local"\ndescription = "custom"\nmodel = "vendor/custom"\n';
209
+ writeFile(custom, customText);
210
+ for (const filename of Object.keys(managedAgentEfforts)) {
211
+ const file = path.join(agentsDir, filename);
212
+ const stale = fs.readFileSync(file, "utf8")
213
+ .replace(/^description\s*=.*$/m, '$&\nmodel = "vendor/project-model"')
214
+ .replace(/^model_reasoning_effort\s*=.*$/m, 'model_reasoning_effort = "low"');
215
+ writeFile(file, stale);
216
+ }
217
+
218
+ run("node", [cli, "sync", "--projects", repo]);
219
+ assertManagedAgents(agentsDir, "vendor/project-model");
220
+ assert(fs.readFileSync(custom, "utf8") === customText, "sync should preserve custom agent contents");
221
+ assertStatusOk(repo);
222
+
223
+ run("node", [cli, "sync", "--projects", repo, "--reset-agent-models"]);
224
+ assertManagedAgents(agentsDir);
225
+ assert(fs.readFileSync(custom, "utf8") === customText, "model reset must not touch custom agents");
226
+ }
227
+
228
+ function testForcePreservesCustomAgentsAndModelOverrides() {
229
+ const repo = tmpdir("force-agent");
109
230
  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');
231
+ const agentsDir = path.join(repo, ".agents", "agents");
232
+ const custom = path.join(agentsDir, "custom-local.toml");
233
+ const customText = 'name = "custom-local"\ndescription = "custom"\n';
234
+ writeFile(custom, customText);
235
+ const explorer = path.join(agentsDir, "explorer.toml");
236
+ writeFile(explorer, fs.readFileSync(explorer, "utf8").replace(/^description\s*=.*$/m, '$&\nmodel = "vendor/override"'));
112
237
  run("node", [cli, "init", "--force"], { cwd: repo });
113
- assert(exists(custom), "custom agent should be preserved");
238
+ assert(fs.readFileSync(custom, "utf8") === customText, "init --force should preserve custom agents");
239
+ assert(fs.readFileSync(explorer, "utf8").includes('model = "vendor/override"'), "init --force should preserve explicit managed-agent model overrides");
240
+ }
241
+
242
+ function testInvalidManagedAgentModelsFailStatusAndAreDroppedOnSync() {
243
+ const repo = tmpdir("invalid-agent-model");
244
+ run("node", [cli, "init"], { cwd: repo });
245
+ run("node", [cli, "sync", "--projects", repo]);
246
+ const explorer = path.join(repo, ".agents", "agents", "explorer.toml");
247
+
248
+ for (const invalidLine of ["model = [", 'model = ""']) {
249
+ const canonical = fs.readFileSync(explorer, "utf8").replace(/^model\s*=.*(?:\r?\n|$)/m, "");
250
+ writeFile(explorer, canonical.replace(/^description\s*=.*$/m, `$&\n${invalidLine}`));
251
+
252
+ const status = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
253
+ assert(status.status !== 0, `status should fail for invalid managed model: ${invalidLine}`);
254
+ const parsed = JSON.parse(status.stdout).results[0];
255
+ const finding = parsed.agentDiffs.find(item => item.path === "explorer.toml");
256
+ assert(finding?.status === "invalid-model", `status should report invalid-model: ${status.stdout}`);
257
+ assert(finding.detail?.includes("model"), `invalid model should include a useful detail: ${status.stdout}`);
258
+ assert(parsed.agentBindings.find(item => item.agent === "explorer.toml")?.model === "invalid", "invalid binding should be explicit in status JSON");
259
+
260
+ run("node", [cli, "sync", "--projects", repo]);
261
+ assert(!/^model\s*=/m.test(managedAgentHeader(fs.readFileSync(explorer, "utf8"))), "sync must not preserve an invalid model override");
262
+ assertStatusOk(repo);
263
+ }
264
+ }
265
+
266
+ function testModelTextInsideInstructionsIsNotPromotedToOverride() {
267
+ const repo = tmpdir("model-in-instructions");
268
+ run("node", [cli, "init"], { cwd: repo });
269
+ run("node", [cli, "sync", "--projects", repo]);
270
+ const explorer = path.join(repo, ".agents", "agents", "explorer.toml");
271
+ const withExample = fs.readFileSync(explorer, "utf8").replace(
272
+ 'developer_instructions = """',
273
+ 'developer_instructions = """\nmodel = "example/in-docs"',
274
+ );
275
+ writeFile(explorer, withExample);
276
+
277
+ run("node", [cli, "sync", "--projects", repo]);
278
+ const synced = fs.readFileSync(explorer, "utf8");
279
+ assert(!/^model\s*=/m.test(managedAgentHeader(synced)), "instruction text must not become a top-level model override");
280
+ assert(!synced.includes('model = "example/in-docs"'), "sync should refresh stale managed instructions without promoting their example model");
281
+ assertStatusOk(repo);
282
+ }
283
+
284
+ function testCommandSpecificArgumentsAreRejectedBeforeWrites() {
285
+ const dryRunDest = tmpdir("invalid-init-dry-run");
286
+ const invalidInit = run("node", [cli, "init", "--dest", dryRunDest, "--dry-run"], { check: false });
287
+ assert(invalidInit.status !== 0 && invalidInit.stderr.includes("not valid for 'init'"), "init should reject --dry-run");
288
+ assert(!exists(path.join(dryRunDest, ".agents")), "invalid init arguments must not write files");
289
+
290
+ const positionalDest = tmpdir("invalid-init-positional");
291
+ const invalidPositional = run("node", [cli, "init", "unexpected-project"], { cwd: positionalDest, check: false });
292
+ assert(invalidPositional.status !== 0 && invalidPositional.stderr.includes("not valid for 'init'"), "init should reject positional project arguments");
293
+ assert(!exists(path.join(positionalDest, ".agents")), "invalid positional init must not write files");
294
+
295
+ const repo = tmpdir("invalid-command-options");
296
+ run("node", [cli, "init"], { cwd: repo });
297
+ run("node", [cli, "sync", "--projects", repo]);
298
+ const explorer = path.join(repo, ".agents", "agents", "explorer.toml");
299
+ writeFile(explorer, fs.readFileSync(explorer, "utf8").replace(/^description\s*=.*$/m, '$&\nmodel = "vendor/keep"'));
300
+
301
+ const invalidStatus = run("node", [cli, "status", "--projects", repo, "--reset-agent-models"], { check: false });
302
+ assert(invalidStatus.status !== 0 && invalidStatus.stderr.includes("not valid for 'status'"), "status should reject --reset-agent-models");
303
+ assert(managedAgentHeader(fs.readFileSync(explorer, "utf8")).includes('model = "vendor/keep"'), "rejected status command must not reset models");
304
+
305
+ const invalidSync = run("node", [cli, "sync", "--projects", repo, "--force"], { check: false });
306
+ assert(invalidSync.status !== 0 && invalidSync.stderr.includes("not valid for 'sync'"), "sync should reject --force");
307
+ const validDryRun = run("node", [cli, "sync", "--projects", repo, "--dry-run", "--reset-agent-models"]);
308
+ assert(validDryRun.status === 0, "sync should accept its documented dry-run/reset options together");
309
+ assert(managedAgentHeader(fs.readFileSync(explorer, "utf8")).includes('model = "vendor/keep"'), "dry-run must not reset models on disk");
114
310
  }
115
311
 
116
312
  function testBridgeIsGeneric() {
117
313
  const repo = tmpdir("bridge");
118
314
  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"]);
315
+ run("python3", [assetAp, "--repo", repo, "install", "--bridges"]);
121
316
  assert(exists(path.join(repo, "AGENTS.md")), "generic bridge should be created");
122
317
  for (const filename of [`CO${"DEX.md"}`, `CLA${"UDE.md"}`]) {
123
318
  assert(!exists(path.join(repo, filename)), "client-named bridge should not be created");
@@ -136,42 +331,145 @@ function testUpgradeCleansManagedBridgeExtrasOnly() {
136
331
  assert(exists(path.join(repo, ".agents", "skills", "auto-coding-skill", "custom.txt")), "non-managed extra should remain");
137
332
  }
138
333
 
334
+ function testOptionalDocsAndLegacyToolsDoNotCauseDrift() {
335
+ const repo = tmpdir("legacy-extras");
336
+ run("node", [cli, "init"], { cwd: repo });
337
+ run("node", [cli, "sync", "--projects", repo]);
338
+ writeFile(path.join(repo, "docs", "interfaces", "api.md"), "# Existing API\n");
339
+ writeFile(path.join(repo, "docs", "tools", "autopipeline", "core.py"), "# legacy copy\n");
340
+ writeFile(path.join(repo, "docs", "tools", "autopipeline", "http_checks.py"), "# legacy copy\n");
341
+ assertStatusOk(repo);
342
+ }
343
+
344
+ function testOptionalScaffoldIsOnDemandAndIdempotent() {
345
+ const repo = tmpdir("optional-scaffold");
346
+ run("node", [cli, "init"], { cwd: repo });
347
+ run("node", [cli, "sync", "--projects", repo]);
348
+ const launcher = path.join(repo, "docs", "tools", "autopipeline", "ap.py");
349
+ run("python3", [launcher, "--repo", repo, "scaffold", "api", "--write"]);
350
+ const api = path.join(repo, "docs", "interfaces", "api.md");
351
+ assert(exists(api), "api scaffold should be created on demand");
352
+ writeFile(api, "# User API\n");
353
+ run("python3", [launcher, "--repo", repo, "scaffold", "api", "--write"]);
354
+ assert(fs.readFileSync(api, "utf8") === "# User API\n", "scaffold should not overwrite existing docs without --force");
355
+ }
356
+
357
+ function testTestingScaffoldMatchesCheckMatrixSchema() {
358
+ const repo = tmpdir("testing-scaffold");
359
+ run("node", [cli, "init"], { cwd: repo });
360
+ run("node", [cli, "sync", "--projects", repo]);
361
+ const launcher = path.join(repo, "docs", "tools", "autopipeline", "ap.py");
362
+ run("python3", [launcher, "--repo", repo, "scaffold", "testing", "--write"]);
363
+
364
+ const matrix = path.join(repo, "docs", "testing", "regression-matrix.md");
365
+ const initial = fs.readFileSync(matrix, "utf8");
366
+ const row = initial.split(/\r?\n/).find(line => line.startsWith("| R-001 |"));
367
+ assert(row, "testing scaffold should include R-001");
368
+ const columns = row.split("|").slice(1, -1).map(value => value.trim());
369
+ assert(columns.length === 8, `regression row should have 8 columns, got ${columns.length}`);
370
+
371
+ const pending = run("python3", [launcher, "--repo", repo, "check-matrix"], { check: false });
372
+ const pendingOutput = `${pending.stdout}\n${pending.stderr}`;
373
+ assert(pending.status !== 0 && pendingOutput.includes("R-001: TODO"), `generated matrix should be parsed as pending: ${pendingOutput}`);
374
+ assert(!pendingOutput.includes("No regression rows found"), "generated matrix must not be rejected as malformed");
375
+
376
+ writeFile(matrix, initial.replace("| TODO | <evidence> |", "| PASS | logs/regression.txt |"));
377
+ run("python3", [launcher, "--repo", repo, "check-matrix"]);
378
+ }
379
+
380
+ function testReviewScaffoldLeavesBaselineGenerationToBaselineCommand() {
381
+ const repo = tmpdir("review-scaffold");
382
+ run("node", [cli, "init"], { cwd: repo });
383
+ run("node", [cli, "sync", "--projects", repo]);
384
+ const launcher = path.join(repo, "docs", "tools", "autopipeline", "ap.py");
385
+
386
+ run("python3", [launcher, "--repo", repo, "scaffold", "review", "--write"]);
387
+ assert(exists(path.join(repo, "docs", "reviews", "_TEMPLATE-REVIEW.md")), "review scaffold should create its review template");
388
+ for (const rel of ["docs/reviews/project-health-baseline.md", "docs/reviews/optimization-backlog.md"]) {
389
+ assert(!exists(path.join(repo, rel)), `review scaffold must leave generated baseline output absent: ${rel}`);
390
+ }
391
+
392
+ run("git", ["init", "-q"], { cwd: repo });
393
+ run("git", ["config", "user.email", "test@example.com"], { cwd: repo });
394
+ run("git", ["config", "user.name", "Auto Coding Test"], { cwd: repo });
395
+ run("git", ["add", "-A"], { cwd: repo });
396
+ run("git", ["commit", "-qm", "baseline"], { cwd: repo });
397
+ run("python3", [launcher, "--repo", repo, "baseline", "init", "--write"]);
398
+ assert(fs.readFileSync(path.join(repo, "docs", "reviews", "project-health-baseline.md"), "utf8").includes("Generated by `ap.py baseline init`"), "baseline command should generate the health baseline");
399
+ assert(fs.readFileSync(path.join(repo, "docs", "reviews", "optimization-backlog.md"), "utf8").includes("Generated by `ap.py baseline init`"), "baseline command should generate the optimization backlog");
400
+ }
401
+
402
+ function testUpgradePrefersModernProjectAssetsAndIgnoresRetiredTemplates() {
403
+ const repo = tmpdir("upgrade-modern-source");
404
+ const fakeHome = tmpdir("upgrade-stale-home");
405
+ run("git", ["init", "-q"], { cwd: repo });
406
+ run("node", [cli, "init"], { cwd: repo });
407
+ run("node", [cli, "sync", "--projects", repo]);
408
+
409
+ const projectSkill = path.join(repo, ".agents", "skills", "auto-coding-skill");
410
+ writeFile(path.join(projectSkill, "data", "templates", "docs", "interfaces", "api.md"), "# Retired project template\n");
411
+
412
+ const staleGlobal = path.join(fakeHome, ".agents", "skills", "auto-coding-skill");
413
+ writeFile(path.join(staleGlobal, "scripts", "ap.py"), "# legacy runtime\n");
414
+ writeFile(path.join(staleGlobal, "data", "templates", "ENGINEERING.md"), "---\n---\n");
415
+ writeFile(path.join(staleGlobal, "data", "templates", "docs", "interfaces", "api.md"), "# Retired global template\n");
416
+
417
+ const launcher = path.join(repo, "docs", "tools", "autopipeline", "ap.py");
418
+ const result = run(
419
+ "python3",
420
+ [launcher, "--repo", repo, "upgrade", "--write", "--json"],
421
+ { env: pythonEnvWithHome(fakeHome) },
422
+ );
423
+ const parsed = JSON.parse(result.stdout);
424
+ assert(fs.realpathSync(parsed.source_root) === fs.realpathSync(projectSkill), `upgrade should prefer the modern project asset root: ${result.stdout}`);
425
+ assert(!exists(path.join(repo, "docs", "interfaces", "api.md")), "upgrade must not materialize retired optional templates");
426
+ }
427
+
428
+ function testUpgradeInitializesNewEngineeringDefaults() {
429
+ const repo = tmpdir("upgrade-engineering-defaults");
430
+ const fakeHome = tmpdir("upgrade-engineering-home");
431
+ run("git", ["init", "-q"], { cwd: repo });
432
+ writeFile(path.join(repo, "package.json"), JSON.stringify({ scripts: { test: "node --test", "test:full": "node --test" } }, null, 2) + "\n");
433
+ run("node", [cli, "init"], { cwd: repo });
434
+
435
+ const projectAp = path.join(repo, ".agents", "skills", "auto-coding-skill", "scripts", "ap.py");
436
+ run("python3", [projectAp, "--repo", repo, "upgrade", "--write"], { env: pythonEnvWithHome(fakeHome) });
437
+
438
+ const engineering = fs.readFileSync(path.join(repo, "docs", "ENGINEERING.md"), "utf8");
439
+ assert(engineering.includes(`name: "${path.basename(repo)}"`), "upgrade should initialize a newly created project name");
440
+ for (const key of ["gate_changed", "gate_standard"]) {
441
+ assert(engineering.includes(`${key}: "npm test"`), `upgrade should initialize commands.${key} from the ordinary Node test script`);
442
+ }
443
+ assert(engineering.includes('gate_full: "npm run test:full"'), "upgrade should infer full only from a dedicated test:full script");
444
+ }
445
+
446
+ function testUpgradeInstallsRuntimeRequiredByLauncher() {
447
+ const repo = tmpdir("upgrade-missing-runtime");
448
+ run("git", ["init", "-q"], { cwd: repo });
449
+ run("python3", [assetAp, "--repo", repo, "upgrade", "--write"]);
450
+ const projectRuntime = path.join(repo, ".agents", "skills", "auto-coding-skill", "scripts", "ap.py");
451
+ const launcher = path.join(repo, "docs", "tools", "autopipeline", "ap.py");
452
+ assert(exists(projectRuntime), "upgrade should install the runtime required by the new launcher");
453
+ const help = run("python3", [launcher, "--help"]);
454
+ assert(help.stdout.includes("autopipeline"), "upgraded launcher should remain executable");
455
+ }
456
+
139
457
  function testLedgerArchiveRecognizesSettledStatuses() {
140
458
  const repo = tmpdir("ledger-status");
141
459
  run("git", ["init", "-q"], { cwd: repo });
142
460
  run("node", [cli, "init", "--force"], { cwd: repo });
143
461
  run("node", [cli, "sync", "--projects", repo]);
144
462
  writeFile(path.join(repo, "docs", "tasks", "taskbook.md"), [
145
- "# Taskbook",
146
- "",
147
- "## Task T001 - superseded work",
148
- "- Status: Superseded by T002",
149
- "",
150
- "## Task T002 - external dependency",
151
- "- Status: External Dependency",
152
- "",
153
- "## Task T003 - deployed work",
154
- "- Status: Deployed / Jenkins #123 SUCCESS",
155
- "",
156
- "## Task T004 - local pass",
157
- "- Status: Local PASS,待生产迁移窗口",
158
- "",
463
+ "# Taskbook", "", "## Task T001 - superseded work", "- Status: Superseded by T002", "",
464
+ "## Task T002 - external dependency", "- Status: External Dependency", "",
465
+ "## Task T003 - deployed work", "- Status: Deployed / Jenkins #123 SUCCESS", "",
466
+ "## Task T004 - local pass", "- Status: Local PASS,待生产迁移窗口", "",
159
467
  ].join("\n"));
160
468
  writeFile(path.join(repo, "docs", "tasks", "closure-log.md"), [
161
- "# Closure Log",
162
- "",
163
- "## T001 - superseded work",
164
- "- Result: DEV-CLOSED",
165
- "",
166
- "## T002 - external dependency",
167
- "- Result: PARTIAL",
168
- "",
169
- "## T003 - deployed work",
170
- "- Result: PASS",
171
- "",
172
- "## T004 - local pass",
173
- "- Result: DEV-CLOSED",
174
- "",
469
+ "# Closure Log", "", "## T001 - superseded work", "- Result: DEV-CLOSED", "",
470
+ "## T002 - external dependency", "- Result: PARTIAL", "",
471
+ "## T003 - deployed work", "- Result: PASS", "",
472
+ "## T004 - local pass", "- Result: DEV-CLOSED", "",
175
473
  ].join("\n"));
176
474
  const result = run("python3", [assetAp, "--repo", repo, "docs-ledger-archive", "--plan", "--period", "2026-06", "--json"]);
177
475
  const parsed = JSON.parse(result.stdout);
@@ -181,10 +479,23 @@ function testLedgerArchiveRecognizesSettledStatuses() {
181
479
 
182
480
  testPreflightAvoidsPartialInstall();
183
481
  testDestVariants();
184
- testSyncCreatesScaffoldAndStatusConverges();
185
- testForcePreservesCustomAgents();
482
+ testLauncherFallsBackToGlobalRuntime();
483
+ testMinimalSyncConvergesWithinBudget();
484
+ testOrdinaryNodeTestIsNotPromotedToFullGate();
485
+ testManagedAgentModelsInheritAndOverridesSurvive();
486
+ testForcePreservesCustomAgentsAndModelOverrides();
487
+ testInvalidManagedAgentModelsFailStatusAndAreDroppedOnSync();
488
+ testModelTextInsideInstructionsIsNotPromotedToOverride();
489
+ testCommandSpecificArgumentsAreRejectedBeforeWrites();
186
490
  testBridgeIsGeneric();
187
491
  testUpgradeCleansManagedBridgeExtrasOnly();
492
+ testOptionalDocsAndLegacyToolsDoNotCauseDrift();
493
+ testOptionalScaffoldIsOnDemandAndIdempotent();
494
+ testTestingScaffoldMatchesCheckMatrixSchema();
495
+ testReviewScaffoldLeavesBaselineGenerationToBaselineCommand();
496
+ testUpgradePrefersModernProjectAssetsAndIgnoresRetiredTemplates();
497
+ testUpgradeInitializesNewEngineeringDefaults();
498
+ testUpgradeInstallsRuntimeRequiredByLauncher();
188
499
  testLedgerArchiveRecognizesSettledStatuses();
189
500
 
190
501
  console.log("cli-installer-regression-ok");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elvis1513/auto-coding-skill",
3
- "version": "2.1.3",
3
+ "version": "2.2.0",
4
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": {
@@ -15,8 +15,8 @@
15
15
  "LICENSE"
16
16
  ],
17
17
  "scripts": {
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
+ "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', 'cli/assets/skill/scripts/scaffold_templates.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 cli/assets/skill/scripts/scaffold_templates.py && python3 cli/tests/ap_profiles_test.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', 'src/auto-coding-skill/scripts/scaffold_templates.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 src/auto-coding-skill/scripts/scaffold_templates.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 {} +",
20
20
  "check:assets": "node cli/src/sync-assets.js --check",
21
21
  "sync-assets": "node cli/src/sync-assets.js",
22
22
  "release:check": "npm run sync-assets && npm run check:assets && npm run test:src && npm run test && npm pack --dry-run"
@@ -1,38 +0,0 @@
1
- # ADR-0000 — <Decision Title>
2
-
3
- - Status: Proposed | Accepted | Superseded
4
- - Date: YYYY-MM-DD
5
- - Owner: <name / team>
6
- - Related task: <task id / link>
7
-
8
- ## 1. Context
9
-
10
- What problem or structural pressure requires an architectural decision?
11
-
12
- ## 2. Decision
13
-
14
- What decision is being made? Keep it specific and actionable.
15
-
16
- ## 3. Alternatives Considered
17
-
18
- | Option | Pros | Cons | Reason not selected |
19
- | --- | --- | --- | --- |
20
- | A | | | |
21
- | B | | | |
22
-
23
- ## 4. Consequences
24
-
25
- - Positive:
26
- - Negative / tradeoffs:
27
- - Migration impact:
28
- - Compatibility impact:
29
-
30
- ## 5. Validation
31
-
32
- - Tests:
33
- - Gate:
34
- - Runtime / benchmark / security evidence:
35
-
36
- ## 6. Rollback
37
-
38
- How can this decision be reverted or superseded if it proves wrong?