@polka-codes/runner 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 +708 -416
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -19540,9 +19540,9 @@ var require_event_target = __commonJS((exports, module) => {
19540
19540
  }
19541
19541
  Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
19542
19542
  var EventTarget = {
19543
- addEventListener(type, handler14, options = {}) {
19543
+ addEventListener(type, handler15, options = {}) {
19544
19544
  for (const listener of this.listeners(type)) {
19545
- if (!options[kForOnEventAttribute] && listener[kListener] === handler14 && !listener[kForOnEventAttribute]) {
19545
+ if (!options[kForOnEventAttribute] && listener[kListener] === handler15 && !listener[kForOnEventAttribute]) {
19546
19546
  return;
19547
19547
  }
19548
19548
  }
@@ -19553,7 +19553,7 @@ var require_event_target = __commonJS((exports, module) => {
19553
19553
  data: isBinary ? data : data.toString()
19554
19554
  });
19555
19555
  event[kTarget] = this;
19556
- callListener(handler14, this, event);
19556
+ callListener(handler15, this, event);
19557
19557
  };
19558
19558
  } else if (type === "close") {
19559
19559
  wrapper = function onClose(code, message) {
@@ -19563,7 +19563,7 @@ var require_event_target = __commonJS((exports, module) => {
19563
19563
  wasClean: this._closeFrameReceived && this._closeFrameSent
19564
19564
  });
19565
19565
  event[kTarget] = this;
19566
- callListener(handler14, this, event);
19566
+ callListener(handler15, this, event);
19567
19567
  };
19568
19568
  } else if (type === "error") {
19569
19569
  wrapper = function onError(error81) {
@@ -19572,28 +19572,28 @@ var require_event_target = __commonJS((exports, module) => {
19572
19572
  message: error81.message
19573
19573
  });
19574
19574
  event[kTarget] = this;
19575
- callListener(handler14, this, event);
19575
+ callListener(handler15, this, event);
19576
19576
  };
19577
19577
  } else if (type === "open") {
19578
19578
  wrapper = function onOpen() {
19579
19579
  const event = new Event("open");
19580
19580
  event[kTarget] = this;
19581
- callListener(handler14, this, event);
19581
+ callListener(handler15, this, event);
19582
19582
  };
19583
19583
  } else {
19584
19584
  return;
19585
19585
  }
19586
19586
  wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
19587
- wrapper[kListener] = handler14;
19587
+ wrapper[kListener] = handler15;
19588
19588
  if (options.once) {
19589
19589
  this.once(type, wrapper);
19590
19590
  } else {
19591
19591
  this.on(type, wrapper);
19592
19592
  }
19593
19593
  },
19594
- removeEventListener(type, handler14) {
19594
+ removeEventListener(type, handler15) {
19595
19595
  for (const listener of this.listeners(type)) {
19596
- if (listener[kListener] === handler14 && !listener[kForOnEventAttribute]) {
19596
+ if (listener[kListener] === handler15 && !listener[kForOnEventAttribute]) {
19597
19597
  this.removeListener(type, listener);
19598
19598
  break;
19599
19599
  }
@@ -20119,16 +20119,16 @@ var require_websocket = __commonJS((exports, module) => {
20119
20119
  }
20120
20120
  return null;
20121
20121
  },
20122
- set(handler14) {
20122
+ set(handler15) {
20123
20123
  for (const listener of this.listeners(method)) {
20124
20124
  if (listener[kForOnEventAttribute]) {
20125
20125
  this.removeListener(method, listener);
20126
20126
  break;
20127
20127
  }
20128
20128
  }
20129
- if (typeof handler14 !== "function")
20129
+ if (typeof handler15 !== "function")
20130
20130
  return;
20131
- this.addEventListener(method, handler14, {
20131
+ this.addEventListener(method, handler15, {
20132
20132
  [kForOnEventAttribute]: true
20133
20133
  });
20134
20134
  }
@@ -21008,7 +21008,7 @@ var {
21008
21008
  Help
21009
21009
  } = import__.default;
21010
21010
  // package.json
21011
- var version = "0.9.2";
21011
+ var version = "0.9.4";
21012
21012
 
21013
21013
  // src/runner.ts
21014
21014
  import { execSync } from "node:child_process";
@@ -32092,35 +32092,27 @@ var toolInfo = {
32092
32092
  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.",
32093
32093
  parameters: exports_external.object({
32094
32094
  questions: exports_external.array(questionObject).describe("One or more follow-up questions you need answered before you can continue.").meta({ usageValue: "questions here" })
32095
- }),
32096
- examples: [
32097
- {
32098
- description: "Single clarifying question (no options)",
32099
- parameters: [
32100
- {
32101
- name: "questions",
32102
- value: { prompt: "What is the target deployment environment?" }
32095
+ }).meta({
32096
+ examples: [
32097
+ {
32098
+ description: "Single clarifying question (no options)",
32099
+ input: {
32100
+ questions: { prompt: "What is the target deployment environment?" }
32103
32101
  }
32104
- ]
32105
- },
32106
- {
32107
- description: "Single question with multiple-choice options",
32108
- parameters: [
32109
- {
32110
- name: "questions",
32111
- value: {
32102
+ },
32103
+ {
32104
+ description: "Single question with multiple-choice options",
32105
+ input: {
32106
+ questions: {
32112
32107
  prompt: "Which frontend framework are you using?",
32113
32108
  options: ["React", "Angular", "Vue", "Svelte"]
32114
32109
  }
32115
32110
  }
32116
- ]
32117
- },
32118
- {
32119
- description: "Two related questions in one call",
32120
- parameters: [
32121
- {
32122
- name: "questions",
32123
- value: [
32111
+ },
32112
+ {
32113
+ description: "Two related questions in one call",
32114
+ input: {
32115
+ questions: [
32124
32116
  { prompt: "What type of application are you building?" },
32125
32117
  {
32126
32118
  prompt: "Preferred programming language?",
@@ -32128,21 +32120,18 @@ var toolInfo = {
32128
32120
  }
32129
32121
  ]
32130
32122
  }
32131
- ]
32132
- },
32133
- {
32134
- description: "Binary (yes/no) confirmation",
32135
- parameters: [
32136
- {
32137
- name: "questions",
32138
- value: {
32123
+ },
32124
+ {
32125
+ description: "Binary (yes/no) confirmation",
32126
+ input: {
32127
+ questions: {
32139
32128
  prompt: "Is it acceptable to refactor existing tests to improve performance?",
32140
32129
  options: ["Yes", "No"]
32141
32130
  }
32142
32131
  }
32143
- ]
32144
- }
32145
- ],
32132
+ }
32133
+ ]
32134
+ }),
32146
32135
  permissionLevel: 0 /* None */
32147
32136
  };
32148
32137
  var handler = async (provider, args) => {
@@ -32187,18 +32176,16 @@ var toolInfo2 = {
32187
32176
  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.",
32188
32177
  parameters: exports_external.object({
32189
32178
  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" })
32190
- }),
32191
- examples: [
32192
- {
32193
- description: "Request to present the result of the task",
32194
- parameters: [
32195
- {
32196
- name: "result",
32197
- value: "Your final result description here"
32179
+ }).meta({
32180
+ examples: [
32181
+ {
32182
+ description: "Request to present the result of the task",
32183
+ input: {
32184
+ result: "Your final result description here"
32198
32185
  }
32199
- ]
32200
- }
32201
- ],
32186
+ }
32187
+ ]
32188
+ }),
32202
32189
  permissionLevel: 0 /* None */
32203
32190
  };
32204
32191
  var handler2 = async (provider, args) => {
@@ -32244,30 +32231,19 @@ var toolInfo3 = {
32244
32231
  const values = Array.isArray(val) ? val : [val];
32245
32232
  return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
32246
32233
  }, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
32247
- }),
32248
- examples: [
32249
- {
32250
- description: "Delegate a code analysis task to the analyzer agent",
32251
- parameters: [
32252
- {
32253
- name: "agentName",
32254
- value: "analyzer"
32255
- },
32256
- {
32257
- name: "task",
32258
- value: "Analyze the authentication implementation"
32259
- },
32260
- {
32261
- name: "context",
32262
- value: "Need to understand the security implications of the current auth system"
32263
- },
32264
- {
32265
- name: "files",
32266
- value: "src/auth/login.ts,src/auth/types.ts"
32234
+ }).meta({
32235
+ examples: [
32236
+ {
32237
+ description: "Delegate a code analysis task to the analyzer agent",
32238
+ input: {
32239
+ agentName: "analyzer",
32240
+ task: "Analyze the authentication implementation",
32241
+ context: "Need to understand the security implications of the current auth system",
32242
+ files: "src/auth/login.ts,src/auth/types.ts"
32267
32243
  }
32268
- ]
32269
- }
32270
- ],
32244
+ }
32245
+ ]
32246
+ }),
32271
32247
  permissionLevel: 0 /* None */
32272
32248
  };
32273
32249
  var handler3 = async (_provider, args) => {
@@ -32311,16 +32287,17 @@ var toolInfo4 = {
32311
32287
  }
32312
32288
  return val;
32313
32289
  }, 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" })
32290
+ }).meta({
32291
+ examples: [
32292
+ {
32293
+ description: "Make a build",
32294
+ input: {
32295
+ command: "npm run build",
32296
+ requiresApproval: "false"
32297
+ }
32298
+ }
32299
+ ]
32314
32300
  }),
32315
- examples: [
32316
- {
32317
- description: "Make a build",
32318
- parameters: [
32319
- { name: "command", value: "npm run build" },
32320
- { name: "requiresApproval", value: "false" }
32321
- ]
32322
- }
32323
- ],
32324
32301
  permissionLevel: 3 /* Arbitrary */
32325
32302
  };
32326
32303
  var handler4 = async (provider, args) => {
@@ -32378,36 +32355,28 @@ var toolInfo5 = {
32378
32355
  const values = Array.isArray(val) ? val : [val];
32379
32356
  return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
32380
32357
  }, exports_external.array(exports_external.string())).describe("One or more URLs to fetch, separated by commas if multiple.").meta({ usageValue: "url" })
32381
- }),
32382
- examples: [
32383
- {
32384
- description: "Fetch a single webpage",
32385
- parameters: [
32386
- {
32387
- name: "url",
32388
- value: "https://example.com"
32358
+ }).meta({
32359
+ examples: [
32360
+ {
32361
+ description: "Fetch a single webpage",
32362
+ input: {
32363
+ url: "https://example.com"
32389
32364
  }
32390
- ]
32391
- },
32392
- {
32393
- description: "Fetch multiple webpages",
32394
- parameters: [
32395
- {
32396
- name: "url",
32397
- value: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
32365
+ },
32366
+ {
32367
+ description: "Fetch multiple webpages",
32368
+ input: {
32369
+ url: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
32398
32370
  }
32399
- ]
32400
- },
32401
- {
32402
- description: "Fetch a raw file from GitHub",
32403
- parameters: [
32404
- {
32405
- name: "url",
32406
- value: "https://raw.githubusercontent.com/user/repo/main/README.md"
32371
+ },
32372
+ {
32373
+ description: "Fetch a raw file from GitHub",
32374
+ input: {
32375
+ url: "https://raw.githubusercontent.com/user/repo/main/README.md"
32407
32376
  }
32408
- ]
32409
- }
32410
- ],
32377
+ }
32378
+ ]
32379
+ }),
32411
32380
  permissionLevel: 1 /* Read */
32412
32381
  };
32413
32382
  var handler5 = async (provider, args) => {
@@ -32463,30 +32432,19 @@ var toolInfo6 = {
32463
32432
  const values = Array.isArray(val) ? val : [val];
32464
32433
  return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
32465
32434
  }, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
32466
- }),
32467
- examples: [
32468
- {
32469
- description: "Hand over a coding task to the coder agent",
32470
- parameters: [
32471
- {
32472
- name: "agentName",
32473
- value: "coder"
32474
- },
32475
- {
32476
- name: "task",
32477
- value: "Implement the login feature"
32478
- },
32479
- {
32480
- name: "context",
32481
- value: "We need a secure login system with email and password"
32482
- },
32483
- {
32484
- name: "files",
32485
- value: "src/auth/login.ts,src/auth/types.ts"
32435
+ }).meta({
32436
+ examples: [
32437
+ {
32438
+ description: "Hand over a coding task to the coder agent",
32439
+ input: {
32440
+ agentName: "coder",
32441
+ task: "Implement the login feature",
32442
+ context: "We need a secure login system with email and password",
32443
+ files: "src/auth/login.ts,src/auth/types.ts"
32486
32444
  }
32487
- ]
32488
- }
32489
- ],
32445
+ }
32446
+ ]
32447
+ }),
32490
32448
  permissionLevel: 0 /* None */
32491
32449
  };
32492
32450
  var handler6 = async (_provider, args) => {
@@ -32531,22 +32489,17 @@ var toolInfo7 = {
32531
32489
  }
32532
32490
  return val;
32533
32491
  }, 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)" })
32534
- }),
32535
- examples: [
32536
- {
32537
- description: "Request to list files",
32538
- parameters: [
32539
- {
32540
- name: "path",
32541
- value: "src"
32542
- },
32543
- {
32544
- name: "maxCount",
32545
- value: "100"
32492
+ }).meta({
32493
+ examples: [
32494
+ {
32495
+ description: "Request to list files",
32496
+ input: {
32497
+ path: "src",
32498
+ maxCount: "100"
32546
32499
  }
32547
- ]
32548
- }
32549
- ],
32500
+ }
32501
+ ]
32502
+ }),
32550
32503
  permissionLevel: 1 /* Read */
