@thejeetsingh/kalcode 2.0.0 → 2.2.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 +0 -4
- package/dist/bin/kalcode.d.ts +2 -0
- package/dist/bin/kalcode.js +12 -0
- package/dist/bin/kalcode.js.map +1 -0
- package/dist/src/agent/context.d.ts +6 -0
- package/dist/src/agent/context.js +60 -0
- package/dist/src/agent/context.js.map +1 -0
- package/dist/src/agent/history.d.ts +8 -0
- package/dist/src/agent/history.js +59 -0
- package/dist/src/agent/history.js.map +1 -0
- package/dist/src/agent/loop.d.ts +6 -0
- package/dist/src/agent/loop.js +235 -0
- package/dist/src/agent/loop.js.map +1 -0
- package/dist/src/agent/memory.d.ts +2 -0
- package/dist/src/agent/memory.js +27 -0
- package/dist/src/agent/memory.js.map +1 -0
- package/dist/src/agent/permissions.d.ts +5 -0
- package/dist/src/agent/permissions.js +66 -0
- package/dist/src/agent/permissions.js.map +1 -0
- package/dist/src/agent/text-tool-parser.d.ts +2 -0
- package/dist/src/agent/text-tool-parser.js +68 -0
- package/dist/src/agent/text-tool-parser.js.map +1 -0
- package/dist/src/api/client.d.ts +2 -0
- package/dist/src/api/client.js +86 -0
- package/dist/src/api/client.js.map +1 -0
- package/dist/src/api/stream-parser.d.ts +2 -0
- package/dist/src/api/stream-parser.js +97 -0
- package/dist/src/api/stream-parser.js.map +1 -0
- package/dist/src/config.d.ts +7 -0
- package/dist/src/config.js +52 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/constants.d.ts +25 -0
- package/{src/constants.ts → dist/src/constants.js} +17 -19
- package/dist/src/constants.js.map +1 -0
- package/dist/src/git/git.d.ts +15 -0
- package/dist/src/git/git.js +73 -0
- package/dist/src/git/git.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +415 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/proxy/server.d.ts +1 -0
- package/dist/src/proxy/server.js +92 -0
- package/dist/src/proxy/server.js.map +1 -0
- package/dist/src/tools/edit-file.d.ts +2 -0
- package/dist/src/tools/edit-file.js +88 -0
- package/dist/src/tools/edit-file.js.map +1 -0
- package/dist/src/tools/glob-tool.d.ts +2 -0
- package/dist/src/tools/glob-tool.js +52 -0
- package/dist/src/tools/glob-tool.js.map +1 -0
- package/dist/src/tools/grep.d.ts +2 -0
- package/dist/src/tools/grep.js +93 -0
- package/dist/src/tools/grep.js.map +1 -0
- package/dist/src/tools/list-directory.d.ts +2 -0
- package/dist/src/tools/list-directory.js +90 -0
- package/dist/src/tools/list-directory.js.map +1 -0
- package/dist/src/tools/read-file.d.ts +2 -0
- package/dist/src/tools/read-file.js +64 -0
- package/dist/src/tools/read-file.js.map +1 -0
- package/dist/src/tools/registry.d.ts +4 -0
- package/dist/src/tools/registry.js +32 -0
- package/dist/src/tools/registry.js.map +1 -0
- package/dist/src/tools/run-command.d.ts +2 -0
- package/dist/src/tools/run-command.js +98 -0
- package/dist/src/tools/run-command.js.map +1 -0
- package/dist/src/tools/write-file.d.ts +2 -0
- package/dist/src/tools/write-file.js +39 -0
- package/dist/src/tools/write-file.js.map +1 -0
- package/dist/src/types.d.ts +61 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/ui/input.d.ts +5 -0
- package/dist/src/ui/input.js +52 -0
- package/dist/src/ui/input.js.map +1 -0
- package/dist/src/ui/model-picker.d.ts +7 -0
- package/dist/src/ui/model-picker.js +70 -0
- package/dist/src/ui/model-picker.js.map +1 -0
- package/dist/src/ui/skills-picker.d.ts +2 -0
- package/dist/src/ui/skills-picker.js +95 -0
- package/dist/src/ui/skills-picker.js.map +1 -0
- package/dist/src/ui/skills.d.ts +14 -0
- package/dist/src/ui/skills.js +137 -0
- package/dist/src/ui/skills.js.map +1 -0
- package/dist/src/ui/spinner.d.ts +5 -0
- package/dist/src/ui/spinner.js +49 -0
- package/dist/src/ui/spinner.js.map +1 -0
- package/dist/src/ui/stream-renderer.d.ts +2 -0
- package/dist/src/ui/stream-renderer.js +66 -0
- package/dist/src/ui/stream-renderer.js.map +1 -0
- package/dist/src/ui/terminal.d.ts +24 -0
- package/dist/src/ui/terminal.js +272 -0
- package/dist/src/ui/terminal.js.map +1 -0
- package/package.json +16 -16
- package/api/health.ts +0 -10
- package/api/v1/chat/completions.ts +0 -59
- package/bin/kalcode.ts +0 -14
- package/src/agent/context.ts +0 -62
- package/src/agent/history.ts +0 -70
- package/src/agent/loop.ts +0 -282
- package/src/agent/memory.ts +0 -26
- package/src/agent/permissions.ts +0 -84
- package/src/agent/text-tool-parser.ts +0 -71
- package/src/api/client.ts +0 -110
- package/src/api/stream-parser.ts +0 -109
- package/src/config.ts +0 -61
- package/src/git/git.ts +0 -86
- package/src/index.ts +0 -403
- package/src/proxy/server.ts +0 -128
- package/src/tools/edit-file.ts +0 -97
- package/src/tools/glob-tool.ts +0 -59
- package/src/tools/grep.ts +0 -96
- package/src/tools/list-directory.ts +0 -101
- package/src/tools/read-file.ts +0 -71
- package/src/tools/registry.ts +0 -41
- package/src/tools/run-command.ts +0 -99
- package/src/tools/write-file.ts +0 -42
- package/src/types.ts +0 -68
- package/src/ui/input.ts +0 -60
- package/src/ui/model-picker.ts +0 -92
- package/src/ui/skills-picker.ts +0 -113
- package/src/ui/skills.ts +0 -152
- package/src/ui/spinner.ts +0 -56
- package/src/ui/stream-renderer.ts +0 -69
- package/src/ui/terminal.ts +0 -337
- package/tsconfig.json +0 -15
- package/vercel.json +0 -12
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { VERSION } from "../constants.js";
|
|
3
|
+
// ─── Claude Code–style color palette (minimal, semantic) ────────────
|
|
4
|
+
const DIM = chalk.dim;
|
|
5
|
+
const BOLD = chalk.bold;
|
|
6
|
+
const RED = chalk.red;
|
|
7
|
+
const YELLOW = chalk.yellow;
|
|
8
|
+
const GREEN = chalk.green;
|
|
9
|
+
const CYAN = chalk.cyan;
|
|
10
|
+
// ─── Helpers ─────────────────────────────────────────────────────────
|
|
11
|
+
function stripAnsi(str) {
|
|
12
|
+
return str.replace(/\x1b\[[0-9;]*m/g, "");
|
|
13
|
+
}
|
|
14
|
+
function visibleLength(str) {
|
|
15
|
+
return stripAnsi(str).length;
|
|
16
|
+
}
|
|
17
|
+
function padRight(str, width) {
|
|
18
|
+
const vis = visibleLength(str);
|
|
19
|
+
if (vis >= width)
|
|
20
|
+
return str;
|
|
21
|
+
return str + " ".repeat(width - vis);
|
|
22
|
+
}
|
|
23
|
+
function getWidth() {
|
|
24
|
+
return Math.min(88, Math.max(60, process.stdout.columns || 80));
|
|
25
|
+
}
|
|
26
|
+
function shortModelName(modelId) {
|
|
27
|
+
const parts = modelId.split("/");
|
|
28
|
+
let name = parts.length > 1 ? parts[1] : modelId;
|
|
29
|
+
// Strip common verbose suffixes for compact display
|
|
30
|
+
name = name
|
|
31
|
+
.replace(/-instruct(?:-\d+)?$/, "")
|
|
32
|
+
.replace(/-chat$/, "");
|
|
33
|
+
if (name.length > 28)
|
|
34
|
+
name = name.slice(0, 28) + "…";
|
|
35
|
+
return name;
|
|
36
|
+
}
|
|
37
|
+
function shortenPath(p) {
|
|
38
|
+
const home = process.env.HOME || "";
|
|
39
|
+
if (home && p.startsWith(home))
|
|
40
|
+
return "~" + p.slice(home.length);
|
|
41
|
+
return p;
|
|
42
|
+
}
|
|
43
|
+
function truncLine(line, max = 120) {
|
|
44
|
+
return line.length > max ? line.slice(0, max) + "…" : line;
|
|
45
|
+
}
|
|
46
|
+
function truncPath(p, max) {
|
|
47
|
+
if (p.length <= max)
|
|
48
|
+
return p;
|
|
49
|
+
// Keep the last components that fit
|
|
50
|
+
const parts = p.split("/");
|
|
51
|
+
let result = parts[parts.length - 1];
|
|
52
|
+
for (let i = parts.length - 2; i >= 0; i--) {
|
|
53
|
+
const candidate = parts[i] + "/" + result;
|
|
54
|
+
if (candidate.length + 2 > max)
|
|
55
|
+
break;
|
|
56
|
+
result = candidate;
|
|
57
|
+
}
|
|
58
|
+
return "…/" + result;
|
|
59
|
+
}
|
|
60
|
+
// ─── Welcome Screen (Claude Code style boxed panel) ─────────────────
|
|
61
|
+
export function renderWelcome(model) {
|
|
62
|
+
const w = getWidth();
|
|
63
|
+
const midCol = Math.floor(w * 0.50);
|
|
64
|
+
const leftW = midCol - 1;
|
|
65
|
+
const rightW = w - midCol - 2;
|
|
66
|
+
// Top border with version embedded: ┌─ kalcode v2.0.0 ──...──┐
|
|
67
|
+
const vTag = ` kalcode v${VERSION} `;
|
|
68
|
+
const topFill = w - 2 - vTag.length - 1;
|
|
69
|
+
console.log("");
|
|
70
|
+
console.log(`┌─${vTag}${"─".repeat(Math.max(0, topFill))}┐`);
|
|
71
|
+
const leftLines = [
|
|
72
|
+
"",
|
|
73
|
+
` ${BOLD("Welcome!")}`,
|
|
74
|
+
"",
|
|
75
|
+
` ${DIM("┌──┐")}`,
|
|
76
|
+
` ${DIM("│")}${CYAN("kc")}${DIM("│")}`,
|
|
77
|
+
` ${DIM("└──┘")}`,
|
|
78
|
+
"",
|
|
79
|
+
` ${shortModelName(model)} ${DIM("· NVIDIA NIM")}`,
|
|
80
|
+
` ${DIM(truncPath(shortenPath(process.cwd()), leftW - 4))}`,
|
|
81
|
+
"",
|
|
82
|
+
];
|
|
83
|
+
const rightLines = [
|
|
84
|
+
"",
|
|
85
|
+
` ${YELLOW("Tips for getting started")}`,
|
|
86
|
+
` Run ${BOLD("/init")} to create a KALCODE.md file`,
|
|
87
|
+
` with instructions for kalcode`,
|
|
88
|
+
"",
|
|
89
|
+
` ${YELLOW("Recent activity")}`,
|
|
90
|
+
` ${DIM("No recent activity")}`,
|
|
91
|
+
"",
|
|
92
|
+
"",
|
|
93
|
+
"",
|
|
94
|
+
];
|
|
95
|
+
const rows = Math.max(leftLines.length, rightLines.length);
|
|
96
|
+
for (let i = 0; i < rows; i++) {
|
|
97
|
+
const l = padRight(leftLines[i] || "", leftW);
|
|
98
|
+
const r = padRight(rightLines[i] || "", rightW);
|
|
99
|
+
console.log(`│${l}│${r}│`);
|
|
100
|
+
}
|
|
101
|
+
console.log(`└${"─".repeat(leftW)}┴${"─".repeat(rightW)}┘`);
|
|
102
|
+
}
|
|
103
|
+
// ─── Separator + Hints (shown between welcome and prompt) ───────────
|
|
104
|
+
export function renderSeparator() {
|
|
105
|
+
console.log("");
|
|
106
|
+
console.log(DIM("─".repeat(getWidth())));
|
|
107
|
+
}
|
|
108
|
+
export function renderHints() {
|
|
109
|
+
const left = DIM(" ? for shortcuts");
|
|
110
|
+
const right = DIM("/help for commands /model to switch model");
|
|
111
|
+
const w = getWidth();
|
|
112
|
+
const gap = Math.max(2, w - visibleLength(left) - visibleLength(right));
|
|
113
|
+
console.log(left + " ".repeat(gap) + right);
|
|
114
|
+
console.log("");
|
|
115
|
+
}
|
|
116
|
+
// ─── Status line (no-op; state is shown in welcome + hints) ─────────
|
|
117
|
+
export function renderStatusLine(_opts) {
|
|
118
|
+
// Intentionally empty — status context is in the welcome box
|
|
119
|
+
}
|
|
120
|
+
// ─── Help (Claude Code style boxed panel) ───────────────────────────
|
|
121
|
+
export function renderHelp() {
|
|
122
|
+
const w = getWidth();
|
|
123
|
+
const inner = w - 2;
|
|
124
|
+
// Top border
|
|
125
|
+
const hTag = " Commands ";
|
|
126
|
+
const hFill = inner - hTag.length - 1;
|
|
127
|
+
console.log("");
|
|
128
|
+
console.log(`┌─${hTag}${"─".repeat(Math.max(0, hFill))}┐`);
|
|
129
|
+
const sections = [
|
|
130
|
+
["Session", [
|
|
131
|
+
["/help", "Show this help"],
|
|
132
|
+
["/clear", "Clear conversation"],
|
|
133
|
+
["/retry", "Retry last message"],
|
|
134
|
+
["/model", "Switch model (TUI picker)"],
|
|
135
|
+
["/compact", "Toggle compact output"],
|
|
136
|
+
["/ask", "Toggle read-only mode"],
|
|
137
|
+
["/auto", "Toggle auto-accept"],
|
|
138
|
+
["/skills", "List available skills"],
|
|
139
|
+
["/", "Show slash commands"],
|
|
140
|
+
["/exit", "Quit"],
|
|
141
|
+
]],
|
|
142
|
+
["Context", [
|
|
143
|
+
["/add <f>", "Add file to context"],
|
|
144
|
+
["/drop <f>", "Remove file from context"],
|
|
145
|
+
["/files", "List context files"],
|
|
146
|
+
]],
|
|
147
|
+
["Git", [
|
|
148
|
+
["/diff", "Show uncommitted changes"],
|
|
149
|
+
["/status", "Git status"],
|
|
150
|
+
["/log", "Recent commits"],
|
|
151
|
+
["/undo", "Undo last commit"],
|
|
152
|
+
["/commit", "Commit all changes"],
|
|
153
|
+
["/init", "Create KALCODE.md"],
|
|
154
|
+
]],
|
|
155
|
+
];
|
|
156
|
+
for (const [title, cmds] of sections) {
|
|
157
|
+
const titleLine = ` ${BOLD(title)}`;
|
|
158
|
+
console.log(`│${padRight(titleLine, inner)}│`);
|
|
159
|
+
for (const [cmd, desc] of cmds) {
|
|
160
|
+
const line = ` ${BOLD(cmd.padEnd(14))}${DIM(desc)}`;
|
|
161
|
+
console.log(`│${padRight(line, inner)}│`);
|
|
162
|
+
}
|
|
163
|
+
console.log(`│${" ".repeat(inner)}│`);
|
|
164
|
+
}
|
|
165
|
+
console.log(`└${"─".repeat(inner)}┘`);
|
|
166
|
+
console.log("");
|
|
167
|
+
}
|
|
168
|
+
// ─── Tool calls (Claude Code style ● marker + ⎿ continuation) ──────
|
|
169
|
+
export function renderToolCall(name, args) {
|
|
170
|
+
const display = toolDisplayName(name);
|
|
171
|
+
const summary = formatToolSummary(name, args);
|
|
172
|
+
console.log("");
|
|
173
|
+
console.log(summary
|
|
174
|
+
? ` ${CYAN("●")} ${BOLD(display)} ${DIM(summary)}`
|
|
175
|
+
: ` ${CYAN("●")} ${BOLD(display)}`);
|
|
176
|
+
}
|
|
177
|
+
export function renderToolResult(name, result, compact) {
|
|
178
|
+
const lines = result.split("\n").filter((l) => l.length > 0);
|
|
179
|
+
if (lines.length === 0)
|
|
180
|
+
return;
|
|
181
|
+
const cont = ` ${DIM("⎿")} `;
|
|
182
|
+
if (name === "writeFile" || name === "editFile") {
|
|
183
|
+
console.log(`${cont}${DIM(truncLine(lines[0]))}`);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const maxLines = compact ? 4 : 8;
|
|
187
|
+
const visible = lines.length <= maxLines
|
|
188
|
+
? lines
|
|
189
|
+
: [...lines.slice(0, maxLines - 1), `… ${lines.length - maxLines + 1} more lines`];
|
|
190
|
+
for (const line of visible) {
|
|
191
|
+
console.log(`${cont}${DIM(truncLine(line))}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// ─── Model info ─────────────────────────────────────────────────────
|
|
195
|
+
export function renderModelInfo(current, available) {
|
|
196
|
+
console.log("");
|
|
197
|
+
console.log(` Current: ${BOLD(shortModelName(current))}`);
|
|
198
|
+
console.log("");
|
|
199
|
+
for (const m of available) {
|
|
200
|
+
const active = m.id === current;
|
|
201
|
+
const marker = active ? GREEN("●") : DIM("○");
|
|
202
|
+
const name = active ? BOLD(m.name) : m.name;
|
|
203
|
+
const params = DIM(`(${m.params})`);
|
|
204
|
+
console.log(` ${marker} ${name} ${params}`);
|
|
205
|
+
}
|
|
206
|
+
console.log("");
|
|
207
|
+
}
|
|
208
|
+
// ─── Misc renders ───────────────────────────────────────────────────
|
|
209
|
+
export function renderError(message) {
|
|
210
|
+
console.log(` ${RED("✗")} ${RED(message)}`);
|
|
211
|
+
}
|
|
212
|
+
export function renderUsage(usage) {
|
|
213
|
+
if (!usage)
|
|
214
|
+
return;
|
|
215
|
+
const { prompt_tokens, completion_tokens, total_tokens } = usage;
|
|
216
|
+
console.log(DIM(`\n ${total_tokens} tokens · ${prompt_tokens} in · ${completion_tokens} out`));
|
|
217
|
+
}
|
|
218
|
+
export function renderThinking() {
|
|
219
|
+
process.stdout.write(DIM(" thinking…"));
|
|
220
|
+
}
|
|
221
|
+
export function clearThinking() {
|
|
222
|
+
process.stdout.write("\r\x1b[2K");
|
|
223
|
+
}
|
|
224
|
+
export function renderRetryWait(attempt, waitSec) {
|
|
225
|
+
process.stdout.write(`\r\x1b[2K ${YELLOW("⏳")} ${DIM(`Rate limited — retry ${attempt} in ${waitSec}s`)}`);
|
|
226
|
+
}
|
|
227
|
+
export function renderInterrupted() {
|
|
228
|
+
console.log("");
|
|
229
|
+
console.log(` ${YELLOW("⚠")} ${YELLOW("Interrupted")}`);
|
|
230
|
+
}
|
|
231
|
+
// ─── Private helpers ────────────────────────────────────────────────
|
|
232
|
+
function toolDisplayName(name) {
|
|
233
|
+
switch (name) {
|
|
234
|
+
case "readFile":
|
|
235
|
+
return "Read";
|
|
236
|
+
case "writeFile":
|
|
237
|
+
return "Write";
|
|
238
|
+
case "editFile":
|
|
239
|
+
return "Edit";
|
|
240
|
+
case "runCommand":
|
|
241
|
+
return "Bash";
|
|
242
|
+
case "grep":
|
|
243
|
+
return "Grep";
|
|
244
|
+
case "glob":
|
|
245
|
+
return "Glob";
|
|
246
|
+
case "listDirectory":
|
|
247
|
+
return "List";
|
|
248
|
+
default:
|
|
249
|
+
return name;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function formatToolSummary(name, args) {
|
|
253
|
+
switch (name) {
|
|
254
|
+
case "readFile":
|
|
255
|
+
case "writeFile":
|
|
256
|
+
case "editFile":
|
|
257
|
+
return String(args.filePath || "");
|
|
258
|
+
case "runCommand": {
|
|
259
|
+
const cmd = String(args.command || "");
|
|
260
|
+
return cmd.length > 80 ? cmd.slice(0, 80) + "…" : cmd;
|
|
261
|
+
}
|
|
262
|
+
case "grep":
|
|
263
|
+
return `"${args.pattern}" in ${args.path || "."}`;
|
|
264
|
+
case "glob":
|
|
265
|
+
return String(args.pattern || "");
|
|
266
|
+
case "listDirectory":
|
|
267
|
+
return String(args.dirPath || ".");
|
|
268
|
+
default:
|
|
269
|
+
return "";
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
//# sourceMappingURL=terminal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["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ED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thejeetsingh/kalcode",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "CLI coding agent powered by NVIDIA NIM",
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "CLI coding agent powered by NVIDIA NIM — works with npm and bun",
|
|
5
5
|
"author": "Jeet Singh",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -18,39 +18,39 @@
|
|
|
18
18
|
"ai",
|
|
19
19
|
"nvidia",
|
|
20
20
|
"nim",
|
|
21
|
-
"terminal"
|
|
21
|
+
"terminal",
|
|
22
|
+
"agent"
|
|
22
23
|
],
|
|
23
24
|
"type": "module",
|
|
24
25
|
"bin": {
|
|
25
|
-
"kalcode": "./bin/kalcode.
|
|
26
|
+
"kalcode": "./dist/bin/kalcode.js"
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
|
28
|
-
"
|
|
29
|
-
"src",
|
|
30
|
-
"api",
|
|
29
|
+
"dist",
|
|
31
30
|
"README.md",
|
|
32
|
-
"LICENSE"
|
|
33
|
-
"tsconfig.json",
|
|
34
|
-
"vercel.json"
|
|
31
|
+
"LICENSE"
|
|
35
32
|
],
|
|
36
33
|
"engines": {
|
|
37
|
-
"
|
|
34
|
+
"node": ">=18"
|
|
38
35
|
},
|
|
39
36
|
"publishConfig": {
|
|
40
37
|
"access": "public"
|
|
41
38
|
},
|
|
42
39
|
"scripts": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"prepublishOnly": "npm run build",
|
|
42
|
+
"start": "node dist/bin/kalcode.js",
|
|
43
|
+
"dev": "tsc --watch",
|
|
44
|
+
"start:bun": "bun run bin/kalcode.ts",
|
|
45
45
|
"proxy": "bun run src/proxy/server.ts",
|
|
46
|
-
"proxy:dev": "bun --watch run src/proxy/server.ts",
|
|
47
46
|
"typecheck": "tsc --noEmit"
|
|
48
47
|
},
|
|
49
48
|
"dependencies": {
|
|
50
|
-
"chalk": "^5.4.0"
|
|
49
|
+
"chalk": "^5.4.0",
|
|
50
|
+
"glob": "^11.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/
|
|
53
|
+
"@types/node": "^22.0.0",
|
|
54
54
|
"typescript": "^5.7.0"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/api/health.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const API_URL = "https://integrate.api.nvidia.com/v1/chat/completions";
|
|
2
|
-
|
|
3
|
-
export const runtime = "edge";
|
|
4
|
-
|
|
5
|
-
function json(status: number, payload: Record<string, unknown>): Response {
|
|
6
|
-
return new Response(JSON.stringify(payload), {
|
|
7
|
-
status,
|
|
8
|
-
headers: {
|
|
9
|
-
"Content-Type": "application/json",
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function getBearerToken(req: Request): string {
|
|
15
|
-
const auth = req.headers.get("authorization") || "";
|
|
16
|
-
const m = auth.match(/^Bearer\s+(.+)$/i);
|
|
17
|
-
return m?.[1]?.trim() || "";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default async function handler(req: Request): Promise<Response> {
|
|
21
|
-
if (req.method !== "POST") {
|
|
22
|
-
return json(405, { error: { message: "Method not allowed." } });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const serverNimKey = process.env.NVIDIA_NIM_KEY || "";
|
|
26
|
-
const requiredProxyToken = process.env.KALCODE_PROXY_TOKEN || "";
|
|
27
|
-
|
|
28
|
-
if (!serverNimKey) {
|
|
29
|
-
return json(500, { error: { message: "Server missing NVIDIA_NIM_KEY." } });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (requiredProxyToken) {
|
|
33
|
-
const incoming = getBearerToken(req);
|
|
34
|
-
if (!incoming || incoming !== requiredProxyToken) {
|
|
35
|
-
return json(401, { error: { message: "Unauthorized." } });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const body = await req.text();
|
|
40
|
-
const upstream = await fetch(API_URL, {
|
|
41
|
-
method: "POST",
|
|
42
|
-
headers: {
|
|
43
|
-
"Content-Type": "application/json",
|
|
44
|
-
Authorization: `Bearer ${serverNimKey}`,
|
|
45
|
-
},
|
|
46
|
-
body,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const headers = new Headers();
|
|
50
|
-
const contentType = upstream.headers.get("content-type");
|
|
51
|
-
if (contentType) headers.set("Content-Type", contentType);
|
|
52
|
-
const cacheControl = upstream.headers.get("cache-control");
|
|
53
|
-
if (cacheControl) headers.set("Cache-Control", cacheControl);
|
|
54
|
-
|
|
55
|
-
return new Response(upstream.body, {
|
|
56
|
-
status: upstream.status,
|
|
57
|
-
headers,
|
|
58
|
-
});
|
|
59
|
-
}
|
package/bin/kalcode.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
// Optional local-dev escape hatch for TLS issues. Never enable in production.
|
|
3
|
-
if (process.env.KALCODE_INSECURE_TLS === "1") {
|
|
4
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
5
|
-
console.warn("Warning: insecure TLS mode enabled (KALCODE_INSECURE_TLS=1).");
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
import { main } from "../src/index.js";
|
|
9
|
-
|
|
10
|
-
main().catch((err) => {
|
|
11
|
-
console.error("Fatal error:", err);
|
|
12
|
-
process.exit(1);
|
|
13
|
-
});
|
|
14
|
-
|
package/src/agent/context.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { readFileSync, existsSync, statSync } from "fs";
|
|
2
|
-
import { resolve, relative } from "path";
|
|
3
|
-
import { MAX_FILE_SIZE } from "../constants.js";
|
|
4
|
-
|
|
5
|
-
const addedFiles = new Map<string, string>();
|
|
6
|
-
|
|
7
|
-
export function addFileToContext(filePath: string): string {
|
|
8
|
-
const abs = resolve(filePath);
|
|
9
|
-
if (!existsSync(abs)) return `File not found: ${filePath}`;
|
|
10
|
-
const stat = statSync(abs);
|
|
11
|
-
if (stat.isDirectory()) return `Cannot add directory: ${filePath}`;
|
|
12
|
-
if (stat.size > MAX_FILE_SIZE) return `File too large: ${filePath}`;
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
const content = readFileSync(abs, "utf-8");
|
|
16
|
-
const rel = relative(process.cwd(), abs);
|
|
17
|
-
addedFiles.set(rel, content);
|
|
18
|
-
return `Added ${rel} (${content.split("\n").length} lines)`;
|
|
19
|
-
} catch (err) {
|
|
20
|
-
return `Error reading ${filePath}: ${err}`;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function dropFileFromContext(filePath: string): string {
|
|
25
|
-
const abs = resolve(filePath);
|
|
26
|
-
const rel = relative(process.cwd(), abs);
|
|
27
|
-
if (addedFiles.has(rel)) {
|
|
28
|
-
addedFiles.delete(rel);
|
|
29
|
-
return `Dropped ${rel}`;
|
|
30
|
-
}
|
|
31
|
-
// Try matching by the raw input too
|
|
32
|
-
if (addedFiles.has(filePath)) {
|
|
33
|
-
addedFiles.delete(filePath);
|
|
34
|
-
return `Dropped ${filePath}`;
|
|
35
|
-
}
|
|
36
|
-
return `Not in context: ${filePath}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function getContextFiles(): Map<string, string> {
|
|
40
|
-
return addedFiles;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function listContextFiles(): string[] {
|
|
44
|
-
return Array.from(addedFiles.keys());
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function clearContextFiles(): void {
|
|
48
|
-
addedFiles.clear();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function buildContextBlock(): string {
|
|
52
|
-
if (addedFiles.size === 0) return "";
|
|
53
|
-
let block = "\n\nFiles in context (provided by user for reference):\n";
|
|
54
|
-
for (const [path, content] of addedFiles) {
|
|
55
|
-
const lines = content.split("\n");
|
|
56
|
-
const preview = lines.length > 200
|
|
57
|
-
? lines.slice(0, 200).join("\n") + `\n... (${lines.length - 200} more lines)`
|
|
58
|
-
: content;
|
|
59
|
-
block += `\n--- ${path} ---\n${preview}\n`;
|
|
60
|
-
}
|
|
61
|
-
return block;
|
|
62
|
-
}
|
package/src/agent/history.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { Message } from "../types.js";
|
|
2
|
-
import { buildSystemPrompt } from "../constants.js";
|
|
3
|
-
import { loadProjectMemory } from "./memory.js";
|
|
4
|
-
import { buildContextBlock } from "./context.js";
|
|
5
|
-
import { isGitRepo, gitCurrentBranch } from "../git/git.js";
|
|
6
|
-
|
|
7
|
-
let messages: Message[] = [];
|
|
8
|
-
|
|
9
|
-
export async function initHistory(): Promise<void> {
|
|
10
|
-
let systemContent = buildSystemPrompt(process.cwd());
|
|
11
|
-
|
|
12
|
-
// Load project memory
|
|
13
|
-
const memory = loadProjectMemory(process.cwd());
|
|
14
|
-
if (memory) {
|
|
15
|
-
systemContent += `\n\nProject conventions (from KALCODE.md):\n${memory}`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Git context
|
|
19
|
-
if (isGitRepo()) {
|
|
20
|
-
const branch = await gitCurrentBranch();
|
|
21
|
-
systemContent += `\n\nGit: on branch "${branch}"`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
messages = [{ role: "system", content: systemContent }];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function addMessage(msg: Message): void {
|
|
28
|
-
messages.push(msg);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function getMessages(): Message[] {
|
|
32
|
-
// Inject context files into the last user message if present
|
|
33
|
-
const contextBlock = buildContextBlock();
|
|
34
|
-
if (!contextBlock) return messages;
|
|
35
|
-
|
|
36
|
-
// Clone and append context to the system message
|
|
37
|
-
const result = [...messages];
|
|
38
|
-
if (result.length > 0 && result[0]!.role === "system") {
|
|
39
|
-
result[0] = { ...result[0]!, content: result[0]!.content + contextBlock };
|
|
40
|
-
}
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getLastUserMessage(): string | null {
|
|
45
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
46
|
-
if (messages[i]!.role === "user") {
|
|
47
|
-
return messages[i]!.content as string;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function removeLastExchange(): void {
|
|
54
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
55
|
-
if (messages[i]!.role === "user") {
|
|
56
|
-
messages = messages.slice(0, i);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function clearHistory(): void {
|
|
63
|
-
// Re-init is async now, but we can just reset messages
|
|
64
|
-
const systemMsg = messages.length > 0 ? messages[0]! : { role: "system" as const, content: "" };
|
|
65
|
-
messages = [systemMsg];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function getMessageCount(): number {
|
|
69
|
-
return messages.filter(m => m.role !== "system").length;
|
|
70
|
-
}
|