open-xmen 0.1.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 (60) hide show
  1. package/.cerebro/.gitignore +27 -0
  2. package/.cerebro/cerebro-identity.md +76 -0
  3. package/.cerebro/docs/agent-mapping.md +54 -0
  4. package/.cerebro/docs/cerebro-workflow.md +115 -0
  5. package/.cerebro/docs/orchestration.md +28 -0
  6. package/.cerebro/docs/overview.md +44 -0
  7. package/.cerebro/docs/skill-policy.md +25 -0
  8. package/.cerebro/integrations/semble.md +30 -0
  9. package/.cerebro/opencode/model-routing.md +37 -0
  10. package/.cerebro/schemas/boulder.schema.json +143 -0
  11. package/.cerebro/schemas/team-run.schema.json +234 -0
  12. package/.cerebro/schemas/upgrade-manifest.schema.json +45 -0
  13. package/.cerebro/schemas/upgrade-state.schema.json +38 -0
  14. package/.cerebro/scripts/check-agent-teams-enabled.py +24 -0
  15. package/.cerebro/scripts/ensure-upgrade-cache-gitignored.py +27 -0
  16. package/.cerebro/scripts/fetch-upstream-ref.py +67 -0
  17. package/.cerebro/scripts/reset-runtime.py +125 -0
  18. package/.cerebro/scripts/setup-status.py +101 -0
  19. package/.cerebro/scripts/test-stop-hook.py +60 -0
  20. package/.cerebro/scripts/upgrade-latest-tag.py +34 -0
  21. package/.cerebro/scripts/validate-agent-frontmatter.py +87 -0
  22. package/.cerebro/scripts/validate-boulder.py +105 -0
  23. package/.cerebro/scripts/validate-opencode-runtime.py +94 -0
  24. package/.cerebro/scripts/validate-team-runs.py +310 -0
  25. package/.cerebro/scripts/validate-upgrade-metadata.py +104 -0
  26. package/.cerebro/scripts/write-upgrade-state.py +93 -0
  27. package/.cerebro/templates/customer-vision.md +58 -0
  28. package/.cerebro/templates/plan.md +35 -0
  29. package/.cerebro/templates/product-brief.md +110 -0
  30. package/.cerebro/templates/project-context.md +64 -0
  31. package/.cerebro/templates/requirements-brief.md +67 -0
  32. package/.cerebro/templates/team-run.json +22 -0
  33. package/.cerebro/upgrade-manifest.json +160 -0
  34. package/.opencode/.gitignore +5 -0
  35. package/.opencode/agents/beast.md +38 -0
  36. package/.opencode/agents/cerebro.md +22 -0
  37. package/.opencode/agents/cyclops.md +22 -0
  38. package/.opencode/agents/cypher.md +46 -0
  39. package/.opencode/agents/emma-frost.md +38 -0
  40. package/.opencode/agents/forge.md +22 -0
  41. package/.opencode/agents/legion.md +45 -0
  42. package/.opencode/agents/nightcrawler.md +22 -0
  43. package/.opencode/agents/professor-x.md +39 -0
  44. package/.opencode/agents/sage.md +22 -0
  45. package/.opencode/agents/storm.md +49 -0
  46. package/.opencode/agents/wolverine.md +22 -0
  47. package/.opencode/commands/cerebro-doctor.md +19 -0
  48. package/.opencode/commands/cerebro-index.md +22 -0
  49. package/.opencode/commands/cerebro-plan.md +21 -0
  50. package/.opencode/commands/cerebro-reset.md +20 -0
  51. package/.opencode/commands/cerebro-start-work.md +20 -0
  52. package/.opencode/commands/cerebro-upgrade.md +19 -0
  53. package/.opencode/commands/to-me-my-x-men.md +27 -0
  54. package/AGENTS.md +12 -0
  55. package/README.md +193 -0
  56. package/dist/cli.d.ts +2 -0
  57. package/dist/cli.js +597 -0
  58. package/dist/index.d.ts +4 -0
  59. package/dist/index.js +466 -0
  60. package/package.json +54 -0
