leos-agent 7.0.0 → 10.2.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 (96) hide show
  1. package/README.md +544 -28
  2. package/commands/handoff.md +11 -0
  3. package/commands/handon.md +10 -0
  4. package/commands/review-pr.md +9 -0
  5. package/commands-claude/watch-review.md +9 -0
  6. package/index.js +12 -0
  7. package/package.json +29 -14
  8. package/payload/codex-agents/leo-executor.toml +36 -0
  9. package/payload/codex-agents/leo-runner.toml +28 -0
  10. package/rules/preferences.md +97 -0
  11. package/scripts/check.py +244 -0
  12. package/scripts/ghreview.py +17 -3
  13. package/scripts/handoff.py +183 -0
  14. package/scripts/leo-install.py +509 -0
  15. package/scripts/measure_context.py +113 -0
  16. package/scripts/publish-npm.py +138 -0
  17. package/scripts/watch_review.py +169 -0
  18. package/skills/doctor/SKILL.md +73 -115
  19. package/skills/doctor/agents/openai.yaml +5 -0
  20. package/skills/handoff/SKILL.md +99 -0
  21. package/skills/handoff/agents/openai.yaml +5 -0
  22. package/skills/handon/SKILL.md +61 -0
  23. package/skills/install/SKILL.md +79 -0
  24. package/skills/install/agents/openai.yaml +5 -0
  25. package/skills/review-pr/SKILL.md +59 -318
  26. package/skills/review-pr/reference/lenses.md +67 -0
  27. package/skills/review-pr/reference/procedure.md +348 -0
  28. package/skills-claude/attach-pr/SKILL.md +178 -0
  29. package/skills-claude/watch-review/SKILL.md +91 -0
  30. package/adapters/cursor/agents/executor.md +0 -17
  31. package/adapters/cursor/agents/expert.md +0 -70
  32. package/adapters/cursor/agents/explore.md +0 -16
  33. package/adapters/cursor/agents/implementer.md +0 -18
  34. package/adapters/cursor/agents/investigator.md +0 -18
  35. package/adapters/cursor/agents/planner.md +0 -28
  36. package/adapters/cursor/agents/review-lens.md +0 -22
  37. package/adapters/cursor/agents/reviewer.md +0 -34
  38. package/adapters/opencode/agents.json +0 -105
  39. package/adapters/opencode/plugin.js +0 -576
  40. package/config/MCP_PINS.md +0 -17
  41. package/config/models.json +0 -676
  42. package/hooks/bash-guard.py +0 -583
  43. package/hooks/cursor-guard.py +0 -84
  44. package/hooks/hooks-cursor.json +0 -11
  45. package/hooks/hooks.json +0 -20
  46. package/hooks/session-start.py +0 -148
  47. package/roles/executor.md +0 -15
  48. package/roles/expert.md +0 -67
  49. package/roles/explore.md +0 -13
  50. package/roles/implementer.md +0 -16
  51. package/roles/investigator.md +0 -15
  52. package/roles/planner.md +0 -25
  53. package/roles/review-lens.md +0 -20
  54. package/roles/reviewer.md +0 -31
  55. package/scripts/doctor.py +0 -520
  56. package/scripts/jsonc_bridge.cjs +0 -23
  57. package/scripts/memory.py +0 -744
  58. package/scripts/render_adapters.py +0 -508
  59. package/scripts/setup.py +0 -1753
  60. package/settings.json +0 -7
  61. package/skills/.gitkeep +0 -0
  62. package/skills/brainstorming/SKILL.md +0 -111
  63. package/skills/debugging/SKILL.md +0 -100
  64. package/skills/delegation/SKILL.md +0 -143
  65. package/skills/executing-plans/SKILL.md +0 -117
  66. package/skills/finishing-a-branch/SKILL.md +0 -125
  67. package/skills/freshness/SKILL.md +0 -131
  68. package/skills/memory/SKILL.md +0 -154
  69. package/skills/resolve-ticket/SKILL.md +0 -275
  70. package/skills/setup/SKILL.md +0 -199
  71. package/skills/setup/agents/openai.yaml +0 -5
  72. package/skills/test-first/SKILL.md +0 -92
  73. package/skills/using-leo/SKILL.md +0 -101
  74. package/skills/using-leo/references/claude-mapping.md +0 -33
  75. package/skills/using-leo/references/codex-mapping.md +0 -33
  76. package/skills/using-leo/references/cursor-mapping.md +0 -35
  77. package/skills/using-leo/references/hermes-mapping.md +0 -37
  78. package/skills/using-leo/references/opencode-mapping.md +0 -39
  79. package/skills/verification/SKILL.md +0 -110
  80. package/skills/visual-verification/SKILL.md +0 -115
  81. package/skills/watch-review/SKILL.md +0 -128
  82. package/skills/watch-review/agents/openai.yaml +0 -5
  83. package/skills/worktrees/SKILL.md +0 -131
  84. package/skills/writing-plans/SKILL.md +0 -97
  85. package/skills/writing-skills/SKILL.md +0 -141
  86. package/vendor/jsonc-parser-3.3.1/LICENSE.md +0 -21
  87. package/vendor/jsonc-parser-3.3.1/README.md +0 -26
  88. package/vendor/jsonc-parser-3.3.1/lib/umd/impl/edit.js +0 -201
  89. package/vendor/jsonc-parser-3.3.1/lib/umd/impl/format.js +0 -275
  90. package/vendor/jsonc-parser-3.3.1/lib/umd/impl/parser.js +0 -682
  91. package/vendor/jsonc-parser-3.3.1/lib/umd/impl/scanner.js +0 -456
  92. package/vendor/jsonc-parser-3.3.1/lib/umd/impl/string-intern.js +0 -42
  93. package/vendor/jsonc-parser-3.3.1/lib/umd/main.d.ts +0 -351
  94. package/vendor/jsonc-parser-3.3.1/lib/umd/main.js +0 -194
  95. package/vendor/jsonc-parser-3.3.1/package.json +0 -37
  96. package/workflows/cost-tiered-fix.js +0 -287
