@johnz4021/illuminate 0.3.0 → 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 +87 -30
- package/dist/cli.mjs +167 -13
- package/package.json +3 -3
- package/viewer/assets/{elk.bundled-Cc32fJO7.js → elk.bundled-BPr-wH-B.js} +2 -2
- package/viewer/assets/{elk.bundled-Cc32fJO7.js.map → elk.bundled-BPr-wH-B.js.map} +1 -1
- package/viewer/assets/index-CO0dIJ7I.css +1 -0
- package/viewer/assets/index-DhDORCdv.js +71 -0
- package/viewer/assets/index-DhDORCdv.js.map +1 -0
- package/viewer/index.html +2 -2
- package/viewer/assets/index-CNRN0YFF.css +0 -1
- package/viewer/assets/index-DQUK_1bX.js +0 -71
- package/viewer/assets/index-DQUK_1bX.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,41 +1,105 @@
|
|
|
1
1
|
# illuminate
|
|
2
2
|
|
|
3
|
-
Ask how your code works and get a map you can point at. Claude
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Ask Claude Code how your code works and get a map you can point at. Claude reads the repo and draws the answer as
|
|
4
|
+
boxes and arrows in your browser. A plain program then checks every box and arrow against the real code before you see
|
|
5
|
+
it, so the map can't show something that isn't there.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+

