refacil-sdd-ai 5.0.4 → 5.0.7

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 CHANGED
@@ -19,49 +19,62 @@ Installs **skills** and **sub-agents** for **Claude Code**, **Cursor**, and **Op
19
19
 
20
20
  ## Installation
21
21
 
22
- Recommended: install globally once, then run `init` per repo.
22
+ ### Step 1 Install the package globally
23
23
 
24
24
  ```bash
25
- # 1. Global (once)
26
25
  npm install -g refacil-sdd-ai
26
+ ```
27
+
28
+ ### Step 2 — Run `init` to install skills into your IDEs
27
29
 
28
- # 2. In the repo root
30
+ ```bash
29
31
  refacil-sdd-ai init
30
- # Interactive IDE selector (Claude Code / Cursor / OpenCode) — pre-selects IDEs
31
- # whose folder already exists. Use --all to install for all three without prompting.
32
- # Copies skills and sub-agents to the selected IDEs, configures hooks,
33
- # and creates/updates .claudeignore, .cursorignore and .opencodeignore.
34
- # Also prompts for global branch config (baseBranch, protectedBranches, artifactLanguage)
35
- # pre-filled from ~/.refacil-sdd-ai/config.yaml. Skipped with --yes or --defaults.
32
+ ```
33
+
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
+
36
+ - Interactive IDE selector (Claude Code / Cursor / OpenCode) — pre-selects installed IDEs.
37
+ Use `--all` to install for all three without prompting.
38
+ - Your IDE selection is saved to `~/.refacil-sdd-ai/selected-ides.json` and reused on every `update`.
39
+ - Also prompts for global branch config (`baseBranch`, `protectedBranches`, `artifactLanguage`)
40
+ stored in `~/.refacil-sdd-ai/config.yaml`. Skip with `--yes` or `--defaults`.
41
+
42
+ Re-run `init` if you install a new IDE or want to change which IDEs have the methodology.
36
43
 
37
- # 3. Restart your IDE session
38
- # (new skills are not detected until you restart)
44
+ **After `init`, restart your IDE session** — new skills are not detected until you restart.
39
45
 
40
- # 4. In the IDE
46
+ ### Step 3 Configure each repo with `/refacil:setup`
47
+
48
+ In each repo where you want to use the methodology, open the IDE and run:
49
+
50
+ ```
41
51
  /refacil:setup
42
- # Generates AGENTS.md and the .agents/ directory for the project
43
52
  ```
44
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.
55
+
45
56
  ### Adding a new IDE to an existing installation
46
57
 
47
- If you already have the methodology installed for Claude Code or Cursor and want to add OpenCode (or any other IDE), just run `init` again from the repo root:
58
+ To add an IDE that was not selected during the original `init`, run `init` again:
48
59
 
49
60
  ```bash
50
61
  refacil-sdd-ai init
51
62
  ```
52
63
 
53
- The selector will pre-select the IDEs whose folders already exist (`.claude/`, `.cursor/`). Check the new IDE you want to add (e.g. OpenCode), leave the existing ones checked, and confirm — only the newly selected IDE will receive files; existing installations are refreshed in place.
64
+ The selector pre-marks your previously selected IDEs (from `~/.refacil-sdd-ai/selected-ides.json`). Check the new IDE, leave the others checked, and confirm — the new IDE is added and the selection is updated.
54
65
 
55
- > **`update` does not add new IDEs** — it only updates IDEs already installed. Use `init` to add a new one.
66
+ > **`update` does not add new IDEs** — it only updates the IDEs already in your selection. Use `init` to add a new one.
56
67
 
57
68
  ### Update
58
69
 
59
70
  ```bash
60
71
  npm update -g refacil-sdd-ai
61
- refacil-sdd-ai update # in each repo where it is used
72
+ refacil-sdd-ai update
62
73
  ```
63
74
 
