@visual-z/xeno 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +498 -0
- package/docs/install.md +130 -0
- package/package.json +43 -0
- package/src/apps/approve.ts +49 -0
- package/src/apps/cli.ts +37 -0
- package/src/apps/commands.ts +226 -0
- package/src/apps/completions.ts +28 -0
- package/src/apps/input.ts +297 -0
- package/src/apps/render.ts +207 -0
- package/src/apps/shell.ts +2353 -0
- package/src/apps/startup.ts +1302 -0
- package/src/core/benchmark.ts +195 -0
- package/src/core/boundary.ts +174 -0
- package/src/core/churn.ts +59 -0
- package/src/core/completion-review.ts +66 -0
- package/src/core/context-policy.ts +60 -0
- package/src/core/context-window.ts +54 -0
- package/src/core/continuation.ts +114 -0
- package/src/core/cycle.ts +17 -0
- package/src/core/data-query.ts +201 -0
- package/src/core/deadline.ts +39 -0
- package/src/core/derive.ts +489 -0
- package/src/core/edit-plan.ts +200 -0
- package/src/core/environment.ts +29 -0
- package/src/core/event-validation.ts +99 -0
- package/src/core/events.ts +486 -0
- package/src/core/evidence-links.ts +71 -0
- package/src/core/evidence.ts +89 -0
- package/src/core/execution.ts +12 -0
- package/src/core/exhaustive.ts +18 -0
- package/src/core/experiment.ts +40 -0
- package/src/core/export.ts +169 -0
- package/src/core/file-references.ts +35 -0
- package/src/core/frontmatter.ts +213 -0
- package/src/core/handoff.ts +397 -0
- package/src/core/harness-comparison.ts +90 -0
- package/src/core/history-query.ts +103 -0
- package/src/core/history.ts +100 -0
- package/src/core/json-event.ts +135 -0
- package/src/core/json-pointer.ts +46 -0
- package/src/core/keymap.ts +241 -0
- package/src/core/observation-view.ts +87 -0
- package/src/core/outcome.ts +45 -0
- package/src/core/overflow.ts +59 -0
- package/src/core/permissions.ts +182 -0
- package/src/core/policy-evaluation.ts +55 -0
- package/src/core/progress.ts +101 -0
- package/src/core/project.ts +372 -0
- package/src/core/prompts.ts +83 -0
- package/src/core/queue.ts +60 -0
- package/src/core/read-bounds.ts +15 -0
- package/src/core/recall-analysis.ts +90 -0
- package/src/core/recall-trial.ts +153 -0
- package/src/core/response-recovery.ts +46 -0
- package/src/core/scheduling.ts +8 -0
- package/src/core/settings.ts +174 -0
- package/src/core/skills.ts +121 -0
- package/src/core/stall.ts +48 -0
- package/src/core/text-normalize.ts +81 -0
- package/src/core/theme.ts +179 -0
- package/src/core/tokens.ts +149 -0
- package/src/core/tool-contract.ts +102 -0
- package/src/core/tool-input.ts +38 -0
- package/src/core/transcript.ts +60 -0
- package/src/core/window-trial.ts +65 -0
- package/src/core/work-state.ts +103 -0
- package/src/core/yaml.ts +282 -0
- package/src/index.ts +10 -0
- package/src/runtime/auth.ts +255 -0
- package/src/runtime/benchmark.ts +187 -0
- package/src/runtime/catalog.ts +365 -0
- package/src/runtime/evidence-notes.ts +33 -0
- package/src/runtime/exec-sessions.ts +214 -0
- package/src/runtime/execution-control.ts +39 -0
- package/src/runtime/harness-comparison.ts +356 -0
- package/src/runtime/history-tools.ts +108 -0
- package/src/runtime/loop.ts +1983 -0
- package/src/runtime/model.ts +614 -0
- package/src/runtime/models-fetch.ts +155 -0
- package/src/runtime/oauth-device.ts +86 -0
- package/src/runtime/oauth.ts +759 -0
- package/src/runtime/openai-responses.ts +286 -0
- package/src/runtime/openai.ts +675 -0
- package/src/runtime/provider.ts +498 -0
- package/src/runtime/recall-trial.ts +226 -0
- package/src/runtime/resume.ts +66 -0
- package/src/runtime/retry.ts +297 -0
- package/src/runtime/tools.ts +1193 -0
- package/src/runtime/usage.ts +225 -0
- package/src/runtime/window-trial.ts +140 -0
- package/src/runtime/working-notes.ts +30 -0
- package/src/store/atomic.ts +31 -0
- package/src/store/auth-store.ts +50 -0
- package/src/store/blobs.ts +142 -0
- package/src/store/command.ts +75 -0
- package/src/store/config.ts +69 -0
- package/src/store/context-files.ts +356 -0
- package/src/store/file-index.ts +81 -0
- package/src/store/git-branch.ts +35 -0
- package/src/store/history-search.ts +19 -0
- package/src/store/log.ts +642 -0
- package/src/store/models.ts +41 -0
- package/src/store/observations.ts +181 -0
- package/src/store/query-source.ts +44 -0
- package/src/store/recovery.ts +39 -0
- package/src/store/replay.ts +63 -0
- package/src/store/resources.ts +361 -0
- package/src/store/restore.ts +302 -0
- package/src/store/search.ts +644 -0
- package/src/store/serial.ts +13 -0
- package/src/store/sessions.ts +463 -0
- package/src/store/trust.ts +69 -0
- package/src/store/workspace.ts +256 -0
- package/src/store/worktree.ts +233 -0
- package/src/tui/ansi.ts +67 -0
- package/src/tui/autocomplete.ts +29 -0
- package/src/tui/complete.ts +87 -0
- package/src/tui/diff.ts +160 -0
- package/src/tui/editor.ts +893 -0
- package/src/tui/exhaustive.ts +14 -0
- package/src/tui/fuzzy.ts +75 -0
- package/src/tui/host.ts +223 -0
- package/src/tui/input.ts +69 -0
- package/src/tui/keys.ts +378 -0
- package/src/tui/markdown.ts +17 -0
- package/src/tui/render.ts +153 -0
- package/src/tui/select.ts +240 -0
- package/src/tui/settings.ts +40 -0
- package/src/tui/statusline.ts +162 -0
- package/src/tui/style.ts +205 -0
- package/src/tui/terminal.ts +30 -0
- package/src/tui/text.ts +52 -0
- package/src/tui/toolview.ts +386 -0
- package/src/tui/transcript.ts +71 -0
- package/src/tui/tree.ts +405 -0
- package/src/tui/width.ts +567 -0
- package/src/vendor/pi-tui/LICENSE.upstream +21 -0
- package/src/vendor/pi-tui/VENDOR.md +23 -0
- package/src/vendor/pi-tui/alt-screen-search.ts +327 -0
- package/src/vendor/pi-tui/autocomplete.ts +835 -0
- package/src/vendor/pi-tui/components/alt-screen-flash.ts +51 -0
- package/src/vendor/pi-tui/components/box.ts +167 -0
- package/src/vendor/pi-tui/components/cancellable-loader.ts +40 -0
- package/src/vendor/pi-tui/components/editor.ts +2470 -0
- package/src/vendor/pi-tui/components/h-stack.ts +44 -0
- package/src/vendor/pi-tui/components/image.ts +127 -0
- package/src/vendor/pi-tui/components/input.ts +494 -0
- package/src/vendor/pi-tui/components/loader.ts +101 -0
- package/src/vendor/pi-tui/components/markdown.ts +1015 -0
- package/src/vendor/pi-tui/components/mouse-region.ts +33 -0
- package/src/vendor/pi-tui/components/scroll-view.ts +224 -0
- package/src/vendor/pi-tui/components/select-list.ts +273 -0
- package/src/vendor/pi-tui/components/settings-list.ts +328 -0
- package/src/vendor/pi-tui/components/spacer.ts +28 -0
- package/src/vendor/pi-tui/components/stack.ts +154 -0
- package/src/vendor/pi-tui/components/text.ts +107 -0
- package/src/vendor/pi-tui/components/truncated-text.ts +65 -0
- package/src/vendor/pi-tui/components/v-stack.ts +33 -0
- package/src/vendor/pi-tui/editor-component.ts +74 -0
- package/src/vendor/pi-tui/fuzzy.ts +138 -0
- package/src/vendor/pi-tui/index.ts +156 -0
- package/src/vendor/pi-tui/keybindings.ts +320 -0
- package/src/vendor/pi-tui/keys.ts +1401 -0
- package/src/vendor/pi-tui/kill-ring.ts +46 -0
- package/src/vendor/pi-tui/latex.ts +1506 -0
- package/src/vendor/pi-tui/layout-node.ts +51 -0
- package/src/vendor/pi-tui/layout.ts +449 -0
- package/src/vendor/pi-tui/native-modifiers.ts +13 -0
- package/src/vendor/pi-tui/native-module-path.ts +31 -0
- package/src/vendor/pi-tui/native-platform.ts +63 -0
- package/src/vendor/pi-tui/stdin-buffer.ts +444 -0
- package/src/vendor/pi-tui/terminal-colors.ts +73 -0
- package/src/vendor/pi-tui/terminal-image.ts +696 -0
- package/src/vendor/pi-tui/terminal.ts +547 -0
- package/src/vendor/pi-tui/tui-alt-screen.ts +1742 -0
- package/src/vendor/pi-tui/tui-main-screen.ts +655 -0
- package/src/vendor/pi-tui/tui.ts +1456 -0
- package/src/vendor/pi-tui/undo-stack.ts +28 -0
- package/src/vendor/pi-tui/utils.ts +1345 -0
- package/src/vendor/pi-tui/word-navigation.ts +117 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Component } from "../tui.ts";
|
|
2
|
+
import { truncateToWidth } from "../utils.ts";
|
|
3
|
+
|
|
4
|
+
const DEFAULT_DURATION_MS = 1000;
|
|
5
|
+
|
|
6
|
+
interface FlashEntry {
|
|
7
|
+
id: number;
|
|
8
|
+
message: string;
|
|
9
|
+
timer: NodeJS.Timeout;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Transient messages composited by the alternate-screen renderer. */
|
|
13
|
+
export class AltScreenFlashContainer implements Component {
|
|
14
|
+
private readonly entries: FlashEntry[] = [];
|
|
15
|
+
private nextId = 0;
|
|
16
|
+
private readonly requestRender: () => void;
|
|
17
|
+
|
|
18
|
+
constructor(requestRender: () => void) {
|
|
19
|
+
this.requestRender = requestRender;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
flash(message: string, durationMs = DEFAULT_DURATION_MS): void {
|
|
23
|
+
const id = this.nextId++;
|
|
24
|
+
const timer = setTimeout(
|
|
25
|
+
() => {
|
|
26
|
+
const index = this.entries.findIndex((entry) => entry.id === id);
|
|
27
|
+
if (index === -1) return;
|
|
28
|
+
this.entries.splice(index, 1);
|
|
29
|
+
this.requestRender();
|
|
30
|
+
},
|
|
31
|
+
Math.max(0, durationMs),
|
|
32
|
+
);
|
|
33
|
+
timer.unref();
|
|
34
|
+
this.entries.push({ id, message, timer });
|
|
35
|
+
this.requestRender();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
dispose(): void {
|
|
39
|
+
for (const entry of this.entries) clearTimeout(entry.timer);
|
|
40
|
+
this.entries.length = 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
invalidate(): void {}
|
|
44
|
+
|
|
45
|
+
render(width: number): string[] {
|
|
46
|
+
return this.entries.map((entry) => {
|
|
47
|
+
const message = truncateToWidth(` ${entry.message} `, width, "");
|
|
48
|
+
return `\x1b[7m${message}\x1b[27m`;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { type Component, dispatchMouseEvent, type TuiMouseDispatchResult, type TuiMouseEvent } from "../tui.ts";
|
|
2
|
+
import { applyBackgroundToLine, visibleWidth } from "../utils.ts";
|
|
3
|
+
|
|
4
|
+
type RenderCache = {
|
|
5
|
+
childLines: string[];
|
|
6
|
+
width: number;
|
|
7
|
+
bgSample: string | undefined;
|
|
8
|
+
lines: string[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Box component - a container that applies padding and background to all children
|
|
13
|
+
*/
|
|
14
|
+
export class Box implements Component {
|
|
15
|
+
children: Component[] = [];
|
|
16
|
+
private paddingX: number;
|
|
17
|
+
private paddingY: number;
|
|
18
|
+
private bgFn?: (text: string) => string;
|
|
19
|
+
|
|
20
|
+
// Cache for rendered output
|
|
21
|
+
private cache?: RenderCache;
|
|
22
|
+
private mouseLayout?: { width: number; children: Array<{ component: Component; height: number }> };
|
|
23
|
+
|
|
24
|
+
constructor(paddingX = 1, paddingY = 1, bgFn?: (text: string) => string) {
|
|
25
|
+
this.paddingX = paddingX;
|
|
26
|
+
this.paddingY = paddingY;
|
|
27
|
+
this.bgFn = bgFn;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
addChild(component: Component): void {
|
|
31
|
+
this.children.push(component);
|
|
32
|
+
this.invalidateCache();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
removeChild(component: Component): void {
|
|
36
|
+
const index = this.children.indexOf(component);
|
|
37
|
+
if (index !== -1) {
|
|
38
|
+
this.children.splice(index, 1);
|
|
39
|
+
this.invalidateCache();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
clear(): void {
|
|
44
|
+
this.children = [];
|
|
45
|
+
this.invalidateCache();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setBgFn(bgFn?: (text: string) => string): void {
|
|
49
|
+
this.bgFn = bgFn;
|
|
50
|
+
// Don't invalidate here - we'll detect bgFn changes by sampling output
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private invalidateCache(): void {
|
|
54
|
+
this.cache = undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private matchCache(width: number, childLines: string[], bgSample: string | undefined): boolean {
|
|
58
|
+
const cache = this.cache;
|
|
59
|
+
return (
|
|
60
|
+
!!cache &&
|
|
61
|
+
cache.width === width &&
|
|
62
|
+
cache.bgSample === bgSample &&
|
|
63
|
+
cache.childLines.length === childLines.length &&
|
|
64
|
+
cache.childLines.every((line, i) => line === childLines[i])
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
invalidate(): void {
|
|
69
|
+
this.invalidateCache();
|
|
70
|
+
for (const child of this.children) {
|
|
71
|
+
child.invalidate?.();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
handleMouse(event: TuiMouseEvent): TuiMouseDispatchResult | undefined {
|
|
76
|
+
const contentWidth = Math.max(1, event.width - this.paddingX * 2);
|
|
77
|
+
const contentY = event.y - this.paddingY;
|
|
78
|
+
const contentX = event.x - this.paddingX;
|
|
79
|
+
if (contentY < 0 || contentX < 0 || contentX >= contentWidth) return undefined;
|
|
80
|
+
|
|
81
|
+
const mouseChildren =
|
|
82
|
+
this.mouseLayout?.width === contentWidth
|
|
83
|
+
? this.mouseLayout.children
|
|
84
|
+
: this.children.map((component) => ({ component, height: component.render(contentWidth).length }));
|
|
85
|
+
let childY = 0;
|
|
86
|
+
for (const { component: child, height: childHeight } of mouseChildren) {
|
|
87
|
+
if (contentY >= childY && contentY < childY + childHeight) {
|
|
88
|
+
return dispatchMouseEvent(child, {
|
|
89
|
+
...event,
|
|
90
|
+
x: contentX,
|
|
91
|
+
y: contentY - childY,
|
|
92
|
+
width: contentWidth,
|
|
93
|
+
height: childHeight,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
childY += childHeight;
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
render(width: number): string[] {
|
|
102
|
+
if (this.children.length === 0) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const contentWidth = Math.max(1, width - this.paddingX * 2);
|
|
107
|
+
const leftPad = " ".repeat(this.paddingX);
|
|
108
|
+
|
|
109
|
+
// Render all children
|
|
110
|
+
const childLines: string[] = [];
|
|
111
|
+
const mouseChildren: Array<{ component: Component; height: number }> = [];
|
|
112
|
+
for (const child of this.children) {
|
|
113
|
+
const lines = child.render(contentWidth);
|
|
114
|
+
mouseChildren.push({ component: child, height: lines.length });
|
|
115
|
+
for (const line of lines) {
|
|
116
|
+
childLines.push(leftPad + line);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
this.mouseLayout = { width: contentWidth, children: mouseChildren };
|
|
120
|
+
|
|
121
|
+
if (childLines.length === 0) {
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Check if bgFn output changed by sampling
|
|
126
|
+
const bgSample = this.bgFn ? this.bgFn("test") : undefined;
|
|
127
|
+
|
|
128
|
+
// Check cache validity
|
|
129
|
+
if (this.matchCache(width, childLines, bgSample)) {
|
|
130
|
+
return this.cache!.lines;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Apply background and padding
|
|
134
|
+
const result: string[] = [];
|
|
135
|
+
|
|
136
|
+
// Top padding
|
|
137
|
+
for (let i = 0; i < this.paddingY; i++) {
|
|
138
|
+
result.push(this.applyBg("", width));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Content
|
|
142
|
+
for (const line of childLines) {
|
|
143
|
+
result.push(this.applyBg(line, width));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Bottom padding
|
|
147
|
+
for (let i = 0; i < this.paddingY; i++) {
|
|
148
|
+
result.push(this.applyBg("", width));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Update cache
|
|
152
|
+
this.cache = { childLines, width, bgSample, lines: result };
|
|
153
|
+
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private applyBg(line: string, width: number): string {
|
|
158
|
+
const visLen = visibleWidth(line);
|
|
159
|
+
const padNeeded = Math.max(0, width - visLen);
|
|
160
|
+
const padded = line + " ".repeat(padNeeded);
|
|
161
|
+
|
|
162
|
+
if (this.bgFn) {
|
|
163
|
+
return applyBackgroundToLine(padded, width, this.bgFn);
|
|
164
|
+
}
|
|
165
|
+
return padded;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getKeybindings } from "../keybindings.ts";
|
|
2
|
+
import { Loader } from "./loader.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Loader that can be cancelled with Escape.
|
|
6
|
+
* Extends Loader with an AbortSignal for cancelling async operations.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const loader = new CancellableLoader(tui, cyan, dim, "Working...");
|
|
10
|
+
* loader.onAbort = () => done(null);
|
|
11
|
+
* doWork(loader.signal).then(done);
|
|
12
|
+
*/
|
|
13
|
+
export class CancellableLoader extends Loader {
|
|
14
|
+
private abortController = new AbortController();
|
|
15
|
+
|
|
16
|
+
/** Called when user presses Escape */
|
|
17
|
+
onAbort?: () => void;
|
|
18
|
+
|
|
19
|
+
/** AbortSignal that is aborted when user presses Escape */
|
|
20
|
+
get signal(): AbortSignal {
|
|
21
|
+
return this.abortController.signal;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Whether the loader was aborted */
|
|
25
|
+
get aborted(): boolean {
|
|
26
|
+
return this.abortController.signal.aborted;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
handleInput(data: string): void {
|
|
30
|
+
const kb = getKeybindings();
|
|
31
|
+
if (kb.matches(data, "tui.select.cancel")) {
|
|
32
|
+
this.abortController.abort();
|
|
33
|
+
this.onAbort?.();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
dispose(): void {
|
|
38
|
+
this.stop();
|
|
39
|
+
}
|
|
40
|
+
}
|