@guilhermefsousa/open-spec-kit 0.0.10 → 0.0.11
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 +1 -1
- package/bin/open-spec-kit.js +7 -0
- package/package.json +1 -1
- package/src/commands/doctor.js +107 -197
- package/src/commands/init.js +112 -347
- package/src/commands/install.js +393 -0
- package/src/commands/update.js +117 -165
- package/src/schemas/spec.schema.js +3 -3
- package/src/utils/global-path.js +73 -0
- package/templates/agents/agents/spec-hub.agent.md +13 -13
- package/templates/agents/rules/hub_structure.instructions.md +1 -1
- package/templates/agents/rules/ownership.instructions.md +39 -39
- package/templates/agents/skills/dev-orchestrator/SKILL.md +17 -17
- package/templates/agents/skills/discovery/SKILL.md +17 -17
- package/templates/agents/skills/setup-project/SKILL.md +12 -12
- package/templates/agents/skills/specifying-features/SKILL.md +28 -28
- package/templates/github/agents/spec-hub.agent.md +5 -5
- package/templates/github/copilot-instructions.md +9 -9
- package/templates/github/instructions/hub_structure.instructions.md +1 -1
- package/templates/github/instructions/ownership.instructions.md +9 -9
- package/templates/github/skills/dev-orchestrator/SKILL.md +619 -5
- package/templates/github/skills/discovery/SKILL.md +419 -5
- package/templates/github/skills/setup-project/SKILL.md +496 -5
- package/templates/github/skills/specifying-features/SKILL.md +417 -5
- /package/templates/github/prompts/{dev.prompt.md → osk-build.prompt.md} +0 -0
- /package/templates/github/prompts/{discovery.prompt.md → osk-discover.prompt.md} +0 -0
- /package/templates/github/prompts/{setup.prompt.md → osk-init.prompt.md} +0 -0
- /package/templates/github/prompts/{nova-feature.prompt.md → osk-spec.prompt.md} +0 -0
|
@@ -1,9 +1,623 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
description: "
|
|
2
|
+
name: osk-build
|
|
3
|
+
description: "Orchestrates feature implementation: reads approved spec, selects the right coding agent by stack, creates branches, runs TDD cycle, handles test failures, creates MRs, and updates living docs on Confluence post-merge."
|
|
4
|
+
metadata:
|
|
5
|
+
works_on: [copilot, antigravity, claude]
|
|
6
|
+
argument-hint: "[spec number, e.g. 001] or [spec number --post-merge]"
|
|
4
7
|
---
|
|
5
8
|
|
|
6
|
-
# Dev Orchestrator
|
|
9
|
+
# Dev Orchestrator
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
## Objective
|
|
12
|
+
|
|
13
|
+
Take an approved spec and orchestrate its implementation end-to-end: select the right coding agent, create branches, implement with TDD, validate, create MRs, and update living documentation after merge.
|
|
14
|
+
|
|
15
|
+
## Before you start
|
|
16
|
+
|
|
17
|
+
### Validate prerequisites
|
|
18
|
+
|
|
19
|
+
1. Check that `specs/NNN-name/` exists and contains all 5 files (brief.md, contracts.md, scenarios.md, tasks.md, links.md). If any file is missing: **stop** with message: "Spec incompleta. Execute /osk-spec antes de /osk-build."
|
|
20
|
+
2. In Confluence (via MCP — same as /osk-init), check the feature page labels:
|
|
21
|
+
- If label `em-spec` is NOT present: **stop** — "Feature não passou pelo /osk-spec. Execute /osk-discover e /osk-spec antes de /osk-build."
|
|
22
|
+
- If label `prd-rejeitado` is present AND its addition date is MORE RECENT than `em-spec`: **stop** — "PRD foi rejeitado após a spec. Execute /osk-discover novamente para resolver." (Check via MCP — page metadata or label order.)
|
|
23
|
+
- Otherwise: proceed
|
|
24
|
+
3. Check for concurrent execution: if there's an active branch `feat/NNN-*` in any repo, **WARN and PAUSE** — display message: "Branch ativa `feat/NNN-*` encontrada. Continuar mesmo assim? (pode causar conflitos)". Only proceed with explicit dev confirmation.
|
|
25
|
+
|
|
26
|
+
### Read context
|
|
27
|
+
|
|
28
|
+
Read these files FIRST:
|
|
29
|
+
|
|
30
|
+
1. `projects.yml` — repos, stack, dependencies
|
|
31
|
+
2. `docs/architecture.md` — system structure
|
|
32
|
+
3. ALL files in `docs/lessons/` — past mistakes to avoid
|
|
33
|
+
4. The approved spec in `specs/NNN-name/` (all 5 files)
|
|
34
|
+
|
|
35
|
+
## Inputs
|
|
36
|
+
|
|
37
|
+
- Approved spec number (e.g., `001`)
|
|
38
|
+
- Spec files: `brief.md`, `contracts.md`, `scenarios.md`, `tasks.md`, `links.md`
|
|
39
|
+
|
|
40
|
+
## Agent selection
|
|
41
|
+
|
|
42
|
+
Read `projects.yml` → `agents` section to select agents dynamically.
|
|
43
|
+
|
|
44
|
+
### Coding agents
|
|
45
|
+
|
|
46
|
+
For each repo in tasks.md:
|
|
47
|
+
1. Read the repo's `stack` from `projects.yml` repos[]
|
|
48
|
+
2. Normalize the stack keyword to lowercase (e.g., ".NET" → "dotnet", "Node.js" → "nodejs")
|
|
49
|
+
3. Look up in `projects.yml` → `agents.coding.{keyword}`
|
|
50
|
+
4. If found: use that agent name
|
|
51
|
+
5. If NOT found: **STOP** — "Stack '{stack}' sem agent configurado. Adicione o mapeamento em projects.yml → agents.coding."
|
|
52
|
+
|
|
53
|
+
If multiple stacks (e.g., API in .NET, Front in React), use different agents per repo.
|
|
54
|
+
|
|
55
|
+
### Support agents
|
|
56
|
+
|
|
57
|
+
Read from `projects.yml` → `agents` section:
|
|
58
|
+
|
|
59
|
+
| Role | Config key | If null or missing |
|
|
60
|
+
|------|-----------|-------------------|
|
|
61
|
+
| Security scan | `agents.security` | Skip scan, add note to MR: "Security scan manual necessário" |
|
|
62
|
+
| Code review | `agents.code_review` | Skip pre-review, notify dev |
|
|
63
|
+
| Design document | `agents.design_doc` | Update DD directly no Confluence (read → append → update) |
|
|
64
|
+
|
|
65
|
+
**All agent names come from projects.yml. Skills NEVER hardcode agent names.**
|
|
66
|
+
|
|
67
|
+
## Flow
|
|
68
|
+
|
|
69
|
+
### Phase A — Preparation
|
|
70
|
+
|
|
71
|
+
1. Read the full spec (contracts.md, scenarios.md, tasks.md)
|
|
72
|
+
2. Read `specs/NNN-name/audit-report.md` — if it contains ⚠️ items, evaluate whether they block implementation. If it contains ❌ items, **stop**: "Spec não passou no audit. Execute /osk-spec novamente."
|
|
73
|
+
3. Parse tasks.md to identify:
|
|
74
|
+
- Task groups per repo
|
|
75
|
+
- Dependencies between groups
|
|
76
|
+
- Parallelizable groups (marked `[P]`)
|
|
77
|
+
- Execution order
|
|
78
|
+
4. **Check if repos exist** — for each repo referenced in tasks.md:
|
|
79
|
+
- Look up the repo in `projects.yml`
|
|
80
|
+
- If `status: active` and `url` is filled → repo exists, skip
|
|
81
|
+
- If `status: planned` and `url` is null → **create the repo** (see Phase A.1 below)
|
|
82
|
+
- If the repo is NOT declared in projects.yml → stop and ask the dev
|
|
83
|
+
5. Create GitLab/GitHub Issues (1 per task) via API or terminal:
|
|
84
|
+
- Title: `[NNN] task description`
|
|
85
|
+
- Labels: `spec`, `NNN-feature-name`
|
|
86
|
+
- Assign to the repo's issue board
|
|
87
|
+
|
|
88
|
+
### Phase A.1 — Auto-create repo (when needed)
|
|
89
|
+
|
|
90
|
+
When a repo has `status: planned` in projects.yml:
|
|
91
|
+
|
|
92
|
+
1. **Create the repo** on the VCS declared in `projects.yml` (`vcs` field):
|
|
93
|
+
- `github`: `gh repo create {vcs_org}/{repo-name} --private`
|
|
94
|
+
- `gitlab`: `glab project create {repo-name} --group {vcs_org}`
|
|
95
|
+
- If `vcs` field is missing in projects.yml: infer from existing repo URLs. If no repos exist yet, **stop** and ask the dev: "Qual VCS usar? Adicione `vcs: github` ou `vcs: gitlab` e `vcs_org: {org}` no projects.yml."
|
|
96
|
+
2. **Clone locally** and initialize
|
|
97
|
+
3. **Select the engineer agent** for the repo's stack (see Agent selection table)
|
|
98
|
+
4. **Engineer agent scaffolds the project:**
|
|
99
|
+
- Project structure (folders, base files)
|
|
100
|
+
- CI/CD pipeline config (Dockerfile, docker-compose service, .gitlab-ci.yml or GitHub Actions)
|
|
101
|
+
- .gitignore, README.md
|
|
102
|
+
- Base dependencies (package.json, .csproj, pom.xml, etc.)
|
|
103
|
+
- Initial commit with scaffold
|
|
104
|
+
5. **Push to remote**
|
|
105
|
+
6. **Update projects.yml:**
|
|
106
|
+
- `url` → the new repo URL
|
|
107
|
+
- `status` → `active`
|
|
108
|
+
7. **Commit projects.yml change** in the spec repo
|
|
109
|
+
|
|
110
|
+
The scaffold should be minimal but functional — the engineer agent knows the stack conventions. No business logic at this point, just the skeleton.
|
|
111
|
+
|
|
112
|
+
**Rollback on failure**: if any step of Phase A.1 fails AFTER the repo was created on the VCS, do NOT update projects.yml. Report to dev: "Repo '{name}' criado no VCS mas scaffold incompleto. Estado: {last_successful_step}. Resolução manual necessária."
|
|
113
|
+
|
|
114
|
+
**docker-compose**: if the project uses Docker (check `projects.yml` stack), the scaffold MUST include:
|
|
115
|
+
- `Dockerfile` for the component
|
|
116
|
+
- Entry in the project's `docker-compose.yml` (if it exists) or creation of a new `docker-compose.yml` with the service + dependencies (PostgreSQL, RabbitMQ, etc.)
|
|
117
|
+
|
|
118
|
+
### Phase B — Execution (per task, in dependency order)
|
|
119
|
+
|
|
120
|
+
**Before starting execution**: change the feature label on Confluence → `em-dev`.
|
|
121
|
+
|
|
122
|
+
**Dependency check**: before executing a task, verify that all tasks it depends on (from tasks.md dependency graph) are completed. If a dependency is `blocked`, mark the current task as `blocked-dependency` and skip it. Notify dev: "Task '{task}' bloqueada porque depende de '{blocked_task}' que está bloqueada."
|
|
123
|
+
|
|
124
|
+
For each task (move GitLab Issue → `in-progress` when starting):
|
|
125
|
+
|
|
126
|
+
B.1. Open/clone the correct repo (from projects.yml — now guaranteed to exist)
|
|
127
|
+
B.2. Create branch: `feat/NNN-short-description`
|
|
128
|
+
B.3. **Invoke the coding agent — RED phase (generate tests)**
|
|
129
|
+
- Invoke the coding agent for this repo's stack (see Agent selection table)
|
|
130
|
+
- Agent receives: `scenarios.md`, `contracts.md`, `tasks.md` (the specific task)
|
|
131
|
+
- Agent's goal: generate tests that translate EVERY CT-NNN-XX mapped to this task
|
|
132
|
+
- Each CT's Given/When/Then IS the test specification — the agent translates to the stack's test framework
|
|
133
|
+
- Tests MUST be a **faithful translation** — do NOT invent tests not in scenarios.md, do NOT skip scenarios
|
|
134
|
+
- Tests MUST fail initially (red phase) — if they pass before implementation, the test is wrong
|
|
135
|
+
- **Why test-first matters with AI agents**: without a failing test as objective criteria, the agent declares "done" without proof. The test is the contract between the spec and the code. (ref: arXiv 2402.13521, DORA 2025, TDAD arXiv 2603.17973)
|
|
136
|
+
|
|
137
|
+
B.3.5. **Commit tests (RED) — MANDATORY before starting implementation**
|
|
138
|
+
After generating ALL tests, commit immediately — before any implementation code:
|
|
139
|
+
```bash
|
|
140
|
+
git add -A
|
|
141
|
+
git commit -m "test(NNN): failing tests for {task-short-name} [RED]"
|
|
142
|
+
```
|
|
143
|
+
This ensures tests are not lost if execution is interrupted. Without this commit, an interruption loses all RED phase work.
|
|
144
|
+
|
|
145
|
+
B.4. **Orchestrator validates RED phase**
|
|
146
|
+
- Count CTs in scenarios.md that map to this task → count tests generated
|
|
147
|
+
- If count(CTs) != count(tests): list missing CTs and ask the coding agent to add them
|
|
148
|
+
- Run tests → confirm ALL fail (red). If any passes, flag it — the test may be testing nothing
|
|
149
|
+
|
|
150
|
+
B.5. **Invoke the coding agent — GREEN phase (implement code)**
|
|
151
|
+
- Same coding agent, same context, PLUS the failing tests from B.3
|
|
152
|
+
- Agent's goal: implement the code to make ALL tests pass
|
|
153
|
+
- Agent MUST NOT modify the tests — only the implementation code
|
|
154
|
+
- If a test is wrong (contradicts contracts.md), the orchestrator fixes the test and re-runs — never the coding agent
|
|
155
|
+
- `docs/lessons/` provided as context — mistakes to avoid
|
|
156
|
+
|
|
157
|
+
B.5.5. **Commit implementation (GREEN) — MANDATORY after all tests pass**
|
|
158
|
+
After ALL tests pass, commit immediately:
|
|
159
|
+
```bash
|
|
160
|
+
git add -A
|
|
161
|
+
git commit -m "feat(NNN): implement {task-short-name} — all tests pass [GREEN]"
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Phase C — Validation
|
|
165
|
+
|
|
166
|
+
C.1. Run tests
|
|
167
|
+
C.2. **If tests fail:**
|
|
168
|
+
- Read the error output
|
|
169
|
+
- Attempt to fix (max 3 retries)
|
|
170
|
+
- If fixed → continue
|
|
171
|
+
- If not fixed after 3 retries:
|
|
172
|
+
- Move VCS Issue → `blocked`
|
|
173
|
+
- **Preservar trabalho antes de notificar**:
|
|
174
|
+
```bash
|
|
175
|
+
git add -A
|
|
176
|
+
git commit -m "wip(NNN): blocked after 3 retries — {error-summary}"
|
|
177
|
+
```
|
|
178
|
+
- Notify Google Chat:
|
|
179
|
+
```bash
|
|
180
|
+
./scripts/notify-gchat.sh --card \
|
|
181
|
+
--title "🚫 Task bloqueada" \
|
|
182
|
+
--subtitle "{project_name} — {feature_name}" \
|
|
183
|
+
--body "Task '{task_description}' falhou após 3 tentativas. Erro: {error_summary}. Salvo em docs/lessons/." \
|
|
184
|
+
--button-text "Ver Issue" \
|
|
185
|
+
--button-url "{vcs_issue_url}"
|
|
186
|
+
```
|
|
187
|
+
- Save failure context to `docs/lessons/` for future reference
|
|
188
|
+
- SKIP to next task
|
|
189
|
+
- **Unblocking**: to resume a blocked task, the dev re-runs `/osk-build NNN`. The agent detects tasks with `blocked` status, displays the saved context from `docs/lessons/`, and asks the dev whether to retry. If the dev confirms, the 3-retry counter resets. If the same task blocks again after another 3 retries, escalate to TL via GChat and mark the task as `blocked-permanent`. Do NOT auto-retry without dev confirmation — this prevents infinite loops.
|
|
190
|
+
|
|
191
|
+
C.3. **Conformance check** (inspired by OpenSpec's `/opsx:verify`)
|
|
192
|
+
|
|
193
|
+
After tests pass, verify that the implementation faithfully reflects contracts.md. The orchestrator reads contracts.md and delegates verification to the coding agent for the repo's stack.
|
|
194
|
+
|
|
195
|
+
**Dimension 1 — Completeness (endpoints)**:
|
|
196
|
+
The orchestrator extracts the endpoint table from contracts.md (Method + Route columns) and asks the coding agent:
|
|
197
|
+
> "List all registered routes in this application (HTTP method + path). Compare against this endpoint table from contracts.md. Report: endpoints in the spec but missing in code, and endpoints in code not in the spec."
|
|
198
|
+
|
|
199
|
+
**Dimension 2 — Correctness (paths and response fields)**:
|
|
200
|
+
The orchestrator extracts response type field names from contracts.md and asks the coding agent:
|
|
201
|
+
> "For each endpoint, verify that the response object returned has EXACTLY the same field names as defined in contracts.md. Report missing, renamed, or extra fields."
|
|
202
|
+
|
|
203
|
+
**Conformance report** — the coding agent returns:
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
## Conformance Report
|
|
207
|
+
|
|
208
|
+
### Endpoints
|
|
209
|
+
| Spec (contracts.md) | Code | Status |
|
|
210
|
+
|---------------------|------|--------|
|
|
211
|
+
| POST /api/auth/cadastro | POST /api/auth/cadastro | ✅ MATCH |
|
|
212
|
+
| GET /api/listas | GET /api/listas | ✅ MATCH |
|
|
213
|
+
| PUT /api/listas/{id} | — | ❌ MISSING |
|
|
214
|
+
|
|
215
|
+
### Response Fields
|
|
216
|
+
| Endpoint | Type (contracts.md) | Field | Status |
|
|
217
|
+
|----------|---------------------|-------|--------|
|
|
218
|
+
| GET /api/listas | PaginatedResponse | itens | ❌ implemented as "dados" |
|
|
219
|
+
| POST /api/auth/cadastro | CadastroResponse | id, nome, email | ✅ MATCH |
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Action on divergences:**
|
|
223
|
+
- ❌ MISSING endpoint → coding agent implements the missing endpoint
|
|
224
|
+
- ❌ Different path → coding agent fixes the route in code (NOT in spec — spec is source of truth pre-merge)
|
|
225
|
+
- ❌ Renamed field → coding agent fixes the field name in code to match contracts.md
|
|
226
|
+
- After fixes → re-run tests (should still pass since tests were generated from the same spec)
|
|
227
|
+
- If divergence was INTENTIONAL (spec was wrong, dev corrected during implementation) → update contracts.md and record the change in `docs/lessons/`
|
|
228
|
+
|
|
229
|
+
> **Rule**: contracts.md is the source of truth PRE-implementation. Code is the source of truth POST-merge. The conformance check ensures alignment before the merge. To diverge intentionally, update the spec first.
|
|
230
|
+
|
|
231
|
+
**Conformance report artifact**: after running the conformance check, save the report to `specs/NNN-name/conformance-report.json` in the spec repo with this schema:
|
|
232
|
+
|
|
233
|
+
```json
|
|
234
|
+
{
|
|
235
|
+
"feature": "NNN",
|
|
236
|
+
"timestamp": "2026-04-11T12:00:00Z",
|
|
237
|
+
"endpoints": {
|
|
238
|
+
"total": 4,
|
|
239
|
+
"matching": 4,
|
|
240
|
+
"missing": 0,
|
|
241
|
+
"divergent": 0,
|
|
242
|
+
"details": [
|
|
243
|
+
{ "spec": "POST /api/listas", "code": "POST /api/listas", "status": "match" },
|
|
244
|
+
{ "spec": "GET /api/listas", "code": "GET /api/listas", "status": "match" }
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
"fields": {
|
|
248
|
+
"total": 12,
|
|
249
|
+
"matching": 12,
|
|
250
|
+
"divergent": 0,
|
|
251
|
+
"details": []
|
|
252
|
+
},
|
|
253
|
+
"result": "pass"
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
This artifact enables CI Guard (see below) and provides audit trail for compliance.
|
|
258
|
+
|
|
259
|
+
Also append a summary line to `specs/NNN-name/conformance-history.log` (create if it doesn't exist):
|
|
260
|
+
```
|
|
261
|
+
{timestamp} | {result} | {matching}/{total} endpoints | {matching}/{total} fields
|
|
262
|
+
```
|
|
263
|
+
This preserves history across multiple /osk-build runs.
|
|
264
|
+
|
|
265
|
+
C.4. **Run extension hooks** (if any)
|
|
266
|
+
|
|
267
|
+
If the spec repo has a `hooks/pre-merge/` directory with executable scripts, run each one in alphabetical order. Each script receives two arguments: `<spec-dir>` and `<repo-dir>`.
|
|
268
|
+
|
|
269
|
+
- Exit 0 → hook passes, continue
|
|
270
|
+
- Exit non-zero → hook fails, treat as blocked (same flow as test failure: log, retry, skip)
|
|
271
|
+
|
|
272
|
+
This is the extension point for teams to add custom validations without modifying the SKILL. Examples:
|
|
273
|
+
- Accessibility check on frontend
|
|
274
|
+
- Performance budget validation
|
|
275
|
+
- License compliance scan
|
|
276
|
+
- Custom lint rules
|
|
277
|
+
|
|
278
|
+
If `hooks/pre-merge/` doesn't exist or is empty, skip this step.
|
|
279
|
+
|
|
280
|
+
C.5. **Run security scan** — read `projects.yml` → `agents.security`. If configured (not null), invoke that agent:
|
|
281
|
+
- Check for hardcoded secrets
|
|
282
|
+
- Check for injection vulnerabilities
|
|
283
|
+
- Check for unsafe dependencies
|
|
284
|
+
- If `agents.security` is null or missing: skip scan, add note to MR description: "⚠️ Security scan manual necessário — agent não configurado"
|
|
285
|
+
C.6. **If tests pass + conformance OK + hooks OK + security OK:**
|
|
286
|
+
- Create MR via VCS API or terminal
|
|
287
|
+
- MR description references: spec number, task, REQ-NNN
|
|
288
|
+
- Move VCS Issue → `em-review`
|
|
289
|
+
- Read `projects.yml` → `agents.code_review`. If configured (not null), invoke that agent for automated pre-review. If null: skip pre-review, notify dev: "Code review automatizado indisponível — review manual necessário"
|
|
290
|
+
C.7. Notify Google Chat (rich card format):
|
|
291
|
+
```bash
|
|
292
|
+
./scripts/notify-gchat.sh --card \
|
|
293
|
+
--title "🔀 MR criado" \
|
|
294
|
+
--subtitle "{project_name} — {feature_name}" \
|
|
295
|
+
--body "{body_text}" \
|
|
296
|
+
--next "{next_step}" \
|
|
297
|
+
--button-text "Revisar MR" \
|
|
298
|
+
--button-url "{mr_url}"
|
|
299
|
+
```
|
|
300
|
+
**Body format** — use `<b>` for bold, `<br>` for line breaks, `•` for bullets:
|
|
301
|
+
```
|
|
302
|
+
<b>{feature_name} — tasks implementadas:</b><br>• T-NNN-REPO-XX — descrição<br>• T-NNN-REPO-YY — descrição<br><br>🧪 <b>Total:</b> X testes passando | Y branches prontas pra review
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Phase C (branch) — MR rejected (if code review finds issues)
|
|
306
|
+
|
|
307
|
+
If the code reviewer (human or agent) rejects the MR:
|
|
308
|
+
|
|
309
|
+
1. Read the review feedback (comments, requested changes)
|
|
310
|
+
2. Fix the issues in the same branch
|
|
311
|
+
3. Re-run tests to ensure fixes don't break anything
|
|
312
|
+
4. Re-run conformance check (C.3) if routes or response fields changed
|
|
313
|
+
5. Push the fixes and update the MR
|
|
314
|
+
6. Re-invoke the code review agent (from `projects.yml` → `agents.code_review`) for new review
|
|
315
|
+
7. Repeat until approved — sem limite de correções
|
|
316
|
+
|
|
317
|
+
### Phase D — Post-merge (after human CR approves)
|
|
318
|
+
|
|
319
|
+
**How to trigger Phase D**: the dev re-executes `/osk-build NNN` after merging the MR. The agent detects merged MRs by checking links.md (MRs without "merged" status) or by querying the VCS API. Alternatively, the dev can run `/osk-build NNN --post-merge` to explicitly trigger Phase D.
|
|
320
|
+
|
|
321
|
+
After the dev merges the MR:
|
|
322
|
+
|
|
323
|
+
D.1. Update `specs/NNN-name/links.md` with merged MR link
|
|
324
|
+
|
|
325
|
+
D.1.5. **Sync spec with implementation reality**
|
|
326
|
+
If the conformance report (Phase C.3) detected INTENTIONAL divergences (spec was wrong, implementation corrected it), update the LOCAL spec files to match what was actually implemented:
|
|
327
|
+
- `contracts.md`: fix endpoint paths, response fields, or types that diverged
|
|
328
|
+
- `scenarios.md`: update Given/When/Then if behavior changed
|
|
329
|
+
- Commit: `fix(NNN): sync spec with implementation — {summary of changes}`
|
|
330
|
+
|
|
331
|
+
This ensures specs remain the source of truth for FUTURE features that reference them. Without this update, /osk-discover and /osk-spec for next features read stale contracts.
|
|
332
|
+
|
|
333
|
+
If conformance report shows NO divergences → skip (specs already match).
|
|
334
|
+
|
|
335
|
+
D.2. Move VCS Issue → `done`
|
|
336
|
+
D.3. **Update living docs on Confluence** (via MCP):
|
|
337
|
+
|
|
338
|
+
> **Ownership rule**: /osk-build is the LAST to touch living docs. Its updates reflect what WAS IMPLEMENTED (merged code), not what was planned in the spec. If the implemented behavior diverged from the spec (e.g., rule adjusted during dev), Confluence must reflect the REALITY of the code, not the original spec. Code is the source of truth post-merge.
|
|
339
|
+
|
|
340
|
+
| Document | What to update | When |
|
|
341
|
+
|----------|---------------|------|
|
|
342
|
+
| DD (Design Document) | New components, flows, contracts | If feature changes architecture |
|
|
343
|
+
| Dominio/Regras | New business rules implemented | If new rules were added |
|
|
344
|
+
| Dominio/Fluxos | New or changed flows | If flows changed |
|
|
345
|
+
| Dominio/Integracoes | New external integrations | If new integrations |
|
|
346
|
+
| Glossario | New technical terms | If new domain concepts |
|
|
347
|
+
| Feature page label | adicionar `done` | Always |
|
|
348
|
+
|
|
349
|
+
**Note on labels**: the Confluence API only supports ADDING labels (not removing). Previous labels (discovery, aguardando-po, prd-review, etc.) accumulate as history. The CURRENT workflow label is always the most recently added one. To filter features by state, look for the most recent label.
|
|
350
|
+
|
|
351
|
+
**Confluence unavailable fallback**: if Confluence access (MCP or REST API) is down during post-merge:
|
|
352
|
+
- Save pending updates to `docs/pending-confluence-updates.md` with: target page, content to add, date
|
|
353
|
+
- Notify the dev with message: "Confluence indisponível — atualizações salvas em docs/pending-confluence-updates.md. Execute manualmente quando o Confluence voltar."
|
|
354
|
+
- On the next /osk-build execution, check if `docs/pending-confluence-updates.md` exists and attempt to apply pending updates
|
|
355
|
+
|
|
356
|
+
D.4. **Post-implementation discoveries:**
|
|
357
|
+
|
|
358
|
+
If implementation revealed:
|
|
359
|
+
- a) A SURPRISE (unexpected behavior, edge case) → save to `docs/lessons/NNN-title.md` with template below
|
|
360
|
+
- b) A NEW ARCHITECTURE DECISION (chose a pattern, discovered a constraint) → add to `docs/architecture.md` "Decisões em Aberto" table with Status: `resolvida — [decisão tomada durante implementação de {SIGLA}-NNN]`. This ensures architecture.md reflects decisions made during /osk-build, not just during /osk-discover.
|
|
361
|
+
|
|
362
|
+
Lessons template:
|
|
363
|
+
```
|
|
364
|
+
## O que aconteceu
|
|
365
|
+
[description]
|
|
366
|
+
## Causa raiz
|
|
367
|
+
[why it happened]
|
|
368
|
+
## Como evitar
|
|
369
|
+
[what to do differently next time]
|
|
370
|
+
```
|
|
371
|
+
D.4.5. **Update CHANGELOG.md**
|
|
372
|
+
|
|
373
|
+
In the MAIN repo (first repo in projects.yml), create or update `CHANGELOG.md` with an entry for this feature:
|
|
374
|
+
|
|
375
|
+
```markdown
|
|
376
|
+
## [{SIGLA}-NNN] Feature Name — YYYY-MM-DD
|
|
377
|
+
|
|
378
|
+
### Adicionado
|
|
379
|
+
- {list new endpoints from conformance report}
|
|
380
|
+
- {list new entities from contracts.md}
|
|
381
|
+
|
|
382
|
+
### Alterado
|
|
383
|
+
- {list modified entities/endpoints, if evolution feature}
|
|
384
|
+
|
|
385
|
+
### Observações
|
|
386
|
+
- {any "A CONFIRMAR" items still pending}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
If `CHANGELOG.md` doesn't exist, create it with header: `# Changelog` and a reference to [Keep a Changelog](https://keepachangelog.com/).
|
|
390
|
+
|
|
391
|
+
D.5. Notify Google Chat (rich card format):
|
|
392
|
+
```bash
|
|
393
|
+
./scripts/notify-gchat.sh --card \
|
|
394
|
+
--title "🚀 Feature NNN implementada" \
|
|
395
|
+
--subtitle "{project_name}" \
|
|
396
|
+
--body "{body_text}" \
|
|
397
|
+
--next "{next_step}" \
|
|
398
|
+
--button-text "Ver {repo_name}" \
|
|
399
|
+
--button-url "{repo_url}"
|
|
400
|
+
```
|
|
401
|
+
**Body format** — list ALL tasks from tasks.md with bullet points:
|
|
402
|
+
```
|
|
403
|
+
<b>{feature_name} — todas as tasks:</b><br>• T-NNN-API-01 — descrição<br>• T-NNN-API-02 — descrição<br>• T-NNN-FRONT-01 — descrição<br>...<br><br>🧪 <b>Total:</b> X testes API passando | Y testes front passando
|
|
404
|
+
```
|
|
405
|
+
**Rules for rich notifications:**
|
|
406
|
+
- List every task from tasks.md (API + Front + Worker)
|
|
407
|
+
- Include test count per repo
|
|
408
|
+
- `--next` must always state the concrete next step
|
|
409
|
+
- `--button-text` + `--button-url` link to the main repo or feature page
|
|
410
|
+
- All text in pt-BR with correct accents
|
|
411
|
+
|
|
412
|
+
Replace `{}` values with actual data from execution context. Notifications always in pt-BR.
|
|
413
|
+
|
|
414
|
+
### Phase E — Infrastructure validation (optional, recommended before release)
|
|
415
|
+
|
|
416
|
+
**How to trigger Phase E**: dev runs `/osk-build --validate`, or automatically after the last feature of the cycle. Not executed per feature — only when the dev wants to validate the complete system against real infrastructure.
|
|
417
|
+
|
|
418
|
+
**Prerequisite**: the project has a `docker-compose.yml` (or equivalent infra) declared in `projects.yml`. If not, skip this phase.
|
|
419
|
+
|
|
420
|
+
E.1. Start infrastructure via `docker-compose up -d` (database, messaging, etc.)
|
|
421
|
+
- If ports conflict, adjust in docker-compose and connection strings
|
|
422
|
+
- Wait for health checks to pass
|
|
423
|
+
|
|
424
|
+
E.2. For EACH repo, invoke the stack's coding agent to:
|
|
425
|
+
- Apply pending schema/migrations (the agent knows the stack command)
|
|
426
|
+
- Start the service locally
|
|
427
|
+
- The orchestrator does NOT execute stack commands directly — delegates to the agent
|
|
428
|
+
|
|
429
|
+
E.3. Validate the API (orchestrator does via curl):
|
|
430
|
+
- Health check (`GET /health` → 200)
|
|
431
|
+
- Minimum flow: register → login → 1 authenticated CRUD operation
|
|
432
|
+
- Verify CORS (front origin must be accepted)
|
|
433
|
+
- If the spec has NFR scenarios (performance targets): run a basic load smoke test against the critical endpoint (e.g., `hey -n 100 -c 10 {url}` or equivalent) and verify the p95 response time meets the target. If load testing tooling is not available, log: "NFR validation manual necessária — tooling de load test não disponível."
|
|
434
|
+
|
|
435
|
+
E.4. Validate the frontend (orchestrator checks):
|
|
436
|
+
- Build passes (stack agent executes the build)
|
|
437
|
+
- `baseURL` points to the correct API port
|
|
438
|
+
- Login screen loads and can authenticate
|
|
439
|
+
|
|
440
|
+
E.5. If any step fails:
|
|
441
|
+
- Log in `docs/lessons/` with root cause and applied fix
|
|
442
|
+
- Fix and retry the validation
|
|
443
|
+
- Notify dev via GChat if the issue requires manual decision
|
|
444
|
+
|
|
445
|
+
E.6. Tear down infrastructure: `docker-compose down`
|
|
446
|
+
|
|
447
|
+
E.7. Notify Google Chat (rich card format):
|
|
448
|
+
```bash
|
|
449
|
+
./scripts/notify-gchat.sh --card \
|
|
450
|
+
--title "✅ Validação de infraestrutura OK" \
|
|
451
|
+
--subtitle "{project_name}" \
|
|
452
|
+
--body "<b>Smoke test passou:</b><br>• Infra: PostgreSQL + RabbitMQ<br>• Migrações aplicadas<br>• Health check OK<br>• Fluxo cadastro → login → CRUD OK<br>• CORS OK<br>• Front build + conexão OK" \
|
|
453
|
+
--next "Pronto para deploy" \
|
|
454
|
+
--button-text "Ver projeto" \
|
|
455
|
+
--button-url "{repo_url}"
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
## Agents used
|
|
459
|
+
|
|
460
|
+
All agent names are read from `projects.yml` → `agents` section. **Never hardcode agent names.**
|
|
461
|
+
|
|
462
|
+
| Role | Config key | When | Purpose |
|
|
463
|
+
|------|-----------|------|---------|
|
|
464
|
+
| Coding agent | `agents.coding.{stack}` | Phase B | Code implementation (selected by repo stack) |
|
|
465
|
+
| Security scan | `agents.security` | Phase C.5 | Security scan before MR |
|
|
466
|
+
| Code review | `agents.code_review` | Phase C.6 | Automated pre-review of MR |
|
|
467
|
+
| Design document | `agents.design_doc` | Phase D | Update DD if architecture changed |
|
|
468
|
+
|
|
469
|
+
**Fallbacks (when agent config is null or agent unavailable):**
|
|
470
|
+
- **Coding agent** not configured for stack: **STOP** — "Stack '{stack}' sem agent configurado. Adicione o mapeamento em projects.yml → agents.coding."
|
|
471
|
+
- **Security**: skip scan, add note to MR: "⚠️ Security scan manual necessário"
|
|
472
|
+
- **Code review**: skip pre-review, notify dev: "Code review automatizado indisponível — review manual necessário"
|
|
473
|
+
- **Design doc**: update DD directly no Confluence (read storage → append → update)
|
|
474
|
+
|
|
475
|
+
## CI Guard (optional — for teams with CI/CD pipelines)
|
|
476
|
+
|
|
477
|
+
The conformance report generated in Phase C.3 (`specs/NNN-name/conformance-report.json`) enables automated spec compliance gates in CI/CD pipelines.
|
|
478
|
+
|
|
479
|
+
### How to set up
|
|
480
|
+
|
|
481
|
+
Add a step to your CI pipeline (GitHub Actions, GitLab CI, etc.) that reads the conformance report and blocks the merge if there are failures:
|
|
482
|
+
|
|
483
|
+
```yaml
|
|
484
|
+
# GitHub Actions example
|
|
485
|
+
- name: Spec Conformance Guard
|
|
486
|
+
run: |
|
|
487
|
+
REPORT=$(cat specs/*/conformance-report.json 2>/dev/null | jq -s '.')
|
|
488
|
+
FAILURES=$(echo "$REPORT" | jq '[.[] | select(.result != "pass")] | length')
|
|
489
|
+
if [ "$FAILURES" -gt 0 ]; then
|
|
490
|
+
echo "❌ Spec conformance failed — $FAILURES feature(s) with divergences"
|
|
491
|
+
echo "$REPORT" | jq '.[] | select(.result != "pass") | {feature, endpoints: .endpoints.divergent, fields: .fields.divergent}'
|
|
492
|
+
exit 1
|
|
493
|
+
fi
|
|
494
|
+
echo "✅ All features conform to specs"
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### What it blocks
|
|
498
|
+
|
|
499
|
+
- ❌ Endpoints in contracts.md not implemented in code
|
|
500
|
+
- ❌ Endpoint paths that don't match contracts.md exactly
|
|
501
|
+
- ❌ Response field names that diverge from contracts.md types
|
|
502
|
+
- ❌ Extension hooks (pre-merge) that failed
|
|
503
|
+
|
|
504
|
+
### What it doesn't block
|
|
505
|
+
|
|
506
|
+
- Spec updates (contracts.md changes) — those are intentional evolution
|
|
507
|
+
- Test count mismatches — caught earlier in Phase B.4, not in CI
|
|
508
|
+
- Security scan — separate CI step
|
|
509
|
+
|
|
510
|
+
### When to adopt
|
|
511
|
+
|
|
512
|
+
- **Now**: run conformance check manually during /osk-build (Phase C.3) — already implemented
|
|
513
|
+
- **Next**: add CI Guard when the team sets up CI/CD pipelines
|
|
514
|
+
- **Future**: add custom hooks for domain-specific validations
|
|
515
|
+
|
|
516
|
+
## Extension System
|
|
517
|
+
|
|
518
|
+
The kit is extensible via three mechanisms. Teams add custom behavior without modifying the core SKILLs.
|
|
519
|
+
|
|
520
|
+
### 1. Agents (stack support)
|
|
521
|
+
|
|
522
|
+
To add support for a new programming language or framework:
|
|
523
|
+
|
|
524
|
+
1. Create an agent definition in `padrao-labs-agents/.agents/agents/{name}.agent.md`
|
|
525
|
+
2. Add the stack → agent mapping in `projects.yml` → `agents.coding` (e.g., `go: my-go-engineer`)
|
|
526
|
+
3. The /osk-build automatically selects the new agent when a repo in `projects.yml` declares that stack
|
|
527
|
+
|
|
528
|
+
### 2. Rules (cross-cutting concerns)
|
|
529
|
+
|
|
530
|
+
To add rules that apply across all skills:
|
|
531
|
+
|
|
532
|
+
1. Create a `.md` file in `.agents/rules/` with frontmatter: `name`, `description`, `applyTo`
|
|
533
|
+
2. All skills and agents that match `applyTo` will receive the rule as context
|
|
534
|
+
3. Examples: coding standards, security policies, naming conventions
|
|
535
|
+
|
|
536
|
+
### 3. Hooks (custom validations)
|
|
537
|
+
|
|
538
|
+
To add custom validation steps to the /osk-build pipeline:
|
|
539
|
+
|
|
540
|
+
1. Create a `hooks/` directory in the spec repo
|
|
541
|
+
2. Add executable scripts to `hooks/pre-merge/` — they run in Phase C.4 before MR creation
|
|
542
|
+
3. Each script receives: `$1` = spec directory path, `$2` = code repo path
|
|
543
|
+
4. Exit 0 = pass, non-zero = fail (blocks the merge)
|
|
544
|
+
|
|
545
|
+
**Hook examples:**
|
|
546
|
+
|
|
547
|
+
```bash
|
|
548
|
+
# hooks/pre-merge/check-accessibility.sh
|
|
549
|
+
# Runs axe-core on the frontend build
|
|
550
|
+
cd "$2" && npx axe-core --exit-code build/
|
|
551
|
+
|
|
552
|
+
# hooks/pre-merge/check-license.sh
|
|
553
|
+
# Validates no GPL dependencies in a commercial project
|
|
554
|
+
cd "$2" && npx license-checker --failOn "GPL"
|
|
555
|
+
|
|
556
|
+
# hooks/pre-merge/check-bundle-size.sh
|
|
557
|
+
# Blocks merge if frontend bundle exceeds 500KB
|
|
558
|
+
BUNDLE_SIZE=$(du -sk "$2/dist/assets/" | cut -f1)
|
|
559
|
+
[ "$BUNDLE_SIZE" -lt 500 ] || (echo "Bundle too large: ${BUNDLE_SIZE}KB" && exit 1)
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
**Hook lifecycle:**
|
|
563
|
+
- `hooks/pre-merge/` — runs in Phase C.4, after conformance check, before security scan
|
|
564
|
+
- Future: `hooks/post-merge/`, `hooks/pre-spec/`, `hooks/post-setup/` as needed
|
|
565
|
+
|
|
566
|
+
## Rules
|
|
567
|
+
|
|
568
|
+
1. ALWAYS generate tests before implementation (TDD) — tests MUST come from scenarios.md, not invented by the agent
|
|
569
|
+
2. Max 3 retries on test failure — then mark as blocked and move on. **1 retry = 1 complete cycle of: read error → modify code → re-run tests.** Each cycle counts regardless of change size.
|
|
570
|
+
3. Each task = 1 branch = 1 MR (never bundle)
|
|
571
|
+
4. MR description must reference spec number and REQ-NNN
|
|
572
|
+
5. Security scan is mandatory before creating MR
|
|
573
|
+
6. Living docs on Confluence MUST be updated post-merge
|
|
574
|
+
7. Lessons learned from failures MUST be saved to docs/lessons/
|
|
575
|
+
8. All VCS Issues (GitLab/GitHub) must reflect current state (open → in-progress → em-review → done | blocked)
|
|
576
|
+
9. **Language**: ALL generated content — Confluence pages AND local files — MUST be in **Brazilian Portuguese (pt-BR) with correct accents** (e.g., "não" NOT "nao", "autenticação" NOT "autenticacao", "código" NOT "codigo"). Technical terms stay in English (e.g., endpoint, status, token). **When invoking coding agents**, pass this language rule explicitly — code comments MUST also use pt-BR with accents (e.g., `// Validação padrão` NOT `// Validacao padrao`).
|
|
577
|
+
10. **Cross-platform scripts**: when running `./scripts/notify-gchat.*`, detect the OS. On Windows use `powershell -ExecutionPolicy Bypass -File ./scripts/notify-gchat.ps1`, on Linux/macOS use `bash ./scripts/notify-gchat.sh`. Parameters are the same for both.
|
|
578
|
+
|
|
579
|
+
## Validation checklist
|
|
580
|
+
|
|
581
|
+
- [ ] Audit-report.md read and evaluated (no ❌ items)
|
|
582
|
+
- [ ] Repos auto-created if `status: planned` (Phase A.1)
|
|
583
|
+
- [ ] Feature label changed to `em-dev` on Confluence
|
|
584
|
+
- [ ] Correct coding agent selected per stack
|
|
585
|
+
- [ ] VCS Issues created (1 per task)
|
|
586
|
+
- [ ] Tests generated before implementation (TDD)
|
|
587
|
+
- [ ] **Commit RED** (`test(NNN): failing tests [RED]`) done before starting GREEN
|
|
588
|
+
- [ ] All tests pass
|
|
589
|
+
- [ ] **Commit GREEN** (`feat(NNN): all tests pass [GREEN]`) done after all tests pass
|
|
590
|
+
- [ ] Conformance check passed (endpoints + response fields match contracts.md)
|
|
591
|
+
- [ ] Conformance report saved (`specs/NNN/conformance-report.json`) + history appended to `conformance-history.log`
|
|
592
|
+
- [ ] Extension hooks passed (if any in `hooks/pre-merge/`)
|
|
593
|
+
- [ ] Security scan passed
|
|
594
|
+
- [ ] MR created with spec references
|
|
595
|
+
- [ ] Pre-review by code-reviewer completed
|
|
596
|
+
- [ ] MR rejected loop handled (if applicable — fix, re-test, re-check conformance)
|
|
597
|
+
- [ ] links.md updated with MR links
|
|
598
|
+
- [ ] Living docs updated on Confluence (DD, Dominio, Glossario)
|
|
599
|
+
- [ ] Spec synced with implementation if intentional divergences (Phase D.1.5)
|
|
600
|
+
- [ ] Architecture.md updated with new decisions if discovered during implementation (Phase D.4)
|
|
601
|
+
- [ ] CHANGELOG.md updated in main repo (Phase D.4.5)
|
|
602
|
+
- [ ] Feature label → `done` on Confluence
|
|
603
|
+
- [ ] Lessons saved if applicable
|
|
604
|
+
- [ ] GChat notifications sent at each transition
|
|
605
|
+
- [ ] Phase E (infra validation) executed before release (if applicable)
|
|
606
|
+
|
|
607
|
+
## Recovery after interruption
|
|
608
|
+
|
|
609
|
+
If the agent was interrupted at any phase, on resume execute:
|
|
610
|
+
|
|
611
|
+
```bash
|
|
612
|
+
git status # identify uncommitted files
|
|
613
|
+
git log --oneline # see where it stopped
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
| Detected state | Action |
|
|
617
|
+
|----------------|--------|
|
|
618
|
+
| Tests created, not committed | `git add -A && git commit -m "test(NNN): [RED] resumed"` → continue to B.5 |
|
|
619
|
+
| Tests committed, partial implementation | `git add -A && git commit -m "wip(NNN): partial impl"` → continue GREEN |
|
|
620
|
+
| Tests and impl committed, no PR | Create PR directly → Phase D |
|
|
621
|
+
| Branch already exists with commits | Continue on it — do NOT create a new branch |
|
|
622
|
+
|
|
623
|
+
**General rule**: never lose existing commits. Always `git status` before any decision.
|