cc-safety-net 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/bin/cc-safety-net.js +80 -39
- package/dist/bin/doctor/types.d.ts +2 -2
- package/dist/bin/hook/constants.d.ts +2 -2
- package/dist/bin/hook/install/kimi-code.d.ts +3 -0
- package/dist/bin/hook/kimi-code.d.ts +1 -0
- package/dist/bin/integration-metadata.d.ts +9 -9
- package/dist/index.js +42 -1
- package/dist/pi/index.js +42 -1
- package/dist/types.d.ts +2 -2
- package/package.json +2 -2
- package/dist/bin/hook/install/kimi-cli.d.ts +0 -3
- package/dist/bin/hook/kimi-cli.d.ts +0 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](#claude-code-installation)
|
|
8
8
|
[](#github-copilot-cli-installation)
|
|
9
9
|
[](#gemini-cli-installation)
|
|
10
|
-
[](#kimi-code-installation)
|
|
11
11
|
[](#opencode-installation)
|
|
12
12
|
[](#pi-installation)
|
|
13
13
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -31,7 +31,7 @@ A Coding Agent CLI plugin that acts as a safety net, catching destructive git an
|
|
|
31
31
|
- [Claude Code Installation](#claude-code-installation)
|
|
32
32
|
- [Gemini CLI Installation](#gemini-cli-installation)
|
|
33
33
|
- [GitHub Copilot CLI Installation](#github-copilot-cli-installation)
|
|
34
|
-
- [Kimi
|
|
34
|
+
- [Kimi Code Installation](#kimi-code-installation)
|
|
35
35
|
- [OpenCode Installation](#opencode-installation)
|
|
36
36
|
- [Pi Installation](#pi-installation)
|
|
37
37
|
- [Status Line Integration](#status-line-integration)
|
|
@@ -218,12 +218,12 @@ gemini extensions install https://github.com/kenryu42/gemini-safety-net
|
|
|
218
218
|
|
|
219
219
|
---
|
|
220
220
|
|
|
221
|
-
### Kimi
|
|
221
|
+
### Kimi Code Installation
|
|
222
222
|
|
|
223
|
-
Install CC Safety Net into your Kimi
|
|
223
|
+
Install CC Safety Net into your Kimi Code config:
|
|
224
224
|
|
|
225
225
|
```bash
|
|
226
|
-
npx -y cc-safety-net hook install --kimi-
|
|
226
|
+
npx -y cc-safety-net hook install --kimi-code
|
|
227
227
|
```
|
|
228
228
|
|
|
229
229
|
---
|
|
@@ -3,13 +3,54 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
|
|
|
3
3
|
|
|
4
4
|
// node_modules/shell-quote/quote.js
|
|
5
5
|
var require_quote = __commonJS((exports, module) => {
|
|
6
|
+
var OPS = [
|
|
7
|
+
"||",
|
|
8
|
+
"&&",
|
|
9
|
+
";;",
|
|
10
|
+
"|&",
|
|
11
|
+
"<(",
|
|
12
|
+
"<<<",
|
|
13
|
+
">>",
|
|
14
|
+
">&",
|
|
15
|
+
"<&",
|
|
16
|
+
"&",
|
|
17
|
+
";",
|
|
18
|
+
"(",
|
|
19
|
+
")",
|
|
20
|
+
"|",
|
|
21
|
+
"<",
|
|
22
|
+
">"
|
|
23
|
+
];
|
|
24
|
+
var LINE_TERMINATORS = /[\n\r\u2028\u2029]/;
|
|
25
|
+
var GLOB_SHELL_SPECIAL = /[\s#!"$&'():;<=>@\\^`|]/g;
|
|
6
26
|
module.exports = function quote(xs) {
|
|
7
27
|
return xs.map(function(s) {
|
|
8
28
|
if (s === "") {
|
|
9
29
|
return "''";
|
|
10
30
|
}
|
|
11
31
|
if (s && typeof s === "object") {
|
|
12
|
-
|
|
32
|
+
if (s.op === "glob") {
|
|
33
|
+
if (typeof s.pattern !== "string") {
|
|
34
|
+
throw new TypeError("glob token requires a string `pattern`");
|
|
35
|
+
}
|
|
36
|
+
if (LINE_TERMINATORS.test(s.pattern)) {
|
|
37
|
+
throw new TypeError("glob `pattern` must not contain line terminators");
|
|
38
|
+
}
|
|
39
|
+
return s.pattern.replace(GLOB_SHELL_SPECIAL, "\\$&");
|
|
40
|
+
}
|
|
41
|
+
if (typeof s.op === "string") {
|
|
42
|
+
if (OPS.indexOf(s.op) < 0) {
|
|
43
|
+
throw new TypeError("invalid `op` value: " + JSON.stringify(s.op));
|
|
44
|
+
}
|
|
45
|
+
return s.op.replace(/[\s\S]/g, "\\$&");
|
|
46
|
+
}
|
|
47
|
+
if (typeof s.comment === "string") {
|
|
48
|
+
if (LINE_TERMINATORS.test(s.comment)) {
|
|
49
|
+
throw new TypeError("`comment` must not contain line terminators");
|
|
50
|
+
}
|
|
51
|
+
return "#" + s.comment;
|
|
52
|
+
}
|
|
53
|
+
throw new TypeError("unrecognized object token shape");
|
|
13
54
|
}
|
|
14
55
|
if (/["\s\\]/.test(s) && !/'/.test(s)) {
|
|
15
56
|
return "'" + s.replace(/(['])/g, "\\$1") + "'";
|
|
@@ -6387,8 +6428,8 @@ var CLAUDE_CODE_HOOK_EVENT = "PreToolUse";
|
|
|
6387
6428
|
var CLAUDE_CODE_TOOL_NAME = "Bash";
|
|
6388
6429
|
var GEMINI_CLI_HOOK_EVENT = "BeforeTool";
|
|
6389
6430
|
var GEMINI_CLI_TOOL_NAME = "run_shell_command";
|
|
6390
|
-
var
|
|
6391
|
-
var
|
|
6431
|
+
var KIMI_CODE_HOOK_EVENT = "PreToolUse";
|
|
6432
|
+
var KIMI_CODE_TOOL_NAME = "Shell";
|
|
6392
6433
|
|
|
6393
6434
|
// src/bin/hook/claude-code.ts
|
|
6394
6435
|
async function runClaudeCodeHook() {
|
|
@@ -6437,8 +6478,8 @@ async function runGeminiCLIHook() {
|
|
|
6437
6478
|
});
|
|
6438
6479
|
}
|
|
6439
6480
|
|
|
6440
|
-
// src/bin/hook/kimi-
|
|
6441
|
-
async function
|
|
6481
|
+
// src/bin/hook/kimi-code.ts
|
|
6482
|
+
async function runKimiCodeHook() {
|
|
6442
6483
|
await runConfiguredHookAdapter({
|
|
6443
6484
|
createDenyOutput: (message) => ({
|
|
6444
6485
|
hookSpecificOutput: {
|
|
@@ -6447,7 +6488,7 @@ async function runKimiCliHook() {
|
|
|
6447
6488
|
permissionDecisionReason: message
|
|
6448
6489
|
}
|
|
6449
6490
|
}),
|
|
6450
|
-
isSupported: (input) => input.hook_event_name ===
|
|
6491
|
+
isSupported: (input) => input.hook_event_name === KIMI_CODE_HOOK_EVENT && input.tool_name === KIMI_CODE_TOOL_NAME,
|
|
6451
6492
|
getCommand: (input) => input.tool_input?.command,
|
|
6452
6493
|
getCwd: (input) => input.cwd,
|
|
6453
6494
|
getSessionId: (input) => input.session_id
|
|
@@ -6495,12 +6536,12 @@ var integrationMetadata = [
|
|
|
6495
6536
|
}
|
|
6496
6537
|
},
|
|
6497
6538
|
{
|
|
6498
|
-
id: "kimi-
|
|
6499
|
-
displayName: "Kimi
|
|
6539
|
+
id: "kimi-code",
|
|
6540
|
+
displayName: "Kimi Code",
|
|
6500
6541
|
doctorVisible: true,
|
|
6501
6542
|
runtimeHook: {
|
|
6502
|
-
flags: ["-kc", "--kimi-
|
|
6503
|
-
description: "Run as Kimi
|
|
6543
|
+
flags: ["-kc", "--kimi-code"],
|
|
6544
|
+
description: "Run as Kimi Code PreToolUse hook",
|
|
6504
6545
|
legacyTopLevel: false,
|
|
6505
6546
|
order: 4
|
|
6506
6547
|
}
|
|
@@ -6533,7 +6574,7 @@ var hookRunners = {
|
|
|
6533
6574
|
"claude-code": runClaudeCodeHook,
|
|
6534
6575
|
"copilot-cli": runCopilotCliHook,
|
|
6535
6576
|
"gemini-cli": runGeminiCLIHook,
|
|
6536
|
-
"kimi-
|
|
6577
|
+
"kimi-code": runKimiCodeHook
|
|
6537
6578
|
};
|
|
6538
6579
|
var hookIntegrations = runtimeHookIntegrationMetadata.map((integration) => ({
|
|
6539
6580
|
...integration,
|
|
@@ -6557,8 +6598,8 @@ var hookCommand = {
|
|
|
6557
6598
|
description: "Run as an agent CLI hook (reads JSON from stdin)",
|
|
6558
6599
|
usage: "hook <coding cli>",
|
|
6559
6600
|
subcommands: [
|
|
6560
|
-
{ usage: "install --kimi-
|
|
6561
|
-
{ usage: "uninstall --kimi-
|
|
6601
|
+
{ usage: "install --kimi-code", description: "Install Kimi Code hook config" },
|
|
6602
|
+
{ usage: "uninstall --kimi-code", description: "Uninstall Kimi Code hook config" }
|
|
6562
6603
|
],
|
|
6563
6604
|
options: [
|
|
6564
6605
|
...platformOptions,
|
|
@@ -6567,7 +6608,7 @@ var hookCommand = {
|
|
|
6567
6608
|
description: "Show this help"
|
|
6568
6609
|
}
|
|
6569
6610
|
],
|
|
6570
|
-
examples: [...platformExamples, "cc-safety-net hook install --kimi-
|
|
6611
|
+
examples: [...platformExamples, "cc-safety-net hook install --kimi-code"]
|
|
6571
6612
|
};
|
|
6572
6613
|
|
|
6573
6614
|
// src/bin/commands/rule.ts
|
|
@@ -7216,7 +7257,7 @@ function formatSystemInfoTable(system) {
|
|
|
7216
7257
|
{ label: "Codex", value: system.codexCliVersion },
|
|
7217
7258
|
{ label: "Copilot CLI", value: system.copilotCliVersion },
|
|
7218
7259
|
{ label: "Gemini CLI", value: system.geminiCliVersion },
|
|
7219
|
-
{ label: "Kimi
|
|
7260
|
+
{ label: "Kimi Code", value: system.kimiCodeVersion },
|
|
7220
7261
|
{ label: "OpenCode", value: system.openCodeVersion },
|
|
7221
7262
|
{ label: "Pi", value: system.piCliVersion },
|
|
7222
7263
|
{ label: "Node.js", value: system.nodeVersion },
|
|
@@ -7260,7 +7301,7 @@ var CLAUDE_PLUGIN_LIST_CONFIG_PATH = "claude plugin list";
|
|
|
7260
7301
|
var CLAUDE_SAFETY_NET_PLUGIN_ID = "safety-net@cc-marketplace";
|
|
7261
7302
|
var GEMINI_EXTENSIONS_LIST_CONFIG_PATH = "gemini extensions list";
|
|
7262
7303
|
var GEMINI_SAFETY_NET_SOURCE = "https://github.com/kenryu42/gemini-safety-net";
|
|
7263
|
-
var KIMI_HOOK_COMMAND_PATTERN = /cc-safety-net\s+hook\s+(?:[^\s]+\s+)*--kimi-
|
|
7304
|
+
var KIMI_HOOK_COMMAND_PATTERN = /cc-safety-net\s+hook\s+(?:[^\s]+\s+)*--kimi-code(\s|["']|$)/;
|
|
7264
7305
|
var CODEX_PLUGIN_HOOKS_WARNING = "Codex plugin hooks are behind a feature flag. Add `plugin_hooks = true` under [features] in $CODEX_HOME/config.toml.";
|
|
7265
7306
|
var CODEX_SAFETY_NET_PLUGIN_ID = "safety-net@cc-marketplace";
|
|
7266
7307
|
var SELF_TEST_CASES = [
|
|
@@ -7492,25 +7533,25 @@ function detectGeminiCLI(extensionsListOutput) {
|
|
|
7492
7533
|
function _getKimiConfigPath(homeDir) {
|
|
7493
7534
|
return join10(process.env.KIMI_SHARE_DIR || join10(homeDir, ".kimi"), "config.toml");
|
|
7494
7535
|
}
|
|
7495
|
-
function
|
|
7536
|
+
function detectKimiCode(homeDir) {
|
|
7496
7537
|
const configPath = _getKimiConfigPath(homeDir);
|
|
7497
7538
|
if (!existsSync13(configPath)) {
|
|
7498
|
-
return { platform: "kimi-
|
|
7539
|
+
return { platform: "kimi-code", status: "n/a", configPath };
|
|
7499
7540
|
}
|
|
7500
7541
|
try {
|
|
7501
7542
|
if (!KIMI_HOOK_COMMAND_PATTERN.test(readFileSync10(configPath, "utf-8"))) {
|
|
7502
|
-
return { platform: "kimi-
|
|
7543
|
+
return { platform: "kimi-code", status: "n/a", configPath };
|
|
7503
7544
|
}
|
|
7504
7545
|
} catch (e) {
|
|
7505
7546
|
return {
|
|
7506
|
-
platform: "kimi-
|
|
7547
|
+
platform: "kimi-code",
|
|
7507
7548
|
status: "n/a",
|
|
7508
7549
|
configPath,
|
|
7509
7550
|
errors: [`Failed to read ${configPath}: ${e instanceof Error ? e.message : String(e)}`]
|
|
7510
7551
|
};
|
|
7511
7552
|
}
|
|
7512
7553
|
return {
|
|
7513
|
-
platform: "kimi-
|
|
7554
|
+
platform: "kimi-code",
|
|
7514
7555
|
status: "configured",
|
|
7515
7556
|
method: "hook config",
|
|
7516
7557
|
configPath,
|
|
@@ -7869,8 +7910,8 @@ function detectAllHooks(cwd, options2) {
|
|
|
7869
7910
|
return detectGeminiCLI(options2?.geminiExtensionsListOutput);
|
|
7870
7911
|
case "copilot-cli":
|
|
7871
7912
|
return detectCopilotCLI();
|
|
7872
|
-
case "kimi-
|
|
7873
|
-
return
|
|
7913
|
+
case "kimi-code":
|
|
7914
|
+
return detectKimiCode(homeDir);
|
|
7874
7915
|
case "pi":
|
|
7875
7916
|
return detectPi(options2?.piSafetyNetProbe);
|
|
7876
7917
|
case "codex":
|
|
@@ -7886,7 +7927,7 @@ import { existsSync as existsSync14 } from "node:fs";
|
|
|
7886
7927
|
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
7887
7928
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
7888
7929
|
import { delimiter, extname, join as join11 } from "node:path";
|
|
7889
|
-
var CURRENT_VERSION = "1.0.
|
|
7930
|
+
var CURRENT_VERSION = "1.0.3";
|
|
7890
7931
|
var VERSION_FETCH_TIMEOUT_MS = 2000;
|
|
7891
7932
|
var PI_PROBE_TIMEOUT_MS = 5000;
|
|
7892
7933
|
var PI_SENTINEL_COMMAND = "cc-safety-net";
|
|
@@ -8249,7 +8290,7 @@ async function getSystemInfo(fetcher = defaultVersionFetcher, options2 = {}) {
|
|
|
8249
8290
|
geminiCliVersion: parseVersion(geminiRaw),
|
|
8250
8291
|
geminiExtensionsListOutput,
|
|
8251
8292
|
copilotCliVersion: parseVersion(copilotRaw),
|
|
8252
|
-
|
|
8293
|
+
kimiCodeVersion: parseVersion(kimiRaw),
|
|
8253
8294
|
piCliVersion: parseVersion(piRaw),
|
|
8254
8295
|
nodeVersion: parseVersion(nodeRaw),
|
|
8255
8296
|
npmVersion: parseVersion(npmRaw),
|
|
@@ -9395,7 +9436,7 @@ function formatTraceJson(result) {
|
|
|
9395
9436
|
return JSON.stringify(result, null, 2);
|
|
9396
9437
|
}
|
|
9397
9438
|
// src/bin/help.ts
|
|
9398
|
-
var version = "1.0.
|
|
9439
|
+
var version = "1.0.3";
|
|
9399
9440
|
var INDENT = " ";
|
|
9400
9441
|
var PROGRAM_NAME = "cc-safety-net";
|
|
9401
9442
|
function formatOptionFlags(option) {
|
|
@@ -9502,7 +9543,7 @@ function showCommandHelp(commandName) {
|
|
|
9502
9543
|
// src/bin/hook/install.ts
|
|
9503
9544
|
import { homedir as homedir6 } from "node:os";
|
|
9504
9545
|
|
|
9505
|
-
// src/bin/hook/install/kimi-
|
|
9546
|
+
// src/bin/hook/install/kimi-code.ts
|
|
9506
9547
|
import { existsSync as existsSync16, mkdirSync as mkdirSync4, readFileSync as readFileSync11, writeFileSync as writeFileSync3 } from "node:fs";
|
|
9507
9548
|
import { dirname as dirname9, join as join12 } from "node:path";
|
|
9508
9549
|
|
|
@@ -9590,8 +9631,8 @@ function removeArrayRangeItem(content, item) {
|
|
|
9590
9631
|
return `${content.slice(0, removeStart)}${content.slice(removeEnd)}`;
|
|
9591
9632
|
}
|
|
9592
9633
|
|
|
9593
|
-
// src/bin/hook/install/kimi-
|
|
9594
|
-
var KIMI_HOOK_COMMAND = "npx -y cc-safety-net hook --kimi-
|
|
9634
|
+
// src/bin/hook/install/kimi-code.ts
|
|
9635
|
+
var KIMI_HOOK_COMMAND = "npx -y cc-safety-net hook --kimi-code";
|
|
9595
9636
|
var KIMI_HOOK_BLOCK = `[[hooks]]
|
|
9596
9637
|
event = "PreToolUse"
|
|
9597
9638
|
matcher = "Shell"
|
|
@@ -9626,8 +9667,8 @@ function skipTomlComment(content, index) {
|
|
|
9626
9667
|
function findTomlArrayClose(content, openIndex) {
|
|
9627
9668
|
return findMatchingBracket(content, openIndex, {
|
|
9628
9669
|
skipComment: skipTomlComment,
|
|
9629
|
-
stringError: "Unterminated string in Kimi
|
|
9630
|
-
bracketError: "Unmatched hooks array in Kimi
|
|
9670
|
+
stringError: "Unterminated string in Kimi Code config",
|
|
9671
|
+
bracketError: "Unmatched hooks array in Kimi Code config"
|
|
9631
9672
|
});
|
|
9632
9673
|
}
|
|
9633
9674
|
function findTopLevelInlineHooksArray(content) {
|
|
@@ -9686,7 +9727,7 @@ function removeKimiInlineHook(content, hooksRange) {
|
|
|
9686
9727
|
end: itemStart + KIMI_INLINE_HOOK.length
|
|
9687
9728
|
});
|
|
9688
9729
|
}
|
|
9689
|
-
function
|
|
9730
|
+
function installKimiCode(homeDir) {
|
|
9690
9731
|
const configPath = getKimiConfigPath(homeDir);
|
|
9691
9732
|
mkdirSync4(dirname9(configPath), { recursive: true });
|
|
9692
9733
|
if (!existsSync16(configPath)) {
|
|
@@ -9700,7 +9741,7 @@ function installKimiCli(homeDir) {
|
|
|
9700
9741
|
writeFileSync3(configPath, appendKimiHook(content));
|
|
9701
9742
|
return { path: configPath, alreadyInstalled: false };
|
|
9702
9743
|
}
|
|
9703
|
-
function
|
|
9744
|
+
function uninstallKimiCode(homeDir) {
|
|
9704
9745
|
const configPath = getKimiConfigPath(homeDir);
|
|
9705
9746
|
if (!existsSync16(configPath))
|
|
9706
9747
|
return { path: configPath, alreadyInstalled: false };
|
|
@@ -9719,21 +9760,21 @@ function getHomeDir() {
|
|
|
9719
9760
|
return process.env.HOME ?? homedir6();
|
|
9720
9761
|
}
|
|
9721
9762
|
function parseInstallTarget(args, action) {
|
|
9722
|
-
const unknownOption = args.find((arg) => arg.startsWith("-") && !["--kimi-
|
|
9763
|
+
const unknownOption = args.find((arg) => arg.startsWith("-") && !["--kimi-code"].includes(arg));
|
|
9723
9764
|
if (unknownOption)
|
|
9724
9765
|
throw new Error(`Unknown install option: ${unknownOption}`);
|
|
9725
9766
|
const unexpectedArg = args.find((arg) => !arg.startsWith("-"));
|
|
9726
9767
|
if (unexpectedArg)
|
|
9727
9768
|
throw new Error(`Unexpected argument for hook ${action}: ${unexpectedArg}`);
|
|
9728
|
-
if (!args.includes("--kimi-
|
|
9729
|
-
throw new Error("Choose exactly one install target: --kimi-
|
|
9769
|
+
if (!args.includes("--kimi-code"))
|
|
9770
|
+
throw new Error("Choose exactly one install target: --kimi-code");
|
|
9730
9771
|
}
|
|
9731
9772
|
function runHookInstallCommand(action, args) {
|
|
9732
9773
|
try {
|
|
9733
9774
|
parseInstallTarget(args, action);
|
|
9734
9775
|
const homeDir = getHomeDir();
|
|
9735
|
-
const result = action === "install" ?
|
|
9736
|
-
const name = "Kimi
|
|
9776
|
+
const result = action === "install" ? installKimiCode(homeDir) : uninstallKimiCode(homeDir);
|
|
9777
|
+
const name = "Kimi Code";
|
|
9737
9778
|
const pastTense = action === "install" ? "Installed" : "Uninstalled";
|
|
9738
9779
|
console.log(action === "install" && result.alreadyInstalled ? `${name} hook already installed in ${result.path}` : action === "uninstall" && !result.alreadyInstalled ? `${name} hook not installed in ${result.path}` : `${pastTense} ${name} hook ${action === "install" ? "in" : "from"} ${result.path}`);
|
|
9739
9780
|
return 0;
|
|
@@ -10751,7 +10792,7 @@ var commandParsers = {
|
|
|
10751
10792
|
const integration = findHookIntegrationByFlag(args);
|
|
10752
10793
|
if (integration)
|
|
10753
10794
|
return { mode: "hook", integration };
|
|
10754
|
-
console.error("hook requires a subcommand or integration flag. Try: cc-safety-net hook install --kimi-
|
|
10795
|
+
console.error("hook requires a subcommand or integration flag. Try: cc-safety-net hook install --kimi-code");
|
|
10755
10796
|
showCommandHelp("hook");
|
|
10756
10797
|
process.exit(1);
|
|
10757
10798
|
},
|
|
@@ -122,8 +122,8 @@ export interface SystemInfo {
|
|
|
122
122
|
geminiExtensionsListOutput: string | null;
|
|
123
123
|
/** Copilot CLI version (from `copilot --binary-version`, falling back to `copilot --version`) */
|
|
124
124
|
copilotCliVersion: string | null;
|
|
125
|
-
/** Kimi
|
|
126
|
-
|
|
125
|
+
/** Kimi Code version (from `kimi --version`) */
|
|
126
|
+
kimiCodeVersion: string | null;
|
|
127
127
|
/** Pi CLI version (from `pi --version`) */
|
|
128
128
|
piCliVersion: string | null;
|
|
129
129
|
/** Node.js version (from `node --version`) */
|
|
@@ -2,5 +2,5 @@ export declare const CLAUDE_CODE_HOOK_EVENT = "PreToolUse";
|
|
|
2
2
|
export declare const CLAUDE_CODE_TOOL_NAME = "Bash";
|
|
3
3
|
export declare const GEMINI_CLI_HOOK_EVENT = "BeforeTool";
|
|
4
4
|
export declare const GEMINI_CLI_TOOL_NAME = "run_shell_command";
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const KIMI_CODE_HOOK_EVENT = "PreToolUse";
|
|
6
|
+
export declare const KIMI_CODE_TOOL_NAME = "Shell";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runKimiCodeHook(): Promise<void>;
|
|
@@ -33,12 +33,12 @@ declare const integrationMetadata: readonly [{
|
|
|
33
33
|
readonly order: 3;
|
|
34
34
|
};
|
|
35
35
|
}, {
|
|
36
|
-
readonly id: "kimi-
|
|
37
|
-
readonly displayName: "Kimi
|
|
36
|
+
readonly id: "kimi-code";
|
|
37
|
+
readonly displayName: "Kimi Code";
|
|
38
38
|
readonly doctorVisible: true;
|
|
39
39
|
readonly runtimeHook: {
|
|
40
|
-
readonly flags: readonly ["-kc", "--kimi-
|
|
41
|
-
readonly description: "Run as Kimi
|
|
40
|
+
readonly flags: readonly ["-kc", "--kimi-code"];
|
|
41
|
+
readonly description: "Run as Kimi Code PreToolUse hook";
|
|
42
42
|
readonly legacyTopLevel: false;
|
|
43
43
|
readonly order: 4;
|
|
44
44
|
};
|
|
@@ -56,12 +56,12 @@ type RuntimeHookIntegrationMetadata = Extract<(typeof integrationMetadata)[numbe
|
|
|
56
56
|
runtimeHook: object;
|
|
57
57
|
}>;
|
|
58
58
|
export type RuntimeHookIntegrationId = RuntimeHookIntegrationMetadata['id'];
|
|
59
|
-
export declare const doctorIntegrationOrder: ("claude-code" | "codex" | "copilot-cli" | "gemini-cli" | "kimi-
|
|
59
|
+
export declare const doctorIntegrationOrder: ("claude-code" | "codex" | "copilot-cli" | "gemini-cli" | "kimi-code" | "opencode" | "pi")[];
|
|
60
60
|
export declare const runtimeHookIntegrationMetadata: {
|
|
61
|
-
id: "claude-code" | "copilot-cli" | "gemini-cli" | "kimi-
|
|
62
|
-
displayName: "Claude Code" | "Copilot CLI" | "Gemini CLI" | "Kimi
|
|
63
|
-
flags: readonly ["-cc", "--claude-code"] | readonly ["-cp", "--copilot-cli"] | readonly ["-gc", "--gemini-cli"] | readonly ["-kc", "--kimi-
|
|
64
|
-
description: "Run as Claude Code PreToolUse hook" | "Run as Copilot CLI PreToolUse hook" | "Run as Gemini CLI BeforeTool hook" | "Run as Kimi
|
|
61
|
+
id: "claude-code" | "copilot-cli" | "gemini-cli" | "kimi-code";
|
|
62
|
+
displayName: "Claude Code" | "Copilot CLI" | "Gemini CLI" | "Kimi Code";
|
|
63
|
+
flags: readonly ["-cc", "--claude-code"] | readonly ["-cp", "--copilot-cli"] | readonly ["-gc", "--gemini-cli"] | readonly ["-kc", "--kimi-code"];
|
|
64
|
+
description: "Run as Claude Code PreToolUse hook" | "Run as Copilot CLI PreToolUse hook" | "Run as Gemini CLI BeforeTool hook" | "Run as Kimi Code PreToolUse hook";
|
|
65
65
|
legacyTopLevel: boolean;
|
|
66
66
|
}[];
|
|
67
67
|
export declare function getIntegrationDisplayName(id: IntegrationId): string;
|
package/dist/index.js
CHANGED
|
@@ -2,13 +2,54 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
|
|
|
2
2
|
|
|
3
3
|
// node_modules/shell-quote/quote.js
|
|
4
4
|
var require_quote = __commonJS((exports, module) => {
|
|
5
|
+
var OPS = [
|
|
6
|
+
"||",
|
|
7
|
+
"&&",
|
|
8
|
+
";;",
|
|
9
|
+
"|&",
|
|
10
|
+
"<(",
|
|
11
|
+
"<<<",
|
|
12
|
+
">>",
|
|
13
|
+
">&",
|
|
14
|
+
"<&",
|
|
15
|
+
"&",
|
|
16
|
+
";",
|
|
17
|
+
"(",
|
|
18
|
+
")",
|
|
19
|
+
"|",
|
|
20
|
+
"<",
|
|
21
|
+
">"
|
|
22
|
+
];
|
|
23
|
+
var LINE_TERMINATORS = /[\n\r\u2028\u2029]/;
|
|
24
|
+
var GLOB_SHELL_SPECIAL = /[\s#!"$&'():;<=>@\\^`|]/g;
|
|
5
25
|
module.exports = function quote(xs) {
|
|
6
26
|
return xs.map(function(s) {
|
|
7
27
|
if (s === "") {
|
|
8
28
|
return "''";
|
|
9
29
|
}
|
|
10
30
|
if (s && typeof s === "object") {
|
|
11
|
-
|
|
31
|
+
if (s.op === "glob") {
|
|
32
|
+
if (typeof s.pattern !== "string") {
|
|
33
|
+
throw new TypeError("glob token requires a string `pattern`");
|
|
34
|
+
}
|
|
35
|
+
if (LINE_TERMINATORS.test(s.pattern)) {
|
|
36
|
+
throw new TypeError("glob `pattern` must not contain line terminators");
|
|
37
|
+
}
|
|
38
|
+
return s.pattern.replace(GLOB_SHELL_SPECIAL, "\\$&");
|
|
39
|
+
}
|
|
40
|
+
if (typeof s.op === "string") {
|
|
41
|
+
if (OPS.indexOf(s.op) < 0) {
|
|
42
|
+
throw new TypeError("invalid `op` value: " + JSON.stringify(s.op));
|
|
43
|
+
}
|
|
44
|
+
return s.op.replace(/[\s\S]/g, "\\$&");
|
|
45
|
+
}
|
|
46
|
+
if (typeof s.comment === "string") {
|
|
47
|
+
if (LINE_TERMINATORS.test(s.comment)) {
|
|
48
|
+
throw new TypeError("`comment` must not contain line terminators");
|
|
49
|
+
}
|
|
50
|
+
return "#" + s.comment;
|
|
51
|
+
}
|
|
52
|
+
throw new TypeError("unrecognized object token shape");
|
|
12
53
|
}
|
|
13
54
|
if (/["\s\\]/.test(s) && !/'/.test(s)) {
|
|
14
55
|
return "'" + s.replace(/(['])/g, "\\$1") + "'";
|
package/dist/pi/index.js
CHANGED
|
@@ -2,13 +2,54 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
|
|
|
2
2
|
|
|
3
3
|
// node_modules/shell-quote/quote.js
|
|
4
4
|
var require_quote = __commonJS((exports, module) => {
|
|
5
|
+
var OPS = [
|
|
6
|
+
"||",
|
|
7
|
+
"&&",
|
|
8
|
+
";;",
|
|
9
|
+
"|&",
|
|
10
|
+
"<(",
|
|
11
|
+
"<<<",
|
|
12
|
+
">>",
|
|
13
|
+
">&",
|
|
14
|
+
"<&",
|
|
15
|
+
"&",
|
|
16
|
+
";",
|
|
17
|
+
"(",
|
|
18
|
+
")",
|
|
19
|
+
"|",
|
|
20
|
+
"<",
|
|
21
|
+
">"
|
|
22
|
+
];
|
|
23
|
+
var LINE_TERMINATORS = /[\n\r\u2028\u2029]/;
|
|
24
|
+
var GLOB_SHELL_SPECIAL = /[\s#!"$&'():;<=>@\\^`|]/g;
|
|
5
25
|
module.exports = function quote(xs) {
|
|
6
26
|
return xs.map(function(s) {
|
|
7
27
|
if (s === "") {
|
|
8
28
|
return "''";
|
|
9
29
|
}
|
|
10
30
|
if (s && typeof s === "object") {
|
|
11
|
-
|
|
31
|
+
if (s.op === "glob") {
|
|
32
|
+
if (typeof s.pattern !== "string") {
|
|
33
|
+
throw new TypeError("glob token requires a string `pattern`");
|
|
34
|
+
}
|
|
35
|
+
if (LINE_TERMINATORS.test(s.pattern)) {
|
|
36
|
+
throw new TypeError("glob `pattern` must not contain line terminators");
|
|
37
|
+
}
|
|
38
|
+
return s.pattern.replace(GLOB_SHELL_SPECIAL, "\\$&");
|
|
39
|
+
}
|
|
40
|
+
if (typeof s.op === "string") {
|
|
41
|
+
if (OPS.indexOf(s.op) < 0) {
|
|
42
|
+
throw new TypeError("invalid `op` value: " + JSON.stringify(s.op));
|
|
43
|
+
}
|
|
44
|
+
return s.op.replace(/[\s\S]/g, "\\$&");
|
|
45
|
+
}
|
|
46
|
+
if (typeof s.comment === "string") {
|
|
47
|
+
if (LINE_TERMINATORS.test(s.comment)) {
|
|
48
|
+
throw new TypeError("`comment` must not contain line terminators");
|
|
49
|
+
}
|
|
50
|
+
return "#" + s.comment;
|
|
51
|
+
}
|
|
52
|
+
throw new TypeError("unrecognized object token shape");
|
|
12
53
|
}
|
|
13
54
|
if (/["\s\\]/.test(s) && !/'/.test(s)) {
|
|
14
55
|
return "'" + s.replace(/(['])/g, "\\$1") + "'";
|
package/dist/types.d.ts
CHANGED
|
@@ -83,8 +83,8 @@ export interface GeminiHookOutput {
|
|
|
83
83
|
stopReason?: string;
|
|
84
84
|
suppressOutput?: boolean;
|
|
85
85
|
}
|
|
86
|
-
/** Kimi
|
|
87
|
-
export interface
|
|
86
|
+
/** Kimi Code hook input format */
|
|
87
|
+
export interface KimiCodeHookInput {
|
|
88
88
|
session_id?: string;
|
|
89
89
|
cwd?: string;
|
|
90
90
|
hook_event_name: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-safety-net",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A coding agent CLI hook - block destructive git and filesystem commands before execution",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"shell-quote": "^1.8.
|
|
67
|
+
"shell-quote": "^1.8.4"
|
|
68
68
|
},
|
|
69
69
|
"trustedDependencies": [
|
|
70
70
|
"@ast-grep/cli"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function runKimiCliHook(): Promise<void>;
|