@elvis1513/auto-coding-skill 4.1.3 → 4.1.6

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.
@@ -7,8 +7,12 @@ from __future__ import annotations
7
7
  import os
8
8
  import re
9
9
  import signal
10
+ import shlex
10
11
  import shutil
11
12
  import subprocess
13
+ import sys
14
+ import urllib.error
15
+ import urllib.request
12
16
  from pathlib import Path
13
17
  from typing import Iterable, Optional, Dict, Any
14
18
 
@@ -17,16 +21,32 @@ try:
17
21
  except Exception:
18
22
  yaml = None
19
23
 
20
- try:
21
- import requests # type: ignore
22
- except Exception:
23
- requests = None
24
-
25
-
26
24
  class APError(RuntimeError):
27
25
  pass
28
26
 
29
27
 
28
+ def runtime_requirements_path() -> Path:
29
+ return Path(__file__).resolve().parents[1] / "requirements.txt"
30
+
31
+
32
+ def require_yaml() -> Any:
33
+ if yaml is None:
34
+ install = shlex.join(
35
+ [
36
+ sys.executable,
37
+ "-m",
38
+ "pip",
39
+ "install",
40
+ "--requirement",
41
+ str(runtime_requirements_path()),
42
+ ]
43
+ )
44
+ raise APError(
45
+ f"PyYAML is missing from {sys.executable}. Run: {install}"
46
+ )
47
+ return yaml
48
+
49
+
30
50
  def run(cmd: Iterable[str], cwd: Optional[Path] = None, check: bool = True) -> subprocess.CompletedProcess:
31
51
  p = subprocess.run(list(cmd), cwd=str(cwd) if cwd else None, text=True, capture_output=True)
32
52
  if check and p.returncode != 0:
@@ -46,10 +66,7 @@ def ensure_git_repo(repo: Path) -> None:
46
66
  def load_yaml(path: Path) -> Dict[str, Any]:
47
67
  if not path.exists():
48
68
  raise APError(f"YAML not found: {path}")
49
- if yaml is None:
50
- raise APError(
51
- "PyYAML not installed. Install dependencies with: pip install pyyaml requests"
52
- )
69
+ yaml_module = require_yaml()
53
70
  if path.suffix.lower() in {".md", ".markdown"}:
54
71
  text = path.read_text(encoding="utf-8")
55
72
  m = re.match(r"^---\s*\n(.*?)\n---\s*(\n|$)", text, flags=re.DOTALL)
@@ -58,10 +75,10 @@ def load_yaml(path: Path) -> Dict[str, Any]:
58
75
  f"Config markdown frontmatter not found: {path}\n"
59
76
  "Expected YAML frontmatter wrapped by '---' at top of file."
60
77
  )
61
- data = yaml.safe_load(m.group(1))
78
+ data = yaml_module.safe_load(m.group(1))
62
79
  else:
63
80
  with path.open("r", encoding="utf-8") as f:
64
- data = yaml.safe_load(f)
81
+ data = yaml_module.safe_load(f)
65
82
  return data or {}
66
83
 
67
84
 
@@ -87,12 +104,12 @@ def copy_tree(src: Path, dst: Path) -> None:
87
104
 
88
105
 
89
106
  def http_get_status(url: str, timeout_s: int = 5) -> int:
90
- if requests is None:
91
- raise APError(
92
- "requests not installed. Install dependencies with: pip install pyyaml requests"
93
- )
94
- r = requests.get(url, timeout=timeout_s)
95
- return r.status_code
107
+ request = urllib.request.Request(url, method="GET")
108
+ try:
109
+ with urllib.request.urlopen(request, timeout=timeout_s) as response:
110
+ return int(response.status)
111
+ except urllib.error.HTTPError as exc:
112
+ return int(exc.code)
96
113
 
97
114
 
98
115
  def find_config(repo: Path) -> Path:
package/cli/src/index.js CHANGED
@@ -3,7 +3,7 @@ import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import os from "node:os";
5
5
  import crypto from "node:crypto";
6
- import { execFileSync } from "node:child_process";
6
+ import { execFileSync, spawnSync } from "node:child_process";
7
7
  import { fileURLToPath } from "node:url";
8
8
 
