@ritualai/cli 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/commands/init.js +19 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/pat-store.js +3 -3
- package/dist/lib/pat-store.js.map +1 -1
- package/dist/lib/project-config.js +51 -0
- package/dist/lib/project-config.js.map +1 -0
- package/dist/lib/repo-name.js +80 -0
- package/dist/lib/repo-name.js.map +1 -0
- package/dist/lib/workspace-flow.js +82 -0
- package/dist/lib/workspace-flow.js.map +1 -0
- package/package.json +1 -1
- package/skills/claude-code/ritual/SKILL.md +117 -16
- package/skills/codex/ritual/SKILL.md +117 -16
- package/skills/cursor/ritual/SKILL.md +117 -16
- package/skills/gemini/ritual/SKILL.md +117 -16
- package/skills/kiro/ritual/SKILL.md +117 -16
- package/skills/vscode/ritual/SKILL.md +117 -16
|
@@ -51,60 +51,161 @@ When **not** to use:
|
|
|
51
51
|
- An exploration already exists with recommendations — fetch directly via `get_exploration` + `get_recommendations`
|
|
52
52
|
- The user wants to *implement* a feature from existing recommendations — use `/ritual-builder-spec` (from `@ritual-ai/cli`)
|
|
53
53
|
|
|
54
|
-
### Workflow —
|
|
54
|
+
### Workflow — 8 phases
|
|
55
55
|
|
|
56
56
|
Each phase has explicit **[USER PAUSE]** points — never skip them.
|
|
57
57
|
|
|
58
58
|
#### Phase 1 — Pick a workspace
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
Resolution order:
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
1. **Project-bound workspace (preferred).** Check for a `.ritual/config.json` at the project root (you can use the Read tool — the file is a small JSON with `workspaceId` + `workspaceName`). If it exists, that's the workspace this repo is bound to. Surface it to the user: "Using workspace **`{workspaceName}`** (bound to this repo). Sound right?" — wait for **[USER PAUSE]**.
|
|
63
|
+
2. **List existing project workspaces.** If no `.ritual/config.json`, call `mcp__ritual__list_workspaces` — this returns project-type workspaces (the General workspace is excluded by default; agents never use it). Present as a numbered list (id, name). **[USER PAUSE]** for selection.
|
|
64
|
+
3. **Create a new one if none exist or user wants a fresh one.** Call `mcp__ritual__create_workspace` with a name — convention is to name it after the repo (basename of cwd, or origin remote). Confirm the name with the user first. **[USER PAUSE]**
|
|
63
65
|
|
|
64
|
-
Store `workspace_id
|
|
66
|
+
Store `workspace_id` for the rest of the flow.
|
|
67
|
+
|
|
68
|
+
If you created a new workspace, suggest the user run `ritual init` to persist the binding into `.ritual/config.json` for next time (or write it yourself if the user is in a Claude Code session that can edit files).
|
|
69
|
+
|
|
70
|
+
#### Phase 1.5 — Code reconnaissance
|
|
71
|
+
|
|
72
|
+
**Skip only if the user explicitly asks ("just generate, don't read the code") OR if you're operating outside a codebase context.**
|
|
73
|
+
|
|
74
|
+
Before generating considerations, do a structured scan of the codebase so the sub-problems land specific to *this* code, not generic. The legacy system shipped considerations that read like a textbook table of contents because it skipped this step; the difference between "Conversion Timing, Trust Signals, Recovery Paths" (generic) and "Leverage `apps/checkout/session.py` anonymous-checkout path vs. adding a new step in `CheckoutSessionMixin`" (codebase-specific) is whether you did Phase 1.5.
|
|
75
|
+
|
|
76
|
+
Steps:
|
|
77
|
+
|
|
78
|
+
1. **Read the README + top-level project structure.** Use `ls` / Glob to see top-level files (5–10 lines). Identify the language, framework, key directories.
|
|
79
|
+
|
|
80
|
+
2. **Glob for relevance.** Derive patterns from the user's problem. Examples:
|
|
81
|
+
- User says "auth flow" → `**/auth/**`, `**/login*`, `**/user*`, `**/session*`
|
|
82
|
+
- User says "checkout" → `**/checkout/**`, `**/cart/**`, `**/order/**`, `**/payment*`
|
|
83
|
+
- User says "notifications" → `**/notif*`, `**/email/**`, `**/sms/**`, `**/push/**`
|
|
84
|
+
Cap at ~15 hits per pattern.
|
|
85
|
+
|
|
86
|
+
3. **Skim 3–5 most-relevant files.** For each, read the first ~100 lines + scan for class/function names. Triangulate: "is the behavior we care about actually here, or does it call into somewhere else?"
|
|
87
|
+
|
|
88
|
+
4. **Build a recon summary** — 5–10 lines, concrete file paths, key abstractions, observed constraints. Examples of GOOD summaries:
|
|
89
|
+
|
|
90
|
+
> Codebase recon (django-oscar, Django 5.0):
|
|
91
|
+
> - Booking flow lives in `apps/checkout/views.py` (`CheckoutSessionMixin` orchestrates the step chain)
|
|
92
|
+
> - Anonymous checkout already supported via `apps/checkout/session.py:CheckoutSessionData`
|
|
93
|
+
> - Account creation entry point: `apps/customer/forms.py:RegisterUserForm`
|
|
94
|
+
> - Strategy classes (`apps/partner/strategy.py`) are the conventional pluggability pattern
|
|
95
|
+
> - User-model split: `auth.User` is the Django auth user; `apps/customer/models.py:Customer` is the order-attached profile — they can be linked or anonymous
|
|
96
|
+
|
|
97
|
+
5. **Surface to the user as a [USER PAUSE]**:
|
|
98
|
+
|
|
99
|
+
> Reading the codebase I see:
|
|
100
|
+
> <recon summary>
|
|
101
|
+
>
|
|
102
|
+
> Anything I'm missing about design intent or constraints I won't find by reading the code (e.g. business decisions, prod incidents, in-flight migrations)?
|
|
103
|
+
|
|
104
|
+
Wait for confirmation or additional context. The user's reply (if any) becomes part of the input to Phase 2.
|
|
105
|
+
|
|
106
|
+
6. **Compose the augmented `raw_input` for Phase 2.** Concatenate:
|
|
107
|
+
- The user's original problem (verbatim, top)
|
|
108
|
+
- A `--- Codebase context ---` section with the recon summary
|
|
109
|
+
- The user's reply from step 5 if non-empty
|
|
110
|
+
- Phase 1.5 IS the difference between "generic considerations" and "considerations that name actual files and reference existing patterns". Don't skip the recon step. Don't compress the summary to one line.
|
|
111
|
+
|
|
112
|
+
7. **Collect the `sources` array.** The file paths you read in step 3 — exactly as they appear in the repo (e.g. `"apps/checkout/views.py"`, NOT `"./apps/checkout/views.py"` or absolute paths). This list is passed alongside `raw_input` to `generate_considerations` and `generate_problem_statement` so the API can auto-inject **prior knowledge-graph context** for overlapping files. Keep the list focused — only files you actually read and consider load-bearing for this problem. 5–10 is the sweet spot; >20 dilutes the KG signal.
|
|
113
|
+
|
|
114
|
+
**[USER PAUSE]** confirmation of recon is required before proceeding.
|
|
65
115
|
|
|
66
116
|
#### Phase 2 — Generate sub-problems
|
|
67
117
|
|
|
118
|
+
##### 2.1 First draft
|
|
119
|
+
|
|
68
120
|
Call `mcp__ritual__generate_considerations` with:
|
|
69
121
|
- `workspace_id`
|
|
70
|
-
- `raw_input` (the problem
|
|
122
|
+
- `raw_input` (the user's problem + the Phase 1.5 codebase recon, concatenated as described above)
|
|
71
123
|
- `template_id` (omit unless the user specified one)
|
|
124
|
+
- `sources` (the file path list from Phase 1.5 step 7 — file-path strings only, e.g. `["apps/checkout/views.py", ...]`)
|
|
72
125
|
|
|
73
|
-
LLM call, ~5
|
|
126
|
+
LLM call, ~5–10s. Returns 5–6 sub-problems — different framing axes the agent should investigate. Track each one as `{ text, version: 1 }` in your working memory.
|
|
127
|
+
|
|
128
|
+
**If the response includes `kg_context_used` with `implementationCount > 0`:** surface this to the user BEFORE presenting the considerations. It's the visible signal that prior team decisions shaped this draft.
|
|
129
|
+
|
|
130
|
+
> Reading the codebase I overlapped with 3 prior Ritual explorations on these files:
|
|
131
|
+
> - **"Anonymous checkout opt-in"** (shipped 2026-04-12) — 2 decisions, 1 deferral
|
|
132
|
+
> - **"Payment-method routing"** (shipped 2026-03-22) — 4 decisions
|
|
133
|
+
> - **"Session-data persistence"** (shipped 2026-02-08) — 1 decision
|
|
134
|
+
>
|
|
135
|
+
> I factored those into the sub-problems below.
|
|
136
|
+
|
|
137
|
+
If `implementationCount === 0`: don't mention the KG check (silent — would just be noise on a cold KG).
|
|
74
138
|
|
|
75
139
|
**[USER PAUSE]** Present as a numbered list and ask which to include:
|
|
76
140
|
|
|
77
|
-
> Sub-problems the system identified:
|
|
141
|
+
> Sub-problems the system identified (v1):
|
|
78
142
|
>
|
|
79
143
|
> 1. {sub-problem 1}
|
|
80
144
|
> 2. {sub-problem 2}
|
|
81
145
|
> ...
|
|
82
146
|
>
|
|
83
|
-
> Which should we factor into the scope? Pick any subset, or "
|
|
147
|
+
> Which should we factor into the scope? Pick any subset, "all", or ask for a different framing (e.g. "make them more technical", "drop the measurement angle", "focus on enterprise").
|
|
148
|
+
|
|
149
|
+
##### 2.2 Iteration loop
|
|
150
|
+
|
|
151
|
+
If the user asks for a refinement (anything that isn't "all" / specific picks / "these are good"):
|
|
152
|
+
|
|
153
|
+
Call `mcp__ritual__refine_considerations` with:
|
|
154
|
+
- `workspace_id`, `raw_input`, `template_id`, `sources` — unchanged from the generate call. Critical: pass the SAME `sources` array each iteration so the KG-injected priorContext stays consistent.
|
|
155
|
+
- `change_prompt`: the user's request verbatim
|
|
156
|
+
- `selected`: items from prior versions the user kept (track `{ text, from_version }`, send just `text`)
|
|
157
|
+
- `dismissed`: items the user explicitly rejected
|
|
158
|
+
- `session_id`: omitted on the first refinement; pass the `session_id` from the previous refine response on subsequent ones to chain context
|
|
159
|
+
|
|
160
|
+
Track the new items as `{ text, version: N+1 }`. Present **alongside** the prior versions, not replacing them — the user can mix selections across versions.
|
|
161
|
+
|
|
162
|
+
Loop until the user says "these are good" or picks a subset.
|
|
84
163
|
|
|
85
|
-
|
|
164
|
+
**Critical**: never re-call `generate_considerations` for a refinement. That endpoint is stateless and re-rolls a fresh seed; you'll lose what the user just told you. The whole point of `refine_*` is the LLM sees the iteration context.
|
|
165
|
+
|
|
166
|
+
Store the final picked sub-problems for Phase 3 — they go into `considerations[]`.
|
|
86
167
|
|
|
87
168
|
#### Phase 3 — Generate scope
|
|
88
169
|
|
|
170
|
+
##### 3.1 First draft
|
|
171
|
+
|
|
89
172
|
Call `mcp__ritual__generate_problem_statement` with:
|
|
90
173
|
- `workspace_id`
|
|
91
|
-
- `raw_input`
|
|
92
|
-
- `considerations` (the picks from Phase 2
|
|
174
|
+
- `raw_input` (same augmented version from Phase 2)
|
|
175
|
+
- `considerations` (the picks from Phase 2)
|
|
93
176
|
- `template_id` (same as Phase 2 if used)
|
|
177
|
+
- `sources` (the same file-path list passed to generate_considerations — keeps the KG anchor consistent)
|
|
178
|
+
|
|
179
|
+
Returns a polished "How might we ..." style scope (typically <800 chars) plus optional follow-up questions and quality scores. Treat this as **v1** of the problem statement.
|
|
180
|
+
|
|
181
|
+
If the response includes `kg_context_used` with `implementationCount > 0`, prepend a note to the scope presentation:
|
|
94
182
|
|
|
95
|
-
|
|
183
|
+
> *(Grounded in {N} prior implementation{s}: {top match name}, …)*
|
|
96
184
|
|
|
97
185
|
**[USER PAUSE]** Present and ask:
|
|
98
186
|
|
|
99
|
-
> Here's the scope:
|
|
187
|
+
> Here's the scope (v1):
|
|
100
188
|
>
|
|
101
189
|
> > **{generated scope}**
|
|
102
190
|
>
|
|
103
|
-
> Looks good? Want to tighten / broaden / change the audience? Or "ship it" to lock it in.
|
|
191
|
+
> Looks good? Want to tighten / broaden / change the audience / focus on a specific tier? Or "ship it" to lock it in.
|
|
192
|
+
|
|
193
|
+
##### 3.2 Iteration loop
|
|
194
|
+
|
|
195
|
+
If the user asks for a refinement:
|
|
196
|
+
|
|
197
|
+
Call `mcp__ritual__refine_problem_statement` with:
|
|
198
|
+
- `workspace_id`, `raw_input`, `considerations`, `template_id`, `sources` — unchanged. (Same `sources` as the original generate call — keeps the KG anchor stable.)
|
|
199
|
+
- `previous_problem_statement`: the FULL TEXT of the current best draft (the v1 you just showed)
|
|
200
|
+
- `change_prompt`: the user's request verbatim ("tighten and drop the audience clause")
|
|
201
|
+
- `version`: optional label like `"v2"` — purely for telemetry
|
|
202
|
+
- `session_id`: omitted on the first refinement; chain on subsequent ones
|
|
203
|
+
|
|
204
|
+
The returned text becomes `v2`. Show it. The user can iterate v2 → v3 → ... by calling refine again with `previous_problem_statement` set to the latest draft.
|
|
104
205
|
|
|
105
|
-
|
|
206
|
+
**Critical**: each refinement's `previous_problem_statement` is the LATEST draft, not the original v1. Otherwise the LLM keeps refining the same starting point and the user can't compose multiple refinements ("tighter, AND drop the audience clause, AND make it past-tense").
|
|
106
207
|
|
|
107
|
-
|
|
208
|
+
When the user accepts ("ship it" / "looks good"), store the final text as `problem_statement` for Phase 4.
|
|
108
209
|
|
|
109
210
|
#### Phase 4 — Create the exploration
|
|
110
211
|
|
|
@@ -51,60 +51,161 @@ When **not** to use:
|
|
|
51
51
|
- An exploration already exists with recommendations — fetch directly via `get_exploration` + `get_recommendations`
|
|
52
52
|
- The user wants to *implement* a feature from existing recommendations — use `/ritual-builder-spec` (from `@ritual-ai/cli`)
|
|
53
53
|
|
|
54
|
-
### Workflow —
|
|
54
|
+
### Workflow — 8 phases
|
|
55
55
|
|
|
56
56
|
Each phase has explicit **[USER PAUSE]** points — never skip them.
|
|
57
57
|
|
|
58
58
|
#### Phase 1 — Pick a workspace
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
Resolution order:
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
1. **Project-bound workspace (preferred).** Check for a `.ritual/config.json` at the project root (you can use the Read tool — the file is a small JSON with `workspaceId` + `workspaceName`). If it exists, that's the workspace this repo is bound to. Surface it to the user: "Using workspace **`{workspaceName}`** (bound to this repo). Sound right?" — wait for **[USER PAUSE]**.
|
|
63
|
+
2. **List existing project workspaces.** If no `.ritual/config.json`, call `mcp__ritual__list_workspaces` — this returns project-type workspaces (the General workspace is excluded by default; agents never use it). Present as a numbered list (id, name). **[USER PAUSE]** for selection.
|
|
64
|
+
3. **Create a new one if none exist or user wants a fresh one.** Call `mcp__ritual__create_workspace` with a name — convention is to name it after the repo (basename of cwd, or origin remote). Confirm the name with the user first. **[USER PAUSE]**
|
|
63
65
|
|
|
64
|
-
Store `workspace_id
|
|
66
|
+
Store `workspace_id` for the rest of the flow.
|
|
67
|
+
|
|
68
|
+
If you created a new workspace, suggest the user run `ritual init` to persist the binding into `.ritual/config.json` for next time (or write it yourself if the user is in a Claude Code session that can edit files).
|
|
69
|
+
|
|
70
|
+
#### Phase 1.5 — Code reconnaissance
|
|
71
|
+
|
|
72
|
+
**Skip only if the user explicitly asks ("just generate, don't read the code") OR if you're operating outside a codebase context.**
|
|
73
|
+
|
|
74
|
+
Before generating considerations, do a structured scan of the codebase so the sub-problems land specific to *this* code, not generic. The legacy system shipped considerations that read like a textbook table of contents because it skipped this step; the difference between "Conversion Timing, Trust Signals, Recovery Paths" (generic) and "Leverage `apps/checkout/session.py` anonymous-checkout path vs. adding a new step in `CheckoutSessionMixin`" (codebase-specific) is whether you did Phase 1.5.
|
|
75
|
+
|
|
76
|
+
Steps:
|
|
77
|
+
|
|
78
|
+
1. **Read the README + top-level project structure.** Use `ls` / Glob to see top-level files (5–10 lines). Identify the language, framework, key directories.
|
|
79
|
+
|
|
80
|
+
2. **Glob for relevance.** Derive patterns from the user's problem. Examples:
|
|
81
|
+
- User says "auth flow" → `**/auth/**`, `**/login*`, `**/user*`, `**/session*`
|
|
82
|
+
- User says "checkout" → `**/checkout/**`, `**/cart/**`, `**/order/**`, `**/payment*`
|
|
83
|
+
- User says "notifications" → `**/notif*`, `**/email/**`, `**/sms/**`, `**/push/**`
|
|
84
|
+
Cap at ~15 hits per pattern.
|
|
85
|
+
|
|
86
|
+
3. **Skim 3–5 most-relevant files.** For each, read the first ~100 lines + scan for class/function names. Triangulate: "is the behavior we care about actually here, or does it call into somewhere else?"
|
|
87
|
+
|
|
88
|
+
4. **Build a recon summary** — 5–10 lines, concrete file paths, key abstractions, observed constraints. Examples of GOOD summaries:
|
|
89
|
+
|
|
90
|
+
> Codebase recon (django-oscar, Django 5.0):
|
|
91
|
+
> - Booking flow lives in `apps/checkout/views.py` (`CheckoutSessionMixin` orchestrates the step chain)
|
|
92
|
+
> - Anonymous checkout already supported via `apps/checkout/session.py:CheckoutSessionData`
|
|
93
|
+
> - Account creation entry point: `apps/customer/forms.py:RegisterUserForm`
|
|
94
|
+
> - Strategy classes (`apps/partner/strategy.py`) are the conventional pluggability pattern
|
|
95
|
+
> - User-model split: `auth.User` is the Django auth user; `apps/customer/models.py:Customer` is the order-attached profile — they can be linked or anonymous
|
|
96
|
+
|
|
97
|
+
5. **Surface to the user as a [USER PAUSE]**:
|
|
98
|
+
|
|
99
|
+
> Reading the codebase I see:
|
|
100
|
+
> <recon summary>
|
|
101
|
+
>
|
|
102
|
+
> Anything I'm missing about design intent or constraints I won't find by reading the code (e.g. business decisions, prod incidents, in-flight migrations)?
|
|
103
|
+
|
|
104
|
+
Wait for confirmation or additional context. The user's reply (if any) becomes part of the input to Phase 2.
|
|
105
|
+
|
|
106
|
+
6. **Compose the augmented `raw_input` for Phase 2.** Concatenate:
|
|
107
|
+
- The user's original problem (verbatim, top)
|
|
108
|
+
- A `--- Codebase context ---` section with the recon summary
|
|
109
|
+
- The user's reply from step 5 if non-empty
|
|
110
|
+
- Phase 1.5 IS the difference between "generic considerations" and "considerations that name actual files and reference existing patterns". Don't skip the recon step. Don't compress the summary to one line.
|
|
111
|
+
|
|
112
|
+
7. **Collect the `sources` array.** The file paths you read in step 3 — exactly as they appear in the repo (e.g. `"apps/checkout/views.py"`, NOT `"./apps/checkout/views.py"` or absolute paths). This list is passed alongside `raw_input` to `generate_considerations` and `generate_problem_statement` so the API can auto-inject **prior knowledge-graph context** for overlapping files. Keep the list focused — only files you actually read and consider load-bearing for this problem. 5–10 is the sweet spot; >20 dilutes the KG signal.
|
|
113
|
+
|
|
114
|
+
**[USER PAUSE]** confirmation of recon is required before proceeding.
|
|
65
115
|
|
|
66
116
|
#### Phase 2 — Generate sub-problems
|
|
67
117
|
|
|
118
|
+
##### 2.1 First draft
|
|
119
|
+
|
|
68
120
|
Call `mcp__ritual__generate_considerations` with:
|
|
69
121
|
- `workspace_id`
|
|
70
|
-
- `raw_input` (the problem
|
|
122
|
+
- `raw_input` (the user's problem + the Phase 1.5 codebase recon, concatenated as described above)
|
|
71
123
|
- `template_id` (omit unless the user specified one)
|
|
124
|
+
- `sources` (the file path list from Phase 1.5 step 7 — file-path strings only, e.g. `["apps/checkout/views.py", ...]`)
|
|
72
125
|
|
|
73
|
-
LLM call, ~5
|
|
126
|
+
LLM call, ~5–10s. Returns 5–6 sub-problems — different framing axes the agent should investigate. Track each one as `{ text, version: 1 }` in your working memory.
|
|
127
|
+
|
|
128
|
+
**If the response includes `kg_context_used` with `implementationCount > 0`:** surface this to the user BEFORE presenting the considerations. It's the visible signal that prior team decisions shaped this draft.
|
|
129
|
+
|
|
130
|
+
> Reading the codebase I overlapped with 3 prior Ritual explorations on these files:
|
|
131
|
+
> - **"Anonymous checkout opt-in"** (shipped 2026-04-12) — 2 decisions, 1 deferral
|
|
132
|
+
> - **"Payment-method routing"** (shipped 2026-03-22) — 4 decisions
|
|
133
|
+
> - **"Session-data persistence"** (shipped 2026-02-08) — 1 decision
|
|
134
|
+
>
|
|
135
|
+
> I factored those into the sub-problems below.
|
|
136
|
+
|
|
137
|
+
If `implementationCount === 0`: don't mention the KG check (silent — would just be noise on a cold KG).
|
|
74
138
|
|
|
75
139
|
**[USER PAUSE]** Present as a numbered list and ask which to include:
|
|
76
140
|
|
|
77
|
-
> Sub-problems the system identified:
|
|
141
|
+
> Sub-problems the system identified (v1):
|
|
78
142
|
>
|
|
79
143
|
> 1. {sub-problem 1}
|
|
80
144
|
> 2. {sub-problem 2}
|
|
81
145
|
> ...
|
|
82
146
|
>
|
|
83
|
-
> Which should we factor into the scope? Pick any subset, or "
|
|
147
|
+
> Which should we factor into the scope? Pick any subset, "all", or ask for a different framing (e.g. "make them more technical", "drop the measurement angle", "focus on enterprise").
|
|
148
|
+
|
|
149
|
+
##### 2.2 Iteration loop
|
|
150
|
+
|
|
151
|
+
If the user asks for a refinement (anything that isn't "all" / specific picks / "these are good"):
|
|
152
|
+
|
|
153
|
+
Call `mcp__ritual__refine_considerations` with:
|
|
154
|
+
- `workspace_id`, `raw_input`, `template_id`, `sources` — unchanged from the generate call. Critical: pass the SAME `sources` array each iteration so the KG-injected priorContext stays consistent.
|
|
155
|
+
- `change_prompt`: the user's request verbatim
|
|
156
|
+
- `selected`: items from prior versions the user kept (track `{ text, from_version }`, send just `text`)
|
|
157
|
+
- `dismissed`: items the user explicitly rejected
|
|
158
|
+
- `session_id`: omitted on the first refinement; pass the `session_id` from the previous refine response on subsequent ones to chain context
|
|
159
|
+
|
|
160
|
+
Track the new items as `{ text, version: N+1 }`. Present **alongside** the prior versions, not replacing them — the user can mix selections across versions.
|
|
161
|
+
|
|
162
|
+
Loop until the user says "these are good" or picks a subset.
|
|
84
163
|
|
|
85
|
-
|
|
164
|
+
**Critical**: never re-call `generate_considerations` for a refinement. That endpoint is stateless and re-rolls a fresh seed; you'll lose what the user just told you. The whole point of `refine_*` is the LLM sees the iteration context.
|
|
165
|
+
|
|
166
|
+
Store the final picked sub-problems for Phase 3 — they go into `considerations[]`.
|
|
86
167
|
|
|
87
168
|
#### Phase 3 — Generate scope
|
|
88
169
|
|
|
170
|
+
##### 3.1 First draft
|
|
171
|
+
|
|
89
172
|
Call `mcp__ritual__generate_problem_statement` with:
|
|
90
173
|
- `workspace_id`
|
|
91
|
-
- `raw_input`
|
|
92
|
-
- `considerations` (the picks from Phase 2
|
|
174
|
+
- `raw_input` (same augmented version from Phase 2)
|
|
175
|
+
- `considerations` (the picks from Phase 2)
|
|
93
176
|
- `template_id` (same as Phase 2 if used)
|
|
177
|
+
- `sources` (the same file-path list passed to generate_considerations — keeps the KG anchor consistent)
|
|
178
|
+
|
|
179
|
+
Returns a polished "How might we ..." style scope (typically <800 chars) plus optional follow-up questions and quality scores. Treat this as **v1** of the problem statement.
|
|
180
|
+
|
|
181
|
+
If the response includes `kg_context_used` with `implementationCount > 0`, prepend a note to the scope presentation:
|
|
94
182
|
|
|
95
|
-
|
|
183
|
+
> *(Grounded in {N} prior implementation{s}: {top match name}, …)*
|
|
96
184
|
|
|
97
185
|
**[USER PAUSE]** Present and ask:
|
|
98
186
|
|
|
99
|
-
> Here's the scope:
|
|
187
|
+
> Here's the scope (v1):
|
|
100
188
|
>
|
|
101
189
|
> > **{generated scope}**
|
|
102
190
|
>
|
|
103
|
-
> Looks good? Want to tighten / broaden / change the audience? Or "ship it" to lock it in.
|
|
191
|
+
> Looks good? Want to tighten / broaden / change the audience / focus on a specific tier? Or "ship it" to lock it in.
|
|
192
|
+
|
|
193
|
+
##### 3.2 Iteration loop
|
|
194
|
+
|
|
195
|
+
If the user asks for a refinement:
|
|
196
|
+
|
|
197
|
+
Call `mcp__ritual__refine_problem_statement` with:
|
|
198
|
+
- `workspace_id`, `raw_input`, `considerations`, `template_id`, `sources` — unchanged. (Same `sources` as the original generate call — keeps the KG anchor stable.)
|
|
199
|
+
- `previous_problem_statement`: the FULL TEXT of the current best draft (the v1 you just showed)
|
|
200
|
+
- `change_prompt`: the user's request verbatim ("tighten and drop the audience clause")
|
|
201
|
+
- `version`: optional label like `"v2"` — purely for telemetry
|
|
202
|
+
- `session_id`: omitted on the first refinement; chain on subsequent ones
|
|
203
|
+
|
|
204
|
+
The returned text becomes `v2`. Show it. The user can iterate v2 → v3 → ... by calling refine again with `previous_problem_statement` set to the latest draft.
|
|
104
205
|
|
|
105
|
-
|
|
206
|
+
**Critical**: each refinement's `previous_problem_statement` is the LATEST draft, not the original v1. Otherwise the LLM keeps refining the same starting point and the user can't compose multiple refinements ("tighter, AND drop the audience clause, AND make it past-tense").
|
|
106
207
|
|
|
107
|
-
|
|
208
|
+
When the user accepts ("ship it" / "looks good"), store the final text as `problem_statement` for Phase 4.
|
|
108
209
|
|
|
109
210
|
#### Phase 4 — Create the exploration
|
|
110
211
|
|