netheriteai-code 1.0.0 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netheriteai-code",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "NetheriteAI:Code by hurdacu. High-performance coding assistant.",
5
5
  "author": "hurdacu",
6
6
  "license": "MIT",
package/src/agent.js CHANGED
@@ -6,9 +6,11 @@ function isGlmModel(model) {
6
6
  }
7
7
 
8
8
  export function buildSystemPrompt(workspaceRoot, model) {
9
+ const isWin = process.platform === "win32";
9
10
  const lines = [
10
11
  "You are NetheriteAI Code, a terminal coding agent.",
11
12
  `You operate inside this workspace: ${workspaceRoot}`,
13
+ `Current Platform: ${process.platform}${isWin ? " (Use PowerShell syntax for shell commands)" : ""}`,
12
14
  "Use tools when you need filesystem access, shell execution, or todo tracking.",
13
15
  "Before changing files, inspect relevant files first.",
14
16
  "Prefer targeted tools like edit_file, create_file, append_file, and make_dir over overwriting large files when possible.",
@@ -200,10 +202,10 @@ export async function runAgentTurn({ workspaceRoot, model, history, userPrompt,
200
202
  name: toolCall.function.name,
201
203
  result,
202
204
  });
205
+ // Workaround: Use 'user' role instead of 'tool' because the remote server rejects 'tool' role.
203
206
  messages.push({
204
- role: "tool",
205
- tool_call_id: toolCall.id,
206
- content: JSON.stringify(result),
207
+ role: "user",
208
+ content: `Observation from write_file:\n${JSON.stringify(result, null, 2)}`,
207
209
  });
208
210
  onEvent?.({ type: "assistant", text: `Wrote ${path}.` });
209
211
  return {
@@ -220,10 +222,10 @@ export async function runAgentTurn({ workspaceRoot, model, history, userPrompt,
220
222
  name: toolCall.function.name,
221
223
  result: toolError,
222
224
  });
225
+ // Workaround: Use 'user' role instead of 'tool' because the remote server rejects 'tool' role.
223
226
  messages.push({
224
- role: "tool",
225
- tool_call_id: toolCall.id,
226
- content: JSON.stringify(toolError),
227
+ role: "user",
228
+ content: `Error from write_file:\n${toolError.error}`,
227
229
  });
228
230
  onEvent?.({ type: "assistant", text: `Error: ${toolError.error}` });
229
231
  return {
@@ -291,5 +293,13 @@ export async function runAgentTurn({ workspaceRoot, model, history, userPrompt,
291
293
  content: observations.join("\n\n"),
292
294
  });
293
295
  }
296
+
297
+ // Keep history lean to avoid server overload
298
+ if (messages.length > 20) {
299
+ const systemMsg = messages[0];
300
+ const recent = messages.slice(-12);
301
+ messages.length = 0;
302
+ messages.push(systemMsg, ...recent);
303
+ }
294
304
  }
295
305
  }
package/src/cli.js CHANGED
@@ -11,7 +11,7 @@ import { printTable, resolveWorkspaceRoot } from "./utils.js";
11
11
 
12
12
  const execFileAsync = promisify(execFile);
13
13
 
14
- const VERSION = "1.0.0";
14
+ const VERSION = "1.0.3";
15
15
 
16
16
  async function handleAutoUpdate() {
17
17
  // If we were just restarted by an update, don't check again
@@ -343,7 +343,7 @@ async function runChatSession({ workspaceRoot, model, useTui, session }) {
343
343
  getModel: () => activeModel,
344
344
  agentName: "NetheriteAI:Code",
345
345
  providerName: "NetheriteAI",
346
- version: "0.1.0",
346
+ version: VERSION,
347
347
  workspaceLabel: workspaceRoot,
348
348
  sessionId: session.id,
349
349
  initialSessionTitle: session.title,
package/src/ollama.js CHANGED
@@ -62,7 +62,7 @@ export async function pickDefaultModel() {
62
62
 
63
63
  export async function chat({ model, messages, tools, signal }) {
64
64
  const body = { model, messages, stream: false };
65
- if (tools?.length && model !== "glm-5:cloud") body.tools = tools;
65
+ if (tools?.length && (model !== "glm-5:cloud" || tools.length <= 5)) body.tools = tools;
66
66
  const response = await request("/api/chat", body, signal);
67
67
  const json = await response.json();
68
68
  let content = json.message?.content || "";
@@ -81,7 +81,7 @@ export async function chat({ model, messages, tools, signal }) {
81
81
 
82
82
  export async function chatStream({ model, messages, tools, onChunk, onReasoningChunk, signal }) {
83
83
  const body = { model, messages, stream: true };
84
- if (tools?.length && model !== "glm-5:cloud") body.tools = tools;
84
+ if (tools?.length && (model !== "glm-5:cloud" || tools.length <= 10)) body.tools = tools;
85
85
 
86
86
  const response = await request("/api/chat", body, signal);
87
87
  if (!response.body) throw new Error("Server down");
package/src/tools.js CHANGED
@@ -63,21 +63,6 @@ export function getToolDefinitions() {
63
63
  },
64
64
  },
65
65
  },
66
- {
67
- type: "function",
68
- function: {
69
- name: "create_file",
70
- description: "Create a new file.",
71
- parameters: {
72
- type: "object",
73
- properties: {
74
- path: { type: "string" },
75
- content: { type: "string" },
76
- },
77
- required: ["path", "content"],
78
- },
79
- },
80
- },
81
66
  {
82
67
  type: "function",
83
68
  function: {
@@ -96,31 +81,30 @@ export function getToolDefinitions() {
96
81
  {
97
82
  type: "function",
98
83
  function: {
99
- name: "append_file",
100
- description: "Append content to a file.",
84
+ name: "edit_file",
85
+ description: "Edit a file by replacing text.",
101
86
  parameters: {
102
87
  type: "object",
103
88
  properties: {
104
89
  path: { type: "string" },
105
- content: { type: "string" },
90
+ oldText: { type: "string" },
91
+ newText: { type: "string" },
106
92
  },
107
- required: ["path", "content"],
93
+ required: ["path", "oldText", "newText"],
108
94
  },
109
95
  },
110
96
  },
111
97
  {
112
98
  type: "function",
113
99
  function: {
114
- name: "edit_file",
115
- description: "Edit a file by replacing text.",
100
+ name: "run_command",
101
+ description: "Run a shell command.",
116
102
  parameters: {
117
103
  type: "object",
118
104
  properties: {
119
- path: { type: "string" },
120
- oldText: { type: "string" },
121
- newText: { type: "string" },
105
+ commandLine: { type: "string" },
122
106
  },
123
- required: ["path", "oldText", "newText"],
107
+ required: ["commandLine"],
124
108
  },
125
109
  },
126
110
  },
@@ -131,9 +115,7 @@ export function getToolDefinitions() {
131
115
  description: "Create a new directory.",
132
116
  parameters: {
133
117
  type: "object",
134
- properties: {
135
- path: { type: "string" },
136
- },
118
+ properties: { path: { type: "string" } },
137
119
  required: ["path"],
138
120
  },
139
121
  },
@@ -157,7 +139,7 @@ export function getToolDefinitions() {
157
139
  type: "function",
158
140
  function: {
159
141
  name: "rename_path",
160
- description: "Rename a file or directory.",
142
+ description: "Rename or move a file or directory.",
161
143
  parameters: {
162
144
  type: "object",
163
145
  properties: {
@@ -168,25 +150,11 @@ export function getToolDefinitions() {
168
150
  },
169
151
  },
170
152
  },
171
- {
172
- type: "function",
173
- function: {
174
- name: "run_command",
175
- description: "Run a shell command.",
176
- parameters: {
177
- type: "object",
178
- properties: {
179
- commandLine: { type: "string" },
180
- },
181
- required: ["commandLine"],
182
- },
183
- },
184
- },
185
153
  {
186
154
  type: "function",
187
155
  function: {
188
156
  name: "send_input",
189
- description: "Send input (stdin) to a background process_id that is waiting for input.",
157
+ description: "Send input to a background process.",
190
158
  parameters: {
191
159
  type: "object",
192
160
  properties: {
@@ -290,7 +258,9 @@ async function runOneCommand(root, command, args = [], hooks = {}) {
290
258
  }
291
259
 
292
260
  async function runShellLine(root, commandLine, hooks = {}) {
293
- const result = await runSpawnedCommand(root, "bash", ["-lc", commandLine], hooks);
261
+ const shell = isWin ? "powershell.exe" : "bash";
262
+ const args = isWin ? ["-NoProfile", "-Command", commandLine] : ["-lc", commandLine];
263
+ const result = await runSpawnedCommand(root, shell, args, hooks);
294
264
  return {
295
265
  ok: true,
296
266
  commandLine,