64
- `update` detects which IDEs are installed by folder presence (`.claude/`, `.cursor/`, `.opencode/`) and only updates those — it never creates IDE directories that did not exist before. In Claude Code and Cursor the `check-update` hook (every session) syncs skills and `compact-guidance`. In OpenCode the equivalent runs via the `session.created` handler of the embedded plugin (`.opencode/plugins/refacil-hooks.js`). Only if the automatic detection (`lib/methodology-migration-pending.js`) finds a pending methodology migration does it write the flag and allow `notify-update` / `tui.prompt.append` to prompt `/refacil:update`. If there is no migration, the user is not interrupted. The `/refacil:update` skill uses `refacil-sdd-ai migration-pending` as the same criterion.
75
+ `update` reads `~/.refacil-sdd-ai/selected-ides.json` (the selection saved during `init`) and only updates those IDEs — it never touches IDEs you did not select. You do not need to run `update` per repo; it operates on the global install.
76
+
77
+ In Claude Code and Cursor the `check-update` hook (every session) syncs skills and `compact-guidance` automatically. It also cleans up any leftover project-level `refacil-*` artifacts from older installations and prints a message if it removes anything. In OpenCode the equivalent runs via the `session.created` handler of the embedded plugin. Only if a pending methodology migration is detected does the hook prompt `/refacil:update` — otherwise the user is not interrupted.
65
78
 
66
79
  ### Uninstall
67
80
 
@@ -443,6 +456,8 @@ Local bus (WebSocket over `127.0.0.1`) so agents across different repos can comm
443
456
 
444
457
  **SDD-AI conventions in the bus**: anyone in the room joined with `/refacil:join` (methodology already active in the repo). **Change requests** to another session go with **clear scope** in the `ask` (no pasting the guide in every message); the destination repo channels with **`/refacil:propose`** and whoever implements **closes via bus** to who requested the work. Details and edge cases: `refacil-prereqs/BUS-CROSS-REPO.md` in the installed skills.
445
458
 
459
+ **Contract-first questions (recommended)**: for cross-repo integration clarifications, format `ask/reply` around contract fields (integration point, input contract, output contract, compatibility, source of truth). If the first response is partial, send a focused retry `ask` only for unresolved points. This keeps bus conversations actionable for integration work instead of generic chat.
460
+
446
461
  **Pure observer** (0 tokens): `refacil-sdd-ai bus watch <session>` or `refacil-sdd-ai bus view` for the web UI.
447
462
 
448
463
  > **Diagrams, scenarios and pitch**: see `refacil-bus-diagrams.md` (included in the package) — includes architecture, flow with attend, flow without attend, comparative impact table, and visual decision guide (Mermaid).
@@ -56,20 +56,26 @@ If you prefer to continue here, provide:
56
56
 
57
57
  The main agent passes you: `mode: investigation` + bug `description`.
58
58
 
59
- ### Step 1: Investigate root cause
59
+ ### Step 1: Reproduce and minimize first
60
+
61
+ - Define the minimal reproducible scenario from the description (inputs, trigger, observed failure).
62
+ - Narrow scope to the smallest code path that can still explain the failure.
63
+
64
+ ### Step 2: Investigate root cause
60
65
 
61
66
  - Search the codebase for symbols/files mentioned in logs or stack traces from the description.
62
67
  - Trace the flow from entry (controller/endpoint) to the failure point.
63
68
  - Review recent commits if the bug is new: `git log --oneline -20`.
64
69
  - If the cause seems to be in an interaction with another repo (unexpected API response, event with a different format, broken contract on the producer/consumer side), indicate it in `hypotheses` with `crossRepo: true` and the protocol from `refacil-prereqs/BUS-CROSS-REPO.md` so the wrapper resolves it.
65
70
 
66
- ### Step 2: Formulate hypotheses
71
+ ### Step 3: Formulate hypotheses with evidence
67
72
 
68
73
  Prepare 1-3 hypotheses ordered by confidence (`high`/`medium`/`low`), each with:
69
74
  - Suspicious file and line.
70
75
  - Description of the unhandled condition.
76
+ - Evidence that supports the hypothesis (repro observation, log, code path check).
71
77
 
72
- ### Step 3: Propose fix for hypothesis #1
78
+ ### Step 4: Propose fix for hypothesis #1
73
79
 
74
80
  Describe:
75
81
  - Minimum necessary change.
@@ -84,6 +90,7 @@ Describe:
84
90
 
85
91
  Hypotheses (ordered by confidence):
86
92
  1. [high|medium|low] file:line — [description]
93
+ Evidence: [what validates this hypothesis]
87
94
  2. ...
88
95
 
89
96
  Proposed fix for hypothesis #1:
@@ -101,6 +108,7 @@ Proposed fix for hypothesis #1:
101
108
  "file": "<path/file>",
102
109
  "line": <int or null>,
103
110
  "description": "<description of the cause>",
111
+ "evidence": "<brief evidence backing this hypothesis>",
104
112
  "crossRepo": <bool>
105
113
  }
106
114
  ],