32551
32504
  };
32552
32505
  var handler7 = async (provider, args) => {
@@ -32587,27 +32540,22 @@ var toolInfo8 = {
32587
32540
  const values = Array.isArray(val) ? val : [val];
32588
32541
  return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
32589
32542
  }, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" })
32590
- }),
32591
- examples: [
32592
- {
32593
- description: "Request to read the contents of a file",
32594
- parameters: [
32595
- {
32596
- name: "path",
32597
- value: "src/main.js"
32543
+ }).meta({
32544
+ examples: [
32545
+ {
32546
+ description: "Request to read the contents of a file",
32547
+ input: {
32548
+ path: "src/main.js"
32598
32549
  }
32599
- ]
32600
- },
32601
- {
32602
- description: "Request to read multiple files",
32603
- parameters: [
32604
- {
32605
- name: "path",
32606
- value: "src/main.js,src/index.js"
32550
+ },
32551
+ {
32552
+ description: "Request to read multiple files",
32553
+ input: {
32554
+ path: "src/main.js,src/index.js"
32607
32555
  }
32608
- ]
32609
- }
32610
- ],
32556
+ }
32557
+ ]
32558
+ }),
32611
32559
  permissionLevel: 1 /* Read */
32612
32560
  };
32613
32561
  var handler8 = async (provider, args) => {
@@ -32652,18 +32600,16 @@ var toolInfo9 = {
32652
32600
  description: "Request to remove a file at the specified path.",
32653
32601
  parameters: exports_external.object({
32654
32602
  path: exports_external.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
32655
- }),
32656
- examples: [
32657
- {
32658
- description: "Request to remove a file",
32659
- parameters: [
32660
- {
32661
- name: "path",
32662
- value: "src/main.js"
32603
+ }).meta({
32604
+ examples: [
32605
+ {
32606
+ description: "Request to remove a file",
32607
+ input: {
32608
+ path: "src/main.js"
32663
32609
  }
32664
- ]
32665
- }
32666
- ],
32610
+ }
32611
+ ]
32612
+ }),
32667
32613
  permissionLevel: 2 /* Write */
32668
32614
  };
