@polka-codes/cli-shared 0.9.2 → 0.9.3

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 +686 -416
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -26789,35 +26789,27 @@ var toolInfo = {
26789
26789
  description: "Call this when vital details are missing. Pose each follow-up as one direct, unambiguous question. If it speeds the reply, add up to five short, mutually-exclusive answer options. Group any related questions in the same call to avoid a back-and-forth chain.",
26790
26790
  parameters: exports_external.object({
26791
26791
  questions: exports_external.array(questionObject).describe("One or more follow-up questions you need answered before you can continue.").meta({ usageValue: "questions here" })
26792
- }),
26793
- examples: [
26794
- {
26795
- description: "Single clarifying question (no options)",
26796
- parameters: [
26797
- {
26798
- name: "questions",
26799
- value: { prompt: "What is the target deployment environment?" }
26792
+ }).meta({
26793
+ examples: [
26794
+ {
26795
+ description: "Single clarifying question (no options)",
26796
+ input: {
26797
+ questions: { prompt: "What is the target deployment environment?" }
26800
26798
  }
26801
- ]
26802
- },
26803
- {
26804
- description: "Single question with multiple-choice options",
26805
- parameters: [
26806
- {
26807
- name: "questions",
26808
- value: {
26799
+ },
26800
+ {
26801
+ description: "Single question with multiple-choice options",
26802
+ input: {
26803
+ questions: {
26809
26804
  prompt: "Which frontend framework are you using?",
26810
26805
  options: ["React", "Angular", "Vue", "Svelte"]
26811
26806
  }
26812
26807
  }
26813
- ]
26814
- },
26815
- {
26816
- description: "Two related questions in one call",
26817
- parameters: [
26818
- {
26819
- name: "questions",
26820
- value: [
26808
+ },
26809
+ {
26810
+ description: "Two related questions in one call",
26811
+ input: {
26812
+ questions: [
26821
26813
  { prompt: "What type of application are you building?" },
26822
26814
  {
26823
26815
  prompt: "Preferred programming language?",
@@ -26825,21 +26817,18 @@ var toolInfo = {
26825
26817
  }
26826
26818
  ]
26827
26819
  }
26828
- ]
26829
- },
26830
- {
26831
- description: "Binary (yes/no) confirmation",
26832
- parameters: [
26833
- {
26834
- name: "questions",
26835
- value: {
26820
+ },
26821
+ {
26822
+ description: "Binary (yes/no) confirmation",
26823
+ input: {
26824
+ questions: {
26836
26825
  prompt: "Is it acceptable to refactor existing tests to improve performance?",
26837
26826
  options: ["Yes", "No"]
26838
26827
  }
26839
26828
  }
26840
- ]
26841
- }
26842
- ],
26829
+ }
26830
+ ]
26831
+ }),
26843
26832
  permissionLevel: 0 /* None */
26844
26833
  };
26845
26834
  var handler = async (provider, args) => {
@@ -26884,18 +26873,16 @@ var toolInfo2 = {
26884
26873
  description: "Use this tool when you believe the user’s requested task is complete. Indicate that your work is finished, but acknowledge the user may still provide additional instructions or questions if they want to continue. This tool MUST NOT to be used with any other tool.",
26885
26874
  parameters: exports_external.object({
26886
26875
  result: exports_external.string().describe("The result of the task. Formulate this result in a way that is final and does not require further input from the user. Don't end your result with questions or offers for further assistance.").meta({ usageValue: "Your final result description here" })
26887
- }),
26888
- examples: [
26889
- {
26890
- description: "Request to present the result of the task",
26891
- parameters: [
26892
- {
26893
- name: "result",
26894
- value: "Your final result description here"
26876
+ }).meta({
26877
+ examples: [
26878
+ {
26879
+ description: "Request to present the result of the task",
26880
+ input: {
26881
+ result: "Your final result description here"
26895
26882
  }
26896
- ]
26897
- }
26898
- ],
26883
+ }
26884
+ ]
26885
+ }),
26899
26886
  permissionLevel: 0 /* None */
26900
26887
  };
26901
26888
  var handler2 = async (provider, args) => {
@@ -26941,30 +26928,19 @@ var toolInfo3 = {
26941
26928
  const values = Array.isArray(val) ? val : [val];
26942
26929
  return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
26943
26930
  }, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
26944
- }),
26945
- examples: [
26946
- {
26947
- description: "Delegate a code analysis task to the analyzer agent",
26948
- parameters: [
26949
- {
26950
- name: "agentName",
26951
- value: "analyzer"
26952
- },
26953
- {
26954
- name: "task",
26955
- value: "Analyze the authentication implementation"
26956
- },
26957
- {
26958
- name: "context",
26959
- value: "Need to understand the security implications of the current auth system"
26960
- },
26961
- {
26962
- name: "files",
26963
- value: "src/auth/login.ts,src/auth/types.ts"
26931
+ }).meta({
26932
+ examples: [
26933
+ {
26934
+ description: "Delegate a code analysis task to the analyzer agent",
26935
+ input: {
26936
+ agentName: "analyzer",
26937
+ task: "Analyze the authentication implementation",
26938
+ context: "Need to understand the security implications of the current auth system",
26939
+ files: "src/auth/login.ts,src/auth/types.ts"
26964
26940
  }
26965
- ]
26966
- }
26967
- ],
26941
+ }
26942
+ ]
26943
+ }),
26968
26944
  permissionLevel: 0 /* None */
26969
26945
  };
26970
26946
  var handler3 = async (_provider, args) => {
@@ -27008,16 +26984,17 @@ var toolInfo4 = {
27008
26984
  }
27009
26985
  return val;
27010
26986
  }, exports_external.boolean().optional().default(false)).describe("Set to `true` for commands that install/uninstall software, modify or delete files, change system settings, perform network operations, or have other side effects. Use `false` for safe, read-only, or purely local development actions (e.g., listing files, make a build, running tests).").meta({ usageValue: "true | false" })
26987
+ }).meta({
26988
+ examples: [
26989
+ {
26990
+ description: "Make a build",
26991
+ input: {
26992
+ command: "npm run build",
26993
+ requiresApproval: "false"
26994
+ }
26995
+ }
26996
+ ]
27011
26997
  }),
27012
- examples: [
27013
- {
27014
- description: "Make a build",
27015
- parameters: [
27016
- { name: "command", value: "npm run build" },
27017
- { name: "requiresApproval", value: "false" }
27018
- ]
27019
- }
27020
- ],
27021
26998
  permissionLevel: 3 /* Arbitrary */
27022
26999
  };
27023
27000
  var handler4 = async (provider, args) => {
@@ -27075,36 +27052,28 @@ var toolInfo5 = {
27075
27052
  const values = Array.isArray(val) ? val : [val];
27076
27053
  return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
27077
27054
  }, exports_external.array(exports_external.string())).describe("One or more URLs to fetch, separated by commas if multiple.").meta({ usageValue: "url" })
27078
- }),
27079
- examples: [
27080
- {
27081
- description: "Fetch a single webpage",
27082
- parameters: [
27083
- {
27084
- name: "url",
27085
- value: "https://example.com"
27055
+ }).meta({
27056
+ examples: [
27057
+ {
27058
+ description: "Fetch a single webpage",
27059
+ input: {
27060
+ url: "https://example.com"
27086
27061
  }
27087
- ]
27088
- },
27089
- {
27090
- description: "Fetch multiple webpages",
27091
- parameters: [
27092
- {
27093
- name: "url",
27094
- value: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
27062
+ },
27063
+ {
27064
+ description: "Fetch multiple webpages",
27065
+ input: {
27066
+ url: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
27095
27067
  }
27096
- ]
27097
- },
27098
- {
27099
- description: "Fetch a raw file from GitHub",
27100
- parameters: [
27101
- {
27102
- name: "url",
27103
- value: "https://raw.githubusercontent.com/user/repo/main/README.md"
27068
+ },
27069
+ {
27070
+ description: "Fetch a raw file from GitHub",
27071
+ input: {
27072
+ url: "https://raw.githubusercontent.com/user/repo/main/README.md"
27104
27073
  }
27105
- ]
27106
- }
27107
- ],
27074
+ }
27075
+ ]
27076
+ }),
27108
27077
  permissionLevel: 1 /* Read */
27109
27078
  };
