@polka-codes/cli-shared 0.9.2 → 0.9.4

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 +729 -425
  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,96 +50993,132 @@ ${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
+ if (this.#aborted) {
51001
+ break;
51002
+ }
51003
+ respMessages = [];
51067
51004
  let timeout;
51005
+ let requestAbortController;
51006
+ requestAbortController = new AbortController;
51007
+ this.#abortController = requestAbortController;
51068
51008
  const resetTimeout = () => {
51069
51009
  if (timeout) {
51070
51010
  clearTimeout(timeout);
51071
51011
  }
51072
- if (requestTimeoutSeconds > 0) {
51012
+ if (requestTimeoutSeconds > 0 && requestAbortController) {
51073
51013
  timeout = setTimeout(() => {
51074
- console.debug(`No data received for ${requestTimeoutSeconds} seconds. Aborting request.`);
51075
- this.abort();
51014
+ console.debug(`Request timeout after ${requestTimeoutSeconds} seconds. Canceling current request attempt ${i + 1}/${retryCount}.`);
51015
+ requestAbortController?.abort();
51076
51016
  }, requestTimeoutSeconds * 1000);
51077
51017
  }
51078
51018
  };
51079
- 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
51019
  try {
51100
- const stream = streamText({
51020
+ resetTimeout();
51021
+ const streamTextOptions = {
51101
51022
  model: this.ai,
51102
51023
  messages,
51103
- providerOptions,
51024
+ providerOptions: this.config.parameters?.providerOptions,
51104
51025
  onChunk: async ({ chunk }) => {
51105
51026
  resetTimeout();
51106
51027
  switch (chunk.type) {
51107
51028
  case "text":
51108
- currentAssistantMessage += chunk.text;
51109
51029
  await this.#callback({ kind: "Text" /* Text */, agent: this, newText: chunk.text });
51110
51030
  break;
51111
51031
  case "reasoning":
51112
51032
  await this.#callback({ kind: "Reasoning" /* Reasoning */, agent: this, newText: chunk.text });
51113
51033
  break;
51034
+ case "tool-call":
51035
+ break;
51114
51036
  }
51115
51037
  },
51116
51038
  onFinish: this.config.usageMeter.onFinishHandler(this.ai),
51117
51039
  onError: async (error81) => {
51118
51040
  console.error("Error in stream:", error81);
51119
51041
  },
51120
- abortSignal: this.#abortController.signal
51042
+ abortSignal: requestAbortController.signal
51043
+ };
51044
+ if (this.config.toolFormat === "native") {
51045
+ streamTextOptions.tools = this.#toolSet;
51046
+ }
51047
+ const stream = streamText(streamTextOptions);
51048
+ await stream.consumeStream({
51049
+ onError: (error81) => {
51050
+ console.error("Error in stream:", error81);
51051
+ }
51121
51052
  });
51122
- await stream.consumeStream();
51053
+ const resp = await stream.response;
51054
+ respMessages = resp.messages;
51055
+ if (timeout) {
51056
+ clearTimeout(timeout);
51057
+ timeout = undefined;
51058
+ }
51123
51059
  } catch (error81) {
51124
51060
  if (error81 instanceof Error && error81.name === "AbortError") {
51125
- break;
51061
+ if (this.#aborted) {
51062
+ break;
51063
+ }
51064
+ console.debug(`Request attempt ${i + 1} timed out, will retry`);
51065
+ } else {
51066
+ console.error("Error in stream:", error81);
51126
51067
  }
51127
- console.error("Error in stream:", error81);
51128
51068
  } finally {
51129
51069
  if (timeout) {
51130
51070
  clearTimeout(timeout);
51131
51071
  }
51132
51072
  }
51133
- if (currentAssistantMessage) {
51073
+ if (respMessages.length > 0) {
51134
51074
  break;
51135
51075
  }
51136
51076
  if (this.#aborted) {
51137
51077
  break;
51138
51078
  }
51139
- console.debug(`Retrying request ${i + 1} of ${retryCount}`);
51079
+ if (i < retryCount - 1) {
51080
+ console.debug(`Retrying request ${i + 2} of ${retryCount}`);
51081
+ }
51140
51082
  }
51141
- if (!currentAssistantMessage) {
51083
+ if (respMessages.length === 0) {
51142
51084
  if (this.#aborted) {
51143
51085
  return [];
51144
51086
  }
51145
- throw new Error("No assistant message received");
51087
+ throw new Error("No assistant message received after all retry attempts");
51146
51088
  }
51147
- console.log("Assistant message:", currentAssistantMessage);
51148
- this.#messages.push({
51149
- role: "assistant",
51150
- content: currentAssistantMessage
51151
- });
51089
+ this.#messages.push(...respMessages);
51090
+ if (this.config.toolFormat === "native") {
51091
+ return respMessages.flatMap((msg) => {
51092
+ if (msg.role === "assistant") {
51093
+ const content = msg.content;
51094
+ if (typeof content === "string") {
51095
+ return [{ type: "text", content }];
51096
+ }
51097
+ return content.flatMap((part) => {
51098
+ if (part.type === "text" || part.type === "reasoning") {
51099
+ return [{ type: "text", content: part.text }];
51100
+ }
51101
+ if (part.type === "tool-call") {
51102
+ return [{ type: "tool_use", id: part.toolCallId, name: part.toolName, params: part.input }];
51103
+ }
51104
+ return [];
51105
+ });
51106
+ }
51107
+ return [];
51108
+ });
51109
+ }
51110
+ const currentAssistantMessage = respMessages.map((msg) => {
51111
+ if (typeof msg.content === "string") {
51112
+ return msg.content;
51113
+ }
51114
+ return msg.content.map((part) => {
51115
+ if (part.type === "text") {
51116
+ return part.text;
51117
+ }
51118
+ return "";
51119
+ });
51120
+ }).join(`
51121
+ `);
51152
51122
  const ret = parseAssistantMessage(currentAssistantMessage, this.config.tools.map(toToolInfoV1), this.config.toolNamePrefix);
51153
51123
  await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: currentAssistantMessage });
51154
51124
  return ret;
@@ -51162,12 +51132,12 @@ ${instance.prompt}`;
51162
51132
  case "text":
51163
51133
  break;
51164
51134
  case "tool_use": {
51165
- await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name });
51135
+ await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, content: content.params });
51166
51136
  const toolResp = await this.#invokeTool(content.name, content.params);
51167
51137
  switch (toolResp.type) {
51168
51138
  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 });
51139
+ await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name, content: toolResp.message });
51140
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
51171
51141
  break;
51172
51142
  }
51173
51143
  case "Exit" /* Exit */:
@@ -51176,17 +51146,17 @@ ${instance.prompt}`;
51176
51146
  }
