netheriteai-code 1.0.0 → 1.0.2

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.2",
4
4
  "description": "NetheriteAI:Code by hurdacu. High-performance coding assistant.",
5
5
  "author": "hurdacu",
6
6
  "license": "MIT",
package/src/agent.js CHANGED
@@ -200,10 +200,10 @@ export async function runAgentTurn({ workspaceRoot, model, history, userPrompt,
200
200
  name: toolCall.function.name,
201
201
  result,
202
202
  });
203
+ // Workaround: Use 'user' role instead of 'tool' because the remote server rejects 'tool' role.
203
204
  messages.push({
204
- role: "tool",
205
- tool_call_id: toolCall.id,
206
- content: JSON.stringify(result),
205
+ role: "user",
206
+ content: `Observation from write_file:\n${JSON.stringify(result, null, 2)}`,
207
207
  });
208
208
  onEvent?.({ type: "assistant", text: `Wrote ${path}.` });
209
209
  return {
@@ -220,10 +220,10 @@ export async function runAgentTurn({ workspaceRoot, model, history, userPrompt,
220
220
  name: toolCall.function.name,
221
221
  result: toolError,
222
222
  });
223
+ // Workaround: Use 'user' role instead of 'tool' because the remote server rejects 'tool' role.
223
224
  messages.push({
224
- role: "tool",
225
- tool_call_id: toolCall.id,
226
- content: JSON.stringify(toolError),
225
+ role: "user",
226
+ content: `Error from write_file:\n${toolError.error}`,
227
227
  });
228
228
  onEvent?.({ type: "assistant", text: `Error: ${toolError.error}` });
229
229
  return {
@@ -291,5 +291,13 @@ export async function runAgentTurn({ workspaceRoot, model, history, userPrompt,
291
291
  content: observations.join("\n\n"),
292
292
  });
293
293
  }
294
+
295
+ // Keep history lean to avoid server overload
296
+ if (messages.length > 20) {
297
+ const systemMsg = messages[0];
298
+ const recent = messages.slice(-12);
299
+ messages.length = 0;
300
+ messages.push(systemMsg, ...recent);
301
+ }
294
302
  }
295
303
  }
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.2";
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: {