cc-safety-net 1.0.4 → 1.0.6
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 +2 -0
- package/dist/bin/cc-safety-net.js +23 -9
- package/dist/bin/hook/constants.d.ts +1 -1
- package/dist/index.js +16 -2
- package/dist/pi/index.js +16 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -226,6 +226,8 @@ Install CC Safety Net into your Kimi Code config:
|
|
|
226
226
|
npx -y cc-safety-net hook install --kimi-code
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
+
Optional: run `npx skill add kenryu42/cc-safety-net` to add the `/cc-safety-net` skill for configuring custom rules.
|
|
230
|
+
|
|
229
231
|
---
|
|
230
232
|
|
|
231
233
|
|
|
@@ -5126,7 +5126,7 @@ function writeJsonAtomic(path, value) {
|
|
|
5126
5126
|
}
|
|
5127
5127
|
|
|
5128
5128
|
// src/core/rules/policy/scope-policy.ts
|
|
5129
|
-
import { existsSync as existsSync7, readFileSync as readFileSync6 } from "node:fs";
|
|
5129
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6, realpathSync as realpathSync7 } from "node:fs";
|
|
5130
5130
|
import { dirname as dirname6, isAbsolute as isAbsolute6, join as join6, relative, resolve as resolve5, sep as sep4 } from "node:path";
|
|
5131
5131
|
|
|
5132
5132
|
// src/core/rules/rulebook.ts
|
|
@@ -5552,8 +5552,9 @@ function sha256Digest(content) {
|
|
|
5552
5552
|
// src/core/rules/policy/scope-policy.ts
|
|
5553
5553
|
function loadRulesPolicy(options2 = {}) {
|
|
5554
5554
|
const paths = getPolicyPaths(options2);
|
|
5555
|
+
const sameConfigPath = isSameConfigPath(paths.userConfigPath, paths.projectConfigPath);
|
|
5555
5556
|
const user = readRulesConfig(paths.userConfigPath);
|
|
5556
|
-
const project = readRulesConfig(paths.projectConfigPath);
|
|
5557
|
+
const project = sameConfigPath ? { config: null, errors: [] } : readRulesConfig(paths.projectConfigPath);
|
|
5557
5558
|
const errors = [
|
|
5558
5559
|
...getLegacyRulesConfigErrors(paths, options2),
|
|
5559
5560
|
...user.errors.map((error) => `${paths.userConfigPath}: ${error}`),
|
|
@@ -5724,6 +5725,19 @@ function rulesPolicyToConfig(policy) {
|
|
|
5724
5725
|
}
|
|
5725
5726
|
return { version: 1, rules: policy.rules };
|
|
5726
5727
|
}
|
|
5728
|
+
function isSameConfigPath(userConfigPath, projectConfigPath) {
|
|
5729
|
+
if (resolve5(userConfigPath) === resolve5(projectConfigPath)) {
|
|
5730
|
+
return true;
|
|
5731
|
+
}
|
|
5732
|
+
if (!existsSync7(userConfigPath) || !existsSync7(projectConfigPath)) {
|
|
5733
|
+
return false;
|
|
5734
|
+
}
|
|
5735
|
+
try {
|
|
5736
|
+
return realpathSync7(userConfigPath) === realpathSync7(projectConfigPath);
|
|
5737
|
+
} catch {
|
|
5738
|
+
return false;
|
|
5739
|
+
}
|
|
5740
|
+
}
|
|
5727
5741
|
function getLegacyRulesConfigErrors(paths, options2) {
|
|
5728
5742
|
return Array.from(new Set([
|
|
5729
5743
|
...getLegacyRulesConfigError(getLegacyUserRulesConfigPath(options2), paths.userConfigPath, "~/.cc-safety-net/config.json"),
|
|
@@ -6429,7 +6443,7 @@ var CLAUDE_CODE_TOOL_NAME = "Bash";
|
|
|
6429
6443
|
var GEMINI_CLI_HOOK_EVENT = "BeforeTool";
|
|
6430
6444
|
var GEMINI_CLI_TOOL_NAME = "run_shell_command";
|
|
6431
6445
|
var KIMI_CODE_HOOK_EVENT = "PreToolUse";
|
|
6432
|
-
var KIMI_CODE_TOOL_NAME = "
|
|
6446
|
+
var KIMI_CODE_TOOL_NAME = "Bash";
|
|
6433
6447
|
|
|
6434
6448
|
// src/bin/hook/claude-code.ts
|
|
6435
6449
|
async function runClaudeCodeHook() {
|
|
@@ -7531,7 +7545,7 @@ function detectGeminiCLI(extensionsListOutput) {
|
|
|
7531
7545
|
};
|
|
7532
7546
|
}
|
|
7533
7547
|
function _getKimiConfigPath(homeDir) {
|
|
7534
|
-
return join10(process.env.
|
|
7548
|
+
return join10(process.env.KIMI_CODE_HOME || join10(homeDir, ".kimi-code"), "config.toml");
|
|
7535
7549
|
}
|
|
7536
7550
|
function detectKimiCode(homeDir) {
|
|
7537
7551
|
const configPath = _getKimiConfigPath(homeDir);
|
|
@@ -7927,7 +7941,7 @@ import { existsSync as existsSync14 } from "node:fs";
|
|
|
7927
7941
|
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
7928
7942
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
7929
7943
|
import { delimiter, extname, join as join11 } from "node:path";
|
|
7930
|
-
var CURRENT_VERSION = "1.0.
|
|
7944
|
+
var CURRENT_VERSION = "1.0.6";
|
|
7931
7945
|
var VERSION_FETCH_TIMEOUT_MS = 2000;
|
|
7932
7946
|
var PI_PROBE_TIMEOUT_MS = 5000;
|
|
7933
7947
|
var PI_SENTINEL_COMMAND = "cc-safety-net";
|
|
@@ -9436,7 +9450,7 @@ function formatTraceJson(result) {
|
|
|
9436
9450
|
return JSON.stringify(result, null, 2);
|
|
9437
9451
|
}
|
|
9438
9452
|
// src/bin/help.ts
|
|
9439
|
-
var version = "1.0.
|
|
9453
|
+
var version = "1.0.6";
|
|
9440
9454
|
var INDENT = " ";
|
|
9441
9455
|
var PROGRAM_NAME = "cc-safety-net";
|
|
9442
9456
|
function formatOptionFlags(option) {
|
|
@@ -9635,11 +9649,11 @@ function removeArrayRangeItem(content, item) {
|
|
|
9635
9649
|
var KIMI_HOOK_COMMAND = "npx -y cc-safety-net hook --kimi-code";
|
|
9636
9650
|
var KIMI_HOOK_BLOCK = `[[hooks]]
|
|
9637
9651
|
event = "PreToolUse"
|
|
9638
|
-
matcher = "
|
|
9652
|
+
matcher = "Bash"
|
|
9639
9653
|
command = "${KIMI_HOOK_COMMAND}"`;
|
|
9640
|
-
var KIMI_INLINE_HOOK = `{ event = "PreToolUse", matcher = "
|
|
9654
|
+
var KIMI_INLINE_HOOK = `{ event = "PreToolUse", matcher = "Bash", command = "${KIMI_HOOK_COMMAND}" }`;
|
|
9641
9655
|
function getKimiConfigPath(homeDir) {
|
|
9642
|
-
return join12(process.env.
|
|
9656
|
+
return join12(process.env.KIMI_CODE_HOME ?? join12(homeDir, ".kimi-code"), "config.toml");
|
|
9643
9657
|
}
|
|
9644
9658
|
function removeTopLevelEmptyHooksArray(content) {
|
|
9645
9659
|
const result = content.split(`
|
|
@@ -3,4 +3,4 @@ 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
5
|
export declare const KIMI_CODE_HOOK_EVENT = "PreToolUse";
|
|
6
|
-
export declare const KIMI_CODE_TOOL_NAME = "
|
|
6
|
+
export declare const KIMI_CODE_TOOL_NAME = "Bash";
|
package/dist/index.js
CHANGED
|
@@ -5070,7 +5070,7 @@ function writeJsonAtomic(path, value) {
|
|
|
5070
5070
|
}
|
|
5071
5071
|
|
|
5072
5072
|
// src/core/rules/policy/scope-policy.ts
|
|
5073
|
-
import { existsSync as existsSync7, readFileSync as readFileSync6 } from "node:fs";
|
|
5073
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6, realpathSync as realpathSync7 } from "node:fs";
|
|
5074
5074
|
import { dirname as dirname6, isAbsolute as isAbsolute6, join as join6, relative, resolve as resolve5, sep as sep4 } from "node:path";
|
|
5075
5075
|
|
|
5076
5076
|
// src/core/rules/rulebook.ts
|
|
@@ -5496,8 +5496,9 @@ function sha256Digest(content) {
|
|
|
5496
5496
|
// src/core/rules/policy/scope-policy.ts
|
|
5497
5497
|
function loadRulesPolicy(options2 = {}) {
|
|
5498
5498
|
const paths = getPolicyPaths(options2);
|
|
5499
|
+
const sameConfigPath = isSameConfigPath(paths.userConfigPath, paths.projectConfigPath);
|
|
5499
5500
|
const user = readRulesConfig(paths.userConfigPath);
|
|
5500
|
-
const project = readRulesConfig(paths.projectConfigPath);
|
|
5501
|
+
const project = sameConfigPath ? { config: null, errors: [] } : readRulesConfig(paths.projectConfigPath);
|
|
5501
5502
|
const errors = [
|
|
5502
5503
|
...getLegacyRulesConfigErrors(paths, options2),
|
|
5503
5504
|
...user.errors.map((error) => `${paths.userConfigPath}: ${error}`),
|
|
@@ -5668,6 +5669,19 @@ function rulesPolicyToConfig(policy) {
|
|
|
5668
5669
|
}
|
|
5669
5670
|
return { version: 1, rules: policy.rules };
|
|
5670
5671
|
}
|
|
5672
|
+
function isSameConfigPath(userConfigPath, projectConfigPath) {
|
|
5673
|
+
if (resolve5(userConfigPath) === resolve5(projectConfigPath)) {
|
|
5674
|
+
return true;
|
|
5675
|
+
}
|
|
5676
|
+
if (!existsSync7(userConfigPath) || !existsSync7(projectConfigPath)) {
|
|
5677
|
+
return false;
|
|
5678
|
+
}
|
|
5679
|
+
try {
|
|
5680
|
+
return realpathSync7(userConfigPath) === realpathSync7(projectConfigPath);
|
|
5681
|
+
} catch {
|
|
5682
|
+
return false;
|
|
5683
|
+
}
|
|
5684
|
+
}
|
|
5671
5685
|
function getLegacyRulesConfigErrors(paths, options2) {
|
|
5672
5686
|
return Array.from(new Set([
|
|
5673
5687
|
...getLegacyRulesConfigError(getLegacyUserRulesConfigPath(options2), paths.userConfigPath, "~/.cc-safety-net/config.json"),
|
package/dist/pi/index.js
CHANGED
|
@@ -5134,7 +5134,7 @@ function writeJsonAtomic(path, value) {
|
|
|
5134
5134
|
}
|
|
5135
5135
|
|
|
5136
5136
|
// src/core/rules/policy/scope-policy.ts
|
|
5137
|
-
import { existsSync as existsSync7, readFileSync as readFileSync6 } from "node:fs";
|
|
5137
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6, realpathSync as realpathSync7 } from "node:fs";
|
|
5138
5138
|
import { dirname as dirname6, isAbsolute as isAbsolute6, join as join6, relative, resolve as resolve5, sep as sep4 } from "node:path";
|
|
5139
5139
|
|
|
5140
5140
|
// src/core/rules/rulebook.ts
|
|
@@ -5560,8 +5560,9 @@ function sha256Digest(content) {
|
|
|
5560
5560
|
// src/core/rules/policy/scope-policy.ts
|
|
5561
5561
|
function loadRulesPolicy(options2 = {}) {
|
|
5562
5562
|
const paths = getPolicyPaths(options2);
|
|
5563
|
+
const sameConfigPath = isSameConfigPath(paths.userConfigPath, paths.projectConfigPath);
|
|
5563
5564
|
const user = readRulesConfig(paths.userConfigPath);
|
|
5564
|
-
const project = readRulesConfig(paths.projectConfigPath);
|
|
5565
|
+
const project = sameConfigPath ? { config: null, errors: [] } : readRulesConfig(paths.projectConfigPath);
|
|
5565
5566
|
const errors = [
|
|
5566
5567
|
...getLegacyRulesConfigErrors(paths, options2),
|
|
5567
5568
|
...user.errors.map((error) => `${paths.userConfigPath}: ${error}`),
|
|
@@ -5732,6 +5733,19 @@ function rulesPolicyToConfig(policy) {
|
|
|
5732
5733
|
}
|
|
5733
5734
|
return { version: 1, rules: policy.rules };
|
|
5734
5735
|
}
|
|
5736
|
+
function isSameConfigPath(userConfigPath, projectConfigPath) {
|
|
5737
|
+
if (resolve5(userConfigPath) === resolve5(projectConfigPath)) {
|
|
5738
|
+
return true;
|
|
5739
|
+
}
|
|
5740
|
+
if (!existsSync7(userConfigPath) || !existsSync7(projectConfigPath)) {
|
|
5741
|
+
return false;
|
|
5742
|
+
}
|
|
5743
|
+
try {
|
|
5744
|
+
return realpathSync7(userConfigPath) === realpathSync7(projectConfigPath);
|
|
5745
|
+
} catch {
|
|
5746
|
+
return false;
|
|
5747
|
+
}
|
|
5748
|
+
}
|
|
5735
5749
|
function getLegacyRulesConfigErrors(paths, options2) {
|
|
5736
5750
|
return Array.from(new Set([
|
|
5737
5751
|
...getLegacyRulesConfigError(getLegacyUserRulesConfigPath(options2), paths.userConfigPath, "~/.cc-safety-net/config.json"),
|