@elvis1513/auto-coding-skill 4.0.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -14
- package/cli/assets/agents/reviewer.toml +3 -2
- package/cli/assets/skill/SKILL.md +38 -92
- package/cli/assets/skill/data/contracts/orchestration-v1.schema.json +16 -1
- package/cli/assets/skill/data/policies/workflow-migrations-v1.json +291 -5
- package/cli/assets/skill/data/templates/ENGINEERING.md +40 -134
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +117 -27
- package/cli/assets/skill/scripts/__pycache__/core.cpython-314.pyc +0 -0
- package/cli/assets/skill/scripts/__pycache__/scaffold_templates.cpython-314.pyc +0 -0
- package/cli/assets/skill/scripts/ap.py +427 -57
- package/cli/assets/skill/scripts/core.py +21 -5
- package/cli/assets/skill/scripts/scaffold_templates.py +40 -5
- package/cli/src/index.js +192 -85
- package/cli/tests/ap_concurrency_test.py +77 -11
- package/cli/tests/ap_profiles_test.py +66 -23
- package/cli/tests/index.test.js +98 -66
- package/package.json +1 -1
- package/cli/assets/skill/data/templates/docs/tasks/closure-log.md +0 -17
- package/cli/assets/skill/data/templates/docs/tasks/taskbook.md +0 -30
|
@@ -202,7 +202,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
202
202
|
return current_path
|
|
203
203
|
self.fail(f"no worktree registered for {wanted}")
|
|
204
204
|
|
|
205
|
-
def start_task(self, repo: Path, task_id: str) -> Path:
|
|
205
|
+
def start_task(self, repo: Path, task_id: str, owned_path: str = ".") -> Path:
|
|
206
206
|
result = self.ap(
|
|
207
207
|
repo,
|
|
208
208
|
"task-start",
|
|
@@ -210,7 +210,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
210
210
|
"--base",
|
|
211
211
|
"origin/dev",
|
|
212
212
|
"--owned-path",
|
|
213
|
-
|
|
213
|
+
owned_path,
|
|
214
214
|
"--isolated",
|
|
215
215
|
"--review-required",
|
|
216
216
|
)
|
|
@@ -377,6 +377,19 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
377
377
|
def test_clean_serial_task_uses_direct_branch_and_no_diff_is_noop(self) -> None:
|
|
378
378
|
_, repo, remote = self.make_repo("adaptive", require_review=False)
|
|
379
379
|
worktrees_before = git_output(repo, "worktree", "list", "--porcelain")
|
|
380
|
+
unnecessary = self.ap(
|
|
381
|
+
repo,
|
|
382
|
+
"task-start",
|
|
383
|
+
"DIRECT-SKIP",
|
|
384
|
+
"--base",
|
|
385
|
+
"origin/dev",
|
|
386
|
+
"--owned-path",
|
|
387
|
+
"shared.txt",
|
|
388
|
+
check=False,
|
|
389
|
+
)
|
|
390
|
+
self.assertNotEqual(0, unnecessary.returncode)
|
|
391
|
+
self.assertIn("does not need a machine task lifecycle", unnecessary.stdout + unnecessary.stderr)
|
|
392
|
+
self.assertFalse(self.registry_manifest_path(repo, "DIRECT-SKIP").exists())
|
|
380
393
|
start = self.ap(
|
|
381
394
|
repo,
|
|
382
395
|
"task-start",
|
|
@@ -385,6 +398,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
385
398
|
"origin/dev",
|
|
386
399
|
"--owned-path",
|
|
387
400
|
"shared.txt",
|
|
401
|
+
"--force-lifecycle",
|
|
388
402
|
)
|
|
389
403
|
self.assertIn("execution_mode=direct", start.stdout)
|
|
390
404
|
self.assertEqual(worktrees_before, git_output(repo, "worktree", "list", "--porcelain"))
|
|
@@ -400,7 +414,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
400
414
|
self.assertFalse(self.registry_manifest_path(repo, "DIRECT-1").exists())
|
|
401
415
|
|
|
402
416
|
before = git_output(repo, "rev-parse", "HEAD")
|
|
403
|
-
self.ap(repo, "task-start", "DIRECT-NOOP", "--owned-path", "shared.txt")
|
|
417
|
+
self.ap(repo, "task-start", "DIRECT-NOOP", "--owned-path", "shared.txt", "--force-lifecycle")
|
|
404
418
|
noop = self.ap(repo, "commit-push", "DIRECT-NOOP", "--msg", "DIRECT-NOOP: none")
|
|
405
419
|
self.assertIn("NOOP", noop.stdout)
|
|
406
420
|
self.assertEqual(before, git_output(repo, "rev-parse", "HEAD"))
|
|
@@ -701,8 +715,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
701
715
|
|
|
702
716
|
def test_control_commands_are_rejected_from_another_task_worktree(self) -> None:
|
|
703
717
|
_, repo, _ = self.make_repo()
|
|
704
|
-
first = self.start_task(repo, "CROSS-1")
|
|
705
|
-
second = self.start_task(repo, "CROSS-2")
|
|
718
|
+
first = self.start_task(repo, "CROSS-1", "cross/one")
|
|
719
|
+
second = self.start_task(repo, "CROSS-2", "cross/two")
|
|
706
720
|
|
|
707
721
|
commands = [
|
|
708
722
|
("task-integrate", "CROSS-1"),
|
|
@@ -735,6 +749,58 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
735
749
|
}
|
|
736
750
|
self.assertEqual(before, after)
|
|
737
751
|
|
|
752
|
+
def test_task_start_rejects_overlapping_active_owned_paths(self) -> None:
|
|
753
|
+
_, repo, _ = self.make_repo()
|
|
754
|
+
first = self.start_task(repo, "OWNER-1", "backend")
|
|
755
|
+
result = self.ap(
|
|
756
|
+
repo,
|
|
757
|
+
"task-start",
|
|
758
|
+
"OWNER-2",
|
|
759
|
+
"--base",
|
|
760
|
+
"origin/dev",
|
|
761
|
+
"--owned-path",
|
|
762
|
+
"backend/api",
|
|
763
|
+
"--isolated",
|
|
764
|
+
check=False,
|
|
765
|
+
)
|
|
766
|
+
self.assertNotEqual(0, result.returncode)
|
|
767
|
+
self.assertIn("overlap active task OWNER-1", result.stdout + result.stderr)
|
|
768
|
+
self.assertTrue(first.exists())
|
|
769
|
+
self.assertFalse(self.registry_manifest_path(repo, "OWNER-2").exists())
|
|
770
|
+
self.assert_local_branch(repo, "codex/OWNER-2", False)
|
|
771
|
+
|
|
772
|
+
def test_task_start_rejects_terminal_ledger_lifecycle_and_multi_writer(self) -> None:
|
|
773
|
+
_, repo, _ = self.make_repo()
|
|
774
|
+
terminal = self.ap(
|
|
775
|
+
repo,
|
|
776
|
+
"task-start",
|
|
777
|
+
"LEDGER-END",
|
|
778
|
+
"--base",
|
|
779
|
+
"origin/dev",
|
|
780
|
+
"--owned-path",
|
|
781
|
+
"docs/tasks/closure-log.md",
|
|
782
|
+
check=False,
|
|
783
|
+
)
|
|
784
|
+
self.assertNotEqual(0, terminal.returncode)
|
|
785
|
+
self.assertIn("terminal maintenance", terminal.stdout + terminal.stderr)
|
|
786
|
+
self.assertFalse(self.registry_manifest_path(repo, "LEDGER-END").exists())
|
|
787
|
+
|
|
788
|
+
multi = self.ap(
|
|
789
|
+
repo,
|
|
790
|
+
"task-start",
|
|
791
|
+
"MULTI-1",
|
|
792
|
+
"--base",
|
|
793
|
+
"origin/dev",
|
|
794
|
+
"--owned-path",
|
|
795
|
+
"frontend",
|
|
796
|
+
"--writers",
|
|
797
|
+
"2",
|
|
798
|
+
check=False,
|
|
799
|
+
)
|
|
800
|
+
self.assertNotEqual(0, multi.returncode)
|
|
801
|
+
self.assertIn("exactly one writer lease", multi.stdout + multi.stderr)
|
|
802
|
+
self.assertFalse(self.registry_manifest_path(repo, "MULTI-1").exists())
|
|
803
|
+
|
|
738
804
|
def test_missing_task_manifest_is_rejected_in_linked_worktree(self) -> None:
|
|
739
805
|
_, repo, remote = self.make_repo("worktree")
|
|
740
806
|
worktree = self.start_task(repo, "NO-MANIFEST")
|
|
@@ -786,8 +852,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
786
852
|
|
|
787
853
|
def test_commit_push_requires_matching_manifest_and_isolated_worktree(self) -> None:
|
|
788
854
|
_, repo, remote = self.make_repo()
|
|
789
|
-
worktree = self.start_task(repo, "ISOLATED-1")
|
|
790
|
-
second_worktree = self.start_task(repo, "ISOLATED-2")
|
|
855
|
+
worktree = self.start_task(repo, "ISOLATED-1", "task-only.txt")
|
|
856
|
+
second_worktree = self.start_task(repo, "ISOLATED-2", "second-task-only.txt")
|
|
791
857
|
(worktree / "task-only.txt").write_text("task change\n", encoding="utf-8")
|
|
792
858
|
(second_worktree / "second-task-only.txt").write_text(
|
|
793
859
|
"second task change\n",
|
|
@@ -953,8 +1019,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
953
1019
|
|
|
954
1020
|
def test_task_deletion_is_isolated_and_committed_only_on_its_task_branch(self) -> None:
|
|
955
1021
|
_, repo, remote = self.make_repo()
|
|
956
|
-
deleting = self.start_task(repo, "DELETE-1")
|
|
957
|
-
observer = self.start_task(repo, "DELETE-2")
|
|
1022
|
+
deleting = self.start_task(repo, "DELETE-1", "shared.txt")
|
|
1023
|
+
observer = self.start_task(repo, "DELETE-2", "observer.txt")
|
|
958
1024
|
(deleting / "shared.txt").unlink()
|
|
959
1025
|
(observer / "observer.txt").write_text("observer\n", encoding="utf-8")
|
|
960
1026
|
|
|
@@ -972,7 +1038,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
972
1038
|
def test_task_finish_refuses_dirty_or_unmerged_tasks(self) -> None:
|
|
973
1039
|
_, repo, _ = self.make_repo()
|
|
974
1040
|
|
|
975
|
-
dirty_worktree = self.start_task(repo, "DIRTY-1")
|
|
1041
|
+
dirty_worktree = self.start_task(repo, "DIRTY-1", "dirty.txt")
|
|
976
1042
|
(dirty_worktree / "dirty.txt").write_text("not committed\n", encoding="utf-8")
|
|
977
1043
|
dirty = self.ap(repo, "task-finish", "DIRTY-1", check=False)
|
|
978
1044
|
self.assertNotEqual(0, dirty.returncode)
|
|
@@ -980,7 +1046,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
980
1046
|
self.assert_local_branch(repo, "codex/DIRTY-1", True)
|
|
981
1047
|
self.assertTrue((dirty_worktree / "dirty.txt").exists())
|
|
982
1048
|
|
|
983
|
-
unmerged_worktree = self.start_task(repo, "UNMERGED-1")
|
|
1049
|
+
unmerged_worktree = self.start_task(repo, "UNMERGED-1", "unmerged.txt")
|
|
984
1050
|
(unmerged_worktree / "unmerged.txt").write_text("committed only on task\n", encoding="utf-8")
|
|
985
1051
|
git(unmerged_worktree, "add", "unmerged.txt")
|
|
986
1052
|
git(unmerged_worktree, "commit", "-qm", "unmerged task commit")
|
|
@@ -233,13 +233,15 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
233
233
|
self.assertEqual(["src/frontend/LoginPage.tsx"], plan["classification_files"])
|
|
234
234
|
self.assertTrue(plan["intent_provided"])
|
|
235
235
|
self.assertEqual(["auth", "release_or_tooling", "ui"], plan["intent_categories"])
|
|
236
|
-
self.
|
|
236
|
+
self.assertTrue(plan["needs_browser"])
|
|
237
|
+
self.assertEqual(["reviewer"], plan["recommended_agents"])
|
|
238
|
+
self.assertNotIn("browser_debugger", plan["recommended_agents"])
|
|
239
|
+
self.assertNotIn("docs_researcher", plan["recommended_agents"])
|
|
237
240
|
self.assertNotIn("新增登录鉴权页面并发布", str(plan))
|
|
238
241
|
|
|
239
242
|
def test_ordinary_code_resolves_standard(self) -> None:
|
|
240
|
-
repo, cfg = self.make_repo(
|
|
241
|
-
|
|
242
|
-
plan = self.plan(repo, cfg)
|
|
243
|
+
repo, cfg = self.make_repo()
|
|
244
|
+
plan = self.plan(repo, cfg, planned_paths=["src/widget.py"])
|
|
243
245
|
self.assertEqual("standard", plan["profile"])
|
|
244
246
|
self.assertEqual("changed", plan["selected_scope"])
|
|
245
247
|
self.assertEqual("dev", plan["effective_mode"])
|
|
@@ -262,6 +264,12 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
262
264
|
delivery = next(stage for stage in agent_plan["stages"] if stage["id"] == "delivery")
|
|
263
265
|
self.assertEqual("serial", delivery["mode"])
|
|
264
266
|
self.assertFalse(plan["review_required"])
|
|
267
|
+
self.assertEqual(
|
|
268
|
+
["analysis", "final_changed_scope_gate", "commit_push"],
|
|
269
|
+
plan["mechanism_plan"]["required"],
|
|
270
|
+
)
|
|
271
|
+
self.assertFalse(plan["mechanism_plan"]["lifecycle_required"])
|
|
272
|
+
self.assertIn("task_lifecycle", plan["mechanism_plan"]["not_required"])
|
|
265
273
|
|
|
266
274
|
def test_execution_mode_is_none_direct_isolated_or_parallel(self) -> None:
|
|
267
275
|
repo, cfg = self.make_repo()
|
|
@@ -272,6 +280,8 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
272
280
|
dirty.write_text("user change\n", encoding="utf-8")
|
|
273
281
|
isolated = self.plan(repo, cfg, planned_paths=["src/widget.py"])
|
|
274
282
|
self.assertEqual("isolated", isolated["execution_mode"])
|
|
283
|
+
self.assertTrue(isolated["mechanism_plan"]["lifecycle_required"])
|
|
284
|
+
self.assertIn("worktree", isolated["mechanism_plan"]["required"])
|
|
275
285
|
dirty.unlink()
|
|
276
286
|
parallel = self.plan(
|
|
277
287
|
repo,
|
|
@@ -282,6 +292,7 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
282
292
|
self.assertEqual("isolated", parallel["execution_mode"])
|
|
283
293
|
self.assertTrue(parallel["review_required"])
|
|
284
294
|
self.assertIn("fixer", parallel["recommended_agents"])
|
|
295
|
+
self.assertIn("parallel_fixers", parallel["mechanism_plan"]["required"])
|
|
285
296
|
|
|
286
297
|
def test_validation_routes_collect_all_commands_and_reject_unmapped_code(self) -> None:
|
|
287
298
|
repo, cfg = self.make_repo()
|
|
@@ -301,6 +312,34 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
301
312
|
ap._validate_validation_plan(cfg, ap._validation_plan(cfg, ["contracts/api.yaml"]))
|
|
302
313
|
self.assertIn("no validation route", str(context.exception))
|
|
303
314
|
|
|
315
|
+
def test_final_gate_budget_is_hard_bounded_and_times_out(self) -> None:
|
|
316
|
+
cfg = base_config()
|
|
317
|
+
cfg["validation"] = {
|
|
318
|
+
"on_unmapped": "error",
|
|
319
|
+
"max_command_seconds": 0.05,
|
|
320
|
+
"max_total_seconds": 0.1,
|
|
321
|
+
"routes": [{"name": "slow", "paths": ["src/**"], "commands": ["slow"]}],
|
|
322
|
+
}
|
|
323
|
+
cfg["commands"]["slow"] = f'{sys.executable} -c "import time; time.sleep(1)"'
|
|
324
|
+
repo, cfg = self.make_repo("src/widget.py", cfg)
|
|
325
|
+
with self.assertRaises(APError) as context:
|
|
326
|
+
ap.cmd_light_gate(
|
|
327
|
+
argparse.Namespace(
|
|
328
|
+
repo=str(repo),
|
|
329
|
+
scope="changed",
|
|
330
|
+
profile="",
|
|
331
|
+
mode="dev",
|
|
332
|
+
base="",
|
|
333
|
+
explain=False,
|
|
334
|
+
)
|
|
335
|
+
)
|
|
336
|
+
self.assertIn("timed out", str(context.exception))
|
|
337
|
+
|
|
338
|
+
cfg["validation"]["max_command_seconds"] = 121
|
|
339
|
+
with self.assertRaises(APError) as context:
|
|
340
|
+
ap._final_gate_budget(cfg)
|
|
341
|
+
self.assertIn("cannot exceed 120", str(context.exception))
|
|
342
|
+
|
|
304
343
|
def test_test_only_change_resolves_micro(self) -> None:
|
|
305
344
|
repo, cfg = self.make_repo("tests/widget_test.py")
|
|
306
345
|
(repo / "docs" / "tasks" / "evidence.jsonl").write_text("{}\n", encoding="utf-8")
|
|
@@ -329,22 +368,22 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
329
368
|
self.assertFalse(plan["needs_jenkins"])
|
|
330
369
|
self.assertFalse(plan["needs_target"])
|
|
331
370
|
|
|
332
|
-
def
|
|
371
|
+
def test_ui_api_reports_capabilities_without_auto_dispatch(self) -> None:
|
|
333
372
|
repo, cfg = self.make_repo("src/api/settings-page.tsx")
|
|
334
373
|
plan = self.plan(repo, cfg)
|
|
335
|
-
|
|
336
|
-
self.assertEqual(
|
|
337
|
-
self.assertEqual(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
]
|
|
347
|
-
self.assertEqual(
|
|
374
|
+
self.assertTrue(plan["needs_browser"])
|
|
375
|
+
self.assertEqual([], plan["recommended_agents"])
|
|
376
|
+
self.assertEqual("main-only", plan["agent_plan"]["strategy"])
|
|
377
|
+
self.assertEqual(["main"], plan["agent_plan"]["stages"][0]["roles"])
|
|
378
|
+
|
|
379
|
+
def test_terminal_ledger_maintenance_creates_no_lifecycle_plan(self) -> None:
|
|
380
|
+
repo, cfg = self.make_repo()
|
|
381
|
+
plan = self.plan(repo, cfg, planned_paths=["docs/tasks/closure-log.md"])
|
|
382
|
+
self.assertTrue(plan["terminal_maintenance"])
|
|
383
|
+
self.assertEqual("none", plan["execution_mode"])
|
|
384
|
+
self.assertFalse(plan["review_required"])
|
|
385
|
+
self.assertFalse(plan["design_required"])
|
|
386
|
+
self.assertEqual([], plan["recommended_agents"])
|
|
348
387
|
|
|
349
388
|
def test_requested_verify_mode_is_rejected(self) -> None:
|
|
350
389
|
repo, cfg = self.make_repo("src/widget.py")
|
|
@@ -551,9 +590,13 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
551
590
|
|
|
552
591
|
def test_upgrade_unknown_policy_conflict_fails_before_any_write(self) -> None:
|
|
553
592
|
repo, _ = self.make_repo()
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
593
|
+
engineering = repo / "docs" / "ENGINEERING.md"
|
|
594
|
+
engineering.write_text(
|
|
595
|
+
engineering.read_text(encoding="utf-8")
|
|
596
|
+
+ "High-risk work must run the full gate.\n",
|
|
597
|
+
encoding="utf-8",
|
|
598
|
+
)
|
|
599
|
+
before = engineering.read_text(encoding="utf-8")
|
|
557
600
|
args = argparse.Namespace(repo=str(repo), write=True, dry_run=False, json=False)
|
|
558
601
|
with mock.patch.object(
|
|
559
602
|
ap,
|
|
@@ -562,8 +605,8 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
562
605
|
):
|
|
563
606
|
with self.assertRaises(APError) as context:
|
|
564
607
|
ap.cmd_upgrade(args)
|
|
565
|
-
self.assertIn("
|
|
566
|
-
self.assertEqual(before,
|
|
608
|
+
self.assertIn("docs/ENGINEERING.md", str(context.exception))
|
|
609
|
+
self.assertEqual(before, engineering.read_text(encoding="utf-8"))
|
|
567
610
|
self.assertFalse((repo / ".agents").exists())
|
|
568
611
|
|
|
569
612
|
def test_doctor_ignores_managed_blocks_but_rejects_unknown_external_rule(self) -> None:
|