code-ollama 0.24.1 → 0.25.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.
@@ -1,4 +1,4 @@
1
- import { $ as NAME, A as loadConfig, B as ASSISTANT, C as checkHealth, D as pullModel, E as listModels, F as withSystemMessage, G as BACK, H as USER, I as HEADER_PREFIX, J as LABEL, K as CATALOG, L as WARNING, M as removeClipboardImage, N as saveClipboardImage, O as sanitizeAssistantContent, P as resetSystemMessage, Q as REJECT, R as LIST$1, S as TOOL_INTENT_CORRECTION, T as hasUncalledToolIntent, U as PLAN_GENERATION_INSTRUCTION, V as SYSTEM, W as PLAN_INSTRUCTION, X as SAFE, Y as PLAN, Z as APPROVE, _ as loadSession, a as normalizeToolCall, b as reset, c as WRITE_TOOLS, d as write, et as VERSION, f as appendMessage, g as listSessions, h as deleteSessionIfEmpty, i as formatToolResultContent, j as saveConfig, k as streamChat, l as tick, m as deleteSession, n as executeTool, o as READ_TOOLS, p as createSession, q as AUTO, r as executeToolCall, s as TOOLS, t as checkForUpdate, tt as LIST, u as color, v as updateSessionModel, w as deleteModel, x as setClearHandler, y as clear, z as getTheme } from "../cli.js";
1
+ import { $ as LABEL, A as loadConfig, B as CHAT, C as checkHealth, D as pullModel, E as listModels, F as withSystemMessage, G as ASSISTANT, H as SEARCH_SETTINGS, I as HEADER_PREFIX, J as PLAN_GENERATION_INSTRUCTION, K as SYSTEM, L as WARNING, M as removeClipboardImage, N as saveClipboardImage, O as sanitizeAssistantContent, P as resetSystemMessage, Q as AUTO, R as LIST$1, S as TOOL_INTENT_CORRECTION, T as hasUncalledToolIntent, U as SESSION_MANAGER, V as MODEL_MANAGER, W as THEME_SETTINGS, X as BACK, Y as PLAN_INSTRUCTION, Z as CATALOG, _ as loadSession, a as normalizeToolCall, at as VERSION, b as reset, c as WRITE_TOOLS, d as write, et as PLAN, f as appendMessage, g as listSessions, h as deleteSessionIfEmpty, i as formatToolResultContent, it as NAME, j as saveConfig, k as streamChat, l as tick, m as deleteSession, n as executeTool, nt as APPROVE, o as READ_TOOLS, ot as LIST, p as createSession, q as USER, r as executeToolCall, rt as REJECT, s as TOOLS, t as checkForUpdate, tt as SAFE, u as color, v as updateSessionModel, w as deleteModel, x as setClearHandler, y as clear, z as getTheme } from "../cli.js";
2
2
  import { existsSync, readdirSync, statSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
4
  import { basename, extname, isAbsolute, join, relative, resolve } from "node:path";
@@ -3255,46 +3255,36 @@ function UpdateBanner({ onLoad, theme }) {
3255
3255
  });
3256
3256
  }
3257
3257
  //#endregion
3258
- //#region src/components/App/constants.ts
3259
- var Screen = /* @__PURE__ */ function(Screen) {
3260
- Screen["Chat"] = "chat";
3261
- Screen["ModelManager"] = "model-manager";
3262
- Screen["SearchSettings"] = "search-settings";
3263
- Screen["SessionManager"] = "session-manager";
3264
- Screen["ThemeSettings"] = "theme-settings";
3265
- return Screen;
3266
- }({});
3267
- //#endregion
3268
3258
  //#region src/components/App/hooks/useScreenRouter.ts
