@hasna/hooks 0.7.10 → 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 (96) hide show
  1. package/README.md +32 -6
  2. package/bin/index.js +2640 -1820
  3. package/bin/serve.js +742 -551
  4. package/dist/config.d.ts +25 -19
  5. package/dist/index.d.ts +3 -2
  6. package/dist/index.js +1251 -717
  7. package/dist/lib/app-home.d.ts +9 -0
  8. package/dist/lib/installer.d.ts +40 -10
  9. package/dist/lib/local-opt-in.d.ts +80 -0
  10. package/dist/lib/profiles.d.ts +10 -0
  11. package/dist/lib/registration.d.ts +75 -0
  12. package/dist/lib/registry.d.ts +14 -0
  13. package/dist/lib/resolver-types.d.ts +45 -0
  14. package/dist/lib/sync.d.ts +13 -8
  15. package/dist/lib/transport.d.ts +87 -0
  16. package/dist/openapi.d.ts +1 -1
  17. package/dist/storage.js +54 -63
  18. package/hooks/hook-affected-tests/package.json +1 -1
  19. package/hooks/hook-agent-rules-version-check/README.md +1 -1
  20. package/hooks/hook-agent-rules-version-check/package.json +1 -1
  21. package/hooks/hook-agentmessages/package.json +1 -1
  22. package/hooks/hook-announce-start/package.json +1 -1
  23. package/hooks/hook-announce-stop/package.json +1 -1
  24. package/hooks/hook-autoformat/package.json +1 -1
  25. package/hooks/hook-branchprotect/package.json +1 -1
  26. package/hooks/hook-checkbugs/package.json +1 -1
  27. package/hooks/hook-checkdocs/package.json +1 -1
  28. package/hooks/hook-checkfiles/package.json +1 -1
  29. package/hooks/hook-checklint/package.json +1 -1
  30. package/hooks/hook-checkpoint/package.json +1 -1
  31. package/hooks/hook-checksecurity/package.json +1 -1
  32. package/hooks/hook-checktasks/package.json +1 -1
  33. package/hooks/hook-checktests/package.json +1 -1
  34. package/hooks/hook-conflict-detect/package.json +1 -1
  35. package/hooks/hook-contextrefresh/package.json +1 -1
  36. package/hooks/hook-desktopnotify/package.json +1 -1
  37. package/hooks/hook-dm-inject/package.json +1 -1
  38. package/hooks/hook-envsetup/package.json +1 -1
  39. package/hooks/hook-failure-to-task/package.json +1 -1
  40. package/hooks/hook-filelock/package.json +1 -1
  41. package/hooks/hook-fleet-blockers-gate/package.json +1 -1
  42. package/hooks/hook-fleet-catchup/package.json +1 -1
  43. package/hooks/hook-gitguard/package.json +1 -1
  44. package/hooks/hook-packageage/package.json +1 -1
  45. package/hooks/hook-permissionguard/package.json +1 -1
  46. package/hooks/hook-phonenotify/package.json +1 -1
  47. package/hooks/hook-precompact/package.json +1 -1
  48. package/hooks/hook-protectfiles/package.json +1 -1
  49. package/hooks/hook-stylescheck/package.json +1 -1
  50. package/hooks/hook-trash-guard/README.md +132 -0
  51. package/hooks/hook-trash-guard/package.json +12 -0
  52. package/hooks/hook-trash-guard/src/hook.ts +1114 -0
  53. package/hooks/hook-typecheck-gate/package.json +1 -1
  54. package/package.json +7 -10
  55. package/scripts/ensure-profiles-dir.mjs +52 -1
  56. package/hooks/codewith-native-common.test.ts +0 -1935
  57. package/hooks/hook-affected-tests/tsconfig.json +0 -25
  58. package/hooks/hook-agent-rules-version-check/src/hook.test.ts +0 -104
  59. package/hooks/hook-agent-rules-version-check/tsconfig.json +0 -25
  60. package/hooks/hook-announce-start/tsconfig.json +0 -25
  61. package/hooks/hook-announce-stop/tsconfig.json +0 -25
  62. package/hooks/hook-autoformat/tsconfig.json +0 -25
  63. package/hooks/hook-branchprotect/tsconfig.json +0 -25
  64. package/hooks/hook-checkbugs/tsconfig.json +0 -15
  65. package/hooks/hook-checkdocs/tsconfig.json +0 -15
  66. package/hooks/hook-checkfiles/tsconfig.json +0 -15
  67. package/hooks/hook-checklint/tsconfig.json +0 -15
  68. package/hooks/hook-checkpoint/tsconfig.json +0 -25
  69. package/hooks/hook-checksecurity/tsconfig.json +0 -15
  70. package/hooks/hook-checktasks/tsconfig.json +0 -20
  71. package/hooks/hook-checktests/tsconfig.json +0 -15
  72. package/hooks/hook-conflict-detect/tsconfig.json +0 -25
  73. package/hooks/hook-contextrefresh/tsconfig.json +0 -25
  74. package/hooks/hook-desktopnotify/tsconfig.json +0 -25
  75. package/hooks/hook-dm-inject/tsconfig.json +0 -25
  76. package/hooks/hook-envsetup/tsconfig.json +0 -25
  77. package/hooks/hook-failure-to-task/tsconfig.json +0 -25
  78. package/hooks/hook-filelock/tsconfig.json +0 -25
  79. package/hooks/hook-fleet-blockers-gate/src/hook.test.ts +0 -302
  80. package/hooks/hook-fleet-blockers-gate/tsconfig.json +0 -25
  81. package/hooks/hook-fleet-catchup/src/hook.test.ts +0 -156
  82. package/hooks/hook-fleet-catchup/tsconfig.json +0 -25
  83. package/hooks/hook-gitguard/tsconfig.json +0 -25
  84. package/hooks/hook-knowledge-context/src/hook.test.ts +0 -379
  85. package/hooks/hook-packageage/tsconfig.json +0 -25
  86. package/hooks/hook-permissionguard/tsconfig.json +0 -25
  87. package/hooks/hook-phonenotify/tsconfig.json +0 -25
  88. package/hooks/hook-precompact/tsconfig.json +0 -25
  89. package/hooks/hook-protectfiles/tsconfig.json +0 -25
  90. package/hooks/hook-scanoutput/src/hook.test.ts +0 -217
  91. package/hooks/hook-spiral-detector/src/hook.test.ts +0 -72
  92. package/hooks/hook-stylescheck/tsconfig.json +0 -25
  93. package/hooks/hook-typecheck-gate/tsconfig.json +0 -25
  94. package/hooks/hook-workspace-repos-guard/src/hook.test.ts +0 -466
  95. package/hooks/hook-workspace-repos-guard/tsconfig.json +0 -21
  96. package/hooks/mention-context/src/hook.test.ts +0 -68
