koneck 2.68.0 → 2.70.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/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +1 -1
- package/dist/engine.js.map +1 -1
- package/dist/ink-chat.d.ts.map +1 -1
- package/dist/ink-chat.js +98 -9
- package/dist/ink-chat.js.map +1 -1
- package/dist/mention-resolve.d.ts +64 -0
- package/dist/mention-resolve.d.ts.map +1 -0
- package/dist/mention-resolve.js +139 -0
- package/dist/mention-resolve.js.map +1 -0
- package/dist/types.d.ts +9 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/web/api.d.ts.map +1 -1
- package/dist/web/api.js +86 -1
- package/dist/web/api.js.map +1 -1
- package/dist/web/events.d.ts +21 -0
- package/dist/web/events.d.ts.map +1 -1
- package/dist/web/events.js.map +1 -1
- package/dist/web/mention-signals.d.ts +41 -0
- package/dist/web/mention-signals.d.ts.map +1 -0
- package/dist/web/mention-signals.js +117 -0
- package/dist/web/mention-signals.js.map +1 -0
- package/dist/web/mention.d.ts +121 -0
- package/dist/web/mention.d.ts.map +1 -0
- package/dist/web/mention.js +211 -0
- package/dist/web/mention.js.map +1 -0
- package/dist/web/sessions.d.ts.map +1 -1
- package/dist/web/sessions.js +26 -4
- package/dist/web/sessions.js.map +1 -1
- package/dist/web/ui-client.d.ts.map +1 -1
- package/dist/web/ui-client.js +430 -13
- package/dist/web/ui-client.js.map +1 -1
- package/dist/web/ui-css.d.ts.map +1 -1
- package/dist/web/ui-css.js +54 -0
- package/dist/web/ui-css.js.map +1 -1
- package/dist/web/ui.d.ts.map +1 -1
- package/dist/web/ui.js +9 -0
- package/dist/web/ui.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning `@path` in a message into the file itself.
|
|
3
|
+
*
|
|
4
|
+
* Referencing a file has to mean something by the time the model reads the message. Two ways to make
|
|
5
|
+
* it mean something:
|
|
6
|
+
*
|
|
7
|
+
* - leave the path in the text and let the model call `read_files` — cheap, and costs a round trip;
|
|
8
|
+
* - put the content in the message — one turn, and spends the tokens whether they were needed.
|
|
9
|
+
*
|
|
10
|
+
* KONECK does the second, and the picker shows what it will cost before the reference is made, which
|
|
11
|
+
* is what makes the choice a choice rather than a surprise. The number beside the filename in the
|
|
12
|
+
* dropdown is this. Nothing here decides on anybody's behalf that a file is too large to include:
|
|
13
|
+
* the size is stated up front and the person picking is the one who knows whether it is worth it.
|
|
14
|
+
*
|
|
15
|
+
* A directory becomes its listing rather than its contents, which is not a limit but a different
|
|
16
|
+
* thing being asked for — `@src` means "here is what is in src", and twenty files pasted end to end
|
|
17
|
+
* is not that.
|
|
18
|
+
*/
|
|
19
|
+
/** One thing the message referred to, and what came of looking for it. */
|
|
20
|
+
export interface Resolved {
|
|
21
|
+
/** As written, without the @. */
|
|
22
|
+
ref: string;
|
|
23
|
+
kind: 'file' | 'dir' | 'missing' | 'binary' | 'unreadable';
|
|
24
|
+
/** The text to give the model: the file, or the listing. */
|
|
25
|
+
content?: string;
|
|
26
|
+
/** Why nothing was included, when nothing was. */
|
|
27
|
+
note?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The references in a draft.
|
|
31
|
+
*
|
|
32
|
+
* `@` counts only at a word boundary, matching the picker's own rule, so an email address and an npm
|
|
33
|
+
* scope in a sentence are left alone. Trailing punctuation is dropped because people write "look at
|
|
34
|
+
* @src/engine.ts, it's the loop" and the comma is not part of the name.
|
|
35
|
+
*/
|
|
36
|
+
export declare function referencesIn(text: string): string[];
|
|
37
|
+
/**
|
|
38
|
+
* How many lines a body actually has.
|
|
39
|
+
*
|
|
40
|
+
* Splitting on the newline and taking the length counts one too many for any file that ends in one,
|
|
41
|
+
* which is nearly all of them: "one\ntwo\n" splits into three pieces and is two lines. It said
|
|
42
|
+
* 3 lines for a 2-line file until a test insisted on the number.
|
|
43
|
+
*/
|
|
44
|
+
export declare function linesIn(content: string): number;
|
|
45
|
+
/**
|
|
46
|
+
* Reads one reference.
|
|
47
|
+
*
|
|
48
|
+
* A reference that does not resolve is reported rather than dropped: silently ignoring `@src/engien.ts`
|
|
49
|
+
* leaves somebody wondering why the model never mentioned the file they attached, and a one-line
|
|
50
|
+
* "no such path" in the message answers that immediately.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveOne(cwd: string, ref: string): Promise<Resolved>;
|
|
53
|
+
/**
|
|
54
|
+
* The message with everything it referred to attached beneath it.
|
|
55
|
+
*
|
|
56
|
+
* Beneath rather than inline, so the sentence a person wrote stays the sentence the model reads
|
|
57
|
+
* first. The blocks are fenced with a name and a line count because a model given eight hundred
|
|
58
|
+
* unlabelled lines cannot cite where anything came from.
|
|
59
|
+
*/
|
|
60
|
+
export declare function attachReferences(cwd: string, text: string): Promise<{
|
|
61
|
+
text: string;
|
|
62
|
+
attached: Resolved[];
|
|
63
|
+
}>;
|
|
64
|
+
//# sourceMappingURL=mention-resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mention-resolve.d.ts","sourceRoot":"","sources":["../src/mention-resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,0EAA0E;AAC1E,MAAM,WAAW,QAAQ;IACvB,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAC;IAC3D,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAanD;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG/C;AAQD;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsC5E;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB,CAAC,CAyBD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning `@path` in a message into the file itself.
|
|
3
|
+
*
|
|
4
|
+
* Referencing a file has to mean something by the time the model reads the message. Two ways to make
|
|
5
|
+
* it mean something:
|
|
6
|
+
*
|
|
7
|
+
* - leave the path in the text and let the model call `read_files` — cheap, and costs a round trip;
|
|
8
|
+
* - put the content in the message — one turn, and spends the tokens whether they were needed.
|
|
9
|
+
*
|
|
10
|
+
* KONECK does the second, and the picker shows what it will cost before the reference is made, which
|
|
11
|
+
* is what makes the choice a choice rather than a surprise. The number beside the filename in the
|
|
12
|
+
* dropdown is this. Nothing here decides on anybody's behalf that a file is too large to include:
|
|
13
|
+
* the size is stated up front and the person picking is the one who knows whether it is worth it.
|
|
14
|
+
*
|
|
15
|
+
* A directory becomes its listing rather than its contents, which is not a limit but a different
|
|
16
|
+
* thing being asked for — `@src` means "here is what is in src", and twenty files pasted end to end
|
|
17
|
+
* is not that.
|
|
18
|
+
*/
|
|
19
|
+
import path from 'path';
|
|
20
|
+
import { readFile, readdir, stat } from 'fs/promises';
|
|
21
|
+
/**
|
|
22
|
+
* The references in a draft.
|
|
23
|
+
*
|
|
24
|
+
* `@` counts only at a word boundary, matching the picker's own rule, so an email address and an npm
|
|
25
|
+
* scope in a sentence are left alone. Trailing punctuation is dropped because people write "look at
|
|
26
|
+
* @src/engine.ts, it's the loop" and the comma is not part of the name.
|
|
27
|
+
*/
|
|
28
|
+
export function referencesIn(text) {
|
|
29
|
+
const out = [];
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
const pattern = /(^|[\s(["'])@([^\s"'()[\]]+)/g;
|
|
32
|
+
let match;
|
|
33
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
34
|
+
const ref = match[2].replace(/[.,;:!?]+$/, '');
|
|
35
|
+
if (ref === '' || ref.startsWith('@'))
|
|
36
|
+
continue;
|
|
37
|
+
if (seen.has(ref))
|
|
38
|
+
continue;
|
|
39
|
+
seen.add(ref);
|
|
40
|
+
out.push(ref);
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* How many lines a body actually has.
|
|
46
|
+
*
|
|
47
|
+
* Splitting on the newline and taking the length counts one too many for any file that ends in one,
|
|
48
|
+
* which is nearly all of them: "one\ntwo\n" splits into three pieces and is two lines. It said
|
|
49
|
+
* 3 lines for a 2-line file until a test insisted on the number.
|
|
50
|
+
*/
|
|
51
|
+
export function linesIn(content) {
|
|
52
|
+
const body = content.replace(/\s+$/, '');
|
|
53
|
+
return body === '' ? 0 : body.split('\n').length;
|
|
54
|
+
}
|
|
55
|
+
/** True when a buffer holds bytes no prompt should carry. */
|
|
56
|
+
function looksBinary(buffer) {
|
|
57
|
+
// A NUL in the first few kilobytes is the standard test and the one git itself uses.
|
|
58
|
+
return buffer.subarray(0, 8000).includes(0);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Reads one reference.
|
|
62
|
+
*
|
|
63
|
+
* A reference that does not resolve is reported rather than dropped: silently ignoring `@src/engien.ts`
|
|
64
|
+
* leaves somebody wondering why the model never mentioned the file they attached, and a one-line
|
|
65
|
+
* "no such path" in the message answers that immediately.
|
|
66
|
+
*/
|
|
67
|
+
export async function resolveOne(cwd, ref) {
|
|
68
|
+
const full = path.resolve(cwd, ref);
|
|
69
|
+
// A reference is to something in the project. Anything outside it is not a mistake worth guessing
|
|
70
|
+
// at, and following it would turn a filename in a chat box into a way to read /etc.
|
|
71
|
+
const relative = path.relative(path.resolve(cwd), full);
|
|
72
|
+
if (relative.startsWith('..') || path.isAbsolute(relative)) {
|
|
73
|
+
return { ref, kind: 'missing', note: 'outside the project folder' };
|
|
74
|
+
}
|
|
75
|
+
let info;
|
|
76
|
+
try {
|
|
77
|
+
info = await stat(full);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return { ref, kind: 'missing', note: 'no such file or folder in this project' };
|
|
81
|
+
}
|
|
82
|
+
if (info.isDirectory()) {
|
|
83
|
+
try {
|
|
84
|
+
const entries = await readdir(full, { withFileTypes: true });
|
|
85
|
+
const listed = entries
|
|
86
|
+
.filter(e => !e.name.startsWith('.'))
|
|
87
|
+
.map(e => (e.isDirectory() ? e.name + '/' : e.name))
|
|
88
|
+
.sort();
|
|
89
|
+
return { ref, kind: 'dir', content: listed.join('\n') };
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return { ref, kind: 'unreadable', note: 'the folder could not be read' };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const buffer = await readFile(full);
|
|
97
|
+
if (looksBinary(buffer)) {
|
|
98
|
+
return { ref, kind: 'binary', note: 'a binary file, ' + buffer.length + ' bytes' };
|
|
99
|
+
}
|
|
100
|
+
return { ref, kind: 'file', content: buffer.toString('utf8') };
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return { ref, kind: 'unreadable', note: 'the file could not be read' };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The message with everything it referred to attached beneath it.
|
|
108
|
+
*
|
|
109
|
+
* Beneath rather than inline, so the sentence a person wrote stays the sentence the model reads
|
|
110
|
+
* first. The blocks are fenced with a name and a line count because a model given eight hundred
|
|
111
|
+
* unlabelled lines cannot cite where anything came from.
|
|
112
|
+
*/
|
|
113
|
+
export async function attachReferences(cwd, text) {
|
|
114
|
+
const refs = referencesIn(text);
|
|
115
|
+
if (refs.length === 0)
|
|
116
|
+
return { text, attached: [] };
|
|
117
|
+
const attached = await Promise.all(refs.map(ref => resolveOne(cwd, ref)));
|
|
118
|
+
const useful = attached.filter(a => a.kind === 'file' || a.kind === 'dir');
|
|
119
|
+
const problems = attached.filter(a => a.kind !== 'file' && a.kind !== 'dir');
|
|
120
|
+
if (useful.length === 0 && problems.length === 0)
|
|
121
|
+
return { text, attached };
|
|
122
|
+
const parts = [text.trimEnd()];
|
|
123
|
+
if (useful.length > 0) {
|
|
124
|
+
parts.push('', 'Referenced with @ in the message above:');
|
|
125
|
+
for (const item of useful) {
|
|
126
|
+
const body = (item.content ?? '').replace(/\s+$/, '');
|
|
127
|
+
const lines = linesIn(body);
|
|
128
|
+
const label = item.kind === 'dir'
|
|
129
|
+
? '@' + item.ref + '/ — folder listing, ' + lines + ' entries'
|
|
130
|
+
: '@' + item.ref + ' — ' + lines + ' lines';
|
|
131
|
+
parts.push('', '<<< ' + label, body, '>>> end ' + item.ref);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
for (const problem of problems) {
|
|
135
|
+
parts.push('', 'Note: @' + problem.ref + ' could not be attached — ' + (problem.note ?? 'unknown'));
|
|
136
|
+
}
|
|
137
|
+
return { text: parts.join('\n'), attached };
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=mention-resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mention-resolve.js","sourceRoot":"","sources":["../src/mention-resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAatD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,OAAO,GAAG,+BAA+B,C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130
|
onChunk?: (text: string) => void;
|
|
131
131
|
onToolCall?: (name: string, args: string) => void;
|
|
132
132
|
/** `detail` carries why a tool failed, so a UI can show the reason rather than just a cross. */
|
|
133
|
-
|
|
133
|
+
/**
|
|
134
|
+
* A tool finished.
|
|
135
|
+
*
|
|
136
|
+
* `args` is the call's own arguments, the same string the start hook was given. It is here because
|
|
137
|
+
* the browser panel works out what a call was about by parsing them — so without them a completed
|
|
138
|
+
* write had no path, the panel's header fell back to saying "write_file", and the diff it should
|
|
139
|
+
* have opened never appeared. The end of a call knows as much about it as the beginning did.
|
|
140
|
+
*/
|
|
141
|
+
onToolResult?: (name: string, ok: boolean, elapsedMs: number, detail?: string, args?: string) => void;
|
|
134
142
|
/**
|
|
135
143
|
* A workspace hook ran. Reported so an interface can show what a hook did — a hook that blocks
|
|
136
144
|
* a tool invisibly is indistinguishable from a bug in KONECK.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,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xB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,cAAc,EAAE,WAAW,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
package/dist/web/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/web/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/web/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA0B/C,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAYrC,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AA6BD,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,wBAAsB,QAAQ,CAC5B,YAAY,EAAE,WAAW,EAAE,OAAO,GAAE,UAAe,GAClD,OAAO,CAAC,SAAS,CAAC,CAw9CpB"}
|
package/dist/web/api.js
CHANGED
|
@@ -27,11 +27,22 @@ import { listPast, readPast } from './history.js';
|
|
|
27
27
|
import { summarise as summariseTrajectory } from '../trajectory.js';
|
|
28
28
|
import { listDir, viewFile } from './files.js';
|
|
29
29
|
import { searchSessions, searchAllWorkspaces } from './search.js';
|
|
30
|
+
import { listWorkspaceEntries } from '../workspace-files.js';
|
|
31
|
+
import { rankMentions, describeCandidates, shortReason } from './mention.js';
|
|
32
|
+
import { gatherSignals } from './mention-signals.js';
|
|
30
33
|
import { trustedWorkspaces, isWorkspaceTrusted, trustWorkspace } from '../workspace-trust.js';
|
|
31
34
|
import { MODES } from '../permissions.js';
|
|
32
35
|
import { checkpoints, makeCheckpoint, checkpointPreview, restoreCheckpoint, gate, health, settings, writeSetting, projectContext, writeInstructions, runWebRefactor, REFACTOR_SHAPES, mcpServers } from './capabilities.js';
|
|
33
36
|
export const DEFAULT_WEB_PORT = 4300;
|
|
34
37
|
const LOOPBACK = '127.0.0.1';
|
|
38
|
+
/**
|
|
39
|
+
* How long the `@` picker's listing and signals stay usable.
|
|
40
|
+
*
|
|
41
|
+
* Short, because it exists to survive a burst of keystrokes rather than to be a cache in any real
|
|
42
|
+
* sense — and the dropdown opening refreshes it regardless, which is the moment staleness would be
|
|
43
|
+
* noticed.
|
|
44
|
+
*/
|
|
45
|
+
const MENTION_CACHE_MS = 15_000;
|
|
35
46
|
function tokenMatches(expected, given) {
|
|
36
47
|
if (!given)
|
|
37
48
|
return false;
|
|
@@ -86,6 +97,14 @@ export async function startWeb(baseConfigIn, options = {}) {
|
|
|
86
97
|
* add to that list would be exactly the escalation the prompt exists to prevent.
|
|
87
98
|
*/
|
|
88
99
|
let workspace = baseConfig.cwd;
|
|
100
|
+
/*
|
|
101
|
+
* What the `@` picker holds between keystrokes.
|
|
102
|
+
*
|
|
103
|
+
* Refreshed whenever the dropdown opens, so a file created a second ago is there, and otherwise
|
|
104
|
+
* held for long enough that typing a filename is not thousands of directory reads. Invalidated by
|
|
105
|
+
* key rather than cleared, because the workspace and the session both change what belongs in it.
|
|
106
|
+
*/
|
|
107
|
+
let mentionCache = null;
|
|
89
108
|
/** Makes each uploaded filename unique without a clock collision. */
|
|
90
109
|
let uploadCounter = 0;
|
|
91
110
|
const registry = new SessionRegistry();
|
|
@@ -401,7 +420,73 @@ export async function startWeb(baseConfigIn, options = {}) {
|
|
|
401
420
|
const text = String(body.text ?? '');
|
|
402
421
|
if (text.length > 400_000)
|
|
403
422
|
return json(res, 200, { tokens: null, tooLong: true });
|
|
404
|
-
|
|
423
|
+
/*
|
|
424
|
+
* The whole text is tokenised; only the asked-for tail is sent back.
|
|
425
|
+
*
|
|
426
|
+
* Sending the tail is what makes repainting a streaming write cheap: measured on a 610-line
|
|
427
|
+
* tsx file, tokenising is 7.7ms and the full token array is 118KB, while the twenty lines
|
|
428
|
+
* that actually arrived are a fraction of that.
|
|
429
|
+
*
|
|
430
|
+
* Tokenising the whole text rather than just those lines buys nothing today, and it would be
|
|
431
|
+
* dishonest to pretend otherwise: the highlighter colours each line independently, so the
|
|
432
|
+
* answer for lines 500-520 is identical either way. It is done this way because that is the
|
|
433
|
+
* only version that stays correct if the highlighter ever carries state between lines, and
|
|
434
|
+
* because the cost of being ready for that is seven milliseconds.
|
|
435
|
+
*
|
|
436
|
+
* The limitation that goes with line-independence is worth naming: a block comment whose
|
|
437
|
+
* continuation lines do not begin with an asterisk is not coloured on those lines. That
|
|
438
|
+
* applies to the file view and the terminal equally — it is where the highlighter lives, not
|
|
439
|
+
* something this route introduces.
|
|
440
|
+
*/
|
|
441
|
+
const all = highlightTokens(text.split('\n'), String(body.path ?? 'x.txt'));
|
|
442
|
+
const from = Number.isFinite(body.from) ? Math.max(0, Math.floor(body.from)) : 0;
|
|
443
|
+
return json(res, 200, from > 0
|
|
444
|
+
? { from, tokens: all.slice(from) }
|
|
445
|
+
: { from: 0, tokens: all });
|
|
446
|
+
}
|
|
447
|
+
/*
|
|
448
|
+
* The candidates for an `@` in the composer.
|
|
449
|
+
*
|
|
450
|
+
* Two things are cached, for different reasons. The workspace listing is a directory walk over
|
|
451
|
+
* thousands of paths and cannot happen per keystroke. The signals — git, the ledger, the
|
|
452
|
+
* session's own history — are three more reads that would turn typing into waiting. Both are
|
|
453
|
+
* held briefly and refreshed when the dropdown opens, which is the moment somebody would
|
|
454
|
+
* notice a file they just created being missing.
|
|
455
|
+
*
|
|
456
|
+
* The ranking itself runs on every request rather than in the browser. It has to: the browser
|
|
457
|
+
* has no ledger, no git and no trajectory, and shipping all three to it so it could sort forty
|
|
458
|
+
* filenames would cost more than the sort.
|
|
459
|
+
*/
|
|
460
|
+
if (route === '/api/mention' && req.method === 'GET') {
|
|
461
|
+
if (!mayRead)
|
|
462
|
+
return json(res, 401, { error: 'token required' });
|
|
463
|
+
const q = url.searchParams.get('q') ?? '';
|
|
464
|
+
const opening = url.searchParams.get('fresh') === '1';
|
|
465
|
+
const sessionId = url.searchParams.get('session') ?? '';
|
|
466
|
+
const cacheKey = workspace + '\u0000' + sessionId;
|
|
467
|
+
const now = Date.now();
|
|
468
|
+
const stale = !mentionCache
|
|
469
|
+
|| mentionCache.key !== cacheKey
|
|
470
|
+
|| opening
|
|
471
|
+
|| now - mentionCache.at > MENTION_CACHE_MS;
|
|
472
|
+
if (stale) {
|
|
473
|
+
const events = sessionId ? (registry.get(sessionId)?.trajectory() ?? []) : [];
|
|
474
|
+
const [entries, signals] = await Promise.all([
|
|
475
|
+
listWorkspaceEntries(workspace).catch(() => []),
|
|
476
|
+
gatherSignals(workspace, events).catch(() => ({})),
|
|
477
|
+
]);
|
|
478
|
+
mentionCache = { key: cacheKey, at: now, entries, signals };
|
|
479
|
+
}
|
|
480
|
+
const held = mentionCache;
|
|
481
|
+
const ranked = rankMentions(held.entries, q, held.signals);
|
|
482
|
+
const candidates = await describeCandidates(workspace, ranked);
|
|
483
|
+
return json(res, 200, {
|
|
484
|
+
query: q,
|
|
485
|
+
total: held.entries.length,
|
|
486
|
+
// The short forms come from here rather than from the client, so the browser and the
|
|
487
|
+
// terminal cannot end up calling the same signal two different things.
|
|
488
|
+
candidates: candidates.map(c => ({ ...c, shorts: c.because.map(shortReason) })),
|
|
489
|
+
});
|
|
405
490
|
}
|
|
406
491
|
if (route === '/api/search' && req.method === 'GET') {
|
|
407
492
|
if (!mayRead)
|