klyro 0.1.59 → 0.1.61
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/READ.md +1 -1
- package/dist/agent/anthropic-adapter.js +1 -1
- package/dist/cli/repl.js +27 -13
- package/dist/context/klyro-md.js +1 -1
- package/dist/tui/app.test.js +2 -2
- package/dist/tui/mouse.d.ts +10 -0
- package/dist/tui/mouse.js +29 -0
- package/dist/tui/snapshot.test.js +3 -3
- package/package.json +1 -1
package/READ.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|-------|--------|-----|
|
|
23
23
|
| Language | TypeScript 5.5, Node 20+ | Strict, `NodeNext`, `tsc` → `dist/` |
|
|
24
24
|
| CLI | `commander 12.1` | Stable, `InvalidArgumentError` for `exit 2` |
|
|
25
|
-
| TUI | `ink 7.1` + `react 19` + `ink-spinner 5` | React for terminal
|
|
25
|
+
| TUI | `ink 7.1` + `react 19` + `ink-spinner 5` | React renderer for the terminal |
|
|
26
26
|
| Schema | `zod 4.5` | Tool input validation + config schema |
|
|
27
27
|
| Test | `vitest 4.1` `fileParallelism:false` `10s timeout` | `node` env, deterministic mocks |
|
|
28
28
|
| Build | `tsc` (not `tsup`) | `tsc --noEmit` `typecheck`, `tsc` `build` |
|
|
@@ -106,7 +106,7 @@ async function* streamAnthropic(req, opts) {
|
|
|
106
106
|
}
|
|
107
107
|
yield { kind: 'message_start' };
|
|
108
108
|
// Stream SSE: lines are `event: <type>\ndata: <json>\n\n`.
|
|
109
|
-
// We use a simple incremental parser;
|
|
109
|
+
// We use a simple incremental parser; Anthropic's API guarantees
|
|
110
110
|
// well-formed SSE.
|
|
111
111
|
const reader = resp.body.getReader();
|
|
112
112
|
const decoder = new TextDecoder('utf-8');
|
package/dist/cli/repl.js
CHANGED
|
@@ -21,7 +21,7 @@ import { TuiApprovalBridge } from '../tui/approval.js';
|
|
|
21
21
|
import { parseUnifiedDiff } from '../tui/diff-parser.js';
|
|
22
22
|
import { parse } from './slash/parser.js';
|
|
23
23
|
import { resolveProvider, providerHelp, lastProviderError } from '../providers.js';
|
|
24
|
-
import { MouseFilter, MOUSE_ENABLE, MOUSE_DISABLE } from '../tui/mouse.js';
|
|
24
|
+
import { MouseFilter, MOUSE_ENABLE, MOUSE_DISABLE, createReadWrapper } from '../tui/mouse.js';
|
|
25
25
|
import { inferProviderFromBaseURL } from '../agent/registry.js';
|
|
26
26
|
import { getDefaultSessionStore } from '../persistence/session.js';
|
|
27
27
|
import { buildSystemPrompt, parseImageInput } from '../context/system-prompt.js';
|
|
@@ -207,25 +207,37 @@ export async function startRepl(opts = {}) {
|
|
|
207
207
|
catch { /* ignore */ }
|
|
208
208
|
};
|
|
209
209
|
// OpenCode-style wheel scrolling (§8.5, S8): Ink owns stdin and cannot see
|
|
210
|
-
// mouse events, so
|
|
211
|
-
// hooks, everything else passes through to Ink untouched.
|
|
210
|
+
// mouse events, so intercept stdin reads — wheel deltas drive the App's
|
|
211
|
+
// scroll hooks, everything else passes through to Ink untouched.
|
|
212
|
+
//
|
|
213
|
+
// IMPORTANT: Ink 7 reads stdin via 'readable' + stdin.read() (paused mode),
|
|
214
|
+
// never 'data' events — so the tap wraps read(), not emit().
|
|
212
215
|
const mouseFilter = new MouseFilter();
|
|
216
|
+
const origStdinRead = process.stdin.read.bind(process.stdin);
|
|
213
217
|
const origStdinEmit = process.stdin.emit.bind(process.stdin);
|
|
214
218
|
let mouseTapInstalled = false;
|
|
219
|
+
function dispatchWheels(wheels) {
|
|
220
|
+
for (const w of wheels) {
|
|
221
|
+
try {
|
|
222
|
+
if (isMounted && directHooks)
|
|
223
|
+
directHooks.scrollLines(w);
|
|
224
|
+
}
|
|
225
|
+
catch { /* ignore */ }
|
|
226
|
+
}
|
|
227
|
+
}
|
|
215
228
|
function installMouseTap() {
|
|
216
229
|
if (!isAltScreen || mouseTapInstalled)
|
|
217
230
|
return;
|
|
218
231
|
mouseTapInstalled = true;
|
|
219
|
-
process.stdin
|
|
232
|
+
const stdinAny = process.stdin;
|
|
233
|
+
// Primary path: Ink's paused-mode read loop.
|
|
234
|
+
stdinAny.read = createReadWrapper(origStdinRead, mouseFilter, (d) => dispatchWheels([d]));
|
|
235
|
+
// Fallback path: flowing mode ('data' events), e.g. if any library
|
|
236
|
+
// resumes the stream. Same split, same dispatch.
|
|
237
|
+
stdinAny.emit = (...a) => {
|
|
220
238
|
if (a[0] === 'data' && Buffer.isBuffer(a[1])) {
|
|
221
239
|
const split = mouseFilter.push(a[1]);
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
if (isMounted && directHooks)
|
|
225
|
-
directHooks.scrollLines(w);
|
|
226
|
-
}
|
|
227
|
-
catch { /* ignore */ }
|
|
228
|
-
}
|
|
240
|
+
dispatchWheels(split.wheels);
|
|
229
241
|
if (split.kept.length === 0)
|
|
230
242
|
return false;
|
|
231
243
|
a[1] = split.kept;
|
|
@@ -238,7 +250,9 @@ export async function startRepl(opts = {}) {
|
|
|
238
250
|
return;
|
|
239
251
|
mouseTapInstalled = false;
|
|
240
252
|
mouseFilter.reset();
|
|
241
|
-
process.stdin
|
|
253
|
+
const stdinAny = process.stdin;
|
|
254
|
+
stdinAny.read = origStdinRead;
|
|
255
|
+
stdinAny.emit = origStdinEmit;
|
|
242
256
|
}
|
|
243
257
|
// Declare app before handler to avoid TDZ; handler added after render
|
|
244
258
|
let app;
|
|
@@ -519,7 +533,7 @@ export async function startRepl(opts = {}) {
|
|
|
519
533
|
const rec = await tuiStore.create({ cwd, task: taskText, config: { model, maxSteps: currentMaxSteps } });
|
|
520
534
|
sessionId = rec.id;
|
|
521
535
|
tuiSessionId = rec.id;
|
|
522
|
-
// Session info goes to status bar, not transcript (clean
|
|
536
|
+
// Session info goes to status bar, not transcript (clean Klyro transcript)
|
|
523
537
|
queuedStatus({ status: 'running', step: 0, model });
|
|
524
538
|
}
|
|
525
539
|
catch {
|
package/dist/context/klyro-md.js
CHANGED
|
@@ -37,7 +37,7 @@ export async function loadKlyroMd(cwd) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
// Root (imports resolved relative to each file, contained to cwd)
|
|
40
|
-
for (const name of ['KLYRO.md', 'KLYRO.local.md', 'AGENTS.md', '
|
|
40
|
+
for (const name of ['KLYRO.md', 'KLYRO.local.md', 'AGENTS.md', '.cursorrules']) {
|
|
41
41
|
const p = path.join(cwd, name);
|
|
42
42
|
try {
|
|
43
43
|
const t = await fs.readFile(p, 'utf-8');
|
package/dist/tui/app.test.js
CHANGED
|
@@ -6,8 +6,8 @@ describe('App', () => {
|
|
|
6
6
|
it('shows the empty-state hint and the status line', () => {
|
|
7
7
|
const { lastFrame } = render(_jsx(App, { initialModel: "mock", maxSteps: 10, cwd: "/test", onPrompt: async () => { }, onSlash: async () => { } }));
|
|
8
8
|
const out = lastFrame();
|
|
9
|
-
//
|
|
10
|
-
expect(out).toMatch(/
|
|
9
|
+
// Top bar shows KLYRO + sessions, center shows Message Klyro placeholder
|
|
10
|
+
expect(out).toMatch(/Sessions|Message Klyro/i);
|
|
11
11
|
expect(out).toMatch(/Message Klyro|Type a message/i);
|
|
12
12
|
});
|
|
13
13
|
it('renders initial transcript items', () => {
|
package/dist/tui/mouse.d.ts
CHANGED
|
@@ -34,3 +34,13 @@ export declare class MouseFilter {
|
|
|
34
34
|
}
|
|
35
35
|
export declare const MOUSE_ENABLE = "\u001B[?1000h\u001B[?1006h";
|
|
36
36
|
export declare const MOUSE_DISABLE = "\u001B[?1000l\u001B[?1006l";
|
|
37
|
+
/**
|
|
38
|
+
* stdin.read() wrapper implementing the tap (see repl.ts installMouseTap).
|
|
39
|
+
* Ink 7 consumes stdin via paused-mode read() calls, so filtering happens
|
|
40
|
+
* here — not on 'data' events (which never fire for Ink).
|
|
41
|
+
*
|
|
42
|
+
* Contract: sized reads pass through untouched; null passes through;
|
|
43
|
+
* mouse sequences are swallowed (wheels dispatched); everything else is
|
|
44
|
+
* returned byte-identical in its original string/Buffer shape.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createReadWrapper(origRead: (size?: number) => unknown, filter: MouseFilter, onWheel: (delta: number) => void): (size?: number) => unknown;
|
package/dist/tui/mouse.js
CHANGED
|
@@ -92,3 +92,32 @@ export class MouseFilter {
|
|
|
92
92
|
}
|
|
93
93
|
export const MOUSE_ENABLE = '\x1b[?1000h\x1b[?1006h'; // button events + SGR coords
|
|
94
94
|
export const MOUSE_DISABLE = '\x1b[?1000l\x1b[?1006l';
|
|
95
|
+
/**
|
|
96
|
+
* stdin.read() wrapper implementing the tap (see repl.ts installMouseTap).
|
|
97
|
+
* Ink 7 consumes stdin via paused-mode read() calls, so filtering happens
|
|
98
|
+
* here — not on 'data' events (which never fire for Ink).
|
|
99
|
+
*
|
|
100
|
+
* Contract: sized reads pass through untouched; null passes through;
|
|
101
|
+
* mouse sequences are swallowed (wheels dispatched); everything else is
|
|
102
|
+
* returned byte-identical in its original string/Buffer shape.
|
|
103
|
+
*/
|
|
104
|
+
export function createReadWrapper(origRead, filter, onWheel) {
|
|
105
|
+
return (size) => {
|
|
106
|
+
if (size !== undefined)
|
|
107
|
+
return origRead(size);
|
|
108
|
+
const chunk = origRead();
|
|
109
|
+
if (chunk == null)
|
|
110
|
+
return chunk;
|
|
111
|
+
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
112
|
+
const split = filter.push(buf);
|
|
113
|
+
for (const w of split.wheels) {
|
|
114
|
+
try {
|
|
115
|
+
onWheel(w);
|
|
116
|
+
}
|
|
117
|
+
catch { /* ignore */ }
|
|
118
|
+
}
|
|
119
|
+
if (split.kept.length === 0)
|
|
120
|
+
return null;
|
|
121
|
+
return typeof chunk === 'string' ? split.kept.toString('utf8') : split.kept;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -16,11 +16,11 @@ describe('App visual snapshot', () => {
|
|
|
16
16
|
it('renders header + statusline + transcript + input at idle', () => {
|
|
17
17
|
const { lastFrame } = render(_jsx(App, { ...DEFAULT_PROPS, initialModel: "gpt-4o-mini", maxSteps: 30, initialStatus: { status: 'idle', model: 'gpt-4o-mini', step: 0, maxSteps: 30, usageInput: 0, usageOutput: 0, repairs: 0 } }));
|
|
18
18
|
const frame = lastFrame();
|
|
19
|
-
//
|
|
20
|
-
expect(frame).toMatch(/
|
|
19
|
+
// Top bar shows KLYRO, transcript shows sessions/files context
|
|
20
|
+
expect(frame).toMatch(/KLYRO/i);
|
|
21
21
|
expect(frame).toMatch(/demo|Sessions|Files/i);
|
|
22
22
|
expect(frame).toMatch(/shift\+tab|for history|Message Klyro|Type a message/i);
|
|
23
|
-
expect(frame).toMatch(/Message Klyro
|
|
23
|
+
expect(frame).toMatch(/Message Klyro|>/i);
|
|
24
24
|
});
|
|
25
25
|
it('renders a transcript with assistant text', () => {
|
|
26
26
|
const { lastFrame } = render(_jsx(App, { ...DEFAULT_PROPS, initialModel: "gpt-4o-mini", maxSteps: 30, initialStatus: { status: 'idle', model: 'gpt-4o-mini', step: 0, maxSteps: 30, usageInput: 0, usageOutput: 0, repairs: 0 }, initialTranscript: [
|
package/package.json
CHANGED