@elvis1513/auto-coding-skill 4.3.7 → 5.0.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.
Files changed (34) hide show
  1. package/README.md +30 -761
  2. package/cli/assets/managed-install.json +42 -1
  3. package/cli/assets/skill/SKILL.md +17 -100
  4. package/cli/assets/skill/data/templates/ENVIRONMENT.md +34 -0
  5. package/cli/assets/skill/data/templates/PROJECT.md +30 -0
  6. package/cli/assets/skill/data/templates/architecture/.gitkeep +1 -0
  7. package/cli/assets/skill/data/templates/bridges/AGENTS.md +52 -157
  8. package/cli/assets/skill/data/templates/deployment/.gitkeep +1 -0
  9. package/cli/assets/skill/data/templates/design/.gitkeep +1 -0
  10. package/cli/assets/skill/data/templates/interfaces/.gitkeep +1 -0
  11. package/cli/assets/skill/data/templates/product/.gitkeep +1 -0
  12. package/cli/src/index.js +154 -2585
  13. package/cli/src/sync-assets.js +38 -95
  14. package/package.json +9 -17
  15. package/cli/assets/agents/browser-debugger.toml +0 -27
  16. package/cli/assets/agents/docs-researcher.toml +0 -18
  17. package/cli/assets/agents/explorer.toml +0 -26
  18. package/cli/assets/agents/fixer.toml +0 -29
  19. package/cli/assets/agents/reviewer.toml +0 -50
  20. package/cli/assets/skill/data/contracts/orchestration-v1.schema.json +0 -567
  21. package/cli/assets/skill/data/policies/feedback-resolutions-v1.json +0 -68
  22. package/cli/assets/skill/data/policies/workflow-migrations-v1.json +0 -657
  23. package/cli/assets/skill/data/templates/ENGINEERING.md +0 -115
  24. package/cli/assets/skill/data/templates/tools/ap.py +0 -16
  25. package/cli/assets/skill/requirements.txt +0 -1
  26. package/cli/assets/skill/scripts/ap.py +0 -17791
  27. package/cli/assets/skill/scripts/core.py +0 -510
  28. package/cli/assets/skill/scripts/http_checks.py +0 -92
  29. package/cli/assets/skill/scripts/install_integrity.py +0 -427
  30. package/cli/assets/skill/scripts/scaffold_templates.py +0 -325
  31. package/cli/tests/ap_concurrency_test.py +0 -3602
  32. package/cli/tests/ap_profiles_test.py +0 -3272
  33. package/cli/tests/core_shell_test.py +0 -345
  34. package/cli/tests/index.test.js +0 -2967