51177
51147
  return { type: "exit", reason: toolResp };
51178
51148
  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 });
51149
+ await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
51150
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
51181
51151
  break outer;
51182
51152
  }
51183
51153
  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 });
51154
+ await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
51155
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
51186
51156
  break outer;
51187
51157
  }
51188
51158
  case "Interrupted" /* Interrupted */:
51189
- await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
51159
+ await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
51190
51160
  return { type: "exit", reason: toolResp };
51191
51161
  case "HandOver" /* HandOver */: {
51192
51162
  if (toolResponses.length > 0) {
@@ -51220,7 +51190,7 @@ ${instance.prompt}`;
51220
51190
  }
51221
51191
  case "Pause" /* Pause */: {
51222
51192
  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 });
51193
+ toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object, id: content.id });
51224
51194
  hasPause = true;
51225
51195
  }
51226
51196
  }
@@ -51232,10 +51202,49 @@ ${instance.prompt}`;
51232
51202
  return { type: "exit", reason: { type: "Pause", responses: toolResponses } };
51233
51203
  }
51234
51204
  if (toolResponses.length === 0) {
51235
- return { type: "reply", message: responsePrompts.requireUseTool };
51205
+ return {
51206
+ type: "reply",
51207
+ message: {
51208
+ role: "user",
51209
+ content: responsePrompts.requireUseToolNative
51210
+ }
51211
+ };
51212
+ }
51213
+ if (this.config.toolFormat === "native") {
51214
+ const toolResults = toolResponses.filter((resp) => resp.type === "response").map((resp) => ({
51215
+ type: "tool-result",
51216
+ toolCallId: resp.id,
51217
+ toolName: resp.tool,
51218
+ output: {
51219
+ type: "text",
51220
+ value: resp.response
51221
+ }
51222
+ }));
51223
+ return {
51224
+ type: "reply",
51225
+ message: {
51226
+ role: "tool",
51227
+ content: toolResults
51228
+ }
51229
+ };
51230
+ }
51231
+ if (toolResponses.length === 0) {
51232
+ return {
51233
+ type: "reply",
51234
+ message: {
51235
+ role: "user",
51236
+ content: responsePrompts.requireUseTool
51237
+ }
51238
+ };
51236
51239
  }
51237
51240
  const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2));
