koneck 2.120.0 → 2.122.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/dist/highlight-spans.d.ts +35 -0
- package/dist/highlight-spans.d.ts.map +1 -0
- package/dist/highlight-spans.js +216 -0
- package/dist/highlight-spans.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -54
- package/dist/index.js.map +1 -1
- package/dist/ink-chat.d.ts +15 -0
- package/dist/ink-chat.d.ts.map +1 -1
- package/dist/ink-chat.js +575 -362
- package/dist/ink-chat.js.map +1 -1
- package/dist/sandbox-modes.d.ts +10 -0
- package/dist/sandbox-modes.d.ts.map +1 -0
- package/dist/sandbox-modes.js +9 -0
- package/dist/sandbox-modes.js.map +1 -0
- package/dist/sandbox.d.ts +3 -2
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +2 -1
- package/dist/sandbox.js.map +1 -1
- package/dist/tool-outcome.d.ts +11 -0
- package/dist/tool-outcome.d.ts.map +1 -0
- package/dist/tool-outcome.js +28 -0
- package/dist/tool-outcome.js.map +1 -0
- package/dist/tools.d.ts +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +1 -18
- package/dist/tools.js.map +1 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +11 -2
- package/dist/tui.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/web/api.d.ts.map +1 -1
- package/dist/web/api.js +33 -2
- package/dist/web/api.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Syntax highlighting as structured spans, for the terminal's diff panel.
|
|
3
|
+
*
|
|
4
|
+
* `highlight.ts` returns lines with ANSI codes already embedded, built by running one regex
|
|
5
|
+
* replacement after another over the same string. That is fine for printing a line and wrong here,
|
|
6
|
+
* for two reasons. The colours it inserts become text the later regexes then match against — the
|
|
7
|
+
* number rule sees the `32` inside the green it just wrote — so the chain is correct only in the
|
|
8
|
+
* order it happens to run in, and a rule added later can quietly corrupt the ones before it. And
|
|
9
|
+
* embedded ANSI cannot be combined with a background: the diff panel tints added lines green, and a
|
|
10
|
+
* pre-coloured string carries its own resets that fight the tint.
|
|
11
|
+
*
|
|
12
|
+
* So this walks each line once, character by character, and returns typed spans. Nothing is
|
|
13
|
+
* re-scanned, so nothing can be corrupted; whitespace is preserved exactly, which the regex chain
|
|
14
|
+
* did not manage either; and the caller decides what colour a kind is and what sits behind it.
|
|
15
|
+
*
|
|
16
|
+
* Line-at-a-time deliberately. A diff shows fragments — hunks with gaps between them — so there is
|
|
17
|
+
* no whole file to parse and a block comment's opening may never be in view. Each line is judged on
|
|
18
|
+
* what it contains, which is what a diff reader is looking at anyway.
|
|
19
|
+
*/
|
|
20
|
+
export type SpanKind = 'plain' | 'keyword' | 'string' | 'comment' | 'number' | 'fn' | 'type' | 'punct';
|
|
21
|
+
export interface Span {
|
|
22
|
+
text: string;
|
|
23
|
+
kind: SpanKind;
|
|
24
|
+
}
|
|
25
|
+
export type SpanLang = 'js' | 'py' | 'sh' | 'css' | 'json' | 'md' | 'generic';
|
|
26
|
+
/** The language to tokenise as, from a file name. */
|
|
27
|
+
export declare function spanLangFor(filename: string): SpanLang;
|
|
28
|
+
/**
|
|
29
|
+
* One line, walked once, as typed spans.
|
|
30
|
+
*
|
|
31
|
+
* Adjacent spans of the same kind are merged so the caller renders a handful of elements rather
|
|
32
|
+
* than one per character — a 100-column line of plain text is one span, not a hundred.
|
|
33
|
+
*/
|
|
34
|
+
export declare function tokenizeLine(line: string, lang?: SpanLang): Span[];
|
|
35
|
+
//# sourceMappingURL=highlight-spans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight-spans.d.ts","sourceRoot":"","sources":["../src/highlight-spans.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,QAAQ,GAChB,OAAO,GACP,SAAS,GACT,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,IAAI,GACJ,MAAM,GACN,OAAO,CAAC;AAEZ,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAE9E,qDAAqD;AACrD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAYtD;AA4DD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,QAAoB,GAAG,IAAI,EAAE,CAqF7E"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Syntax highlighting as structured spans, for the terminal's diff panel.
|
|
3
|
+
*
|
|
4
|
+
* `highlight.ts` returns lines with ANSI codes already embedded, built by running one regex
|
|
5
|
+
* replacement after another over the same string. That is fine for printing a line and wrong here,
|
|
6
|
+
* for two reasons. The colours it inserts become text the later regexes then match against — the
|
|
7
|
+
* number rule sees the `32` inside the green it just wrote — so the chain is correct only in the
|
|
8
|
+
* order it happens to run in, and a rule added later can quietly corrupt the ones before it. And
|
|
9
|
+
* embedded ANSI cannot be combined with a background: the diff panel tints added lines green, and a
|
|
10
|
+
* pre-coloured string carries its own resets that fight the tint.
|
|
11
|
+
*
|
|
12
|
+
* So this walks each line once, character by character, and returns typed spans. Nothing is
|
|
13
|
+
* re-scanned, so nothing can be corrupted; whitespace is preserved exactly, which the regex chain
|
|
14
|
+
* did not manage either; and the caller decides what colour a kind is and what sits behind it.
|
|
15
|
+
*
|
|
16
|
+
* Line-at-a-time deliberately. A diff shows fragments — hunks with gaps between them — so there is
|
|
17
|
+
* no whole file to parse and a block comment's opening may never be in view. Each line is judged on
|
|
18
|
+
* what it contains, which is what a diff reader is looking at anyway.
|
|
19
|
+
*/
|
|
20
|
+
/** The language to tokenise as, from a file name. */
|
|
21
|
+
export function spanLangFor(filename) {
|
|
22
|
+
const ext = filename.split('.').pop()?.toLowerCase() ?? '';
|
|
23
|
+
const map = {
|
|
24
|
+
js: 'js', jsx: 'js', ts: 'js', tsx: 'js', mjs: 'js', cjs: 'js',
|
|
25
|
+
py: 'py', pyi: 'py',
|
|
26
|
+
sh: 'sh', bash: 'sh', zsh: 'sh', fish: 'sh',
|
|
27
|
+
css: 'css', scss: 'css', sass: 'css', less: 'css',
|
|
28
|
+
json: 'json',
|
|
29
|
+
md: 'md', mdx: 'md',
|
|
30
|
+
groovy: 'js', java: 'js', kt: 'js', gradle: 'js',
|
|
31
|
+
};
|
|
32
|
+
return map[ext] ?? 'generic';
|
|
33
|
+
}
|
|
34
|
+
const JS_KEYWORDS = new Set([
|
|
35
|
+
'const', 'let', 'var', 'function', 'return', 'if', 'else', 'for', 'while', 'do', 'break',
|
|
36
|
+
'continue', 'new', 'delete', 'typeof', 'instanceof', 'in', 'of', 'class', 'extends', 'super',
|
|
37
|
+
'this', 'import', 'export', 'from', 'as', 'default', 'async', 'await', 'yield', 'try', 'catch',
|
|
38
|
+
'finally', 'throw', 'switch', 'case', 'interface', 'type', 'enum', 'implements', 'private',
|
|
39
|
+
'public', 'protected', 'readonly', 'static', 'abstract', 'declare', 'namespace', 'satisfies',
|
|
40
|
+
'true', 'false', 'null', 'undefined', 'void', 'never', 'unknown', 'any',
|
|
41
|
+
]);
|
|
42
|
+
/** Built-in types and constructors, which read differently from control flow. */
|
|
43
|
+
const JS_TYPES = new Set([
|
|
44
|
+
'string', 'number', 'boolean', 'object', 'symbol', 'bigint', 'Array', 'Promise', 'Map', 'Set',
|
|
45
|
+
'Record', 'Partial', 'Readonly', 'Object', 'String', 'Number', 'Boolean', 'Date', 'RegExp',
|
|
46
|
+
'Error', 'JSON', 'Math', 'console', 'process', 'Buffer',
|
|
47
|
+
]);
|
|
48
|
+
const PY_KEYWORDS = new Set([
|
|
49
|
+
'def', 'class', 'return', 'if', 'elif', 'else', 'for', 'while', 'break', 'continue', 'import',
|
|
50
|
+
'from', 'as', 'pass', 'raise', 'try', 'except', 'finally', 'with', 'lambda', 'yield', 'global',
|
|
51
|
+
'nonlocal', 'assert', 'del', 'and', 'or', 'not', 'in', 'is', 'None', 'True', 'False', 'async',
|
|
52
|
+
'await', 'self',
|
|
53
|
+
]);
|
|
54
|
+
const SH_KEYWORDS = new Set([
|
|
55
|
+
'if', 'then', 'else', 'elif', 'fi', 'for', 'while', 'do', 'done', 'case', 'esac', 'function',
|
|
56
|
+
'return', 'exit', 'export', 'local', 'echo', 'cd', 'set', 'unset', 'source', 'in',
|
|
57
|
+
]);
|
|
58
|
+
function keywordsFor(lang) {
|
|
59
|
+
if (lang === 'py')
|
|
60
|
+
return PY_KEYWORDS;
|
|
61
|
+
if (lang === 'sh')
|
|
62
|
+
return SH_KEYWORDS;
|
|
63
|
+
return JS_KEYWORDS;
|
|
64
|
+
}
|
|
65
|
+
/** Where a line comment starts, ignoring ones inside a string. -1 when there is none. */
|
|
66
|
+
function lineCommentAt(line, lang) {
|
|
67
|
+
const markers = lang === 'py' || lang === 'sh' ? ['#'] : lang === 'css' ? [] : ['//'];
|
|
68
|
+
if (!markers.length)
|
|
69
|
+
return -1;
|
|
70
|
+
let quote = '';
|
|
71
|
+
for (let i = 0; i < line.length; i++) {
|
|
72
|
+
const ch = line[i];
|
|
73
|
+
if (quote) {
|
|
74
|
+
if (ch === '\\') {
|
|
75
|
+
i++;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (ch === quote)
|
|
79
|
+
quote = '';
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
83
|
+
quote = ch;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
for (const m of markers) {
|
|
87
|
+
if (line.startsWith(m, i))
|
|
88
|
+
return i;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return -1;
|
|
92
|
+
}
|
|
93
|
+
const IDENT_START = /[A-Za-z_$@]/;
|
|
94
|
+
const IDENT_REST = /[A-Za-z0-9_$]/;
|
|
95
|
+
const PUNCT = /[{}()[\];:,.<>=!+\-*/%&|^~?]/;
|
|
96
|
+
/**
|
|
97
|
+
* One line, walked once, as typed spans.
|
|
98
|
+
*
|
|
99
|
+
* Adjacent spans of the same kind are merged so the caller renders a handful of elements rather
|
|
100
|
+
* than one per character — a 100-column line of plain text is one span, not a hundred.
|
|
101
|
+
*/
|
|
102
|
+
export function tokenizeLine(line, lang = 'generic') {
|
|
103
|
+
const out = [];
|
|
104
|
+
const push = (text, kind) => {
|
|
105
|
+
if (!text)
|
|
106
|
+
return;
|
|
107
|
+
const last = out[out.length - 1];
|
|
108
|
+
if (last && last.kind === kind)
|
|
109
|
+
last.text += text;
|
|
110
|
+
else
|
|
111
|
+
out.push({ text, kind });
|
|
112
|
+
};
|
|
113
|
+
if (lang === 'md')
|
|
114
|
+
return markdownSpans(line);
|
|
115
|
+
// A whole-line comment, and a block comment's body, are comments however they are indented.
|
|
116
|
+
const trimmed = line.trim();
|
|
117
|
+
if (trimmed.startsWith('//') || trimmed.startsWith('/*') || trimmed.startsWith('*')
|
|
118
|
+
|| ((lang === 'py' || lang === 'sh') && trimmed.startsWith('#'))) {
|
|
119
|
+
return [{ text: line, kind: 'comment' }];
|
|
120
|
+
}
|
|
121
|
+
// A trailing comment is taken off first, so the code before it is tokenised on its own.
|
|
122
|
+
const comment = lineCommentAt(line, lang);
|
|
123
|
+
const code = comment === -1 ? line : line.slice(0, comment);
|
|
124
|
+
const tail = comment === -1 ? '' : line.slice(comment);
|
|
125
|
+
const keywords = keywordsFor(lang);
|
|
126
|
+
let i = 0;
|
|
127
|
+
while (i < code.length) {
|
|
128
|
+
const ch = code[i];
|
|
129
|
+
// Whitespace stays exactly as it is — this is what the regex chain lost.
|
|
130
|
+
if (ch === ' ' || ch === '\t') {
|
|
131
|
+
let j = i;
|
|
132
|
+
while (j < code.length && (code[j] === ' ' || code[j] === '\t'))
|
|
133
|
+
j++;
|
|
134
|
+
push(code.slice(i, j), 'plain');
|
|
135
|
+
i = j;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
// A string, to its closing quote or the end of the line if it is unterminated.
|
|
139
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
140
|
+
let j = i + 1;
|
|
141
|
+
while (j < code.length) {
|
|
142
|
+
if (code[j] === '\\') {
|
|
143
|
+
j += 2;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (code[j] === ch) {
|
|
147
|
+
j++;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
j++;
|
|
151
|
+
}
|
|
152
|
+
push(code.slice(i, j), 'string');
|
|
153
|
+
i = j;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
// A number, including decimals, hex and separators.
|
|
157
|
+
if (/[0-9]/.test(ch)) {
|
|
158
|
+
let j = i;
|
|
159
|
+
while (j < code.length && /[0-9a-fA-FxX._]/.test(code[j]))
|
|
160
|
+
j++;
|
|
161
|
+
push(code.slice(i, j), 'number');
|
|
162
|
+
i = j;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
// An identifier: a keyword, a known type, a call, or a plain name.
|
|
166
|
+
if (IDENT_START.test(ch)) {
|
|
167
|
+
let j = i + 1;
|
|
168
|
+
while (j < code.length && IDENT_REST.test(code[j]))
|
|
169
|
+
j++;
|
|
170
|
+
const word = code.slice(i, j);
|
|
171
|
+
// A call is the name followed by an opening paren, whitespace allowed between.
|
|
172
|
+
let k = j;
|
|
173
|
+
while (k < code.length && code[k] === ' ')
|
|
174
|
+
k++;
|
|
175
|
+
const called = code[k] === '(';
|
|
176
|
+
push(word, keywords.has(word) ? 'keyword'
|
|
177
|
+
: JS_TYPES.has(word) ? 'type'
|
|
178
|
+
: called ? 'fn'
|
|
179
|
+
: /^[A-Z]/.test(word) ? 'type'
|
|
180
|
+
: 'plain');
|
|
181
|
+
i = j;
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (PUNCT.test(ch)) {
|
|
185
|
+
push(ch, 'punct');
|
|
186
|
+
i++;
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
push(ch, 'plain');
|
|
190
|
+
i++;
|
|
191
|
+
}
|
|
192
|
+
if (tail)
|
|
193
|
+
push(tail, 'comment');
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
/** Markdown, where the structure is the syntax: headings, fences, emphasis, list bullets. */
|
|
197
|
+
function markdownSpans(line) {
|
|
198
|
+
const t = line.trim();
|
|
199
|
+
if (t.startsWith('#'))
|
|
200
|
+
return [{ text: line, kind: 'keyword' }];
|
|
201
|
+
if (t.startsWith('```'))
|
|
202
|
+
return [{ text: line, kind: 'type' }];
|
|
203
|
+
if (t.startsWith('>'))
|
|
204
|
+
return [{ text: line, kind: 'comment' }];
|
|
205
|
+
if (/^[-*+]\s/.test(t) || /^\d+\.\s/.test(t)) {
|
|
206
|
+
const at = line.indexOf(t[0]);
|
|
207
|
+
const parts = [
|
|
208
|
+
{ text: line.slice(0, at), kind: 'plain' },
|
|
209
|
+
{ text: t.slice(0, t.indexOf(' ') + 1), kind: 'punct' },
|
|
210
|
+
{ text: t.slice(t.indexOf(' ') + 1), kind: 'plain' },
|
|
211
|
+
];
|
|
212
|
+
return parts.filter(s => s.text);
|
|
213
|
+
}
|
|
214
|
+
return [{ text: line, kind: 'plain' }];
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=highlight-spans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight-spans.js","sourceRoot":"","sources":["../src/highlight-spans.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAmBH,qDAAqD;AACrD,MAAM,UAAU,WAAW,CAAC,QAAgB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,KAAK,CAAC;QAAE,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/D,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAChE,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAW;YACpB,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;YAC1C,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;YACvD,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;SACrD,CAAC;QACF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AA2cA;;;;;;;;;;;;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
|
@@ -5,49 +5,28 @@ import { config } from 'dotenv';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
import { tui } from './tui.js';
|
|
8
|
-
import { runAgent } from './engine.js';
|
|
9
8
|
import { listProviders, PROVIDERS, inferProvider, providersWithCredentials, resolveProvider } from './providers.js';
|
|
10
9
|
import { loadProjectConfig } from './config.js';
|
|
11
10
|
import { loadKoneckConfig } from './config-store.js';
|
|
12
11
|
import { resolveEndpoint, resolveModelChoice } from './endpoints.js';
|
|
13
12
|
import { loadSession, listSessions, relativeAge } from './session.js';
|
|
14
|
-
import { SANDBOX_MODES } from './sandbox.js';
|
|
15
|
-
import { runChatMode } from './chat.js';
|
|
16
|
-
import { runInkChatMode } from './ink-chat.js';
|
|
17
|
-
import { runInit } from './init.js';
|
|
18
|
-
import { getCompletionScript } from './completion.js';
|
|
13
|
+
import { SANDBOX_MODES } from './sandbox-modes.js';
|
|
19
14
|
import { estimateCost, formatCost, hasKnownPricing } from './pricing.js';
|
|
20
|
-
import { needsSetup, runSetup } from './setup.js';
|
|
21
15
|
import { loadGlobalConfig, withoutStoredApiKey } from './config.js';
|
|
22
|
-
import { runDoctor } from './doctor.js';
|
|
23
|
-
import { runStats } from './stats.js';
|
|
24
|
-
import { runWatch } from './watch.js';
|
|
25
16
|
import { saveGlobalConfig } from './config.js';
|
|
26
|
-
import { runHealth } from './health.js';
|
|
27
|
-
import { runDaemon } from './daemon.js';
|
|
28
|
-
import { runIssues } from './issues.js';
|
|
29
|
-
import { runPipeline } from './pipeline.js';
|
|
30
|
-
import { runDebugger } from './debugger.js';
|
|
31
|
-
import { runRefactor } from './refactor.js';
|
|
32
|
-
import { listPluginPacks, installPluginPack } from './plugin-packs.js';
|
|
33
|
-
import { runTestGen } from './test-gen.js';
|
|
34
|
-
import { runServer } from './server.js';
|
|
35
|
-
import { explainSymbol, askQuestion, summarizeFile } from './explain.js';
|
|
36
|
-
import { buildEmbeddingsIndex, getEmbeddingsStats } from './embeddings.js';
|
|
37
17
|
import { requestWorkspaceTrust, isWorkspaceTrusted } from './workspace-trust.js';
|
|
38
18
|
import { checkForUpdate } from './update-check.js';
|
|
39
|
-
import { preparePullRequest, createPullRequest } from './pull-request.js';
|
|
40
|
-
import { runPreflight, preflightReport, isPreflightReady } from './preflight.js';
|
|
41
19
|
config();
|
|
42
20
|
const VERSION = JSON.parse(readFileSync(path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf-8')).version;
|
|
43
21
|
/** Publish only verified delivery work; a model's completion message is never release evidence. */
|
|
44
22
|
async function publishTaskPullRequest(cwd) {
|
|
23
|
+
const { runPreflight, preflightReport, isPreflightReady } = await import('./preflight.js');
|
|
45
24
|
const preflight = await runPreflight(cwd);
|
|
46
25
|
if (!isPreflightReady(preflight)) {
|
|
47
26
|
tui.printWarning('PR was not opened because the delivery preflight did not pass.\n' + preflightReport(preflight));
|
|
48
27
|
return false;
|
|
49
28
|
}
|
|
50
|
-
const result = await createPullRequest(cwd);
|
|
29
|
+
const result = await (await import('./pull-request.js')).createPullRequest(cwd);
|
|
51
30
|
if (result.ok) {
|
|
52
31
|
tui.printSuccess(result.message);
|
|
53
32
|
return true;
|
|
@@ -651,7 +630,7 @@ async function main() {
|
|
|
651
630
|
console.log('');
|
|
652
631
|
}
|
|
653
632
|
else if (action === 'login') {
|
|
654
|
-
await runSetup();
|
|
633
|
+
await (await import('./setup.js')).runSetup();
|
|
655
634
|
}
|
|
656
635
|
else if (action === 'logout') {
|
|
657
636
|
await saveGlobalConfig(withoutStoredApiKey(globalCfg));
|
|
@@ -688,24 +667,24 @@ async function main() {
|
|
|
688
667
|
}
|
|
689
668
|
// ── First-run setup ────────────────────────────────────────────────────────
|
|
690
669
|
if (!args.ci && !args.json && !args.initMode && !args.completionShell && !args.listProviders) {
|
|
691
|
-
if (await needsSetup()) {
|
|
670
|
+
if (await (await import('./setup.js')).needsSetup()) {
|
|
692
671
|
tui.printBanner();
|
|
693
|
-
await runSetup();
|
|
672
|
+
await (await import('./setup.js')).runSetup();
|
|
694
673
|
}
|
|
695
674
|
}
|
|
696
675
|
// ── Init mode ──────────────────────────────────────────────────────────────
|
|
697
676
|
if (args.initMode) {
|
|
698
|
-
await runInit(args.cwd);
|
|
677
|
+
await (await import('./init.js')).runInit(args.cwd);
|
|
699
678
|
process.exit(0);
|
|
700
679
|
}
|
|
701
680
|
// ── Doctor mode ────────────────────────────────────────────────────────────
|
|
702
681
|
if (args.doctorMode) {
|
|
703
|
-
await runDoctor(args.cwd);
|
|
682
|
+
await (await import('./doctor.js')).runDoctor(args.cwd);
|
|
704
683
|
process.exit(0);
|
|
705
684
|
}
|
|
706
685
|
// ── Stats mode ─────────────────────────────────────────────────────────────
|
|
707
686
|
if (args.statsMode) {
|
|
708
|
-
await runStats(args.cwd);
|
|
687
|
+
await (await import('./stats.js')).runStats(args.cwd);
|
|
709
688
|
process.exit(0);
|
|
710
689
|
}
|
|
711
690
|
// ── Health mode ────────────────────────────────────────────────────────────
|
|
@@ -743,7 +722,7 @@ async function main() {
|
|
|
743
722
|
process.exit(0);
|
|
744
723
|
}
|
|
745
724
|
if (args.healthMode) {
|
|
746
|
-
await runHealth(args.cwd);
|
|
725
|
+
await (await import('./health.js')).runHealth(args.cwd);
|
|
747
726
|
process.exit(0);
|
|
748
727
|
}
|
|
749
728
|
// ── Daemon mode ────────────────────────────────────────────────────────────
|
|
@@ -755,7 +734,7 @@ async function main() {
|
|
|
755
734
|
verbose: args.verbose, cwd: args.cwd, ci: true, apiKey: resolved2.apiKey,
|
|
756
735
|
};
|
|
757
736
|
const action = (args.daemonAction ?? 'status');
|
|
758
|
-
await runDaemon(action, daemonConfig);
|
|
737
|
+
await (await import('./daemon.js')).runDaemon(action, daemonConfig);
|
|
759
738
|
process.exit(0);
|
|
760
739
|
}
|
|
761
740
|
// ── Issues mode ────────────────────────────────────────────────────────────
|
|
@@ -767,7 +746,7 @@ async function main() {
|
|
|
767
746
|
useWorktree: false, verbose: args.verbose, cwd: args.cwd, apiKey: resolved2.apiKey,
|
|
768
747
|
};
|
|
769
748
|
const action = (args.issuesAction ?? 'list');
|
|
770
|
-
await runIssues(action, issuesConfig, args.issueId);
|
|
749
|
+
await (await import('./issues.js')).runIssues(action, issuesConfig, args.issueId);
|
|
771
750
|
process.exit(0);
|
|
772
751
|
}
|
|
773
752
|
// ── Index mode (build embeddings) ─────────────────────────────────────────
|
|
@@ -778,11 +757,11 @@ async function main() {
|
|
|
778
757
|
maxTurns: 1, requireApproval: false, useWorktree: false,
|
|
779
758
|
verbose: args.verbose, cwd: args.cwd, apiKey: resolved2.apiKey,
|
|
780
759
|
};
|
|
781
|
-
const stats = await getEmbeddingsStats(args.cwd);
|
|
760
|
+
const stats = await (await import('./embeddings.js')).getEmbeddingsStats(args.cwd);
|
|
782
761
|
if (stats.exists) {
|
|
783
762
|
console.log(chalk.dim(`\n Existing index: ${stats.chunks} chunks, ${stats.files} files, built ${stats.builtAt}\n`));
|
|
784
763
|
}
|
|
785
|
-
await buildEmbeddingsIndex(args.cwd, idxConfig);
|
|
764
|
+
await (await import('./embeddings.js')).buildEmbeddingsIndex(args.cwd, idxConfig);
|
|
786
765
|
process.exit(0);
|
|
787
766
|
}
|
|
788
767
|
// ── Serve mode ─────────────────────────────────────────────────────────────
|
|
@@ -793,7 +772,7 @@ async function main() {
|
|
|
793
772
|
maxTurns: resolved2.maxTurns, requireApproval: false, useWorktree: false,
|
|
794
773
|
verbose: args.verbose, cwd: args.cwd, apiKey: resolved2.apiKey,
|
|
795
774
|
};
|
|
796
|
-
await runServer(serveCfg, args.servePort);
|
|
775
|
+
await (await import('./server.js')).runServer(serveCfg, args.servePort);
|
|
797
776
|
return;
|
|
798
777
|
}
|
|
799
778
|
// ── Explain / Ask / Summarize modes ────────────────────────────────────────
|
|
@@ -805,13 +784,13 @@ async function main() {
|
|
|
805
784
|
verbose: args.verbose, cwd: args.cwd, apiKey: resolved2.apiKey,
|
|
806
785
|
};
|
|
807
786
|
if (args.explainMode && args.explainTarget) {
|
|
808
|
-
await explainSymbol(args.explainTarget, quickCfg);
|
|
787
|
+
await (await import('./explain.js')).explainSymbol(args.explainTarget, quickCfg);
|
|
809
788
|
}
|
|
810
789
|
else if (args.askMode && args.task) {
|
|
811
|
-
await askQuestion(args.task, quickCfg);
|
|
790
|
+
await (await import('./explain.js')).askQuestion(args.task, quickCfg);
|
|
812
791
|
}
|
|
813
792
|
else if (args.summarizeMode && args.summarizeTarget) {
|
|
814
|
-
await summarizeFile(args.summarizeTarget, quickCfg);
|
|
793
|
+
await (await import('./explain.js')).summarizeFile(args.summarizeTarget, quickCfg);
|
|
815
794
|
}
|
|
816
795
|
else {
|
|
817
796
|
tui.printError('Missing argument. Usage: koneck explain <file:line> | koneck ask "question" | koneck summarize <file>');
|
|
@@ -821,10 +800,10 @@ async function main() {
|
|
|
821
800
|
// ── Packs mode ─────────────────────────────────────────────────────────────
|
|
822
801
|
if (args.packsMode) {
|
|
823
802
|
if (args.packsAction === 'install' && args.packName) {
|
|
824
|
-
await installPluginPack(args.packName, args.cwd);
|
|
803
|
+
await (await import('./plugin-packs.js')).installPluginPack(args.packName, args.cwd);
|
|
825
804
|
}
|
|
826
805
|
else {
|
|
827
|
-
await listPluginPacks();
|
|
806
|
+
await (await import('./plugin-packs.js')).listPluginPacks();
|
|
828
807
|
}
|
|
829
808
|
process.exit(0);
|
|
830
809
|
}
|
|
@@ -836,7 +815,7 @@ async function main() {
|
|
|
836
815
|
maxTurns: resolved2.maxTurns, requireApproval: false, useWorktree: false,
|
|
837
816
|
verbose: args.verbose, cwd: args.cwd, apiKey: resolved2.apiKey,
|
|
838
817
|
};
|
|
839
|
-
await runTestGen(tgConfig, args.testGenTarget);
|
|
818
|
+
await (await import('./test-gen.js')).runTestGen(tgConfig, args.testGenTarget);
|
|
840
819
|
process.exit(0);
|
|
841
820
|
}
|
|
842
821
|
// ── Update mode ────────────────────────────────────────────────────────────
|
|
@@ -877,6 +856,7 @@ async function main() {
|
|
|
877
856
|
// ── Completion mode ────────────────────────────────────────────────────────
|
|
878
857
|
if (args.completionShell) {
|
|
879
858
|
try {
|
|
859
|
+
const { getCompletionScript } = await import('./completion.js');
|
|
880
860
|
process.stdout.write(getCompletionScript(args.completionShell));
|
|
881
861
|
}
|
|
882
862
|
catch (err) {
|
|
@@ -954,7 +934,7 @@ async function main() {
|
|
|
954
934
|
// Validate before the agent writes anything. A PR is a delivery action, so ambiguity about the
|
|
955
935
|
// branch or pre-existing work should stop here rather than surface after an expensive task.
|
|
956
936
|
if (args.prMode) {
|
|
957
|
-
const prepared = await preparePullRequest(args.cwd);
|
|
937
|
+
const prepared = await (await import('./pull-request.js')).preparePullRequest(args.cwd);
|
|
958
938
|
if (!prepared.ok) {
|
|
959
939
|
tui.printError(prepared.message);
|
|
960
940
|
process.exit(1);
|
|
@@ -965,39 +945,41 @@ async function main() {
|
|
|
965
945
|
// This used to generate KONECK.md, which nobody expects from a command called "setup".
|
|
966
946
|
// Project file generation lives at `koneck init` and the /init chat command.
|
|
967
947
|
if (args.setupMode) {
|
|
968
|
-
await runSetup();
|
|
948
|
+
await (await import('./setup.js')).runSetup();
|
|
969
949
|
process.exit(0);
|
|
970
950
|
}
|
|
971
951
|
// ── Watch mode ─────────────────────────────────────────────────────────────
|
|
972
952
|
if (args.watchMode) {
|
|
973
|
-
await runWatch(agentConfig, args.watchPattern);
|
|
953
|
+
await (await import('./watch.js')).runWatch(agentConfig, args.watchPattern);
|
|
974
954
|
return;
|
|
975
955
|
}
|
|
976
956
|
// ── Debug mode ─────────────────────────────────────────────────────────────
|
|
977
957
|
if (args.debugMode) {
|
|
978
958
|
tui.printBanner();
|
|
979
|
-
await runDebugger(agentConfig, args.debugCommand);
|
|
959
|
+
await (await import('./debugger.js')).runDebugger(agentConfig, args.debugCommand);
|
|
980
960
|
return;
|
|
981
961
|
}
|
|
982
962
|
// ── Refactor mode ──────────────────────────────────────────────────────────
|
|
983
963
|
if (args.refactorMode) {
|
|
984
|
-
await runRefactor((args.refactorAction ?? 'rename'), args.refactorArgs ?? [], agentConfig);
|
|
964
|
+
await (await import('./refactor.js')).runRefactor((args.refactorAction ?? 'rename'), args.refactorArgs ?? [], agentConfig);
|
|
985
965
|
process.exit(0);
|
|
986
966
|
}
|
|
987
967
|
// ── Pipeline mode ──────────────────────────────────────────────────────────
|
|
988
968
|
if (args.pipelineMode && args.task) {
|
|
989
969
|
tui.printBanner();
|
|
990
|
-
await runPipeline(args.task, agentConfig);
|
|
970
|
+
await (await import('./pipeline.js')).runPipeline(args.task, agentConfig);
|
|
991
971
|
return;
|
|
992
972
|
}
|
|
993
973
|
// ── Chat mode (explicit flag or no args at all) ────────────────────────────
|
|
994
974
|
if (args.chatMode || (!args.task && !args.resume && !args.listSessions)) {
|
|
995
975
|
// Ink owns the interactive terminal surface. The legacy readline chat
|
|
996
976
|
// remains available for redirected input and automation.
|
|
997
|
-
if (process.stdin.isTTY && process.stdout.isTTY)
|
|
998
|
-
await runInkChatMode(agentConfig);
|
|
999
|
-
|
|
1000
|
-
|
|
977
|
+
if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
978
|
+
await (await import('./ink-chat.js')).runInkChatMode(agentConfig);
|
|
979
|
+
}
|
|
980
|
+
else {
|
|
981
|
+
await (await import('./chat.js')).runChatMode(agentConfig);
|
|
982
|
+
}
|
|
1001
983
|
return;
|
|
1002
984
|
}
|
|
1003
985
|
// ── Resume mode ────────────────────────────────────────────────────────────
|
|
@@ -1027,7 +1009,7 @@ async function main() {
|
|
|
1027
1009
|
}
|
|
1028
1010
|
let session;
|
|
1029
1011
|
try {
|
|
1030
|
-
session = await runAgent(task, agentConfig, initialMessages, {
|
|
1012
|
+
session = await (await import('./engine.js')).runAgent(task, agentConfig, initialMessages, {
|
|
1031
1013
|
// Continue the session rather than forking a copy of it.
|
|
1032
1014
|
id: args.resume, turns: prevMeta.turns, totalTokens: prevMeta.totalTokens,
|
|
1033
1015
|
startedAt: prevMeta.startedAt, task: prevMeta.task,
|
|
@@ -1065,7 +1047,7 @@ async function main() {
|
|
|
1065
1047
|
tui.printThinking('');
|
|
1066
1048
|
let session;
|
|
1067
1049
|
try {
|
|
1068
|
-
session = await runAgent(task, agentConfig);
|
|
1050
|
+
session = await (await import('./engine.js')).runAgent(task, agentConfig);
|
|
1069
1051
|
}
|
|
1070
1052
|
catch (err) {
|
|
1071
1053
|
tui.printError(`Fatal: ${err instanceof Error ? err.message : String(err)}`);
|