@polka-codes/cli 0.9.24 → 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.
Files changed (2) hide show
  1. package/dist/index.js +266 -205
  2. 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 agent = request.agent;
23068
- if (typeof agent === "function") {
23069
- agent = agent(parsedURL);
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, template) {
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 < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
24395
- if (template[templateIndex] === "*") {
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 < template.length && template[templateIndex] === "*") {
24411
+ while (templateIndex < template2.length && template2[templateIndex] === "*") {
24412
24412
  templateIndex++;
24413
24413
  }
24414
- return templateIndex === template.length;
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(template) {
30017
+ function typeError(template2) {
30018
30018
  var args = [].slice.call(arguments, 1);
30019
- var errMsg = util2.format.bind(util2, template).apply(null, args);
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(command) {
32272
- const components = command.match(/(?:[^\s"]+|"[^"]*")+/g);
32271
+ static parseCommand(command2) {
32272
+ const components = command2.match(/(?:[^\s"]+|"[^"]*")+/g);
32273
32273
  if (!components) {
32274
- throw new Error(`Provided command: "${command}" could not be parsed.`);
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.24";
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) && tool.permissionLevel <= permissionLevel) {
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: "reply",
96635
- message: [
96636
- {
96637
- role: "user",
96638
- content: responsePrompts.requireUseToolNative
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: "reply",
96684
- message: [
96685
- {
96686
- role: "user",
96687
- content: responsePrompts.requireUseTool
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 ?? [], ...Object.values(exports_allTools)];
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 ?? [], ...Object.values(exports_allTools)];
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) {
@@ -97959,7 +97966,7 @@ var toolInfo15 = {
97959
97966
  return val;
97960
97967
  }, exports_external.boolean().optional().default(false)).describe("Get staged changes instead of unstaged changes."),
97961
97968
  commitRange: exports_external.string().optional().describe('The commit range to get the diff for (e.g., "main...HEAD").'),
97962
- file: exports_external.string().optional().describe("Get the diff for a specific file."),
97969
+ file: exports_external.string().describe("Get the diff for a specific file."),
97963
97970
  contextLines: exports_external.coerce.number().optional().default(5).describe("Number of context lines to include around changes."),
97964
97971
  includeLineNumbers: exports_external.preprocess((val) => {
97965
97972
  if (typeof val === "string") {
@@ -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) {
@@ -98056,50 +98062,64 @@ var prompt5 = `
98056
98062
  You are a senior software engineer reviewing code changes.
98057
98063
 
98058
98064
  ## Critical Instructions
98059
- **ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.
98065
+ - **ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.
98066
+ - **ONLY run git_diff on files that are reviewable source/config files** per the "File Selection for git_diff" rules below. Do not pass excluded files to git_diff.
98067
+
98068
+ ## File Selection for git_diff
98069
+ Use <file_status> to decide which files to diff. Include only files likely to contain human-authored source or meaningful configuration.
98070
+
98071
+ Include (run git_diff):
98072
+ - Application/source code
98073
+ - UI/templates/assets code
98074
+ - Infra/config that affects behavior
98075
+
98076
+ Exclude (do NOT run git_diff; do not review):
98077
+ - Lockfiles
98078
+ - Generated/build artifacts & deps
98079
+ - Test artifacts/snapshots
98080
+ - Data and fixtures
98081
+ - Binary/media/minified/maps
98060
98082
 
98061
98083
  ## Viewing Changes
98062
- - **Use git_diff** to inspect the actual code changes for each relevant file.
98063
- - **Pull request**: use the provided commit range for the git_diff tool with contextLines: 5 and includeLineNumbers: true
98064
- - **Local changes**: diff staged or unstaged files using the git_diff tool with contextLines: 5 and includeLineNumbers: true
98065
- - The diff will include line number annotations: [Line N] for additions and [Line N removed] for deletions
98066
- - If a pull request is present you may receive:
98084
+ - For each included file, **use git_diff** to inspect the actual code changes:
98085
+ - **Pull request:** use the provided commit range for the git_diff tool with contextLines: 5 and includeLineNumbers: true, but only surface and review the included files.
98086
+ - **Local changes:** diff staged or unstaged included files using git_diff with contextLines: 5 and includeLineNumbers: true.
98087
+ - The diff will include line number annotations: [Line N] for additions and [Line N removed] for deletions.
98088
+ - You may receive:
98067
98089
  - <pr_title>
98068
98090
  - <pr_description>
98069
98091
  - <commit_messages>
98070
98092
  - A <review_instructions> tag tells you the focus of the review.
98071
- - File status information is provided in <file_status> - use this to understand which files were modified, added, deleted, or renamed.
98093
+ - Use <file_status> to understand which files were modified, added, deleted, or renamed and to apply the inclusion/exclusion rules above.
98072
98094
 
98073
98095
  ## Line Number Reporting
98074
- - **IMPORTANT**: Use the line numbers from the annotations in the diff output
98075
- - For additions: Look for [Line N] annotations after the + lines
98076
- - For deletions: Look for [Line N removed] annotations after the - lines
98077
- - For modifications: Report the line number of the new/current code (from [Line N] annotations)
98078
- - Report single lines as "N" and ranges as "N-M"
98096
+ - Use the line numbers from the annotations in the diff output.
98097
+ - For additions: use the number from the [Line N] annotation after the + line.
98098
+ - For deletions: use the number from the [Line N removed] annotation after the - line.
98099
+ - For modifications: report the line number of the new/current code (from [Line N]).
98100
+ - Report single lines as "N" and ranges as "N-M".
98079
98101
 
98080
98102
  ## Review Guidelines
98081
98103
  Focus exclusively on the changed lines (+ additions, - deletions, modified lines):
98082
- - **Specific issues**: Point to exact problems in the changed code with accurate line references from the annotations
98083
- - **Actionable fixes**: Provide concrete solutions, not vague suggestions
98084
- - **Clear reasoning**: Explain why each issue matters and how to fix it
98085
- - **Avoid generic advice**: No generic suggestions like "add more tests", "improve documentation", or "follow best practices" unless directly related to a specific problem in the diff
98104
+ - **Specific issues:** Point to exact problems in the changed code with accurate line references from the annotations.
98105
+ - **Actionable fixes:** Provide concrete solutions, not vague suggestions.
98106
+ - **Clear reasoning:** Explain why each issue matters and how to fix it.
98107
+ - **Avoid generic advice** unless directly tied to a specific problem visible in the diff.
98086
98108
 
98087
98109
  ## What NOT to review
98088
- - Existing unchanged code
98089
- - Overall project structure or architecture (unless directly impacted by changes)
98090
- - Generic best practices unrelated to the specific changes
98091
- - Missing features or functionality not part of this diff
98110
+ - Files excluded by the "File Selection for git_diff" rules (do not diff or comment on them).
98111
+ - Existing unchanged code.
98112
+ - Overall project structure/architecture unless directly impacted by the changes.
98113
+ - Missing features or functionality not part of this diff.
98092
98114
 
98093
98115
  ## Output Format
98094
- Do **not** include praise or positive feedback. Ignore generated files such as lock files.
98116
+ Do not include praise or positive feedback.
98095
98117
  Only include reviews for actual issues found in the changed code.
98096
98118
 
98097
98119
  Return your review as a JSON object inside a \`\`\`json block, wrapped like:
98098
- <tool_attempt_completion>
98099
- <tool_parameter_result>
98100
98120
  \`\`\`json
98101
98121
  {
98102
- "overview": "Summary of specific issues found in the diff changes, or 'No issues found' if the changes look good.",
98122
+ "overview": "Summary of specific issues found in the diff changes, 'No issues found', or 'No reviewable changes' if all modified files were excluded.",
98103
98123
  "specificReviews": [
98104
98124
  {
98105
98125
  "file": "path/filename.ext",
@@ -98109,8 +98129,6 @@ Return your review as a JSON object inside a \`\`\`json block, wrapped like:
98109
98129
  ]
98110
98130
  }
98111
98131
  \`\`\`
98112
- </tool_parameter_result>
98113
- </tool_attempt_completion>
98114
98132
  `;
98115
98133
  var reviewDiff_default = {
98116
98134
  name: "reviewDiff",
@@ -98172,7 +98190,8 @@ ${output}`,
98172
98190
  agent: (options) => {
98173
98191
  return new AnalyzerAgent({
98174
98192
  ...options,
98175
- additionalTools: [gitDiff_default]
98193
+ additionalTools: [gitDiff_default],
98194
+ requireToolUse: false
98176
98195
  });
98177
98196
  }
98178
98197
  };
@@ -98234,8 +98253,50 @@ var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails
98234
98253
  var reviewDiff = makeAgentTool(reviewDiff_default);
98235
98254
  var generateProjectConfig = makeMultiAgentTool(generateProjectConfig_default);
98236
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
+ }
98237
98298
  // src/commands/chat.ts
98238
- var import_lodash5 = __toESM(require_lodash(), 1);
98299
+ var import_lodash6 = __toESM(require_lodash(), 1);
98239
98300
 
98240
98301
  // ../../node_modules/mime-types/index.js
98241
98302
  /*!
@@ -98274,7 +98335,7 @@ function lookup(path) {
98274
98335
  }
98275
98336
  return $types[extension2] || false;
98276
98337
  }
98277
- function populateMaps(extensions, types) {
98338
+ function populateMaps(extensions, types2) {
98278
98339
  Object.keys(db).forEach(function forEachMimeType(type) {
98279
98340
  var mime = db[type];
98280
98341
  var exts = mime.extensions;
@@ -98284,10 +98345,10 @@ function populateMaps(extensions, types) {
98284
98345
  extensions[type] = exts;
98285
98346
  for (var i = 0;i < exts.length; i++) {
98286
98347
  var extension2 = exts[i];
98287
- types[extension2] = _preferredType(extension2, types[extension2], type);
98288
- const legacyType = _preferredTypeLegacy(extension2, types[extension2], type);
98289
- if (legacyType !== types[extension2]) {
98290
- $_extensionConflicts.push([extension2, legacyType, types[extension2]]);
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]]);
98291
98352
  }
98292
98353
  }
98293
98354
  });
@@ -109315,8 +109376,8 @@ class ApiProviderConfig {
109315
109376
  this.agents = config4.agents;
109316
109377
  this.toolFormat = config4.toolFormat;
109317
109378
  }
109318
- getConfigForCommand(command) {
109319
- const { provider: provider2, model, parameters, toolFormat } = this.commands?.[command] ?? this.commands?.default ?? {};
109379
+ getConfigForCommand(command2) {
109380
+ const { provider: provider2, model, parameters, toolFormat } = this.commands?.[command2] ?? this.commands?.default ?? {};
109320
109381
  const finalProvider = provider2 ?? this.defaultProvider;
109321
109382
  if (!finalProvider) {
109322
109383
  return;
@@ -109341,8 +109402,8 @@ class ApiProviderConfig {
109341
109402
  toolFormat: finalToolFormat
109342
109403
  };
109343
109404
  }
109344
- getConfigForAgent(agent) {
109345
- const { provider: provider2, model, parameters, toolFormat } = this.agents?.[agent] ?? this.agents?.default ?? {};
109405
+ getConfigForAgent(agent2) {
109406
+ const { provider: provider2, model, parameters, toolFormat } = this.agents?.[agent2] ?? this.agents?.default ?? {};
109346
109407
  const finalProvider = provider2 ?? this.defaultProvider;
109347
109408
  if (!finalProvider) {
109348
109409
  return;
@@ -109414,8 +109475,8 @@ Available commands:
109414
109475
  }
109415
109476
  this.#consecutiveCtrlCCount = 0;
109416
109477
  const trimmedInput = input.trim();
109417
- const [command, ...args] = trimmedInput.split(/\s+/);
109418
- switch (command) {
109478
+ const [command2, ...args] = trimmedInput.split(/\s+/);
109479
+ switch (command2) {
109419
109480
  case ".h":
109420
109481
  case ".help":
109421
109482
  this.#showHelp();
@@ -109671,7 +109732,7 @@ import os2 from "node:os";
109671
109732
  import { existsSync as existsSync2, readFileSync } from "node:fs";
109672
109733
  import { homedir } from "node:os";
109673
109734
  import { join } from "node:path";
109674
- var import_lodash2 = __toESM(require_lodash(), 1);
109735
+ var import_lodash3 = __toESM(require_lodash(), 1);
109675
109736
 
109676
109737
  // ../cli-shared/node_modules/yaml/dist/index.js
109677
109738
  var composer = require_composer();
@@ -112316,9 +112377,9 @@ class ZodUnion4 extends ZodType4 {
112316
112377
  return this._def.options;
112317
112378
  }
112318
112379
  }
112319
- ZodUnion4.create = (types, params) => {
112380
+ ZodUnion4.create = (types2, params) => {
112320
112381
  return new ZodUnion4({
112321
- options: types,
112382
+ options: types2,
112322
112383
  typeName: ZodFirstPartyTypeKind4.ZodUnion,
112323
112384
  ...processCreateParams2(params)
112324
112385
  });
@@ -113582,7 +113643,7 @@ function mergeConfigs(configs) {
113582
113643
  return {};
113583
113644
  }
113584
113645
  const mergedConfig = configs.reduce((acc, config4) => {
113585
- const merged = import_lodash2.merge({}, acc, config4);
113646
+ const merged = import_lodash3.merge({}, acc, config4);
113586
113647
  let accRules = acc.rules ?? [];
113587
113648
  if (typeof accRules === "string") {
113588
113649
  accRules = [accRules];
@@ -113684,7 +113745,7 @@ function lookup2(path) {
113684
113745
  }
113685
113746
  return $types2[extension3] || false;
113686
113747
  }
113687
- function populateMaps2(extensions, types) {
113748
+ function populateMaps2(extensions, types2) {
113688
113749
  Object.keys(db2).forEach(function forEachMimeType(type) {
113689
113750
  var mime = db2[type];
113690
113751
  var exts = mime.extensions;
@@ -113694,10 +113755,10 @@ function populateMaps2(extensions, types) {
113694
113755
  extensions[type] = exts;
113695
113756
  for (var i = 0;i < exts.length; i++) {
113696
113757
  var extension3 = exts[i];
113697
- types[extension3] = _preferredType2(extension3, types[extension3], type);
113698
- const legacyType = _preferredTypeLegacy2(extension3, types[extension3], type);
113699
- if (legacyType !== types[extension3]) {
113700
- $_extensionConflicts2.push([extension3, legacyType, types[extension3]]);
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]]);
113701
113762
  }
113702
113763
  }
113703
113764
  });
@@ -113942,10 +114003,10 @@ var getProvider = (_agentName, _config, options = {}) => {
113942
114003
  mediaType
113943
114004
  };
113944
114005
  },
113945
- executeCommand: (command, _needApprove) => {
114006
+ executeCommand: (command2, _needApprove) => {
113946
114007
  return new Promise((resolve4, reject) => {
113947
- options.command?.onStarted(command);
113948
- const child = spawn2(command, [], {
114008
+ options.command?.onStarted(command2);
114009
+ const child = spawn2(command2, [], {
113949
114010
  shell: true,
113950
114011
  stdio: "pipe"
113951
114012
  });
@@ -114391,17 +114452,17 @@ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
114391
114452
  for (const [styleName, style] of Object.entries(ansi_styles_default)) {
114392
114453
  styles2[styleName] = {
114393
114454
  get() {
114394
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
114395
- Object.defineProperty(this, styleName, { value: builder });
114396
- return builder;
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;
114397
114458
  }
114398
114459
  };
114399
114460
  }
114400
114461
  styles2.visible = {
114401
114462
  get() {
114402
- const builder = createBuilder(this, this[STYLER], true);
114403
- Object.defineProperty(this, "visible", { value: builder });
114404
- return builder;
114463
+ const builder2 = createBuilder(this, this[STYLER], true);
114464
+ Object.defineProperty(this, "visible", { value: builder2 });
114465
+ return builder2;
114405
114466
  }
114406
114467
  };
114407
114468
  var getModelAnsi = (model, level, type, ...arguments_) => {
@@ -114472,12 +114533,12 @@ var createStyler = (open, close, parent) => {
114472
114533
  };
114473
114534
  };
114474
114535
  var createBuilder = (self2, _styler, _isEmpty) => {
114475
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
114476
- Object.setPrototypeOf(builder, proto);
114477
- builder[GENERATOR] = self2;
114478
- builder[STYLER] = _styler;
114479
- builder[IS_EMPTY] = _isEmpty;
114480
- return builder;
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;
114481
114542
  };
114482
114543
  var applyStyle = (self2, string8) => {
114483
114544
  if (self2.level <= 0 || !string8) {
@@ -114695,9 +114756,9 @@ Tool error:`, event.tool));
114695
114756
  };
114696
114757
  };
114697
114758
  // src/options.ts
114698
- var import_lodash3 = __toESM(require_lodash(), 1);
114699
- function addSharedOptions(command) {
114700
- return command.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");
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");
114701
114762
  }
114702
114763
  function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
114703
114764
  let cwd = cwdArg;
@@ -114716,26 +114777,26 @@ function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
114716
114777
  const defaultProvider = options.apiProvider || env2.POLKA_API_PROVIDER || config5.defaultProvider;
114717
114778
  const defaultModel = options.model || env2.POLKA_MODEL || config5.defaultModel;
114718
114779
  if (defaultProvider && defaultModel) {
114719
- import_lodash3.set(config5, ["providers", defaultProvider, "defaultModel"], defaultModel);
114780
+ import_lodash4.set(config5, ["providers", defaultProvider, "defaultModel"], defaultModel);
114720
114781
  }
114721
114782
  const apiKey = options.apiKey || env2.POLKA_API_KEY;
114722
114783
  if (apiKey) {
114723
114784
  if (!defaultProvider) {
114724
114785
  throw new Error("Must specify a provider if providing an API key");
114725
114786
  }
114726
- import_lodash3.set(config5, ["providers", defaultProvider, "apiKey"], apiKey);
114787
+ import_lodash4.set(config5, ["providers", defaultProvider, "apiKey"], apiKey);
114727
114788
  }
114728
114789
  if (env2.ANTHROPIC_API_KEY) {
114729
- import_lodash3.set(config5, ["providers", "anthropic" /* Anthropic */, "apiKey"], env2.ANTHROPIC_API_KEY);
114790
+ import_lodash4.set(config5, ["providers", "anthropic" /* Anthropic */, "apiKey"], env2.ANTHROPIC_API_KEY);
114730
114791
  }
114731
114792
  if (env2.DEEPSEEK_API_KEY) {
114732
- import_lodash3.set(config5, ["providers", "deepseek" /* DeepSeek */, "apiKey"], env2.DEEPSEEK_API_KEY);
114793
+ import_lodash4.set(config5, ["providers", "deepseek" /* DeepSeek */, "apiKey"], env2.DEEPSEEK_API_KEY);
114733
114794
  }
114734
114795
  if (env2.OPENROUTER_API_KEY) {
114735
- import_lodash3.set(config5, ["providers", "openrouter" /* OpenRouter */, "apiKey"], env2.OPENROUTER_API_KEY);
114796
+ import_lodash4.set(config5, ["providers", "openrouter" /* OpenRouter */, "apiKey"], env2.OPENROUTER_API_KEY);
114736
114797
  }
114737
114798
  if (env2.OPENAI_API_KEY) {
114738
- import_lodash3.set(config5, ["providers", "ollama" /* Ollama */, "apiKey"], env2.OPENAI_API_KEY);
114799
+ import_lodash4.set(config5, ["providers", "ollama" /* Ollama */, "apiKey"], env2.OPENAI_API_KEY);
114739
114800
  }
114740
114801
  const providerConfig = new ApiProviderConfig({
114741
114802
  defaultProvider,
@@ -114756,7 +114817,7 @@ function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
114756
114817
  // src/Runner.ts
114757
114818
  import { readFile as readFile2 } from "node:fs/promises";
114758
114819
  import os3 from "node:os";
114759
- var import_lodash4 = __toESM(require_lodash(), 1);
114820
+ var import_lodash5 = __toESM(require_lodash(), 1);
114760
114821
 
114761
114822
  // src/getProviderOptions.ts
114762
114823
  function getProviderOptions(provider3, modelId, thinkingBudgetTokens, supportThinking) {
@@ -114811,7 +114872,7 @@ class Runner {
114811
114872
  multiAgent;
114812
114873
  constructor(options) {
114813
114874
  this.#options = options;
114814
- this.usageMeter = new UsageMeter(import_lodash4.merge(prices_default, options.config.prices ?? {}), {
114875
+ this.usageMeter = new UsageMeter(import_lodash5.merge(prices_default, options.config.prices ?? {}), {
114815
114876
  maxMessages: options.config.maxMessageCount ?? 0,
114816
114877
  maxCost: options.config.budget ?? 0
114817
114878
  });
@@ -114821,8 +114882,8 @@ class Runner {
114821
114882
  }
114822
114883
  const toolProviderOptions = {
114823
114884
  command: this.#options.silent ? undefined : {
114824
- onStarted(command) {
114825
- console.log(`$ >>>> $ ${command}`);
114885
+ onStarted(command2) {
114886
+ console.log(`$ >>>> $ ${command2}`);
114826
114887
  },
114827
114888
  onStdout(data) {
114828
114889
  process.stdout.write(data);
@@ -115023,24 +115084,24 @@ ${fileList.join(`
115023
115084
  }
115024
115085
 
115025
115086
  // src/commands/chat.ts
115026
- var runChat = async (opts, command) => {
115027
- const options = command?.parent?.opts() ?? opts ?? {};
115028
- 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);
115029
115090
  if (!process.stdin.isTTY) {
115030
115091
  console.error("Error: Terminal is not interactive. Please run this command in an interactive terminal.");
115031
115092
  process.exit(1);
115032
115093
  }
115033
- let providerDetails = providerConfig.getConfigForAgent(agent);
115094
+ let providerDetails = providerConfig.getConfigForAgent(agent2);
115034
115095
  if (!providerDetails?.provider) {
115035
115096
  const newConfig = await configPrompt({});
115036
115097
  const updatedConfig = JSON.parse(JSON.stringify(config5 ?? {}));
115037
- import_lodash5.set(updatedConfig, `providers.${newConfig.provider}.model`, newConfig.model);
115038
- import_lodash5.set(updatedConfig, `providers.${newConfig.provider}.apiKey`, newConfig.apiKey);
115098
+ import_lodash6.set(updatedConfig, `providers.${newConfig.provider}.model`, newConfig.model);
115099
+ import_lodash6.set(updatedConfig, `providers.${newConfig.provider}.apiKey`, newConfig.apiKey);
115039
115100
  if (newConfig.baseURL) {
115040
- import_lodash5.set(updatedConfig, `providers.${newConfig.provider}.baseURL`, newConfig.baseURL);
115101
+ import_lodash6.set(updatedConfig, `providers.${newConfig.provider}.baseURL`, newConfig.baseURL);
115041
115102
  }
115042
115103
  providerConfig = new ApiProviderConfig(updatedConfig);
115043
- providerDetails = providerConfig.getConfigForAgent(agent);
115104
+ providerDetails = providerConfig.getConfigForAgent(agent2);
115044
115105
  config5 = updatedConfig;
115045
115106
  }
115046
115107
  const { provider: provider3, model, parameters } = providerDetails ?? {};
@@ -115090,7 +115151,7 @@ var runChat = async (opts, command) => {
115090
115151
  const reason = await runner.continueTask(message, fileParts);
115091
115152
  exitReason = reason;
115092
115153
  } else {
115093
- const reason = await runner.startTask(message, agent, fileParts);
115154
+ const reason = await runner.startTask(message, agent2, fileParts);
115094
115155
  exitReason = reason;
115095
115156
  }
115096
115157
  switch (exitReason.type) {
@@ -115130,7 +115191,7 @@ var runChat = async (opts, command) => {
115130
115191
 
115131
115192
  // src/commands/commit.ts
115132
115193
  import { execSync, spawnSync as spawnSync2 } from "node:child_process";
115133
- var import_lodash6 = __toESM(require_lodash(), 1);
115194
+ var import_lodash7 = __toESM(require_lodash(), 1);
115134
115195
 
115135
115196
  // ../../node_modules/ora/index.js
115136
115197
  import process11 from "node:process";
@@ -115503,17 +115564,17 @@ Object.setPrototypeOf(createChalk2.prototype, Function.prototype);
115503
115564
  for (const [styleName, style] of Object.entries(ansi_styles_default2)) {
115504
115565
  styles4[styleName] = {
115505
115566
  get() {
115506
- const builder = createBuilder2(this, createStyler2(style.open, style.close, this[STYLER2]), this[IS_EMPTY2]);
115507
- Object.defineProperty(this, styleName, { value: builder });
115508
- return builder;
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;
115509
115570
  }
115510
115571
  };
115511
115572
  }
115512
115573
  styles4.visible = {
115513
115574
  get() {
115514
- const builder = createBuilder2(this, this[STYLER2], true);
115515
- Object.defineProperty(this, "visible", { value: builder });
115516
- return builder;
115575
+ const builder2 = createBuilder2(this, this[STYLER2], true);
115576
+ Object.defineProperty(this, "visible", { value: builder2 });
115577
+ return builder2;
115517
115578
  }
115518
115579
  };
115519
115580
  var getModelAnsi2 = (model, level, type, ...arguments_) => {
@@ -115584,12 +115645,12 @@ var createStyler2 = (open, close, parent) => {
115584
115645
  };
115585
115646
  };
115586
115647
  var createBuilder2 = (self2, _styler, _isEmpty) => {
115587
- const builder = (...arguments_) => applyStyle2(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
115588
- Object.setPrototypeOf(builder, proto2);
115589
- builder[GENERATOR2] = self2;
115590
- builder[STYLER2] = _styler;
115591
- builder[IS_EMPTY2] = _isEmpty;
115592
- return builder;
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;
115593
115654
  };
115594
115655
  var applyStyle2 = (self2, string8) => {
115595
115656
  if (self2.level <= 0 || !string8) {
@@ -116219,8 +116280,8 @@ function ora(options) {
116219
116280
  }
116220
116281
 
116221
116282
  // src/commands/commit.ts
116222
- 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, command) => {
116223
- const options = command.parent?.opts() ?? {};
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() ?? {};
116224
116285
  const { providerConfig, config: config5 } = parseOptions(options);
116225
116286
  const commandConfig = providerConfig.getConfigForCommand("commit");
116226
116287
  if (!commandConfig || !commandConfig.provider || !commandConfig.model) {
@@ -116230,7 +116291,7 @@ var commitCommand = new Command("commit").description("Create a commit with AI-g
116230
116291
  console.log("Provider:", commandConfig.provider);
116231
116292
  console.log("Model:", commandConfig.model);
116232
116293
  const spinner = ora("Gathering information...").start();
116233
- const usage = new UsageMeter(import_lodash6.merge(prices_default, config5.prices ?? {}));
116294
+ const usage = new UsageMeter(import_lodash7.merge(prices_default, config5.prices ?? {}));
116234
116295
  try {
116235
116296
  const status = execSync("git status --porcelain").toString();
116236
116297
  const stagedFiles = status.split(`
@@ -116307,8 +116368,8 @@ var askForPath = async (projectName) => {
116307
116368
  targetPath = inputPath.trim();
116308
116369
  }
116309
116370
  };
116310
- var createCommand2 = new Command("create").description("Create a new project").argument("[name]", "Project name").action(async (name18, _options, command) => {
116311
- const cmdOptions = command.parent?.opts() ?? {};
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() ?? {};
116312
116373
  const { providerConfig, maxMessageCount, verbose, budget } = parseOptions(cmdOptions);
116313
116374
  let { provider: maybeProvider, model, apiKey } = providerConfig.getConfigForAgent("architect") ?? {};
116314
116375
  if (!maybeProvider) {
@@ -116346,7 +116407,7 @@ var createCommand2 = new Command("create").description("Create a new project").a
116346
116407
  // src/commands/init.ts
116347
116408
  import { existsSync as existsSync4, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
116348
116409
  import { dirname as dirname2 } from "node:path";
116349
- var import_lodash7 = __toESM(require_lodash(), 1);
116410
+ var import_lodash8 = __toESM(require_lodash(), 1);
116350
116411
 
116351
116412
  // ../../node_modules/yaml/dist/index.js
116352
116413
  var composer2 = require_composer2();
@@ -116396,8 +116457,8 @@ var $visitAsync2 = visit2.visitAsync;
116396
116457
 
116397
116458
  // src/commands/init.ts
116398
116459
  var initCommand = new Command("init").description("Initialize polkacodes configuration").option("-g, --global", "Use global config");
116399
- initCommand.action(async (options, command) => {
116400
- const cmdOptions = command.parent?.opts() ?? {};
116460
+ initCommand.action(async (options, command2) => {
116461
+ const cmdOptions = command2.parent?.opts() ?? {};
116401
116462
  parseOptions(cmdOptions);
116402
116463
  cmdOptions.baseDir = undefined;
116403
116464
  const globalConfigPath = getGlobalConfigPath();
@@ -116477,7 +116538,7 @@ initCommand.action(async (options, command) => {
116477
116538
  break;
116478
116539
  case 2: {
116479
116540
  const globalConfig3 = loadConfigAtPath(globalConfigPath) ?? {};
116480
- import_lodash7.set(globalConfig3, ["providers", newConfig.provider, "apiKey"], newConfig.apiKey);
116541
+ import_lodash8.set(globalConfig3, ["providers", newConfig.provider, "apiKey"], newConfig.apiKey);
116481
116542
  mkdirSync(dirname2(globalConfigPath), { recursive: true });
116482
116543
  writeFileSync(globalConfigPath, $stringify2(globalConfig3));
116483
116544
  console.log(`API key saved to global config file: ${globalConfigPath}`);
@@ -116532,7 +116593,7 @@ ${newConfig.provider.toUpperCase()}_API_KEY=${newConfig.apiKey}`;
116532
116593
  finalConfig.defaultProvider = newConfig.provider;
116533
116594
  finalConfig.defaultModel = newConfig.model;
116534
116595
  if (newConfig.apiKey) {
116535
- import_lodash7.set(finalConfig, ["providers", newConfig.provider, "apiKey"], newConfig.apiKey);
116596
+ import_lodash8.set(finalConfig, ["providers", newConfig.provider, "apiKey"], newConfig.apiKey);
116536
116597
  }
116537
116598
  }
116538
116599
  mkdirSync(dirname2(configPath), { recursive: true });
@@ -116546,9 +116607,9 @@ ${newConfig.provider.toUpperCase()}_API_KEY=${newConfig.apiKey}`;
116546
116607
 
116547
116608
  // src/commands/pr.ts
116548
116609
  import { execSync as execSync2, spawnSync as spawnSync3 } from "node:child_process";
116549
- var import_lodash8 = __toESM(require_lodash(), 1);
116550
- var prCommand = new Command("pr").description("Create a GitHub pull request").argument("[message]", "Optional context for the commit message generation").action(async (message, _options, command) => {
116551
- const options = command.parent?.opts() ?? {};
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() ?? {};
116552
116613
  const { providerConfig, config: config5 } = parseOptions(options);
116553
116614
  const commandConfig = providerConfig.getConfigForCommand("pr");
116554
116615
  if (!commandConfig || !commandConfig.provider || !commandConfig.model) {
@@ -116586,7 +116647,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
116586
116647
  encoding: "utf-8"
116587
116648
  });
116588
116649
  const diff = execSync2(`git diff --cached -U50 ${defaultBranch}`, { encoding: "utf-8" });
116589
- const usage = new UsageMeter(import_lodash8.merge(prices_default, config5.prices ?? {}));
116650
+ const usage = new UsageMeter(import_lodash9.merge(prices_default, config5.prices ?? {}));
116590
116651
  const ai = getModel(commandConfig);
116591
116652
  spinner.text = "Generating pull request details...";
116592
116653
  const resp = await generateGithubPullRequestDetails(ai, {
@@ -116615,7 +116676,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
116615
116676
  // src/commands/review.ts
116616
116677
  import { execSync as execSync3 } from "node:child_process";
116617
116678
  import { Console } from "node:console";
116618
- var import_lodash9 = __toESM(require_lodash(), 1);
116679
+ var import_lodash10 = __toESM(require_lodash(), 1);
116619
116680
 
116620
116681
  // src/commands/task.ts
116621
116682
  import { readFile as readFile4 } from "node:fs/promises";
@@ -116652,7 +116713,7 @@ var readStdin = async (timeoutMs = 30000) => {
116652
116713
  });
116653
116714
  });
116654
116715
  };
116655
- async function runTask(taskArg, _options, command) {
116716
+ async function runTask(taskArg, _options, command2) {
116656
116717
  let task = taskArg;
116657
116718
  if (!task) {
116658
116719
  try {
@@ -116660,7 +116721,7 @@ async function runTask(taskArg, _options, command) {
116660
116721
  if (stdinInput) {
116661
116722
  task = stdinInput;
116662
116723
  } else {
116663
- runChat(command.opts());
116724
+ runChat(command2.opts());
116664
116725
  return;
116665
116726
  }
116666
116727
  } catch (error82) {
@@ -116668,8 +116729,8 @@ async function runTask(taskArg, _options, command) {
116668
116729
  process.exit(1);
116669
116730
  }
116670
116731
  }
116671
- const { config: config5, providerConfig, verbose, maxMessageCount, budget, agent, silent, file: files } = parseOptions(command.opts());
116672
- const { provider: provider3, model, parameters } = providerConfig.getConfigForAgent(agent) ?? {};
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) ?? {};
116673
116734
  if (!provider3 || !model) {
116674
116735
  console.error("Provider and model must be configured");
116675
116736
  process.exit(1);
@@ -116696,7 +116757,7 @@ async function runTask(taskArg, _options, command) {
116696
116757
  console.log();
116697
116758
  runner.printUsage();
116698
116759
  }
116699
- process.exit(0);
116760
+ process.exit(130);
116700
116761
  };
116701
116762
  process.on("SIGINT", sigintHandler);
116702
116763
  const fileContents = [];
@@ -116728,7 +116789,7 @@ async function runTask(taskArg, _options, command) {
116728
116789
  }
116729
116790
  }
116730
116791
  }
116731
- const exitReason = await runner.startTask(task, agent, fileContents);
116792
+ const exitReason = await runner.startTask(task, agent2, fileContents);
116732
116793
  process.off("SIGINT", sigintHandler);
116733
116794
  if (silent) {
116734
116795
  if (exitReason.type === "Exit" /* Exit */) {
@@ -116823,8 +116884,8 @@ function parseGitDiffNameStatus(diffOutput) {
116823
116884
  return { path, status: statusDescription };
116824
116885
  });
116825
116886
  }
116826
- 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, command) => {
116827
- const parentOptions = command.parent?.opts() ?? {};
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() ?? {};
116828
116889
  const { providerConfig, config: config5 } = parseOptions(parentOptions);
116829
116890
  const commandConfig = providerConfig.getConfigForCommand("review");
116830
116891
  if (!commandConfig || !commandConfig.provider || !commandConfig.model) {
@@ -116839,7 +116900,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
116839
116900
  text: "Gathering information...",
116840
116901
  stream: process.stderr
116841
116902
  }).start();
116842
- const usage = new UsageMeter(import_lodash9.merge(prices_default, config5.prices ?? {}));
116903
+ const usage = new UsageMeter(import_lodash10.merge(prices_default, config5.prices ?? {}));
116843
116904
  const customConsole = options.json ? new Console(process.stderr, process.stderr) : console;
116844
116905
  const onEvent = printEvent(parentOptions.verbose, usage, customConsole);
116845
116906
  const ai = getModel(commandConfig);
@@ -116860,9 +116921,9 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
116860
116921
  };
116861
116922
  try {
116862
116923
  if (options.pr) {
116863
- await reviewPR(options.pr, spinner, sharedAiOptions, options.json, command);
116924
+ await reviewPR(options.pr, spinner, sharedAiOptions, options.json, command2);
116864
116925
  } else {
116865
- await reviewLocal(spinner, sharedAiOptions, options.json, command);
116926
+ await reviewLocal(spinner, sharedAiOptions, options.json, command2);
116866
116927
  }
116867
116928
  } catch (error82) {
116868
116929
  spinner.fail(`Error reviewing: ${error82 instanceof Error ? error82.message : String(error82)}`);
@@ -116873,7 +116934,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
116873
116934
  usage.printUsage();
116874
116935
  }
116875
116936
  });
116876
- async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput, command) {
116937
+ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput, command2) {
116877
116938
  const prNumberMatch = prIdentifier.match(/\d+$/);
116878
116939
  if (!prNumberMatch) {
116879
116940
  spinner.fail("Invalid PR number or URL.");
@@ -116919,9 +116980,9 @@ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput, co
116919
116980
  changedFiles
116920
116981
  });
116921
116982
  spinner.succeed("Review generated successfully");
116922
- await handleReviewResult(result, isJsonOutput, command);
116983
+ await handleReviewResult(result, isJsonOutput, command2);
116923
116984
  }
116924
- async function reviewLocal(spinner, sharedAiOptions, isJsonOutput, command) {
116985
+ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput, command2) {
116925
116986
  const gitStatus = execSync3("git status --porcelain=v1", { encoding: "utf-8" });
116926
116987
  const statusLines = gitStatus.split(`
116927
116988
  `).filter((line) => line);
@@ -116937,7 +116998,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput, command) {
116937
116998
  changedFiles: stagedFiles
116938
116999
  });
116939
117000
  spinner.succeed("Review generated successfully");
116940
- await handleReviewResult(result2, isJsonOutput, command);
117001
+ await handleReviewResult(result2, isJsonOutput, command2);
116941
117002
  return;
116942
117003
  }
116943
117004
  if (hasUnstagedChanges) {
@@ -116949,7 +117010,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput, command) {
116949
117010
  changedFiles: unstagedFiles
116950
117011
  });
116951
117012
  spinner.succeed("Review generated successfully");
116952
- await handleReviewResult(result2, isJsonOutput, command);
117013
+ await handleReviewResult(result2, isJsonOutput, command2);
116953
117014
  return;
116954
117015
  }
116955
117016
  spinner.text = "No local changes detected. Falling back to branch diff...";
@@ -116983,9 +117044,9 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput, command) {
116983
117044
  changedFiles: branchChangedFiles
116984
117045
  });
116985
117046
  spinner.succeed("Review generated successfully");
116986
- await handleReviewResult(result, isJsonOutput, command);
117047
+ await handleReviewResult(result, isJsonOutput, command2);
116987
117048
  }
116988
- async function handleReviewResult(result, isJsonOutput, command) {
117049
+ async function handleReviewResult(result, isJsonOutput, command2) {
116989
117050
  if (isJsonOutput) {
116990
117051
  console.log(JSON.stringify(result, null, 2));
116991
117052
  return;
@@ -117000,14 +117061,14 @@ async function handleReviewResult(result, isJsonOutput, command) {
117000
117061
  default: false
117001
117062
  });
117002
117063
  } catch {
117003
- process.exit(0);
117064
+ process.exit(130);
117004
117065
  }
117005
117066
  }
117006
117067
  if (shouldRunTask) {
117007
117068
  const taskInstruction = `please address the review result:
117008
117069
 
117009
117070
  ${formatted}`;
117010
- await runTask(taskInstruction, {}, command);
117071
+ await runTask(taskInstruction, {}, command2);
117011
117072
  }
117012
117073
  }
117013
117074
  function formatReviewForConsole(output) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.9.24",
3
+ "version": "0.9.26",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",