@albinocrabs/feynman 0.2.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.
@@ -0,0 +1,168 @@
1
+ <!-- feynman diagram rules — feynman-activate.md -->
2
+ <!-- Hook reads only the section matching the active intensity. -->
3
+ <!-- Variants: lite (flow+trees), full (all types, default), ultra (force diagrams). -->
4
+ <!-- Each section must stay under 8,000 chars. Measure with: -->
5
+ <!-- node -e "const f=require('fs').readFileSync('rules/feynman-activate.md','utf8');['lite','full','ultra'].forEach(v=>{const s=f.indexOf('<!-- '+v+' -->');const e=f.indexOf('<!-- /'+v+' -->',s);console.log(v,f.slice(s,e+('<!-- /'+v+' -->').length).length,'chars');})" -->
6
+
7
+ <!-- lite -->
8
+ ## Feynman Diagram Rules — Lite
9
+
10
+ ### When diagrams appear
11
+
12
+ **Sequential flows** — A response describing a sequence of steps, stages, or events (A then B then C, or numbered steps that proceed in order) includes an ASCII flow diagram.
13
+
14
+ Syntax: `[Step A] --> [Step B] --> [Step C]`
15
+
16
+ For branching flows:
17
+ ```
18
+ [Start] --> [Decision?]
19
+ |
20
+ yes -- + -- no
21
+ | |
22
+ [Path A] [Path B]
23
+ | |
24
+ +---- [End] --+
25
+ ```
26
+
27
+ **Hierarchical structures** — A response describing a hierarchy, tree, or containment relationship with three or more levels includes an ASCII tree diagram.
28
+
29
+ Syntax:
30
+ ```
31
+ root
32
+ ├── child-a
33
+ │ ├── grandchild-1
34
+ │ └── grandchild-2
35
+ └── child-b
36
+ └── grandchild-3
37
+ ```
38
+
39
+ ### When no diagram appears
40
+
41
+ Responses that are any of the following contain no diagram:
42
+ - A single fact or direct answer (one or two sentences)
43
+ - An answer under four lines that contains no explicit structure
44
+ - A response consisting entirely of a code block
45
+ - A comparison of options without multiple criteria (use a prose sentence or a list instead)
46
+ - A response where the user explicitly asked for prose, a narrative, or an explanation in words
47
+
48
+ The purpose of diagrams is clarity. A diagram that adds no clarity is absent.
49
+ <!-- /lite -->
50
+
51
+ <!-- full -->
52
+ ## Feynman Diagram Rules — Full
53
+
54
+ ### When diagrams appear
55
+
56
+ **Sequential flows** — A response describing a sequence of steps, stages, or events includes an ASCII flow diagram.
57
+
58
+ Syntax: `[Step A] --> [Step B] --> [Step C]`
59
+
60
+ For branching flows:
61
+ ```
62
+ [Start] --> [Decision?]
63
+ |
64
+ yes -- + -- no
65
+ | |
66
+ [Path A] [Path B]
67
+ | |
68
+ +---- [End] --+
69
+ ```
70
+
71
+ **Hierarchical structures** — A response describing a hierarchy, tree, or containment relationship with three or more levels includes an ASCII tree diagram.
72
+
73
+ Syntax:
74
+ ```
75
+ root
76
+ ├── child-a
77
+ │ ├── grandchild-1
78
+ │ └── grandchild-2
79
+ └── child-b
80
+ └── grandchild-3
81
+ ```
82
+
83
+ **Comparisons** — A response comparing two or more options across multiple criteria includes side-by-side ASCII columns (maximum three columns, ten words per cell).
84
+
85
+ Syntax:
86
+ ```
87
+ Option A | Option B | Option C
88
+ ------------------|-------------------|------------------
89
+ fast startup | slow startup | medium startup
90
+ low memory | high memory | medium memory
91
+ no persistence | full persistence | optional
92
+ ```
93
+
94
+ **Status summaries** — A response summarizing the status of multiple items, tasks, or states where the total content exceeds five lines uses a frame block.
95
+
96
+ Syntax:
97
+ ```
98
+ ┌─ Status ─┐
99
+ item-a done
100
+ item-b in progress
101
+ item-c blocked
102
+ └─────────┘
103
+ ```
104
+
105
+ **Priority orderings** — A response that orders three or more items by priority, importance, severity, or rank includes an ▲▼ priority scale.
106
+
107
+ Syntax:
108
+ ```
109
+ ▲ high
110
+ item-1
111
+ item-2
112
+ ▼ low
113
+ item-3
114
+ ```
115
+
116
+ ### When no diagram appears
117
+
118
+ Responses that are any of the following contain no diagram:
119
+ - A single fact or direct answer (one or two sentences)
120
+ - An answer under four lines that contains no explicit structure
121
+ - A response consisting entirely of a code block
122
+ - A case where a plain list or table already captures the structure clearly without a diagram
123
+ - A response where the user explicitly asked for prose, a narrative, or an explanation in words
124
+
125
+ The purpose of diagrams is clarity. A diagram that adds no clarity is absent.
126
+ <!-- /full -->
127
+
128
+ <!-- ultra -->
129
+ ## Feynman Diagram Rules — Ultra
130
+
131
+ ### When diagrams appear
132
+
133
+ All rules from full mode apply.
134
+
135
+ **Any structured response** — A response that contains any structure — even short ones — includes an ASCII diagram. Structure means: any list with two or more items, any comparison, any sequence, any hierarchy, any set of states.
136
+
137
+ **Short lists** — A response with two or more items in a list includes at minimum a simple ASCII tree or column layout, even when the overall answer is brief.
138
+
139
+ Syntax for a short tree:
140
+ ```
141
+ topic
142
+ ├── item-a
143
+ └── item-b
144
+ ```
145
+
146
+ Syntax for a short column:
147
+ ```
148
+ item-a | item-b
149
+ ----------|--------
150
+ detail | detail
151
+ ```
152
+
153
+ **Sequential flows** — Same as full mode. Includes an ASCII flow diagram.
154
+
155
+ **Hierarchical structures** — Same as full mode. Includes an ASCII tree.
156
+
157
+ **Comparisons** — Same as full mode. Includes side-by-side ASCII columns.
158
+
159
+ **Status summaries** — Same as full mode. Uses ┌─ frame blocks.
160
+
161
+ **Priority orderings** — Same as full mode. Uses ▲▼ scale.
162
+
163
+ ### When no diagram appears
164
+
165
+ The only response that contains no diagram is a single sentence of pure prose with no enumerable items, no steps, no comparisons, and no structure of any kind.
166
+
167
+ All other responses — including those with two or more items, any named concept with sub-parts, any sequence of actions, any set of options — include an ASCII diagram.
168
+ <!-- /ultra -->
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: feynman
3
+ disable-model-invocation: true
4
+ description: >
5
+ Toggle ASCII diagram injection on/off or set intensity level (lite/full/ultra).
6
+ Use when user says /feynman, /feynman on, /feynman off, /feynman lite/full/ultra, /feynman status.
7
+ ---
8
+
9
+ Manage feynman diagram injection. Read current state, apply requested change, report result.
10
+
11
+ ## When invoked
12
+
13
+ Parse `$ARGUMENTS`:
14
+ - `on` — enable feynman, keep current intensity
15
+ - `off` — disable feynman
16
+ - `lite` — enable at lite intensity (flows + trees only)
17
+ - `full` — enable at full intensity (all diagram types)
18
+ - `ultra` — enable at ultra intensity (force diagram always)
19
+ - no argument or `status` — show current state, no changes
20
+
21
+ ## Steps
22
+
23
+ 1. Read current state:
24
+
25
+ ```bash
26
+ node -e "
27
+ const fs = require('fs'), os = require('os'), path = require('path');
28
+ const stateFile = path.join(os.homedir(), '.claude', '.feynman', 'state.json');
29
+ const flagFile = path.join(os.homedir(), '.claude', '.feynman-active');
30
+ let st = {enabled: false, intensity: 'full', injections: 0};
31
+ try { st = JSON.parse(fs.readFileSync(stateFile, 'utf8')); } catch(e) {}
32
+ console.log('enabled:', st.enabled, '| intensity:', st.intensity, '| injections:', (st.injections ?? st.count ?? 0), '| flag:', fs.existsSync(flagFile));
33
+ "
34
+ ```
35
+
36
+ 2. Apply change (skip if no argument or `status`):
37
+
38
+ ```bash
39
+ node -e "
40
+ const fs = require('fs'), os = require('os'), path = require('path');
41
+ const stateFile = path.join(os.homedir(), '.claude', '.feynman', 'state.json');
42
+ const flagFile = path.join(os.homedir(), '.claude', '.feynman-active');
43
+ const arg = process.argv[1] || '';
44
+ let st = {enabled: true, intensity: 'full', injections: 0};
45
+ try { st = JSON.parse(fs.readFileSync(stateFile, 'utf8')); } catch(e) {}
46
+ if (arg === 'on') { st.enabled = true; fs.writeFileSync(flagFile, st.intensity); }
47
+ if (arg === 'off') { st.enabled = false; try { fs.unlinkSync(flagFile); } catch(e) {} }
48
+ if (['lite','full','ultra'].includes(arg)) { st.intensity = arg; st.enabled = true; fs.writeFileSync(flagFile, arg); }
49
+ fs.mkdirSync(path.dirname(stateFile), {recursive: true});
50
+ fs.writeFileSync(stateFile, JSON.stringify(st, null, 2));
51
+ console.log(JSON.stringify(st));
52
+ " "$ARGUMENTS"
53
+ ```
54
+
55
+ 3. Report result:
56
+
57
+ ```
58
+ ┌─ feynman ───────────────────────────┐
59
+ status on / off
60
+ intensity lite / full / ultra
61
+ injections N total
62
+ └────────────────────────────────────┘
63
+ ```
package/uninstall.sh ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bash
2
+ # feynman uninstall — thin wrapper around bin/feynman.js
3
+ # Usage: bash uninstall.sh
4
+ set -e
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+
7
+ # Node >= 18 check
8
+ if ! command -v node >/dev/null 2>&1; then
9
+ echo "Error: node not found. Install Node.js >=18: https://nodejs.org" >&2
10
+ exit 1
11
+ fi
12
+ NODE_VER=$(node -v 2>/dev/null | sed 's/v//' | cut -d. -f1)
13
+ if [ -z "$NODE_VER" ] || [ "$NODE_VER" -lt 18 ] 2>/dev/null; then
14
+ echo "Error: Node.js >=18 required (found $(node -v 2>/dev/null || echo 'unknown'))" >&2
15
+ exit 1
16
+ fi
17
+
18
+ exec node "$SCRIPT_DIR/bin/feynman.js" uninstall "$@"