botholomew 0.9.9 → 0.9.11
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 +18 -14
- package/package.json +1 -1
- package/src/chat/agent.ts +5 -1
- package/src/cli.ts +2 -0
- package/src/commands/db.ts +112 -0
- package/src/commands/skill.ts +21 -0
- package/src/constants.ts +7 -4
- package/src/db/doctor.ts +214 -0
- package/src/db/sql/17-worker_log_path.sql +3 -0
- package/src/db/workers.ts +7 -2
- package/src/init/templates.ts +2 -0
- package/src/skills/commands.ts +29 -4
- package/src/skills/parser.ts +41 -1
- package/src/tools/registry.ts +2 -0
- package/src/tools/skill/delete.ts +56 -0
- package/src/tui/App.tsx +17 -11
- package/src/tui/components/WorkerPanel.tsx +240 -6
- package/src/worker/index.ts +15 -1
- package/src/worker/log-reader.ts +35 -0
- package/src/worker/prompt.ts +10 -0
- package/src/worker/run.ts +10 -2
- package/src/worker/spawn.ts +23 -5
package/src/worker/spawn.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
1
2
|
import { join } from "node:path";
|
|
2
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
getBotholomewDir,
|
|
5
|
+
getWorkerLogPath,
|
|
6
|
+
getWorkerLogsDir,
|
|
7
|
+
} from "../constants.ts";
|
|
8
|
+
import { uuidv7 } from "../db/uuid.ts";
|
|
3
9
|
import { logger } from "../utils/logger.ts";
|
|
4
10
|
import type { WorkerMode } from "./index.ts";
|
|
5
11
|
|
|
@@ -12,11 +18,14 @@ export interface SpawnWorkerOptions {
|
|
|
12
18
|
* Spawn a worker as a detached background process. Unlike the old daemon
|
|
13
19
|
* model, multiple workers per project are allowed and expected — this just
|
|
14
20
|
* launches a new one.
|
|
21
|
+
*
|
|
22
|
+
* The parent generates the worker id and opens a per-worker log file before
|
|
23
|
+
* spawning so that the TUI / CLI can later tail just this worker's output.
|
|
15
24
|
*/
|
|
16
25
|
export async function spawnWorker(
|
|
17
26
|
projectDir: string,
|
|
18
27
|
options: SpawnWorkerOptions = {},
|
|
19
|
-
): Promise<{ pid: number }> {
|
|
28
|
+
): Promise<{ pid: number; workerId: string; logPath: string }> {
|
|
20
29
|
const dotDir = getBotholomewDir(projectDir);
|
|
21
30
|
const dirExists = await Bun.file(join(dotDir, "config.json")).exists();
|
|
22
31
|
if (!dirExists) {
|
|
@@ -24,11 +33,20 @@ export async function spawnWorker(
|
|
|
24
33
|
process.exit(1);
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
const
|
|
36
|
+
const workerId = uuidv7();
|
|
37
|
+
await mkdir(getWorkerLogsDir(projectDir), { recursive: true });
|
|
38
|
+
const logPath = getWorkerLogPath(projectDir, workerId);
|
|
28
39
|
const logFile = Bun.file(logPath);
|
|
29
40
|
|
|
30
41
|
const workerScript = new URL("./run.ts", import.meta.url).pathname;
|
|
31
|
-
const args = [
|
|
42
|
+
const args = [
|
|
43
|
+
"bun",
|
|
44
|
+
"run",
|
|
45
|
+
workerScript,
|
|
46
|
+
projectDir,
|
|
47
|
+
`--worker-id=${workerId}`,
|
|
48
|
+
`--log-path=${logPath}`,
|
|
49
|
+
];
|
|
32
50
|
if (options.mode === "persist") args.push("--persist");
|
|
33
51
|
if (options.taskId) args.push(`--task-id=${options.taskId}`);
|
|
34
52
|
|
|
@@ -44,5 +62,5 @@ export async function spawnWorker(
|
|
|
44
62
|
);
|
|
45
63
|
logger.dim(` Log: ${logPath}`);
|
|
46
64
|
|
|
47
|
-
return { pid: proc.pid ?? 0 };
|
|
65
|
+
return { pid: proc.pid ?? 0, workerId, logPath };
|
|
48
66
|
}
|