botholomew 0.8.9 → 0.9.4
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/package.json +1 -1
- package/src/chat/agent.ts +34 -31
- package/src/commands/context.ts +223 -373
- package/src/commands/tools.ts +100 -11
- package/src/context/describer.ts +3 -118
- package/src/context/drives.ts +110 -0
- package/src/context/fetcher.ts +11 -1
- package/src/context/ingest.ts +13 -10
- package/src/context/refresh.ts +39 -24
- package/src/context/url-utils.ts +0 -23
- package/src/db/context.ts +195 -119
- package/src/db/embeddings.ts +35 -16
- package/src/db/sql/13-drive-paths.sql +49 -0
- package/src/tools/context/list-drives.ts +36 -0
- package/src/tools/context/refresh.ts +41 -23
- package/src/tools/context/search.ts +8 -3
- package/src/tools/dir/create.ts +14 -11
- package/src/tools/dir/size.ts +3 -2
- package/src/tools/dir/tree.ts +57 -17
- package/src/tools/file/copy.ts +14 -8
- package/src/tools/file/count-lines.ts +6 -3
- package/src/tools/file/delete.ts +12 -5
- package/src/tools/file/edit.ts +5 -3
- package/src/tools/file/exists.ts +25 -3
- package/src/tools/file/info.ts +90 -18
- package/src/tools/file/move.ts +15 -16
- package/src/tools/file/read.ts +79 -5
- package/src/tools/file/write.ts +29 -12
- package/src/tools/registry.ts +2 -2
- package/src/tools/search/grep.ts +44 -11
- package/src/tools/search/semantic.ts +7 -3
- package/src/tui/components/ContextPanel.tsx +73 -35
- package/src/tui/markdown.ts +2 -3
- package/src/worker/prompt.ts +42 -46
- package/src/tools/dir/list.ts +0 -89
package/src/tools/dir/list.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
getDistinctDirectories,
|
|
4
|
-
listContextItemsByPrefix,
|
|
5
|
-
} from "../../db/context.ts";
|
|
6
|
-
import type { ToolDefinition } from "../tool.ts";
|
|
7
|
-
|
|
8
|
-
const DirEntrySchema = z.object({
|
|
9
|
-
name: z.string(),
|
|
10
|
-
type: z.enum(["file", "directory"]),
|
|
11
|
-
size: z.number(),
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const inputSchema = z.object({
|
|
15
|
-
path: z.string().optional().describe("Directory path (defaults to /)"),
|
|
16
|
-
recursive: z
|
|
17
|
-
.boolean()
|
|
18
|
-
.optional()
|
|
19
|
-
.default(true)
|
|
20
|
-
.describe("Include contents of subdirectories (defaults to true)"),
|
|
21
|
-
limit: z
|
|
22
|
-
.number()
|
|
23
|
-
.optional()
|
|
24
|
-
.default(100)
|
|
25
|
-
.describe("Maximum number of entries to return (defaults to 100)"),
|
|
26
|
-
offset: z
|
|
27
|
-
.number()
|
|
28
|
-
.optional()
|
|
29
|
-
.default(0)
|
|
30
|
-
.describe("Number of entries to skip (defaults to 0)"),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const outputSchema = z.object({
|
|
34
|
-
entries: z.array(DirEntrySchema),
|
|
35
|
-
total: z.number(),
|
|
36
|
-
is_error: z.boolean(),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export const contextListDirTool = {
|
|
40
|
-
name: "context_list_dir",
|
|
41
|
-
description:
|
|
42
|
-
"[[ bash equivalent command: ls ]] List directory contents in context.",
|
|
43
|
-
group: "context",
|
|
44
|
-
inputSchema,
|
|
45
|
-
outputSchema,
|
|
46
|
-
execute: async (input, ctx) => {
|
|
47
|
-
const path = input.path ?? "/";
|
|
48
|
-
const recursive = input.recursive ?? true;
|
|
49
|
-
const limit = input.limit ?? 100;
|
|
50
|
-
const offset = input.offset ?? 0;
|
|
51
|
-
const normalizedPath = path.endsWith("/") ? path : `${path}/`;
|
|
52
|
-
|
|
53
|
-
const allItems = await listContextItemsByPrefix(ctx.conn, path, {
|
|
54
|
-
recursive,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const entries: z.infer<typeof DirEntrySchema>[] = allItems.map((item) => ({
|
|
58
|
-
name: recursive
|
|
59
|
-
? item.context_path
|
|
60
|
-
: item.context_path.slice(normalizedPath.length),
|
|
61
|
-
type:
|
|
62
|
-
item.mime_type === "inode/directory"
|
|
63
|
-
? ("directory" as const)
|
|
64
|
-
: ("file" as const),
|
|
65
|
-
size: item.content?.length ?? 0,
|
|
66
|
-
}));
|
|
67
|
-
|
|
68
|
-
// Add subdirectories (if not recursive, show immediate child dirs)
|
|
69
|
-
if (!recursive) {
|
|
70
|
-
const dirs = await getDistinctDirectories(ctx.conn, path);
|
|
71
|
-
for (const dir of dirs) {
|
|
72
|
-
const name = dir.slice(normalizedPath.length);
|
|
73
|
-
if (!entries.some((e) => e.name === name)) {
|
|
74
|
-
entries.push({ name, type: "directory", size: 0 });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
entries.sort((a, b) => {
|
|
80
|
-
if (a.type !== b.type) return a.type === "directory" ? -1 : 1;
|
|
81
|
-
return a.name.localeCompare(b.name);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const total = entries.length;
|
|
85
|
-
const paginated = entries.slice(offset, offset + limit);
|
|
86
|
-
|
|
87
|
-
return { entries: paginated, total, is_error: false };
|
|
88
|
-
},
|
|
89
|
-
} satisfies ToolDefinition<typeof inputSchema, typeof outputSchema>;
|