32669
32615
  var handler9 = async (provider, args) => {
@@ -32702,22 +32648,17 @@ var toolInfo10 = {
32702
32648
  parameters: exports_external.object({
32703
32649
  source_path: exports_external.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
32704
32650
  target_path: exports_external.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
32705
- }),
32706
- examples: [
32707
- {
32708
- description: "Request to rename a file",
32709
- parameters: [
32710
- {
32711
- name: "source_path",
32712
- value: "src/old-name.js"
32713
- },
32714
- {
32715
- name: "target_path",
32716
- value: "src/new-name.js"
32651
+ }).meta({
32652
+ examples: [
32653
+ {
32654
+ description: "Request to rename a file",
32655
+ input: {
32656
+ source_path: "src/old-name.js",
32657
+ target_path: "src/new-name.js"
32717
32658
  }
32718
- ]
32719
- }
32720
- ],
32659
+ }
32660
+ ]
32661
+ }),
32721
32662
  permissionLevel: 2 /* Write */
32722
32663
  };
32723
32664
  var handler10 = async (provider, args) => {
@@ -32846,18 +32787,13 @@ Critical rules:
32846
32787
  4. Special operations:
32847
32788
  * To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
32848
32789
  * To delete code: Use empty REPLACE section`).meta({ usageValue: "Search and replace blocks here" })
32849
- }),
32850
- examples: [
32851
- {
32852
- description: "Request to replace sections of content in a file",
32853
- parameters: [
32854
- {
32855
- name: "path",
32856
- value: "src/main.js"
32857
- },
32858
- {
32859
- name: "diff",
32860
- value: `<<<<<<< SEARCH
32790
+ }).meta({
32791
+ examples: [
32792
+ {
32793
+ description: "Request to replace sections of content in a file",
32794
+ input: {
32795
+ path: "src/main.js",
32796
+ diff: `<<<<<<< SEARCH
32861
32797
  import React from 'react';
32862
32798
  =======
32863
32799
  import React, { useState } from 'react';
@@ -32885,35 +32821,23 @@ return (
32885
32821
  <div>
32886
32822
  >>>>>>> REPLACE`
32887
32823
  }
32888
- ]
32889
- },
32890
- {
32891
- description: "Request to perform a simple, single-line replacement",
32892
- parameters: [
32893
- {
32894
- name: "path",
32895
- value: "src/config.js"
32896
- },
32897
- {
32898
- name: "diff",
32899
- value: `<<<<<<< SEARCH
32824
+ },
32825
+ {
32826
+ description: "Request to perform a simple, single-line replacement",
32827
+ input: {
32828
+ path: "src/config.js",
32829
+ diff: `<<<<<<< SEARCH
32900
32830
  const API_URL = 'https://api.example.com';
32901
32831
  =======
32902
32832
  const API_URL = 'https://api.staging.example.com';
32903
32833
  >>>>>>> REPLACE`
32904
32834
  }
32905
- ]
32906
- },
32907
- {
32908
- description: "Request to add a new function to a file",
32909
- parameters: [
32910
- {
32911
- name: "path",
32912
- value: "src/utils.js"
32913
- },
32914
- {
32915
- name: "diff",
32916
- value: `<<<<<<< SEARCH
32835
+ },
32836
+ {
32837
+ description: "Request to add a new function to a file",
32838
+ input: {
32839
+ path: "src/utils.js",
32840
+ diff: `<<<<<<< SEARCH
32917
32841
  function helperA() {
32918
32842
  // ...
32919
32843
  }
@@ -32927,18 +32851,12 @@ function newHelper() {
32927
32851
  }
32928
32852
  >>>>>>> REPLACE`
32929
32853
  }
32930
- ]
32931
- },
32932
- {
32933
- description: "Request to delete a block of code from a file",
32934
- parameters: [
32935
- {
32936
- name: "path",
32937
- value: "src/app.js"
32938
- },
32939
- {
32940
- name: "diff",
32941
- value: `<<<<<<< SEARCH
32854
+ },
32855
+ {
32856
+ description: "Request to delete a block of code from a file",
32857
+ input: {
32858
+ path: "src/app.js",
32859
+ diff: `<<<<<<< SEARCH
32942
32860
  function oldFeature() {
32943
32861
  // This is no longer needed
32944
32862
  }
@@ -32946,9 +32864,9 @@ function oldFeature() {
32946
32864
  =======
32947
32865
  >>>>>>> REPLACE`
32948
32866
  }
32949
- ]
32950
- }
32951
- ],
32867
+ }
32868
+ ]
32869
+ }),
32952
32870
  permissionLevel: 2 /* Write */
32953
32871
  };
32954
32872
  var handler11 = async (provider, args) => {
@@ -33016,26 +32934,18 @@ var toolInfo12 = {
33016
32934
  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({
33017
32935
  usageValue: "file pattern here (optional)"
33018
32936
  })
33019
- }),
33020
- examples: [
33021
- {
33022
- description: "Request to perform a regex search across files",
33023
- parameters: [
33024
- {
33025
- name: "path",
33026
- value: "src"
33027
- },
33028
- {
33029
- name: "regex",
33030
- value: "^components/"
33031
- },
33032
- {
33033
- name: "filePattern",
33034
- value: "*.ts,*.tsx"
32937
+ }).meta({
32938
+ examples: [
32939
+ {
32940
+ description: "Request to perform a regex search across files",
32941
+ input: {
32942
+ path: "src",
32943
+ regex: "^components/",
32944
+ filePattern: "*.ts,*.tsx"
33035
32945
  }
33036
- ]
33037
- }
33038
- ],
32946
+ }
32947
+ ]
32948
+ }),
33039
32949
  permissionLevel: 1 /* Read */
33040
32950
  };
33041
32951
  var handler12 = async (provider, args) => {
@@ -33081,18 +32991,13 @@ var toolInfo13 = {
33081
32991
  parameters: exports_external.object({
33082
32992
  path: exports_external.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
33083
32993
  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" })
33084
- }),
33085
- examples: [
33086
- {
33087
- description: "Request to write content to a file",
33088
- parameters: [
33089
- {
33090
- name: "path",
33091
- value: "src/main.js"
33092
- },
33093
- {
33094
- name: "content",
33095
- value: `import React from 'react';
32994
+ }).meta({
32995
+ examples: [
32996
+ {
32997
+ description: "Request to write content to a file",
32998
+ input: {
32999
+ path: "src/main.js",
33000
+ content: `import React from 'react';
33096
33001
 
33097
33002
  function App() {
33098
33003
  return (
@@ -33105,9 +33010,9 @@ function App() {
33105
33010
  export default App;
33106
33011
  `
33107
33012
  }
33108
- ]
33109
- }
33110
- ],
33013
+ }
33014
+ ]
33015
+ }),
33111
33016
  permissionLevel: 2 /* Write */
33112
33017
  };
33113
33018
  var handler13 = async (provider, args) => {
@@ -33167,45 +33072,6 @@ var getAvailableTools = ({
33167
33072
  return tools;
33168
33073
  };
33169
33074
 
33170
- // ../core/src/tool-v1-compat.ts
33171
- function zodSchemaToParameters(schema) {
33172
- const parameters = [];
33173
- const { shape } = schema;
33174
- for (const name in shape) {
33175
- const def = shape[name];
33176
- const isOptional = def.safeParse(undefined).success;
33177
- const description = def.description || "";
33178
- const param = {
33179
- name,
33180
- description,
33181
- required: !isOptional
33182
- };
33183
- const usageValue = def.meta()?.usageValue;
33184
- if (usageValue) {
33185
- param.usageValue = usageValue;
33186
- }
33187
- if (def instanceof exports_external.ZodObject) {
33188
- param.children = zodSchemaToParameters(def);
33189
- } else if (def instanceof exports_external.ZodArray) {
33190
- param.allowMultiple = true;
33191
- const element = def.element;
33192
- if (element instanceof exports_external.ZodObject) {
33193
- param.children = zodSchemaToParameters(element);
33194
- }
33195
- }
33196
- parameters.push(param);
33197
- }
33198
- return parameters;
33199
- }
33200
- function toToolInfoV1(tool) {
33201
- const { parameters: zodSchema, ...rest } = tool;
33202
- const v1Parameters = zodSchemaToParameters(zodSchema);
33203
- return {
33204
- ...rest,
33205
- parameters: v1Parameters
33206
- };
33207
- }
33208
-
33209
33075
  // ../core/src/UsageMeter.ts
33210
33076
  class UsageMeter {
33211
33077
  #totals = { input: 0, output: 0, cachedRead: 0, cost: 0 };
@@ -55873,6 +55739,53 @@ var JSONRPCMessageSchema = exports_external2.union([
55873
55739
  JSONRPCErrorSchema
55874
55740
  ]);
55875
55741
 
55742
+ // ../core/src/Agent/AgentBase.ts
55743
+ var import_lodash = __toESM(require_lodash(), 1);
55744
+
55745
+ // ../core/src/tool-v1-compat.ts
55746
+ function zodSchemaToParameters(schema) {
55747
+ const parameters = [];
55748
+ const { shape } = schema;
55749
+ for (const name17 in shape) {
55750
+ const def = shape[name17];
55751
+ const isOptional = def.safeParse(undefined).success;
55752
+ const description = def.description || "";
55753
+ const param = {
55754
+ name: name17,
55755
+ description,
55756
+ required: !isOptional
55757
+ };
55758
+ const usageValue = def.meta()?.usageValue;
55759
+ if (usageValue) {
55760
+ param.usageValue = usageValue;
55761
+ }
55762
+ if (def instanceof exports_external.ZodObject) {
55763
+ param.children = zodSchemaToParameters(def);
55764
+ } else if (def instanceof exports_external.ZodArray) {
55765
+ param.allowMultiple = true;
55766
+ const element = def.element;
55767
+ if (element instanceof exports_external.ZodObject) {
55768
+ param.children = zodSchemaToParameters(element);
55769
+ }
55770
+ }
55771
+ parameters.push(param);
55772
+ }
55773
+ return parameters;
55774
+ }
55775
+ function toToolInfoV1(tool) {
55776
+ const { parameters: zodSchema2, ...rest } = tool;
55777
+ const v1Parameters = zodSchemaToParameters(zodSchema2);
55778
+ const examples = zodSchema2.meta()?.examples;
55779
+ const v1Tool = {
55780
+ ...rest,
55781
+ parameters: v1Parameters
55782
+ };
55783
+ if (examples) {
55784
+ v1Tool.examples = examples;
55785
+ }
55786
+ return v1Tool;
55787
+ }
55788
+
55876
55789
  // ../core/src/Agent/parseAssistantMessage.ts
55877
55790
  function parseNestedParameters(content, parameterPrefix, childrenParams) {
55878
55791
  const result = {};
@@ -56046,7 +55959,7 @@ var toolInfoExamplesPrompt = (tool, example, toolNamePrefix, parameterPrefix) =>
56046
55959
  ## Example: ${example.description}
56047
55960
 
56048
55961
  <${toolNamePrefix}${tool.name}>
56049
- ${example.parameters.map((param) => `${renderParameterValue(param.name, param.value, parameterPrefix)}`).join(`
55962
+ ${Object.entries(example.input).map(([name17, value]) => renderParameterValue(name17, value, parameterPrefix)).join(`
56050
55963
  `)}
56051
55964
  </${toolNamePrefix}${tool.name}>
56052
55965
  `;
@@ -56055,6 +55968,7 @@ var toolUsePrompt = (tools, toolNamePrefix) => {
56055
55968
  return "";
56056
55969
  }
56057
55970
  const parameterPrefix = `${toolNamePrefix}parameter_`;
55971
+ const v1Tools = tools.map(toToolInfoV1);
56058
55972
  return `
56059
55973
  ====
56060
55974
 
@@ -56113,11 +56027,11 @@ Always adhere to this format, ensuring every opening tag has a matching closing
56113
56027
  NEVER surround tool use with triple backticks (\`\`\`).
56114
56028
 
56115
56029
  # Tools
56116
- ${tools.map((tool) => toolInfoPrompt(tool, toolNamePrefix, parameterPrefix)).join(`
56030
+ ${v1Tools.map((tool) => toolInfoPrompt(tool, toolNamePrefix, parameterPrefix)).join(`
56117
56031
  `)}
56118
56032
 
56119
56033
  # Tool Use Examples
56120
- ${tools.map((tool) => {
56034
+ ${v1Tools.map((tool) => {
56121
56035
  let promp = "";
56122
56036
  for (const example of tool.examples ?? []) {
56123
56037
  promp += toolInfoExamplesPrompt(tool, example, toolNamePrefix, parameterPrefix);
@@ -56210,6 +56124,8 @@ e.g. <tool_tool_name>tool_name</tool_tool_name>
56210
56124
  Ensure the opening and closing tags are correctly nested and closed, and that you are using the correct tool name.
56211
56125
  Avoid unnecessary text or symbols before or after the tool use.
56212
56126
  Avoid unnecessary escape characters or special characters.
56127
+ `,
56128
+ requireUseToolNative: `Error: No tool use detected. You MUST use a tool before proceeding.
56213
56129
  `,
56214
56130
  toolResults: (tool, result) => {
56215
56131
  if (typeof result === "string") {
@@ -56248,6 +56164,7 @@ class AgentBase {
56248
56164
  config;
56249
56165
  handlers;
56250
56166
  #policies;
56167
+ #toolSet;
56251
56168
  #messages = [];
56252
56169
  #aborted = false;
56253
56170
  #abortController;
@@ -56285,6 +56202,20 @@ ${instance.prompt}`;
56285
56202
  role: "system",
56286
56203
  content: this.config.systemPrompt
56287
56204
  });
56205
+ if (this.config.toolFormat === "native") {
56206
+ const tools = {};
56207
+ for (const tool of Object.values(this.handlers)) {
56208
+ const toolName = import_lodash.camelCase(tool.name);
56209
+ tools[toolName] = {
56210
+ description: tool.description,
56211
+ inputSchema: jsonSchema(toJSONSchema(tool.parameters))
56212
+ };
56213
+ this.handlers[toolName] = tool;
56214
+ }
56215
+ this.#toolSet = tools;
56216
+ } else {
56217
+ this.#toolSet = {};
56218
+ }
56288
56219
  }
56289
56220
  abort() {
56290
56221
  this.#aborted = true;
@@ -56312,13 +56243,19 @@ ${instance.prompt}`;
56312
56243
  if (this.#messages.length === 0) {
56313
56244
  this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
56314
56245
  }
56315
- return await this.#request(prompt);
56246
+ return await this.#request({
56247
+ role: "user",
56248
+ content: prompt
56249
+ });
56316
56250
  }
56317
56251
  async handleStepResponse(response) {
56318
56252
  return this.#handleResponse(response);
56319
56253
  }
56320
56254
  async#processLoop(userMessage) {
56321
- let nextRequest = userMessage;
56255
+ let nextRequest = {
56256
+ role: "user",
56257
+ content: userMessage
56258
+ };
56322
56259
  while (true) {
56323
56260
  if (this.#aborted) {
56324
56261
  return { type: "Aborted" };
@@ -56347,10 +56284,7 @@ ${instance.prompt}`;
56347
56284
  throw new Error("userMessage is missing");
56348
56285
  }
56349
56286
  await this.#callback({ kind: "StartRequest" /* StartRequest */, agent: this, userMessage });
56350
- this.#messages.push({
56351
- role: "user",
56352
- content: userMessage
56353
- });
56287
+ this.#messages.push(userMessage);
56354
56288
  for (const instance of this.#policies) {
56355
56289
  if (instance.onBeforeRequest) {
56356
56290
  await instance.onBeforeRequest(this);
@@ -56362,96 +56296,132 @@ ${instance.prompt}`;
56362
56296
  messages = await instance.prepareMessages(this, messages);
56363
56297
  }
56364
56298
  }
56365
- let currentAssistantMessage = "";
56366
56299
  const retryCount = this.config.retryCount ?? 5;
56367
- const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 10;
56300
+ const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 90;
56301
+ let respMessages = [];
56368
56302
  for (let i = 0;i < retryCount; i++) {
56369
- currentAssistantMessage = "";
56303
+ if (this.#aborted) {
56304
+ break;
56305
+ }
56306
+ respMessages = [];
56370
56307
  let timeout;
56308
+ let requestAbortController;
56309
+ requestAbortController = new AbortController;
56310
+ this.#abortController = requestAbortController;
56371
56311
  const resetTimeout = () => {
56372
56312
  if (timeout) {
56373
56313
  clearTimeout(timeout);
56374
56314
  }
56375
- if (requestTimeoutSeconds > 0) {
56315
+ if (requestTimeoutSeconds > 0 && requestAbortController) {
56376
56316
  timeout = setTimeout(() => {
56377
- console.debug(`No data received for ${requestTimeoutSeconds} seconds. Aborting request.`);
56378
- this.abort();
56317
+ console.debug(`Request timeout after ${requestTimeoutSeconds} seconds. Canceling current request attempt ${i + 1}/${retryCount}.`);
56318
+ requestAbortController?.abort();
56379
56319
  }, requestTimeoutSeconds * 1000);
56380
56320
  }
56381
56321
  };
56382
- this.#abortController = new AbortController;
56383
- const providerOptions = {};
56384
- const thinkingBudgetTokens = this.config.parameters?.thinkingBudgetTokens;
56385
- const enableThinking = thinkingBudgetTokens > 0;
56386
- if (enableThinking) {
56387
- providerOptions.anthropic = {
56388
- thinking: { type: "enabled", budgetTokens: thinkingBudgetTokens }
56389
- };
56390
- providerOptions.openrouter = {
56391
- reasoning: {
56392
- max_tokens: thinkingBudgetTokens
56393
- }
56394
- };
56395
- providerOptions.google = {
56396
- thinkingConfig: {
56397
- includeThoughts: true,
56398
- thinkingBudget: thinkingBudgetTokens
56399
- }
56400
- };
56401
- }
56402
56322
  try {
56403
- const stream = streamText({
56323
+ resetTimeout();
56324
+ const streamTextOptions = {
56404
56325
  model: this.ai,
56405
56326
  messages,
56406
- providerOptions,
56327
+ providerOptions: this.config.parameters?.providerOptions,
56407
56328
  onChunk: async ({ chunk }) => {
56408
56329
  resetTimeout();
56409
56330
  switch (chunk.type) {
56410
56331
  case "text":
56411
- currentAssistantMessage += chunk.text;
56412
56332
  await this.#callback({ kind: "Text" /* Text */, agent: this, newText: chunk.text });
56413
56333
  break;
56414
56334
  case "reasoning":
56415
56335
  await this.#callback({ kind: "Reasoning" /* Reasoning */, agent: this, newText: chunk.text });
56416
56336
  break;
56337
+ case "tool-call":
56338
+ break;
56417
56339
  }
56418
56340
  },
56419
56341
  onFinish: this.config.usageMeter.onFinishHandler(this.ai),
56420
56342
  onError: async (error81) => {
56421
56343
  console.error("Error in stream:", error81);
56422
56344
  },
56423
- abortSignal: this.#abortController.signal
56345
+ abortSignal: requestAbortController.signal
56346
+ };
56347
+ if (this.config.toolFormat === "native") {
56348
+ streamTextOptions.tools = this.#toolSet;
56349
+ }
56350
+ const stream = streamText(streamTextOptions);
56351
+ await stream.consumeStream({
56352
+ onError: (error81) => {
56353
+ console.error("Error in stream:", error81);
56354
+ }
56424
56355
  });
56425
- await stream.consumeStream();
56356
+ const resp = await stream.response;
56357
+ respMessages = resp.messages;
56358
+ if (timeout) {
56359
+ clearTimeout(timeout);
56360
+ timeout = undefined;
56361
+ }
56426
56362
  } catch (error81) {
56427
56363
  if (error81 instanceof Error && error81.name === "AbortError") {
56428
- break;
56364
+ if (this.#aborted) {
56365
+ break;
56366
+ }
56367
+ console.debug(`Request attempt ${i + 1} timed out, will retry`);
56368
+ } else {
56369
+ console.error("Error in stream:", error81);
56429
56370
  }
56430
- console.error("Error in stream:", error81);
56431
56371
  } finally {
56432
56372
  if (timeout) {
56433
56373
  clearTimeout(timeout);
56434
56374
  }
56435
56375
  }
56436
- if (currentAssistantMessage) {
56376
+ if (respMessages.length > 0) {
56437
56377
  break;
56438
56378
  }
56439
56379
  if (this.#aborted) {
56440
56380
  break;
56441
56381
  }
56442
- console.debug(`Retrying request ${i + 1} of ${retryCount}`);
56382
+ if (i < retryCount - 1) {
56383
+ console.debug(`Retrying request ${i + 2} of ${retryCount}`);
56384
+ }
56443
56385
  }
56444
- if (!currentAssistantMessage) {
56386
+ if (respMessages.length === 0) {
56445
56387
  if (this.#aborted) {
56446
56388
  return [];
56447
56389
  }
56448
- throw new Error("No assistant message received");
56390
+ throw new Error("No assistant message received after all retry attempts");
56449
56391
  }
56450
- console.log("Assistant message:", currentAssistantMessage);
56451
- this.#messages.push({
56452
- role: "assistant",
56453
- content: currentAssistantMessage
56454
- });
56392
+ this.#messages.push(...respMessages);
56393
+ if (this.config.toolFormat === "native") {
56394
+ return respMessages.flatMap((msg) => {
56395
+ if (msg.role === "assistant") {
56396
+ const content = msg.content;
56397
+ if (typeof content === "string") {
56398
+ return [{ type: "text", content }];
56399
+ }
56400
+ return content.flatMap((part) => {
56401
+ if (part.type === "text" || part.type === "reasoning") {
56402
+ return [{ type: "text", content: part.text }];
56403
+ }
56404
+ if (part.type === "tool-call") {
56405
+ return [{ type: "tool_use", id: part.toolCallId, name: part.toolName, params: part.input }];
56406
+ }
56407
+ return [];
56408
+ });
56409
+ }
56410
+ return [];
56411
+ });
56412
+ }
56413
+ const currentAssistantMessage = respMessages.map((msg) => {
56414
+ if (typeof msg.content === "string") {
56415
+ return msg.content;
56416
+ }
56417
+ return msg.content.map((part) => {
56418
+ if (part.type === "text") {
56419
+ return part.text;
56420
+ }
56421
+ return "";
56422
+ });
56423
+ }).join(`
56424
+ `);
56455
56425
  const ret = parseAssistantMessage(currentAssistantMessage, this.config.tools.map(toToolInfoV1), this.config.toolNamePrefix);
56456
56426
  await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: currentAssistantMessage });
56457
56427
  return ret;
@@ -56465,12 +56435,12 @@ ${instance.prompt}`;
56465
56435
  case "text":
56466
56436
  break;
56467
56437
  case "tool_use": {
56468
- await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name });
56438
+ await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, content: content.params });
56469
56439
  const toolResp = await this.#invokeTool(content.name, content.params);
56470
56440
  switch (toolResp.type) {
56471
56441
  case "Reply" /* Reply */: {
56472
- await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
56473
- toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
56442
+ await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name, content: toolResp.message });
56443
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
56474
56444
  break;
56475
56445
  }
56476
56446
  case "Exit" /* Exit */:
@@ -56479,17 +56449,17 @@ ${instance.prompt}`;
56479
56449
  }
56480
56450
  return { type: "exit", reason: toolResp };
56481
56451
  case "Invalid" /* Invalid */: {
56482
- await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
56483
- toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
56452
+ await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
56453
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
56484
56454
  break outer;
56485
56455
  }
56486
56456
  case "Error" /* Error */: {
56487
- await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
56488
- toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
56457
+ await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
56458
+ toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
56489
56459
  break outer;
56490
56460
  }
56491
56461
  case "Interrupted" /* Interrupted */:
56492
- await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
56462
+ await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
56493
56463
  return { type: "exit", reason: toolResp };
56494
56464
  case "HandOver" /* HandOver */: {
56495
56465
  if (toolResponses.length > 0) {
@@ -56523,7 +56493,7 @@ ${instance.prompt}`;
56523
56493
  }
56524
56494
  case "Pause" /* Pause */: {
56525
56495
  await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
56526
- toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object });
56496
+ toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object, id: content.id });
56527
56497
  hasPause = true;
56528
56498
  }
56529
56499
  }
@@ -56535,10 +56505,49 @@ ${instance.prompt}`;
56535
56505
  return { type: "exit", reason: { type: "Pause", responses: toolResponses } };
56536
56506
  }
56537
56507
  if (toolResponses.length === 0) {
56538
- return { type: "reply", message: responsePrompts.requireUseTool };
56508
+ return {
56509
+ type: "reply",
56510
+ message: {
56511
+ role: "user",
56512
+ content: responsePrompts.requireUseToolNative
56513
+ }
56514
+ };
56515
+ }
56516
+ if (this.config.toolFormat === "native") {
56517
+ const toolResults = toolResponses.filter((resp) => resp.type === "response").map((resp) => ({
56518
+ type: "tool-result",
56519
+ toolCallId: resp.id,
56520
+ toolName: resp.tool,
56521
+ output: {
56522
+ type: "text",
56523
+ value: resp.response
56524
+ }
56525
+ }));
56526
+ return {
56527
+ type: "reply",
56528
+ message: {
56529
+ role: "tool",
56530
+ content: toolResults
56531
+ }
56532
+ };
56533
+ }
56534
+ if (toolResponses.length === 0) {
56535
+ return {
56536
+ type: "reply",
56537
+ message: {
56538
+ role: "user",
56539
+ content: responsePrompts.requireUseTool
56540
+ }
56541
+ };
56539
56542
  }
56540
56543
  const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2));
56541
- return { type: "reply", message: finalResp };
56544
+ return {
56545
+ type: "reply",
56546
+ message: {
56547
+ role: "user",
56548
+ content: finalResp
56549
+ }
56550
+ };
56542
56551
  }
56543
56552
  async#invokeTool(name17, args) {
56544
56553
  try {
@@ -56579,6 +56588,80 @@ ${instance.prompt}`;
56579
56588
  }