package/dist/config.d.ts CHANGED
@@ -1,27 +1,33 @@
1
1
  /**
2
2
  * Runtime configuration for @hasna/hooks.
3
3
  *
4
- * Presence of an API URL selects the remote registry; absence means the local
5
- * store is authoritative. There is deliberately no mode concept.
4
+ * Transport policy (fleet fail-closed doctrine, 2026-09-04): the remote
5
+ * registry is selected and authenticated by the ONE resolver in
6
+ * `@hasna/contracts/client` (strict URL+key pair, resolved fresh per call —
7
+ * see `src/lib/transport.ts`). Without a resolved pair the CLI must FAIL
8
+ * CLOSED instead of silently serving the local store. Local mode (bundled
9
+ * registry + local SQLite at the effective data root) is an explicit opt-in
10
+ * via HASNA_HOOKS_LOCAL=1 / HOOKS_LOCAL=1 — never the default for a CLI run.
11
+ *
12
+ * The app's own credential chain is gone: no `~/.hasna/fleet-env`,
13
+ * `~/.hasna/cloud`, `~/.config/hasna` or `$XDG_CONFIG_HOME` read, no
14
+ * `~/.hasna/hooks/config.json` `api_url` / `api_key_ref` key store, no
15
+ * `HASNA_HOOKS_REGISTRY_URL` / `HOOKS_REGISTRY_URL` spellings, no `*_MODE`
16
+ * transport switches. The authority and the credential both come from
17
+ * @hasna/contracts, which resolves per call: Keychain `hasna.credentials.hooks.*`,
18
+ * disk `~/.hasna/hooks/config/credentials`, then `HASNA_HOOKS_API_URL` /
19
+ * `HASNA_HOOKS_API_KEY` (the unprefixed `HOOKS_*` spellings remain only as the
20
+ * resolver's silent alias fallback).
6
21
  */
