@elvis1513/auto-coding-skill 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -2
- package/cli/assets/agents/fixer.toml +3 -3
- package/cli/assets/skill/SKILL.md +35 -22
- package/cli/assets/skill/data/contracts/orchestration-v1.schema.json +18 -2
- package/cli/assets/skill/data/policies/workflow-migrations-v1.json +371 -0
- package/cli/assets/skill/data/templates/ENGINEERING.md +27 -13
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +5 -1
- package/cli/assets/skill/scripts/ap.py +403 -19
- package/cli/src/index.js +390 -39
- package/cli/tests/ap_concurrency_test.py +73 -7
- package/cli/tests/ap_profiles_test.py +100 -2
- package/cli/tests/index.test.js +102 -12
- package/package.json +1 -1
|
@@ -49,7 +49,7 @@ def git_output(cwd: Path, *args: str) -> str:
|
|
|
49
49
|
return git(cwd, *args).stdout.strip()
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def base_config(isolation: str | object = "
|
|
52
|
+
def base_config(isolation: str | object = "adaptive") -> dict:
|
|
53
53
|
config = {
|
|
54
54
|
"workflow": {"mode": "dev", "profile": "auto", "completion": "push"},
|
|
55
55
|
"project": {"name": "concurrency-test"},
|
|
@@ -73,10 +73,10 @@ def base_config(isolation: str | object = "worktree") -> dict:
|
|
|
73
73
|
"gate_full": "true",
|
|
74
74
|
},
|
|
75
75
|
"gate": {
|
|
76
|
-
"default_scope": "
|
|
77
|
-
"fallback_scope": "
|
|
78
|
-
"full_on_unknown":
|
|
79
|
-
"no_change_scope": "
|
|
76
|
+
"default_scope": "changed",
|
|
77
|
+
"fallback_scope": "changed",
|
|
78
|
+
"full_on_unknown": False,
|
|
79
|
+
"no_change_scope": "changed",
|
|
80
80
|
"rules": [],
|
|
81
81
|
},
|
|
82
82
|
"structure": {"enabled": False, "enforcement": "advisory"},
|
|
@@ -109,7 +109,7 @@ def base_config(isolation: str | object = "worktree") -> dict:
|
|
|
109
109
|
class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
110
110
|
def make_repo(
|
|
111
111
|
self,
|
|
112
|
-
isolation: str | object = "
|
|
112
|
+
isolation: str | object = "adaptive",
|
|
113
113
|
) -> tuple[Path, Path, Path]:
|
|
114
114
|
temp = tempfile.TemporaryDirectory(prefix="autocoding-concurrency-")
|
|
115
115
|
self.addCleanup(temp.cleanup)
|
|
@@ -242,6 +242,72 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
242
242
|
)
|
|
243
243
|
return result
|
|
244
244
|
|
|
245
|
+
def test_task_start_rejects_unknown_full_gate_policy_before_creating_branch(self) -> None:
|
|
246
|
+
_, repo, _ = self.make_repo()
|
|
247
|
+
(repo / "AGENTS.md").write_text(
|
|
248
|
+
"# Workflow\n- High-risk work\n must run the real full gate before push.\n",
|
|
249
|
+
encoding="utf-8",
|
|
250
|
+
)
|
|
251
|
+
result = self.ap(
|
|
252
|
+
repo,
|
|
253
|
+
"task-start",
|
|
254
|
+
"POLICY-START",
|
|
255
|
+
"--base",
|
|
256
|
+
"origin/dev",
|
|
257
|
+
"--owned-path",
|
|
258
|
+
".",
|
|
259
|
+
check=False,
|
|
260
|
+
)
|
|
261
|
+
self.assertNotEqual(0, result.returncode)
|
|
262
|
+
self.assertIn("AGENTS.md:2", result.stdout + result.stderr)
|
|
263
|
+
self.assert_local_branch(repo, "codex/POLICY-START", False)
|
|
264
|
+
|
|
265
|
+
def test_task_start_rejects_legacy_gate_yaml_before_creating_branch(self) -> None:
|
|
266
|
+
_, repo, _ = self.make_repo()
|
|
267
|
+
engineering = repo / "docs" / "ENGINEERING.md"
|
|
268
|
+
text = engineering.read_text(encoding="utf-8").replace(
|
|
269
|
+
" full_on_unknown: false\n",
|
|
270
|
+
" full_on_unknown: true\n full_on:\n - prod_config\n",
|
|
271
|
+
).replace(
|
|
272
|
+
" rules: []\n",
|
|
273
|
+
" rules:\n - match:\n - Jenkinsfile\n scope: full\n commands:\n - gate_full\n",
|
|
274
|
+
)
|
|
275
|
+
engineering.write_text(text, encoding="utf-8")
|
|
276
|
+
result = self.ap(
|
|
277
|
+
repo,
|
|
278
|
+
"task-start",
|
|
279
|
+
"POLICY-YAML",
|
|
280
|
+
"--base",
|
|
281
|
+
"origin/dev",
|
|
282
|
+
"--owned-path",
|
|
283
|
+
".",
|
|
284
|
+
check=False,
|
|
285
|
+
)
|
|
286
|
+
self.assertNotEqual(0, result.returncode)
|
|
287
|
+
self.assertIn("gate.full_on", result.stdout + result.stderr)
|
|
288
|
+
self.assertIn("gate.rules[0].scope", result.stdout + result.stderr)
|
|
289
|
+
self.assert_local_branch(repo, "codex/POLICY-YAML", False)
|
|
290
|
+
|
|
291
|
+
def test_commit_push_rejects_policy_added_after_task_start(self) -> None:
|
|
292
|
+
_, repo, _ = self.make_repo()
|
|
293
|
+
worktree = self.start_task(repo, "POLICY-PUSH")
|
|
294
|
+
(worktree / "AGENTS.md").write_text(
|
|
295
|
+
"# Workflow\nRuntime changes require the full gate.\n",
|
|
296
|
+
encoding="utf-8",
|
|
297
|
+
)
|
|
298
|
+
self.approve_task(worktree, "POLICY-PUSH")
|
|
299
|
+
result = self.ap(
|
|
300
|
+
worktree,
|
|
301
|
+
"commit-push",
|
|
302
|
+
"POLICY-PUSH",
|
|
303
|
+
"--msg",
|
|
304
|
+
"POLICY-PUSH: blocked",
|
|
305
|
+
check=False,
|
|
306
|
+
)
|
|
307
|
+
self.assertNotEqual(0, result.returncode)
|
|
308
|
+
self.assertIn("AGENTS.md:2", result.stdout + result.stderr)
|
|
309
|
+
self.assertEqual("", git_output(worktree, "diff", "--cached", "--name-only"))
|
|
310
|
+
|
|
245
311
|
def manifest_payloads(self, repo: Path) -> list[dict]:
|
|
246
312
|
common_dir_raw = git_output(repo, "rev-parse", "--git-common-dir")
|
|
247
313
|
common_dir = Path(common_dir_raw)
|
|
@@ -1566,7 +1632,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1566
1632
|
check=False,
|
|
1567
1633
|
)
|
|
1568
1634
|
self.assertNotEqual(0, result.returncode)
|
|
1569
|
-
self.assertIn("must be worktree", result.stdout + result.stderr)
|
|
1635
|
+
self.assertIn("must be adaptive or worktree", result.stdout + result.stderr)
|
|
1570
1636
|
self.assertEqual(before, git_output(legacy_repo, "rev-parse", "HEAD"))
|
|
1571
1637
|
self.assertEqual(
|
|
1572
1638
|
"baseline",
|
|
@@ -27,7 +27,7 @@ def run(repo: Path, *args: str) -> None:
|
|
|
27
27
|
def base_config() -> dict:
|
|
28
28
|
return {
|
|
29
29
|
"workflow": {"mode": "dev", "profile": "auto", "completion": "push"},
|
|
30
|
-
"concurrency": {"isolation": "
|
|
30
|
+
"concurrency": {"isolation": "adaptive"},
|
|
31
31
|
"project": {"name": "profile-test"},
|
|
32
32
|
"access": {
|
|
33
33
|
"project": {
|
|
@@ -68,6 +68,30 @@ def base_config() -> dict:
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
class AutoCodingProfileTests(unittest.TestCase):
|
|
71
|
+
@staticmethod
|
|
72
|
+
def workflow_policy(*, fragments: list[dict] | None = None) -> dict:
|
|
73
|
+
return {
|
|
74
|
+
"schema_version": 1,
|
|
75
|
+
"managed_versions": {"agents": "3.0.2", "engineering": "3.0.2"},
|
|
76
|
+
"known_official_engineering_body_sha256": [],
|
|
77
|
+
"known_official_fragments": fragments or [],
|
|
78
|
+
"conflict_rules": [
|
|
79
|
+
{
|
|
80
|
+
"id": "mandatory-full",
|
|
81
|
+
"paths": ["AGENTS.md", "docs/ENGINEERING.md"],
|
|
82
|
+
"pattern": r"^.*must run the full gate.*$",
|
|
83
|
+
"flags": "im",
|
|
84
|
+
"message": "full gate is not automatic",
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"dependency_recovery": {
|
|
88
|
+
"allowed_gate": "gate_changed",
|
|
89
|
+
"requires_locked_dependency": True,
|
|
90
|
+
"retry_same_gate_only": True,
|
|
91
|
+
"forbid_full_gate_recovery": True,
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
71
95
|
def make_repo(self, change_path: str | None = None, config: dict | None = None) -> tuple[Path, dict]:
|
|
72
96
|
temp = tempfile.TemporaryDirectory(prefix="autocoding-profile-")
|
|
73
97
|
self.addCleanup(temp.cleanup)
|
|
@@ -453,13 +477,87 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
453
477
|
ap.cmd_doctor(argparse.Namespace(repo=str(repo)))
|
|
454
478
|
self.assertIn("gate.rules[0].scope", str(context.exception))
|
|
455
479
|
|
|
480
|
+
def test_upgrade_migrates_legacy_yaml_and_known_policy_fragments(self) -> None:
|
|
481
|
+
cfg = base_config()
|
|
482
|
+
cfg["gate"]["full_on"] = {"paths": ["src/**"]}
|
|
483
|
+
cfg["gate"]["rules"] = [
|
|
484
|
+
{
|
|
485
|
+
"name": "legacy",
|
|
486
|
+
"paths": ["src/**"],
|
|
487
|
+
"profile": "high-risk",
|
|
488
|
+
"scope": "full",
|
|
489
|
+
"commands": ["gate_full"],
|
|
490
|
+
}
|
|
491
|
+
]
|
|
492
|
+
repo, _ = self.make_repo(config=cfg)
|
|
493
|
+
engineering = repo / "docs" / "ENGINEERING.md"
|
|
494
|
+
engineering.write_text(
|
|
495
|
+
engineering.read_text(encoding="utf-8") + "High-risk work must run the full gate.\n",
|
|
496
|
+
encoding="utf-8",
|
|
497
|
+
)
|
|
498
|
+
policy = self.workflow_policy(
|
|
499
|
+
fragments=[
|
|
500
|
+
{
|
|
501
|
+
"id": "official-high-risk-full",
|
|
502
|
+
"paths": ["docs/ENGINEERING.md"],
|
|
503
|
+
"match": "exact-line",
|
|
504
|
+
"text": "High-risk work must run the full gate.",
|
|
505
|
+
}
|
|
506
|
+
]
|
|
507
|
+
)
|
|
508
|
+
args = argparse.Namespace(repo=str(repo), write=True, dry_run=False, json=False)
|
|
509
|
+
with mock.patch.object(ap, "_load_workflow_migration_policy", return_value=policy):
|
|
510
|
+
ap.cmd_upgrade(args)
|
|
511
|
+
|
|
512
|
+
migrated, body = ap._read_frontmatter_markdown(engineering)
|
|
513
|
+
self.assertNotIn("full_on", migrated["gate"])
|
|
514
|
+
self.assertNotIn("scope", migrated["gate"]["rules"][0])
|
|
515
|
+
self.assertNotIn("commands", migrated["gate"]["rules"][0])
|
|
516
|
+
self.assertEqual("true", migrated["commands"]["gate_full"])
|
|
517
|
+
self.assertNotIn("must run the full gate", body)
|
|
518
|
+
|
|
519
|
+
def test_upgrade_unknown_policy_conflict_fails_before_any_write(self) -> None:
|
|
520
|
+
repo, _ = self.make_repo()
|
|
521
|
+
agents = repo / "AGENTS.md"
|
|
522
|
+
agents.write_text("# Rules\nHigh-risk work must run the full gate.\n", encoding="utf-8")
|
|
523
|
+
before = agents.read_text(encoding="utf-8")
|
|
524
|
+
args = argparse.Namespace(repo=str(repo), write=True, dry_run=False, json=False)
|
|
525
|
+
with mock.patch.object(
|
|
526
|
+
ap,
|
|
527
|
+
"_load_workflow_migration_policy",
|
|
528
|
+
return_value=self.workflow_policy(),
|
|
529
|
+
):
|
|
530
|
+
with self.assertRaises(APError) as context:
|
|
531
|
+
ap.cmd_upgrade(args)
|
|
532
|
+
self.assertIn("AGENTS.md:2", str(context.exception))
|
|
533
|
+
self.assertEqual(before, agents.read_text(encoding="utf-8"))
|
|
534
|
+
self.assertFalse((repo / ".agents").exists())
|
|
535
|
+
|
|
536
|
+
def test_doctor_ignores_managed_blocks_but_rejects_unknown_external_rule(self) -> None:
|
|
537
|
+
repo, _ = self.make_repo()
|
|
538
|
+
agents = repo / "AGENTS.md"
|
|
539
|
+
agents.write_text(
|
|
540
|
+
"<!-- auto-coding-skill:managed-agents:start version=3.0.2 -->\n"
|
|
541
|
+
"High-risk work must run the full gate.\n"
|
|
542
|
+
"<!-- auto-coding-skill:managed-agents:end -->\n",
|
|
543
|
+
encoding="utf-8",
|
|
544
|
+
)
|
|
545
|
+
policy = self.workflow_policy()
|
|
546
|
+
with mock.patch.object(ap, "_load_workflow_migration_policy", return_value=policy):
|
|
547
|
+
ap.cmd_doctor(argparse.Namespace(repo=str(repo)))
|
|
548
|
+
agents.write_text(agents.read_text(encoding="utf-8") + "High-risk work must run the full gate.\n", encoding="utf-8")
|
|
549
|
+
with mock.patch.object(ap, "_load_workflow_migration_policy", return_value=policy):
|
|
550
|
+
with self.assertRaises(APError) as context:
|
|
551
|
+
ap.cmd_doctor(argparse.Namespace(repo=str(repo)))
|
|
552
|
+
self.assertIn("AGENTS.md:4", str(context.exception))
|
|
553
|
+
|
|
456
554
|
def test_doctor_rejects_legacy_isolation(self) -> None:
|
|
457
555
|
cfg = base_config()
|
|
458
556
|
cfg["concurrency"]["isolation"] = "legacy"
|
|
459
557
|
repo, _ = self.make_repo(config=cfg)
|
|
460
558
|
with self.assertRaises(APError) as context:
|
|
461
559
|
ap.cmd_doctor(argparse.Namespace(repo=str(repo)))
|
|
462
|
-
self.assertIn("must be worktree", str(context.exception))
|
|
560
|
+
self.assertIn("must be adaptive or worktree", str(context.exception))
|
|
463
561
|
|
|
464
562
|
def test_doctor_requires_one_fast_gate_for_every_profile(self) -> None:
|
|
465
563
|
for profile in ["micro", "standard", "high-risk", "auto"]:
|
package/cli/tests/index.test.js
CHANGED
|
@@ -206,11 +206,11 @@ function testMinimalSyncConvergesWithinBudget() {
|
|
|
206
206
|
|
|
207
207
|
const files = listProjectFiles(repo);
|
|
208
208
|
const lines = files.reduce((total, file) => total + fs.readFileSync(file, "utf8").split(/\r?\n/).length, 0);
|
|
209
|
-
assert(files.length <=
|
|
210
|
-
assert(lines <=
|
|
209
|
+
assert(files.length <= 23, `minimal scaffold file budget exceeded: ${files.length}`);
|
|
210
|
+
assert(lines <= 10000, `minimal scaffold line budget exceeded: ${lines}`);
|
|
211
211
|
const engineering = fs.readFileSync(path.join(repo, "docs", "ENGINEERING.md"), "utf8");
|
|
212
212
|
assert(engineering.includes("profile: \"auto\""), "engineering should enable adaptive profiles");
|
|
213
|
-
assert(engineering.includes("isolation: \"
|
|
213
|
+
assert(engineering.includes("isolation: \"adaptive\""), "engineering should default to adaptive clean-branch/worktree isolation");
|
|
214
214
|
assert(engineering.includes('completion: "push"'), "engineering should complete normal development at push");
|
|
215
215
|
assert(engineering.includes('gate_changed: "git diff --check"'), "generic projects should receive the fast diff gate");
|
|
216
216
|
assert(engineering.includes(`name: "${path.basename(repo)}"`), "project name should be initialized automatically");
|
|
@@ -256,7 +256,7 @@ function testStatusRejectsLegacyIsolation() {
|
|
|
256
256
|
fillRequiredAccess(repo);
|
|
257
257
|
const engineeringPath = path.join(repo, "docs", "ENGINEERING.md");
|
|
258
258
|
const engineering = fs.readFileSync(engineeringPath, "utf8").replace(
|
|
259
|
-
'isolation: "
|
|
259
|
+
'isolation: "adaptive"',
|
|
260
260
|
'isolation: "legacy"',
|
|
261
261
|
);
|
|
262
262
|
fs.writeFileSync(engineeringPath, engineering);
|
|
@@ -265,12 +265,30 @@ function testStatusRejectsLegacyIsolation() {
|
|
|
265
265
|
assert(result.status !== 0, "status must reject legacy isolation");
|
|
266
266
|
const parsed = JSON.parse(result.stdout).results[0];
|
|
267
267
|
assert(
|
|
268
|
-
parsed.invalidConfigTokens.includes("concurrency.isolation (must be worktree)"),
|
|
268
|
+
parsed.invalidConfigTokens.includes("concurrency.isolation (must be adaptive or worktree)"),
|
|
269
269
|
`status should identify the invalid isolation value: ${result.stdout}`,
|
|
270
270
|
);
|
|
271
271
|
assert(parsed.next.includes("upgrade --write"), "status should direct legacy projects through upgrade");
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
function testStatusRejectsLegacyGateEscalation() {
|
|
275
|
+
const repo = tmpdir("legacy-gate-status");
|
|
276
|
+
run("node", [cli, "init"], { cwd: repo });
|
|
277
|
+
run("node", [cli, "sync", "--projects", repo]);
|
|
278
|
+
const engineeringPath = path.join(repo, "docs", "ENGINEERING.md");
|
|
279
|
+
const engineering = fs.readFileSync(engineeringPath, "utf8").replace(
|
|
280
|
+
' full_on_unknown: false\n no_change_scope: "changed"\n profile_log:',
|
|
281
|
+
' full_on_unknown: "true"\n full_on: ["prod_config"]\n no_change_scope: "changed"\n rules:\n - match: ["Jenkinsfile"]\n scope: "full"\n commands: ["gate_full"]\n profile_log:',
|
|
282
|
+
);
|
|
283
|
+
fs.writeFileSync(engineeringPath, engineering);
|
|
284
|
+
const status = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
|
|
285
|
+
assert(status.status === 2, "legacy automatic gate escalation must make status non-zero");
|
|
286
|
+
const invalid = JSON.parse(status.stdout).results[0].invalidConfigTokens;
|
|
287
|
+
for (const expected of ["gate.full_on", "gate.full_on_unknown", "gate.rules[].scope", "gate.rules[].commands"]) {
|
|
288
|
+
assert(invalid.some(item => item.includes(expected)), `status should report ${expected}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
274
292
|
function testOrdinaryNodeTestIsNotPromotedToAutomaticGate() {
|
|
275
293
|
const repo = tmpdir("node-gate-inference");
|
|
276
294
|
writeFile(path.join(repo, "package.json"), JSON.stringify({ scripts: { test: "node --test" } }, null, 2) + "\n");
|
|
@@ -618,7 +636,7 @@ function testUpgradeMigratesLegacyAutomaticGateToFastDefault() {
|
|
|
618
636
|
assert(engineering.includes("gate_changed: git diff --check"), "upgrade should replace the v3 auto-seeded npm test gate");
|
|
619
637
|
assert(engineering.includes("mode: dev"), "upgrade should migrate verify mode to fast development mode");
|
|
620
638
|
assert(engineering.includes("completion: push"), "upgrade should add push completion");
|
|
621
|
-
assert(engineering.includes("isolation:
|
|
639
|
+
assert(engineering.includes("isolation: adaptive"), "upgrade should migrate legacy isolation to adaptive");
|
|
622
640
|
for (const key of ["default_scope", "fallback_scope", "no_change_scope"]) {
|
|
623
641
|
assert(engineering.includes(`${key}: changed`), `upgrade should migrate gate.${key} to changed`);
|
|
624
642
|
}
|
|
@@ -701,7 +719,7 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
|
|
|
701
719
|
|
|
702
720
|
const engineering = path.join(repo, "docs", "ENGINEERING.md");
|
|
703
721
|
const initial = fs.readFileSync(engineering, "utf8");
|
|
704
|
-
const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=3\.0\.
|
|
722
|
+
const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=3\.0\.3 -->/;
|
|
705
723
|
const endMarker = "<!-- auto-coding-skill:managed-workflow:end -->";
|
|
706
724
|
assert(startPattern.test(initial), "new projects should include a versioned managed workflow marker");
|
|
707
725
|
assert(initial.includes(endMarker), "new projects should include the managed workflow end marker");
|
|
@@ -720,7 +738,7 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
|
|
|
720
738
|
const dryRun = run("node", [cli, "sync", "--projects", repo, "--dry-run", "--json"]);
|
|
721
739
|
const dryResult = JSON.parse(dryRun.stdout).results[0];
|
|
722
740
|
assert(dryResult.managedWorkflow.state === "stale", `dry-run should expose stale workflow state: ${dryRun.stdout}`);
|
|
723
|
-
assert(dryResult.managedWorkflow.version === "3.0.
|
|
741
|
+
assert(dryResult.managedWorkflow.version === "3.0.3", "dry-run should expose the target workflow version");
|
|
724
742
|
assert(dryResult.actions.some(item => item.action === "would-update" && item.path === "docs/ENGINEERING.md"), "dry-run should plan the managed body update");
|
|
725
743
|
assert(fs.readFileSync(engineering, "utf8") === customized, "dry-run must not write ENGINEERING.md");
|
|
726
744
|
|
|
@@ -730,14 +748,14 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
|
|
|
730
748
|
const updatedEnd = updated.indexOf(endMarker) + endMarker.length;
|
|
731
749
|
assert(updated.slice(0, updatedStart) === outsideBefore, "sync must preserve frontmatter and content before the managed block byte-for-byte");
|
|
732
750
|
assert(updated.slice(updatedEnd) === outsideAfter, "sync must preserve content after the managed block byte-for-byte");
|
|
733
|
-
assert(updated.includes("version=3.0.
|
|
751
|
+
assert(updated.includes("version=3.0.3"), "sync should install the current managed workflow version");
|
|
734
752
|
assert(updated.includes("## Execution profiles"), "sync should refresh stale managed workflow content");
|
|
735
753
|
|
|
736
754
|
fillRequiredAccess(repo);
|
|
737
755
|
const status = run("node", [cli, "status", "--projects", repo, "--json"]);
|
|
738
756
|
const statusResult = JSON.parse(status.stdout).results[0];
|
|
739
757
|
assert(statusResult.managedWorkflow.state === "current", `status should expose current managed workflow state: ${status.stdout}`);
|
|
740
|
-
assert(statusResult.managedWorkflow.version === "3.0.
|
|
758
|
+
assert(statusResult.managedWorkflow.version === "3.0.3", "status should expose the installed managed workflow version");
|
|
741
759
|
|
|
742
760
|
const beforeSecondSync = fs.readFileSync(engineering, "utf8");
|
|
743
761
|
const second = run("node", [cli, "sync", "--projects", repo, "--json"]);
|
|
@@ -765,7 +783,7 @@ function testLegacyEngineeringMigrationPreservesExistingBody() {
|
|
|
765
783
|
assert(dryResult.actions.find(item => item.path === "docs/ENGINEERING.md")?.detail.includes("preserved-custom"), "custom legacy action should be labeled preserved-custom");
|
|
766
784
|
run("node", [cli, "sync", "--projects", repo]);
|
|
767
785
|
const migrated = fs.readFileSync(engineering, "utf8");
|
|
768
|
-
assert(migrated.includes("version=3.0.
|
|
786
|
+
assert(migrated.includes("version=3.0.3"), "legacy migration should insert the current managed workflow");
|
|
769
787
|
assert(migrated.includes(legacyNote), "legacy migration must preserve the complete existing body");
|
|
770
788
|
const migratedStart = migrated.indexOf("<!-- auto-coding-skill:managed-workflow:start");
|
|
771
789
|
const migratedEnd = migrated.indexOf(endMarker) + endMarker.length;
|
|
@@ -824,7 +842,7 @@ function testMalformedManagedMarkersFailClosed() {
|
|
|
824
842
|
const before = fs.readFileSync(engineering, "utf8");
|
|
825
843
|
|
|
826
844
|
const result = run("node", [cli, "sync", "--projects", repo], { check: false });
|
|
827
|
-
assert(result.status !== 0 && result.stderr.includes("refusing
|
|
845
|
+
assert(result.status !== 0 && result.stderr.includes("refusing"), `${name}: malformed markers should reject sync`);
|
|
828
846
|
assert(fs.readFileSync(engineering, "utf8") === before, `${name}: rejected sync must not touch ENGINEERING.md`);
|
|
829
847
|
assert(fs.readFileSync(skill, "utf8") === `user-sentinel-${name}\n`, `${name}: preflight must reject before writing the skill`);
|
|
830
848
|
}
|
|
@@ -891,11 +909,80 @@ function testLegacyTaskPreflightRejectsWholeBatchAtomically() {
|
|
|
891
909
|
assert(fs.readFileSync(secondAgent).equals(secondAgentBefore), "batch preflight must not write the project containing the legacy task");
|
|
892
910
|
}
|
|
893
911
|
|
|
912
|
+
function testManagedAgentsMigrationPreservesCustomRules() {
|
|
913
|
+
const repo = tmpdir("managed-agents-document");
|
|
914
|
+
run("node", [cli, "init"], { cwd: repo });
|
|
915
|
+
run("node", [cli, "sync", "--projects", repo]);
|
|
916
|
+
const agents = path.join(repo, "AGENTS.md");
|
|
917
|
+
const initial = fs.readFileSync(agents, "utf8");
|
|
918
|
+
assert(initial.includes("managed-agents:start version=3.0.3"), "new projects should receive the versioned root AGENTS block");
|
|
919
|
+
|
|
920
|
+
const custom = [
|
|
921
|
+
"# Project rules",
|
|
922
|
+
"",
|
|
923
|
+
"- Preserve this repository-specific rule exactly.",
|
|
924
|
+
"- `high-risk` cannot be downgraded and must execute `commands.gate_full`; changed or standard fallbacks do not count. Use `PASS / FAIL / PARTIAL` only from the required executed evidence.",
|
|
925
|
+
"",
|
|
926
|
+
].join("\n");
|
|
927
|
+
writeFile(agents, custom);
|
|
928
|
+
const dryRun = run("node", [cli, "sync", "--projects", repo, "--dry-run", "--json"]);
|
|
929
|
+
const plan = JSON.parse(dryRun.stdout).results[0].managedAgentsDocument;
|
|
930
|
+
assert(plan.state === "legacy-custom", `unmarked custom AGENTS should be migrated: ${dryRun.stdout}`);
|
|
931
|
+
assert(plan.migrations.includes("agents-v22-govchain-full"), "known official full-gate rule should be selected by exact migration id");
|
|
932
|
+
|
|
933
|
+
run("node", [cli, "sync", "--projects", repo]);
|
|
934
|
+
const migrated = fs.readFileSync(agents, "utf8");
|
|
935
|
+
assert(migrated.includes("managed-agents:start version=3.0.3"), "AGENTS migration should install the current managed block");
|
|
936
|
+
assert(migrated.includes("Preserve this repository-specific rule exactly."), "AGENTS migration must preserve unrelated custom rules");
|
|
937
|
+
assert(!migrated.includes("must execute `commands.gate_full`"), "known official conflicting rule should be removed");
|
|
938
|
+
const stable = fs.readFileSync(agents);
|
|
939
|
+
run("node", [cli, "sync", "--projects", repo]);
|
|
940
|
+
assert(fs.readFileSync(agents).equals(stable), "managed AGENTS sync should be idempotent");
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
function testUnknownWorkflowConflictFailsWholeBatchBeforeWrites() {
|
|
944
|
+
const first = tmpdir("workflow-conflict-first");
|
|
945
|
+
const second = tmpdir("workflow-conflict-second");
|
|
946
|
+
for (const repo of [first, second]) {
|
|
947
|
+
run("git", ["init", "-q"], { cwd: repo });
|
|
948
|
+
run("node", [cli, "init"], { cwd: repo });
|
|
949
|
+
run("node", [cli, "sync", "--projects", repo]);
|
|
950
|
+
}
|
|
951
|
+
const firstSkill = path.join(first, ".agents", "skills", "auto-coding-skill", "SKILL.md");
|
|
952
|
+
writeFile(firstSkill, "batch-sentinel\n");
|
|
953
|
+
const secondAgents = path.join(second, "AGENTS.md");
|
|
954
|
+
fs.appendFileSync(secondAgents, "\n- High-risk changes\n must run the real full gate before push.\n");
|
|
955
|
+
|
|
956
|
+
const status = run("node", [cli, "status", "--projects", second, "--json"], { check: false });
|
|
957
|
+
assert(status.status !== 0, "status must be non-ok for an unknown conflicting workflow rule");
|
|
958
|
+
const statusPlan = JSON.parse(status.stdout).results[0].managedAgentsDocument;
|
|
959
|
+
assert(statusPlan.state === "conflict", `status should expose the document conflict: ${status.stdout}`);
|
|
960
|
+
assert(statusPlan.conflicts[0].file === "AGENTS.md" && statusPlan.conflicts[0].line > 0, "status conflict should include file and line");
|
|
961
|
+
|
|
962
|
+
const sync = run("node", [cli, "sync", "--projects", `${first},${second}`], { check: false });
|
|
963
|
+
assert(sync.status !== 0 && sync.stderr.includes("entire sync batch before writes"), "one unknown conflict must reject the complete batch");
|
|
964
|
+
assert(fs.readFileSync(firstSkill, "utf8") === "batch-sentinel\n", "batch conflict preflight must run before an earlier project's skill write");
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
function testEngineeringMarkerBoundaryIsNormalized() {
|
|
968
|
+
const repo = tmpdir("engineering-marker-boundary");
|
|
969
|
+
run("node", [cli, "init"], { cwd: repo });
|
|
970
|
+
run("node", [cli, "sync", "--projects", repo]);
|
|
971
|
+
const engineering = path.join(repo, "docs", "ENGINEERING.md");
|
|
972
|
+
const marker = "<!-- auto-coding-skill:managed-workflow:end -->";
|
|
973
|
+
const current = fs.readFileSync(engineering, "utf8");
|
|
974
|
+
writeFile(engineering, current.replace(`${marker}\n`, `${marker}# Project-specific workflow\n`));
|
|
975
|
+
run("node", [cli, "sync", "--projects", repo]);
|
|
976
|
+
const normalized = fs.readFileSync(engineering, "utf8");
|
|
977
|
+
assert(normalized.includes(`${marker}\n# Project-specific workflow\n`), "sync should normalize a heading glued to the managed end marker");
|
|
978
|
+
}
|
|
979
|
+
|
|
894
980
|
testPreflightAvoidsPartialInstall();
|
|
895
981
|
testDestVariants();
|
|
896
982
|
testLauncherFallsBackToGlobalRuntime();
|
|
897
983
|
testMinimalSyncConvergesWithinBudget();
|
|
898
984
|
testStatusRejectsLegacyIsolation();
|
|
985
|
+
testStatusRejectsLegacyGateEscalation();
|
|
899
986
|
testOrdinaryNodeTestIsNotPromotedToAutomaticGate();
|
|
900
987
|
testAccessPasswordsAreRequiredButNeverPrintedByStatus();
|
|
901
988
|
testManagedAgentModelsInheritAndOverridesSurvive();
|
|
@@ -922,5 +1009,8 @@ testOfficialLegacyEngineeringBodyIsReplacedWithoutDuplication();
|
|
|
922
1009
|
testMalformedManagedMarkersFailClosed();
|
|
923
1010
|
testSkillOnlySyncTouchesOnlySkill();
|
|
924
1011
|
testLegacyTaskPreflightRejectsWholeBatchAtomically();
|
|
1012
|
+
testManagedAgentsMigrationPreservesCustomRules();
|
|
1013
|
+
testUnknownWorkflowConflictFailsWholeBatchBeforeWrites();
|
|
1014
|
+
testEngineeringMarkerBoundaryIsNormalized();
|
|
925
1015
|
|
|
926
1016
|
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": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "CLI installer for an isolated .agents engineering workflow with parallel Git worktrees, fast local gates, push-based completion, and safe cleanup.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|