ikie-cli 0.1.17 → 0.1.19
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/agent.d.ts +5 -0
- package/dist/agent.js +20 -2
- package/dist/repl.js +8 -8
- package/dist/theme.d.ts +1 -1
- package/dist/theme.js +1 -1
- package/package.json +1 -1
package/dist/agent.d.ts
CHANGED
|
@@ -15,6 +15,11 @@ export interface AgentTurnStats {
|
|
|
15
15
|
filesChanged: number;
|
|
16
16
|
}
|
|
17
17
|
export declare function estimateTokens(chars: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* Extract the most useful upstream error message from an OpenAI SDK error.
|
|
20
|
+
* The SDK wraps provider responses; we prefer the nested error.message if it exists.
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractUpstreamError(err: unknown): string;
|
|
18
23
|
/**
|
|
19
24
|
* Safely restore previously-saved stdin listeners after a raw-mode interaction
|
|
20
25
|
* (permission prompt, ask_user, theme picker, agent turn).
|
package/dist/agent.js
CHANGED
|
@@ -6,6 +6,20 @@ import { c, toolLine, permissionPrompt, toolSuccessLine, toolErrorLine, toolOutp
|
|
|
6
6
|
export function estimateTokens(chars) {
|
|
7
7
|
return Math.max(1, Math.round(chars / 4));
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Extract the most useful upstream error message from an OpenAI SDK error.
|
|
11
|
+
* The SDK wraps provider responses; we prefer the nested error.message if it exists.
|
|
12
|
+
*/
|
|
13
|
+
export function extractUpstreamError(err) {
|
|
14
|
+
if (!(err instanceof Error))
|
|
15
|
+
return String(err);
|
|
16
|
+
// OpenAI SDK v4 error shape: error.error?.message or error.message
|
|
17
|
+
const e = err;
|
|
18
|
+
const upstream = e.error?.message ||
|
|
19
|
+
e.response?.data?.error?.message ||
|
|
20
|
+
e.message;
|
|
21
|
+
return upstream || 'Unknown error';
|
|
22
|
+
}
|
|
9
23
|
/**
|
|
10
24
|
* Safely restore previously-saved stdin listeners after a raw-mode interaction
|
|
11
25
|
* (permission prompt, ask_user, theme picker, agent turn).
|
|
@@ -380,7 +394,7 @@ export class Agent {
|
|
|
380
394
|
}
|
|
381
395
|
catch (err) {
|
|
382
396
|
spinner.stop();
|
|
383
|
-
throw err;
|
|
397
|
+
throw new Error(extractUpstreamError(err));
|
|
384
398
|
}
|
|
385
399
|
let textContent = '';
|
|
386
400
|
let thinkingContent = '';
|
|
@@ -446,7 +460,7 @@ export class Agent {
|
|
|
446
460
|
// user cancelled — swallow
|
|
447
461
|
}
|
|
448
462
|
else {
|
|
449
|
-
throw err;
|
|
463
|
+
throw new Error(extractUpstreamError(err));
|
|
450
464
|
}
|
|
451
465
|
}
|
|
452
466
|
finally {
|
|
@@ -482,6 +496,10 @@ export class Agent {
|
|
|
482
496
|
...this.buildParams(),
|
|
483
497
|
}, requestOpts);
|
|
484
498
|
}
|
|
499
|
+
catch (err) {
|
|
500
|
+
spinner.stop();
|
|
501
|
+
throw new Error(extractUpstreamError(err));
|
|
502
|
+
}
|
|
485
503
|
finally {
|
|
486
504
|
spinner.stop();
|
|
487
505
|
}
|
package/dist/repl.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as readline from 'node:readline';
|
|
2
2
|
import { execSync, exec } from 'child_process';
|
|
3
|
-
import { restoreStdinListeners } from './agent.js';
|
|
3
|
+
import { restoreStdinListeners, extractUpstreamError } from './agent.js';
|
|
4
4
|
import { c, PROMPT, CONTINUE_PROMPT, PROMPT_ARROW, printPromptHeader, modeTag, drawBanner, infoLine, successLine, errorLine, THEMES, setTheme, stripAnsi, contextRing, renderSlashMenu, } from './theme.js';
|
|
5
5
|
import { renderMarkdown } from './renderer.js';
|
|
6
6
|
import { loadAllMemory } from './memory.js';
|
|
@@ -1068,10 +1068,11 @@ export async function startREPL(agent, config, projectContext, oneShot) {
|
|
|
1068
1068
|
forwardToReadline(data);
|
|
1069
1069
|
return;
|
|
1070
1070
|
}
|
|
1071
|
+
// Multi-line paste without bracketed-paste markers: treat the whole chunk
|
|
1072
|
+
// as a pasted block so it doesn't submit immediately.
|
|
1071
1073
|
if (!pasteMode && !text.includes('\x1b[200~') && /[\r\n]/.test(text.trim()) && text.length > 3) {
|
|
1072
1074
|
closeMenu();
|
|
1073
|
-
|
|
1074
|
-
rl.write(normalized);
|
|
1075
|
+
insertPasteBlock(text);
|
|
1075
1076
|
return;
|
|
1076
1077
|
}
|
|
1077
1078
|
let rest = text;
|
|
@@ -1083,8 +1084,7 @@ export async function startREPL(agent, config, projectContext, oneShot) {
|
|
|
1083
1084
|
return;
|
|
1084
1085
|
}
|
|
1085
1086
|
pasteBuffer += rest.slice(0, end);
|
|
1086
|
-
|
|
1087
|
-
rl.write(normalized);
|
|
1087
|
+
insertPasteBlock(pasteBuffer);
|
|
1088
1088
|
pasteBuffer = '';
|
|
1089
1089
|
pasteMode = false;
|
|
1090
1090
|
rest = rest.slice(end + '\x1b[201~'.length);
|
|
@@ -1268,8 +1268,8 @@ export async function startREPL(agent, config, projectContext, oneShot) {
|
|
|
1268
1268
|
}
|
|
1269
1269
|
}
|
|
1270
1270
|
}
|
|
1271
|
-
// Plan mode:
|
|
1272
|
-
if (agent.getMode() === 'plan' && !abortController.signal.aborted) {
|
|
1271
|
+
// Plan mode: only offer execution if the agent actually produced a plan (used tools).
|
|
1272
|
+
if (agent.getMode() === 'plan' && !abortController.signal.aborted && agent.getLastTurnStats().toolCalls > 0) {
|
|
1273
1273
|
process.stdin.removeListener('data', cancelHandler);
|
|
1274
1274
|
const go = await confirmExecutePlan();
|
|
1275
1275
|
process.stdin.on('data', cancelHandler);
|
|
@@ -1295,7 +1295,7 @@ export async function startREPL(agent, config, projectContext, oneShot) {
|
|
|
1295
1295
|
restoredImages = true;
|
|
1296
1296
|
}
|
|
1297
1297
|
const e = err;
|
|
1298
|
-
console.error(`\n${errorLine(`Error: ${
|
|
1298
|
+
console.error(`\n${errorLine(`Error: ${extractUpstreamError(err)}`)}`);
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
1301
1301
|
finally {
|
package/dist/theme.d.ts
CHANGED
package/dist/theme.js
CHANGED
|
@@ -3,7 +3,7 @@ import os from 'os';
|
|
|
3
3
|
import { join as pathJoin, basename } from 'path';
|
|
4
4
|
import { existsSync, readFileSync } from 'fs';
|
|
5
5
|
import { loadConfig, saveConfig } from './config.js';
|
|
6
|
-
export const VERSION = '0.1.
|
|
6
|
+
export const VERSION = '0.1.19';
|
|
7
7
|
const IKIE_BANNER = [
|
|
8
8
|
' ██╗██╗ ██╗██╗███████╗',
|
|
9
9
|
' ██║██║ ██╔╝██║██╔════╝',
|