@elvis1513/auto-coding-skill 4.2.1 → 4.2.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.
@@ -85,6 +85,25 @@ function writeFile(file, text) {
85
85
  fs.writeFileSync(file, text);
86
86
  }
87
87
 
88
+ function readEngineeringConfig(file) {
89
+ const script = [
90
+ "import json, pathlib, sys, yaml",
91
+ "text = pathlib.Path(sys.argv[1]).read_text(encoding='utf-8')",
92
+ "parts = text.split('---', 2)",
93
+ "assert len(parts) == 3 and not parts[0].strip(), 'missing YAML frontmatter'",
94
+ "print(json.dumps(yaml.safe_load(parts[1]) or {}, sort_keys=True))",
95
+ ].join("; ");
96
+ return JSON.parse(run("python3", ["-c", script, file]).stdout);
97
+ }
98
+
99
+ function canonicalJson(value) {
100
+ if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
101
+ if (value && typeof value === "object") {
102
+ return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(",")}}`;
103
+ }
104
+ return JSON.stringify(value);
105
+ }
106
+
88
107
  function readTomlString(text, key, file) {
89
108
  const match = text.match(new RegExp(`^${key}\\s*=\\s*"([^"]+)"\\s*$`, "m"));
90
109
  assert(match, `${file}: missing ${key}`);
