@polka-codes/cli-shared 0.8.21 → 0.8.22

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 +44 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -37637,7 +37637,48 @@ var searchFiles_default = {
37637
37637
  };
37638
37638
  // ../core/src/tools/updateKnowledge.ts
37639
37639
  var import_yaml = __toESM(require_dist(), 1);
37640
- import { join } from "node:path";
37640
+
37641
+ // ../core/src/path.ts
37642
+ function normalize(path) {
37643
+ const isAbsolute = path.startsWith("/");
37644
+ const segments = path.split("/").filter(Boolean);
37645
+ const stack = [];
37646
+ for (const seg of segments) {
37647
+ if (seg === ".")
37648
+ continue;
37649
+ if (seg === "..") {
37650
+ if (stack.length && stack[stack.length - 1] !== "..") {
37651
+ stack.pop();
37652
+ } else if (!isAbsolute) {
37653
+ stack.push("..");
37654
+ }
37655
+ } else {
37656
+ stack.push(seg);
37657
+ }
37658
+ }
37659
+ let result = stack.join("/");
37660
+ if (!result && !isAbsolute)
37661
+ return ".";
37662
+ if (result && path.endsWith("/"))
37663
+ result += "/";
37664
+ return (isAbsolute ? "/" : "") + result;
37665
+ }
37666
+ function join(...parts) {
37667
+ if (parts.length === 0)
37668
+ return ".";
37669
+ let combined = "";
37670
+ for (const p2 of parts) {
37671
+ if (typeof p2 !== "string") {
37672
+ throw new TypeError("Arguments to join must be strings");
37673
+ }
37674
+ if (p2) {
37675
+ combined = combined ? `${combined}/${p2}` : p2;
37676
+ }
37677
+ }
37678
+ return normalize(combined);
37679
+ }
37680
+
37681
+ // ../core/src/tools/updateKnowledge.ts
37641
37682
  var toolInfo9 = {
37642
37683
  name: "update_knowledge",
37643
37684
  description: "Update knowledge in a knowledge.ai.yml file with smart merging capabilities. This tool lets you add, update, or remove information using path-based updates and special directives.",
@@ -47411,7 +47452,7 @@ var readLocalConfig = (path) => {
47411
47452
  var import_ignore2 = __toESM(require_ignore(), 1);
47412
47453
  import { spawn as spawn2 } from "node:child_process";
47413
47454
  import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
47414
- import { dirname } from "node:path";
47455
+ import { dirname as dirname2 } from "node:path";
47415
47456
 
47416
47457
  // ../../node_modules/@inquirer/core/dist/esm/lib/key.js
47417
47458
  var isUpKey = (key) => key.name === "up" || key.name === "k" || key.ctrl && key.name === "p";
@@ -48867,7 +48908,7 @@ var getProvider = (agentName, config2, options = {}) => {
48867
48908
  if (ig.ignores(path)) {
48868
48909
  throw new Error(`Not allow to access file ${path}`);
48869
48910
  }
48870
- await mkdir(dirname(path), { recursive: true });
48911
+ await mkdir(dirname2(path), { recursive: true });
48871
48912
  return await writeFile(path, content, "utf8");
48872
48913
  },
48873
48914
  removeFile: async (path) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli-shared",
3
- "version": "0.8.21",
3
+ "version": "0.8.22",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",