@lioneltay/worker-manager 0.0.2 → 0.0.3
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 +11 -7
- package/hooks/hooks.json +2 -2
- package/package.json +7 -5
package/dist/index.js
CHANGED
|
@@ -2,20 +2,22 @@
|
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import * as os from "node:os";
|
|
5
|
-
import { getStateDir, getGitRoot, readAndFlushMail, readRegistry,
|
|
5
|
+
import { getStateDir, getGitRoot, readOrchestratorId, readAndFlushMail, readRegistry, } from "./state.js";
|
|
6
6
|
import { startOrchestratorServer } from "./orchestrator.js";
|
|
7
7
|
import { startWorkerServer } from "./worker.js";
|
|
8
8
|
function runHook() {
|
|
9
9
|
try {
|
|
10
|
+
const claudePid = parseInt(process.env.CLAUDE_PID, 10);
|
|
11
|
+
if (!claudePid)
|
|
12
|
+
return;
|
|
10
13
|
const gitRoot = getGitRoot();
|
|
11
14
|
const stateDir = getStateDir(gitRoot);
|
|
12
|
-
const orchestratorId = readOrchestratorId(stateDir,
|
|
15
|
+
const orchestratorId = readOrchestratorId(stateDir, claudePid);
|
|
13
16
|
if (!orchestratorId)
|
|
14
17
|
return;
|
|
15
18
|
const messages = readAndFlushMail(stateDir, orchestratorId);
|
|
16
|
-
if (messages.length === 0)
|
|
19
|
+
if (messages.length === 0)
|
|
17
20
|
return;
|
|
18
|
-
}
|
|
19
21
|
for (const msg of messages) {
|
|
20
22
|
const prefix = msg.type === "completion" ? "COMPLETED" : "QUESTION";
|
|
21
23
|
process.stdout.write(`[Worker ${msg.workerName} (${msg.workerId})] ${prefix}: ${msg.content}\n`);
|
|
@@ -31,15 +33,17 @@ function runStopHook() {
|
|
|
31
33
|
// Orchestrator mode: check for pending mail
|
|
32
34
|
if (!workerId || !stateDir) {
|
|
33
35
|
try {
|
|
36
|
+
const claudePid = parseInt(process.env.CLAUDE_PID, 10);
|
|
37
|
+
if (!claudePid)
|
|
38
|
+
return;
|
|
34
39
|
const gitRoot = getGitRoot();
|
|
35
40
|
const orchestratorStateDir = getStateDir(gitRoot);
|
|
36
|
-
const orchestratorId = readOrchestratorId(orchestratorStateDir,
|
|
41
|
+
const orchestratorId = readOrchestratorId(orchestratorStateDir, claudePid);
|
|
37
42
|
if (!orchestratorId)
|
|
38
43
|
return;
|
|
39
44
|
const messages = readAndFlushMail(orchestratorStateDir, orchestratorId);
|
|
40
|
-
if (messages.length === 0)
|
|
45
|
+
if (messages.length === 0)
|
|
41
46
|
return;
|
|
42
|
-
}
|
|
43
47
|
const formatted = messages
|
|
44
48
|
.map((m) => {
|
|
45
49
|
const prefix = m.type === "completion" ? "COMPLETED" : "QUESTION";
|
package/hooks/hooks.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"hooks": [
|
|
6
6
|
{
|
|
7
7
|
"type": "command",
|
|
8
|
-
"command": "npx -y @lioneltay/worker-manager --hook",
|
|
8
|
+
"command": "CLAUDE_PID=$PPID npx -y @lioneltay/worker-manager --hook",
|
|
9
9
|
"timeout": 5
|
|
10
10
|
}
|
|
11
11
|
]
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"hooks": [
|
|
17
17
|
{
|
|
18
18
|
"type": "command",
|
|
19
|
-
"command": "npx -y @lioneltay/worker-manager --stop-hook",
|
|
19
|
+
"command": "CLAUDE_PID=$PPID npx -y @lioneltay/worker-manager --stop-hook",
|
|
20
20
|
"timeout": 5
|
|
21
21
|
}
|
|
22
22
|
]
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lioneltay/worker-manager",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Claude Code plugin for spawning and managing worker agents in isolated worktrees",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/lioneltay/agent-forge",
|
|
7
|
+
"url": "git+https://github.com/lioneltay/agent-forge.git",
|
|
8
8
|
"directory": "packages/claude-plugins/worker-manager"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
@@ -21,15 +21,17 @@
|
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsc",
|
|
24
|
-
"dev": "tsc --watch"
|
|
24
|
+
"dev": "tsc --watch",
|
|
25
|
+
"test": "vitest run --exclude dist"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
28
28
|
"@lioneltay/worktree-manager": "^0.0.1",
|
|
29
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
29
30
|
"zod": "^3.24.2"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/node": "^22.13.1",
|
|
33
|
-
"typescript": "^5.7.3"
|
|
34
|
+
"typescript": "^5.7.3",
|
|
35
|
+
"vitest": "^4.0.18"
|
|
34
36
|
}
|
|
35
37
|
}
|