@@ -197,6 +205,7 @@ Resolve and run the test command according to `METHODOLOGY-CONTRACT.md §3`. All
197
205
  ## Rules
198
206
 
199
207
  - In mode=investigation: **NEVER modify files**. Only report hypotheses and proposed fix.
208
+ - In mode=investigation: follow diagnose loop discipline (reproduce, minimize, hypothesize, validate evidence) before proposing a fix.
200
209
  - In mode=fix: the fix must be MINIMAL. Never over-refactor.
201
210
  - Regression tests are MANDATORY in mode=fix.
202
211
  - Use **concise** output mode by default.
package/agents/tester.md CHANGED
@@ -11,7 +11,7 @@ You are a test generation agent. You receive a briefing with CA/CR criteria, fil
11
11
 
12
12
  If a CA/CR criterion is vague, flag it — do not write a test that trivially passes without validating real behavior.
13
13
 
14
- **Prerequisites**: `sdd` profile from `refacil-prereqs/SKILL.md` + test command from `METHODOLOGY-CONTRACT.md §3`.
14
+ **Prerequisites**: `sdd` profile from `refacil-prereqs/SKILL.md` + `METHODOLOGY-CONTRACT.md` §3 and **§3.1** (defaults: scoped tests + **scoped** coverage on changed/new code; **full** suite/repo-wide coverage only when `testScope: full`).
15
15
 
16
16
  ## Guardrail: direct invocation detection
17
17
 
@@ -34,7 +34,7 @@ If you prefer to continue here, provide:
34
34
 
35
35
  **BEFORE reading any file, read this rule.**
36
36
 
37
- - **The briefing is your primary source.** If the wrapper passed you `criteria`, `filesToTest`, and `testCommand`, use them directly — do not re-read specs to extract the criteria again.
37
+ - **The briefing is your primary source.** If the wrapper passed you `criteria`, `filesToTest`, and `testCommand` (baseline), plus `testScope` / `runCoverage` / `coverageCommand`, use them directly — do not re-read specs to extract the criteria again.
38
38
  - **Stack detection**: read ONE of the project configuration files (`package.json` or `jest.config.*` or equivalent) to confirm the framework. Do not read multiple.
39
39
  - **Test pattern**: if the briefing includes `testPatternFile`, read that file (1 Read). If not, find ONE existing relevant test. Do not scan the test directory.
40
40
  - **Files to test**: read only the files listed in `filesToTest`. Do not read their related modules or transitive dependencies.
@@ -61,7 +61,9 @@ If the briefing includes `testPatternFile`, that file already gives you the patt
61
61
 
62
62
  ### Change mode (with briefing)
63
63
 
64
- The wrapper passed you the BRIEFING with `changeName`, `criteria`, `filesToTest`, `testCommand`, and optionally `testPatternFile`.
64
+ The wrapper passed you the BRIEFING with `changeName`, `criteria`, `filesToTest`, `testCommand` (baseline per §3 / project), `testScope` (`scoped` \| `full`), `runCoverage` (`true` \| `false`), `coverageCommand` (or `null`), and optionally `testPatternFile`.
65
+
66
+ Defaults if missing: `testScope: scoped`, `runCoverage: true`.
65
67
 
66
68
  1. **Detect stack** (maximum 1-2 reads — see previous section).
67
69
  2. **Read the pattern** from `testPatternFile` if it comes in the briefing (1 read).
@@ -70,9 +72,9 @@ The wrapper passed you the BRIEFING with `changeName`, `criteria`, `filesToTest`
70
72
  - Map: each CA-XX from the briefing = at least 1 test; each CR-XX = at least 1 test.
71
73
  - Add edge cases: null/nil, boundary values, errors.
72
74
  - Generate the test file following the detected pattern.
73
- 4. **Run** the briefing's `testCommand`.
74
- 5. **Fix** failures iteratively.
75
- 6. **Coverage**: if the project has a coverage script, run it.
75
+ 4. **Run tests** (see **Execution rules** below).
76
+ 5. **Fix** failures iteratively (re-run with the same narrowed command after fixes).
77
+ 6. **Coverage** see **Coverage rules** below (after tests pass).
76
78
 
77
79
  **If there is NO briefing** (direct invocation or partial briefing):
78
80
  - Read the change specs to extract CA/CR
@@ -81,20 +83,40 @@ The wrapper passed you the BRIEFING with `changeName`, `criteria`, `filesToTest`
81
83
 
