agentopology 0.5.1 → 0.6.0

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 (121) hide show
  1. package/README.md +5 -5
  2. package/dist/__tests__/e2e/roundtrip.test.d.ts +16 -0
  3. package/dist/__tests__/e2e/roundtrip.test.d.ts.map +1 -0
  4. package/dist/__tests__/e2e/roundtrip.test.js +178 -0
  5. package/dist/__tests__/e2e/roundtrip.test.js.map +1 -0
  6. package/dist/__tests__/e2e/scaffold-owns.test.d.ts +10 -0
  7. package/dist/__tests__/e2e/scaffold-owns.test.d.ts.map +1 -0
  8. package/dist/__tests__/e2e/scaffold-owns.test.js +154 -0
  9. package/dist/__tests__/e2e/scaffold-owns.test.js.map +1 -0
  10. package/dist/__tests__/global-setup.d.ts +7 -0
  11. package/dist/__tests__/global-setup.d.ts.map +1 -0
  12. package/dist/__tests__/global-setup.js +16 -0
  13. package/dist/__tests__/global-setup.js.map +1 -0
  14. package/dist/__tests__/live/claude-code.live.test.d.ts +20 -0
  15. package/dist/__tests__/live/claude-code.live.test.d.ts.map +1 -0
  16. package/dist/__tests__/live/claude-code.live.test.js +136 -0
  17. package/dist/__tests__/live/claude-code.live.test.js.map +1 -0
  18. package/dist/__tests__/live/zz-debug.test.d.ts +2 -0
  19. package/dist/__tests__/live/zz-debug.test.d.ts.map +1 -0
  20. package/dist/__tests__/live/zz-debug.test.js +4 -0
  21. package/dist/__tests__/live/zz-debug.test.js.map +1 -0
  22. package/dist/__tests__/open-findings.test.d.ts +10 -0
  23. package/dist/__tests__/open-findings.test.d.ts.map +1 -0
  24. package/dist/__tests__/open-findings.test.js +37 -0
  25. package/dist/__tests__/open-findings.test.js.map +1 -0
  26. package/dist/__tests__/spec-testing-sync.test.d.ts +10 -0
  27. package/dist/__tests__/spec-testing-sync.test.d.ts.map +1 -0
  28. package/dist/__tests__/spec-testing-sync.test.js +57 -0
  29. package/dist/__tests__/spec-testing-sync.test.js.map +1 -0
  30. package/dist/bindings/__tests__/hook-command.test.d.ts +9 -0
  31. package/dist/bindings/__tests__/hook-command.test.d.ts.map +1 -0
  32. package/dist/bindings/__tests__/hook-command.test.js +88 -0
  33. package/dist/bindings/__tests__/hook-command.test.js.map +1 -0
  34. package/dist/bindings/__tests__/mod-plugin.test.d.ts +9 -0
  35. package/dist/bindings/__tests__/mod-plugin.test.d.ts.map +1 -0
  36. package/dist/bindings/__tests__/mod-plugin.test.js +164 -0
  37. package/dist/bindings/__tests__/mod-plugin.test.js.map +1 -0
  38. package/dist/bindings/claude-code.d.ts +52 -1
  39. package/dist/bindings/claude-code.d.ts.map +1 -1
  40. package/dist/bindings/claude-code.js +306 -68
  41. package/dist/bindings/claude-code.js.map +1 -1
  42. package/dist/bindings/index.d.ts +7 -0
  43. package/dist/bindings/index.d.ts.map +1 -1
  44. package/dist/bindings/index.js +26 -7
  45. package/dist/bindings/index.js.map +1 -1
  46. package/dist/bindings/types.d.ts +6 -0
  47. package/dist/bindings/types.d.ts.map +1 -1
  48. package/dist/bindings/types.js.map +1 -1
  49. package/dist/cli/__tests__/cli.test.d.ts +1 -1
  50. package/dist/cli/__tests__/cli.test.js +1 -1
  51. package/dist/cli/index.js +118 -78
  52. package/dist/cli/index.js.map +1 -1
  53. package/dist/docs/content.d.ts.map +1 -1
  54. package/dist/docs/content.js +39 -3
  55. package/dist/docs/content.js.map +1 -1
  56. package/dist/docs/teach.d.ts.map +1 -1
  57. package/dist/docs/teach.js +36 -0
  58. package/dist/docs/teach.js.map +1 -1
  59. package/dist/import/__tests__/import.test.js +21 -9
  60. package/dist/import/__tests__/import.test.js.map +1 -1
  61. package/dist/import/claude-code.d.ts.map +1 -1
  62. package/dist/import/claude-code.js +128 -44
  63. package/dist/import/claude-code.js.map +1 -1
  64. package/dist/import/serializer.d.ts.map +1 -1
  65. package/dist/import/serializer.js +10 -0
  66. package/dist/import/serializer.js.map +1 -1
  67. package/dist/parser/__tests__/mod-hooks.test.d.ts +10 -0
  68. package/dist/parser/__tests__/mod-hooks.test.d.ts.map +1 -0
  69. package/dist/parser/__tests__/mod-hooks.test.js +136 -0
  70. package/dist/parser/__tests__/mod-hooks.test.js.map +1 -0
  71. package/dist/parser/ast.d.ts +29 -2
  72. package/dist/parser/ast.d.ts.map +1 -1
  73. package/dist/parser/ast.js.map +1 -1
  74. package/dist/parser/index.d.ts +6 -1
  75. package/dist/parser/index.d.ts.map +1 -1
  76. package/dist/parser/index.js +76 -22
  77. package/dist/parser/index.js.map +1 -1
  78. package/dist/parser/paths.d.ts +15 -0
  79. package/dist/parser/paths.d.ts.map +1 -0
  80. package/dist/parser/paths.js +34 -0
  81. package/dist/parser/paths.js.map +1 -0
  82. package/dist/parser/run.d.ts +24 -0
  83. package/dist/parser/run.d.ts.map +1 -0
  84. package/dist/parser/run.js +55 -0
  85. package/dist/parser/run.js.map +1 -0
  86. package/dist/parser/validator.d.ts +12 -0
  87. package/dist/parser/validator.d.ts.map +1 -1
  88. package/dist/parser/validator.js +218 -2
  89. package/dist/parser/validator.js.map +1 -1
  90. package/dist/scaffold/__tests__/safety.test.d.ts +11 -0
  91. package/dist/scaffold/__tests__/safety.test.d.ts.map +1 -0
  92. package/dist/scaffold/__tests__/safety.test.js +184 -0
  93. package/dist/scaffold/__tests__/safety.test.js.map +1 -0
  94. package/dist/scaffold/__tests__/scaffold.test.js +2 -1
  95. package/dist/scaffold/__tests__/scaffold.test.js.map +1 -1
  96. package/dist/scaffold/__tests__/settings-merge.test.js +40 -9
  97. package/dist/scaffold/__tests__/settings-merge.test.js.map +1 -1
  98. package/dist/scaffold/incremental.d.ts +49 -13
  99. package/dist/scaffold/incremental.d.ts.map +1 -1
  100. package/dist/scaffold/incremental.js +235 -95
  101. package/dist/scaffold/incremental.js.map +1 -1
  102. package/dist/scaffold/manifest.d.ts +8 -1
  103. package/dist/scaffold/manifest.d.ts.map +1 -1
  104. package/dist/scaffold/manifest.js +32 -8
  105. package/dist/scaffold/manifest.js.map +1 -1
  106. package/dist/scaffold/merge.d.ts +15 -4
  107. package/dist/scaffold/merge.d.ts.map +1 -1
  108. package/dist/scaffold/merge.js +109 -18
  109. package/dist/scaffold/merge.js.map +1 -1
  110. package/dist/scaffold/types.d.ts +17 -0
  111. package/dist/scaffold/types.d.ts.map +1 -1
  112. package/dist/visualizer/__tests__/gate-connectors.test.d.ts +2 -0
  113. package/dist/visualizer/__tests__/gate-connectors.test.d.ts.map +1 -0
  114. package/dist/visualizer/__tests__/gate-connectors.test.js +88 -0
  115. package/dist/visualizer/__tests__/gate-connectors.test.js.map +1 -0
  116. package/dist/visualizer/index.js +41 -4
  117. package/dist/visualizer/index.js.map +1 -1
  118. package/package.json +1 -1
  119. package/spec/grammar.md +20 -4
  120. package/spec/testing.md +81 -0
  121. package/spec/validation.md +6 -2