56580
56589
  }
56581
56590
 
56591
+ // ../core/src/Agent/AnalyzerAgent/prompts.ts
56592
+ var fullSystemPrompt = (info, tools, toolNamePrefix, instructions, scripts, useNativeTool) => `
56593
+ # Analyzer Agent
56594
+
56595
+ ## Role
56596
+ You are the **Analyzer** agent, responsible for:
56597
+ 1. **Project Structure Analysis** – Understand codebase organization and architecture.
56598
+ 2. **Code Pattern Analysis** – Identify common patterns, conventions, and best practices.
56599
+ 3. **Dependency Analysis** – Examine project dependencies and their usage.
56600
+ 4. **Workflow Analysis** – Understand development tools, scripts, and processes.
56601
+ 5. **Documentation Review** – Analyze documentation and code comments.
56602
+
56603
+ > **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.
56604
+
56605
+ ## Rules
56606
+ 1. **Thoroughness**: Conduct comprehensive analysis of relevant project aspects.
56607
+ 2. **Pattern Recognition**: Identify recurring patterns, conventions, and architectural decisions.
56608
+ 3. **Dependency Mapping**: Track and understand relationships between components.
56609
+ 4. **Workflow Understanding**: Analyze build processes, testing approaches, and development tools.
56610
+ 5. **Documentation Assessment**: Review documentation quality and completeness.
56611
+ 6. **Non-Modification**: Never modify code or files - focus solely on analysis.
56612
+
56613
+ ${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
56614
+ ${capabilities(toolNamePrefix)}
56615
+ ${systemInformation(info)}
56616
+ ${customInstructions(instructions)}
56617
+ ${customScripts(scripts)}
56618
+ `;
56619
+
56620
+ // ../core/src/Agent/AnalyzerAgent/index.ts
56621
+ class AnalyzerAgent extends AgentBase {
56622
+ constructor(options) {
56623
+ const combinedTools = [...options.additionalTools ?? [], ...Object.values(exports_allTools)];
56624
+ const tools = getAvailableTools({
56625
+ provider: options.provider,
56626
+ allTools: combinedTools,
56627
+ hasAgent: (options.agents?.length ?? 0) > 0,
56628
+ permissionLevel: 1 /* Read */,
56629
+ interactive: true
56630
+ });
56631
+ const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
56632
+ const systemPrompt = fullSystemPrompt({
56633
+ os: options.os
56634
+ }, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.toolFormat === "native");
56635
+ super(analyzerAgentInfo.name, options.ai, {
56636
+ systemPrompt,
56637
+ tools,
56638
+ toolNamePrefix,
56639
+ provider: options.provider,
56640
+ interactive: options.interactive,
56641
+ agents: options.agents,
56642
+ scripts: options.scripts,
56643
+ callback: options.callback,
56644
+ policies: options.policies,
56645
+ toolFormat: options.toolFormat,
56646
+ parameters: options.parameters ?? {},
56647
+ usageMeter: options.usageMeter ?? new UsageMeter
56648
+ });
56649
+ }
56650
+ onBeforeInvokeTool() {
56651
+ return Promise.resolve(undefined);
56652
+ }
56653
+ }
56654
+ var analyzerAgentInfo = {
56655
+ name: "analyzer",
56656
+ responsibilities: [
56657
+ "Analyzing project structure and organization",
56658
+ "Identifying key source code files and their relationships",
56659
+ "Understanding common coding patterns and conventions",
56660
+ "Examining development workflow and tooling",
56661
+ "Analyzing dependencies and their usage patterns"
56662
+ ]
56663
+ };
56664
+
56582
56665
  // ../core/src/Agent/CodeFixerAgent/prompts.ts
