codeep 1.2.87 → 1.2.88

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.
@@ -190,12 +190,17 @@ export async function handleCommand(input, session, onChunk, abortSignal) {
190
190
  return { handled: true, response: `Write access granted for \`${ctx?.name || session.workspaceRoot}\`` };
191
191
  }
192
192
  case 'lang': {
193
+ const validLangs = ['auto', 'en', 'zh', 'es', 'hi', 'ar', 'pt', 'fr', 'de', 'ja', 'ru', 'hr'];
193
194
  if (!args.length) {
194
195
  const current = config.get('language') || 'auto';
195
- return { handled: true, response: `Current language: \`${current}\`. Usage: \`/lang <code>\` (e.g. \`en\`, \`hr\`, \`auto\`)` };
196
+ return { handled: true, response: `Current language: \`${current}\`. Usage: \`/lang <code>\` (${validLangs.join(', ')})` };
196
197
  }
197
- config.set('language', args[0]);
198
- return { handled: true, response: `Language set to \`${args[0]}\`` };
198
+ const lang = args[0].toLowerCase();
199
+ if (!validLangs.includes(lang)) {
200
+ return { handled: true, response: `Invalid language \`${args[0]}\`. Valid: ${validLangs.join(', ')}` };
201
+ }
202
+ config.set('language', lang);
203
+ return { handled: true, response: `Language set to \`${lang}\`` };
199
204
  }
200
205
  // ─── File context ──────────────────────────────────────────────────────────
201
206
  case 'add': {
@@ -211,7 +216,11 @@ export async function handleCommand(input, session, onChunk, abortSignal) {
211
216
  const added = [];
212
217
  const errors = [];
213
218
  for (const filePath of args) {
214
- const fullPath = pathMod.isAbsolute(filePath) ? filePath : pathMod.join(root, filePath);
219
+ const fullPath = pathMod.resolve(root, filePath);
220
+ if (!fullPath.startsWith(root + pathMod.sep) && fullPath !== root) {
221
+ errors.push(`\`${filePath}\`: path outside workspace`);
222
+ continue;
223
+ }
215
224
  const relativePath = pathMod.relative(root, fullPath);
216
225
  try {
217
226
  const stat = await fs.stat(fullPath);
@@ -248,7 +257,9 @@ export async function handleCommand(input, session, onChunk, abortSignal) {
248
257
  const root = session.workspaceRoot;
249
258
  let dropped = 0;
250
259
  for (const filePath of args) {
251
- const fullPath = pathMod.isAbsolute(filePath) ? filePath : pathMod.join(root, filePath);
260
+ const fullPath = pathMod.resolve(root, filePath);
261
+ if (!fullPath.startsWith(root + pathMod.sep) && fullPath !== root)
262
+ continue;
252
263
  if (session.addedFiles.delete(fullPath))
253
264
  dropped++;
254
265
  }
@@ -1,5 +1,7 @@
1
1
  // acp/transport.ts
2
2
  // Newline-delimited JSON-RPC over stdio
3
+ const MAX_BUFFER_SIZE = 10 * 1024 * 1024; // 10MB
4
+ const REQUEST_TIMEOUT_MS = 30_000; // 30s
3
5
  export class StdioTransport {
4
6
  buffer = '';
5
7
  handler = null;
@@ -13,6 +15,10 @@ export class StdioTransport {
13
15
  }
14
16
  onData(chunk) {
15
17
  this.buffer += chunk;
18
+ if (this.buffer.length > MAX_BUFFER_SIZE) {
19
+ this.buffer = '';
20
+ return;
21
+ }
16
22
  const lines = this.buffer.split('\n');
17
23
  this.buffer = lines.pop() ?? '';
18
24
  for (const line of lines) {
@@ -59,6 +65,11 @@ export class StdioTransport {
59
65
  return new Promise((resolve) => {
60
66
  this.pendingRequests.set(id, resolve);
61
67
  process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n');
68
+ setTimeout(() => {
69
+ if (this.pendingRequests.delete(id)) {
70
+ resolve(null);
71
+ }
72
+ }, REQUEST_TIMEOUT_MS);
62
73
  });
63
74
  }
64
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "1.2.87",
3
+ "version": "1.2.88",
4
4
  "description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",