code-ollama 0.14.0 → 0.14.1

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.
@@ -65,7 +65,7 @@ var CodeBlock = memo(function CodeBlock({ code, language, role }) {
65
65
  const isSystem = role === SYSTEM;
66
66
  return /* @__PURE__ */ jsx(Box, {
67
67
  flexDirection: "column",
68
- borderStyle: "round",
68
+ borderStyle: "bold",
69
69
  borderColor: isSystem ? "gray" : "dim",
70
70
  paddingX: 1,
71
71
  marginY: 1,
@@ -308,11 +308,12 @@ function Messages({ messages, isLoading, sessionId = 0, streamingMessage }) {
308
308
  }
309
309
  //#endregion
310
310
  //#region src/components/SelectPrompt.tsx
311
- function SelectPrompt({ children, onCancel, ...selectProps }) {
311
+ function SelectPrompt({ borderStyle, children, onCancel, ...selectProps }) {
312
312
  useInput((input, key) => {
313
313
  if (key.escape || key.ctrl && input === "c") onCancel?.();
314
314
  });
315
315
  return /* @__PURE__ */ jsxs(Box, {
316
+ borderStyle,
316
317
  flexDirection: "column",
317
318
  children: [children, /* @__PURE__ */ jsx(Select, { ...selectProps })]
318
319
  });
@@ -373,29 +374,32 @@ var options$1 = [
373
374
  }
374
375
  ];
375
376
  function PlanApproval({ planContent, onModeChange }) {
376
- return /* @__PURE__ */ jsx(SelectPrompt, {
377
- options: options$1,
378
- onChange: useCallback((value) => {
379
- onModeChange(value);
380
- }, [onModeChange]),
381
- onCancel: useCallback(() => {
382
- onModeChange(PLAN);
383
- }, [onModeChange]),
384
- children: /* @__PURE__ */ jsxs(Box, {
385
- flexDirection: "column",
386
- marginTop: 1,
387
- children: [
388
- /* @__PURE__ */ jsx(Text, {
389
- bold: true,
390
- color: "magenta",
391
- children: "Plan Generated - Choose execution mode:"
392
- }),
393
- /* @__PURE__ */ jsx(Box, {
394
- marginY: 1,
395
- children: /* @__PURE__ */ jsx(Text, { children: planContent })
396
- }),
397
- /* @__PURE__ */ jsx(SelectPromptHint, { message: "Select execution mode" })
398
- ]
377
+ return /* @__PURE__ */ jsx(Box, {
378
+ marginX: 2,
379
+ children: /* @__PURE__ */ jsx(SelectPrompt, {
380
+ borderStyle: "bold",
381
+ options: options$1,
382
+ onChange: useCallback((value) => {
383
+ onModeChange(value);
384
+ }, [onModeChange]),
385
+ onCancel: useCallback(() => {
386
+ onModeChange(PLAN);
387
+ }, [onModeChange]),
388
+ children: /* @__PURE__ */ jsxs(Box, {
389
+ flexDirection: "column",
390
+ children: [
391
+ /* @__PURE__ */ jsx(Text, {
392
+ bold: true,
393
+ color: "magenta",
394
+ children: "Plan Generated - Choose execution mode:"
395
+ }),
396
+ /* @__PURE__ */ jsx(Box, {
397
+ marginY: 1,
398
+ children: /* @__PURE__ */ jsx(Text, { children: planContent })
399
+ }),
400
+ /* @__PURE__ */ jsx(SelectPromptHint, { message: "Select execution mode" })
401
+ ]
402
+ })
399
403
  })
400
404
  });
401
405
  }
@@ -416,47 +420,51 @@ function ToolApproval({ toolCall, onDecision }) {
416
420
  onDecision(REJECT);
417
421
  }, [onDecision]);
418
422
  const args = JSON.stringify(toolCall.function.arguments, null, 2);
419
- return /* @__PURE__ */ jsxs(SelectPrompt, {
420
- options,
421
- onChange: handleChange,
422
- onCancel: handleEscape,
423
- children: [
424
- /* @__PURE__ */ jsx(Text, {
425
- color: "yellow",
426
- children: "⚠️ Tool requires approval:"
427
- }),
428
- /* @__PURE__ */ jsxs(Box, {
429
- marginX: 3,
430
- marginBottom: 1,
431
- flexDirection: "column",
432
- children: [/* @__PURE__ */ jsxs(Text, { children: [
433
- /* @__PURE__ */ jsx(Text, {
434
- italic: true,
435
- children: "Tool:"
436
- }),
437
- " ",
438
- toolCall.function.name
439
- ] }), /* @__PURE__ */ jsxs(Text, { children: [
440
- /* @__PURE__ */ jsx(Text, {
441
- italic: true,
442
- children: "Arguments:"
443
- }),
444
- " ",
445
- args
446
- ] })]
447
- }),
448
- /* @__PURE__ */ jsx(SelectPromptHint, {
449
- message: "Select approval action",
450
- escapeLabel: "reject"
451
- })
452
- ]
423
+ return /* @__PURE__ */ jsx(Box, {
424
+ marginX: 2,
425
+ children: /* @__PURE__ */ jsxs(SelectPrompt, {
426
+ borderStyle: "bold",
427
+ options,
428
+ onChange: handleChange,
429
+ onCancel: handleEscape,
430
+ children: [
431
+ /* @__PURE__ */ jsx(Text, {
432
+ color: "yellow",
433
+ children: "Tool requires approval ⚠️ "
434
+ }),
435
+ /* @__PURE__ */ jsxs(Box, {
436
+ flexDirection: "column",
437
+ marginBottom: 1,
438
+ marginX: 2,
439
+ children: [/* @__PURE__ */ jsxs(Text, { children: [
440
+ /* @__PURE__ */ jsx(Text, {
441
+ dimColor: true,
442
+ children: "Tool:"
443
+ }),
444
+ " ",
445
+ toolCall.function.name
446
+ ] }), /* @__PURE__ */ jsxs(Text, { children: [
447
+ /* @__PURE__ */ jsx(Text, {
448
+ dimColor: true,
449
+ children: "Arguments:"
450
+ }),
451
+ " ",
452
+ args
453
+ ] })]
454
+ }),
455
+ /* @__PURE__ */ jsx(SelectPromptHint, {
456
+ message: "Select approval action",
457
+ escapeLabel: "reject"
458
+ })
459
+ ]
460
+ })
453
461
  });
454
462
  }
455
463
  //#endregion
456
464
  //#region src/components/Chat/constants.ts
457
465
  var ACTION_NOT_PERFORMED = "The requested action was NOT performed";
458
466
  var PLAN_CHECKLIST_REMINDER = "Then display the execution plan as an unchecked Markdown checklist only";
459
- var PLAN_EXECUTION_REMINDER = "Do not claim success and do not call write_file or run_shell until the user approves execution";
467
+ var PLAN_EXECUTION_REMINDER = `Do not claim success and do not call ${Array.from(WRITE_TOOLS).join(", ")} until the user approves execution`;
460
468
  var INTERRUPT_REASON = /* @__PURE__ */ function(INTERRUPT_REASON) {
461
469
  INTERRUPT_REASON["INTERRUPTED"] = "interrupted";
462
470
  INTERRUPT_REASON["REJECTED"] = "rejected";
@@ -464,7 +472,39 @@ var INTERRUPT_REASON = /* @__PURE__ */ function(INTERRUPT_REASON) {
464
472
  }({});
465
473
  //#endregion
466
474
  //#region src/components/TextInput/TextInput.tsx
467
- function TextInput({ value, isDisabled = false, placeholder, cursorPosition: externalCursorPosition, onChange, onSubmit }) {
475
+ function buildLineSegments(displayValue, cursorPosition, width) {
476
+ const safeWidth = Math.max(1, width);
477
+ const cursorChar = displayValue[cursorPosition] || " ";
478
+ const renderValue = displayValue.slice(0, cursorPosition) + cursorChar + displayValue.slice(cursorPosition + 1);
479
+ const totalLength = Math.max(1, renderValue.length);
480
+ const lines = [];
481
+ for (let start = 0; start < totalLength; start += safeWidth) {
482
+ const end = start + safeWidth;
483
+ const text = renderValue.slice(start, end);
484
+ const hasCursor = cursorPosition >= start && cursorPosition < end;
485
+ if (!hasCursor) {
486
+ lines.push({
487
+ text,
488
+ hasCursor,
489
+ beforeCursor: "",
490
+ cursorChar: " ",
491
+ afterCursor: ""
492
+ });
493
+ continue;
494
+ }
495
+ const offset = cursorPosition - start;
496
+ lines.push({
497
+ text,
498
+ hasCursor,
499
+ beforeCursor: text.slice(0, offset),
500
+ cursorChar: text[offset] || " ",
501
+ afterCursor: text.slice(offset + 1)
502
+ });
503
+ }
504
+ return lines;
505
+ }
506
+ function TextInput({ value, isDisabled = false, placeholder, cursorPosition: externalCursorPosition, wrapIndent = 0, onChange, onSubmit }) {
507
+ const { stdout } = useStdout();
468
508
  const [cursorPosition, setCursorPosition] = useState(value.length);
469
509
  const prevValueRef = useRef(value);
470
510
  const prevExternalCursorRef = useRef(externalCursorPosition);
@@ -522,6 +562,14 @@ function TextInput({ value, isDisabled = false, placeholder, cursorPosition: ext
522
562
  setCursorPosition(value.length);
523
563
  return;
524
564
  }
565
+ if (key.ctrl && input === "a") {
566
+ setCursorPosition(0);
567
+ return;
568
+ }
569
+ if (key.ctrl && input === "e") {
570
+ setCursorPosition(value.length);
571
+ return;
572
+ }
525
573
  // v8 ignore start
526
574
  if (input) {
527
575
  onChange(value.slice(0, cursorPosition) + input + value.slice(cursorPosition));
@@ -531,23 +579,31 @@ function TextInput({ value, isDisabled = false, placeholder, cursorPosition: ext
531
579
  }, { isActive: !isDisabled });
532
580
  const displayValue = value || (placeholder ?? "");
533
581
  const isPlaceholder = Boolean(!value && placeholder);
534
- const cursorChar = displayValue[cursorPosition] || " ";
535
- const before = displayValue.slice(0, cursorPosition);
536
- const after = displayValue.slice(cursorPosition + 1);
537
- return /* @__PURE__ */ jsxs(Fragment, { children: [
538
- /* @__PURE__ */ jsx(Text, {
539
- dimColor: isPlaceholder,
540
- children: before
541
- }),
542
- /* @__PURE__ */ jsx(Text, {
543
- inverse: true,
544
- children: cursorChar
545
- }),
546
- /* @__PURE__ */ jsx(Text, {
582
+ const availableWidth = Math.max(1, stdout.columns - wrapIndent);
583
+ return /* @__PURE__ */ jsx(Box, {
584
+ flexDirection: "column",
585
+ children: useMemo(() => buildLineSegments(displayValue, cursorPosition, availableWidth), [
586
+ availableWidth,
587
+ cursorPosition,
588
+ displayValue
589
+ ]).map((line, index) => /* @__PURE__ */ jsx(Text, { children: line.hasCursor ? /* @__PURE__ */ jsxs(Fragment, { children: [
590
+ /* @__PURE__ */ jsx(Text, {
591
+ dimColor: isPlaceholder,
592
+ children: line.beforeCursor
593
+ }),
594
+ /* @__PURE__ */ jsx(Text, {
595
+ inverse: true,
596
+ children: line.cursorChar
597
+ }),
598
+ /* @__PURE__ */ jsx(Text, {
599
+ dimColor: isPlaceholder,
600
+ children: line.afterCursor
601
+ })
602
+ ] }) : /* @__PURE__ */ jsx(Text, {
547
603
  dimColor: isPlaceholder,
548
- children: after
549
- })
550
- ] });
604
+ children: line.text
605
+ }) }, `${String(index)}-${line.text}`))
606
+ });
551
607
  }
552
608
  //#endregion
553
609
  //#region src/components/Chat/CommandMenu.tsx
@@ -789,6 +845,7 @@ function Input({ isDisabled = false, onInterrupt, onSubmit }) {
789
845
  value: input,
790
846
  isDisabled,
791
847
  cursorPosition,
848
+ wrapIndent: 2,
792
849
  onChange: setInput,
793
850
  onSubmit: handleSubmitText,
794
851
  placeholder: "Ask anything... (/ commands, @ files)"
@@ -1228,7 +1285,7 @@ function Header({ model, onLoad }) {
1228
1285
  return /* @__PURE__ */ jsx(Static, {
1229
1286
  items: [0],
1230
1287
  children: (key) => /* @__PURE__ */ jsxs(Box, {
1231
- borderStyle: "round",
1288
+ borderStyle: "bold",
1232
1289
  flexDirection: "column",
1233
1290
  paddingX: 1,
1234
1291
  children: [
@@ -1394,6 +1451,7 @@ function SearchSettings({ currentUrl, onClose, onSave }) {
1394
1451
  /* @__PURE__ */ jsx(Text, { children: "Set the SearXNG base URL. DuckDuckGo remains the fallback." }),
1395
1452
  /* @__PURE__ */ jsxs(Box, { children: [/* @__PURE__ */ jsx(Text, { children: "> " }), /* @__PURE__ */ jsx(TextInput, {
1396
1453
  value: draftUrl,
1454
+ wrapIndent: 2,
1397
1455
  onChange: setDraftUrl,
1398
1456
  onSubmit: handleSubmit,
1399
1457
  placeholder: "http://localhost:8080"
package/dist/cli.js CHANGED
@@ -32,7 +32,7 @@ var LIST = [
32
32
  //#endregion
33
33
  //#region package.json
34
34
  var name = "code-ollama";
35
- var version = "0.14.0";
35
+ var version = "0.14.1";
36
36
  //#endregion
37
37
  //#region src/constants/package.ts
38
38
  var NAME = name;
@@ -904,7 +904,7 @@ async function main(args = process.argv.slice(2)) {
904
904
  else await launchTui();
905
905
  }
906
906
  async function launchTui(sessionId) {
907
- const { renderApp } = await import("./assets/tui-TX7C0xYg.js");
907
+ const { renderApp } = await import("./assets/tui-CoX71F7Y.js");
908
908
  reset();
909
909
  renderApp(sessionId);
910
910
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-ollama",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
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",
@@ -42,7 +42,7 @@
42
42
  "@inkjs/ui": "2.0.0",
43
43
  "@shikijs/cli": "4.0.2",
44
44
  "cac": "7.0.0",
45
- "ink": "7.0.2",
45
+ "ink": "7.0.3",
46
46
  "marked": "15.0.12",
47
47
  "marked-terminal": "7.3.0",
48
48
  "ollama": "0.6.3",