@@ -1,508 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Render harness adapters from config/models.json and canonical role prompts."""
3
-
4
- import argparse
5
- import json
6
- from pathlib import Path
7
- import sys
8
-
9
-
10
- ROOT = Path(__file__).resolve().parents[1]
11
- CONFIG_PATH = ROOT / "config" / "models.json"
12
- ROLE_ROOT = ROOT / "roles"
13
- CLAUDE_MANIFEST = ROOT / ".claude-plugin" / "plugin.json"
14
- GENERATED = "<!-- Generated by scripts/render_adapters.py; do not edit. -->\n"
15
- TIERS = ("fable", "opus", "sonnet", "haiku")
16
-
17
-
18
- def _roles(config):
19
- """(role, tier, access) triples, sorted.
20
-
21
- `access` used to be a literal set here, duplicating a fact already stated
22
- by each role prompt's own `tools:` line and duplicated a third time in the
23
- OpenCode test, with nothing tying the three together.
24
- """
25
- for role, spec in sorted(config["roles"].items()):
26
- yield role, spec["tier"], spec["access"]
27
-
28
-
29
- def _cap(config, key, harness):
30
- for row in config["capabilities"]:
31
- if row["key"] == key:
32
- return row["values"][harness]
33
- raise KeyError(f"no capability row {key!r}")
34
-
35
-
36
- def _validate(config):
37
- """Refuse to render an incoherent matrix.
38
-
39
- This is the only place a contradiction can be caught before --check ships
40
- it: a mapping that renders cleanly is indistinguishable from a true one.
41
- """
42
- harnesses = set(config["harnesses"])
43
- for harness, rows in config["harnesses"].items():
44
- for tier in rows.get("absentTiers", ()):
45
- # Two conditions, and collapse alone is not enough.
46
- #
47
- # Dropping a tier drops its roles. The ceiling tier is the only one
48
- # whose role exists *solely* to be stronger than the rung below —
49
- # `expert` cannot break a deadlock a collapsed Opus already lost, so
50
- # when it collapses it has no remaining purpose. Every other role
51
- # keeps its job through a collapse: "routing between collapsed rungs
52
- # buys role, not power" is the policy's own line. Sonnet and Haiku
53
- # share a model on two harnesses today, and declaring Sonnet absent
54
- # there would silently delete `implementer` — a real rung with a
55
- # real job — which is exactly the failure this whole rule replaced.
56
- if tier != TIERS[0]:
57
- raise ValueError(
58
- f"{harness}: tier {tier!r} is declared absent, but only the ceiling "
59
- f"tier ({TIERS[0]!r}) can be — every other rung's roles keep their "
60
- "job through a collapse"
61
- )
62
- twins = [
63
- t for t in TIERS if t != tier and _tier_identity(rows[t]) == _tier_identity(rows[tier])
64
- ]
65
- if not twins:
66
- raise ValueError(
67
- f"{harness}: tier {tier!r} is declared absent but has a model of its own — "
68
- "absence is only ever justified by tier collapse"
69
- )
70
- for row in config["capabilities"]:
71
- unanswered = harnesses - set(row["values"])
72
- if unanswered:
73
- raise ValueError(
74
- f"capability {row['key']!r} unanswered for {sorted(unanswered)} — every "
75
- "harness answers every row, that is the whole point of the matrix"
76
- )
77
- for harness, value in row["values"].items():
78
- if value["mode"] not in row["modes"]:
79
- raise ValueError(
80
- f"capability {row['key']!r}/{harness}: mode {value['mode']!r} "
81
- f"is not one of {row['modes']}"
82
- )
83
-
84
-
85
- def _split_role(text):
86
- lines = text.splitlines()
87
- if not lines or lines[0] != "---":
88
- raise ValueError("role prompt is missing YAML frontmatter")
89
- try:
90
- end = lines.index("---", 1)
91
- except ValueError as exc:
92
- raise ValueError("role prompt has unterminated YAML frontmatter") from exc
93
- return lines[1:end], "\n".join(lines[end + 1 :]).strip() + "\n"
94
-
95
-
96
- def _tier_identity(row):
97
- """A tier is a model *and* its requested reasoning effort.
98
-
99
- Codex deliberately maps Fable and Opus to the same model at different
100
- efforts. Treating a model id alone as identity falsely removes Fable.
101
- """
102
- return row["model"], row.get("effort")
103
-
104
-
105
- def _without(frontmatter, keys):
106
- return [line for line in frontmatter if not any(line.startswith(key + ":") for key in keys)]
107
-
108
-
109
- def _agent_docs(role, tier, access, config):
110
- source = (ROLE_ROOT / f"{role}.md").read_text(encoding="utf-8")
111
- frontmatter, body = _split_role(source)
112
-
113
- claude_frontmatter = _without(frontmatter, {"model", "effort"})
114
- # Concrete model, never a plugin-config placeholder: Claude Code does not
115
- # interpolate plugin options into agent frontmatter, so a placeholder here
116
- # reaches the model selector verbatim and every spawn dies with "issue
117
- # with the selected model". config/models.json stays the one source.
118
- #
119
- # And a *bare* alias, never an alias with a context suffix: the agent
120
- # frontmatter `model` field documents exactly three accepted shapes — a
121
- # bare alias, a full model id, or `inherit`. `opus[1m]` is valid for
122
- # /model and for skill frontmatter, but it is not one of those three, so
123
- # it is the same undocumented-assumption bet that the placeholder was.
124
- # Skill frontmatter (skills-claude/*) keeps [1m]; agents do not.
125
- claude_frontmatter.append(f"model: {config['harnesses']['claude'][tier]['model']}")
126
- effort = config["harnesses"]["claude"][tier].get("effort")
127
- if effort:
128
- claude_frontmatter.append(f"effort: {effort}")
129
- claude = (
130
- "---\n"
131
- + "\n".join(claude_frontmatter)
132
- + "\n---\n\n"
133
- + GENERATED
134
- + "\n"
135
- + body
136
- )
137
-
138
- cursor_frontmatter = _without(frontmatter, {"model", "effort", "tools"})
139
- cursor_frontmatter.append("model: inherit")
140
- if access == "read-only" and _cap(config, "readOnlyRoles", "cursor")["mode"] == "frontmatter":
141
- cursor_frontmatter.append("readonly: true")
142
- cursor = (
143
- "---\n"
144
- + "\n".join(cursor_frontmatter)
145
- + "\n---\n\n"
146
- + GENERATED
147
- + "\n"
148
- + body
149
- )
150
- return claude, cursor
151
-
152
-
153
- def _opencode_agents(config):
154
- """Render adapters/opencode/agents.json: one entry per role, keyed by
155
- role name, sourced from the same roles/*.md canonical prompts and the
156
- same config/models.json tiers every other harness reads.
157
-
158
- A role is dropped only when its tier is *declared absent* on this harness
159
- (`absentTiers`), rather than registering a fake rung. That is `expert`
160
- here, whose fable tier collapses onto opus.
161
-
162
- The rule this replaced dropped any role whose tier resolved to the same
163
- model as opus — model identity, not intent. The day `sonnet` collapsed
164
- onto the opus model, `implementer` would have silently vanished from the
165
- roster, and the only test that noticed would have said "6 != 5".
166
- """
167
- opencode = config["harnesses"]["opencode"]
168
- absent = set(opencode.get("absentTiers", ()))
169
- adapter = opencode["adapter"]
170
- agents = {}
171
- for role, tier, access in _roles(config):
172
- model = opencode[tier]["model"]
173
- if tier in absent:
174
- continue
175
- source = (ROLE_ROOT / f"{role}.md").read_text(encoding="utf-8")
176
- frontmatter, body = _split_role(source)
177
- fm = {}
178
- for line in frontmatter:
179
- if ":" not in line:
180
- continue
181
- key, _, value = line.partition(":")
182
- fm[key.strip()] = value.strip()
183
- if access == "read-only":
184
- permission = dict(adapter["readOnlyPermission"])
185
- else:
186
- # Stopgap for opencode#5894 (unconfirmed whether
187
- # tool.execute.before intercepts subagent bash): coarse denies
188
- # on the catastrophic rm class for write-capable agents. The
189
- # precise tripwire stays hooks/bash-guard.py.
190
- permission = {"bash": {cmd: "deny" for cmd in adapter["writeBashDeny"]}}
191
- # `permission.edit: deny` prevents native edits, not destructive shell
192
- # commands. Apply the narrow catastrophic Bash denial to every role,
193
- # including shell-capable read-only agents.
194
- permission.setdefault("bash", {}).update(
195
- {cmd: "deny" for cmd in adapter["writeBashDeny"]}
196
- )
197
- agents[role] = {
198
- "description": fm.get("description", ""),
199
- "mode": "subagent",
200
- "model": f"openrouter/{model}",
201
- "prompt": body,
202
- "permission": permission,
203
- }
204
- return json.dumps(agents, indent=2, sort_keys=True) + "\n"
205
-
206
-
207
- def _table(rows):
208
- lines = ["| Tier | Model | Effort |", "|---|---|---|"]
209
- for tier in ("fable", "opus", "sonnet", "haiku"):
210
- item = rows[tier]
211
- lines.append(f"| {tier.title()} | `{item['model']}` | {item.get('effort', 'native default')} |")
212
- return "\n".join(lines)
213
-
214
-
215
- def _collapse_note(rows):
216
- """Name tiers that share one model on this harness.
217
-
218
- The policy treats the four tiers as distinct rungs, and its "no Fable
219
- tier here, cap escalation at Opus" branch only fires if the harness says
220
- so. A mapping that silently points two rungs at one model leaves that
221
- branch unreachable while the expert rung is materially fake.
222
- """
223
- by_model = {}
224
- for tier in ("fable", "opus", "sonnet", "haiku"):
225
- by_model.setdefault(_tier_identity(rows[tier]), []).append(tier)
226
- collapsed = [tiers for tiers in by_model.values() if len(tiers) > 1]
227
- if not collapsed:
228
- return ""
229
- groups = ", ".join(
230
- "≡".join(t.title() for t in tiers) + f" (`{rows[tiers[0]]['model']}`)"
231
- for tiers in collapsed
232
- )
233
- note = f"\nTier collapse here: {groups} — routing between collapsed rungs buys role, not power. "
234
- if any("fable" in tiers and "opus" in tiers for tiers in collapsed):
235
- note += (
236
- "Fable is not a real rung: `expert` cannot break a deadlock a "
237
- "collapsed Opus already lost, so cap escalation at Opus and report. "
238
- )
239
- return note.rstrip() + "\n"
240
-
241
-
242
- def _skill_notes(config, harness):
243
- """Name the leo:* skills this harness does not get, and why.
244
-
245
- Silence here is worse than the exclusion: a policy Skill index that lists
246
- skills the harness never registered reads as "available" until someone
247
- invokes one. Reason strings describe placeholders in prose on purpose —
248
- tests/test_harness_mappings.py fails the build if the literal Claude
249
- token appears in a non-Claude mapping.
250
- """
251
- skills = config.get("skills", {})
252
- reasons = skills.get("reasons", {})
253
- missing = set(skills.get("exclude", {}).get(harness, ()))
254
- if harness != "claude":
255
- missing |= set(skills.get("claudeOnly", ()))
256
- if not missing:
257
- # Claude's appendix used to end here, silent in both directions: it
258
- # never listed what only it has, and the exclusion list renders only
259
- # for the others. A Claude session could not tell from its own mapping
260
- # which of its skills do not travel.
261
- exclusive = sorted(set(skills.get("claudeOnly", ())))
262
- if not exclusive:
263
- return ""
264
- lines = ["", "## Leo skills only available here", ""]
265
- for name in exclusive:
266
- lines.append(f"- `leo:{name}` — {reasons.get(name, 'not portable to other harnesses')}.")
267
- lines.append("")
268
- lines.append(
269
- "Every other skill in the policy's Skill index is registered on every "
270
- "harness and behaves the same. These are not, so a procedure that "
271
- "leans on one of them does not transfer."
272
- )
273
- return "\n".join(lines) + "\n"
274
- lines = ["", "## Leo skills not available here", ""]
275
- for name in sorted(missing):
276
- lines.append(f"- `leo:{name}` — {reasons.get(name, 'not portable to this harness')}.")
277
- lines.append("")
278
- lines.append(
279
- "Every other skill in the policy's Skill index is registered here and "
280
- "behaves the same, and so are the operational skills — "
281
- + ", ".join(f"`leo:{name}`" for name in config["skills"].get("operational", ()))
282
- + " all run on this harness. "
283
- "Where they name a capability the table above says is missing, take "
284
- "the fallback each one documents."
285
- )
286
- return "\n".join(lines) + "\n"
287
-
288
-
289
- def _capability_table(config, harness):
290
- """The declarative half of every appendix.
291
-
292
- Every harness answers every row, so a *gap* is disclosed by exactly the
293
- same mechanism as a capability. Hand-written prose is what let the
294
- worktree tools and the workflow runner go unmentioned on three harnesses
295
- each: nothing forces a paragraph that was never written, and nothing
296
- notices when one goes stale.
297
-
298
- The notes are still human-written English. The matrix does not make them
299
- true; it makes them structurally complete and impossible to omit.
300
- """
301
- lines = ["", "## Capabilities here", "", "| Capability | Here |", "|---|---|"]
302
- for row in config["capabilities"]:
303
- lines.append(f"| {row['label']} | {row['values'][harness]['note']} |")
304
- return "\n".join(lines) + "\n"
305
-
306
-
307
- def _capability_notes(config, harness):
308
- """Per-harness visual-evidence rungs and memory projection target.
309
-
310
- Both are things leo:visual-verification and leo:memory would otherwise have
311
- to guess at from inside a session. Written as prose rather than a literal
312
- plugin-root token: tests/test_harness_mappings.py fails the build if the
313
- Claude placeholder leaks into another harness's mapping.
314
- """
315
- visual = config.get("visual", {}).get(harness)
316
- target = config.get("memoryTarget", {}).get(harness)
317
- if not visual and not target:
318
- return ""
319
- out = []
320
- if visual:
321
- out.append(
322
- f"\nVisual evidence here: {visual}. When no rung answers, "
323
- "leo:visual-verification requires the unverified-change warning in "
324
- "place of a done report.\n"
325
- )
326
- if target:
327
- out.append(
328
- f"\nMemory projection here writes to {target}. Only global-scope "
329
- "facts are projected — every per-user surface loads in every "
330
- "repository, so repo facts would leak across projects; they reach "
331
- "the model through the session context block instead. Leo's block "
332
- "is marker-delimited; the rest of the file is untouched.\n"
333
- )
334
- return "".join(out)
335
-
336
-
337
- def _mapping_docs(config):
338
- """One loop, not five hand-written blocks.
339
-
340
- Everything the per-harness prose used to say is now either a capability
341
- note or a shared paragraph, so a new harness gets a complete appendix by
342
- answering the matrix rather than by someone remembering to write one.
343
- """
344
- out = {}
345
- for harness, rows in sorted(config["harnesses"].items()):
346
- parts = [GENERATED, f"# {rows['title']} mapping\n\n"]
347
- if rows.get("provider"):
348
- parts.append(f"Provider: `{rows['provider']}`\n\n")
349
- parts.append(_table(rows))
350
- parts.append("\n")
351
- parts.append(_capability_table(config, harness))
352
- parts.append(_capability_notes(config, harness))
353
- parts.append(_collapse_note(rows))
354
- if harness == "opencode":
355
- parts.append("\n" + _absent_tier_sentence(config) + "\n")
356
- parts.append(_skill_notes(config, harness))
357
- out[harness] = "".join(parts)
358
- return out
359
-
360
-
361
- def _absent_tier_sentence(config):
362
- """Derived, not asserted: the roles OpenCode does not register.
363
-
364
- Hand-written, this sentence named `expert` and Fable directly and would
365
- have gone quietly wrong the first time the tier table changed.
366
- """
367
- opencode = config["harnesses"]["opencode"]
368
- absent = list(opencode.get("absentTiers", ()))
369
- if not absent:
370
- return "Every tier is a distinct rung here."
371
- roles = [r for r, tier, _ in _roles(config) if tier in absent]
372
- tiers = " and ".join(t.title() for t in absent)
373
- verb = "is" if len(absent) == 1 else "are"
374
- listed = ", ".join(f"`{r}`" for r in roles)
375
- return (
376
- f"{tiers} {verb} not a real rung here, so {listed} "
377
- f"{'is' if len(roles) == 1 else 'are'} not registered as an agent and "
378
- "escalation caps at Opus."
379
- )
380
-
381
-
382
- def _payload_readme(config):
383
- """The npm landing page for `leos-agent`.
384
-
385
- The root README cannot be symlinked in: every harness copies or caches
386
- this payload on its own, so a link pointing outside it dangles, and the
387
- packaging tests forbid symlinks here for exactly that reason. Generating
388
- it instead keeps one source and lets --check catch drift.
389
-
390
- Scoped to OpenCode deliberately — npm is only how OpenCode installs this.
391
- Every other harness has a native marketplace, and its instructions would
392
- be noise on this page.
393
- """
394
- opencode = config["harnesses"]["opencode"]
395
- return (
396
- GENERATED
397
- + "\n# Leo's Agent\n\n"
398
- "Leo's Agent is a portable operating policy with cost-tiered routing, "
399
- "specialist roles, process skills, review discipline, and a narrow command guard. "
400
- "This npm package is the **OpenCode** distribution; use the "
401
- "[repository](https://github.com/foxhatleo/leos-agent) for Claude Code, Codex, Cursor, "
402
- "and Hermes instructions.\n\n"
403
- "Supported hosts are macOS, Linux, and WSL with Python 3.9+; native Windows is unsupported.\n\n"
404
- "## Install and update\n\n"
405
- "```sh\nopencode plugin leos-agent --global\n```\n\n"
406
- "On builds without that subcommand, add `leos-agent` to the `plugin` array in "
407
- "`~/.config/opencode/opencode.json` or `opencode.jsonc`:\n\n"
408
- '```json\n{ "$schema": "https://opencode.ai/config.json", "plugin": ["leos-agent"] }\n```\n\n'
409
- "Run `opencode auth login` and choose OpenRouter before using the mapped models; Leo "
410
- "never writes provider credentials. Update with "
411
- "`opencode plugin leos-agent --global --force`, then start a new session. OpenCode "
412
- "currently has no plugin removal command; remove the `leos-agent` configuration entry "
413
- "to uninstall.\n\n"
414
- "The plugin registers generated shadow skills (`leo-<name>`) and namespaced "
415
- f"`leo-<role>` agents ({len(json.loads(_opencode_agents(config)))} generated definitions) "
416
- "from `adapters/opencode/agents.json`, "
417
- "then injects the operating policy through OpenCode's configuration. Invoke its shadow "
418
- "skill as `leo-using-leo`. If a skill is absent, "
419
- "run `opencode debug skill`; its `location` should be an `opencode-skills-<hash>/leo-<name>/` "
420
- "directory under machine-local state, not a hand-written package path.\n\n"
421
- "## MCP and durable state\n\n"
422
- "Use `leo-setup` to inspect or explicitly configure MCP services: `connectors` reports "
423
- "without writing, while `connect` and `apply` make only reviewed, harness-owned changes. "
424
- "Vendor connectors are never installed automatically and OAuth stays in OpenCode. "
425
- "Slack, Gmail, Drive, and providers without dynamic registration remain manual-only.\n\n"
426
- "Uninstall preserves `${LEOS_AGENT_LOCAL_PATH:-$HOME/.leos-agent-local}`. Before a full "
427
- "purge, export or copy that directory; only then explicitly remove it. For a 7.0 recovery, "
428
- "move old `LEOS_AGENT_PATH/local/` data there, rename the variable, restart, and run "
429
- "`leo-doctor`.\n\n"
430
- "## Model tiers\n\n"
431
- "Tier names describe the kind of work, not a fixed provider model.\n\n"
432
- + _table({tier: opencode[tier] for tier in TIERS})
433
- + "\n\n"
434
- + _absent_tier_sentence(config)
435
- + " Retier by editing `config/models.json` and re-running `scripts/render_adapters.py`.\n\n"
436
- "## Links\n\n"
437
- "- [Repository, contributing, and security policy](https://github.com/foxhatleo/leos-agent)\n"
438
- "- [GitHub Releases](https://github.com/foxhatleo/leos-agent/releases)\n"
439
- "- [Operating policy](https://github.com/foxhatleo/leos-agent/blob/main/plugins/leo/skills/using-leo/SKILL.md)\n\n"
440
- "MIT licensed.\n"
441
- )
442
-
443
-
444
- def render(config):
445
- _validate(config)
446
- outputs = {}
447
- for role, tier, access in _roles(config):
448
- claude, cursor = _agent_docs(role, tier, access, config)
449
- # Claude Code agents MUST live at the conventional agents/ path: a
450
- # manifest "agents" array of file paths validates but silently loads
451
- # zero agents, and the conventional directory auto-loads.
452
- outputs[ROOT / "agents" / f"{role}.md"] = claude
453
- outputs[ROOT / "adapters" / "cursor" / "agents" / f"{role}.md"] = cursor
454
- for harness, content in _mapping_docs(config).items():
455
- outputs[ROOT / "skills" / "using-leo" / "references" / f"{harness}-mapping.md"] = content
456
- outputs[ROOT / "adapters" / "opencode" / "agents.json"] = _opencode_agents(config)
457
- outputs[ROOT / "README.md"] = _payload_readme(config)
458
-
459
- # The manifest is no longer rewritten here: per-install model overrides
460
- # were retired along with the placeholder they fed. Retiering means editing
461
- # config/models.json and re-running this script, the flow README documents.
462
- return outputs
463
-
464
-
465
- def main():
466
- parser = argparse.ArgumentParser()
467
- parser.add_argument("--check", action="store_true", help="fail if generated adapters drift")
468
- args = parser.parse_args()
469
- config = json.loads(CONFIG_PATH.read_text(encoding="utf-8"))
470
- outputs = render(config)
471
- drift = []
472
- for path, expected in outputs.items():
473
- if path.exists() and path.read_text(encoding="utf-8") == expected:
474
- continue
475
- if args.check:
476
- drift.append(path.relative_to(ROOT).as_posix())
477
- else:
478
- path.parent.mkdir(parents=True, exist_ok=True)
479
- path.write_text(expected, encoding="utf-8")
480
-
481
- # Stale generated files are drift too. Comparing only what render() would
482
- # produce is blind to a file that exists and *shouldn't* — a role dropped
483
- # from models.json, a harness renamed — so the orphan survives every
484
- # --check and ships. Sweep the generated trees and flag anything unclaimed.
485
- for pattern in (
486
- "agents/*.md",
487
- "adapters/cursor/agents/*.md",
488
- "adapters/opencode/agents.json",
489
- "README.md",
490
- "skills/using-leo/references/*-mapping.md",
491
- ):
492
- for path in sorted(ROOT.glob(pattern)):
493
- if path in outputs:
494
- continue
495
- rel = path.relative_to(ROOT).as_posix()
496
- if args.check:
497
- drift.append(f"{rel} (stale: nothing in config/models.json generates it)")
498
- else:
499
- path.unlink()
500
- print(f"removed stale generated file: {rel}", file=sys.stderr)
501
- if drift:
502
- print("generated adapter drift: " + ", ".join(drift), file=sys.stderr)
503
- return 1
504
- return 0
505
-
506
-
507
- if __name__ == "__main__":
508
- raise SystemExit(main())