27110
27079
  var handler5 = async (provider, args) => {
@@ -27160,30 +27129,19 @@ var toolInfo6 = {
27160
27129
  const values = Array.isArray(val) ? val : [val];
27161
27130
  return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
27162
27131
  }, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
27163
- }),
27164
- examples: [
27165
- {
27166
- description: "Hand over a coding task to the coder agent",
27167
- parameters: [
27168
- {
27169
- name: "agentName",
27170
- value: "coder"
27171
- },
27172
- {
27173
- name: "task",
27174
- value: "Implement the login feature"
27175
- },
27176
- {
27177
- name: "context",
27178
- value: "We need a secure login system with email and password"
27179
- },
27180
- {
27181
- name: "files",
27182
- value: "src/auth/login.ts,src/auth/types.ts"
27132
+ }).meta({
27133
+ examples: [
27134
+ {
27135
+ description: "Hand over a coding task to the coder agent",
27136
+ input: {
27137
+ agentName: "coder",
27138
+ task: "Implement the login feature",
27139
+ context: "We need a secure login system with email and password",
27140
+ files: "src/auth/login.ts,src/auth/types.ts"
27183
27141
  }
27184
- ]
27185
- }
27186
- ],
27142
+ }
27143
+ ]
27144
+ }),
27187
27145
  permissionLevel: 0 /* None */
27188
27146
  };
27189
27147
  var handler6 = async (_provider, args) => {
@@ -27228,22 +27186,17 @@ var toolInfo7 = {
27228
27186
  }
27229
27187
  return val;
27230
27188
  }, exports_external.boolean().optional().default(true)).describe("Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.").meta({ usageValue: "true or false (optional)" })
27231
- }),
27232
- examples: [
27233
- {
27234
- description: "Request to list files",
27235
- parameters: [
27236
- {
27237
- name: "path",
27238
- value: "src"
27239
- },
27240
- {
27241
- name: "maxCount",
27242
- value: "100"
27189
+ }).meta({
27190
+ examples: [
27191
+ {
27192
+ description: "Request to list files",
27193
+ input: {
27194
+ path: "src",
27195
+ maxCount: "100"
27243
27196
  }
27244
- ]
27245
- }
27246
- ],
27197
+ }
27198
+ ]
27199
+ }),
27247
27200
  permissionLevel: 1 /* Read */
27248
27201
  };
27249
27202
  var handler7 = async (provider, args) => {
@@ -27284,27 +27237,22 @@ var toolInfo8 = {
27284
27237
  const values = Array.isArray(val) ? val : [val];
27285
27238
  return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
27286
27239
  }, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" })
27287
- }),
27288
- examples: [
27289
- {
27290
- description: "Request to read the contents of a file",
27291
- parameters: [
27292
- {
27293
- name: "path",
27294
- value: "src/main.js"
27240
+ }).meta({
27241
+ examples: [
27242
+ {
27243
+ description: "Request to read the contents of a file",
27244
+ input: {
27245
+ path: "src/main.js"
27295
27246
  }
27296
- ]
27297
- },
27298
- {
27299
- description: "Request to read multiple files",
27300
- parameters: [
27301
- {
27302
- name: "path",
27303
- value: "src/main.js,src/index.js"
27247
+ },
27248
+ {
27249
+ description: "Request to read multiple files",
27250
+ input: {
27251
+ path: "src/main.js,src/index.js"
27304
27252
  }
27305
- ]
27306
- }
27307
- ],
27253
+ }
27254
+ ]
27255
+ }),
27308
27256
  permissionLevel: 1 /* Read */
27309
27257
  };
27310
27258
  var handler8 = async (provider, args) => {
@@ -27349,18 +27297,16 @@ var toolInfo9 = {
27349
27297
  description: "Request to remove a file at the specified path.",
27350
27298
  parameters: exports_external.object({
27351
27299
  path: exports_external.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
27352
- }),
27353
- examples: [
27354
- {
27355
- description: "Request to remove a file",
27356
- parameters: [
27357
- {
27358
- name: "path",
27359
- value: "src/main.js"
27300
+ }).meta({
27301
+ examples: [
27302
+ {
27303
+ description: "Request to remove a file",
27304
+ input: {
27305
+ path: "src/main.js"
27360
27306
  }
27361
- ]
27362
- }
27363
- ],
27307
+ }
27308
+ ]
27309
+ }),
27364
27310
  permissionLevel: 2 /* Write */
27365
27311
  };
27366
27312
  var handler9 = async (provider, args) => {
@@ -27399,22 +27345,17 @@ var toolInfo10 = {
27399
27345
  parameters: exports_external.object({
27400
27346
  source_path: exports_external.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
27401
27347
  target_path: exports_external.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
27402
- }),
27403
- examples: [
27404
- {
27405
- description: "Request to rename a file",
27406
- parameters: [
27407
- {
27408
- name: "source_path",
27409
- value: "src/old-name.js"
27410
- },
27411
- {
27412
- name: "target_path",
27413
- value: "src/new-name.js"
27348
+ }).meta({
27349
+ examples: [
27350
+ {
27351
+ description: "Request to rename a file",
27352
+ input: {
27353
+ source_path: "src/old-name.js",
27354
+ target_path: "src/new-name.js"
27414
27355
  }
27415
- ]
27416
- }
27417
- ],
27356
+ }
27357
+ ]
27358
+ }),
27418
27359
  permissionLevel: 2 /* Write */
27419
27360
  };
