@widnyana/design-thinking 0.0.6 → 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,11 +72,15 @@ 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.1
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
50
79
 
80
+ # via the omp marketplace
81
+ omp plugin marketplace add widnyana/eyay-toolkits
82
+ omp plugin install design-thinking@eyay-toolkits
83
+
51
84
  # try without installing
52
85
  pi -e npm:@widnyana/design-thinking
53
86
  pi -e ./pi-packages/design-thinking
@@ -59,14 +92,18 @@ pi -e ./pi-packages/design-thinking
59
92
 
60
93
  | Command | What it does |
61
94
  |---|---|
62
- | `/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. |
63
96
  | `/dt on\|off\|status` | Set or query the mode explicitly. |
64
- | `/dt approve\|deny` | Arm/revoke file edits for the next agent run — run `approve` after a presented graph to let the implementation run edit, `deny` to re-lock. |
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). |
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. |
65
99
  | `/dt <prompt>` | Turn the mode **on** (never off), then run `<prompt>` under it — graph and clarifying questions first, implementation after your go-ahead. |
66
100
  | `/cg <module \| task>` | Generate a call graph: extract the graph existing code implements, or sketch one for a task. |
67
- | `/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. |
68
102
  | `/cg-review [file\|module\|diff]` | Reconstruct the implemented graph, diff it against the method's checklist, end with a VERDICT. |
69
- | `/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.
70
107
 
71
108
  ## A real-world walkthrough
72
109
 
@@ -76,7 +113,7 @@ Task: *add rate limiting to an Express API.* One design pass, end to end:
76
113
  > /dt # mode on — graph-first rules injected
77
114
 
78
115
  > /cg-plan add per-user rate limiting to the API
79
- → agent sketches a DesignGraph first (SHAPES, GRAPH, E, boundaries),
116
+ → agent sketches the graph first (SHAPES, GRAPH, E, boundaries),
80
117
  then implements code that matches it
81
118
 
82
119
  > /cg-map nodejs # optional: before planning, when the
@@ -102,6 +139,6 @@ flowchart LR
102
139
  P --> C[implement] --> R["/cg-review <file>"] --> O["/dt off"]
103
140
  ```
104
141
 
105
- Skills (`graph-protocol`, `design-method`, `design-graph`) are loaded by the
142
+ Skills (`design-thinking`, `design-graph`, `graph-protocol`) are loaded by the
106
143
  agent on demand mid-turn — you never invoke them directly; the `/cg*` prompts
107
144
  and `/dt` mode tell the model when to reach for them.