@hasna/hooks 0.8.0 → 0.9.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.
Files changed (52) hide show
  1. package/bin/index.js +315 -67
  2. package/bin/serve.js +12 -0
  3. package/dist/index.js +52 -4
  4. package/dist/lib/installer.d.ts +40 -1
  5. package/dist/lib/registration.d.ts +75 -0
  6. package/dist/lib/registry.d.ts +14 -0
  7. package/hooks/hook-agent-rules-version-check/README.md +1 -1
  8. package/hooks/hook-trash-guard/README.md +132 -0
  9. package/hooks/hook-trash-guard/package.json +12 -0
  10. package/hooks/hook-trash-guard/src/hook.ts +1114 -0
  11. package/package.json +4 -2
  12. package/hooks/codewith-native-common.test.ts +0 -1935
  13. package/hooks/hook-affected-tests/tsconfig.json +0 -25
  14. package/hooks/hook-agent-rules-version-check/src/hook.test.ts +0 -104
  15. package/hooks/hook-agent-rules-version-check/tsconfig.json +0 -25
  16. package/hooks/hook-announce-start/tsconfig.json +0 -25
  17. package/hooks/hook-announce-stop/tsconfig.json +0 -25
  18. package/hooks/hook-autoformat/tsconfig.json +0 -25
  19. package/hooks/hook-branchprotect/tsconfig.json +0 -25
  20. package/hooks/hook-checkbugs/tsconfig.json +0 -15
  21. package/hooks/hook-checkdocs/tsconfig.json +0 -15
  22. package/hooks/hook-checkfiles/tsconfig.json +0 -15
  23. package/hooks/hook-checklint/tsconfig.json +0 -15
  24. package/hooks/hook-checkpoint/tsconfig.json +0 -25
  25. package/hooks/hook-checksecurity/tsconfig.json +0 -15
  26. package/hooks/hook-checktasks/tsconfig.json +0 -20
  27. package/hooks/hook-checktests/tsconfig.json +0 -15
  28. package/hooks/hook-conflict-detect/tsconfig.json +0 -25
  29. package/hooks/hook-contextrefresh/tsconfig.json +0 -25
  30. package/hooks/hook-desktopnotify/tsconfig.json +0 -25
  31. package/hooks/hook-dm-inject/tsconfig.json +0 -25
  32. package/hooks/hook-envsetup/tsconfig.json +0 -25
  33. package/hooks/hook-failure-to-task/tsconfig.json +0 -25
  34. package/hooks/hook-filelock/tsconfig.json +0 -25
  35. package/hooks/hook-fleet-blockers-gate/src/hook.test.ts +0 -302
  36. package/hooks/hook-fleet-blockers-gate/tsconfig.json +0 -25
  37. package/hooks/hook-fleet-catchup/src/hook.test.ts +0 -156
  38. package/hooks/hook-fleet-catchup/tsconfig.json +0 -25
  39. package/hooks/hook-gitguard/tsconfig.json +0 -25
  40. package/hooks/hook-knowledge-context/src/hook.test.ts +0 -379
  41. package/hooks/hook-packageage/tsconfig.json +0 -25
  42. package/hooks/hook-permissionguard/tsconfig.json +0 -25
  43. package/hooks/hook-phonenotify/tsconfig.json +0 -25
  44. package/hooks/hook-precompact/tsconfig.json +0 -25
  45. package/hooks/hook-protectfiles/tsconfig.json +0 -25
  46. package/hooks/hook-scanoutput/src/hook.test.ts +0 -217
  47. package/hooks/hook-spiral-detector/src/hook.test.ts +0 -72
  48. package/hooks/hook-stylescheck/tsconfig.json +0 -25
  49. package/hooks/hook-typecheck-gate/tsconfig.json +0 -25
  50. package/hooks/hook-workspace-repos-guard/src/hook.test.ts +0 -466
  51. package/hooks/hook-workspace-repos-guard/tsconfig.json +0 -21
  52. package/hooks/mention-context/src/hook.test.ts +0 -68
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,104 +0,0 @@
1
- import { describe, test, expect } from "bun:test";
2
- import { mkdtempSync, writeFileSync, rmSync } from "fs";
3
- import { join } from "path";
4
- import { tmpdir } from "os";
5
- import { extractSentinelVersion, scanArtifacts, evaluate, defaultArtifactPaths } from "./hook";
6
-
7
- describe("hook-agent-rules-version-check", () => {
8
- describe("extractSentinelVersion", () => {
9
- test("extracts version from a full sentinel", () => {
10
- expect(
11
- extractSentinelVersion("x\n<!-- hasna:agent-operating-rules v=1.2.3 sha256=abc123 -->\ny")
12
- ).toBe("1.2.3");
13
- });
14
-
15
- test("extracts version without sha", () => {
16
- expect(extractSentinelVersion("<!-- hasna:agent-operating-rules v=0.9.0 -->")).toBe("0.9.0");
17
- });
18
-
19
- test("tolerates extra whitespace", () => {
20
- expect(extractSentinelVersion("<!-- hasna:agent-operating-rules v=2.0.0 -->")).toBe("2.0.0");
21
- });
22
-
23
- test("returns null when no sentinel present", () => {
24
- expect(extractSentinelVersion("# just a doc\nno sentinel here")).toBeNull();
25
- });
26
-
27
- test("does not match other hasna sentinels", () => {
28
- expect(extractSentinelVersion("<!-- hasna:hacp v=1.0.0 -->")).toBeNull();
29
- });
30
- });
31
-
32
- describe("scanArtifacts", () => {
33
- test("collects sentinel hits and skips missing/plain files", () => {
34
- const dir = mkdtempSync(join(tmpdir(), "rules-check-"));
35
- try {
36
- const withSentinel = join(dir, "a.md");
37
- const withoutSentinel = join(dir, "b.md");
38
- writeFileSync(withSentinel, "<!-- hasna:agent-operating-rules v=1.0.0 -->");
39
- writeFileSync(withoutSentinel, "# no sentinel");
40
-
41
- const hits = scanArtifacts([withSentinel, withoutSentinel, join(dir, "missing.md")]);
42
- expect(hits).toHaveLength(1);
43
- expect(hits[0]).toEqual({ file: withSentinel, version: "1.0.0" });
44
- } finally {
45
- rmSync(dir, { recursive: true, force: true });
46
- }
47
- });
48
- });
49
-
50
- describe("defaultArtifactPaths", () => {
51
- test("covers the delivery-matrix runtimes", () => {
52
- const paths = defaultArtifactPaths("/home/u");
53
- expect(paths).toContain("/home/u/.claude/CLAUDE.md");
54
- expect(paths).toContain("/home/u/.codex/AGENTS.md");
55
- expect(paths).toContain("/home/u/.config/opencode/AGENTS.md");
56
- expect(paths).toContain("/home/u/.cursor/rules/hasna-global.mdc");
57
- });
58
- });
59
-
60
- describe("evaluate", () => {
61
- test("silent when nothing is rendered", () => {
62
- expect(evaluate([], "1.0.0")).toBeNull();
63
- expect(evaluate([], null)).toBeNull();
64
- });
65
-
66
- test("silent when all artifacts match the expected version", () => {
67
- const hits = [
68
- { file: "/a.md", version: "1.0.0" },
69
- { file: "/b.md", version: "1.0.0" },
70
- ];
71
- expect(evaluate(hits, "1.0.0")).toBeNull();
72
- });
73
-
74
- test("warns and lists stale artifacts on mismatch", () => {
75
- const hits = [
76
- { file: "/a.md", version: "1.0.0" },
77
- { file: "/b.md", version: "0.9.0" },
78
- ];
79
- const warning = evaluate(hits, "1.0.0");
80
- expect(warning).toContain("OUT OF DATE");
81
- expect(warning).toContain("/b.md: v0.9.0");
82
- expect(warning).not.toContain("/a.md");
83
- });
84
-
85
- test("without expected version, warns when artifacts disagree", () => {
86
- const hits = [
87
- { file: "/a.md", version: "1.0.0" },
88
- { file: "/b.md", version: "1.1.0" },
89
- ];
90
- const warning = evaluate(hits, null);
91
- expect(warning).toContain("DISAGREE");
92
- expect(warning).toContain("/a.md: v1.0.0");
93
- expect(warning).toContain("/b.md: v1.1.0");
94
- });
95
-
96
- test("without expected version, silent when artifacts agree", () => {
97
- const hits = [
98
- { file: "/a.md", version: "1.0.0" },
99
- { file: "/b.md", version: "1.0.0" },
100
- ];
101
- expect(evaluate(hits, null)).toBeNull();
102
- });
103
- });
104
- });
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "strict": true,
7
- "esModuleInterop": true,
8
- "skipLibCheck": true,
9
- "outDir": "./dist",
10
- "declaration": true,
11
- "declarationMap": true
12
- },
13
- "include": ["src/**/*"],
14
- "exclude": ["node_modules", "dist"]
15
- }
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "strict": true,
7
- "esModuleInterop": true,
8
- "skipLibCheck": true,
9
- "outDir": "./dist",
10
- "declaration": true,
11
- "declarationMap": true
12
- },
13
- "include": ["src/**/*"],
14
- "exclude": ["node_modules", "dist"]
15
- }
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "strict": true,
7
- "esModuleInterop": true,
8
- "skipLibCheck": true,
9
- "outDir": "./dist",
10
- "declaration": true,
11
- "declarationMap": true
12
- },
13
- "include": ["src/**/*"],
14
- "exclude": ["node_modules", "dist"]
15
- }
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "strict": true,
7
- "esModuleInterop": true,
8
- "skipLibCheck": true,
9
- "outDir": "./dist",
10
- "declaration": true,
11
- "declarationMap": true
12
- },
13
- "include": ["src/**/*"],
14
- "exclude": ["node_modules", "dist"]
15
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "strict": true,
7
- "esModuleInterop": true,
8
- "skipLibCheck": true,
9
- "outDir": "./dist",
10
- "declaration": true,
11
- "declarationMap": true
12
- },
13
- "include": ["src/**/*"],
14
- "exclude": ["node_modules", "dist"]
15
- }
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "lib": ["ES2022"],
7
- "strict": true,
8
- "skipLibCheck": true,
9
- "noEmit": true,
10
- "esModuleInterop": true,
11
- "resolveJsonModule": true,
12
- "declaration": true,
13
- "declarationMap": true,
14
- "outDir": "./dist",
15
- "rootDir": "./src",
16
- "types": ["bun-types", "node"]
17
- },
18
- "include": ["src/**/*.ts"],
19
- "exclude": ["node_modules", "dist"]
20
- }
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "strict": true,
7
- "esModuleInterop": true,
8
- "skipLibCheck": true,
9
- "outDir": "./dist",
10
- "declaration": true,
11
- "declarationMap": true
12
- },
13
- "include": ["src/**/*"],
14
- "exclude": ["node_modules", "dist"]
15
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowImportingTsExtensions": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "declaration": true,
18
- "declarationMap": true,
19
- "outDir": "./dist",
20
- "rootDir": "./src",
21
- "types": ["bun-types"]
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }