@polka-codes/cli 0.8.12 → 0.8.14

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 +162 -107
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -31615,17 +31615,17 @@ var require_visit3 = __commonJS((exports) => {
31615
31615
  visit2.BREAK = BREAK;
31616
31616
  visit2.SKIP = SKIP;
31617
31617
  visit2.REMOVE = REMOVE;
31618
- function visit_(key2, node, visitor, path2) {
31619
- const ctrl = callVisitor(key2, node, visitor, path2);
31618
+ function visit_(key2, node, visitor, path) {
31619
+ const ctrl = callVisitor(key2, node, visitor, path);
31620
31620
  if (identity2.isNode(ctrl) || identity2.isPair(ctrl)) {
31621
- replaceNode(key2, path2, ctrl);
31622
- return visit_(key2, ctrl, visitor, path2);
31621
+ replaceNode(key2, path, ctrl);
31622
+ return visit_(key2, ctrl, visitor, path);
31623
31623
  }
31624
31624
  if (typeof ctrl !== "symbol") {
31625
31625
  if (identity2.isCollection(node)) {
31626
- path2 = Object.freeze(path2.concat(node));
31626
+ path = Object.freeze(path.concat(node));
31627
31627
  for (let i2 = 0;i2 < node.items.length; ++i2) {
31628
- const ci = visit_(i2, node.items[i2], visitor, path2);
31628
+ const ci = visit_(i2, node.items[i2], visitor, path);
31629
31629
  if (typeof ci === "number")
31630
31630
  i2 = ci - 1;
31631
31631
  else if (ci === BREAK)
@@ -31636,13 +31636,13 @@ var require_visit3 = __commonJS((exports) => {
31636
31636
  }
31637
31637
  }
31638
31638
  } else if (identity2.isPair(node)) {
31639
- path2 = Object.freeze(path2.concat(node));
31640
- const ck = visit_("key", node.key, visitor, path2);
31639
+ path = Object.freeze(path.concat(node));
31640
+ const ck = visit_("key", node.key, visitor, path);
31641
31641
  if (ck === BREAK)
31642
31642
  return BREAK;
31643
31643
  else if (ck === REMOVE)
31644
31644
  node.key = null;
31645
- const cv = visit_("value", node.value, visitor, path2);
31645
+ const cv = visit_("value", node.value, visitor, path);
31646
31646
  if (cv === BREAK)
31647
31647
  return BREAK;
31648
31648
  else if (cv === REMOVE)
@@ -31663,17 +31663,17 @@ var require_visit3 = __commonJS((exports) => {
31663
31663
  visitAsync.BREAK = BREAK;
31664
31664
  visitAsync.SKIP = SKIP;
31665
31665
  visitAsync.REMOVE = REMOVE;
31666
- async function visitAsync_(key2, node, visitor, path2) {
31667
- const ctrl = await callVisitor(key2, node, visitor, path2);
31666
+ async function visitAsync_(key2, node, visitor, path) {
31667
+ const ctrl = await callVisitor(key2, node, visitor, path);
31668
31668
  if (identity2.isNode(ctrl) || identity2.isPair(ctrl)) {
31669
- replaceNode(key2, path2, ctrl);
31670
- return visitAsync_(key2, ctrl, visitor, path2);
31669
+ replaceNode(key2, path, ctrl);
31670
+ return visitAsync_(key2, ctrl, visitor, path);
31671
31671
  }
31672
31672
  if (typeof ctrl !== "symbol") {
31673
31673
  if (identity2.isCollection(node)) {
31674
- path2 = Object.freeze(path2.concat(node));
31674
+ path = Object.freeze(path.concat(node));
31675
31675
  for (let i2 = 0;i2 < node.items.length; ++i2) {
31676
- const ci = await visitAsync_(i2, node.items[i2], visitor, path2);
31676
+ const ci = await visitAsync_(i2, node.items[i2], visitor, path);
31677
31677
  if (typeof ci === "number")
31678
31678
  i2 = ci - 1;
31679
31679
  else if (ci === BREAK)
@@ -31684,13 +31684,13 @@ var require_visit3 = __commonJS((exports) => {
31684
31684
  }
31685
31685
  }
31686
31686
  } else if (identity2.isPair(node)) {
31687
- path2 = Object.freeze(path2.concat(node));
31688
- const ck = await visitAsync_("key", node.key, visitor, path2);
31687
+ path = Object.freeze(path.concat(node));
31688
+ const ck = await visitAsync_("key", node.key, visitor, path);
31689
31689
  if (ck === BREAK)
31690
31690
  return BREAK;
31691
31691
  else if (ck === REMOVE)
31692
31692
  node.key = null;
31693
- const cv = await visitAsync_("value", node.value, visitor, path2);
31693
+ const cv = await visitAsync_("value", node.value, visitor, path);
31694
31694
  if (cv === BREAK)
31695
31695
  return BREAK;
31696
31696
  else if (cv === REMOVE)
@@ -31717,23 +31717,23 @@ var require_visit3 = __commonJS((exports) => {
31717
31717
  }
31718
31718
  return visitor;
31719
31719
  }
31720
- function callVisitor(key2, node, visitor, path2) {
31720
+ function callVisitor(key2, node, visitor, path) {
31721
31721
  if (typeof visitor === "function")
31722
- return visitor(key2, node, path2);
31722
+ return visitor(key2, node, path);
31723
31723
  if (identity2.isMap(node))
31724
- return visitor.Map?.(key2, node, path2);
31724
+ return visitor.Map?.(key2, node, path);
31725
31725
  if (identity2.isSeq(node))
31726
- return visitor.Seq?.(key2, node, path2);
31726
+ return visitor.Seq?.(key2, node, path);
31727
31727
  if (identity2.isPair(node))
31728
- return visitor.Pair?.(key2, node, path2);
31728
+ return visitor.Pair?.(key2, node, path);
31729
31729
  if (identity2.isScalar(node))
31730
- return visitor.Scalar?.(key2, node, path2);
31730
+ return visitor.Scalar?.(key2, node, path);
31731
31731
  if (identity2.isAlias(node))
31732
- return visitor.Alias?.(key2, node, path2);
31732
+ return visitor.Alias?.(key2, node, path);
31733
31733
  return;
31734
31734
  }
31735
- function replaceNode(key2, path2, node) {
31736
- const parent = path2[path2.length - 1];
31735
+ function replaceNode(key2, path, node) {
31736
+ const parent = path[path.length - 1];
31737
31737
  if (identity2.isCollection(parent)) {
31738
31738
  parent.items[key2] = node;
31739
31739
  } else if (identity2.isPair(parent)) {
@@ -32280,10 +32280,10 @@ var require_Collection3 = __commonJS((exports) => {
32280
32280
  var createNode = require_createNode3();
32281
32281
  var identity2 = require_identity3();
32282
32282
  var Node = require_Node3();
32283
- function collectionFromPath(schema, path2, value) {
32283
+ function collectionFromPath(schema, path, value) {
32284
32284
  let v2 = value;
32285
- for (let i2 = path2.length - 1;i2 >= 0; --i2) {
32286
- const k2 = path2[i2];
32285
+ for (let i2 = path.length - 1;i2 >= 0; --i2) {
32286
+ const k2 = path[i2];
32287
32287
  if (typeof k2 === "number" && Number.isInteger(k2) && k2 >= 0) {
32288
32288
  const a2 = [];
32289
32289
  a2[k2] = v2;
@@ -32302,7 +32302,7 @@ var require_Collection3 = __commonJS((exports) => {
32302
32302
  sourceObjects: new Map
32303
32303
  });
32304
32304
  }
32305
- var isEmptyPath = (path2) => path2 == null || typeof path2 === "object" && !!path2[Symbol.iterator]().next().done;
32305
+ var isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done;
32306
32306
 
32307
32307
  class Collection extends Node.NodeBase {
32308
32308
  constructor(type, schema) {
@@ -32323,11 +32323,11 @@ var require_Collection3 = __commonJS((exports) => {
32323
32323
  copy.range = this.range.slice();
32324
32324
  return copy;
32325
32325
  }
32326
- addIn(path2, value) {
32327
- if (isEmptyPath(path2))
32326
+ addIn(path, value) {
32327
+ if (isEmptyPath(path))
32328
32328
  this.add(value);
32329
32329
  else {
32330
- const [key2, ...rest] = path2;
32330
+ const [key2, ...rest] = path;
32331
32331
  const node = this.get(key2, true);
32332
32332
  if (identity2.isCollection(node))
32333
32333
  node.addIn(rest, value);
@@ -32337,8 +32337,8 @@ var require_Collection3 = __commonJS((exports) => {
32337
32337
  throw new Error(`Expected YAML collection at ${key2}. Remaining path: ${rest}`);
32338
32338
  }
32339
32339
  }
32340
- deleteIn(path2) {
32341
- const [key2, ...rest] = path2;
32340
+ deleteIn(path) {
32341
+ const [key2, ...rest] = path;
32342
32342
  if (rest.length === 0)
32343
32343
  return this.delete(key2);
32344
32344
  const node = this.get(key2, true);
@@ -32347,8 +32347,8 @@ var require_Collection3 = __commonJS((exports) => {
32347
32347
  else
32348
32348
  throw new Error(`Expected YAML collection at ${key2}. Remaining path: ${rest}`);
32349
32349
  }
32350
- getIn(path2, keepScalar) {
32351
- const [key2, ...rest] = path2;
32350
+ getIn(path, keepScalar) {
32351
+ const [key2, ...rest] = path;
32352
32352
  const node = this.get(key2, true);
32353
32353
  if (rest.length === 0)
32354
32354
  return !keepScalar && identity2.isScalar(node) ? node.value : node;
@@ -32363,15 +32363,15 @@ var require_Collection3 = __commonJS((exports) => {
32363
32363
  return n2 == null || allowScalar && identity2.isScalar(n2) && n2.value == null && !n2.commentBefore && !n2.comment && !n2.tag;
32364
32364
  });
32365
32365
  }
32366
- hasIn(path2) {
32367
- const [key2, ...rest] = path2;
32366
+ hasIn(path) {
32367
+ const [key2, ...rest] = path;
32368
32368
  if (rest.length === 0)
32369
32369
  return this.has(key2);
32370
32370
  const node = this.get(key2, true);
32371
32371
  return identity2.isCollection(node) ? node.hasIn(rest) : false;
32372
32372
  }
32373
- setIn(path2, value) {
32374
- const [key2, ...rest] = path2;
32373
+ setIn(path, value) {
32374
+ const [key2, ...rest] = path;
32375
32375
  if (rest.length === 0) {
32376
32376
  this.set(key2, value);
32377
32377
  } else {
@@ -34753,9 +34753,9 @@ var require_Document3 = __commonJS((exports) => {
34753
34753
  if (assertCollection(this.contents))
34754
34754
  this.contents.add(value);
34755
34755
  }
34756
- addIn(path2, value) {
34756
+ addIn(path, value) {
34757
34757
  if (assertCollection(this.contents))
34758
- this.contents.addIn(path2, value);
34758
+ this.contents.addIn(path, value);
34759
34759
  }
34760
34760
  createAlias(node, name) {
34761
34761
  if (!node.anchor) {
@@ -34804,30 +34804,30 @@ var require_Document3 = __commonJS((exports) => {
34804
34804
  delete(key2) {
34805
34805
  return assertCollection(this.contents) ? this.contents.delete(key2) : false;
34806
34806
  }
34807
- deleteIn(path2) {
34808
- if (Collection.isEmptyPath(path2)) {
34807
+ deleteIn(path) {
34808
+ if (Collection.isEmptyPath(path)) {
34809
34809
  if (this.contents == null)
34810
34810
  return false;
34811
34811
  this.contents = null;
34812
34812
  return true;
34813
34813
  }
34814
- return assertCollection(this.contents) ? this.contents.deleteIn(path2) : false;
34814
+ return assertCollection(this.contents) ? this.contents.deleteIn(path) : false;
34815
34815
  }
34816
34816
  get(key2, keepScalar) {
34817
34817
  return identity2.isCollection(this.contents) ? this.contents.get(key2, keepScalar) : undefined;
34818
34818
  }
34819
- getIn(path2, keepScalar) {
34820
- if (Collection.isEmptyPath(path2))
34819
+ getIn(path, keepScalar) {
34820
+ if (Collection.isEmptyPath(path))
34821
34821
  return !keepScalar && identity2.isScalar(this.contents) ? this.contents.value : this.contents;
34822
- return identity2.isCollection(this.contents) ? this.contents.getIn(path2, keepScalar) : undefined;
34822
+ return identity2.isCollection(this.contents) ? this.contents.getIn(path, keepScalar) : undefined;
34823
34823
  }
34824
34824
  has(key2) {
34825
34825
  return identity2.isCollection(this.contents) ? this.contents.has(key2) : false;
34826
34826
  }
34827
- hasIn(path2) {
34828
- if (Collection.isEmptyPath(path2))
34827
+ hasIn(path) {
34828
+ if (Collection.isEmptyPath(path))
34829
34829
  return this.contents !== undefined;
34830
- return identity2.isCollection(this.contents) ? this.contents.hasIn(path2) : false;
34830
+ return identity2.isCollection(this.contents) ? this.contents.hasIn(path) : false;
34831
34831
  }
34832
34832
  set(key2, value) {
34833
34833
  if (this.contents == null) {
@@ -34836,13 +34836,13 @@ var require_Document3 = __commonJS((exports) => {
34836
34836
  this.contents.set(key2, value);
34837
34837
  }
34838
34838
  }
34839
- setIn(path2, value) {
34840
- if (Collection.isEmptyPath(path2)) {
34839
+ setIn(path, value) {
34840
+ if (Collection.isEmptyPath(path)) {
34841
34841
  this.contents = value;
34842
34842
  } else if (this.contents == null) {
34843
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path2), value);
34843
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path), value);
34844
34844
  } else if (assertCollection(this.contents)) {
34845
- this.contents.setIn(path2, value);
34845
+ this.contents.setIn(path, value);
34846
34846
  }
34847
34847
  }
34848
34848
  setSchema(version2, options = {}) {
@@ -36734,9 +36734,9 @@ var require_cst_visit3 = __commonJS((exports) => {
36734
36734
  visit2.BREAK = BREAK;
36735
36735
  visit2.SKIP = SKIP;
36736
36736
  visit2.REMOVE = REMOVE;
36737
- visit2.itemAtPath = (cst2, path2) => {
36737
+ visit2.itemAtPath = (cst2, path) => {
36738
36738
  let item = cst2;
36739
- for (const [field, index] of path2) {
36739
+ for (const [field, index] of path) {
36740
36740
  const tok = item?.[field];
36741
36741
  if (tok && "items" in tok) {
36742
36742
  item = tok.items[index];
@@ -36745,23 +36745,23 @@ var require_cst_visit3 = __commonJS((exports) => {
36745
36745
  }
36746
36746
  return item;
36747
36747
  };
36748
- visit2.parentCollection = (cst2, path2) => {
36749
- const parent = visit2.itemAtPath(cst2, path2.slice(0, -1));
36750
- const field = path2[path2.length - 1][0];
36748
+ visit2.parentCollection = (cst2, path) => {
36749
+ const parent = visit2.itemAtPath(cst2, path.slice(0, -1));
36750
+ const field = path[path.length - 1][0];
36751
36751
  const coll = parent?.[field];
36752
36752
  if (coll && "items" in coll)
36753
36753
  return coll;
36754
36754
  throw new Error("Parent collection not found");
36755
36755
  };
36756
- function _visit(path2, item, visitor) {
36757
- let ctrl = visitor(item, path2);
36756
+ function _visit(path, item, visitor) {
36757
+ let ctrl = visitor(item, path);
36758
36758
  if (typeof ctrl === "symbol")
36759
36759
  return ctrl;
36760
36760
  for (const field of ["key", "value"]) {
36761
36761
  const token = item[field];
36762
36762
  if (token && "items" in token) {
36763
36763
  for (let i2 = 0;i2 < token.items.length; ++i2) {
36764
- const ci = _visit(Object.freeze(path2.concat([[field, i2]])), token.items[i2], visitor);
36764
+ const ci = _visit(Object.freeze(path.concat([[field, i2]])), token.items[i2], visitor);
36765
36765
  if (typeof ci === "number")
36766
36766
  i2 = ci - 1;
36767
36767
  else if (ci === BREAK)
@@ -36772,10 +36772,10 @@ var require_cst_visit3 = __commonJS((exports) => {
36772
36772
  }
36773
36773
  }
36774
36774
  if (typeof ctrl === "function" && field === "key")
36775
- ctrl = ctrl(item, path2);
36775
+ ctrl = ctrl(item, path);
36776
36776
  }
36777
36777
  }
36778
- return typeof ctrl === "function" ? ctrl(item, path2) : ctrl;
36778
+ return typeof ctrl === "function" ? ctrl(item, path) : ctrl;
36779
36779
  }
36780
36780
  exports.visit = visit2;
36781
36781
  });
@@ -38447,7 +38447,7 @@ var {
38447
38447
  Help
38448
38448
  } = import__.default;
38449
38449
  // package.json
38450
- var version = "0.8.12";
38450
+ var version = "0.8.14";
38451
38451
 
38452
38452
  // ../core/src/AiService/AiServiceBase.ts
38453
38453
  class AiServiceBase {
@@ -48240,11 +48240,11 @@ var delegate_default = {
48240
48240
  // ../core/src/tools/executeCommand.ts
48241
48241
  var toolInfo4 = {
48242
48242
  name: "execute_command",
48243
- description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. After an `execute_command` call, no other tool calls are allowed in the same assistant response.",
48243
+ description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. **IMPORTANT**: After an `execute_command` call, you MUST stop and NOT allowed to make further tool calls in the same message.",
48244
48244
  parameters: [
48245
48245
  {
48246
48246
  name: "command",
48247
- description: "The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.",
48247
+ description: "The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.",
48248
48248
  required: true,
48249
48249
  usageValue: "your-command-here"
48250
48250
  },
@@ -49520,7 +49520,7 @@ var toolUsePrompt = (tools, toolNamePrefix) => {
49520
49520
 
49521
49521
  TOOL USE
49522
49522
 
49523
- You have access to a set of tools that are executed upon the user's approval. You can use one tool per message, and will receive the result of that tool use in the user's response. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.
49523
+ You have access to a set of tools that are executed upon the user's approval. You can use up to 5 tool calls per message, and will receive the results of those tool uses in the user's response. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.
49524
49524
 
49525
49525
  # Tool Use Formatting
49526
49526
 
@@ -49586,18 +49586,16 @@ ${tools.map((tool) => {
49586
49586
 
49587
49587
  1. **Outline Your Thought Process**
49588
49588
  - Before using a tool, wrap your reasoning inside \`<thinking>\` tags. Be concise—just enough to clarify your plan and the rationale behind selecting a specific tool.
49589
-
49590
49589
  2. **Wait for Feedback**
49591
49590
  - After using a tool, wait for the user's response indicating success/failure or any output logs. Do not assume the result of a tool without explicit confirmation.
49592
-
49593
49591
  3. **Error Handling**
49594
49592
  - If a tool fails or produces an unexpected result, analyze the error, decide on an alternative approach or tool, and proceed carefully.
49595
-
49596
49593
  4. **Avoid Repetition**
49597
49594
  - Do not quote or repeat previous commands or prompts verbatim. Move the conversation forward by focusing on the latest required action.
49598
-
49599
49595
  5. **No Unnecessary Re-invocations**
49600
- - Only invoke the same tool again if a genuine need arises (e.g., different parameters or updated context).`;
49596
+ - Only invoke the same tool again if a genuine need arises (e.g., different parameters or updated context).
49597
+ 6. **Tool Call Limit**
49598
+ - Do not make more than 5 tool calls in a single message.`;
49601
49599
  };
49602
49600
  var agentsPrompt = (agents, name) => `
49603
49601
  ====
@@ -54728,6 +54726,65 @@ var KnowledgeManagementPolicy = (tools) => {
54728
54726
  }
54729
54727
  };
54730
54728
  };
54729
+ // ../core/src/Agent/policies/TruncateContext.ts
54730
+ var DEFAULT_MAX_TOKENS_ESTIMATE = 8000;
54731
+ function getMaxTokens(agent) {
54732
+ const params = agent.parameters || {};
54733
+ if (params.maxTokens && typeof params.maxTokens === "number" && params.maxTokens > 0) {
54734
+ return params.maxTokens;
54735
+ }
54736
+ return DEFAULT_MAX_TOKENS_ESTIMATE;
54737
+ }
54738
+ function estimateTokens(text) {
54739
+ return Math.ceil(text.length / 4);
54740
+ }
54741
+ var TruncateContextPolicy = (tools) => {
54742
+ return {
54743
+ name: "truncatecontext" /* TruncateContext */,
54744
+ async onBeforeRequest(agent) {
54745
+ const messages = agent.messages;
54746
+ if (messages.length < 3) {
54747
+ return;
54748
+ }
54749
+ let totalTokens = 0;
54750
+ for (const msg of messages) {
54751
+ if (typeof msg.content === "string") {
54752
+ totalTokens += estimateTokens(msg.content);
54753
+ } else if (Array.isArray(msg.content)) {
54754
+ for (const block of msg.content) {
54755
+ if (typeof block === "object" && "text" in block && typeof block.text === "string") {
54756
+ totalTokens += estimateTokens(block.text);
54757
+ }
54758
+ }
54759
+ }
54760
+ }
54761
+ const maxTokens = getMaxTokens(agent);
54762
+ if (totalTokens <= maxTokens) {
54763
+ return;
54764
+ }
54765
+ const totalMessages = messages.length;
54766
+ const messagesToKeep = Math.ceil(totalMessages / 2);
54767
+ const minKeep = Math.max(2, messagesToKeep);
54768
+ if (minKeep >= totalMessages) {
54769
+ return;
54770
+ }
54771
+ const keepFromStart = Math.floor(minKeep / 2);
54772
+ const keepFromEnd = minKeep - keepFromStart;
54773
+ const startMessages = messages.slice(0, keepFromStart);
54774
+ const endMessages = messages.slice(-keepFromEnd);
54775
+ const truncatedCount = totalMessages - minKeep;
54776
+ const truncatedMessages = [
54777
+ ...startMessages,
54778
+ {
54779
+ role: "user",
54780
+ content: `Note: ${truncatedCount} messages were truncated from the middle to prevent context overflow.`
54781
+ },
54782
+ ...endMessages
54783
+ ];
54784
+ agent.setMessages(truncatedMessages);
54785
+ }
54786
+ };
54787
+ };
54731
54788
  // ../core/src/Agent/index.ts
54732
54789
  var allAgents = [architectAgentInfo, coderAgentInfo, analyzerAgentInfo, codeFixerAgentInfo];
54733
54790
  // ../core/src/AiTool/createNewProject.ts
@@ -60689,14 +60746,8 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
60689
60746
 
60690
60747
  // ../cli-shared/src/utils/searchFiles.ts
60691
60748
  import { spawn } from "node:child_process";
60692
-
60693
- // ../../node_modules/@vscode/ripgrep/lib/index.js
60694
- var __dirname = "/Users/xiliangchen/projects/polka-codes/node_modules/@vscode/ripgrep/lib";
60695
- var path = __require("path");
60696
- var $rgPath = path.join(__dirname, `../bin/rg${process.platform === "win32" ? ".exe" : ""}`);
60697
-
60698
- // ../cli-shared/src/utils/searchFiles.ts
60699
- async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
60749
+ import { rgPath } from "@vscode/ripgrep";
60750
+ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
60700
60751
  const args = [
60701
60752
  "--line-number",
60702
60753
  "--context=5",
@@ -60717,10 +60768,10 @@ async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
60717
60768
  args.push("--glob", `!${pattern}`);
60718
60769
  }
60719
60770
  }
60720
- args.push(regex, path2);
60771
+ args.push(regex, path);
60721
60772
  return new Promise((resolve2, reject) => {
60722
60773
  const results = [];
60723
- const rg = spawn($rgPath, args, {
60774
+ const rg = spawn(rgPath, args, {
60724
60775
  cwd,
60725
60776
  stdio: ["ignore", "pipe", "pipe"]
60726
60777
  });
@@ -60746,28 +60797,28 @@ async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
60746
60797
  var getProvider = (agentName, config2, options = {}) => {
60747
60798
  const ig = import_ignore2.default().add(options.excludeFiles ?? []);
60748
60799
  const provider2 = {
60749
- readFile: async (path2) => {
60750
- if (ig.ignores(path2)) {
60751
- throw new Error(`Not allow to access file ${path2}`);
60800
+ readFile: async (path) => {
60801
+ if (ig.ignores(path)) {
60802
+ throw new Error(`Not allow to access file ${path}`);
60752
60803
  }
60753
60804
  try {
60754
- return await readFile(path2, "utf8");
60805
+ return await readFile(path, "utf8");
60755
60806
  } catch (_e2) {
60756
60807
  return;
60757
60808
  }
60758
60809
  },
60759
- writeFile: async (path2, content) => {
60760
- if (ig.ignores(path2)) {
60761
- throw new Error(`Not allow to access file ${path2}`);
60810
+ writeFile: async (path, content) => {
60811
+ if (ig.ignores(path)) {
60812
+ throw new Error(`Not allow to access file ${path}`);
60762
60813
  }
60763
- await mkdir(dirname2(path2), { recursive: true });
60764
- return await writeFile(path2, content, "utf8");
60814
+ await mkdir(dirname2(path), { recursive: true });
60815
+ return await writeFile(path, content, "utf8");
60765
60816
  },
60766
- removeFile: async (path2) => {
60767
- if (ig.ignores(path2)) {
60768
- throw new Error(`Not allow to access file ${path2}`);
60817
+ removeFile: async (path) => {
60818
+ if (ig.ignores(path)) {
60819
+ throw new Error(`Not allow to access file ${path}`);
60769
60820
  }
60770
- return await unlink(path2);
60821
+ return await unlink(path);
60771
60822
  },
60772
60823
  renameFile: async (sourcePath, targetPath) => {
60773
60824
  if (ig.ignores(sourcePath) || ig.ignores(targetPath)) {
@@ -60775,11 +60826,11 @@ var getProvider = (agentName, config2, options = {}) => {
60775
60826
  }
60776
60827
  return await rename(sourcePath, targetPath);
60777
60828
  },
60778
- listFiles: async (path2, recursive, maxCount) => {
60779
- return await listFiles(path2, recursive, maxCount, process.cwd(), options.excludeFiles);
60829
+ listFiles: async (path, recursive, maxCount) => {
60830
+ return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
60780
60831
  },
60781
- searchFiles: async (path2, regex, filePattern) => {
60782
- return await searchFiles(path2, regex, filePattern, process.cwd(), options.excludeFiles);
60832
+ searchFiles: async (path, regex, filePattern) => {
60833
+ return await searchFiles(path, regex, filePattern, process.cwd(), options.excludeFiles);
60783
60834
  },
60784
60835
  executeCommand: (command, needApprove) => {
60785
60836
  return new Promise((resolve2, reject) => {
@@ -61503,6 +61554,10 @@ class Runner {
61503
61554
  this.#hasKnowledgeManagementPolicy = true;
61504
61555
  console.log("KnowledgeManagementPolicy enabled");
61505
61556
  break;
61557
+ case "truncatecontext" /* TruncateContext */:
61558
+ policies2.push(TruncateContextPolicy);
61559
+ console.log("TruncateContextPolicy enabled");
61560
+ break;
61506
61561
  default:
61507
61562
  console.log("Unknown policy:", policy);
61508
61563
  break;
@@ -63005,8 +63060,8 @@ function getErrorMap3() {
63005
63060
  return overrideErrorMap3;
63006
63061
  }
63007
63062
  var makeIssue3 = (params) => {
63008
- const { data, path: path2, errorMaps, issueData } = params;
63009
- const fullPath = [...path2, ...issueData.path || []];
63063
+ const { data, path, errorMaps, issueData } = params;
63064
+ const fullPath = [...path, ...issueData.path || []];
63010
63065
  const fullIssue = {
63011
63066
  ...issueData,
63012
63067
  path: fullPath
@@ -63133,11 +63188,11 @@ var _ZodEnum_cache3;
63133
63188
  var _ZodNativeEnum_cache3;
63134
63189
 
63135
63190
  class ParseInputLazyPath3 {
63136
- constructor(parent, value, path2, key2) {
63191
+ constructor(parent, value, path, key2) {
63137
63192
  this._cachedPath = [];
63138
63193
  this.parent = parent;
63139
63194
  this.data = value;
63140
- this._path = path2;
63195
+ this._path = path;
63141
63196
  this._key = key2;
63142
63197
  }
63143
63198
  get path() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.8.12",
3
+ "version": "0.8.14",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  }
15
15
  },
16
16
  "scripts": {
17
- "build": "bun build src/index.ts --outdir dist --target node"
17
+ "build": "bun build src/index.ts --outdir dist --target node --external=@vscode/ripgrep"
18
18
  },
19
19
  "dependencies": {
20
20
  "@inquirer/prompts": "^7.2.3",