@@ -182,14 +201,92 @@ function testInitFullyConvergesExistingProject() {
182
201
  run("node", [cli, "init"], { cwd: repo });
183
202
  fillRequiredAccess(repo, "preserved-project-secret");
184
203
  const engineering = path.join(repo, "docs", "ENGINEERING.md");
204
+ const structureStandard = path.join(repo, "docs", "architecture", "structure-standard.md");
205
+ assert(
206
+ fs.readFileSync(structureStandard, "utf8").startsWith("# Project Structure Standard"),
207
+ "first init must scaffold the project structure standard",
208
+ );
209
+ const customStructureStandard = "# XJMate Structure Standard\n\nProject-owned architecture policy.\n";
210
+ const expectedRiskRules = [
211
+ {
212
+ name: "frontend-manifest-and-extension-policy",
213
+ paths: ["package.json", "frontend/package.json", "frontend/extensions/**"],
214
+ profile: "high-risk",
215
+ review: "required",
216
+ design: "required",
217
+ },
218
+ ];
219
+ const expectedStructure = {
220
+ enabled: false,
221
+ enforcement: "blocking",
222
+ architecture_standard: "xjmate-clean-architecture",
223
+ exclude: ["docs/**"],
224
+ allow_large_files: ["generated/**"],
225
+ reusable_tool_dirs: ["tools/**"],
226
+ max_file_lines_warn: 701,
227
+ max_file_lines_block: 1401,
228
+ max_function_lines_warn: 101,
229
+ max_added_lines_to_large_file: 41,
230
+ require_reuse_search: false,
231
+ block_new_responsibility_in_large_file: false,
232
+ accepted_debt_paths: ["legacy/accepted/**"],
233
+ layer_rules: {
234
+ enabled: false,
235
+ block: true,
236
+ rules: [
237
+ {
238
+ name: "project-domain",
239
+ paths: ["src/domain/**"],
240
+ forbidden_imports: ["src/infrastructure/**"],
241
+ },
242
+ ],
243
+ },
244
+ };
245
+ const customRiskYaml = [
246
+ "risk:",
247
+ " rules:",
248
+ " - name: frontend-manifest-and-extension-policy",
249
+ " paths:",
250
+ " - package.json",
251
+ " - frontend/package.json",
252
+ " - frontend/extensions/**",
253
+ " profile: high-risk",
254
+ " review: required",
255
+ " design: required",
256
+ ].join("\n");
257
+ const customStructureYaml = [
258
+ "structure:",
259
+ " enabled: false",
260
+ " enforcement: blocking",
261
+ " architecture_standard: xjmate-clean-architecture",
262
+ " exclude: [docs/**]",
263
+ " allow_large_files: [generated/**]",
264
+ " reusable_tool_dirs: [tools/**]",
265
+ " max_file_lines_warn: 701",
266
+ " max_file_lines_block: 1401",
267
+ " max_function_lines_warn: 101",
268
+ " max_added_lines_to_large_file: 41",
269
+ " require_reuse_search: false",
270
+ " block_new_responsibility_in_large_file: false",
271
+ " accepted_debt_paths: [legacy/accepted/**]",
272
+ " layer_rules:",
273
+ " enabled: false",
274
+ " block: true",
275
+ " rules:",
276
+ " - name: project-domain",
277
+ " paths: [src/domain/**]",
278
+ " forbidden_imports: [src/infrastructure/**]",
279
+ ].join("\n");
185
280
  writeFile(engineering, fs.readFileSync(engineering, "utf8")
186
281
  .replace("concurrency:\n", "legacy_extra:\n forbidden: true\n\nconcurrency:\n")
282
+ .replace(/^risk:\r?\n[\s\S]*?(?=^structure:)/m, `${customRiskYaml}\n`)
283
+ .replace(/^structure:\r?\n[\s\S]*?(?=^optimization:)/m, `${customStructureYaml}\n`)
187
284
  .replace("# Project Facts", "# Obsolete workflow rules\n\nRun a full build every time.\n\n# Project Facts"));
188
285
  writeFile(path.join(repo, "docs", "legacy", "old-taskbook.md"), "historical\n");
189
286
  writeFile(path.join(repo, "docs", "architecture", "system-context.md"), "# System context\n\nKeep me.\n");
190
287
  writeFile(path.join(repo, "docs", "architecture", "adr", "0042-project-choice.md"), "# ADR-0042\n\nKeep me.\n");
191
288
  writeFile(path.join(repo, "docs", "interfaces", "event-contracts.md"), "# Events\n\nKeep me.\n");
192
- writeFile(path.join(repo, "docs", "architecture", "structure-standard.md"), "# stale managed template\n");
289
+ writeFile(structureStandard, customStructureStandard);
193
290
  writeFile(path.join(repo, ".agents", "agents", "custom.toml"), 'name = "custom"\n');
194
291
  writeFile(path.join(repo, ".agents", "skills", "auto-coding-skill", "obsolete.txt"), "obsolete\n");
195
292
 
@@ -205,17 +302,27 @@ function testInitFullyConvergesExistingProject() {
205
302
  ].sort();
206
303
  assert(JSON.stringify(installedDocs) === JSON.stringify(expectedInstalledDocs), `docs framework must converge while preserving valid artifacts: ${installedDocs.join(", ")}`);
207
304
  const converged = fs.readFileSync(engineering, "utf8");
305
+ const convergedConfig = readEngineeringConfig(engineering);
208
306
  assert(converged.includes("preserved-project-secret"), "supported access values must survive init");
209
307
  assert(!converged.includes("legacy_extra") && !converged.includes("Run a full build every time"), "unknown fields and legacy workflow text must be removed");
308
+ assert(canonicalJson(convergedConfig.risk?.rules) === canonicalJson(expectedRiskRules), "project risk.rules must survive init path-for-path");
309
+ for (const [key, expected] of Object.entries(expectedStructure)) {
310
+ assert(
311
+ canonicalJson(convergedConfig.structure?.[key]) === canonicalJson(expected),
312
+ `supported structure.${key} must survive init`,
313
+ );
314
+ }
210
315
  assert(exists(path.join(repo, ".agents", "agents", "custom.toml")), "project-owned custom agents must survive init");
211
316
  assert(!exists(path.join(repo, ".agents", "skills", "auto-coding-skill", "obsolete.txt")), "extra Skill files must be removed");
212
- assert(exists(path.join(repo, ".agents", "archive", "auto-coding-skill", "4.2.1", "docs", "legacy", "old-taskbook.md")), "removed docs must be archived outside active docs");
213
- assert(fs.readFileSync(path.join(repo, "docs", "architecture", "structure-standard.md"), "utf8").startsWith("# Project Structure Standard"), "managed templates must be replaced");
317
+ assert(exists(path.join(repo, ".agents", "archive", "auto-coding-skill", "4.2.2", "docs", "legacy", "old-taskbook.md")), "removed docs must be archived outside active docs");
318
+ assert(fs.readFileSync(structureStandard, "utf8") === customStructureStandard, "init must preserve a project-owned structure standard");
214
319
  assert(fs.readFileSync(path.join(repo, "docs", "architecture", "adr", "0042-project-choice.md"), "utf8").includes("Keep me"), "numbered ADR artifacts must survive init");
215
320
  assert(fs.readFileSync(path.join(repo, "docs", "architecture", "system-context.md"), "utf8").includes("Keep me"), "architecture artifacts must survive init");
216
321
  assert(fs.readFileSync(path.join(repo, "docs", "interfaces", "event-contracts.md"), "utf8").includes("Keep me"), "interface artifacts must survive init");
217
322
 
218
323
  run("node", [cli, "init"], { cwd: repo });
324
+ assert(fs.readFileSync(engineering, "utf8") === converged, "repeated init must be byte-idempotent for ENGINEERING.md");
325
+ assert(fs.readFileSync(structureStandard, "utf8") === customStructureStandard, "repeated init must preserve the project structure standard byte-for-byte");
219
326
  const secondDocs = listProjectFiles(path.join(repo, "docs"))
220
327
  .map(file => path.relative(repo, file).split(path.sep).join("/"))
221
328
  .sort();
@@ -289,7 +396,7 @@ function testMinimalInitConvergesWithinBudget() {
289
396
  // Integrity, staging, fail-closed classification, and contract helpers are
290
397
  // executable support code, not prompt context. Keep a measured ceiling while
291
398
  // leaving deterministic checks readable.
292
- assert(lines <= 13100, `minimal scaffold line budget exceeded: ${lines}`);
399
+ assert(lines <= 14300, `minimal scaffold line budget exceeded: ${lines}`);
293
400
  const engineering = fs.readFileSync(path.join(repo, "docs", "ENGINEERING.md"), "utf8");
294
401
  assert(engineering.includes("profile: auto"), "engineering should enable adaptive profiles");
295
402
  assert(engineering.includes("isolation: adaptive"), "engineering should default to adaptive clean-branch/worktree isolation");
@@ -309,7 +416,10 @@ function testMinimalInitConvergesWithinBudget() {
309
416
  assert(fixer.includes("不提交、不推送、不集成"), "fixer should leave Git lifecycle to the main agent");
310
417
  assert(reviewer.includes("diff_fingerprint"), "reviewer verdict should bind to a stable diff");
311
418
  assert(reviewer.includes("agent-result-template"), "reviewer should use the complete result skeleton");
419
+ assert(reviewer.includes("AUTOCODING_REVIEW_ASSIGNMENT"), "reviewer should receive the supervised assignment path");
312
420
  assert(reviewer.includes("90 秒"), "reviewer should enforce the focused review budget");
421
+ assert(agentsProtocol.includes("ap.py review-run"), "AGENTS should use the supervised Reviewer runtime");
422
+ assert(agentsProtocol.includes("cannot stop an in-app subagent"), "AGENTS should state the supervision boundary honestly");
313
423
  assert(browserDebugger.includes('sandbox_mode = "read-only"'), "browser discovery should be read-only");
314
424
 
315
425
  const incomplete = run("node", [cli, "status", "--projects", repo, "--json"], { check: false });
@@ -825,7 +935,7 @@ function testManagedEngineeringInitIsAuthoritativeAndIdempotent() {
825
935
 
826
936
  const engineering = path.join(repo, "docs", "ENGINEERING.md");
827
937
  const initial = fs.readFileSync(engineering, "utf8");
828
- const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.2\.1 -->/;
938
+ const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.2\.2 -->/;
829
939
  const endMarker = "<!-- auto-coding-skill:managed-workflow:end -->";
830
940
  assert(startPattern.test(initial), "new projects should include a versioned managed workflow marker");
831
941
  assert(initial.includes(endMarker), "new projects should include the managed workflow end marker");
@@ -839,21 +949,21 @@ function testManagedEngineeringInitIsAuthoritativeAndIdempotent() {
839
949
  const dryRun = run("node", [cli, "sync", "--projects", repo, "--dry-run", "--json"]);
840
950
  const dryResult = JSON.parse(dryRun.stdout).results[0];
841
951
  assert(dryResult.managedWorkflow.state === "stale", `dry-run should expose stale workflow state: ${dryRun.stdout}`);
842
- assert(dryResult.managedWorkflow.version === "4.2.1", "dry-run should expose the target workflow version");
952
+ assert(dryResult.managedWorkflow.version === "4.2.2", "dry-run should expose the target workflow version");
843
953
  assert(dryResult.actions.some(item => item.action === "would-update" && item.path === "docs/ENGINEERING.md"), "dry-run should plan the managed body update");
844
954
  assert(fs.readFileSync(engineering, "utf8") === customized, "dry-run must not write ENGINEERING.md");
845
955
 
846
956
  run("node", [cli, "init"], { cwd: repo });
847
957
  const updated = fs.readFileSync(engineering, "utf8");
848
958
  assert(!updated.includes("project note before") && !updated.includes("project note after"), "init must remove text outside the canonical ENGINEERING body");
849
- assert(updated.includes("version=4.2.1"), "init should install the current managed workflow version");
959
+ assert(updated.includes("version=4.2.2"), "init should install the current managed workflow version");
850
960
  assert(updated.includes("The frontmatter contract is:"), "init should refresh stale managed workflow content");
851
961
 
852
962
  fillRequiredAccess(repo);
853
963
  const status = run("node", [cli, "status", "--projects", repo, "--json"]);
854
964
  const statusResult = JSON.parse(status.stdout).results[0];
855
965
  assert(statusResult.managedWorkflow.state === "current", `status should expose current managed workflow state: ${status.stdout}`);
856
- assert(statusResult.managedWorkflow.version === "4.2.1", "status should expose the installed managed workflow version");
966
+ assert(statusResult.managedWorkflow.version === "4.2.2", "status should expose the installed managed workflow version");
857
967
 
858
968
  const beforeSecondInit = fs.readFileSync(engineering, "utf8");
859
969
  run("node", [cli, "init"], { cwd: repo });
@@ -880,7 +990,7 @@ function testLegacyEngineeringMigrationPreservesExistingBody() {
880
990
  assert(dryResult.actions.find(item => item.path === "docs/ENGINEERING.md")?.detail.includes("preserved-custom"), "custom legacy action should be labeled preserved-custom");
881
991
  run("node", [cli, "sync", "--projects", repo]);
882
992
  const migrated = fs.readFileSync(engineering, "utf8");
883
- assert(migrated.includes("version=4.2.1"), "legacy migration should insert the current managed workflow");
993
+ assert(migrated.includes("version=4.2.2"), "legacy migration should insert the current managed workflow");
884
994
  assert(migrated.includes(legacyNote), "legacy migration must preserve the complete existing body");
885
995
  const stable = fs.readFileSync(engineering, "utf8");
886
996
  run("node", [cli, "sync", "--projects", repo]);
@@ -980,7 +1090,7 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
980
1090
  run("node", [cli, "sync", "--projects", repo]);
981
1091
  const agents = path.join(repo, "AGENTS.md");
982
1092
  const initial = fs.readFileSync(agents, "utf8");
983
- assert(initial.includes("managed-agents:start version=4.2.1"), "new projects should receive the versioned root AGENTS block");
1093
+ assert(initial.includes("managed-agents:start version=4.2.2"), "new projects should receive the versioned root AGENTS block");
984
1094
 
985
1095
  const custom = [
986
1096
  "# Project rules",
@@ -999,12 +1109,12 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
999
1109
 
1000
1110
  run("node", [cli, "sync", "--projects", repo]);
1001
1111
  const migrated = fs.readFileSync(agents, "utf8");
1002
- assert(migrated.includes("managed-agents:start version=4.2.1"), "AGENTS migration should install the current managed block");
1112
+ assert(migrated.includes("managed-agents:start version=4.2.2"), "AGENTS migration should install the current managed block");
1003
1113
  assert(!migrated.includes("Preserve this repository-specific rule exactly."), "root AGENTS must contain no project-specific tail");
1004
1114
  assert(!migrated.includes("must execute `commands.gate_full`"), "known official conflicting rule should be removed");
1005
1115
  const canonical = fs.readFileSync(path.join(repoRoot, "cli", "assets", "skill", "data", "templates", "bridges", "AGENTS.md"), "utf8");
1006
1116
  assert(migrated === canonical, "root AGENTS must be byte-identical to the packaged canonical file");
1007
- const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.2.1.md");
1117
+ const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.2.2.md");
1008
1118
  assert(fs.readFileSync(archive, "utf8").includes("Preserve this repository-specific rule exactly."), "previous AGENTS content must be archived once");
1009
1119
  const stable = fs.readFileSync(agents);
1010
1120
  run("node", [cli, "sync", "--projects", repo]);
@@ -1061,7 +1171,7 @@ function testEngineeringFrameworkRejectsAnyNonCanonicalWorkflowText() {
1061
1171
 
1062
1172
  run("node", [cli, "init"], { cwd: repo });
1063
1173
  assert(!fs.readFileSync(engineering, "utf8").includes("backend owns APIs"), "init must restore the canonical ENGINEERING body");
1064
- const archived = path.join(repo, ".agents", "archive", "auto-coding-skill", "4.2.1", "docs", "ENGINEERING.md");
1174
+ const archived = path.join(repo, ".agents", "archive", "auto-coding-skill", "4.2.2", "docs", "ENGINEERING.md");
1065
1175
  assert(fs.readFileSync(archived, "utf8").includes("backend owns APIs"), "removed project text should remain in non-authoritative history");
1066
1176
  }
1067
1177
 
@@ -1073,12 +1183,12 @@ function testManagedInstallIntegrityIsBoundedAndRepairable() {
1073
1183
 
1074
1184
  const manifestPath = path.join(repo, ".agents", "managed-install.json");
1075
1185
  const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
1076
- assert(manifest.schema_version === 1 && manifest.skill_version === "4.2.1", "installed manifest must identify the release");
1186
+ assert(manifest.schema_version === 1 && manifest.skill_version === "4.2.2", "installed manifest must identify the release");
1077
1187
  assert(manifest.entries.length > 0, "installed manifest must list managed files");
1078
1188
  for (const entry of manifest.entries) {
1079
1189
  assert(typeof entry.path === "string" && !path.isAbsolute(entry.path) && !entry.path.includes(".."), "manifest paths must be safe relative paths");
1080
1190
  assert(/^[0-9a-f]{64}$/.test(entry.sha256), `${entry.path}: manifest hash must be sha256`);
1081
- assert(entry.version === "4.2.1" && typeof entry.executable === "boolean", `${entry.path}: version/executable metadata missing`);
1191
+ assert(entry.version === "4.2.2" && typeof entry.executable === "boolean", `${entry.path}: version/executable metadata missing`);
1082
1192
  }
1083
1193
  assert(!manifest.managed_namespaces.some(item => item.path === ".agents" || item.path === "docs"), "manifest must not mirror entire project-owned trees");
1084
1194
 
@@ -1148,19 +1258,21 @@ function testManagedInstallIntegrityIsBoundedAndRepairable() {
1148
1258
  }
1149
1259
 
1150
1260
  function testReleaseVersionMarkersStayInSync() {
1151
- const expected = "4.2.1";
1261
+ const expected = "4.2.2";
1152
1262
  const pkg = JSON.parse(fs.readFileSync(path.join(repoRoot, "package.json"), "utf8"));
1153
1263
  const lock = JSON.parse(fs.readFileSync(path.join(repoRoot, "package-lock.json"), "utf8"));
1154
1264
  const policy = JSON.parse(fs.readFileSync(
1155
1265
  path.join(repoRoot, "src", "auto-coding-skill", "data", "policies", "workflow-migrations-v1.json"),
1156
1266
  "utf8",
1157
1267
  ));
1158
- assert(pkg.version === expected, "package version must match the 4.2.1 release");
1268
+ assert(pkg.version === expected, "package version must match the 4.2.2 release");
1159
1269
  assert(lock.version === expected && lock.packages[""].version === expected, "package-lock versions must match");
1160
1270
  assert(policy.managed_versions.engineering === expected && policy.managed_versions.agents === expected, "managed workflow versions must match");
1161
1271
  const manifest = JSON.parse(fs.readFileSync(path.join(repoRoot, "cli", "assets", "managed-install.json"), "utf8"));
1162
1272
  assert(manifest.skill_version === expected && manifest.schema_version === 1, "managed install manifest version/schema must match");
1163
1273
  assert(manifest.entries.every(entry => entry.version === expected && /^[0-9a-f]{64}$/.test(entry.sha256)), "managed install entries must carry release hashes and versions");
1274
+ assert(!manifest.entries.some(entry => entry.path === "docs/architecture/structure-standard.md"), "project structure standard must not be exact-managed");
1275
+ assert(manifest.preserved.includes("docs/architecture/structure-standard.md"), "manifest must declare the project structure standard preserved");
1164
1276
  const publishWorkflow = fs.readFileSync(path.join(repoRoot, ".github", "workflows", "npm-publish.yml"), "utf8");
1165
1277
  const runtimeRequirements = fs.readFileSync(path.join(repoRoot, "src", "auto-coding-skill", "requirements.txt"), "utf8");
1166
1278
  assert(publishWorkflow.includes("tags:\n - \"v*\""), "npm publish must run from version tag pushes");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elvis1513/auto-coding-skill",
3
- "version": "4.2.1",
3
+ "version": "4.2.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": {