56583
56666
  var basePrompt = `You are a highly skilled software engineer specializing in debugging and fixing code issues. You have extensive experience with:
56584
56667
  - Type systems and type checking
@@ -56668,10 +56751,10 @@ class CodeFixerAgent extends AgentBase {
56668
56751
  permissionLevel: 3 /* Arbitrary */,
56669
56752
  interactive: true
56670
56753
  });
56671
- const toolNamePrefix = "tool_";
56754
+ const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
56672
56755
  const systemPrompt = fullSystemPrompt3({
56673
56756
  os: options.os
56674
- }, tools.map(toToolInfoV1), toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.interactive, options.toolFormat === "native");
56757
+ }, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.interactive, options.toolFormat === "native");
56675
56758
  super(codeFixerAgentInfo.name, options.ai, {
56676
56759
  systemPrompt,
56677
56760
  tools,
@@ -56917,23 +57000,23 @@ var prompt = `You are an AiTool designed to assist users in creating new project
56917
57000
  - Create a .gitattributes file with appropriate configurations:
56918
57001
  - Mark lock files as generated and exclude them from diffs
56919
57002
  - Example for different package managers:
56920
-
57003
+
56921
57004
  # For Bun
56922
57005
  bun.lock linguist-generated=true
56923
57006
  bun.lock -diff
