@polka-codes/cli 0.9.59 → 0.9.61
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/dist/index.js +55 -28
- 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.
|
|
35582
|
+
var version = "0.9.61";
|
|
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.
|
|
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
|
|
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
|
}
|
|
@@ -77801,7 +77808,8 @@ var prices_default = {
|
|
|
77801
77808
|
"claude-sonnet-4-20250514": { inputPrice: 3, outputPrice: 15, cacheWritesPrice: 3.75, cacheReadsPrice: 0.3, supportsThinking: true },
|
|
77802
77809
|
"claude-3-7-sonnet-20250219": { inputPrice: 3, outputPrice: 15, cacheWritesPrice: 3.75, cacheReadsPrice: 0.3, supportsThinking: true },
|
|
77803
77810
|
"claude-3-5-sonnet-20241022": { inputPrice: 3, outputPrice: 15, cacheWritesPrice: 3.75, cacheReadsPrice: 0.3, supportsThinking: false },
|
|
77804
|
-
"claude-3-5-haiku-20241022": { inputPrice: 0.8, outputPrice: 4, cacheWritesPrice: 1, cacheReadsPrice: 0.08, supportsThinking: false }
|
|
77811
|
+
"claude-3-5-haiku-20241022": { inputPrice: 0.8, outputPrice: 4, cacheWritesPrice: 1, cacheReadsPrice: 0.08, supportsThinking: false },
|
|
77812
|
+
"claude-haiku-4-5-20250929": { inputPrice: 1, outputPrice: 5, cacheWritesPrice: 1.25, cacheReadsPrice: 0.1, supportsThinking: false }
|
|
77805
77813
|
},
|
|
77806
77814
|
["ollama" /* Ollama */]: {},
|
|
77807
77815
|
["deepseek" /* DeepSeek */]: {
|
|
@@ -77810,19 +77818,28 @@ var prices_default = {
|
|
|
77810
77818
|
},
|
|
77811
77819
|
["openrouter" /* OpenRouter */]: {},
|
|
77812
77820
|
["openai" /* OpenAI */]: {
|
|
77813
|
-
"gpt-5-2025-08-07": { inputPrice: 1.25, outputPrice: 10, cacheWritesPrice: 0, cacheReadsPrice: 0.125, supportsThinking:
|
|
77821
|
+
"gpt-5-2025-08-07": { inputPrice: 1.25, outputPrice: 10, cacheWritesPrice: 0, cacheReadsPrice: 0.125, supportsThinking: true },
|
|
77814
77822
|
"gpt-5-mini-2025-08-07": { inputPrice: 0.25, outputPrice: 2, cacheWritesPrice: 0, cacheReadsPrice: 0.025, supportsThinking: false },
|
|
77815
|
-
"gpt-5-nano-2025-08-07": { inputPrice: 0.05, outputPrice: 0.4, cacheWritesPrice: 0, cacheReadsPrice: 0.005, supportsThinking: false }
|
|
77823
|
+
"gpt-5-nano-2025-08-07": { inputPrice: 0.05, outputPrice: 0.4, cacheWritesPrice: 0, cacheReadsPrice: 0.005, supportsThinking: false },
|
|
77824
|
+
"gpt-5.1-2025-11-13": { inputPrice: 1.25, outputPrice: 10, cacheWritesPrice: 0, cacheReadsPrice: 0.125, supportsThinking: true },
|
|
77825
|
+
"gpt-5.1-codex": { inputPrice: 1.25, outputPrice: 10, cacheWritesPrice: 0, cacheReadsPrice: 0.125, supportsThinking: true }
|
|
77816
77826
|
},
|
|
77817
77827
|
["google-vertex" /* GoogleVertex */]: {
|
|
77818
|
-
"gemini-2.5-pro": { inputPrice: 1.25, outputPrice: 10, cacheWritesPrice:
|
|
77828
|
+
"gemini-2.5-pro": { inputPrice: 1.25, outputPrice: 10, cacheWritesPrice: 1.625, cacheReadsPrice: 0.125, supportsThinking: true },
|
|
77819
77829
|
"gemini-2.5-flash": { inputPrice: 0.3, outputPrice: 2.5, cacheWritesPrice: 0, cacheReadsPrice: 0.075, supportsThinking: true },
|
|
77820
77830
|
"gemini-2.5-flash-lite": { inputPrice: 0.1, outputPrice: 0.4, cacheWritesPrice: 0, cacheReadsPrice: 0.025, supportsThinking: false },
|
|
77821
|
-
"gemini-
|
|
77822
|
-
inputPrice:
|
|
77823
|
-
outputPrice:
|
|
77824
|
-
cacheWritesPrice:
|
|
77825
|
-
cacheReadsPrice: 0.
|
|
77831
|
+
"gemini-3-pro-preview": {
|
|
77832
|
+
inputPrice: 2,
|
|
77833
|
+
outputPrice: 12,
|
|
77834
|
+
cacheWritesPrice: 2.375,
|
|
77835
|
+
cacheReadsPrice: 0.2,
|
|
77836
|
+
supportsThinking: true
|
|
77837
|
+
},
|
|
77838
|
+
"gemini-3-pro": {
|
|
77839
|
+
inputPrice: 2,
|
|
77840
|
+
outputPrice: 12,
|
|
77841
|
+
cacheWritesPrice: 2.375,
|
|
77842
|
+
cacheReadsPrice: 0.2,
|
|
77826
77843
|
supportsThinking: true
|
|
77827
77844
|
}
|
|
77828
77845
|
}
|
|
@@ -80254,7 +80271,7 @@ async function runCode(task, _options, command) {
|
|
|
80254
80271
|
if (stdin) {
|
|
80255
80272
|
taskInput = stdin;
|
|
80256
80273
|
}
|
|
80257
|
-
const { file: files } = parseOptions(command.opts());
|
|
80274
|
+
const { file: files } = parseOptions(command.opts(), { commandName: "code" });
|
|
80258
80275
|
const fileContents = [];
|
|
80259
80276
|
if (files) {
|
|
80260
80277
|
for (const file2 of files) {
|
|
@@ -80393,7 +80410,7 @@ ${input2.context}
|
|
|
80393
80410
|
Commit message:
|
|
80394
80411
|
${commitMessage}`);
|
|
80395
80412
|
await tools2.createCommit({ message: commitMessage });
|
|
80396
|
-
return;
|
|
80413
|
+
return commitMessage;
|
|
80397
80414
|
}
|
|
80398
80415
|
}
|
|
80399
80416
|
context.logger.warn("Failed to generate commit message.", result);
|
|
@@ -80842,13 +80859,14 @@ async function runPreflightChecks(epicContext, context) {
|
|
|
80842
80859
|
}
|
|
80843
80860
|
async function performReviewAndFixCycle(iterationCount, taskItem, highLevelPlan, context) {
|
|
80844
80861
|
const { logger, step, tools: tools2 } = context;
|
|
80862
|
+
const commitMessages = [];
|
|
80845
80863
|
for (let i = 0;i < MAX_REVIEW_RETRIES; i++) {
|
|
80846
80864
|
const diffResult = await tools2.executeCommand({ command: "git", args: ["diff", "--name-status", "HEAD~1", "HEAD"] });
|
|
80847
80865
|
const changedFiles = parseGitDiffNameStatus(diffResult.stdout).filter(({ path }) => path !== ".epic.yml");
|
|
80848
80866
|
if (changedFiles.length === 0) {
|
|
80849
80867
|
logger.info(`No files were changed. Skipping review.
|
|
80850
80868
|
`);
|
|
80851
|
-
return { passed: true };
|
|
80869
|
+
return { passed: true, commitMessages: [] };
|
|
80852
80870
|
}
|
|
80853
80871
|
logger.info(`
|
|
80854
80872
|
Review iteration ${i + 1}/${MAX_REVIEW_RETRIES}`);
|
|
@@ -80879,7 +80897,7 @@ ${formatReviewToolInput(changeInfo)}`;
|
|
|
80879
80897
|
if (!reviewResult || !reviewResult.specificReviews || reviewResult.specificReviews.length === 0) {
|
|
80880
80898
|
logger.info(`Review passed. No issues found.
|
|
80881
80899
|
`);
|
|
80882
|
-
return { passed: true };
|
|
80900
|
+
return { passed: true, commitMessages };
|
|
80883
80901
|
}
|
|
80884
80902
|
logger.warn(`Warning: Review found ${reviewResult.specificReviews.length} issue(s). Attempting to fix...
|
|
80885
80903
|
`);
|
|
@@ -80910,17 +80928,22 @@ ${reviewSummary}`;
|
|
|
80910
80928
|
}, context);
|
|
80911
80929
|
});
|
|
80912
80930
|
await step(`commit-fix-${iterationCount}-${i}`, async () => {
|
|
80913
|
-
await
|
|
80914
|
-
|
|
80931
|
+
const commitMessage = await commitWorkflow({
|
|
80932
|
+
all: true,
|
|
80933
|
+
context: reviewSummary
|
|
80934
|
+
}, context);
|
|
80935
|
+
if (commitMessage) {
|
|
80936
|
+
commitMessages.push(commitMessage);
|
|
80937
|
+
}
|
|
80915
80938
|
});
|
|
80916
80939
|
if (i === MAX_REVIEW_RETRIES - 1) {
|
|
80917
80940
|
logger.error(`
|
|
80918
80941
|
Max retries (${MAX_REVIEW_RETRIES}) reached. Moving to the next task, but issues might remain.
|
|
80919
80942
|
`);
|
|
80920
|
-
return { passed: false };
|
|
80943
|
+
return { passed: false, commitMessages };
|
|
80921
80944
|
}
|
|
80922
80945
|
}
|
|
80923
|
-
return { passed: false };
|
|
80946
|
+
return { passed: false, commitMessages };
|
|
80924
80947
|
}
|
|
80925
80948
|
async function findNextTask(tools2) {
|
|
80926
80949
|
const openRootTasks = await tools2.listTodoItems({ status: "open" });
|
|
@@ -80979,7 +81002,8 @@ Focus only on this item, but use the plan for context.`;
|
|
|
80979
81002
|
await tools2.executeCommand({ command: "git", args: ["commit", "-m", commitMessage] });
|
|
80980
81003
|
});
|
|
80981
81004
|
commitMessages.push(commitMessage);
|
|
80982
|
-
const { passed: reviewPassed } = await performReviewAndFixCycle(iterationCount, nextTask, highLevelPlan, context);
|
|
81005
|
+
const { passed: reviewPassed, commitMessages: fixCommitMessages } = await performReviewAndFixCycle(iterationCount, nextTask, highLevelPlan, context);
|
|
81006
|
+
commitMessages.push(...fixCommitMessages);
|
|
80983
81007
|
const taskElapsed = Date.now() - taskStartTime;
|
|
80984
81008
|
const taskElapsedTime = formatElapsedTime(taskElapsed);
|
|
80985
81009
|
if (reviewPassed) {
|
|
@@ -81633,7 +81657,10 @@ async function runEpic(task2, _options, command) {
|
|
|
81633
81657
|
const workflowInput = {
|
|
81634
81658
|
...epicContext,
|
|
81635
81659
|
async saveEpicContext(context) {
|
|
81636
|
-
await saveEpicContext(
|
|
81660
|
+
await saveEpicContext({
|
|
81661
|
+
...epicContext,
|
|
81662
|
+
...context
|
|
81663
|
+
});
|
|
81637
81664
|
},
|
|
81638
81665
|
saveUsageSnapshot
|
|
81639
81666
|
};
|