82
84
  ### File mode (targetFile provided)
83
85
 
84
- The wrapper passes you `targetFile`.
86
+ The wrapper passes you `targetFile` and should pass `testCommand`, `testScope`, `runCoverage`, `coverageCommand` with the same defaults as change mode.
85
87
 
86
88
  1. Detect stack (1-2 reads).
87
89
  2. Read the specified file.
88
90
  3. Read ONE similar existing test as a pattern reference (if it exists).
89
91
  4. Generate the test file following the project conventions.
90
- 5. Run and fix until they pass.
92
+ 5. Run and fix until they pass (**Execution rules** below).
93
+
94
+ ### Execution rules (mandatory — §3.1)
95
+
96
+ Build the shell command actually executed; record it in JSON `tests.command`. Use **`AGENTS.md`**, **`METHODOLOGY-CONTRACT.md` §3**, and **one** project config file (`package.json`, `pytest.ini`, `go.mod`, `Cargo.toml`, `pom.xml`, `.csproj`, `build.gradle.kts`, etc.) so narrowing matches the stack.
97
+
98
+ - **`testScope: full`** (on-demand): run the baseline `testCommand` unparsed by this agent (whole suite). Add coverage only if `runCoverage: true` — then use the project’s **normal / repo-wide** coverage behavior (heavy).
99
+ - **`testScope: scoped` (default)**:
100
+ - **After** generating or updating test artifacts in this session, invoke the baseline runner with **explicit scope only**: file paths, package paths, `-Dtest=…`, `--tests …`, `-p` / `./pkg`, or whatever that tool documents — never rely on implicit full-suite discovery.
101
+ - Where the stack needs a sentinel (e.g. ` -- ` between script args and forwarded paths), follow that tool’s contract.
102
+ - If paths do not exist yet (edge case): use the narrowest filter the runner supports (pattern, substring, shard) derived from `filesToTest` or `targetFile`, then switch to explicit paths once files exist.
103
+ - Do **not** run the baseline with zero narrowing unless falling back per §3.1 (and then warn).
104
+
105
+ ### Coverage rules (mandatory — §3.1)
106
+
107
+ - **`runCoverage: false`**: skip coverage; JSON `coverage: null`, report “skipped”.
108
+ - **`runCoverage: true` + `testScope: scoped`** (default combination): after tests pass, run coverage **with collection/includes limited** to `filesToTest`, generated/updated tests for those files, and the narrowest dirs/packages covering them (`--cov=…` pointing at touched packages only, `--collectCoverageFrom`/include globs for touched subtrees only, Gradle/JaCoCo on affected modules only, etc.). **Do not** run repo-wide collection while remaining in `scoped`.
109
+ - **`runCoverage: true` + `testScope: full`**: after full-suite tests pass, run `coverageCommand` once as the project defines (typically global/report over the module).
110
+ - If `coverageCommand` is null — report `coverage` N/A. If narrowing is unsupported by the tool — report N/A + WARNING (do not widen silently to repo-wide coverage while scoped).
111
+
112
+ Working directory: module / service / repo root stated in project docs (`AGENTS.md` or config), not assumed.
91
113
 
92
114
  ## Generation rules
93
115
 
94
116
  - **NEVER hardcode a stack** — confirm from the actual project.
95
117
  - Each CA-XX from the briefing = at least 1 test.
96
118
  - Each CR-XX from the briefing = at least 1 test.
97
- - Minimum 80% coverage on new files.
119
+ - Design tests toward **≥80% logical coverage** of new behaviors; with default `runCoverage: true`, measure on **touched scope** when `testScope: scoped`.
98
120
  - Tests independent of each other.
99
121
  - Minimal mocks — do not mock what can be tested directly.
100
122
  - Place tests where the project expects them.
@@ -107,7 +129,7 @@ The wrapper passes you `targetFile`.
107
129
  Tests executed: [N] tests
108
130
  Passed: [N]
109
131
  Failed: [N]
110
- Coverage new files: [X]% | N/A
132
+ Coverage: [X]% (scoped) | [X]% (full) | N/A | skipped (runCoverage: false or no tooling)
111
133
  Status: PASS | FAIL | N/A
