hookloom 1.3.0 → 1.3.1
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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/dist/{check-CRZ6Rgdo.mjs → check-DUtMm88w.mjs} +3 -3
- package/dist/check-fL0W2EGm.mjs +1 -0
- package/dist/cli.mjs +5 -6
- package/dist/{command-line-CxFCE3W7.mjs → command-line-rI6Nk-jn.mjs} +1 -1
- package/dist/dispatcher.mjs +7 -7
- package/dist/examples/blocked-fetch.mjs +2 -2
- package/dist/examples/browser-close.mjs +2 -2
- package/dist/examples/dash-guard.mjs +2 -2
- package/dist/examples/default-branch-health.mjs +5 -5
- package/dist/examples/dewrap.mjs +2 -2
- package/dist/examples/github-rate-limit.mjs +5 -3
- package/dist/examples/issue-comment-guard.mjs +3 -3
- package/dist/examples/private-reference-guard.mjs +3 -3
- package/dist/examples/repository-metadata.mjs +1 -1
- package/dist/{hook-DIS0wk_5.mjs → hook-ClJcbzby.mjs} +2 -2
- package/dist/{permission-rule-BVXyOtut.mjs → permission-rule-BxFEjGo0.mjs} +1 -1
- package/dist/{private-references-CUZqASjK.mjs → private-references-B0qyQ0dB.mjs} +2 -2
- package/dist/{schema-EYih4WFo.mjs → schema-ByVW3IRJ.mjs} +1 -1
- package/dist/{schema-Dl9EJYyt.mjs → schema-Dfw94F_X.mjs} +1 -2
- package/dist/{schemas-B4KRDIno.mjs → schemas-BDlKVNhe.mjs} +132 -1
- package/dist/{shell-4WSaabze.mjs → shell-BWP1aDQb.mjs} +67 -2
- package/dist/{state-Db3zojdV.mjs → state-Br7wFToE.mjs} +1 -1
- package/package.json +1 -1
- package/dist/check-ySa9Ce1V.mjs +0 -1
- package/dist/events-CHsq0Cl4.mjs +0 -132
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as permissionRuleProblem } from "./permission-rule-
|
|
2
|
-
import {
|
|
3
|
-
import { t as handlersOf } from "./schema-
|
|
1
|
+
import { r as permissionRuleProblem } from "./permission-rule-BxFEjGo0.mjs";
|
|
2
|
+
import { g as eventContract, v as harnesses } from "./schemas-BDlKVNhe.mjs";
|
|
3
|
+
import { t as handlersOf } from "./schema-Dfw94F_X.mjs";
|
|
4
4
|
// src/registry/check.ts
|
|
5
5
|
/**
|
|
6
6
|
* The rules a registry must meet for a harness to be able to run it, beyond its shape.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as checkRegistry } from "./check-DUtMm88w.mjs";
|
package/dist/cli.mjs
CHANGED
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
import { isDeepStrictEqual, parseArgs } from "node:util";
|
|
3
3
|
import { accessSync, constants, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { delimiter, dirname, extname, isAbsolute, join, resolve } from "node:path";
|
|
5
|
-
import { r as
|
|
6
|
-
import { n as isRecord } from "./shell-
|
|
5
|
+
import { c as number, d as strictObject, f as string, g as eventContract, l as object, m as unknown, n as array, r as boolean, s as looseObject, t as _enum, u as record$1, v as harnesses } from "./schemas-BDlKVNhe.mjs";
|
|
6
|
+
import { n as isRecord } from "./shell-BWP1aDQb.mjs";
|
|
7
7
|
import { a as registryPath, i as configurationDirectory, r as claudeDirectory, t as atomicWrite } from "./files-CBn-xAo2.mjs";
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
9
|
-
import { t as checkRegistry } from "./check-
|
|
10
|
-
import {
|
|
11
|
-
import { n as parseRegistry } from "./schema-Dl9EJYyt.mjs";
|
|
9
|
+
import { t as checkRegistry } from "./check-DUtMm88w.mjs";
|
|
10
|
+
import { n as parseRegistry } from "./schema-Dfw94F_X.mjs";
|
|
12
11
|
import { n as withLock } from "./lock-8b6urUtv.mjs";
|
|
13
12
|
import { execFile, spawn } from "node:child_process";
|
|
14
13
|
import { createInterface } from "node:readline";
|
|
15
14
|
import { homedir, tmpdir } from "node:os";
|
|
16
15
|
import { once } from "node:events";
|
|
17
|
-
import { n as invocation, r as version, t as claudeUsesPowerShell } from "./command-line-
|
|
16
|
+
import { n as invocation, r as version, t as claudeUsesPowerShell } from "./command-line-rI6Nk-jn.mjs";
|
|
18
17
|
// src/examples/catalogue.ts
|
|
19
18
|
const BOTH = ["claude", "codex"];
|
|
20
19
|
const LOCAL_SECONDS = 10;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { delimiter, join } from "node:path";
|
|
3
3
|
// src/version.ts
|
|
4
|
-
const version = "1.3.
|
|
4
|
+
const version = "1.3.1";
|
|
5
5
|
// src/dispatch/command-line.ts
|
|
6
6
|
/**
|
|
7
7
|
* The program and arguments with which each harness runs a command hook on each platform.
|
package/dist/dispatcher.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { text } from "node:stream/consumers";
|
|
2
|
-
import {
|
|
2
|
+
import { g as eventContract, v as harnesses } from "./schemas-BDlKVNhe.mjs";
|
|
3
3
|
import { closeSync, existsSync, fstatSync, globSync, openSync, readFileSync, readSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { dirname, join, resolve } from "node:path";
|
|
6
6
|
import { a as registryPath, n as cacheDirectory, r as claudeDirectory, t as atomicWrite } from "./files-CBn-xAo2.mjs";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
|
-
import { a as stringField, i as parsePayload, n as isRecord, o as toolInput, r as namedField } from "./shell-
|
|
9
|
-
import { n as invocation, r as version } from "./command-line-
|
|
10
|
-
import { a as sessionKey, i as removeOlderThan, n as readRecord, o as writeRecord, r as records, t as digest } from "./state-
|
|
8
|
+
import { a as stringField, i as parsePayload, n as isRecord, o as toolInput, r as namedField } from "./shell-BWP1aDQb.mjs";
|
|
9
|
+
import { n as invocation, r as version } from "./command-line-rI6Nk-jn.mjs";
|
|
10
|
+
import { a as sessionKey, i as removeOlderThan, n as readRecord, o as writeRecord, r as records, t as digest } from "./state-Br7wFToE.mjs";
|
|
11
11
|
import { spawn } from "node:child_process";
|
|
12
12
|
import { t as withoutHarnessMessages } from "./prompt-text-A_jEvJei.mjs";
|
|
13
|
-
import { t as handlersOf } from "./schema-
|
|
14
|
-
import { n as permissionRuleMatches, t as parsePermissionRule } from "./permission-rule-
|
|
13
|
+
import { t as handlersOf } from "./schema-Dfw94F_X.mjs";
|
|
14
|
+
import { n as permissionRuleMatches, t as parsePermissionRule } from "./permission-rule-BxFEjGo0.mjs";
|
|
15
15
|
import { fileURLToPath } from "node:url";
|
|
16
16
|
// src/registry/load.ts
|
|
17
17
|
/**
|
|
@@ -20,7 +20,7 @@ import { fileURLToPath } from "node:url";
|
|
|
20
20
|
const MEMO_PREFIX = "registry-";
|
|
21
21
|
var RegistryError = class extends Error {};
|
|
22
22
|
async function validate(text, path) {
|
|
23
|
-
const [{ parseRegistry }, { checkRegistry }] = await Promise.all([import("./schema-
|
|
23
|
+
const [{ parseRegistry }, { checkRegistry }] = await Promise.all([import("./schema-ByVW3IRJ.mjs"), import("./check-fL0W2EGm.mjs")]);
|
|
24
24
|
const registry = parseRegistry(JSON.parse(text));
|
|
25
25
|
const problems = checkRegistry(registry);
|
|
26
26
|
if (problems.length > 0) throw new RegistryError(`${path} cannot run:\n${problems.map((problem) => `${problem.harness} ${problem.event}: ${problem.message}`).join("\n")}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as stringField } from "../shell-
|
|
2
|
-
import { a as shellCommand, i as main, n as context, o as toolOutput } from "../hook-
|
|
1
|
+
import { a as stringField } from "../shell-BWP1aDQb.mjs";
|
|
2
|
+
import { a as shellCommand, i as main, n as context, o as toolOutput } from "../hook-ClJcbzby.mjs";
|
|
3
3
|
// src/examples/blocked-fetch.ts
|
|
4
4
|
/**
|
|
5
5
|
* After a page fetch is refused or blocked, reminds the agent to try a browser before reporting the page unreadable. Never blocks.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { closeSync, existsSync, fstatSync, openSync, readSync } from "node:fs";
|
|
2
|
-
import { a as stringField, n as isRecord } from "../shell-
|
|
2
|
+
import { a as stringField, n as isRecord } from "../shell-BWP1aDQb.mjs";
|
|
3
3
|
import { t as withoutHarnessMessages } from "../prompt-text-A_jEvJei.mjs";
|
|
4
|
-
import { i as main } from "../hook-
|
|
4
|
+
import { i as main } from "../hook-ClJcbzby.mjs";
|
|
5
5
|
// src/examples/transcript.ts
|
|
6
6
|
/**
|
|
7
7
|
* Reads a Claude Code transcript: which records are the user's own requests, and which are the harness's.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { readFileSync, statSync } from "node:fs";
|
|
2
|
-
import { a as stringField, n as isRecord, o as toolInput, t as splitCommand } from "../shell-
|
|
2
|
+
import { a as stringField, n as isRecord, o as toolInput, t as splitCommand } from "../shell-BWP1aDQb.mjs";
|
|
3
3
|
import { basename, extname, resolve } from "node:path";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
|
-
import { a as shellCommand, i as main, r as deny } from "../hook-
|
|
5
|
+
import { a as shellCommand, i as main, r as deny } from "../hook-ClJcbzby.mjs";
|
|
6
6
|
// src/examples/codex-patch.ts
|
|
7
7
|
/**
|
|
8
8
|
* Rebuilds the file contents a Codex `apply_patch` call would produce, so a hook can judge a patch as whole files before and after.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { c as number, f as string, l as object, n as array, p as union } from "../schemas-BDlKVNhe.mjs";
|
|
1
2
|
import { execFileSync } from "node:child_process";
|
|
2
3
|
import { join } from "node:path";
|
|
3
|
-
import { n as readRecord, o as writeRecord, t as digest } from "../state-
|
|
4
|
-
import { a as stringField } from "../shell-
|
|
4
|
+
import { n as readRecord, o as writeRecord, t as digest } from "../state-Br7wFToE.mjs";
|
|
5
|
+
import { a as stringField } from "../shell-BWP1aDQb.mjs";
|
|
5
6
|
import { n as withLock, t as LockedError } from "../lock-8b6urUtv.mjs";
|
|
6
|
-
import { c as number, f as string, l as object, n as array, p as union } from "../schemas-B4KRDIno.mjs";
|
|
7
7
|
import { n as cacheDirectory } from "../files-CBn-xAo2.mjs";
|
|
8
|
-
import { i as main, n as context } from "../hook-
|
|
9
|
-
import { o as originRepository } from "../private-references-
|
|
8
|
+
import { i as main, n as context } from "../hook-ClJcbzby.mjs";
|
|
9
|
+
import { o as originRepository } from "../private-references-B0qyQ0dB.mjs";
|
|
10
10
|
// src/examples/pressure.ts
|
|
11
11
|
/**
|
|
12
12
|
* Throttles a notice by how much it matters: pressure runs from 0 to 1, derived from a hook's own measurements, and the higher it is the sooner a session is told again.
|
package/dist/examples/dewrap.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { basename, resolve, sep } from "node:path";
|
|
2
2
|
import { readFileSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { a as stringField, o as toolInput } from "../shell-
|
|
4
|
-
import { a as shellCommand, i as main } from "../hook-
|
|
3
|
+
import { a as stringField, o as toolInput } from "../shell-BWP1aDQb.mjs";
|
|
4
|
+
import { a as shellCommand, i as main } from "../hook-ClJcbzby.mjs";
|
|
5
5
|
// src/examples/dewrap/lines.ts
|
|
6
6
|
/**
|
|
7
7
|
* Recognising what a line is, shared by the prose, comment and docstring rejoiners.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as shellCommand, i as main, n as context, o as toolOutput, t as commandWords } from "../hook-
|
|
1
|
+
import { a as shellCommand, i as main, n as context, o as toolOutput, t as commandWords } from "../hook-ClJcbzby.mjs";
|
|
2
2
|
// src/examples/github-rate-limit.ts
|
|
3
3
|
/**
|
|
4
4
|
* After a `gh` command is refused for a rate limit, points the agent at the REST route. `gh`'s own subcommands spend the GraphQL budget, which can be empty while the REST budget still has room.
|
|
@@ -9,12 +9,14 @@ const CHECK = "`gh api rate_limit -q '.resources|{core,graphql,search}'`";
|
|
|
9
9
|
/** The first `gh` subcommand of a command line and whether it called the REST API, or `undefined` when this is not a `gh` rate-limit failure. */
|
|
10
10
|
function rateLimited(command, output) {
|
|
11
11
|
if (!RATE_LIMIT.test(output)) return void 0;
|
|
12
|
-
const
|
|
12
|
+
const calls = commandWords(command).filter((words) => words[0]?.split("/").at(-1) === "gh");
|
|
13
|
+
const [call] = calls;
|
|
14
|
+
const graphql = calls.some((words) => words[1] === "api" && words[2] === "graphql");
|
|
13
15
|
const subcommand = call?.[1];
|
|
14
16
|
if (subcommand === void 0) return void 0;
|
|
15
17
|
return {
|
|
16
18
|
subcommand,
|
|
17
|
-
rest: !GRAPHQL_REFUSAL.test(output) && subcommand === "api" &&
|
|
19
|
+
rest: !GRAPHQL_REFUSAL.test(output) && subcommand === "api" && !graphql
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
22
|
function advice(subcommand, rest) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { f as string, l as object, r as boolean } from "../schemas-BDlKVNhe.mjs";
|
|
1
2
|
import { execFileSync } from "node:child_process";
|
|
2
|
-
import { a as stringField, t as splitCommand } from "../shell-
|
|
3
|
-
import {
|
|
4
|
-
import { a as shellCommand, i as main, r as deny } from "../hook-DIS0wk_5.mjs";
|
|
3
|
+
import { a as stringField, t as splitCommand } from "../shell-BWP1aDQb.mjs";
|
|
4
|
+
import { a as shellCommand, i as main, r as deny } from "../hook-ClJcbzby.mjs";
|
|
5
5
|
// src/examples/issue-comment-guard.ts
|
|
6
6
|
/**
|
|
7
7
|
* Before a shell command, refuses a new comment on a GitHub issue the signed-in user wrote when no other person has commented: a decision or requirement for such an issue belongs in its body, which stays the one statement of what is asked for. Prefixing the command with `ISSUE_COMMENT_OK=1` lets a real reply or status note through. A lookup that fails allows the command, since the comment needs the same access.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { a as stringField, o as toolInput } from "../shell-
|
|
3
|
+
import { a as stringField, o as toolInput } from "../shell-BWP1aDQb.mjs";
|
|
4
4
|
import { n as cacheDirectory } from "../files-CBn-xAo2.mjs";
|
|
5
|
-
import { a as shellCommand, i as main, r as deny } from "../hook-
|
|
6
|
-
import { a as gh, i as existingDirectory, n as Lookups, o as originRepository, r as addedPrivateReferences, s as repositoryWrites, t as ESCAPE } from "../private-references-
|
|
5
|
+
import { a as shellCommand, i as main, r as deny } from "../hook-ClJcbzby.mjs";
|
|
6
|
+
import { a as gh, i as existingDirectory, n as Lookups, o as originRepository, r as addedPrivateReferences, s as repositoryWrites, t as ESCAPE } from "../private-references-B0qyQ0dB.mjs";
|
|
7
7
|
// src/examples/private-reference-guard.ts
|
|
8
8
|
/**
|
|
9
9
|
* Before a tool call, refuses to put the name of a private repository into a public one, through a file edit, a commit message or a `gh` write. Prefixing the command with `PRIVATE_REF_OK=1` lets a deliberate reference through.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as shellCommand, i as main, n as context, o as toolOutput, t as commandWords } from "../hook-
|
|
1
|
+
import { a as shellCommand, i as main, n as context, o as toolOutput, t as commandWords } from "../hook-ClJcbzby.mjs";
|
|
2
2
|
// src/examples/repository-metadata.ts
|
|
3
3
|
/**
|
|
4
4
|
* After a repository is created, forked, renamed or transferred, reminds the agent to set its description and topics, with the exact commands.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { text } from "node:stream/consumers";
|
|
2
|
-
import { i as parsePayload, o as toolInput, t as splitCommand } from "./shell-
|
|
3
|
-
import {
|
|
2
|
+
import { i as parsePayload, o as toolInput, t as splitCommand } from "./shell-BWP1aDQb.mjs";
|
|
3
|
+
import { v as harnesses } from "./schemas-BDlKVNhe.mjs";
|
|
4
4
|
// src/examples/hook.ts
|
|
5
5
|
/**
|
|
6
6
|
* What every example hook shares: reading its input, answering in the harness's output format and reading a tool call.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
-
import { a as stringField, o as toolInput, t as splitCommand } from "./shell-
|
|
2
|
+
import { a as stringField, o as toolInput, t as splitCommand } from "./shell-BWP1aDQb.mjs";
|
|
3
3
|
// src/dispatch/permission-rule.ts
|
|
4
4
|
/**
|
|
5
5
|
* Evaluates the permission rule a handler's `if` field holds against a tool call, following https://code.claude.com/docs/en/permissions and the hook-specific behaviour at https://code.claude.com/docs/en/hooks.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { dirname, resolve } from "node:path";
|
|
4
|
-
import { n as isRecord, t as splitCommand } from "./shell-
|
|
4
|
+
import { n as isRecord, t as splitCommand } from "./shell-BWP1aDQb.mjs";
|
|
5
5
|
import { t as atomicWrite } from "./files-CBn-xAo2.mjs";
|
|
6
6
|
// src/examples/private-references.ts
|
|
7
7
|
/**
|
|
@@ -59,7 +59,7 @@ const BODY_FILE_FLAGS = /* @__PURE__ */ new Set([
|
|
|
59
59
|
"--body-file",
|
|
60
60
|
"--file"
|
|
61
61
|
]);
|
|
62
|
-
const ENDPOINT = /^\/?repos\/([^/{}]+)\/([^/{}]+)(?:\/|$)/u;
|
|
62
|
+
const ENDPOINT = /^\/?repos\/([^/{}$]+)\/([^/{}$]+)(?:\/|$)/u;
|
|
63
63
|
const gh = (args) => {
|
|
64
64
|
try {
|
|
65
65
|
return execFileSync("gh", [...args], {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as handlersOf, n as parseRegistry, r as registryDocument } from "./schema-
|
|
1
|
+
export { t as handlersOf, n as parseRegistry, r as registryDocument } from "./schema-Dfw94F_X.mjs";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as int, c as number, d as strictObject, f as string, h as url, i as discriminatedUnion, n as array, o as literal, p as union, r as boolean, t as _enum, u as record } from "./schemas-B4KRDIno.mjs";
|
|
1
|
+
import { _ as eventNames, a as int, c as number, d as strictObject, f as string, h as url, i as discriminatedUnion, n as array, o as literal, p as union, r as boolean, t as _enum, u as record, v as harnesses } from "./schemas-BDlKVNhe.mjs";
|
|
3
2
|
// src/registry/schema.ts
|
|
4
3
|
/**
|
|
5
4
|
* The shape of a registry document, defined once: the types, the runtime validator and the published JSON Schema all come from these definitions. Rules that depend on the harness or the event are in `check.ts`.
|
|
@@ -1,3 +1,134 @@
|
|
|
1
|
+
// src/events.ts
|
|
2
|
+
/**
|
|
3
|
+
* What each harness does with each lifecycle event, as published at https://code.claude.com/docs/en/hooks and https://learn.chatgpt.com/docs/hooks.
|
|
4
|
+
*/
|
|
5
|
+
const harnesses = ["claude", "codex"];
|
|
6
|
+
const general = {
|
|
7
|
+
decides: false,
|
|
8
|
+
evaluatesIf: false,
|
|
9
|
+
defaultTimeoutSeconds: 600,
|
|
10
|
+
maxTimeoutSeconds: 600,
|
|
11
|
+
registeredByPlugin: true
|
|
12
|
+
};
|
|
13
|
+
function matching(matchField) {
|
|
14
|
+
return {
|
|
15
|
+
...general,
|
|
16
|
+
matchField
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function toolEvent(matchField) {
|
|
20
|
+
return {
|
|
21
|
+
...matching(matchField),
|
|
22
|
+
evaluatesIf: true
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function deciding(contract) {
|
|
26
|
+
return {
|
|
27
|
+
...contract,
|
|
28
|
+
decides: true
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const CLAUDE_SESSION_END_SECONDS = 1.5;
|
|
32
|
+
const CLAUDE_PROMPT_SECONDS = 30;
|
|
33
|
+
const CLAUDE_DISPLAY_SECONDS = 10;
|
|
34
|
+
const CODEX_SHUTDOWN_DEFAULT_SECONDS = 1;
|
|
35
|
+
const CODEX_SHUTDOWN_MAX_SECONDS = 3;
|
|
36
|
+
const claude = {
|
|
37
|
+
SessionStart: matching("source"),
|
|
38
|
+
Setup: matching("trigger"),
|
|
39
|
+
UserPromptSubmit: deciding({
|
|
40
|
+
...general,
|
|
41
|
+
defaultTimeoutSeconds: CLAUDE_PROMPT_SECONDS
|
|
42
|
+
}),
|
|
43
|
+
UserPromptExpansion: deciding(matching("command_name")),
|
|
44
|
+
PreSkillShellCommand: deciding(toolEvent("tool_name")),
|
|
45
|
+
PreToolUse: deciding(toolEvent("tool_name")),
|
|
46
|
+
PermissionRequest: deciding(toolEvent("tool_name")),
|
|
47
|
+
PermissionDenied: deciding(toolEvent("tool_name")),
|
|
48
|
+
PostToolUse: toolEvent("tool_name"),
|
|
49
|
+
PostToolUseFailure: toolEvent("tool_name"),
|
|
50
|
+
PostToolBatch: deciding(general),
|
|
51
|
+
Notification: matching("notification_type"),
|
|
52
|
+
MessageDisplay: {
|
|
53
|
+
...general,
|
|
54
|
+
defaultTimeoutSeconds: CLAUDE_DISPLAY_SECONDS
|
|
55
|
+
},
|
|
56
|
+
SubagentStart: matching("agent_type"),
|
|
57
|
+
SubagentStop: deciding(matching("agent_type")),
|
|
58
|
+
TaskCreated: deciding(general),
|
|
59
|
+
TaskCompleted: deciding(general),
|
|
60
|
+
Stop: deciding(general),
|
|
61
|
+
StopFailure: matching("error"),
|
|
62
|
+
TeammateIdle: deciding(general),
|
|
63
|
+
InstructionsLoaded: matching("load_reason"),
|
|
64
|
+
ConfigChange: deciding(matching("source")),
|
|
65
|
+
CwdChanged: general,
|
|
66
|
+
DirectoryAdded: matching("source"),
|
|
67
|
+
FileChanged: {
|
|
68
|
+
...matching("file_path"),
|
|
69
|
+
registeredByPlugin: false
|
|
70
|
+
},
|
|
71
|
+
WorktreeCreate: deciding({
|
|
72
|
+
...general,
|
|
73
|
+
registeredByPlugin: false
|
|
74
|
+
}),
|
|
75
|
+
WorktreeRemove: deciding({
|
|
76
|
+
...general,
|
|
77
|
+
registeredByPlugin: false
|
|
78
|
+
}),
|
|
79
|
+
PreCompact: deciding(matching("trigger")),
|
|
80
|
+
PostCompact: matching("trigger"),
|
|
81
|
+
PreModelSwitch: deciding({
|
|
82
|
+
...matching("to_model"),
|
|
83
|
+
defaultTimeoutSeconds: CLAUDE_PROMPT_SECONDS
|
|
84
|
+
}),
|
|
85
|
+
PostModelSwitch: {
|
|
86
|
+
...matching("to_model"),
|
|
87
|
+
defaultTimeoutSeconds: CLAUDE_PROMPT_SECONDS
|
|
88
|
+
},
|
|
89
|
+
Elicitation: deciding(matching("mcp_server_name")),
|
|
90
|
+
ElicitationResult: deciding(matching("mcp_server_name")),
|
|
91
|
+
SessionEnd: {
|
|
92
|
+
...matching("reason"),
|
|
93
|
+
defaultTimeoutSeconds: CLAUDE_SESSION_END_SECONDS,
|
|
94
|
+
maxTimeoutSeconds: CLAUDE_SESSION_END_SECONDS
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const codexShutdown = {
|
|
98
|
+
...general,
|
|
99
|
+
defaultTimeoutSeconds: CODEX_SHUTDOWN_DEFAULT_SECONDS,
|
|
100
|
+
maxTimeoutSeconds: CODEX_SHUTDOWN_MAX_SECONDS
|
|
101
|
+
};
|
|
102
|
+
const contracts = {
|
|
103
|
+
claude,
|
|
104
|
+
codex: {
|
|
105
|
+
SessionStart: matching("source"),
|
|
106
|
+
UserPromptSubmit: deciding(general),
|
|
107
|
+
PreToolUse: deciding(matching("tool_name")),
|
|
108
|
+
PermissionRequest: deciding(matching("tool_name")),
|
|
109
|
+
PostToolUse: matching("tool_name"),
|
|
110
|
+
PreModelRequest: deciding(general),
|
|
111
|
+
PostModelRequest: general,
|
|
112
|
+
PreCompact: deciding(matching("trigger")),
|
|
113
|
+
PostCompact: matching("trigger"),
|
|
114
|
+
SubagentStart: matching("agent_type"),
|
|
115
|
+
SubagentStop: deciding(matching("agent_type")),
|
|
116
|
+
Stop: deciding(general),
|
|
117
|
+
Interrupt: codexShutdown,
|
|
118
|
+
SessionEnd: {
|
|
119
|
+
...codexShutdown,
|
|
120
|
+
matchField: "reason"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
/** Every event the harness documents, in the order of its contract table. */
|
|
125
|
+
function eventNames(harness) {
|
|
126
|
+
return Object.keys(contracts[harness]);
|
|
127
|
+
}
|
|
128
|
+
/** The contract of an event, or `undefined` when the harness has no such event. */
|
|
129
|
+
function eventContract(harness, event) {
|
|
130
|
+
return Object.hasOwn(contracts[harness], event) ? contracts[harness][event] : void 0;
|
|
131
|
+
}
|
|
1
132
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/util.js
|
|
2
133
|
function getEnumValues(entries) {
|
|
3
134
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
@@ -5575,4 +5706,4 @@ function refine(fn, _params = {}) {
|
|
|
5575
5706
|
function superRefine(fn, params) {
|
|
5576
5707
|
return /* @__PURE__ */ _superRefine(fn, params);
|
|
5577
5708
|
}
|
|
5578
|
-
export { int as a, number as c, strictObject as d, string as f, url as h, discriminatedUnion as i, object as l, unknown as m, array as n, literal as o, union as p, boolean as r, looseObject as s, _enum as t, record as u };
|
|
5709
|
+
export { eventNames as _, int as a, number as c, strictObject as d, string as f, eventContract as g, url as h, discriminatedUnion as i, object as l, unknown as m, array as n, literal as o, union as p, boolean as r, looseObject as s, _enum as t, record as u, harnesses as v };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { f as string, l as object } from "./schemas-BDlKVNhe.mjs";
|
|
1
2
|
// src/dispatch/payload.ts
|
|
2
3
|
function isRecord(value) {
|
|
3
4
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -29,6 +30,9 @@ function namedField(payload, name) {
|
|
|
29
30
|
return typeof value === "string" ? value : JSON.stringify(value);
|
|
30
31
|
}
|
|
31
32
|
// src/dispatch/shell.ts
|
|
33
|
+
/**
|
|
34
|
+
* Splits a shell command line into the simple commands a permission rule is compared with, as Claude Code describes at https://code.claude.com/docs/en/permissions#compound-commands.
|
|
35
|
+
*/
|
|
32
36
|
const ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*\+?=/u;
|
|
33
37
|
const KEYWORDS = /* @__PURE__ */ new Set([
|
|
34
38
|
"!",
|
|
@@ -113,7 +117,10 @@ var Scanner = class {
|
|
|
113
117
|
endCommand();
|
|
114
118
|
this.position += 1;
|
|
115
119
|
for (const delimiter of heredocs.splice(0)) this.skipHeredoc(delimiter);
|
|
116
|
-
} else if (
|
|
120
|
+
} else if (this.source.startsWith("<<<", this.position)) {
|
|
121
|
+
wordStart ??= this.position;
|
|
122
|
+
this.position += 3;
|
|
123
|
+
} else if (character === "<" && next === "<") {
|
|
117
124
|
endWord();
|
|
118
125
|
heredocs.push(this.heredocDelimiter());
|
|
119
126
|
} else if (character === "&" && next === ">" || (character === ">" || character === "<") && next === "&") {
|
|
@@ -128,6 +135,7 @@ var Scanner = class {
|
|
|
128
135
|
endCommand();
|
|
129
136
|
this.position += 1;
|
|
130
137
|
this.scan(")");
|
|
138
|
+
pendingOperator = false;
|
|
131
139
|
} else if (character === ")") {
|
|
132
140
|
endCommand();
|
|
133
141
|
this.position += 1;
|
|
@@ -144,6 +152,7 @@ var Scanner = class {
|
|
|
144
152
|
if (character === "\\") this.position += 2;
|
|
145
153
|
else if (character === "'") this.skipTo("'");
|
|
146
154
|
else if (character === "\"") this.doubleQuoted();
|
|
155
|
+
else if (character === "$" && this.source[this.position + 1] === "'") this.ansiQuoted();
|
|
147
156
|
else if (!this.expansion()) this.position += 1;
|
|
148
157
|
}
|
|
149
158
|
/** Consumes a substitution or variable at the current position, reporting whether there was one. */
|
|
@@ -158,6 +167,7 @@ var Scanner = class {
|
|
|
158
167
|
}
|
|
159
168
|
if (character !== "$" || next === void 0) return false;
|
|
160
169
|
if (next === "(") {
|
|
170
|
+
if (this.arithmetic()) return true;
|
|
161
171
|
this.expands = true;
|
|
162
172
|
this.position += 2;
|
|
163
173
|
this.scan(")");
|
|
@@ -166,11 +176,46 @@ var Scanner = class {
|
|
|
166
176
|
if (/[A-Za-z_{0-9@*?#!]/u.test(next)) this.expands = true;
|
|
167
177
|
return false;
|
|
168
178
|
}
|
|
179
|
+
arithmetic() {
|
|
180
|
+
if (!this.source.startsWith("$((", this.position)) return false;
|
|
181
|
+
const start = this.position;
|
|
182
|
+
const found = this.commands.length;
|
|
183
|
+
this.position += 3;
|
|
184
|
+
let depth = 0;
|
|
185
|
+
while (this.position < this.source.length) {
|
|
186
|
+
const character = this.source[this.position];
|
|
187
|
+
if (character === "(") depth += 1;
|
|
188
|
+
else if (character === ")" && depth > 0) depth -= 1;
|
|
189
|
+
else if (character === ")") break;
|
|
190
|
+
if (!this.expansion()) this.position += 1;
|
|
191
|
+
}
|
|
192
|
+
if (this.source.startsWith("))", this.position)) {
|
|
193
|
+
this.position += 2;
|
|
194
|
+
this.expands = true;
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
this.position = start;
|
|
198
|
+
for (const list of [
|
|
199
|
+
this.commands,
|
|
200
|
+
this.words,
|
|
201
|
+
this.prefixes
|
|
202
|
+
]) list.length = found;
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
169
205
|
skipTo(quote) {
|
|
170
206
|
const end = this.source.indexOf(quote, this.position + 1);
|
|
171
207
|
if (end === -1) throw new Unsplittable();
|
|
172
208
|
this.position = end + 1;
|
|
173
209
|
}
|
|
210
|
+
ansiQuoted() {
|
|
211
|
+
this.position += 2;
|
|
212
|
+
while (this.position < this.source.length) {
|
|
213
|
+
const character = this.source[this.position];
|
|
214
|
+
this.position += character === "\\" ? 2 : 1;
|
|
215
|
+
if (character === "'") return;
|
|
216
|
+
}
|
|
217
|
+
throw new Unsplittable();
|
|
218
|
+
}
|
|
174
219
|
doubleQuoted() {
|
|
175
220
|
this.position += 1;
|
|
176
221
|
while (this.position < this.source.length) {
|
|
@@ -222,8 +267,28 @@ var Scanner = class {
|
|
|
222
267
|
this.prefixes.push(texts.slice(0, index).map(unquoted));
|
|
223
268
|
}
|
|
224
269
|
};
|
|
270
|
+
const ANSI_ESCAPES = /* @__PURE__ */ new Map([
|
|
271
|
+
["n", "\n"],
|
|
272
|
+
["t", " "],
|
|
273
|
+
["r", "\r"],
|
|
274
|
+
["'", "'"],
|
|
275
|
+
["\"", "\""],
|
|
276
|
+
["\\", "\\"]
|
|
277
|
+
]);
|
|
278
|
+
function ansiText(body) {
|
|
279
|
+
return body.replaceAll(/\\(.)/gsu, (sequence, character) => ANSI_ESCAPES.get(character) ?? sequence);
|
|
280
|
+
}
|
|
225
281
|
function unquoted(word) {
|
|
226
|
-
return word.replaceAll(
|
|
282
|
+
return word.replaceAll(/\$'(?<ansi>(?:\\.|[^'\\])*)'|'(?<single>[^']*)'|"(?<double>(?:\\.|[^"\\])*)"|\\(?<escaped>.)/gsu, (...found) => {
|
|
283
|
+
const { ansi, single, double, escaped } = object({
|
|
284
|
+
ansi: string().optional(),
|
|
285
|
+
single: string().optional(),
|
|
286
|
+
double: string().optional(),
|
|
287
|
+
escaped: string().optional()
|
|
288
|
+
}).parse(found.at(-1));
|
|
289
|
+
if (ansi !== void 0) return ansiText(ansi);
|
|
290
|
+
return single ?? double?.replaceAll(/\\([$`"\\\n])/gu, "$1") ?? escaped ?? "";
|
|
291
|
+
});
|
|
227
292
|
}
|
|
228
293
|
/** The simple commands of a command line, or `undefined` when it cannot be split. */
|
|
229
294
|
function splitCommand(command) {
|
|
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { readFileSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { t as atomicWrite } from "./files-CBn-xAo2.mjs";
|
|
5
|
-
import { a as stringField, n as isRecord } from "./shell-
|
|
5
|
+
import { a as stringField, n as isRecord } from "./shell-BWP1aDQb.mjs";
|
|
6
6
|
// src/dispatch/state.ts
|
|
7
7
|
/**
|
|
8
8
|
* Small JSON records the dispatcher keeps between events. Losing one only means a handler runs or speaks once more, so an unreadable record counts as absent.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hookloom",
|
|
3
3
|
"description": "One hook registry for Claude Code and Codex: a plugin that dispatches every lifecycle event to your hooks, with a CLI to set up, migrate and roll back",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"author": "Joseph Mearman <joseph@mearman.co.uk>",
|
|
6
6
|
"bin": {
|
|
7
7
|
"hookloom": "./dist/cli.mjs"
|
package/dist/check-ySa9Ce1V.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { t as checkRegistry } from "./check-CRZ6Rgdo.mjs";
|
package/dist/events-CHsq0Cl4.mjs
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// src/events.ts
|
|
2
|
-
/**
|
|
3
|
-
* What each harness does with each lifecycle event, as published at https://code.claude.com/docs/en/hooks and https://learn.chatgpt.com/docs/hooks.
|
|
4
|
-
*/
|
|
5
|
-
const harnesses = ["claude", "codex"];
|
|
6
|
-
const general = {
|
|
7
|
-
decides: false,
|
|
8
|
-
evaluatesIf: false,
|
|
9
|
-
defaultTimeoutSeconds: 600,
|
|
10
|
-
maxTimeoutSeconds: 600,
|
|
11
|
-
registeredByPlugin: true
|
|
12
|
-
};
|
|
13
|
-
function matching(matchField) {
|
|
14
|
-
return {
|
|
15
|
-
...general,
|
|
16
|
-
matchField
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function toolEvent(matchField) {
|
|
20
|
-
return {
|
|
21
|
-
...matching(matchField),
|
|
22
|
-
evaluatesIf: true
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function deciding(contract) {
|
|
26
|
-
return {
|
|
27
|
-
...contract,
|
|
28
|
-
decides: true
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const CLAUDE_SESSION_END_SECONDS = 1.5;
|
|
32
|
-
const CLAUDE_PROMPT_SECONDS = 30;
|
|
33
|
-
const CLAUDE_DISPLAY_SECONDS = 10;
|
|
34
|
-
const CODEX_SHUTDOWN_DEFAULT_SECONDS = 1;
|
|
35
|
-
const CODEX_SHUTDOWN_MAX_SECONDS = 3;
|
|
36
|
-
const claude = {
|
|
37
|
-
SessionStart: matching("source"),
|
|
38
|
-
Setup: matching("trigger"),
|
|
39
|
-
UserPromptSubmit: deciding({
|
|
40
|
-
...general,
|
|
41
|
-
defaultTimeoutSeconds: CLAUDE_PROMPT_SECONDS
|
|
42
|
-
}),
|
|
43
|
-
UserPromptExpansion: deciding(matching("command_name")),
|
|
44
|
-
PreSkillShellCommand: deciding(toolEvent("tool_name")),
|
|
45
|
-
PreToolUse: deciding(toolEvent("tool_name")),
|
|
46
|
-
PermissionRequest: deciding(toolEvent("tool_name")),
|
|
47
|
-
PermissionDenied: deciding(toolEvent("tool_name")),
|
|
48
|
-
PostToolUse: toolEvent("tool_name"),
|
|
49
|
-
PostToolUseFailure: toolEvent("tool_name"),
|
|
50
|
-
PostToolBatch: deciding(general),
|
|
51
|
-
Notification: matching("notification_type"),
|
|
52
|
-
MessageDisplay: {
|
|
53
|
-
...general,
|
|
54
|
-
defaultTimeoutSeconds: CLAUDE_DISPLAY_SECONDS
|
|
55
|
-
},
|
|
56
|
-
SubagentStart: matching("agent_type"),
|
|
57
|
-
SubagentStop: deciding(matching("agent_type")),
|
|
58
|
-
TaskCreated: deciding(general),
|
|
59
|
-
TaskCompleted: deciding(general),
|
|
60
|
-
Stop: deciding(general),
|
|
61
|
-
StopFailure: matching("error"),
|
|
62
|
-
TeammateIdle: deciding(general),
|
|
63
|
-
InstructionsLoaded: matching("load_reason"),
|
|
64
|
-
ConfigChange: deciding(matching("source")),
|
|
65
|
-
CwdChanged: general,
|
|
66
|
-
DirectoryAdded: matching("source"),
|
|
67
|
-
FileChanged: {
|
|
68
|
-
...matching("file_path"),
|
|
69
|
-
registeredByPlugin: false
|
|
70
|
-
},
|
|
71
|
-
WorktreeCreate: deciding({
|
|
72
|
-
...general,
|
|
73
|
-
registeredByPlugin: false
|
|
74
|
-
}),
|
|
75
|
-
WorktreeRemove: deciding({
|
|
76
|
-
...general,
|
|
77
|
-
registeredByPlugin: false
|
|
78
|
-
}),
|
|
79
|
-
PreCompact: deciding(matching("trigger")),
|
|
80
|
-
PostCompact: matching("trigger"),
|
|
81
|
-
PreModelSwitch: deciding({
|
|
82
|
-
...matching("to_model"),
|
|
83
|
-
defaultTimeoutSeconds: CLAUDE_PROMPT_SECONDS
|
|
84
|
-
}),
|
|
85
|
-
PostModelSwitch: {
|
|
86
|
-
...matching("to_model"),
|
|
87
|
-
defaultTimeoutSeconds: CLAUDE_PROMPT_SECONDS
|
|
88
|
-
},
|
|
89
|
-
Elicitation: deciding(matching("mcp_server_name")),
|
|
90
|
-
ElicitationResult: deciding(matching("mcp_server_name")),
|
|
91
|
-
SessionEnd: {
|
|
92
|
-
...matching("reason"),
|
|
93
|
-
defaultTimeoutSeconds: CLAUDE_SESSION_END_SECONDS,
|
|
94
|
-
maxTimeoutSeconds: CLAUDE_SESSION_END_SECONDS
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const codexShutdown = {
|
|
98
|
-
...general,
|
|
99
|
-
defaultTimeoutSeconds: CODEX_SHUTDOWN_DEFAULT_SECONDS,
|
|
100
|
-
maxTimeoutSeconds: CODEX_SHUTDOWN_MAX_SECONDS
|
|
101
|
-
};
|
|
102
|
-
const contracts = {
|
|
103
|
-
claude,
|
|
104
|
-
codex: {
|
|
105
|
-
SessionStart: matching("source"),
|
|
106
|
-
UserPromptSubmit: deciding(general),
|
|
107
|
-
PreToolUse: deciding(matching("tool_name")),
|
|
108
|
-
PermissionRequest: deciding(matching("tool_name")),
|
|
109
|
-
PostToolUse: matching("tool_name"),
|
|
110
|
-
PreModelRequest: deciding(general),
|
|
111
|
-
PostModelRequest: general,
|
|
112
|
-
PreCompact: deciding(matching("trigger")),
|
|
113
|
-
PostCompact: matching("trigger"),
|
|
114
|
-
SubagentStart: matching("agent_type"),
|
|
115
|
-
SubagentStop: deciding(matching("agent_type")),
|
|
116
|
-
Stop: deciding(general),
|
|
117
|
-
Interrupt: codexShutdown,
|
|
118
|
-
SessionEnd: {
|
|
119
|
-
...codexShutdown,
|
|
120
|
-
matchField: "reason"
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
/** Every event the harness documents, in the order of its contract table. */
|
|
125
|
-
function eventNames(harness) {
|
|
126
|
-
return Object.keys(contracts[harness]);
|
|
127
|
-
}
|
|
128
|
-
/** The contract of an event, or `undefined` when the harness has no such event. */
|
|
129
|
-
function eventContract(harness, event) {
|
|
130
|
-
return Object.hasOwn(contracts[harness], event) ? contracts[harness][event] : void 0;
|
|
131
|
-
}
|
|
132
|
-
export { eventNames as n, harnesses as r, eventContract as t };
|