@kuralle-agents/fs 0.11.0 → 0.12.0
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/README.md +107 -1
- package/dist/bash-shell.d.ts +15 -0
- package/dist/bash-shell.js +46 -0
- package/dist/cloudflare/cf-shell.d.ts +16 -0
- package/dist/cloudflare/cf-shell.js +28 -0
- package/dist/define-skill.d.ts +7 -0
- package/dist/define-skill.js +8 -0
- package/dist/fs-skill-store.d.ts +4 -0
- package/dist/fs-skill-store.js +101 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +12 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +3 -0
- package/dist/node/node-shell.d.ts +5 -0
- package/dist/node/node-shell.js +180 -0
- package/dist/node/node-sql-fs.d.ts +7 -0
- package/dist/node/node-sql-fs.js +26 -0
- package/dist/okf.d.ts +25 -0
- package/dist/okf.js +142 -0
- package/dist/shell.d.ts +2 -0
- package/dist/shell.js +8 -0
- package/dist/skill-frontmatter.d.ts +12 -0
- package/dist/skill-frontmatter.js +168 -0
- package/dist/sql/factory.d.ts +33 -0
- package/dist/sql/factory.js +41 -0
- package/dist/sql/libsql-http.d.ts +9 -0
- package/dist/sql/libsql-http.js +69 -0
- package/dist/sql/r2-blob.d.ts +11 -0
- package/dist/sql/r2-blob.js +18 -0
- package/dist/sql/sql-fs.d.ts +50 -0
- package/dist/sql/sql-fs.js +691 -0
- package/dist/sql/types.d.ts +10 -0
- package/dist/sql/types.js +1 -0
- package/dist/virtual-shell.d.ts +44 -0
- package/dist/virtual-shell.js +74 -0
- package/package.json +18 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CpOptions, FileSystem, MkdirOptions, RmOptions } from '@kuralle-agents/core';
|
|
2
|
+
import type { Shell } from '@kuralle-agents/core';
|
|
3
|
+
interface JustBashStat {
|
|
4
|
+
isFile: boolean;
|
|
5
|
+
isDirectory: boolean;
|
|
6
|
+
isSymbolicLink: boolean;
|
|
7
|
+
size: number;
|
|
8
|
+
mtime: Date;
|
|
9
|
+
mode?: number;
|
|
10
|
+
}
|
|
11
|
+
interface JustBashDirent {
|
|
12
|
+
name: string;
|
|
13
|
+
isFile: boolean;
|
|
14
|
+
isDirectory: boolean;
|
|
15
|
+
isSymbolicLink: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface JustBashFsLike {
|
|
18
|
+
readFile(path: string): Promise<string>;
|
|
19
|
+
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
20
|
+
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
21
|
+
appendFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
22
|
+
exists(path: string): Promise<boolean>;
|
|
23
|
+
stat(path: string): Promise<JustBashStat>;
|
|
24
|
+
lstat(path: string): Promise<JustBashStat>;
|
|
25
|
+
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
26
|
+
readdir(path: string): Promise<string[]>;
|
|
27
|
+
readdirWithFileTypes?(path: string): Promise<JustBashDirent[]>;
|
|
28
|
+
rm(path: string, options?: RmOptions): Promise<void>;
|
|
29
|
+
cp(src: string, dest: string, options?: CpOptions): Promise<void>;
|
|
30
|
+
mv(src: string, dest: string): Promise<void>;
|
|
31
|
+
symlink(target: string, linkPath: string): Promise<void>;
|
|
32
|
+
readlink(path: string): Promise<string>;
|
|
33
|
+
realpath(path: string): Promise<string>;
|
|
34
|
+
resolvePath(base: string, path: string): string;
|
|
35
|
+
getAllPaths(): string[];
|
|
36
|
+
}
|
|
37
|
+
export declare function justBashFsToFileSystem(jbFs: JustBashFsLike): FileSystem;
|
|
38
|
+
export declare function virtualShell(opts?: {
|
|
39
|
+
initialFiles?: Record<string, string>;
|
|
40
|
+
}): {
|
|
41
|
+
fs: FileSystem;
|
|
42
|
+
shell: Shell;
|
|
43
|
+
};
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Bash, InMemoryFs as JustBashFs } from 'just-bash';
|
|
2
|
+
import { bashShell } from './bash-shell.js';
|
|
3
|
+
import { createGlobMatcher } from './path-utils.js';
|
|
4
|
+
function entryType(stat) {
|
|
5
|
+
if (stat.isSymbolicLink)
|
|
6
|
+
return 'symlink';
|
|
7
|
+
if (stat.isDirectory)
|
|
8
|
+
return 'directory';
|
|
9
|
+
return 'file';
|
|
10
|
+
}
|
|
11
|
+
function mapStat(stat) {
|
|
12
|
+
return {
|
|
13
|
+
type: entryType(stat),
|
|
14
|
+
size: stat.size,
|
|
15
|
+
mtime: stat.mtime,
|
|
16
|
+
mode: stat.mode,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function mapDirent(entry) {
|
|
20
|
+
return {
|
|
21
|
+
name: entry.name,
|
|
22
|
+
type: entry.isSymbolicLink
|
|
23
|
+
? 'symlink'
|
|
24
|
+
: entry.isDirectory
|
|
25
|
+
? 'directory'
|
|
26
|
+
: 'file',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function justBashFsToFileSystem(jbFs) {
|
|
30
|
+
return {
|
|
31
|
+
readFile: (path) => jbFs.readFile(path),
|
|
32
|
+
readFileBytes: (path) => jbFs.readFileBuffer(path),
|
|
33
|
+
writeFile: (path, content) => jbFs.writeFile(path, content),
|
|
34
|
+
writeFileBytes: (path, content) => jbFs.writeFile(path, content),
|
|
35
|
+
appendFile: (path, content) => jbFs.appendFile(path, content),
|
|
36
|
+
exists: (path) => jbFs.exists(path),
|
|
37
|
+
stat: async (path) => mapStat(await jbFs.stat(path)),
|
|
38
|
+
lstat: async (path) => mapStat(await jbFs.lstat(path)),
|
|
39
|
+
mkdir: (path, options) => jbFs.mkdir(path, options),
|
|
40
|
+
readdir: (path) => jbFs.readdir(path),
|
|
41
|
+
readdirWithFileTypes: async (path) => {
|
|
42
|
+
if (jbFs.readdirWithFileTypes) {
|
|
43
|
+
const entries = await jbFs.readdirWithFileTypes(path);
|
|
44
|
+
return entries.map(mapDirent);
|
|
45
|
+
}
|
|
46
|
+
const names = await jbFs.readdir(path);
|
|
47
|
+
const entries = [];
|
|
48
|
+
for (const name of names) {
|
|
49
|
+
const child = path === '/' ? `/${name}` : `${path}/${name}`;
|
|
50
|
+
const stat = await jbFs.stat(child);
|
|
51
|
+
entries.push({ name, type: entryType(stat) });
|
|
52
|
+
}
|
|
53
|
+
return entries;
|
|
54
|
+
},
|
|
55
|
+
rm: (path, options) => jbFs.rm(path, options),
|
|
56
|
+
cp: (src, dest, options) => jbFs.cp(src, dest, options),
|
|
57
|
+
mv: (src, dest) => jbFs.mv(src, dest),
|
|
58
|
+
symlink: (target, linkPath) => jbFs.symlink(target, linkPath),
|
|
59
|
+
readlink: (path) => jbFs.readlink(path),
|
|
60
|
+
realpath: (path) => jbFs.realpath(path),
|
|
61
|
+
resolvePath: (base, path) => jbFs.resolvePath(base, path),
|
|
62
|
+
glob: async (pattern) => {
|
|
63
|
+
const matcher = createGlobMatcher(pattern);
|
|
64
|
+
return jbFs.getAllPaths().filter((p) => matcher.test(p));
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function virtualShell(opts) {
|
|
69
|
+
const jbFs = new JustBashFs(opts?.initialFiles);
|
|
70
|
+
const fs = justBashFsToFileSystem(jbFs);
|
|
71
|
+
const bash = new Bash({ fs: jbFs });
|
|
72
|
+
const shell = bashShell(bash);
|
|
73
|
+
return { fs, shell };
|
|
74
|
+
}
|
package/package.json
CHANGED
|
@@ -6,26 +6,40 @@
|
|
|
6
6
|
"url": "git+https://github.com/kuralle/kuralle-agents.git",
|
|
7
7
|
"directory": "packages/kuralle-fs"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.12.0",
|
|
10
10
|
"description": "Portable filesystem primitive for Kuralle agents",
|
|
11
11
|
"type": "module",
|
|
12
|
+
"sideEffects": false,
|
|
12
13
|
"main": "dist/index.js",
|
|
13
14
|
"types": "dist/index.d.ts",
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|
|
16
17
|
"types": "./dist/index.d.ts",
|
|
17
18
|
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./shell": {
|
|
21
|
+
"types": "./dist/shell.d.ts",
|
|
22
|
+
"default": "./dist/shell.js"
|
|
23
|
+
},
|
|
24
|
+
"./node": {
|
|
25
|
+
"types": "./dist/node/index.d.ts",
|
|
26
|
+
"default": "./dist/node/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./cloudflare": {
|
|
29
|
+
"types": "./dist/cloudflare/cf-shell.d.ts",
|
|
30
|
+
"default": "./dist/cloudflare/cf-shell.js"
|
|
18
31
|
}
|
|
19
32
|
},
|
|
20
33
|
"dependencies": {
|
|
21
|
-
"
|
|
34
|
+
"just-bash": "^3.1.0",
|
|
35
|
+
"@kuralle-agents/core": "0.12.0"
|
|
22
36
|
},
|
|
23
37
|
"peerDependencies": {
|
|
24
38
|
"zod": "^4.0.0"
|
|
25
39
|
},
|
|
26
40
|
"devDependencies": {
|
|
27
41
|
"@cloudflare/vitest-pool-workers": "^0.12.7",
|
|
28
|
-
"@types/node": "^
|
|
42
|
+
"@types/node": "^22.5.0",
|
|
29
43
|
"bun-types": "^1.3.0",
|
|
30
44
|
"typescript": "^5.3.0",
|
|
31
45
|
"vitest": "^3.2.4",
|
|
@@ -42,7 +56,7 @@
|
|
|
42
56
|
"prebuild": "rm -rf dist",
|
|
43
57
|
"build": "tsc -p tsconfig.json",
|
|
44
58
|
"clean": "rm -rf dist",
|
|
45
|
-
"test": "bun test test
|
|
59
|
+
"test": "bun test ./test && vitest run --config vitest.config.ts",
|
|
46
60
|
"test:inmemoryfs": "bun test test/in-memory-fs.test.ts",
|
|
47
61
|
"test:fs-tool": "bun test test/fs-tool.test.ts",
|
|
48
62
|
"test:fs-workers": "vitest run --config vitest.config.ts"
|