@cydm/pie 1.0.3 → 1.0.5
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/builtin/extensions/plan-mode/index.js +27 -0
- package/dist/builtin/extensions/todo/index.js +2732 -143
- package/dist/cli.js +280 -16
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -65783,8 +65783,8 @@ function createExtensionContext2(extension, cwd, uiContext, abortFn, isIdleFn, h
|
|
|
65783
65783
|
sendUserMessage(content) {
|
|
65784
65784
|
actions?.sendUserMessage(content);
|
|
65785
65785
|
},
|
|
65786
|
-
setPlanMode(enabled) {
|
|
65787
|
-
actions?.setPlanMode(enabled);
|
|
65786
|
+
setPlanMode(enabled, options) {
|
|
65787
|
+
actions?.setPlanMode(enabled, options);
|
|
65788
65788
|
},
|
|
65789
65789
|
// Extended properties for subagent creation
|
|
65790
65790
|
get apiKey() {
|
|
@@ -65799,6 +65799,15 @@ function createExtensionContext2(extension, cwd, uiContext, abortFn, isIdleFn, h
|
|
|
65799
65799
|
getAllTools() {
|
|
65800
65800
|
return actions?.getAllTools ? actions.getAllTools() : actions?.getActiveTools()?.map((name) => ({ name, description: "" })) ?? [];
|
|
65801
65801
|
},
|
|
65802
|
+
getMessages() {
|
|
65803
|
+
return actions?.getMessages?.() ?? [];
|
|
65804
|
+
},
|
|
65805
|
+
getSessionMetadata() {
|
|
65806
|
+
return actions?.getSessionMetadata?.() ?? {};
|
|
65807
|
+
},
|
|
65808
|
+
setSessionMetadata(key, value) {
|
|
65809
|
+
actions?.setSessionMetadata?.(key, value);
|
|
65810
|
+
},
|
|
65802
65811
|
get yoloMode() {
|
|
65803
65812
|
return actions?.yoloMode ?? false;
|
|
65804
65813
|
}
|
|
@@ -66190,7 +66199,7 @@ var ExtensionRunner = class {
|
|
|
66190
66199
|
setActiveTools: (toolNames) => this.actions.setActiveTools(toolNames),
|
|
66191
66200
|
getActiveTools: () => this.actions.getActiveTools(),
|
|
66192
66201
|
sendUserMessage: (content) => this.actions.sendUserMessage(content),
|
|
66193
|
-
setPlanMode: (enabled) => this.actions.setPlanMode(enabled),
|
|
66202
|
+
setPlanMode: (enabled, options) => this.actions.setPlanMode(enabled, options),
|
|
66194
66203
|
get apiKey() {
|
|
66195
66204
|
return runner.actions.apiKey;
|
|
66196
66205
|
},
|
|
@@ -66201,6 +66210,9 @@ var ExtensionRunner = class {
|
|
|
66201
66210
|
return runner.actions.skills ?? [];
|
|
66202
66211
|
},
|
|
66203
66212
|
getAllTools: () => runner.actions.getAllTools(),
|
|
66213
|
+
getMessages: () => runner.actions.getMessages(),
|
|
66214
|
+
getSessionMetadata: () => runner.actions.getSessionMetadata(),
|
|
66215
|
+
setSessionMetadata: (key, value) => runner.actions.setSessionMetadata(key, value),
|
|
66204
66216
|
get yoloMode() {
|
|
66205
66217
|
return runner.actions.yoloMode ?? false;
|
|
66206
66218
|
}
|
|
@@ -69314,6 +69326,75 @@ function findFirstChangedLine(oldText, newText) {
|
|
|
69314
69326
|
return void 0;
|
|
69315
69327
|
}
|
|
69316
69328
|
|
|
69329
|
+
// src/todo/render.ts
|
|
69330
|
+
var TODO_STATUS_ICONS = {
|
|
69331
|
+
completed: "\u2713",
|
|
69332
|
+
"in-progress": "\u25C9",
|
|
69333
|
+
"not-started": "\u25CB"
|
|
69334
|
+
};
|
|
69335
|
+
function formatTodoTitle(todo, activeTheme) {
|
|
69336
|
+
if (todo.status === "completed") {
|
|
69337
|
+
return activeTheme.fg("dim", activeTheme.strikethrough(todo.title));
|
|
69338
|
+
}
|
|
69339
|
+
if (todo.status === "in-progress") {
|
|
69340
|
+
return activeTheme.fg("warning", todo.title);
|
|
69341
|
+
}
|
|
69342
|
+
return activeTheme.fg("muted", todo.title);
|
|
69343
|
+
}
|
|
69344
|
+
function formatTodoIcon(todo, activeTheme) {
|
|
69345
|
+
const icon = TODO_STATUS_ICONS[todo.status] ?? "?";
|
|
69346
|
+
if (todo.status === "completed") {
|
|
69347
|
+
return activeTheme.fg("success", icon);
|
|
69348
|
+
}
|
|
69349
|
+
if (todo.status === "in-progress") {
|
|
69350
|
+
return activeTheme.fg("warning", icon);
|
|
69351
|
+
}
|
|
69352
|
+
return activeTheme.fg("muted", icon);
|
|
69353
|
+
}
|
|
69354
|
+
function renderManageTodoListCall(args, activeTheme = theme) {
|
|
69355
|
+
let text = activeTheme.fg("toolTitle", activeTheme.bold("manage_todo_list "));
|
|
69356
|
+
text += activeTheme.fg("muted", args.operation || "...");
|
|
69357
|
+
if (args.operation === "write" && Array.isArray(args.todoList)) {
|
|
69358
|
+
const count = args.todoList.length;
|
|
69359
|
+
text += activeTheme.fg("dim", ` (${count} item${count === 1 ? "" : "s"})`);
|
|
69360
|
+
}
|
|
69361
|
+
return text;
|
|
69362
|
+
}
|
|
69363
|
+
function renderManageTodoListResult(result, options, activeTheme = theme) {
|
|
69364
|
+
const details = result.details;
|
|
69365
|
+
if (!details) {
|
|
69366
|
+
const firstText = result.content?.find((item) => item.type === "text" && typeof item.text === "string")?.text;
|
|
69367
|
+
return firstText || "";
|
|
69368
|
+
}
|
|
69369
|
+
if (details.error) {
|
|
69370
|
+
return activeTheme.fg("error", `\u2717 ${details.error}`);
|
|
69371
|
+
}
|
|
69372
|
+
const todos = details.todos || [];
|
|
69373
|
+
if (todos.length === 0) {
|
|
69374
|
+
return activeTheme.fg("dim", "No todos");
|
|
69375
|
+
}
|
|
69376
|
+
const completed = todos.filter((todo) => todo.status === "completed").length;
|
|
69377
|
+
let text = `${activeTheme.fg("success", "\u2713")} ${activeTheme.fg("muted", `${completed}/${todos.length} completed`)}`;
|
|
69378
|
+
if (options.expanded) {
|
|
69379
|
+
for (const todo of todos) {
|
|
69380
|
+
text += `
|
|
69381
|
+
${formatTodoIcon(todo, activeTheme)} ${activeTheme.fg("accent", `${todo.id}.`)} ${formatTodoTitle(todo, activeTheme)}`;
|
|
69382
|
+
}
|
|
69383
|
+
}
|
|
69384
|
+
return text;
|
|
69385
|
+
}
|
|
69386
|
+
function renderTodoWidgetLines(todos, activeTheme = theme) {
|
|
69387
|
+
if (todos.length === 0) {
|
|
69388
|
+
return [];
|
|
69389
|
+
}
|
|
69390
|
+
const completed = todos.filter((todo) => todo.status === "completed").length;
|
|
69391
|
+
const lines = [activeTheme.fg("muted", `Todo List - ${completed}/${todos.length} completed`)];
|
|
69392
|
+
for (const todo of todos) {
|
|
69393
|
+
lines.push(` ${formatTodoIcon(todo, activeTheme)} ${activeTheme.fg("accent", `${todo.id}.`)} ${formatTodoTitle(todo, activeTheme)}`);
|
|
69394
|
+
}
|
|
69395
|
+
return lines;
|
|
69396
|
+
}
|
|
69397
|
+
|
|
69317
69398
|
// src/components/tool-execution.ts
|
|
69318
69399
|
function formatSize3(bytes) {
|
|
69319
69400
|
if (bytes < 1024) return `${bytes}B`;
|
|
@@ -69396,7 +69477,13 @@ var ToolExecutionComponent = class extends Container {
|
|
|
69396
69477
|
formatToolExecution() {
|
|
69397
69478
|
let text = "";
|
|
69398
69479
|
const invalidArg = theme.fg("error", "[invalid arg]");
|
|
69399
|
-
if (this.toolName === "
|
|
69480
|
+
if (this.toolName === "manage_todo_list") {
|
|
69481
|
+
text = renderManageTodoListCall(this.args, theme);
|
|
69482
|
+
if (this.result) {
|
|
69483
|
+
text += `
|
|
69484
|
+
${renderManageTodoListResult(this.result, { expanded: this.expanded }, theme)}`;
|
|
69485
|
+
}
|
|
69486
|
+
} else if (this.toolName === "read") {
|
|
69400
69487
|
const rawPath = str(this.args?.file_path ?? this.args?.path);
|
|
69401
69488
|
const path18 = rawPath !== null ? shortenPath(rawPath) : null;
|
|
69402
69489
|
const offset = this.args?.offset;
|
|
@@ -69732,6 +69819,27 @@ ${theme.fg("error", "Error: " + errorOutput)}`;
|
|
|
69732
69819
|
}
|
|
69733
69820
|
};
|
|
69734
69821
|
|
|
69822
|
+
// src/components/todo-widget.ts
|
|
69823
|
+
var TodoWidgetComponent = class extends Container {
|
|
69824
|
+
state;
|
|
69825
|
+
constructor(state) {
|
|
69826
|
+
super();
|
|
69827
|
+
this.state = state;
|
|
69828
|
+
this.refresh();
|
|
69829
|
+
}
|
|
69830
|
+
refresh() {
|
|
69831
|
+
this.clear();
|
|
69832
|
+
const lines = renderTodoWidgetLines(this.state.read());
|
|
69833
|
+
if (lines.length === 0) {
|
|
69834
|
+
return;
|
|
69835
|
+
}
|
|
69836
|
+
this.addChild(new Spacer(1));
|
|
69837
|
+
for (const line of lines) {
|
|
69838
|
+
this.addChild(new Text(line, 1, 0));
|
|
69839
|
+
}
|
|
69840
|
+
}
|
|
69841
|
+
};
|
|
69842
|
+
|
|
69735
69843
|
// src/components/tree-selector.ts
|
|
69736
69844
|
var RESET = "\x1B[0m";
|
|
69737
69845
|
var INVERSE = "\x1B[7m";
|
|
@@ -74709,6 +74817,70 @@ function createFileCommandHandlers(fileManager, ui) {
|
|
|
74709
74817
|
};
|
|
74710
74818
|
}
|
|
74711
74819
|
|
|
74820
|
+
// src/todo/state-manager.ts
|
|
74821
|
+
var TodoStateManager = class {
|
|
74822
|
+
todos = [];
|
|
74823
|
+
read() {
|
|
74824
|
+
return this.todos.map((todo) => ({ ...todo }));
|
|
74825
|
+
}
|
|
74826
|
+
write(todos) {
|
|
74827
|
+
this.todos = todos.map((todo) => ({ ...todo }));
|
|
74828
|
+
}
|
|
74829
|
+
clear() {
|
|
74830
|
+
this.todos = [];
|
|
74831
|
+
}
|
|
74832
|
+
getStats() {
|
|
74833
|
+
const total = this.todos.length;
|
|
74834
|
+
const completed = this.todos.filter((todo) => todo.status === "completed").length;
|
|
74835
|
+
const inProgress = this.todos.filter((todo) => todo.status === "in-progress").length;
|
|
74836
|
+
return {
|
|
74837
|
+
total,
|
|
74838
|
+
completed,
|
|
74839
|
+
inProgress,
|
|
74840
|
+
notStarted: total - completed - inProgress
|
|
74841
|
+
};
|
|
74842
|
+
}
|
|
74843
|
+
validate(todos) {
|
|
74844
|
+
const errors = [];
|
|
74845
|
+
if (!Array.isArray(todos)) {
|
|
74846
|
+
return { valid: false, errors: ["todoList must be an array"] };
|
|
74847
|
+
}
|
|
74848
|
+
const validStatuses = /* @__PURE__ */ new Set(["not-started", "in-progress", "completed"]);
|
|
74849
|
+
for (let index = 0; index < todos.length; index++) {
|
|
74850
|
+
const item = todos[index];
|
|
74851
|
+
const prefix = `Item ${index + 1}`;
|
|
74852
|
+
if (typeof item?.id !== "number" || !Number.isInteger(item.id) || item.id < 1) {
|
|
74853
|
+
errors.push(`${prefix}: 'id' must be a positive integer`);
|
|
74854
|
+
}
|
|
74855
|
+
if (typeof item?.title !== "string" || item.title.trim().length === 0) {
|
|
74856
|
+
errors.push(`${prefix}: 'title' is required`);
|
|
74857
|
+
}
|
|
74858
|
+
if (typeof item?.description !== "string") {
|
|
74859
|
+
errors.push(`${prefix}: 'description' must be a string`);
|
|
74860
|
+
}
|
|
74861
|
+
if (!validStatuses.has(item?.status)) {
|
|
74862
|
+
errors.push(`${prefix}: 'status' must be one of: not-started, in-progress, completed`);
|
|
74863
|
+
}
|
|
74864
|
+
if (item?.id !== index + 1) {
|
|
74865
|
+
errors.push(`${prefix}: ids must be sequential starting from 1`);
|
|
74866
|
+
}
|
|
74867
|
+
}
|
|
74868
|
+
return { valid: errors.length === 0, errors };
|
|
74869
|
+
}
|
|
74870
|
+
restoreFromMessages(messages) {
|
|
74871
|
+
this.todos = [];
|
|
74872
|
+
for (const message of messages) {
|
|
74873
|
+
if (message.role !== "toolResult" || message.toolName !== "manage_todo_list") {
|
|
74874
|
+
continue;
|
|
74875
|
+
}
|
|
74876
|
+
const details = message.details;
|
|
74877
|
+
if (details?.todos) {
|
|
74878
|
+
this.todos = details.todos.map((todo) => ({ ...todo }));
|
|
74879
|
+
}
|
|
74880
|
+
}
|
|
74881
|
+
}
|
|
74882
|
+
};
|
|
74883
|
+
|
|
74712
74884
|
// src/interactive-mode.ts
|
|
74713
74885
|
var InteractiveMode = class {
|
|
74714
74886
|
agent;
|
|
@@ -74718,6 +74890,9 @@ var InteractiveMode = class {
|
|
|
74718
74890
|
footerData;
|
|
74719
74891
|
editor;
|
|
74720
74892
|
editorContainer;
|
|
74893
|
+
todoWidgetContainer;
|
|
74894
|
+
todoWidget;
|
|
74895
|
+
todoState = new TodoStateManager();
|
|
74721
74896
|
keybindings;
|
|
74722
74897
|
sessionManager;
|
|
74723
74898
|
skills;
|
|
@@ -74739,8 +74914,25 @@ var InteractiveMode = class {
|
|
|
74739
74914
|
toolOutputExpanded = false;
|
|
74740
74915
|
// Plan mode state
|
|
74741
74916
|
planModeEnabled = false;
|
|
74742
|
-
|
|
74743
|
-
|
|
74917
|
+
pendingPlanModeTransition = null;
|
|
74918
|
+
planModeEnterPrefix = `<system-reminder>
|
|
74919
|
+
# Plan Mode - System Reminder
|
|
74920
|
+
|
|
74921
|
+
CRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase. STRICTLY FORBIDDEN:
|
|
74922
|
+
ANY file edits, modifications, or system changes. Do NOT use write/edit or bash to manipulate files.
|
|
74923
|
+
Commands may ONLY read or inspect. This overrides all other instructions.
|
|
74924
|
+
|
|
74925
|
+
Your responsibility is to analyze, read, search, and produce a clear execution plan.
|
|
74926
|
+
</system-reminder>
|
|
74927
|
+
|
|
74928
|
+
`;
|
|
74929
|
+
planModeExitPrefix = `<system-reminder>
|
|
74930
|
+
Your operational mode has changed from plan to build.
|
|
74931
|
+
You are no longer in read-only mode.
|
|
74932
|
+
You may now make file changes, run shell commands, and use your tools as needed.
|
|
74933
|
+
</system-reminder>
|
|
74934
|
+
|
|
74935
|
+
`;
|
|
74744
74936
|
// File manager for multi-modal input
|
|
74745
74937
|
fileManager;
|
|
74746
74938
|
mentionHandler;
|
|
@@ -74827,6 +75019,21 @@ var InteractiveMode = class {
|
|
|
74827
75019
|
this.skillsSection = formatSkillsForPrompt(options.skills);
|
|
74828
75020
|
}
|
|
74829
75021
|
options;
|
|
75022
|
+
refreshTodoWidget() {
|
|
75023
|
+
this.todoWidget.refresh();
|
|
75024
|
+
this.todoWidgetContainer.invalidate?.();
|
|
75025
|
+
this.safeRequestRender();
|
|
75026
|
+
}
|
|
75027
|
+
syncSessionScopedState(messages) {
|
|
75028
|
+
const sessionMessages = messages ?? this.sessionManager.getMessages();
|
|
75029
|
+
this.todoState.restoreFromMessages(sessionMessages);
|
|
75030
|
+
this.refreshTodoWidget();
|
|
75031
|
+
this.emitExtensionEvent({
|
|
75032
|
+
type: "session:changed",
|
|
75033
|
+
sessionId: this.sessionManager.getActiveSession()?.id ?? null,
|
|
75034
|
+
metadata: { ...this.sessionManager.getActiveSession()?.metadata ?? {} }
|
|
75035
|
+
});
|
|
75036
|
+
}
|
|
74830
75037
|
async init() {
|
|
74831
75038
|
const savedLevel = this.options.settingsManager.getDefaultThinkingLevel();
|
|
74832
75039
|
if (savedLevel) {
|
|
@@ -74847,12 +75054,14 @@ var InteractiveMode = class {
|
|
|
74847
75054
|
});
|
|
74848
75055
|
this.updateTerminalTitle();
|
|
74849
75056
|
this.setupUI();
|
|
75057
|
+
this.syncSessionScopedState();
|
|
74850
75058
|
this.setupAutocomplete();
|
|
74851
75059
|
this.setupAgentSubscription();
|
|
74852
75060
|
this.setupEditorSubmitHandler();
|
|
74853
75061
|
this.setupKeybindings();
|
|
74854
75062
|
this.registerBuiltinCommands();
|
|
74855
75063
|
await this.loadExtensions();
|
|
75064
|
+
this.syncSessionScopedState();
|
|
74856
75065
|
this.emitExtensionEvent({ type: "agent:start" });
|
|
74857
75066
|
this.setupAutocomplete();
|
|
74858
75067
|
this.registerExtensionShortcuts();
|
|
@@ -74898,7 +75107,10 @@ var InteractiveMode = class {
|
|
|
74898
75107
|
void this.editor.onSubmit(content);
|
|
74899
75108
|
}
|
|
74900
75109
|
},
|
|
74901
|
-
setPlanMode: (enabled) => {
|
|
75110
|
+
setPlanMode: (enabled, options) => {
|
|
75111
|
+
if (this.planModeEnabled !== enabled || options?.forcePromptInjection) {
|
|
75112
|
+
this.pendingPlanModeTransition = enabled ? "enter" : "exit";
|
|
75113
|
+
}
|
|
74902
75114
|
this.planModeEnabled = enabled;
|
|
74903
75115
|
if (process.env.PIE_VERBOSE) {
|
|
74904
75116
|
console.error(`[Extension] Plan mode ${enabled ? "enabled" : "disabled"}`);
|
|
@@ -74911,6 +75123,14 @@ var InteractiveMode = class {
|
|
|
74911
75123
|
parameters: t.parameters
|
|
74912
75124
|
}));
|
|
74913
75125
|
},
|
|
75126
|
+
getMessages: () => this.agent.state.messages,
|
|
75127
|
+
getSessionMetadata: () => ({ ...this.sessionManager.getActiveSession()?.metadata ?? {} }),
|
|
75128
|
+
setSessionMetadata: (key, value) => {
|
|
75129
|
+
const activeSession = this.sessionManager.getActiveSession();
|
|
75130
|
+
if (!activeSession) return;
|
|
75131
|
+
activeSession.metadata[key] = value;
|
|
75132
|
+
activeSession.isDirty = true;
|
|
75133
|
+
},
|
|
74914
75134
|
// YOLO mode status for subagent sandbox inheritance
|
|
74915
75135
|
// Note: Using arrow function to capture correct 'this'
|
|
74916
75136
|
yoloMode: this.yoloMode
|
|
@@ -75428,7 +75648,10 @@ var InteractiveMode = class {
|
|
|
75428
75648
|
void this.editor.onSubmit(content);
|
|
75429
75649
|
}
|
|
75430
75650
|
},
|
|
75431
|
-
setPlanMode: (enabled) => {
|
|
75651
|
+
setPlanMode: (enabled, options) => {
|
|
75652
|
+
if (this.planModeEnabled !== enabled || options?.forcePromptInjection) {
|
|
75653
|
+
this.pendingPlanModeTransition = enabled ? "enter" : "exit";
|
|
75654
|
+
}
|
|
75432
75655
|
this.planModeEnabled = enabled;
|
|
75433
75656
|
if (process.env.PIE_VERBOSE) {
|
|
75434
75657
|
console.error(`[Extension] Plan mode ${enabled ? "enabled" : "disabled"}`);
|
|
@@ -75448,6 +75671,14 @@ var InteractiveMode = class {
|
|
|
75448
75671
|
parameters: t.parameters
|
|
75449
75672
|
}));
|
|
75450
75673
|
},
|
|
75674
|
+
getMessages: () => this.agent.state.messages,
|
|
75675
|
+
getSessionMetadata: () => ({ ...this.sessionManager.getActiveSession()?.metadata ?? {} }),
|
|
75676
|
+
setSessionMetadata: (key, value) => {
|
|
75677
|
+
const activeSession = this.sessionManager.getActiveSession();
|
|
75678
|
+
if (!activeSession) return;
|
|
75679
|
+
activeSession.metadata[key] = value;
|
|
75680
|
+
activeSession.isDirty = true;
|
|
75681
|
+
},
|
|
75451
75682
|
// Provide YOLO mode status for subagent sandbox inheritance
|
|
75452
75683
|
yoloMode: this.yoloMode
|
|
75453
75684
|
};
|
|
@@ -75744,6 +75975,9 @@ ${newToolsSection}`
|
|
|
75744
75975
|
contextWindow: this.options.model?.contextWindow ?? 0
|
|
75745
75976
|
});
|
|
75746
75977
|
this.editorContainer = new Container();
|
|
75978
|
+
this.todoWidgetContainer = new Container();
|
|
75979
|
+
this.todoWidget = new TodoWidgetComponent(this.todoState);
|
|
75980
|
+
this.todoWidgetContainer.addChild(this.todoWidget);
|
|
75747
75981
|
const editorTheme = getEditorTheme();
|
|
75748
75982
|
this.editor = new Editor(this.ui, editorTheme, { paddingX: 1 });
|
|
75749
75983
|
this.editor.onChange = () => {
|
|
@@ -75757,6 +75991,7 @@ ${newToolsSection}`
|
|
|
75757
75991
|
this.editorContainer.addChild(this.editor);
|
|
75758
75992
|
this.ui.addChild(this.chatContainer);
|
|
75759
75993
|
this.ui.addChild(this.pendingMessagesContainer);
|
|
75994
|
+
this.ui.addChild(this.todoWidgetContainer);
|
|
75760
75995
|
this.ui.addChild(new Spacer());
|
|
75761
75996
|
this.ui.addChild(this.footer);
|
|
75762
75997
|
this.ui.addChild(this.editorContainer);
|
|
@@ -75996,7 +76231,18 @@ ${newToolsSection}`
|
|
|
75996
76231
|
thinkingContent += content2.thinking || "";
|
|
75997
76232
|
} else if (content2.type === "toolCall") {
|
|
75998
76233
|
const toolCall = content2;
|
|
75999
|
-
const
|
|
76234
|
+
const contentIndex = message.content.indexOf(content2);
|
|
76235
|
+
const partialToolId = `__partial_tool__:${contentIndex}`;
|
|
76236
|
+
const toolId = toolCall.id || partialToolId;
|
|
76237
|
+
if (toolCall.id && !this.pendingTools.has(toolCall.id) && this.pendingTools.has(partialToolId)) {
|
|
76238
|
+
const existingComponent = this.pendingTools.get(partialToolId);
|
|
76239
|
+
if (existingComponent) {
|
|
76240
|
+
this.pendingTools.delete(partialToolId);
|
|
76241
|
+
this.pendingTools.set(toolCall.id, existingComponent);
|
|
76242
|
+
existingComponent.updateArgs(toolCall.arguments);
|
|
76243
|
+
}
|
|
76244
|
+
continue;
|
|
76245
|
+
}
|
|
76000
76246
|
if (!this.pendingTools.has(toolId)) {
|
|
76001
76247
|
const toolComponent = new ToolExecutionComponent(
|
|
76002
76248
|
toolCall.name,
|
|
@@ -76084,6 +76330,13 @@ ${newToolsSection}`
|
|
|
76084
76330
|
);
|
|
76085
76331
|
}
|
|
76086
76332
|
}
|
|
76333
|
+
if (event.toolName === "manage_todo_list") {
|
|
76334
|
+
const details = event.result?.details;
|
|
76335
|
+
if (details?.todos) {
|
|
76336
|
+
this.todoState.write(details.todos);
|
|
76337
|
+
}
|
|
76338
|
+
this.refreshTodoWidget();
|
|
76339
|
+
}
|
|
76087
76340
|
this.footer.setState({ lifecycleEvent: "tool_execution_end" });
|
|
76088
76341
|
this.emitExtensionEvent({
|
|
76089
76342
|
type: "tool:execution:end",
|
|
@@ -76652,15 +76905,14 @@ ${newToolsSection}`
|
|
|
76652
76905
|
this.ui.requestRender();
|
|
76653
76906
|
await new Promise((resolve5) => setImmediate(resolve5));
|
|
76654
76907
|
let finalContent = messageContent;
|
|
76655
|
-
|
|
76908
|
+
const planPrefix = this.pendingPlanModeTransition === "enter" ? this.planModeEnterPrefix : this.pendingPlanModeTransition === "exit" ? this.planModeExitPrefix : null;
|
|
76909
|
+
if (planPrefix) {
|
|
76656
76910
|
if (typeof messageContent === "string") {
|
|
76657
|
-
finalContent =
|
|
76911
|
+
finalContent = planPrefix + messageContent;
|
|
76658
76912
|
} else if (Array.isArray(messageContent)) {
|
|
76659
|
-
finalContent = [
|
|
76660
|
-
{ type: "text", text: this.planModeEnterPrefix },
|
|
76661
|
-
...messageContent
|
|
76662
|
-
];
|
|
76913
|
+
finalContent = [{ type: "text", text: planPrefix }, ...messageContent];
|
|
76663
76914
|
}
|
|
76915
|
+
this.pendingPlanModeTransition = null;
|
|
76664
76916
|
}
|
|
76665
76917
|
this.agent.prompt(finalContent).catch((err) => {
|
|
76666
76918
|
this.showError(`Agent error: ${err.message}`);
|
|
@@ -77092,6 +77344,8 @@ ${newToolsSection}`
|
|
|
77092
77344
|
this.agent.sessionId = activeSession.id;
|
|
77093
77345
|
}
|
|
77094
77346
|
this.syncSessionModelMetadata();
|
|
77347
|
+
this.planModeEnabled = false;
|
|
77348
|
+
this.pendingPlanModeTransition = null;
|
|
77095
77349
|
this.updateTerminalTitle();
|
|
77096
77350
|
this.chatContainer.clear();
|
|
77097
77351
|
this.streamingComponent = void 0;
|
|
@@ -77102,6 +77356,7 @@ ${newToolsSection}`
|
|
|
77102
77356
|
this.updatePendingMessagesDisplay();
|
|
77103
77357
|
this.chatContainer.addChild(new Spacer(1));
|
|
77104
77358
|
this.chatContainer.addChild(new Text(theme.fg("accent", "\u2713 New session started"), 1, 0));
|
|
77359
|
+
this.syncSessionScopedState();
|
|
77105
77360
|
this.ui.requestRender();
|
|
77106
77361
|
}
|
|
77107
77362
|
handleCtrlC() {
|
|
@@ -77427,12 +77682,15 @@ ${newToolsSection}`
|
|
|
77427
77682
|
this.updateTerminalTitle();
|
|
77428
77683
|
const messages = this.sessionManager.getMessages();
|
|
77429
77684
|
const conversationMessages = messages.filter(
|
|
77430
|
-
(msg) => msg.role === "user" || msg.role === "assistant"
|
|
77685
|
+
(msg) => msg.role === "user" || msg.role === "assistant" || msg.role === "toolResult"
|
|
77431
77686
|
);
|
|
77432
77687
|
this.agent.resetProcessingState();
|
|
77433
77688
|
this.agent.replaceMessages(conversationMessages);
|
|
77434
77689
|
this.lastSyncedMessageCount = this.agent.state.messages.length;
|
|
77690
|
+
this.syncSessionScopedState(messages);
|
|
77435
77691
|
this.chatContainer.clear();
|
|
77692
|
+
this.streamingComponent = void 0;
|
|
77693
|
+
this.pendingTools.clear();
|
|
77436
77694
|
this.lastStatusSpacer = void 0;
|
|
77437
77695
|
this.lastStatusText = void 0;
|
|
77438
77696
|
this.messageQueue = [];
|
|
@@ -77614,7 +77872,10 @@ ${newToolsSection}`
|
|
|
77614
77872
|
const messages = this.sessionManager.getMessages();
|
|
77615
77873
|
this.agent.replaceMessages(messages);
|
|
77616
77874
|
this.lastSyncedMessageCount = this.agent.state.messages.length;
|
|
77875
|
+
this.syncSessionScopedState(messages);
|
|
77617
77876
|
this.chatContainer.clear();
|
|
77877
|
+
this.streamingComponent = void 0;
|
|
77878
|
+
this.pendingTools.clear();
|
|
77618
77879
|
this.lastStatusSpacer = void 0;
|
|
77619
77880
|
this.lastStatusText = void 0;
|
|
77620
77881
|
this.messageQueue = [];
|
|
@@ -77642,7 +77903,10 @@ ${newToolsSection}`
|
|
|
77642
77903
|
const messages = this.sessionManager.getMessages();
|
|
77643
77904
|
this.agent.replaceMessages(messages);
|
|
77644
77905
|
this.lastSyncedMessageCount = this.agent.state.messages.length;
|
|
77906
|
+
this.syncSessionScopedState(messages);
|
|
77645
77907
|
this.chatContainer.clear();
|
|
77908
|
+
this.streamingComponent = void 0;
|
|
77909
|
+
this.pendingTools.clear();
|
|
77646
77910
|
this.lastStatusSpacer = void 0;
|
|
77647
77911
|
this.lastStatusText = void 0;
|
|
77648
77912
|
this.messageQueue = [];
|