code-ollama 0.4.0 → 0.5.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/README.md +4 -0
- package/dist/assets/{tui-BLJeczya.js → tui-Da6uWrqo.js} +75 -11
- package/dist/cli.js +3 -29
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
> [!NOTE]
|
|
2
2
|
> TUI is under active development. APIs may change.
|
|
3
3
|
|
|
4
|
+
<p align="center">
|
|
5
|
+
<img alt="Ollama" height="200" src="https://github.com/ai-action/assets/blob/master/logos/ollama.svg?raw=true">
|
|
6
|
+
</p>
|
|
7
|
+
|
|
4
8
|
# Code Ollama
|
|
5
9
|
|
|
6
10
|
[](https://www.npmjs.com/package/code-ollama)
|
|
@@ -1,9 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as setClearHandler, c as loadConfig, d as withSystemMessage, f as ROLE, i as executeTool, l as saveConfig, m as VERSION, n as READ_ONLY_TOOLS, o as listModels, p as PLAN_GENERATION_INSTRUCTION, r as TOOLS, s as streamChat, t as DANGEROUS_TOOLS, u as resetSystemMessage } from "../cli.js";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { Box, Text, render, useInput } from "ink";
|
|
4
|
-
import { memo, useCallback, useEffect, useState } from "react";
|
|
4
|
+
import { memo, useCallback, useEffect, useMemo, useState } from "react";
|
|
5
5
|
import { Select, Spinner, TextInput } from "@inkjs/ui";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/constants/command.ts
|
|
8
|
+
var LIST = [{
|
|
9
|
+
name: "/clear",
|
|
10
|
+
description: "clear the current session"
|
|
11
|
+
}, {
|
|
12
|
+
name: "/model",
|
|
13
|
+
description: "switch the model"
|
|
14
|
+
}];
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/constants/decision.ts
|
|
17
|
+
var APPROVE = "approve";
|
|
18
|
+
var REJECT = "reject";
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/constants/mode.ts
|
|
21
|
+
var NAME = {
|
|
22
|
+
SAFE: "safe",
|
|
23
|
+
AUTO: "auto",
|
|
24
|
+
PLAN: "plan"
|
|
25
|
+
};
|
|
26
|
+
var LABEL = {
|
|
27
|
+
safe: "Safe",
|
|
28
|
+
auto: "Auto",
|
|
29
|
+
plan: "Plan"
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/constants/ui.ts
|
|
33
|
+
var HEADER_PREFIX = "🦙";
|
|
34
|
+
//#endregion
|
|
7
35
|
//#region src/components/Messages.tsx
|
|
8
36
|
function getMessageColor(role) {
|
|
9
37
|
switch (role) {
|
|
@@ -153,20 +181,56 @@ var ACTION_NOT_PERFORMED = "The requested action was NOT performed";
|
|
|
153
181
|
var PLAN_CHECKLIST_REMINDER = "Then display the execution plan as an unchecked Markdown checklist only";
|
|
154
182
|
var PLAN_EXECUTION_REMINDER = "Do not claim success and do not call write_file or run_shell until the user approves execution";
|
|
155
183
|
//#endregion
|
|
184
|
+
//#region src/components/Chat/CommandMenu.tsx
|
|
185
|
+
function getMatchingCommands(input) {
|
|
186
|
+
const normalizedInput = input.trim().toLowerCase();
|
|
187
|
+
if (!normalizedInput.startsWith("/")) return [];
|
|
188
|
+
return LIST.filter(({ name }) => name.toLowerCase().startsWith(normalizedInput)).map(({ name, description }) => ({
|
|
189
|
+
label: `${name} - ${description}`,
|
|
190
|
+
value: name
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
function CommandMenu({ input, onSubmit }) {
|
|
194
|
+
const commandOptions = useMemo(() => getMatchingCommands(input), [input]);
|
|
195
|
+
if (!commandOptions.length) return null;
|
|
196
|
+
return /* @__PURE__ */ jsx(SelectPrompt, {
|
|
197
|
+
highlightText: input,
|
|
198
|
+
onChange: onSubmit,
|
|
199
|
+
options: commandOptions
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
156
203
|
//#region src/components/Chat/Input.tsx
|
|
157
204
|
function Input({ isDisabled = false, onSubmit }) {
|
|
205
|
+
const [input, setInput] = useState("");
|
|
158
206
|
const [resetKey, setResetKey] = useState(0);
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
207
|
+
const handleSubmitText = useCallback((input) => {
|
|
208
|
+
setTimeout(() => {
|
|
209
|
+
if (input.startsWith("/")) return;
|
|
210
|
+
const trimmedInput = input.trim();
|
|
211
|
+
if (!trimmedInput) return;
|
|
212
|
+
onSubmit(trimmedInput);
|
|
213
|
+
setInput("");
|
|
214
|
+
setResetKey((key) => key + 1);
|
|
215
|
+
});
|
|
216
|
+
}, [onSubmit]);
|
|
217
|
+
const handleSubmitCommand = useCallback((input) => {
|
|
218
|
+
if (!LIST.find(({ name }) => name === input)) return;
|
|
219
|
+
onSubmit(input);
|
|
220
|
+
setInput("");
|
|
163
221
|
setResetKey((key) => key + 1);
|
|
164
222
|
}, [onSubmit]);
|
|
165
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
223
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
224
|
+
flexDirection: "column",
|
|
225
|
+
children: [/* @__PURE__ */ jsxs(Box, { children: [/* @__PURE__ */ jsx(Text, { children: "> " }), /* @__PURE__ */ jsx(TextInput, {
|
|
226
|
+
isDisabled,
|
|
227
|
+
onChange: setInput,
|
|
228
|
+
onSubmit: handleSubmitText
|
|
229
|
+
}, resetKey)] }), input.startsWith("/") && /* @__PURE__ */ jsx(CommandMenu, {
|
|
230
|
+
input,
|
|
231
|
+
onSubmit: handleSubmitCommand
|
|
232
|
+
})]
|
|
233
|
+
});
|
|
170
234
|
}
|
|
171
235
|
//#endregion
|
|
172
236
|
//#region src/components/Chat/plan.ts
|
package/dist/cli.js
CHANGED
|
@@ -6,32 +6,9 @@ import { homedir } from "node:os";
|
|
|
6
6
|
import { Ollama } from "ollama";
|
|
7
7
|
import { exec } from "node:child_process";
|
|
8
8
|
import { promisify } from "node:util";
|
|
9
|
-
var NAMES = [{
|
|
10
|
-
name: "/clear",
|
|
11
|
-
description: "clear the current session"
|
|
12
|
-
}, {
|
|
13
|
-
name: "/model",
|
|
14
|
-
description: "switch the model"
|
|
15
|
-
}].map(({ name }) => name);
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/constants/decision.ts
|
|
18
|
-
var APPROVE = "approve";
|
|
19
|
-
var REJECT = "reject";
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/constants/mode.ts
|
|
22
|
-
var NAME$1 = {
|
|
23
|
-
SAFE: "safe",
|
|
24
|
-
AUTO: "auto",
|
|
25
|
-
PLAN: "plan"
|
|
26
|
-
};
|
|
27
|
-
var LABEL = {
|
|
28
|
-
safe: "Safe",
|
|
29
|
-
auto: "Auto",
|
|
30
|
-
plan: "Plan"
|
|
31
|
-
};
|
|
32
9
|
//#endregion
|
|
33
10
|
//#region src/constants/package.ts
|
|
34
|
-
var VERSION = "0.
|
|
11
|
+
var VERSION = "0.5.0";
|
|
35
12
|
//#endregion
|
|
36
13
|
//#region src/constants/prompt.ts
|
|
37
14
|
var BASE_SYSTEM_PROMPT = `You are a coding assistant that helps users write, edit, and understand code. You have access to tools for reading files, writing files, running shell commands, and searching code
|
|
@@ -90,9 +67,6 @@ var NAME = {
|
|
|
90
67
|
VIEW_RANGE: "view_range"
|
|
91
68
|
};
|
|
92
69
|
//#endregion
|
|
93
|
-
//#region src/constants/ui.ts
|
|
94
|
-
var HEADER_PREFIX = "🦙";
|
|
95
|
-
//#endregion
|
|
96
70
|
//#region src/utils/agents.ts
|
|
97
71
|
var AGENTS_FILE = "AGENTS.md";
|
|
98
72
|
function loadAgentsContent() {
|
|
@@ -525,7 +499,7 @@ async function processRunStream(messages, model) {
|
|
|
525
499
|
}
|
|
526
500
|
async function main(args = process.argv.slice(2)) {
|
|
527
501
|
if (!args.length) {
|
|
528
|
-
const { renderApp } = await import("./assets/tui-
|
|
502
|
+
const { renderApp } = await import("./assets/tui-Da6uWrqo.js");
|
|
529
503
|
process.stdout.write("\x1Bc");
|
|
530
504
|
renderApp();
|
|
531
505
|
return;
|
|
@@ -548,4 +522,4 @@ function isEntrypoint(argv1 = process.argv[1]) {
|
|
|
548
522
|
if (isEntrypoint()) main();
|
|
549
523
|
// v8 ignore stop
|
|
550
524
|
//#endregion
|
|
551
|
-
export {
|
|
525
|
+
export { setClearHandler as a, loadConfig as c, withSystemMessage as d, ROLE as f, executeTool as i, saveConfig as l, VERSION as m, main, READ_ONLY_TOOLS as n, listModels as o, PLAN_GENERATION_INSTRUCTION as p, TOOLS as r, streamChat as s, DANGEROUS_TOOLS as t, resetSystemMessage as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-ollama",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@commitlint/config-conventional": "20.5.3",
|
|
51
51
|
"@eslint/compat": "2.0.5",
|
|
52
52
|
"@eslint/js": "10.0.1",
|
|
53
|
-
"@types/node": "25.6.
|
|
53
|
+
"@types/node": "25.6.1",
|
|
54
54
|
"@types/react": "19.2.14",
|
|
55
55
|
"@vitest/coverage-v8": "4.1.5",
|
|
56
56
|
"eslint": "10.3.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"tsx": "4.21.0",
|
|
66
66
|
"typescript": "6.0.3",
|
|
67
67
|
"typescript-eslint": "8.59.2",
|
|
68
|
-
"vite": "8.0.
|
|
68
|
+
"vite": "8.0.11",
|
|
69
69
|
"vitest": "4.1.5"
|
|
70
70
|
},
|
|
71
71
|
"files": [
|