@elvis1513/auto-coding-skill 4.1.7 → 4.1.9

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.
@@ -20,6 +20,23 @@ const managedAgentEfforts = {
20
20
  "fixer.toml": "medium",
21
21
  "reviewer.toml": "xhigh",
22
22
  };
23
+ const exactDocs = [
24
+ "docs/ENGINEERING.md",
25
+ "docs/architecture/adr/_TEMPLATE-ADR.md",
26
+ "docs/architecture/structure-standard.md",
27
+ "docs/bugs/bug-list.md",
28
+ "docs/deployment/deploy-records/_TEMPLATE-DEPLOY-RECORD.md",
29
+ "docs/deployment/deploy-runbook.md",
30
+ "docs/design/_TEMPLATE-DD.md",
31
+ "docs/interfaces/api-change-log.md",
32
+ "docs/interfaces/api.md",
33
+ "docs/project/overview.md",
34
+ "docs/project/repository-map.md",
35
+ "docs/project/runtime.md",
36
+ "docs/reviews/_TEMPLATE-REVIEW.md",
37
+ "docs/testing/regression-matrix.md",
38
+ "docs/tools/autopipeline/ap.py",
39
+ ];
23
40
 
24
41
  function assert(condition, message) {
25
42
  if (!condition) throw new Error(message);
@@ -138,7 +155,7 @@ function fillRequiredAccess(repo, password = "local-dev-password") {
138
155
  ].join("\n");
139
156
  const withAccess = text.replace(/^access:\r?\n[\s\S]*?(?=^concurrency:)/m, `${block}\n\n`);
140
157
  const updated = withAccess
141
- .replace(' project_fast: ""', ' project_fast: "true"')
158
+ .replace(/ project_fast: (?:""|'')/, ' project_fast: "true"')
142
159
  .replace(
143
160
  " routes: []",
144
161
  [
@@ -160,13 +177,49 @@ function assertStatusOk(repo) {
160
177
  assert(parsed.results[0].ok === true, `status should be ok: ${result.stdout}`);
161
178
  }
162
179
 
163
- function testPreflightAvoidsPartialInstall() {
164
- const repo = tmpdir("partial-init");
180
+ function testInitFullyConvergesExistingProject() {
181
+ const repo = tmpdir("full-init");
182
+ run("node", [cli, "init"], { cwd: repo });
183
+ fillRequiredAccess(repo, "preserved-project-secret");
184
+ const engineering = path.join(repo, "docs", "ENGINEERING.md");
185
+ writeFile(engineering, fs.readFileSync(engineering, "utf8")
186
+ .replace("concurrency:\n", "legacy_extra:\n forbidden: true\n\nconcurrency:\n")
187
+ .replace("# Project Facts", "# Obsolete workflow rules\n\nRun a full build every time.\n\n# Project Facts"));
188
+ writeFile(path.join(repo, "docs", "legacy", "old-taskbook.md"), "historical\n");
189
+ writeFile(path.join(repo, "docs", "architecture", "system-context.md"), "# System context\n\nKeep me.\n");
190
+ writeFile(path.join(repo, "docs", "architecture", "adr", "0042-project-choice.md"), "# ADR-0042\n\nKeep me.\n");
191
+ writeFile(path.join(repo, "docs", "interfaces", "event-contracts.md"), "# Events\n\nKeep me.\n");
192
+ writeFile(path.join(repo, "docs", "architecture", "structure-standard.md"), "# stale managed template\n");
165
193
  writeFile(path.join(repo, ".agents", "agents", "custom.toml"), 'name = "custom"\n');
166
- const result = run("node", [cli, "init"], { cwd: repo, check: false });
167
- assert(result.status !== 0, "init should fail when agents target exists without --force");
168
- assert(!exists(path.join(repo, ".agents", "skills", "auto-coding-skill")), "failed init must not leave a partial skill copy");
169
- assert(exists(path.join(repo, ".agents", "agents", "custom.toml")), "existing custom agent should remain");
194
+ writeFile(path.join(repo, ".agents", "skills", "auto-coding-skill", "obsolete.txt"), "obsolete\n");
195
+
196
+ run("node", [cli, "init"], { cwd: repo });
197
+ const installedDocs = listProjectFiles(path.join(repo, "docs"))
198
+ .map(file => path.relative(repo, file).split(path.sep).join("/"))
199
+ .sort();
200
+ const expectedInstalledDocs = [
201
+ ...exactDocs,
202
+ "docs/architecture/adr/0042-project-choice.md",
203
+ "docs/architecture/system-context.md",
204
+ "docs/interfaces/event-contracts.md",
205
+ ].sort();
206
+ assert(JSON.stringify(installedDocs) === JSON.stringify(expectedInstalledDocs), `docs framework must converge while preserving valid artifacts: ${installedDocs.join(", ")}`);
207
+ const converged = fs.readFileSync(engineering, "utf8");
208
+ assert(converged.includes("preserved-project-secret"), "supported access values must survive init");
209
+ assert(!converged.includes("legacy_extra") && !converged.includes("Run a full build every time"), "unknown fields and legacy workflow text must be removed");
210
+ assert(exists(path.join(repo, ".agents", "agents", "custom.toml")), "project-owned custom agents must survive init");
211
+ assert(!exists(path.join(repo, ".agents", "skills", "auto-coding-skill", "obsolete.txt")), "extra Skill files must be removed");
212
+ assert(exists(path.join(repo, ".agents", "archive", "auto-coding-skill", "4.1.9", "docs", "legacy", "old-taskbook.md")), "removed docs must be archived outside active docs");
213
+ assert(fs.readFileSync(path.join(repo, "docs", "architecture", "structure-standard.md"), "utf8").startsWith("# Project Structure Standard"), "managed templates must be replaced");
214
+ assert(fs.readFileSync(path.join(repo, "docs", "architecture", "adr", "0042-project-choice.md"), "utf8").includes("Keep me"), "numbered ADR artifacts must survive init");
215
+ assert(fs.readFileSync(path.join(repo, "docs", "architecture", "system-context.md"), "utf8").includes("Keep me"), "architecture artifacts must survive init");
216
+ assert(fs.readFileSync(path.join(repo, "docs", "interfaces", "event-contracts.md"), "utf8").includes("Keep me"), "interface artifacts must survive init");
217
+
218
+ run("node", [cli, "init"], { cwd: repo });
219
+ const secondDocs = listProjectFiles(path.join(repo, "docs"))
220
+ .map(file => path.relative(repo, file).split(path.sep).join("/"))
221
+ .sort();
222
+ assert(JSON.stringify(secondDocs) === JSON.stringify(expectedInstalledDocs), "repeated init must stay idempotent");
170
223
  }
171
224
 
172
225
  function testInitRejectsMissingPythonRuntimeBeforeWrites() {
@@ -219,34 +272,31 @@ function testLauncherFallsBackToGlobalRuntime() {
219
272
  assert(help.stdout.includes("autopipeline"), "project launcher should execute the global runtime when no project copy exists");
220
273
  }
221
274
 
222
- function testMinimalSyncConvergesWithinBudget() {
275
+ function testMinimalInitConvergesWithinBudget() {
223
276
  const repo = tmpdir("minimal-sync");
224
277
  run("node", [cli, "init"], { cwd: repo });
225
- const before = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
226
- assert(before.status !== 0, "status should fail before core scaffold exists");
227
- run("node", [cli, "sync", "--projects", repo]);
228
278
 
229
- for (const rel of ["docs/ENGINEERING.md", "docs/tools/autopipeline/ap.py"]) {
279
+ for (const rel of exactDocs) {
230
280
  assert(exists(path.join(repo, rel)), `missing core scaffold file: ${rel}`);
231
281
  }
232
- for (const rel of ["docs/tasks/taskbook.md", "docs/tasks/closure-log.md", "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"]) {
282
+ for (const rel of ["docs/tasks/taskbook.md", "docs/tasks/closure-log.md", "docs/tools/autopipeline/core.py", "docs/tools/autopipeline/http_checks.py"]) {
233
283
  assert(!exists(path.join(repo, rel)), `optional/duplicate file should not be installed: ${rel}`);
234
284
  }
235
285
 
236
286
  const files = listProjectFiles(repo);
237
287
  const lines = files.reduce((total, file) => total + fs.readFileSync(file, "utf8").split(/\r?\n/).length, 0);
238
- assert(files.length <= 23, `minimal scaffold file budget exceeded: ${files.length}`);
239
- // Deterministic direct-claim and orchestration-contract guards replace model-only
240
- // assertions in 4.1.4; keep a measured ceiling without forcing opaque code.
241
- assert(lines <= 11200, `minimal scaffold line budget exceeded: ${lines}`);
288
+ assert(files.length <= 40, `minimal scaffold file budget exceeded: ${files.length}`);
289
+ // The 4.1.9 integrity verifier is executable support code, not prompt context.
290
+ // Keep a measured ceiling while leaving the deterministic checks readable.
291
+ assert(lines <= 12200, `minimal scaffold line budget exceeded: ${lines}`);
242
292
  const engineering = fs.readFileSync(path.join(repo, "docs", "ENGINEERING.md"), "utf8");
243
- assert(engineering.includes("profile: \"auto\""), "engineering should enable adaptive profiles");
244
- assert(engineering.includes("isolation: \"adaptive\""), "engineering should default to adaptive clean-branch/worktree isolation");
245
- assert(engineering.includes('completion: "push"'), "engineering should complete normal development at push");
246
- assert(engineering.includes('project_fast: ""'), "generic projects should expose an optional project-fast command");
293
+ assert(engineering.includes("profile: auto"), "engineering should enable adaptive profiles");
294
+ assert(engineering.includes("isolation: adaptive"), "engineering should default to adaptive clean-branch/worktree isolation");
295
+ assert(engineering.includes("completion: push"), "engineering should complete normal development at push");
296
+ assert(engineering.includes("project_fast: ''"), "generic projects should expose an optional project-fast command");
247
297
  assert(engineering.includes("max_command_seconds: 120"), "engineering should bound each final route command");
248
298
  assert(engineering.includes("max_total_seconds: 180"), "engineering should bound the complete final gate");
249
- assert(engineering.includes(`name: "${path.basename(repo)}"`), "project name should be initialized automatically");
299
+ assert(engineering.includes(`name: ${path.basename(repo)}`), "project name should be initialized automatically");
250
300
  assert(!engineering.includes("## Design, review, and subagents"), "engineering must not duplicate the behavioral protocol");
251
301
  const agentsProtocol = fs.readFileSync(path.join(repo, "AGENTS.md"), "utf8");
252
302
  assert(agentsProtocol.includes("## Minimum mechanism budget"), "AGENTS should own the shared behavioral protocol");
@@ -291,8 +341,8 @@ function testStatusRejectsLegacyIsolation() {
291
341
  fillRequiredAccess(repo);
292
342
  const engineeringPath = path.join(repo, "docs", "ENGINEERING.md");
293
343
  const engineering = fs.readFileSync(engineeringPath, "utf8").replace(
294
- 'isolation: "adaptive"',
295
- 'isolation: "legacy"',
344
+ "isolation: adaptive",
345
+ "isolation: legacy",
296
346
  );
297
347
  fs.writeFileSync(engineeringPath, engineering);
298
348
 
@@ -303,7 +353,7 @@ function testStatusRejectsLegacyIsolation() {
303
353
  parsed.invalidConfigTokens.includes("concurrency.isolation (must be adaptive or worktree)"),
304
354
  `status should identify the invalid isolation value: ${result.stdout}`,
305
355
  );
306
- assert(parsed.next.includes("upgrade --write"), "status should direct legacy projects through upgrade");
356
+ assert(parsed.next.includes("autocoding init"), "status should direct legacy projects through authoritative init");
307
357
  }
308
358
 
309
359
  function testStatusRejectsLegacyGateEscalation() {
@@ -324,13 +374,27 @@ function testStatusRejectsLegacyGateEscalation() {
324
374
  }
325
375
  }
326
376
 
377
+ function testStatusAcceptsValidIndentlessYamlRoutes() {
378
+ const repo = tmpdir("indentless-routes");
379
+ run("node", [cli, "init"], { cwd: repo });
380
+ fillRequiredAccess(repo);
381
+ const engineering = path.join(repo, "docs", "ENGINEERING.md");
382
+ const text = fs.readFileSync(engineering, "utf8").replace(
383
+ /(^ routes:\n)([\s\S]*?)(?=^risk:)/m,
384
+ (_match, heading, body) => heading + body.replace(/^ /gm, " "),
385
+ );
386
+ writeFile(engineering, text);
387
+ const status = run("node", [cli, "status", "--projects", repo, "--json"]);
388
+ assert(JSON.parse(status.stdout).results[0].ok === true, "valid indentless YAML routes must not be reported as empty");
389
+ }
390
+
327
391
  function testOrdinaryNodeTestIsNotPromotedToAutomaticGate() {
328
392
  const repo = tmpdir("node-gate-inference");
329
393
  writeFile(path.join(repo, "package.json"), JSON.stringify({ scripts: { test: "node --test" } }, null, 2) + "\n");
330
394
  run("node", [cli, "init"], { cwd: repo });
331
395
  run("node", [cli, "sync", "--projects", repo]);
332
396
  const engineering = fs.readFileSync(path.join(repo, "docs", "ENGINEERING.md"), "utf8");
333
- assert(engineering.includes('project_fast: ""'), "ordinary test must not be promoted to the project-fast command");
397
+ assert(engineering.includes("project_fast: ''"), "ordinary test must not be promoted to the project-fast command");
334
398
  assert(!engineering.includes("gate_standard:"), "ordinary test must not seed an automatic standard gate");
335
399
  assert(!engineering.includes("gate_full:"), "ordinary test must not seed an automatic full gate");
336
400
 
@@ -385,7 +449,7 @@ function testAccessPasswordsAreRequiredButNeverPrintedByStatus() {
385
449
 
386
450
  writeFile(engineering, fs.readFileSync(engineering, "utf8").replace(/^access:\r?\n[\s\S]*?(?=^concurrency:)/m, ""));
387
451
  const absent = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
388
- assert(JSON.parse(absent.stdout).results[0].next.includes("upgrade --write"), "missing access paths should recommend configuration upgrade");
452
+ assert(JSON.parse(absent.stdout).results[0].next.includes("autocoding init"), "missing access paths should recommend authoritative init");
389
453
  }
390
454
 
391
455
  function testManagedAgentModelsInheritAndOverridesSurvive() {
@@ -425,7 +489,7 @@ function testForcePreservesCustomAgentsAndModelOverrides() {
425
489
  const explorer = path.join(agentsDir, "explorer.toml");
426
490
  writeFile(explorer, fs.readFileSync(explorer, "utf8").replace(/^description\s*=.*$/m, '$&\nmodel = "vendor/override"'));
427
491
  run("node", [cli, "init", "--force"], { cwd: repo });
428
- assert(fs.readFileSync(custom, "utf8") === customText, "init --force should preserve custom agents");
492
+ assert(fs.readFileSync(custom, "utf8") === customText, "init must preserve agents outside the managed set");
429
493
  assert(fs.readFileSync(explorer, "utf8").includes('model = "vendor/override"'), "init --force should preserve explicit managed-agent model overrides");
430
494
  }
431
495
 
@@ -502,7 +566,6 @@ function testCommandSpecificArgumentsAreRejectedBeforeWrites() {
502
566
  function testBridgeIsGeneric() {
503
567
  const repo = tmpdir("bridge");
504
568
  run("node", [cli, "init", "--force"], { cwd: repo });
505
- run("python3", [assetAp, "--repo", repo, "install", "--bridges"]);
506
569
  assert(exists(path.join(repo, "AGENTS.md")), "generic bridge should be created");
507
570
  const bridge = fs.readFileSync(path.join(repo, "AGENTS.md"), "utf8");
508
571
  assert(bridge.includes("Every delegated fixer or parallel writer owns a task ID/worktree"), "bridge should expose delegated-writer isolation");
@@ -531,6 +594,13 @@ function testOptionalDocsAndLegacyToolsDoNotCauseDrift() {
531
594
  writeFile(path.join(repo, "docs", "interfaces", "api.md"), "# Existing API\n");
532
595
  writeFile(path.join(repo, "docs", "tools", "autopipeline", "core.py"), "# legacy copy\n");
533
596
  writeFile(path.join(repo, "docs", "tools", "autopipeline", "http_checks.py"), "# legacy copy\n");
597
+ fillRequiredAccess(repo);
598
+ const drift = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
599
+ assert(drift.status !== 0, "extra runtime copies must be reported as drift");
600
+ run("node", [cli, "init"], { cwd: repo });
601
+ assert(!exists(path.join(repo, "docs", "tools", "autopipeline", "core.py")), "legacy runtime copy must be removed");
602
+ assert(!exists(path.join(repo, "docs", "tools", "autopipeline", "http_checks.py")), "legacy HTTP copy must be removed");
603
+ assert(fs.readFileSync(path.join(repo, "docs", "interfaces", "api.md"), "utf8") === "# Existing API\n", "mutable project docs must survive init");
534
604
  assertStatusOk(repo);
535
605
  }
536
606
 
@@ -615,7 +685,7 @@ function testUpgradePrefersModernProjectAssetsAndIgnoresRetiredTemplates() {
615
685
  );
616
686
  const parsed = JSON.parse(result.stdout);
617
687
  assert(fs.realpathSync(parsed.source_root) === fs.realpathSync(projectSkill), `upgrade should prefer the modern project asset root: ${result.stdout}`);
618
- assert(!exists(path.join(repo, "docs", "interfaces", "api.md")), "upgrade must not materialize retired optional templates");
688
+ assert(fs.readFileSync(path.join(repo, "docs", "interfaces", "api.md"), "utf8").startsWith("# API Contract"), "compatibility upgrade must not replace the canonical API doc with a retired physical template");
619
689
  }
620
690
 
621
691
  function testUpgradeInitializesNewEngineeringDefaults() {
@@ -629,8 +699,8 @@ function testUpgradeInitializesNewEngineeringDefaults() {
629
699
  run("python3", [projectAp, "--repo", repo, "upgrade", "--write"], { env: pythonEnvWithHome(fakeHome) });
630
700
 
631
701
  const engineering = fs.readFileSync(path.join(repo, "docs", "ENGINEERING.md"), "utf8");
632
- assert(engineering.includes(`name: "${path.basename(repo)}"`), "upgrade should initialize a newly created project name");
633
- assert(engineering.includes('project_fast: "npm run test:changed"'), "upgrade should infer only a dedicated changed-scope test");
702
+ assert(engineering.includes(`name: ${path.basename(repo)}`), "upgrade should initialize a newly created project name");
703
+ assert(engineering.includes("project_fast: npm run test:changed"), "upgrade should infer only a dedicated changed-scope test");
634
704
  assert(!engineering.includes("gate_standard:"), "upgrade must not infer an automatic standard gate");
635
705
  assert(!engineering.includes("gate_full:"), "upgrade must not infer an automatic full gate");
636
706
  }
@@ -745,14 +815,14 @@ function testLedgerArchiveUpdatesExistingPeriodIndex() {
745
815
  assert(index.includes("(2 files)"), `archive index should report cumulative design count: ${index}`);
746
816
  }
747
817
 
748
- function testManagedEngineeringSyncIsControlledAndIdempotent() {
818
+ function testManagedEngineeringInitIsAuthoritativeAndIdempotent() {
749
819
  const repo = tmpdir("managed-engineering");
750
820
  run("node", [cli, "init"], { cwd: repo });
751
821
  run("node", [cli, "sync", "--projects", repo]);
752
822
 
753
823
  const engineering = path.join(repo, "docs", "ENGINEERING.md");
754
824
  const initial = fs.readFileSync(engineering, "utf8");
755
- const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.1\.7 -->/;
825
+ const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.1\.9 -->/;
756
826
  const endMarker = "<!-- auto-coding-skill:managed-workflow:end -->";
757
827
  assert(startPattern.test(initial), "new projects should include a versioned managed workflow marker");
758
828
  assert(initial.includes(endMarker), "new projects should include the managed workflow end marker");
@@ -763,37 +833,28 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
763
833
  .replace(endMarker, `${endMarker}\nproject note after managed workflow`)
764
834
  .replace("The frontmatter contract is:", "Stale managed workflow contract:");
765
835
  writeFile(engineering, customized);
766
- const staleStart = customized.indexOf("<!-- auto-coding-skill:managed-workflow:start");
767
- const staleEnd = customized.indexOf(endMarker) + endMarker.length;
768
- const outsideBefore = customized.slice(0, staleStart);
769
- const outsideAfter = customized.slice(staleEnd);
770
-
771
836
  const dryRun = run("node", [cli, "sync", "--projects", repo, "--dry-run", "--json"]);
772
837
  const dryResult = JSON.parse(dryRun.stdout).results[0];
773
838
  assert(dryResult.managedWorkflow.state === "stale", `dry-run should expose stale workflow state: ${dryRun.stdout}`);
774
- assert(dryResult.managedWorkflow.version === "4.1.7", "dry-run should expose the target workflow version");
839
+ assert(dryResult.managedWorkflow.version === "4.1.9", "dry-run should expose the target workflow version");
775
840
  assert(dryResult.actions.some(item => item.action === "would-update" && item.path === "docs/ENGINEERING.md"), "dry-run should plan the managed body update");
776
841
  assert(fs.readFileSync(engineering, "utf8") === customized, "dry-run must not write ENGINEERING.md");
777
842
 
778
- run("node", [cli, "sync", "--projects", repo]);
843
+ run("node", [cli, "init"], { cwd: repo });
779
844
  const updated = fs.readFileSync(engineering, "utf8");
780
- const updatedStart = updated.indexOf("<!-- auto-coding-skill:managed-workflow:start");
781
- const updatedEnd = updated.indexOf(endMarker) + endMarker.length;
782
- assert(updated.slice(0, updatedStart) === outsideBefore, "sync must preserve frontmatter and content before the managed block byte-for-byte");
783
- assert(updated.slice(updatedEnd) === outsideAfter, "sync must preserve content after the managed block byte-for-byte");
784
- assert(updated.includes("version=4.1.7"), "sync should install the current managed workflow version");
785
- assert(updated.includes("The frontmatter contract is:"), "sync should refresh stale managed workflow content");
845
+ assert(!updated.includes("project note before") && !updated.includes("project note after"), "init must remove text outside the canonical ENGINEERING body");
846
+ assert(updated.includes("version=4.1.9"), "init should install the current managed workflow version");
847
+ assert(updated.includes("The frontmatter contract is:"), "init should refresh stale managed workflow content");
786
848
 
787
849
  fillRequiredAccess(repo);
788
850
  const status = run("node", [cli, "status", "--projects", repo, "--json"]);
789
851
  const statusResult = JSON.parse(status.stdout).results[0];
790
852
  assert(statusResult.managedWorkflow.state === "current", `status should expose current managed workflow state: ${status.stdout}`);
791
- assert(statusResult.managedWorkflow.version === "4.1.7", "status should expose the installed managed workflow version");
853
+ assert(statusResult.managedWorkflow.version === "4.1.9", "status should expose the installed managed workflow version");
792
854
 
793
- const beforeSecondSync = fs.readFileSync(engineering, "utf8");
794
- const second = run("node", [cli, "sync", "--projects", repo, "--json"]);
795
- assert(!JSON.parse(second.stdout).results[0].actions.some(item => item.path === "docs/ENGINEERING.md"), "current managed workflow should be idempotent");
796
- assert(fs.readFileSync(engineering, "utf8") === beforeSecondSync, "idempotent sync must not rewrite ENGINEERING.md");
855
+ const beforeSecondInit = fs.readFileSync(engineering, "utf8");
856
+ run("node", [cli, "init"], { cwd: repo });
857
+ assert(fs.readFileSync(engineering, "utf8") === beforeSecondInit, "idempotent init must not rewrite ENGINEERING.md");
797
858
  }
798
859
 
799
860
  function testLegacyEngineeringMigrationPreservesExistingBody() {
@@ -816,12 +877,8 @@ function testLegacyEngineeringMigrationPreservesExistingBody() {
816
877
  assert(dryResult.actions.find(item => item.path === "docs/ENGINEERING.md")?.detail.includes("preserved-custom"), "custom legacy action should be labeled preserved-custom");
817
878
  run("node", [cli, "sync", "--projects", repo]);
818
879
  const migrated = fs.readFileSync(engineering, "utf8");
819
- assert(migrated.includes("version=4.1.7"), "legacy migration should insert the current managed workflow");
880
+ assert(migrated.includes("version=4.1.9"), "legacy migration should insert the current managed workflow");
820
881
  assert(migrated.includes(legacyNote), "legacy migration must preserve the complete existing body");
821
- const migratedStart = migrated.indexOf("<!-- auto-coding-skill:managed-workflow:start");
822
- const migratedEnd = migrated.indexOf(endMarker) + endMarker.length;
823
- assert(`${migrated.slice(0, migratedStart)}${migrated.slice(migratedEnd)}` === legacy, "removing the inserted managed block should recover custom legacy content byte-for-byte");
824
-
825
882
  const stable = fs.readFileSync(engineering, "utf8");
826
883
  run("node", [cli, "sync", "--projects", repo]);
827
884
  assert(fs.readFileSync(engineering, "utf8") === stable, "legacy migration should converge after one sync");
@@ -920,7 +977,7 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
920
977
  run("node", [cli, "sync", "--projects", repo]);
921
978
  const agents = path.join(repo, "AGENTS.md");
922
979
  const initial = fs.readFileSync(agents, "utf8");
923
- assert(initial.includes("managed-agents:start version=4.1.7"), "new projects should receive the versioned root AGENTS block");
980
+ assert(initial.includes("managed-agents:start version=4.1.9"), "new projects should receive the versioned root AGENTS block");
924
981
 
925
982
  const custom = [
926
983
  "# Project rules",
@@ -939,12 +996,12 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
939
996
 
940
997
  run("node", [cli, "sync", "--projects", repo]);
941
998
  const migrated = fs.readFileSync(agents, "utf8");
942
- assert(migrated.includes("managed-agents:start version=4.1.7"), "AGENTS migration should install the current managed block");
999
+ assert(migrated.includes("managed-agents:start version=4.1.9"), "AGENTS migration should install the current managed block");
943
1000
  assert(!migrated.includes("Preserve this repository-specific rule exactly."), "root AGENTS must contain no project-specific tail");
944
1001
  assert(!migrated.includes("must execute `commands.gate_full`"), "known official conflicting rule should be removed");
945
1002
  const canonical = fs.readFileSync(path.join(repoRoot, "cli", "assets", "skill", "data", "templates", "bridges", "AGENTS.md"), "utf8");
946
1003
  assert(migrated === canonical, "root AGENTS must be byte-identical to the packaged canonical file");
947
- const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.1.7.md");
1004
+ const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.1.9.md");
948
1005
  assert(fs.readFileSync(archive, "utf8").includes("Preserve this repository-specific rule exactly."), "previous AGENTS content must be archived once");
949
1006
  const stable = fs.readFileSync(agents);
950
1007
  run("node", [cli, "sync", "--projects", repo]);
@@ -988,43 +1045,119 @@ function testEngineeringMarkerBoundaryIsNormalized() {
988
1045
  assert(normalized.includes(`${marker}\n# Project-specific workflow\n`), "sync should normalize a heading glued to the managed end marker");
989
1046
  }
990
1047
 
991
- function testEngineeringFrameworkAllowsProjectFactsButRejectsDuplicateWorkflow() {
1048
+ function testEngineeringFrameworkRejectsAnyNonCanonicalWorkflowText() {
992
1049
  const repo = tmpdir("engineering-framework");
993
1050
  run("node", [cli, "init"], { cwd: repo });
994
1051
  run("node", [cli, "sync", "--projects", repo]);
995
1052
  fillRequiredAccess(repo);
996
1053
  const engineering = path.join(repo, "docs", "ENGINEERING.md");
997
1054
  fs.appendFileSync(engineering, "\n# Project Facts\n\n## Repository boundaries\n\n- backend owns APIs.\n");
998
- const projectFactsStatus = run("node", [cli, "status", "--projects", repo, "--json"]);
999
- assert(JSON.parse(projectFactsStatus.stdout).results[0].managedWorkflow.state === "current", "project fact sections should remain outside the managed block");
1000
-
1001
- fs.appendFileSync(engineering, "\n## Delivery flow\n\n1. Known obsolete workflow.\n");
1002
- const migration = run("node", [cli, "sync", "--projects", repo, "--dry-run", "--json"]);
1003
- const migrationResult = JSON.parse(migration.stdout).results[0];
1004
- assert(migrationResult.managedWorkflow.state === "stale", "known duplicate sections should use controlled migration");
1005
- assert(migrationResult.managedWorkflow.migrations.includes("engineering-section-delivery-flow"), "known section migration should be explicit");
1006
- assert(migrationResult.actions.some(item => item.action === "would-archive" && item.path.includes("ENGINEERING.pre-4.1.7")), "controlled section cleanup should archive the previous ENGINEERING file");
1007
- run("node", [cli, "sync", "--projects", repo]);
1008
- assert(!fs.readFileSync(engineering, "utf8").includes("Known obsolete workflow"), "known duplicate workflow section should be removed");
1055
+ const status = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
1056
+ assert(status.status !== 0, "text outside the canonical ENGINEERING body must be drift");
1057
+ assert(JSON.parse(status.stdout).results[0].docsDiffs.some(item => item.path === "docs/ENGINEERING.md"), "status should identify ENGINEERING convergence");
1058
+
1059
+ run("node", [cli, "init"], { cwd: repo });
1060
+ assert(!fs.readFileSync(engineering, "utf8").includes("backend owns APIs"), "init must restore the canonical ENGINEERING body");
1061
+ const archived = path.join(repo, ".agents", "archive", "auto-coding-skill", "4.1.9", "docs", "ENGINEERING.md");
1062
+ assert(fs.readFileSync(archived, "utf8").includes("backend owns APIs"), "removed project text should remain in non-authoritative history");
1063
+ }
1064
+
1065
+ function testManagedInstallIntegrityIsBoundedAndRepairable() {
1066
+ const repo = tmpdir("managed-integrity");
1067
+ const initialized = run("node", [cli, "init"], { cwd: repo });
1068
+ assert(initialized.stdout.includes("verify: .agents/managed-install.json"), "init must verify managed files before reporting success");
1069
+ fillRequiredAccess(repo);
1070
+
1071
+ const manifestPath = path.join(repo, ".agents", "managed-install.json");
1072
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
1073
+ assert(manifest.schema_version === 1 && manifest.skill_version === "4.1.9", "installed manifest must identify the release");
1074
+ assert(manifest.entries.length > 0, "installed manifest must list managed files");
1075
+ for (const entry of manifest.entries) {
1076
+ assert(typeof entry.path === "string" && !path.isAbsolute(entry.path) && !entry.path.includes(".."), "manifest paths must be safe relative paths");
1077
+ assert(/^[0-9a-f]{64}$/.test(entry.sha256), `${entry.path}: manifest hash must be sha256`);
1078
+ assert(entry.version === "4.1.9" && typeof entry.executable === "boolean", `${entry.path}: version/executable metadata missing`);
1079
+ }
1080
+ assert(!manifest.managed_namespaces.some(item => item.path === ".agents" || item.path === "docs"), "manifest must not mirror entire project-owned trees");
1081
+
1082
+ const customAgent = path.join(repo, ".agents", "agents", "project-specialist.toml");
1083
+ const archiveNote = path.join(repo, ".agents", "archive", "owner-note.md");
1084
+ const adr = path.join(repo, "docs", "architecture", "adr", "0042-project-choice.md");
1085
+ writeFile(customAgent, 'name = "project-specialist"\ndescription = "project owned"\n');
1086
+ writeFile(archiveNote, "historical\n");
1087
+ writeFile(adr, "# ADR-0042\n\nProject owned.\n");
1088
+ assertStatusOk(repo);
1089
+ const launcher = path.join(repo, "docs", "tools", "autopipeline", "ap.py");
1090
+ run("python3", [launcher, "--repo", repo, "doctor"]);
1091
+
1092
+ const skill = path.join(repo, ".agents", "skills", "auto-coding-skill", "SKILL.md");
1093
+ fs.appendFileSync(skill, "\nmanaged drift\n");
1094
+ let doctor = run("python3", [launcher, "--repo", repo, "doctor"], { check: false });
1095
+ assert(doctor.status !== 0 && `${doctor.stdout}\n${doctor.stderr}`.includes("SKILL.md: managed content drift"), "doctor must identify managed Skill drift");
1096
+ run("node", [cli, "init"], { cwd: repo });
1097
+
1098
+ const extraSkill = path.join(repo, ".agents", "skills", "auto-coding-skill", "obsolete.txt");
1099
+ writeFile(extraSkill, "obsolete\n");
1100
+ let status = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
1101
+ let parsed = JSON.parse(status.stdout).results[0];
1102
+ assert(status.status !== 0 && parsed.installIntegrity.errors.some(item => item.includes("unexpected file in managed namespace")), "status must reject extras in the exact Skill namespace");
1103
+ run("node", [cli, "init"], { cwd: repo });
1104
+
1105
+ const oldRuntime = path.join(repo, "docs", "tools", "autopipeline", "core.py");
1106
+ writeFile(oldRuntime, "# obsolete project runtime copy\n");
1107
+ status = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
1108
+ parsed = JSON.parse(status.stdout).results[0];
1109
+ assert(status.status !== 0 && parsed.installIntegrity.errors.some(item => item.includes("docs/tools/autopipeline/core.py")), "launcher namespace extras must be drift");
1110
+ run("node", [cli, "init"], { cwd: repo });
1111
+ assert(!exists(oldRuntime), "init must clean obsolete files from the exact launcher namespace");
1112
+
1113
+ if (process.platform !== "win32") {
1114
+ const core = path.join(repo, ".agents", "skills", "auto-coding-skill", "scripts", "core.py");
1115
+ fs.chmodSync(core, fs.statSync(core).mode & ~0o111);
1116
+ status = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
1117
+ parsed = JSON.parse(status.stdout).results[0];
1118
+ assert(status.status !== 0 && parsed.installIntegrity.errors.some(item => item.includes("core.py: executable bit drift")), "status must detect executable-bit drift");
1119
+ run("node", [cli, "init"], { cwd: repo });
1120
+ assert((fs.statSync(core).mode & 0o111) !== 0, "init must restore the declared executable bit");
1121
+ }
1122
+
1123
+ const explorer = path.join(repo, ".agents", "agents", "explorer.toml");
1124
+ writeFile(explorer, fs.readFileSync(explorer, "utf8").replace(/^description\s*=.*$/m, '$&\nmodel = "vendor/project-model"'));
1125
+ assertStatusOk(repo);
1126
+ writeFile(explorer, fs.readFileSync(explorer, "utf8").replace('model = "vendor/project-model"', "model = []"));
1127
+ doctor = run("python3", [launcher, "--repo", repo, "doctor"], { check: false });
1128
+ assert(doctor.status !== 0 && `${doctor.stdout}\n${doctor.stderr}`.includes("model must be a non-empty TOML string"), "doctor must reject invalid normalized-agent overrides");
1129
+ run("node", [cli, "init"], { cwd: repo });
1009
1130
 
1010
- fs.appendFileSync(engineering, "\n## Team workflow\n\n1. Unknown competing workflow.\n");
1011
- const duplicateStatus = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
1012
- assert(duplicateStatus.status !== 0, "duplicate workflow sections must make status non-current");
1013
- const plan = JSON.parse(duplicateStatus.stdout).results[0].managedWorkflow;
1014
- assert(plan.state === "conflict" && plan.conflicts.some(item => item.ruleId === "duplicate-managed-workflow-section"), "duplicate workflow conflict should identify the docs framework rule");
1131
+ const staleManifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
1132
+ staleManifest.skill_version = "0.0.0";
1133
+ writeFile(manifestPath, `${JSON.stringify(staleManifest)}\n`);
1134
+ status = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
1135
+ parsed = JSON.parse(status.stdout).results[0];
1136
+ assert(status.status !== 0 && parsed.installManifestDiffs.some(item => item.status === "stale"), "status must compare the local manifest with the release manifest");
1137
+ doctor = run("python3", [launcher, "--repo", repo, "doctor"], { check: false });
1138
+ assert(doctor.status !== 0 && `${doctor.stdout}\n${doctor.stderr}`.includes("manifest version"), "doctor must reject a mismatched local manifest");
1139
+ run("node", [cli, "init"], { cwd: repo });
1140
+
1141
+ assert(fs.readFileSync(customAgent, "utf8").includes("project owned"), "init must preserve project-owned custom agents");
1142
+ assert(fs.readFileSync(archiveNote, "utf8") === "historical\n", "init must preserve archives untouched");
1143
+ assert(fs.readFileSync(adr, "utf8").includes("Project owned"), "init must preserve project-owned documents");
1144
+ assertStatusOk(repo);
1015
1145
  }
1016
1146
 
1017
1147
  function testReleaseVersionMarkersStayInSync() {
1018
- const expected = "4.1.7";
1148
+ const expected = "4.1.9";
1019
1149
  const pkg = JSON.parse(fs.readFileSync(path.join(repoRoot, "package.json"), "utf8"));
1020
1150
  const lock = JSON.parse(fs.readFileSync(path.join(repoRoot, "package-lock.json"), "utf8"));
1021
1151
  const policy = JSON.parse(fs.readFileSync(
1022
1152
  path.join(repoRoot, "src", "auto-coding-skill", "data", "policies", "workflow-migrations-v1.json"),
1023
1153
  "utf8",
1024
1154
  ));
1025
- assert(pkg.version === expected, "package version must match the 4.1.7 release");
1155
+ assert(pkg.version === expected, "package version must match the 4.1.9 release");
1026
1156
  assert(lock.version === expected && lock.packages[""].version === expected, "package-lock versions must match");
1027
1157
  assert(policy.managed_versions.engineering === expected && policy.managed_versions.agents === expected, "managed workflow versions must match");
1158
+ const manifest = JSON.parse(fs.readFileSync(path.join(repoRoot, "cli", "assets", "managed-install.json"), "utf8"));
1159
+ assert(manifest.skill_version === expected && manifest.schema_version === 1, "managed install manifest version/schema must match");
1160
+ assert(manifest.entries.every(entry => entry.version === expected && /^[0-9a-f]{64}$/.test(entry.sha256)), "managed install entries must carry release hashes and versions");
1028
1161
  const publishWorkflow = fs.readFileSync(path.join(repoRoot, ".github", "workflows", "npm-publish.yml"), "utf8");
1029
1162
  const runtimeRequirements = fs.readFileSync(path.join(repoRoot, "src", "auto-coding-skill", "requirements.txt"), "utf8");
1030
1163
  assert(publishWorkflow.includes("tags:\n - \"v*\""), "npm publish must run from version tag pushes");
@@ -1055,13 +1188,14 @@ function testProtocolResponsibilitiesStaySeparated() {
1055
1188
  assert(engineering.includes("The frontmatter contract is:") && !engineering.includes("## Git and parallel work"), "ENGINEERING must remain project configuration/facts");
1056
1189
  }
1057
1190
 
1058
- testPreflightAvoidsPartialInstall();
1191
+ testInitFullyConvergesExistingProject();
1059
1192
  testInitRejectsMissingPythonRuntimeBeforeWrites();
1060
1193
  testDestVariants();
1061
1194
  testLauncherFallsBackToGlobalRuntime();
1062
- testMinimalSyncConvergesWithinBudget();
1195
+ testMinimalInitConvergesWithinBudget();
1063
1196
  testStatusRejectsLegacyIsolation();
1064
1197
  testStatusRejectsLegacyGateEscalation();
1198
+ testStatusAcceptsValidIndentlessYamlRoutes();
1065
1199
  testOrdinaryNodeTestIsNotPromotedToAutomaticGate();
1066
1200
  testAccessPasswordsAreRequiredButNeverPrintedByStatus();
1067
1201
  testManagedAgentModelsInheritAndOverridesSurvive();
@@ -1082,7 +1216,7 @@ testRemovedVerificationFlagsFailFast();
1082
1216
  testUpgradeInstallsRuntimeRequiredByLauncher();
1083
1217
  testLedgerArchiveRecognizesSettledStatuses();
1084
1218
  testLedgerArchiveUpdatesExistingPeriodIndex();
1085
- testManagedEngineeringSyncIsControlledAndIdempotent();
1219
+ testManagedEngineeringInitIsAuthoritativeAndIdempotent();
1086
1220
  testLegacyEngineeringMigrationPreservesExistingBody();
1087
1221
  testOfficialLegacyEngineeringBodyIsReplacedWithoutDuplication();
1088
1222
  testMalformedManagedMarkersFailClosed();
@@ -1091,7 +1225,8 @@ testLegacyTaskPreflightRejectsWholeBatchAtomically();
1091
1225
  testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules();
1092
1226
  testUnknownWorkflowConflictFailsWholeBatchBeforeWrites();
1093
1227
  testEngineeringMarkerBoundaryIsNormalized();
1094
- testEngineeringFrameworkAllowsProjectFactsButRejectsDuplicateWorkflow();
1228
+ testEngineeringFrameworkRejectsAnyNonCanonicalWorkflowText();
1229
+ testManagedInstallIntegrityIsBoundedAndRepairable();
1095
1230
  testReleaseVersionMarkersStayInSync();
1096
1231
  testProtocolResponsibilitiesStaySeparated();
1097
1232
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elvis1513/auto-coding-skill",
3
- "version": "4.1.7",
3
+ "version": "4.1.9",
4
4
  "description": "CLI installer for a delivery-first .agents workflow with adaptive Git isolation, routed changed-scope validation, risk-based review, push completion, and safe cleanup.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,6 +11,7 @@
11
11
  "cli/tests",
12
12
  "cli/assets/skill",
13
13
  "cli/assets/agents",
14
+ "cli/assets/managed-install.json",
14
15
  "README.md",
15
16
  "LICENSE"
16
17
  ],
@@ -18,8 +19,8 @@
18
19
  "clean:cache": "find cli src -type d -name '__pycache__' -prune -exec rm -rf {} +",
19
20
  "prepack": "npm run clean:cache",
20
21
  "check:package": "npm run clean:cache && node cli/src/check-package.js",
21
- "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 cli/tests/ap_concurrency_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 {} +",
22
- "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 {} +",
22
+ "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/install_integrity.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/install_integrity.py cli/assets/skill/scripts/scaffold_templates.py && python3 cli/tests/ap_profiles_test.py && python3 cli/tests/ap_concurrency_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 {} +",
23
+ "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/install_integrity.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/install_integrity.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 {} +",
23
24
  "check:assets": "node cli/src/sync-assets.js --check",
24
25
  "sync-assets": "node cli/src/sync-assets.js",
25
26
  "release:check": "npm run check:assets && npm run test:src && npm run test && npm run check:package"