From e22bb79adbb4cd52a9e274f117f0858193d84a51 Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Sun, 6 Dec 2026 13:43:49 +0000 Subject: [PATCH] claude: replace the OpenCode plugin with an agent-policy script The Claude Code Bash hook lived in an OpenCode plugin, a TypeScript npm package with a build step and a lockfile, though OpenCode is no longer used. The hook rewrote commands, adding nix build flags and quoting flake references, which hid the correction from the agent. Because it rewrote nix build, it also had to approve it, and it approved any command containing a nix build, whatever else the command ran. agent-policy is a stdlib-only Python script that either denies a tool call with a reason or passes it on. It keeps the same rules, but a command the hook used to rewrite is now denied with a message saying what to change, and nix build only has to use --no-link. Claude Code calls it as `agent-policy claude-hook`, and its unit tests run as a flake check in place of the plugin's. nix build is approved by a Bash(nix build *) allow rule instead, which Claude Code matches against each command in a compound one. Test plan: - CI - Ran the built hook on a git commit in a jj repo (denied, exit 2) - Built maverick and checked managed-settings.json carries the hook and the allow rule --- AGENTS.md | 2 +- flake.nix | 4 +- modules/home/claude/default.nix | 7 +- pkgs/agent-policy/agent_policy.py | 188 ++++ pkgs/agent-policy/default.nix | 26 + pkgs/agent-policy/test_agent_policy.py | 144 +++ pkgs/opencode-plugin/default.nix | 46 - pkgs/opencode-plugin/package-lock.json | 830 ------------------ pkgs/opencode-plugin/package.json | 20 - pkgs/opencode-plugin/shim/claude-hook.ts | 92 -- pkgs/opencode-plugin/src/hooks/jj-redirect.ts | 22 - pkgs/opencode-plugin/src/hooks/nix.ts | 43 - .../src/hooks/redundant-cwd.ts | 29 - pkgs/opencode-plugin/src/index.ts | 66 -- pkgs/opencode-plugin/src/types.ts | 6 - pkgs/opencode-plugin/test/jj-redirect.test.ts | 54 -- pkgs/opencode-plugin/test/nix.test.ts | 139 --- .../test/redundant-cwd.test.ts | 69 -- pkgs/opencode-plugin/tsconfig.json | 15 - 19 files changed, 366 insertions(+), 1436 deletions(-) create mode 100644 pkgs/agent-policy/agent_policy.py create mode 100644 pkgs/agent-policy/default.nix create mode 100644 pkgs/agent-policy/test_agent_policy.py delete mode 100644 pkgs/opencode-plugin/default.nix delete mode 100644 pkgs/opencode-plugin/package-lock.json delete mode 100644 pkgs/opencode-plugin/package.json delete mode 100644 pkgs/opencode-plugin/shim/claude-hook.ts delete mode 100644 pkgs/opencode-plugin/src/hooks/jj-redirect.ts delete mode 100644 pkgs/opencode-plugin/src/hooks/nix.ts delete mode 100644 pkgs/opencode-plugin/src/hooks/redundant-cwd.ts delete mode 100644 pkgs/opencode-plugin/src/index.ts delete mode 100644 pkgs/opencode-plugin/src/types.ts delete mode 100644 pkgs/opencode-plugin/test/jj-redirect.test.ts delete mode 100644 pkgs/opencode-plugin/test/nix.test.ts delete mode 100644 pkgs/opencode-plugin/test/redundant-cwd.test.ts delete mode 100644 pkgs/opencode-plugin/tsconfig.json diff --git a/AGENTS.md b/AGENTS.md index 2f9cfe96..6c3d541e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -390,7 +390,7 @@ CI is **not** a standalone workflow file — it is driven by **buildbot-nix**, t - **`formatting`** — a treefmt check (`(treefmtEval pkgs).config.build.check self`). This is the CI equivalent of `nix fmt`: treefmt runs `nixpkgs-fmt` (Nix), `gofumpt`, `black`, and `rustfmt` per `flake.nix`'s `treefmtEval`. An unformatted tree fails CI. - **`nixos-`** — the toplevel of every host whose `system` matches the build system, with `configurationRevision` zeroed. This is effectively `nix build '.#nixosConfigurations."".config.system.build.toplevel'` for the whole fleet, so any host that stops evaluating fails CI. -- **`opencode-plugin`** and the **`./tests`** module tests (x86_64-linux only) — snapshot-verified NixOS module tests, regenerable via `nix run .#generate-snapshots`. +- **`agent-policy`** and the **`./tests`** module tests (x86_64-linux only) — snapshot-verified NixOS module tests, regenerable via `nix run .#generate-snapshots`. Because every host's toplevel is a check, a config change that breaks *any* host — not just the one you touched — fails CI. Targeted local `nix build` for the affected host(s) is the fast feedback loop; full CI is the comprehensive one. diff --git a/flake.nix b/flake.nix index 438cffbe..0edaefbe 100644 --- a/flake.nix +++ b/flake.nix @@ -99,7 +99,7 @@ "caddy-with-dns" = final.callPackage ./pkgs/caddy-with-dns.nix { }; "ogygia" = ogygia.packages.${final.stdenv.hostPlatform.system}.ogygia; "qnaplcd" = final.callPackage ./pkgs/qnaplcd.nix { inherit qnaplcd-menu; }; - "opencode-plugin" = final.callPackage ./pkgs/opencode-plugin { }; + "agent-policy" = final.callPackage ./pkgs/agent-policy { }; "gitea-actions-vm-image" = final.callPackage ./pkgs/gitea-actions-vm-image { gitea-actions-runner = final.unstable.gitea-actions-runner; }; @@ -253,7 +253,7 @@ in { checks = { - opencode-plugin = pkgs.opencode-plugin; + agent-policy = pkgs.agent-policy; installer-iso = installerIso; } // nixosMachines; diff --git a/modules/home/claude/default.nix b/modules/home/claude/default.nix index b0ebf5e2..dfaf1891 100644 --- a/modules/home/claude/default.nix +++ b/modules/home/claude/default.nix @@ -10,7 +10,10 @@ let claudeSettings = { remoteControlAtStartup = false; - permissions.defaultMode = "auto"; + permissions = { + defaultMode = "auto"; + allow = [ "Bash(nix build *)" ]; + }; attribution = { commit = ""; pr = ""; @@ -33,7 +36,7 @@ let hooks = [ { type = "command"; - command = "${pkgs.opencode-plugin}/bin/claude-hook-shim"; + command = "${lib.getExe pkgs.agent-policy} claude-hook"; } ]; } diff --git a/pkgs/agent-policy/agent_policy.py b/pkgs/agent-policy/agent_policy.py new file mode 100644 index 00000000..3ac30566 --- /dev/null +++ b/pkgs/agent-policy/agent_policy.py @@ -0,0 +1,188 @@ +#!/usr/bin/env python3 +"""Deterministic policy for coding agents' tool calls. + +A call the policy objects to is denied with a reason the agent can act on. +Any other call is left to the agent's own permission checks. +""" + +import argparse +import json +import os +import shlex +import sys + + +PUNCTUATION = "();<>|&\n" + + +def parse(command): + """Split a shell command into the argv of each simple command. + + Returns None when the command can't be tokenised, such as with an + unterminated quote. + """ + lexer = shlex.shlex(command, posix=True, punctuation_chars=PUNCTUATION) + lexer.whitespace = " \t\r" + lexer.whitespace_split = True + # shlex would otherwise end a word at the # of a flake reference. + lexer.commenters = "" + try: + tokens = list(lexer) + except ValueError: + return None + + commands = [[]] + for token in tokens: + if all(c in PUNCTUATION for c in token): + if "<" not in token and ">" not in token: + commands.append([]) + else: + commands[-1].append(token) + + argvs = [] + for argv in commands: + while argv and "=" in argv[0] and not argv[0].startswith("="): + argv = argv[1:] + if argv: + argvs.append(argv) + return argvs + + +def has_unquoted_flake_ref(command): + quote = None + escaped = False + for i, c in enumerate(command): + if escaped: + escaped = False + elif quote: + if c == quote: + quote = None + elif c == "\\" and quote == '"': + escaped = True + elif c == "\\": + escaped = True + elif c in "'\"": + quote = c + elif c == "#" and i > 0 and command[i - 1] == ".": + return True + return False + + +def nix_subcommand(argv): + if argv[0] == "nix" and len(argv) > 1: + return argv[1] + return None + + +GIT_OPTIONS_WITH_VALUE = { + "-C", + "-c", + "--git-dir", + "--work-tree", + "--namespace", +} + + +def git_subcommand(argv): + args = iter(argv[1:]) + for arg in args: + if arg in GIT_OPTIONS_WITH_VALUE: + next(args, None) + elif not arg.startswith("-"): + return arg + return None + + +def repo_flag_paths(argv): + if argv[0] == "git": + flags = {"-C"} + elif argv[0] == "jj": + flags = {"-R", "--repository"} + else: + return [] + + paths = [] + for i, arg in enumerate(argv): + if arg in flags and i + 1 < len(argv): + paths.append(argv[i + 1]) + return paths + + +def bash_denial(command, cwd): + commands = parse(command) + if commands is None: + return None + + nix_build_or_run = False + for argv in commands: + sub = nix_subcommand(argv) + if sub in ("build", "run"): + nix_build_or_run = True + if sub == "build" and "--no-link" not in argv: + return ( + "Run nix build with --no-link, so it leaves no result " + "symlink behind." + ) + + if ( + argv[0] == "git" + and git_subcommand(argv) == "commit" + and os.path.isdir(os.path.join(cwd, ".jj")) + ): + return ( + "This repository uses Jujutsu (jj), not Git. Use 'jj commit " + "-m \"...\"' instead of 'git commit'. DO NOT use 'jj " + "describe', it is not a replacement for 'git commit'. See the " + "jj skill for the full workflow." + ) + + for path in repo_flag_paths(argv): + resolved = os.path.realpath( + os.path.join(cwd, os.path.expanduser(path)) + ) + if resolved == os.path.realpath(cwd): + return ( + "Redundant -C/-R flag: the path is already the working " + "directory. Run the command without it." + ) + + if nix_build_or_run and has_unquoted_flake_ref(command): + return ( + "Quote flake references, like '.#attr', so the shell passes " + "them through unchanged." + ) + + return None + + +def denial(tool, tool_input, cwd): + """The reason to deny a tool call, or None to leave it alone.""" + if tool == "bash": + return bash_denial(tool_input.get("command", ""), cwd) + return None + + +CLAUDE_TOOLS = {"Bash": "bash"} + + +def claude_hook(stdin, stderr): + event = json.load(stdin) + tool = CLAUDE_TOOLS.get(event.get("tool_name")) + reason = denial( + tool, event.get("tool_input", {}), event.get("cwd") or os.getcwd() + ) + if reason is None: + return 0 + stderr.write(reason) + return 2 + + +def main(): + parser = argparse.ArgumentParser(prog="agent-policy") + parser.add_argument("adapter", choices=["claude-hook"]) + parser.parse_args() + sys.exit(claude_hook(sys.stdin, sys.stderr)) + + +if __name__ == "__main__": + main() diff --git a/pkgs/agent-policy/default.nix b/pkgs/agent-policy/default.nix new file mode 100644 index 00000000..a0149406 --- /dev/null +++ b/pkgs/agent-policy/default.nix @@ -0,0 +1,26 @@ +{ stdenvNoCC, python3 }: + +stdenvNoCC.mkDerivation { + pname = "agent-policy"; + version = "1.0.0"; + + src = ./.; + + buildInputs = [ python3 ]; + nativeCheckInputs = [ python3 ]; + + doCheck = true; + checkPhase = '' + runHook preCheck + python3 -m unittest + runHook postCheck + ''; + + installPhase = '' + runHook preInstall + install -Dm755 agent_policy.py $out/bin/agent-policy + runHook postInstall + ''; + + meta.mainProgram = "agent-policy"; +} diff --git a/pkgs/agent-policy/test_agent_policy.py b/pkgs/agent-policy/test_agent_policy.py new file mode 100644 index 00000000..c9345fde --- /dev/null +++ b/pkgs/agent-policy/test_agent_policy.py @@ -0,0 +1,144 @@ +import io +import json +import os +import tempfile +import unittest + +from agent_policy import bash_denial, claude_hook, denial + + +class Dirs(unittest.TestCase): + def setUp(self): + tmp = tempfile.TemporaryDirectory() + self.addCleanup(tmp.cleanup) + self.plain = os.path.join(tmp.name, "plain") + self.jj = os.path.join(tmp.name, "jj") + os.makedirs(self.plain) + os.makedirs(os.path.join(self.jj, ".jj")) + + def assertDenied(self, reason, *fragments): + self.assertIsNotNone(reason) + for fragment in fragments: + self.assertIn(fragment, reason) + + +class NixTest(Dirs): + def test_nix_build_with_no_link_passes(self): + self.assertIsNone( + bash_denial("nix build --no-link '.#foo'", self.plain) + ) + + def test_nix_build_without_no_link_is_denied(self): + for cmd in ("nix build '.#foo'", "ls && nix build '.#foo'"): + with self.subTest(cmd=cmd): + self.assertDenied(bash_denial(cmd, self.plain), "--no-link") + + def test_unquoted_flake_ref_is_denied(self): + self.assertDenied( + bash_denial( + "nix build --no-link --print-out-paths .#foo", self.plain + ), + "Quote flake references", + ) + self.assertDenied( + bash_denial("nix run .#generate-snapshots", self.plain), + "Quote flake references", + ) + + def test_quoted_flake_refs_pass(self): + for ref in ( + "'.#foo'", + '".#foo"', + "'.#nixosConfigurations.\"host\".config'", + ): + with self.subTest(ref=ref): + self.assertIsNone(bash_denial(f"nix run {ref}", self.plain)) + + def test_unquoted_flake_ref_outside_nix_passes(self): + self.assertIsNone(bash_denial("echo .#foo", self.plain)) + + def test_nix_build_in_quotes_is_not_nix(self): + self.assertIsNone(bash_denial("echo 'nix build .#foo'", self.plain)) + + +class GitCommitTest(Dirs): + def test_git_commit_in_jj_repo_is_denied(self): + for cmd in ( + "git commit -m x", + "git add a && git commit -m x", + "git -c user.name=x commit", + ): + with self.subTest(cmd=cmd): + self.assertDenied(bash_denial(cmd, self.jj), "jj commit") + + def test_git_commit_outside_jj_passes(self): + self.assertIsNone(bash_denial("git commit -m x", self.plain)) + + def test_other_git_commands_pass(self): + self.assertIsNone(bash_denial("git log --grep commit", self.jj)) + + +class RepoFlagTest(Dirs): + def test_redundant_flags_are_denied(self): + for cmd in ( + f"git -C {self.plain} status", + "git -C . status", + f"jj -R {self.plain} log", + f"jj --repository {self.plain} log", + f"jj -R '{self.plain}' log", + ): + with self.subTest(cmd=cmd): + self.assertDenied(bash_denial(cmd, self.plain), "Redundant") + + def test_other_directories_pass(self): + self.assertIsNone(bash_denial(f"git -C {self.jj} status", self.plain)) + + +class ParseTest(Dirs): + def test_unparseable_command_passes(self): + self.assertIsNone(bash_denial("echo 'unterminated", self.plain)) + + def test_env_assignments_are_skipped(self): + self.assertDenied( + bash_denial("FOO=1 git commit", self.jj), "jj commit" + ) + + def test_newline_separates_commands(self): + self.assertDenied(bash_denial("ls\ngit commit", self.jj), "jj commit") + + +class ClaudeHookTest(Dirs): + def run_hook(self, event): + stderr = io.StringIO() + code = claude_hook(io.StringIO(json.dumps(event)), stderr) + return code, stderr.getvalue() + + def test_deny_exits_2_with_reason(self): + code, stderr = self.run_hook( + { + "tool_name": "Bash", + "tool_input": {"command": "git commit"}, + "cwd": self.jj, + } + ) + self.assertEqual(code, 2) + self.assertIn("jj commit", stderr) + + def test_pass_prints_nothing(self): + self.assertEqual( + self.run_hook( + { + "tool_name": "Bash", + "tool_input": {"command": "ls"}, + "cwd": self.plain, + } + ), + (0, ""), + ) + + def test_unknown_tool_passes(self): + self.assertIsNone(denial(None, {}, self.plain)) + + +if __name__ == "__main__": + unittest.main() diff --git a/pkgs/opencode-plugin/default.nix b/pkgs/opencode-plugin/default.nix deleted file mode 100644 index 92121465..00000000 --- a/pkgs/opencode-plugin/default.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ lib, buildNpmPackage, importNpmLock, nodejs }: - -buildNpmPackage { - pname = "opencode-plugin"; - version = "1.0.0"; - - src = ./.; - - npmDeps = importNpmLock { npmRoot = ./.; }; - npmConfigHook = importNpmLock.npmConfigHook; - - buildPhase = '' - runHook preBuild - npm run build - runHook postBuild - ''; - - checkPhase = '' - runHook preCheck - npm test - runHook postCheck - ''; - doCheck = true; - - installPhase = '' - runHook preInstall - - mkdir -p $out/lib/opencode-plugin - cp -r dist $out/lib/opencode-plugin/ - cp package.json $out/lib/opencode-plugin/ - - mkdir -p $out/bin - cat > $out/bin/claude-hook-shim <=18" - } - }, - "node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-arm64/-/msgpackr-extract-darwin-arm64-3.0.7.tgz", - "integrity": "sha512-2zPHLn+MuGJ6GP/5jDrwa9Jy0CI+D3Ibpvopf5SFfmc1G9gdofR4uB7YrJAAp4vodn/7iDOciyv8bgkRPLw7cA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-darwin-x64": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-x64/-/msgpackr-extract-darwin-x64-3.0.7.tgz", - "integrity": "sha512-of1miwFfEdgs5nythewsEoocfpbjzUf8PC996YDe3kAyv0ZJiMJs5NXlYhE6IdjxfNEPqUXj/BYBnpD8kRdfeQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm/-/msgpackr-extract-linux-arm-3.0.7.tgz", - "integrity": "sha512-aDPbiEkFHs3H68705JKxJ15IT41wFdvDhba1pL8ygfdoshboL5dsXtiu76/CqhLWYneE+9hwBE+0abqNOiQ4Bw==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm64": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm64/-/msgpackr-extract-linux-arm64-3.0.7.tgz", - "integrity": "sha512-jcRydYARTW0gX5idJhxV7m3KkRUD7KtZLYFF1ZY18HrPqpGY0TCqPUTJCwka2kVfVOwfKs3ZmlPSmQb4S6xj7w==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-linux-x64": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-x64/-/msgpackr-extract-linux-x64-3.0.7.tgz", - "integrity": "sha512-A9xOmARctmUvHrBj5GGzGAigsZFnqE4kld5oprX3PyPbkVALV4jwBc17gPZrhSOvnXQc81hE9K7S2hDUCgialA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-win32-x64": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-win32-x64/-/msgpackr-extract-win32-x64-3.0.7.tgz", - "integrity": "sha512-PRBiOqK4mcR0rvm6nybO7pSOYRR2Zza0+43UK2IvbVGelzMqZViiZJmOWGuWOX678QKESO6YrHx36z43nSS6iQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@opencode-ai/plugin": { - "version": "1.19.6", - "resolved": "https://registry.npmjs.org/@opencode-ai/plugin/-/plugin-1.19.6.tgz", - "integrity": "sha512-eq1+T75FdIwPTiB8WQLV3Kii0TDAqHsC0baQtbpPS5bzgSc2UhGouy10FxedwKXbC/Prm2FgDhoARwwKDd3yhw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@ai-sdk/provider": "3.0.8", - "@opencode-ai/sdk": "1.19.6", - "effect": "4.0.0-beta.83", - "zod": "4.1.8" - }, - "peerDependencies": { - "@opentui/core": ">=0.4.5", - "@opentui/keymap": ">=0.4.5", - "@opentui/solid": ">=0.4.5" - }, - "peerDependenciesMeta": { - "@opentui/core": { - "optional": true - }, - "@opentui/keymap": { - "optional": true - }, - "@opentui/solid": { - "optional": true - } - } - }, - "node_modules/@opencode-ai/sdk": { - "version": "1.19.6", - "resolved": "https://registry.npmjs.org/@opencode-ai/sdk/-/sdk-1.19.6.tgz", - "integrity": "sha512-jYV7s+Tlc5jDILOyWFIgISkPlfk7z3ByqeC8/T9aESZBgSZosQR784U2UoM3ZrJ8S0LJ2cB+IA9xZN7Jj8tnhQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "cross-spawn": "7.0.6" - } - }, - "node_modules/@standard-schema/spec": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", - "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/node": { - "version": "24.19.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.4.tgz", - "integrity": "sha512-s04odlR3ksJrLu7QLi+pddkWLD0RmSbcP9KuWn2/ozQKAp/YgwBC/6x9kJj8yAzZnGPfxePm7zm7nysVPCRagw==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": ">=7.24.0 <7.24.7" - } - }, - "node_modules/@typescript/typescript-aix-ppc64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", - "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-darwin-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", - "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-darwin-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", - "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-freebsd-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", - "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-freebsd-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", - "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-arm": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", - "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", - "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-loong64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", - "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==", - "cpu": [ - "loong64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-mips64el": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", - "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==", - "cpu": [ - "mips64el" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-ppc64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", - "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-riscv64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", - "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-s390x": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", - "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", - "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-netbsd-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", - "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-netbsd-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", - "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-openbsd-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", - "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-openbsd-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", - "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-sunos-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", - "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-win32-arm64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", - "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-win32-x64": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", - "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "dev": true, - "license": "MIT", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/detect-libc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", - "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", - "dev": true, - "license": "Apache-2.0", - "optional": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/effect": { - "version": "4.0.0-beta.83", - "resolved": "https://registry.npmjs.org/effect/-/effect-4.0.0-beta.83.tgz", - "integrity": "sha512-0wsak8RtgGAr9UWSbVDgJHZcUqMSvicHcvaZv1MbMM7MCGgW4Rn/137J1MHQbwYPcwYGxT/IqehFd+UbYuj78w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@standard-schema/spec": "^1.1.0", - "fast-check": "^4.8.0", - "find-my-way-ts": "^0.1.6", - "ini": "^7.0.0", - "kubernetes-types": "^1.30.0", - "msgpackr": "^2.0.1", - "multipasta": "^0.2.7", - "toml": "^4.1.1", - "uuid": "^14.0.0", - "yaml": "^2.9.0" - } - }, - "node_modules/fast-check": { - "version": "4.11.0", - "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-4.11.0.tgz", - "integrity": "sha512-V4Uc238rhQOdQlc+Gz7JG6SGBtrWnWL8d/6RyiBeCMcNKMhF6DZ0KkAVHJSyNV5r4lA0PmIpZ6iRpTVoz4qjoA==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/dubzzz" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fast-check" - } - ], - "license": "MIT", - "dependencies": { - "pure-rand": "^8.0.0" - }, - "engines": { - "node": ">=12.17.0" - } - }, - "node_modules/find-my-way-ts": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/find-my-way-ts/-/find-my-way-ts-0.1.6.tgz", - "integrity": "sha512-a85L9ZoXtNAey3Y6Z+eBWW658kO/MwR7zIafkIUPUMf3isZG0NCs2pjW2wtjxAKuJPxMAsHUIP4ZPGv0o5gyTA==", - "dev": true, - "license": "MIT" - }, - "node_modules/ini": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/ini/-/ini-7.0.0.tgz", - "integrity": "sha512-ifK0CgjALofS5bkrcTy4RaQ9Vx2Knf/eLeIO+NaswQEpH1UblrtTSCIvN71qQDMq0PeQ/SSPojvEJp9vvvfr+w==", - "dev": true, - "license": "ISC", - "engines": { - "node": "^22.22.2 || ^24.15.0 || >=26.0.0" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true, - "license": "ISC" - }, - "node_modules/json-schema": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", - "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", - "dev": true, - "license": "(AFL-2.1 OR BSD-3-Clause)" - }, - "node_modules/kubernetes-types": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/kubernetes-types/-/kubernetes-types-1.30.0.tgz", - "integrity": "sha512-Dew1okvhM/SQcIa2rcgujNndZwU8VnSapDgdxlYoB84ZlpAD43U6KLAFqYo17ykSFGHNPrg0qry0bP+GJd9v7Q==", - "dev": true, - "license": "Apache-2.0" - }, - "node_modules/msgpackr": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-2.1.4.tgz", - "integrity": "sha512-TvP18sX5U3MXoHHSUZen/FagaNTEJObyb8OlnJcNbqN6Ux/oCwYJrHhCOzi31bItyW/Efz1IDnRDKQ23j4ZuvA==", - "dev": true, - "license": "MIT", - "optionalDependencies": { - "msgpackr-extract": "^3.0.6" - } - }, - "node_modules/msgpackr-extract": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/msgpackr-extract/-/msgpackr-extract-3.0.7.tgz", - "integrity": "sha512-/dOQboWnkR1cjm88XyH/cGSivECGgyQu3814+bNUAq5wACQC8Ya/CViB9WApvWJ5Hya/JJQQmUeBFOZj8MLjGA==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "dependencies": { - "node-gyp-build-optional-packages": "5.2.2" - }, - "bin": { - "download-msgpackr-prebuilds": "bin/download-prebuilds.js" - }, - "optionalDependencies": { - "@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.7", - "@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.7", - "@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.7", - "@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.7", - "@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.7", - "@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.7" - } - }, - "node_modules/multipasta": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/multipasta/-/multipasta-0.2.9.tgz", - "integrity": "sha512-kAovZHgxryqb0xTFz7OTCPxbas8UBTTwCDhfrlaNecp1/z6xcMfp5PVhDxsW7jONHyDF10/ccp30MxA2+66GJw==", - "dev": true, - "license": "MIT" - }, - "node_modules/node-gyp-build-optional-packages": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.2.2.tgz", - "integrity": "sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "detect-libc": "^2.0.1" - }, - "bin": { - "node-gyp-build-optional-packages": "bin.js", - "node-gyp-build-optional-packages-optional": "optional.js", - "node-gyp-build-optional-packages-test": "build-test.js" - } - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/pure-rand": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-8.4.2.tgz", - "integrity": "sha512-vvuOGgcuPJAirlHvuQw1TrOiw7ptaIXXmIbNuiNOY6lNGJJH49PQ1Kj4nd783nPdQhQdicgOjVI2yI/9BD6/Ng==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/dubzzz" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fast-check" - } - ], - "license": "MIT" - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/toml": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/toml/-/toml-4.3.0.tgz", - "integrity": "sha512-lVb8X9BsPVuH0M4BKeS91tXAmJvCjQ5UIyAbQFaxkKGyUFK2RPkhwaFSQH8vbpl1d23eu/IBH+dwVMHWaq9A5A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=20" - } - }, - "node_modules/typescript": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", - "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc" - }, - "engines": { - "node": ">=16.20.0" - }, - "optionalDependencies": { - "@typescript/typescript-aix-ppc64": "7.0.2", - "@typescript/typescript-darwin-arm64": "7.0.2", - "@typescript/typescript-darwin-x64": "7.0.2", - "@typescript/typescript-freebsd-arm64": "7.0.2", - "@typescript/typescript-freebsd-x64": "7.0.2", - "@typescript/typescript-linux-arm": "7.0.2", - "@typescript/typescript-linux-arm64": "7.0.2", - "@typescript/typescript-linux-loong64": "7.0.2", - "@typescript/typescript-linux-mips64el": "7.0.2", - "@typescript/typescript-linux-ppc64": "7.0.2", - "@typescript/typescript-linux-riscv64": "7.0.2", - "@typescript/typescript-linux-s390x": "7.0.2", - "@typescript/typescript-linux-x64": "7.0.2", - "@typescript/typescript-netbsd-arm64": "7.0.2", - "@typescript/typescript-netbsd-x64": "7.0.2", - "@typescript/typescript-openbsd-arm64": "7.0.2", - "@typescript/typescript-openbsd-x64": "7.0.2", - "@typescript/typescript-sunos-x64": "7.0.2", - "@typescript/typescript-win32-arm64": "7.0.2", - "@typescript/typescript-win32-x64": "7.0.2" - } - }, - "node_modules/undici-types": { - "version": "7.24.6", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz", - "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==", - "dev": true, - "license": "MIT" - }, - "node_modules/uuid": { - "version": "14.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.3.tgz", - "integrity": "sha512-Sc5u1VVln93y1Xnz4R+CunOZc7R9LUcTmhj7Rc7Eg3HVcf7rVn2FOoa812fe0W8p3jD7xeoGSYbfqCGGH2B6xw==", - "dev": true, - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "license": "MIT", - "bin": { - "uuid": "dist-node/bin/uuid" - } - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/yaml": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz", - "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", - "dev": true, - "license": "ISC", - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14.6" - }, - "funding": { - "url": "https://github.com/sponsors/eemeli" - } - }, - "node_modules/zod": { - "version": "4.1.8", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.1.8.tgz", - "integrity": "sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - } - } -} diff --git a/pkgs/opencode-plugin/package.json b/pkgs/opencode-plugin/package.json deleted file mode 100644 index 90ce8e57..00000000 --- a/pkgs/opencode-plugin/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "opencode-plugin", - "version": "1.0.0", - "type": "module", - "main": "dist/src/index.js", - "types": "dist/src/index.d.ts", - "exports": { - ".": "./dist/src/index.js", - "./shim": "./dist/shim/claude-hook.js" - }, - "scripts": { - "build": "tsc", - "test": "node --test dist/test/*.test.js" - }, - "devDependencies": { - "@opencode-ai/plugin": "^1.2.6", - "@types/node": "^24.0.0", - "typescript": "^7.0.0" - } -} diff --git a/pkgs/opencode-plugin/shim/claude-hook.ts b/pkgs/opencode-plugin/shim/claude-hook.ts deleted file mode 100644 index f13c0118..00000000 --- a/pkgs/opencode-plugin/shim/claude-hook.ts +++ /dev/null @@ -1,92 +0,0 @@ -import * as fs from "node:fs"; -import * as path from "node:path"; -import { nixHook } from "../src/hooks/nix.js"; -import { jjRedirectHook } from "../src/hooks/jj-redirect.js"; -import { - extractRepoPath, - redundantCwdCheck, -} from "../src/hooks/redundant-cwd.js"; -import type { HookResult } from "../src/types.js"; - -function readStdin(): Promise { - return new Promise((resolve) => { - let data = ""; - process.stdin.on("data", (chunk: Buffer) => (data += chunk.toString())); - process.stdin.on("end", () => resolve(data)); - }); -} - -async function main() { - const stdin = await readStdin(); - const input = JSON.parse(stdin); - - const command: string = input.tool_input.command; - const cwd: string = input.cwd || process.cwd(); - - let currentCommand = command; - - // --- nix hook --- - let nixApprove = false; - const nixResult = nixHook(currentCommand); - if (nixResult.action === "block") { - process.stderr.write(nixResult.reason); - process.exit(2); - } - if (nixResult.action === "modify") { - currentCommand = nixResult.command; - } - if (nixResult.action === "approve") { - nixApprove = true; - } - if (nixResult.action === "approve_modify") { - currentCommand = nixResult.command; - nixApprove = true; - } - - // --- jj-redirect hook --- - const jjDirExists = fs.existsSync(path.join(cwd, ".jj")); - const jjResult = jjRedirectHook(currentCommand, jjDirExists); - if (jjResult.action === "block") { - process.stderr.write(jjResult.reason); - process.exit(2); - } - - // --- redundant-cwd hook --- - const rawPath = extractRepoPath(currentCommand); - if (rawPath !== null) { - try { - const resolvedArgPath = fs.realpathSync( - path.isAbsolute(rawPath) ? rawPath : path.join(cwd, rawPath), - ); - const resolvedCwd = fs.realpathSync(cwd); - const cwdResult = redundantCwdCheck(resolvedArgPath, resolvedCwd); - if (cwdResult.action === "block") { - process.stderr.write(cwdResult.reason); - process.exit(2); - } - } catch { - // If realpath fails (path doesn't exist), skip the check - } - } - - // Output the Claude protocol response if command was modified or needs approval - if (currentCommand !== command || nixApprove) { - const output: Record = { - hookSpecificOutput: { - hookEventName: "PreToolUse", - permissionDecision: nixApprove ? "allow" : "ask", - ...(currentCommand !== command && { - updatedInput: { command: currentCommand }, - }), - }, - }; - process.stdout.write(JSON.stringify(output)); - } - - process.exit(0); -} - -main().catch((err: Error) => { - process.stderr.write(`Hook error: ${err.message}`); - process.exit(1); -}); diff --git a/pkgs/opencode-plugin/src/hooks/jj-redirect.ts b/pkgs/opencode-plugin/src/hooks/jj-redirect.ts deleted file mode 100644 index c2329bf7..00000000 --- a/pkgs/opencode-plugin/src/hooks/jj-redirect.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { HookResult } from "../types.js"; - -export function jjRedirectHook( - command: string, - jjDirExists: boolean, -): HookResult { - // Only act on git commit commands - if (!/(?:^|[;&|])\s*git\s+commit\b/.test(command)) { - return { action: "allow" }; - } - - // Only redirect in jj repos - if (!jjDirExists) { - return { action: "allow" }; - } - - return { - action: "block", - reason: - 'This repository uses Jujutsu (jj), not Git. Use \'jj commit -m "..."\' instead of \'git commit\'. DO NOT use \'jj describe\', it is not a replacement for \'git commit\'. See the jj skill for the full workflow.', - }; -} diff --git a/pkgs/opencode-plugin/src/hooks/nix.ts b/pkgs/opencode-plugin/src/hooks/nix.ts deleted file mode 100644 index a679bfc4..00000000 --- a/pkgs/opencode-plugin/src/hooks/nix.ts +++ /dev/null @@ -1,43 +0,0 @@ -import type { HookResult } from "../types.js"; - -export function nixHook(command: string): HookResult { - const isNixBuild = /(?:^|[;&|])\s*nix\s+build\b/.test(command); - const isNixRun = /(?:^|[;&|])\s*nix\s+run\b/.test(command); - - // Only act on commands containing nix build or nix run - if (!isNixBuild && !isNixRun) { - return { action: "allow" }; - } - - let modified = command; - - // For nix build only: add --no-link and --print-out-paths if missing - if (isNixBuild) { - if (!modified.includes("--no-link")) { - modified = modified.replace(/(nix\s+build)/, "$1 --no-link"); - } - if (!modified.includes("--print-out-paths")) { - modified = modified.replace(/(nix\s+build)/, "$1 --print-out-paths"); - } - } - - // Quote unquoted .# arguments for both nix build and nix run - modified = modified.replace( - /([ \t])([^ \t'"]*\.#[^ \t'"]*)/g, - '$1"$2"', - ); - - // Always approve nix build commands - if (isNixBuild) { - if (modified === command) { - return { action: "approve" }; - } - return { action: "approve_modify", command: modified }; - } - - if (modified === command) { - return { action: "allow" }; - } - - return { action: "modify", command: modified }; -} diff --git a/pkgs/opencode-plugin/src/hooks/redundant-cwd.ts b/pkgs/opencode-plugin/src/hooks/redundant-cwd.ts deleted file mode 100644 index bbe5c273..00000000 --- a/pkgs/opencode-plugin/src/hooks/redundant-cwd.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { HookResult } from "../types.js"; - -/** - * Extract the path argument from git -C or jj -R/--repository flags. - * Returns null if no such flag is present. - */ -export function extractRepoPath(command: string): string | null { - const match = command.match( - /(?:git\s+-C|jj\s+(?:-R|--repository))\s+(\S+)/, - ); - if (!match) return null; - - // Strip surrounding quotes if present - return match[1].replace(/^['"]|['"]$/g, ""); -} - -export function redundantCwdCheck( - resolvedArgPath: string, - resolvedCwd: string, -): HookResult { - if (resolvedArgPath === resolvedCwd) { - return { - action: "block", - reason: - "Redundant -C/-R flag: the path is already the working directory. Run the command without it.", - }; - } - return { action: "allow" }; -} diff --git a/pkgs/opencode-plugin/src/index.ts b/pkgs/opencode-plugin/src/index.ts deleted file mode 100644 index 7cb73737..00000000 --- a/pkgs/opencode-plugin/src/index.ts +++ /dev/null @@ -1,66 +0,0 @@ -import type { Plugin } from "@opencode-ai/plugin"; -import * as fs from "node:fs"; -import * as path from "node:path"; -import { nixHook } from "./hooks/nix.js"; -import { jjRedirectHook } from "./hooks/jj-redirect.js"; -import { extractRepoPath, redundantCwdCheck } from "./hooks/redundant-cwd.js"; - -export type { HookResult } from "./types.js"; - -const plugin: Plugin = async () => { - return { - "tool.execute.before": async (input, output) => { - if (input.tool !== "bash") return; - - const command = output.args.command; - if (typeof command !== "string") return; - const cwd = process.cwd(); - - // --- nix hook --- - const nixResult = nixHook(command); - if (nixResult.action === "block") { - throw new Error(nixResult.reason); - } - if (nixResult.action === "modify") { - output.args.command = nixResult.command; - } - if (nixResult.action === "approve_modify") { - output.args.command = nixResult.command; - } - - // --- redundant-cwd hook --- - const rawPath = extractRepoPath(output.args.command); - if (rawPath !== null) { - try { - const resolvedArgPath = fs.realpathSync( - path.isAbsolute(rawPath) ? rawPath : path.join(cwd, rawPath), - ); - const resolvedCwd = fs.realpathSync(cwd); - const cwdResult = redundantCwdCheck(resolvedArgPath, resolvedCwd); - if (cwdResult.action === "block") { - throw new Error(cwdResult.reason); - } - } catch (e: unknown) { - if ( - e instanceof Error && - "code" in e && - (e as NodeJS.ErrnoException).code === "ENOENT" - ) { - // path doesn't exist, skip the check - } else { - throw e; - } - } - } - - // --- jj-redirect hook --- - const jjDirExists = fs.existsSync(path.join(cwd, ".jj")); - const jjResult = jjRedirectHook(output.args.command, jjDirExists); - if (jjResult.action === "block") { - throw new Error(jjResult.reason); - } - }, - }; -}; - -export default plugin; diff --git a/pkgs/opencode-plugin/src/types.ts b/pkgs/opencode-plugin/src/types.ts deleted file mode 100644 index a78b1d14..00000000 --- a/pkgs/opencode-plugin/src/types.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type HookResult = - | { action: "allow" } - | { action: "modify"; command: string } - | { action: "approve" } - | { action: "approve_modify"; command: string } - | { action: "block"; reason: string }; diff --git a/pkgs/opencode-plugin/test/jj-redirect.test.ts b/pkgs/opencode-plugin/test/jj-redirect.test.ts deleted file mode 100644 index 68802776..00000000 --- a/pkgs/opencode-plugin/test/jj-redirect.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { describe, it } from "node:test"; -import assert from "node:assert/strict"; -import { jjRedirectHook } from "../src/hooks/jj-redirect.js"; - -describe("jjRedirectHook", () => { - it("allows non-git-commit commands", () => { - assert.deepStrictEqual(jjRedirectHook("git status", true), { - action: "allow", - }); - }); - - it("allows git push in jj repos", () => { - assert.deepStrictEqual(jjRedirectHook("git push", true), { - action: "allow", - }); - }); - - it("allows git commit in non-jj repos", () => { - assert.deepStrictEqual(jjRedirectHook('git commit -m "test"', false), { - action: "allow", - }); - }); - - it("blocks git commit in jj repos", () => { - const result = jjRedirectHook('git commit -m "test"', true); - assert.equal(result.action, "block"); - if (result.action === "block") { - assert.ok(result.reason.includes("Jujutsu")); - assert.ok(result.reason.includes("jj commit")); - } - }); - - it("blocks git commit after && in jj repos", () => { - const result = jjRedirectHook( - 'git add . && git commit -m "test"', - true, - ); - assert.equal(result.action, "block"); - }); - - it("blocks git commit after ; in jj repos", () => { - const result = jjRedirectHook( - 'git add .; git commit -m "test"', - true, - ); - assert.equal(result.action, "block"); - }); - - it("allows non-commit git commands in jj repos", () => { - assert.deepStrictEqual(jjRedirectHook("git log --oneline", true), { - action: "allow", - }); - }); -}); diff --git a/pkgs/opencode-plugin/test/nix.test.ts b/pkgs/opencode-plugin/test/nix.test.ts deleted file mode 100644 index 76bf1fe9..00000000 --- a/pkgs/opencode-plugin/test/nix.test.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { describe, it } from "node:test"; -import assert from "node:assert/strict"; -import { nixHook } from "../src/hooks/nix.js"; - -describe("nixHook", () => { - it("allows non-nix commands unchanged", () => { - assert.deepStrictEqual(nixHook("echo hello"), { action: "allow" }); - }); - - it("allows nix commands that are not build or run", () => { - assert.deepStrictEqual(nixHook("nix flake check"), { action: "allow" }); - }); - - it("allows nix fmt", () => { - assert.deepStrictEqual(nixHook("nix fmt"), { action: "allow" }); - }); - - it("adds --no-link and --print-out-paths to nix build", () => { - const result = nixHook("nix build .#foo"); - assert.equal(result.action, "approve_modify"); - if (result.action === "approve_modify") { - assert.ok(result.command.includes("--no-link")); - assert.ok(result.command.includes("--print-out-paths")); - } - }); - - it("does not add --no-link if already present", () => { - const result = nixHook("nix build --no-link .#foo"); - assert.equal(result.action, "approve_modify"); - if (result.action === "approve_modify") { - assert.ok(!result.command.includes("--no-link --no-link")); - assert.ok(result.command.includes("--print-out-paths")); - } - }); - - it("does not add --print-out-paths if already present", () => { - const result = nixHook("nix build --print-out-paths .#foo"); - assert.equal(result.action, "approve_modify"); - if (result.action === "approve_modify") { - assert.ok(result.command.includes("--no-link")); - assert.ok(!result.command.includes("--print-out-paths --print-out-paths")); - } - }); - - it("quotes unquoted .# arguments", () => { - const result = nixHook("nix build --no-link --print-out-paths .#foo"); - assert.equal(result.action, "approve_modify"); - if (result.action === "approve_modify") { - assert.ok(result.command.includes('".#foo"')); - } - }); - - it("does not double-quote already quoted .# arguments", () => { - const result = nixHook( - 'nix build --no-link --print-out-paths ".#foo"', - ); - assert.deepStrictEqual(result, { action: "approve" }); - }); - - it("handles nix run with .# quoting but no flags", () => { - const result = nixHook("nix run .#generate-snapshots"); - assert.equal(result.action, "modify"); - if (result.action === "modify") { - assert.ok(result.command.includes('".#generate-snapshots"')); - assert.ok(!result.command.includes("--no-link")); - assert.ok(!result.command.includes("--print-out-paths")); - } - }); - - it("allows nix run with already quoted .# argument", () => { - const result = nixHook('nix run ".#generate-snapshots"'); - assert.deepStrictEqual(result, { action: "allow" }); - }); - - it("handles compound commands with nix build after &&", () => { - const result = nixHook("echo foo && nix build .#bar"); - assert.equal(result.action, "approve_modify"); - if (result.action === "approve_modify") { - assert.ok(result.command.includes("--no-link")); - assert.ok(result.command.includes('".#bar"')); - } - }); - - it("handles complex flake references", () => { - const result = nixHook( - "nix build --no-link --print-out-paths .#nixosConfigurations.host.config.system.build.toplevel", - ); - assert.equal(result.action, "approve_modify"); - if (result.action === "approve_modify") { - assert.ok( - result.command.includes( - '".#nixosConfigurations.host.config.system.build.toplevel"', - ), - ); - } - }); - - it("handles nix build without .# argument", () => { - const result = nixHook("nix build"); - assert.equal(result.action, "approve_modify"); - if (result.action === "approve_modify") { - assert.ok(result.command.includes("--no-link")); - assert.ok(result.command.includes("--print-out-paths")); - assert.ok(!result.command.includes(".#")); - } - }); - - it("quotes multiple .# arguments in one command", () => { - const result = nixHook("nix build .#foo .#bar"); - assert.equal(result.action, "approve_modify"); - if (result.action === "approve_modify") { - assert.ok(result.command.includes('".#foo"')); - assert.ok(result.command.includes('".#bar"')); - } - }); - - it("handles flake reference with double quotes inside hostname", () => { - const result = nixHook('nix build .#nixosConfigurations."host.domain".config.system.build.toplevel'); - // Should not double-quote, just add flags - assert.equal(result.action, "approve_modify"); - if (result.action === "approve_modify") { - // The existing quotes should remain, and it should add flags - assert.ok(result.command.includes('--no-link')); - } - }); - - it("allows subshell with nix build (not a direct invocation)", () => { - // Subshells like $(nix build ...) don't start with "nix build" pattern - // They start with "$(" so they should be allowed without modification - const result = nixHook("$(nix build .#pkg)"); - assert.equal(result.action, "allow"); - }); - - it("allows command substitution with nix build (not a direct invocation)", () => { - // Command substitution like VAR=$(nix build ...) doesn't match nix build pattern - const result = nixHook("STORE_PATH=$(nix build --no-link --print-out-paths .#pkg)"); - assert.equal(result.action, "allow"); - }); -}); diff --git a/pkgs/opencode-plugin/test/redundant-cwd.test.ts b/pkgs/opencode-plugin/test/redundant-cwd.test.ts deleted file mode 100644 index e7719b2a..00000000 --- a/pkgs/opencode-plugin/test/redundant-cwd.test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { describe, it } from "node:test"; -import assert from "node:assert/strict"; -import { - extractRepoPath, - redundantCwdCheck, -} from "../src/hooks/redundant-cwd.js"; - -describe("extractRepoPath", () => { - it("returns null for commands without -C/-R", () => { - assert.equal(extractRepoPath("git status"), null); - }); - - it("returns null for jj log without -R", () => { - assert.equal(extractRepoPath("jj log"), null); - }); - - it("extracts path from git -C", () => { - assert.equal(extractRepoPath("git -C /foo/bar status"), "/foo/bar"); - }); - - it("extracts path from jj -R", () => { - assert.equal(extractRepoPath("jj -R /foo/bar log"), "/foo/bar"); - }); - - it("extracts path from jj --repository", () => { - assert.equal( - extractRepoPath("jj --repository /foo/bar log"), - "/foo/bar", - ); - }); - - it("strips surrounding double quotes", () => { - assert.equal(extractRepoPath('git -C "/foo/bar" status'), "/foo/bar"); - }); - - it("strips surrounding single quotes", () => { - assert.equal(extractRepoPath("git -C '/foo/bar' status"), "/foo/bar"); - }); - - it("handles relative paths", () => { - assert.equal(extractRepoPath("git -C ../other status"), "../other"); - }); - - it("handles dot path", () => { - assert.equal(extractRepoPath("git -C . status"), "."); - }); -}); - -describe("redundantCwdCheck", () => { - it("allows when paths differ", () => { - assert.deepStrictEqual(redundantCwdCheck("/foo/bar", "/baz/qux"), { - action: "allow", - }); - }); - - it("blocks when paths match", () => { - const result = redundantCwdCheck("/foo/bar", "/foo/bar"); - assert.equal(result.action, "block"); - if (result.action === "block") { - assert.ok(result.reason.includes("Redundant")); - } - }); - - it("allows when paths are similar but different", () => { - assert.deepStrictEqual(redundantCwdCheck("/foo/bar", "/foo/baz"), { - action: "allow", - }); - }); -}); diff --git a/pkgs/opencode-plugin/tsconfig.json b/pkgs/opencode-plugin/tsconfig.json deleted file mode 100644 index 011735f5..00000000 --- a/pkgs/opencode-plugin/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2022", - "module": "Node16", - "moduleResolution": "Node16", - "outDir": "dist", - "rootDir": ".", - "declaration": true, - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "types": ["node"] - }, - "include": ["src/**/*.ts", "test/**/*.ts", "shim/**/*.ts"] -} -- 2.56.1