@widnyana/design-thinking 0.0.20 → 0.1.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/GUIDE.md ADDED
@@ -0,0 +1,233 @@
1
+ # design-thinking: guide, tips, and tricks
2
+
3
+ This guide covers the Claude Code plugin and the pi / omp package. They share the
4
+ same methods, references, and commands. Where the two harnesses behave differently,
5
+ the section says so.
6
+
7
+ ## The idea in one paragraph
8
+
9
+ Draw the graph before you write the code. Nodes are functions (or screens, or
10
+ agent tasks), edges are what flows between them, and every failure path gets a
11
+ name. Then the code must match the graph. If it does not, one of the two is
12
+ wrong, and a review can show which one.
13
+
14
+ The method comes from r17x's gist:
15
+ https://gist.github.com/r17x/90eb2f7be93932b5693753aedb09c01a
16
+
17
+ ## Pick the right method
18
+
19
+ | You are working on | Method | Shape | Where it shows up |
20
+ |---|---|---|---|
21
+ | Code: a feature, a fix, a refactor | Design Thinking | `X → Graph → Effect<A, E, R>` | `/cg`, `/cg-plan`, `/cg-review`, `/cg-map`, `/dt` |
22
+ | An interface: screens, flows, components | Design Graph | `Job → Flow → Surface<C, V, N>` | `/cg-plan` and `/cg-review` switch to it for interface tasks |
23
+ | Work split across subagents or workers | Graph Protocol | `X → Graph → Delegation<A, E, R>` | `/cg-plan` adds it when a task needs more than one worker |
24
+ | A research topic | Meta Research Prompt Generator | waves of research, review, index, synthesis agents | `/research-prompt` |
25
+
26
+ The letters mean the same thing in every method:
27
+
28
+ - **A (or C)**: what flows on the happy path.
29
+ - **E (or V)**: every way it breaks (or every way the content can be missing).
30
+ - **R (or N)**: what each node needs before it can run (or before a screen can show).
31
+
32
+ ## Commands at a glance
33
+
34
+ | Command | Use it when |
35
+ |---|---|
36
+ | `/dt` | You want every plan and review in this session drawn as a graph first. Bare `/dt` toggles. `/dt on`, `/dt off`, `/dt status` set or show it. |
37
+ | `/dt <prompt>` | You want to start a task with the mode on. It turns the mode on (never off) and runs the prompt. |
38
+ | `/cg <module or task>` | You want to see how existing code flows, or sketch the flow of a new task. |
39
+ | `/cg-plan <task>` | You are about to build something and want the design agreed first. |
40
+ | `/cg-review [target]` | You finished a change and want to check the code against its graph. No target means the current `git diff`. |
41
+ | `/cg-map <language or framework>` | The stack is new to you, or to the agent, and you want the markers mapped to its idioms first. |
42
+ | `/research-prompt <topic>` | You want a multi-agent research run on a topic. |
43
+
44
+ Claude Code: if another plugin has a command with the same name, use the full name,
45
+ for example `/design-thinking:cg-plan`.
46
+
47
+ ## A normal working loop
48
+
49
+ 1. `/dt on` at the start of a session where real design decisions happen.
50
+ 2. `/cg-map <stack>` once per stack, only if the stack vocabulary is unclear.
51
+ 3. `/cg-plan <task>`. Read the graph. Push back on the graph, not on the code.
52
+ 4. Approve (see "How approval works" below). The agent implements to match the graph.
53
+ 5. `/cg-review` on the diff. It rebuilds the graph the code really implements and
54
+ compares it with the plan.
55
+ 6. `/dt off` when you are done.
56
+
57
+ ## How approval works
58
+
59
+ **pi and omp** have a mechanical gate. While `/dt` is on and nothing is approved,
60
+ file edits, shell commands, and code execution are blocked. Read-only tools still
61
+ work. When a run ends with a graph, a dialog opens:
62
+
63
+ - **Approve**: the gate opens and implementation starts at once.
64
+ - **Refine**: you type feedback, the agent updates the graph, and the dialog opens again.
65
+ - **Deny**: everything stays blocked until a new graph is shown.
66
+
67
+ The approval covers one instruction from you. When you send a new message, the gate
68
+ closes again and the agent folds your message into the existing graph. Sessions
69
+ with no UI use `/dt approve` and `/dt deny` instead.
70
+
71
+ **Claude Code** has no mechanical gate. The mode is a rule the agent follows: graph
72
+ and questions first, no edits until you say go. Say "approved" or "go ahead" in
73
+ plain words.
74
+
75
+ ## Reading a graph quickly
76
+
77
+ Read these sections first. They catch most problems:
78
+
79
+ 1. **PROBLEM**: one line. If it is vague, stop and fix it before anything else.
80
+ 2. **GRAPH**: follow the arrows. Every arrow should carry something you can name.
81
+ 3. **VERDICT**: does it say what the code must satisfy, or name the mismatches?
82
+
83
+ The markers:
84
+
85
+ | Marker | Meaning |
86
+ |---|---|
87
+ | `⟳retry[×n]` | transient failure, try again |
88
+ | `↯escape(alt)` | recoverable, return an alternative |
89
+ | `☠die` | a bug or broken invariant, not a domain error |
90
+ | `🔒 x → y` | untrusted data becomes trusted here, and only here |
91
+ | `(1)` `(N)` `(T)` | runs once, many values over time, valid for a time window |
92
+ | `⛈ name` | a layer that wraps the node (logging, retry policy) without changing it |
93
+ | `@scope` | where a resource is acquired and released |
94
+
95
+ Red flags worth a comment before you approve:
96
+
97
+ - A failure with no marker. Someone will swallow it later.
98
+ - `☠die` on something a user can cause. That is a domain error, not a bug.
99
+ - Validation in the middle of the graph instead of at a `🔒` edge.
100
+ - TEST LAYERS that needs a mock of half the world. The node does too much.
101
+ - A `(N)` node drawn as `(1)`, for example a paginated API treated as one call.
102
+
103
+ ## Tips for `/cg`
104
+
105
+ - Name a real entry point: `/cg src/http/router.ts` or `/cg "what happens on POST /orders"`.
106
+ A vague target gives a vague graph.
107
+ - Every node in a trace comes with `path:line` under `src:`. If a line is missing or
108
+ wrong, ask the agent to verify it. The format forbids guessed paths.
109
+ - The **Tests** section appears only when the test wiring differs from production.
110
+ That difference is exactly what the tests swap out, so read it.
111
+ - A plain fact question ("what port does X use") gets a plain answer, no graph.
112
+
113
+ ## Tips for `/cg-plan`
114
+
115
+ - Give the task with its constraints: `/cg-plan add per-user rate limit, Redis is already a dependency, 429 with Retry-After`.
116
+ - Interface tasks get the Design Graph skeleton (JOB, SURFACES, FLOW, VOID, NEEDS,
117
+ ATTENTION, PROOF). Check the VOID section: empty, loading, partial, error, and
118
+ denied each need a design, not a default.
119
+ - A small task stops after the graph. A task with two or more independent parts
120
+ gets a delegation plan: a DELEGATED GRAPH with waves and one AGENT SUBGRAPH per
121
+ node. Each worker then returns a RETURN block, and the agent ends with an
122
+ IMPLEMENTED GRAPH that lists OFF-SCRIPT work and GAPS.
123
+ - Nodes that touch the same files never run in the same wave. If you see that, the
124
+ plan is wrong.
125
+ - Keep the plan graph in the session. `/cg-review` compares against it.
126
+
127
+ ## Tips for `/cg-review`
128
+
129
+ - Run it with no argument right after implementation: it reviews `git diff`.
130
+ - Point it at one module when the diff is large: `/cg-review src/billing/`.
131
+ - Findings are grouped by § number (1 to 10). §2 (tangled happy path) and §4
132
+ (unhandled breaks) are usually the ones that cause incidents.
133
+ - For delegated work, give it the delegated graph and the workers' RETURN blocks.
134
+ It compares each subgraph with what was really built.
135
+
136
+ ## Tips for `/cg-map`
137
+
138
+ - Run it once per stack and keep the answer in the session. Later plans and reviews
139
+ reuse the vocabulary.
140
+ - Good inputs are specific: `/cg-map rust tokio axum`, `/cg-map python fastapi sqlalchemy`.
141
+
142
+ ## `/research-prompt`: research runs
143
+
144
+ It is a two-step tool, as r17x designed it. Step one writes a prompt file and prints
145
+ one command. Step two is you running that command. The generator never starts the
146
+ research itself, so you can read the prompt before many agents spend tokens on it.
147
+
148
+ ```
149
+ /research-prompt nix store
150
+ REFS: ./docs/prior-research.md, https://nixos.org/manual
151
+ Focus on garbage collection internals and binary cache trust model.
152
+ ```
153
+
154
+ Input fields, in any order after the first line:
155
+
156
+ - `NAME: <kebab-case>`: the project name. Without it, the first plain line becomes the name.
157
+ - `REFS: a, b`: files or URLs the researchers read first. Bare `./`, `/`, `~/`, or `http` tokens count too.
158
+ - `DEPENDS_ON: name1, name2`: earlier research projects to build on.
159
+ - Any other text: context that focuses the topics.
160
+
161
+ Everything lives under `./research/` in the directory where you run it:
162
+
163
+ ```
164
+ ./research/
165
+ projects/<NAME>/.<NAME>.research.prompt the coordinator prompt
166
+ projects/<NAME>/RESEARCH.md the final document
167
+ scratch/ per-node working files
168
+ ref/INDEX.md, ref/<repo>/, ref/<file> cloned repos and downloaded specs
169
+ ```
170
+
171
+ Tips:
172
+
173
+ - Run the printed command from the same directory. All paths in the prompt are relative.
174
+ - Claude Code prints a `claude -p ... --allowedTools ...` line. pi prints `pi --mode json -p ...`,
175
+ omp prints `omp --mode json -p ...`. pi needs a subagent tool installed for the parallel waves.
176
+ - The run streams JSON events so you can see it working. Without the streaming flag
177
+ (`--output-format stream-json` on Claude Code, `--mode json` on pi/omp), print mode
178
+ stays silent until the very end. A quieter way to watch progress from a second
179
+ terminal: `ls -lt research/scratch research/ref`. Scratch files appear when each
180
+ node finishes, so an empty `scratch/` early in wave 1 is normal.
181
+ - Run it in a scratch or research directory, not inside a code repo you care about:
182
+ `research/ref/` gets full `git clone` copies, and code indexers will pick them up.
183
+ - No model is pinned. Add `--model <name>` to the printed line if you want a specific one.
184
+ - Interrupted run: run `/research-prompt` again with the same NAME. It lists which
185
+ nodes are COMPLETE or MISSING and prints a resume command. Finished nodes are
186
+ skipped.
187
+ - Finished project: the same NAME is refused. Build on it with
188
+ `DEPENDS_ON: <NAME>` under a new name.
189
+ - Add `research/scratch/` and `research/ref/` to `.gitignore` unless you want cloned
190
+ repos in your history. `research/projects/*/RESEARCH.md` is the part worth keeping.
191
+ - pi with `/dt` on: the prompt file write goes through the approval gate. Approve it,
192
+ or `/dt off` first.
193
+
194
+ ## Harness differences
195
+
196
+ | | Claude Code | pi / omp |
197
+ |---|---|---|
198
+ | Install | `/plugin install design-thinking@eyay-toolkits` | `pi install npm:@widnyana/design-thinking` or `omp install npm:@widnyana/design-thinking` |
199
+ | `/dt` state | `.claude/design-thinking.local.md` in the project, re-announced at session start | kept in the session; shown in the status bar |
200
+ | Edits before approval | rule only | blocked mechanically, dialog to approve |
201
+ | Specs the agent reads | the `design-thinking`, `design-graph`, `graph-protocol` skills and `references/` | the package `references/` directory (absolute path injected while `/dt` is on) |
202
+ | LSP reminder | no | yes, always on: use the language server when the session has one |
203
+
204
+ Claude Code: add `.claude/*.local.md` to `.gitignore`. It is per-user state.
205
+
206
+ ## Troubleshooting
207
+
208
+ | Symptom | Cause and fix |
209
+ |---|---|
210
+ | pi: every edit is blocked | `/dt` is on and nothing is approved. Approve in the dialog, or `/dt off`. |
211
+ | pi: no dialog appears | The run did not end with a graph (it needs VERDICT plus at least three other sections), or the session has no UI. Use `/dt approve`. |
212
+ | pi: `pi -p "/research-prompt ..."` writes nothing | Print mode runs the slash command and exits before the queued message runs. Use an interactive session (or RPC mode). |
213
+ | Claude Code: mode lost after restart | Check `.claude/design-thinking.local.md` says `enabled: true`. The hook reads it at session start. |
214
+ | Graph uses a header like `DesignGraph<A, E, R>` | Old version. Update: the current header is `X → Graph → Effect<A, E, R>`. |
215
+ | `/research-prompt` says the prompt already exists | A run was started before. Use the printed resume command, or pick a new NAME. |
216
+ | The agent writes prose instead of a graph | Ask for "the full output format". Specs: `references/output-format.md`. |
217
+
218
+ ## When not to use it
219
+
220
+ - One-line fixes, typos, renames, config value changes. Prose is fine.
221
+ - Questions with a single fact as the answer.
222
+ - Throwaway spikes you will delete. Draw the graph when the spike becomes real code.
223
+
224
+ ## Where the specs live
225
+
226
+ All in the package's `references/` directory:
227
+
228
+ - `design-thinking.md`: the code method, §1 to §10.
229
+ - `output-format.md`: sections, markers, call graph block, completeness checklist.
230
+ - `design-graph.md`: the interface method and its skeleton.
231
+ - `graph-protocol.md`: delegation, AGENT SUBGRAPH, RETURN, IMPLEMENTED GRAPH.
232
+ - `meta-research.md`: the research prompt generator.
233
+ - `effect-ts.md`: the original Effect-TS version, for attribution.
package/README.md CHANGED
@@ -5,7 +5,7 @@ AI coding agents ship code before asking what breaks. This extension flips the
5
5
  order: with `/dt` active, [pi](https://pi.dev) draws the call graph first —
6
6
  nodes are functions, edges are data flow, every failure path is named — then
7
7
  writes code that *is* the graph. Plans, reviews, and refactors render in a
8
- fixed, mechanically checkable notation (Graph Protocol) that looks the same in
8
+ fixed, mechanically checkable notation that looks the same in
9
9
  Go, Rust, Python, or TypeScript.
10
10
 
11
11
  Method by [r17x](https://github.com/r17x) ([Design Thinking
@@ -23,7 +23,7 @@ the error, retry silently, drop the request) nobody agreed to, or the
23
23
  reviewer approves a plan that was never specific enough to catch the
24
24
  mismatch once the code lands.
25
25
 
26
- Design Graph replaces the prose plan with something that can be diffed.
26
+ The graph replaces the prose plan with something that can be diffed.
27
27
  Nodes are functions, edges are data and error/escape paths, boundaries are
28
28
  named — fixed before code exists. `/cg-review` then reconstructs the graph
29
29
  the code actually implements and diffs it against the one that was planned,
@@ -33,6 +33,35 @@ Go, Rust, Python, or TypeScript, so the check doesn't depend on the stack.
33
33
  Skip it for a one-line fix — prose is fine there. Reach for `/dt` when the
34
34
  change has a failure path worth agreeing on before it's written.
35
35
 
36
+ Guides, tips, and troubleshooting: [GUIDE.md](GUIDE.md).
37
+
38
+ ## Three methods, one shape
39
+
40
+ From r17x's gist: the same three-channel discipline, applied to three materials.
41
+
42
+ | Method | Shape | Nodes / edges | Use for |
43
+ |---|---|---|---|
44
+ | Design Thinking | `X → Graph → Effect<A, E, R>` | functions / data flow | code: plans, reviews, refactors |
45
+ | Design Graph | `Job → Flow → Surface<C, V, N>` | surfaces / the moves between them | interfaces: screens, flows, components |
46
+ | Graph Protocol | `X → Graph → Delegation<A, E, R>` | tasks / data dependencies | splitting work across subagents: AGENT SUBGRAPH in, IMPLEMENTED GRAPH out |
47
+
48
+ Plus r17x's **Meta Research Prompt Generator** (from the gist comments) as
49
+ `/research-prompt`: one topic line in, one research coordination prompt file
50
+ and the command to run it out. Its waves of research, review, index, and
51
+ synthesis agents each get an AGENT SUBGRAPH. All its files live under
52
+ `./research/` in the directory where you run it:
53
+
54
+ ```
55
+ ./research/
56
+ projects/<NAME>/.<NAME>.research.prompt the coordinator prompt
57
+ projects/<NAME>/RESEARCH.md the final document
58
+ scratch/n1_<slug>.md, r1_review_<slug>.md per-node working files
59
+ ref/INDEX.md, ref/<repo>/, ref/<file> cloned repos and downloaded specs
60
+ ```
61
+
62
+ Add `research/scratch/` and `research/ref/` to `.gitignore` if you do not want
63
+ them committed.
64
+
36
65
  ## Install
37
66
 
38
67
  ```bash
@@ -43,7 +72,7 @@ pi install npm:@widnyana/design-thinking
43
72
  omp install npm:@widnyana/design-thinking
44
73
 
45
74
  # pinned version
46
- pi install npm:@widnyana/design-thinking@0.0.19
75
+ pi install npm:@widnyana/design-thinking@0.1.0
47
76
 
48
77
  # from a local checkout of this repo
49
78
  pi install /absolute/path/to/pi-packages/design-thinking
@@ -63,15 +92,18 @@ pi -e ./pi-packages/design-thinking
63
92
 
64
93
  | Command | What it does |
65
94
  |---|---|
66
- | `/dt` | Toggle Design Thinking mode. While on, plans and reviews render as Design Graphs. Persists across restarts. |
95
+ | `/dt` | Toggle Design Thinking mode. While on, plans and reviews render as annotated call graphs. Persists across restarts. |
67
96
  | `/dt on\|off\|status` | Set or query the mode explicitly. |
68
97
  | Review dialog | When a run ends with a presented Design Graph — or the agent asks for approval in prose — a dialog opens automatically (arrow keys + Enter or mouse), **never mid-run**: **Approve** arms the gate (file edits, shells, code execution) **and** sends the go-ahead so implementation starts immediately, **Refine** asks for feedback and sends it back to the agent (the dialog re-opens after the updated graph), **Deny** keeps everything blocked until a new Design Graph is presented (a Deny latches — it won't re-prompt on every run end). Headless/no-UI sessions fall back to manual `/dt approve\|deny`. While unapproved, `write`, `edit`, `bash`, and code-execution tools are blocked outright — read-only exploration keeps `read`/`grep`/`glob`, plus read-only MCP lookups (qmd, codegraph explore). |
69
98
  | LSP reminder | Always-on, independent of `/dt`: while the harness has an `lsp` tool (omp with LSP enabled — default), every run gets a short `LSP FIRST` block — use the language server for definitions/references/renames/diagnostics, never hand-grep or hand-edit renames; if the project has no configured server, the agent tells you once per session how to enable one. Without an `lsp` tool, you get one notification per session **with a UI** (omp: enable it or add a server; pi: pi has no LSP integration) — headless/no-UI sessions get none. |
70
99
  | `/dt <prompt>` | Turn the mode **on** (never off), then run `<prompt>` under it — graph and clarifying questions first, implementation after your go-ahead. |
71
100
  | `/cg <module \| task>` | Generate a call graph: extract the graph existing code implements, or sketch one for a task. |
72
- | `/cg-plan <task>` | Design before code — full Design Graph, then implement to match it. |
101
+ | `/cg-plan <task>` | Design before code: full graph, then (when the task needs several workers) a Graph Protocol delegation plan with one AGENT SUBGRAPH per node, then implement and compare. |
73
102
  | `/cg-review [file\|module\|diff]` | Reconstruct the implemented graph, diff it against the method's checklist, end with a VERDICT. |
74
- | `/cg-map <language\|framework>` | Map the Protocol vocabulary onto a stack's idioms (Result vs exceptions, RAII vs defer). |
103
+ | `/cg-map <language\|framework>` | Map the Design Thinking vocabulary onto a stack's idioms (Result vs exceptions, RAII vs defer). |
104
+ | `/research-prompt <topic>` | Meta Research Prompt Generator: writes `./research/projects/<NAME>/.<NAME>.research.prompt` and prints the `claude -p` / `pi --mode json -p` / `omp --mode json -p` command that runs it. Fields: `NAME:`, `REFS:`, `DEPENDS_ON:`, free-text context. |
105
+
106
+ With `/dt` on, the file `/research-prompt` writes goes through the approval gate like any other edit: approve it in the review dialog, or run `/dt off` first.
75
107
 
76
108
  ## A real-world walkthrough
77
109
 
@@ -81,7 +113,7 @@ Task: *add rate limiting to an Express API.* One design pass, end to end:
81
113
  > /dt # mode on — graph-first rules injected
82
114
 
83
115
  > /cg-plan add per-user rate limiting to the API
84
- → agent sketches a DesignGraph first (SHAPES, GRAPH, E, boundaries),
116
+ → agent sketches the graph first (SHAPES, GRAPH, E, boundaries),
85
117
  then implements code that matches it
86
118
 
87
119
  > /cg-map nodejs # optional: before planning, when the
@@ -107,6 +139,6 @@ flowchart LR
107
139
  P --> C[implement] --> R["/cg-review <file>"] --> O["/dt off"]
108
140
  ```
109
141
 
110
- Skills (`graph-protocol`, `design-method`, `design-graph`) are loaded by the
142
+ Skills (`design-thinking`, `design-graph`, `graph-protocol`) are loaded by the
111
143
  agent on demand mid-turn — you never invoke them directly; the `/cg*` prompts
112
144
  and `/dt` mode tell the model when to reach for them.
@@ -1,24 +1,25 @@
1
1
  /**
2
2
  * Design Thinking — pi extension
3
3
  *
4
- * Adopts the three pillars:
5
- * - Design Thinking : the mindset (§1–§10 pipeline, problem-first)
6
- * - Design Graph : the artifact (annotated call graph of a concrete problem)
7
- * - Graph Protocol : the notation spec (fixed sections, fixed markers)
4
+ * Adopts r17x's three methods (one shape, three materials):
5
+ * - Design Thinking : code, X → Graph → Effect<A, E, R> (§1-§10 pipeline)
6
+ * - Design Graph : interface, Job → Flow → Surface<C, V, N>
7
+ * - Graph Protocol : delegation, AGENT SUBGRAPH in, IMPLEMENTED GRAPH out
8
8
  *
9
9
  * When /dt mode is active, every turn appends a compact distilled block to the
10
- * system prompt so design/plan/review answers render as Design Graphs in
11
- * Graph Protocol form. Full specs live in the package's references/ directory,
10
+ * system prompt so design/plan/review answers render as an annotated call
11
+ * graph in the Design Thinking output format. Full specs live in the package's references/ directory,
12
12
  * loaded on demand — not inlined here, to keep the injected prompt small.
13
13
  * Separately, an ALWAYS-ON LSP reminder composes into every run's system
14
14
  * prompt while the harness exposes an `lsp` tool (mode-independent); without
15
15
  * one, the user is told once per session how to enable it.
16
16
  *
17
17
  * Commands:
18
+ * /research-prompt <msg> Meta Research Prompt Generator (references/meta-research.md)
18
19
  * /dt toggle Design Thinking mode
19
20
  * /dt on|off set explicitly
20
21
  * /dt approve|deny manual arm/revoke fallback (headless / no-UI sessions)
21
- * After a gated run presents a Design Graph, a review dialog opens
22
+ * After a gated run presents a design graph, a review dialog opens
22
23
  * automatically: Approve (arm + implement), Refine (send feedback), or
23
24
  * Deny (keep file edits blocked). /dt <prompt> turns the mode ON (never
24
25
  * off) and runs the prompt — graph + clarifying questions before code.
@@ -36,7 +37,7 @@
36
37
  * decision is applied only if its epoch is still current AND the gate is
37
38
  * still on AND still unapproved. Stale decisions are discarded, not
38
39
  * applied.
39
- * - The dialog opens at run end when the agent presented a Design Graph
40
+ * - The dialog opens at run end when the agent presented a design graph
40
41
  * (VERDICT + section headers) OR ended the turn asking for approval in
41
42
  * prose — the human always gets a button, never a prose-only ask.
42
43
  * - Dialogs are opened with an extension-owned AbortSignal: omp binds
@@ -52,6 +53,7 @@
52
53
  * to whatever stack the project uses; never the discipline.
53
54
  */
54
55
 
56
+ import fs from "node:fs";
55
57
  import path from "node:path";
56
58
  import { fileURLToPath } from "node:url";
57
59
 
@@ -77,7 +79,7 @@ const DISTILLED = `
77
79
  DESIGN THINKING MODE — active.
78
80
  Read the problem. Draw the data flow as a call graph. Write code that IS the graph.
79
81
 
80
- X → DesignGraph<A, E, R>
82
+ X → Graph → Effect<A, E, R>
81
83
  │ │ │ │ │
82
84
  │ │ │ │ └─ R: what each node needs (§5)
83
85
  │ │ │ └──── E: where the graph breaks (§4)
@@ -93,7 +95,7 @@ Pipeline: shapes → graph(A) → cardinality → E(⟳retry ↯escape ☠die)
93
95
  Rules:
94
96
  - ANY turn that will end in code or file changes (feature, change, fix,
95
97
  refactor — the model does NOT get to reclassify the request): render the
96
- Design Graph in Graph Protocol form and any clarifying questions FIRST;
98
+ graph in the Design Thinking output format and any clarifying questions FIRST;
97
99
  ZERO mutations until the user approves the design — no file edits, no
98
100
  shell commands, no code execution. Reading/exploring code first is fine,
99
101
  via read-only tools only (read/grep/glob; read-only MCP devices such as
@@ -105,25 +107,29 @@ Rules:
105
107
  when the run ends — never mid-run: approve (implement the presented design
106
108
  without re-presenting the graph), refine (present an updated graph), or
107
109
  deny (stay blocked).
108
- - Design, plan, and review answers must render a Design Graph — fixed
110
+ - Design, plan, and review answers must render the graph, fixed
109
111
  sections: PROBLEM, SHAPES, GRAPH, CARDINALITY, BOUNDARIES, BEHAVIOR, SCOPE,
110
112
  TEST LAYERS, VERDICT.
111
113
  - The happy path (A) stays readable; failure handling lives at defined join points.
112
114
  - Each layer scopes its own E; inner errors never leak through.
113
115
  - If the code doesn't match the call graph, the implementation is wrong.
114
116
  - Adapt vocabulary to the current language/stack; never the discipline.
117
+ - Interface work uses the Design Graph (Surface<C, V, N>) skeleton.
118
+ - Delegating to subagents or workers follows Graph Protocol: AGENT SUBGRAPH
119
+ in, IMPLEMENTED GRAPH out, compared before the work counts as done.
115
120
 
116
121
  Full specs — read these when a section needs detail:
117
- - ${REF_DIR}/protocol.md (Graph Protocol: notation spec + worked example)
118
- - ${REF_DIR}/method.md (the §1–§10 method, generalized)
119
- - ${REF_DIR}/design-graph.md (the artifact spec + completeness checklist)
122
+ - ${REF_DIR}/design-thinking.md (the code method, §1-§10)
123
+ - ${REF_DIR}/output-format.md (sections, markers, call graph block, checklist)
124
+ - ${REF_DIR}/design-graph.md (the interface method + skeleton)
125
+ - ${REF_DIR}/graph-protocol.md (delegation: execution graph, AGENT SUBGRAPH, RETURN)
120
126
  The extension blocks file edits, shells (bash/powershell), and code
121
127
  execution (eval) mechanically until the user approves — a review dialog
122
128
  opens when a graph-presenting run ends. Approval covers
123
129
  ONE human turn: it stays armed across the many runs it takes to implement
124
130
  the approved design, and drops the moment the user sends a new instruction.
125
131
  Treat that next instruction as a refinement of the current design: UPDATE
126
- the existing Design Graph to fold it in and re-present it (do not start a
132
+ the existing design graph to fold it in and re-present it (do not start a
127
133
  blank graph unless the goal itself changed), then end the turn and wait for
128
134
  the dialog. /dt deny or mode off also re-lock.
129
135
  NEVER ask the user to run /dt approve, /dt deny, or any approval command:
@@ -177,7 +183,7 @@ interface DtState {
177
183
 
178
184
 
179
185
  const GATE_REASON =
180
- "Design Thinking mode is ON: file edits, shell commands, and code execution are blocked until the user approves the presented design. Do NOT attempt this change through any other channel — no bash or shell commands, no eval/scripts, no subagent delegation. Explore with read-only tools (read/grep/glob), present (or update and re-present) the Design Graph (Graph Protocol), then END YOUR TURN with NO prose approval request — an approval dialog opens for the user automatically when the run ends. NEVER ask the user to run /dt approve, /dt deny, or any command; NEVER re-attempt the blocked action this turn.";
186
+ "Design Thinking mode is ON: file edits, shell commands, and code execution are blocked until the user approves the presented design. Do NOT attempt this change through any other channel — no bash or shell commands, no eval/scripts, no subagent delegation. Explore with read-only tools (read/grep/glob), present (or update and re-present) the design graph, then END YOUR TURN with NO prose approval request — an approval dialog opens for the user automatically when the run ends. NEVER ask the user to run /dt approve, /dt deny, or any command; NEVER re-attempt the blocked action this turn.";
181
187
 
182
188
  const REVIEW_OPTIONS = [
183
189
  "Approve — implement now",
@@ -210,12 +216,12 @@ const LSP_SUGGESTION_OMP =
210
216
  const LSP_SUGGESTION_PI =
211
217
  "LSP Reminder: pi has no LSP integration — code intelligence falls back to text search. omp provides a built-in `lsp` tool.";
212
218
 
213
- // Graph Protocol section headers. A real Design Graph renders the fixed set;
219
+ // Output-format section headers (code and interface skeletons). A real graph renders the fixed set;
214
220
  // VERDICT is mandatory. Requiring VERDICT + ≥3 others avoids tripping on a bare
215
221
  // mention of the word "verdict" in prose, and still fires on a graph rendered
216
222
  // without that exact literal elsewhere.
217
223
  const SECTION_HEADER =
218
- /^[ \t]*#{0,4}[ \t>*-]*(PROBLEM|SHAPES|GRAPH|CARDINALITY|BOUNDARIES|BEHAVIOR|SCOPE|TEST LAYERS|VERDICT)\b/gm;
224
+ /^[ \t]*#{0,4}[ \t>*-]*(PROBLEM|SHAPES|GRAPH|CARDINALITY|BOUNDARIES|BEHAVIOR|SCOPE|TEST LAYERS|JOB|SURFACES|FLOW|VOID|NEEDS|BOUNDARY|ATTENTION|PROOF|VERDICT)\b/gm;
219
225
 
220
226
  /** The agent is asking the human for a go-ahead in prose — narrow on purpose so
221
227
  * an ordinary closing sentence does not trip it. */
@@ -235,7 +241,7 @@ function messageText(content: unknown): string {
235
241
  .join("\n");
236
242
  }
237
243
 
238
- /** Does an assistant message render a Design Graph (Graph Protocol)? */
244
+ /** Does an assistant message render a design graph (code or interface skeleton)? */
239
245
  function presentsGraph(message: { role: string; content?: unknown }): boolean {
240
246
  if (message.role !== "assistant") return false;
241
247
  const seen = new Set<string>();
@@ -260,10 +266,10 @@ export default function designThinkingExtension(pi: ExtensionAPI) {
260
266
  // "armed" lets mutating tools through. Approval is NOT consumed by runs:
261
267
  // implementing an approved design spans many runs, and re-arming per run
262
268
  // only produced approval loops. It is re-locked by relock() when a new user
263
- // instruction arrives, when a NEW Design Graph is presented, by /dt deny, or
269
+ // instruction arrives, when a NEW design graph is presented, by /dt deny, or
264
270
  // when the mode turns off.
265
271
  let approval: "none" | "armed" = "none";
266
- // A Design Graph was presented in the CURRENT design cycle. Reset by
272
+ // A design graph was presented in the CURRENT design cycle. Reset by
267
273
  // relock() — i.e. when a new user instruction arrives. Approval is scoped to
268
274
  // one human turn: it survives the many runs of implementing an approved
269
275
  // design, and drops the moment the user speaks again (a new goal, or a
@@ -447,7 +453,7 @@ export default function designThinkingExtension(pi: ExtensionAPI) {
447
453
  applyStatus(ctx);
448
454
  ctx.ui.notify(
449
455
  on
450
- ? "Design Thinking ON — plans and reviews will render as Design Graphs (Graph Protocol)"
456
+ ? "Design Thinking ON — plans and reviews will render as annotated call graphs"
451
457
  : "Design Thinking OFF",
452
458
  "info",
453
459
  );
@@ -458,13 +464,35 @@ export default function designThinkingExtension(pi: ExtensionAPI) {
458
464
  relock();
459
465
  // deliverAs "steer": sends immediately when idle, queues mid-stream.
460
466
  await pi.sendUserMessage(
461
- `${prompt}\n\n(Design Thinking is ON: before implementing, present the Design Graph (Graph Protocol) and any clarifying questions, then wait for my go-ahead.)`,
467
+ `${prompt}\n\n(Design Thinking is ON: before implementing, present the design graph and any clarifying questions, then wait for my go-ahead.)`,
462
468
  { deliverAs: "steer" },
463
469
  );
464
470
  }
465
471
  },
466
472
  });
467
473
 
474
+ // ── /research-prompt command ────────────────────────────────────────────
475
+ // r17x's Meta Research Prompt Generator. The template ships in references/;
476
+ // pi prompts cannot read package files, so the command reads it and sends
477
+ // it with the user's message (§6 boundary: file → text, read once here).
478
+ pi.registerCommand("research-prompt", {
479
+ description: "Meta Research Prompt Generator: writes ./research/projects/<NAME>/.<NAME>.research.prompt and prints the run command",
480
+ handler: async (args, ctx) => {
481
+ let generator: string;
482
+ try {
483
+ generator = fs.readFileSync(path.join(REF_DIR, "meta-research.md"), "utf8");
484
+ } catch (err) {
485
+ ctx.ui.notify(`research-prompt: cannot read ${REF_DIR}/meta-research.md (${(err as Error).message})`, "error");
486
+ return;
487
+ }
488
+ const harness = isOmp() ? "omp" : "pi";
489
+ await pi.sendUserMessage(
490
+ `${generator}\n\n---\n\nYou run inside ${harness}: in step 8 print only the ${harness} command.\n\nUser message:\n${(args ?? "").trim()}`,
491
+ { deliverAs: "steer" },
492
+ );
493
+ },
494
+ });
495
+
468
496
  // ── Run hooks ───────────────────────────────────────────────────────────
469
497
  // A genuine user instruction re-locks the gate: the previous approval covered
470
498
  // the previous turn's work only. Our own go-ahead / refine messages arrive as
@@ -606,7 +634,7 @@ export default function designThinkingExtension(pi: ExtensionAPI) {
606
634
  }
607
635
  retractOffer();
608
636
  await pi.sendUserMessage(
609
- `Refine the presented design (do not implement yet): ${feedback.trim()}\n\n(Design Thinking: update the Design Graph (Graph Protocol) per this feedback and present it again. Mutations stay blocked.)`,
637
+ `Refine the presented design (do not implement yet): ${feedback.trim()}\n\n(Design Thinking: update the design graph per this feedback and present it again. Mutations stay blocked.)`,
610
638
  { deliverAs: "steer" },
611
639
  );
612
640
  })().catch((err: unknown) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widnyana/design-thinking",
3
- "version": "0.0.20",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "description": "Design Thinking · Design Graph · Graph Protocol — a stack-agnostic design methodology for pi. Turns every plan, review, and refactor into an annotated call graph. Method originally by r17x; generalized to a pi package by widnyana.",
6
6
  "author": {
@@ -21,6 +21,7 @@
21
21
  "skills",
22
22
  "references",
23
23
  "README.md",
24
+ "GUIDE.md",
24
25
  "LICENSE"
25
26
  ],
26
27
  "repository": {
package/prompts/cg-map.md CHANGED
@@ -1,16 +1,16 @@
1
1
  ---
2
- description: Map the Graph Protocol vocabulary onto a language/framework's concrete idioms
2
+ description: Map the Design Thinking vocabulary onto a language/framework's concrete idioms
3
3
  argument-hint: "<language | framework>"
4
4
  ---
5
- Map the Design Graph method onto: $@
5
+ Map the Design Thinking method onto: $@
6
6
 
7
7
  Produce a vocabulary mapping so the method's three channels (A, E, R) and its
8
8
  markers have concrete, idiomatic counterparts in the target stack. Output a
9
- mapping table followed by a small worked mini-graph in Graph Protocol format.
9
+ mapping table followed by a small worked mini-graph in the Design Thinking output format.
10
10
 
11
11
  ## Mapping table (required rows)
12
12
 
13
- | Protocol concept | Question to answer for the target stack |
13
+ | Concept | Question to answer for the target stack |
14
14
  |---|---|
15
15
  | **A** — happy path | Where does the straight-line happy path live? (main fn, do-block, generator pipeline, SQL CTE chain…) |
16
16
  | **E** — failure carrying | How are failures values vs control flow? (Result/Either, checked exceptions, error returns, panics+recover, throw at layer joins…) |
@@ -30,11 +30,12 @@ mapping table followed by a small worked mini-graph in Graph Protocol format.
30
30
  - Be concrete: name actual libraries, patterns, and syntax idioms of the stack.
31
31
  - If the stack lacks a native counterpart for a concept, say so and name the
32
32
  closest convention (and its cost).
33
- - After the table, render a mini Design Graph (PROBLEM → header tree → GRAPH →
33
+ - After the table, render a mini graph (PROBLEM → header tree → GRAPH →
34
34
  VERDICT only) for a small example task in this stack, using the mapped
35
35
  vocabulary — proving the mapping works end to end.
36
36
  - This mapping is a companion artifact: once produced, refer to it in later
37
37
  `/cg-plan` and `/cg-review` runs in the same stack.
38
38
 
39
- Full specs live in this package's `references/` directory: `protocol.md`
40
- (notation), `method.md` (the method), `design-graph.md` (artifact).
39
+ Full specs live in this package's `references/` directory: `design-thinking.md`
40
+ (the code method), `output-format.md` (format + checklist), `design-graph.md`
41
+ (the interface method), `graph-protocol.md` (delegation to agents).