@widnyana/design-thinking 0.0.3 → 0.0.5
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.
|
@@ -82,15 +82,29 @@ Skills load BY NAME into the agent (/skill:<name>); the files above are named
|
|
|
82
82
|
by stem, NOT by skill name. Exact mapping:
|
|
83
83
|
/skill:graph-protocol → protocol.md /skill:design-method → method.md
|
|
84
84
|
/skill:design-graph → design-graph.md
|
|
85
|
+
Zero file edits are possible until the user runs /dt approve for the turn —
|
|
86
|
+
the extension blocks write/edit tools mechanically. Present the graph first.
|
|
85
87
|
NEVER read references/<skill-name>.md — no such files exist.
|
|
86
88
|
`.trim();
|
|
87
89
|
|
|
90
|
+
const MUTATING_TOOLS: Record<string, true> = {
|
|
91
|
+
write: true,
|
|
92
|
+
edit: true,
|
|
93
|
+
apply_patch: true,
|
|
94
|
+
multiedit: true,
|
|
95
|
+
};
|
|
96
|
+
|
|
88
97
|
interface DtState {
|
|
89
98
|
enabled: boolean;
|
|
90
99
|
}
|
|
91
100
|
|
|
101
|
+
const GATE_REASON =
|
|
102
|
+
"Design Thinking mode is ON: present the Design Graph (Graph Protocol) and wait for user approval before file edits. The user can unlock this turn with /dt approve.";
|
|
103
|
+
|
|
92
104
|
export default function designThinkingExtension(pi: ExtensionAPI) {
|
|
93
105
|
let enabled = false;
|
|
106
|
+
// Per-turn approval flag: set by /dt approve, reset on every user turn.
|
|
107
|
+
let approvedForTurn = false;
|
|
94
108
|
|
|
95
109
|
function applyStatus(ctx: ExtensionContext) {
|
|
96
110
|
ctx.ui.setStatus(
|
|
@@ -131,13 +145,27 @@ export default function designThinkingExtension(pi: ExtensionAPI) {
|
|
|
131
145
|
|
|
132
146
|
// /dt — the Design Thinking tool. Toggles mode, or /dt on|off|status.
|
|
133
147
|
pi.registerCommand("dt", {
|
|
134
|
-
description: "Design Thinking mode: /dt toggles, on|off|status set/query, anything else runs as a prompt with mode on",
|
|
148
|
+
description: "Design Thinking mode: /dt toggles, on|off|status set/query, approve|deny unlock/lock file edits for this turn, anything else runs as a prompt with mode on",
|
|
135
149
|
handler: async (args, ctx) => {
|
|
136
150
|
const arg = (args ?? "").trim();
|
|
137
151
|
const lower = arg.toLowerCase();
|
|
138
152
|
|
|
139
153
|
if (lower === "status") {
|
|
140
|
-
ctx.ui.notify(`Design Thinking mode: ${enabled ? "on" : "off"}`, "info");
|
|
154
|
+
ctx.ui.notify(`Design Thinking mode: ${enabled ? "on" : "off"}${approvedForTurn ? " (edits approved for this turn)" : ""}`, "info");
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// /dt approve|deny — explicit user unlock/lock for the CURRENT turn.
|
|
159
|
+
if (lower === "approve") {
|
|
160
|
+
approvedForTurn = enabled;
|
|
161
|
+
ctx.ui.notify(
|
|
162
|
+
enabled ? "Design Thinking: file edits approved for this turn" : "Design Thinking is OFF — nothing to approve",
|
|
163
|
+
"info",
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
if (lower === "deny") {
|
|
167
|
+
approvedForTurn = false;
|
|
168
|
+
ctx.ui.notify("Design Thinking: file edits blocked again", "info");
|
|
141
169
|
return;
|
|
142
170
|
}
|
|
143
171
|
|
|
@@ -145,6 +173,7 @@ export default function designThinkingExtension(pi: ExtensionAPI) {
|
|
|
145
173
|
// mode and always turns the mode ON (never toggles it off); bare /dt toggles.
|
|
146
174
|
const prompt = /^(on|off|status)$/.test(lower) ? "" : arg;
|
|
147
175
|
enabled = lower === "on" || prompt ? true : lower === "off" ? false : !enabled;
|
|
176
|
+
if (!enabled) approvedForTurn = false;
|
|
148
177
|
persist();
|
|
149
178
|
applyStatus(ctx);
|
|
150
179
|
ctx.ui.notify(
|
|
@@ -166,9 +195,21 @@ export default function designThinkingExtension(pi: ExtensionAPI) {
|
|
|
166
195
|
|
|
167
196
|
// While active, append the distilled block to the system prompt every turn.
|
|
168
197
|
pi.on("before_agent_start", async (event) => {
|
|
198
|
+
// A new user turn starts a fresh agent run: the approval from the
|
|
199
|
+
// previous turn does not carry over.
|
|
200
|
+
approvedForTurn = false;
|
|
169
201
|
if (!enabled) return undefined;
|
|
170
202
|
return {
|
|
171
203
|
systemPrompt: event.systemPrompt + "\n\n" + DISTILLED + "\n",
|
|
172
204
|
};
|
|
173
205
|
});
|
|
206
|
+
|
|
207
|
+
// Hard gate: while enabled, mutating tools are blocked until the user
|
|
208
|
+
// approves the design for this turn (/dt approve). Prompt-level rules
|
|
209
|
+
// alone proved insufficient — this is the mechanical backstop.
|
|
210
|
+
pi.on("tool_call", async (event) => {
|
|
211
|
+
if (!enabled || approvedForTurn) return undefined;
|
|
212
|
+
if (!MUTATING_TOOLS[event.toolName]) return undefined;
|
|
213
|
+
return { block: true, reason: GATE_REASON };
|
|
214
|
+
});
|
|
174
215
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widnyana/design-thinking",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
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": {
|
|
@@ -35,8 +35,11 @@
|
|
|
35
35
|
"methodology",
|
|
36
36
|
"call-graph"
|
|
37
37
|
],
|
|
38
|
+
"omp": {
|
|
39
|
+
"extensions": ["./extensions/design-thinking.ts"]
|
|
40
|
+
},
|
|
38
41
|
"pi": {
|
|
39
|
-
"extensions": ["./extensions"],
|
|
42
|
+
"extensions": ["./extensions/design-thinking.ts"],
|
|
40
43
|
"prompts": ["./prompts"],
|
|
41
44
|
"skills": ["./skills"]
|
|
42
45
|
},
|
|
@@ -11,8 +11,8 @@ description: >
|
|
|
11
11
|
# Design Graph — The Artifact
|
|
12
12
|
|
|
13
13
|
A **Design Graph** is the annotated call graph of a concrete problem. It is
|
|
14
|
-
what you produce when you apply
|
|
15
|
-
something, and it is written in
|
|
14
|
+
what you produce when you apply Design Thinking (see the `design-method` skill) to
|
|
15
|
+
something, and it is written in Graph Protocol notation (see the `graph-protocol` skill).
|
|
16
16
|
|
|
17
17
|
Nodes are functions. Edges are data flow. The annotations answer, for every
|
|
18
18
|
node: what flows through it (A), how many times it runs (cardinality), where
|
|
@@ -97,5 +97,5 @@ VERDICT line.
|
|
|
97
97
|
|
|
98
98
|
## Worked example
|
|
99
99
|
|
|
100
|
-
See the end of
|
|
100
|
+
See the end of the `graph-protocol` skill for a complete, non-TS worked
|
|
101
101
|
example (a resumable URL-sync CLI in Python) with all sections filled.
|
|
@@ -25,7 +25,7 @@ implement only after the user approves the design. Reading and exploring code
|
|
|
25
25
|
first is fine; the FIRST edit is not allowed before the graph. This rule is
|
|
26
26
|
not optional and not stack-dependent.
|
|
27
27
|
|
|
28
|
-
Render every result in
|
|
28
|
+
Render every result in Graph Protocol format (see the `graph-protocol` skill).
|
|
29
29
|
|
|
30
30
|
```
|
|
31
31
|
X → DesignGraph<A, E, R>
|