56924
-
57007
+
56925
57008
  # For npm
56926
57009
  package-lock.json linguist-generated=true
56927
57010
  package-lock.json -diff
56928
-
57011
+
56929
57012
  # For Yarn
56930
57013
  yarn.lock linguist-generated=true
56931
57014
  yarn.lock -diff
56932
-
57015
+
56933
57016
  # For pnpm
56934
57017
  pnpm-lock.yaml linguist-generated=true
56935
57018
  pnpm-lock.yaml -diff
56936
-
57019
+
56937
57020
  - Include other common configurations as needed based on project type
56938
57021
 
56939
57022
  6. **Handover to Coder Agent:**
@@ -57189,6 +57272,202 @@ var generateProjectConfig_default = {
57189
57272
  agent: "analyzer"
57190
57273
  };
57191
57274
 
57275
+ // ../core/src/AiTool/tools/gitDiff.ts
57276
+ var toolInfo14 = {
57277
+ name: "git_diff",
57278
+ 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.",
57279
+ parameters: exports_external.object({
57280
+ staged: exports_external.preprocess((val) => {
57281
+ if (typeof val === "string") {
57282
+ const lower = val.toLowerCase();
57283
+ if (lower === "false")
57284
+ return false;
57285
+ if (lower === "true")
57286
+ return true;
57287
+ }
57288
+ return val;
57289
+ }, exports_external.boolean().optional().default(false)).describe("Get staged changes instead of unstaged changes."),
57290
+ commitRange: exports_external.string().optional().describe('The commit range to get the diff for (e.g., "main...HEAD").'),
57291
+ file: exports_external.string().optional().describe("Get the diff for a specific file.")
57292
+ }),
57293
+ permissionLevel: 1 /* Read */
57294
+ };
57295
+ var handler14 = async (provider2, args) => {
57296
+ if (!provider2.executeCommand) {
57297
+ return {
57298
+ type: "Error" /* Error */,
57299
+ message: "Not possible to execute command. Abort."
57300
+ };
57301
+ }
57302
+ const { staged, file: file3, commitRange } = toolInfo14.parameters.parse(args);
57303
+ const commandParts = ["git", "diff", "--no-color"];
57304
+ if (staged) {
57305
+ commandParts.push("--staged");
57306
+ }
57307
+ if (commitRange) {
57308
+ commandParts.push(commitRange);
57309
+ }
57310
+ if (file3) {
57311
+ commandParts.push("--", file3);
57312
+ }
57313
+ const command = commandParts.join(" ");
57314
+ try {
57315
+ const result = await provider2.executeCommand(command, false);
57316
+ if (result.exitCode === 0) {
57317
+ if (!result.stdout.trim()) {
57318
+ return {
57319
+ type: "Reply" /* Reply */,
57320
+ message: "No diff found."
57321
+ };
57322
+ }
57323
+ return {
57324
+ type: "Reply" /* Reply */,
57325
+ message: `<diff file="${file3 ?? "all"}">
57326
+ ${result.stdout}
57327
+ </diff>`
57328
+ };
57329
+ }
57330
+ return {
57331
+ type: "Error" /* Error */,
57332
+ message: `\`${command}\` exited with code ${result.exitCode}:
57333
+ ${result.stderr}`
57334
+ };
57335
+ } catch (error81) {
57336
+ return {
57337
+ type: "Error" /* Error */,
57338
+ message: error81 instanceof Error ? error81.message : String(error81)
57339
+ };
57340
+ }
57341
+ };
57342
+ var isAvailable14 = (provider2) => {
57343
+ return !!provider2.executeCommand;
57344
+ };
57345
+ var gitDiff_default = {
57346
+ ...toolInfo14,
57347
+ handler: handler14,
57348
+ isAvailable: isAvailable14
57349
+ };
57350
+
57351
+ // ../core/src/AiTool/reviewDiff.ts
57352
+ var prompt5 = `
57353
+ # Code Review Prompt
57354
+
57355
+ You are a senior software engineer reviewing code changes.
57356
+
57357
+ ## Critical Instructions
57358
+ **ONLY review the actual changes shown in the diff.** Do not comment on existing code that wasn't modified.
57359
+
57360
+ ## Viewing Changes
57361
+ - **Use git_diff** to inspect the actual code changes for each relevant file.
57362
+ - **Pull request**: use the provided commit range for the git_diff tool.
57363
+ - **Local changes**: diff staged or unstaged files using the git_diff tool.
57364
+ - If a pull request is present you may receive:
57365
+ - <pr_title>
57366
+ - <pr_description>
57367
+ - <commit_messages>
57368
+ - A <review_instructions> tag tells you the focus of the review.
57369
+ - File status information is provided in <file_status> - use this to understand which files were modified, added, deleted, or renamed.
57370
+
57371
+ ## Review Guidelines
57372
+ Focus exclusively on the changed lines (+ additions, - deletions, modified lines):
57373
+ - **Specific issues**: Point to exact problems in the changed code with line references
57374
+ - **Actionable fixes**: Provide concrete solutions, not vague suggestions
57375
+ - **Clear reasoning**: Explain why each issue matters and how to fix it
57376
+ - **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
57377
+
57378
+ ## What NOT to review
57379
+ - Existing unchanged code
57380
+ - Overall project structure or architecture (unless directly impacted by changes)
57381
+ - Generic best practices unrelated to the specific changes
57382
+ - Missing features or functionality not part of this diff
57383
+
57384
+ ## Output Format
57385
+ Do **not** include praise or positive feedback. Ignore generated files such as lock files.
57386
+ Only include reviews for actual issues found in the changed code.
57387
+
57388
+ Return your review as a JSON object inside a \`\`\`json block, wrapped like:
57389
+ <tool_attempt_completion>
57390
+ <tool_parameter_result>
57391
+ \`\`\`json
57392
+ {
57393
+ "overview": "Summary of specific issues found in the diff changes, or 'No issues found' if the changes look good.",
57394
+ "specificReviews": [
57395
+ {
57396
+ "file": "path/filename.ext",
57397
+ "lines": "N or N-M",
57398
+ "review": "Specific issue with the changed code and exact actionable fix."
57399
+ }
57400
+ ]
57401
+ }
57402
+ \`\`\`
57403
+ </tool_parameter_result>
57404
+ </tool_attempt_completion>
57405
+ `;
57406
+ var reviewDiff_default = {
57407
+ name: "reviewDiff",
57408
+ description: "Reviews a git diff",
57409
+ prompt: prompt5,
57410
+ formatInput: (params) => {
57411
+ const parts = [];
57412
+ if (params.pullRequestTitle) {
57413
+ parts.push(`<pr_title>
57414
+ ${params.pullRequestTitle}
57415
+ </pr_title>`);
57416
+ }
57417
+ if (params.pullRequestDescription) {
57418
+ parts.push(`<pr_description>
57419
+ ${params.pullRequestDescription}
57420
+ </pr_description>`);
57421
+ }
57422
+ if (params.commitMessages) {
57423
+ parts.push(`<commit_messages>
57424
+ ${params.commitMessages}
57425
+ </commit_messages>`);
57426
+ }
57427
+ if (params.changedFiles && params.changedFiles.length > 0) {
57428
+ const fileList = params.changedFiles.map((file3) => `${file3.status}: ${file3.path}`).join(`
57429
+ `);
57430
+ parts.push(`<file_status>
57431
+ ${fileList}
57432
+ </file_status>`);
57433
+ }
57434
+ let instructions = "";
57435
+ if (params.commitRange) {
57436
+ 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.`;
57437
+ } else if (params.staged) {
57438
+ 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.";
57439
+ } else {
57440
+ instructions = "Review the unstaged changes. Use the git_diff tool to inspect the actual code changes. File status information is already provided above.";
57441
+ }
57442
+ parts.push(`<review_instructions>
57443
+ ${instructions}
57444
+ </review_instructions>`);
57445
+ return parts.join(`
57446
+ `);
57447
+ },
57448
+ parseOutput: (output) => {
57449
+ const jsonBlockRegex = /```json\n([\s\S]*?)\n```/;
57450
+ const match = output.match(jsonBlockRegex);
57451
+ const content = match ? match[1] : output;
57452
+ try {
57453
+ return JSON.parse(content);
57454
+ } catch (error81) {
57455
+ console.error("Error parsing JSON output:", error81);
57456
+ return {
57457
+ overview: `Could not parse review output. Raw output:
57458
+ ${output}`,
57459
+ specificReviews: []
57460
+ };
57461
+ }
57462
+ },
57463
+ agent: (options) => {
57464
+ return new AnalyzerAgent({
57465
+ ...options,
57466
+ additionalTools: [gitDiff_default]
57467
+ });
57468
+ }
57469
+ };
57470
+
57192
57471
  // ../core/src/AiTool/index.ts
57193
57472
  var executeTool = async (definition, ai, params, usageMeter) => {
57194
57473
  const resp = await generateText({
@@ -57204,10 +57483,7 @@ var executeTool = async (definition, ai, params, usageMeter) => {
57204
57483
  usageMeter.addUsage(ai, resp);
57205
57484
  return definition.parseOutput(resp.text);
57206
57485
  };
57207
- var executeAgentTool = async (definition, agent, params) => {
57208
- if (!definition.agent) {
57209
- throw new Error("Agent not specified");
57210
- }
57486
+ var executeMultiAgentTool = async (definition, agent, params) => {
57211
57487
  const exitReason = await agent.startTask({
57212
57488
  agentName: definition.agent,
57213
57489
  task: definition.prompt,
@@ -57218,22 +57494,38 @@ var executeAgentTool = async (definition, agent, params) => {
57218
57494
  }
57219
57495
  throw new Error(`Tool execution failed: ${exitReason.type}`);
57220
57496
  };
57497
+ var executeAgentTool = async (definition, options, params) => {
57498
+ const agent = definition.agent(options);
57499
+ const exitReason = await agent.start(`${definition.prompt}
57500
+
57501
+ ${definition.formatInput(params)}`);
57502
+ if (exitReason.type === "Exit" /* Exit */) {
57503
+ return definition.parseOutput(exitReason.message);
57504
+ }
57505
+ throw new Error(`Tool execution failed: ${exitReason.type}`);
57506
+ };
57221
57507
  var makeTool = (definition) => {
57222
57508
  return async (ai, params, usageMeter) => {
57223
57509
  return executeTool(definition, ai, params, usageMeter);
57224
57510
  };
57225
57511
  };
57226
- var makeAgentTool = (definition) => {
57512
+ var makeMultiAgentTool = (definition) => {
57227
57513
  return async (agent, params) => {
57228
- return executeAgentTool(definition, agent, params);
57514
+ return executeMultiAgentTool(definition, agent, params);
57515
+ };
57516
+ };
57517
+ var makeAgentTool = (definition) => {
57518
+ return async (options, params) => {
57519
+ return executeAgentTool(definition, options, params);
57229
57520
  };
57230
57521
  };
57231
57522
  var generateGitCommitMessage = makeTool(generateGitCommitMessage_default);
57232
57523
  var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails_default);
57233
- var generateProjectConfig = makeAgentTool(generateProjectConfig_default);
57234
- var createNewProject = makeAgentTool(createNewProject_default);
57524
+ var reviewDiff = makeAgentTool(reviewDiff_default);
57525
+ var generateProjectConfig = makeMultiAgentTool(generateProjectConfig_default);
57526
+ var createNewProject = makeMultiAgentTool(createNewProject_default);
57235
57527
  // ../cli-shared/src/config.ts
57236
- var import_lodash = __toESM(require_lodash(), 1);
57528
+ var import_lodash2 = __toESM(require_lodash(), 1);
57237
57529
 
57238
57530
  // ../cli-shared/node_modules/yaml/dist/index.js
57239
57531
  var composer = require_composer();
@@ -61137,7 +61429,7 @@ function mergeConfigs(configs) {
61137
61429
  return {};
61138
61430
  }
61139
61431
  const mergedConfig = configs.reduce((acc, config4) => {
61140
- const merged = import_lodash.merge({}, acc, config4);
61432
+ const merged = import_lodash2.merge({}, acc, config4);
61141
61433
  let accRules = acc.rules ?? [];
61142
61434
  if (typeof accRules === "string") {
61143
61435
  accRules = [accRules];
@@ -61761,15 +62053,15 @@ function useKeypress(userHandler) {
61761
62053
  signal.current = userHandler;
61762
62054
  useEffect((rl) => {
61763
62055
  let ignore = false;
61764
- const handler14 = withUpdates((_input, event) => {
62056
+ const handler15 = withUpdates((_input, event) => {
61765
62057
  if (ignore)
61766
62058
  return;
61767
62059
  signal.current(event, rl);
61768
62060
  });
61769
- rl.input.on("keypress", handler14);
62061
+ rl.input.on("keypress", handler15);
61770
62062
  return () => {
61771
62063
  ignore = true;
61772
- rl.input.removeListener("keypress", handler14);
62064
+ rl.input.removeListener("keypress", handler15);
61773
62065
  };
61774
62066
  }, []);
61775
62067
  }
@@ -61928,16 +62220,16 @@ class Emitter {
61928
62220
 
61929
62221
  class SignalExitBase {
61930
62222
  }
61931
- var signalExitWrap = (handler14) => {
62223
+ var signalExitWrap = (handler15) => {
61932
62224
  return {
61933
62225
  onExit(cb, opts) {
61934
- return handler14.onExit(cb, opts);
62226
+ return handler15.onExit(cb, opts);
61935
62227
  },
61936
62228
  load() {
61937
- return handler14.load();
62229
+ return handler15.load();
61938
62230
  },
61939
62231
  unload() {
61940
- return handler14.unload();
62232
+ return handler15.unload();
61941
62233
  }
61942
62234
  };
61943
62235
  };
@@ -62093,11 +62385,11 @@ class ScreenManager {
62093
62385
  render(content, bottomContent = "") {
62094
62386
  const promptLine = lastLine(content);
62095
62387
  const rawPromptLine = stripVTControlCharacters(promptLine);
62096
- let prompt5 = rawPromptLine;
62388
+ let prompt6 = rawPromptLine;
62097
62389
  if (this.rl.line.length > 0) {
62098
- prompt5 = prompt5.slice(0, -this.rl.line.length);
62390
+ prompt6 = prompt6.slice(0, -this.rl.line.length);
62099
62391
  }
62100
- this.rl.setPrompt(prompt5);
62392
+ this.rl.setPrompt(prompt6);
62101
62393
  this.cursorPos = this.rl.getCursorPos();
62102
62394
  const width = readlineWidth();
62103
62395
  content = breakLines(content, width);
@@ -62167,7 +62459,7 @@ function getCallSites() {
62167
62459
  }
62168
62460
  function createPrompt(view) {
62169
62461
  const callSites = getCallSites();
62170
- const prompt5 = (config4, context = {}) => {
62462
+ const prompt6 = (config4, context = {}) => {
62171
62463
  const { input = process.stdin, signal } = context;
62172
62464
  const cleanups = new Set;
62173
62465
  const output = new import_mute_stream.default;
@@ -62232,7 +62524,7 @@ function createPrompt(view) {
62232
62524
  }).then(() => promise4), { cancel });
62233
62525
  });
62234
62526
  };
62235
- return prompt5;
62527
+ return prompt6;
62236
62528
  }
62237
62529
  // ../../node_modules/@inquirer/core/dist/esm/lib/Separator.js
62238
62530
  var import_yoctocolors_cjs2 = __toESM(require_yoctocolors_cjs(), 1);