@hasna/hooks 0.13.1 → 0.14.0
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 +30 -15
- package/bin/hooks/stop-review.js +53 -17
- package/bin/hooks-mcp.js +4787 -1415
- package/bin/index.js +5250 -2337
- package/bin/native-safety-entry.js +15 -37
- package/bin/native-safety-worker.cjs +38 -36
- package/bin/serve.js +34 -11
- package/dist/index.js +4970 -1579
- package/dist/lib/claude-skills-coordination.d.ts +1 -1
- package/dist/lib/codex-safety-trust.d.ts +2 -2
- package/dist/lib/native-safety-registration.d.ts +2 -2
- package/dist/lib/native-safety.d.ts +1 -1
- package/dist/lib/registry.d.ts +3 -1
- package/dist/native-safety.d.ts +4 -2
- package/dist/native-safety.js +21 -2
- package/dist/sdk/index.js +9 -53
- package/hooks/hook-job-folder-guard/README.md +61 -0
- package/hooks/hook-job-folder-guard/package.json +12 -0
- package/hooks/hook-job-folder-guard/src/classify.ts +398 -0
- package/hooks/hook-job-folder-guard/src/hook.ts +96 -0
- package/hooks/hook-protected-delete-guard/README.md +114 -0
- package/hooks/hook-protected-delete-guard/package.json +12 -0
- package/hooks/hook-protected-delete-guard/src/hook.ts +539 -0
- package/hooks/hook-signed-link-guard/src/classify.ts +41 -2
- package/hooks/hook-stop-review/README.md +16 -0
- package/hooks/hook-stop-review/manifest.json +1 -1
- package/hooks/hook-stop-review/package.json +1 -1
- package/hooks/hook-stop-review/src/hook.ts +1 -1
- package/hooks/hook-stop-review/src/native.ts +44 -8
- package/hooks/hook-stop-review/src/policy.ts +20 -8
- package/hooks/hook-stop-review/src/runtime.ts +16 -13
- package/hooks/hook-stop-review/src/types.ts +12 -2
- package/hooks/hook-trash-guard/README.md +130 -13
- package/hooks/hook-trash-guard/src/hook.ts +518 -71
- package/hooks/local-executors.ts +130 -12
- package/hooks/native-safety-composite.ts +19 -8
- package/package.json +3 -3
- package/scripts/build-native-entry.ts +123 -0
- package/scripts/build-native-worker.ts +11 -4
- package/scripts/validate-package.ts +8 -2
- package/hooks/native-safety-entry.ts +0 -11
package/bin/serve.js
CHANGED
|
@@ -186,6 +186,18 @@ var HOOKS = [
|
|
|
186
186
|
legacyMatchers: ["^(Bash|Write|Edit|MultiEdit|NotebookEdit|apply_patch|ApplyPatch|functions\\.apply_patch)$"],
|
|
187
187
|
tags: ["workspace", "repos", "structure", "guard", "safety", "orgs", "multi-agent"]
|
|
188
188
|
},
|
|
189
|
+
{
|
|
190
|
+
name: "protected-delete-guard",
|
|
191
|
+
timeoutSeconds: 10,
|
|
192
|
+
displayName: "Protected Delete Guard",
|
|
193
|
+
description: "Refuses rm, rmdir, unlink and find with a delete action on the protected class (/, the system roots, the home directory, ~/.hasna, ~/.ssh, ~/.aws) and on coding-agent session and history stores; only refuses, never rewrites a command and needs no Trash",
|
|
194
|
+
version: "0.1.0",
|
|
195
|
+
category: "Git Safety",
|
|
196
|
+
event: "PreToolUse",
|
|
197
|
+
matcher: "^(Bash|apply_patch|ApplyPatch|functions\\.apply_patch)$",
|
|
198
|
+
targetMatchers: { claude: "^(Bash|Monitor|apply_patch|ApplyPatch|functions\\.apply_patch)$" },
|
|
199
|
+
tags: ["rm", "delete", "protected", "session-history", "guard", "safety", "bash"]
|
|
200
|
+
},
|
|
189
201
|
{
|
|
190
202
|
name: "trash-guard",
|
|
191
203
|
displayName: "Trash Guard",
|
|
@@ -593,7 +605,7 @@ var HOOKS = [
|
|
|
593
605
|
bundledEntry: "bin/hooks/stop-review.js",
|
|
594
606
|
displayName: "Stop Review",
|
|
595
607
|
description: "Reviews turn completion against the latest user request and active goal",
|
|
596
|
-
version: "0.1.
|
|
608
|
+
version: "0.1.1",
|
|
597
609
|
category: "Agent Teams",
|
|
598
610
|
event: "Stop",
|
|
599
611
|
events: ["Stop"],
|
|
@@ -652,6 +664,17 @@ var HOOKS = [
|
|
|
652
664
|
matcher: "Bash",
|
|
653
665
|
tags: ["failures", "tasks", "tests", "build", "automation"]
|
|
654
666
|
},
|
|
667
|
+
{
|
|
668
|
+
name: "job-folder-guard",
|
|
669
|
+
displayName: "Job Folder Guard",
|
|
670
|
+
description: "Adds a notice to the model's context when a Write, Edit, MultiEdit, NotebookEdit or Bash command writes to or uses a harness job folder (<path>/jobs/<id>/tmp/, a Claude Code or Switcher job folder), naming the session's Scratchpad folder instead; never blocks and never changes the permission flow",
|
|
671
|
+
version: "0.1.0",
|
|
672
|
+
category: "Workflow Automation",
|
|
673
|
+
event: "PreToolUse",
|
|
674
|
+
matcher: "^(Write|Edit|MultiEdit|NotebookEdit|Bash)$",
|
|
675
|
+
tags: ["scratch", "scratchpad", "jobs", "switcher", "notice"],
|
|
676
|
+
timeoutSeconds: 5
|
|
677
|
+
},
|
|
655
678
|
{
|
|
656
679
|
name: "filelock",
|
|
657
680
|
displayName: "File Lock",
|
|
@@ -731,7 +754,7 @@ function getHook(name) {
|
|
|
731
754
|
import { existsSync as existsSync2, mkdirSync, readFileSync, readdirSync, realpathSync, writeFileSync } from "fs";
|
|
732
755
|
import { basename, dirname, isAbsolute, join as join3, normalize, resolve as resolve2, sep } from "path";
|
|
733
756
|
|
|
734
|
-
//
|
|
757
|
+
// node_modules/zod/v3/external.js
|
|
735
758
|
var exports_external = {};
|
|
736
759
|
__export(exports_external, {
|
|
737
760
|
void: () => voidType,
|
|
@@ -843,7 +866,7 @@ __export(exports_external, {
|
|
|
843
866
|
BRAND: () => BRAND
|
|
844
867
|
});
|
|
845
868
|
|
|
846
|
-
//
|
|
869
|
+
// node_modules/zod/v3/helpers/util.js
|
|
847
870
|
var util;
|
|
848
871
|
(function(util2) {
|
|
849
872
|
util2.assertEqual = (_) => {};
|
|
@@ -974,7 +997,7 @@ var getParsedType = (data) => {
|
|
|
974
997
|
}
|
|
975
998
|
};
|
|
976
999
|
|
|
977
|
-
//
|
|
1000
|
+
// node_modules/zod/v3/ZodError.js
|
|
978
1001
|
var ZodIssueCode = util.arrayToEnum([
|
|
979
1002
|
"invalid_type",
|
|
980
1003
|
"invalid_literal",
|
|
@@ -1093,7 +1116,7 @@ ZodError.create = (issues) => {
|
|
|
1093
1116
|
return error;
|
|
1094
1117
|
};
|
|
1095
1118
|
|
|
1096
|
-
//
|
|
1119
|
+
// node_modules/zod/v3/locales/en.js
|
|
1097
1120
|
var errorMap = (issue, _ctx) => {
|
|
1098
1121
|
let message;
|
|
1099
1122
|
switch (issue.code) {
|
|
@@ -1196,7 +1219,7 @@ var errorMap = (issue, _ctx) => {
|
|
|
1196
1219
|
};
|
|
1197
1220
|
var en_default = errorMap;
|
|
1198
1221
|
|
|
1199
|
-
//
|
|
1222
|
+
// node_modules/zod/v3/errors.js
|
|
1200
1223
|
var overrideErrorMap = en_default;
|
|
1201
1224
|
function setErrorMap(map) {
|
|
1202
1225
|
overrideErrorMap = map;
|
|
@@ -1204,7 +1227,7 @@ function setErrorMap(map) {
|
|
|
1204
1227
|
function getErrorMap() {
|
|
1205
1228
|
return overrideErrorMap;
|
|
1206
1229
|
}
|
|
1207
|
-
//
|
|
1230
|
+
// node_modules/zod/v3/helpers/parseUtil.js
|
|
1208
1231
|
var makeIssue = (params) => {
|
|
1209
1232
|
const { data, path, errorMaps, issueData } = params;
|
|
1210
1233
|
const fullPath = [...path, ...issueData.path || []];
|
|
@@ -1310,14 +1333,14 @@ var isAborted = (x) => x.status === "aborted";
|
|
|
1310
1333
|
var isDirty = (x) => x.status === "dirty";
|
|
1311
1334
|
var isValid = (x) => x.status === "valid";
|
|
1312
1335
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
1313
|
-
//
|
|
1336
|
+
// node_modules/zod/v3/helpers/errorUtil.js
|
|
1314
1337
|
var errorUtil;
|
|
1315
1338
|
(function(errorUtil2) {
|
|
1316
1339
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
1317
1340
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
1318
1341
|
})(errorUtil || (errorUtil = {}));
|
|
1319
1342
|
|
|
1320
|
-
//
|
|
1343
|
+
// node_modules/zod/v3/types.js
|
|
1321
1344
|
class ParseInputLazyPath {
|
|
1322
1345
|
constructor(parent, value, path, key) {
|
|
1323
1346
|
this._cachedPath = [];
|
|
@@ -5552,7 +5575,7 @@ import { readFileSync as readFileSync5 } from "fs";
|
|
|
5552
5575
|
import { dirname as dirname4, join as join9 } from "path";
|
|
5553
5576
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
5554
5577
|
|
|
5555
|
-
//
|
|
5578
|
+
// node_modules/@hasna/contracts/dist/client/transport.js
|
|
5556
5579
|
import { spawnSync } from "child_process";
|
|
5557
5580
|
import { closeSync as closeSync2, fstatSync as fstatSync2, openSync as openSync2, readFileSync as readFileSync22 } from "fs";
|
|
5558
5581
|
import { O_NOFOLLOW as O_NOFOLLOW2, O_NONBLOCK as O_NONBLOCK2, O_RDONLY as O_RDONLY2 } from "constants";
|
|
@@ -7021,7 +7044,7 @@ function getStorageBackend() {
|
|
|
7021
7044
|
return getStorageDatabaseUrl() ? "postgresql" : "sqlite";
|
|
7022
7045
|
}
|
|
7023
7046
|
|
|
7024
|
-
//
|
|
7047
|
+
// node_modules/@hasna/contracts/dist/auth/index.js
|
|
7025
7048
|
import { createHash as createHash3, createHmac, randomBytes as randomBytes2, timingSafeEqual } from "crypto";
|
|
7026
7049
|
var MAX_TENANT_ID_LENGTH = 64;
|
|
7027
7050
|
var TENANT_ID_PATTERN = new RegExp(`^[A-Za-z0-9][A-Za-z0-9._-]{0,${MAX_TENANT_ID_LENGTH - 1}}$`);
|