refacil-sdd-ai 5.1.1 → 5.2.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Refacil
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **SDD-AI** (Specification-Driven Development with AI) packaged as a CLI.
4
4
 
5
- Installs **skills** and **sub-agents** for **Claude Code**, **Cursor**, and **OpenCode** that guide the developer through a structured AI-assisted development workflow, using **`refacil-sdd/`** as the specification store, plus a **local bus** so agents across different repos can communicate with each other.
5
+ Installs **skills** and **sub-agents** for **Claude Code**, **Cursor**, **OpenCode**, and **Codex** that guide the developer through a structured AI-assisted development workflow, using **`refacil-sdd/`** as the specification store, plus a **local bus** so agents across different repos can communicate with each other.
6
6
 
7
7
  ---
8
8
 
@@ -11,9 +11,9 @@ Installs **skills** and **sub-agents** for **Claude Code**, **Cursor**, and **Op
11
11
  ## Requirements
12
12
 
13
13
  - **Node.js >= 20.0.0**
14
- - One or more supported IDEs: **Claude Code >= 2.1.89**, **Cursor**, or **OpenCode**
14
+ - One or more supported IDEs: **Claude Code >= 2.1.89**, **Cursor**, **OpenCode**, or **Codex**
15
15
 
16
- `refacil-sdd-ai init` checks the Claude Code version and warns if it is below 2.1.89. With an older version the rest of the methodology works, but `compact-bash` will have no effect (Claude Code only — OpenCode and Cursor have their own hook delivery mechanisms).
16
+ `refacil-sdd-ai init` checks the Claude Code version and warns if it is below 2.1.89. With an older version the rest of the methodology works, but `compact-bash` will have no effect (Claude Code only — Cursor, OpenCode, and Codex have their own hook delivery mechanisms).
17
17
 
18
18
  ---
19
19
 
@@ -33,8 +33,8 @@ refacil-sdd-ai init
33
33
 
34
34
  `init` installs skills, sub-agents, and hooks into your IDE's **global user directories** (`~/.claude/`, `~/.cursor/`, `~/.config/opencode/`). Skills are available in all your repos from this point — no need to re-run `init` when you open a new repo.
35
35
 
36
- - Interactive IDE selector (Claude Code / Cursor / OpenCode) — pre-selects installed IDEs.
37
- Use `--all` to install for all three without prompting.
36
+ - Interactive IDE selector (Claude Code / Cursor / OpenCode / Codex) — pre-selects installed IDEs.
37
+ Use `--all` to install for all four without prompting.
38
38
  - Your IDE selection is saved to `~/.refacil-sdd-ai/selected-ides.json` and reused on every `update`.
39
39
  - Also prompts for global branch config (`baseBranch`, `protectedBranches`, `artifactLanguage`)
40
40
  stored in `~/.refacil-sdd-ai/config.yaml`. Skip with `--yes` or `--defaults`.
@@ -51,7 +51,14 @@ In each repo where you want to use the methodology, open the IDE and run:
51
51
  /refacil:setup
