@polka-codes/cli 0.8.13 → 0.8.15

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 +93 -99
  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.13";
38450
+ var version = "0.8.15";
38451
38451
 
38452
38452
  // ../core/src/AiService/AiServiceBase.ts
38453
38453
  class AiServiceBase {
@@ -60746,14 +60746,8 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
60746
60746
 
60747
60747
  // ../cli-shared/src/utils/searchFiles.ts
60748
60748
  import { spawn } from "node:child_process";
60749
-
60750
- // ../../node_modules/@vscode/ripgrep/lib/index.js
60751
- var __dirname = "/Users/xiliangchen/projects/polka-codes/node_modules/@vscode/ripgrep/lib";
60752
- var path = __require("path");
60753
- var $rgPath = path.join(__dirname, `../bin/rg${process.platform === "win32" ? ".exe" : ""}`);
60754
-
60755
- // ../cli-shared/src/utils/searchFiles.ts
60756
- async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
60749
+ import { rgPath } from "@vscode/ripgrep";
60750
+ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
60757
60751
  const args = [
60758
60752
  "--line-number",
60759
60753
  "--context=5",
@@ -60774,10 +60768,10 @@ async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
60774
60768
  args.push("--glob", `!${pattern}`);
60775
60769
  }
60776
60770
  }
60777
- args.push(regex, path2);
60771
+ args.push(regex, path);
60778
60772
  return new Promise((resolve2, reject) => {
60779
60773
  const results = [];
60780
- const rg = spawn($rgPath, args, {
60774
+ const rg = spawn(rgPath, args, {
60781
60775
  cwd,
60782
60776
  stdio: ["ignore", "pipe", "pipe"]
60783
60777
  });
@@ -60803,28 +60797,28 @@ async function searchFiles(path2, regex, filePattern, cwd, excludeFiles) {
60803
60797
  var getProvider = (agentName, config2, options = {}) => {
60804
60798
  const ig = import_ignore2.default().add(options.excludeFiles ?? []);
60805
60799
  const provider2 = {
60806
- readFile: async (path2) => {
60807
- if (ig.ignores(path2)) {
60808
- 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}`);
60809
60803
  }
60810
60804
  try {
60811
- return await readFile(path2, "utf8");
60805
+ return await readFile(path, "utf8");
60812
60806
  } catch (_e2) {
60813
60807
  return;
60814
60808
  }
60815
60809
  },
60816
- writeFile: async (path2, content) => {
60817
- if (ig.ignores(path2)) {
60818
- 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}`);
60819
60813
  }
60820
- await mkdir(dirname2(path2), { recursive: true });
60821
- return await writeFile(path2, content, "utf8");
60814
+ await mkdir(dirname2(path), { recursive: true });
60815
+ return await writeFile(path, content, "utf8");
60822
60816
  },
60823
- removeFile: async (path2) => {
60824
- if (ig.ignores(path2)) {
60825
- 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}`);
60826
60820
  }
60827
- return await unlink(path2);
60821
+ return await unlink(path);
60828
60822
  },
60829
60823
  renameFile: async (sourcePath, targetPath) => {
60830
60824
  if (ig.ignores(sourcePath) || ig.ignores(targetPath)) {
@@ -60832,11 +60826,11 @@ var getProvider = (agentName, config2, options = {}) => {
60832
60826
  }
60833
60827
  return await rename(sourcePath, targetPath);
60834
60828
  },
60835
- listFiles: async (path2, recursive, maxCount) => {
60836
- 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);
60837
60831
  },
60838
- searchFiles: async (path2, regex, filePattern) => {
60839
- 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);
60840
60834
  },
60841
60835
  executeCommand: (command, needApprove) => {
60842
60836
  return new Promise((resolve2, reject) => {
@@ -63066,8 +63060,8 @@ function getErrorMap3() {
63066
63060
  return overrideErrorMap3;
63067
63061
  }
63068
63062
  var makeIssue3 = (params) => {
63069
- const { data, path: path2, errorMaps, issueData } = params;
63070
- const fullPath = [...path2, ...issueData.path || []];
63063
+ const { data, path, errorMaps, issueData } = params;
63064
+ const fullPath = [...path, ...issueData.path || []];
63071
63065
  const fullIssue = {
63072
63066
  ...issueData,
63073
63067
  path: fullPath
@@ -63194,11 +63188,11 @@ var _ZodEnum_cache3;
63194
63188
  var _ZodNativeEnum_cache3;
63195
63189
 
63196
63190
  class ParseInputLazyPath3 {
63197
- constructor(parent, value, path2, key2) {
63191
+ constructor(parent, value, path, key2) {
63198
63192
  this._cachedPath = [];
63199
63193
  this.parent = parent;
63200
63194
  this.data = value;
63201
- this._path = path2;
63195
+ this._path = path;
63202
63196
  this._key = key2;
63203
63197
  }
63204
63198
  get path() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.8.13",
3
+ "version": "0.8.15",
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",