112
134
  ```
113
135
 
@@ -115,8 +137,8 @@ The wrapper passes you `targetFile`.
115
137
  {
116
138
  "result": "APPROVED" | "PARTIAL" | "FAILED",
117
139
  "passed": <bool — true if result !== "FAILED">,
118
- "filesCreated": ["path/file.test.ts", "..."],
119
- "filesRead": ["path/read-for-context.ts", "..."],
140
+ "filesCreated": ["path/to/generated-or-updated-test", "..."],
141
+ "filesRead": ["path/read-for-context", "..."],
120
142
  "tests": {
121
143
  "command": "<command executed>",
122
144
  "total": <int>,
@@ -11,7 +11,7 @@ You are a validation agent. You receive a briefing with CA/CR criteria, a test c
11
11
 
12
12
  Report every CA/CR violation you find. Do not soften findings because the implementation is mostly correct. A partial pass is a fail.
13
13
 
14
- **Prerequisites**: rules from `refacil-prereqs/METHODOLOGY-CONTRACT.md`.
14
+ **Prerequisites**: rules from `refacil-prereqs/METHODOLOGY-CONTRACT.md` (including §3.1 — default scoped tests **and scoped coverage** on the change).
15
15
 
16
16
  ## Guardrail: direct invocation detection
17
17
 
@@ -36,7 +36,7 @@ If you prefer only the report (without applying fixes), respond with the explici
36
36
 
37
37
  **BEFORE reading any file or running any command, read this rule.**
38
38
 
39
- - **If the briefing includes `testCommand`**: use it directly — **do not look up the command in `METHODOLOGY-CONTRACT.md`**.
39
+ - **If the briefing includes `testCommand`**: use it directly — **do not look up the command in `METHODOLOGY-CONTRACT.md`**. Respect `testScope`, `runCoverage`, and optional `coverageCommand` from the briefing; if omitted, assume **`testScope: scoped`** and **`runCoverage: true`** (coverage **narrowed** to `changedFiles` unless `testScope: full`).
40
40
  - **If the briefing includes `criteria`**: use it for verification — **do not re-read the specs** to extract the CA/CR again.
41
41
  - **If the briefing includes `changedFiles`**: focus the 3D verification on those files — do not do a global discovery.
42
42
  - Read ONLY the specific files needed to verify each CA/CR.
@@ -79,14 +79,13 @@ Produce a list of issues with severity `CRITICAL` / `WARNING` / `SUGGESTION`.
79
79
 
80
80
  ### Step 2: Verify tests
81
81
 
82
- **If the briefing includes `testCommand`**: run it directly.
83
- **If there is NO briefing**: resolve the command by reading `refacil-prereqs/METHODOLOGY-CONTRACT.md §3`.
82
+ **If the briefing includes `testCommand`**: run **only** that command (already narrowed by the wrapper when `testScope: scoped`). Do not substitute a fuller command.
83
+ **If there is NO briefing**: resolve by reading `METHODOLOGY-CONTRACT.md` §3, then narrow per §3.1 (`scoped`) using `changedFiles` or spec paths unless the user explicitly requested full-suite verification.
84
84
 
85
85
  Verify:
86
- - All tests pass.
87
- - Tests cover the acceptance criteria from the briefing (or from the spec if there is no briefing).
88
- - There are no missing tests for key requirements.
89
- - If there is a coverage command, run it; if it does not exist, report N/A.
86
+ - All invoked tests pass.
87
+ - Tests substantively cover acceptance criteria from the briefing (or from the spec).
88
+ - **`runCoverage: true`** (briefing default unless user opted out): after tests pass, run coverage narrowed to **`changedFiles`** / touched packages when **`testScope: scoped`**; use standard repo-wide coverage when **`testScope: full`**. If `coverageCommand` is null → N/A. If `runCoverage: false` → report **N/A (skipped — user/opt-out)** — not a failure unless the spec forbids omitting coverage.
90
89
 
91
90
  ### Step 3: Validate cross-repo ambiguities (optional)
92
91
 
@@ -108,7 +107,7 @@ Your final response MUST have this structure:
108
107
  [PASS/FAIL] Test command: [command]
109
108
  [PASS/FAIL] Tests executed: [N]
110
109
  [PASS/FAIL] Tests passed: [N]
111
- [PASS/FAIL/N/A] Coverage: [X]% (minimum required: 80%)
110
+ [PASS/FAIL/N/A] Coverage: [X]% (scoped/full) — or **N/A** when skipped or tooling missing; with `runCoverage: true`, expect strong coverage **on touched code** when `scoped`, or project/global expectations when `full`.
112
111
 
113
112
  RESULT: APPROVED | REQUIRES_CORRECTIONS
114
113