52
52
  ```
53
53
 
54
- This generates `AGENTS.md` and the `.agents/` project index for that repo. It is the only step required per repo. Skills will prompt you to run it if it has not been done yet.
54
+ `/refacil:setup`:
55
+
56
+ 1. Scaffolds **`AGENTS.md`**, **`.agents/`**, **`refacil-sdd/changes/`**, and project branch configuration (everything the methodology needs for **this codebase**).
57
+ 2. Runs **`refacil-sdd-ai sync-repo-ide`** from the **repository root** so per-repo stubs and excludes match **your IDE selection from `init`** (`~/.refacil-sdd-ai/selected-ides.json`): **`CLAUDE.md`**, **`.cursorrules`**, **`.claudeignore`**, **`.cursorignore`**, **`.opencodeignore`**, plus **`compact-guidance`** / **`testing-policy`** markers when **`AGENTS.md`** / **`.agents/testing.md`** exist (same logic as **`init`** / **`update`** for those files).
58
+
59
+ You can run **`refacil-sdd-ai sync-repo-ide`** manually anytime from the repo root (e.g. after changing IDE selection). It does **not** reinstall global skills — only repo-local files driven by **`selected-ides.json`** (with the same fallback detection as **`update`** when that file is missing).
60
+
61
+ Skills will prompt you to run `/refacil:setup` if the repo index is missing.
55
62
 
56
63
  ### Adding a new IDE to an existing installation
57
64
 
@@ -91,6 +98,7 @@ npm uninstall -g refacil-sdd-ai
91
98
  |---|---|
92
99
  | `refacil-sdd-ai init` | Install skills and hooks into global IDE user directories |
93
100
  | `refacil-sdd-ai update` | Re-copy skills and hooks to the latest version (global) |
101
+ | `refacil-sdd-ai sync-repo-ide` | Repo-only: `CLAUDE.md`, `.cursorrules`, ignore files, compact-guidance + testing-policy markers — IDE list from `selected-ides.json` (same as `/refacil:setup` Step 4b–5). No global reinstall |
94
102
  | `refacil-sdd-ai migration-pending [--json]` | Same detection as hooks/`notify-update`; exit 1 if migration is pending; on exit 0 also deletes obsolete `.refacil-pending-update` (same as at the start of `check-update`) |
95
103
  | `refacil-sdd-ai clean` | Remove SDD-AI skills and hooks from global IDE user directories |
96
104
  | `refacil-sdd-ai help` | Show help |
@@ -190,13 +198,13 @@ refacil-sdd-ai sdd config --json
190
198
 
191
199
  ## Available IDE Skills
192
200
 
193
- All invoked as `/refacil:<name>` in Claude Code, Cursor, or OpenCode.
201
+ All invoked as `/refacil:<name>` in Claude Code, Cursor, OpenCode, or Codex.
194
202
 
195
203
  ### SDD cycle
196
204
 
197
205
  | Skill | Usage |
198
206
  |---|---|
199
- | `/refacil:setup` | Generate AGENTS.md and the `.agents/` project index |
207
+ | `/refacil:setup` | Generate AGENTS.md, `.agents/`, `refacil-sdd/changes/`, branch config; **`sync-repo-ide`** (stubs, ignores, session markers for IDEs chosen in **`init`**) |
200
208
  | `/refacil:guide` | Interactive guide on which command to use |
201
209
  | `/refacil:explore` | Explore the codebase without modifying anything |
202
210
  | `/refacil:propose` | Create a change proposal: proposal + specs + design + tasks |
@@ -227,7 +235,7 @@ Some skills delegate their heavy work to **sub-agents** that run in isolated con
227
235
 
228
236
  **Model**: `refacil-proposer` runs with `model: opusplan` (uses Opus during plan mode for highest-stakes planning, then switches to Sonnet for execution). Other sub-agents use `model: sonnet` by default for Claude Code, others use inherit model.
229
237
 
230
- **Triple-platform**: `.claude/agents/refacil-*.md` uses `tools:` (granular allowlist). `.cursor/agents/refacil-*.md` is auto-generated: `readonly: true` for agents without `Edit`/`Write`, `readonly: false` for those that have them; always `model: inherit`. `.opencode/agents/refacil-*.md` is auto-generated via `transformFrontmatterForOpenCode()`: converts `tools:` to a `permission:` block (`edit: allow/deny`, `bash: allow/deny`, `webfetch: deny`), adds `mode: subagent`, adds `hidden: true` for internal agents, and removes `model:`. The installer transforms the frontmatter automatically for all three IDEs.
238
+ **Multi-platform**: `.claude/agents/refacil-*.md` uses `tools:` (granular allowlist). `.cursor/agents/refacil-*.md` is auto-generated: `readonly: true` for agents without `Edit`/`Write`, `readonly: false` for those that have them; always `model: inherit`. `.opencode/agents/refacil-*.md` is auto-generated via `transformFrontmatterForOpenCode()`: converts `tools:` to a `permission:` block (`edit: allow/deny`, `bash: allow/deny`, `webfetch: deny`), adds `mode: subagent`, adds `hidden: true` for internal agents, and removes `model:`. `.codex/agents/refacil-*.toml` is auto-generated via `convertAgentToToml()`: extracts `name` and `description` from the YAML frontmatter and places the Markdown body in `developer_instructions = """..."""`. The installer transforms the frontmatter automatically for all four IDEs.
231
239
 
232
240
  **Two-pass `refacil:bug` flow**: the wrapper first invokes the sub-agent in `investigation` mode (writes nothing) → the user confirms the hypothesis and approves the fix → the wrapper validates the working branch → invokes the sub-agent in `fix` mode to implement.
233
241
 
@@ -316,14 +324,14 @@ From there, the full cycle is:
316
324
 
317
325
  ## Automatic Hooks
318
326
 
319
- Installed during `init` / `update` for each selected IDE. The same four behaviors are active in Claude Code, Cursor, and OpenCode — each through its own delivery mechanism.
327
+ Installed during `init` / `update` for each selected IDE. The same four behaviors are active in Claude Code, Cursor, OpenCode, and Codex — each through its own delivery mechanism.
320
328
 
321
- | Behavior | Claude Code | Cursor | OpenCode |
322
- |---|---|---|---|
323
- | **check-update** | `SessionStart` hook in `~/.claude/settings.json` | `SessionStart` hook in `~/.cursor/hooks.json` | `session.created` handler in the global OpenCode plugin |
324
- | **notify-update** | `UserPromptSubmit` hook | `beforeSubmitPrompt` hook | `tui.prompt.append` handler |
325
- | **compact-bash** | `PreToolUse` (Bash) hook | `PreToolUse` (Bash) hook | `tool.execute.before` handler for bash tool |
326
- | **check-review** | `PreToolUse` (Bash) hook | `PreToolUse` (Bash) hook | `tool.execute.before` handler for bash tool |
329
+ | Behavior | Claude Code | Cursor | OpenCode | Codex |
330
+ |---|---|---|---|---|
331
+ | **check-update** | `SessionStart` hook in `~/.claude/settings.json` | `SessionStart` hook in `~/.cursor/hooks.json` | `session.created` handler in the global OpenCode plugin | `sessionStart` hook in `~/.codex/config.toml` |
332
+ | **notify-update** | `UserPromptSubmit` hook | `beforeSubmitPrompt` hook | `tui.prompt.append` handler | `userPromptSubmit` hook in `~/.codex/config.toml` |
333
+ | **compact-bash** | `PreToolUse` (Bash) hook | `PreToolUse` (Bash) hook | `tool.execute.before` handler for bash tool | `preToolUse` hook (Bash matcher) in `~/.codex/config.toml` |
334
+ | **check-review** | `PreToolUse` (Bash) hook | `PreToolUse` (Bash) hook | `tool.execute.before` handler for bash tool | `preToolUse` hook (Bash matcher) in `~/.codex/config.toml` |
327
335
 
328
336
  | Behavior | What it does |
329
337
  |---|---|
@@ -334,6 +342,8 @@ Installed during `init` / `update` for each selected IDE. The same four behavior
334
342
 
335
343
  > **OpenCode plugin**: a single file installed in the global OpenCode plugins directory implements all four behaviors. It loads `lib/compact/rules.js` from the package to reuse the same rewrite rules — no duplicated logic. If the rules file is not resolvable, compact-bash is disabled gracefully with a warning to stderr; the plugin never crashes the session.
336
344
 
345
+ > **Codex hooks**: injected into `~/.codex/config.toml` under `[hooks]` with `[features] codex_hooks = true`. Each SDD-AI hook entry carries a boolean marker (`_sdd`, `_sdd_compact`, `_sdd_review`, `_sdd_notify`) for clean removal on `clean`. User-defined hooks outside these entries are preserved.
346
+
337
347
  > **Why two hooks for updates?** `SessionStart` does the silent sync when opening the session without user interaction. `notify-update` on `UserPromptSubmit` / `beforeSubmitPrompt` injects the instruction just before the agent processes the next user message, ensuring it is not ignored.
338
348
 
339
349
  ### Review gate on push
@@ -493,6 +503,11 @@ Skills, sub-agents, and hooks are installed into the user's global IDE directori
493
503
  ~/.config/opencode/agents/refacil-*.md # OpenCode sub-agents (permission block + mode:subagent)
494
504
  ~/.config/opencode/plugins/refacil-hooks.js # Plugin: session.created + tui.prompt.append + tool.execute.before
495
505
 
506
+ # Codex (if selected)
507
+ ~/.codex/skills/refacil-*/ # Codex skills (same content as Claude Code)
508
+ ~/.codex/agents/refacil-*.toml # Codex sub-agents (TOML: name + description + developer_instructions)
509
+ ~/.codex/config.toml # SDD hooks merged in under [hooks] with [features] codex_hooks = true
510
+
496
511
  # refacil-sdd-ai state
497
512
  ~/.refacil-sdd-ai/
498
513
  selected-ides.json # IDE selection saved on init, reused by update
@@ -502,15 +517,15 @@ Skills, sub-agents, and hooks are installed into the user's global IDE directori
502
517
 
503
518
  ### Per repo (generated by `/refacil:setup`)
504
519
 
505
- The only per-repo step is running `/refacil:setup` once per project. It generates the project index no IDE skills or hooks are written to the repo.
520
+ The per-repo step is **`/refacil:setup`** once per project. It generates the **project index** (**`AGENTS.md`**, **`.agents/`**, **`refacil-sdd/changes/`**) and invokes **`refacil-sdd-ai sync-repo-ide`**, which writes **stub + ignore files** according to **`~/.refacil-sdd-ai/selected-ides.json`** (no need for `.claude/` / `.cursor/` folders in the repo). **Skills and hooks remain global**, not copied into the project.
506
521
 
507
522
  ```