|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Design: [Codemap v1 Design](https://claude.ai/artifact/55L8tokprGe61qtfpDXJ5h).
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
sign-in, and illuminate checks every claim and draws the map. Questions you ask on the map go to that same session,
|
|
13
|
-
and the answers come back to the map.
|
|
11
|
+
## Install
|
|
14
12
|
|
|
15
13
|
In Claude Code (2.1.275 or later), in any repo:
|
|
16
14
|
|
|
17
15
|
```
|
|
18
|
-
/plugin install illuminate --marketplace johnz4021/
|
|
16
|
+
/plugin install illuminate --marketplace johnz4021/illuminate
|
|
19
17
|
```
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
Then restart Claude Code. That's all: illuminate uses your own Claude Code session and sign-in, so there is no API key
|
|
20
|
+
to set up. It needs Node 20.19 or later. If Node is missing or too old, ask for a map anyway: Claude checks, offers to
|
|
21
|
+
install or update it, and tells you what to restart.
|
|
22
|
+
|
|
23
|
+
## What you can ask
|
|
24
|
+
|
|
25
|
+
Ask in plain words, or start with `/illuminate`. A map opens in your browser after about a minute. The screenshots
|
|
26
|
+
below are real maps of a small demo app (a clinic's patient system).
|
|
27
|
+
|
|
28
|
+
### 1. How something works
|
|
29
|
+
|
|
30
|
+
> What happens when a patient converts? Does the welcome email go out?
|
|
31
|
+
|
|
32
|
+
Claude follows the flow from where it starts to where it ends, across files. If something on the way should connect
|
|
33
|
+
and doesn't, the map shows it as a red dashed arrow, with the search that proves nothing is there. That is the map at
|
|
34
|
+
the top of this page: the app announces the conversion, and nothing is listening.
|
|
35
|
+
|
|
36
|
+
### 2. What a change did
|
|
37
|
+
|
|
38
|
+
> What did you just change?
|
|
39
|
+
|
|
40
|
+
The map shows the code as it is now, compared with a commit (the last one, unless you name another). What is new is
|
|
41
|
+
green, what is different is amber, and what was deleted is struck through in red. illuminate works those out itself
|
|
42
|
+
from the two versions. The switch at the top left shows the code before, after, or both.
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
Good for reading what an agent did after a long task. It compares with a commit, so work you hadn't committed before
|
|
47
|
+
the task counts as changed too.
|
|
48
|
+
|
|
49
|
+
### 3. A user journey
|
|
23
50
|
|
|
24
|
-
|
|
51
|
+
> Show me the user journey: what does staff go through to convert a patient?
|
|
52
|
+
|
|
53
|
+
Asked what a person sees or does, Claude draws screens, actions and choices from left to right, with no code on the
|
|
54
|
+
boxes. Each screen can show a wireframe of its page, drawn from the code, with the part the step is about marked.
|
|
55
|
+
Nothing has to be running.
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
### 4. A change before it's made
|
|
60
|
+
|
|
61
|
+
> How would we send the welcome email right away when a patient converts? Show me a plan.
|
|
62
|
+
|
|
63
|
+
Claude draws the code as it is, checked, with the proposal on top in violet: new boxes and arrows dashed, and what
|
|
64
|
+
would change marked. Nothing is edited. After the change is built, reopen the map and illuminate marks which proposed
|
|
65
|
+
parts are now in the code.
|
|
66
|
+
|
|
67
|
+

|
|
68
|
+
|
|
69
|
+
## On the map
|
|
70
|
+
|
|
71
|
+
- **Take the walkthrough.** A few stops, starting with the answer to your question.
|
|
72
|
+
- **Click any box or arrow** to see what it does and the code behind it: the function itself, with the lines the map
|
|
73
|
+
relies on marked and a link that opens the file in your editor at that line.
|
|
74
|
+
- **Ask a follow-up** in the box at the bottom, or select something first and ask about that. The answer lights up the
|
|
75
|
+
part of the map it's about. When the question is about the code itself ("what's in this payload?"), the answer comes
|
|
76
|
+
with the lines that show it, each with a note.
|
|
77
|
+
- **Ask for a fix.** Claude proposes one, drawn on the map next to the exact change. Nothing is edited until you
|
|
78
|
+
approve it.
|
|
79
|
+
|
|
80
|
+
The top bar says whether the map still matches the code ("Every part is in the code"). The check proves each part is
|
|
81
|
+
real; it doesn't prove the map covers everything.
|
|
82
|
+
|
|
83
|
+
## How it runs in Claude Code
|
|
84
|
+
|
|
85
|
+
illuminate runs as an MCP server in Claude Code: your session does the reading and writing, and illuminate checks every
|
|
86
|
+
claim and draws the map. Questions you ask on the map go to that same session, and the answers come back to the map.
|
|
87
|
+
|
|
88
|
+
Without the plugin: `claude mcp add --scope user illuminate -- npx -y @johnz4021/illuminate channel`. From a checkout of
|
|
89
|
+
this repo instead (for working on illuminate):
|
|
25
90
|
|
|
26
91
|
```
|
|
27
92
|
npm i && npm run build
|
|
28
93
|
claude mcp add --scope user illuminate -- node "$PWD/packages/server/bin/illuminate.mjs" channel
|
|
29
94
|
```
|
|
30
95
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
tools when Claude Code asks (`mcp__plugin_illuminate_illuminate__*` from the plugin, `mcp__illuminate__*` otherwise).
|
|
96
|
+
Once a map is ready, Claude keeps one `illuminate_listen` call open: after two minutes Claude Code moves it to the
|
|
97
|
+
background and gives you your terminal back, and when you ask on the map it wakes the session with your question. The
|
|
98
|
+
session has to stay open for that. Every 25 minutes or so the call returns and Claude quietly starts another (Claude
|
|
99
|
+
Code drops a call that has been quiet for 30 minutes); after about two hours with no questions, illuminate stops
|
|
100
|
+
listening. If a question on the map says Claude Code isn't listening, tell Claude "listen to illuminate". To skip
|
|
101
|
+
approving each illuminate tool call, allow its tools when Claude Code asks (`mcp__plugin_illuminate_illuminate__*` from
|
|
102
|
+
the plugin, `mcp__illuminate__*` otherwise).
|
|
39
103
|
|
|
40
104
|
Moving long tool calls to the background is on by default; if you've turned it off (`CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS=0`),
|
|
41
105
|
listening holds your terminal until you ask on the map. Starting Claude Code with
|
|
@@ -99,6 +163,8 @@ can tie it to the code. Screenshots are saved under `.illuminate/screens/`.
|
|
|
99
163
|
|
|
100
164
|
## How it works
|
|
101
165
|
|
|
166
|
+
What happens behind the four kinds of map above:
|
|
167
|
+
|
|
102
168
|
1. **Make a map.** A deterministic scan gives Claude a head start (entry points, routes, which requests hit which
|
|
103
169
|
routes, which tables are written). Claude explores with Read/Grep/Glob only and returns the map in a fixed format.
|
|
104
170
|
2. **Check every claim.** `check()` re-reads each cited line, verifies calls, requests and imports against code facts,
|
|
@@ -109,16 +175,7 @@ can tie it to the code. Screenshots are saved under `.illuminate/screens/`.
|
|
|
109
175
|
anything and ask, as a conversation: replies are short and lead with the answer, and the map does the explaining (each reply
|
|
110
176
|
lights up what it's about). Claude explores further when the map isn't enough; what it finds is drawn only if it
|
|
111
177
|
passes the checker.
|
|
112
|
-
4. **
|
|
113
|
-
map shows the code as it is, checked, with the proposal on top in violet: new boxes and arrows dashed, what would
|
|
114
|
-
go struck through. Nothing is edited. After the change is built, reopen the map: illuminate checks the code and
|
|
115
|
-
marks which proposed parts are now there. Ask what someone sees or goes through, and the map is drawn as a
|
|
116
|
-
user flow instead: screens, actions and choices from left to right, with the code behind each one a click away.
|
|
117
|
-
5. **See what a change did.** Ask "what did you just change?" or "what did the last commit do?" and the map shows
|
|
118
|
-
the code as it is now, with what is new in green, what is different in amber and what was deleted struck through
|
|
119
|
-
in red. illuminate works those out itself by comparing with a commit (the last one, unless you name another), and
|
|
120
|
-
a changed box shows its lines. A switch on the map shows the before, the after (each with the other side faded to a shadow), or both. It compares with a commit, so work you hadn't committed before the task counts too.
|
|
121
|
-
6. **Fix from the map.** Ask for a change and Claude proposes a fix, drawn as a green dashed arrow next to the exact diff.
|
|
178
|
+
4. **Fix from the map.** Ask for a change and Claude proposes a fix, drawn as a green dashed arrow next to the exact diff.
|
|
122
179
|
Nothing changes until you approve. Then illuminate writes exactly that change (refusing if the files changed since),
|
|
123
180
|
re-checks the map, and offers Undo.
|
|
124
181
|
|
package/dist/cli.mjs
CHANGED
|
@@ -2919,11 +2919,10 @@ var init_screens = __esm({
|
|
|
2919
2919
|
|
|
2920
2920
|
// packages/core/src/check.ts
|
|
2921
2921
|
function check(map, root, options = {}) {
|
|
2922
|
-
const
|
|
2923
|
-
const
|
|
2924
|
-
const
|
|
2925
|
-
const baseRepo =
|
|
2926
|
-
const base = baseRepo && { repo: baseRepo, facts: factsFor(baseRepo, carryResolver((p) => baseRepo.has(p), fileExistsIn(repo.root))) };
|
|
2922
|
+
const window = options.lineWindow ?? DEFAULT_LINE_WINDOW;
|
|
2923
|
+
const { now, base } = sidesOf(map, root);
|
|
2924
|
+
const repo = now.repo;
|
|
2925
|
+
const baseRepo = base?.repo ?? null;
|
|
2927
2926
|
const cmp = map.since ? { ref: map.since, base } : null;
|
|
2928
2927
|
const byId = new Map(map.nodes.map((n) => [n.id, n]));
|
|
2929
2928
|
let repoFiles = null;
|
|
@@ -3007,6 +3006,13 @@ function factsFor(repo, exists) {
|
|
|
3007
3006
|
}
|
|
3008
3007
|
};
|
|
3009
3008
|
}
|
|
3009
|
+
function sidesOf(map, root) {
|
|
3010
|
+
const repo = createRepoReader(root);
|
|
3011
|
+
const now = { repo, facts: factsFor(repo, fileExistsIn(repo.root)) };
|
|
3012
|
+
const baseRepo = map.since ? createBaseReader(repo.root, map.since) : null;
|
|
3013
|
+
const base = baseRepo && { repo: baseRepo, facts: factsFor(baseRepo, carryResolver((p) => baseRepo.has(p), fileExistsIn(repo.root))) };
|
|
3014
|
+
return { now, base };
|
|
3015
|
+
}
|
|
3010
3016
|
function checkEvidence(repo, e, window) {
|
|
3011
3017
|
const base = { file: e.file, line: e.line };
|
|
3012
3018
|
const read = repo.read(e.file);
|
|
@@ -3179,7 +3185,7 @@ function checkAbsence(a, repo, files) {
|
|
|
3179
3185
|
if (!searched) reasons.push(a.search.paths ? `no files match ${a.search.paths.join(", ")}, so nothing was searched` : "there were no files to search");
|
|
3180
3186
|
return { status: reasons.length ? "unconfirmed" : "confirmed", found, searched, locations, reasons };
|
|
3181
3187
|
}
|
|
3182
|
-
var MAX_LOCATIONS, fileOf, within, short, symbolIn;
|
|
3188
|
+
var MAX_LOCATIONS, fileOf, within, short, DEFAULT_LINE_WINDOW, symbolIn;
|
|
3183
3189
|
var init_check = __esm({
|
|
3184
3190
|
"packages/core/src/check.ts"() {
|
|
3185
3191
|
"use strict";
|
|
@@ -3192,10 +3198,132 @@ var init_check = __esm({
|
|
|
3192
3198
|
fileOf = (symbol) => symbol.slice(0, symbol.indexOf("#"));
|
|
3193
3199
|
within = (from, symbol) => from === symbol || from.startsWith(`${symbol}.`);
|
|
3194
3200
|
short = (text2) => text2.length > 60 ? `${text2.slice(0, 57)}\u2026` : text2;
|
|
3201
|
+
DEFAULT_LINE_WINDOW = 3;
|
|
3195
3202
|
symbolIn = (side, symbol) => side.facts.get(fileOf(symbol))?.symbols.find((s) => s.id === symbol) ?? null;
|
|
3196
3203
|
}
|
|
3197
3204
|
});
|
|
3198
3205
|
|
|
3206
|
+
// packages/core/src/code.ts
|
|
3207
|
+
function lineFinder(text2) {
|
|
3208
|
+
const starts = [0];
|
|
3209
|
+
for (let i = text2.indexOf("\n"); i !== -1; i = text2.indexOf("\n", i + 1)) starts.push(i + 1);
|
|
3210
|
+
return (offset) => {
|
|
3211
|
+
let lo = 0;
|
|
3212
|
+
let hi = starts.length - 1;
|
|
3213
|
+
while (lo < hi) {
|
|
3214
|
+
const mid = lo + hi + 1 >> 1;
|
|
3215
|
+
if (starts[mid] <= offset) lo = mid;
|
|
3216
|
+
else hi = mid - 1;
|
|
3217
|
+
}
|
|
3218
|
+
return lo + 1;
|
|
3219
|
+
};
|
|
3220
|
+
}
|
|
3221
|
+
function join5(a, b) {
|
|
3222
|
+
const from = Math.min(a.from, b.from);
|
|
3223
|
+
const to = Math.max(a.to, b.to);
|
|
3224
|
+
const outer = [a, b].find((r) => r.from === from && r.to === to);
|
|
3225
|
+
const inner = outer === a ? b : a;
|
|
3226
|
+
return outer ? { ...outer, name: outer.whole ? outer.name : inner.whole ? inner.name : outer.name ?? inner.name } : { from, to, name: a.name === b.name ? a.name : a.name ?? b.name, whole: false };
|
|
3227
|
+
}
|
|
3228
|
+
function blocksFor(side, marks, symbol) {
|
|
3229
|
+
const files = [.../* @__PURE__ */ new Set([...symbol ? [fileOf2(symbol)] : [], ...marks.map((m) => m.file)])];
|
|
3230
|
+
const out = [];
|
|
3231
|
+
let total = 0;
|
|
3232
|
+
for (const file of files) {
|
|
3233
|
+
const text2 = side.repo.text(file);
|
|
3234
|
+
if (text2 === null) continue;
|
|
3235
|
+
const lines = text2.split("\n");
|
|
3236
|
+
const lineOf2 = lineFinder(text2);
|
|
3237
|
+
const span = (s) => ({ from: lineOf2(s.span.start), to: lineOf2(Math.max(s.span.start, s.span.end - 1)) });
|
|
3238
|
+
const symbols = (side.facts.get(file)?.symbols ?? []).filter((s) => s.kind !== "property").map((s) => ({ name: s.name, id: s.id, ...span(s) }));
|
|
3239
|
+
const here = marks.filter((m) => m.file === file && m.line >= 1 && m.line <= lines.length);
|
|
3240
|
+
const around = (line, name) => ({ from: Math.max(1, line - CONTEXT), to: Math.min(lines.length, line + CONTEXT), name, whole: false });
|
|
3241
|
+
const ranges = [];
|
|
3242
|
+
const named = symbol && fileOf2(symbol) === file ? symbols.find((s) => s.id === symbol) : void 0;
|
|
3243
|
+
if (named) {
|
|
3244
|
+
if (named.to - named.from < WHOLE_NAMED) ranges.push({ from: named.from, to: named.to, name: named.name, whole: true });
|
|
3245
|
+
else if (!here.some((m) => m.line >= named.from && m.line <= named.to)) ranges.push({ from: named.from, to: named.from + 2 * CONTEXT, name: named.name, whole: false });
|
|
3246
|
+
}
|
|
3247
|
+
for (const m of here) {
|
|
3248
|
+
const inside = symbols.filter((s) => s.from <= m.line && m.line <= s.to && s.to - s.from >= 2).sort((a, b) => a.to - a.from - (b.to - b.from))[0];
|
|
3249
|
+
if (inside && inside.to - inside.from < WHOLE_FOUND) ranges.push({ from: inside.from, to: inside.to, name: inside.name, whole: true });
|
|
3250
|
+
else ranges.push(around(m.line, inside?.name ?? null));
|
|
3251
|
+
}
|
|
3252
|
+
ranges.sort((a, b) => a.from - b.from || b.to - a.to);
|
|
3253
|
+
const merged = [];
|
|
3254
|
+
for (const r of ranges) {
|
|
3255
|
+
const last = merged[merged.length - 1];
|
|
3256
|
+
if (last && r.from <= last.to + 1) merged[merged.length - 1] = join5(last, r);
|
|
3257
|
+
else merged.push(r);
|
|
3258
|
+
}
|
|
3259
|
+
for (const r of merged) {
|
|
3260
|
+
if (out.length >= MAX_BLOCKS || total >= MAX_LINES) return out;
|
|
3261
|
+
const to = Math.min(r.to, r.from + (MAX_LINES - total) - 1);
|
|
3262
|
+
const inRange = here.filter((m) => m.line >= r.from && m.line <= to);
|
|
3263
|
+
out.push({
|
|
3264
|
+
file,
|
|
3265
|
+
name: r.name,
|
|
3266
|
+
whole: r.whole && to === r.to,
|
|
3267
|
+
start: r.from,
|
|
3268
|
+
lines: lines.slice(r.from - 1, to).map((l) => l.length > MAX_LINE_CHARS ? `${l.slice(0, MAX_LINE_CHARS)}\u2026` : l),
|
|
3269
|
+
cited: [...new Set(inRange.map((m) => m.line))].sort((a, b) => a - b),
|
|
3270
|
+
notes: inRange.flatMap((m) => m.note ? [{ line: m.line, note: m.note }] : [])
|
|
3271
|
+
});
|
|
3272
|
+
total += to - r.from + 1;
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
return out;
|
|
3276
|
+
}
|
|
3277
|
+
function locate(side, evidence) {
|
|
3278
|
+
const found = [];
|
|
3279
|
+
let missing = 0;
|
|
3280
|
+
for (const e of evidence) {
|
|
3281
|
+
const c = checkEvidence(side.repo, e, DEFAULT_LINE_WINDOW);
|
|
3282
|
+
if (c.ok && c.foundAt !== null) found.push({ ...e, line: c.foundAt });
|
|
3283
|
+
else missing++;
|
|
3284
|
+
}
|
|
3285
|
+
return { found, missing };
|
|
3286
|
+
}
|
|
3287
|
+
function codeOf(map, root, id, when = "now") {
|
|
3288
|
+
const item = map.nodes.find((n) => n.id === id) ?? map.edges.find((e) => e.id === id);
|
|
3289
|
+
if (!item) return null;
|
|
3290
|
+
const { now, base } = sidesOf(map, root);
|
|
3291
|
+
const side = when === "before" ? base : now;
|
|
3292
|
+
if (!side) return null;
|
|
3293
|
+
const { found, missing } = locate(side, item.evidence);
|
|
3294
|
+
return { when, blocks: blocksFor(side, found, "symbol" in item ? item.symbol : void 0), missing };
|
|
3295
|
+
}
|
|
3296
|
+
function checkNotes(root, notes) {
|
|
3297
|
+
const { now } = sidesOf({}, root);
|
|
3298
|
+
const kept = [];
|
|
3299
|
+
const dropped = [];
|
|
3300
|
+
for (const n of notes) {
|
|
3301
|
+
const c = checkEvidence(now.repo, n, DEFAULT_LINE_WINDOW);
|
|
3302
|
+
if (!c.ok || c.foundAt === null) dropped.push(`${n.file}:${n.line}: ${c.reason ?? "not found"}`);
|
|
3303
|
+
else if (!kept.some((k) => k.file === n.file && k.line === c.foundAt)) kept.push({ ...n, line: c.foundAt });
|
|
3304
|
+
}
|
|
3305
|
+
return { notes: kept, dropped };
|
|
3306
|
+
}
|
|
3307
|
+
function codeForNotes(root, notes) {
|
|
3308
|
+
const { now } = sidesOf({}, root);
|
|
3309
|
+
const { found, missing } = locate(now, notes);
|
|
3310
|
+
return { when: "now", blocks: blocksFor(now, found), missing };
|
|
3311
|
+
}
|
|
3312
|
+
var WHOLE_NAMED, WHOLE_FOUND, CONTEXT, MAX_BLOCKS, MAX_LINES, MAX_LINE_CHARS, fileOf2;
|
|
3313
|
+
var init_code = __esm({
|
|
3314
|
+
"packages/core/src/code.ts"() {
|
|
3315
|
+
"use strict";
|
|
3316
|
+
init_check();
|
|
3317
|
+
WHOLE_NAMED = 160;
|
|
3318
|
+
WHOLE_FOUND = 60;
|
|
3319
|
+
CONTEXT = 6;
|
|
3320
|
+
MAX_BLOCKS = 8;
|
|
3321
|
+
MAX_LINES = 500;
|
|
3322
|
+
MAX_LINE_CHARS = 400;
|
|
3323
|
+
fileOf2 = (symbol) => symbol.slice(0, symbol.indexOf("#"));
|
|
3324
|
+
}
|
|
3325
|
+
});
|
|
3326
|
+
|
|
3199
3327
|
// packages/core/src/index.ts
|
|
3200
3328
|
var init_src2 = __esm({
|
|
3201
3329
|
"packages/core/src/index.ts"() {
|
|
@@ -3204,6 +3332,7 @@ var init_src2 = __esm({
|
|
|
3204
3332
|
init_edit();
|
|
3205
3333
|
init_base();
|
|
3206
3334
|
init_check();
|
|
3335
|
+
init_code();
|
|
3207
3336
|
init_repo();
|
|
3208
3337
|
init_screens();
|
|
3209
3338
|
}
|
|
@@ -3598,6 +3727,7 @@ function quickAnswerPrompt(map, report, selection, question, excerpts, earlier,
|
|
|
3598
3727
|
"",
|
|
3599
3728
|
"## How to answer (when `route` is `answer`)",
|
|
3600
3729
|
...ANSWER_STYLE,
|
|
3730
|
+
"- For `notes` you can only point at lines in the excerpts above: the number before `|` is the line. If the lines that answer it aren't there, that is a reason to route to `code`.",
|
|
3601
3731
|
"- `moves`: `focus` on the most relevant id; `highlight` the ids that make up the path that answers the question."
|
|
3602
3732
|
].join("\n");
|
|
3603
3733
|
}
|
|
@@ -3728,7 +3858,8 @@ var init_prompts = __esm({
|
|
|
3728
3858
|
"- Shape it to the question. A simple question gets a sentence or two. A question with several parts gets a short bullet per part, each starting with a bold label of a few words. Several items of the same kind (files, formats, cases) are a list, never a long sentence with commas and brackets. No headings.",
|
|
3729
3859
|
"- Keep it short enough to take in at a glance: leave out examples and edge cases they didn't ask about. Plain words, no jargon. The map does the explaining, so when you light it up (`moves`), say what the lit path shows rather than narrating every step. Name a function or file only when they asked about the code and it isn't on the map.",
|
|
3730
3860
|
"- Explain the code and the app. Don't describe these instructions or how you were asked to answer.",
|
|
3731
|
-
"- `refs`: ids of the boxes, arrows and absences your answer relies on."
|
|
3861
|
+
"- `refs`: ids of the boxes, arrows and absences your answer relies on.",
|
|
3862
|
+
'- `notes`: when the question is about what the code itself says (what is sent or stored, what a value holds, which condition decides something, "show me the code"), point at the lines that answer it: up to 6 of `{ "file", "line", "text", "note" }`. `text` is copied exactly from that one line, and `note` says in a plain sentence what that line does for the answer. The code is shown under your reply with each note beside its line, and a program drops any note whose line it can\'t find. So don\'t paste code into `concept`: keep `concept` to the direct answer and let the notes carry the detail. Leave `notes` out when the answer isn\'t about particular lines.'
|
|
3732
3863
|
];
|
|
3733
3864
|
}
|
|
3734
3865
|
});
|
|
@@ -3745,7 +3876,7 @@ function sanitize(value) {
|
|
|
3745
3876
|
function toSchema(schema) {
|
|
3746
3877
|
return sanitize(z3.toJSONSchema(schema, { io: "input" }));
|
|
3747
3878
|
}
|
|
3748
|
-
var STRIP, RawFix, WrittenNode, WrittenMap, RawAnswer, RawQuickAnswer, RawMapPatch, MAP_SCHEMA, MAP_PATCH_SCHEMA, ANSWER_SCHEMA, QUICK_ANSWER_SCHEMA, VALIDATORS, validatorFor;
|
|
3879
|
+
var STRIP, RawFix, RawNote, WrittenNode, WrittenMap, RawAnswer, RawQuickAnswer, RawMapPatch, MAP_SCHEMA, MAP_PATCH_SCHEMA, ANSWER_SCHEMA, QUICK_ANSWER_SCHEMA, VALIDATORS, validatorFor;
|
|
3749
3880
|
var init_schemas = __esm({
|
|
3750
3881
|
"packages/server/src/schemas.ts"() {
|
|
3751
3882
|
"use strict";
|
|
@@ -3759,6 +3890,7 @@ var init_schemas = __esm({
|
|
|
3759
3890
|
/** The connection the fix creates between two boxes; `evidenceText` must appear in the new code. */
|
|
3760
3891
|
connects: z3.object({ from: z3.string(), to: z3.string(), label: z3.string().min(1).max(60), evidenceFile: z3.string().min(1), evidenceText: z3.string().min(1).max(200) }).optional()
|
|
3761
3892
|
});
|
|
3893
|
+
RawNote = Evidence.extend({ note: z3.string().min(1).max(300) });
|
|
3762
3894
|
WrittenNode = Node.extend({ explain: z3.object({ concept: z3.string() }).partial().optional() });
|
|
3763
3895
|
WrittenMap = CodeMap.extend({ nodes: z3.array(WrittenNode).min(1) });
|
|
3764
3896
|
RawAnswer = z3.object({
|
|
@@ -3769,13 +3901,15 @@ var init_schemas = __esm({
|
|
|
3769
3901
|
/** New things found while exploring, with evidence, same rules as the map. */
|
|
3770
3902
|
add: z3.object({ areas: z3.array(Area).optional(), nodes: z3.array(WrittenNode).optional(), edges: z3.array(Edge).optional(), absences: z3.array(Absence).optional() }).optional(),
|
|
3771
3903
|
moves: z3.object({ focus: z3.string().optional(), highlight: z3.array(z3.string()).optional() }).optional(),
|
|
3904
|
+
/** Lines of code the answer points at, each with a note, when the question is about what the code itself says. */
|
|
3905
|
+
notes: z3.array(RawNote).max(8).optional(),
|
|
3772
3906
|
/** Pictures of the screen for boxes on the map (existing ones, or ones in `add`), when the question is about what the person sees. */
|
|
3773
3907
|
screens: z3.array(z3.object({ node: z3.string(), screen: Screen })).max(4).optional(),
|
|
3774
3908
|
/** Boxes or arrows already on the map that a suggested change would alter or remove (new ones go in `add`, marked there). */
|
|
3775
3909
|
propose: z3.array(z3.object({ id: z3.string(), proposed: Proposal })).max(12).optional(),
|
|
3776
3910
|
fix: RawFix.optional()
|
|
3777
3911
|
});
|
|
3778
|
-
RawQuickAnswer = RawAnswer.pick({ refs: true, moves: true }).extend({
|
|
3912
|
+
RawQuickAnswer = RawAnswer.pick({ refs: true, moves: true, notes: true }).extend({
|
|
3779
3913
|
/**
|
|
3780
3914
|
* `answer`: the map and the excerpts fully answer it. `code`: about this map, but needs code it doesn't show.
|
|
3781
3915
|
* `elsewhere`: about a different part of the app than this map covers.
|
|
@@ -3857,6 +3991,10 @@ function selectionLines(map, s) {
|
|
|
3857
3991
|
})
|
|
3858
3992
|
];
|
|
3859
3993
|
}
|
|
3994
|
+
function notesOf(root, raw) {
|
|
3995
|
+
const r = checkNotes(root, raw ?? []);
|
|
3996
|
+
return { notes: r.notes, problems: r.dropped.map((d) => `A note on the code wasn't shown, its line isn't there: ${d}`) };
|
|
3997
|
+
}
|
|
3860
3998
|
function statusOf(report, id) {
|
|
3861
3999
|
const c = report.nodes[id] ?? report.edges[id] ?? report.absences[id];
|
|
3862
4000
|
return c ? c.status : "unknown";
|
|
@@ -3905,6 +4043,7 @@ async function answer(o) {
|
|
|
3905
4043
|
}
|
|
3906
4044
|
if (quick.success && quick.data.route === "answer" && quick.data.concept.trim()) {
|
|
3907
4045
|
const q = quick.data;
|
|
4046
|
+
const noted2 = notesOf(o.root, q.notes);
|
|
3908
4047
|
const result3 = {
|
|
3909
4048
|
id: `ans-${crypto3.randomBytes(4).toString("hex")}`,
|
|
3910
4049
|
question: o.question,
|
|
@@ -3916,7 +4055,8 @@ async function answer(o) {
|
|
|
3916
4055
|
highlight: (q.moves?.highlight ?? []).filter((id) => live0.has(id))
|
|
3917
4056
|
},
|
|
3918
4057
|
added: [],
|
|
3919
|
-
|
|
4058
|
+
notes: noted2.notes,
|
|
4059
|
+
problems: noted2.problems,
|
|
3920
4060
|
fix: null,
|
|
3921
4061
|
source: "map",
|
|
3922
4062
|
offer: null,
|
|
@@ -4020,6 +4160,8 @@ async function answer(o) {
|
|
|
4020
4160
|
if (proposed.ok) fix = proposed.proposal;
|
|
4021
4161
|
else problems.push(...proposed.problems.map((p) => `The proposed fix can't be applied: ${p}`));
|
|
4022
4162
|
}
|
|
4163
|
+
const noted = notesOf(o.root, raw.notes);
|
|
4164
|
+
problems.push(...noted.problems);
|
|
4023
4165
|
const live = mapIds(map);
|
|
4024
4166
|
const result2 = {
|
|
4025
4167
|
id: `ans-${crypto3.randomBytes(4).toString("hex")}`,
|
|
@@ -4034,6 +4176,7 @@ async function answer(o) {
|
|
|
4034
4176
|
added,
|
|
4035
4177
|
proposed: marked,
|
|
4036
4178
|
screens: screened.filter((id) => live.has(id)),
|
|
4179
|
+
notes: noted.notes,
|
|
4037
4180
|
problems,
|
|
4038
4181
|
fix,
|
|
4039
4182
|
source: "code",
|
|
@@ -4164,18 +4307,18 @@ async function headStart(root) {
|
|
|
4164
4307
|
].join("\n");
|
|
4165
4308
|
return { text: text2 || "(The automatic scan found no entry points; explore the repo directly.)", scan };
|
|
4166
4309
|
}
|
|
4167
|
-
var
|
|
4310
|
+
var MAX_LINES2, MAX_SYMBOL_FILES, MAX_SYMBOLS_PER_FILE, CITABLE, TEST_FILE, section;
|
|
4168
4311
|
var init_hints = __esm({
|
|
4169
4312
|
"packages/server/src/hints.ts"() {
|
|
4170
4313
|
"use strict";
|
|
4171
4314
|
init_src();
|
|
4172
4315
|
init_changes();
|
|
4173
|
-
|
|
4316
|
+
MAX_LINES2 = 40;
|
|
4174
4317
|
MAX_SYMBOL_FILES = 150;
|
|
4175
4318
|
MAX_SYMBOLS_PER_FILE = 40;
|
|
4176
4319
|
CITABLE = /* @__PURE__ */ new Set(["function", "method", "component", "class"]);
|
|
4177
4320
|
TEST_FILE = /(^|\/)(test|tests|__tests__|__mocks__|e2e|fixtures?)\/|\.(test|spec)\.[cm]?[jt]sx?$|_test\.(go|py)$|(^|\/)test_[^/]*\.py$/;
|
|
4178
|
-
section = (title, lines, max =
|
|
4321
|
+
section = (title, lines, max = MAX_LINES2) => lines.length ? [`${title}:`, ...lines.slice(0, max), ...lines.length > max ? [` \u2026and ${lines.length - max} more`] : [], ""] : [];
|
|
4179
4322
|
}
|
|
4180
4323
|
});
|
|
4181
4324
|
|
|
@@ -4569,6 +4712,17 @@ async function startServer(o) {
|
|
|
4569
4712
|
}
|
|
4570
4713
|
return json(res, 200, { ...stored, report: check(stored.map, root), job, failure: null, answers: stored.answers ?? [], fixes: fixStates(stored) });
|
|
4571
4714
|
}
|
|
4715
|
+
if (mapId && parts[2] === "code" && parts.length === 3 && m === "GET") {
|
|
4716
|
+
const stored = store.get(mapId);
|
|
4717
|
+
const view2 = stored && codeOf(stored.map, root, url2.searchParams.get("item") ?? "", url2.searchParams.get("when") === "before" ? "before" : "now");
|
|
4718
|
+
if (!view2) throw new HttpError(404, "No code to show for that.");
|
|
4719
|
+
return json(res, 200, { ...view2, root });
|
|
4720
|
+
}
|
|
4721
|
+
if (mapId && parts[2] === "answers" && parts[3] && parts[4] === "code" && m === "GET") {
|
|
4722
|
+
const notes = store.get(mapId)?.answers?.find((a) => a.id === parts[3])?.notes;
|
|
4723
|
+
if (!notes?.length) throw new HttpError(404, "No code to show for that.");
|
|
4724
|
+
return json(res, 200, { ...codeForNotes(root, notes), root });
|
|
4725
|
+
}
|
|
4572
4726
|
if (mapId && parts[2] === "answers" && parts[3] && parts[4] === "offer" && m === "POST") {
|
|
4573
4727
|
const body = await readBody(req);
|
|
4574
4728
|
return json(res, 200, takeOffer(mapId, parts[3], body.choice === "map" ? "map" : body.choice === "words" ? "words" : null));
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnz4021/illuminate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Checked, interactive maps of how your code works, drawn by your own Claude Code session.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/johnz4021/
|
|
9
|
+
"url": "git+https://github.com/johnz4021/illuminate.git"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://github.com/johnz4021/
|
|
11
|
+
"homepage": "https://github.com/johnz4021/illuminate#readme",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"claude-code",
|
|
14
14
|
"mcp",
|