@polka-codes/cli 0.9.59 → 0.9.60

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 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -35579,7 +35579,7 @@ var {
35579
35579
  Help
35580
35580
  } = import__.default;
35581
35581
  // package.json
35582
- var version = "0.9.59";
35582
+ var version = "0.9.60";
35583
35583
 
35584
35584
  // src/commands/code.ts
35585
35585
  import { readFile as readFile3 } from "node:fs/promises";
@@ -48181,7 +48181,8 @@ config(en_default());
48181
48181
  var providerModelSchema = exports_external.object({
48182
48182
  provider: exports_external.string().optional(),
48183
48183
  model: exports_external.string().optional(),
48184
- parameters: exports_external.record(exports_external.string(), exports_external.any()).optional()
48184
+ parameters: exports_external.record(exports_external.string(), exports_external.any()).optional(),
48185
+ budget: exports_external.number().positive().optional()
48185
48186
  });
48186
48187
  var configSchema = exports_external.object({
48187
48188
  prices: exports_external.record(exports_external.string(), exports_external.record(exports_external.string(), exports_external.object({
@@ -48210,9 +48211,7 @@ var configSchema = exports_external.object({
48210
48211
  command: exports_external.string(),
48211
48212
  description: exports_external.string()
48212
48213
  }))).optional(),
48213
- commands: exports_external.object({
48214
- default: providerModelSchema.optional()
48215
- }).catchall(providerModelSchema).optional(),
48214
+ commands: exports_external.record(exports_external.string(), providerModelSchema).optional(),
48216
48215
  rules: exports_external.array(exports_external.string()).optional().or(exports_external.string()).optional(),
48217
48216
  excludeFiles: exports_external.array(exports_external.string()).optional()
48218
48217
  }).strict();
@@ -77708,7 +77707,9 @@ class ApiProviderConfig {
77708
77707
  this.commands = config4.commands;
77709
77708
  }
77710
77709
  getConfigForCommand(command) {
77711
- const { provider: provider3, model, parameters } = this.commands?.[command] ?? this.commands?.default ?? {};
77710
+ const commandConfig = this.commands?.[command];
77711
+ const defaultConfig = this.commands?.default;
77712
+ const { provider: provider3, model, parameters, budget } = { ...defaultConfig, ...commandConfig };
77712
77713
  const finalProvider = provider3 ?? this.defaultProvider;
77713
77714
  if (!finalProvider) {
77714
77715
  return;
@@ -77728,7 +77729,8 @@ class ApiProviderConfig {
77728
77729
  project,
77729
77730
  keyFile,
77730
77731
  baseUrl,
77731
- parameters: finalParameters
77732
+ parameters: finalParameters,
77733
+ budget
77732
77734
  };
77733
77735
  }
77734
77736
  }
@@ -77737,7 +77739,7 @@ class ApiProviderConfig {
77737
77739
  function addSharedOptions(command) {
77738
77740
  return command.option("-c --config <paths>", "Path to config file(s)", (value, prev) => prev.concat(value), []).option("--api-provider <provider>", "API provider").option("--model <model>", "Model ID").option("--api-key <key>", "API key").option("--max-messages <iterations>", "Maximum number of messages to send.", Number.parseInt).option("--budget <budget>", "Budget for the AI service.", Number.parseFloat).option("-v --verbose", "Enable verbose output. Use -v for level 1, -vv for level 2", (_value, prev) => (prev ?? 0) + 1).option("-d --base-dir <path>", "Base directory to run commands in").option("--file <path...>", "File to include in the task").option("--silent", "Enable silent mode").option("-y, --yes", "Skip interactive prompts", false);
77739
77741
  }
77740
- function parseOptions(options, { cwdArg } = {}, home = os2.homedir(), env2 = getEnv()) {
77742
+ function parseOptions(options, { cwdArg, commandName } = {}, home = os2.homedir(), env2 = getEnv()) {
77741
77743
  let cwd = cwdArg;
77742
77744
  if (options.baseDir) {
77743
77745
  process.chdir(options.baseDir);
@@ -77773,13 +77775,18 @@ function parseOptions(options, { cwdArg } = {}, home = os2.homedir(), env2 = get
77773
77775
  defaultProvider,
77774
77776
  ...config4
77775
77777
  });
77778
+ const commandConfig = commandName ? providerConfig.getConfigForCommand(commandName) : undefined;
77776
77779
  const verbose = options.silent ? -1 : options.verbose ?? 0;
77780
+ const commandSpecificConfig = commandName ? config4.commands?.[commandName] : undefined;
77781
+ const defaultCommandConfig = config4.commands?.default;
77782
+ const mergedCommandConfig = { ...defaultCommandConfig, ...commandSpecificConfig };
77777
77783
  return {
77778
77784
  maxMessageCount: options.maxMessageCount ?? config4.maxMessageCount ?? 100,
77779
- budget: options.budget ?? (env2.POLKA_BUDGET ? Number.parseFloat(env2.POLKA_BUDGET) : undefined) ?? config4.budget ?? 10,
77785
+ budget: options.budget ?? mergedCommandConfig.budget ?? (env2.POLKA_BUDGET ? Number.parseFloat(env2.POLKA_BUDGET) : undefined) ?? config4.budget ?? 10,
77780
77786
  verbose,
77781
77787
  config: config4,
77782
77788
  providerConfig,
77789
+ commandConfig,
77783
77790
  file: options.file
77784
77791
  };
77785
77792
  }
@@ -80254,7 +80261,7 @@ async function runCode(task, _options, command) {
80254
80261
  if (stdin) {
80255
80262
  taskInput = stdin;
80256
80263
  }
80257
- const { file: files } = parseOptions(command.opts());
80264
+ const { file: files } = parseOptions(command.opts(), { commandName: "code" });
80258
80265
  const fileContents = [];
80259
80266
  if (files) {
80260
80267
  for (const file2 of files) {
@@ -80393,7 +80400,7 @@ ${input2.context}
80393
80400
  Commit message:
80394
80401
  ${commitMessage}`);
80395
80402
  await tools2.createCommit({ message: commitMessage });
80396
- return;
80403
+ return commitMessage;
80397
80404
  }
80398
80405
  }
80399
80406
  context.logger.warn("Failed to generate commit message.", result);
@@ -80842,13 +80849,14 @@ async function runPreflightChecks(epicContext, context) {
80842
80849
  }
80843
80850
  async function performReviewAndFixCycle(iterationCount, taskItem, highLevelPlan, context) {
80844
80851
  const { logger, step, tools: tools2 } = context;
80852
+ const commitMessages = [];
80845
80853
  for (let i = 0;i < MAX_REVIEW_RETRIES; i++) {
80846
80854
  const diffResult = await tools2.executeCommand({ command: "git", args: ["diff", "--name-status", "HEAD~1", "HEAD"] });
80847
80855
  const changedFiles = parseGitDiffNameStatus(diffResult.stdout).filter(({ path }) => path !== ".epic.yml");
80848
80856
  if (changedFiles.length === 0) {
80849
80857
  logger.info(`No files were changed. Skipping review.
80850
80858
  `);
80851
- return { passed: true };
80859
+ return { passed: true, commitMessages: [] };
80852
80860
  }
80853
80861
  logger.info(`
80854
80862
  Review iteration ${i + 1}/${MAX_REVIEW_RETRIES}`);
@@ -80879,7 +80887,7 @@ ${formatReviewToolInput(changeInfo)}`;
80879
80887
  if (!reviewResult || !reviewResult.specificReviews || reviewResult.specificReviews.length === 0) {
80880
80888
  logger.info(`Review passed. No issues found.
80881
80889
  `);
80882
- return { passed: true };
80890
+ return { passed: true, commitMessages };
80883
80891
  }
80884
80892
  logger.warn(`Warning: Review found ${reviewResult.specificReviews.length} issue(s). Attempting to fix...
80885
80893
  `);
@@ -80910,17 +80918,22 @@ ${reviewSummary}`;
80910
80918
  }, context);
80911
80919
  });
80912
80920
  await step(`commit-fix-${iterationCount}-${i}`, async () => {
80913
- await tools2.executeCommand({ command: "git", args: ["add", "."] });
80914
- await tools2.executeCommand({ command: "git", args: ["commit", "--amend", "--no-edit"] });
80921
+ const commitMessage = await commitWorkflow({
80922
+ all: true,
80923
+ context: reviewSummary
80924
+ }, context);
80925
+ if (commitMessage) {
80926
+ commitMessages.push(commitMessage);
80927
+ }
80915
80928
  });
80916
80929
  if (i === MAX_REVIEW_RETRIES - 1) {
80917
80930
  logger.error(`
80918
80931
  Max retries (${MAX_REVIEW_RETRIES}) reached. Moving to the next task, but issues might remain.
80919
80932
  `);
80920
- return { passed: false };
80933
+ return { passed: false, commitMessages };
80921
80934
  }
80922
80935
  }
80923
- return { passed: false };
80936
+ return { passed: false, commitMessages };
80924
80937
  }
80925
80938
  async function findNextTask(tools2) {
80926
80939
  const openRootTasks = await tools2.listTodoItems({ status: "open" });
@@ -80979,7 +80992,8 @@ Focus only on this item, but use the plan for context.`;
80979
80992
  await tools2.executeCommand({ command: "git", args: ["commit", "-m", commitMessage] });
80980
80993
  });
80981
80994
  commitMessages.push(commitMessage);
80982
- const { passed: reviewPassed } = await performReviewAndFixCycle(iterationCount, nextTask, highLevelPlan, context);
80995
+ const { passed: reviewPassed, commitMessages: fixCommitMessages } = await performReviewAndFixCycle(iterationCount, nextTask, highLevelPlan, context);
80996
+ commitMessages.push(...fixCommitMessages);
80983
80997
  const taskElapsed = Date.now() - taskStartTime;
80984
80998
  const taskElapsedTime = formatElapsedTime(taskElapsed);
80985
80999
  if (reviewPassed) {
@@ -81633,7 +81647,10 @@ async function runEpic(task2, _options, command) {
81633
81647
  const workflowInput = {
81634
81648
  ...epicContext,
81635
81649
  async saveEpicContext(context) {
81636
- await saveEpicContext(context);
81650
+ await saveEpicContext({
81651
+ ...epicContext,
81652
+ ...context
81653
+ });
81637
81654
  },
81638
81655
  saveUsageSnapshot
81639
81656
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.9.59",
3
+ "version": "0.9.60",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",