508
- # Shared (IDE-agnostic)
509
- CLAUDE.md # Minimal index → points to AGENTS.md
510
- .cursorrules # Cursor format equivalent of CLAUDE.md
511
- .claudeignore # Base exclusions (node_modules, dist, .env, *.key, etc.)
512
- .cursorignore # Same content as .claudeignore
513
- .opencodeignore # Same content as .claudeignore
523
+ # Shared — project index from /refacil:setup; stubs + ignores from sync-repo-ide / selected IDE list
524
+ CLAUDE.md # Minimal index → AGENTS.md (if Claude Code is in your IDE selection)
525
+ .cursorrules # Same role for Cursor if Cursor is selected
526
+ .claudeignore # Base exclusions (node_modules, dist, .env, …) when Claude is selected
527
+ .cursorignore # Same template as .claudeignore when Cursor is selected
528
+ .opencodeignore # Same when OpenCode is selected
514
529
  AGENTS.md # Project index → generated by /refacil:setup
515
530
  # Points to .agents/ + includes auto-managed blocks
516
531
  # (compact-guidance and bus presentation)
@@ -532,6 +547,7 @@ refacil-sdd/ # SDD artifacts store
532
547
  - [Claude Code](https://claude.ai/code) — Anthropic CLI
533
548
  - [Cursor](https://cursor.sh) — AI IDE
534
549
  - [OpenCode](https://opencode.ai) — open-source AI development agent
550
+ - [Codex](https://github.com/openai/codex) — OpenAI CLI agent
535
551
 
536
552
  ## License
537
553
 
@@ -11,7 +11,7 @@ You are a debugging agent operating in two modes. In investigation mode you rece
11
11
 
12
12
  Reject weak hypotheses. If the evidence does not support a root cause, say so. Do not propose a fix until the cause is clear.
13
13
 
14
- **Prerequisites**: `agents` profile from `refacil-prereqs/SKILL.md` + rules from `METHODOLOGY-CONTRACT.md`.
14
+ **Prerequisites**: `agents` profile from `refacil-prereqs/SKILL.md` + rules from **`METHODOLOGY-CONTRACT.md` (§3, §3.1 — verification defaults to scoped in fix mode)**.
15
15
 
16
16
  ## Guardrail: direct invocation detection
17
17
 
@@ -29,6 +29,7 @@ If you prefer to continue here, provide:
29
29
  - mode: investigation (only analyze and propose hypotheses) or fix (implement with already-confirmed hypothesis)
30
30
  - description: <full bug description>
31
31
  - hypothesis: <confirmed root cause> (only for mode=fix)
32
+ - testScope: scoped \| full (only for mode=fix; default scoped)
32
33
  ```
33
34
 
34
35
  **Do not proceed with reads or implementation until the scope is clear.**
@@ -124,7 +125,7 @@ Proposed fix for hypothesis #1:
124
125
 
125
126
  ## Fix mode
126
127
 
127
- The main agent passes you: `mode: fix` + `description` + `hypothesis` (root cause confirmed by the user).
128
+ The main agent passes you: `mode: fix` + `description` + `hypothesis` (root cause confirmed by the user) + optional **`testScope`** (`scoped` \| `full`, default **`scoped`**).
128
129
 
129
130
  ### Step 1: Implement the fix
130
131
 
@@ -139,7 +140,7 @@ Detect the project's testing stack and framework: read `METHODOLOGY-CONTRACT.md
139
140
  Generate tests that:
140
141
  1. **Reproduce the bug**: a test that fails WITHOUT the fix (verifies the test is valid).
141
142
  2. **Verify the fix**: the same test passes WITH the fix.
142
- 3. **Verify no regression**: normal flow tests still pass.
143
+ 3. **Guardrails**: extend with normal/control-path assertions when they fit the bug surface (Step 4 **scoped** run targets those files/packages — **not** the entire repo suite).
143
144
 
144
145
  Each test must cover:
145
146
  - `should [correct behavior] when [condition that previously failed]`
@@ -164,9 +165,14 @@ Create `refacil-sdd/changes/<fix-name>/summary.md`:
164
165
 
165
166
  This file is mandatory for traceability and allows the `check-review` hook to detect the active change. The `.review-passed` will be created by `/refacil:review` upon approval.
166
167
 
167
- ### Step 4: Run all tests
168
+ ### Step 4: Verify tests (`METHODOLOGY-CONTRACT.md` §3.1)
168
169
 
169
- Resolve and run the test command according to `METHODOLOGY-CONTRACT.md §3`. All tests must pass.
170
+ 1. Read **`testScope`** from wrapper (default **`scoped`** if omitted).
171
+ 2. **`testScope: full`**: Resolve baseline from **`METHODOLOGY-CONTRACT.md §3`**, run **once unparsed** — **all tests** emitted by that command must pass.
172
+ 3. **`testScope: scoped`** (default): Collect **`verificationTargets`** — every production/test file **you edited or added** during fix mode (**including** regression tests created this session).
173
+ - Build **`scopedCommand`** by narrowing baseline §3 to cover only those roots (directories, `-p`/`-pl`, `--`/path suffixes — follow stack docs + **`AGENTS.md` / `.agents/testing.md`** when present — see §3.1 **Scoped command patterns**).
174
+ - Run **`scopedCommand`**; everything it selects must pass. **Do not** upgrade to repo-wide invocation while `scoped` unless §3.1 says narrowing is unreliable — then run baseline **once**, prepend report line **WARN: scoped narrowing unavailable → full-suite fallback (heavy)**.
175
+ 4. **`testsResult.command`** in JSON must quote the **literal** executed shell string (`scopedCommand` or baseline).
170
176
 
171
177
  ### Report + JSON block (fix)
172
178
 
@@ -208,4 +214,5 @@ Resolve and run the test command according to `METHODOLOGY-CONTRACT.md §3`. All
208
214
  - In mode=investigation: follow diagnose loop discipline (reproduce, minimize, hypothesize, validate evidence) before proposing a fix.
209
215
  - In mode=fix: the fix must be MINIMAL. Never over-refactor.
210
216
  - Regression tests are MANDATORY in mode=fix.
217
+ - **Scoped verification**: default **`testScope: scoped`** from wrapper — narrowed command in Step 4, not wholesale “run entire repo suite” unless `full`.
211
218
  - Use **concise** output mode by default.
@@ -11,7 +11,7 @@ You are an implementation agent. You receive a structured briefing (objective, s
11
11
 
12
12
  If the briefing is ambiguous or a task cannot be completed safely, report it — do not silently skip or guess.
13
13
 
14
- **Prerequisites**: rules from `refacil-prereqs/METHODOLOGY-CONTRACT.md`.
14
+ **Prerequisites**: rules from `refacil-prereqs/METHODOLOGY-CONTRACT.md` (**§3**, **§3.1** — default verification is **scoped**).
15
15
 
16
16
  ## Guardrail: direct invocation detection
17
17
 
@@ -72,7 +72,9 @@ Read from the prompt the `BRIEFING:` sections passed by the wrapper:
72
72
  - `scope.modify` — existing files to modify
73
73
  - `scope.doNotTouch` — files out of scope
74
74
  - `tasks` — numbered task list
75
- - `testCommand` — verification command
75
+ - `testScope` — `scoped` \| `full` (default **`scoped`** if absent — treat missing as scoped)
76
+ - `testCommand` — **exact shell command** to execute for verification (narrowed when `scoped`)
77
+ - `verificationWarning` — optional hint from wrapper (often explains fallback-to-baseline)
76
78
  - `architectureContext` — already-extracted architecture context
77
79
  - `specsNote` — if there are specs, where they are and whether there are possible contradictions
78
80
 
@@ -82,7 +84,7 @@ If the briefing is **not present** (direct invocation without briefing):
82
84
  3. Read `refacil-sdd/changes/<changeName>/tasks.md` (tasks)
83
85
  4. Read `AGENTS.md` (architecture)
84
86
  5. Read the change specs
85
- 6. Read `METHODOLOGY-CONTRACT.md §3` (test command)
87
+ 6. Read `METHODOLOGY-CONTRACT.md` §3 and §3.1 (narrow **before** invoking the runner unless you explicitly widen)
86
88
 
87
89
  ### Step 2: Read existing interfaces (scope.modify only)
88
90
 
@@ -103,7 +105,12 @@ If a task requires touching a file outside the scope: note it in `issues` as pot
103
105
 
104
106
  ### Step 4: Verify
105
107
 
106
- Run the `testCommand` from the briefing (or from `METHODOLOGY-CONTRACT.md §3` if not in the briefing).
108
+ Follow **`METHODOLOGY-CONTRACT.md §3.1`**:
109
+
110
+ 1. Run **exactly** the **`testCommand`** supplied in the briefing.
111
+ 2. If **`testCommand` is missing**, resolve baseline from **`METHODOLOGY-CONTRACT.md §3`** and **narrow** it yourself using `scope.create` ∪ `scope.modify` plus the §3.1 **Scoped command patterns**. If narrowing is unsafe, run the baseline **once**, add **`issues`** entry severity **MEDIUM** explaining full-suite fallback, and cite `verificationWarning` pattern if analogous.
112
+ 3. **Do not** broaden the briefing’s `testCommand` into a fuller suite when `testScope` is **`scoped`** (or omitted). Repo-wide regression belongs in CI or an explicit **`/refacil:test … full`**.
113
+ 4. If `verificationWarning` is present in the briefing, mirror a short note in **`issues`** (severity **LOW**) so the wrapper/user sees CPU/RAM risk was intentional.
107
114
 
108
115
  ### Step 5: Report + JSON block
109
116