@polka-codes/cli 0.9.72 → 0.9.74
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 +246 -48
- 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.74";
|
|
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
|
});
|
|
@@ -69384,16 +69558,16 @@ ${content}`;
|
|
|
69384
69558
|
},
|
|
69385
69559
|
askFollowupQuestion: async (question, answerOptions) => {
|
|
69386
69560
|
if (answerOptions.length === 0) {
|
|
69387
|
-
return await
|
|
69561
|
+
return await dist_default5({ message: question });
|
|
69388
69562
|
}
|
|
69389
69563
|
const otherMessage = "Other (enter text)";
|
|
69390
69564
|
answerOptions.push(otherMessage);
|
|
69391
|
-
const answer = await
|
|
69565
|
+
const answer = await dist_default7({
|
|
69392
69566
|
message: question,
|
|
69393
69567
|
choices: answerOptions.map((option) => ({ name: option, value: option }))
|
|
69394
69568
|
});
|
|
69395
69569
|
if (answer === otherMessage) {
|
|
69396
|
-
return await
|
|
69570
|
+
return await dist_default5({ message: "Enter your answer:" });
|
|
69397
69571
|
}
|
|
69398
69572
|
return answer;
|
|
69399
69573
|
},
|
|
@@ -84086,7 +84260,7 @@ function applyCacheControl(messages, provider3, modelId) {
|
|
|
84086
84260
|
async function getUserInput(message, options = {}) {
|
|
84087
84261
|
const { default: defaultValue, throwOnCancel = false } = options;
|
|
84088
84262
|
try {
|
|
84089
|
-
let result = await
|
|
84263
|
+
let result = await dist_default5({
|
|
84090
84264
|
message: `${message}${source_default.gray(" (type .m for multiline)")}`,
|
|
84091
84265
|
default: defaultValue
|
|
84092
84266
|
});
|
|
@@ -84460,7 +84634,7 @@ async function confirm(input, context) {
|
|
|
84460
84634
|
await new Promise((resolve4) => setTimeout(resolve4, 50));
|
|
84461
84635
|
try {
|
|
84462
84636
|
process.stderr.write("\x07");
|
|
84463
|
-
const result = await
|
|
84637
|
+
const result = await dist_default4({ message: input.message });
|
|
84464
84638
|
return result;
|
|
84465
84639
|
} catch (_e) {
|
|
84466
84640
|
throw new UserCancelledError;
|
|
@@ -84487,7 +84661,7 @@ async function select(input2, context) {
|
|
|
84487
84661
|
await new Promise((resolve4) => setTimeout(resolve4, 50));
|
|
84488
84662
|
try {
|
|
84489
84663
|
process.stderr.write("\x07");
|
|
84490
|
-
const result = await
|
|
84664
|
+
const result = await dist_default7({ message: input2.message, choices: input2.choices });
|
|
84491
84665
|
return result;
|
|
84492
84666
|
} catch (_e) {
|
|
84493
84667
|
throw new UserCancelledError;
|
|
@@ -84639,7 +84813,8 @@ async function generateText2(input2, context) {
|
|
|
84639
84813
|
}
|
|
84640
84814
|
if ("response" in error46) {
|
|
84641
84815
|
const response = error46.response;
|
|
84642
|
-
if (response.status === 429) {
|
|
84816
|
+
if (response.status === 429 || response.status >= 500) {
|
|
84817
|
+
console.debug(`Request failed with status ${response.status}, retrying...`);
|
|
84643
84818
|
const backoff2 = computeRateLimitBackoffSeconds(i2);
|
|
84644
84819
|
await new Promise((resolve4) => setTimeout(resolve4, backoff2 * 1000));
|
|
84645
84820
|
continue;
|
|
@@ -85805,14 +85980,14 @@ var fixWorkflow = async (input2, context) => {
|
|
|
85805
85980
|
let formatCommand;
|
|
85806
85981
|
if (!command) {
|
|
85807
85982
|
const config4 = await loadConfig();
|
|
85808
|
-
const
|
|
85983
|
+
const check3 = config4?.scripts?.check;
|
|
85809
85984
|
const test = config4?.scripts?.test;
|
|
85810
85985
|
const format = config4?.scripts?.format;
|
|
85811
85986
|
let checkCommand;
|
|
85812
|
-
if (typeof
|
|
85813
|
-
checkCommand =
|
|
85814
|
-
} else if (
|
|
85815
|
-
checkCommand =
|
|
85987
|
+
if (typeof check3 === "string") {
|
|
85988
|
+
checkCommand = check3;
|
|
85989
|
+
} else if (check3) {
|
|
85990
|
+
checkCommand = check3.command;
|
|
85816
85991
|
}
|
|
85817
85992
|
let testCommand;
|
|
85818
85993
|
if (typeof test === "string") {
|
|
@@ -86779,7 +86954,7 @@ Review iteration ${i2 + 1}/${MAX_REVIEW_RETRIES}`);
|
|
|
86779
86954
|
commitRange: "HEAD~1...HEAD",
|
|
86780
86955
|
changedFiles
|
|
86781
86956
|
};
|
|
86782
|
-
const reviewAgentResult = await step(`review-${iterationCount}-${i2}`, async () => {
|
|
86957
|
+
const reviewAgentResult = await step(`review-${iterationCount}-${i2}`, { retry: 1 }, async () => {
|
|
86783
86958
|
const defaultContext = await getDefaultContext();
|
|
86784
86959
|
const memoryContext = await tools2.getMemoryContext();
|
|
86785
86960
|
const userMessage = `${defaultContext}
|
|
@@ -86823,7 +86998,7 @@ ${highLevelPlan}
|
|
|
86823
86998
|
After an initial implementation, a review found the following issues. Please fix them:
|
|
86824
86999
|
|
|
86825
87000
|
${reviewSummary}`;
|
|
86826
|
-
await step(`fix-${iterationCount}-${i2}`, async () => {
|
|
87001
|
+
await step(`fix-${iterationCount}-${i2}`, { retry: 1 }, async () => {
|
|
86827
87002
|
await codeWorkflow({
|
|
86828
87003
|
task: fixTask,
|
|
86829
87004
|
mode: "noninteractive",
|
|
@@ -86886,7 +87061,7 @@ ${"-".repeat(80)}`);
|
|
|
86886
87061
|
logger.info(`${"-".repeat(80)}`);
|
|
86887
87062
|
logger.info(`${nextTask}
|
|
86888
87063
|
`);
|
|
86889
|
-
await step(`task-${iterationCount}`, async () => {
|
|
87064
|
+
await step(`task-${iterationCount}`, { retry: 1 }, async () => {
|
|
86890
87065
|
const taskWithContext = `You are working on an epic. Here is the full plan:
|
|
86891
87066
|
|
|
86892
87067
|
<plan>
|
|
@@ -87693,7 +87868,7 @@ var fetchOllamaModels = async () => {
|
|
|
87693
87868
|
}
|
|
87694
87869
|
};
|
|
87695
87870
|
async function configPrompt(existingConfig) {
|
|
87696
|
-
const provider3 = await
|
|
87871
|
+
const provider3 = await dist_default7({
|
|
87697
87872
|
message: "Choose AI Provider:",
|
|
87698
87873
|
choices: Object.entries(AiProvider).map(([key, value]) => ({ name: key, value })),
|
|
87699
87874
|
default: existingConfig?.provider
|
|
@@ -87701,7 +87876,7 @@ async function configPrompt(existingConfig) {
|
|
|
87701
87876
|
let model = existingConfig?.model;
|
|
87702
87877
|
switch (provider3) {
|
|
87703
87878
|
case "anthropic" /* Anthropic */:
|
|
87704
|
-
model = await
|
|
87879
|
+
model = await dist_default7({
|
|
87705
87880
|
message: "Choose Model ID:",
|
|
87706
87881
|
choices: Object.keys(prices_default["anthropic" /* Anthropic */]).map((key) => ({ name: key, value: key })),
|
|
87707
87882
|
default: existingConfig?.model ?? "claude-opus-4-20250514"
|
|
@@ -87711,18 +87886,18 @@ async function configPrompt(existingConfig) {
|
|
|
87711
87886
|
{
|
|
87712
87887
|
const models = await fetchOllamaModels();
|
|
87713
87888
|
if (models && models.length > 0) {
|
|
87714
|
-
model = await
|
|
87889
|
+
model = await dist_default7({
|
|
87715
87890
|
message: "Choose Model ID:",
|
|
87716
87891
|
choices: models.map((model2) => ({ name: model2, value: model2 })),
|
|
87717
87892
|
default: existingConfig?.model
|
|
87718
87893
|
});
|
|
87719
87894
|
} else {
|
|
87720
|
-
model = await
|
|
87895
|
+
model = await dist_default5({ message: "Enter Model ID:" });
|
|
87721
87896
|
}
|
|
87722
87897
|
}
|
|
87723
87898
|
break;
|
|
87724
87899
|
case "deepseek" /* DeepSeek */:
|
|
87725
|
-
model = await
|
|
87900
|
+
model = await dist_default7({
|
|
87726
87901
|
message: "Choose Model ID:",
|
|
87727
87902
|
choices: [
|
|
87728
87903
|
{ name: "deepseek-chat", value: "deepseek-chat" },
|
|
@@ -87732,16 +87907,16 @@ async function configPrompt(existingConfig) {
|
|
|
87732
87907
|
});
|
|
87733
87908
|
break;
|
|
87734
87909
|
case "openrouter" /* OpenRouter */:
|
|
87735
|
-
model = await
|
|
87910
|
+
model = await dist_default5({ message: "Enter Model ID (Visit https://openrouter.ai/models for available models):" });
|
|
87736
87911
|
break;
|
|
87737
87912
|
}
|
|
87738
87913
|
let apiKey;
|
|
87739
87914
|
if (provider3 !== "ollama" /* Ollama */) {
|
|
87740
|
-
apiKey = await
|
|
87915
|
+
apiKey = await dist_default6({ message: "Enter API Key:", mask: "*" });
|
|
87741
87916
|
}
|
|
87742
87917
|
let baseURL;
|
|
87743
87918
|
if (provider3 === "ollama" /* Ollama */) {
|
|
87744
|
-
baseURL = await
|
|
87919
|
+
baseURL = await dist_default5({ message: "Enter Ollama Base URL:", default: "http://localhost:11434" });
|
|
87745
87920
|
}
|
|
87746
87921
|
return { provider: provider3, model, apiKey, baseURL };
|
|
87747
87922
|
}
|
|
@@ -87760,7 +87935,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
87760
87935
|
const exists = existsSync2(configPath);
|
|
87761
87936
|
if (exists) {
|
|
87762
87937
|
if (interactive) {
|
|
87763
|
-
const proceed = await
|
|
87938
|
+
const proceed = await dist_default4({
|
|
87764
87939
|
message: `Found existing config at ${configPath}. Do you want to proceed? This will overwrite the existing config.`,
|
|
87765
87940
|
default: false
|
|
87766
87941
|
});
|
|
@@ -87771,7 +87946,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
87771
87946
|
}
|
|
87772
87947
|
} else if (!options.global) {
|
|
87773
87948
|
if (interactive) {
|
|
87774
|
-
const location = await
|
|
87949
|
+
const location = await dist_default7({
|
|
87775
87950
|
message: "No config file found. Do you want to create one?",
|
|
87776
87951
|
choices: [
|
|
87777
87952
|
{ name: `Create a global config at ${globalConfigPath}`, value: "global" },
|
|
@@ -87797,7 +87972,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
87797
87972
|
if (apiKey && !isGlobal) {
|
|
87798
87973
|
let option = "local";
|
|
87799
87974
|
if (interactive) {
|
|
87800
|
-
option = await
|
|
87975
|
+
option = await dist_default7({
|
|
87801
87976
|
message: "It is not recommended to store API keys in the local config file. How would you like to proceed?",
|
|
87802
87977
|
choices: [
|
|
87803
87978
|
{ name: "Save API key in the local config file", value: "local" },
|
|
@@ -87851,7 +88026,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
87851
88026
|
logger.info(`Configuration saved to ${configPath}`);
|
|
87852
88027
|
let shouldAnalyze = false;
|
|
87853
88028
|
if (!isGlobal && interactive) {
|
|
87854
|
-
shouldAnalyze = await
|
|
88029
|
+
shouldAnalyze = await dist_default4({
|
|
87855
88030
|
message: "Would you like to analyze the project to generate recommended configuration?",
|
|
87856
88031
|
default: false
|
|
87857
88032
|
});
|
|
@@ -88013,7 +88188,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
88013
88188
|
interactive: !yes && !json2
|
|
88014
88189
|
});
|
|
88015
88190
|
if (reviewResult) {
|
|
88016
|
-
|
|
88191
|
+
let formattedReview = formatReviewForConsole(reviewResult);
|
|
88017
88192
|
if (json2) {
|
|
88018
88193
|
console.log(JSON.stringify(reviewResult, null, 2));
|
|
88019
88194
|
} else if (formattedReview) {
|
|
@@ -88026,10 +88201,33 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
88026
88201
|
} else if (process.stdin.isTTY && !json2) {
|
|
88027
88202
|
await new Promise((resolve4) => setTimeout(resolve4, 50));
|
|
88028
88203
|
try {
|
|
88029
|
-
|
|
88204
|
+
const answer = await dist_default7({
|
|
88030
88205
|
message: "Do you wish polka-codes to address the review results?",
|
|
88031
|
-
|
|
88206
|
+
choices: [
|
|
88207
|
+
{ name: "No", value: "no" },
|
|
88208
|
+
{ name: "Yes", value: "yes" },
|
|
88209
|
+
{ name: "Select findings", value: "select" }
|
|
88210
|
+
],
|
|
88211
|
+
default: "no"
|
|
88032
88212
|
});
|
|
88213
|
+
if (answer === "yes") {
|
|
88214
|
+
shouldRunTask = true;
|
|
88215
|
+
} else if (answer === "select") {
|
|
88216
|
+
const selectedIndices = await dist_default3({
|
|
88217
|
+
message: "Select findings to address",
|
|
88218
|
+
choices: reviewResult.specificReviews.map((review3, index) => ({
|
|
88219
|
+
name: `${review3.file}:${review3.lines} - ${review3.review.split(`
|
|
88220
|
+
`)[0]}`,
|
|
88221
|
+
value: index,
|
|
88222
|
+
checked: true
|
|
88223
|
+
}))
|
|
88224
|
+
});
|
|
88225
|
+
if (selectedIndices.length > 0) {
|
|
88226
|
+
shouldRunTask = true;
|
|
88227
|
+
reviewResult.specificReviews = reviewResult.specificReviews.filter((_, index) => selectedIndices.includes(index));
|
|
88228
|
+
formattedReview = formatReviewForConsole(reviewResult);
|
|
88229
|
+
}
|
|
88230
|
+
}
|
|
88033
88231
|
} catch (error46) {
|
|
88034
88232
|
if (error46 instanceof Error && error46.name === "ExitPromptError") {
|
|
88035
88233
|
return;
|