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