@polka-codes/cli 0.9.25 → 0.9.26
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 +225 -180
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23064,14 +23064,14 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
23064
23064
|
if (request.compress && !headers.has("Accept-Encoding")) {
|
|
23065
23065
|
headers.set("Accept-Encoding", "gzip,deflate");
|
|
23066
23066
|
}
|
|
23067
|
-
let
|
|
23068
|
-
if (typeof
|
|
23069
|
-
|
|
23067
|
+
let agent2 = request.agent;
|
|
23068
|
+
if (typeof agent2 === "function") {
|
|
23069
|
+
agent2 = agent2(parsedURL);
|
|
23070
23070
|
}
|
|
23071
23071
|
return Object.assign({}, parsedURL, {
|
|
23072
23072
|
method: request.method,
|
|
23073
23073
|
headers: exportNodeCompatibleHeaders(headers),
|
|
23074
|
-
agent
|
|
23074
|
+
agent: agent2
|
|
23075
23075
|
});
|
|
23076
23076
|
}
|
|
23077
23077
|
function AbortError(message) {
|
|
@@ -24385,14 +24385,14 @@ var require_common2 = __commonJS((exports, module) => {
|
|
|
24385
24385
|
}
|
|
24386
24386
|
}
|
|
24387
24387
|
}
|
|
24388
|
-
function matchesTemplate(search,
|
|
24388
|
+
function matchesTemplate(search, template2) {
|
|
24389
24389
|
let searchIndex = 0;
|
|
24390
24390
|
let templateIndex = 0;
|
|
24391
24391
|
let starIndex = -1;
|
|
24392
24392
|
let matchIndex = 0;
|
|
24393
24393
|
while (searchIndex < search.length) {
|
|
24394
|
-
if (templateIndex <
|
|
24395
|
-
if (
|
|
24394
|
+
if (templateIndex < template2.length && (template2[templateIndex] === search[searchIndex] || template2[templateIndex] === "*")) {
|
|
24395
|
+
if (template2[templateIndex] === "*") {
|
|
24396
24396
|
starIndex = templateIndex;
|
|
24397
24397
|
matchIndex = searchIndex;
|
|
24398
24398
|
templateIndex++;
|
|
@@ -24408,10 +24408,10 @@ var require_common2 = __commonJS((exports, module) => {
|
|
|
24408
24408
|
return false;
|
|
24409
24409
|
}
|
|
24410
24410
|
}
|
|
24411
|
-
while (templateIndex <
|
|
24411
|
+
while (templateIndex < template2.length && template2[templateIndex] === "*") {
|
|
24412
24412
|
templateIndex++;
|
|
24413
24413
|
}
|
|
24414
|
-
return templateIndex ===
|
|
24414
|
+
return templateIndex === template2.length;
|
|
24415
24415
|
}
|
|
24416
24416
|
function disable() {
|
|
24417
24417
|
const namespaces = [
|
|
@@ -30014,9 +30014,9 @@ var require_jwa = __commonJS((exports, module) => {
|
|
|
30014
30014
|
}
|
|
30015
30015
|
return base64url5.replace(/\-/g, "+").replace(/_/g, "/");
|
|
30016
30016
|
}
|
|
30017
|
-
function typeError(
|
|
30017
|
+
function typeError(template2) {
|
|
30018
30018
|
var args = [].slice.call(arguments, 1);
|
|
30019
|
-
var errMsg = util2.format.bind(util2,
|
|
30019
|
+
var errMsg = util2.format.bind(util2, template2).apply(null, args);
|
|
30020
30020
|
return new TypeError(errMsg);
|
|
30021
30021
|
}
|
|
30022
30022
|
function bufferOrString(obj) {
|
|
@@ -32268,10 +32268,10 @@ var require_pluggable_auth_handler = __commonJS((exports) => {
|
|
|
32268
32268
|
throw new executable_response_1.ExecutableResponseError(`The output file contained an invalid response: ${responseString}`);
|
|
32269
32269
|
}
|
|
32270
32270
|
}
|
|
32271
|
-
static parseCommand(
|
|
32272
|
-
const components =
|
|
32271
|
+
static parseCommand(command2) {
|
|
32272
|
+
const components = command2.match(/(?:[^\s"]+|"[^"]*")+/g);
|
|
32273
32273
|
if (!components) {
|
|
32274
|
-
throw new Error(`Provided command: "${
|
|
32274
|
+
throw new Error(`Provided command: "${command2}" could not be parsed.`);
|
|
32275
32275
|
}
|
|
32276
32276
|
for (let i = 0;i < components.length; i++) {
|
|
32277
32277
|
if (components[i][0] === '"' && components[i].slice(-1) === '"') {
|
|
@@ -58572,7 +58572,7 @@ var {
|
|
|
58572
58572
|
Help
|
|
58573
58573
|
} = import__.default;
|
|
58574
58574
|
// package.json
|
|
58575
|
-
var version = "0.9.
|
|
58575
|
+
var version = "0.9.26";
|
|
58576
58576
|
|
|
58577
58577
|
// src/commands/chat.ts
|
|
58578
58578
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
@@ -71056,8 +71056,7 @@ var toolInfo = {
|
|
|
71056
71056
|
}
|
|
71057
71057
|
}
|
|
71058
71058
|
]
|
|
71059
|
-
})
|
|
71060
|
-
permissionLevel: 0 /* None */
|
|
71059
|
+
})
|
|
71061
71060
|
};
|
|
71062
71061
|
var handler = async (provider, args) => {
|
|
71063
71062
|
if (!provider.askFollowupQuestion) {
|
|
@@ -71119,8 +71118,7 @@ var toolInfo2 = {
|
|
|
71119
71118
|
}
|
|
71120
71119
|
}
|
|
71121
71120
|
]
|
|
71122
|
-
})
|
|
71123
|
-
permissionLevel: 0 /* None */
|
|
71121
|
+
})
|
|
71124
71122
|
};
|
|
71125
71123
|
var handler2 = async (provider, args) => {
|
|
71126
71124
|
const parsed = toolInfo2.parameters.safeParse(args);
|
|
@@ -71183,8 +71181,7 @@ var toolInfo3 = {
|
|
|
71183
71181
|
}
|
|
71184
71182
|
}
|
|
71185
71183
|
]
|
|
71186
|
-
})
|
|
71187
|
-
permissionLevel: 0 /* None */
|
|
71184
|
+
})
|
|
71188
71185
|
};
|
|
71189
71186
|
var handler3 = async (_provider, args) => {
|
|
71190
71187
|
const parsed = toolInfo3.parameters.safeParse(args);
|
|
@@ -71240,8 +71237,7 @@ var toolInfo4 = {
|
|
|
71240
71237
|
}
|
|
71241
71238
|
}
|
|
71242
71239
|
]
|
|
71243
|
-
})
|
|
71244
|
-
permissionLevel: 3 /* Arbitrary */
|
|
71240
|
+
})
|
|
71245
71241
|
};
|
|
71246
71242
|
var handler4 = async (provider, args) => {
|
|
71247
71243
|
if (!provider.executeCommand) {
|
|
@@ -71331,8 +71327,7 @@ var toolInfo5 = {
|
|
|
71331
71327
|
}
|
|
71332
71328
|
}
|
|
71333
71329
|
]
|
|
71334
|
-
})
|
|
71335
|
-
permissionLevel: 1 /* Read */
|
|
71330
|
+
})
|
|
71336
71331
|
};
|
|
71337
71332
|
var handler5 = async (provider, args) => {
|
|
71338
71333
|
if (!provider.fetchUrl) {
|
|
@@ -71408,8 +71403,7 @@ var toolInfo6 = {
|
|
|
71408
71403
|
}
|
|
71409
71404
|
}
|
|
71410
71405
|
]
|
|
71411
|
-
})
|
|
71412
|
-
permissionLevel: 0 /* None */
|
|
71406
|
+
})
|
|
71413
71407
|
};
|
|
71414
71408
|
var handler6 = async (_provider, args) => {
|
|
71415
71409
|
const parsed = toolInfo6.parameters.safeParse(args);
|
|
@@ -71476,8 +71470,7 @@ var toolInfo7 = {
|
|
|
71476
71470
|
}
|
|
71477
71471
|
}
|
|
71478
71472
|
]
|
|
71479
|
-
})
|
|
71480
|
-
permissionLevel: 1 /* Read */
|
|
71473
|
+
})
|
|
71481
71474
|
};
|
|
71482
71475
|
var handler7 = async (provider, args) => {
|
|
71483
71476
|
if (!provider.listFiles) {
|
|
@@ -71518,8 +71511,7 @@ var toolInfo8 = {
|
|
|
71518
71511
|
description: "Read a binary file from a URL or local path. Use file:// prefix to access local files. This can be used to access non-text files such as PDFs or images.",
|
|
71519
71512
|
parameters: exports_external.object({
|
|
71520
71513
|
url: exports_external.string().describe("The URL or local path of the file to read.")
|
|
71521
|
-
})
|
|
71522
|
-
permissionLevel: 1 /* Read */
|
|
71514
|
+
})
|
|
71523
71515
|
};
|
|
71524
71516
|
var handler8 = async (provider, args) => {
|
|
71525
71517
|
if (!provider.readBinaryFile) {
|
|
@@ -71603,8 +71595,7 @@ var toolInfo9 = {
|
|
|
71603
71595
|
}
|
|
71604
71596
|
}
|
|
71605
71597
|
]
|
|
71606
|
-
})
|
|
71607
|
-
permissionLevel: 1 /* Read */
|
|
71598
|
+
})
|
|
71608
71599
|
};
|
|
71609
71600
|
var handler9 = async (provider, args) => {
|
|
71610
71601
|
if (!provider.readFile) {
|
|
@@ -71663,8 +71654,7 @@ var toolInfo10 = {
|
|
|
71663
71654
|
}
|
|
71664
71655
|
}
|
|
71665
71656
|
]
|
|
71666
|
-
})
|
|
71667
|
-
permissionLevel: 2 /* Write */
|
|
71657
|
+
})
|
|
71668
71658
|
};
|
|
71669
71659
|
var handler10 = async (provider, args) => {
|
|
71670
71660
|
if (!provider.removeFile) {
|
|
@@ -71721,8 +71711,7 @@ var toolInfo11 = {
|
|
|
71721
71711
|
}
|
|
71722
71712
|
}
|
|
71723
71713
|
]
|
|
71724
|
-
})
|
|
71725
|
-
permissionLevel: 2 /* Write */
|
|
71714
|
+
})
|
|
71726
71715
|
};
|
|
71727
71716
|
var handler11 = async (provider, args) => {
|
|
71728
71717
|
if (!provider.renameFile) {
|
|
@@ -71935,8 +71924,7 @@ function oldFeature() {
|
|
|
71935
71924
|
}
|
|
71936
71925
|
}
|
|
71937
71926
|
]
|
|
71938
|
-
})
|
|
71939
|
-
permissionLevel: 2 /* Write */
|
|
71927
|
+
})
|
|
71940
71928
|
};
|
|
71941
71929
|
var handler12 = async (provider, args) => {
|
|
71942
71930
|
if (!provider.readFile || !provider.writeFile) {
|
|
@@ -72042,8 +72030,7 @@ var toolInfo13 = {
|
|
|
72042
72030
|
}
|
|
72043
72031
|
}
|
|
72044
72032
|
]
|
|
72045
|
-
})
|
|
72046
|
-
permissionLevel: 1 /* Read */
|
|
72033
|
+
})
|
|
72047
72034
|
};
|
|
72048
72035
|
var handler13 = async (provider, args) => {
|
|
72049
72036
|
if (!provider.searchFiles) {
|
|
@@ -72128,8 +72115,7 @@ export default App;
|
|
|
72128
72115
|
}
|
|
72129
72116
|
}
|
|
72130
72117
|
]
|
|
72131
|
-
})
|
|
72132
|
-
permissionLevel: 2 /* Write */
|
|
72118
|
+
})
|
|
72133
72119
|
};
|
|
72134
72120
|
var handler14 = async (provider, args) => {
|
|
72135
72121
|
if (!provider.writeFile) {
|
|
@@ -72177,7 +72163,6 @@ var getAvailableTools = ({
|
|
|
72177
72163
|
provider: provider2,
|
|
72178
72164
|
allTools: allTools2,
|
|
72179
72165
|
hasAgent,
|
|
72180
|
-
permissionLevel,
|
|
72181
72166
|
interactive
|
|
72182
72167
|
}) => {
|
|
72183
72168
|
const filteredTools = interactive ? allTools2 : allTools2.filter((tool) => tool.name !== askFollowupQuestion_default.name);
|
|
@@ -72190,7 +72175,7 @@ var getAvailableTools = ({
|
|
|
72190
72175
|
continue;
|
|
72191
72176
|
}
|
|
72192
72177
|
}
|
|
72193
|
-
if (tool.isAvailable(provider2)
|
|
72178
|
+
if (tool.isAvailable(provider2)) {
|
|
72194
72179
|
tools.push(tool);
|
|
72195
72180
|
}
|
|
72196
72181
|
}
|
|
@@ -96630,14 +96615,23 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
96630
96615
|
return { type: "exit", reason: { type: "Pause", responses: toolResponses } };
|
|
96631
96616
|
}
|
|
96632
96617
|
if (toolResponses.length === 0) {
|
|
96618
|
+
if (this.config.requireToolUse) {
|
|
96619
|
+
return {
|
|
96620
|
+
type: "reply",
|
|
96621
|
+
message: [
|
|
96622
|
+
{
|
|
96623
|
+
role: "user",
|
|
96624
|
+
content: responsePrompts.requireUseToolNative
|
|
96625
|
+
}
|
|
96626
|
+
]
|
|
96627
|
+
};
|
|
96628
|
+
}
|
|
96633
96629
|
return {
|
|
96634
|
-
type: "
|
|
96635
|
-
|
|
96636
|
-
|
|
96637
|
-
|
|
96638
|
-
|
|
96639
|
-
}
|
|
96640
|
-
]
|
|
96630
|
+
type: "exit",
|
|
96631
|
+
reason: {
|
|
96632
|
+
type: "Exit" /* Exit */,
|
|
96633
|
+
message: response.filter((c) => c.type === "text").map((c) => c.content).join("")
|
|
96634
|
+
}
|
|
96641
96635
|
};
|
|
96642
96636
|
}
|
|
96643
96637
|
const mediaUserMessage = medias.length > 0 ? [
|
|
@@ -96679,14 +96673,23 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
96679
96673
|
};
|
|
96680
96674
|
}
|
|
96681
96675
|
if (toolResponses.length === 0) {
|
|
96676
|
+
if (this.config.requireToolUse) {
|
|
96677
|
+
return {
|
|
96678
|
+
type: "reply",
|
|
96679
|
+
message: [
|
|
96680
|
+
{
|
|
96681
|
+
role: "user",
|
|
96682
|
+
content: responsePrompts.requireUseTool
|
|
96683
|
+
}
|
|
96684
|
+
]
|
|
96685
|
+
};
|
|
96686
|
+
}
|
|
96682
96687
|
return {
|
|
96683
|
-
type: "
|
|
96684
|
-
|
|
96685
|
-
|
|
96686
|
-
|
|
96687
|
-
|
|
96688
|
-
}
|
|
96689
|
-
]
|
|
96688
|
+
type: "exit",
|
|
96689
|
+
reason: {
|
|
96690
|
+
type: "Exit" /* Exit */,
|
|
96691
|
+
message: response.filter((c) => c.type === "text").map((c) => c.content).join("")
|
|
96692
|
+
}
|
|
96690
96693
|
};
|
|
96691
96694
|
}
|
|
96692
96695
|
const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool: tool2, response: response2 }) => responsePrompts.toolResults(tool2, response2));
|
|
@@ -96776,14 +96779,15 @@ ${customScripts(scripts)}
|
|
|
96776
96779
|
`;
|
|
96777
96780
|
|
|
96778
96781
|
// ../core/src/Agent/AnalyzerAgent/index.ts
|
|
96782
|
+
var agentTools = [askFollowupQuestion_default, attemptCompletion_default, delegate_default, fetchUrl_default, handOver_default, listFiles_default, readBinaryFile_default, readFile_default, searchFiles_default];
|
|
96783
|
+
|
|
96779
96784
|
class AnalyzerAgent extends AgentBase {
|
|
96780
96785
|
constructor(options) {
|
|
96781
|
-
const combinedTools = [...options.additionalTools ?? [], ...
|
|
96786
|
+
const combinedTools = [...options.additionalTools ?? [], ...agentTools];
|
|
96782
96787
|
const tools = getAvailableTools({
|
|
96783
96788
|
provider: options.provider,
|
|
96784
96789
|
allTools: combinedTools,
|
|
96785
96790
|
hasAgent: (options.agents?.length ?? 0) > 0,
|
|
96786
|
-
permissionLevel: 1 /* Read */,
|
|
96787
96791
|
interactive: true
|
|
96788
96792
|
});
|
|
96789
96793
|
const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
|
|
@@ -96803,7 +96807,8 @@ class AnalyzerAgent extends AgentBase {
|
|
|
96803
96807
|
toolFormat: options.toolFormat,
|
|
96804
96808
|
parameters: options.parameters ?? {},
|
|
96805
96809
|
usageMeter: options.usageMeter ?? new UsageMeter,
|
|
96806
|
-
requestTimeoutSeconds: options.requestTimeoutSeconds
|
|
96810
|
+
requestTimeoutSeconds: options.requestTimeoutSeconds,
|
|
96811
|
+
requireToolUse: options.requireToolUse ?? true
|
|
96807
96812
|
});
|
|
96808
96813
|
}
|
|
96809
96814
|
onBeforeInvokeTool() {
|
|
@@ -96867,14 +96872,15 @@ ${customScripts(scripts)}
|
|
|
96867
96872
|
`;
|
|
96868
96873
|
|
|
96869
96874
|
// ../core/src/Agent/ArchitectAgent/index.ts
|
|
96875
|
+
var agentTools2 = [askFollowupQuestion_default, attemptCompletion_default, delegate_default, fetchUrl_default, handOver_default, listFiles_default, readBinaryFile_default, readFile_default, searchFiles_default];
|
|
96876
|
+
|
|
96870
96877
|
class ArchitectAgent extends AgentBase {
|
|
96871
96878
|
constructor(options) {
|
|
96872
|
-
const combinedTools = [...options.additionalTools ?? [], ...
|
|
96879
|
+
const combinedTools = [...options.additionalTools ?? [], ...agentTools2];
|
|
96873
96880
|
const tools = getAvailableTools({
|
|
96874
96881
|
provider: options.provider,
|
|
96875
96882
|
allTools: combinedTools,
|
|
96876
96883
|
hasAgent: (options.agents?.length ?? 0) > 0,
|
|
96877
|
-
permissionLevel: 1 /* Read */,
|
|
96878
96884
|
interactive: true
|
|
96879
96885
|
});
|
|
96880
96886
|
const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
|
|
@@ -96894,7 +96900,8 @@ class ArchitectAgent extends AgentBase {
|
|
|
96894
96900
|
toolFormat: options.toolFormat,
|
|
96895
96901
|
parameters: options.parameters ?? {},
|
|
96896
96902
|
usageMeter: options.usageMeter ?? new UsageMeter,
|
|
96897
|
-
requestTimeoutSeconds: options.requestTimeoutSeconds
|
|
96903
|
+
requestTimeoutSeconds: options.requestTimeoutSeconds,
|
|
96904
|
+
requireToolUse: options.requireToolUse ?? true
|
|
96898
96905
|
});
|
|
96899
96906
|
}
|
|
96900
96907
|
onBeforeInvokeTool() {
|
|
@@ -96997,7 +97004,6 @@ class CodeFixerAgent extends AgentBase {
|
|
|
96997
97004
|
provider: options.provider,
|
|
96998
97005
|
allTools: combinedTools,
|
|
96999
97006
|
hasAgent: (options.agents?.length ?? 0) > 0,
|
|
97000
|
-
permissionLevel: 3 /* Arbitrary */,
|
|
97001
97007
|
interactive: true
|
|
97002
97008
|
});
|
|
97003
97009
|
const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
|
|
@@ -97017,7 +97023,8 @@ class CodeFixerAgent extends AgentBase {
|
|
|
97017
97023
|
toolFormat: options.toolFormat,
|
|
97018
97024
|
parameters: options.parameters ?? {},
|
|
97019
97025
|
usageMeter: options.usageMeter ?? new UsageMeter,
|
|
97020
|
-
requestTimeoutSeconds: options.requestTimeoutSeconds
|
|
97026
|
+
requestTimeoutSeconds: options.requestTimeoutSeconds,
|
|
97027
|
+
requireToolUse: options.requireToolUse ?? true
|
|
97021
97028
|
});
|
|
97022
97029
|
this.#maxRetries = options.maxRetries ?? 5;
|
|
97023
97030
|
}
|
|
@@ -97202,7 +97209,6 @@ class CoderAgent extends AgentBase {
|
|
|
97202
97209
|
provider: options.provider,
|
|
97203
97210
|
allTools: combinedTools,
|
|
97204
97211
|
hasAgent: (options.agents?.length ?? 0) > 0,
|
|
97205
|
-
permissionLevel: 3 /* Arbitrary */,
|
|
97206
97212
|
interactive: true
|
|
97207
97213
|
});
|
|
97208
97214
|
const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
|
|
@@ -97222,7 +97228,8 @@ class CoderAgent extends AgentBase {
|
|
|
97222
97228
|
toolFormat: options.toolFormat,
|
|
97223
97229
|
parameters: options.parameters ?? {},
|
|
97224
97230
|
usageMeter: options.usageMeter ?? new UsageMeter,
|
|
97225
|
-
requestTimeoutSeconds: options.requestTimeoutSeconds
|
|
97231
|
+
requestTimeoutSeconds: options.requestTimeoutSeconds,
|
|
97232
|
+
requireToolUse: options.requireToolUse ?? true
|
|
97226
97233
|
});
|
|
97227
97234
|
}
|
|
97228
97235
|
async#runScript(scriptName, shouldReplyWithError) {
|
|
@@ -97971,8 +97978,7 @@ var toolInfo15 = {
|
|
|
97971
97978
|
}
|
|
97972
97979
|
return val;
|
|
97973
97980
|
}, exports_external.boolean().optional().default(false)).describe("Annotate the diff with line numbers for additions and deletions.")
|
|
97974
|
-
})
|
|
97975
|
-
permissionLevel: 1 /* Read */
|
|
97981
|
+
})
|
|
97976
97982
|
};
|
|
97977
97983
|
var handler15 = async (provider2, args) => {
|
|
97978
97984
|
if (!provider2.executeCommand) {
|
|
@@ -98111,8 +98117,6 @@ Do not include praise or positive feedback.
|
|
|
98111
98117
|
Only include reviews for actual issues found in the changed code.
|
|
98112
98118
|
|
|
98113
98119
|
Return your review as a JSON object inside a \`\`\`json block, wrapped like:
|
|
98114
|
-
<tool_attempt_completion>
|
|
98115
|
-
<tool_parameter_result>
|
|
98116
98120
|
\`\`\`json
|
|
98117
98121
|
{
|
|
98118
98122
|
"overview": "Summary of specific issues found in the diff changes, 'No issues found', or 'No reviewable changes' if all modified files were excluded.",
|
|
@@ -98125,8 +98129,6 @@ Return your review as a JSON object inside a \`\`\`json block, wrapped like:
|
|
|
98125
98129
|
]
|
|
98126
98130
|
}
|
|
98127
98131
|
\`\`\`
|
|
98128
|
-
</tool_parameter_result>
|
|
98129
|
-
</tool_attempt_completion>
|
|
98130
98132
|
`;
|
|
98131
98133
|
var reviewDiff_default = {
|
|
98132
98134
|
name: "reviewDiff",
|
|
@@ -98188,7 +98190,8 @@ ${output}`,
|
|
|
98188
98190
|
agent: (options) => {
|
|
98189
98191
|
return new AnalyzerAgent({
|
|
98190
98192
|
...options,
|
|
98191
|
-
additionalTools: [gitDiff_default]
|
|
98193
|
+
additionalTools: [gitDiff_default],
|
|
98194
|
+
requireToolUse: false
|
|
98192
98195
|
});
|
|
98193
98196
|
}
|
|
98194
98197
|
};
|
|
@@ -98250,8 +98253,50 @@ var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails
|
|
|
98250
98253
|
var reviewDiff = makeAgentTool(reviewDiff_default);
|
|
98251
98254
|
var generateProjectConfig = makeMultiAgentTool(generateProjectConfig_default);
|
|
98252
98255
|
var createNewProject = makeMultiAgentTool(createNewProject_default);
|
|
98256
|
+
// ../core/src/workflow/utils.ts
|
|
98257
|
+
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
98258
|
+
// ../core/src/workflow/builder.ts
|
|
98259
|
+
class StepsBuilder {
|
|
98260
|
+
#steps = [];
|
|
98261
|
+
build() {
|
|
98262
|
+
if (this.#steps.length === 0) {
|
|
98263
|
+
throw new Error("A workflow must have at least one step.");
|
|
98264
|
+
}
|
|
98265
|
+
const rootStep = this.#steps.length > 1 ? {
|
|
98266
|
+
id: "root",
|
|
98267
|
+
type: "sequential",
|
|
98268
|
+
steps: this.#steps
|
|
98269
|
+
} : this.#steps[0];
|
|
98270
|
+
return rootStep;
|
|
98271
|
+
}
|
|
98272
|
+
step(step) {
|
|
98273
|
+
this.#steps.push(step);
|
|
98274
|
+
return this;
|
|
98275
|
+
}
|
|
98276
|
+
parallel(id, step) {
|
|
98277
|
+
return this.step({
|
|
98278
|
+
id,
|
|
98279
|
+
type: "parallel",
|
|
98280
|
+
step
|
|
98281
|
+
});
|
|
98282
|
+
}
|
|
98283
|
+
custom(id, run) {
|
|
98284
|
+
return this.step({
|
|
98285
|
+
id,
|
|
98286
|
+
type: "custom",
|
|
98287
|
+
run
|
|
98288
|
+
});
|
|
98289
|
+
}
|
|
98290
|
+
agent(id, spec2) {
|
|
98291
|
+
return this.step({
|
|
98292
|
+
...spec2,
|
|
98293
|
+
id,
|
|
98294
|
+
type: "agent"
|
|
98295
|
+
});
|
|
98296
|
+
}
|
|
98297
|
+
}
|
|
98253
98298
|
// src/commands/chat.ts
|
|
98254
|
-
var
|
|
98299
|
+
var import_lodash6 = __toESM(require_lodash(), 1);
|
|
98255
98300
|
|
|
98256
98301
|
// ../../node_modules/mime-types/index.js
|
|
98257
98302
|
/*!
|
|
@@ -98290,7 +98335,7 @@ function lookup(path) {
|
|
|
98290
98335
|
}
|
|
98291
98336
|
return $types[extension2] || false;
|
|
98292
98337
|
}
|
|
98293
|
-
function populateMaps(extensions,
|
|
98338
|
+
function populateMaps(extensions, types2) {
|
|
98294
98339
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
98295
98340
|
var mime = db[type];
|
|
98296
98341
|
var exts = mime.extensions;
|
|
@@ -98300,10 +98345,10 @@ function populateMaps(extensions, types) {
|
|
|
98300
98345
|
extensions[type] = exts;
|
|
98301
98346
|
for (var i = 0;i < exts.length; i++) {
|
|
98302
98347
|
var extension2 = exts[i];
|
|
98303
|
-
|
|
98304
|
-
const legacyType = _preferredTypeLegacy(extension2,
|
|
98305
|
-
if (legacyType !==
|
|
98306
|
-
$_extensionConflicts.push([extension2, legacyType,
|
|
98348
|
+
types2[extension2] = _preferredType(extension2, types2[extension2], type);
|
|
98349
|
+
const legacyType = _preferredTypeLegacy(extension2, types2[extension2], type);
|
|
98350
|
+
if (legacyType !== types2[extension2]) {
|
|
98351
|
+
$_extensionConflicts.push([extension2, legacyType, types2[extension2]]);
|
|
98307
98352
|
}
|
|
98308
98353
|
}
|
|
98309
98354
|
});
|
|
@@ -109331,8 +109376,8 @@ class ApiProviderConfig {
|
|
|
109331
109376
|
this.agents = config4.agents;
|
|
109332
109377
|
this.toolFormat = config4.toolFormat;
|
|
109333
109378
|
}
|
|
109334
|
-
getConfigForCommand(
|
|
109335
|
-
const { provider: provider2, model, parameters, toolFormat } = this.commands?.[
|
|
109379
|
+
getConfigForCommand(command2) {
|
|
109380
|
+
const { provider: provider2, model, parameters, toolFormat } = this.commands?.[command2] ?? this.commands?.default ?? {};
|
|
109336
109381
|
const finalProvider = provider2 ?? this.defaultProvider;
|
|
109337
109382
|
if (!finalProvider) {
|
|
109338
109383
|
return;
|
|
@@ -109357,8 +109402,8 @@ class ApiProviderConfig {
|
|
|
109357
109402
|
toolFormat: finalToolFormat
|
|
109358
109403
|
};
|
|
109359
109404
|
}
|
|
109360
|
-
getConfigForAgent(
|
|
109361
|
-
const { provider: provider2, model, parameters, toolFormat } = this.agents?.[
|
|
109405
|
+
getConfigForAgent(agent2) {
|
|
109406
|
+
const { provider: provider2, model, parameters, toolFormat } = this.agents?.[agent2] ?? this.agents?.default ?? {};
|
|
109362
109407
|
const finalProvider = provider2 ?? this.defaultProvider;
|
|
109363
109408
|
if (!finalProvider) {
|
|
109364
109409
|
return;
|
|
@@ -109430,8 +109475,8 @@ Available commands:
|
|
|
109430
109475
|
}
|
|
109431
109476
|
this.#consecutiveCtrlCCount = 0;
|
|
109432
109477
|
const trimmedInput = input.trim();
|
|
109433
|
-
const [
|
|
109434
|
-
switch (
|
|
109478
|
+
const [command2, ...args] = trimmedInput.split(/\s+/);
|
|
109479
|
+
switch (command2) {
|
|
109435
109480
|
case ".h":
|
|
109436
109481
|
case ".help":
|
|
109437
109482
|
this.#showHelp();
|
|
@@ -109687,7 +109732,7 @@ import os2 from "node:os";
|
|
|
109687
109732
|
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
109688
109733
|
import { homedir } from "node:os";
|
|
109689
109734
|
import { join } from "node:path";
|
|
109690
|
-
var
|
|
109735
|
+
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
109691
109736
|
|
|
109692
109737
|
// ../cli-shared/node_modules/yaml/dist/index.js
|
|
109693
109738
|
var composer = require_composer();
|
|
@@ -112332,9 +112377,9 @@ class ZodUnion4 extends ZodType4 {
|
|
|
112332
112377
|
return this._def.options;
|
|
112333
112378
|
}
|
|
112334
112379
|
}
|
|
112335
|
-
ZodUnion4.create = (
|
|
112380
|
+
ZodUnion4.create = (types2, params) => {
|
|
112336
112381
|
return new ZodUnion4({
|
|
112337
|
-
options:
|
|
112382
|
+
options: types2,
|
|
112338
112383
|
typeName: ZodFirstPartyTypeKind4.ZodUnion,
|
|
112339
112384
|
...processCreateParams2(params)
|
|
112340
112385
|
});
|
|
@@ -113598,7 +113643,7 @@ function mergeConfigs(configs) {
|
|
|
113598
113643
|
return {};
|
|
113599
113644
|
}
|
|
113600
113645
|
const mergedConfig = configs.reduce((acc, config4) => {
|
|
113601
|
-
const merged =
|
|
113646
|
+
const merged = import_lodash3.merge({}, acc, config4);
|
|
113602
113647
|
let accRules = acc.rules ?? [];
|
|
113603
113648
|
if (typeof accRules === "string") {
|
|
113604
113649
|
accRules = [accRules];
|
|
@@ -113700,7 +113745,7 @@ function lookup2(path) {
|
|
|
113700
113745
|
}
|
|
113701
113746
|
return $types2[extension3] || false;
|
|
113702
113747
|
}
|
|
113703
|
-
function populateMaps2(extensions,
|
|
113748
|
+
function populateMaps2(extensions, types2) {
|
|
113704
113749
|
Object.keys(db2).forEach(function forEachMimeType(type) {
|
|
113705
113750
|
var mime = db2[type];
|
|
113706
113751
|
var exts = mime.extensions;
|
|
@@ -113710,10 +113755,10 @@ function populateMaps2(extensions, types) {
|
|
|
113710
113755
|
extensions[type] = exts;
|
|
113711
113756
|
for (var i = 0;i < exts.length; i++) {
|
|
113712
113757
|
var extension3 = exts[i];
|
|
113713
|
-
|
|
113714
|
-
const legacyType = _preferredTypeLegacy2(extension3,
|
|
113715
|
-
if (legacyType !==
|
|
113716
|
-
$_extensionConflicts2.push([extension3, legacyType,
|
|
113758
|
+
types2[extension3] = _preferredType2(extension3, types2[extension3], type);
|
|
113759
|
+
const legacyType = _preferredTypeLegacy2(extension3, types2[extension3], type);
|
|
113760
|
+
if (legacyType !== types2[extension3]) {
|
|
113761
|
+
$_extensionConflicts2.push([extension3, legacyType, types2[extension3]]);
|
|
113717
113762
|
}
|
|
113718
113763
|
}
|
|
113719
113764
|
});
|
|
@@ -113958,10 +114003,10 @@ var getProvider = (_agentName, _config, options = {}) => {
|
|
|
113958
114003
|
mediaType
|
|
113959
114004
|
};
|
|
113960
114005
|
},
|
|
113961
|
-
executeCommand: (
|
|
114006
|
+
executeCommand: (command2, _needApprove) => {
|
|
113962
114007
|
return new Promise((resolve4, reject) => {
|
|
113963
|
-
options.command?.onStarted(
|
|
113964
|
-
const child = spawn2(
|
|
114008
|
+
options.command?.onStarted(command2);
|
|
114009
|
+
const child = spawn2(command2, [], {
|
|
113965
114010
|
shell: true,
|
|
113966
114011
|
stdio: "pipe"
|
|
113967
114012
|
});
|
|
@@ -114407,17 +114452,17 @@ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
|
114407
114452
|
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
114408
114453
|
styles2[styleName] = {
|
|
114409
114454
|
get() {
|
|
114410
|
-
const
|
|
114411
|
-
Object.defineProperty(this, styleName, { value:
|
|
114412
|
-
return
|
|
114455
|
+
const builder2 = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
114456
|
+
Object.defineProperty(this, styleName, { value: builder2 });
|
|
114457
|
+
return builder2;
|
|
114413
114458
|
}
|
|
114414
114459
|
};
|
|
114415
114460
|
}
|
|
114416
114461
|
styles2.visible = {
|
|
114417
114462
|
get() {
|
|
114418
|
-
const
|
|
114419
|
-
Object.defineProperty(this, "visible", { value:
|
|
114420
|
-
return
|
|
114463
|
+
const builder2 = createBuilder(this, this[STYLER], true);
|
|
114464
|
+
Object.defineProperty(this, "visible", { value: builder2 });
|
|
114465
|
+
return builder2;
|
|
114421
114466
|
}
|
|
114422
114467
|
};
|
|
114423
114468
|
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
@@ -114488,12 +114533,12 @@ var createStyler = (open, close, parent) => {
|
|
|
114488
114533
|
};
|
|
114489
114534
|
};
|
|
114490
114535
|
var createBuilder = (self2, _styler, _isEmpty) => {
|
|
114491
|
-
const
|
|
114492
|
-
Object.setPrototypeOf(
|
|
114493
|
-
|
|
114494
|
-
|
|
114495
|
-
|
|
114496
|
-
return
|
|
114536
|
+
const builder2 = (...arguments_) => applyStyle(builder2, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
114537
|
+
Object.setPrototypeOf(builder2, proto);
|
|
114538
|
+
builder2[GENERATOR] = self2;
|
|
114539
|
+
builder2[STYLER] = _styler;
|
|
114540
|
+
builder2[IS_EMPTY] = _isEmpty;
|
|
114541
|
+
return builder2;
|
|
114497
114542
|
};
|
|
114498
114543
|
var applyStyle = (self2, string8) => {
|
|
114499
114544
|
if (self2.level <= 0 || !string8) {
|
|
@@ -114711,9 +114756,9 @@ Tool error:`, event.tool));
|
|
|
114711
114756
|
};
|
|
114712
114757
|
};
|
|
114713
114758
|
// src/options.ts
|
|
114714
|
-
var
|
|
114715
|
-
function addSharedOptions(
|
|
114716
|
-
return
|
|
114759
|
+
var import_lodash4 = __toESM(require_lodash(), 1);
|
|
114760
|
+
function addSharedOptions(command2) {
|
|
114761
|
+
return command2.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("--retry-count <count>", "Number of retries for failed requests.", Number.parseInt).option("--request-timeout-seconds <seconds>", "Request timeout in seconds.", Number.parseInt).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").option("--agent <agent>", "Initial agent to use (default: architect)").option("--file <path...>", "File to include in the task").option("--silent", "Enable silent mode");
|
|
114717
114762
|
}
|
|
114718
114763
|
function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
|
|
114719
114764
|
let cwd = cwdArg;
|
|
@@ -114732,26 +114777,26 @@ function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
|
|
|
114732
114777
|
const defaultProvider = options.apiProvider || env2.POLKA_API_PROVIDER || config5.defaultProvider;
|
|
114733
114778
|
const defaultModel = options.model || env2.POLKA_MODEL || config5.defaultModel;
|
|
114734
114779
|
if (defaultProvider && defaultModel) {
|
|
114735
|
-
|
|
114780
|
+
import_lodash4.set(config5, ["providers", defaultProvider, "defaultModel"], defaultModel);
|
|
114736
114781
|
}
|
|
114737
114782
|
const apiKey = options.apiKey || env2.POLKA_API_KEY;
|
|
114738
114783
|
if (apiKey) {
|
|
114739
114784
|
if (!defaultProvider) {
|
|
114740
114785
|
throw new Error("Must specify a provider if providing an API key");
|
|
114741
114786
|
}
|
|
114742
|
-
|
|
114787
|
+
import_lodash4.set(config5, ["providers", defaultProvider, "apiKey"], apiKey);
|
|
114743
114788
|
}
|
|
114744
114789
|
if (env2.ANTHROPIC_API_KEY) {
|
|
114745
|
-
|
|
114790
|
+
import_lodash4.set(config5, ["providers", "anthropic" /* Anthropic */, "apiKey"], env2.ANTHROPIC_API_KEY);
|
|
114746
114791
|
}
|
|
114747
114792
|
if (env2.DEEPSEEK_API_KEY) {
|
|
114748
|
-
|
|
114793
|
+
import_lodash4.set(config5, ["providers", "deepseek" /* DeepSeek */, "apiKey"], env2.DEEPSEEK_API_KEY);
|
|
114749
114794
|
}
|
|
114750
114795
|
if (env2.OPENROUTER_API_KEY) {
|
|
114751
|
-
|
|
114796
|
+
import_lodash4.set(config5, ["providers", "openrouter" /* OpenRouter */, "apiKey"], env2.OPENROUTER_API_KEY);
|
|
114752
114797
|
}
|
|
114753
114798
|
if (env2.OPENAI_API_KEY) {
|
|
114754
|
-
|
|
114799
|
+
import_lodash4.set(config5, ["providers", "ollama" /* Ollama */, "apiKey"], env2.OPENAI_API_KEY);
|
|
114755
114800
|
}
|
|
114756
114801
|
const providerConfig = new ApiProviderConfig({
|
|
114757
114802
|
defaultProvider,
|
|
@@ -114772,7 +114817,7 @@ function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
|
|
|
114772
114817
|
// src/Runner.ts
|
|
114773
114818
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
114774
114819
|
import os3 from "node:os";
|
|
114775
|
-
var
|
|
114820
|
+
var import_lodash5 = __toESM(require_lodash(), 1);
|
|
114776
114821
|
|
|
114777
114822
|
// src/getProviderOptions.ts
|
|
114778
114823
|
function getProviderOptions(provider3, modelId, thinkingBudgetTokens, supportThinking) {
|
|
@@ -114827,7 +114872,7 @@ class Runner {
|
|
|
114827
114872
|
multiAgent;
|
|
114828
114873
|
constructor(options) {
|
|
114829
114874
|
this.#options = options;
|
|
114830
|
-
this.usageMeter = new UsageMeter(
|
|
114875
|
+
this.usageMeter = new UsageMeter(import_lodash5.merge(prices_default, options.config.prices ?? {}), {
|
|
114831
114876
|
maxMessages: options.config.maxMessageCount ?? 0,
|
|
114832
114877
|
maxCost: options.config.budget ?? 0
|
|
114833
114878
|
});
|
|
@@ -114837,8 +114882,8 @@ class Runner {
|
|
|
114837
114882
|
}
|
|
114838
114883
|
const toolProviderOptions = {
|
|
114839
114884
|
command: this.#options.silent ? undefined : {
|
|
114840
|
-
onStarted(
|
|
114841
|
-
console.log(`$ >>>> $ ${
|
|
114885
|
+
onStarted(command2) {
|
|
114886
|
+
console.log(`$ >>>> $ ${command2}`);
|
|
114842
114887
|
},
|
|
114843
114888
|
onStdout(data) {
|
|
114844
114889
|
process.stdout.write(data);
|
|
@@ -115039,24 +115084,24 @@ ${fileList.join(`
|
|
|
115039
115084
|
}
|
|
115040
115085
|
|
|
115041
115086
|
// src/commands/chat.ts
|
|
115042
|
-
var runChat = async (opts,
|
|
115043
|
-
const options =
|
|
115044
|
-
let { config: config5, providerConfig, maxMessageCount, verbose, budget, agent } = parseOptions(options);
|
|
115087
|
+
var runChat = async (opts, command2) => {
|
|
115088
|
+
const options = command2?.parent?.opts() ?? opts ?? {};
|
|
115089
|
+
let { config: config5, providerConfig, maxMessageCount, verbose, budget, agent: agent2 } = parseOptions(options);
|
|
115045
115090
|
if (!process.stdin.isTTY) {
|
|
115046
115091
|
console.error("Error: Terminal is not interactive. Please run this command in an interactive terminal.");
|
|
115047
115092
|
process.exit(1);
|
|
115048
115093
|
}
|
|
115049
|
-
let providerDetails = providerConfig.getConfigForAgent(
|
|
115094
|
+
let providerDetails = providerConfig.getConfigForAgent(agent2);
|
|
115050
115095
|
if (!providerDetails?.provider) {
|
|
115051
115096
|
const newConfig = await configPrompt({});
|
|
115052
115097
|
const updatedConfig = JSON.parse(JSON.stringify(config5 ?? {}));
|
|
115053
|
-
|
|
115054
|
-
|
|
115098
|
+
import_lodash6.set(updatedConfig, `providers.${newConfig.provider}.model`, newConfig.model);
|
|
115099
|
+
import_lodash6.set(updatedConfig, `providers.${newConfig.provider}.apiKey`, newConfig.apiKey);
|
|
115055
115100
|
if (newConfig.baseURL) {
|
|
115056
|
-
|
|
115101
|
+
import_lodash6.set(updatedConfig, `providers.${newConfig.provider}.baseURL`, newConfig.baseURL);
|
|
115057
115102
|
}
|
|
115058
115103
|
providerConfig = new ApiProviderConfig(updatedConfig);
|
|
115059
|
-
providerDetails = providerConfig.getConfigForAgent(
|
|
115104
|
+
providerDetails = providerConfig.getConfigForAgent(agent2);
|
|
115060
115105
|
config5 = updatedConfig;
|
|
115061
115106
|
}
|
|
115062
115107
|
const { provider: provider3, model, parameters } = providerDetails ?? {};
|
|
@@ -115106,7 +115151,7 @@ var runChat = async (opts, command) => {
|
|
|
115106
115151
|
const reason = await runner.continueTask(message, fileParts);
|
|
115107
115152
|
exitReason = reason;
|
|
115108
115153
|
} else {
|
|
115109
|
-
const reason = await runner.startTask(message,
|
|
115154
|
+
const reason = await runner.startTask(message, agent2, fileParts);
|
|
115110
115155
|
exitReason = reason;
|
|
115111
115156
|
}
|
|
115112
115157
|
switch (exitReason.type) {
|
|
@@ -115146,7 +115191,7 @@ var runChat = async (opts, command) => {
|
|
|
115146
115191
|
|
|
115147
115192
|
// src/commands/commit.ts
|
|
115148
115193
|
import { execSync, spawnSync as spawnSync2 } from "node:child_process";
|
|
115149
|
-
var
|
|
115194
|
+
var import_lodash7 = __toESM(require_lodash(), 1);
|
|
115150
115195
|
|
|
115151
115196
|
// ../../node_modules/ora/index.js
|
|
115152
115197
|
import process11 from "node:process";
|
|
@@ -115519,17 +115564,17 @@ Object.setPrototypeOf(createChalk2.prototype, Function.prototype);
|
|
|
115519
115564
|
for (const [styleName, style] of Object.entries(ansi_styles_default2)) {
|
|
115520
115565
|
styles4[styleName] = {
|
|
115521
115566
|
get() {
|
|
115522
|
-
const
|
|
115523
|
-
Object.defineProperty(this, styleName, { value:
|
|
115524
|
-
return
|
|
115567
|
+
const builder2 = createBuilder2(this, createStyler2(style.open, style.close, this[STYLER2]), this[IS_EMPTY2]);
|
|
115568
|
+
Object.defineProperty(this, styleName, { value: builder2 });
|
|
115569
|
+
return builder2;
|
|
115525
115570
|
}
|
|
115526
115571
|
};
|
|
115527
115572
|
}
|
|
115528
115573
|
styles4.visible = {
|
|
115529
115574
|
get() {
|
|
115530
|
-
const
|
|
115531
|
-
Object.defineProperty(this, "visible", { value:
|
|
115532
|
-
return
|
|
115575
|
+
const builder2 = createBuilder2(this, this[STYLER2], true);
|
|
115576
|
+
Object.defineProperty(this, "visible", { value: builder2 });
|
|
115577
|
+
return builder2;
|
|
115533
115578
|
}
|
|
115534
115579
|
};
|
|
115535
115580
|
var getModelAnsi2 = (model, level, type, ...arguments_) => {
|
|
@@ -115600,12 +115645,12 @@ var createStyler2 = (open, close, parent) => {
|
|
|
115600
115645
|
};
|
|
115601
115646
|
};
|
|
115602
115647
|
var createBuilder2 = (self2, _styler, _isEmpty) => {
|
|
115603
|
-
const
|
|
115604
|
-
Object.setPrototypeOf(
|
|
115605
|
-
|
|
115606
|
-
|
|
115607
|
-
|
|
115608
|
-
return
|
|
115648
|
+
const builder2 = (...arguments_) => applyStyle2(builder2, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
115649
|
+
Object.setPrototypeOf(builder2, proto2);
|
|
115650
|
+
builder2[GENERATOR2] = self2;
|
|
115651
|
+
builder2[STYLER2] = _styler;
|
|
115652
|
+
builder2[IS_EMPTY2] = _isEmpty;
|
|
115653
|
+
return builder2;
|
|
115609
115654
|
};
|
|
115610
115655
|
var applyStyle2 = (self2, string8) => {
|
|
115611
115656
|
if (self2.level <= 0 || !string8) {
|
|
@@ -116235,8 +116280,8 @@ function ora(options) {
|
|
|
116235
116280
|
}
|
|
116236
116281
|
|
|
116237
116282
|
// src/commands/commit.ts
|
|
116238
|
-
var commitCommand = new Command("commit").description("Create a commit with AI-generated message").option("-a, --all", "Stage all files before committing").argument("[message]", "Optional context for the commit message generation").action(async (message, localOptions,
|
|
116239
|
-
const options =
|
|
116283
|
+
var commitCommand = new Command("commit").description("Create a commit with AI-generated message").option("-a, --all", "Stage all files before committing").argument("[message]", "Optional context for the commit message generation").action(async (message, localOptions, command2) => {
|
|
116284
|
+
const options = command2.parent?.opts() ?? {};
|
|
116240
116285
|
const { providerConfig, config: config5 } = parseOptions(options);
|
|
116241
116286
|
const commandConfig = providerConfig.getConfigForCommand("commit");
|
|
116242
116287
|
if (!commandConfig || !commandConfig.provider || !commandConfig.model) {
|
|
@@ -116246,7 +116291,7 @@ var commitCommand = new Command("commit").description("Create a commit with AI-g
|
|
|
116246
116291
|
console.log("Provider:", commandConfig.provider);
|
|
116247
116292
|
console.log("Model:", commandConfig.model);
|
|
116248
116293
|
const spinner = ora("Gathering information...").start();
|
|
116249
|
-
const usage = new UsageMeter(
|
|
116294
|
+
const usage = new UsageMeter(import_lodash7.merge(prices_default, config5.prices ?? {}));
|
|
116250
116295
|
try {
|
|
116251
116296
|
const status = execSync("git status --porcelain").toString();
|
|
116252
116297
|
const stagedFiles = status.split(`
|
|
@@ -116323,8 +116368,8 @@ var askForPath = async (projectName) => {
|
|
|
116323
116368
|
targetPath = inputPath.trim();
|
|
116324
116369
|
}
|
|
116325
116370
|
};
|
|
116326
|
-
var createCommand2 = new Command("create").description("Create a new project").argument("[name]", "Project name").action(async (name18, _options,
|
|
116327
|
-
const cmdOptions =
|
|
116371
|
+
var createCommand2 = new Command("create").description("Create a new project").argument("[name]", "Project name").action(async (name18, _options, command2) => {
|
|
116372
|
+
const cmdOptions = command2.parent?.opts() ?? {};
|
|
116328
116373
|
const { providerConfig, maxMessageCount, verbose, budget } = parseOptions(cmdOptions);
|
|
116329
116374
|
let { provider: maybeProvider, model, apiKey } = providerConfig.getConfigForAgent("architect") ?? {};
|
|
116330
116375
|
if (!maybeProvider) {
|
|
@@ -116362,7 +116407,7 @@ var createCommand2 = new Command("create").description("Create a new project").a
|
|
|
116362
116407
|
// src/commands/init.ts
|
|
116363
116408
|
import { existsSync as existsSync4, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
116364
116409
|
import { dirname as dirname2 } from "node:path";
|
|
116365
|
-
var
|
|
116410
|
+
var import_lodash8 = __toESM(require_lodash(), 1);
|
|
116366
116411
|
|
|
116367
116412
|
// ../../node_modules/yaml/dist/index.js
|
|
116368
116413
|
var composer2 = require_composer2();
|
|
@@ -116412,8 +116457,8 @@ var $visitAsync2 = visit2.visitAsync;
|
|
|
116412
116457
|
|
|
116413
116458
|
// src/commands/init.ts
|
|
116414
116459
|
var initCommand = new Command("init").description("Initialize polkacodes configuration").option("-g, --global", "Use global config");
|
|
116415
|
-
initCommand.action(async (options,
|
|
116416
|
-
const cmdOptions =
|
|
116460
|
+
initCommand.action(async (options, command2) => {
|
|
116461
|
+
const cmdOptions = command2.parent?.opts() ?? {};
|
|
116417
116462
|
parseOptions(cmdOptions);
|
|
116418
116463
|
cmdOptions.baseDir = undefined;
|
|
116419
116464
|
const globalConfigPath = getGlobalConfigPath();
|
|
@@ -116493,7 +116538,7 @@ initCommand.action(async (options, command) => {
|
|
|
116493
116538
|
break;
|
|
116494
116539
|
case 2: {
|
|
116495
116540
|
const globalConfig3 = loadConfigAtPath(globalConfigPath) ?? {};
|
|
116496
|
-
|
|
116541
|
+
import_lodash8.set(globalConfig3, ["providers", newConfig.provider, "apiKey"], newConfig.apiKey);
|
|
116497
116542
|
mkdirSync(dirname2(globalConfigPath), { recursive: true });
|
|
116498
116543
|
writeFileSync(globalConfigPath, $stringify2(globalConfig3));
|
|
116499
116544
|
console.log(`API key saved to global config file: ${globalConfigPath}`);
|
|
@@ -116548,7 +116593,7 @@ ${newConfig.provider.toUpperCase()}_API_KEY=${newConfig.apiKey}`;
|
|
|
116548
116593
|
finalConfig.defaultProvider = newConfig.provider;
|
|
116549
116594
|
finalConfig.defaultModel = newConfig.model;
|
|
116550
116595
|
if (newConfig.apiKey) {
|
|
116551
|
-
|
|
116596
|
+
import_lodash8.set(finalConfig, ["providers", newConfig.provider, "apiKey"], newConfig.apiKey);
|
|
116552
116597
|
}
|
|
116553
116598
|
}
|
|
116554
116599
|
mkdirSync(dirname2(configPath), { recursive: true });
|
|
@@ -116562,9 +116607,9 @@ ${newConfig.provider.toUpperCase()}_API_KEY=${newConfig.apiKey}`;
|
|
|
116562
116607
|
|
|
116563
116608
|
// src/commands/pr.ts
|
|
116564
116609
|
import { execSync as execSync2, spawnSync as spawnSync3 } from "node:child_process";
|
|
116565
|
-
var
|
|
116566
|
-
var prCommand = new Command("pr").description("Create a GitHub pull request").argument("[message]", "Optional context for the commit message generation").action(async (message, _options,
|
|
116567
|
-
const options =
|
|
116610
|
+
var import_lodash9 = __toESM(require_lodash(), 1);
|
|
116611
|
+
var prCommand = new Command("pr").description("Create a GitHub pull request").argument("[message]", "Optional context for the commit message generation").action(async (message, _options, command2) => {
|
|
116612
|
+
const options = command2.parent?.opts() ?? {};
|
|
116568
116613
|
const { providerConfig, config: config5 } = parseOptions(options);
|
|
116569
116614
|
const commandConfig = providerConfig.getConfigForCommand("pr");
|
|
116570
116615
|
if (!commandConfig || !commandConfig.provider || !commandConfig.model) {
|
|
@@ -116602,7 +116647,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
|
|
|
116602
116647
|
encoding: "utf-8"
|
|
116603
116648
|
});
|
|
116604
116649
|
const diff = execSync2(`git diff --cached -U50 ${defaultBranch}`, { encoding: "utf-8" });
|
|
116605
|
-
const usage = new UsageMeter(
|
|
116650
|
+
const usage = new UsageMeter(import_lodash9.merge(prices_default, config5.prices ?? {}));
|
|
116606
116651
|
const ai = getModel(commandConfig);
|
|
116607
116652
|
spinner.text = "Generating pull request details...";
|
|
116608
116653
|
const resp = await generateGithubPullRequestDetails(ai, {
|
|
@@ -116631,7 +116676,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
|
|
|
116631
116676
|
// src/commands/review.ts
|
|
116632
116677
|
import { execSync as execSync3 } from "node:child_process";
|
|
116633
116678
|
import { Console } from "node:console";
|
|
116634
|
-
var
|
|
116679
|
+
var import_lodash10 = __toESM(require_lodash(), 1);
|
|
116635
116680
|
|
|
116636
116681
|
// src/commands/task.ts
|
|
116637
116682
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
@@ -116668,7 +116713,7 @@ var readStdin = async (timeoutMs = 30000) => {
|
|
|
116668
116713
|
});
|
|
116669
116714
|
});
|
|
116670
116715
|
};
|
|
116671
|
-
async function runTask(taskArg, _options,
|
|
116716
|
+
async function runTask(taskArg, _options, command2) {
|
|
116672
116717
|
let task = taskArg;
|
|
116673
116718
|
if (!task) {
|
|
116674
116719
|
try {
|
|
@@ -116676,7 +116721,7 @@ async function runTask(taskArg, _options, command) {
|
|
|
116676
116721
|
if (stdinInput) {
|
|
116677
116722
|
task = stdinInput;
|
|
116678
116723
|
} else {
|
|
116679
|
-
runChat(
|
|
116724
|
+
runChat(command2.opts());
|
|
116680
116725
|
return;
|
|
116681
116726
|
}
|
|
116682
116727
|
} catch (error82) {
|
|
@@ -116684,8 +116729,8 @@ async function runTask(taskArg, _options, command) {
|
|
|
116684
116729
|
process.exit(1);
|
|
116685
116730
|
}
|
|
116686
116731
|
}
|
|
116687
|
-
const { config: config5, providerConfig, verbose, maxMessageCount, budget, agent, silent, file: files } = parseOptions(
|
|
116688
|
-
const { provider: provider3, model, parameters } = providerConfig.getConfigForAgent(
|
|
116732
|
+
const { config: config5, providerConfig, verbose, maxMessageCount, budget, agent: agent2, silent, file: files } = parseOptions(command2.opts());
|
|
116733
|
+
const { provider: provider3, model, parameters } = providerConfig.getConfigForAgent(agent2) ?? {};
|
|
116689
116734
|
if (!provider3 || !model) {
|
|
116690
116735
|
console.error("Provider and model must be configured");
|
|
116691
116736
|
process.exit(1);
|
|
@@ -116744,7 +116789,7 @@ async function runTask(taskArg, _options, command) {
|
|
|
116744
116789
|
}
|
|
116745
116790
|
}
|
|
116746
116791
|
}
|
|
116747
|
-
const exitReason = await runner.startTask(task,
|
|
116792
|
+
const exitReason = await runner.startTask(task, agent2, fileContents);
|
|
116748
116793
|
process.off("SIGINT", sigintHandler);
|
|
116749
116794
|
if (silent) {
|
|
116750
116795
|
if (exitReason.type === "Exit" /* Exit */) {
|
|
@@ -116839,8 +116884,8 @@ function parseGitDiffNameStatus(diffOutput) {
|
|
|
116839
116884
|
return { path, status: statusDescription };
|
|
116840
116885
|
});
|
|
116841
116886
|
}
|
|
116842
|
-
var reviewCommand = new Command("review").description("Review a GitHub pull request or local changes").option("--pr <pr>", "The pull request number or URL to review").option("--json", "Output the review in JSON format", false).action(async (options,
|
|
116843
|
-
const parentOptions =
|
|
116887
|
+
var reviewCommand = new Command("review").description("Review a GitHub pull request or local changes").option("--pr <pr>", "The pull request number or URL to review").option("--json", "Output the review in JSON format", false).action(async (options, command2) => {
|
|
116888
|
+
const parentOptions = command2.parent?.opts() ?? {};
|
|
116844
116889
|
const { providerConfig, config: config5 } = parseOptions(parentOptions);
|
|
116845
116890
|
const commandConfig = providerConfig.getConfigForCommand("review");
|
|
116846
116891
|
if (!commandConfig || !commandConfig.provider || !commandConfig.model) {
|
|
@@ -116855,7 +116900,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
116855
116900
|
text: "Gathering information...",
|
|
116856
116901
|
stream: process.stderr
|
|
116857
116902
|
}).start();
|
|
116858
|
-
const usage = new UsageMeter(
|
|
116903
|
+
const usage = new UsageMeter(import_lodash10.merge(prices_default, config5.prices ?? {}));
|
|
116859
116904
|
const customConsole = options.json ? new Console(process.stderr, process.stderr) : console;
|
|
116860
116905
|
const onEvent = printEvent(parentOptions.verbose, usage, customConsole);
|
|
116861
116906
|
const ai = getModel(commandConfig);
|
|
@@ -116876,9 +116921,9 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
116876
116921
|
};
|
|
116877
116922
|
try {
|
|
116878
116923
|
if (options.pr) {
|
|
116879
|
-
await reviewPR(options.pr, spinner, sharedAiOptions, options.json,
|
|
116924
|
+
await reviewPR(options.pr, spinner, sharedAiOptions, options.json, command2);
|
|
116880
116925
|
} else {
|
|
116881
|
-
await reviewLocal(spinner, sharedAiOptions, options.json,
|
|
116926
|
+
await reviewLocal(spinner, sharedAiOptions, options.json, command2);
|
|
116882
116927
|
}
|
|
116883
116928
|
} catch (error82) {
|
|
116884
116929
|
spinner.fail(`Error reviewing: ${error82 instanceof Error ? error82.message : String(error82)}`);
|
|
@@ -116889,7 +116934,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
116889
116934
|
usage.printUsage();
|
|
116890
116935
|
}
|
|
116891
116936
|
});
|
|
116892
|
-
async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput,
|
|
116937
|
+
async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput, command2) {
|
|
116893
116938
|
const prNumberMatch = prIdentifier.match(/\d+$/);
|
|
116894
116939
|
if (!prNumberMatch) {
|
|
116895
116940
|
spinner.fail("Invalid PR number or URL.");
|
|
@@ -116935,9 +116980,9 @@ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput, co
|
|
|
116935
116980
|
changedFiles
|
|
116936
116981
|
});
|
|
116937
116982
|
spinner.succeed("Review generated successfully");
|
|
116938
|
-
await handleReviewResult(result, isJsonOutput,
|
|
116983
|
+
await handleReviewResult(result, isJsonOutput, command2);
|
|
116939
116984
|
}
|
|
116940
|
-
async function reviewLocal(spinner, sharedAiOptions, isJsonOutput,
|
|
116985
|
+
async function reviewLocal(spinner, sharedAiOptions, isJsonOutput, command2) {
|
|
116941
116986
|
const gitStatus = execSync3("git status --porcelain=v1", { encoding: "utf-8" });
|
|
116942
116987
|
const statusLines = gitStatus.split(`
|
|
116943
116988
|
`).filter((line) => line);
|
|
@@ -116953,7 +116998,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput, command) {
|
|
|
116953
116998
|
changedFiles: stagedFiles
|
|
116954
116999
|
});
|
|
116955
117000
|
spinner.succeed("Review generated successfully");
|
|
116956
|
-
await handleReviewResult(result2, isJsonOutput,
|
|
117001
|
+
await handleReviewResult(result2, isJsonOutput, command2);
|
|
116957
117002
|
return;
|
|
116958
117003
|
}
|
|
116959
117004
|
if (hasUnstagedChanges) {
|
|
@@ -116965,7 +117010,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput, command) {
|
|
|
116965
117010
|
changedFiles: unstagedFiles
|
|
116966
117011
|
});
|
|
116967
117012
|
spinner.succeed("Review generated successfully");
|
|
116968
|
-
await handleReviewResult(result2, isJsonOutput,
|
|
117013
|
+
await handleReviewResult(result2, isJsonOutput, command2);
|
|
116969
117014
|
return;
|
|
116970
117015
|
}
|
|
116971
117016
|
spinner.text = "No local changes detected. Falling back to branch diff...";
|
|
@@ -116999,9 +117044,9 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput, command) {
|
|
|
116999
117044
|
changedFiles: branchChangedFiles
|
|
117000
117045
|
});
|
|
117001
117046
|
spinner.succeed("Review generated successfully");
|
|
117002
|
-
await handleReviewResult(result, isJsonOutput,
|
|
117047
|
+
await handleReviewResult(result, isJsonOutput, command2);
|
|
117003
117048
|
}
|
|
117004
|
-
async function handleReviewResult(result, isJsonOutput,
|
|
117049
|
+
async function handleReviewResult(result, isJsonOutput, command2) {
|
|
117005
117050
|
if (isJsonOutput) {
|
|
117006
117051
|
console.log(JSON.stringify(result, null, 2));
|
|
117007
117052
|
return;
|
|
@@ -117023,7 +117068,7 @@ async function handleReviewResult(result, isJsonOutput, command) {
|
|
|
117023
117068
|
const taskInstruction = `please address the review result:
|
|
117024
117069
|
|
|
117025
117070
|
${formatted}`;
|
|
117026
|
-
await runTask(taskInstruction, {},
|
|
117071
|
+
await runTask(taskInstruction, {}, command2);
|
|
117027
117072
|
}
|
|
117028
117073
|
}
|
|
117029
117074
|
function formatReviewForConsole(output) {
|