@polka-codes/core 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/_tsup-dts-rollup.d.ts +11 -0
- package/dist/index.js +53 -5
- package/package.json +1 -1
|
@@ -1857,6 +1857,12 @@ declare const defaultModels: {
|
|
|
1857
1857
|
export { defaultModels }
|
|
1858
1858
|
export { defaultModels as defaultModels_alias_1 }
|
|
1859
1859
|
|
|
1860
|
+
/**
|
|
1861
|
+
* Returns the directory portion of a path string.
|
|
1862
|
+
* Strips trailing slashes, then takes everything up to the last slash.
|
|
1863
|
+
*/
|
|
1864
|
+
export declare function dirname(path: string): string;
|
|
1865
|
+
|
|
1860
1866
|
export declare const editingFilesPrompt: (toolNamePrefix: string) => string;
|
|
1861
1867
|
|
|
1862
1868
|
declare const executeAgentTool: <T extends AiToolDefinition<any, any>>(definition: T, agent: MultiAgent, params: GetInput<T>) => Promise<GetOutput<T>>;
|
|
@@ -2079,6 +2085,11 @@ export declare const isAvailable_alias_8: (provider: FilesystemProvider) => bool
|
|
|
2079
2085
|
|
|
2080
2086
|
export declare const isAvailable_alias_9: (provider: FilesystemProvider) => boolean;
|
|
2081
2087
|
|
|
2088
|
+
/**
|
|
2089
|
+
* Joins all given path segments, then normalizes the result.
|
|
2090
|
+
*/
|
|
2091
|
+
export declare function join(...parts: string[]): string;
|
|
2092
|
+
|
|
2082
2093
|
declare const KnowledgeManagementPolicy: (tools: Parameters<AgentPolicy>[0]) => {
|
|
2083
2094
|
name: Policies;
|
|
2084
2095
|
tools: {
|
package/dist/index.js
CHANGED
|
@@ -1773,8 +1773,59 @@ var searchFiles_default = {
|
|
|
1773
1773
|
};
|
|
1774
1774
|
|
|
1775
1775
|
// src/tools/updateKnowledge.ts
|
|
1776
|
-
import { join } from "node:path";
|
|
1777
1776
|
import YAML from "yaml";
|
|
1777
|
+
|
|
1778
|
+
// src/path.ts
|
|
1779
|
+
function dirname(path) {
|
|
1780
|
+
if (path.length === 0) return ".";
|
|
1781
|
+
const isRooted = path[0] === "/";
|
|
1782
|
+
let end = path.length - 1;
|
|
1783
|
+
while (end > 0 && path[end] === "/") end--;
|
|
1784
|
+
const idx = path.lastIndexOf("/", end);
|
|
1785
|
+
if (idx < 0) {
|
|
1786
|
+
return isRooted ? "/" : ".";
|
|
1787
|
+
}
|
|
1788
|
+
if (isRooted && idx === 0) {
|
|
1789
|
+
return "/";
|
|
1790
|
+
}
|
|
1791
|
+
return path.slice(0, idx);
|
|
1792
|
+
}
|
|
1793
|
+
function normalize(path) {
|
|
1794
|
+
const isAbsolute = path.startsWith("/");
|
|
1795
|
+
const segments = path.split("/").filter(Boolean);
|
|
1796
|
+
const stack = [];
|
|
1797
|
+
for (const seg of segments) {
|
|
1798
|
+
if (seg === ".") continue;
|
|
1799
|
+
if (seg === "..") {
|
|
1800
|
+
if (stack.length && stack[stack.length - 1] !== "..") {
|
|
1801
|
+
stack.pop();
|
|
1802
|
+
} else if (!isAbsolute) {
|
|
1803
|
+
stack.push("..");
|
|
1804
|
+
}
|
|
1805
|
+
} else {
|
|
1806
|
+
stack.push(seg);
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
let result = stack.join("/");
|
|
1810
|
+
if (!result && !isAbsolute) return ".";
|
|
1811
|
+
if (result && path.endsWith("/")) result += "/";
|
|
1812
|
+
return (isAbsolute ? "/" : "") + result;
|
|
1813
|
+
}
|
|
1814
|
+
function join(...parts) {
|
|
1815
|
+
if (parts.length === 0) return ".";
|
|
1816
|
+
let combined = "";
|
|
1817
|
+
for (const p of parts) {
|
|
1818
|
+
if (typeof p !== "string") {
|
|
1819
|
+
throw new TypeError("Arguments to join must be strings");
|
|
1820
|
+
}
|
|
1821
|
+
if (p) {
|
|
1822
|
+
combined = combined ? `${combined}/${p}` : p;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
return normalize(combined);
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
// src/tools/updateKnowledge.ts
|
|
1778
1829
|
var toolInfo9 = {
|
|
1779
1830
|
name: "update_knowledge",
|
|
1780
1831
|
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.",
|
|
@@ -3545,9 +3596,6 @@ var MultiAgent = class {
|
|
|
3545
3596
|
}
|
|
3546
3597
|
};
|
|
3547
3598
|
|
|
3548
|
-
// src/Agent/policies/KnowledgeManagement.ts
|
|
3549
|
-
import { dirname, join as join2 } from "node:path";
|
|
3550
|
-
|
|
3551
3599
|
// src/config.ts
|
|
3552
3600
|
import { z } from "zod";
|
|
3553
3601
|
var providerModelSchema = z.object({
|
|
@@ -3711,7 +3759,7 @@ var KnowledgeManagementPolicy = (tools) => {
|
|
|
3711
3759
|
if (path === ".") {
|
|
3712
3760
|
continue;
|
|
3713
3761
|
}
|
|
3714
|
-
const fullpath =
|
|
3762
|
+
const fullpath = join(path, "knowledge.ai.yml");
|
|
3715
3763
|
if (!readFiles.has(fullpath)) {
|
|
3716
3764
|
allFullPaths.push(fullpath);
|
|
3717
3765
|
readFiles.add(fullpath);
|