@@ -0,0 +1,81 @@
1
+ # Testing spec: what the suite proves
2
+
3
+ Every guarantee has an id. A test carries that id in its name (`[G3] ...`), and
4
+ `src/__tests__/spec-testing-sync.test.ts` fails when an id here has no test, or
5
+ a test names an id that isn't here. Open findings are listed as `it.todo` in
6
+ `src/__tests__/open-findings.test.ts`, so the suite shows what is not yet
7
+ guaranteed instead of hiding it.
8
+
9
+ ## How to run
10
+
11
+ | Suite | Command | Needs |
12
+ |---|---|---|
13
+ | Everything offline (unit, CLI, e2e) | `npx vitest run` | nothing; the build runs first (vitest globalSetup), so tests never see a stale `dist/` |
14
+ | Live Claude Code | `AT_LIVE=1 npx vitest run src/__tests__/live` | the `claude` CLI; one small haiku call per project; `AT_CLAUDE_BIN` overrides the binary |
15
+
16
+ Run the live suite before every release, and after any change to a binding.
17
+
18
+ ## Guarantees
19
+
20
+ | Id | Guarantee | Where |
21
+ |---|---|---|
22
+ | G1 | The first scaffold keeps a file it did not create (conflict, kept unless `--force`) | e2e/scaffold-owns.test.ts |
23
+ | G2 | Scaffold never writes or deletes through a symlink, even with `--force` | e2e/scaffold-owns.test.ts |
24
+ | G3 | Re-scaffolding keeps the user's hooks, `ask`, `defaultMode` and other permission keys | e2e/scaffold-owns.test.ts |
25
+ | G4 | A second scaffold with no changes writes nothing | e2e/scaffold-owns.test.ts |
26
+ | G5 | `--dry-run` writes nothing | e2e/scaffold-owns.test.ts |
27
+ | G6 | Prose in a gate's `run` fails validate (V96) and scaffold, and nothing is written | e2e/scaffold-owns.test.ts |
28
+ | G7 | An edited file that scaffold owns is kept on the next run | e2e/scaffold-owns.test.ts |
29
+ | G8 | `--prune` removes untouched leftovers and keeps edited ones | e2e/scaffold-owns.test.ts |
30
+ | G9 | Two topologies in one project keep separate manifests | e2e/scaffold-owns.test.ts |
31
+ | G10 | No `${…}` reference or `#`-key reaches settings `env` (Claude Code applies env literally) | e2e/scaffold-owns.test.ts |
32
+ | G11 | An unsafe generated path aborts the run before any file is written | scaffold/__tests__/safety.test.ts |
33
+ | G12 | A second scaffold of an imported project changes nothing | e2e/roundtrip.test.ts |
34
+ | G13 | An agent's `extensions` never leak into project-wide settings (only a topology-level `extensions` block is top-level) | e2e/roundtrip.test.ts |
35
+ | G14 | An imported hook and its compiled form (`$CLAUDE_PROJECT_DIR`) merge as one hook, not two | e2e/roundtrip.test.ts |
36
+ | G15 | V97 refuses a `file:` outside the project | e2e/roundtrip.test.ts |
37
+ | G16 | Scaffold names every hand-written `file:` the project lacks | e2e/roundtrip.test.ts |
38
+ | G17 | V11 does not demand a flow path for an on-demand (`invocation: manual`) agent | e2e/roundtrip.test.ts |
39
+ | R1 | Import then scaffold keeps every hand-built file (was: 37 of 72 missing) | e2e/roundtrip.test.ts |
40
+ | R2 | Import then scaffold leaves every hand-built file byte-identical, settings.json included (was: 2,957 lines cut to 1,706) | e2e/roundtrip.test.ts |
41
+ | R3 | The imported .at validates with no errors (was: 22) | e2e/roundtrip.test.ts |
42
+ | R4 | Import keeps frontmatter the language has no field for, comma-string lists, and the real `permissions` block | e2e/roundtrip.test.ts |
43
+ | A4 | Agents, groups, skills and commands found on disk are imported with `file:` and never generated | e2e/roundtrip.test.ts |
44
+ | F3 | `--allow-invalid` compiles despite validation errors; `--force` only overwrites kept files | e2e/roundtrip.test.ts |
45
+ | C5 | A hook's own script is created only when missing: never overwritten (even with `--force`), reported or claimed | e2e/roundtrip.test.ts |
46
+ | L2 | Real Claude Code loads a hand-built project after import then scaffold | live/claude-code.live.test.ts |
47
+ | L1 | Real Claude Code loads every scaffolded example: every agent, skill and command registers, and the session succeeds | live/claude-code.live.test.ts |
48
+
49
+ ## Open findings (not yet guaranteed)
50
+
51
+ Each is an `it.todo` with the same id. When one is fixed, its todo becomes a
52
+ real test and the row moves to Guarantees. Source: the compile audit,
53
+ 2026-10-28/29 (plan page and `.history/2026-10-28-content-harness-gaps.md`).
54
+
55
+ | Id | Finding | Phase |
56
+ |---|---|---|
57
+ | N11 | sync pulls generated prose back into the .at, so the prompt grows each cycle | 2 |
58
+ | N12 | A skill `prompt: "path"` emits `See: path`; the instructions never reach Claude | 2 |
59
+ | A3 | `kind: external` actions ignore `commands:` and emit a TODO stub | 3 |
60
+ | A3b | Tools with a real `script:` get stub copies | 3 |
61
+ | B4 | Schedule scripts call the wrong action path; `every:` becomes a commented-out cron line | 3 |
62
+ | H1 | Human nodes compile to frontmatter-less AGENT.md files that Claude Code ignores; they should be an approval step | 3 |
63
+ | N4 | `.mcp.json` drops `type`, so a url server is skipped | 3 |
64
+ | N5 | `type: prompt` hooks are emitted as commands | 3 |
65
+ | N6 | Universal events (AgentStop, ToolUse, Error) are emitted unmapped, so the hook never fires | 3 |
66
+ | N7 | MCP tool names: whole-server and dotted names mis-converted; permissions not converted | 3 |
67
+ | N8 | V27 accepts `confirm` and `bypass`, emitted as invalid `permissionMode` | 3 |
68
+ | N9 | A hook matcher with a regex breaks the agent file's YAML | 3 |
69
+ | N10 | `invocation: manual` drops the description, so the agent is not registered | 3 |
70
+ | N14 | `settings.ask` is parsed but never emitted | 3 |
71
+ | N16 | Model ids are not checked per target | 3 |
72
+ | N17 | Unquoted YAML scalars change type (`yes` becomes `true`) | 3 |
73
+ | N18 | No reference checks for `skills:`, `mcp-servers:`, skill `agent:` | 3 |
74
+ | N19 | Hook stubs carry the date, so output is not byte-stable | 3 |
75
+ | C1 | `scaffold --dry-run` says settings.json and .mcp.json would be "config merged" but does not show the diff (content session, 2026-10-29) | 3 |
76
+ | C2 | Scaffold adds `.claude/CLAUDE.md`, which competes with a project's root CLAUDE.md (content session, 2026-10-29) | 3 |
77
+ | C3 | Run-line parsing takes placeholders and file arguments as scripts (`SLUG`, `frames-critic.json`) and plans stubs for them (content session, 2026-10-29) | 3 |
78
+ | C4 | A gate whose `after:` is an action or a human compiles to no enforceable hook (10 gates in content-harness) | 3 |
79
+ | B5 | An agent's permissions read as per-agent grants; Claude Code allow rules are session-wide | 4 |
80
+ | F1 | Missing first-class fields: agent effort, initialPrompt, omitClaudeMd, cache TTL, color; skill when_to_use, arguments, paths, shell | 4 |
81
+ | F2 | Hooks as a typed union (http, mcp_tool, agent; once, async, if) | 4 |
@@ -665,7 +665,7 @@ agent researcher {
665
665
 
666
666
  ## Summary Table
667
667
 
668
- All 93 rules, generated from `src/parser/validator.ts` so the spec cannot drift
668
+ All 97 rules, generated from `src/parser/validator.ts` so the spec cannot drift
669
669
  from the implementation. Rules V8, V12, V23, V24, V89 and V90 are collected at
670
670
  **parse time** — the misuse they catch leaves no trace in the AST — and surfaced
671
671
  through the validator like any other rule.
@@ -684,7 +684,7 @@ through the validator like any other rule.
684
684
  | V8 | error/warning | Import references should resolve (warning only -- we cannot check the filesystem) |
685
685
  | V9 | error/warning | Every action referenced in flow must appear in orchestrator.handles |
686
686
  | V10 | error/warning | Prompt content should not be empty if a prompt block is declared |
687
- | V11 | error | If agent A writes X and agent B reads X, a path A -> B must exist in flow |
687
+ | V11 | error | If agent A writes X and agent B reads X, a path A -> B must exist in flow — unless either is on demand (`invocation: manual`), which has no flow by definition |
688
688
  | V12 | error | Edge attribute order must be [when, max, per] |
689
689
  | V13 | error | Gate `after` and `before` must reference declared nodes |
690
690
  | V14 | error | `tools` and `disallowed-tools` cannot both appear on the same agent |
@@ -767,6 +767,10 @@ through the validator like any other rule.
767
767
  | V91 | error | A required field must not be satisfied by a parser-injected placeholder — `meta.version` and `orchestrator.model` are required, and their sentinels (`0.0.0`, `unknown`) satisfied every downstream check |
768
768
  | V92 | error | An edge's attributes go in ONE bracket, comma-separated — `[when ...] [max N]` produced a condition string containing brackets, silently |
769
769
  | V93 | warning | An edge between two agents that both declare paths should declare a handoff — `writer.writes \| reader.reads` empty means the receiver runs after the sender with none of its output |
770
+ | V94 | error | A hook's `type` is `command`, `prompt` or `mod`; `flag:` belongs only to a mod and is an env variable name — `type: mod` passed silently and was scaffolded as a bash command |
771
+ | V95 | error | A hook's `on:` must fit its type — a mod takes a known engine event (`tool.call`, `prompt.submit`; five more seen in the engine warn as unproven), a command/prompt hook a PascalCase event |
772
+ | V96 | error | A gate or hook `run` must be a command, not prose — a sentence there compiled to junk script files (`E;`, `fail:`) and crashed scaffold with EISDIR; the explanation belongs in `description` |
773
+ | V97 | error | A node, skill or command `file:` must be a project-relative path (no `..`, not absolute, safe names) — it marks hand-written internals scaffold never writes, so it must be a path scaffold can honour |
770
774
 
771
775
  > Sections above document the first 35 rules with worked examples. The rest are
772
776
  > single-line entries here plus their doc comment in the source. Adding an