51238
- return { type: "reply", message: finalResp };
51241
+ return {
51242
+ type: "reply",
51243
+ message: {
51244
+ role: "user",
51245
+ content: finalResp
51246
+ }
51247
+ };
51239
51248
  }
51240
51249
  async#invokeTool(name17, args) {
51241
51250
  try {
@@ -51276,6 +51285,80 @@ ${instance.prompt}`;
51276
51285
  }
51277
51286
  }
51278
51287
 
51288
+ // ../core/src/Agent/AnalyzerAgent/prompts.ts
51289
+ var fullSystemPrompt = (info, tools, toolNamePrefix, instructions, scripts, useNativeTool) => `
51290
+ # Analyzer Agent
51291
+
51292
+ ## Role
51293
+ You are the **Analyzer** agent, responsible for:
51294
+ 1. **Project Structure Analysis** – Understand codebase organization and architecture.
51295
+ 2. **Code Pattern Analysis** – Identify common patterns, conventions, and best practices.
51296
+ 3. **Dependency Analysis** – Examine project dependencies and their usage.
51297
+ 4. **Workflow Analysis** – Understand development tools, scripts, and processes.
51298
+ 5. **Documentation Review** – Analyze documentation and code comments.
51299
+
51300
+ > **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.
51301
+
51302
+ ## Rules
51303
+ 1. **Thoroughness**: Conduct comprehensive analysis of relevant project aspects.
51304
+ 2. **Pattern Recognition**: Identify recurring patterns, conventions, and architectural decisions.
51305
+ 3. **Dependency Mapping**: Track and understand relationships between components.
51306
+ 4. **Workflow Understanding**: Analyze build processes, testing approaches, and development tools.
51307
+ 5. **Documentation Assessment**: Review documentation quality and completeness.
51308
+ 6. **Non-Modification**: Never modify code or files - focus solely on analysis.
51309
+
51310
+ ${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
51311
+ ${capabilities(toolNamePrefix)}
51312
+ ${systemInformation(info)}
51313
+ ${customInstructions(instructions)}
51314
+ ${customScripts(scripts)}
51315
+ `;
51316
+
51317
+ // ../core/src/Agent/AnalyzerAgent/index.ts
51318
+ class AnalyzerAgent extends AgentBase {
51319
+ constructor(options) {
51320
+ const combinedTools = [...options.additionalTools ?? [], ...Object.values(exports_allTools)];
51321
+ const tools = getAvailableTools({
51322
+ provider: options.provider,
51323
+ allTools: combinedTools,
51324
+ hasAgent: (options.agents?.length ?? 0) > 0,
51325
+ permissionLevel: 1 /* Read */,
51326
+ interactive: true
51327
+ });
51328
+ const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
51329
+ const systemPrompt = fullSystemPrompt({
51330
+ os: options.os
51331
+ }, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.toolFormat === "native");
51332
+ super(analyzerAgentInfo.name, options.ai, {
51333
+ systemPrompt,
51334
+ tools,
51335
+ toolNamePrefix,
51336
+ provider: options.provider,
51337
+ interactive: options.interactive,
51338
+ agents: options.agents,
51339
+ scripts: options.scripts,
51340
+ callback: options.callback,
51341
+ policies: options.policies,
51342
+ toolFormat: options.toolFormat,
51343
+ parameters: options.parameters ?? {},
51344
+ usageMeter: options.usageMeter ?? new UsageMeter
51345
+ });
51346
+ }
51347
+ onBeforeInvokeTool() {
51348
+ return Promise.resolve(undefined);
51349
+ }
51350
+ }
51351
+ var analyzerAgentInfo = {
51352
+ name: "analyzer",
51353
+ responsibilities: [
51354
+ "Analyzing project structure and organization",
51355
+ "Identifying key source code files and their relationships",
51356
+ "Understanding common coding patterns and conventions",
51357
+ "Examining development workflow and tooling",
51358
+ "Analyzing dependencies and their usage patterns"
51359
+ ]
51360
+ };
51361
+
51279
51362
  // ../core/src/Agent/CodeFixerAgent/prompts.ts
51280
51363
  var basePrompt = `You are a highly skilled software engineer specializing in debugging and fixing code issues. You have extensive experience with:
51281
51364
  - Type systems and type checking
@@ -51365,10 +51448,10 @@ class CodeFixerAgent extends AgentBase {
51365
51448
  permissionLevel: 3 /* Arbitrary */,
51366
51449
  interactive: true
51367
51450
  });
51368
- const toolNamePrefix = "tool_";
51451
+ const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
51369
51452
  const systemPrompt = fullSystemPrompt3({
51370
51453
  os: options.os
51371
- }, tools.map(toToolInfoV1), toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.interactive, options.toolFormat === "native");
51454
+ }, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.interactive, options.toolFormat === "native");
51372
51455
  super(codeFixerAgentInfo.name, options.ai, {
51373
51456
  systemPrompt,
51374
51457
  tools,
@@ -51614,23 +51697,23 @@ var prompt = `You are an AiTool designed to assist users in creating new project
51614
51697
  - Create a .gitattributes file with appropriate configurations:
51615
51698
  - Mark lock files as generated and exclude them from diffs
51616
51699
  - Example for different package managers:
51617
-
51700
+
51618
51701
  # For Bun
51619
51702
  bun.lock linguist-generated=true
51620
51703
  bun.lock -diff
51621
-
51704
+
51622
51705
  # For npm
51623
51706
  package-lock.json linguist-generated=true
51624
51707
  package-lock.json -diff
51625
-
51708
+
51626
51709
  # For Yarn
51627
51710
  yarn.lock linguist-generated=true
51628
51711
  yarn.lock -diff
51629
-
51712
+
51630
51713
  # For pnpm
51631
51714
  pnpm-lock.yaml linguist-generated=true
51632
51715
  pnpm-lock.yaml -diff
51633
-
51716
+
51634
51717
  - Include other common configurations as needed based on project type
51635
51718
 
51636
51719
  6. **Handover to Coder Agent:**
@@ -51886,6 +51969,202 @@ var generateProjectConfig_default = {
51886
51969
  agent: "analyzer"
51887
51970
  };
51888
51971
 
51972
+ // ../core/src/AiTool/tools/gitDiff.ts
51973
+ var toolInfo14 = {
51974
+ name: "git_diff",
51975
+ 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.",
51976
+ parameters: exports_external.object({
51977
+ staged: exports_external.preprocess((val) => {
51978
+ if (typeof val === "string") {
51979
+ const lower = val.toLowerCase();
51980
+ if (lower === "false")
51981
+ return false;
51982
+ if (lower === "true")
51983
+ return true;
51984
+ }
51985
+ return val;
51986
+ }, exports_external.boolean().optional().default(false)).describe("Get staged changes instead of unstaged changes."),
51987
+ commitRange: exports_external.string().optional().describe('The commit range to get the diff for (e.g., "main...HEAD").'),
51988
+ file: exports_external.string().optional().describe("Get the diff for a specific file.")
51989
+ }),
51990
+ permissionLevel: 1 /* Read */
51991
+ };
51992
+ var handler14 = async (provider2, args) => {
51993
+ if (!provider2.executeCommand) {
51994
+ return {
51995
+ type: "Error" /* Error */,
51996
+ message: "Not possible to execute command. Abort."
51997
+ };
51998
+ }
51999
+ const { staged, file: file3, commitRange } = toolInfo14.parameters.parse(args);
52000
+ const commandParts = ["git", "diff", "--no-color"];
52001
+ if (staged) {
52002
+ commandParts.push("--staged");
52003
+ }
52004
+ if (commitRange) {
52005
+ commandParts.push(commitRange);
52006
+ }
52007
+ if (file3) {
52008
+ commandParts.push("--", file3);
52009
+ }
52010
+ const command = commandParts.join(" ");
52011
+ try {
52012
+ const result = await provider2.executeCommand(command, false);
52013
+ if (result.exitCode === 0) {
52014
+ if (!result.stdout.trim()) {
52015
+ return {
52016
+ type: "Reply" /* Reply */,
52017
+ message: "No diff found."
52018
+ };
52019
+ }
52020
+ return {
52021
+ type: "Reply" /* Reply */,
52022
+ message: `<diff file="${file3 ?? "all"}">
52023
+ ${result.stdout}
52024
+ </diff>`
52025
+ };
52026
+ }
52027
+ return {
52028
+ type: "Error" /* Error */,
52029
+ message: `\`${command}\` exited with code ${result.exitCode}:
52030
+ ${result.stderr}`
52031
+ };
52032
+ } catch (error81) {
52033
+ return {
52034
+ type: "Error" /* Error */,
52035
+ message: error81 instanceof Error ? error81.message : String(error81)
52036
+ };
52037
+ }
52038
+ };
52039
+ var isAvailable14 = (provider2) => {
52040
+ return !!provider2.executeCommand;
52041
+ };
52042
+ var gitDiff_default = {
52043
+ ...toolInfo14,
52044
+ handler: handler14,
52045
+ isAvailable: isAvailable14
52046
+ };
52047
+
52048
+ // ../core/src/AiTool/reviewDiff.ts
52049
+ var prompt5 = `
52050
+ # Code Review Prompt
52051
+
52052
+ You are a senior software engineer reviewing code changes.
52053
+
52054
+ ## Critical Instructions
52055
+ **ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.
52056
+
52057
+ ## Viewing Changes
52058
+ - **Use git_diff** to inspect the actual code changes for each relevant file.
52059
+ - **Pull request**: use the provided commit range for the git_diff tool.
52060
+ - **Local changes**: diff staged or unstaged files using the git_diff tool.
52061
+ - If a pull request is present you may receive:
52062
+ - <pr_title>
52063
+ - <pr_description>
52064
+ - <commit_messages>
52065
+ - A <review_instructions> tag tells you the focus of the review.
52066
+ - File status information is provided in <file_status> - use this to understand which files were modified, added, deleted, or renamed.
52067
+
52068
+ ## Review Guidelines
52069
+ Focus exclusively on the changed lines (+ additions, - deletions, modified lines):
52070
+ - **Specific issues**: Point to exact problems in the changed code with line references
52071
+ - **Actionable fixes**: Provide concrete solutions, not vague suggestions
52072
+ - **Clear reasoning**: Explain why each issue matters and how to fix it
52073
+ - **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
52074
+
52075
+ ## What NOT to review
52076
+ - Existing unchanged code
52077
+ - Overall project structure or architecture (unless directly impacted by changes)
52078
+ - Generic best practices unrelated to the specific changes
52079
+ - Missing features or functionality not part of this diff
52080
+
52081
+ ## Output Format
52082
+ Do **not** include praise or positive feedback. Ignore generated files such as lock files.
52083
+ Only include reviews for actual issues found in the changed code.
52084
+
52085
+ Return your review as a JSON object inside a \`\`\`json block, wrapped like:
52086
+ <tool_attempt_completion>
52087
+ <tool_parameter_result>
52088
+ \`\`\`json
52089
+ {
52090
+ "overview": "Summary of specific issues found in the diff changes, or 'No issues found' if the changes look good.",
52091
+ "specificReviews": [
52092
+ {
52093
+ "file": "path/filename.ext",
52094
+ "lines": "N or N-M",
52095
+ "review": "Specific issue with the changed code and exact actionable fix."
52096
+ }
52097
+ ]
52098
+ }
52099
+ \`\`\`
52100
+ </tool_parameter_result>
52101
+ </tool_attempt_completion>
52102
+ `;
52103
+ var reviewDiff_default = {
52104
+ name: "reviewDiff",
52105
+ description: "Reviews a git diff",
52106
+ prompt: prompt5,
52107
+ formatInput: (params) => {
52108
+ const parts = [];
52109
+ if (params.pullRequestTitle) {
52110
+ parts.push(`<pr_title>
52111
+ ${params.pullRequestTitle}
52112
+ </pr_title>`);
52113
+ }
52114
+ if (params.pullRequestDescription) {
52115
+ parts.push(`<pr_description>
52116
+ ${params.pullRequestDescription}
52117
+ </pr_description>`);
52118
+ }
52119
+ if (params.commitMessages) {
52120
+ parts.push(`<commit_messages>
52121
+ ${params.commitMessages}
52122
+ </commit_messages>`);
52123
+ }
52124
+ if (params.changedFiles && params.changedFiles.length > 0) {
52125
+ const fileList = params.changedFiles.map((file3) => `${file3.status}: ${file3.path}`).join(`
52126
+ `);
52127
+ parts.push(`<file_status>
52128
+ ${fileList}
52129
+ </file_status>`);
52130
+ }
52131
+ let instructions = "";
52132
+ if (params.commitRange) {
52133
+ instructions = `Review the pull request. Use the git_diff tool with commit range '${params.commitRange}' to inspect the actual code changes. File status information is already provided above.`;
52134
+ } else if (params.staged) {
52135
+ instructions = "Review the staged changes. Use the git_diff tool with staged: true to inspect the actual code changes. File status information is already provided above.";
52136
+ } else {
52137
+ instructions = "Review the unstaged changes. Use the git_diff tool to inspect the actual code changes. File status information is already provided above.";
52138
+ }
52139
+ parts.push(`<review_instructions>
52140
+ ${instructions}
52141
+ </review_instructions>`);
52142
+ return parts.join(`
52143
+ `);
52144
+ },
52145
+ parseOutput: (output) => {
52146
+ const jsonBlockRegex = /```json\n([\s\S]*?)\n```/;
52147
+ const match = output.match(jsonBlockRegex);
52148
+ const content = match ? match[1] : output;
52149
+ try {
52150
+ return JSON.parse(content);
52151
+ } catch (error81) {
52152
+ console.error("Error parsing JSON output:", error81);
52153
+ return {
52154
+ overview: `Could not parse review output. Raw output:
52155
+ ${output}`,
52156
+ specificReviews: []
52157
+ };
52158
+ }
52159
+ },
52160
+ agent: (options) => {
52161
+ return new AnalyzerAgent({
52162
+ ...options,
52163
+ additionalTools: [gitDiff_default]
52164
+ });
52165
+ }
52166
+ };
52167
+
51889
52168
  // ../core/src/AiTool/index.ts
