deepclause-sdk 0.1.2 → 0.2.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/README.md +45 -6
- package/dist/cli/config.d.ts +2 -2
- package/dist/cli/repl.d.ts +55 -4
- package/dist/cli/repl.d.ts.map +1 -1
- package/dist/cli/repl.js +675 -52
- package/dist/cli/repl.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/prolog-src/deepclause_mi.pl +516 -2
- package/dist/repl/backend.d.ts +9 -0
- package/dist/repl/backend.d.ts.map +1 -1
- package/dist/repl/backend.js +62 -5
- package/dist/repl/backend.js.map +1 -1
- package/dist/repl/harness-tools.d.ts +36 -0
- package/dist/repl/harness-tools.d.ts.map +1 -1
- package/dist/repl/harness-tools.js +173 -0
- package/dist/repl/harness-tools.js.map +1 -1
- package/dist/repl/history.d.ts +29 -0
- package/dist/repl/history.d.ts.map +1 -1
- package/dist/repl/history.js +71 -0
- package/dist/repl/history.js.map +1 -1
- package/dist/repl/index.d.ts +6 -0
- package/dist/repl/index.d.ts.map +1 -1
- package/dist/repl/index.js +9 -1
- package/dist/repl/index.js.map +1 -1
- package/dist/repl/picker.d.ts +3 -0
- package/dist/repl/picker.d.ts.map +1 -1
- package/dist/repl/picker.js +132 -0
- package/dist/repl/picker.js.map +1 -1
- package/dist/repl/process-backend.d.ts +31 -0
- package/dist/repl/process-backend.d.ts.map +1 -0
- package/dist/repl/process-backend.js +10 -0
- package/dist/repl/process-backend.js.map +1 -0
- package/dist/repl/process-executor.d.ts +67 -0
- package/dist/repl/process-executor.d.ts.map +1 -0
- package/dist/repl/process-executor.js +371 -0
- package/dist/repl/process-executor.js.map +1 -0
- package/dist/repl/process-worker.d.ts +10 -0
- package/dist/repl/process-worker.d.ts.map +1 -0
- package/dist/repl/process-worker.js +210 -0
- package/dist/repl/process-worker.js.map +1 -0
- package/dist/repl/processes.d.ts +282 -0
- package/dist/repl/processes.d.ts.map +1 -0
- package/dist/repl/processes.js +557 -0
- package/dist/repl/processes.js.map +1 -0
- package/dist/repl/render.d.ts +52 -2
- package/dist/repl/render.d.ts.map +1 -1
- package/dist/repl/render.js +52 -17
- package/dist/repl/render.js.map +1 -1
- package/dist/repl/session.d.ts +135 -3
- package/dist/repl/session.d.ts.map +1 -1
- package/dist/repl/session.js +413 -4
- package/dist/repl/session.js.map +1 -1
- package/dist/repl/status.d.ts +3 -1
- package/dist/repl/status.d.ts.map +1 -1
- package/dist/repl/status.js +4 -0
- package/dist/repl/status.js.map +1 -1
- package/dist/repl/tui/autocomplete.d.ts +19 -0
- package/dist/repl/tui/autocomplete.d.ts.map +1 -0
- package/dist/repl/tui/autocomplete.js +48 -0
- package/dist/repl/tui/autocomplete.js.map +1 -0
- package/dist/repl/tui/document.d.ts +51 -0
- package/dist/repl/tui/document.d.ts.map +1 -0
- package/dist/repl/tui/document.js +160 -0
- package/dist/repl/tui/document.js.map +1 -0
- package/dist/repl/tui/harness-view.d.ts +102 -0
- package/dist/repl/tui/harness-view.d.ts.map +1 -0
- package/dist/repl/tui/harness-view.js +323 -0
- package/dist/repl/tui/harness-view.js.map +1 -0
- package/dist/repl/tui/picker.d.ts +31 -0
- package/dist/repl/tui/picker.d.ts.map +1 -0
- package/dist/repl/tui/picker.js +43 -0
- package/dist/repl/tui/picker.js.map +1 -0
- package/dist/repl/tui/renderer.d.ts +98 -0
- package/dist/repl/tui/renderer.d.ts.map +1 -0
- package/dist/repl/tui/renderer.js +289 -0
- package/dist/repl/tui/renderer.js.map +1 -0
- package/dist/repl/tui/services-panel.d.ts +35 -0
- package/dist/repl/tui/services-panel.d.ts.map +1 -0
- package/dist/repl/tui/services-panel.js +108 -0
- package/dist/repl/tui/services-panel.js.map +1 -0
- package/dist/repl/tui/status-bar.d.ts +6 -2
- package/dist/repl/tui/status-bar.d.ts.map +1 -1
- package/dist/repl/tui/status-bar.js +82 -24
- package/dist/repl/tui/status-bar.js.map +1 -1
- package/dist/repl/tui/terminal.d.ts +28 -0
- package/dist/repl/tui/terminal.d.ts.map +1 -0
- package/dist/repl/tui/terminal.js +94 -0
- package/dist/repl/tui/terminal.js.map +1 -0
- package/dist/repl/tui/theme.d.ts +60 -0
- package/dist/repl/tui/theme.d.ts.map +1 -1
- package/dist/repl/tui/theme.js +142 -0
- package/dist/repl/tui/theme.js.map +1 -1
- package/dist/repl/tui/tool-pane.d.ts +68 -0
- package/dist/repl/tui/tool-pane.d.ts.map +1 -0
- package/dist/repl/tui/tool-pane.js +261 -0
- package/dist/repl/tui/tool-pane.js.map +1 -0
- package/dist/repl/tui/working-line.d.ts +23 -0
- package/dist/repl/tui/working-line.d.ts.map +1 -0
- package/dist/repl/tui/working-line.js +58 -0
- package/dist/repl/tui/working-line.js.map +1 -0
- package/dist/repl/worker-host.d.ts +80 -0
- package/dist/repl/worker-host.d.ts.map +1 -0
- package/dist/repl/worker-host.js +305 -0
- package/dist/repl/worker-host.js.map +1 -0
- package/dist/repl/worker-protocol.d.ts +123 -0
- package/dist/repl/worker-protocol.d.ts.map +1 -0
- package/dist/repl/worker-protocol.js +9 -0
- package/dist/repl/worker-protocol.js.map +1 -0
- package/dist/runner.d.ts +24 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +47 -0
- package/dist/runner.js.map +1 -1
- package/dist/system/assets/docs/AGENT_PROMPT.md +193 -0
- package/dist/system/assets/docs/DML_AUTHORING.md +21 -0
- package/dist/system/assets/docs/DML_REFERENCE.md +145 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/prolog-src/deepclause_mi.pl +516 -2
|
@@ -1,27 +1,71 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Fixed status bar for the REPL TUI (pi-style footer).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* the
|
|
4
|
+
* One row: where the harness lives and what it is doing on the left, the model on
|
|
5
|
+
* the right, and the token/context counters in between. Anything that does not fit
|
|
6
|
+
* is dropped whole, in priority order (see `render`), so a narrow terminal loses
|
|
7
|
+
* detail instead of showing truncated fragments.
|
|
6
8
|
*/
|
|
7
9
|
import { truncateToWidth, visibleWidth } from '@earendil-works/pi-tui';
|
|
8
10
|
import { formatContextSegment, formatModelSegment, formatUsageSegment, } from '../status.js';
|
|
9
11
|
import { dim } from './theme.js';
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The workspace, as short as it can be while still identifying it.
|
|
14
|
+
*
|
|
15
|
+
* A single row cannot afford `/home/me/git/org/project` — it takes half the line
|
|
16
|
+
* and pushes the model and counters off it — so this falls back to the parent and
|
|
17
|
+
* name (`…/org/project`) and then to the name alone.
|
|
18
|
+
*/
|
|
19
|
+
function shortenPath(path, maxWidth = 24) {
|
|
20
|
+
const home = process.env.HOME;
|
|
21
|
+
const shown = home && path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
22
|
+
if (visibleWidth(shown) <= maxWidth)
|
|
23
|
+
return shown;
|
|
24
|
+
const parts = shown.split('/').filter(Boolean);
|
|
25
|
+
const parentAndName = `…/${parts.slice(-2).join('/')}`;
|
|
26
|
+
if (visibleWidth(parentAndName) <= maxWidth)
|
|
27
|
+
return parentAndName;
|
|
28
|
+
return `…/${parts[parts.length - 1] ?? shown}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Join the segments that fit, in the order given, as whole segments.
|
|
32
|
+
*
|
|
33
|
+
* The old code truncated the last segment to fit, which is how a footer ended up
|
|
34
|
+
* reading `deepseek-flash · ` — a separator with nothing after it, and no way to
|
|
35
|
+
* tell a short value from a cut one. Skipping a long segment (a full path) also
|
|
36
|
+
* lets the short, more useful ones after it through.
|
|
37
|
+
*/
|
|
38
|
+
function joinFitting(segments, width, separator = ' · ') {
|
|
39
|
+
const present = segments.filter((segment) => Boolean(segment));
|
|
40
|
+
const kept = [];
|
|
41
|
+
let used = 0;
|
|
42
|
+
for (const segment of present) {
|
|
43
|
+
const cost = (kept.length > 0 ? visibleWidth(separator) : 0) + visibleWidth(segment);
|
|
44
|
+
if (used + cost > width)
|
|
45
|
+
continue;
|
|
46
|
+
kept.push(segment);
|
|
47
|
+
used += cost;
|
|
17
48
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
49
|
+
// Nothing fit: say so with an empty string. The caller decides what to truncate —
|
|
50
|
+
// this never cuts a segment in half, which is what produced `deepseek-flash · `.
|
|
51
|
+
return kept.join(separator);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Left content padded, with `right` against the right edge.
|
|
55
|
+
*
|
|
56
|
+
* The counters are dropped whole before the model is touched: a run is identified
|
|
57
|
+
* by its model, and a half-printed counter is worse than a missing one.
|
|
58
|
+
*/
|
|
59
|
+
function spread(left, right, width) {
|
|
60
|
+
const gap = 2;
|
|
61
|
+
const rightWidth = visibleWidth(right);
|
|
62
|
+
if (rightWidth >= width)
|
|
63
|
+
return truncateToWidth(right, width, '…');
|
|
64
|
+
const joined = joinFitting(left, Math.max(0, width - rightWidth - gap), ' ');
|
|
65
|
+
if (joined) {
|
|
66
|
+
return joined + ' '.repeat(width - visibleWidth(joined) - rightWidth) + right;
|
|
21
67
|
}
|
|
22
|
-
|
|
23
|
-
const total = leftWidth + visibleWidth(truncated);
|
|
24
|
-
return left + ' '.repeat(Math.max(0, width - total)) + truncated;
|
|
68
|
+
return ' '.repeat(width - rightWidth) + right;
|
|
25
69
|
}
|
|
26
70
|
export class StatusBarComponent {
|
|
27
71
|
options;
|
|
@@ -30,15 +74,29 @@ export class StatusBarComponent {
|
|
|
30
74
|
}
|
|
31
75
|
render(width) {
|
|
32
76
|
const snapshot = this.options.getSnapshot();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
|
|
77
|
+
// The long steering hint only on a wide terminal; `running` alone still says
|
|
78
|
+
// what matters, and the dock's loader shows that work is happening.
|
|
79
|
+
const running = this.options.isRunning?.()
|
|
80
|
+
? (width >= 100 ? 'running (type to steer)' : 'running')
|
|
81
|
+
: undefined;
|
|
82
|
+
const frozen = this.options.isFrozen?.() ? 'FROZEN' : undefined;
|
|
83
|
+
const harness = this.options.harness ? `harness ${this.options.harness}` : undefined;
|
|
84
|
+
const processes = this.options.processLabel?.();
|
|
85
|
+
// Priority order, most useful first: where we are, what state we are in, what
|
|
86
|
+
// it has cost, what we are pointed at. The session id is printed by the exit
|
|
87
|
+
// footer, and the backend is only interesting when debugging, so they go last.
|
|
88
|
+
const line = spread([
|
|
89
|
+
shortenPath(this.options.workspace),
|
|
90
|
+
running,
|
|
91
|
+
processes,
|
|
92
|
+
frozen,
|
|
93
|
+
formatUsageSegment(snapshot),
|
|
94
|
+
formatContextSegment(snapshot),
|
|
95
|
+
harness,
|
|
96
|
+
`backend ${this.options.backend}`,
|
|
97
|
+
`session ${this.options.sessionId}`,
|
|
98
|
+
], formatModelSegment(snapshot), width);
|
|
99
|
+
return [dim(line)];
|
|
42
100
|
}
|
|
43
101
|
invalidate() {
|
|
44
102
|
// Stateless rendering: reads the snapshot on each frame.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-bar.js","sourceRoot":"","sources":["../../../src/repl/tui/status-bar.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"status-bar.js","sourceRoot":"","sources":["../../../src/repl/tui/status-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAkB,MAAM,wBAAwB,CAAC;AAEvF,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,GAEnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,GAAG,EAAE,M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ACxC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,SAAS,CAAC;YACxD,CAAC,CAAC,SAAS,CAAC;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QAChE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACrF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;QAEhD,8EAA8E;QAC9E,6EAA6E;QAC7E,+EAA+E;QAC/E,MAAM,IAAI,GAAG,MAAM,CACjB;YACE,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;YACnC,OAAO;YACP,SAAS;YACT,MAAM;YACN,kBAAkB,CAAC,QAAQ,CAAC;YAC5B,oBAAoB,CAAC,QAAQ,CAAC;YAC9B,OAAO;YACP,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACjC,WAAW,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;SACpC,EACD,kBAAkB,CAAC,QAAQ,CAAC,EAC5B,KAAK,CACN,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACrB,CAAC;IAED,UAAU;QACR,yDAAyD;IAC3D,CAAC;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A terminal that knows how tall it really is.
|
|
3
|
+
*
|
|
4
|
+
* pi-tui asks the stream: `rows` is `process.stdout.rows || LINES || 24`. When the
|
|
5
|
+
* stream does not report a size — an unsized pty, a multiplexer or embedded
|
|
6
|
+
* terminal that never sends SIGWINCH, a wrapper that resizes the pty after the
|
|
7
|
+
* child starts — `rows` is 0 and the fallback is a **hard-coded 24**. The TUI then
|
|
8
|
+
* draws a 24-row frame inside a taller terminal, so the UI occupies the top of the
|
|
9
|
+
* screen and leaves the rest untouched, which reads as "it does not use the full
|
|
10
|
+
* height".
|
|
11
|
+
*
|
|
12
|
+
* `refreshTerminalDimensions()` (which pi-tui calls on start) only re-raises
|
|
13
|
+
* SIGWINCH at itself, so it cannot fix a stream that has no size to report.
|
|
14
|
+
* `stty size` asks the tty directly, which is the same source `tput`/`$LINES`
|
|
15
|
+
* use, and is the fallback here.
|
|
16
|
+
*/
|
|
17
|
+
import { ProcessTerminal } from '@earendil-works/pi-tui';
|
|
18
|
+
export declare class SizedTerminal extends ProcessTerminal {
|
|
19
|
+
private fallback?;
|
|
20
|
+
private queried;
|
|
21
|
+
/** Re-read the size (call on resize, where the stream may still not report one). */
|
|
22
|
+
refreshSize(): void;
|
|
23
|
+
private streamSize;
|
|
24
|
+
private ttySize;
|
|
25
|
+
get rows(): number;
|
|
26
|
+
get columns(): number;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=terminal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../../src/repl/tui/terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAyCzD,qBAAa,aAAc,SAAQ,eAAe;IAChD,OAAO,CAAC,QAAQ,CAAC,CAAO;IACxB,OAAO,CAAC,OAAO,CAAS;IAExB,oFAAoF;IACpF,WAAW,IAAI,IAAI;IAKnB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,OAAO;IAUf,IAAa,IAAI,IAAI,MAAM,CAM1B;IAED,IAAa,OAAO,IAAI,MAAM,CAM7B;CACF"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A terminal that knows how tall it really is.
|
|
3
|
+
*
|
|
4
|
+
* pi-tui asks the stream: `rows` is `process.stdout.rows || LINES || 24`. When the
|
|
5
|
+
* stream does not report a size — an unsized pty, a multiplexer or embedded
|
|
6
|
+
* terminal that never sends SIGWINCH, a wrapper that resizes the pty after the
|
|
7
|
+
* child starts — `rows` is 0 and the fallback is a **hard-coded 24**. The TUI then
|
|
8
|
+
* draws a 24-row frame inside a taller terminal, so the UI occupies the top of the
|
|
9
|
+
* screen and leaves the rest untouched, which reads as "it does not use the full
|
|
10
|
+
* height".
|
|
11
|
+
*
|
|
12
|
+
* `refreshTerminalDimensions()` (which pi-tui calls on start) only re-raises
|
|
13
|
+
* SIGWINCH at itself, so it cannot fix a stream that has no size to report.
|
|
14
|
+
* `stty size` asks the tty directly, which is the same source `tput`/`$LINES`
|
|
15
|
+
* use, and is the fallback here.
|
|
16
|
+
*/
|
|
17
|
+
import { execFileSync } from 'child_process';
|
|
18
|
+
import { ProcessTerminal } from '@earendil-works/pi-tui';
|
|
19
|
+
/**
|
|
20
|
+
* A usable dimension, or undefined.
|
|
21
|
+
*
|
|
22
|
+
* `Number(process.env.LINES)` is NaN when the variable is unset, and `??` does not
|
|
23
|
+
* skip NaN — chaining it directly produced a NaN height, and a NaN viewport renders
|
|
24
|
+
* nothing at all.
|
|
25
|
+
*/
|
|
26
|
+
function positive(value) {
|
|
27
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0
|
|
28
|
+
? Math.floor(value)
|
|
29
|
+
: undefined;
|
|
30
|
+
}
|
|
31
|
+
/** Ask the controlling tty for its size. Returns undefined when it has none. */
|
|
32
|
+
function queryTtySize() {
|
|
33
|
+
if (process.platform === 'win32')
|
|
34
|
+
return undefined;
|
|
35
|
+
try {
|
|
36
|
+
// stdin must be the tty: `inherit` gives stty the real one, and stderr is
|
|
37
|
+
// dropped so a shell that cannot report a size is silent.
|
|
38
|
+
const output = execFileSync('stty', ['size'], {
|
|
39
|
+
stdio: ['inherit', 'pipe', 'ignore'],
|
|
40
|
+
encoding: 'utf8',
|
|
41
|
+
});
|
|
42
|
+
const match = /^\s*(\d+)\s+(\d+)\s*$/.exec(output);
|
|
43
|
+
if (!match)
|
|
44
|
+
return undefined;
|
|
45
|
+
const rows = Number(match[1]);
|
|
46
|
+
const columns = Number(match[2]);
|
|
47
|
+
if (rows > 0 && columns > 0)
|
|
48
|
+
return { rows, columns };
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// No tty, no stty, or not permitted: the parent's answer is the best available.
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
export class SizedTerminal extends ProcessTerminal {
|
|
56
|
+
fallback;
|
|
57
|
+
queried = false;
|
|
58
|
+
/** Re-read the size (call on resize, where the stream may still not report one). */
|
|
59
|
+
refreshSize() {
|
|
60
|
+
this.queried = false;
|
|
61
|
+
this.fallback = undefined;
|
|
62
|
+
}
|
|
63
|
+
streamSize() {
|
|
64
|
+
// The stream is authoritative when it answers: it reflects SIGWINCH.
|
|
65
|
+
return {
|
|
66
|
+
rows: process.stdout.rows || undefined,
|
|
67
|
+
columns: process.stdout.columns || undefined,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
ttySize() {
|
|
71
|
+
if (!this.queried) {
|
|
72
|
+
this.queried = true;
|
|
73
|
+
const stream = this.streamSize();
|
|
74
|
+
// Only bother when the stream cannot be trusted for either dimension.
|
|
75
|
+
this.fallback = stream.rows && stream.columns ? undefined : queryTtySize();
|
|
76
|
+
}
|
|
77
|
+
return this.fallback;
|
|
78
|
+
}
|
|
79
|
+
get rows() {
|
|
80
|
+
const stream = this.streamSize();
|
|
81
|
+
return positive(stream.rows)
|
|
82
|
+
?? positive(this.ttySize()?.rows)
|
|
83
|
+
?? positive(Number(process.env.LINES))
|
|
84
|
+
?? 24;
|
|
85
|
+
}
|
|
86
|
+
get columns() {
|
|
87
|
+
const stream = this.streamSize();
|
|
88
|
+
return positive(stream.columns)
|
|
89
|
+
?? positive(this.ttySize()?.columns)
|
|
90
|
+
?? positive(Number(process.env.COLUMNS))
|
|
91
|
+
?? 80;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=terminal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../../src/repl/tui/terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAOzD;;;;;;GAMG;AACH,SAAS,QAAQ,CAAC,KAAyB;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QACrE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACnB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,gFAAgF;AAChF,SAAS,YAAY;IACnB,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC;IACnD,IAAI,CAAC;QACH,0EAA0E;QAC1E,0DAA0D;QAC1D,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE;YAC5C,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC;YACpC,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAC7B,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,IAAI,GAAG,CAAC,IAAI,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,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;eAC1B,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC;eACjC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;eACrC,EAAE,CAAC;IACV,CAAC;CACF"}
|
package/dist/repl/tui/theme.d.ts
CHANGED
|
@@ -27,4 +27,64 @@ export declare function promptLabel(text: string): string;
|
|
|
27
27
|
export declare function dim(text: string): string;
|
|
28
28
|
/** Editor theme: a blue border, cyan selection. */
|
|
29
29
|
export declare function editorTheme(): EditorTheme;
|
|
30
|
+
/**
|
|
31
|
+
* Pi's theme system, adopted for the component layer.
|
|
32
|
+
*
|
|
33
|
+
* Markdown and editor themes come from pi so prose and the input box match the
|
|
34
|
+
* application the user already runs (`getMarkdownTheme`/`getEditorTheme` are
|
|
35
|
+
* resolved against pi's active theme). Our own chrome is styled through pi-tui's
|
|
36
|
+
* `styleText`, which converts to the terminal's colour mode for us, so the
|
|
37
|
+
* palette below is *colours* rather than pre-baked escape sequences.
|
|
38
|
+
*
|
|
39
|
+
* `initTheme()` is best-effort: if pi's theme files are unreadable the SDK still
|
|
40
|
+
* renders, with the fallbacks below.
|
|
41
|
+
*/
|
|
42
|
+
import { type MarkdownTheme, type SelectListTheme, type TextStyle } from '@earendil-works/pi-tui';
|
|
43
|
+
/** Load pi's active theme once. Never throws: a missing theme is not fatal. */
|
|
44
|
+
export declare function initTuiTheme(): void;
|
|
45
|
+
/** Palette entries, as colours so pi-tui owns the escape-sequence conversion. */
|
|
46
|
+
declare const C: {
|
|
47
|
+
readonly accent: import("@earendil-works/pi-tui").IndexedColor;
|
|
48
|
+
readonly border: import("@earendil-works/pi-tui").IndexedColor;
|
|
49
|
+
readonly borderMuted: import("@earendil-works/pi-tui").IndexedColor;
|
|
50
|
+
readonly title: import("@earendil-works/pi-tui").IndexedColor;
|
|
51
|
+
readonly muted: import("@earendil-works/pi-tui").IndexedColor;
|
|
52
|
+
readonly dim: import("@earendil-works/pi-tui").IndexedColor;
|
|
53
|
+
readonly success: import("@earendil-works/pi-tui").IndexedColor;
|
|
54
|
+
readonly error: import("@earendil-works/pi-tui").IndexedColor;
|
|
55
|
+
readonly warning: import("@earendil-works/pi-tui").IndexedColor;
|
|
56
|
+
readonly output: import("@earendil-works/pi-tui").IndexedColor;
|
|
57
|
+
readonly thinking: import("@earendil-works/pi-tui").IndexedColor;
|
|
58
|
+
};
|
|
59
|
+
export type TuiToken = keyof typeof C;
|
|
60
|
+
/** Style text with a semantic colour, honouring the terminal's colour mode. */
|
|
61
|
+
export declare function paintToken(token: TuiToken, text: string, extra?: TextStyle): string;
|
|
62
|
+
/** Convenience wrappers for the tokens the components use most. */
|
|
63
|
+
export declare const tuiStyle: {
|
|
64
|
+
readonly accent: (text: string) => string;
|
|
65
|
+
readonly title: (text: string) => string;
|
|
66
|
+
readonly muted: (text: string) => string;
|
|
67
|
+
readonly dim: (text: string) => string;
|
|
68
|
+
readonly success: (text: string) => string;
|
|
69
|
+
readonly error: (text: string) => string;
|
|
70
|
+
readonly warning: (text: string) => string;
|
|
71
|
+
readonly output: (text: string) => string;
|
|
72
|
+
readonly thinking: (text: string) => string;
|
|
73
|
+
readonly borderMuted: (text: string) => string;
|
|
74
|
+
};
|
|
75
|
+
/** Scrollbar colours for the transcript's `ScrollView`. */
|
|
76
|
+
export declare const scrollbarStyles: {
|
|
77
|
+
readonly track: (text: string) => string;
|
|
78
|
+
readonly thumb: (text: string) => string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Markdown theme: pi's, so prose matches the rest of the user's terminal. The
|
|
82
|
+
* import is synchronous because this is called from render paths, and pi is
|
|
83
|
+
* already a hard dependency (compaction uses it).
|
|
84
|
+
*/
|
|
85
|
+
export declare function markdownTheme(): MarkdownTheme;
|
|
86
|
+
export declare function tuiEditorTheme(): EditorTheme;
|
|
87
|
+
/** Selection-list theme: pi's, so pickers look like the rest of pi. */
|
|
88
|
+
export declare function selectListTheme(): SelectListTheme;
|
|
89
|
+
export {};
|
|
30
90
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/repl/tui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAyBxE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,gBAAgB,CAAC;AAGzC,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,UAAO,GAAG,MAAM,CAMjF;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,8DAA8D;AAC9D,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExC;AAED,mDAAmD;AACnD,wBAAgB,WAAW,IAAI,WAAW,CAWzC"}
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/repl/tui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAyBxE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,6EAA6E;AAC7E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C;AAKD,wBAAgB,cAAc,IAAI,WAAW,CAI5C;AAeD,uEAAuE;AACvE,wBAAgB,eAAe,IAAI,eAAe,CAajD"}
|
package/dist/repl/tui/theme.js
CHANGED
|
@@ -78,4 +78,146 @@ export function editorTheme() {
|
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Pi's theme system, adopted for the component layer.
|
|
83
|
+
*
|
|
84
|
+
* Markdown and editor themes come from pi so prose and the input box match the
|
|
85
|
+
* application the user already runs (`getMarkdownTheme`/`getEditorTheme` are
|
|
86
|
+
* resolved against pi's active theme). Our own chrome is styled through pi-tui's
|
|
87
|
+
* `styleText`, which converts to the terminal's colour mode for us, so the
|
|
88
|
+
* palette below is *colours* rather than pre-baked escape sequences.
|
|
89
|
+
*
|
|
90
|
+
* `initTheme()` is best-effort: if pi's theme files are unreadable the SDK still
|
|
91
|
+
* renders, with the fallbacks below.
|
|
92
|
+
*/
|
|
93
|
+
import { getTerminalColorMode, indexedColor, styleText, } from '@earendil-works/pi-tui';
|
|
94
|
+
import { getMarkdownTheme, getSelectListTheme, initTheme } from '@earendil-works/pi-coding-agent';
|
|
95
|
+
let themeInitialized = false;
|
|
96
|
+
/** Load pi's active theme once. Never throws: a missing theme is not fatal. */
|
|
97
|
+
export function initTuiTheme() {
|
|
98
|
+
if (themeInitialized)
|
|
99
|
+
return;
|
|
100
|
+
themeInitialized = true;
|
|
101
|
+
try {
|
|
102
|
+
initTheme();
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// pi's theme is a nicety; the fallbacks below cover a missing theme.
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Palette entries, as colours so pi-tui owns the escape-sequence conversion. */
|
|
109
|
+
const C = {
|
|
110
|
+
accent: indexedColor(75),
|
|
111
|
+
border: indexedColor(75),
|
|
112
|
+
borderMuted: indexedColor(240),
|
|
113
|
+
title: indexedColor(180),
|
|
114
|
+
muted: indexedColor(245),
|
|
115
|
+
dim: indexedColor(240),
|
|
116
|
+
success: indexedColor(114),
|
|
117
|
+
error: indexedColor(203),
|
|
118
|
+
warning: indexedColor(214),
|
|
119
|
+
output: indexedColor(150),
|
|
120
|
+
thinking: indexedColor(245),
|
|
121
|
+
};
|
|
122
|
+
/** Style text with a semantic colour, honouring the terminal's colour mode. */
|
|
123
|
+
export function paintToken(token, text, extra) {
|
|
124
|
+
return styleText(text, { fg: C[token], ...extra }, getTerminalColorMode());
|
|
125
|
+
}
|
|
126
|
+
/** Convenience wrappers for the tokens the components use most. */
|
|
127
|
+
export const tuiStyle = {
|
|
128
|
+
accent: (text) => paintToken('accent', text),
|
|
129
|
+
title: (text) => paintToken('title', text, { bold: true }),
|
|
130
|
+
muted: (text) => paintToken('muted', text),
|
|
131
|
+
dim: (text) => paintToken('dim', text),
|
|
132
|
+
success: (text) => paintToken('success', text),
|
|
133
|
+
error: (text) => paintToken('error', text),
|
|
134
|
+
warning: (text) => paintToken('warning', text),
|
|
135
|
+
output: (text) => paintToken('output', text),
|
|
136
|
+
thinking: (text) => paintToken('thinking', text, { italic: true }),
|
|
137
|
+
borderMuted: (text) => paintToken('borderMuted', text),
|
|
138
|
+
};
|
|
139
|
+
/** Scrollbar colours for the transcript's `ScrollView`. */
|
|
140
|
+
export const scrollbarStyles = {
|
|
141
|
+
track: (text) => paintToken('borderMuted', text),
|
|
142
|
+
thumb: (text) => paintToken('accent', text),
|
|
143
|
+
};
|
|
144
|
+
/** Fallback markdown theme, used only if pi's cannot be resolved. */
|
|
145
|
+
function fallbackMarkdownTheme() {
|
|
146
|
+
const id = (text) => text;
|
|
147
|
+
return {
|
|
148
|
+
heading: tuiStyle.title,
|
|
149
|
+
link: tuiStyle.accent,
|
|
150
|
+
linkUrl: tuiStyle.dim,
|
|
151
|
+
code: tuiStyle.output,
|
|
152
|
+
codeBlock: tuiStyle.output,
|
|
153
|
+
codeBlockBorder: tuiStyle.dim,
|
|
154
|
+
quote: tuiStyle.muted,
|
|
155
|
+
quoteBorder: tuiStyle.dim,
|
|
156
|
+
hr: tuiStyle.dim,
|
|
157
|
+
listBullet: tuiStyle.accent,
|
|
158
|
+
bold: (text) => paintToken('title', text, { bold: true }),
|
|
159
|
+
italic: (text) => paintToken('thinking', text, { italic: true }),
|
|
160
|
+
strikethrough: id,
|
|
161
|
+
underline: id,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
let cachedMarkdownTheme;
|
|
165
|
+
/**
|
|
166
|
+
* Markdown theme: pi's, so prose matches the rest of the user's terminal. The
|
|
167
|
+
* import is synchronous because this is called from render paths, and pi is
|
|
168
|
+
* already a hard dependency (compaction uses it).
|
|
169
|
+
*/
|
|
170
|
+
export function markdownTheme() {
|
|
171
|
+
if (cachedMarkdownTheme)
|
|
172
|
+
return cachedMarkdownTheme;
|
|
173
|
+
try {
|
|
174
|
+
// pi's theme functions are lazy: they throw on *use* when the theme was
|
|
175
|
+
// never initialized, so probe one rather than trusting the getter.
|
|
176
|
+
initTuiTheme();
|
|
177
|
+
const theme = getMarkdownTheme();
|
|
178
|
+
theme.heading('probe');
|
|
179
|
+
cachedMarkdownTheme = theme;
|
|
180
|
+
return theme;
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
cachedMarkdownTheme = fallbackMarkdownTheme();
|
|
184
|
+
return cachedMarkdownTheme;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** Editor theme: pi's if available, else the SDK's existing one. */
|
|
188
|
+
let cachedEditorTheme;
|
|
189
|
+
export function tuiEditorTheme() {
|
|
190
|
+
if (cachedEditorTheme)
|
|
191
|
+
return cachedEditorTheme;
|
|
192
|
+
cachedEditorTheme = editorTheme();
|
|
193
|
+
return cachedEditorTheme;
|
|
194
|
+
}
|
|
195
|
+
/** Fallback list theme, used only if pi's cannot be resolved. */
|
|
196
|
+
function fallbackSelectListTheme() {
|
|
197
|
+
return {
|
|
198
|
+
selectedPrefix: (text) => tuiStyle.accent(text),
|
|
199
|
+
selectedText: (text) => paintToken('title', text, { bold: true }),
|
|
200
|
+
description: (text) => tuiStyle.dim(text),
|
|
201
|
+
scrollInfo: (text) => tuiStyle.dim(text),
|
|
202
|
+
noMatch: (text) => tuiStyle.dim(text),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
let cachedSelectListTheme;
|
|
206
|
+
/** Selection-list theme: pi's, so pickers look like the rest of pi. */
|
|
207
|
+
export function selectListTheme() {
|
|
208
|
+
if (cachedSelectListTheme)
|
|
209
|
+
return cachedSelectListTheme;
|
|
210
|
+
try {
|
|
211
|
+
initTuiTheme();
|
|
212
|
+
const theme = getSelectListTheme();
|
|
213
|
+
// pi's theme functions are lazy and throw when the theme was never initialized.
|
|
214
|
+
theme.selectedPrefix('probe');
|
|
215
|
+
cachedSelectListTheme = theme;
|
|
216
|
+
return theme;
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
cachedSelectListTheme = fallbackSelectListTheme();
|
|
220
|
+
return cachedSelectListTheme;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
81
223
|
//# sourceMappingURL=theme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../../src/repl/tui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAoB,MAAM,wBAAwB,CAAC;AAExE,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,YAAY;IACpB,uDAAuD;IACvD,MAAM,EAAE,iBAAiB;IACzB,iEAAiE;IACjE,MAAM,EAAE,kBAAkB;IAC1B,iEAAiE;IACjE,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,kBAAkB;IAC1B,kFAAkF;IAClF,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,kBAAkB;IAC3B,OAAO,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CAAC,IAAI,CAAC;QACjD,UAAU,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;QAChD,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;KAC9C,CAAC;AACJ,CAAC;AAED,IAAI,qBAAkD,CAAC;AAEvD,uEAAuE;AACvE,MAAM,UAAU,eAAe;IAC7B,IAAI,qBAAqB;QAAE,OAAO,qBAAqB,CAAC;IACxD,IAAI,CAAC;QACH,YAAY,EAAE,CAAC;QACf,MAAM,KAAK,GAAG,kBAAkB,EAAE,CAAC;QACnC,gFAAgF;QAChF,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC9B,qBAAqB,GAAG,KAAK,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,qBAAqB,GAAG,uBAAuB,EAAE,CAAC;QAClD,OAAO,qBAAqB,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tool-call pane for the fullscreen TUI.
|
|
3
|
+
*
|
|
4
|
+
* Modelled on Pi's tool panes, but built for our tools rather than Pi's tool
|
|
5
|
+
* model: `execute` (a goal and its bindings), `bash` (command, captured output,
|
|
6
|
+
* exit code, duration), `listing`, `visualize`, and the DML runtime's own tools.
|
|
7
|
+
*
|
|
8
|
+
* Collapsed by default — a tool call is usually a one-line event, and the detail
|
|
9
|
+
* is only wanted when something looks wrong. The last pane can be expanded with a
|
|
10
|
+
* keybinding (see `toggleLastPane` in the renderer).
|
|
11
|
+
*/
|
|
12
|
+
import { type Component } from '@earendil-works/pi-tui';
|
|
13
|
+
export type ToolPaneState = 'running' | 'ok' | 'failed';
|
|
14
|
+
export interface DmlToolPaneOptions {
|
|
15
|
+
toolName: string;
|
|
16
|
+
args: Record<string, unknown>;
|
|
17
|
+
/** Inline `execute`: show the goal, and keep the pane tight. */
|
|
18
|
+
compact?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The frame's indentation (`framePrefix`), so a pane inside a nested frame hangs
|
|
21
|
+
* where the surrounding output does. Every line the pane emits starts with it.
|
|
22
|
+
*/
|
|
23
|
+
prefix?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare class DmlToolPane implements Component {
|
|
26
|
+
private readonly toolName;
|
|
27
|
+
private args;
|
|
28
|
+
private state;
|
|
29
|
+
private failure?;
|
|
30
|
+
private result?;
|
|
31
|
+
private expanded;
|
|
32
|
+
private elapsedMs?;
|
|
33
|
+
private readonly compact;
|
|
34
|
+
private prefix;
|
|
35
|
+
private cachedWidth?;
|
|
36
|
+
private cachedLines?;
|
|
37
|
+
constructor(options: DmlToolPaneOptions);
|
|
38
|
+
/** Re-indent the pane (a frame's depth is only known once its output arrives). */
|
|
39
|
+
setPrefix(prefix: string): void;
|
|
40
|
+
setArgs(args: Record<string, unknown>): void;
|
|
41
|
+
setResult(result: unknown, success: boolean, elapsedMs?: number): void;
|
|
42
|
+
setExpanded(expanded: boolean): void;
|
|
43
|
+
toggle(): void;
|
|
44
|
+
get isExpanded(): boolean;
|
|
45
|
+
/** One-line summary for a bounded list, e.g. `bash — printf hello`. */
|
|
46
|
+
get summary(): string;
|
|
47
|
+
private invalidateCache;
|
|
48
|
+
invalidate(): void;
|
|
49
|
+
/** The interesting argument, rendered as one short line. */
|
|
50
|
+
private bodyLines;
|
|
51
|
+
/** Result text, split into lines: stdout/stderr, bindings, or an error. */
|
|
52
|
+
private resultLines;
|
|
53
|
+
render(width: number): string[];
|
|
54
|
+
private renderLines;
|
|
55
|
+
/** Wrap a styled string to `width`, prefixing continuation lines. */
|
|
56
|
+
private wrap;
|
|
57
|
+
}
|
|
58
|
+
/** A plain text block component, so callers can append text as a component. */
|
|
59
|
+
export declare class TextBlock implements Component {
|
|
60
|
+
private readonly text;
|
|
61
|
+
constructor(value: string, paddingX?: number);
|
|
62
|
+
setText(value: string): void;
|
|
63
|
+
render(width: number): string[];
|
|
64
|
+
invalidate(): void;
|
|
65
|
+
}
|
|
66
|
+
/** A bounded single-line text component (for long binding values). */
|
|
67
|
+
export declare function truncated(value: string): Component;
|
|
68
|
+
//# sourceMappingURL=tool-pane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-pane.d.ts","sourceRoot":"","sources":["../../../src/repl/tui/tool-pane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,wBAAwB,CAAC;AAIhC,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,IAAI,GAAG,QAAQ,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAKD,qBAAa,WAAY,YAAW,SAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,IAAI,CAA0B;IACtC,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,MAAM,CAAC,CAAU;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,WAAW,CAAC,CAAW;gBAEnB,OAAO,EAAE,kBAAkB;IAOvC,kFAAkF;IAClF,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAM/B,OAAO,CAAC,IAAI,EAAE,MAAM,CA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