@polka-codes/cli 0.6.1 → 0.6.2
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 +44 -33
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20433,9 +20433,9 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
20433
20433
|
function foldLines(source) {
|
|
20434
20434
|
let first, line;
|
|
20435
20435
|
try {
|
|
20436
|
-
first = new RegExp(`(.*?)(?<![
|
|
20436
|
+
first = new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
20437
20437
|
`, "sy");
|
|
20438
|
-
line = new RegExp(`[
|
|
20438
|
+
line = new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
20439
20439
|
`, "sy");
|
|
20440
20440
|
} catch {
|
|
20441
20441
|
first = /(.*?)[ \t]*\r?\n/sy;
|
|
@@ -21435,7 +21435,7 @@ var require_lexer = __commonJS((exports) => {
|
|
|
21435
21435
|
var tagChars = new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()");
|
|
21436
21436
|
var flowIndicatorChars = new Set(",[]{}");
|
|
21437
21437
|
var invalidAnchorChars = new Set(` ,[]{}
|
|
21438
|
-
\r
|
|
21438
|
+
\r `);
|
|
21439
21439
|
var isNotAnchorChar = (ch) => !ch || invalidAnchorChars.has(ch);
|
|
21440
21440
|
|
|
21441
21441
|
class Lexer {
|
|
@@ -24629,7 +24629,7 @@ var {
|
|
|
24629
24629
|
Help
|
|
24630
24630
|
} = import__.default;
|
|
24631
24631
|
// package.json
|
|
24632
|
-
var version = "0.6.
|
|
24632
|
+
var version = "0.6.2";
|
|
24633
24633
|
|
|
24634
24634
|
// ../../node_modules/@anthropic-ai/sdk/version.mjs
|
|
24635
24635
|
var VERSION = "0.36.2";
|
|
@@ -30771,7 +30771,7 @@ var _parseJSON = (jsonString, allow) => {
|
|
|
30771
30771
|
};
|
|
30772
30772
|
const skipBlank = () => {
|
|
30773
30773
|
while (index < length && `
|
|
30774
|
-
\r
|
|
30774
|
+
\r `.includes(jsonString[index])) {
|
|
30775
30775
|
index++;
|
|
30776
30776
|
}
|
|
30777
30777
|
};
|
|
@@ -45391,53 +45391,64 @@ var mergeArray = (a2, b2) => {
|
|
|
45391
45391
|
}
|
|
45392
45392
|
return [...a2, ...b2];
|
|
45393
45393
|
};
|
|
45394
|
-
function
|
|
45394
|
+
function mergeConfigs(configs) {
|
|
45395
|
+
if (configs.length === 0) {
|
|
45396
|
+
return {};
|
|
45397
|
+
}
|
|
45398
|
+
const mergedConfig = configs.reduce((acc, config) => {
|
|
45399
|
+
const merged = import_lodash.merge({}, acc, config);
|
|
45400
|
+
let accRules = acc.rules ?? [];
|
|
45401
|
+
if (typeof accRules === "string") {
|
|
45402
|
+
accRules = [accRules];
|
|
45403
|
+
}
|
|
45404
|
+
let configRules = config.rules ?? [];
|
|
45405
|
+
if (typeof configRules === "string") {
|
|
45406
|
+
configRules = [configRules];
|
|
45407
|
+
}
|
|
45408
|
+
merged.rules = mergeArray(accRules, configRules);
|
|
45409
|
+
merged.excludeFiles = mergeArray(acc.excludeFiles, config.excludeFiles);
|
|
45410
|
+
return merged;
|
|
45411
|
+
});
|
|
45412
|
+
return mergedConfig;
|
|
45413
|
+
}
|
|
45414
|
+
function loadConfig(paths, cwd = process.cwd(), home = homedir()) {
|
|
45415
|
+
const configs = [];
|
|
45395
45416
|
const globalConfigPath = getGlobalConfigPath(home);
|
|
45396
|
-
let globalConfig;
|
|
45397
45417
|
if (existsSync(globalConfigPath)) {
|
|
45398
45418
|
try {
|
|
45399
|
-
globalConfig = readConfig(globalConfigPath);
|
|
45419
|
+
const globalConfig = readConfig(globalConfigPath);
|
|
45420
|
+
configs.push(globalConfig);
|
|
45400
45421
|
} catch (error) {
|
|
45401
45422
|
console.warn(`Error loading global config file: ${globalConfigPath}
|
|
45402
45423
|
${error}`);
|
|
45403
45424
|
}
|
|
45404
45425
|
}
|
|
45405
|
-
|
|
45406
|
-
|
|
45407
|
-
|
|
45408
|
-
|
|
45409
|
-
|
|
45410
|
-
|
|
45426
|
+
if (paths) {
|
|
45427
|
+
const configPaths = Array.isArray(paths) ? paths : [paths];
|
|
45428
|
+
for (const path4 of configPaths) {
|
|
45429
|
+
try {
|
|
45430
|
+
const config = readConfig(path4);
|
|
45431
|
+
configs.push(config);
|
|
45432
|
+
} catch (error) {
|
|
45433
|
+
console.error(`Error loading config file: ${path4}
|
|
45411
45434
|
${error}`);
|
|
45412
|
-
|
|
45435
|
+
throw error;
|
|
45436
|
+
}
|
|
45413
45437
|
}
|
|
45414
45438
|
} else {
|
|
45415
45439
|
const configPath = join3(cwd, localConfigFileName);
|
|
45416
45440
|
try {
|
|
45417
|
-
projectConfig = readConfig(configPath);
|
|
45441
|
+
const projectConfig = readConfig(configPath);
|
|
45442
|
+
configs.push(projectConfig);
|
|
45418
45443
|
} catch (error) {
|
|
45419
45444
|
if (error instanceof ZodError) {
|
|
45420
|
-
console.error(`Error in config file: ${
|
|
45445
|
+
console.error(`Error in config file: ${configPath}
|
|
45421
45446
|
${error}`);
|
|
45422
45447
|
throw error;
|
|
45423
45448
|
}
|
|
45424
45449
|
}
|
|
45425
45450
|
}
|
|
45426
|
-
|
|
45427
|
-
const mergedConfig = import_lodash.merge({}, globalConfig, projectConfig);
|
|
45428
|
-
let projectRules = projectConfig.rules ?? [];
|
|
45429
|
-
if (typeof projectRules === "string") {
|
|
45430
|
-
projectRules = [projectRules];
|
|
45431
|
-
}
|
|
45432
|
-
let globalRules = globalConfig.rules ?? [];
|
|
45433
|
-
if (typeof globalRules === "string") {
|
|
45434
|
-
globalRules = [globalRules];
|
|
45435
|
-
}
|
|
45436
|
-
mergedConfig.rules = mergeArray(globalRules, projectRules);
|
|
45437
|
-
mergedConfig.excludeFiles = mergeArray(globalConfig.excludeFiles, projectConfig.excludeFiles);
|
|
45438
|
-
return mergedConfig;
|
|
45439
|
-
}
|
|
45440
|
-
return projectConfig || globalConfig;
|
|
45451
|
+
return configs.length > 0 ? mergeConfigs(configs) : undefined;
|
|
45441
45452
|
}
|
|
45442
45453
|
var readConfig = (path4) => {
|
|
45443
45454
|
const file = readFileSync(path4, "utf8");
|
|
@@ -45447,7 +45458,7 @@ var readConfig = (path4) => {
|
|
|
45447
45458
|
|
|
45448
45459
|
// src/options.ts
|
|
45449
45460
|
function addSharedOptions(command) {
|
|
45450
|
-
return command.option("-c --config <
|
|
45461
|
+
return command.option("-c --config <paths...>", "Path to config file(s)").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. Default to 50", Number.parseInt, 50).option("--budget <budget>", "Budget for the AI service. Default to $1000", Number.parseFloat, 1000).option("-v --verbose", "Enable verbose output. Use -v for level 1, -vv for level 2", (value, prev) => prev + 1, 0).option("-d --base-dir <path>", "Base directory to run commands in");
|
|
45451
45462
|
}
|
|
45452
45463
|
function parseOptions(options, cwdArg, home = os2.homedir()) {
|
|
45453
45464
|
let cwd = cwdArg;
|