@polka-codes/cli 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.
- package/dist/index.js +72 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38447,7 +38447,7 @@ var {
|
|
|
38447
38447
|
Help
|
|
38448
38448
|
} = import__.default;
|
|
38449
38449
|
// package.json
|
|
38450
|
-
var version = "0.8.
|
|
38450
|
+
var version = "0.8.22";
|
|
38451
38451
|
|
|
38452
38452
|
// ../core/src/AiService/AiServiceBase.ts
|
|
38453
38453
|
class AiServiceBase {
|
|
@@ -48612,7 +48612,64 @@ var searchFiles_default = {
|
|
|
48612
48612
|
};
|
|
48613
48613
|
// ../core/src/tools/updateKnowledge.ts
|
|
48614
48614
|
var import_yaml = __toESM(require_dist(), 1);
|
|
48615
|
-
|
|
48615
|
+
|
|
48616
|
+
// ../core/src/path.ts
|
|
48617
|
+
function dirname(path) {
|
|
48618
|
+
if (path.length === 0)
|
|
48619
|
+
return ".";
|
|
48620
|
+
const isRooted = path[0] === "/";
|
|
48621
|
+
let end = path.length - 1;
|
|
48622
|
+
while (end > 0 && path[end] === "/")
|
|
48623
|
+
end--;
|
|
48624
|
+
const idx = path.lastIndexOf("/", end);
|
|
48625
|
+
if (idx < 0) {
|
|
48626
|
+
return isRooted ? "/" : ".";
|
|
48627
|
+
}
|
|
48628
|
+
if (isRooted && idx === 0) {
|
|
48629
|
+
return "/";
|
|
48630
|
+
}
|
|
48631
|
+
return path.slice(0, idx);
|
|
48632
|
+
}
|
|
48633
|
+
function normalize(path) {
|
|
48634
|
+
const isAbsolute = path.startsWith("/");
|
|
48635
|
+
const segments = path.split("/").filter(Boolean);
|
|
48636
|
+
const stack = [];
|
|
48637
|
+
for (const seg of segments) {
|
|
48638
|
+
if (seg === ".")
|
|
48639
|
+
continue;
|
|
48640
|
+
if (seg === "..") {
|
|
48641
|
+
if (stack.length && stack[stack.length - 1] !== "..") {
|
|
48642
|
+
stack.pop();
|
|
48643
|
+
} else if (!isAbsolute) {
|
|
48644
|
+
stack.push("..");
|
|
48645
|
+
}
|
|
48646
|
+
} else {
|
|
48647
|
+
stack.push(seg);
|
|
48648
|
+
}
|
|
48649
|
+
}
|
|
48650
|
+
let result = stack.join("/");
|
|
48651
|
+
if (!result && !isAbsolute)
|
|
48652
|
+
return ".";
|
|
48653
|
+
if (result && path.endsWith("/"))
|
|
48654
|
+
result += "/";
|
|
48655
|
+
return (isAbsolute ? "/" : "") + result;
|
|
48656
|
+
}
|
|
48657
|
+
function join(...parts) {
|
|
48658
|
+
if (parts.length === 0)
|
|
48659
|
+
return ".";
|
|
48660
|
+
let combined = "";
|
|
48661
|
+
for (const p2 of parts) {
|
|
48662
|
+
if (typeof p2 !== "string") {
|
|
48663
|
+
throw new TypeError("Arguments to join must be strings");
|
|
48664
|
+
}
|
|
48665
|
+
if (p2) {
|
|
48666
|
+
combined = combined ? `${combined}/${p2}` : p2;
|
|
48667
|
+
}
|
|
48668
|
+
}
|
|
48669
|
+
return normalize(combined);
|
|
48670
|
+
}
|
|
48671
|
+
|
|
48672
|
+
// ../core/src/tools/updateKnowledge.ts
|
|
48616
48673
|
var toolInfo9 = {
|
|
48617
48674
|
name: "update_knowledge",
|
|
48618
48675
|
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.",
|
|
@@ -50333,9 +50390,6 @@ class MultiAgent {
|
|
|
50333
50390
|
return this.#agents.length > 0;
|
|
50334
50391
|
}
|
|
50335
50392
|
}
|
|
50336
|
-
// ../core/src/Agent/policies/KnowledgeManagement.ts
|
|
50337
|
-
import { dirname, join as join2 } from "node:path";
|
|
50338
|
-
|
|
50339
50393
|
// ../core/node_modules/zod/lib/index.mjs
|
|
50340
50394
|
var util;
|
|
50341
50395
|
(function(util2) {
|
|
@@ -54482,7 +54536,7 @@ var KnowledgeManagementPolicy = (tools) => {
|
|
|
54482
54536
|
if (path === ".") {
|
|
54483
54537
|
continue;
|
|
54484
54538
|
}
|
|
54485
|
-
const fullpath =
|
|
54539
|
+
const fullpath = join(path, "knowledge.ai.yml");
|
|
54486
54540
|
if (!readFiles.has(fullpath)) {
|
|
54487
54541
|
allFullPaths.push(fullpath);
|
|
54488
54542
|
readFiles.add(fullpath);
|
|
@@ -55101,12 +55155,12 @@ Available commands:
|
|
|
55101
55155
|
import { existsSync as existsSync2 } from "node:fs";
|
|
55102
55156
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
55103
55157
|
import os2 from "node:os";
|
|
55104
|
-
import { join as
|
|
55158
|
+
import { join as join4 } from "node:path";
|
|
55105
55159
|
|
|
55106
55160
|
// ../cli-shared/src/config.ts
|
|
55107
55161
|
import { existsSync, readFileSync } from "node:fs";
|
|
55108
55162
|
import { homedir } from "node:os";
|
|
55109
|
-
import { join as
|
|
55163
|
+
import { join as join2 } from "node:path";
|
|
55110
55164
|
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
55111
55165
|
|
|
55112
55166
|
// ../cli-shared/node_modules/yaml/dist/index.js
|
|
@@ -58991,7 +59045,7 @@ var pipelineType2 = ZodPipeline2.create;
|
|
|
58991
59045
|
|
|
58992
59046
|
// ../cli-shared/src/config.ts
|
|
58993
59047
|
function getGlobalConfigPath(home = homedir()) {
|
|
58994
|
-
return
|
|
59048
|
+
return join2(home, ".config", "polkacodes", "config.yml");
|
|
58995
59049
|
}
|
|
58996
59050
|
function loadConfigAtPath(path) {
|
|
58997
59051
|
try {
|
|
@@ -59058,7 +59112,7 @@ ${error}`);
|
|
|
59058
59112
|
}
|
|
59059
59113
|
}
|
|
59060
59114
|
} else {
|
|
59061
|
-
const configPath =
|
|
59115
|
+
const configPath = join2(cwd, localConfigFileName);
|
|
59062
59116
|
try {
|
|
59063
59117
|
const projectConfig = readConfig(configPath);
|
|
59064
59118
|
configs.push(projectConfig);
|
|
@@ -60471,7 +60525,7 @@ function checkRipgrep() {
|
|
|
60471
60525
|
// ../cli-shared/src/utils/listFiles.ts
|
|
60472
60526
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
60473
60527
|
import { promises as fs2 } from "node:fs";
|
|
60474
|
-
import { join as
|
|
60528
|
+
import { join as join3, relative, resolve } from "node:path";
|
|
60475
60529
|
var DEFAULT_IGNORES = [
|
|
60476
60530
|
"__pycache__",
|
|
60477
60531
|
".DS_Store",
|
|
@@ -60489,7 +60543,7 @@ var DEFAULT_IGNORES = [
|
|
|
60489
60543
|
];
|
|
60490
60544
|
async function extendPatterns(basePatterns, dirPath) {
|
|
60491
60545
|
try {
|
|
60492
|
-
const gitignorePath =
|
|
60546
|
+
const gitignorePath = join3(dirPath, ".gitignore");
|
|
60493
60547
|
const content = await fs2.readFile(gitignorePath, "utf8");
|
|
60494
60548
|
const lines2 = content.split(/\r?\n/).filter(Boolean);
|
|
60495
60549
|
return [...basePatterns, ...lines2];
|
|
@@ -60503,7 +60557,7 @@ function createIgnore(patterns) {
|
|
|
60503
60557
|
async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
60504
60558
|
let rootPatterns = [...DEFAULT_IGNORES, ...excludeFiles || []];
|
|
60505
60559
|
try {
|
|
60506
|
-
const rootGitignore = await fs2.readFile(
|
|
60560
|
+
const rootGitignore = await fs2.readFile(join3(cwd, ".gitignore"), "utf8");
|
|
60507
60561
|
const lines2 = rootGitignore.split(/\r?\n/).filter(Boolean);
|
|
60508
60562
|
rootPatterns = [...rootPatterns, ...lines2];
|
|
60509
60563
|
} catch {}
|
|
@@ -60524,7 +60578,7 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
|
60524
60578
|
const entries = await fs2.readdir(currentPath, { withFileTypes: true });
|
|
60525
60579
|
entries.sort((a2, b2) => a2.name.localeCompare(b2.name));
|
|
60526
60580
|
for (const entry of entries) {
|
|
60527
|
-
const fullPath =
|
|
60581
|
+
const fullPath = join3(currentPath, entry.name);
|
|
60528
60582
|
const relPath = relative(cwd, fullPath).replace(/\\/g, "/");
|
|
60529
60583
|
if (folderIg.ignores(relPath)) {
|
|
60530
60584
|
continue;
|
|
@@ -60541,7 +60595,7 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
|
60541
60595
|
results.push(relPath);
|
|
60542
60596
|
if (results.length >= maxCount) {
|
|
60543
60597
|
const remainingEntries = entries.slice(entries.indexOf(entry) + 1);
|
|
60544
|
-
const hasRemainingFiles = remainingEntries.some((e2) => !e2.isDirectory() && !folderIg.ignores(relative(cwd,
|
|
60598
|
+
const hasRemainingFiles = remainingEntries.some((e2) => !e2.isDirectory() && !folderIg.ignores(relative(cwd, join3(currentPath, e2.name)).replace(/\\/g, "/")));
|
|
60545
60599
|
if (hasRemainingFiles) {
|
|
60546
60600
|
const marker = `${currentRelPath}/(files omitted)`;
|
|
60547
60601
|
results.push(marker);
|
|
@@ -61478,7 +61532,7 @@ ${fileList.join(`
|
|
|
61478
61532
|
</files>`;
|
|
61479
61533
|
let knowledgeContent = "";
|
|
61480
61534
|
if (this.#hasKnowledgeManagementPolicy) {
|
|
61481
|
-
const knowledgeFilePath =
|
|
61535
|
+
const knowledgeFilePath = join4(cwd, "knowledge.ai.yml");
|
|
61482
61536
|
if (existsSync2(knowledgeFilePath)) {
|
|
61483
61537
|
try {
|
|
61484
61538
|
const content = await readFile2(knowledgeFilePath, "utf8");
|
|
@@ -62421,9 +62475,9 @@ ${result.response}`);
|
|
|
62421
62475
|
// src/commands/create.ts
|
|
62422
62476
|
import { existsSync as existsSync3 } from "node:fs";
|
|
62423
62477
|
import { mkdir as mkdir2, stat } from "node:fs/promises";
|
|
62424
|
-
import { join as
|
|
62478
|
+
import { join as join5 } from "node:path";
|
|
62425
62479
|
var askForPath = async (projectName) => {
|
|
62426
|
-
let targetPath =
|
|
62480
|
+
let targetPath = join5(process.cwd(), projectName);
|
|
62427
62481
|
while (true) {
|
|
62428
62482
|
const confirmPath = await esm_default2({
|
|
62429
62483
|
message: `Do you want to create project at ${targetPath}?`,
|