3269
- function useScreenRouter() {
3259
+ function useScreenRouter({ initialScreen } = {}) {
3270
3260
  const { exit } = useApp();
3271
- const [currentScreen, setScreen] = useState(Screen.Chat);
3261
+ const [currentScreen, setScreen] = useState(initialScreen ?? "chat");
3272
3262
  return {
3273
3263
  currentScreen,
3274
3264
  setScreen,
3275
3265
  handleClose: useCallback(() => {
3276
- setScreen(Screen.Chat);
3266
+ setScreen(CHAT);
3277
3267
  }, []),
3278
3268
  handleCommand: useCallback((command, callbacks) => {
3279
3269
  const { onCreateSession, onSetPreviewThemeId, model, theme } = callbacks;
3280
3270
  switch (command) {
3281
3271
  case "/session":
3282
- setScreen(Screen.SessionManager);
3272
+ setScreen(SESSION_MANAGER);
3283
3273
  break;
3284
3274
  case "/model":
3285
- setScreen(Screen.ModelManager);
3275
+ setScreen(MODEL_MANAGER);
3286
3276
  break;
3287
3277
  case "/search":
3288
- setScreen(Screen.SearchSettings);
3278
+ setScreen(SEARCH_SETTINGS);
3289
3279
  break;
3290
3280
  case "/theme":
3291
3281
  onSetPreviewThemeId(theme);
3292
- setScreen(Screen.ThemeSettings);
3282
+ setScreen(THEME_SETTINGS);
3293
3283
  break;
3294
3284
  case "/clear": {
3295
3285
  resetSystemMessage();
3296
3286
  const nextSession = onCreateSession(model);
3297
- setScreen(Screen.Chat);
3287
+ setScreen(CHAT);
3298
3288
  clear(nextSession.metadata.id);
3299
3289
  break;
3300
3290
  }
@@ -3381,7 +3371,7 @@ function useThemeSettings({ currentTheme, onUpdateConfig, setScreen }) {
3381
3371
  activeTheme,
3382
3372
  handleThemeClose: useCallback(() => {
3383
3373
  setPreviewThemeId(null);
3384
- setScreen(Screen.Chat);
3374
+ setScreen(CHAT);
3385
3375
  }, [setScreen]),
3386
3376
  handleThemePreview,
3387
3377
  handleThemeSave: useCallback((themeId) => {
@@ -3473,13 +3463,13 @@ function ReadinessCheck({ errorMessage, onCommand, setupState, theme = getTheme(
3473
3463
  }
3474
3464
  //#endregion
3475
3465
  //#region src/components/App/App.tsx
3476
- function App({ sessionId }) {
3466
+ function App({ sessionId, initialScreen }) {
3477
3467
  const [appConfig, setConfig] = useState(() => loadConfig());
3478
3468
  const [mode, setMode] = useState(SAFE);
3479
3469
  const [isLoaded, setIsLoaded] = useState(false);
3480
3470
  const [setupState, setSetupState] = useState(() => appConfig.model ? ReadinessState.Ready : ReadinessState.MissingModelConfig);
3481
3471
  const [setupErrorMessage, setSetupErrorMessage] = useState(null);
3482
- const { currentScreen, setScreen, handleClose, handleCommand } = useScreenRouter();
3472
+ const { currentScreen, setScreen, handleClose, handleCommand } = useScreenRouter({ initialScreen });
3483
3473
  const { activeSession, setSession, handleCreateSession, handleOpenSession, handleDeleteSession, handleMessagesChange } = useSessionManager({
3484
3474
  sessionId,
3485
3475
  model: appConfig.model ?? "",
@@ -3496,7 +3486,7 @@ function App({ sessionId }) {
3496
3486
  }
3497
3487
  return;
3498
3488
  }
3499
- if (currentScreen !== Screen.Chat) return;
3489
+ if (currentScreen !== "chat") return;
3500
3490
  // v8 ignore next
3501
3491
  if (isMounted) {
3502
3492
  setSetupErrorMessage(null);
@@ -3533,7 +3523,7 @@ function App({ sessionId }) {
3533
3523
  ...current,
3534
3524
  metadata: updateSessionModel(current.metadata.id, newModel)
3535
3525
  }));
3536
- setScreen(Screen.Chat);
3526
+ setScreen(CHAT);
3537
3527
  }, [setScreen, setSession]);
3538
3528
  const { activeTheme, handleThemeClose, handleThemePreview, handleThemeSave, setPreviewThemeId } = useThemeSettings({
3539
3529
  currentTheme: appConfig.theme,
@@ -3556,7 +3546,7 @@ function App({ sessionId }) {
3556
3546
  ]);
3557
3547
  let screenContent;
3558
3548
  switch (currentScreen) {
3559
- case Screen.ModelManager:
3549
+ case MODEL_MANAGER:
3560
3550
  screenContent = /* @__PURE__ */ jsx(ModelManager, {
3561
3551
  currentModel: appConfig.model ?? "",
3562
3552
  onSelect: handleUpdateConfig,
@@ -3564,7 +3554,7 @@ function App({ sessionId }) {
3564
3554
  theme: activeTheme
3565
3555
  });
3566
3556
  break;
3567
- case Screen.SearchSettings:
3557
+ case SEARCH_SETTINGS:
3568
3558
  screenContent = /* @__PURE__ */ jsx(SearchSettings, {
3569
3559
  currentUrl: appConfig.searxngBaseUrl,
3570
3560
  onSave: handleUpdateConfig,
@@ -3572,26 +3562,26 @@ function App({ sessionId }) {
3572
3562
  theme: activeTheme
3573
3563
  });
3574
3564
  break;
3575
- case Screen.SessionManager:
3565
+ case SESSION_MANAGER:
3576
3566
  screenContent = /* @__PURE__ */ jsx(SessionManager, {
3577
3567
  currentSessionId: activeSession.metadata.id,
3578
3568
  onClose: handleClose,
3579
3569
  onDelete: (sessionId) => {
3580
3570
  handleDeleteSession(sessionId);
3581
- setScreen(Screen.SessionManager);
3571
+ setScreen(SESSION_MANAGER);
3582
3572
  },
3583
3573
  onNew: () => {
3584
3574
  handleCreateSession();
3585
- setScreen(Screen.Chat);
3575
+ setScreen(CHAT);
3586
3576
  },
3587
3577
  onOpen: (sessionId) => {
3588
3578
  handleOpenSession(sessionId);
3589
- setScreen(Screen.Chat);
3579
+ setScreen(CHAT);
3590
3580
  },
3591
3581
  theme: activeTheme
3592
3582
  });
3593
3583
  break;
3594
- case Screen.ThemeSettings:
3584
+ case THEME_SETTINGS:
3595
3585
  screenContent = /* @__PURE__ */ jsx(ThemeSettings, {
3596
3586
  currentTheme: appConfig.theme,
3597
3587
  onClose: handleThemeClose,
@@ -3599,7 +3589,7 @@ function App({ sessionId }) {
3599
3589
  onSave: handleThemeSave
3600
3590
  });
3601
3591
  break;
3602
- case Screen.Chat:
3592
+ case CHAT:
3603
3593
  screenContent = setupState === ReadinessState.Ready ? /* @__PURE__ */ jsx(Chat, {
3604
3594
  initialMessages: activeSession.messages,
3605
3595
  model: appConfig.model,
@@ -3687,15 +3677,18 @@ function ExitHint({ action = "go back" }) {
3687
3677
  }
3688
3678
  //#endregion
3689
3679
  //#region src/tui.tsx
3690
- function renderApp(sessionId) {
3680
+ function renderApp(options = {}) {
3691
3681
  let resetKey = 0;
3692
- const app = render(/* @__PURE__ */ jsx(App, { sessionId }, resetKey), {
3682
+ const app = render(/* @__PURE__ */ jsx(App, {
3683
+ sessionId: options.sessionId,
3684
+ initialScreen: options.initialScreen
3685
+ }, resetKey), {
3693
3686
  exitOnCtrlC: false,
3694
3687
  maxFps: 60
3695
3688
  });
3696
3689
  setClearHandler((nextSessionId) => {
3697
3690
  reset();
3698
- app.rerender(/* @__PURE__ */ jsx(App, { sessionId: nextSessionId ?? sessionId }, ++resetKey));
3691
+ app.rerender(/* @__PURE__ */ jsx(App, { sessionId: nextSessionId ?? options.sessionId }, ++resetKey));
3699
3692
  });
3700
3693
  }
3701
3694
  //#endregion
package/dist/cli.js CHANGED
@@ -50,7 +50,7 @@ var LIST$1 = [
50
50
  //#endregion
51
51
  //#region package.json
52
52
  var name = "code-ollama";
53
- var version = "0.24.1";
53
+ var version = "0.25.0";
54
54
  //#endregion
55
55
  //#region src/constants/package.ts
56
56
  var NAME = name;
@@ -252,6 +252,13 @@ var USER = "user";
252
252
  var ASSISTANT = "assistant";
253
253
  var SYSTEM = "system";
254
254
  //#endregion
255
+ //#region src/constants/screen.ts
256
+ var CHAT = "chat";
257
+ var MODEL_MANAGER = "model-manager";
258
+ var SEARCH_SETTINGS = "search-settings";
259
+ var SESSION_MANAGER = "session-manager";
260
+ var THEME_SETTINGS = "theme-settings";
261
+ //#endregion
255
262
  //#region src/constants/theme.ts
256
263
  var DEFAULT_THEME_ID = "github-dark";
257
264
  var LIST = [
@@ -1756,15 +1763,19 @@ cli.command("run <model> <prompt>", "Run a one-off prompt").action(async (model,
1756
1763
  process.exitCode = 1;
1757
1764
  }
1758
1765
  });
1759
- cli.command("resume <sessionId>", "Resume a saved session").action(async (sessionId) => {
1766
+ cli.command("resume [sessionId]", "Resume a saved session").action(async (sessionId) => {
1760
1767
  try {
1768
+ if (!sessionId) {
1769
+ await launchTui({ initialScreen: SESSION_MANAGER });
1770
+ return;
1771
+ }
1761
1772
  const loaded = loadSession(sessionId);
1762
1773
  if (loaded.metadata.directory && loaded.metadata.directory !== process.cwd()) {
1763
1774
  writeError(color(`${WARNING} Cannot resume: session belongs to ${loaded.metadata.directory}\n`, "yellow"));
1764
1775
  process.exitCode = 1;
1765
1776
  return;
1766
1777
  }
1767
- await launchTui(sessionId);
1778
+ await launchTui({ sessionId });
1768
1779
  } catch (error) {
1769
1780
  writeError(`Error: ${error instanceof Error ? error.message : "Unknown error"}\n`);
1770
1781
  process.exitCode = 1;
@@ -1839,10 +1850,10 @@ async function main(args = process.argv.slice(2)) {
1839
1850
  ]);
1840
1851
  else await launchTui();
1841
1852
  }
1842
- async function launchTui(sessionId) {
1843
- const { renderApp } = await import("./assets/tui-CboegfoT.js");
1853
+ async function launchTui(options = {}) {
1854
+ const { renderApp } = await import("./assets/tui-c76QePyQ.js");
1844
1855
  reset();
1845
- renderApp(sessionId);
1856
+ renderApp(options);
1846
1857
  }
1847
1858
  // v8 ignore start
1848
1859
  function isEntrypoint(argv1 = process.argv[1]) {
@@ -1856,4 +1867,4 @@ function isEntrypoint(argv1 = process.argv[1]) {
1856
1867
  if (isEntrypoint()) main();
1857
1868
  // v8 ignore stop
1858
1869
  //#endregion
1859
- export { NAME as $, loadConfig as A, ASSISTANT as B, checkHealth as C, pullModel as D, listModels as E, withSystemMessage as F, BACK as G, USER as H, HEADER_PREFIX as I, LABEL as J, CATALOG as K, WARNING as L, removeClipboardImage as M, saveClipboardImage as N, sanitizeAssistantContent as O, resetSystemMessage as P, REJECT as Q, LIST as R, TOOL_INTENT_CORRECTION as S, hasUncalledToolIntent as T, PLAN_GENERATION_INSTRUCTION as U, SYSTEM as V, PLAN_INSTRUCTION as W, SAFE as X, PLAN as Y, APPROVE as Z, loadSession as _, normalizeToolCall as a, reset as b, WRITE_TOOLS as c, write as d, VERSION as et, appendMessage as f, listSessions as g, deleteSessionIfEmpty as h, formatToolResultContent as i, saveConfig as j, streamChat as k, tick as l, deleteSession as m, main, executeTool as n, READ_TOOLS as o, createSession as p, AUTO as q, executeToolCall as r, TOOLS as s, checkForUpdate as t, LIST$1 as tt, color as u, updateSessionModel as v, deleteModel as w, setClearHandler as x, clear as y, getTheme as z };
1870
+ export { LABEL as $, loadConfig as A, CHAT as B, checkHealth as C, pullModel as D, listModels as E, withSystemMessage as F, ASSISTANT as G, SEARCH_SETTINGS as H, HEADER_PREFIX as I, PLAN_GENERATION_INSTRUCTION as J, SYSTEM as K, WARNING as L, removeClipboardImage as M, saveClipboardImage as N, sanitizeAssistantContent as O, resetSystemMessage as P, AUTO as Q, LIST as R, TOOL_INTENT_CORRECTION as S, hasUncalledToolIntent as T, SESSION_MANAGER as U, MODEL_MANAGER as V, THEME_SETTINGS as W, BACK as X, PLAN_INSTRUCTION as Y, CATALOG as Z, loadSession as _, normalizeToolCall as a, VERSION as at, reset as b, WRITE_TOOLS as c, write as d, PLAN as et, appendMessage as f, listSessions as g, deleteSessionIfEmpty as h, formatToolResultContent as i, NAME as it, saveConfig as j, streamChat as k, tick as l, deleteSession as m, main, executeTool as n, APPROVE as nt, READ_TOOLS as o, LIST$1 as ot, createSession as p, USER as q, executeToolCall as r, REJECT as rt, TOOLS as s, checkForUpdate as t, SAFE as tt, color as u, updateSessionModel as v, deleteModel as w, setClearHandler as x, clear as y, getTheme as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-ollama",
3
- "version": "0.24.1",
3
+ "version": "0.25.0",
4
4
  "description": "Ollama coding agent that runs in your terminal",
5
5
  "author": "Mark <mark@remarkablemark.org> (https://remarkablemark.org)",
6
6
  "type": "module",