9
9
  function die(msg){
@@ -118,6 +118,26 @@ function validateCommandArgs(args){
118
118
 
119
119
  function exists(p){ try { fs.accessSync(p); return true; } catch { return false; } }
120
120
  function rmrf(p){ fs.rmSync(p, { recursive: true, force: true }); }
121
+ function quoted(value){ return JSON.stringify(String(value)); }
122
+
123
+ function requireRuntimeDependencies(assetSkill){
124
+ const defaultPython = process.platform === "win32" ? "python" : "python3";
125
+ const python = String(process.env.AUTOCODING_PYTHON || defaultPython).trim() || defaultPython;
126
+ const requirements = path.join(assetSkill, "requirements.txt");
127
+ if (!exists(requirements)) die(`missing runtime dependency definition: ${requirements}`);
128
+ const check = spawnSync(
129
+ python,
130
+ ["-c", "import yaml"],
131
+ { encoding: "utf8", stdio: "pipe" },
132
+ );
133
+ if (check.status === 0) return;
134
+ const detail = String(check.stderr || check.error?.message || "PyYAML import failed").trim().split(/\r?\n/).slice(-1)[0];
135
+ const install = `${quoted(python)} -m pip install --requirement ${quoted(requirements)}`;
136
+ die(
137
+ `Python runtime dependency check failed${detail ? `: ${detail}` : ""}\n`
138
+ + `Run: ${install}\nThen rerun autocoding init.`,
139
+ );
140
+ }
121
141
  function shouldSkip(name){
122
142
  return name === "__pycache__" || name === ".DS_Store" || name.endsWith(".pyc");
123
143
  }
@@ -1470,6 +1490,8 @@ Compatibility:
1470
1490
 
1471
1491
  if (args.ai) console.warn("[autocoding] --ai is deprecated and ignored; installing generic .agents.");
1472
1492
 
1493
+ requireRuntimeDependencies(assetSkill);
1494
+
1473
1495
  const { skillDir, agentsDir } = resolveInstallDirs(args.mode, args.dest);
1474
1496
  const existingTargets = [skillDir, agentsDir].filter(target => exists(target));
1475
1497
  if (existingTargets.length && !args.force) {
@@ -16,6 +16,7 @@ import yaml
16
16
  REPO_ROOT = Path(__file__).resolve().parents[2]
17
17
  AP_SCRIPT = REPO_ROOT / "src" / "auto-coding-skill" / "scripts" / "ap.py"
18
18
  _MISSING = object()
19
+ _TEST_OWNER = os.environ.get("CODEX_THREAD_ID") or "concurrency-test-owner"
19
20
 
20
21
 
21
22
  def command(
@@ -24,6 +25,8 @@ def command(
24
25
  check: bool = True,
25
26
  input_text: str | None = None,
26
27
  ) -> subprocess.CompletedProcess[str]:
28
+ env = os.environ.copy()
29
+ env.setdefault("CODEX_THREAD_ID", _TEST_OWNER)
27
30
  result = subprocess.run(
28
31
  list(args),
29
32
  cwd=cwd,
@@ -32,6 +35,7 @@ def command(
32
35
  input=input_text,
33
36
  capture_output=True,
34
37
  timeout=30,
38
+ env=env,
35
39
  )
36
40
  if check and result.returncode != 0:
37
41
  raise AssertionError(
@@ -188,6 +192,13 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
188
192
  )
189
193
  return fingerprint
190
194
 
195
+ def claim_direct(self, repo: Path, *owned_paths: str) -> str:
196
+ args: list[str] = ["classify", "--task-kind", "change", "--claim-direct", "--json"]
197
+ for path in owned_paths:
198
+ args.extend(["--planned-path", path])
199
+ payload = json.loads(self.ap(repo, *args).stdout)
200
+ return payload["direct_claim"]["id"]
201
+
191
202
  def commit_push(self, repo: Path, task_id: str, message: str) -> subprocess.CompletedProcess[str]:
192
203
  self.approve_task(repo, task_id)
193
204
  return self.ap(repo, "commit-push", task_id, "--msg", message)
@@ -446,6 +457,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
446
457
 
447
458
  def test_continue_direct_can_adopt_owned_changes_for_new_review_lifecycle(self) -> None:
448
459
  _, repo, remote = self.make_repo("adaptive", require_review=False)
460
+ claim = self.claim_direct(repo, "shared.txt")
449
461
  (repo / "shared.txt").write_text("continued direct\n", encoding="utf-8")
450
462
  started = self.ap(
451
463
  repo,
@@ -454,6 +466,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
454
466
  "--owned-path",
455
467
  "shared.txt",
456
468
  "--continue-direct",
469
+ "--direct-claim",
470
+ claim,
457
471
  "--review-required",
458
472
  )
459
473
  self.assertIn("execution_mode=direct", started.stdout)
@@ -477,6 +491,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
477
491
  self.assertIn("execution_mode=direct", pushed.stdout)
478
492
  self.assertEqual("continued direct", git_output(remote, "show", "refs/heads/dev:shared.txt"))
479
493
 
494
+ claim = self.claim_direct(repo, "shared.txt")
480
495
  (repo / "shared.txt").write_text("owned again\n", encoding="utf-8")
481
496
  (repo / "unrelated.txt").write_text("unknown\n", encoding="utf-8")
482
497
  rejected = self.ap(
@@ -486,6 +501,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
486
501
  "--owned-path",
487
502
  "shared.txt",
488
503
  "--continue-direct",
504
+ "--direct-claim",
505
+ claim,
489
506
  "--review-required",
490
507
  check=False,
491
508
  )
@@ -493,6 +510,43 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
493
510
  self.assertIn("unrelated.txt", rejected.stdout + rejected.stderr)
494
511
  self.assertFalse(self.registry_manifest_path(repo, "DIRECT-CONTINUE-BLOCKED").exists())
495
512
 
513
+ def test_reviewer_cannot_be_current_writer(self) -> None:
514
+ _, repo, _ = self.make_repo()
515
+ self.ap(
516
+ repo,
517
+ "task-start",
518
+ "SELF-REVIEW",
519
+ "--base",
520
+ "origin/dev",
521
+ "--owned-path",
522
+ "src",
523
+ "--isolated",
524
+ "--review-required",
525
+ "--writer",
526
+ "self-reviewer",
527
+ )
528
+ worktree = self.task_worktree(repo, "SELF-REVIEW")
529
+ payload = worktree / "src" / "payload.txt"
530
+ payload.parent.mkdir(parents=True, exist_ok=True)
531
+ payload.write_text("changed\n", encoding="utf-8")
532
+ status = json.loads(
533
+ self.ap(worktree, "task-status", "SELF-REVIEW", "--json").stdout
534
+ )["tasks"][0]
535
+ rejected = self.ap(
536
+ worktree,
537
+ "task-review",
538
+ "SELF-REVIEW",
539
+ "--verdict",
540
+ "approved",
541
+ "--diff-fingerprint",
542
+ status["current_diff_fingerprint"],
543
+ "--reviewer",
544
+ "self-reviewer",
545
+ check=False,
546
+ )
547
+ self.assertNotEqual(0, rejected.returncode)
548
+ self.assertIn("writer lease holder", rejected.stdout + rejected.stderr)
549
+
496
550
  def test_schema_one_task_status_fails_closed_with_migration_recovery(self) -> None:
497
551
  _, repo, _ = self.make_repo()
498
552
  self.start_task(repo, "LEGACY-SCHEMA")
@@ -602,7 +656,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
602
656
 
603
657
  def test_writer_lease_requires_match_and_owner_handoff_uses_generation_cas(self) -> None:
604
658
  _, repo, _ = self.make_repo()
605
- owner = os.environ["CODEX_THREAD_ID"]
659
+ owner = _TEST_OWNER
606
660
  self.ap(
607
661
  repo,
608
662
  "task-start",
@@ -1284,6 +1338,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
1284
1338
  git(task_module, "update-ref", "-d", "refs/heads/extra-check", extra_tip)
1285
1339
 
1286
1340
  git(task_module, "checkout", "-qb", "hidden")
1341
+ git(task_module, "config", "user.email", "test@example.com")
1342
+ git(task_module, "config", "user.name", "Auto Coding Test")
1287
1343
  (task_module / "hidden.txt").write_text("local-only history\n", encoding="utf-8")
1288
1344
  git(task_module, "add", "hidden.txt")
1289
1345
  git(task_module, "commit", "-qm", "hidden local commit")
@@ -1630,6 +1686,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
1630
1686
 
1631
1687
  module_b = worktree / "vendor" / "b"
1632
1688
  baseline = git_output(module_b, "rev-parse", "HEAD")
1689
+ git(module_b, "config", "user.email", "test@example.com")
1690
+ git(module_b, "config", "user.name", "Auto Coding Test")
1633
1691
  git(module_b, "checkout", "-qb", "hidden")
1634
1692
  (module_b / "hidden.txt").write_text("local-only residual history\n", encoding="utf-8")
1635
1693
  git(module_b, "add", "hidden.txt")
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
 
4
4
  import argparse
5
5
  import json
6
+ import os
6
7
  import subprocess
7
8
  import sys
8
9
  import tempfile
@@ -277,7 +278,9 @@ class AutoCodingProfileTests(unittest.TestCase):
277
278
  )
278
279
  self.assertFalse(plan["mechanism_plan"]["lifecycle_required"])
279
280
  self.assertIn("read_only_subagents", plan["mechanism_plan"]["optional_when_beneficial"])
281
+ self.assertNotIn("parallel_fixers", plan["mechanism_plan"]["optional_when_beneficial"])
280
282
  self.assertIn("task_lifecycle", plan["mechanism_plan"]["forbidden"])
283
+ self.assertIn("parallel_fixers", plan["mechanism_plan"]["forbidden"])
281
284
 
282
285
  def test_intent_only_classifies_read_only_change_and_terminal_work(self) -> None:
283
286
  repo, cfg = self.make_repo()
@@ -360,6 +363,12 @@ class AutoCodingProfileTests(unittest.TestCase):
360
363
 
361
364
  def test_continue_direct_accepts_only_declared_current_task_dirt(self) -> None:
362
365
  repo, cfg = self.make_repo()
366
+ claim = ap._create_direct_claim(
367
+ repo,
368
+ cfg,
369
+ ["src/widget.py"],
370
+ os.environ.get("CODEX_THREAD_ID") or "profile-test-owner",
371
+ )
363
372
  target = repo / "src" / "widget.py"
364
373
  target.parent.mkdir(parents=True, exist_ok=True)
365
374
  target.write_text("task change\n", encoding="utf-8")
@@ -371,20 +380,32 @@ class AutoCodingProfileTests(unittest.TestCase):
371
380
  cfg,
372
381
  planned_paths=["src/widget.py"],
373
382
  continue_direct=True,
383
+ direct_claim_id=claim["claim_id"],
374
384
  )
375
385
  self.assertEqual("direct", continued["execution_mode"])
376
386
  self.assertTrue(continued["continued_direct"])
377
387
  self.assertEqual([], continued["dirty_outside_plan"])
378
388
 
379
389
  (repo / "unrelated.txt").write_text("other writer\n", encoding="utf-8")
380
- blocked = self.plan(
381
- repo,
382
- cfg,
383
- planned_paths=["src/widget.py"],
384
- continue_direct=True,
385
- )
386
- self.assertEqual("isolated", blocked["execution_mode"])
387
- self.assertEqual(["unrelated.txt"], blocked["dirty_outside_plan"])
390
+ with self.assertRaises(APError) as context:
391
+ self.plan(
392
+ repo,
393
+ cfg,
394
+ planned_paths=["src/widget.py"],
395
+ continue_direct=True,
396
+ direct_claim_id=claim["claim_id"],
397
+ )
398
+ self.assertIn("outside the clean direct claim", str(context.exception))
399
+
400
+ def test_continue_direct_requires_a_clean_pre_write_claim(self) -> None:
401
+ repo, cfg = self.make_repo()
402
+ (repo / "unknown.txt").write_text("pre-existing user change\n", encoding="utf-8")
403
+ with self.assertRaises(APError) as context:
404
+ ap._create_direct_claim(repo, cfg, ["."], "profile-test-owner")
405
+ self.assertIn("before the first write", str(context.exception))
406
+ with self.assertRaises(APError) as context:
407
+ self.plan(repo, cfg, planned_paths=["."], continue_direct=True)
408
+ self.assertIn("requires --direct-claim", str(context.exception))
388
409
 
389
410
  def test_risk_intent_is_candidate_while_paths_and_rules_control_escalation(self) -> None:
390
411
  repo, cfg = self.make_repo()
@@ -419,6 +440,38 @@ class AutoCodingProfileTests(unittest.TestCase):
419
440
  order = self.plan(repo, cfg, planned_paths=["backend/orders/sort_order.py"])
420
441
  self.assertNotIn("payment", order["categories"])
421
442
 
443
+ def test_high_confidence_intent_and_backend_login_escalate_without_ui_false_positive(self) -> None:
444
+ repo, cfg = self.make_repo()
445
+ for intent, category in [
446
+ ("修改数据库迁移", "db"),
447
+ ("修改后端鉴权权限", "auth"),
448
+ ("修改支付结算逻辑", "payment"),
449
+ ("修改生产网关配置", "gateway"),
450
+ ]:
451
+ with self.subTest(intent=intent):
452
+ plan = self.plan(repo, cfg, intent=intent)
453
+ self.assertEqual("high-risk", plan["profile"])
454
+ self.assertTrue(plan["review_required"])
455
+ self.assertIn(category, plan["high_confidence_intent_categories"])
456
+
457
+ backend_login = self.plan(
458
+ repo,
459
+ cfg,
460
+ planned_paths=["backend/login_handler.go"],
461
+ intent="修复登录处理",
462
+ )
463
+ self.assertEqual("high-risk", backend_login["profile"])
464
+ self.assertTrue(backend_login["review_required"])
465
+
466
+ login_ui = self.plan(
467
+ repo,
468
+ cfg,
469
+ planned_paths=["frontend/LoginPage.tsx"],
470
+ intent="修复登录页面跳转",
471
+ )
472
+ self.assertEqual("standard", login_ui["profile"])
473
+ self.assertFalse(login_ui["review_required"])
474
+
422
475
  def test_generated_agent_strategies_match_contract_schema(self) -> None:
423
476
  schema = json.loads(
424
477
  (REPO_ROOT / "src" / "auto-coding-skill" / "data" / "contracts" / "orchestration-v1.schema.json")
@@ -434,6 +487,50 @@ class AutoCodingProfileTests(unittest.TestCase):
434
487
  with self.subTest(kwargs=kwargs):
435
488
  plan = self.plan(repo, cfg, **kwargs)
436
489
  self.assertIn(plan["agent_plan"]["strategy"], allowed)
490
+ ap._validate_orchestration_contract("classify", plan)
491
+
492
+ def test_agent_assignment_and_result_contracts_are_machine_enforced(self) -> None:
493
+ fingerprint = "a" * 64
494
+ assignment = {
495
+ "contract_version": 1,
496
+ "node_id": "reviewer-1",
497
+ "task_id": "T001",
498
+ "role": "reviewer",
499
+ "base_sha": "HEAD",
500
+ "scope": "review owned diff",
501
+ "depends_on": [],
502
+ "acceptance": ["review current fingerprint"],
503
+ "diff_base": "HEAD~1",
504
+ "diff_head": "HEAD",
505
+ "diff_fingerprint": fingerprint,
506
+ "owning_fixer": "fixer-1",
507
+ }
508
+ ap._validate_orchestration_contract("assignment", assignment)
509
+ self_review = dict(assignment, node_id="fixer-1")
510
+ with self.assertRaises(APError):
511
+ ap._validate_orchestration_contract("assignment", self_review)
512
+
513
+ result = {
514
+ "contract_version": 1,
515
+ "node_id": "reviewer-1",
516
+ "role": "reviewer",
517
+ "task_id": "T001",
518
+ "base_sha": "HEAD~1",
519
+ "status": "completed",
520
+ "summary": "reviewed",
521
+ "depends_on": [],
522
+ "owned_paths": [],
523
+ "changed_paths": [],
524
+ "diff_fingerprint": fingerprint,
525
+ "evidence": ["diff reviewed"],
526
+ "findings": [],
527
+ "verdict": "approved",
528
+ "risks": [],
529
+ "next_owner": "main",
530
+ }
531
+ ap._validate_orchestration_contract("result", result)
532
+ with self.assertRaises(APError):
533
+ ap._validate_orchestration_contract("result", dict(result, diff_fingerprint=""))
437
534
 
438
535
  def test_validation_routes_collect_all_commands_and_reject_unmapped_code(self) -> None:
439
536
  repo, cfg = self.make_repo()
@@ -169,6 +169,23 @@ function testPreflightAvoidsPartialInstall() {
169
169
  assert(exists(path.join(repo, ".agents", "agents", "custom.toml")), "existing custom agent should remain");
170
170
  }
171
171
 
172
+ function testInitRejectsMissingPythonRuntimeBeforeWrites() {
173
+ if (process.platform === "win32") return;
174
+ const repo = tmpdir("missing-python-runtime");
175
+ const fakePython = path.join(repo, "python-without-yaml");
176
+ writeFile(fakePython, "#!/bin/sh\necho 'No module named yaml' >&2\nexit 1\n");
177
+ fs.chmodSync(fakePython, 0o755);
178
+ const result = run("node", [cli, "init"], {
179
+ cwd: repo,
180
+ check: false,
181
+ env: { AUTOCODING_PYTHON: fakePython },
182
+ });
183
+ assert(result.status !== 0, "init should fail when its Python runtime cannot import PyYAML");
184
+ assert(result.stderr.includes("Python runtime dependency check failed"), "init should identify the runtime dependency failure");
185
+ assert(result.stderr.includes("requirements.txt") && result.stderr.includes("Then rerun autocoding init"), "init should print one deterministic recovery command");
186
+ assert(!exists(path.join(repo, ".agents")), "runtime preflight must fail before writing .agents");
187
+ }
188
+
172
189
  function testDestVariants() {
173
190
  const variants = [
174
191
  { name: "repo-root", dest(root) { return root; } },
@@ -219,7 +236,9 @@ function testMinimalSyncConvergesWithinBudget() {
219
236
  const files = listProjectFiles(repo);
220
237
  const lines = files.reduce((total, file) => total + fs.readFileSync(file, "utf8").split(/\r?\n/).length, 0);
221
238
  assert(files.length <= 23, `minimal scaffold file budget exceeded: ${files.length}`);
222
- assert(lines <= 10800, `minimal scaffold line budget exceeded: ${lines}`);
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}`);
223
242
  const engineering = fs.readFileSync(path.join(repo, "docs", "ENGINEERING.md"), "utf8");
224
243
  assert(engineering.includes("profile: \"auto\""), "engineering should enable adaptive profiles");
225
244
  assert(engineering.includes("isolation: \"adaptive\""), "engineering should default to adaptive clean-branch/worktree isolation");
@@ -733,7 +752,7 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
733
752
 
734
753
  const engineering = path.join(repo, "docs", "ENGINEERING.md");
735
754
  const initial = fs.readFileSync(engineering, "utf8");
736
- const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.1\.3 -->/;
755
+ const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.1\.6 -->/;
737
756
  const endMarker = "<!-- auto-coding-skill:managed-workflow:end -->";
738
757
  assert(startPattern.test(initial), "new projects should include a versioned managed workflow marker");
739
758
  assert(initial.includes(endMarker), "new projects should include the managed workflow end marker");
@@ -752,7 +771,7 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
752
771
  const dryRun = run("node", [cli, "sync", "--projects", repo, "--dry-run", "--json"]);
753
772
  const dryResult = JSON.parse(dryRun.stdout).results[0];
754
773
  assert(dryResult.managedWorkflow.state === "stale", `dry-run should expose stale workflow state: ${dryRun.stdout}`);
755
- assert(dryResult.managedWorkflow.version === "4.1.3", "dry-run should expose the target workflow version");
774
+ assert(dryResult.managedWorkflow.version === "4.1.6", "dry-run should expose the target workflow version");
756
775
  assert(dryResult.actions.some(item => item.action === "would-update" && item.path === "docs/ENGINEERING.md"), "dry-run should plan the managed body update");
757
776
  assert(fs.readFileSync(engineering, "utf8") === customized, "dry-run must not write ENGINEERING.md");
758
777
 
@@ -762,14 +781,14 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
762
781
  const updatedEnd = updated.indexOf(endMarker) + endMarker.length;
763
782
  assert(updated.slice(0, updatedStart) === outsideBefore, "sync must preserve frontmatter and content before the managed block byte-for-byte");
764
783
  assert(updated.slice(updatedEnd) === outsideAfter, "sync must preserve content after the managed block byte-for-byte");
765
- assert(updated.includes("version=4.1.3"), "sync should install the current managed workflow version");
784
+ assert(updated.includes("version=4.1.6"), "sync should install the current managed workflow version");
766
785
  assert(updated.includes("The frontmatter contract is:"), "sync should refresh stale managed workflow content");
767
786
 
768
787
  fillRequiredAccess(repo);
769
788
  const status = run("node", [cli, "status", "--projects", repo, "--json"]);
770
789
  const statusResult = JSON.parse(status.stdout).results[0];
771
790
  assert(statusResult.managedWorkflow.state === "current", `status should expose current managed workflow state: ${status.stdout}`);
772
- assert(statusResult.managedWorkflow.version === "4.1.3", "status should expose the installed managed workflow version");
791
+ assert(statusResult.managedWorkflow.version === "4.1.6", "status should expose the installed managed workflow version");
773
792
 
774
793
  const beforeSecondSync = fs.readFileSync(engineering, "utf8");
775
794
  const second = run("node", [cli, "sync", "--projects", repo, "--json"]);
@@ -797,7 +816,7 @@ function testLegacyEngineeringMigrationPreservesExistingBody() {
797
816
  assert(dryResult.actions.find(item => item.path === "docs/ENGINEERING.md")?.detail.includes("preserved-custom"), "custom legacy action should be labeled preserved-custom");
798
817
  run("node", [cli, "sync", "--projects", repo]);
799
818
  const migrated = fs.readFileSync(engineering, "utf8");
800
- assert(migrated.includes("version=4.1.3"), "legacy migration should insert the current managed workflow");
819
+ assert(migrated.includes("version=4.1.6"), "legacy migration should insert the current managed workflow");
801
820
  assert(migrated.includes(legacyNote), "legacy migration must preserve the complete existing body");
802
821
  const migratedStart = migrated.indexOf("<!-- auto-coding-skill:managed-workflow:start");
803
822
  const migratedEnd = migrated.indexOf(endMarker) + endMarker.length;
@@ -901,7 +920,7 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
901
920
  run("node", [cli, "sync", "--projects", repo]);
902
921
  const agents = path.join(repo, "AGENTS.md");
903
922
  const initial = fs.readFileSync(agents, "utf8");
904
- assert(initial.includes("managed-agents:start version=4.1.3"), "new projects should receive the versioned root AGENTS block");
923
+ assert(initial.includes("managed-agents:start version=4.1.6"), "new projects should receive the versioned root AGENTS block");
905
924
 
906
925
  const custom = [
907
926
  "# Project rules",
@@ -920,12 +939,12 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
920
939
 
921
940
  run("node", [cli, "sync", "--projects", repo]);
922
941
  const migrated = fs.readFileSync(agents, "utf8");
923
- assert(migrated.includes("managed-agents:start version=4.1.3"), "AGENTS migration should install the current managed block");
942
+ assert(migrated.includes("managed-agents:start version=4.1.6"), "AGENTS migration should install the current managed block");
924
943
  assert(!migrated.includes("Preserve this repository-specific rule exactly."), "root AGENTS must contain no project-specific tail");
925
944
  assert(!migrated.includes("must execute `commands.gate_full`"), "known official conflicting rule should be removed");
926
945
  const canonical = fs.readFileSync(path.join(repoRoot, "cli", "assets", "skill", "data", "templates", "bridges", "AGENTS.md"), "utf8");
927
946
  assert(migrated === canonical, "root AGENTS must be byte-identical to the packaged canonical file");
928
- const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.1.3.md");
947
+ const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.1.6.md");
929
948
  assert(fs.readFileSync(archive, "utf8").includes("Preserve this repository-specific rule exactly."), "previous AGENTS content must be archived once");
930
949
  const stable = fs.readFileSync(agents);
931
950
  run("node", [cli, "sync", "--projects", repo]);
@@ -984,7 +1003,7 @@ function testEngineeringFrameworkAllowsProjectFactsButRejectsDuplicateWorkflow()
984
1003
  const migrationResult = JSON.parse(migration.stdout).results[0];
985
1004
  assert(migrationResult.managedWorkflow.state === "stale", "known duplicate sections should use controlled migration");
986
1005
  assert(migrationResult.managedWorkflow.migrations.includes("engineering-section-delivery-flow"), "known section migration should be explicit");
987
- assert(migrationResult.actions.some(item => item.action === "would-archive" && item.path.includes("ENGINEERING.pre-4.1.3")), "controlled section cleanup should archive the previous ENGINEERING file");
1006
+ assert(migrationResult.actions.some(item => item.action === "would-archive" && item.path.includes("ENGINEERING.pre-4.1.6")), "controlled section cleanup should archive the previous ENGINEERING file");
988
1007
  run("node", [cli, "sync", "--projects", repo]);
989
1008
  assert(!fs.readFileSync(engineering, "utf8").includes("Known obsolete workflow"), "known duplicate workflow section should be removed");
990
1009
 
@@ -996,16 +1015,24 @@ function testEngineeringFrameworkAllowsProjectFactsButRejectsDuplicateWorkflow()
996
1015
  }
997
1016
 
998
1017
  function testReleaseVersionMarkersStayInSync() {
999
- const expected = "4.1.3";
1018
+ const expected = "4.1.6";
1000
1019
  const pkg = JSON.parse(fs.readFileSync(path.join(repoRoot, "package.json"), "utf8"));
1001
1020
  const lock = JSON.parse(fs.readFileSync(path.join(repoRoot, "package-lock.json"), "utf8"));
1002
1021
  const policy = JSON.parse(fs.readFileSync(
1003
1022
  path.join(repoRoot, "src", "auto-coding-skill", "data", "policies", "workflow-migrations-v1.json"),
1004
1023
  "utf8",
1005
1024
  ));
1006
- assert(pkg.version === expected, "package version must match the 4.1.3 release");
1025
+ assert(pkg.version === expected, "package version must match the 4.1.6 release");
1007
1026
  assert(lock.version === expected && lock.packages[""].version === expected, "package-lock versions must match");
1008
1027
  assert(policy.managed_versions.engineering === expected && policy.managed_versions.agents === expected, "managed workflow versions must match");
1028
+ const publishWorkflow = fs.readFileSync(path.join(repoRoot, ".github", "workflows", "npm-publish.yml"), "utf8");
1029
+ const runtimeRequirements = fs.readFileSync(path.join(repoRoot, "src", "auto-coding-skill", "requirements.txt"), "utf8");
1030
+ assert(publishWorkflow.includes("tags:\n - \"v*\""), "npm publish must run from version tag pushes");
1031
+ assert(publishWorkflow.includes("actions/setup-python@v6") && publishWorkflow.includes("src/auto-coding-skill/requirements.txt"), "npm publish must install the pinned Python runtime before verification");
1032
+ assert(runtimeRequirements.trim() === "PyYAML==6.0.3", "the runtime must have one pinned third-party dependency");
1033
+ assert(!runtimeRequirements.toLowerCase().includes("requests"), "HTTP checks must stay on the Python standard library");
1034
+ assert(publishWorkflow.includes("Verify release identity"), "npm publish must bind the tag to package version");
1035
+ assert(publishWorkflow.includes("Check npm registry") && publishWorkflow.includes("Verify npm publication"), "npm publish must be idempotent and registry-verified");
1009
1036
  for (const rel of [
1010
1037
  "src/auto-coding-skill/data/templates/ENGINEERING.md",
1011
1038
  "src/auto-coding-skill/data/templates/bridges/AGENTS.md",
@@ -1028,6 +1055,7 @@ function testProtocolResponsibilitiesStaySeparated() {
1028
1055
  }
1029
1056
 
1030
1057
  testPreflightAvoidsPartialInstall();
1058
+ testInitRejectsMissingPythonRuntimeBeforeWrites();
1031
1059
  testDestVariants();
1032
1060
  testLauncherFallsBackToGlobalRuntime();
1033
1061
  testMinimalSyncConvergesWithinBudget();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elvis1513/auto-coding-skill",
3
- "version": "4.1.3",
3
+ "version": "4.1.6",
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": {