koneck 2.128.56 → 2.128.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +11 -4
- package/dist/chat.js.map +1 -1
- package/dist/config-store.d.ts +2 -0
- package/dist/config-store.d.ts.map +1 -1
- package/dist/config-store.js +13 -1
- package/dist/config-store.js.map +1 -1
- package/dist/diff-layout.d.ts +120 -0
- package/dist/diff-layout.d.ts.map +1 -0
- package/dist/diff-layout.js +173 -0
- package/dist/diff-layout.js.map +1 -0
- package/dist/entry-screen.d.ts +58 -0
- package/dist/entry-screen.d.ts.map +1 -0
- package/dist/entry-screen.js +140 -0
- package/dist/entry-screen.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -5
- package/dist/index.js.map +1 -1
- package/dist/ink-chat.d.ts +17 -13
- package/dist/ink-chat.d.ts.map +1 -1
- package/dist/ink-chat.js +239 -142
- package/dist/ink-chat.js.map +1 -1
- package/dist/markdown-ink.d.ts.map +1 -1
- package/dist/markdown-ink.js +16 -6
- package/dist/markdown-ink.js.map +1 -1
- package/dist/session-changes.d.ts +1 -1
- package/dist/session-changes.d.ts.map +1 -1
- package/dist/session-changes.js +5 -2
- package/dist/session-changes.js.map +1 -1
- package/dist/status-line.d.ts +16 -0
- package/dist/status-line.d.ts.map +1 -1
- package/dist/status-line.js +9 -0
- package/dist/status-line.js.map +1 -1
- package/dist/theme.d.ts +98 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +174 -0
- package/dist/theme.js.map +1 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +17 -7
- package/dist/tui.js.map +1 -1
- package/dist/web/api.d.ts.map +1 -1
- package/dist/web/api.js +10 -0
- package/dist/web/api.js.map +1 -1
- package/dist/web/sessions.d.ts +6 -0
- package/dist/web/sessions.d.ts.map +1 -1
- package/dist/web/sessions.js +11 -0
- package/dist/web/sessions.js.map +1 -1
- package/dist/web/ui-client.d.ts.map +1 -1
- package/dist/web/ui-client.js +96 -17
- package/dist/web/ui-client.js.map +1 -1
- package/dist/web/ui-css.d.ts.map +1 -1
- package/dist/web/ui-css.js +19 -4
- package/dist/web/ui-css.js.map +1 -1
- package/dist/web/ui.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the diff panel is laid out, decided once for the terminal and the browser.
|
|
3
|
+
*
|
|
4
|
+
* Asked for with Claude Code's panel as the picture: a list of the changed files at the top, each
|
|
5
|
+
* with its own counts, tests and generated files folded into one line, and below a rule the one
|
|
6
|
+
* file being read — its changed lines on a band the full width of the panel, and a long line
|
|
7
|
+
* wrapped with its + or - carried onto each piece rather than cut off at the edge.
|
|
8
|
+
*
|
|
9
|
+
* The panel it replaced stacked every file's diff in one column. Fifteen files was a scroll through
|
|
10
|
+
* all of them to find the one wanted, and a line longer than the panel lost its end.
|
|
11
|
+
*
|
|
12
|
+
* Nothing here draws. It returns which files are listed, in what order, which is selected, and a
|
|
13
|
+
* diff broken into rows of a given width; each interface paints those in its own way. The browser
|
|
14
|
+
* wraps with CSS, so it uses the list and the fold and not the row wrapping.
|
|
15
|
+
*/
|
|
16
|
+
import { sliceToWidth, displayWidth } from './markdown-ink.js';
|
|
17
|
+
/** A diff longer than this is capped and the rest counted: a 4,000-line rewrite is not read in a panel. */
|
|
18
|
+
export const PANEL_DIFF_LINES = 400;
|
|
19
|
+
/** Lines of unchanged code kept around each change — what Claude Code's panel shows. */
|
|
20
|
+
export const PANEL_CONTEXT = 3;
|
|
21
|
+
/**
|
|
22
|
+
* Tests, lockfiles, build output and generated code: changes to review, but not first.
|
|
23
|
+
*
|
|
24
|
+
* Folded rather than hidden. A test that changed is part of the change — it is shown on request,
|
|
25
|
+
* and counted in the header either way.
|
|
26
|
+
*/
|
|
27
|
+
export function isTestOrGenerated(p) {
|
|
28
|
+
const f = p.replace(/\\/g, '/');
|
|
29
|
+
const name = f.split('/').pop() ?? f;
|
|
30
|
+
if (/(^|\/)(tests?|__tests__|__snapshots__|spec|e2e|fixtures)\//i.test(f))
|
|
31
|
+
return true;
|
|
32
|
+
if (/\.(test|spec)\.[^/]+$/i.test(name) || /_test\.(go|py|rb)$/i.test(name) || /^test_.*\.py$/i.test(name))
|
|
33
|
+
return true;
|
|
34
|
+
if (/(^|\/)(dist|build|out|coverage|generated|gen|vendor|node_modules)\//i.test(f))
|
|
35
|
+
return true;
|
|
36
|
+
if (/\.(min\.(js|css)|map|snap|lock)$/i.test(name) || /\.g\.[a-z]+$/i.test(name) || /\.generated\./i.test(name))
|
|
37
|
+
return true;
|
|
38
|
+
return /^(package-lock\.json|yarn\.lock|pnpm-lock\.yaml|composer\.lock|Cargo\.lock|poetry\.lock|Gemfile\.lock|go\.sum|bun\.lockb?)$/i.test(name);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The files in the order they are listed: the work first, in the order it was touched, then the
|
|
42
|
+
* tests and generated files after it.
|
|
43
|
+
*/
|
|
44
|
+
export function listFiles(files) {
|
|
45
|
+
const main = [];
|
|
46
|
+
const generated = [];
|
|
47
|
+
files.forEach((d, index) => {
|
|
48
|
+
const tag = d.binary ? 'binary' : d.created && d.removed === 0 ? 'new' : d.deleted ? 'deleted' : '';
|
|
49
|
+
const item = { path: d.path, added: d.added, removed: d.removed, tag, generated: isTestOrGenerated(d.path), index };
|
|
50
|
+
(item.generated ? generated : main).push(item);
|
|
51
|
+
});
|
|
52
|
+
return { main, generated };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The session's changes as plain data for the browser: listed in the terminal's order, with the
|
|
56
|
+
* fold decided, and each line with its number and sign. The browser chooses and wraps; it does not
|
|
57
|
+
* decide what is a test or which file comes first.
|
|
58
|
+
*/
|
|
59
|
+
export function panelData(files) {
|
|
60
|
+
const { main, generated } = listFiles(files);
|
|
61
|
+
const t = files.reduce((a, d) => ({ added: a.added + d.added, removed: a.removed + d.removed }), { added: 0, removed: 0 });
|
|
62
|
+
return {
|
|
63
|
+
files: files.length, ...t,
|
|
64
|
+
list: [...main, ...generated].map(f => {
|
|
65
|
+
const d = files[f.index];
|
|
66
|
+
return {
|
|
67
|
+
...f, binary: d.binary, hidden: d.hiddenLines,
|
|
68
|
+
lines: d.hunks.flatMap(h => h.lines.map(l => ({
|
|
69
|
+
k: l.kind, n: (l.kind === 'del' ? l.before : l.after) ?? null, t: l.text,
|
|
70
|
+
}))),
|
|
71
|
+
};
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The list as shown: which rows fit in `rows`, scrolled so the selected one is among them.
|
|
77
|
+
*
|
|
78
|
+
* `selected` is a position in the visible order — main files, then the generated ones when the
|
|
79
|
+
* fold is open — and is clamped, so a file disappearing from under it does not select nothing.
|
|
80
|
+
*/
|
|
81
|
+
export function fileListView(files, opts) {
|
|
82
|
+
const { main, generated } = listFiles(files);
|
|
83
|
+
const order = opts.showGenerated || main.length === 0 ? [...main, ...generated] : main;
|
|
84
|
+
const total = files.reduce((a, d) => ({ added: a.added + d.added, removed: a.removed + d.removed }), { added: 0, removed: 0 });
|
|
85
|
+
const sel = order.length ? Math.max(0, Math.min(opts.selected, order.length - 1)) : -1;
|
|
86
|
+
const room = Math.max(1, opts.rows);
|
|
87
|
+
// The window keeps the selection in view, as low as it can so the top of the list stays put.
|
|
88
|
+
const start = order.length <= room ? 0 : Math.max(0, Math.min(sel - room + 1, order.length - room));
|
|
89
|
+
const from = Math.max(0, Math.min(start, sel));
|
|
90
|
+
const shown = order.slice(from, from + room);
|
|
91
|
+
return {
|
|
92
|
+
files: files.length, ...total,
|
|
93
|
+
rows: shown.map((f, i) => ({ ...f, selected: from + i === sel })),
|
|
94
|
+
above: from,
|
|
95
|
+
below: Math.max(0, order.length - from - shown.length),
|
|
96
|
+
folded: { count: main.length === 0 ? 0 : generated.length, open: opts.showGenerated },
|
|
97
|
+
selected: sel >= 0 ? order[sel].index : -1,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** How many files the list can move through with the fold as it is. */
|
|
101
|
+
export function listLength(files, showGenerated) {
|
|
102
|
+
const { main, generated } = listFiles(files);
|
|
103
|
+
return showGenerated || main.length === 0 ? main.length + generated.length : main.length;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* One file's diff as rows `width` cells wide, long lines wrapped.
|
|
107
|
+
*
|
|
108
|
+
* The line number goes on the first piece only; every piece carries the sign, so a wrapped added
|
|
109
|
+
* line reads as added all the way down — the thing Claude Code's panel does that a clipped line
|
|
110
|
+
* cannot. Tabs are expanded first, because a tab has no width until it is drawn and the band
|
|
111
|
+
* behind a changed line has to be one.
|
|
112
|
+
*/
|
|
113
|
+
export function diffRows(d, width) {
|
|
114
|
+
/*
|
|
115
|
+
* Cached per diff and width: the panel asks on every repaint, and a diff does not change — a new
|
|
116
|
+
* edit arrives as a new object. Measured on a Raspberry Pi 5, two 400-line diffs: 66ms to lay
|
|
117
|
+
* out one uncached, which was most of an 86ms repaint.
|
|
118
|
+
*/
|
|
119
|
+
const byWidth = ROWS_CACHE.get(d);
|
|
120
|
+
const hit = byWidth?.get(width);
|
|
121
|
+
if (hit)
|
|
122
|
+
return hit;
|
|
123
|
+
const rows = layoutRows(d, width);
|
|
124
|
+
if (byWidth)
|
|
125
|
+
byWidth.set(width, rows);
|
|
126
|
+
else
|
|
127
|
+
ROWS_CACHE.set(d, new Map([[width, rows]]));
|
|
128
|
+
return rows;
|
|
129
|
+
}
|
|
130
|
+
const ROWS_CACHE = new WeakMap();
|
|
131
|
+
function layoutRows(d, width) {
|
|
132
|
+
if (d.binary)
|
|
133
|
+
return [{ t: 'binary' }];
|
|
134
|
+
const w = Math.max(8, width);
|
|
135
|
+
const rows = [];
|
|
136
|
+
for (const hunk of d.hunks) {
|
|
137
|
+
for (const l of hunk.lines) {
|
|
138
|
+
const number = (l.kind === 'del' ? l.before : l.after) ?? null;
|
|
139
|
+
const sign = l.kind === 'add' ? '+' : l.kind === 'del' ? '-' : ' ';
|
|
140
|
+
for (const [i, piece] of wrapCells(l.text.replace(/\t/g, ' '), w).entries()) {
|
|
141
|
+
rows.push({ t: 'line', kind: l.kind, number, sign, text: piece, first: i === 0 });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (d.hiddenLines > 0)
|
|
146
|
+
rows.push({ t: 'more', count: d.hiddenLines });
|
|
147
|
+
return rows;
|
|
148
|
+
}
|
|
149
|
+
/** A line broken into pieces no wider than `width` cells; an empty line is one empty piece. */
|
|
150
|
+
export function wrapCells(text, width) {
|
|
151
|
+
// Printable ASCII is one cell a character — most code, and far cheaper than measuring.
|
|
152
|
+
if (/^[\x20-\x7e]*$/.test(text)) {
|
|
153
|
+
if (text.length <= width)
|
|
154
|
+
return [text];
|
|
155
|
+
const out = [];
|
|
156
|
+
for (let i = 0; i < text.length; i += width)
|
|
157
|
+
out.push(text.slice(i, i + width));
|
|
158
|
+
return out;
|
|
159
|
+
}
|
|
160
|
+
if (displayWidth(text) <= width)
|
|
161
|
+
return [text];
|
|
162
|
+
const out = [];
|
|
163
|
+
let rest = text;
|
|
164
|
+
while (rest.length) {
|
|
165
|
+
const head = sliceToWidth(rest, width);
|
|
166
|
+
// A character wider than the whole width would never fit; take it alone rather than loop.
|
|
167
|
+
const take = head.text.length || [...rest][0].length;
|
|
168
|
+
out.push(rest.slice(0, take));
|
|
169
|
+
rest = rest.slice(take);
|
|
170
|
+
}
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=diff-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-layout.js","sourceRoot":"","sources":["../src/diff-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE/D,2GAA2G;AAC3G,MA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AAC,IAAI,CAAC,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,GAAG,GAAa,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,KAAK;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QAChF,OAAO,GAAG,CAAC;IACb,CAAC;IACD,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,KAAK;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACvC,0FAA0F;QAC1F,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAE,CAAC,MAAM,CAAC;QACtD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QAC9B,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The screen KONECK opens on: choosing a theme the first time, and granting a workspace access.
|
|
3
|
+
*
|
|
4
|
+
* Asked for with a screenshot of what it replaced — three bracketed lines on an empty terminal:
|
|
5
|
+
* "can you improve the entry, make it modern and appealing, and must have themes the user can
|
|
6
|
+
* choose to use, even have a snippet preview". So it is a card: the mark and the version, the
|
|
7
|
+
* question in plain words, the choices on a highlighted bar, and the keys that work. The first
|
|
8
|
+
* time, a theme picker comes before it, with a diff drawn in the theme under the cursor — a theme
|
|
9
|
+
* judged on what KONECK actually draws, not on swatches.
|
|
10
|
+
*
|
|
11
|
+
* The letters still work, as they did: Y, A and N, or the arrows and Enter. Escape and Ctrl+C
|
|
12
|
+
* cancel, which for the trust question is the refusal, the safe answer.
|
|
13
|
+
*/
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { type ThemeName } from './theme.js';
|
|
16
|
+
export type TrustAnswer = 'once' | 'always' | 'exit';
|
|
17
|
+
/** The width the card is drawn at: the terminal's, within reason. */
|
|
18
|
+
export declare function cardWidth(columns: number | undefined): number;
|
|
19
|
+
/**
|
|
20
|
+
* The preview: a small change drawn as the diff panel draws one, in the theme under the cursor.
|
|
21
|
+
*
|
|
22
|
+
* A light theme is shown on a light ground, so it can be judged on a dark terminal as it would
|
|
23
|
+
* look on the light one it is meant for — on black its dark text would only look broken.
|
|
24
|
+
*/
|
|
25
|
+
export declare function ThemePreview({ theme, width }: {
|
|
26
|
+
theme: ThemeName;
|
|
27
|
+
width: number;
|
|
28
|
+
}): React.JSX.Element;
|
|
29
|
+
export declare function EntryScreen({ version, workspace, askTheme, askTrust, initialTheme, columns, onDone }: {
|
|
30
|
+
version: string;
|
|
31
|
+
workspace: string;
|
|
32
|
+
askTheme: boolean;
|
|
33
|
+
askTrust: boolean;
|
|
34
|
+
initialTheme: ThemeName;
|
|
35
|
+
columns?: number;
|
|
36
|
+
onDone: (result: {
|
|
37
|
+
theme: ThemeName | null;
|
|
38
|
+
trust: TrustAnswer | null;
|
|
39
|
+
}) => void;
|
|
40
|
+
}): React.JSX.Element;
|
|
41
|
+
/**
|
|
42
|
+
* Shows the entry screen and resolves with what was chosen.
|
|
43
|
+
*
|
|
44
|
+
* Ink is mounted for this alone and unmounted before the conversation starts, so the conversation's
|
|
45
|
+
* own interface begins on a clean slate. The card is left in the scrollback above it, which is
|
|
46
|
+
* where a record of what was granted belongs.
|
|
47
|
+
*/
|
|
48
|
+
export declare function runEntryScreen(opts: {
|
|
49
|
+
version: string;
|
|
50
|
+
workspace: string;
|
|
51
|
+
askTheme: boolean;
|
|
52
|
+
askTrust: boolean;
|
|
53
|
+
initialTheme: ThemeName;
|
|
54
|
+
}): Promise<{
|
|
55
|
+
theme: ThemeName | null;
|
|
56
|
+
trust: TrustAnswer | null;
|
|
57
|
+
}>;
|
|
58
|
+
//# sourceMappingURL=entry-screen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-screen.d.ts","sourceRoot":"","sources":["../src/entry-screen.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAA0E,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAGpH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAQrD,qEAAqE;AACrE,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE7D;AAWD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAkCrG;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IACrG,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,SAAS,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;CAClF,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAiGpB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,SAAS,CAAC;CACnG,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC,CAQlE"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The screen KONECK opens on: choosing a theme the first time, and granting a workspace access.
|
|
4
|
+
*
|
|
5
|
+
* Asked for with a screenshot of what it replaced — three bracketed lines on an empty terminal:
|
|
6
|
+
* "can you improve the entry, make it modern and appealing, and must have themes the user can
|
|
7
|
+
* choose to use, even have a snippet preview". So it is a card: the mark and the version, the
|
|
8
|
+
* question in plain words, the choices on a highlighted bar, and the keys that work. The first
|
|
9
|
+
* time, a theme picker comes before it, with a diff drawn in the theme under the cursor — a theme
|
|
10
|
+
* judged on what KONECK actually draws, not on swatches.
|
|
11
|
+
*
|
|
12
|
+
* The letters still work, as they did: Y, A and N, or the arrows and Enter. Escape and Ctrl+C
|
|
13
|
+
* cancel, which for the trust question is the refusal, the safe answer.
|
|
14
|
+
*/
|
|
15
|
+
import { useState } from 'react';
|
|
16
|
+
import { Box, Text, render, useInput, useApp } from 'ink';
|
|
17
|
+
import { palette, applyTheme, currentTheme, THEMES, themeNamed, PREVIEW_SNIPPET } from './theme.js';
|
|
18
|
+
import { tokenizeLine, spanLangFor } from './highlight-spans.js';
|
|
19
|
+
const TRUST_CHOICES = [
|
|
20
|
+
{ key: 'y', label: 'Allow for this session', value: 'once' },
|
|
21
|
+
{ key: 'a', label: 'Always allow this workspace', value: 'always' },
|
|
22
|
+
{ key: 'n', label: 'Cancel', value: 'exit' },
|
|
23
|
+
];
|
|
24
|
+
/** The width the card is drawn at: the terminal's, within reason. */
|
|
25
|
+
export function cardWidth(columns) {
|
|
26
|
+
return Math.max(44, Math.min((columns ?? 80) - 2, 78));
|
|
27
|
+
}
|
|
28
|
+
function Header({ version }) {
|
|
29
|
+
return (_jsxs(Box, { children: [_jsx(Text, { color: palette.cyan, bold: true, children: "\uA4D8 KONECK" }), _jsxs(Text, { color: palette.dim, children: [" v", version] })] }));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The preview: a small change drawn as the diff panel draws one, in the theme under the cursor.
|
|
33
|
+
*
|
|
34
|
+
* A light theme is shown on a light ground, so it can be judged on a dark terminal as it would
|
|
35
|
+
* look on the light one it is meant for — on black its dark text would only look broken.
|
|
36
|
+
*/
|
|
37
|
+
export function ThemePreview({ theme, width }) {
|
|
38
|
+
const t = themeNamed(theme);
|
|
39
|
+
const p = t.palette;
|
|
40
|
+
const ground = t.base === 'light' ? '#FFFFFF' : undefined;
|
|
41
|
+
const lang = spanLangFor(PREVIEW_SNIPPET.path);
|
|
42
|
+
const inner = Math.max(20, width - 4);
|
|
43
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: p.dim, paddingX: 1, width: width, children: [_jsxs(Text, { color: p.muted, children: ["preview \u00B7 ", _jsx(Text, { color: p.ink, bold: true, children: PREVIEW_SNIPPET.path })] }), PREVIEW_SNIPPET.lines.map((l, i) => {
|
|
44
|
+
const bg = l.k === 'add' ? p.diffAddBg : l.k === 'del' ? p.diffDelBg : ground;
|
|
45
|
+
const fg = l.k === 'add' ? p.diffAdd : l.k === 'del' ? p.diffDel : p.dim;
|
|
46
|
+
const sign = l.k === 'add' ? '+' : l.k === 'del' ? '-' : ' ';
|
|
47
|
+
const spans = tokenizeLine(l.t, lang);
|
|
48
|
+
// The gutter is the number (3), a space, the sign and two spaces: seven cells.
|
|
49
|
+
const used = 7 + l.t.length;
|
|
50
|
+
const tint = bg ? { backgroundColor: bg } : {};
|
|
51
|
+
return (_jsxs(Text, { wrap: "truncate", children: [_jsxs(Text, { color: fg, ...tint, children: [String(l.n).padStart(3), " ", sign, " "] }), spans.map((s, j) => _jsx(Text, { color: p.syntax[s.kind], ...tint, children: s.text }, j)), _jsx(Text, { ...tint, children: ' '.repeat(Math.max(0, inner - used)) })] }, i));
|
|
52
|
+
}), _jsxs(Text, { wrap: "truncate", children: [_jsx(Text, { color: p.green, children: "\u2714 tests pass" }), _jsx(Text, { color: p.dim, children: " \u00B7 " }), _jsx(Text, { color: p.amber, children: "auto mode" }), _jsx(Text, { color: p.dim, children: " \u00B7 " }), _jsx(Text, { color: p.crimson, children: "ctx 79%" })] })] }));
|
|
53
|
+
}
|
|
54
|
+
export function EntryScreen({ version, workspace, askTheme, askTrust, initialTheme, columns, onDone }) {
|
|
55
|
+
const { exit } = useApp();
|
|
56
|
+
const [stage, setStage] = useState(askTheme ? 'theme' : 'trust');
|
|
57
|
+
const [themeAt, setThemeAt] = useState(Math.max(0, THEMES.findIndex(t => t.name === initialTheme)));
|
|
58
|
+
const [chosenTheme, setChosenTheme] = useState(null);
|
|
59
|
+
const [trustAt, setTrustAt] = useState(0);
|
|
60
|
+
const width = cardWidth(columns);
|
|
61
|
+
const finish = (theme, trust) => {
|
|
62
|
+
onDone({ theme, trust });
|
|
63
|
+
exit();
|
|
64
|
+
};
|
|
65
|
+
// Moving through the list applies the theme, so the whole card — not only the preview — shows it.
|
|
66
|
+
const hover = (i) => {
|
|
67
|
+
const n = (i + THEMES.length) % THEMES.length;
|
|
68
|
+
setThemeAt(n);
|
|
69
|
+
applyTheme(THEMES[n].name);
|
|
70
|
+
};
|
|
71
|
+
useInput((input, key) => {
|
|
72
|
+
if (stage === 'theme') {
|
|
73
|
+
// The theme applied, not `themeAt`: a key can arrive before the render after the last one.
|
|
74
|
+
const at = Math.max(0, THEMES.findIndex(t => t.name === currentTheme()));
|
|
75
|
+
if (key.upArrow)
|
|
76
|
+
return hover(at - 1);
|
|
77
|
+
if (key.downArrow)
|
|
78
|
+
return hover(at + 1);
|
|
79
|
+
const digit = Number(input);
|
|
80
|
+
if (Number.isInteger(digit) && digit >= 1 && digit <= THEMES.length)
|
|
81
|
+
return hover(digit - 1);
|
|
82
|
+
if (key.return) {
|
|
83
|
+
const name = THEMES[at].name;
|
|
84
|
+
setChosenTheme(name);
|
|
85
|
+
if (askTrust)
|
|
86
|
+
setStage('trust');
|
|
87
|
+
else
|
|
88
|
+
finish(name, null);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// Leaving without choosing keeps the theme there was; it is asked again next time.
|
|
92
|
+
if (key.escape || (key.ctrl && input === 'c')) {
|
|
93
|
+
applyTheme(initialTheme);
|
|
94
|
+
if (askTrust) {
|
|
95
|
+
setStage('trust');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
finish(null, null);
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (key.upArrow) {
|
|
103
|
+
setTrustAt(v => (v + TRUST_CHOICES.length - 1) % TRUST_CHOICES.length);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (key.downArrow) {
|
|
107
|
+
setTrustAt(v => (v + 1) % TRUST_CHOICES.length);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (key.return) {
|
|
111
|
+
finish(chosenTheme, TRUST_CHOICES[trustAt].value);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (key.escape || (key.ctrl && input === 'c')) {
|
|
115
|
+
finish(chosenTheme, 'exit');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const typed = TRUST_CHOICES.find(c => c.key === input.toLowerCase());
|
|
119
|
+
if (typed)
|
|
120
|
+
finish(chosenTheme, typed.value);
|
|
121
|
+
});
|
|
122
|
+
// Notes start in one column, so the list reads as a table.
|
|
123
|
+
const labelWidth = Math.max(...THEMES.map(t => t.label.length));
|
|
124
|
+
const row = (selected, key, label, note) => (_jsx(Box, { width: width - 4, children: _jsxs(Text, { wrap: "truncate", ...(selected ? { backgroundColor: palette.cyan, color: palette.onAccent } : { color: palette.ink }), children: [selected ? ' › ' : ' ', _jsx(Text, { bold: true, children: key }), ' ', note ? label.padEnd(labelWidth) : label, note ? _jsx(Text, { ...(selected ? {} : { color: palette.dim }), children: ' ' + note }) : '', ' '] }) }, label));
|
|
125
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: palette.cyan, paddingX: 1, width: width, marginTop: 1, children: [_jsx(Header, { version: version }), _jsx(Text, { children: " " }), stage === 'theme' ? (_jsxs(_Fragment, { children: [_jsx(Text, { color: palette.ink, bold: true, children: "Welcome. Pick a theme." }), _jsx(Text, { color: palette.muted, children: "It sets KONECK's colours; /theme changes it any time." }), _jsx(Text, { children: " " }), THEMES.map((t, i) => row(i === themeAt, String(i + 1), t.label, t.note)), _jsx(Text, { children: " " }), _jsx(ThemePreview, { theme: THEMES[themeAt].name, width: width - 4 }), _jsx(Text, { children: " " }), _jsxs(Text, { color: palette.dim, children: ["\u2191\u2193 or 1\u2013", THEMES.length, " to try \u00B7 enter to choose \u00B7 esc to keep the current one"] })] })) : (_jsxs(_Fragment, { children: [_jsx(Text, { color: palette.ink, bold: true, children: "Allow KONECK to work in this folder?" }), _jsx(Text, { color: palette.cyan, wrap: "truncate-start", children: workspace }), _jsx(Text, { children: " " }), _jsx(Text, { color: palette.muted, wrap: "wrap", children: "It will read and edit files and run commands here. The mode you work in decides what it asks you first." }), _jsx(Text, { children: " " }), TRUST_CHOICES.map((c, i) => row(i === trustAt, c.key.toUpperCase(), c.label)), _jsx(Text, { children: " " }), _jsx(Text, { color: palette.dim, children: "\u2191\u2193 to move \u00B7 enter to choose \u00B7 or press y, a or n" })] }))] }));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Shows the entry screen and resolves with what was chosen.
|
|
129
|
+
*
|
|
130
|
+
* Ink is mounted for this alone and unmounted before the conversation starts, so the conversation's
|
|
131
|
+
* own interface begins on a clean slate. The card is left in the scrollback above it, which is
|
|
132
|
+
* where a record of what was granted belongs.
|
|
133
|
+
*/
|
|
134
|
+
export async function runEntryScreen(opts) {
|
|
135
|
+
let result = { theme: null, trust: opts.askTrust ? 'exit' : null };
|
|
136
|
+
const app = render(_jsx(EntryScreen, { ...opts, columns: process.stdout.columns, onDone: r => { result = r; } }), { exitOnCtrlC: false });
|
|
137
|
+
await app.waitUntilExit();
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=entry-screen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-screen.js","sourceRoot":"","sources":["../src/entry-screen.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;AAEH,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AACpH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIjE,MAAM,aAAa,GAAsE;IACvF,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,wBAAwB,EAAE,KAAK,EAAE,MAAM,EAAE;IAC5D,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,6BAA6B,EAAE,KAAK,EAAE,QAAQ,EAAE;IACnE,EAAE,GAA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src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AA0eA;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,CAAC;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAC9D,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,EAAE,OAAO,GAC1B,MAAM,GAAG,SAAS,CAepB"}
|
package/dist/index.js
CHANGED
|
@@ -32,14 +32,15 @@ import chalk from 'chalk';
|
|
|
32
32
|
import { tui } from './tui.js';
|
|
33
33
|
import { listProviders, PROVIDERS, inferProvider, providersWithCredentials, resolveProvider } from './providers.js';
|
|
34
34
|
import { loadProjectConfig } from './config.js';
|
|
35
|
-
import { loadKoneckConfig } from './config-store.js';
|
|
35
|
+
import { loadKoneckConfig, setConfigKey } from './config-store.js';
|
|
36
36
|
import { resolveEndpoint, resolveModelChoice } from './endpoints.js';
|
|
37
37
|
import { loadSession, listSessions, relativeAge } from './session.js';
|
|
38
38
|
import { SANDBOX_MODES } from './sandbox-modes.js';
|
|
39
39
|
import { estimateCost, formatCost, hasKnownPricing } from './pricing.js';
|
|
40
40
|
import { loadGlobalConfig, withoutStoredApiKey } from './config.js';
|
|
41
41
|
import { saveGlobalConfig } from './config.js';
|
|
42
|
-
import {
|
|
42
|
+
import { isWorkspaceTrusted, trustWorkspace } from './workspace-trust.js';
|
|
43
|
+
import { applyTheme, currentTheme } from './theme.js';
|
|
43
44
|
import { checkForUpdate } from './update-check.js';
|
|
44
45
|
config();
|
|
45
46
|
const VERSION = JSON.parse(readFileSync(path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf-8')).version;
|
|
@@ -563,6 +564,7 @@ export function inheritBaseURL(layers, effectiveProvider, providerNamedOnCli) {
|
|
|
563
564
|
async function resolveConfig(args) {
|
|
564
565
|
const projectConfig = await loadProjectConfig(args.cwd); // .koneckrc beside the code
|
|
565
566
|
const storeConfig = await loadKoneckConfig(); // written by /config
|
|
567
|
+
applyTheme(storeConfig.theme);
|
|
566
568
|
const globalConfig = await loadGlobalConfig(); // written by koneck auth login
|
|
567
569
|
const layered = (...values) => values.find(v => v !== undefined);
|
|
568
570
|
const fileConfig = { ...globalConfig, ...storeConfig, ...projectConfig };
|
|
@@ -715,9 +717,32 @@ async function main() {
|
|
|
715
717
|
` Run \`koneck\` here once and allow it, or use --ci in trusted automation.`);
|
|
716
718
|
process.exit(1);
|
|
717
719
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
720
|
+
/*
|
|
721
|
+
* The entry screen: a theme the first time, and the workspace question when it is not trusted
|
|
722
|
+
* yet. The theme is asked only at a terminal, and once — a saved theme, whichever it is, is
|
|
723
|
+
* the answer. See entry-screen.tsx.
|
|
724
|
+
*/
|
|
725
|
+
const store = await loadKoneckConfig().catch(() => ({}));
|
|
726
|
+
applyTheme(store.theme);
|
|
727
|
+
const askTheme = !store.theme && !!process.stdin.isTTY && !!process.stdout.isTTY;
|
|
728
|
+
if (askTheme || !alreadyTrusted) {
|
|
729
|
+
const { runEntryScreen } = await import('./entry-screen.js');
|
|
730
|
+
const { theme, trust } = await runEntryScreen({
|
|
731
|
+
version: VERSION, workspace: path.resolve(args.cwd), askTheme, askTrust: !alreadyTrusted,
|
|
732
|
+
initialTheme: currentTheme(),
|
|
733
|
+
});
|
|
734
|
+
if (theme) {
|
|
735
|
+
applyTheme(theme);
|
|
736
|
+
await setConfigKey('theme', theme).catch(() => { });
|
|
737
|
+
}
|
|
738
|
+
if (!alreadyTrusted) {
|
|
739
|
+
if (trust === 'always')
|
|
740
|
+
await trustWorkspace(args.cwd);
|
|
741
|
+
if (trust !== 'once' && trust !== 'always') {
|
|
742
|
+
console.log(chalk.dim('\n Workspace access was not granted. Exiting.\n'));
|
|
743
|
+
process.exit(0);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
721
746
|
}
|
|
722
747
|
}
|
|
723
748
|
if (!args.ci && !args.json) {
|