opencode-onboard 0.2.6 → 0.2.12
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.
- package/README.md +30 -6
- package/content/.opencode/plugins/session-log.js +266 -35
- package/content/AGENTS.md +384 -384
- package/package.json +1 -1
- package/src/index.js +180 -18
- package/src/steps/__tests__/check-rtk.test.js +3 -2
- package/src/steps/__tests__/clean-ai-files.test.js +1 -1
- package/src/steps/__tests__/copy-content.test.js +4 -2
- package/src/steps/__tests__/token-optimization.test.js +78 -0
- package/src/steps/check-rtk.js +22 -4
- package/src/steps/choose-source-scope.js +1 -1
- package/src/steps/enable-caveman-guidance.js +93 -0
- package/src/steps/install-caveman.js +42 -0
- package/src/steps/install-quota.js +82 -0
- package/src/steps/token-optimization.js +59 -0
- package/src/steps/write-onboard-config.js +2 -0
- package/src/utils/exec.js +19 -7
package/content/AGENTS.md
CHANGED
|
@@ -1,384 +1,384 @@
|
|
|
1
|
-
# AGENTS.md, Bootstrap Mode
|
|
2
|
-
|
|
3
|
-
> This project has not been initialized yet.
|
|
4
|
-
> Your ONLY job right now is to run the initialization sequence below.
|
|
5
|
-
> Do not do anything else until all steps are complete.
|
|
6
|
-
|
|
7
|
-
## Trigger
|
|
8
|
-
|
|
9
|
-
When the user says anything resembling initialization, "init", "initialize", "setup", "start", "bootstrap", "get started", "prepare", execute all steps below in order. Do not ask for confirmation before starting.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Initialization Sequence
|
|
14
|
-
|
|
15
|
-
### Step 1, Archive project history into OpenSpec
|
|
16
|
-
|
|
17
|
-
Scan the codebase for any existing documentation, changelogs, ADRs, README files, or notable history that describes decisions already made in this project. Create an OpenSpec archive entry that captures this history so agents have context going forward.
|
|
18
|
-
|
|
19
|
-
Before scanning, load source roots from `.agents/source-roots.json` when present. Only scan those roots plus this repo's docs/config files.
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
openspec new change "project-history"
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Write a `proposal.md` inside that change summarizing:
|
|
26
|
-
- What this project is
|
|
27
|
-
- Key decisions already made (inferred from code and docs)
|
|
28
|
-
- Known tech debt or constraints visible in the codebase
|
|
29
|
-
- Current state of the project
|
|
30
|
-
|
|
31
|
-
Then archive it immediately:
|
|
32
|
-
```bash
|
|
33
|
-
openspec archive "project-history"
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
### Step 2, Generate DESIGN.md
|
|
39
|
-
|
|
40
|
-
`DESIGN.md` contains a prompt. You MUST follow this exact sequence, do not skip or reorder steps:
|
|
41
|
-
|
|
42
|
-
1. **Read `DESIGN.md` now** using a file read tool. The file contains a prompt with instructions and an output format.
|
|
43
|
-
2. **Store the full prompt text** in your context.
|
|
44
|
-
3. **Overwrite `DESIGN.md` with an empty string** (zero bytes). Do this before generating any content.
|
|
45
|
-
4. **Analyze the actual codebase**: use `.agents/source-roots.json` as source roots when present, then read CSS files, Tailwind config, component files, token definitions. Do not rely on prior knowledge, read the files.
|
|
46
|
-
5. **Write the result into `DESIGN.md`** following exactly the format and sections described in the stored prompt.
|
|
47
|
-
|
|
48
|
-
The output must be a real, populated `DESIGN.md` based on what you found in the codebase, not from memory or assumptions.
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
### Step 3, Generate ARCHITECTURE.md
|
|
53
|
-
|
|
54
|
-
`ARCHITECTURE.md` contains a prompt. You MUST follow this exact sequence, do not skip or reorder steps:
|
|
55
|
-
|
|
56
|
-
1. **Read `ARCHITECTURE.md` now** using a file read tool. The file contains a prompt with instructions and an output format.
|
|
57
|
-
2. **Store the full prompt text** in your context.
|
|
58
|
-
3. **Overwrite `ARCHITECTURE.md` with an empty string** (zero bytes). Do this before generating any content.
|
|
59
|
-
4. **Analyze the actual codebase**: use `.agents/source-roots.json` as source roots when present, then read folder structure, config files, route definitions, data models, integration points. Do not rely on prior knowledge, read the files.
|
|
60
|
-
5. **Write the result into `ARCHITECTURE.md`** following exactly the format and sections described in the stored prompt.
|
|
61
|
-
|
|
62
|
-
The output must be a real, populated `ARCHITECTURE.md` based on what you found in the codebase, covering all sections the prompt describes.
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
### Step 4, Rewrite this file
|
|
67
|
-
|
|
68
|
-
Replace the entire contents of this file (`AGENTS.md`) with everything below the line `<!-- AGENTS-TEMPLATE-START -->` in this same file. Delete the bootstrap section and the template marker, the file should contain only the template content when done.
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
### Step 5, Confirm
|
|
73
|
-
|
|
74
|
-
Tell the user:
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
78
|
-
Initialization complete.
|
|
79
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
80
|
-
|
|
81
|
-
- ARCHITECTURE.md generated
|
|
82
|
-
- DESIGN.md generated
|
|
83
|
-
- Project history archived in openspec
|
|
84
|
-
- AGENTS.md updated with real guidance
|
|
85
|
-
|
|
86
|
-
!! RESTART OPENCODE NOW !!
|
|
87
|
-
|
|
88
|
-
Quit and reopen OpenCode before doing anything else.
|
|
89
|
-
Nothing will work correctly until you do.
|
|
90
|
-
After restarting you are ready to work.
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## Guardrails During Init
|
|
96
|
-
|
|
97
|
-
- Do NOT implement any features
|
|
98
|
-
- Do NOT create branches or PRs
|
|
99
|
-
- Do NOT modify any project source files
|
|
100
|
-
- Do NOT create RTK files, scripts, or wrappers, RTK is already defined in AGENTS.md and agent files
|
|
101
|
-
- Only read source files for analysis, write only to ARCHITECTURE.md, DESIGN.md, AGENTS.md, and openspec/
|
|
102
|
-
|
|
103
|
-
<!-- AGENTS-TEMPLATE-START -->
|
|
104
|
-
# AGENTS.md
|
|
105
|
-
|
|
106
|
-
This file provides guidance to AI agents when working in this repository.
|
|
107
|
-
|
|
108
|
-
*Agent-agnostic, works with OpenCode, Claude Code, Codex, Gemini, etc.*
|
|
109
|
-
|
|
110
|
-
## Project Overview
|
|
111
|
-
|
|
112
|
-
This is the agent orchestration layer for your project. It provides:
|
|
113
|
-
- Universal agent team for development workflow
|
|
114
|
-
- OpenSpec change management
|
|
115
|
-
- Skills for platform-specific knowledge
|
|
116
|
-
|
|
117
|
-
## Source Scope
|
|
118
|
-
|
|
119
|
-
- Read source scope from `.agents/source-roots.json`.
|
|
120
|
-
- Use those roots for codebase analysis tasks (design, architecture, project-history, exploration).
|
|
121
|
-
- If missing, default to current folder.
|
|
122
|
-
|
|
123
|
-
## I Am the Lead, Full Workflow Ownership
|
|
124
|
-
|
|
125
|
-
When the user provides a work item URL or says "implement the plan" or "I've added comments to the PR", **I own the full lifecycle**. I load the appropriate skill and use ensemble tools to coordinate the agent team.
|
|
126
|
-
|
|
127
|
-
Trigger patterns, I recognize ALL of these, exact wording does not matter:
|
|
128
|
-
- User pastes or mentions a GitHub Issue URL → load `ob-userstory-gh` skill → parse issue → run `/opsx-propose` → confirm with user → run `/opsx-apply` → ship
|
|
129
|
-
- User pastes or mentions an Azure DevOps URL → load `ob-userstory-az` skill → parse work item → run `/opsx-propose` → confirm with user → run `/opsx-apply` → ship
|
|
130
|
-
- `implement the plan` / `implement` / `start` / `go` → run `/opsx-apply` → ship
|
|
131
|
-
- `I've added comments to the PR` → read PR comments → fix → update PR
|
|
132
|
-
- Any GitHub/Azure DevOps PR URL in a feedback/fix request (e.g. "check comments", "fix PR feedback") → run PR Feedback Loop
|
|
133
|
-
|
|
134
|
-
**A GitHub or Azure DevOps URL anywhere in the user's message is always a trigger, regardless of surrounding words.**
|
|
135
|
-
|
|
136
|
-
**Never delegate without a plan. Never write implementation code directly, always spawn specialists, no exceptions. "Small feature", "faster to do it directly", or "environment issues" are not valid reasons to skip ensemble.**
|
|
137
|
-
|
|
138
|
-
## Multi-Agent Execution, opencode-ensemble
|
|
139
|
-
|
|
140
|
-
Parallel execution uses the `opencode-ensemble` plugin (`team_create`, `team_spawn`, etc.).
|
|
141
|
-
Works on **all platforms** (Windows, macOS, Linux) via OpenCode's built-in worktree support.
|
|
142
|
-
|
|
143
|
-
| Tool | What it does |
|
|
144
|
-
|------|-------------|
|
|
145
|
-
| `team_create` | Create a team (caller becomes lead) |
|
|
146
|
-
| `team_spawn` | Start a teammate asynchronously |
|
|
147
|
-
| `team_shutdown` | Stop a teammate, preserve their branch |
|
|
148
|
-
| `team_merge` | Merge a teammate's branch into working dir |
|
|
149
|
-
| `team_cleanup` | Tear down the team |
|
|
150
|
-
| `team_results` | Retrieve full message content (delivery is a ping only) |
|
|
151
|
-
| `team_message` | Send a direct message to a teammate or lead |
|
|
152
|
-
| `team_broadcast` | Message all teammates |
|
|
153
|
-
| `team_status` | View all members and task summary |
|
|
154
|
-
| `team_tasks_list` | View the shared task board |
|
|
155
|
-
| `team_tasks_add` | Add tasks to shared board |
|
|
156
|
-
| `team_tasks_complete` | Mark task done, auto-unblocks dependents |
|
|
157
|
-
| `team_claim` | Atomically claim a pending task (teammates use this) |
|
|
158
|
-
|
|
159
|
-
**Dashboard**: Monitor running agents at **http://localhost:4747/**
|
|
160
|
-
|
|
161
|
-
**Progress inspection commands (tell user explicitly after spawning):**
|
|
162
|
-
- `team_status` for live team snapshot
|
|
163
|
-
- `team_tasks_list` for task board state
|
|
164
|
-
- `team_view member:"<name>"` to inspect a teammate live session
|
|
165
|
-
- `team_results from:"<name>"` to fetch full teammate report text
|
|
166
|
-
|
|
167
|
-
If a teammate stalls due to model quota/rate-limit exhaustion:
|
|
168
|
-
1. `team_shutdown name:"<stuck-member>" force:true`
|
|
169
|
-
2. `team_spawn` same member/task with an available model
|
|
170
|
-
3. `team_message` start instruction with the exact next task ID
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## Pipeline
|
|
175
|
-
|
|
176
|
-
```
|
|
177
|
-
devops-manager (read mode)
|
|
178
|
-
→ parse work item via skill → structured summary
|
|
179
|
-
↓
|
|
180
|
-
openspec-propose
|
|
181
|
-
→ proposal.md + specs + tasks
|
|
182
|
-
↓
|
|
183
|
-
[confirm with user]
|
|
184
|
-
↓
|
|
185
|
-
back-engineer → front-engineer → infra-engineer ← sequential, one at a time, only spawn what the task needs
|
|
186
|
-
↓
|
|
187
|
-
quality-engineer (worktree:false)
|
|
188
|
-
→ tests, build, lint, acceptance criteria
|
|
189
|
-
↓
|
|
190
|
-
security-auditor (worktree:false)
|
|
191
|
-
→ vulnerability audit, secrets, auth gaps
|
|
192
|
-
↓
|
|
193
|
-
devops-manager (ship mode)
|
|
194
|
-
→ screenshots → commit → push → PR → post comment
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
### Phase 1, Parse & Propose
|
|
198
|
-
|
|
199
|
-
```
|
|
200
|
-
1. Detect URL type → load matching skill (ob-userstory-gh or ob-userstory-az)
|
|
201
|
-
2. Follow skill steps: fetch issue/work item via CLI, create OpenSpec change
|
|
202
|
-
3. Run /opsx-propose → generates proposal.md, specs/, design.md, tasks.md
|
|
203
|
-
4. Show the plan: change name, total tasks, task list summary
|
|
204
|
-
5. STOP. Ask user: "Ready to implement? (yes/no)", DO NOT proceed until confirmed.
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Phase 2, Implement
|
|
208
|
-
|
|
209
|
-
```
|
|
210
|
-
1. Run /opsx-apply, handles context reading, ensemble orchestration, and task marking.
|
|
211
|
-
- Lead adds all tasks to board, then spawns specialists ONE AT A TIME (not parallel)
|
|
212
|
-
- Each specialist claims tasks, implements, completes tasks, messages lead when done
|
|
213
|
-
- Lead merges each branch after shutdown, then marks tasks done in tasks.md
|
|
214
|
-
2. After /opsx-apply completes, proceed to quality check.
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### Phase 3, Quality
|
|
218
|
-
|
|
219
|
-
```
|
|
220
|
-
3. team_spawn name:quality agent:quality-engineer worktree:false → tests, build, lint
|
|
221
|
-
4. Wait → team_results → fix any blockers → team_shutdown (no merge, worktree:false)
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Phase 4, Security
|
|
225
|
-
|
|
226
|
-
```
|
|
227
|
-
5. team_spawn name:security agent:security-auditor worktree:false → audit full change
|
|
228
|
-
6. Wait → team_results → fix Critical findings → team_shutdown (no merge, worktree:false)
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### Phase 5, Ship
|
|
232
|
-
|
|
233
|
-
```
|
|
234
|
-
11. team_spawn name:devops agent:devops-manager (ship mode)
|
|
235
|
-
→ screenshots → commit & push → create PR → post comment
|
|
236
|
-
12. Wait → team_results → report PR URL to user
|
|
237
|
-
13. team_cleanup
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
### Phase 6, PR Feedback Loop
|
|
241
|
-
|
|
242
|
-
```
|
|
243
|
-
When user says "I've added comments to the PR" or asks to fix PR comments from PR URLs:
|
|
244
|
-
1. team_create "pr-feedback-<id>-<random>"
|
|
245
|
-
2. team_tasks_add with at least these lead-managed tasks:
|
|
246
|
-
- Parse and classify PR feedback (devops-manager)
|
|
247
|
-
- Implement Api feedback items (back-engineer, if needed)
|
|
248
|
-
- Implement App feedback items (front-engineer, if needed)
|
|
249
|
-
- Infra feedback items (infra-engineer, if needed)
|
|
250
|
-
- Verify with tests/build (quality-engineer)
|
|
251
|
-
- Push updates and post PR replies (devops-manager)
|
|
252
|
-
3. team_spawn devops-manager (feedback mode) with explicit task IDs, then team_message "Start now"
|
|
253
|
-
4. Wait for message → team_results
|
|
254
|
-
5. Add/update implementation tasks on board from parsed checklist (Api/App/Infra), then spawn needed specialists in parallel with explicit task IDs + team_message "Start now"
|
|
255
|
-
6. Wait for specialist results → team_shutdown + team_merge per specialist
|
|
256
|
-
7. team_spawn quality-engineer worktree:false with verification task ID + team_message "Start now"
|
|
257
|
-
8. Wait → team_results → fix blockers if any
|
|
258
|
-
9. team_spawn devops-manager (ship mode) with "push + update PR threads" task ID + team_message "Start now"
|
|
259
|
-
10. Wait → team_results → report what was updated
|
|
260
|
-
11. team_cleanup
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
---
|
|
264
|
-
|
|
265
|
-
## Agents
|
|
266
|
-
|
|
267
|
-
All agents are universal, no project-specific knowledge. Platform and tech knowledge comes from skills.
|
|
268
|
-
|
|
269
|
-
| Agent | File | Role |
|
|
270
|
-
|-------|------|------|
|
|
271
|
-
| `devops-manager` | .agents/agents/devops-manager.md | Reads work items, creates PRs, handles review feedback |
|
|
272
|
-
| `front-engineer` | .agents/agents/front-engineer.md | Web, mobile, UI implementation |
|
|
273
|
-
| `back-engineer` | .agents/agents/back-engineer.md | APIs, services, data, AI implementation |
|
|
274
|
-
| `infra-engineer` | .agents/agents/infra-engineer.md | Terraform, pipelines, cloud infrastructure |
|
|
275
|
-
| `quality-engineer` | .agents/agents/quality-engineer.md | Unit, integration, e2e tests across all layers |
|
|
276
|
-
| `security-auditor` | .agents/agents/security-auditor.md | Vulnerability audit, secrets, auth gaps |
|
|
277
|
-
|
|
278
|
-
## Skills
|
|
279
|
-
|
|
280
|
-
Skills provide platform and tech-specific knowledge. Agents detect and load them automatically, the user never specifies which skill to use.
|
|
281
|
-
|
|
282
|
-
Skills are located in `.agents/skills/`. Each skill has a `SKILL.md` with a description the agent reads to determine relevance.
|
|
283
|
-
|
|
284
|
-
| Skill | Purpose |
|
|
285
|
-
|-------|---------|
|
|
286
|
-
| `ob-userstory-az` | Parse Azure DevOps work item URL |
|
|
287
|
-
| `ob-userstory-gh` | Parse GitHub Issue URL |
|
|
288
|
-
| `ob-pullrequest-az` | Create PR on Azure DevOps |
|
|
289
|
-
| `ob-pullrequest-gh` | Create PR on GitHub |
|
|
290
|
-
| `openspec-propose` | Propose change artifacts (proposal, specs, tasks) |
|
|
291
|
-
| `openspec-apply-change` | Implement change with agent team |
|
|
292
|
-
| `openspec-archive-change` | Archive completed change |
|
|
293
|
-
| `browser-automation` | Browser automation for localhost UI, screenshots, clicks, queries |
|
|
294
|
-
|
|
295
|
-
---
|
|
296
|
-
|
|
297
|
-
## Branch Naming
|
|
298
|
-
|
|
299
|
-
Format: `feature/{issue-id}-{slug}`
|
|
300
|
-
Example: `feature/42-add-user-auth`
|
|
301
|
-
|
|
302
|
-
---
|
|
303
|
-
|
|
304
|
-
## Project Structure
|
|
305
|
-
|
|
306
|
-
```
|
|
307
|
-
[project-root]/
|
|
308
|
-
├── .agents/
|
|
309
|
-
│ ├── agents/ # Agent definitions (universal, no project knowledge)
|
|
310
|
-
│ └── skills/ # Skills (platform/tech specific knowledge)
|
|
311
|
-
├── openspec/
|
|
312
|
-
│ ├── specs/
|
|
313
|
-
│ └── changes/
|
|
314
|
-
│ └── {change}/
|
|
315
|
-
│ └── images/
|
|
316
|
-
├── AGENTS.md
|
|
317
|
-
├── ARCHITECTURE.md
|
|
318
|
-
└── DESIGN.md
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
---
|
|
322
|
-
|
|
323
|
-
## RTK
|
|
324
|
-
|
|
325
|
-
Use `rtk` wrapper for ALL CLI commands. Never run git, az, gh, or openspec commands directly.
|
|
326
|
-
|
|
327
|
-
- `rtk git add` NOT `git add`
|
|
328
|
-
- `rtk git commit` NOT `git commit`
|
|
329
|
-
- `rtk git push` NOT `git push`
|
|
330
|
-
- `rtk az boards work-item show` NOT `az boards work-item show`
|
|
331
|
-
- `rtk az repos pr create` NOT `az repos pr create`
|
|
332
|
-
- `rtk gh issue view` NOT `gh issue view`
|
|
333
|
-
- `rtk gh pr create` NOT `gh pr create`
|
|
334
|
-
- `rtk openspec new change` NOT `openspec new change`
|
|
335
|
-
|
|
336
|
-
---
|
|
337
|
-
|
|
338
|
-
## Guardrails
|
|
339
|
-
|
|
340
|
-
### Git Operations
|
|
341
|
-
|
|
342
|
-
Agents CAN:
|
|
343
|
-
- ✅ Commit to feature branches
|
|
344
|
-
- ✅ Push to feature branches
|
|
345
|
-
|
|
346
|
-
Agents CANNOT:
|
|
347
|
-
- ❌ Commit or push to `main`, FORBIDDEN
|
|
348
|
-
- ❌ Force push, FORBIDDEN
|
|
349
|
-
- ❌ Merge PRs, human-only
|
|
350
|
-
- ❌ Create or delete branches other than `feature/*`
|
|
351
|
-
|
|
352
|
-
### Platform CLI
|
|
353
|
-
|
|
354
|
-
ALL platform interactions via CLI only. Browser MCP and webfetch FORBIDDEN for any DevOps or GitHub operation, use `gh` or `az` CLI exclusively, never fall back to HTTP requests.
|
|
355
|
-
|
|
356
|
-
| Operation | Azure DevOps | GitHub |
|
|
357
|
-
|-----------|-------------|--------|
|
|
358
|
-
| Read issue | `az boards work-item show --id <id>` | `gh issue view <number>` |
|
|
359
|
-
| Read PR threads | `az devops invoke ...` | `gh pr view <number> --comments` |
|
|
360
|
-
| Create PR | `az repos pr create ...` | `gh pr create ...` |
|
|
361
|
-
|
|
362
|
-
Browser MCP tools permitted only for screenshots of **local running app** on `localhost` URLs.
|
|
363
|
-
|
|
364
|
-
### Security
|
|
365
|
-
|
|
366
|
-
Agents CANNOT:
|
|
367
|
-
- ❌ Access `.env` or config files with secrets
|
|
368
|
-
- ❌ Log or output credentials, API keys, or tokens
|
|
369
|
-
- ❌ Commit secrets to git
|
|
370
|
-
|
|
371
|
-
### Scope
|
|
372
|
-
|
|
373
|
-
- Max 10 files per change
|
|
374
|
-
- No architecture changes without human approval
|
|
375
|
-
- No pipeline modifications without human approval
|
|
376
|
-
|
|
377
|
-
---
|
|
378
|
-
|
|
379
|
-
## Communication Style
|
|
380
|
-
|
|
381
|
-
Terse. Technical substance exact. Only fluff die.
|
|
382
|
-
Drop: articles, filler, pleasantries, hedging.
|
|
383
|
-
Fragments OK. Short synonyms. Code unchanged.
|
|
384
|
-
Pattern: [thing] [action] [reason]. [next step].
|
|
1
|
+
# AGENTS.md, Bootstrap Mode
|
|
2
|
+
|
|
3
|
+
> This project has not been initialized yet.
|
|
4
|
+
> Your ONLY job right now is to run the initialization sequence below.
|
|
5
|
+
> Do not do anything else until all steps are complete.
|
|
6
|
+
|
|
7
|
+
## Trigger
|
|
8
|
+
|
|
9
|
+
When the user says anything resembling initialization, "init", "initialize", "setup", "start", "bootstrap", "get started", "prepare", execute all steps below in order. Do not ask for confirmation before starting.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Initialization Sequence
|
|
14
|
+
|
|
15
|
+
### Step 1, Archive project history into OpenSpec
|
|
16
|
+
|
|
17
|
+
Scan the codebase for any existing documentation, changelogs, ADRs, README files, or notable history that describes decisions already made in this project. Create an OpenSpec archive entry that captures this history so agents have context going forward.
|
|
18
|
+
|
|
19
|
+
Before scanning, load source roots from `.agents/source-roots.json` when present. Only scan those roots plus this repo's docs/config files.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
openspec new change "project-history"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Write a `proposal.md` inside that change summarizing:
|
|
26
|
+
- What this project is
|
|
27
|
+
- Key decisions already made (inferred from code and docs)
|
|
28
|
+
- Known tech debt or constraints visible in the codebase
|
|
29
|
+
- Current state of the project
|
|
30
|
+
|
|
31
|
+
Then archive it immediately:
|
|
32
|
+
```bash
|
|
33
|
+
openspec archive "project-history"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
### Step 2, Generate DESIGN.md
|
|
39
|
+
|
|
40
|
+
`DESIGN.md` contains a prompt. You MUST follow this exact sequence, do not skip or reorder steps:
|
|
41
|
+
|
|
42
|
+
1. **Read `DESIGN.md` now** using a file read tool. The file contains a prompt with instructions and an output format.
|
|
43
|
+
2. **Store the full prompt text** in your context.
|
|
44
|
+
3. **Overwrite `DESIGN.md` with an empty string** (zero bytes). Do this before generating any content.
|
|
45
|
+
4. **Analyze the actual codebase**: use `.agents/source-roots.json` as source roots when present, then read CSS files, Tailwind config, component files, token definitions. Do not rely on prior knowledge, read the files.
|
|
46
|
+
5. **Write the result into `DESIGN.md`** following exactly the format and sections described in the stored prompt.
|
|
47
|
+
|
|
48
|
+
The output must be a real, populated `DESIGN.md` based on what you found in the codebase, not from memory or assumptions.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
### Step 3, Generate ARCHITECTURE.md
|
|
53
|
+
|
|
54
|
+
`ARCHITECTURE.md` contains a prompt. You MUST follow this exact sequence, do not skip or reorder steps:
|
|
55
|
+
|
|
56
|
+
1. **Read `ARCHITECTURE.md` now** using a file read tool. The file contains a prompt with instructions and an output format.
|
|
57
|
+
2. **Store the full prompt text** in your context.
|
|
58
|
+
3. **Overwrite `ARCHITECTURE.md` with an empty string** (zero bytes). Do this before generating any content.
|
|
59
|
+
4. **Analyze the actual codebase**: use `.agents/source-roots.json` as source roots when present, then read folder structure, config files, route definitions, data models, integration points. Do not rely on prior knowledge, read the files.
|
|
60
|
+
5. **Write the result into `ARCHITECTURE.md`** following exactly the format and sections described in the stored prompt.
|
|
61
|
+
|
|
62
|
+
The output must be a real, populated `ARCHITECTURE.md` based on what you found in the codebase, covering all sections the prompt describes.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### Step 4, Rewrite this file
|
|
67
|
+
|
|
68
|
+
Replace the entire contents of this file (`AGENTS.md`) with everything below the line `<!-- AGENTS-TEMPLATE-START -->` in this same file. Delete the bootstrap section and the template marker, the file should contain only the template content when done.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### Step 5, Confirm
|
|
73
|
+
|
|
74
|
+
Tell the user:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
78
|
+
Initialization complete.
|
|
79
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
80
|
+
|
|
81
|
+
- ARCHITECTURE.md generated
|
|
82
|
+
- DESIGN.md generated
|
|
83
|
+
- Project history archived in openspec
|
|
84
|
+
- AGENTS.md updated with real guidance
|
|
85
|
+
|
|
86
|
+
!! RESTART OPENCODE NOW !!
|
|
87
|
+
|
|
88
|
+
Quit and reopen OpenCode before doing anything else.
|
|
89
|
+
Nothing will work correctly until you do.
|
|
90
|
+
After restarting you are ready to work.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Guardrails During Init
|
|
96
|
+
|
|
97
|
+
- Do NOT implement any features
|
|
98
|
+
- Do NOT create branches or PRs
|
|
99
|
+
- Do NOT modify any project source files
|
|
100
|
+
- Do NOT create RTK files, scripts, or wrappers, RTK is already defined in AGENTS.md and agent files
|
|
101
|
+
- Only read source files for analysis, write only to ARCHITECTURE.md, DESIGN.md, AGENTS.md, and openspec/
|
|
102
|
+
|
|
103
|
+
<!-- AGENTS-TEMPLATE-START -->
|
|
104
|
+
# AGENTS.md
|
|
105
|
+
|
|
106
|
+
This file provides guidance to AI agents when working in this repository.
|
|
107
|
+
|
|
108
|
+
*Agent-agnostic, works with OpenCode, Claude Code, Codex, Gemini, etc.*
|
|
109
|
+
|
|
110
|
+
## Project Overview
|
|
111
|
+
|
|
112
|
+
This is the agent orchestration layer for your project. It provides:
|
|
113
|
+
- Universal agent team for development workflow
|
|
114
|
+
- OpenSpec change management
|
|
115
|
+
- Skills for platform-specific knowledge
|
|
116
|
+
|
|
117
|
+
## Source Scope
|
|
118
|
+
|
|
119
|
+
- Read source scope from `.agents/source-roots.json`.
|
|
120
|
+
- Use those roots for codebase analysis tasks (design, architecture, project-history, exploration).
|
|
121
|
+
- If missing, default to current folder.
|
|
122
|
+
|
|
123
|
+
## I Am the Lead, Full Workflow Ownership
|
|
124
|
+
|
|
125
|
+
When the user provides a work item URL or says "implement the plan" or "I've added comments to the PR", **I own the full lifecycle**. I load the appropriate skill and use ensemble tools to coordinate the agent team.
|
|
126
|
+
|
|
127
|
+
Trigger patterns, I recognize ALL of these, exact wording does not matter:
|
|
128
|
+
- User pastes or mentions a GitHub Issue URL → load `ob-userstory-gh` skill → parse issue → run `/opsx-propose` → confirm with user → run `/opsx-apply` → ship
|
|
129
|
+
- User pastes or mentions an Azure DevOps URL → load `ob-userstory-az` skill → parse work item → run `/opsx-propose` → confirm with user → run `/opsx-apply` → ship
|
|
130
|
+
- `implement the plan` / `implement` / `start` / `go` → run `/opsx-apply` → ship
|
|
131
|
+
- `I've added comments to the PR` → read PR comments → fix → update PR
|
|
132
|
+
- Any GitHub/Azure DevOps PR URL in a feedback/fix request (e.g. "check comments", "fix PR feedback") → run PR Feedback Loop
|
|
133
|
+
|
|
134
|
+
**A GitHub or Azure DevOps URL anywhere in the user's message is always a trigger, regardless of surrounding words.**
|
|
135
|
+
|
|
136
|
+
**Never delegate without a plan. Never write implementation code directly, always spawn specialists, no exceptions. "Small feature", "faster to do it directly", or "environment issues" are not valid reasons to skip ensemble.**
|
|
137
|
+
|
|
138
|
+
## Multi-Agent Execution, opencode-ensemble
|
|
139
|
+
|
|
140
|
+
Parallel execution uses the `opencode-ensemble` plugin (`team_create`, `team_spawn`, etc.).
|
|
141
|
+
Works on **all platforms** (Windows, macOS, Linux) via OpenCode's built-in worktree support.
|
|
142
|
+
|
|
143
|
+
| Tool | What it does |
|
|
144
|
+
|------|-------------|
|
|
145
|
+
| `team_create` | Create a team (caller becomes lead) |
|
|
146
|
+
| `team_spawn` | Start a teammate asynchronously |
|
|
147
|
+
| `team_shutdown` | Stop a teammate, preserve their branch |
|
|
148
|
+
| `team_merge` | Merge a teammate's branch into working dir |
|
|
149
|
+
| `team_cleanup` | Tear down the team |
|
|
150
|
+
| `team_results` | Retrieve full message content (delivery is a ping only) |
|
|
151
|
+
| `team_message` | Send a direct message to a teammate or lead |
|
|
152
|
+
| `team_broadcast` | Message all teammates |
|
|
153
|
+
| `team_status` | View all members and task summary |
|
|
154
|
+
| `team_tasks_list` | View the shared task board |
|
|
155
|
+
| `team_tasks_add` | Add tasks to shared board |
|
|
156
|
+
| `team_tasks_complete` | Mark task done, auto-unblocks dependents |
|
|
157
|
+
| `team_claim` | Atomically claim a pending task (teammates use this) |
|
|
158
|
+
|
|
159
|
+
**Dashboard**: Monitor running agents at **http://localhost:4747/**
|
|
160
|
+
|
|
161
|
+
**Progress inspection commands (tell user explicitly after spawning):**
|
|
162
|
+
- `team_status` for live team snapshot
|
|
163
|
+
- `team_tasks_list` for task board state
|
|
164
|
+
- `team_view member:"<name>"` to inspect a teammate live session
|
|
165
|
+
- `team_results from:"<name>"` to fetch full teammate report text
|
|
166
|
+
|
|
167
|
+
If a teammate stalls due to model quota/rate-limit exhaustion:
|
|
168
|
+
1. `team_shutdown name:"<stuck-member>" force:true`
|
|
169
|
+
2. `team_spawn` same member/task with an available model
|
|
170
|
+
3. `team_message` start instruction with the exact next task ID
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Pipeline
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
devops-manager (read mode)
|
|
178
|
+
→ parse work item via skill → structured summary
|
|
179
|
+
↓
|
|
180
|
+
openspec-propose
|
|
181
|
+
→ proposal.md + specs + tasks
|
|
182
|
+
↓
|
|
183
|
+
[confirm with user]
|
|
184
|
+
↓
|
|
185
|
+
back-engineer → front-engineer → infra-engineer ← sequential, one at a time, only spawn what the task needs
|
|
186
|
+
↓
|
|
187
|
+
quality-engineer (worktree:false)
|
|
188
|
+
→ tests, build, lint, acceptance criteria
|
|
189
|
+
↓
|
|
190
|
+
security-auditor (worktree:false)
|
|
191
|
+
→ vulnerability audit, secrets, auth gaps
|
|
192
|
+
↓
|
|
193
|
+
devops-manager (ship mode)
|
|
194
|
+
→ screenshots → commit → push → PR → post comment
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Phase 1, Parse & Propose
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
1. Detect URL type → load matching skill (ob-userstory-gh or ob-userstory-az)
|
|
201
|
+
2. Follow skill steps: fetch issue/work item via CLI, create OpenSpec change
|
|
202
|
+
3. Run /opsx-propose → generates proposal.md, specs/, design.md, tasks.md
|
|
203
|
+
4. Show the plan: change name, total tasks, task list summary
|
|
204
|
+
5. STOP. Ask user: "Ready to implement? (yes/no)", DO NOT proceed until confirmed.
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Phase 2, Implement
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
1. Run /opsx-apply, handles context reading, ensemble orchestration, and task marking.
|
|
211
|
+
- Lead adds all tasks to board, then spawns specialists ONE AT A TIME (not parallel)
|
|
212
|
+
- Each specialist claims tasks, implements, completes tasks, messages lead when done
|
|
213
|
+
- Lead merges each branch after shutdown, then marks tasks done in tasks.md
|
|
214
|
+
2. After /opsx-apply completes, proceed to quality check.
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Phase 3, Quality
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
3. team_spawn name:quality agent:quality-engineer worktree:false → tests, build, lint
|
|
221
|
+
4. Wait → team_results → fix any blockers → team_shutdown (no merge, worktree:false)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Phase 4, Security
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
5. team_spawn name:security agent:security-auditor worktree:false → audit full change
|
|
228
|
+
6. Wait → team_results → fix Critical findings → team_shutdown (no merge, worktree:false)
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Phase 5, Ship
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
11. team_spawn name:devops agent:devops-manager (ship mode)
|
|
235
|
+
→ screenshots → commit & push → create PR → post comment
|
|
236
|
+
12. Wait → team_results → report PR URL to user
|
|
237
|
+
13. team_cleanup
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Phase 6, PR Feedback Loop
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
When user says "I've added comments to the PR" or asks to fix PR comments from PR URLs:
|
|
244
|
+
1. team_create "pr-feedback-<id>-<random>"
|
|
245
|
+
2. team_tasks_add with at least these lead-managed tasks:
|
|
246
|
+
- Parse and classify PR feedback (devops-manager)
|
|
247
|
+
- Implement Api feedback items (back-engineer, if needed)
|
|
248
|
+
- Implement App feedback items (front-engineer, if needed)
|
|
249
|
+
- Infra feedback items (infra-engineer, if needed)
|
|
250
|
+
- Verify with tests/build (quality-engineer)
|
|
251
|
+
- Push updates and post PR replies (devops-manager)
|
|
252
|
+
3. team_spawn devops-manager (feedback mode) with explicit task IDs, then team_message "Start now"
|
|
253
|
+
4. Wait for message → team_results
|
|
254
|
+
5. Add/update implementation tasks on board from parsed checklist (Api/App/Infra), then spawn needed specialists in parallel with explicit task IDs + team_message "Start now"
|
|
255
|
+
6. Wait for specialist results → team_shutdown + team_merge per specialist
|
|
256
|
+
7. team_spawn quality-engineer worktree:false with verification task ID + team_message "Start now"
|
|
257
|
+
8. Wait → team_results → fix blockers if any
|
|
258
|
+
9. team_spawn devops-manager (ship mode) with "push + update PR threads" task ID + team_message "Start now"
|
|
259
|
+
10. Wait → team_results → report what was updated
|
|
260
|
+
11. team_cleanup
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Agents
|
|
266
|
+
|
|
267
|
+
All agents are universal, no project-specific knowledge. Platform and tech knowledge comes from skills.
|
|
268
|
+
|
|
269
|
+
| Agent | File | Role |
|
|
270
|
+
|-------|------|------|
|
|
271
|
+
| `devops-manager` | .agents/agents/devops-manager.md | Reads work items, creates PRs, handles review feedback |
|
|
272
|
+
| `front-engineer` | .agents/agents/front-engineer.md | Web, mobile, UI implementation |
|
|
273
|
+
| `back-engineer` | .agents/agents/back-engineer.md | APIs, services, data, AI implementation |
|
|
274
|
+
| `infra-engineer` | .agents/agents/infra-engineer.md | Terraform, pipelines, cloud infrastructure |
|
|
275
|
+
| `quality-engineer` | .agents/agents/quality-engineer.md | Unit, integration, e2e tests across all layers |
|
|
276
|
+
| `security-auditor` | .agents/agents/security-auditor.md | Vulnerability audit, secrets, auth gaps |
|
|
277
|
+
|
|
278
|
+
## Skills
|
|
279
|
+
|
|
280
|
+
Skills provide platform and tech-specific knowledge. Agents detect and load them automatically, the user never specifies which skill to use.
|
|
281
|
+
|
|
282
|
+
Skills are located in `.agents/skills/`. Each skill has a `SKILL.md` with a description the agent reads to determine relevance.
|
|
283
|
+
|
|
284
|
+
| Skill | Purpose |
|
|
285
|
+
|-------|---------|
|
|
286
|
+
| `ob-userstory-az` | Parse Azure DevOps work item URL |
|
|
287
|
+
| `ob-userstory-gh` | Parse GitHub Issue URL |
|
|
288
|
+
| `ob-pullrequest-az` | Create PR on Azure DevOps |
|
|
289
|
+
| `ob-pullrequest-gh` | Create PR on GitHub |
|
|
290
|
+
| `openspec-propose` | Propose change artifacts (proposal, specs, tasks) |
|
|
291
|
+
| `openspec-apply-change` | Implement change with agent team |
|
|
292
|
+
| `openspec-archive-change` | Archive completed change |
|
|
293
|
+
| `browser-automation` | Browser automation for localhost UI, screenshots, clicks, queries |
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Branch Naming
|
|
298
|
+
|
|
299
|
+
Format: `feature/{issue-id}-{slug}`
|
|
300
|
+
Example: `feature/42-add-user-auth`
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Project Structure
|
|
305
|
+
|
|
306
|
+
```
|
|
307
|
+
[project-root]/
|
|
308
|
+
├── .agents/
|
|
309
|
+
│ ├── agents/ # Agent definitions (universal, no project knowledge)
|
|
310
|
+
│ └── skills/ # Skills (platform/tech specific knowledge)
|
|
311
|
+
├── openspec/
|
|
312
|
+
│ ├── specs/
|
|
313
|
+
│ └── changes/
|
|
314
|
+
│ └── {change}/
|
|
315
|
+
│ └── images/
|
|
316
|
+
├── AGENTS.md
|
|
317
|
+
├── ARCHITECTURE.md
|
|
318
|
+
└── DESIGN.md
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## RTK
|
|
324
|
+
|
|
325
|
+
Use `rtk` wrapper for ALL CLI commands. Never run git, az, gh, or openspec commands directly.
|
|
326
|
+
|
|
327
|
+
- `rtk git add` NOT `git add`
|
|
328
|
+
- `rtk git commit` NOT `git commit`
|
|
329
|
+
- `rtk git push` NOT `git push`
|
|
330
|
+
- `rtk az boards work-item show` NOT `az boards work-item show`
|
|
331
|
+
- `rtk az repos pr create` NOT `az repos pr create`
|
|
332
|
+
- `rtk gh issue view` NOT `gh issue view`
|
|
333
|
+
- `rtk gh pr create` NOT `gh pr create`
|
|
334
|
+
- `rtk openspec new change` NOT `openspec new change`
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## Guardrails
|
|
339
|
+
|
|
340
|
+
### Git Operations
|
|
341
|
+
|
|
342
|
+
Agents CAN:
|
|
343
|
+
- ✅ Commit to feature branches
|
|
344
|
+
- ✅ Push to feature branches
|
|
345
|
+
|
|
346
|
+
Agents CANNOT:
|
|
347
|
+
- ❌ Commit or push to `main`, FORBIDDEN
|
|
348
|
+
- ❌ Force push, FORBIDDEN
|
|
349
|
+
- ❌ Merge PRs, human-only
|
|
350
|
+
- ❌ Create or delete branches other than `feature/*`
|
|
351
|
+
|
|
352
|
+
### Platform CLI
|
|
353
|
+
|
|
354
|
+
ALL platform interactions via CLI only. Browser MCP and webfetch FORBIDDEN for any DevOps or GitHub operation, use `gh` or `az` CLI exclusively, never fall back to HTTP requests.
|
|
355
|
+
|
|
356
|
+
| Operation | Azure DevOps | GitHub |
|
|
357
|
+
|-----------|-------------|--------|
|
|
358
|
+
| Read issue | `az boards work-item show --id <id>` | `gh issue view <number>` |
|
|
359
|
+
| Read PR threads | `az devops invoke ...` | `gh pr view <number> --comments` |
|
|
360
|
+
| Create PR | `az repos pr create ...` | `gh pr create ...` |
|
|
361
|
+
|
|
362
|
+
Browser MCP tools permitted only for screenshots of **local running app** on `localhost` URLs.
|
|
363
|
+
|
|
364
|
+
### Security
|
|
365
|
+
|
|
366
|
+
Agents CANNOT:
|
|
367
|
+
- ❌ Access `.env` or config files with secrets
|
|
368
|
+
- ❌ Log or output credentials, API keys, or tokens
|
|
369
|
+
- ❌ Commit secrets to git
|
|
370
|
+
|
|
371
|
+
### Scope
|
|
372
|
+
|
|
373
|
+
- Max 10 files per change
|
|
374
|
+
- No architecture changes without human approval
|
|
375
|
+
- No pipeline modifications without human approval
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## Communication Style
|
|
380
|
+
|
|
381
|
+
Terse. Technical substance exact. Only fluff die.
|
|
382
|
+
Drop: articles, filler, pleasantries, hedging.
|
|
383
|
+
Fragments OK. Short synonyms. Code unchanged.
|
|
384
|
+
Pattern: [thing] [action] [reason]. [next step].
|