@windyroad/style-guide 0.6.3-preview.1173 → 0.6.4-preview.1207
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/hooks/hooks.json
CHANGED
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
|
-
"matcher": "collaborationspawn_agent|collaborationwait_agent|collaborationinterrupt_agent|spawn_agent|wait_agent|interrupt_agent|close_agent|multi_agent_v1__spawn_agent|multi_agent_v1__wait_agent|multi_agent_v1__close_agent",
|
|
61
|
+
"matcher": "collaboration.spawn_agent|collaboration.wait_agent|collaboration.interrupt_agent|collaborationspawn_agent|collaborationwait_agent|collaborationinterrupt_agent|spawn_agent|wait_agent|interrupt_agent|close_agent|multi_agent_v1__spawn_agent|multi_agent_v1__wait_agent|multi_agent_v1__close_agent",
|
|
62
62
|
"hooks": [
|
|
63
63
|
{
|
|
64
64
|
"type": "command",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const SPAWN_TOOLS = new Set([
|
|
2
|
+
"collaboration.spawn_agent",
|
|
3
|
+
"collaborationspawn_agent",
|
|
4
|
+
"spawn_agent",
|
|
5
|
+
"multi_agent_v1__spawn_agent",
|
|
6
|
+
]);
|
|
7
|
+
|
|
8
|
+
export const WAIT_TOOLS = new Set([
|
|
9
|
+
"collaboration.wait_agent",
|
|
10
|
+
"collaborationwait_agent",
|
|
11
|
+
"wait_agent",
|
|
12
|
+
"multi_agent_v1__wait_agent",
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
export const CLOSE_TOOLS = new Set([
|
|
16
|
+
"collaboration.interrupt_agent",
|
|
17
|
+
"collaborationinterrupt_agent",
|
|
18
|
+
"interrupt_agent",
|
|
19
|
+
"close_agent",
|
|
20
|
+
"multi_agent_v1__close_agent",
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
export function parsedResponse(value) {
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
const text = value
|
|
26
|
+
.filter((item) => item && typeof item === "object" && typeof item.text === "string")
|
|
27
|
+
.map((item) => item.text)
|
|
28
|
+
.join("\n");
|
|
29
|
+
return parsedResponse(text);
|
|
30
|
+
}
|
|
31
|
+
if (typeof value === "object" && value) return value;
|
|
32
|
+
try {
|
|
33
|
+
return parsedResponse(JSON.parse(value));
|
|
34
|
+
} catch {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function response(input) {
|
|
40
|
+
return parsedResponse(input?.tool_response);
|
|
41
|
+
}
|
|
@@ -4,6 +4,7 @@ import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync,
|
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { spawnSync } from "node:child_process";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { CLOSE_TOOLS, SPAWN_TOOLS, WAIT_TOOLS, response } from "../hooks/lib/codex-completion-input.mjs";
|
|
7
8
|
|
|
8
9
|
const hookDir = dirname(fileURLToPath(import.meta.url));
|
|
9
10
|
const role = "wr-style-guide:agent";
|
|
@@ -12,11 +13,6 @@ const policy = "docs/STYLE-GUIDE.md";
|
|
|
12
13
|
const ttlSeconds = process.env.REVIEW_TTL ?? "3600";
|
|
13
14
|
const ttl = Number(ttlSeconds) * 1000;
|
|
14
15
|
|
|
15
|
-
function response(input) {
|
|
16
|
-
if (typeof input.tool_response === "object" && input.tool_response) return input.tool_response;
|
|
17
|
-
try { return JSON.parse(input.tool_response); } catch { return {}; }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
function stateDir(sessionId) {
|
|
21
17
|
return join(process.env.TMPDIR || "/tmp", `claude-risk-${sessionId}`);
|
|
22
18
|
}
|
|
@@ -198,9 +194,9 @@ if (!/^[0-9]+$/.test(ttlSeconds) || !Number.isSafeInteger(ttl) || ttl <= 0) {
|
|
|
198
194
|
process.exit(0);
|
|
199
195
|
}
|
|
200
196
|
|
|
201
|
-
if (
|
|
202
|
-
if (
|
|
203
|
-
if (
|
|
197
|
+
if (SPAWN_TOOLS.has(input.tool_name)) remember(input);
|
|
198
|
+
if (CLOSE_TOOLS.has(input.tool_name)) close(input);
|
|
199
|
+
if (WAIT_TOOLS.has(input.tool_name)) wait(input);
|
|
204
200
|
if (input.hook_event_name === "SubagentStop") {
|
|
205
201
|
if (input.agent_type !== role) diagnostic("unrelated-subagent-stop", input);
|
|
206
202
|
else complete(input, input.agent_id, input.last_assistant_message);
|
package/hooks-codex/hooks.json
CHANGED
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
|
-
"matcher": "collaborationspawn_agent|collaborationwait_agent|collaborationinterrupt_agent|spawn_agent|wait_agent|interrupt_agent|close_agent|multi_agent_v1__spawn_agent|multi_agent_v1__wait_agent|multi_agent_v1__close_agent",
|
|
61
|
+
"matcher": "collaboration.spawn_agent|collaboration.wait_agent|collaboration.interrupt_agent|collaborationspawn_agent|collaborationwait_agent|collaborationinterrupt_agent|spawn_agent|wait_agent|interrupt_agent|close_agent|multi_agent_v1__spawn_agent|multi_agent_v1__wait_agent|multi_agent_v1__close_agent",
|
|
62
62
|
"hooks": [
|
|
63
63
|
{
|
|
64
64
|
"type": "command",
|