@@ -1,427 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Generate and verify the bounded auto-coding-skill install manifest."""
3
-
4
- from __future__ import annotations
5
-
6
- import argparse
7
- import hashlib
8
- import json
9
- import os
10
- import re
11
- import stat
12
- import sys
13
- import tomllib
14
- from pathlib import Path
15
- from typing import Any
16
-
17
- from scaffold_templates import (
18
- MANAGED_FRAMEWORK_DOCS,
19
- PROJECT_FEEDBACK_PATTERNS,
20
- PROJECT_OWNED_DOC_ROOTS,
21
- templates_for,
22
- )
23
-
24
-
25
- SCHEMA_VERSION = 1
26
- MANIFEST_PATH = Path(".agents/managed-install.json")
27
- SKIPPED_NAMES = {"__pycache__", ".DS_Store"}
28
- SKIPPED_SUFFIXES = {".pyc", ".pyo", ".pyd"}
29
- STRATEGIES = {"exact", "normalized-agent", "managed-workflow"}
30
-
31
-
32
- def _is_generated_noise(path: Path) -> bool:
33
- return any(part in SKIPPED_NAMES for part in path.parts) or path.suffix.lower() in SKIPPED_SUFFIXES
34
-
35
-
36
- def _files(root: Path) -> list[Path]:
37
- if not root.exists():
38
- return []
39
- return sorted(
40
- (path for path in root.rglob("*") if path.is_file() and not _is_generated_noise(path.relative_to(root))),
41
- key=lambda path: path.relative_to(root).as_posix(),
42
- )
43
-
44
-
45
- def _sha256(data: bytes) -> str:
46
- return hashlib.sha256(data).hexdigest()
47
-
48
-
49
- def _is_escaped(text: str, index: int) -> bool:
50
- slashes = 0
51
- index -= 1
52
- while index >= 0 and text[index] == "\\":
53
- slashes += 1
54
- index -= 1
55
- return slashes % 2 == 1
56
-
57
-
58
- def _next_multiline_state(line: str, initial: str) -> str:
59
- state = initial
60
- quote = ""
61
- index = 0
62
- while index < len(line):
63
- if state:
64
- close = line.find(state, index)
65
- if close < 0:
66
- return state
67
- if state == '\"\"\"' and _is_escaped(line, close):
68
- index = close + 3
69
- continue
70
- state = ""
71
- index = close + 3
72
- continue
73
- if quote:
74
- if line[index] == quote and (quote == "'" or not _is_escaped(line, index)):
75
- quote = ""
76
- index += 1
77
- continue
78
- if line[index] == "#":
79
- return state
80
- triple = line[index:index + 3]
81
- if triple in {'\"\"\"', "'''"}:
82
- state = triple
83
- index += 3
84
- continue
85
- if line[index] in {'\"', "'"}:
86
- quote = line[index]
87
- index += 1
88
- return state
89
-
90
-
91
- def normalize_managed_agent(text: str) -> str:
92
- """Remove the one supported top-level model override, preserving all other bytes."""
93
- try:
94
- parsed = tomllib.loads(text)
95
- except tomllib.TOMLDecodeError as exc:
96
- raise ValueError(f"invalid managed agent TOML: {exc}") from exc
97
- if "model" in parsed and (not isinstance(parsed["model"], str) or not parsed["model"].strip()):
98
- raise ValueError("model must be a non-empty TOML string")
99
- lines = text.replace("\r\n", "\n").split("\n")
100
- matches: list[int] = []
101
- multiline = ""
102
- in_table = False
103
- pattern = re.compile(r"^\s*(?:model|\"model\"|'model')\s*=\s*(.+)$")
104
- for index, line in enumerate(lines):
105
- if not multiline:
106
- trimmed = line.lstrip()
107
- if trimmed.startswith("[") and not trimmed.startswith("[#"):
108
- in_table = True
109
- if not in_table and pattern.match(line):
110
- matches.append(index)
111
- multiline = _next_multiline_state(line, multiline)
112
- if len(matches) > 1:
113
- raise ValueError("model is defined more than once")
114
- if matches:
115
- del lines[matches[0]]
116
- return "\n".join(lines)
117
-
118
-
119
- def managed_workflow_region(text: str) -> str:
120
- normalized = text.replace("\r\n", "\n")
121
- start = list(re.finditer(
122
- r"<!--\s*auto-coding-skill:managed-workflow:start\s+version=[0-9]+\.[0-9]+\.[0-9]+\s*-->",
123
- normalized,
124
- ))
125
- end = list(re.finditer(r"<!--\s*auto-coding-skill:managed-workflow:end\s*-->", normalized))
126
- if len(start) != 1 or len(end) != 1 or start[0].start() >= end[0].start():
127
- raise ValueError("managed workflow markers are missing or malformed")
128
- return normalized[start[0].start():end[0].end()]
129
-
130
-
131
- def _entry(
132
- *,
133
- target: str,
134
- source: str,
135
- strategy: str,
136
- data: bytes,
137
- executable: bool,
138
- scope: str,
139
- version: str,
140
- ) -> dict[str, Any]:
141
- return {
142
- "path": target,
143
- "source": source,
144
- "ownership": strategy,
145
- "sha256": _sha256(data),
146
- "executable": executable,
147
- "scope": scope,
148
- "version": version,
149
- }
150
-
151
-
152
- def build_manifest(skill_root: Path, agents_root: Path, version: str) -> dict[str, Any]:
153
- entries: list[dict[str, Any]] = []
154
- for source_path in _files(skill_root):
155
- rel = source_path.relative_to(skill_root).as_posix()
156
- entries.append(_entry(
157
- target=f".agents/skills/auto-coding-skill/{rel}",
158
- source=f"skill/{rel}",
159
- strategy="exact",
160
- data=source_path.read_bytes(),
161
- executable=bool(source_path.stat().st_mode & 0o111),
162
- scope="shared",
163
- version=version,
164
- ))
165
- for source_path in _files(agents_root):
166
- rel = source_path.relative_to(agents_root).as_posix()
167
- normalized = normalize_managed_agent(source_path.read_text(encoding="utf-8")).encode("utf-8")
168
- entries.append(_entry(
169
- target=f".agents/agents/{rel}",
170
- source=f"agents/{rel}",
171
- strategy="normalized-agent",
172
- data=normalized,
173
- executable=bool(source_path.stat().st_mode & 0o111),
174
- scope="shared",
175
- version=version,
176
- ))
177
-
178
- exact_project_sources = {
179
- "AGENTS.md": skill_root / "data/templates/bridges/AGENTS.md",
180
- "docs/tools/autopipeline/ap.py": skill_root / "data/templates/tools/ap.py",
181
- }
182
- for target, source_path in exact_project_sources.items():
183
- rel = source_path.relative_to(skill_root).as_posix()
184
- entries.append(_entry(
185
- target=target,
186
- source=f"skill/{rel}",
187
- strategy="exact",
188
- data=source_path.read_bytes(),
189
- executable=bool(source_path.stat().st_mode & 0o111),
190
- scope="project",
191
- version=version,
192
- ))
193
-
194
- engineering = skill_root / "data/templates/ENGINEERING.md"
195
- entries.append(_entry(
196
- target="docs/ENGINEERING.md",
197
- source="skill/data/templates/ENGINEERING.md",
198
- strategy="exact",
199
- data=engineering.read_bytes(),
200
- executable=bool(engineering.stat().st_mode & 0o111),
201
- scope="project",
202
- version=version,
203
- ))
204
-
205
- templates = templates_for("all")
206
- for target in sorted(MANAGED_FRAMEWORK_DOCS):
207
- entries.append(_entry(
208
- target=target,
209
- source=f"generated:scaffold_templates:{target}",
210
- strategy="exact",
211
- data=templates[target].encode("utf-8"),
212
- executable=False,
213
- scope="project",
214
- version=version,
215
- ))
216
-
217
- entries.sort(key=lambda item: item["path"])
218
- if len({item["path"] for item in entries}) != len(entries):
219
- raise ValueError("managed install manifest contains duplicate paths")
220
- return {
221
- "schema_version": SCHEMA_VERSION,
222
- "skill_version": version,
223
- "manifest_path": MANIFEST_PATH.as_posix(),
224
- "entries": entries,
225
- "managed_namespaces": [
226
- {"path": ".agents/skills/auto-coding-skill", "scope": "shared"},
227
- {"path": "docs/tools/autopipeline", "scope": "project"},
228
- ],
229
- "preserved": [
230
- ".agents/archive/**",
231
- ".agents/agents/* (except paths listed in entries)",
232
- "docs/project/auto-coding-skill.yaml",
233
- "docs/architecture/structure-standard.md",
234
- *(f"{root}/** (except exact-managed entries)" for root in PROJECT_OWNED_DOC_ROOTS),
235
- *PROJECT_FEEDBACK_PATTERNS,
236
- ],
237
- }
238
-
239
-
240
- def render_manifest(manifest: dict[str, Any]) -> str:
241
- return json.dumps(manifest, ensure_ascii=False, separators=(",", ":")) + "\n"
242
-
243
-
244
- def _safe_relative_path(raw: Any) -> Path:
245
- if not isinstance(raw, str) or not raw or "\\" in raw:
246
- raise ValueError("path must be a non-empty POSIX relative path")
247
- path = Path(raw)
248
- if path.is_absolute() or any(part in {"", ".", ".."} for part in path.parts):
249
- raise ValueError("path must not be absolute or contain traversal")
250
- return path
251
-
252
-
253
- def _load_manifest(path: Path) -> dict[str, Any]:
254
- try:
255
- value = json.loads(path.read_text(encoding="utf-8"))
256
- except FileNotFoundError as exc:
257
- raise ValueError(f"missing manifest: {path}") from exc
258
- except (OSError, json.JSONDecodeError) as exc:
259
- raise ValueError(f"invalid manifest {path}: {exc}") from exc
260
- if not isinstance(value, dict) or value.get("schema_version") != SCHEMA_VERSION:
261
- raise ValueError("managed install manifest schema_version must be 1")
262
- return value
263
-
264
-
265
- def verify_managed_install(
266
- repo: Path,
267
- *,
268
- mode: str = "project",
269
- expected_version: str | None = None,
270
- manifest_path: Path | None = None,
271
- ) -> dict[str, Any]:
272
- repo = repo.resolve()
273
- errors: list[str] = []
274
- manifest_file = manifest_path or repo / MANIFEST_PATH
275
- try:
276
- manifest = _load_manifest(manifest_file)
277
- except ValueError as exc:
278
- return {"ok": False, "version": "", "checked": 0, "errors": [str(exc)]}
279
-
280
- version = manifest.get("skill_version")
281
- if not isinstance(version, str) or not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+", version):
282
- errors.append("manifest skill_version must be a semantic version")
283
- version = ""
284
- if expected_version and version != expected_version:
285
- errors.append(f"manifest version {version or '<invalid>'} does not match expected {expected_version}")
286
- if manifest.get("manifest_path") != MANIFEST_PATH.as_posix():
287
- errors.append(f"manifest_path must be {MANIFEST_PATH.as_posix()}")
288
-
289
- raw_entries = manifest.get("entries")
290
- if not isinstance(raw_entries, list):
291
- return {"ok": False, "version": version, "checked": 0, "errors": errors + ["manifest entries must be a list"]}
292
-
293
- entries: list[tuple[dict[str, Any], Path]] = []
294
- seen: set[str] = set()
295
- for index, entry in enumerate(raw_entries):
296
- label = f"entries[{index}]"
297
- if not isinstance(entry, dict):
298
- errors.append(f"{label} must be an object")
299
- continue
300
- try:
301
- rel = _safe_relative_path(entry.get("path"))
302
- except ValueError as exc:
303
- errors.append(f"{label}: {exc}")
304
- continue
305
- rel_text = rel.as_posix()
306
- if rel_text in seen:
307
- errors.append(f"duplicate managed path: {rel_text}")
308
- continue
309
- seen.add(rel_text)
310
- if entry.get("ownership") not in STRATEGIES:
311
- errors.append(f"{rel_text}: unknown ownership strategy")
312
- if entry.get("scope") not in {"shared", "project"}:
313
- errors.append(f"{rel_text}: scope must be shared or project")
314
- if entry.get("version") != version:
315
- errors.append(f"{rel_text}: entry version does not match manifest")
316
- if not isinstance(entry.get("sha256"), str) or not re.fullmatch(r"[0-9a-f]{64}", entry["sha256"]):
317
- errors.append(f"{rel_text}: invalid sha256")
318
- if not isinstance(entry.get("executable"), bool):
319
- errors.append(f"{rel_text}: executable must be boolean")
320
- entries.append((entry, rel))
321
-
322
- active_scopes = {"shared"} | ({"project"} if mode == "project" else set())
323
- checked = 0
324
- active_paths: set[str] = set()
325
- for entry, rel in entries:
326
- if entry.get("scope") not in active_scopes:
327
- continue
328
- target = repo / rel
329
- rel_text = rel.as_posix()
330
- active_paths.add(rel_text)
331
- if target.is_symlink():
332
- errors.append(f"{rel_text}: managed target must not be a symlink")
333
- continue
334
- if not target.is_file():
335
- errors.append(f"{rel_text}: managed file is missing")
336
- continue
337
- checked += 1
338
- try:
339
- strategy = entry.get("ownership")
340
- if strategy == "exact":
341
- material = target.read_bytes()
342
- elif strategy == "normalized-agent":
343
- material = normalize_managed_agent(target.read_text(encoding="utf-8")).encode("utf-8")
344
- elif strategy == "managed-workflow":
345
- material = managed_workflow_region(target.read_text(encoding="utf-8")).encode("utf-8")
346
- else:
347
- continue
348
- except (OSError, UnicodeError, ValueError) as exc:
349
- errors.append(f"{rel_text}: cannot normalize managed content: {exc}")
350
- continue
351
- if _sha256(material) != entry.get("sha256"):
352
- errors.append(f"{rel_text}: managed content drift")
353
- if os.name != "nt":
354
- actual_executable = bool(stat.S_IMODE(target.stat().st_mode) & 0o111)
355
- if actual_executable != entry.get("executable"):
356
- errors.append(f"{rel_text}: executable bit drift")
357
-
358
- namespaces = manifest.get("managed_namespaces")
359
- if not isinstance(namespaces, list):
360
- errors.append("managed_namespaces must be a list")
361
- namespaces = []
362
- for index, namespace in enumerate(namespaces):
363
- if not isinstance(namespace, dict) or namespace.get("scope") not in active_scopes:
364
- continue
365
- try:
366
- rel = _safe_relative_path(namespace.get("path"))
367
- except ValueError as exc:
368
- errors.append(f"managed_namespaces[{index}]: {exc}")
369
- continue
370
- root = repo / rel
371
- if not root.is_dir():
372
- errors.append(f"{rel.as_posix()}: managed namespace is missing")
373
- continue
374
- expected = {path for path in active_paths if path.startswith(rel.as_posix() + "/")}
375
- actual = {
376
- candidate.relative_to(repo).as_posix()
377
- for candidate in root.rglob("*")
378
- if (candidate.is_file() or candidate.is_symlink())
379
- and not _is_generated_noise(candidate.relative_to(root))
380
- }
381
- for extra in sorted(actual - expected):
382
- errors.append(f"{extra}: unexpected file in managed namespace")
383
-
384
- return {"ok": not errors, "version": version, "checked": checked, "errors": errors}
385
-
386
-
387
- def _main(argv: list[str]) -> int:
388
- parser = argparse.ArgumentParser(description=__doc__)
389
- commands = parser.add_subparsers(dest="command", required=True)
390
- generate = commands.add_parser("generate")
391
- generate.add_argument("--skill-root", required=True)
392
- generate.add_argument("--agents-root", required=True)
393
- generate.add_argument("--version", required=True)
394
- generate.add_argument("--output")
395
- verify = commands.add_parser("verify")
396
- verify.add_argument("--repo", required=True)
397
- verify.add_argument("--mode", choices=("project", "global"), default="project")
398
- verify.add_argument("--expected-version")
399
- verify.add_argument("--manifest")
400
- verify.add_argument("--json", action="store_true")
401
- args = parser.parse_args(argv)
402
- if args.command == "generate":
403
- rendered = render_manifest(build_manifest(Path(args.skill_root), Path(args.agents_root), args.version))
404
- if args.output:
405
- Path(args.output).write_text(rendered, encoding="utf-8")
406
- else:
407
- sys.stdout.write(rendered)
408
- return 0
409
- result = verify_managed_install(
410
- Path(args.repo),
411
- mode=args.mode,
412
- expected_version=args.expected_version,
413
- manifest_path=Path(args.manifest) if args.manifest else None,
414
- )
415
- if args.json:
416
- print(json.dumps(result, ensure_ascii=False))
417
- elif result["ok"]:
418
- print(f"[install-integrity] OK version={result['version']} files={result['checked']}")
419
- else:
420
- print("[install-integrity] FAILED", file=sys.stderr)
421
- for error in result["errors"]:
422
- print(f"- {error}", file=sys.stderr)
423
- return 0 if result["ok"] else 2
424
-
425
-
426
- if __name__ == "__main__":
427
- raise SystemExit(_main(sys.argv[1:]))