@sagmans/dsh-tui 0.4.0 → 0.5.1
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/LICENSE +1 -1
- package/README.md +270 -68
- package/lib/agent/present.js +1 -1
- package/lib/agent/present.js.map +1 -1
- package/lib/agent/prompt-history.d.ts.map +1 -1
- package/lib/agent/prompt-history.js +5 -3
- package/lib/agent/prompt-history.js.map +1 -1
- package/lib/agent/status.d.ts +1 -1
- package/lib/cards.d.ts +83 -13
- package/lib/cards.d.ts.map +1 -1
- package/lib/cards.js +96 -28
- package/lib/cards.js.map +1 -1
- package/lib/export.d.ts +3 -3
- package/lib/export.d.ts.map +1 -1
- package/lib/export.js +23 -13
- package/lib/export.js.map +1 -1
- package/lib/fold-cursor.d.ts +12 -5
- package/lib/fold-cursor.d.ts.map +1 -1
- package/lib/fold-cursor.js +16 -5
- package/lib/fold-cursor.js.map +1 -1
- package/lib/gates.d.ts.map +1 -1
- package/lib/gates.js +42 -9
- package/lib/gates.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +459 -72
- package/lib/index.js.map +1 -1
- package/lib/injection.d.ts +9 -0
- package/lib/injection.d.ts.map +1 -0
- package/lib/injection.js +128 -0
- package/lib/injection.js.map +1 -0
- package/lib/input/actions.d.ts +19 -2
- package/lib/input/actions.d.ts.map +1 -1
- package/lib/input/actions.js +57 -11
- package/lib/input/actions.js.map +1 -1
- package/lib/input/cancel.d.ts +55 -0
- package/lib/input/cancel.d.ts.map +1 -0
- package/lib/input/cancel.js +47 -0
- package/lib/input/cancel.js.map +1 -0
- package/lib/input/completion.d.ts +5 -2
- package/lib/input/completion.d.ts.map +1 -1
- package/lib/input/completion.js +79 -4
- package/lib/input/completion.js.map +1 -1
- package/lib/input/file-search.d.ts +105 -0
- package/lib/input/file-search.d.ts.map +1 -0
- package/lib/input/file-search.js +665 -0
- package/lib/input/file-search.js.map +1 -0
- package/lib/input/fuzzy.d.ts +42 -0
- package/lib/input/fuzzy.d.ts.map +1 -0
- package/lib/input/fuzzy.js +289 -0
- package/lib/input/fuzzy.js.map +1 -0
- package/lib/input/keymap.d.ts +3 -1
- package/lib/input/keymap.d.ts.map +1 -1
- package/lib/input/keymap.js +14 -3
- package/lib/input/keymap.js.map +1 -1
- package/lib/input/match.d.ts +12 -4
- package/lib/input/match.d.ts.map +1 -1
- package/lib/input/match.js +50 -51
- package/lib/input/match.js.map +1 -1
- package/lib/input/submission.d.ts +10 -0
- package/lib/input/submission.d.ts.map +1 -1
- package/lib/input/submission.js +7 -6
- package/lib/input/submission.js.map +1 -1
- package/lib/keys-command.d.ts +19 -3
- package/lib/keys-command.d.ts.map +1 -1
- package/lib/keys-command.js +34 -31
- package/lib/keys-command.js.map +1 -1
- package/lib/settings-notice.d.ts +5 -0
- package/lib/settings-notice.d.ts.map +1 -1
- package/lib/settings-notice.js +9 -7
- package/lib/settings-notice.js.map +1 -1
- package/lib/stash/paths.d.ts +8 -8
- package/lib/stash/paths.d.ts.map +1 -1
- package/lib/stash/paths.js +19 -18
- package/lib/stash/paths.js.map +1 -1
- package/lib/stash/schema.d.ts +11 -12
- package/lib/stash/schema.d.ts.map +1 -1
- package/lib/stash/schema.js +10 -29
- package/lib/stash/schema.js.map +1 -1
- package/lib/stash/store.js +10 -10
- package/lib/stash/store.js.map +1 -1
- package/lib/stash.d.ts +37 -6
- package/lib/stash.d.ts.map +1 -1
- package/lib/stash.js +93 -36
- package/lib/stash.js.map +1 -1
- package/lib/terminal/external-editor.d.ts +93 -0
- package/lib/terminal/external-editor.d.ts.map +1 -0
- package/lib/terminal/external-editor.js +263 -0
- package/lib/terminal/external-editor.js.map +1 -0
- package/lib/terminal/host-writes.d.ts +39 -0
- package/lib/terminal/host-writes.d.ts.map +1 -0
- package/lib/terminal/host-writes.js +136 -0
- package/lib/terminal/host-writes.js.map +1 -0
- package/lib/terminal/signals.d.ts +25 -0
- package/lib/terminal/signals.d.ts.map +1 -0
- package/lib/terminal/signals.js +39 -0
- package/lib/terminal/signals.js.map +1 -0
- package/lib/terminal/warning-screen.d.ts +19 -1
- package/lib/terminal/warning-screen.d.ts.map +1 -1
- package/lib/terminal/warning-screen.js +37 -1
- package/lib/terminal/warning-screen.js.map +1 -1
- package/lib/terminal-text.d.ts +72 -0
- package/lib/terminal-text.d.ts.map +1 -0
- package/lib/terminal-text.js +603 -0
- package/lib/terminal-text.js.map +1 -0
- package/lib/text.d.ts +45 -6
- package/lib/text.d.ts.map +1 -1
- package/lib/text.js +106 -46
- package/lib/text.js.map +1 -1
- package/lib/theme-command.d.ts +7 -4
- package/lib/theme-command.d.ts.map +1 -1
- package/lib/theme-command.js +32 -12
- package/lib/theme-command.js.map +1 -1
- package/lib/theme-files.d.ts +110 -0
- package/lib/theme-files.d.ts.map +1 -0
- package/lib/theme-files.js +352 -0
- package/lib/theme-files.js.map +1 -0
- package/lib/theme-schema.d.ts +121 -0
- package/lib/theme-schema.d.ts.map +1 -0
- package/lib/theme-schema.js +87 -0
- package/lib/theme-schema.js.map +1 -0
- package/lib/theme-settings.d.ts +43 -10
- package/lib/theme-settings.d.ts.map +1 -1
- package/lib/theme-settings.js +103 -43
- package/lib/theme-settings.js.map +1 -1
- package/lib/theme-tokens.d.ts +39 -7
- package/lib/theme-tokens.d.ts.map +1 -1
- package/lib/theme-tokens.js +96 -13
- package/lib/theme-tokens.js.map +1 -1
- package/lib/theme.d.ts +24 -2
- package/lib/theme.d.ts.map +1 -1
- package/lib/theme.js +49 -6
- package/lib/theme.js.map +1 -1
- package/lib/tool-display.d.ts +57 -0
- package/lib/tool-display.d.ts.map +1 -0
- package/lib/tool-display.js +51 -0
- package/lib/tool-display.js.map +1 -0
- package/lib/transcript.d.ts +28 -0
- package/lib/transcript.d.ts.map +1 -1
- package/lib/transcript.js +126 -37
- package/lib/transcript.js.map +1 -1
- package/lib/ui/diff.d.ts +49 -0
- package/lib/ui/diff.d.ts.map +1 -0
- package/lib/ui/diff.js +208 -0
- package/lib/ui/diff.js.map +1 -0
- package/lib/ui/dock.d.ts.map +1 -1
- package/lib/ui/dock.js +9 -6
- package/lib/ui/dock.js.map +1 -1
- package/lib/ui/editor.d.ts.map +1 -1
- package/lib/ui/editor.js +4 -2
- package/lib/ui/editor.js.map +1 -1
- package/lib/ui/frame.d.ts +16 -5
- package/lib/ui/frame.d.ts.map +1 -1
- package/lib/ui/frame.js +32 -13
- package/lib/ui/frame.js.map +1 -1
- package/lib/ui/keymap-picker.d.ts +16 -0
- package/lib/ui/keymap-picker.d.ts.map +1 -0
- package/lib/ui/keymap-picker.js +41 -0
- package/lib/ui/keymap-picker.js.map +1 -0
- package/lib/ui/layout.d.ts +33 -0
- package/lib/ui/layout.d.ts.map +1 -0
- package/lib/ui/layout.js +33 -0
- package/lib/ui/layout.js.map +1 -0
- package/lib/ui/markdown.d.ts +25 -3
- package/lib/ui/markdown.d.ts.map +1 -1
- package/lib/ui/markdown.js +12 -8
- package/lib/ui/markdown.js.map +1 -1
- package/lib/ui/picker-card.d.ts +42 -0
- package/lib/ui/picker-card.d.ts.map +1 -0
- package/lib/ui/picker-card.js +148 -0
- package/lib/ui/picker-card.js.map +1 -0
- package/lib/ui/picker.d.ts +40 -2
- package/lib/ui/picker.d.ts.map +1 -1
- package/lib/ui/picker.js +50 -6
- package/lib/ui/picker.js.map +1 -1
- package/lib/ui/prompt.d.ts +10 -2
- package/lib/ui/prompt.d.ts.map +1 -1
- package/lib/ui/prompt.js +21 -2
- package/lib/ui/prompt.js.map +1 -1
- package/lib/ui/rows.d.ts +8 -6
- package/lib/ui/rows.d.ts.map +1 -1
- package/lib/ui/rows.js +10 -18
- package/lib/ui/rows.js.map +1 -1
- package/lib/ui/stash-picker.d.ts +2 -2
- package/lib/ui/stash-picker.d.ts.map +1 -1
- package/lib/ui/stash-picker.js +4 -4
- package/lib/ui/stash-picker.js.map +1 -1
- package/lib/ui/status.d.ts.map +1 -1
- package/lib/ui/status.js +18 -16
- package/lib/ui/status.js.map +1 -1
- package/lib/ui/theme-picker.d.ts +18 -0
- package/lib/ui/theme-picker.d.ts.map +1 -0
- package/lib/ui/theme-picker.js +68 -0
- package/lib/ui/theme-picker.js.map +1 -0
- package/lib/ui/view.d.ts +146 -22
- package/lib/ui/view.d.ts.map +1 -1
- package/lib/ui/view.js +461 -154
- package/lib/ui/view.js.map +1 -1
- package/package.json +45 -11
- package/themes/deepseek-blue.yaml +183 -0
- package/themes/violet-orbit.yaml +178 -0
package/lib/input/match.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
|
+
import { foldSimple, fuzzyScore } from "./fuzzy.js";
|
|
1
2
|
/**
|
|
2
3
|
* Where each kind of hit starts.
|
|
3
4
|
*
|
|
4
5
|
* A reader comparing rows expects an exact name to stay above a name that
|
|
5
|
-
* merely contains what they typed, so one band always outranks the next.
|
|
6
|
+
* merely contains what they typed, so one band always outranks the next. The
|
|
7
|
+
* gaps between bands are wide enough that every fuzzy reading of a band stays
|
|
8
|
+
* inside it.
|
|
6
9
|
*/
|
|
7
|
-
const EXACT_HIT =
|
|
8
|
-
const PREFIX_HIT =
|
|
9
|
-
const CONTIGUOUS_HIT =
|
|
10
|
-
const SCATTERED_HIT =
|
|
11
|
-
/**
|
|
10
|
+
const EXACT_HIT = 4_000_000;
|
|
11
|
+
const PREFIX_HIT = 3_000_000;
|
|
12
|
+
const CONTIGUOUS_HIT = 2_000_000;
|
|
13
|
+
const SCATTERED_HIT = 1_000_000;
|
|
14
|
+
/**
|
|
15
|
+
* What one character of distance from the start of the row costs.
|
|
16
|
+
*
|
|
17
|
+
* A contiguous hit that starts earlier is the class the reader is aiming at,
|
|
18
|
+
* so its position has to outrank any difference the fuzzy reading can make
|
|
19
|
+
* inside the same band; the fuzzy score is clamped below this step for that
|
|
20
|
+
* reason.
|
|
21
|
+
*/
|
|
22
|
+
const POSITION_PENALTY_PER_CHAR = 1_000;
|
|
12
23
|
const POSITION_PENALTY_CAP = 500;
|
|
24
|
+
/** Room a fuzzy reading has inside its band, one point less than a band step. */
|
|
25
|
+
const FUZZY_BAND_CAP = POSITION_PENALTY_PER_CHAR - 1;
|
|
13
26
|
/**
|
|
14
27
|
* Shortest fragment allowed to gather scattered characters.
|
|
15
28
|
*
|
|
@@ -20,64 +33,50 @@ const SCATTERED_MIN_LENGTH = 3;
|
|
|
20
33
|
/**
|
|
21
34
|
* How well a row answers what the reader typed.
|
|
22
35
|
*
|
|
23
|
-
* A reader types fragments — `glm53` for `GLM-5.3`, `
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
36
|
+
* A reader types fragments — `glm53` for `GLM-5.3`, `edtr` for a path — so
|
|
37
|
+
* matching only a contiguous run makes them remember punctuation the list
|
|
38
|
+
* already renders for them. The band a hit lands in answers "what kind of hit
|
|
39
|
+
* is this": an exact row, a row that opens with the fragment, one that holds
|
|
40
|
+
* it whole, or one that only carries its characters in order. Inside a band
|
|
41
|
+
* the fuzzy reading decides, which is what keeps a match on a word boundary
|
|
42
|
+
* above the same letters spread through the middle of a word.
|
|
43
|
+
*
|
|
44
|
+
* Higher is a better match; `undefined` is the only answer that means no
|
|
45
|
+
* match at all. The bands are decided on the folded text and the reading
|
|
46
|
+
* itself on the row as it was written, because only the original spelling
|
|
47
|
+
* still carries the humps and separators the reading pays for.
|
|
27
48
|
*/
|
|
28
49
|
export function matchScore(needle, haystack) {
|
|
29
|
-
const
|
|
50
|
+
const trimmed = needle.trim();
|
|
51
|
+
const query = foldSimple(trimmed);
|
|
30
52
|
if (query === '')
|
|
31
53
|
return EXACT_HIT;
|
|
32
|
-
const text = haystack
|
|
54
|
+
const text = foldSimple(haystack);
|
|
33
55
|
if (text === query)
|
|
34
56
|
return EXACT_HIT;
|
|
35
57
|
if (text.startsWith(query))
|
|
36
|
-
return PREFIX_HIT;
|
|
58
|
+
return PREFIX_HIT + fuzzyWithin(trimmed, haystack);
|
|
37
59
|
const at = text.indexOf(query);
|
|
38
|
-
if (at >= 0)
|
|
39
|
-
return CONTIGUOUS_HIT - Math.min(at, POSITION_PENALTY_CAP);
|
|
60
|
+
if (at >= 0) {
|
|
61
|
+
return CONTIGUOUS_HIT - Math.min(at, POSITION_PENALTY_CAP) * POSITION_PENALTY_PER_CHAR + fuzzyWithin(trimmed, haystack);
|
|
62
|
+
}
|
|
40
63
|
if (query.length < SCATTERED_MIN_LENGTH)
|
|
41
64
|
return undefined;
|
|
42
|
-
|
|
65
|
+
const raw = fuzzyScore(trimmed, haystack);
|
|
66
|
+
return raw === undefined ? undefined : SCATTERED_HIT + clampToBand(raw);
|
|
43
67
|
}
|
|
44
68
|
/**
|
|
45
|
-
* The
|
|
46
|
-
* characters are not all there in order.
|
|
69
|
+
* The fuzzy reading of a hit, held inside the band that hit already earned.
|
|
47
70
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* the `g` in the model name. How far into the row the fragment starts is the
|
|
51
|
-
* contiguous bands' concern; counting it here would rank a spread-out hit that
|
|
52
|
-
* happens to start early above a tighter one, which is the opposite of what
|
|
53
|
-
* the reader typed.
|
|
71
|
+
* A row that reaches one band must never overtake a row in the band above it,
|
|
72
|
+
* however good its letters look.
|
|
54
73
|
*/
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let from = start + 1;
|
|
63
|
-
let skipped = 0;
|
|
64
|
-
let complete = true;
|
|
65
|
-
for (const character of rest) {
|
|
66
|
-
const found = text.indexOf(character, from);
|
|
67
|
-
if (found < 0) {
|
|
68
|
-
complete = false;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
skipped += found - from;
|
|
72
|
-
from = found + 1;
|
|
73
|
-
if (bestPenalty !== undefined && skipped >= bestPenalty) {
|
|
74
|
-
complete = false;
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (complete && (bestPenalty === undefined || skipped < bestPenalty))
|
|
79
|
-
bestPenalty = skipped;
|
|
80
|
-
}
|
|
81
|
-
return bestPenalty === undefined ? undefined : SCATTERED_HIT - Math.min(bestPenalty, POSITION_PENALTY_CAP);
|
|
74
|
+
function fuzzyWithin(query, haystack) {
|
|
75
|
+
return clampToBand(fuzzyScore(query, haystack));
|
|
76
|
+
}
|
|
77
|
+
function clampToBand(raw) {
|
|
78
|
+
if (raw === undefined)
|
|
79
|
+
return 0;
|
|
80
|
+
return Math.max(-FUZZY_BAND_CAP, Math.min(FUZZY_BAND_CAP, raw));
|
|
82
81
|
}
|
|
83
82
|
//# sourceMappingURL=match.js.map
|
package/lib/input/match.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/input/match.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/input/match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;;;GAOG;AACH,MAAM,SAAS,GAAG,SAAS,CAAA;AAC3B,MAAM,UAAU,GAAG,SAAS,CAAA;AAC5B,MAAM,cAAc,GAAG,SAAS,CAAA;AAChC,MAAM,aAAa,GAAG,SAAS,CAAA;AAE/B;;;;;;;GAOG;AACH,MAAM,yBAAyB,GAAG,KAAK,CAAA;AACvC,MAAM,oBAAoB,GAAG,GAAG,CAAA;AAEhC,iFAAiF;AACjF,MAAM,cAAc,GAAG,yBAAyB,GAAG,CAAC,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,CAAC,CAAA;AAE9B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,QAAgB;IACzD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;IAC7B,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;IACjC,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,SAAS,CAAA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string;
|
|
42
43
|
} | {
|
|
43
44
|
readonly kind: 'keys';
|
|
44
45
|
readonly argument: string;
|
|
@@ -56,6 +57,15 @@ export type Submission = {
|
|
|
56
57
|
/** The chord: park whatever the editor is holding, which a typed command cannot do. */
|
|
57
58
|
| {
|
|
58
59
|
readonly kind: 'stash-draft';
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The chord: edit the draft in the reader's own editor.
|
|
63
|
+
*
|
|
64
|
+
* Typed, this would be a command whose own line is already consumed by the
|
|
65
|
+
* time it runs, so the chord is the only way to hand over the draft in hand.
|
|
66
|
+
*/
|
|
67
|
+
| {
|
|
68
|
+
readonly kind: 'editor';
|
|
59
69
|
} | {
|
|
60
70
|
readonly kind: 'stash-pop';
|
|
61
71
|
readonly selector: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submission.d.ts","sourceRoot":"","sources":["../../src/input/submission.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,C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;AACvD,uFAAuF;GACrF;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAAE;AAClC;;;;;GAKG;GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAAE,GAChC;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC1E;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEtD,iEAAiE;AACjE,eAAO,MAAM,cAAc,gSAGjB,CAAA;AAEV,2EAA2E;AAC3E,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0BvE,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CA+D3D"}
|
package/lib/input/submission.js
CHANGED
|
@@ -12,8 +12,8 @@ export const LOCAL_COMMAND_DESCRIPTIONS = {
|
|
|
12
12
|
'/jobs': 'list background jobs, read one, or kill one',
|
|
13
13
|
'/subagents': 'list delegations; /subagents open <id|last> reads one, /subagents kill <id> stops one',
|
|
14
14
|
'/todo': 'show the list of tasks the agent is keeping',
|
|
15
|
-
'/theme': '
|
|
16
|
-
'/keys': '
|
|
15
|
+
'/theme': 'open the theme picker, the screen previewing each row; /theme <name> applies one; /theme tokens lists the elements',
|
|
16
|
+
'/keys': 'open the key map and filter it by typing; /keys <layer> narrows it',
|
|
17
17
|
'/fork': 'branch this conversation and continue in the branch',
|
|
18
18
|
'/new': 'start a fresh session without leaving the terminal',
|
|
19
19
|
'/copy': 'copy the last answer to the clipboard through the terminal',
|
|
@@ -25,9 +25,9 @@ export const LOCAL_COMMAND_DESCRIPTIONS = {
|
|
|
25
25
|
'/stash': 'store the draft typed after it; ctrl+x then s parks the editor',
|
|
26
26
|
'/stash-pop': 'put a stashed draft (newest by default) into the editor and remove it',
|
|
27
27
|
'/stash-apply': 'put a stashed draft (newest by default) into the editor and keep it',
|
|
28
|
-
'/stash-list':
|
|
28
|
+
'/stash-list': "open this session's stashes; enter pops one",
|
|
29
29
|
'/stash-drop': 'delete a stashed draft (newest by default) without using it',
|
|
30
|
-
'/stash-clear': 'delete every stashed
|
|
30
|
+
'/stash-clear': 'delete every draft stashed in this session after a confirmation',
|
|
31
31
|
'/quit': 'leave and print the resume command',
|
|
32
32
|
'/exit': 'leave and print the resume command',
|
|
33
33
|
};
|
|
@@ -75,8 +75,9 @@ export function classifySubmission(text) {
|
|
|
75
75
|
}
|
|
76
76
|
if (trimmed === '/todo')
|
|
77
77
|
return { kind: 'todo' };
|
|
78
|
-
if (trimmed === '/theme')
|
|
79
|
-
return { kind: 'theme' };
|
|
78
|
+
if (trimmed === '/theme' || trimmed.startsWith('/theme ')) {
|
|
79
|
+
return { kind: 'theme', argument: trimmed.slice('/theme'.length).trim() };
|
|
80
|
+
}
|
|
80
81
|
if (trimmed === '/keys' || trimmed.startsWith('/keys ')) {
|
|
81
82
|
return { kind: 'keys', argument: trimmed.slice('/keys'.length).trim() };
|
|
82
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submission.js","sourceRoot":"","sources":["../../src/input/submission.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"submission.js","sourceRoot":"","sources":["../../src/input/submission.ts"],"names":[],"mappings":"AAwCA,iEAAiE;AACjE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO;IAC7L,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc;CAC5E,CAAA;AAEV,2EAA2E;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GAAqC;IAC1E,OAAO,EAAE,oCAAoC;IAC7C,SAAS,EAAE,mDAAmD;IAC9D,QAAQ,EAAE,qFAAqF;IAC/F,SAAS,EAAE,kDAAkD;IAC7D,OAAO,EAAE,6CAA6C;IACtD,YAAY,EAAE,uFAAuF;IACrG,OAAO,EAAE,6CAA6C;IACtD,QAAQ,EAAE,oHAAoH;IAC9H,OAAO,EAAE,oEAAoE;IAC7E,OAAO,EAAE,qDAAqD;IAC9D,MAAM,EAAE,oDAAoD;IAC5D,OAAO,EAAE,4DAA4D;IACrE,UAAU,EAAE,wEAAwE;IACpF,SAAS,EAAE,gDAAgD;IAC3D,SAAS,EAAE,iDAAiD;IAC5D,QAAQ,EAAE,8BAA8B;IACxC,SAAS,EAAE,6BAA6B;IACxC,QAAQ,EAAE,gEAAgE;IAC1E,YAAY,EAAE,uEAAuE;IACrF,cAAc,EAAE,qEAAqE;IACrF,aAAa,EAAE,6CAA6C;IAC5D,aAAa,EAAE,6DAA6D;IAC5E,cAAc,EAAE,iEAAiE;IACjF,OAAO,EAAE,oCAAoC;IAC7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"}
|
package/lib/keys-command.d.ts
CHANGED
|
@@ -3,14 +3,30 @@ import { type ActionLayer, type Keymap } from './input/actions.ts';
|
|
|
3
3
|
export declare const KEYMAP_LAYERS: readonly ActionLayer[];
|
|
4
4
|
/** The layer a reader named, or nothing when the name is not one of them. */
|
|
5
5
|
export declare function keymapLayer(name: string): ActionLayer | undefined;
|
|
6
|
+
/** What one layer is for, so a list narrowed to it can say what the reader is looking at. */
|
|
7
|
+
export declare function layerNote(layer: ActionLayer): string;
|
|
8
|
+
/** One row of the key map, as the list shows it. */
|
|
9
|
+
export interface KeymapRow {
|
|
10
|
+
/** The action id, or the shadow's own name; what a pick would settle on. */
|
|
11
|
+
readonly id: string;
|
|
12
|
+
/** The row as it reads: the id, the keys in force, and what the action does. */
|
|
13
|
+
readonly label: string;
|
|
14
|
+
/** The part of the map the row belongs to: a layer, or the keys taken from the library. */
|
|
15
|
+
readonly group: string;
|
|
16
|
+
/** Whether the reader wrote this row, which the list's heading counts. */
|
|
17
|
+
readonly written: boolean;
|
|
18
|
+
/** Whether the row names an action rather than a key the map took from the library. */
|
|
19
|
+
readonly action: boolean;
|
|
20
|
+
}
|
|
6
21
|
/**
|
|
7
|
-
* The effective map, one
|
|
22
|
+
* The effective map, one row per action.
|
|
8
23
|
*
|
|
9
24
|
* The id comes first because it is what the reader types into settings.yaml;
|
|
10
25
|
* the keys follow in the order they are read, so a list action answers its
|
|
11
26
|
* first key before its second. A mark says which rows the reader wrote, because
|
|
12
27
|
* a document that no longer matches the shipped map cannot be read off the file
|
|
13
|
-
* once the file grows.
|
|
28
|
+
* once the file grows. The keys the reader took from the library are rows too:
|
|
29
|
+
* they are a fact about the map, and whoever remapped is the one reading it.
|
|
14
30
|
*/
|
|
15
|
-
export declare function
|
|
31
|
+
export declare function keymapRows(map: Keymap, only?: ActionLayer): readonly KeymapRow[];
|
|
16
32
|
//# sourceMappingURL=keys-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys-command.d.ts","sourceRoot":"","sources":["../src/keys-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6D,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE7H,0EAA0E;AAC1E,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EAA4E,CAAA;
|
|
1
|
+
{"version":3,"file":"keys-command.d.ts","sourceRoot":"","sources":["../src/keys-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6D,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE7H,0EAA0E;AAC1E,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EAA4E,CAAA;AAmB5H,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEjE;AAED,6FAA6F;AAC7F,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAEpD;AAED,oDAAoD;AACpD,MAAM,WAAW,SAAS;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,2FAA2F;IAC3F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,uFAAuF;IACvF,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,SAAS,EAAE,CAyBhF"}
|
package/lib/keys-command.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ACTION_CATALOG, actionLabel, keyName, keysFor, newShadows } from "./input/actions.js";
|
|
2
2
|
/** The layers a reader may ask for, in the order the table lists them. */
|
|
3
3
|
export const KEYMAP_LAYERS = ['prompt', 'surface', 'chord', 'gate', 'question', 'picker', 'library'];
|
|
4
|
-
/** What each layer is for, so a list
|
|
4
|
+
/** What each layer is for, so a list narrowed to one reads as a surface rather than a dump. */
|
|
5
5
|
const LAYER_NOTES = {
|
|
6
6
|
prompt: 'the prompt bar',
|
|
7
7
|
surface: 'the surface, answered before the editor',
|
|
@@ -11,50 +11,53 @@ const LAYER_NOTES = {
|
|
|
11
11
|
picker: 'a list',
|
|
12
12
|
library: 'the editor and input pi-tui draws, read from the library',
|
|
13
13
|
};
|
|
14
|
-
/**
|
|
15
|
-
const
|
|
16
|
-
/**
|
|
17
|
-
const
|
|
18
|
-
'keys:',
|
|
19
|
-
' prompt.submit: ctrl+enter # one key, or',
|
|
20
|
-
' prompt.newLine: [enter, shift+enter, ctrl+j] # a list of them',
|
|
21
|
-
];
|
|
14
|
+
/** The mark a row carries when the reader wrote it, so the shipped map and theirs never blur. */
|
|
15
|
+
const WRITTEN_MARK = ' (yours)';
|
|
16
|
+
/** What a row says instead of a layer when it names a key the reader took from the library. */
|
|
17
|
+
const TAKEN_GROUP = 'from the library';
|
|
22
18
|
/** The layer a reader named, or nothing when the name is not one of them. */
|
|
23
19
|
export function keymapLayer(name) {
|
|
24
20
|
return KEYMAP_LAYERS.find(layer => layer === name);
|
|
25
21
|
}
|
|
22
|
+
/** What one layer is for, so a list narrowed to it can say what the reader is looking at. */
|
|
23
|
+
export function layerNote(layer) {
|
|
24
|
+
return LAYER_NOTES[layer];
|
|
25
|
+
}
|
|
26
26
|
/**
|
|
27
|
-
* The effective map, one
|
|
27
|
+
* The effective map, one row per action.
|
|
28
28
|
*
|
|
29
29
|
* The id comes first because it is what the reader types into settings.yaml;
|
|
30
30
|
* the keys follow in the order they are read, so a list action answers its
|
|
31
31
|
* first key before its second. A mark says which rows the reader wrote, because
|
|
32
32
|
* a document that no longer matches the shipped map cannot be read off the file
|
|
33
|
-
* once the file grows.
|
|
33
|
+
* once the file grows. The keys the reader took from the library are rows too:
|
|
34
|
+
* they are a fact about the map, and whoever remapped is the one reading it.
|
|
34
35
|
*/
|
|
35
|
-
export function
|
|
36
|
+
export function keymapRows(map, only) {
|
|
36
37
|
const layers = only === undefined ? KEYMAP_LAYERS : [only];
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const rows = actions.filter(action => action.layer === layer);
|
|
41
|
-
if (rows.length === 0)
|
|
38
|
+
const rows = [];
|
|
39
|
+
for (const action of ACTION_CATALOG) {
|
|
40
|
+
if (!layers.includes(action.layer))
|
|
42
41
|
continue;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
const keys = keysFor(map, action.id).map(keyName).join(' · ');
|
|
43
|
+
const written = map.written.has(action.id);
|
|
44
|
+
rows.push({
|
|
45
|
+
id: action.id,
|
|
46
|
+
label: `${action.id} = ${keys === '' ? 'unbound' : keys} · ${actionLabel(action.id)}${written ? WRITTEN_MARK : ''}`,
|
|
47
|
+
group: action.layer,
|
|
48
|
+
written,
|
|
49
|
+
action: true,
|
|
50
|
+
});
|
|
49
51
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
for (const shadow of newShadows(map)) {
|
|
53
|
+
rows.push({
|
|
54
|
+
id: `shadow:${shadow.key}:${shadow.winner}`,
|
|
55
|
+
label: `${keyName(shadow.key)}: ${shadow.winner} over ${shadow.loser}`,
|
|
56
|
+
group: TAKEN_GROUP,
|
|
57
|
+
written: false,
|
|
58
|
+
action: false,
|
|
59
|
+
});
|
|
56
60
|
}
|
|
57
|
-
|
|
58
|
-
return lines;
|
|
61
|
+
return rows;
|
|
59
62
|
}
|
|
60
63
|
//# sourceMappingURL=keys-command.js.map
|
package/lib/keys-command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys-command.js","sourceRoot":"","s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,EAAE;YACtE,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,KAAK;SACd,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/lib/settings-notice.d.ts
CHANGED
|
@@ -14,6 +14,11 @@ export interface DeferredNotice {
|
|
|
14
14
|
* is read either before the surface owns the screen or after it: one holder,
|
|
15
15
|
* opened when the screen is taken, keeps both orders honest — and a notice
|
|
16
16
|
* written to stderr alone would have been buried under the alternate screen.
|
|
17
|
+
*
|
|
18
|
+
* Everything held is printed, not just the last: a boot can find several things
|
|
19
|
+
* wrong at once — a refused section and the themes beside it — and showing one of
|
|
20
|
+
* them would leave the reader fixing what they were told about while the rest
|
|
21
|
+
* waited for a restart.
|
|
17
22
|
*/
|
|
18
23
|
export declare function createDeferredNotice(): DeferredNotice;
|
|
19
24
|
//# sourceMappingURL=settings-notice.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-notice.d.ts","sourceRoot":"","sources":["../src/settings-notice.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;AAElD,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAC5B,0EAA0E;IAC1E,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED
|
|
1
|
+
{"version":3,"file":"settings-notice.d.ts","sourceRoot":"","sources":["../src/settings-notice.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;AAElD,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAC5B,0EAA0E;IAC1E,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAgBrD"}
|
package/lib/settings-notice.js
CHANGED
|
@@ -5,22 +5,24 @@
|
|
|
5
5
|
* is read either before the surface owns the screen or after it: one holder,
|
|
6
6
|
* opened when the screen is taken, keeps both orders honest — and a notice
|
|
7
7
|
* written to stderr alone would have been buried under the alternate screen.
|
|
8
|
+
*
|
|
9
|
+
* Everything held is printed, not just the last: a boot can find several things
|
|
10
|
+
* wrong at once — a refused section and the themes beside it — and showing one of
|
|
11
|
+
* them would leave the reader fixing what they were told about while the rest
|
|
12
|
+
* waited for a restart.
|
|
8
13
|
*/
|
|
9
14
|
export function createDeferredNotice() {
|
|
10
15
|
let sink;
|
|
11
|
-
|
|
16
|
+
const held = [];
|
|
12
17
|
return {
|
|
13
18
|
open(next) {
|
|
14
19
|
sink = next;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const held = pending;
|
|
18
|
-
pending = undefined;
|
|
19
|
-
next(held);
|
|
20
|
+
for (const message of held.splice(0))
|
|
21
|
+
next(message);
|
|
20
22
|
},
|
|
21
23
|
post(message) {
|
|
22
24
|
if (sink === undefined) {
|
|
23
|
-
|
|
25
|
+
held.push(message);
|
|
24
26
|
return;
|
|
25
27
|
}
|
|
26
28
|
sink(message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-notice.js","sourceRoot":"","sources":["../src/settings-notice.ts"],"names":[],"mappings":"AAWA
|
|
1
|
+
{"version":3,"file":"settings-notice.js","sourceRoot":"","sources":["../src/settings-notice.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,IAA4B,CAAA;IAChC,MAAM,IAAI,GAAa,EAAE,CAAA;IACzB,OAAO;QACL,IAAI,CAAC,IAAI;YACP,IAAI,GAAG,IAAI,CAAA;YACX,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;gBAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QACrD,CAAC;QACD,IAAI,CAAC,OAAO;YACV,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBAClB,OAAM;YACR,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/lib/stash/paths.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/** The stash file for one
|
|
1
|
+
/** The stash file for one session. */
|
|
2
2
|
export interface StashPaths {
|
|
3
|
-
/** The exact
|
|
4
|
-
readonly
|
|
5
|
-
/** Flattened
|
|
3
|
+
/** The exact session this bank belongs to. */
|
|
4
|
+
readonly sessionId: string;
|
|
5
|
+
/** Flattened session id, used as the on-disk key. */
|
|
6
6
|
readonly key: string;
|
|
7
|
-
/** JSON file holding this
|
|
7
|
+
/** JSON file holding this session's stash entries. */
|
|
8
8
|
readonly file: string;
|
|
9
9
|
}
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function sanitizeSessionId(sessionId: string): string;
|
|
11
11
|
/**
|
|
12
12
|
* The directory the harness keeps its own state in.
|
|
13
13
|
*
|
|
@@ -16,7 +16,7 @@ export declare function sanitizeCwd(cwd: string): string;
|
|
|
16
16
|
* out of a reader's real home during a test run.
|
|
17
17
|
*/
|
|
18
18
|
export declare function dshHomeDir(env?: NodeJS.ProcessEnv, home?: string): string;
|
|
19
|
-
/** The root every
|
|
19
|
+
/** The root every session's stash file sits under. */
|
|
20
20
|
export declare function stashBaseDir(env?: NodeJS.ProcessEnv, home?: string): string;
|
|
21
|
-
export declare function resolveStashPaths(
|
|
21
|
+
export declare function resolveStashPaths(sessionId: string, baseDir?: string): StashPaths;
|
|
22
22
|
//# sourceMappingURL=paths.d.ts.map
|
package/lib/stash/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/stash/paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/stash/paths.ts"],"names":[],"mappings":"AA0CA,sCAAsC;AACtC,MAAM,WAAW,UAAU;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAuBD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAM3D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,EAAE,IAAI,GAAE,MAAkB,GAAG,MAAM,CAGjG;AAED,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,EAAE,IAAI,GAAE,MAAkB,GAAG,MAAM,CAEnG;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,MAAuB,GAAG,UAAU,CAGjG"}
|
package/lib/stash/paths.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
// Disk layout for prompt stashes.
|
|
2
2
|
//
|
|
3
|
-
// A
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// filename-safe key that stays human-readable in the agent
|
|
3
|
+
// A bank is scoped to one session: two terminals working in the same directory
|
|
4
|
+
// keep separate drafts, and a resumed session finds the drafts it parked before
|
|
5
|
+
// the restart, because the session id is what a resume preserves. The id is
|
|
6
|
+
// flattened into a filename-safe key that stays human-readable in the agent
|
|
7
|
+
// directory.
|
|
7
8
|
//
|
|
8
9
|
// Readability cannot be bought with injectivity: a separator made of hyphens
|
|
9
|
-
// cannot be told apart from a hyphen inside a
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
10
|
+
// cannot be told apart from a hyphen inside a session id, and truncating a long
|
|
11
|
+
// id can land on a name a shorter id already owns. Two sessions sharing one bank
|
|
12
|
+
// would let one read or delete another's drafts, so every key ends with a digest
|
|
13
|
+
// of the exact session id. The readable part is then only a label: two distinct
|
|
14
|
+
// ids collide in the label, never in the file.
|
|
14
15
|
import { createHash } from 'node:crypto';
|
|
15
16
|
import { homedir } from 'node:os';
|
|
16
17
|
import path from 'node:path';
|
|
@@ -24,7 +25,7 @@ const STASH_DIR_NAME = 'tui-stash';
|
|
|
24
25
|
// common 255-byte filename limit.
|
|
25
26
|
const SANITIZE_MAX_LENGTH = 200;
|
|
26
27
|
const SEPARATOR = '--';
|
|
27
|
-
const KEY_FORMAT_VERSION = '
|
|
28
|
+
const KEY_FORMAT_VERSION = 'v2';
|
|
28
29
|
const KEY_PREFIX = `${KEY_FORMAT_VERSION}${SEPARATOR}`;
|
|
29
30
|
const ESCAPE_CHARACTER = '%';
|
|
30
31
|
const ESCAPED_ESCAPE_CHARACTER = '%25';
|
|
@@ -34,7 +35,7 @@ const ESCAPED_BACKSLASH = '%5C';
|
|
|
34
35
|
const HASH_ALGORITHM = 'sha256';
|
|
35
36
|
/** 64 bits of digest, which no deliberate name can be built to collide with. */
|
|
36
37
|
const HASH_LENGTH = 16;
|
|
37
|
-
/** Escape one
|
|
38
|
+
/** Escape one key segment so it cannot collide with the separator or an escape. */
|
|
38
39
|
function escapeSegment(segment) {
|
|
39
40
|
return segment
|
|
40
41
|
.replaceAll(ESCAPE_CHARACTER, ESCAPED_ESCAPE_CHARACTER)
|
|
@@ -54,9 +55,9 @@ function truncateToUtf8Bytes(value, maxBytes) {
|
|
|
54
55
|
}
|
|
55
56
|
return result;
|
|
56
57
|
}
|
|
57
|
-
export function
|
|
58
|
-
const readable =
|
|
59
|
-
const digest = createHash(HASH_ALGORITHM).update(
|
|
58
|
+
export function sanitizeSessionId(sessionId) {
|
|
59
|
+
const readable = sessionId.split('/').filter(Boolean).map(escapeSegment).join(SEPARATOR);
|
|
60
|
+
const digest = createHash(HASH_ALGORITHM).update(sessionId, 'utf8').digest('hex').slice(0, HASH_LENGTH);
|
|
60
61
|
const suffix = `${SEPARATOR}${digest}`;
|
|
61
62
|
const budget = SANITIZE_MAX_LENGTH - Buffer.byteLength(KEY_PREFIX) - Buffer.byteLength(suffix);
|
|
62
63
|
return `${KEY_PREFIX}${truncateToUtf8Bytes(readable, Math.max(budget, 0))}${suffix}`;
|
|
@@ -72,12 +73,12 @@ export function dshHomeDir(env = process.env, home = homedir()) {
|
|
|
72
73
|
const configured = env.DSH_HOME?.trim();
|
|
73
74
|
return configured === undefined || configured === '' ? path.join(home, DEFAULT_DSH_HOME_DIR) : configured;
|
|
74
75
|
}
|
|
75
|
-
/** The root every
|
|
76
|
+
/** The root every session's stash file sits under. */
|
|
76
77
|
export function stashBaseDir(env = process.env, home = homedir()) {
|
|
77
78
|
return path.join(dshHomeDir(env, home), STASH_DIR_NAME);
|
|
78
79
|
}
|
|
79
|
-
export function resolveStashPaths(
|
|
80
|
-
const key =
|
|
81
|
-
return {
|
|
80
|
+
export function resolveStashPaths(sessionId, baseDir = stashBaseDir()) {
|
|
81
|
+
const key = sanitizeSessionId(sessionId);
|
|
82
|
+
return { sessionId, key, file: path.join(baseDir, `${key}.json`) };
|
|
82
83
|
}
|
|
83
84
|
//# sourceMappingURL=paths.js.map
|
package/lib/stash/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/stash/paths.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/stash/paths.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF,+EAA+E;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