@elvis1513/auto-coding-skill 4.1.0 → 4.1.2
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 +48 -8
- package/cli/assets/skill/SKILL.md +47 -125
- package/cli/assets/skill/data/contracts/orchestration-v1.schema.json +22 -1
- package/cli/assets/skill/data/policies/workflow-migrations-v1.json +2 -2
- package/cli/assets/skill/data/templates/ENGINEERING.md +38 -159
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +102 -114
- package/cli/assets/skill/scripts/ap.py +363 -40
- package/cli/assets/skill/scripts/core.py +21 -5
- package/cli/src/check-package.js +38 -0
- package/cli/src/index.js +20 -0
- package/cli/tests/ap_concurrency_test.py +39 -1
- package/cli/tests/ap_profiles_test.py +113 -3
- package/cli/tests/index.test.js +34 -18
- package/package.json +5 -2
|
@@ -6,6 +6,7 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
import os
|
|
8
8
|
import re
|
|
9
|
+
import signal
|
|
9
10
|
import shutil
|
|
10
11
|
import subprocess
|
|
11
12
|
from pathlib import Path
|
|
@@ -108,8 +109,23 @@ def find_config(repo: Path) -> Path:
|
|
|
108
109
|
)
|
|
109
110
|
|
|
110
111
|
|
|
111
|
-
def run_shell(command: str, cwd: Optional[Path] = None) -> None:
|
|
112
|
-
"""Run shell command
|
|
113
|
-
p = subprocess.
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
def run_shell(command: str, cwd: Optional[Path] = None, timeout_s: Optional[float] = None) -> None:
|
|
113
|
+
"""Run a shell command and terminate its process group on timeout."""
|
|
114
|
+
p = subprocess.Popen(
|
|
115
|
+
["bash", "-lc", command],
|
|
116
|
+
cwd=str(cwd) if cwd else None,
|
|
117
|
+
text=True,
|
|
118
|
+
start_new_session=True,
|
|
119
|
+
)
|
|
120
|
+
try:
|
|
121
|
+
returncode = p.wait(timeout=timeout_s)
|
|
122
|
+
except subprocess.TimeoutExpired as exc:
|
|
123
|
+
os.killpg(p.pid, signal.SIGTERM)
|
|
124
|
+
try:
|
|
125
|
+
p.wait(timeout=2)
|
|
126
|
+
except subprocess.TimeoutExpired:
|
|
127
|
+
os.killpg(p.pid, signal.SIGKILL)
|
|
128
|
+
p.wait()
|
|
129
|
+
raise APError(f"Command timed out after {timeout_s:.1f}s: {command}") from exc
|
|
130
|
+
if returncode != 0:
|
|
131
|
+
raise APError(f"Command failed ({returncode}): {command}")
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const repoRoot = path.resolve(here, "..", "..");
|
|
9
|
+
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
10
|
+
const packed = spawnSync(
|
|
11
|
+
npmCommand,
|
|
12
|
+
["pack", "--dry-run", "--json", "--ignore-scripts"],
|
|
13
|
+
{ cwd: repoRoot, encoding: "utf8" },
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
if (packed.status !== 0) {
|
|
17
|
+
process.stderr.write(packed.stderr || packed.stdout || "npm pack --dry-run failed\n");
|
|
18
|
+
process.exit(packed.status || 1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let payload;
|
|
22
|
+
try {
|
|
23
|
+
payload = JSON.parse(packed.stdout);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
process.stderr.write(`Cannot parse npm pack output: ${error.message}\n`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const files = payload?.[0]?.files?.map(item => String(item.path || "")) || [];
|
|
30
|
+
const forbidden = files.filter(file =>
|
|
31
|
+
/(^|\/)__pycache__(\/|$)/.test(file) || /\.py[cod]$/i.test(file),
|
|
32
|
+
);
|
|
33
|
+
if (forbidden.length > 0) {
|
|
34
|
+
process.stderr.write(`Generated Python cache leaked into package:\n- ${forbidden.join("\n- ")}\n`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
process.stdout.write(`[package-check] OK files=${files.length}\n`);
|
package/cli/src/index.js
CHANGED
|
@@ -1083,6 +1083,8 @@ function projectStatus(project, assetSkill, assetAgents){
|
|
|
1083
1083
|
{ label: "concurrency.delete_remote_branch", path: ["concurrency", "delete_remote_branch"] },
|
|
1084
1084
|
{ label: "concurrency.disposable_ignored", path: ["concurrency", "disposable_ignored"] },
|
|
1085
1085
|
{ label: "validation.on_unmapped", path: ["validation", "on_unmapped"] },
|
|
1086
|
+
{ label: "validation.max_command_seconds", path: ["validation", "max_command_seconds"] },
|
|
1087
|
+
{ label: "validation.max_total_seconds", path: ["validation", "max_total_seconds"] },
|
|
1086
1088
|
{ label: "validation.routes", path: ["validation", "routes"], sequence: true },
|
|
1087
1089
|
{ label: "risk.rules", path: ["risk", "rules"] },
|
|
1088
1090
|
{ label: "docs.framework", path: ["docs", "framework"], filled: true },
|
|
@@ -1123,6 +1125,24 @@ function projectStatus(project, assetSkill, assetAgents){
|
|
|
1123
1125
|
if (isolationState.present && !["adaptive", "worktree"].includes(frontmatterScalarValue(isolationState.value).toLowerCase())) {
|
|
1124
1126
|
invalidConfigTokens.push("concurrency.isolation (must be adaptive or worktree)");
|
|
1125
1127
|
}
|
|
1128
|
+
for (const pathParts of [
|
|
1129
|
+
["validation", "max_command_seconds"],
|
|
1130
|
+
["validation", "max_total_seconds"],
|
|
1131
|
+
]) {
|
|
1132
|
+
const state = frontmatterPathState(text, pathParts);
|
|
1133
|
+
if (!state.present) continue;
|
|
1134
|
+
const value = Number(frontmatterScalarValue(state.value));
|
|
1135
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
1136
|
+
invalidConfigTokens.push(`${pathParts.join(".")} (must be > 0)`);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
const commandState = frontmatterPathState(text, ["validation", "max_command_seconds"]);
|
|
1140
|
+
const totalState = frontmatterPathState(text, ["validation", "max_total_seconds"]);
|
|
1141
|
+
const commandBudget = Number(frontmatterScalarValue(commandState.value));
|
|
1142
|
+
const totalBudget = Number(frontmatterScalarValue(totalState.value));
|
|
1143
|
+
if (commandState.present && totalState.present && Number.isFinite(commandBudget) && Number.isFinite(totalBudget) && commandBudget > totalBudget) {
|
|
1144
|
+
invalidConfigTokens.push("validation.max_command_seconds (cannot exceed max_total_seconds)");
|
|
1145
|
+
}
|
|
1126
1146
|
invalidConfigTokens.push(...legacyGateEscalationTokens(text));
|
|
1127
1147
|
}
|
|
1128
1148
|
const missingConfigTokens = [...missingConfigPaths, ...unfilledConfigTokens, ...invalidConfigTokens];
|
|
@@ -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,12 +414,36 @@ 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"))
|
|
407
421
|
self.assertFalse(self.registry_manifest_path(repo, "DIRECT-NOOP").exists())
|
|
408
422
|
|
|
423
|
+
def test_unnecessary_lifecycle_rejects_before_access_or_fetch_checks(self) -> None:
|
|
424
|
+
_, repo, _ = self.make_repo("adaptive", require_review=False)
|
|
425
|
+
engineering = repo / "docs" / "ENGINEERING.md"
|
|
426
|
+
text = engineering.read_text(encoding="utf-8")
|
|
427
|
+
engineering.write_text(text.replace("front-pass", "", 1), encoding="utf-8")
|
|
428
|
+
git(repo, "add", "docs/ENGINEERING.md")
|
|
429
|
+
git(repo, "commit", "-qm", "invalidate access for preflight test")
|
|
430
|
+
git(repo, "push", "-q", "origin", "dev")
|
|
431
|
+
|
|
432
|
+
result = self.ap(
|
|
433
|
+
repo,
|
|
434
|
+
"task-start",
|
|
435
|
+
"DIRECT-PREFLIGHT",
|
|
436
|
+
"--base",
|
|
437
|
+
"origin/branch-that-must-not-be-fetched",
|
|
438
|
+
"--owned-path",
|
|
439
|
+
"shared.txt",
|
|
440
|
+
check=False,
|
|
441
|
+
)
|
|
442
|
+
output = result.stdout + result.stderr
|
|
443
|
+
self.assertNotEqual(0, result.returncode)
|
|
444
|
+
self.assertIn("does not need a machine task lifecycle", output)
|
|
445
|
+
self.assertNotIn("initialization is incomplete", output)
|
|
446
|
+
|
|
409
447
|
def test_schema_one_task_status_fails_closed_with_migration_recovery(self) -> None:
|
|
410
448
|
_, repo, _ = self.make_repo()
|
|
411
449
|
self.start_task(repo, "LEGACY-SCHEMA")
|
|
@@ -240,10 +240,10 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
240
240
|
self.assertNotIn("新增登录鉴权页面并发布", str(plan))
|
|
241
241
|
|
|
242
242
|
def test_ordinary_code_resolves_standard(self) -> None:
|
|
243
|
-
repo, cfg = self.make_repo(
|
|
244
|
-
|
|
245
|
-
plan = self.plan(repo, cfg)
|
|
243
|
+
repo, cfg = self.make_repo()
|
|
244
|
+
plan = self.plan(repo, cfg, planned_paths=["src/widget.py"])
|
|
246
245
|
self.assertEqual("standard", plan["profile"])
|
|
246
|
+
self.assertEqual("change", plan["task_kind"])
|
|
247
247
|
self.assertEqual("changed", plan["selected_scope"])
|
|
248
248
|
self.assertEqual("dev", plan["effective_mode"])
|
|
249
249
|
self.assertEqual([], plan["recommended_agents"])
|
|
@@ -265,6 +265,53 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
265
265
|
delivery = next(stage for stage in agent_plan["stages"] if stage["id"] == "delivery")
|
|
266
266
|
self.assertEqual("serial", delivery["mode"])
|
|
267
267
|
self.assertFalse(plan["review_required"])
|
|
268
|
+
self.assertEqual(
|
|
269
|
+
["analysis", "final_changed_scope_gate", "commit_push"],
|
|
270
|
+
plan["mechanism_plan"]["required"],
|
|
271
|
+
)
|
|
272
|
+
self.assertFalse(plan["mechanism_plan"]["lifecycle_required"])
|
|
273
|
+
self.assertIn("read_only_subagents", plan["mechanism_plan"]["optional_when_beneficial"])
|
|
274
|
+
self.assertIn("task_lifecycle", plan["mechanism_plan"]["forbidden"])
|
|
275
|
+
|
|
276
|
+
def test_intent_only_classifies_read_only_change_and_terminal_work(self) -> None:
|
|
277
|
+
repo, cfg = self.make_repo()
|
|
278
|
+
read_only = self.plan(repo, cfg, intent="Explain how authentication currently works")
|
|
279
|
+
self.assertEqual("read_only", read_only["task_kind"])
|
|
280
|
+
self.assertEqual("none", read_only["execution_mode"])
|
|
281
|
+
self.assertEqual(["analysis"], read_only["mechanism_plan"]["required"])
|
|
282
|
+
self.assertIn(
|
|
283
|
+
"read_only_subagents",
|
|
284
|
+
read_only["mechanism_plan"]["optional_when_beneficial"],
|
|
285
|
+
)
|
|
286
|
+
self.assertIn("commit_push", read_only["mechanism_plan"]["forbidden"])
|
|
287
|
+
|
|
288
|
+
change = self.plan(repo, cfg, intent="Fix the login redirect bug")
|
|
289
|
+
self.assertEqual("change", change["task_kind"])
|
|
290
|
+
self.assertEqual("direct", change["execution_mode"])
|
|
291
|
+
self.assertIn("commit_push", change["mechanism_plan"]["required"])
|
|
292
|
+
|
|
293
|
+
chinese_change = self.plan(repo, cfg, intent="请解决并优化登录跳转问题")
|
|
294
|
+
self.assertEqual("change", chinese_change["task_kind"])
|
|
295
|
+
|
|
296
|
+
forced_read_only = self.plan(
|
|
297
|
+
repo,
|
|
298
|
+
cfg,
|
|
299
|
+
intent="Fix wording in the explanation",
|
|
300
|
+
requested_task_kind="read_only",
|
|
301
|
+
)
|
|
302
|
+
self.assertEqual("read_only", forced_read_only["task_kind"])
|
|
303
|
+
|
|
304
|
+
terminal = self.plan(
|
|
305
|
+
repo,
|
|
306
|
+
cfg,
|
|
307
|
+
intent="reconcile the completed task ledger",
|
|
308
|
+
)
|
|
309
|
+
self.assertEqual("terminal_maintenance", terminal["task_kind"])
|
|
310
|
+
self.assertEqual(
|
|
311
|
+
["analysis", "targeted_consistency_check", "commit_push"],
|
|
312
|
+
terminal["mechanism_plan"]["required"],
|
|
313
|
+
)
|
|
314
|
+
self.assertIn("task_lifecycle", terminal["mechanism_plan"]["forbidden"])
|
|
268
315
|
|
|
269
316
|
def test_execution_mode_is_none_direct_isolated_or_parallel(self) -> None:
|
|
270
317
|
repo, cfg = self.make_repo()
|
|
@@ -275,6 +322,8 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
275
322
|
dirty.write_text("user change\n", encoding="utf-8")
|
|
276
323
|
isolated = self.plan(repo, cfg, planned_paths=["src/widget.py"])
|
|
277
324
|
self.assertEqual("isolated", isolated["execution_mode"])
|
|
325
|
+
self.assertTrue(isolated["mechanism_plan"]["lifecycle_required"])
|
|
326
|
+
self.assertIn("worktree", isolated["mechanism_plan"]["required"])
|
|
278
327
|
dirty.unlink()
|
|
279
328
|
parallel = self.plan(
|
|
280
329
|
repo,
|
|
@@ -285,6 +334,7 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
285
334
|
self.assertEqual("isolated", parallel["execution_mode"])
|
|
286
335
|
self.assertTrue(parallel["review_required"])
|
|
287
336
|
self.assertIn("fixer", parallel["recommended_agents"])
|
|
337
|
+
self.assertIn("parallel_fixers", parallel["mechanism_plan"]["required"])
|
|
288
338
|
|
|
289
339
|
def test_validation_routes_collect_all_commands_and_reject_unmapped_code(self) -> None:
|
|
290
340
|
repo, cfg = self.make_repo()
|
|
@@ -304,6 +354,66 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
304
354
|
ap._validate_validation_plan(cfg, ap._validation_plan(cfg, ["contracts/api.yaml"]))
|
|
305
355
|
self.assertIn("no validation route", str(context.exception))
|
|
306
356
|
|
|
357
|
+
def test_final_gate_budget_is_configurable_and_times_out(self) -> None:
|
|
358
|
+
cfg = base_config()
|
|
359
|
+
cfg["validation"] = {
|
|
360
|
+
"on_unmapped": "error",
|
|
361
|
+
"max_command_seconds": 0.05,
|
|
362
|
+
"max_total_seconds": 0.1,
|
|
363
|
+
"routes": [{"name": "slow", "paths": ["src/**"], "commands": ["slow"]}],
|
|
364
|
+
}
|
|
365
|
+
cfg["commands"]["slow"] = f'{sys.executable} -c "import time; time.sleep(1)"'
|
|
366
|
+
repo, cfg = self.make_repo("src/widget.py", cfg)
|
|
367
|
+
with self.assertRaises(APError) as context:
|
|
368
|
+
ap.cmd_light_gate(
|
|
369
|
+
argparse.Namespace(
|
|
370
|
+
repo=str(repo),
|
|
371
|
+
scope="changed",
|
|
372
|
+
profile="",
|
|
373
|
+
mode="dev",
|
|
374
|
+
base="",
|
|
375
|
+
explain=False,
|
|
376
|
+
)
|
|
377
|
+
)
|
|
378
|
+
self.assertIn("timed out", str(context.exception))
|
|
379
|
+
|
|
380
|
+
cfg["validation"]["max_command_seconds"] = 240
|
|
381
|
+
cfg["validation"]["max_total_seconds"] = 300
|
|
382
|
+
self.assertEqual(
|
|
383
|
+
{"command_seconds": 240.0, "total_seconds": 300.0},
|
|
384
|
+
ap._final_gate_budget(cfg),
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
cfg["validation"]["max_total_seconds"] = 200
|
|
388
|
+
with self.assertRaises(APError) as context:
|
|
389
|
+
ap._final_gate_budget(cfg)
|
|
390
|
+
self.assertIn("cannot exceed validation.max_total_seconds", str(context.exception))
|
|
391
|
+
|
|
392
|
+
def test_route_timeout_uses_smallest_matching_budget(self) -> None:
|
|
393
|
+
cfg = base_config()
|
|
394
|
+
cfg["commands"] = {"one": "true", "two": "true"}
|
|
395
|
+
cfg["validation"] = {
|
|
396
|
+
"on_unmapped": "error",
|
|
397
|
+
"max_command_seconds": 120,
|
|
398
|
+
"max_total_seconds": 180,
|
|
399
|
+
"routes": [
|
|
400
|
+
{
|
|
401
|
+
"name": "all-src",
|
|
402
|
+
"paths": ["src/**"],
|
|
403
|
+
"commands": ["one", "two"],
|
|
404
|
+
"timeout_seconds": 90,
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"name": "python",
|
|
408
|
+
"paths": ["**/*.py"],
|
|
409
|
+
"commands": ["two"],
|
|
410
|
+
"timeout_seconds": 30,
|
|
411
|
+
},
|
|
412
|
+
],
|
|
413
|
+
}
|
|
414
|
+
plan = ap._validation_plan(cfg, ["src/widget.py"])
|
|
415
|
+
self.assertEqual({"one": 90.0, "two": 30.0}, plan["command_timeouts"])
|
|
416
|
+
|
|
307
417
|
def test_test_only_change_resolves_micro(self) -> None:
|
|
308
418
|
repo, cfg = self.make_repo("tests/widget_test.py")
|
|
309
419
|
(repo / "docs" / "tasks" / "evidence.jsonl").write_text("{}\n", encoding="utf-8")
|
package/cli/tests/index.test.js
CHANGED
|
@@ -225,9 +225,13 @@ function testMinimalSyncConvergesWithinBudget() {
|
|
|
225
225
|
assert(engineering.includes("isolation: \"adaptive\""), "engineering should default to adaptive clean-branch/worktree isolation");
|
|
226
226
|
assert(engineering.includes('completion: "push"'), "engineering should complete normal development at push");
|
|
227
227
|
assert(engineering.includes('project_fast: ""'), "generic projects should expose an optional project-fast command");
|
|
228
|
+
assert(engineering.includes("max_command_seconds: 120"), "engineering should bound each final route command");
|
|
229
|
+
assert(engineering.includes("max_total_seconds: 180"), "engineering should bound the complete final gate");
|
|
228
230
|
assert(engineering.includes(`name: "${path.basename(repo)}"`), "project name should be initialized automatically");
|
|
229
|
-
assert(engineering.includes("## Design, review, and subagents"), "engineering
|
|
230
|
-
|
|
231
|
+
assert(!engineering.includes("## Design, review, and subagents"), "engineering must not duplicate the behavioral protocol");
|
|
232
|
+
const agentsProtocol = fs.readFileSync(path.join(repo, "AGENTS.md"), "utf8");
|
|
233
|
+
assert(agentsProtocol.includes("## Minimum mechanism budget"), "AGENTS should own the shared behavioral protocol");
|
|
234
|
+
assert(agentsProtocol.includes("One writer in a clean checkout works directly"), "AGENTS should enforce direct clean serial work");
|
|
231
235
|
const fixer = fs.readFileSync(path.join(repo, ".agents", "agents", "fixer.toml"), "utf8");
|
|
232
236
|
const reviewer = fs.readFileSync(path.join(repo, ".agents", "agents", "reviewer.toml"), "utf8");
|
|
233
237
|
const browserDebugger = fs.readFileSync(path.join(repo, ".agents", "agents", "browser-debugger.toml"), "utf8");
|
|
@@ -482,8 +486,8 @@ function testBridgeIsGeneric() {
|
|
|
482
486
|
run("python3", [assetAp, "--repo", repo, "install", "--bridges"]);
|
|
483
487
|
assert(exists(path.join(repo, "AGENTS.md")), "generic bridge should be created");
|
|
484
488
|
const bridge = fs.readFileSync(path.join(repo, "AGENTS.md"), "utf8");
|
|
485
|
-
assert(bridge.includes("
|
|
486
|
-
assert(bridge.includes("integrates
|
|
489
|
+
assert(bridge.includes("Every writing agent owns a distinct task ID, worktree"), "bridge should expose writer isolation");
|
|
490
|
+
assert(bridge.includes("integrates in dependency order"), "bridge should expose dependency ordering");
|
|
487
491
|
for (const filename of [`CO${"DEX.md"}`, `CLA${"UDE.md"}`]) {
|
|
488
492
|
assert(!exists(path.join(repo, filename)), "client-named bridge should not be created");
|
|
489
493
|
}
|
|
@@ -729,7 +733,7 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
|
|
|
729
733
|
|
|
730
734
|
const engineering = path.join(repo, "docs", "ENGINEERING.md");
|
|
731
735
|
const initial = fs.readFileSync(engineering, "utf8");
|
|
732
|
-
const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.1\.
|
|
736
|
+
const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.1\.2 -->/;
|
|
733
737
|
const endMarker = "<!-- auto-coding-skill:managed-workflow:end -->";
|
|
734
738
|
assert(startPattern.test(initial), "new projects should include a versioned managed workflow marker");
|
|
735
739
|
assert(initial.includes(endMarker), "new projects should include the managed workflow end marker");
|
|
@@ -738,7 +742,7 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
|
|
|
738
742
|
.replace("workflow:\n", "# project-frontmatter-comment\nworkflow:\n")
|
|
739
743
|
.replace(startPattern, "project note before managed workflow\n<!-- auto-coding-skill:managed-workflow:start version=3.0.0 -->")
|
|
740
744
|
.replace(endMarker, `${endMarker}\nproject note after managed workflow`)
|
|
741
|
-
.replace("
|
|
745
|
+
.replace("The frontmatter contract is:", "Stale managed workflow contract:");
|
|
742
746
|
writeFile(engineering, customized);
|
|
743
747
|
const staleStart = customized.indexOf("<!-- auto-coding-skill:managed-workflow:start");
|
|
744
748
|
const staleEnd = customized.indexOf(endMarker) + endMarker.length;
|
|
@@ -748,7 +752,7 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
|
|
|
748
752
|
const dryRun = run("node", [cli, "sync", "--projects", repo, "--dry-run", "--json"]);
|
|
749
753
|
const dryResult = JSON.parse(dryRun.stdout).results[0];
|
|
750
754
|
assert(dryResult.managedWorkflow.state === "stale", `dry-run should expose stale workflow state: ${dryRun.stdout}`);
|
|
751
|
-
assert(dryResult.managedWorkflow.version === "4.1.
|
|
755
|
+
assert(dryResult.managedWorkflow.version === "4.1.2", "dry-run should expose the target workflow version");
|
|
752
756
|
assert(dryResult.actions.some(item => item.action === "would-update" && item.path === "docs/ENGINEERING.md"), "dry-run should plan the managed body update");
|
|
753
757
|
assert(fs.readFileSync(engineering, "utf8") === customized, "dry-run must not write ENGINEERING.md");
|
|
754
758
|
|
|
@@ -758,14 +762,14 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
|
|
|
758
762
|
const updatedEnd = updated.indexOf(endMarker) + endMarker.length;
|
|
759
763
|
assert(updated.slice(0, updatedStart) === outsideBefore, "sync must preserve frontmatter and content before the managed block byte-for-byte");
|
|
760
764
|
assert(updated.slice(updatedEnd) === outsideAfter, "sync must preserve content after the managed block byte-for-byte");
|
|
761
|
-
assert(updated.includes("version=4.1.
|
|
762
|
-
assert(updated.includes("
|
|
765
|
+
assert(updated.includes("version=4.1.2"), "sync should install the current managed workflow version");
|
|
766
|
+
assert(updated.includes("The frontmatter contract is:"), "sync should refresh stale managed workflow content");
|
|
763
767
|
|
|
764
768
|
fillRequiredAccess(repo);
|
|
765
769
|
const status = run("node", [cli, "status", "--projects", repo, "--json"]);
|
|
766
770
|
const statusResult = JSON.parse(status.stdout).results[0];
|
|
767
771
|
assert(statusResult.managedWorkflow.state === "current", `status should expose current managed workflow state: ${status.stdout}`);
|
|
768
|
-
assert(statusResult.managedWorkflow.version === "4.1.
|
|
772
|
+
assert(statusResult.managedWorkflow.version === "4.1.2", "status should expose the installed managed workflow version");
|
|
769
773
|
|
|
770
774
|
const beforeSecondSync = fs.readFileSync(engineering, "utf8");
|
|
771
775
|
const second = run("node", [cli, "sync", "--projects", repo, "--json"]);
|
|
@@ -793,7 +797,7 @@ function testLegacyEngineeringMigrationPreservesExistingBody() {
|
|
|
793
797
|
assert(dryResult.actions.find(item => item.path === "docs/ENGINEERING.md")?.detail.includes("preserved-custom"), "custom legacy action should be labeled preserved-custom");
|
|
794
798
|
run("node", [cli, "sync", "--projects", repo]);
|
|
795
799
|
const migrated = fs.readFileSync(engineering, "utf8");
|
|
796
|
-
assert(migrated.includes("version=4.1.
|
|
800
|
+
assert(migrated.includes("version=4.1.2"), "legacy migration should insert the current managed workflow");
|
|
797
801
|
assert(migrated.includes(legacyNote), "legacy migration must preserve the complete existing body");
|
|
798
802
|
const migratedStart = migrated.indexOf("<!-- auto-coding-skill:managed-workflow:start");
|
|
799
803
|
const migratedEnd = migrated.indexOf(endMarker) + endMarker.length;
|
|
@@ -823,7 +827,7 @@ function testOfficialLegacyEngineeringBodyIsReplacedWithoutDuplication() {
|
|
|
823
827
|
const migrated = fs.readFileSync(engineering, "utf8");
|
|
824
828
|
assert(migrated.startsWith(customizedFrontmatter), "official legacy migration must preserve YAML frontmatter byte-for-byte");
|
|
825
829
|
assert((migrated.match(/auto-coding-skill:managed-workflow:start/g) || []).length === 1, "official legacy migration should install exactly one managed workflow");
|
|
826
|
-
assert((migrated.match(/^## Delivery levels$/gm) || []).length ===
|
|
830
|
+
assert((migrated.match(/^## Delivery levels$/gm) || []).length === 0, "official legacy migration must remove the old duplicated workflow body");
|
|
827
831
|
|
|
828
832
|
const stable = fs.readFileSync(engineering, "utf8");
|
|
829
833
|
run("node", [cli, "sync", "--projects", repo]);
|
|
@@ -897,7 +901,7 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
|
|
|
897
901
|
run("node", [cli, "sync", "--projects", repo]);
|
|
898
902
|
const agents = path.join(repo, "AGENTS.md");
|
|
899
903
|
const initial = fs.readFileSync(agents, "utf8");
|
|
900
|
-
assert(initial.includes("managed-agents:start version=4.1.
|
|
904
|
+
assert(initial.includes("managed-agents:start version=4.1.2"), "new projects should receive the versioned root AGENTS block");
|
|
901
905
|
|
|
902
906
|
const custom = [
|
|
903
907
|
"# Project rules",
|
|
@@ -916,12 +920,12 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
|
|
|
916
920
|
|
|
917
921
|
run("node", [cli, "sync", "--projects", repo]);
|
|
918
922
|
const migrated = fs.readFileSync(agents, "utf8");
|
|
919
|
-
assert(migrated.includes("managed-agents:start version=4.1.
|
|
923
|
+
assert(migrated.includes("managed-agents:start version=4.1.2"), "AGENTS migration should install the current managed block");
|
|
920
924
|
assert(!migrated.includes("Preserve this repository-specific rule exactly."), "root AGENTS must contain no project-specific tail");
|
|
921
925
|
assert(!migrated.includes("must execute `commands.gate_full`"), "known official conflicting rule should be removed");
|
|
922
926
|
const canonical = fs.readFileSync(path.join(repoRoot, "cli", "assets", "skill", "data", "templates", "bridges", "AGENTS.md"), "utf8");
|
|
923
927
|
assert(migrated === canonical, "root AGENTS must be byte-identical to the packaged canonical file");
|
|
924
|
-
const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.1.
|
|
928
|
+
const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.1.2.md");
|
|
925
929
|
assert(fs.readFileSync(archive, "utf8").includes("Preserve this repository-specific rule exactly."), "previous AGENTS content must be archived once");
|
|
926
930
|
const stable = fs.readFileSync(agents);
|
|
927
931
|
run("node", [cli, "sync", "--projects", repo]);
|
|
@@ -980,7 +984,7 @@ function testEngineeringFrameworkAllowsProjectFactsButRejectsDuplicateWorkflow()
|
|
|
980
984
|
const migrationResult = JSON.parse(migration.stdout).results[0];
|
|
981
985
|
assert(migrationResult.managedWorkflow.state === "stale", "known duplicate sections should use controlled migration");
|
|
982
986
|
assert(migrationResult.managedWorkflow.migrations.includes("engineering-section-delivery-flow"), "known section migration should be explicit");
|
|
983
|
-
assert(migrationResult.actions.some(item => item.action === "would-archive" && item.path.includes("ENGINEERING.pre-4.1.
|
|
987
|
+
assert(migrationResult.actions.some(item => item.action === "would-archive" && item.path.includes("ENGINEERING.pre-4.1.2")), "controlled section cleanup should archive the previous ENGINEERING file");
|
|
984
988
|
run("node", [cli, "sync", "--projects", repo]);
|
|
985
989
|
assert(!fs.readFileSync(engineering, "utf8").includes("Known obsolete workflow"), "known duplicate workflow section should be removed");
|
|
986
990
|
|
|
@@ -992,14 +996,14 @@ function testEngineeringFrameworkAllowsProjectFactsButRejectsDuplicateWorkflow()
|
|
|
992
996
|
}
|
|
993
997
|
|
|
994
998
|
function testReleaseVersionMarkersStayInSync() {
|
|
995
|
-
const expected = "4.1.
|
|
999
|
+
const expected = "4.1.2";
|
|
996
1000
|
const pkg = JSON.parse(fs.readFileSync(path.join(repoRoot, "package.json"), "utf8"));
|
|
997
1001
|
const lock = JSON.parse(fs.readFileSync(path.join(repoRoot, "package-lock.json"), "utf8"));
|
|
998
1002
|
const policy = JSON.parse(fs.readFileSync(
|
|
999
1003
|
path.join(repoRoot, "src", "auto-coding-skill", "data", "policies", "workflow-migrations-v1.json"),
|
|
1000
1004
|
"utf8",
|
|
1001
1005
|
));
|
|
1002
|
-
assert(pkg.version === expected, "package version must match the 4.1.
|
|
1006
|
+
assert(pkg.version === expected, "package version must match the 4.1.2 release");
|
|
1003
1007
|
assert(lock.version === expected && lock.packages[""].version === expected, "package-lock versions must match");
|
|
1004
1008
|
assert(policy.managed_versions.engineering === expected && policy.managed_versions.agents === expected, "managed workflow versions must match");
|
|
1005
1009
|
for (const rel of [
|
|
@@ -1012,6 +1016,17 @@ function testReleaseVersionMarkersStayInSync() {
|
|
|
1012
1016
|
}
|
|
1013
1017
|
}
|
|
1014
1018
|
|
|
1019
|
+
function testProtocolResponsibilitiesStaySeparated() {
|
|
1020
|
+
const skill = fs.readFileSync(path.join(repoRoot, "src", "auto-coding-skill", "SKILL.md"), "utf8");
|
|
1021
|
+
const agents = fs.readFileSync(path.join(repoRoot, "src", "auto-coding-skill", "data", "templates", "bridges", "AGENTS.md"), "utf8");
|
|
1022
|
+
const engineering = fs.readFileSync(path.join(repoRoot, "src", "auto-coding-skill", "data", "templates", "ENGINEERING.md"), "utf8");
|
|
1023
|
+
const totalLines = [skill, agents, engineering].reduce((sum, text) => sum + text.split(/\r?\n/).length, 0);
|
|
1024
|
+
assert(totalLines <= 350, `shared protocol context budget exceeded: ${totalLines} lines`);
|
|
1025
|
+
assert(agents.includes("## Minimum mechanism budget") && agents.includes("## Bounded real validation"), "AGENTS must remain the behavioral protocol");
|
|
1026
|
+
assert(skill.includes("## Select the minimum mechanism set") && !skill.includes("## Authority"), "SKILL must remain invocation guidance");
|
|
1027
|
+
assert(engineering.includes("The frontmatter contract is:") && !engineering.includes("## Git and parallel work"), "ENGINEERING must remain project configuration/facts");
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1015
1030
|
testPreflightAvoidsPartialInstall();
|
|
1016
1031
|
testDestVariants();
|
|
1017
1032
|
testLauncherFallsBackToGlobalRuntime();
|
|
@@ -1049,5 +1064,6 @@ testUnknownWorkflowConflictFailsWholeBatchBeforeWrites();
|
|
|
1049
1064
|
testEngineeringMarkerBoundaryIsNormalized();
|
|
1050
1065
|
testEngineeringFrameworkAllowsProjectFactsButRejectsDuplicateWorkflow();
|
|
1051
1066
|
testReleaseVersionMarkersStayInSync();
|
|
1067
|
+
testProtocolResponsibilitiesStaySeparated();
|
|
1052
1068
|
|
|
1053
1069
|
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": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
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": {
|
|
@@ -15,11 +15,14 @@
|
|
|
15
15
|
"LICENSE"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
+
"clean:cache": "find cli src -type d -name '__pycache__' -prune -exec rm -rf {} +",
|
|
19
|
+
"prepack": "npm run clean:cache",
|
|
20
|
+
"check:package": "npm run clean:cache && node cli/src/check-package.js",
|
|
18
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 {} +",
|
|
19
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 {} +",
|
|
20
23
|
"check:assets": "node cli/src/sync-assets.js --check",
|
|
21
24
|
"sync-assets": "node cli/src/sync-assets.js",
|
|
22
|
-
"release:check": "npm run check:assets && npm run test:src && npm run test && npm
|
|
25
|
+
"release:check": "npm run check:assets && npm run test:src && npm run test && npm run check:package"
|
|
23
26
|
},
|
|
24
27
|
"license": "MIT",
|
|
25
28
|
"publishConfig": {
|