@@ -0,0 +1,20 @@
1
+ ---
2
+ description: Execute or resume the latest Cerebro plan through Cyclops coordination.
3
+ agent: cerebro
4
+ model: openai/gpt-5.4
5
+ ---
6
+ Execute or resume the latest Cerebro plan.
7
+
8
+ ## Required flow
9
+
10
+ 1. Announce field execution mode.
11
+ 2. Read the newest `.cerebro/plans/*.md`, `.cerebro/project-context.md` if present, `.cerebro/boulder.json` if present, and relevant `.cerebro/notepads/`.
12
+ 3. Call `cerebro_model_slots` and `cerebro_run_start` with command `/cerebro-start-work`, objective from the plan, and the plan risk.
13
+ 4. Create task records for each implementation, UI, review, and verification task in the plan.
14
+ 5. Use Cyclops to sequence dependencies, assign Wolverine/Storm/Forge/Nightcrawler/Sage/Beast/Emma Frost as needed, and independently verify results. For tiny low-risk boilerplate or test-stub drafts, Cyclops may dispatch a Spark first-pass with `cerebro_dispatch_agent` using `model_slot: "spark"`, but final implementation and verification stay with full Codex/frontier models.
15
+ 6. Require Wolverine and Storm to maintain `.cerebro/pending-todos/{team}/{agent}/{task}.txt` and return `TASK_RESULT` evidence.
16
+ 7. Record decisions and blockers with `cerebro_mailbox_send`; update task state with `cerebro_task_update`.
17
+ 8. Run all verification commands listed in the plan when safe. If a command is destructive, external, credentialed, or production-affecting, ask first.
18
+ 9. Update `.cerebro/boulder.json` with status, approvals, verification history, and decisions.
19
+ 10. Call `cerebro_verify_pending`; do not final-report while pending todos remain.
20
+ 11. Final report: plan path, files changed, tests run, verification evidence, unresolved issues, rollback notes, and checkpoint paths.
@@ -0,0 +1,19 @@
1
+ ---
2
+ description: Sync Cerebro template-owned files from an explicit upstream release.
3
+ agent: cerebro
4
+ model: openai/gpt-5.4
5
+ ---
6
+ Upgrade Cerebro template-owned files from upstream ref: $ARGUMENTS
7
+
8
+ This command is gated and must not silently overwrite user-owned files.
9
+
10
+ ## Required flow
11
+
12
+ 1. Parse args: `[<ref>] [--dry-run] [--strict] [--force-dirty] [--only <glob>]`.
13
+ 2. Reject `HEAD`, `main`, and `master`; require explicit release tag or commit SHA.
14
+ 3. Load `.cerebro/upgrade-manifest.json`; if absent, propose a manifest and require confirmation before writing.
15
+ 4. Check dirty tracked files in template/merge-owned paths. Stop unless clean or `--force-dirty` is explicitly present.
16
+ 5. Fetch upstream into `.cerebro/upgrade-cache/` using existing scripts where possible.
17
+ 6. Present diffs for merge-owned files and require confirmation before writes.
18
+ 7. Never touch user-owned runtime paths: `.cerebro/plans/**`, `.cerebro/notepads/**`, `.cerebro/team-runs/**`, `.cerebro/boulder.json`, pending todos, or project context unless explicitly requested.
19
+ 8. Validate and write upgrade state.
@@ -0,0 +1,27 @@
1
+ ---
2
+ description: Autonomous Cerebro full-team mode for best-effort execution.
3
+ agent: cerebro
4
+ model: openai/gpt-5.4
5
+ ---
6
+ Assemble the full Cerebro team for autonomous execution of: $ARGUMENTS
7
+
8
+ ## Best-effort standard
9
+
10
+ The user expects the best the team can produce, not the minimum viable version. Prefer excellent architecture, complete UX states, strong verification, and polished results. Fast is good; generic and under-verified is failure.
11
+
12
+ ## Required flow
13
+
14
+ 1. Announce maximum Cerebro power.
15
+ 2. Classify mission shape and risk. If HIGH risk, ask for explicit confirmation before destructive/production/credentialed/data/billing/legal/git-history actions.
16
+ 3. Call `cerebro_model_slots` and `cerebro_run_start` with command `/to-me-my-x-men`.
17
+ 4. Always start with Legion and Cypher:
18
+ - Legion writes customer vision under `.cerebro/notepads/customer/`.
19
+ - Cypher writes requirements under `.cerebro/notepads/requirements/`.
20
+ Ask one focused, structured confirmation question in plain text only for non-inferable blockers. Do not stack questions or ask for open-ended replies when a safe assumption can be documented.
21
+ 5. Promote requirements into a Professor X product brief or implementation plan, reviewed by Beast and validated by Emma Frost when risk/complexity warrants.
22
+ 6. Create task records, then use Cyclops to coordinate implementation with Wolverine, Storm, Forge, Nightcrawler, Sage, Beast, and Emma Frost as appropriate.
23
+ 7. Maintain task-scoped todos for worker tasks and record mailbox decisions/checkpoints. Use Spark for instant first drafts only when it accelerates the mission without lowering final quality; full Codex/frontier agents own final implementation and verification.
24
+ 8. Run verification and final Legion acceptance. A Legion reject creates retry tasks before completion.
25
+ 9. Call `cerebro_verify_pending`; final-report only when todos are clear or explicitly blocked.
26
+
27
+ Final report must include assumptions, files changed, tests/verification, customer acceptance verdict, unresolved issues, and `.cerebro` run paths.
package/AGENTS.md ADDED
@@ -0,0 +1,12 @@
1
+ # Cerebro OpenCode Runtime
2
+
3
+ This project uses the Cerebro workflow ported to OpenCode.
4
+
5
+ - Primary runtime state lives under `.cerebro/`.
6
+ - Use OpenCode commands `/cerebro-index`, `/cerebro-plan`, `/cerebro-start-work`, and `/to-me-my-x-men` for non-trivial work.
7
+ - Preserve Cerebro role names: Legion, Cypher, Professor X, Cyclops, Wolverine, Storm, Forge, Nightcrawler, Sage, Beast, and Emma Frost.
8
+ - OpenCode does not provide Claude Code native team APIs; use Cerebro custom tools and OpenCode subagents/child sessions for coordination.
9
+ - Never read `.env`, `.env.*`, secret, or credential files unless the user explicitly authorizes it for the current task.
10
+ - Do not write generated build output (`dist/`, `build/`, `target/`) unless the task explicitly targets those directories.
11
+
12
+ When handling a Cerebro command, read `.cerebro/cerebro-identity.md` and `.cerebro/opencode/model-routing.md` first if they are not already in context.
package/README.md ADDED
@@ -0,0 +1,193 @@
1
+ # Open X-Men — Cerebro for OpenCode
2
+
3
+ A reusable OpenCode plugin/template that ports the original Claude Code Cerebro/X-Men workflow into the OpenCode ecosystem while preserving the parts that matter:
4
+
5
+ - `.cerebro/` runtime state
6
+ - `/cerebro-index`
7
+ - `/cerebro-plan`
8
+ - `/cerebro-start-work`
9
+ - `/to-me-my-x-men`
10
+ - Cerebro and the X-Men role names
11
+
12
+ Cerebro coordinates. OpenCode agents execute. The workflow keeps the dramatic X-Men soul, but no longer depends on Claude Code native team APIs.
13
+
14
+ ---
15
+
16
+ ## What Changed
17
+
18
+ The old Claude workflow used `.claude/agents`, `.claude/commands`, hooks, and native team tools such as `TeamCreate`, `TaskCreate`, `TaskUpdate`, and `SendMessage`.
19
+
20
+ The OpenCode port uses:
21
+
22
+ - `.opencode/agents/*.md` — OpenCode-native Cerebro role agents
23
+ - `.opencode/commands/*.md` — preserved Cerebro slash commands
24
+ - `open-xmen` package plugin entry — installed by `open-xmen install`
25
+ - `.opencode/plugins/open-xmen.ts` — local development bridge in this repository only; installed projects use the package plugin entry
26
+ - `src/index.ts` — reusable plugin implementation
27
+ - Cerebro custom tools for run state, tasks, mailbox, checkpoints, model slots, and pending-todo checks
28
+ - `AGENTS.md` and `.cerebro/cerebro-identity.md` — OpenCode instruction surface
29
+
30
+ The legacy `.claude/` files are still present as migration source/compatibility material, but the active OpenCode runtime is `.opencode/` + `.cerebro/`.
31
+
32
+ ---
33
+
34
+ ## Model Routing
35
+
36
+ This installation is configured for the user's cost-conscious OpenAI model set. GPT-5.4 is the default; GPT-5.4 Pro can be opted into via `CEREBRO_MODEL_FRONTIER` when the premium lane is worth the cost:
37
+
38
+ | Slot | Model | Roles |
39
+ |---|---|---|
40
+ | `frontier` | `openai/gpt-5.4` | Cerebro, Professor X, Cyclops, Forge, Emma Frost |
41
+ | `strong` | `openai/gpt-5.4` | Legion, Cypher, Sage, Beast |
42
+ | `legacy-frontier` | `openai/gpt-5.2` | Optional fallback/compatibility lane |
43
+ | `coding` | `openai/gpt-5.3-codex` | Wolverine, Storm |
44
+ | `spark` | `openai/gpt-5.3-codex-spark` | Instant code sketches, boilerplate, test stubs, tiny low-risk diffs |
45
+ | `fast` | `openai/gpt-5.4-mini` | Nightcrawler fast search/indexing |
46
+ | `image` | `openai/gpt-image-2` | image/design asset generation only |
47
+
48
+ Override with environment variables if your available models change:
49
+
50
+ ```bash
51
+ export CEREBRO_MODEL_FRONTIER="openai/gpt-5.4"
52
+ export CEREBRO_MODEL_STRONG="openai/gpt-5.4"
53
+ export CEREBRO_MODEL_CODING="openai/gpt-5.3-codex"
54
+ export CEREBRO_MODEL_SPARK="openai/gpt-5.3-codex-spark"
55
+ # optional premium lane: export CEREBRO_MODEL_FRONTIER="openai/gpt-5.4-pro"
56
+ # optional legacy fallback: export CEREBRO_MODEL_FRONTIER="openai/gpt-5.2"
57
+ export CEREBRO_MODEL_FAST="openai/gpt-5.4-mini"
58
+ export CEREBRO_MODEL_IMAGE="openai/gpt-image-2"
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Quick Start
64
+
65
+ Install Open X-Men into any OpenCode project with bunx. The installer adds the published `open-xmen` package as an OpenCode plugin entry and installs the repo-local Cerebro runtime files:
66
+
67
+ ```bash
68
+ cd /path/to/your/project
69
+ bunx open-xmen@latest install
70
+ opencode .
71
+ ```
72
+
73
+ No setup slash command is required. Re-running the installer is safe: existing runtime/template files are skipped by default, while `opencode.jsonc` is updated atomically with an `opencode.jsonc.bak` backup when it changes. Use `--reset` or `--force` only when you want to refresh managed Open X-Men files.
74
+
75
+ Useful installer flags:
76
+
77
+ ```bash
78
+ bunx open-xmen@latest install --dir /path/to/project
79
+ bunx open-xmen@latest install --dry-run
80
+ bunx open-xmen@latest install --reset
81
+ bunx open-xmen@latest install --force
82
+ bunx open-xmen@latest install --no-deps
83
+ ```
84
+
85
+ For local development of this package:
86
+
87
+ ```bash
88
+ npm install
89
+ npm run build
90
+ node dist/cli.js install --dir /path/to/your/project
91
+ ```
92
+
93
+ Then run the Cerebro workflow command you need inside OpenCode:
94
+
95
+ ```text
96
+ /cerebro-index
97
+ /cerebro-plan add a REST API for user authentication
98
+ /cerebro-start-work
99
+ ```
100
+
101
+ For autonomous best-effort mode:
102
+
103
+ ```text
104
+ /to-me-my-x-men build the feature described in the current issue
105
+ ```
106
+
107
+ ---
108
+
109
+ ## CLI
110
+
111
+ ```bash
112
+ open-xmen [install] [--dir <path>] [--dry-run] [--reset] [--force] [--no-deps]
113
+ open-xmen doctor [--dir <path>] [--json]
114
+ open-xmen models
115
+ ```
116
+
117
+ - No subcommand defaults to `install`, matching `bunx open-xmen@latest install` behavior.
118
+ - `--dry-run` prints planned writes and does not mutate the target project.
119
+ - `--reset` / `--force` refresh existing managed files; without them, existing files are skipped.
120
+ - `opencode.jsonc` writes are atomic via `opencode.jsonc.tmp` and create `opencode.jsonc.bak` before replacing an existing config.
121
+ - `doctor --json` returns script-friendly diagnostics.
122
+
123
+ ## Commands
124
+
125
+ | Command | What it does |
126
+ |---|---|
127
+ | `/cerebro-index` | Build `.cerebro/project-context.md` using Nightcrawler, Sage, Forge, and Beast. |
128
+ | `/cerebro-plan [task]` | Interview-first planning with Professor X, Beast, and Emma Frost validation. |
129
+ | `/cerebro-start-work` | Execute or resume the latest Cerebro plan through Cyclops coordination. |
130
+ | `/to-me-my-x-men [task]` | Autonomous full-team mode with Legion + Cypher intent consult and final Legion acceptance. |
131
+ | `/cerebro-doctor` | Validate runtime health. |
132
+ | `/cerebro-reset` | Reset runtime state after confirmation. |
133
+ | `/cerebro-upgrade <ref>` | Gated template sync from an explicit upstream release/ref. |
134
+
135
+ ---
136
+
137
+ ## Team
138
+
139
+ | Agent | Role | Default model |
140
+ |---|---|---|
141
+ | Cerebro | Main OpenCode primary agent / team lead | `openai/gpt-5.4` |
142
+ | Legion | Customer / product-owner proxy | `openai/gpt-5.4` |
143
+ | Cypher | Requirements analyst | `openai/gpt-5.4` |
144
+ | Professor X | Strategic planner | `openai/gpt-5.4` |
145
+ | Cyclops | Execution sequencer and verifier | `openai/gpt-5.4` |
146
+ | Wolverine | Code/test implementation | `openai/gpt-5.3-codex` |
147
+ | Storm | UI/visual implementation | `openai/gpt-5.3-codex` |
148
+ | Forge | Architecture consultant | `openai/gpt-5.4` |
149
+ | Nightcrawler | Read-only codebase search | `openai/gpt-5.4-mini` |
150
+ | Sage | Docs/API research | `openai/gpt-5.4` |
151
+ | Beast | Gap analysis and critique | `openai/gpt-5.4` |
152
+ | Emma Frost | Strict validation | `openai/gpt-5.4` |
153
+
154
+ ---
155
+
156
+ ## Runtime Files
157
+
158
+ ```text
159
+ .cerebro/
160
+ ├── cerebro-identity.md # OpenCode Cerebro orchestration brain
161
+ ├── opencode/model-routing.md # model slots and routing policy
162
+ ├── project-context.md # repository index from /cerebro-index
163
+ ├── plans/ # approved plans
164
+ ├── notepads/ # customer visions, requirements, drafts, reviews, learnings
165
+ ├── team-runs/ # manifests, task state, mailbox logs, checkpoints, events
166
+ ├── pending-todos/ # worker task todos
167
+ ├── boulder.json # execution checkpoint
168
+ ├── schemas/ # state schemas
169
+ ├── templates/ # plan/context/run templates
170
+ └── scripts/ # validators and maintenance helpers
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Validation
176
+
177
+ ```bash
178
+ npm run build
179
+ npx tsc -p tsconfig.json --noEmit
180
+ npm run doctor
181
+ python3 .cerebro/scripts/validate-opencode-runtime.py
182
+ python3 .cerebro/scripts/validate-team-runs.py
183
+ python3 .cerebro/scripts/validate-upgrade-metadata.py
184
+ npm run verify:release
185
+ ```
186
+
187
+ `npm run verify:release` builds the package, packs it with `npm pack --json --ignore-scripts`, checks the packaged runtime file set exactly, rejects forbidden paths such as dev-only plugin bridges or secret-like files, installs the tarball into a clean temp package, runs `open-xmen install --no-deps`, verifies `plugin: ["open-xmen"]`, and runs `open-xmen doctor`.
188
+
189
+ `/cerebro-doctor` runs the same class of checks from inside OpenCode.
190
+
191
+ ## Spark Lane
192
+
193
+ `gpt-5.3-codex-spark` is available as a fast draft lane. Cerebro should use it for instant code generation, boilerplate, test stubs, tiny low-risk diffs, and candidate patches. Full `gpt-5.3-codex` remains the default for Wolverine/Storm final implementation and verification.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};