27420
27361
  var handler10 = async (provider, args) => {
@@ -27543,18 +27484,13 @@ Critical rules:
27543
27484
  4. Special operations:
27544
27485
  * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
27545
27486
  * To delete code: Use empty REPLACE section`).meta({ usageValue: "Search and replace blocks here" })
27546
- }),
27547
- examples: [
27548
- {
27549
- description: "Request to replace sections of content in a file",
27550
- parameters: [
27551
- {
27552
- name: "path",
27553
- value: "src/main.js"
27554
- },
27555
- {
27556
- name: "diff",
27557
- value: `<<<<<<< SEARCH
27487
+ }).meta({
27488
+ examples: [
27489
+ {
27490
+ description: "Request to replace sections of content in a file",
27491
+ input: {
27492
+ path: "src/main.js",
27493
+ diff: `<<<<<<< SEARCH
27558
27494
  import React from 'react';
27559
27495
  =======
27560
27496
  import React, { useState } from 'react';
@@ -27582,35 +27518,23 @@ return (
27582
27518
  <div>
27583
27519
  >>>>>>> REPLACE`
27584
27520
  }
27585
- ]
27586
- },
27587
- {
27588
- description: "Request to perform a simple, single-line replacement",
27589
- parameters: [
27590
- {
27591
- name: "path",
27592
- value: "src/config.js"
27593
- },
27594
- {
27595
- name: "diff",
27596
- value: `<<<<<<< SEARCH
27521
+ },
27522
+ {
27523
+ description: "Request to perform a simple, single-line replacement",
27524
+ input: {
27525
+ path: "src/config.js",
27526
+ diff: `<<<<<<< SEARCH
27597
27527
  const API_URL = 'https://api.example.com';
27598
27528
  =======
27599
27529
  const API_URL = 'https://api.staging.example.com';
27600
27530
  >>>>>>> REPLACE`
27601
27531
  }
27602
- ]
27603
- },
27604
- {
27605
- description: "Request to add a new function to a file",
27606
- parameters: [
27607
- {
27608
- name: "path",
27609
- value: "src/utils.js"
27610
- },
27611
- {
27612
- name: "diff",
27613
- value: `<<<<<<< SEARCH
27532
+ },
27533
+ {
27534
+ description: "Request to add a new function to a file",
27535
+ input: {
27536
+ path: "src/utils.js",
27537
+ diff: `<<<<<<< SEARCH
27614
27538
  function helperA() {
27615
27539
  // ...
27616
27540
  }
@@ -27624,18 +27548,12 @@ function newHelper() {
27624
27548
  }
27625
27549
  >>>>>>> REPLACE`
27626
27550
  }
27627
- ]
27628
- },
27629
- {
27630
- description: "Request to delete a block of code from a file",
27631
- parameters: [
27632
- {
27633
- name: "path",
27634
- value: "src/app.js"
27635
- },
27636
- {
27637
- name: "diff",
27638
- value: `<<<<<<< SEARCH
27551
+ },
27552
+ {
27553
+ description: "Request to delete a block of code from a file",
27554
+ input: {
27555
+ path: "src/app.js",
27556
+ diff: `<<<<<<< SEARCH
27639
27557
  function oldFeature() {
27640
27558
  // This is no longer needed
27641
27559
  }
@@ -27643,9 +27561,9 @@ function oldFeature() {
27643
27561
  =======
27644
27562
  >>>>>>> REPLACE`
27645
27563
  }
27646
- ]
27647
- }
27648
- ],
27564
+ }
27565
+ ]
27566
+ }),
27649
27567
  permissionLevel: 2 /* Write */
27650
27568
  };
27651
27569
  var handler11 = async (provider, args) => {
@@ -27713,26 +27631,18 @@ var toolInfo12 = {
27713
27631
  filePattern: exports_external.string().optional().describe('Comma-separated glob pattern to filter files (e.g., "*.ts" for TypeScript files or "*.ts,*.js" for both TypeScript and JavaScript files). If not provided, it will search all files (*).').meta({
27714
27632
  usageValue: "file pattern here (optional)"
27715
27633
  })
27716
- }),
27717
- examples: [
27718
- {
27719
- description: "Request to perform a regex search across files",
27720
- parameters: [
27721
- {
27722
- name: "path",
27723
- value: "src"
27724
- },
27725
- {
27726
- name: "regex",
27727
- value: "^components/"
27728
- },
27729
- {
27730
- name: "filePattern",
27731
- value: "*.ts,*.tsx"
27634
+ }).meta({
27635
+ examples: [
27636
+ {
27637
+ description: "Request to perform a regex search across files",
27638
+ input: {
27639
+ path: "src",
27640
+ regex: "^components/",
27641
+ filePattern: "*.ts,*.tsx"
27732
27642
  }
27733
- ]
27734
- }
27735
- ],
27643
+ }
27644
+ ]
27645
+ }),
27736
27646
  permissionLevel: 1 /* Read */
27737
27647
  };
27738
27648
  var handler12 = async (provider, args) => {
@@ -27778,18 +27688,13 @@ var toolInfo13 = {
27778
27688
  parameters: exports_external.object({
27779
27689
  path: exports_external.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
27780
27690
  content: exports_external.string().describe("The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.").meta({ usageValue: "Your file content here" })
27781
- }),
27782
- examples: [
27783
- {
27784
- description: "Request to write content to a file",
27785
- parameters: [
27786
- {
27787
- name: "path",
27788
- value: "src/main.js"
27789
- },
27790
- {
27791
- name: "content",
27792
- value: `import React from 'react';
27691
+ }).meta({
27692
+ examples: [
27693
+ {
27694
+ description: "Request to write content to a file",
27695
+ input: {
27696
+ path: "src/main.js",
27697
+ content: `import React from 'react';
27793
27698
 
27794
27699
  function App() {
27795
27700
  return (
@@ -27802,9 +27707,9 @@ function App() {
27802
27707
  export default App;
27803
27708
  `
27804
27709
  }
27805
- ]
27806
- }
27807
- ],
27710
+ }
27711
+ ]
27712
+ }),
27808
27713
  permissionLevel: 2 /* Write */
27809
27714
  };
27810
27715
  var handler13 = async (provider, args) => {
@@ -27864,45 +27769,6 @@ var getAvailableTools = ({
27864
27769
  return tools;
27865
27770
  };
27866
27771
 
27867
- // ../core/src/tool-v1-compat.ts
27868
- function zodSchemaToParameters(schema) {
27869
- const parameters = [];
27870
- const { shape } = schema;
27871
- for (const name in shape) {
27872
- const def = shape[name];
27873
- const isOptional = def.safeParse(undefined).success;
27874
- const description = def.description || "";
27875
- const param = {
27876
- name,
27877
- description,
27878
- required: !isOptional
27879
- };
27880
- const usageValue = def.meta()?.usageValue;
27881
- if (usageValue) {
27882
- param.usageValue = usageValue;
27883
- }
27884
- if (def instanceof exports_external.ZodObject) {
27885
- param.children = zodSchemaToParameters(def);
27886
- } else if (def instanceof exports_external.ZodArray) {
27887
- param.allowMultiple = true;
27888
- const element = def.element;
27889
- if (element instanceof exports_external.ZodObject) {
27890
- param.children = zodSchemaToParameters(element);
27891
- }
27892
- }
27893
- parameters.push(param);
27894
- }
27895
- return parameters;
27896
- }
27897
- function toToolInfoV1(tool) {
27898
- const { parameters: zodSchema, ...rest } = tool;
27899
- const v1Parameters = zodSchemaToParameters(zodSchema);
27900
- return {
27901
- ...rest,
27902
- parameters: v1Parameters
27903
- };
27904
- }
27905
-
27906
27772
  // ../core/src/UsageMeter.ts
27907
27773
  class UsageMeter {
27908
27774
  #totals = { input: 0, output: 0, cachedRead: 0, cost: 0 };
@@ -50570,6 +50436,53 @@ var JSONRPCMessageSchema = exports_external2.union([
50570
50436
  JSONRPCErrorSchema
50571
50437
  ]);
50572
50438
 
50439
+ // ../core/src/Agent/AgentBase.ts
50440
+ var import_lodash = __toESM(require_lodash(), 1);
50441
+
50442
+ // ../core/src/tool-v1-compat.ts
50443
+ function zodSchemaToParameters(schema) {
50444
+ const parameters = [];
50445
+ const { shape } = schema;
50446
+ for (const name17 in shape) {
50447
+ const def = shape[name17];
50448
+ const isOptional = def.safeParse(undefined).success;
50449
+ const description = def.description || "";
50450
+ const param = {
50451
+ name: name17,
50452
+ description,
50453
+ required: !isOptional
50454
+ };
50455
+ const usageValue = def.meta()?.usageValue;
50456
+ if (usageValue) {
50457
+ param.usageValue = usageValue;
50458
+ }
50459
+ if (def instanceof exports_external.ZodObject) {
50460
+ param.children = zodSchemaToParameters(def);
50461
+ } else if (def instanceof exports_external.ZodArray) {
50462
+ param.allowMultiple = true;
50463
+ const element = def.element;
50464
+ if (element instanceof exports_external.ZodObject) {
50465
+ param.children = zodSchemaToParameters(element);
50466
+ }
50467
+ }
50468
+ parameters.push(param);
50469
+ }
50470
+ return parameters;
50471
+ }
50472
+ function toToolInfoV1(tool) {
50473
+ const { parameters: zodSchema2, ...rest } = tool;
50474
+ const v1Parameters = zodSchemaToParameters(zodSchema2);
50475
+ const examples = zodSchema2.meta()?.examples;
50476
+ const v1Tool = {
50477
+ ...rest,
50478
+ parameters: v1Parameters
50479
+ };
50480
+ if (examples) {
50481
+ v1Tool.examples = examples;
50482
+ }
50483
+ return v1Tool;
50484
+ }
50485
+
50573
50486
  // ../core/src/Agent/parseAssistantMessage.ts
50574
50487
  function parseNestedParameters(content, parameterPrefix, childrenParams) {
50575
50488
  const result = {};
@@ -50743,7 +50656,7 @@ var toolInfoExamplesPrompt = (tool, example, toolNamePrefix, parameterPrefix) =>
50743
50656
  ## Example: ${example.description}
50744
50657
 
50745
50658
  <${toolNamePrefix}${tool.name}>
50746
- ${example.parameters.map((param) => `${renderParameterValue(param.name, param.value, parameterPrefix)}`).join(`
50659
+ ${Object.entries(example.input).map(([name17, value]) => renderParameterValue(name17, value, parameterPrefix)).join(`
50747
50660
  `)}
50748
50661
  </${toolNamePrefix}${tool.name}>
50749
50662
  `;
@@ -50752,6 +50665,7 @@ var toolUsePrompt = (tools, toolNamePrefix) => {
50752
50665
  return "";
50753
50666
  }
50754
50667
  const parameterPrefix = `${toolNamePrefix}parameter_`;
50668
+ const v1Tools = tools.map(toToolInfoV1);
50755
50669
  return `
50756
50670
  ====
50757
50671
 
@@ -50810,11 +50724,11 @@ Always adhere to this format, ensuring every opening tag has a matching closing
50810
50724
  NEVER surround tool use with triple backticks (\`\`\`).
50811
50725
 
50812
50726
  # Tools
50813
- ${tools.map((tool) => toolInfoPrompt(tool, toolNamePrefix, parameterPrefix)).join(`
50727
+ ${v1Tools.map((tool) => toolInfoPrompt(tool, toolNamePrefix, parameterPrefix)).join(`
50814
50728
  `)}
50815
50729
 
50816
50730
  # Tool Use Examples
50817
- ${tools.map((tool) => {
50731
+ ${v1Tools.map((tool) => {
50818
50732
  let promp = "";
50819
50733
  for (const example of tool.examples ?? []) {
50820
50734
  promp += toolInfoExamplesPrompt(tool, example, toolNamePrefix, parameterPrefix);
@@ -50907,6 +50821,8 @@ e.g. <tool_tool_name>tool_name</tool_tool_name>
50907
50821
  Ensure the opening and closing tags are correctly nested and closed, and that you are using the correct tool name.
50908
50822
  Avoid unnecessary text or symbols before or after the tool use.
50909
50823
  Avoid unnecessary escape characters or special characters.
50824
+ `,
50825
+ requireUseToolNative: `Error: No tool use detected. You MUST use a tool before proceeding.
50910
50826
  `,
50911
50827
  toolResults: (tool, result) => {
50912
50828
  if (typeof result === "string") {
@@ -50945,6 +50861,7 @@ class AgentBase {
50945
50861
  config;
50946
50862
  handlers;
50947
50863
  #policies;
50864
+ #toolSet;
50948
50865
  #messages = [];
50949
50866
  #aborted = false;
50950
50867
  #abortController;
@@ -50982,6 +50899,20 @@ ${instance.prompt}`;
50982
50899
  role: "system",
50983
50900
  content: this.config.systemPrompt
50984
50901
  });
50902
+ if (this.config.toolFormat === "native") {
50903
+ const tools = {};
50904
+ for (const tool of Object.values(this.handlers)) {
50905
+ const toolName = import_lodash.camelCase(tool.name);
50906
+ tools[toolName] = {
50907
+ description: tool.description,
50908
+ inputSchema: jsonSchema(toJSONSchema(tool.parameters))
50909
+ };
50910
+ this.handlers[toolName] = tool;
50911
+ }
50912
+ this.#toolSet = tools;
50913
+ } else {
50914
+ this.#toolSet = {};
50915
+ }
50985
50916
  }
50986
50917
  abort() {
50987
50918
  this.#aborted = true;
@@ -51009,13 +50940,19 @@ ${instance.prompt}`;
51009
50940
  if (this.#messages.length === 0) {
51010
50941
  this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
51011
50942
  }
51012
- return await this.#request(prompt);
50943
+ return await this.#request({
50944
+ role: "user",
50945
+ content: prompt
50946
+ });
51013
50947
  }
51014
50948
  async handleStepResponse(response) {
51015
50949
  return this.#handleResponse(response);
51016
50950
  }
51017
50951
  async#processLoop(userMessage) {
51018
- let nextRequest = userMessage;
50952
+ let nextRequest = {
50953
+ role: "user",
50954
+ content: userMessage
50955
+ };
51019
50956
  while (true) {
51020
50957
  if (this.#aborted) {
51021
50958
  return { type: "Aborted" };
@@ -51044,10 +50981,7 @@ ${instance.prompt}`;
51044
50981
  throw new Error("userMessage is missing");
51045
50982
  }
51046
50983
  await this.#callback({ kind: "StartRequest" /* StartRequest */, agent: this, userMessage });
51047
- this.#messages.push({
51048
- role: "user",
51049
- content: userMessage
51050
- });
50984
+ this.#messages.push(userMessage);
51051
50985
  for (const instance of this.#policies) {
51052
50986
  if (instance.onBeforeRequest) {
51053
50987
  await instance.onBeforeRequest(this);
@@ -51059,11 +50993,11 @@ ${instance.prompt}`;
51059
50993
  messages = await instance.prepareMessages(this, messages);
51060
50994
  }
51061
50995
  }
51062
- let currentAssistantMessage = "";
51063
50996
  const retryCount = this.config.retryCount ?? 5;
51064
- const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 10;
50997
+ const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 90;
50998
+ let respMessages = [];
51065
50999
  for (let i = 0;i < retryCount; i++) {
51066
- currentAssistantMessage = "";
51000
+ respMessages = [];
51067
51001
  let timeout;
51068
51002
  const resetTimeout = () => {
51069
51003
  if (timeout) {
@@ -51077,40 +51011,22 @@ ${instance.prompt}`;
51077
51011
  }
51078
51012
  };
51079
51013
  this.#abortController = new AbortController;
51080
- const providerOptions = {};
51081
- const thinkingBudgetTokens = this.config.parameters?.thinkingBudgetTokens;
51082
- const enableThinking = thinkingBudgetTokens > 0;
51083
- if (enableThinking) {
51084
- providerOptions.anthropic = {
51085
- thinking: { type: "enabled", budgetTokens: thinkingBudgetTokens }
51086
- };
51087
- providerOptions.openrouter = {
51088
- reasoning: {
51089
- max_tokens: thinkingBudgetTokens
51090
- }
51091
- };
51092
- providerOptions.google = {
51093
- thinkingConfig: {
51094
- includeThoughts: true,
51095
- thinkingBudget: thinkingBudgetTokens
51096
- }
51097
- };
51098
- }
51099
51014
  try {
51100
- const stream = streamText({
51015
+ const streamTextOptions = {
51101
51016
  model: this.ai,
51102
51017
  messages,
51103
- providerOptions,
51018
+ providerOptions: this.config.parameters?.providerOptions,
51104
51019
  onChunk: async ({ chunk }) => {
51105
51020
  resetTimeout();
51106
51021
  switch (chunk.type) {
51107
51022
  case "text":
51108
- currentAssistantMessage += chunk.text;
51109
51023
  await this.#callback({ kind: "Text" /* Text */, agent: this, newText: chunk.text });
51110
51024
  break;
51111
51025
  case "reasoning":
51112
51026
  await this.#callback({ kind: "Reasoning" /* Reasoning */, agent: this, newText: chunk.text });
51113
51027
  break;
51028
+ case "tool-call":
51029
+ break;
51114
51030
  }
51115
51031
  },
51116
51032
  onFinish: this.config.usageMeter.onFinishHandler(this.ai),
@@ -51118,8 +51034,18 @@ ${instance.prompt}`;
51118
51034
  console.error("Error in stream:", error81);
51119
51035
  },
51120
51036
  abortSignal: this.#abortController.signal
51037
+ };
51038
+ if (this.config.toolFormat === "native") {
51039
+ streamTextOptions.tools = this.#toolSet;
51040
+ }
51041
+ const stream = streamText(streamTextOptions);
51042
+ await stream.consumeStream({
51043
+ onError: (error81) => {
51044
+ console.error("Error in stream:", error81);
51045
+ }
51121
51046
  });
51122
- await stream.consumeStream();
51047
+ const resp = await stream.response;
51048
+ respMessages = resp.messages;
51123
51049
  } catch (error81) {
51124
51050
  if (error81 instanceof Error && error81.name === "AbortError") {
51125
51051
  break;
@@ -51130,7 +51056,7 @@ ${instance.prompt}`;
51130
51056
  clearTimeout(timeout);
51131
51057
  }
51132
51058
  }
51133
- if (currentAssistantMessage) {
51059
+ if (respMessages.length > 0) {
51134
51060
  break;
51135
51061
  }
51136
51062
  if (this.#aborted) {
@@ -51138,17 +51064,45 @@ ${instance.prompt}`;
51138
51064
  }
51139
51065
  console.debug(`Retrying request ${i + 1} of ${retryCount}`);
51140
51066
  }
51141
- if (!currentAssistantMessage) {
51067
+ if (respMessages.length === 0) {
51142
51068
  if (this.#aborted) {
51143
51069
  return [];
51144
51070
  }
51145
51071
  throw new Error("No assistant message received");
51146
51072
  }
51147
- console.log("Assistant message:", currentAssistantMessage);
51148
- this.#messages.push({
51149
- role: "assistant",
51150
- content: currentAssistantMessage
51151
- });
51073
+ this.#messages.push(...respMessages);
51074
+ if (this.config.toolFormat === "native") {
51075
+ return respMessages.flatMap((msg) => {
51076
+ if (msg.role === "assistant") {
51077
+ const content = msg.content;
51078
+ if (typeof content === "string") {
51079
+ return [{ type: "text", content }];
51080
+ }
51081
+ return content.flatMap((part) => {
51082
+ if (part.type === "text") {
51083
+ return [{ type: "text", content: part.text }];
51084
+ }
51085
+ if (part.type === "tool-call") {
51086
+ return [{ type: "tool_use", id: part.toolCallId, name: part.toolName, params: part.input }];
51087
+ }
51088
+ return [];
51089
+ });
51090
+ }
51091
+ return [];
51092
+ });
51093
+ }
51094
+ const currentAssistantMessage = respMessages.map((msg) => {
51095
+ if (typeof msg.content === "string") {
51096
+ return msg.content;
51097
+ }
51098
+ return msg.content.map((part) => {
51099
+ if (part.type === "text") {
51100
+ return part.text;
51101
+ }
51102
+ return "";
51103
+ });
51104
+ }).join(`
51105
+ `);
51152
51106
  const ret = parseAssistantMessage(currentAssistantMessage, this.config.tools.map(toToolInfoV1), this.config.toolNamePrefix);
51153
51107
  await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: currentAssistantMessage });
51154
51108
  return ret;
@@ -51162,12 +51116,12 @@ ${instance.prompt}`;
51162
51116
  case "text":
51163
51117
  break;
51164
51118
  case "tool_use": {
51165
- await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name });
51119
+ await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, content: content.params });
51166
51120
  const toolResp = await this.#invokeTool(content.name, content.params);
51167
51121
  switch (toolResp.type) {
51168
51122
  case "Reply" /* Reply */: {
51169
- await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
51170
- toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
51123
+ await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name, content: toolResp.message });
51124
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
51171
51125
  break;
51172
51126
  }
51173
51127
  case "Exit" /* Exit */:
@@ -51176,17 +51130,17 @@ ${instance.prompt}`;
51176
51130
  }
51177
51131
  return { type: "exit", reason: toolResp };
51178
51132
  case "Invalid" /* Invalid */: {
51179
- await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
51180
- toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
51133
+ await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
51134
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
51181
51135
  break outer;
51182
51136
  }
51183
51137
  case "Error" /* Error */: {
51184
- await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
51185
- toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
51138
+ await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
51139
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
51186
51140
  break outer;
51187
51141
  }
51188
51142
  case "Interrupted" /* Interrupted */:
51189
- await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
51143
+ await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
51190
51144
  return { type: "exit", reason: toolResp };
51191
51145
  case "HandOver" /* HandOver */: {
51192
51146
  if (toolResponses.length > 0) {
@@ -51220,7 +51174,7 @@ ${instance.prompt}`;
51220
51174
  }
51221
51175
  case "Pause" /* Pause */: {
51222
51176
  await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
51223
- toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object });
51177
+ toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object, id: content.id });
51224
51178
  hasPause = true;
51225
51179
  }
51226
51180
  }
@@ -51232,10 +51186,49 @@ ${instance.prompt}`;
51232
51186
  return { type: "exit", reason: { type: "Pause", responses: toolResponses } };
51233
51187
  }
51234
51188
  if (toolResponses.length === 0) {
51235
- return { type: "reply", message: responsePrompts.requireUseTool };
51189
+ return {
51190
+ type: "reply",
51191
+ message: {
51192
+ role: "user",
51193
+ content: responsePrompts.requireUseToolNative
51194
+ }
51195
+ };
51196
+ }
51197
+ if (this.config.toolFormat === "native") {
51198
+ const toolResults = toolResponses.filter((resp) => resp.type === "response").map((resp) => ({
51199
+ type: "tool-result",
51200
+ toolCallId: resp.id,
51201
+ toolName: resp.tool,
51202
+ output: {
51203
+ type: "text",
51204
+ value: resp.response
51205
+ }
51206
+ }));
51207
+ return {
51208
+ type: "reply",
51209
+ message: {
51210
+ role: "tool",
51211
+ content: toolResults
51212
+ }
51213
+ };
51214
+ }
51215
+ if (toolResponses.length === 0) {
51216
+ return {
51217
+ type: "reply",
51218
+ message: {
51219
+ role: "user",
51220
+ content: responsePrompts.requireUseTool
51221
+ }
51222
+ };
51236
51223
  }
51237
51224
  const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2));
51238
- return { type: "reply", message: finalResp };
51225
+ return {
51226
+ type: "reply",
51227
+ message: {
51228
+ role: "user",
51229
+ content: finalResp
51230
+ }
51231
+ };
51239
51232
  }
51240
51233
  async#invokeTool(name17, args) {
51241
51234
  try {
@@ -51276,6 +51269,80 @@ ${instance.prompt}`;
51276
51269
  }
51277
51270
  }
51278
51271
 
51272
+ // ../core/src/Agent/AnalyzerAgent/prompts.ts
51273
+ var fullSystemPrompt = (info, tools, toolNamePrefix, instructions, scripts, useNativeTool) => `
51274
+ # Analyzer Agent
51275
+
51276
+ ## Role
51277
+ You are the **Analyzer** agent, responsible for:
51278
+ 1. **Project Structure Analysis** – Understand codebase organization and architecture.
51279
+ 2. **Code Pattern Analysis** – Identify common patterns, conventions, and best practices.
51280
+ 3. **Dependency Analysis** – Examine project dependencies and their usage.
51281
+ 4. **Workflow Analysis** – Understand development tools, scripts, and processes.
51282
+ 5. **Documentation Review** – Analyze documentation and code comments.
51283
+
51284
+ > **Note**: The **Analyzer** agent focuses on understanding and analyzing the codebase without making modifications. Your role is to provide insights and understanding that can inform development decisions.
51285
+
51286
+ ## Rules
51287
+ 1. **Thoroughness**: Conduct comprehensive analysis of relevant project aspects.
51288
+ 2. **Pattern Recognition**: Identify recurring patterns, conventions, and architectural decisions.
51289
+ 3. **Dependency Mapping**: Track and understand relationships between components.
51290
+ 4. **Workflow Understanding**: Analyze build processes, testing approaches, and development tools.
51291
+ 5. **Documentation Assessment**: Review documentation quality and completeness.
51292
+ 6. **Non-Modification**: Never modify code or files - focus solely on analysis.
51293
+
51294
+ ${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
51295
+ ${capabilities(toolNamePrefix)}
51296
+ ${systemInformation(info)}
51297
+ ${customInstructions(instructions)}
51298
+ ${customScripts(scripts)}
51299
+ `;
51300
+
51301
+ // ../core/src/Agent/AnalyzerAgent/index.ts
51302
+ class AnalyzerAgent extends AgentBase {
51303
+ constructor(options) {
51304
+ const combinedTools = [...options.additionalTools ?? [], ...Object.values(exports_allTools)];
51305
+ const tools = getAvailableTools({
51306
+ provider: options.provider,
51307
+ allTools: combinedTools,
51308
+ hasAgent: (options.agents?.length ?? 0) > 0,
51309
+ permissionLevel: 1 /* Read */,
51310
+ interactive: true
51311
+ });
51312
+ const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
51313
+ const systemPrompt = fullSystemPrompt({
51314
+ os: options.os
51315
+ }, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.toolFormat === "native");
51316
+ super(analyzerAgentInfo.name, options.ai, {
51317
+ systemPrompt,
51318
+ tools,
51319
+ toolNamePrefix,
51320
+ provider: options.provider,
51321
+ interactive: options.interactive,
51322
+ agents: options.agents,
51323
+ scripts: options.scripts,
51324
+ callback: options.callback,
51325
+ policies: options.policies,
51326
+ toolFormat: options.toolFormat,
51327
+ parameters: options.parameters ?? {},
51328
+ usageMeter: options.usageMeter ?? new UsageMeter
51329
+ });
51330
+ }
51331
+ onBeforeInvokeTool() {
51332
+ return Promise.resolve(undefined);
51333
+ }
51334
+ }
51335
+ var analyzerAgentInfo = {
51336
+ name: "analyzer",
51337
+ responsibilities: [
51338
+ "Analyzing project structure and organization",
51339
+ "Identifying key source code files and their relationships",
51340
+ "Understanding common coding patterns and conventions",
51341
+ "Examining development workflow and tooling",
51342
+ "Analyzing dependencies and their usage patterns"
51343
+ ]
51344
+ };
51345
+
51279
51346
  // ../core/src/Agent/CodeFixerAgent/prompts.ts
51280
51347
  var basePrompt = `You are a highly skilled software engineer specializing in debugging and fixing code issues. You have extensive experience with:
51281
51348
  - Type systems and type checking
@@ -51365,10 +51432,10 @@ class CodeFixerAgent extends AgentBase {
51365
51432
  permissionLevel: 3 /* Arbitrary */,
51366
51433
  interactive: true
51367
51434
  });
51368
- const toolNamePrefix = "tool_";
51435
+ const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
51369
51436
  const systemPrompt = fullSystemPrompt3({
51370
51437
  os: options.os
51371
- }, tools.map(toToolInfoV1), toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.interactive, options.toolFormat === "native");
51438
+ }, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.interactive, options.toolFormat === "native");
51372
51439
  super(codeFixerAgentInfo.name, options.ai, {
51373
51440
  systemPrompt,
51374
51441
  tools,
@@ -51614,23 +51681,23 @@ var prompt = `You are an AiTool designed to assist users in creating new project
51614
51681
  - Create a .gitattributes file with appropriate configurations:
51615
51682
  - Mark lock files as generated and exclude them from diffs
51616
51683
  - Example for different package managers:
51617
-
51684
+
51618
51685
  # For Bun
51619
51686
  bun.lock linguist-generated=true
51620
51687
  bun.lock -diff
51621
-
51688
+
51622
51689
  # For npm
51623
51690
  package-lock.json linguist-generated=true
51624
51691
  package-lock.json -diff
51625
-
51692
+
51626
51693
  # For Yarn
51627
51694
  yarn.lock linguist-generated=true
51628
51695
  yarn.lock -diff
51629
-
51696
+
51630
51697
  # For pnpm
51631
51698
  pnpm-lock.yaml linguist-generated=true
51632
51699
  pnpm-lock.yaml -diff
51633
-
51700
+
51634
51701
  - Include other common configurations as needed based on project type
51635
51702
 
51636
51703
  6. **Handover to Coder Agent:**
@@ -51886,6 +51953,184 @@ var generateProjectConfig_default = {
51886
51953
  agent: "analyzer"
51887
51954
  };
51888
51955
 
51956
+ // ../core/src/AiTool/tools/gitDiff.ts
51957
+ var toolInfo14 = {
51958
+ name: "git_diff",
51959
+ description: "Get the git diff for the current repository. Can be used to get staged changes, unstaged changes, or changes between commits. By default, it returns unstaged changes.",
51960
+ parameters: exports_external.object({
51961
+ staged: exports_external.preprocess((val) => {
51962
+ if (typeof val === "string") {
51963
+ const lower = val.toLowerCase();
51964
+ if (lower === "false")
51965
+ return false;
51966
+ if (lower === "true")
51967
+ return true;
51968
+ }
51969
+ return val;
51970
+ }, exports_external.boolean().optional().default(false)).describe("Get staged changes instead of unstaged changes."),
51971
+ commitRange: exports_external.string().optional().describe('The commit range to get the diff for (e.g., "main...HEAD").'),
51972
+ file: exports_external.string().optional().describe("Get the diff for a specific file.")
51973
+ }),
51974
+ permissionLevel: 1 /* Read */
51975
+ };
51976
+ var handler14 = async (provider2, args) => {
51977
+ if (!provider2.executeCommand) {
51978
+ return {
51979
+ type: "Error" /* Error */,
51980
+ message: "Not possible to execute command. Abort."
51981
+ };
51982
+ }
51983
+ const { staged, file: file3, commitRange } = toolInfo14.parameters.parse(args);
51984
+ const commandParts = ["git", "diff", "--no-color"];
51985
+ if (staged) {
51986
+ commandParts.push("--staged");
51987
+ }
51988
+ if (commitRange) {
51989
+ commandParts.push(commitRange);
51990
+ }
51991
+ if (file3) {
51992
+ commandParts.push("--", file3);
51993
+ }
51994
+ const command = commandParts.join(" ");
51995
+ try {
51996
+ const result = await provider2.executeCommand(command, false);
51997
+ if (result.exitCode === 0) {
51998
+ if (!result.stdout.trim()) {
51999
+ return {
52000
+ type: "Reply" /* Reply */,
52001
+ message: "No diff found."
52002
+ };
52003
+ }
52004
+ return {
52005
+ type: "Reply" /* Reply */,
52006
+ message: `<diff file="${file3 ?? "all"}">
52007
+ ${result.stdout}
52008
+ </diff>`
52009
+ };
52010
+ }
52011
+ return {
52012
+ type: "Error" /* Error */,
52013
+ message: `\`${command}\` exited with code ${result.exitCode}:
52014
+ ${result.stderr}`
52015
+ };
52016
+ } catch (error81) {
52017
+ return {
52018
+ type: "Error" /* Error */,
52019
+ message: error81 instanceof Error ? error81.message : String(error81)
52020
+ };
52021
+ }
52022
+ };
52023
+ var isAvailable14 = (provider2) => {
52024
+ return !!provider2.executeCommand;
52025
+ };
52026
+ var gitDiff_default = {
52027
+ ...toolInfo14,
52028
+ handler: handler14,
52029
+ isAvailable: isAvailable14
52030
+ };
52031
+
52032
+ // ../core/src/AiTool/reviewDiff.ts
52033
+ var prompt5 = `
52034
+ # Code Review Prompt
52035
+
52036
+ You are a senior software engineer reviewing code changes.
52037
+
52038
+ ## Viewing Changes
52039
+ - Use **git_diff** to inspect code.
52040
+ - **Pull request**: use the provided commit range.
52041
+ - **Local changes**: diff staged or unstaged files.
52042
+ - If a pull request is present you may receive:
52043
+ - <pr_title>
52044
+ - <pr_description>
52045
+ - <commit_messages>
52046
+ - A <review_instructions> tag tells you the focus of the review.
52047
+
52048
+ ## Focus Areas
52049
+ - Readability and maintainability
52050
+ - Correctness, edge cases, potential bugs
52051
+ - Performance implications
52052
+ - Clarity of intent
52053
+ - Best-practice adherence
52054
+
52055
+ ## Output Format
52056
+ Do **not** include praise or positive feedback. Ignore generated files such as lock files.
52057
+
52058
+ Return your review as a JSON object inside a \`\`\`json block, wrapped like:
52059
+ <tool_attempt_completion>
52060
+ <tool_parameter_result>
52061
+ \`\`\`json
52062
+ {
52063
+ "overview": "Summary of overall concerns.",
52064
+ "specificReviews": [
52065
+ {
52066
+ "file": "path/filename.ext",
52067
+ "lines": "N or N-M",
52068
+ "review": "Describe the issue and actionable fix or improvement."
52069
+ }
52070
+ ]
52071
+ }
52072
+ \`\`\`
52073
+ </tool_parameter_result>
52074
+ </tool_attempt_completion>
52075
+ `;
52076
+ var reviewDiff_default = {
52077
+ name: "reviewDiff",
52078
+ description: "Reviews a git diff",
52079
+ prompt: prompt5,
52080
+ formatInput: (params) => {
52081
+ const parts = [];
52082
+ if (params.pullRequestTitle) {
52083
+ parts.push(`<pr_title>
52084
+ ${params.pullRequestTitle}
52085
+ </pr_title>`);
52086
+ }
52087
+ if (params.pullRequestDescription) {
52088
+ parts.push(`<pr_description>
52089
+ ${params.pullRequestDescription}
52090
+ </pr_description>`);
52091
+ }
52092
+ if (params.commitMessages) {
52093
+ parts.push(`<commit_messages>
52094
+ ${params.commitMessages}
52095
+ </commit_messages>`);
52096
+ }
52097
+ let instructions = "";
52098
+ if (params.commitRange) {
52099
+ instructions = `Review the pull request. Get the diff using the git_diff tool with the commit range '${params.commitRange}'.`;
52100
+ } else if (params.staged) {
52101
+ instructions = "Review the staged changes. Get the diff using the git_diff tool with staged: true.";
52102
+ } else {
52103
+ instructions = "Review the unstaged changes. Get the diff using the git_diff tool.";
52104
+ }
52105
+ parts.push(`<review_instructions>
52106
+ ${instructions}
52107
+ </review_instructions>`);
52108
+ return parts.join(`
52109
+ `);
52110
+ },
52111
+ parseOutput: (output) => {
52112
+ const jsonBlockRegex = /```json\n([\s\S]*?)\n```/;
52113
+ const match = output.match(jsonBlockRegex);
52114
+ const content = match ? match[1] : output;
52115
+ try {
52116
+ return JSON.parse(content);
52117
+ } catch (error81) {
52118
+ console.error("Error parsing JSON output:", error81);
52119
+ return {
52120
+ overview: `Could not parse review output. Raw output:
52121
+ ${output}`,
52122
+ specificReviews: []
52123
+ };
52124
+ }
52125
+ },
52126
+ agent: (options) => {
52127
+ return new AnalyzerAgent({
52128
+ ...options,
52129
+ additionalTools: [gitDiff_default]
52130
+ });
52131
+ }
52132
+ };
52133
+
51889
52134
  // ../core/src/AiTool/index.ts
51890
52135
  var executeTool = async (definition, ai, params, usageMeter) => {
51891
52136
  const resp = await generateText({
@@ -51901,10 +52146,7 @@ var executeTool = async (definition, ai, params, usageMeter) => {
51901
52146
  usageMeter.addUsage(ai, resp);
51902
52147
  return definition.parseOutput(resp.text);
51903
52148
  };
51904
- var executeAgentTool = async (definition, agent, params) => {
51905
- if (!definition.agent) {
51906
- throw new Error("Agent not specified");
51907
- }
52149
+ var executeMultiAgentTool = async (definition, agent, params) => {
51908
52150
  const exitReason = await agent.startTask({
51909
52151
  agentName: definition.agent,
51910
52152
  task: definition.prompt,
@@ -51915,22 +52157,38 @@ var executeAgentTool = async (definition, agent, params) => {
51915
52157
  }
51916
52158
  throw new Error(`Tool execution failed: ${exitReason.type}`);
51917
52159
  };
52160
+ var executeAgentTool = async (definition, options, params) => {
52161
+ const agent = definition.agent(options);
52162
+ const exitReason = await agent.start(`${definition.prompt}
52163
+
52164
+ ${definition.formatInput(params)}`);
52165
+ if (exitReason.type === "Exit" /* Exit */) {
52166
+ return definition.parseOutput(exitReason.message);
52167
+ }
52168
+ throw new Error(`Tool execution failed: ${exitReason.type}`);
52169
+ };
51918
52170
  var makeTool = (definition) => {
51919
52171
  return async (ai, params, usageMeter) => {
51920
52172
  return executeTool(definition, ai, params, usageMeter);
51921
52173
  };
51922
52174
  };
51923
- var makeAgentTool = (definition) => {
52175
+ var makeMultiAgentTool = (definition) => {
51924
52176
  return async (agent, params) => {
51925
- return executeAgentTool(definition, agent, params);
52177
+ return executeMultiAgentTool(definition, agent, params);
52178
+ };
52179
+ };
52180
+ var makeAgentTool = (definition) => {
52181
+ return async (options, params) => {
52182
+ return executeAgentTool(definition, options, params);
51926
52183
  };
51927
52184
  };
51928
52185
  var generateGitCommitMessage = makeTool(generateGitCommitMessage_default);
51929
52186
  var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails_default);
51930
- var generateProjectConfig = makeAgentTool(generateProjectConfig_default);
51931
- var createNewProject = makeAgentTool(createNewProject_default);
52187
+ var reviewDiff = makeAgentTool(reviewDiff_default);
52188
+ var generateProjectConfig = makeMultiAgentTool(generateProjectConfig_default);
52189
+ var createNewProject = makeMultiAgentTool(createNewProject_default);
51932
52190
  // src/config.ts
51933
- var import_lodash = __toESM(require_lodash(), 1);
52191
+ var import_lodash2 = __toESM(require_lodash(), 1);
51934
52192
 
51935
52193
  // node_modules/yaml/dist/index.js
51936
52194
  var composer = require_composer();
@@ -55841,7 +56099,7 @@ function mergeConfigs(configs) {
55841
56099
  return {};
55842
56100
  }
55843
56101
  const mergedConfig = configs.reduce((acc, config4) => {
55844
- const merged = import_lodash.merge({}, acc, config4);
56102
+ const merged = import_lodash2.merge({}, acc, config4);
55845
56103
  let accRules = acc.rules ?? [];
55846
56104
  if (typeof accRules === "string") {
55847
56105
  accRules = [accRules];
@@ -56472,15 +56730,15 @@ function useKeypress(userHandler) {
56472
56730
  signal.current = userHandler;
56473
56731
  useEffect((rl) => {
56474
56732
  let ignore = false;
56475
- const handler14 = withUpdates((_input, event) => {
56733
+ const handler15 = withUpdates((_input, event) => {
56476
56734
  if (ignore)
56477
56735
  return;
56478
56736
  signal.current(event, rl);
56479
56737
  });
56480
- rl.input.on("keypress", handler14);
56738
+ rl.input.on("keypress", handler15);
56481
56739
  return () => {
56482
56740
  ignore = true;
56483
- rl.input.removeListener("keypress", handler14);
56741
+ rl.input.removeListener("keypress", handler15);
56484
56742
  };
56485
56743
  }, []);
56486
56744
  }
@@ -56639,16 +56897,16 @@ class Emitter {
56639
56897
 
56640
56898
  class SignalExitBase {
56641
56899
  }
56642
- var signalExitWrap = (handler14) => {
56900
+ var signalExitWrap = (handler15) => {
56643
56901
  return {
56644
56902
  onExit(cb, opts) {
56645
- return handler14.onExit(cb, opts);
56903
+ return handler15.onExit(cb, opts);
56646
56904
  },
56647
56905
  load() {
56648
- return handler14.load();
56906
+ return handler15.load();
56649
56907
  },
56650
56908
  unload() {
56651
- return handler14.unload();
56909
+ return handler15.unload();
56652
56910
  }
56653
56911
  };
56654
56912
  };
@@ -56804,11 +57062,11 @@ class ScreenManager {
56804
57062
  render(content, bottomContent = "") {
56805
57063
  const promptLine = lastLine(content);
56806
57064
  const rawPromptLine = stripVTControlCharacters(promptLine);
56807
- let prompt5 = rawPromptLine;
57065
+ let prompt6 = rawPromptLine;
56808
57066
  if (this.rl.line.length > 0) {
56809
- prompt5 = prompt5.slice(0, -this.rl.line.length);
57067
+ prompt6 = prompt6.slice(0, -this.rl.line.length);
56810
57068
  }
56811
- this.rl.setPrompt(prompt5);
57069
+ this.rl.setPrompt(prompt6);
56812
57070
  this.cursorPos = this.rl.getCursorPos();
56813
57071
  const width = readlineWidth();
56814
57072
  content = breakLines(content, width);
@@ -56878,7 +57136,7 @@ function getCallSites() {
56878
57136
  }
56879
57137
  function createPrompt(view) {
56880
57138
  const callSites = getCallSites();
56881
- const prompt5 = (config4, context = {}) => {
57139
+ const prompt6 = (config4, context = {}) => {
56882
57140
  const { input = process.stdin, signal } = context;
56883
57141
  const cleanups = new Set;
56884
57142
  const output = new import_mute_stream.default;
@@ -56943,7 +57201,7 @@ function createPrompt(view) {
56943
57201
  }).then(() => promise4), { cancel });
56944
57202
  });
56945
57203
  };
56946
- return prompt5;
57204
+ return prompt6;
56947
57205
  }
56948
57206
  // ../../node_modules/@inquirer/core/dist/esm/lib/Separator.js
56949
57207
  var import_yoctocolors_cjs2 = __toESM(require_yoctocolors_cjs(), 1);
@@ -57970,7 +58228,7 @@ ${event.systemPrompt}`);
57970
58228
  ======== New Request ========
57971
58229
  `);
57972
58230
  if (verbose) {
57973
- const { userMessage } = event;
58231
+ const userMessage = event.userMessage.content;
57974
58232
  if (typeof userMessage === "string") {
57975
58233
  console.log(userMessage);
57976
58234
  } else {
@@ -57989,9 +58247,17 @@ ${event.systemPrompt}`);
57989
58247
  case "file":
57990
58248
  console.log(source_default.yellow(`[File name: ${content.filename}, type: ${content.mediaType}]`));
57991
58249
  break;
57992
- default:
57993
- console.log(source_default.red("[Unknown content type]"));
57994
- console.log(content);
58250
+ case "tool-call":
58251
+ console.log(source_default.yellow(`[Tool call: ${content.toolName}]`));
58252
+ break;
58253
+ case "tool-result":
58254
+ console.log(source_default.yellow(`[Tool result: ${content.toolName}]`));
58255
+ if (verbose > 0) {
58256
+ console.log(content.output);
58257
+ }
58258
+ break;
58259
+ case "reasoning":
58260
+ break;
57995
58261
  }
57996
58262
  }
57997
58263
  }
@@ -58025,29 +58291,33 @@ ${event.systemPrompt}`);
58025
58291
  process.stdout.write(source_default.dim(event.newText));
58026
58292
  hadReasoning = true;
58027
58293
  break;
58028
- case "ToolUse" /* ToolUse */:
58029
- {
58030
- const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
58031
- stats.calls++;
58032
- toolCallStats.set(event.tool, stats);
58033
- }
58294
+ case "ToolUse" /* ToolUse */: {
58295
+ console.log(source_default.yellow(`
58296
+
58297
+ Tool use:`, event.tool), event.content);
58298
+ const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
58299
+ stats.calls++;
58300
+ toolCallStats.set(event.tool, stats);
58034
58301
  break;
58035
- case "ToolReply" /* ToolReply */:
58036
- {
58037
- const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
58038
- stats.success++;
58039
- toolCallStats.set(event.tool, stats);
58040
- }
58302
+ }
58303
+ case "ToolReply" /* ToolReply */: {
58304
+ const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
58305
+ stats.success++;
58306
+ toolCallStats.set(event.tool, stats);
58041
58307
  break;
58308
+ }
58042
58309
  case "ToolInvalid" /* ToolInvalid */:
58043
58310
  break;
58044
- case "ToolError" /* ToolError */:
58045
- {
58046
- const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
58047
- stats.errors++;
58048
- toolCallStats.set(event.tool, stats);
58049
- }
58311
+ case "ToolError" /* ToolError */: {
58312
+ console.error(source_default.red(`
58313
+
58314
+ Tool error:`, event.tool));
58315
+ console.error(source_default.red(event.content));
58316
+ const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
58317
+ stats.errors++;
58318
+ toolCallStats.set(event.tool, stats);
58050
58319
  break;
58320
+ }
58051
58321
  case "ToolInterrupted" /* ToolInterrupted */:
58052
58322
  break;
58053
58323
  case "ToolHandOver" /* ToolHandOver */: