@polka-codes/cli 0.9.96 → 0.9.98

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.
Files changed (2) hide show
  1. package/dist/index.js +36 -79
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -75842,7 +75842,6 @@ class FileLock {
75842
75842
  const dbBaseName = basename2(dbPath);
75843
75843
  const files = await readdir2(lockDir);
75844
75844
  const now3 = Date.now();
75845
- let cleanedCount = 0;
75846
75845
  for (const file2 of files) {
75847
75846
  if (!file2.startsWith(`${dbBaseName}.lock.`)) {
75848
75847
  continue;
@@ -75857,7 +75856,6 @@ class FileLock {
75857
75856
  if (age > maxAge) {
75858
75857
  try {
75859
75858
  await unlink2(filePath);
75860
- cleanedCount++;
75861
75859
  } catch (error48) {
75862
75860
  const errorCode = error48?.code;
75863
75861
  if (errorCode !== "ENOENT") {
@@ -75866,9 +75864,6 @@ class FileLock {
75866
75864
  }
75867
75865
  }
75868
75866
  }
75869
- if (cleanedCount > 0) {
75870
- console.log(`[FileLock] Cleaned up ${cleanedCount} old lock file(s) (older than ${maxAge}ms)`);
75871
- }
75872
75867
  } catch (error48) {
75873
75868
  console.debug(`[FileLock] Cleanup encountered an error: ${error48 instanceof Error ? error48.message : String(error48)}`);
75874
75869
  }
@@ -92231,6 +92226,7 @@ var init_env = () => {};
92231
92226
 
92232
92227
  // src/getModel.ts
92233
92228
  import { appendFileSync } from "node:fs";
92229
+ import { inspect } from "node:util";
92234
92230
  function headersToObject(headers) {
92235
92231
  if (!headers) {
92236
92232
  return;
@@ -92263,10 +92259,10 @@ var AiProvider, getModel = (config4, debugLogging = false) => {
92263
92259
  const fetchOverride = debugLogging || TRACING_FILE ? async (url2, options) => {
92264
92260
  const requestBody = options?.body ? JSON.parse(options.body) : undefined;
92265
92261
  if (debugLogging) {
92266
- console.log("-> Request URL:", url2);
92267
- console.log("-> Request Headers:", options?.headers);
92268
- console.log("-> Request Body:");
92269
- console.dir(requestBody, { depth: null });
92262
+ console.error("-> Request URL:", url2);
92263
+ console.error("-> Request Headers:", options?.headers);
92264
+ console.error("-> Request Body:");
92265
+ console.error(inspect(requestBody, { depth: null, colors: process.stderr.isTTY }));
92270
92266
  }
92271
92267
  if (TRACING_FILE) {
92272
92268
  appendFileSync(TRACING_FILE, `${JSON.stringify({
@@ -92280,7 +92276,7 @@ var AiProvider, getModel = (config4, debugLogging = false) => {
92280
92276
  }
92281
92277
  const res = await fetch(url2, options);
92282
92278
  if (debugLogging) {
92283
- console.log("<- Response Status:", res.status);
92279
+ console.error("<- Response Status:", res.status);
92284
92280
  }
92285
92281
  const contentType = res.headers.get("content-type") || "";
92286
92282
  if (contentType.includes("text/event-stream") && res.body) {
@@ -92296,7 +92292,7 @@ var AiProvider, getModel = (config4, debugLogging = false) => {
92296
92292
  if (value) {
92297
92293
  const text2 = decoder.decode(value);
92298
92294
  if (debugLogging) {
92299
- console.log("<- Stream chunk:", text2.replace(/\n/g, "\\n"));
92295
+ console.error("<- Stream chunk:", text2.replace(/\n/g, "\\n"));
92300
92296
  }
92301
92297
  if (TRACING_FILE) {
92302
92298
  for (const line of text2.split(`
@@ -92347,8 +92343,8 @@ var AiProvider, getModel = (config4, debugLogging = false) => {
92347
92343
  responseBody = full;
92348
92344
  }
92349
92345
  if (debugLogging) {
92350
- console.log("<- Response Body:");
92351
- console.dir(responseBody, { depth: null });
92346
+ console.error("<- Response Body:");
92347
+ console.error(inspect(responseBody, { depth: null, colors: process.stderr.isTTY }));
92352
92348
  }
92353
92349
  if (TRACING_FILE) {
92354
92350
  appendFileSync(TRACING_FILE, `${JSON.stringify({
@@ -112342,7 +112338,7 @@ var {
112342
112338
  Help
112343
112339
  } = import__.default;
112344
112340
  // package.json
112345
- var version = "0.9.96";
112341
+ var version = "0.9.98";
112346
112342
 
112347
112343
  // src/commands/agent.ts
112348
112344
  init_src();
@@ -116318,15 +116314,18 @@ class AutonomousAgent {
116318
116314
  }
116319
116315
 
116320
116316
  // src/logger.ts
116317
+ import { formatWithOptions } from "node:util";
116321
116318
  function createStreamConsole(stdout, stderr) {
116319
+ const isStdoutTTY = "isTTY" in stdout && stdout.isTTY;
116320
+ const isStderrTTY = "isTTY" in stderr && stderr.isTTY;
116322
116321
  return {
116323
- log: (...args) => stdout.write(`${args.map(String).join(" ")}
116322
+ log: (...args) => stdout.write(`${formatWithOptions({ colors: isStdoutTTY }, ...args)}
116324
116323
  `),
116325
- info: (...args) => stdout.write(`${args.map(String).join(" ")}
116324
+ info: (...args) => stdout.write(`${formatWithOptions({ colors: isStdoutTTY }, ...args)}
116326
116325
  `),
116327
- warn: (...args) => stderr.write(`${args.map(String).join(" ")}
116326
+ warn: (...args) => stderr.write(`${formatWithOptions({ colors: isStderrTTY }, ...args)}
116328
116327
  `),
116329
- error: (...args) => stderr.write(`${args.map(String).join(" ")}
116328
+ error: (...args) => stderr.write(`${formatWithOptions({ colors: isStderrTTY }, ...args)}
116330
116329
  `)
116331
116330
  };
116332
116331
  }
@@ -116808,7 +116807,7 @@ function addSharedOptions(command) {
116808
116807
  async function parseOptions(options, { cwdArg, commandName } = {}, home = os3.homedir(), env2 = getEnv()) {
116809
116808
  const cwd = options.baseDir ?? cwdArg ?? process.cwd();
116810
116809
  if (options.baseDir) {
116811
- console.log("Using base directory:", cwd);
116810
+ console.error("Using base directory:", cwd);
116812
116811
  process.chdir(cwd);
116813
116812
  }
116814
116813
  const config4 = await loadConfig2(options.config, cwd, home) ?? {};
@@ -116990,22 +116989,22 @@ async function createCommit(input, _context) {
116990
116989
  }
116991
116990
  return { message: input.message };
116992
116991
  }
116993
- async function printChangeFile(_input, _context) {
116992
+ async function printChangeFile(_input, context) {
116994
116993
  const { stagedFiles, unstagedFiles } = getLocalChanges();
116995
116994
  if (stagedFiles.length === 0 && unstagedFiles.length === 0) {
116996
- console.log("No changes to commit.");
116995
+ context.workflowContext.logger.info("No changes to commit.");
116997
116996
  } else {
116998
116997
  if (stagedFiles.length > 0) {
116999
- console.log("Staged files:");
116998
+ context.workflowContext.logger.info("Staged files:");
117000
116999
  for (const file2 of stagedFiles) {
117001
- console.log(`- ${file2.status}: ${file2.path}`);
117000
+ context.workflowContext.logger.info(`- ${file2.status}: ${file2.path}`);
117002
117001
  }
117003
117002
  }
117004
117003
  if (unstagedFiles.length > 0) {
117005
- console.log(`
117004
+ context.workflowContext.logger.info(`
117006
117005
  Unstaged files:`);
117007
117006
  for (const file2 of unstagedFiles) {
117008
- console.log(`- ${file2.status}: ${file2.path}`);
117007
+ context.workflowContext.logger.info(`- ${file2.status}: ${file2.path}`);
117009
117008
  }
117010
117009
  }
117011
117010
  }
@@ -117043,43 +117042,6 @@ async function select(input2, context) {
117043
117042
  }
117044
117043
  async function executeCommand(input2) {
117045
117044
  return new Promise((resolve7, reject) => {
117046
- const ALLOWED_COMMANDS = [
117047
- "git",
117048
- "npm",
117049
- "npx",
117050
- "node",
117051
- "bun",
117052
- "python",
117053
- "python3",
117054
- "ls",
117055
- "cat",
117056
- "grep",
117057
- "find",
117058
- "head",
117059
- "tail",
117060
- "wc",
117061
- "sort",
117062
- "uniq",
117063
- "awk",
117064
- "sed",
117065
- "curl",
117066
- "wget",
117067
- "rsync",
117068
- "cp",
117069
- "mv",
117070
- "rm",
117071
- "mkdir",
117072
- "chmod",
117073
- "chown",
117074
- "file",
117075
- "which",
117076
- "type",
117077
- "echo"
117078
- ];
117079
- if (!ALLOWED_COMMANDS.includes(input2.command)) {
117080
- reject(new Error(`Command not allowed: ${input2.command}`));
117081
- return;
117082
- }
117083
117045
  const child = input2.shell === true ? input2.args && input2.args.length > 0 ? spawn4(input2.command, input2.args, { shell: true, stdio: "pipe" }) : spawn4(input2.command, { shell: true, stdio: "pipe" }) : spawn4(input2.command, input2.args, {
117084
117046
  shell: false,
117085
117047
  stdio: "pipe"
@@ -118162,7 +118124,7 @@ var fetchOllamaModels = async () => {
118162
118124
  const data = await resp.json();
118163
118125
  return data.models.map((model) => model.name);
118164
118126
  } catch (_error) {
118165
- console.log("Unable to fetch Ollama models");
118127
+ console.error("Unable to fetch Ollama models");
118166
118128
  return [];
118167
118129
  }
118168
118130
  };
@@ -120178,7 +120140,7 @@ async function getMemoryStore(logger) {
120178
120140
  const cwd = process.cwd();
120179
120141
  const scope = detectProjectScope(cwd);
120180
120142
  const dbPath = memoryConfig.path || DEFAULT_MEMORY_CONFIG.path;
120181
- const resolvedDbPath = path11.resolve(cwd, dbPath);
120143
+ const resolvedDbPath = path11.resolve(resolveHomePath(dbPath));
120182
120144
  const sqliteStore = new SQLiteMemoryStore({ enabled: true, type: "sqlite", path: resolvedDbPath }, scope);
120183
120145
  const memoryManager = new MemoryManager(sqliteStore);
120184
120146
  memoryStoreCache = {
@@ -121620,27 +121582,24 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
121620
121582
  const { json: json2, pr: pr3, range, context: contextOption, loop: maxIterations, yes: yesOption } = options;
121621
121583
  const yes = maxIterations > 1 || yesOption;
121622
121584
  let changesAppliedInThisIteration = false;
121623
- let context = contextOption;
121624
- let filesToReview = files;
121625
- if (files.length === 1 && !existsSync7(files[0]) && files[0].includes(" ") && !context) {
121626
- if (!json2) {
121627
- console.warn("Warning: The argument looks like context but was passed as a file. Treating it as context. Please use --context for review instructions in the future.");
121628
- }
121629
- context = files[0];
121630
- filesToReview = [];
121631
- }
121632
121585
  const workflowOpts = getBaseWorkflowOptions(command);
121633
121586
  if (json2) {
121634
121587
  workflowOpts.interactive = false;
121635
- workflowOpts.silent = true;
121636
121588
  }
121637
121589
  const { verbose } = workflowOpts;
121638
121590
  const logger = createLogger({
121639
- verbose: json2 ? -1 : verbose
121591
+ verbose
121640
121592
  });
121593
+ let context = contextOption;
121594
+ let filesToReview = files;
121595
+ if (files.length === 1 && !existsSync7(files[0]) && files[0].includes(" ") && !context) {
121596
+ logger.warn("Warning: The argument looks like context but was passed as a file. Treating it as context. Please use --context for review instructions in the future.");
121597
+ context = files[0];
121598
+ filesToReview = [];
121599
+ }
121641
121600
  for (let i2 = 0;i2 < maxIterations; i2++) {
121642
121601
  changesAppliedInThisIteration = false;
121643
- if (i2 > 0 && !json2) {
121602
+ if (i2 > 0) {
121644
121603
  logger.debug(`Re-running review (iteration ${i2 + 1} of ${maxIterations})...`);
121645
121604
  }
121646
121605
  const reviewResult = await reviewCode({
@@ -121713,9 +121672,7 @@ ${formattedReview}`;
121713
121672
  }
121714
121673
  }
121715
121674
  if (maxIterations > 1 && !changesAppliedInThisIteration) {
121716
- if (!json2) {
121717
- logger.debug("No more review feedback to apply. Exiting loop.");
121718
- }
121675
+ logger.debug("No more review feedback to apply. Exiting loop.");
121719
121676
  break;
121720
121677
  }
121721
121678
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.9.96",
3
+ "version": "0.9.98",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",