51890
52169
  var executeTool = async (definition, ai, params, usageMeter) => {
51891
52170
  const resp = await generateText({
@@ -51901,10 +52180,7 @@ var executeTool = async (definition, ai, params, usageMeter) => {
51901
52180
  usageMeter.addUsage(ai, resp);
51902
52181
  return definition.parseOutput(resp.text);
51903
52182
  };
51904
- var executeAgentTool = async (definition, agent, params) => {
51905
- if (!definition.agent) {
51906
- throw new Error("Agent not specified");
51907
- }
52183
+ var executeMultiAgentTool = async (definition, agent, params) => {
51908
52184
  const exitReason = await agent.startTask({
51909
52185
  agentName: definition.agent,
51910
52186
  task: definition.prompt,
@@ -51915,22 +52191,38 @@ var executeAgentTool = async (definition, agent, params) => {
51915
52191
  }
51916
52192
  throw new Error(`Tool execution failed: ${exitReason.type}`);
51917
52193
  };
52194
+ var executeAgentTool = async (definition, options, params) => {
52195
+ const agent = definition.agent(options);
52196
+ const exitReason = await agent.start(`${definition.prompt}
52197
+
52198
+ ${definition.formatInput(params)}`);
52199
+ if (exitReason.type === "Exit" /* Exit */) {
52200
+ return definition.parseOutput(exitReason.message);
52201
+ }
52202
+ throw new Error(`Tool execution failed: ${exitReason.type}`);
52203
+ };
51918
52204
  var makeTool = (definition) => {
51919
52205
  return async (ai, params, usageMeter) => {
51920
52206
  return executeTool(definition, ai, params, usageMeter);
51921
52207
  };
51922
52208
  };
51923
- var makeAgentTool = (definition) => {
52209
+ var makeMultiAgentTool = (definition) => {
51924
52210
  return async (agent, params) => {
51925
- return executeAgentTool(definition, agent, params);
52211
+ return executeMultiAgentTool(definition, agent, params);
52212
+ };
52213
+ };
52214
+ var makeAgentTool = (definition) => {
52215
+ return async (options, params) => {
52216
+ return executeAgentTool(definition, options, params);
51926
52217
  };
51927
52218
  };
51928
52219
  var generateGitCommitMessage = makeTool(generateGitCommitMessage_default);
51929
52220
  var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails_default);
51930
- var generateProjectConfig = makeAgentTool(generateProjectConfig_default);
51931
- var createNewProject = makeAgentTool(createNewProject_default);
52221
+ var reviewDiff = makeAgentTool(reviewDiff_default);
52222
+ var generateProjectConfig = makeMultiAgentTool(generateProjectConfig_default);
52223
+ var createNewProject = makeMultiAgentTool(createNewProject_default);
51932
52224
  // src/config.ts
51933
- var import_lodash = __toESM(require_lodash(), 1);
52225
+ var import_lodash2 = __toESM(require_lodash(), 1);
51934
52226
 
51935
52227
  // node_modules/yaml/dist/index.js
51936
52228
  var composer = require_composer();
@@ -55841,7 +56133,7 @@ function mergeConfigs(configs) {
55841
56133
  return {};
55842
56134
  }
55843
56135
  const mergedConfig = configs.reduce((acc, config4) => {
55844
- const merged = import_lodash.merge({}, acc, config4);
56136
+ const merged = import_lodash2.merge({}, acc, config4);
55845
56137
  let accRules = acc.rules ?? [];
55846
56138
  if (typeof accRules === "string") {
55847
56139
  accRules = [accRules];
@@ -56472,15 +56764,15 @@ function useKeypress(userHandler) {
56472
56764
  signal.current = userHandler;
56473
56765
  useEffect((rl) => {
56474
56766
  let ignore = false;
56475
- const handler14 = withUpdates((_input, event) => {
56767
+ const handler15 = withUpdates((_input, event) => {
56476
56768
  if (ignore)
56477
56769
  return;
56478
56770
  signal.current(event, rl);
56479
56771
  });
56480
- rl.input.on("keypress", handler14);
56772
+ rl.input.on("keypress", handler15);
56481
56773
  return () => {
56482
56774
  ignore = true;
56483
- rl.input.removeListener("keypress", handler14);
56775
+ rl.input.removeListener("keypress", handler15);
56484
56776
  };
56485
56777
  }, []);
56486
56778
  }
@@ -56639,16 +56931,16 @@ class Emitter {
56639
56931
 
56640
56932
  class SignalExitBase {
56641
56933
  }
56642
- var signalExitWrap = (handler14) => {
56934
+ var signalExitWrap = (handler15) => {
56643
56935
  return {
56644
56936
  onExit(cb, opts) {
56645
- return handler14.onExit(cb, opts);
56937
+ return handler15.onExit(cb, opts);
56646
56938
  },
56647
56939
  load() {
56648
- return handler14.load();
56940
+ return handler15.load();
56649
56941
  },
56650
56942
  unload() {
56651
- return handler14.unload();
56943
+ return handler15.unload();
56652
56944
  }
56653
56945
  };
56654
56946
  };
@@ -56804,11 +57096,11 @@ class ScreenManager {
56804
57096
  render(content, bottomContent = "") {
56805
57097
  const promptLine = lastLine(content);
56806
57098
  const rawPromptLine = stripVTControlCharacters(promptLine);
56807
- let prompt5 = rawPromptLine;
57099
+ let prompt6 = rawPromptLine;
56808
57100
  if (this.rl.line.length > 0) {
56809
- prompt5 = prompt5.slice(0, -this.rl.line.length);
57101
+ prompt6 = prompt6.slice(0, -this.rl.line.length);
56810
57102
  }
56811
- this.rl.setPrompt(prompt5);
57103
+ this.rl.setPrompt(prompt6);
56812
57104
  this.cursorPos = this.rl.getCursorPos();
56813
57105
  const width = readlineWidth();
56814
57106
  content = breakLines(content, width);
@@ -56878,7 +57170,7 @@ function getCallSites() {
56878
57170
  }
56879
57171
  function createPrompt(view) {
56880
57172
  const callSites = getCallSites();
56881
- const prompt5 = (config4, context = {}) => {
57173
+ const prompt6 = (config4, context = {}) => {
56882
57174
  const { input = process.stdin, signal } = context;
56883
57175
  const cleanups = new Set;
56884
57176
  const output = new import_mute_stream.default;
@@ -56943,7 +57235,7 @@ function createPrompt(view) {
56943
57235
  }).then(() => promise4), { cancel });
56944
57236
  });
56945
57237
  };
56946
- return prompt5;
57238
+ return prompt6;
56947
57239
  }
56948
57240
  // ../../node_modules/@inquirer/core/dist/esm/lib/Separator.js
56949
57241
  var import_yoctocolors_cjs2 = __toESM(require_yoctocolors_cjs(), 1);
@@ -57970,7 +58262,7 @@ ${event.systemPrompt}`);
57970
58262
  ======== New Request ========
57971
58263
  `);
57972
58264
  if (verbose) {
57973
- const { userMessage } = event;
58265
+ const userMessage = event.userMessage.content;
57974
58266
  if (typeof userMessage === "string") {
57975
58267
  console.log(userMessage);
57976
58268
  } else {
@@ -57989,9 +58281,17 @@ ${event.systemPrompt}`);
57989
58281
  case "file":
57990
58282
  console.log(source_default.yellow(`[File name: ${content.filename}, type: ${content.mediaType}]`));
57991
58283
  break;
57992
- default:
57993
- console.log(source_default.red("[Unknown content type]"));
57994
- console.log(content);
58284
+ case "tool-call":
58285
+ console.log(source_default.yellow(`[Tool call: ${content.toolName}]`));
58286
+ break;
58287
+ case "tool-result":
58288
+ console.log(source_default.yellow(`[Tool result: ${content.toolName}]`));
58289
+ if (verbose > 0) {
58290
+ console.log(content.output);
58291
+ }
58292
+ break;
58293
+ case "reasoning":
58294
+ break;
57995
58295
  }
57996
58296
  }
57997
58297
  }
@@ -58025,29 +58325,33 @@ ${event.systemPrompt}`);
58025
58325
  process.stdout.write(source_default.dim(event.newText));
58026
58326
  hadReasoning = true;
58027
58327
  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
- }
58328
+ case "ToolUse" /* ToolUse */: {
58329
+ console.log(source_default.yellow(`
58330
+
58331
+ Tool use:`, event.tool), event.content);
58332
+ const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
58333
+ stats.calls++;
58334
+ toolCallStats.set(event.tool, stats);
58034
58335
  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
- }
58336
+ }
58337
+ case "ToolReply" /* ToolReply */: {
58338
+ const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
58339
+ stats.success++;
58340
+ toolCallStats.set(event.tool, stats);
58041
58341
  break;
58342
+ }
58042
58343
  case "ToolInvalid" /* ToolInvalid */:
58043
58344
  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
- }
58345
+ case "ToolError" /* ToolError */: {
58346
+ console.error(source_default.red(`
58347
+
58348
+ Tool error:`, event.tool));
58349
+ console.error(source_default.red(event.content));
58350
+ const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
58351
+ stats.errors++;
58352
+ toolCallStats.set(event.tool, stats);
58050
58353
  break;
58354
+ }
58051
58355
  case "ToolInterrupted" /* ToolInterrupted */:
58052
58356
  break;
58053
58357
  case "ToolHandOver" /* ToolHandOver */: