@polka-codes/cli 0.9.73 → 0.9.76
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 +248 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37660,7 +37660,7 @@ var {
|
|
|
37660
37660
|
Help
|
|
37661
37661
|
} = import__.default;
|
|
37662
37662
|
// package.json
|
|
37663
|
-
var version = "0.9.
|
|
37663
|
+
var version = "0.9.76";
|
|
37664
37664
|
|
|
37665
37665
|
// src/commands/code.ts
|
|
37666
37666
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
@@ -67138,6 +67138,7 @@ var vertex = createVertex2();
|
|
|
67138
67138
|
// ../../node_modules/@inquirer/core/dist/lib/key.js
|
|
67139
67139
|
var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
|
|
67140
67140
|
var isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
|
|
67141
|
+
var isSpaceKey = (key) => key.name === "space";
|
|
67141
67142
|
var isBackspaceKey = (key) => key.name === "backspace";
|
|
67142
67143
|
var isTabKey = (key) => key.name === "tab";
|
|
67143
67144
|
var isNumberKey = (key) => "1234567890".includes(key.name);
|
|
@@ -68632,6 +68633,179 @@ class Separator {
|
|
|
68632
68633
|
return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
|
|
68633
68634
|
}
|
|
68634
68635
|
}
|
|
68636
|
+
// ../../node_modules/@inquirer/checkbox/dist/index.js
|
|
68637
|
+
import { styleText as styleText3 } from "node:util";
|
|
68638
|
+
var checkboxTheme = {
|
|
68639
|
+
icon: {
|
|
68640
|
+
checked: styleText3("green", dist_default2.circleFilled),
|
|
68641
|
+
unchecked: dist_default2.circle,
|
|
68642
|
+
cursor: dist_default2.pointer
|
|
68643
|
+
},
|
|
68644
|
+
style: {
|
|
68645
|
+
disabledChoice: (text2) => styleText3("dim", `- ${text2}`),
|
|
68646
|
+
renderSelectedChoices: (selectedChoices) => selectedChoices.map((choice) => choice.short).join(", "),
|
|
68647
|
+
description: (text2) => styleText3("cyan", text2),
|
|
68648
|
+
keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText3("bold", key)} ${styleText3("dim", action)}`).join(styleText3("dim", " • "))
|
|
68649
|
+
},
|
|
68650
|
+
keybindings: []
|
|
68651
|
+
};
|
|
68652
|
+
function isSelectable(item) {
|
|
68653
|
+
return !Separator.isSeparator(item) && !item.disabled;
|
|
68654
|
+
}
|
|
68655
|
+
function isChecked(item) {
|
|
68656
|
+
return isSelectable(item) && item.checked;
|
|
68657
|
+
}
|
|
68658
|
+
function toggle(item) {
|
|
68659
|
+
return isSelectable(item) ? { ...item, checked: !item.checked } : item;
|
|
68660
|
+
}
|
|
68661
|
+
function check2(checked) {
|
|
68662
|
+
return function(item) {
|
|
68663
|
+
return isSelectable(item) ? { ...item, checked } : item;
|
|
68664
|
+
};
|
|
68665
|
+
}
|
|
68666
|
+
function normalizeChoices(choices) {
|
|
68667
|
+
return choices.map((choice) => {
|
|
68668
|
+
if (Separator.isSeparator(choice))
|
|
68669
|
+
return choice;
|
|
68670
|
+
if (typeof choice === "string") {
|
|
68671
|
+
return {
|
|
68672
|
+
value: choice,
|
|
68673
|
+
name: choice,
|
|
68674
|
+
short: choice,
|
|
68675
|
+
checkedName: choice,
|
|
68676
|
+
disabled: false,
|
|
68677
|
+
checked: false
|
|
68678
|
+
};
|
|
68679
|
+
}
|
|
68680
|
+
const name17 = choice.name ?? String(choice.value);
|
|
68681
|
+
const normalizedChoice = {
|
|
68682
|
+
value: choice.value,
|
|
68683
|
+
name: name17,
|
|
68684
|
+
short: choice.short ?? name17,
|
|
68685
|
+
checkedName: choice.checkedName ?? name17,
|
|
68686
|
+
disabled: choice.disabled ?? false,
|
|
68687
|
+
checked: choice.checked ?? false
|
|
68688
|
+
};
|
|
68689
|
+
if (choice.description) {
|
|
68690
|
+
normalizedChoice.description = choice.description;
|
|
68691
|
+
}
|
|
68692
|
+
return normalizedChoice;
|
|
68693
|
+
});
|
|
68694
|
+
}
|
|
68695
|
+
var dist_default3 = createPrompt((config3, done) => {
|
|
68696
|
+
const { pageSize = 7, loop = true, required: required2, validate: validate2 = () => true } = config3;
|
|
68697
|
+
const shortcuts = { all: "a", invert: "i", ...config3.shortcuts };
|
|
68698
|
+
const theme = makeTheme(checkboxTheme, config3.theme);
|
|
68699
|
+
const { keybindings } = theme;
|
|
68700
|
+
const [status, setStatus] = useState("idle");
|
|
68701
|
+
const prefix = usePrefix({ status, theme });
|
|
68702
|
+
const [items, setItems] = useState(normalizeChoices(config3.choices));
|
|
68703
|
+
const bounds = useMemo(() => {
|
|
68704
|
+
const first = items.findIndex(isSelectable);
|
|
68705
|
+
const last = items.findLastIndex(isSelectable);
|
|
68706
|
+
if (first === -1) {
|
|
68707
|
+
throw new ValidationError("[checkbox prompt] No selectable choices. All choices are disabled.");
|
|
68708
|
+
}
|
|
68709
|
+
return { first, last };
|
|
68710
|
+
}, [items]);
|
|
68711
|
+
const [active, setActive] = useState(bounds.first);
|
|
68712
|
+
const [errorMsg, setError] = useState();
|
|
68713
|
+
useKeypress(async (key) => {
|
|
68714
|
+
if (isEnterKey(key)) {
|
|
68715
|
+
const selection = items.filter(isChecked);
|
|
68716
|
+
const isValid2 = await validate2([...selection]);
|
|
68717
|
+
if (required2 && !items.some(isChecked)) {
|
|
68718
|
+
setError("At least one choice must be selected");
|
|
68719
|
+
} else if (isValid2 === true) {
|
|
68720
|
+
setStatus("done");
|
|
68721
|
+
done(selection.map((choice) => choice.value));
|
|
68722
|
+
} else {
|
|
68723
|
+
setError(isValid2 || "You must select a valid value");
|
|
68724
|
+
}
|
|
68725
|
+
} else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
|
|
68726
|
+
if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
|
|
68727
|
+
const offset = isUpKey(key, keybindings) ? -1 : 1;
|
|
68728
|
+
let next = active;
|
|
68729
|
+
do {
|
|
68730
|
+
next = (next + offset + items.length) % items.length;
|
|
68731
|
+
} while (!isSelectable(items[next]));
|
|
68732
|
+
setActive(next);
|
|
68733
|
+
}
|
|
68734
|
+
} else if (isSpaceKey(key)) {
|
|
68735
|
+
setError(undefined);
|
|
68736
|
+
setItems(items.map((choice, i2) => i2 === active ? toggle(choice) : choice));
|
|
68737
|
+
} else if (key.name === shortcuts.all) {
|
|
68738
|
+
const selectAll = items.some((choice) => isSelectable(choice) && !choice.checked);
|
|
68739
|
+
setItems(items.map(check2(selectAll)));
|
|
68740
|
+
} else if (key.name === shortcuts.invert) {
|
|
68741
|
+
setItems(items.map(toggle));
|
|
68742
|
+
} else if (isNumberKey(key)) {
|
|
68743
|
+
const selectedIndex = Number(key.name) - 1;
|
|
68744
|
+
let selectableIndex = -1;
|
|
68745
|
+
const position = items.findIndex((item) => {
|
|
68746
|
+
if (Separator.isSeparator(item))
|
|
68747
|
+
return false;
|
|
68748
|
+
selectableIndex++;
|
|
68749
|
+
return selectableIndex === selectedIndex;
|
|
68750
|
+
});
|
|
68751
|
+
const selectedItem = items[position];
|
|
68752
|
+
if (selectedItem && isSelectable(selectedItem)) {
|
|
68753
|
+
setActive(position);
|
|
68754
|
+
setItems(items.map((choice, i2) => i2 === position ? toggle(choice) : choice));
|
|
68755
|
+
}
|
|
68756
|
+
}
|
|
68757
|
+
});
|
|
68758
|
+
const message = theme.style.message(config3.message, status);
|
|
68759
|
+
let description;
|
|
68760
|
+
const page = usePagination({
|
|
68761
|
+
items,
|
|
68762
|
+
active,
|
|
68763
|
+
renderItem({ item, isActive }) {
|
|
68764
|
+
if (Separator.isSeparator(item)) {
|
|
68765
|
+
return ` ${item.separator}`;
|
|
68766
|
+
}
|
|
68767
|
+
if (item.disabled) {
|
|
68768
|
+
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
68769
|
+
return theme.style.disabledChoice(`${item.name} ${disabledLabel}`);
|
|
68770
|
+
}
|
|
68771
|
+
if (isActive) {
|
|
68772
|
+
description = item.description;
|
|
68773
|
+
}
|
|
68774
|
+
const checkbox = item.checked ? theme.icon.checked : theme.icon.unchecked;
|
|
68775
|
+
const name17 = item.checked ? item.checkedName : item.name;
|
|
68776
|
+
const color = isActive ? theme.style.highlight : (x2) => x2;
|
|
68777
|
+
const cursor = isActive ? theme.icon.cursor : " ";
|
|
68778
|
+
return color(`${cursor}${checkbox} ${name17}`);
|
|
68779
|
+
},
|
|
68780
|
+
pageSize,
|
|
68781
|
+
loop
|
|
68782
|
+
});
|
|
68783
|
+
if (status === "done") {
|
|
68784
|
+
const selection = items.filter(isChecked);
|
|
68785
|
+
const answer = theme.style.answer(theme.style.renderSelectedChoices(selection, items));
|
|
68786
|
+
return [prefix, message, answer].filter(Boolean).join(" ");
|
|
68787
|
+
}
|
|
68788
|
+
const keys = [
|
|
68789
|
+
["↑↓", "navigate"],
|
|
68790
|
+
["space", "select"]
|
|
68791
|
+
];
|
|
68792
|
+
if (shortcuts.all)
|
|
68793
|
+
keys.push([shortcuts.all, "all"]);
|
|
68794
|
+
if (shortcuts.invert)
|
|
68795
|
+
keys.push([shortcuts.invert, "invert"]);
|
|
68796
|
+
keys.push(["⏎", "submit"]);
|
|
68797
|
+
const helpLine = theme.style.keysHelpTip(keys);
|
|
68798
|
+
const lines = [
|
|
68799
|
+
[prefix, message].filter(Boolean).join(" "),
|
|
68800
|
+
page,
|
|
68801
|
+
" ",
|
|
68802
|
+
description ? theme.style.description(description) : "",
|
|
68803
|
+
errorMsg ? theme.style.error(errorMsg) : "",
|
|
68804
|
+
helpLine
|
|
68805
|
+
].filter(Boolean).join(`
|
|
68806
|
+
`).trimEnd();
|
|
68807
|
+
return `${lines}${cursorHide}`;
|
|
68808
|
+
});
|
|
68635
68809
|
// ../../node_modules/@inquirer/confirm/dist/index.js
|
|
68636
68810
|
function getBooleanValue(value, defaultValue) {
|
|
68637
68811
|
let answer = defaultValue !== false;
|
|
@@ -68644,7 +68818,7 @@ function getBooleanValue(value, defaultValue) {
|
|
|
68644
68818
|
function boolToString(value) {
|
|
68645
68819
|
return value ? "Yes" : "No";
|
|
68646
68820
|
}
|
|
68647
|
-
var
|
|
68821
|
+
var dist_default4 = createPrompt((config3, done) => {
|
|
68648
68822
|
const { transformer = boolToString } = config3;
|
|
68649
68823
|
const [status, setStatus] = useState("idle");
|
|
68650
68824
|
const [value, setValue] = useState("");
|
|
@@ -68681,7 +68855,7 @@ var dist_default3 = createPrompt((config3, done) => {
|
|
|
68681
68855
|
var inputTheme = {
|
|
68682
68856
|
validationFailureMode: "keep"
|
|
68683
68857
|
};
|
|
68684
|
-
var
|
|
68858
|
+
var dist_default5 = createPrompt((config3, done) => {
|
|
68685
68859
|
const { prefill = "tab" } = config3;
|
|
68686
68860
|
const theme = makeTheme(inputTheme, config3.theme);
|
|
68687
68861
|
const [status, setStatus] = useState("idle");
|
|
@@ -68762,7 +68936,7 @@ var dist_default4 = createPrompt((config3, done) => {
|
|
|
68762
68936
|
];
|
|
68763
68937
|
});
|
|
68764
68938
|
// ../../node_modules/@inquirer/password/dist/index.js
|
|
68765
|
-
var
|
|
68939
|
+
var dist_default6 = createPrompt((config3, done) => {
|
|
68766
68940
|
const { validate: validate2 = () => true } = config3;
|
|
68767
68941
|
const theme = makeTheme(config3.theme);
|
|
68768
68942
|
const [status, setStatus] = useState("idle");
|
|
@@ -68810,21 +68984,21 @@ var dist_default5 = createPrompt((config3, done) => {
|
|
|
68810
68984
|
return [[prefix, message, config3.mask ? formattedValue : helpTip].join(" "), error46];
|
|
68811
68985
|
});
|
|
68812
68986
|
// ../../node_modules/@inquirer/select/dist/index.js
|
|
68813
|
-
import { styleText as
|
|
68987
|
+
import { styleText as styleText4 } from "node:util";
|
|
68814
68988
|
var selectTheme = {
|
|
68815
68989
|
icon: { cursor: dist_default2.pointer },
|
|
68816
68990
|
style: {
|
|
68817
|
-
disabled: (text2) =>
|
|
68818
|
-
description: (text2) =>
|
|
68819
|
-
keysHelpTip: (keys) => keys.map(([key, action]) => `${
|
|
68991
|
+
disabled: (text2) => styleText4("dim", `- ${text2}`),
|
|
68992
|
+
description: (text2) => styleText4("cyan", text2),
|
|
68993
|
+
keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText4("bold", key)} ${styleText4("dim", action)}`).join(styleText4("dim", " • "))
|
|
68820
68994
|
},
|
|
68821
68995
|
indexMode: "hidden",
|
|
68822
68996
|
keybindings: []
|
|
68823
68997
|
};
|
|
68824
|
-
function
|
|
68998
|
+
function isSelectable2(item) {
|
|
68825
68999
|
return !Separator.isSeparator(item) && !item.disabled;
|
|
68826
69000
|
}
|
|
68827
|
-
function
|
|
69001
|
+
function normalizeChoices2(choices) {
|
|
68828
69002
|
return choices.map((choice) => {
|
|
68829
69003
|
if (Separator.isSeparator(choice))
|
|
68830
69004
|
return choice;
|
|
@@ -68849,7 +69023,7 @@ function normalizeChoices(choices) {
|
|
|
68849
69023
|
return normalizedChoice;
|
|
68850
69024
|
});
|
|
68851
69025
|
}
|
|
68852
|
-
var
|
|
69026
|
+
var dist_default7 = createPrompt((config3, done) => {
|
|
68853
69027
|
const { loop = true, pageSize = 7 } = config3;
|
|
68854
69028
|
const theme = makeTheme(selectTheme, config3.theme);
|
|
68855
69029
|
const { keybindings } = theme;
|
|
@@ -68857,10 +69031,10 @@ var dist_default6 = createPrompt((config3, done) => {
|
|
|
68857
69031
|
const prefix = usePrefix({ status, theme });
|
|
68858
69032
|
const searchTimeoutRef = useRef();
|
|
68859
69033
|
const searchEnabled = !keybindings.includes("vim");
|
|
68860
|
-
const items = useMemo(() =>
|
|
69034
|
+
const items = useMemo(() => normalizeChoices2(config3.choices), [config3.choices]);
|
|
68861
69035
|
const bounds = useMemo(() => {
|
|
68862
|
-
const first = items.findIndex(
|
|
68863
|
-
const last = items.findLastIndex(
|
|
69036
|
+
const first = items.findIndex(isSelectable2);
|
|
69037
|
+
const last = items.findLastIndex(isSelectable2);
|
|
68864
69038
|
if (first === -1) {
|
|
68865
69039
|
throw new ValidationError("[select prompt] No selectable choices. All choices are disabled.");
|
|
68866
69040
|
}
|
|
@@ -68869,7 +69043,7 @@ var dist_default6 = createPrompt((config3, done) => {
|
|
|
68869
69043
|
const defaultItemIndex = useMemo(() => {
|
|
68870
69044
|
if (!("default" in config3))
|
|
68871
69045
|
return -1;
|
|
68872
|
-
return items.findIndex((item) =>
|
|
69046
|
+
return items.findIndex((item) => isSelectable2(item) && item.value === config3.default);
|
|
68873
69047
|
}, [config3.default, items]);
|
|
68874
69048
|
const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
|
|
68875
69049
|
const selectedChoice = items[active];
|
|
@@ -68885,7 +69059,7 @@ var dist_default6 = createPrompt((config3, done) => {
|
|
|
68885
69059
|
let next = active;
|
|
68886
69060
|
do {
|
|
68887
69061
|
next = (next + offset + items.length) % items.length;
|
|
68888
|
-
} while (!
|
|
69062
|
+
} while (!isSelectable2(items[next]));
|
|
68889
69063
|
setActive(next);
|
|
68890
69064
|
}
|
|
68891
69065
|
} else if (isNumberKey(key) && !Number.isNaN(Number(rl.line))) {
|
|
@@ -68898,7 +69072,7 @@ var dist_default6 = createPrompt((config3, done) => {
|
|
|
68898
69072
|
return selectableIndex === selectedIndex;
|
|
68899
69073
|
});
|
|
68900
69074
|
const item = items[position];
|
|
68901
|
-
if (item != null &&
|
|
69075
|
+
if (item != null && isSelectable2(item)) {
|
|
68902
69076
|
setActive(position);
|
|
68903
69077
|
}
|
|
68904
69078
|
searchTimeoutRef.current = setTimeout(() => {
|
|
@@ -68909,7 +69083,7 @@ var dist_default6 = createPrompt((config3, done) => {
|
|
|
68909
69083
|
} else if (searchEnabled) {
|
|
68910
69084
|
const searchTerm = rl.line.toLowerCase();
|
|
68911
69085
|
const matchIndex = items.findIndex((item) => {
|
|
68912
|
-
if (Separator.isSeparator(item) || !
|
|
69086
|
+
if (Separator.isSeparator(item) || !isSelectable2(item))
|
|
68913
69087
|
return false;
|
|
68914
69088
|
return item.name.toLowerCase().startsWith(searchTerm);
|
|
68915
69089
|
});
|
|
@@ -69383,17 +69557,23 @@ ${content}`;
|
|
|
69383
69557
|
});
|
|
69384
69558
|
},
|
|
69385
69559
|
askFollowupQuestion: async (question, answerOptions) => {
|
|
69560
|
+
if (options.yes) {
|
|
69561
|
+
if (answerOptions.length > 0) {
|
|
69562
|
+
return answerOptions[0];
|
|
69563
|
+
}
|
|
69564
|
+
return "";
|
|
69565
|
+
}
|
|
69386
69566
|
if (answerOptions.length === 0) {
|
|
69387
|
-
return await
|
|
69567
|
+
return await dist_default5({ message: question });
|
|
69388
69568
|
}
|
|
69389
69569
|
const otherMessage = "Other (enter text)";
|
|
69390
69570
|
answerOptions.push(otherMessage);
|
|
69391
|
-
const answer = await
|
|
69571
|
+
const answer = await dist_default7({
|
|
69392
69572
|
message: question,
|
|
69393
69573
|
choices: answerOptions.map((option) => ({ name: option, value: option }))
|
|
69394
69574
|
});
|
|
69395
69575
|
if (answer === otherMessage) {
|
|
69396
|
-
return await
|
|
69576
|
+
return await dist_default5({ message: "Enter your answer:" });
|
|
69397
69577
|
}
|
|
69398
69578
|
return answer;
|
|
69399
69579
|
},
|
|
@@ -84086,7 +84266,7 @@ function applyCacheControl(messages, provider3, modelId) {
|
|
|
84086
84266
|
async function getUserInput(message, options = {}) {
|
|
84087
84267
|
const { default: defaultValue, throwOnCancel = false } = options;
|
|
84088
84268
|
try {
|
|
84089
|
-
let result = await
|
|
84269
|
+
let result = await dist_default5({
|
|
84090
84270
|
message: `${message}${source_default.gray(" (type .m for multiline)")}`,
|
|
84091
84271
|
default: defaultValue
|
|
84092
84272
|
});
|
|
@@ -84460,7 +84640,7 @@ async function confirm(input, context) {
|
|
|
84460
84640
|
await new Promise((resolve4) => setTimeout(resolve4, 50));
|
|
84461
84641
|
try {
|
|
84462
84642
|
process.stderr.write("\x07");
|
|
84463
|
-
const result = await
|
|
84643
|
+
const result = await dist_default4({ message: input.message });
|
|
84464
84644
|
return result;
|
|
84465
84645
|
} catch (_e) {
|
|
84466
84646
|
throw new UserCancelledError;
|
|
@@ -84487,7 +84667,7 @@ async function select(input2, context) {
|
|
|
84487
84667
|
await new Promise((resolve4) => setTimeout(resolve4, 50));
|
|
84488
84668
|
try {
|
|
84489
84669
|
process.stderr.write("\x07");
|
|
84490
|
-
const result = await
|
|
84670
|
+
const result = await dist_default7({ message: input2.message, choices: input2.choices });
|
|
84491
84671
|
return result;
|
|
84492
84672
|
} catch (_e) {
|
|
84493
84673
|
throw new UserCancelledError;
|
|
@@ -84791,6 +84971,7 @@ async function runWorkflow(workflow2, workflowInput, options) {
|
|
|
84791
84971
|
const excludeFiles = [".epic.yml", ...config4.excludeFiles ?? []];
|
|
84792
84972
|
const toolProvider = (options.getProvider ?? getProvider)({
|
|
84793
84973
|
excludeFiles,
|
|
84974
|
+
yes,
|
|
84794
84975
|
getModel: (tool3) => {
|
|
84795
84976
|
const toolConfig = config4.tools?.[tool3];
|
|
84796
84977
|
if (toolConfig === false) {
|
|
@@ -85806,14 +85987,14 @@ var fixWorkflow = async (input2, context) => {
|
|
|
85806
85987
|
let formatCommand;
|
|
85807
85988
|
if (!command) {
|
|
85808
85989
|
const config4 = await loadConfig();
|
|
85809
|
-
const
|
|
85990
|
+
const check3 = config4?.scripts?.check;
|
|
85810
85991
|
const test = config4?.scripts?.test;
|
|
85811
85992
|
const format = config4?.scripts?.format;
|
|
85812
85993
|
let checkCommand;
|
|
85813
|
-
if (typeof
|
|
85814
|
-
checkCommand =
|
|
85815
|
-
} else if (
|
|
85816
|
-
checkCommand =
|
|
85994
|
+
if (typeof check3 === "string") {
|
|
85995
|
+
checkCommand = check3;
|
|
85996
|
+
} else if (check3) {
|
|
85997
|
+
checkCommand = check3.command;
|
|
85817
85998
|
}
|
|
85818
85999
|
let testCommand;
|
|
85819
86000
|
if (typeof test === "string") {
|
|
@@ -87694,7 +87875,7 @@ var fetchOllamaModels = async () => {
|
|
|
87694
87875
|
}
|
|
87695
87876
|
};
|
|
87696
87877
|
async function configPrompt(existingConfig) {
|
|
87697
|
-
const provider3 = await
|
|
87878
|
+
const provider3 = await dist_default7({
|
|
87698
87879
|
message: "Choose AI Provider:",
|
|
87699
87880
|
choices: Object.entries(AiProvider).map(([key, value]) => ({ name: key, value })),
|
|
87700
87881
|
default: existingConfig?.provider
|
|
@@ -87702,7 +87883,7 @@ async function configPrompt(existingConfig) {
|
|
|
87702
87883
|
let model = existingConfig?.model;
|
|
87703
87884
|
switch (provider3) {
|
|
87704
87885
|
case "anthropic" /* Anthropic */:
|
|
87705
|
-
model = await
|
|
87886
|
+
model = await dist_default7({
|
|
87706
87887
|
message: "Choose Model ID:",
|
|
87707
87888
|
choices: Object.keys(prices_default["anthropic" /* Anthropic */]).map((key) => ({ name: key, value: key })),
|
|
87708
87889
|
default: existingConfig?.model ?? "claude-opus-4-20250514"
|
|
@@ -87712,18 +87893,18 @@ async function configPrompt(existingConfig) {
|
|
|
87712
87893
|
{
|
|
87713
87894
|
const models = await fetchOllamaModels();
|
|
87714
87895
|
if (models && models.length > 0) {
|
|
87715
|
-
model = await
|
|
87896
|
+
model = await dist_default7({
|
|
87716
87897
|
message: "Choose Model ID:",
|
|
87717
87898
|
choices: models.map((model2) => ({ name: model2, value: model2 })),
|
|
87718
87899
|
default: existingConfig?.model
|
|
87719
87900
|
});
|
|
87720
87901
|
} else {
|
|
87721
|
-
model = await
|
|
87902
|
+
model = await dist_default5({ message: "Enter Model ID:" });
|
|
87722
87903
|
}
|
|
87723
87904
|
}
|
|
87724
87905
|
break;
|
|
87725
87906
|
case "deepseek" /* DeepSeek */:
|
|
87726
|
-
model = await
|
|
87907
|
+
model = await dist_default7({
|
|
87727
87908
|
message: "Choose Model ID:",
|
|
87728
87909
|
choices: [
|
|
87729
87910
|
{ name: "deepseek-chat", value: "deepseek-chat" },
|
|
@@ -87733,16 +87914,16 @@ async function configPrompt(existingConfig) {
|
|
|
87733
87914
|
});
|
|
87734
87915
|
break;
|
|
87735
87916
|
case "openrouter" /* OpenRouter */:
|
|
87736
|
-
model = await
|
|
87917
|
+
model = await dist_default5({ message: "Enter Model ID (Visit https://openrouter.ai/models for available models):" });
|
|
87737
87918
|
break;
|
|
87738
87919
|
}
|
|
87739
87920
|
let apiKey;
|
|
87740
87921
|
if (provider3 !== "ollama" /* Ollama */) {
|
|
87741
|
-
apiKey = await
|
|
87922
|
+
apiKey = await dist_default6({ message: "Enter API Key:", mask: "*" });
|
|
87742
87923
|
}
|
|
87743
87924
|
let baseURL;
|
|
87744
87925
|
if (provider3 === "ollama" /* Ollama */) {
|
|
87745
|
-
baseURL = await
|
|
87926
|
+
baseURL = await dist_default5({ message: "Enter Ollama Base URL:", default: "http://localhost:11434" });
|
|
87746
87927
|
}
|
|
87747
87928
|
return { provider: provider3, model, apiKey, baseURL };
|
|
87748
87929
|
}
|
|
@@ -87761,7 +87942,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
87761
87942
|
const exists = existsSync2(configPath);
|
|
87762
87943
|
if (exists) {
|
|
87763
87944
|
if (interactive) {
|
|
87764
|
-
const proceed = await
|
|
87945
|
+
const proceed = await dist_default4({
|
|
87765
87946
|
message: `Found existing config at ${configPath}. Do you want to proceed? This will overwrite the existing config.`,
|
|
87766
87947
|
default: false
|
|
87767
87948
|
});
|
|
@@ -87772,7 +87953,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
87772
87953
|
}
|
|
87773
87954
|
} else if (!options.global) {
|
|
87774
87955
|
if (interactive) {
|
|
87775
|
-
const location = await
|
|
87956
|
+
const location = await dist_default7({
|
|
87776
87957
|
message: "No config file found. Do you want to create one?",
|
|
87777
87958
|
choices: [
|
|
87778
87959
|
{ name: `Create a global config at ${globalConfigPath}`, value: "global" },
|
|
@@ -87798,7 +87979,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
87798
87979
|
if (apiKey && !isGlobal) {
|
|
87799
87980
|
let option = "local";
|
|
87800
87981
|
if (interactive) {
|
|
87801
|
-
option = await
|
|
87982
|
+
option = await dist_default7({
|
|
87802
87983
|
message: "It is not recommended to store API keys in the local config file. How would you like to proceed?",
|
|
87803
87984
|
choices: [
|
|
87804
87985
|
{ name: "Save API key in the local config file", value: "local" },
|
|
@@ -87852,7 +88033,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
87852
88033
|
logger.info(`Configuration saved to ${configPath}`);
|
|
87853
88034
|
let shouldAnalyze = false;
|
|
87854
88035
|
if (!isGlobal && interactive) {
|
|
87855
|
-
shouldAnalyze = await
|
|
88036
|
+
shouldAnalyze = await dist_default4({
|
|
87856
88037
|
message: "Would you like to analyze the project to generate recommended configuration?",
|
|
87857
88038
|
default: false
|
|
87858
88039
|
});
|
|
@@ -88014,7 +88195,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
88014
88195
|
interactive: !yes && !json2
|
|
88015
88196
|
});
|
|
88016
88197
|
if (reviewResult) {
|
|
88017
|
-
|
|
88198
|
+
let formattedReview = formatReviewForConsole(reviewResult);
|
|
88018
88199
|
if (json2) {
|
|
88019
88200
|
console.log(JSON.stringify(reviewResult, null, 2));
|
|
88020
88201
|
} else if (formattedReview) {
|
|
@@ -88027,10 +88208,33 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
88027
88208
|
} else if (process.stdin.isTTY && !json2) {
|
|
88028
88209
|
await new Promise((resolve4) => setTimeout(resolve4, 50));
|
|
88029
88210
|
try {
|
|
88030
|
-
|
|
88211
|
+
const answer = await dist_default7({
|
|
88031
88212
|
message: "Do you wish polka-codes to address the review results?",
|
|
88032
|
-
|
|
88213
|
+
choices: [
|
|
88214
|
+
{ name: "No", value: "no" },
|
|
88215
|
+
{ name: "Yes", value: "yes" },
|
|
88216
|
+
{ name: "Select findings", value: "select" }
|
|
88217
|
+
],
|
|
88218
|
+
default: "no"
|
|
88033
88219
|
});
|
|
88220
|
+
if (answer === "yes") {
|
|
88221
|
+
shouldRunTask = true;
|
|
88222
|
+
} else if (answer === "select") {
|
|
88223
|
+
const selectedIndices = await dist_default3({
|
|
88224
|
+
message: "Select findings to address",
|
|
88225
|
+
choices: reviewResult.specificReviews.map((review3, index) => ({
|
|
88226
|
+
name: `${review3.file}:${review3.lines} - ${review3.review.split(`
|
|
88227
|
+
`)[0]}`,
|
|
88228
|
+
value: index,
|
|
88229
|
+
checked: true
|
|
88230
|
+
}))
|
|
88231
|
+
});
|
|
88232
|
+
if (selectedIndices.length > 0) {
|
|
88233
|
+
shouldRunTask = true;
|
|
88234
|
+
reviewResult.specificReviews = reviewResult.specificReviews.filter((_, index) => selectedIndices.includes(index));
|
|
88235
|
+
formattedReview = formatReviewForConsole(reviewResult);
|
|
88236
|
+
}
|
|
88237
|
+
}
|
|
88034
88238
|
} catch (error46) {
|
|
88035
88239
|
if (error46 instanceof Error && error46.name === "ExitPromptError") {
|
|
88036
88240
|
return;
|