7
22
  export declare function getHooksDataDir(): string;
8
23
  export declare function getCustomHooksDir(): string;
9
24
  export declare function getLockPath(): string;
10
- export declare function getConfigPath(): string;
11
- export interface HooksConfig {
12
- api_url?: string;
13
- api_key_ref?: string;
14
- }
15
- export declare function readConfig(): HooksConfig;
16
- export declare function writeConfig(config: HooksConfig): string;
17
- export declare function resolveApiUrl(): string | undefined;
18
25
  /**
19
- * P1-8: the registry API key resolves through the shared client seam, never
20
- * by hand — its chain (deliberate override, profile, disk, then the legacy
21
- * HASNA_HOOKS_API_KEY / HOOKS_API_KEY env variables) is the single path that
22
- * receives credential-resolution fixes. A secret-valued CLI flag stays
23
- * removed (a flag value is visible in process listings and shell history);
24
- * the vault-key-NAME reference (config api_key_ref) is a name, not a value,
25
- * and is untouched.
26
- */
27
- export declare function resolveApiKey(): string | undefined;
26
+ * The legacy `config.json` reader/writer and its `api_url` / `api_key_ref`
27
+ * fields were REMOVED (hasna/apps#1720): the file was this package's own
28
+ * configuration key store, outranked the canonical env names for operators who
29
+ * had both, and carried a secret-valued reference outside the resolver's
30
+ * chain. The registry authority and its credential now resolve exclusively
31
+ * through `@hasna/contracts` (env, Keychain item `hasna.credentials.hooks.api-url`
32
+ * / `.api-key`, and `~/.hasna/hooks/config/credentials`).
33
+ */
package/dist/index.d.ts CHANGED
@@ -74,8 +74,9 @@ export declare function runHook(name: string, input: HookInput, options?: RunHoo
74
74
  export { createProfile, getProfile, listProfiles, updateProfile, deleteProfile, touchProfile, getProfilesDir, exportProfiles, importProfiles, type AgentProfile, type CreateProfileInput, } from "./lib/profiles.js";
75
75
  export { HOOKS_STORAGE_ENV, HOOKS_STORAGE_FALLBACK_ENV, HOOKS_STORAGE_BACKEND_ENV, HOOKS_STORAGE_BACKEND_FALLBACK_ENV, HOOKS_STORAGE_TABLES, RETIRED_STORAGE_MODE_ENV, STORAGE_BACKENDS, STORAGE_BACKEND_ENV, STORAGE_DATABASE_ENV, STORAGE_TABLES, getStorageBackend, getStorageDatabaseEnv, getStorageDatabaseEnvName, getStorageDatabaseUrl, getStoragePg, getStorageStatus, getSyncMetaAll, parseStorageTables, resolveTables, runStorageMigrations, storagePull, storagePush, storageSync, } from "./storage.js";
76
76
  export type { StorageBackend, StorageEnv, StorageStatus, SyncMeta, SyncResult } from "./storage.js";
77
- export { getHooksDataDir, getCustomHooksDir, getLockPath, getConfigPath, readConfig, writeConfig, resolveApiUrl, resolveApiKey, } from "./config.js";
78
- export type { HooksConfig } from "./config.js";
77
+ export { getHooksDataDir, getCustomHooksDir, getLockPath, } from "./config.js";
78
+ export { resolveHooksTransport, resolveHooksServePublishKey, hooksRegistryOrigin, type HooksRemoteAuthority, type HooksCredentialOptions, type HooksTransportMode, type HooksTransportNotice, type HooksTransportOptions, type HooksTransportResolution, } from "./lib/transport.js";
79
+ export type { HooksLocalOptInEnv } from "./lib/resolver-types.js";
79
80
  export { getHookRecord, listHookRecords, upsertHookRecord, removeHookRecord, readLock, writeLock, setPinnedHook, getPinnedHook, removePinnedHook, pinInstalledHook, removeHookFromStore, verifyScriptHash, checkScriptHash, retrustHook, sha256Of, sha256File, } from "./lib/store.js";
80
81
  export type { HookRecord, LockEntry, LockFile, TrustCheck } from "./lib/store.js";
81
82
  export { parseManifest, readCustomManifest, listCustomHooks, writeCustomHook, resolveScript, } from "./lib/manifest.js";