olympus-ai 2.4.1 → 2.5.2

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 (149) hide show
  1. package/dist/__tests__/hooks/bundle.test.d.ts +2 -0
  2. package/dist/__tests__/hooks/bundle.test.d.ts.map +1 -0
  3. package/dist/__tests__/hooks/bundle.test.js +116 -0
  4. package/dist/__tests__/hooks/bundle.test.js.map +1 -0
  5. package/dist/__tests__/hooks/integration.test.d.ts +2 -0
  6. package/dist/__tests__/hooks/integration.test.d.ts.map +1 -0
  7. package/dist/__tests__/hooks/integration.test.js +132 -0
  8. package/dist/__tests__/hooks/integration.test.js.map +1 -0
  9. package/dist/__tests__/hooks/performance.test.d.ts +2 -0
  10. package/dist/__tests__/hooks/performance.test.d.ts.map +1 -0
  11. package/dist/__tests__/hooks/performance.test.js +267 -0
  12. package/dist/__tests__/hooks/performance.test.js.map +1 -0
  13. package/dist/__tests__/hooks/router.test.d.ts +2 -0
  14. package/dist/__tests__/hooks/router.test.d.ts.map +1 -0
  15. package/dist/__tests__/hooks/router.test.js +793 -0
  16. package/dist/__tests__/hooks/router.test.js.map +1 -0
  17. package/dist/__tests__/installer.test.js +7 -3
  18. package/dist/__tests__/installer.test.js.map +1 -1
  19. package/dist/hooks/config.d.ts +47 -0
  20. package/dist/hooks/config.d.ts.map +1 -0
  21. package/dist/hooks/config.js +120 -0
  22. package/dist/hooks/config.js.map +1 -0
  23. package/dist/hooks/entry.d.ts +17 -0
  24. package/dist/hooks/entry.d.ts.map +1 -0
  25. package/dist/hooks/entry.js +66 -0
  26. package/dist/hooks/entry.js.map +1 -0
  27. package/dist/hooks/index.d.ts +3 -0
  28. package/dist/hooks/index.d.ts.map +1 -1
  29. package/dist/hooks/index.js +6 -0
  30. package/dist/hooks/index.js.map +1 -1
  31. package/dist/hooks/olympus-hooks.cjs +653 -0
  32. package/dist/hooks/registrations/index.d.ts +25 -0
  33. package/dist/hooks/registrations/index.d.ts.map +1 -0
  34. package/dist/hooks/registrations/index.js +43 -0
  35. package/dist/hooks/registrations/index.js.map +1 -0
  36. package/dist/hooks/registrations/messages-transform.d.ts +8 -0
  37. package/dist/hooks/registrations/messages-transform.d.ts.map +1 -0
  38. package/dist/hooks/registrations/messages-transform.js +63 -0
  39. package/dist/hooks/registrations/messages-transform.js.map +1 -0
  40. package/dist/hooks/registrations/notification.d.ts +7 -0
  41. package/dist/hooks/registrations/notification.d.ts.map +1 -0
  42. package/dist/hooks/registrations/notification.js +34 -0
  43. package/dist/hooks/registrations/notification.js.map +1 -0
  44. package/dist/hooks/registrations/post-tool-use.d.ts +18 -0
  45. package/dist/hooks/registrations/post-tool-use.d.ts.map +1 -0
  46. package/dist/hooks/registrations/post-tool-use.js +198 -0
  47. package/dist/hooks/registrations/post-tool-use.js.map +1 -0
  48. package/dist/hooks/registrations/pre-tool-use.d.ts +11 -0
  49. package/dist/hooks/registrations/pre-tool-use.d.ts.map +1 -0
  50. package/dist/hooks/registrations/pre-tool-use.js +102 -0
  51. package/dist/hooks/registrations/pre-tool-use.js.map +1 -0
  52. package/dist/hooks/registrations/session-start.d.ts +7 -0
  53. package/dist/hooks/registrations/session-start.d.ts.map +1 -0
  54. package/dist/hooks/registrations/session-start.js +60 -0
  55. package/dist/hooks/registrations/session-start.js.map +1 -0
  56. package/dist/hooks/registrations/stop.d.ts +8 -0
  57. package/dist/hooks/registrations/stop.d.ts.map +1 -0
  58. package/dist/hooks/registrations/stop.js +28 -0
  59. package/dist/hooks/registrations/stop.js.map +1 -0
  60. package/dist/hooks/registrations/user-prompt-submit.d.ts +7 -0
  61. package/dist/hooks/registrations/user-prompt-submit.d.ts.map +1 -0
  62. package/dist/hooks/registrations/user-prompt-submit.js +114 -0
  63. package/dist/hooks/registrations/user-prompt-submit.js.map +1 -0
  64. package/dist/hooks/registry.d.ts +39 -0
  65. package/dist/hooks/registry.d.ts.map +1 -0
  66. package/dist/hooks/registry.js +58 -0
  67. package/dist/hooks/registry.js.map +1 -0
  68. package/dist/hooks/router.d.ts +31 -0
  69. package/dist/hooks/router.d.ts.map +1 -0
  70. package/dist/hooks/router.js +155 -0
  71. package/dist/hooks/router.js.map +1 -0
  72. package/dist/hooks/types.d.ts +102 -0
  73. package/dist/hooks/types.d.ts.map +1 -0
  74. package/dist/hooks/types.js +8 -0
  75. package/dist/hooks/types.js.map +1 -0
  76. package/dist/installer/default-config.d.ts +112 -0
  77. package/dist/installer/default-config.d.ts.map +1 -0
  78. package/dist/installer/default-config.js +153 -0
  79. package/dist/installer/default-config.js.map +1 -0
  80. package/dist/installer/hooks.d.ts +104 -0
  81. package/dist/installer/hooks.d.ts.map +1 -1
  82. package/dist/installer/hooks.js +80 -0
  83. package/dist/installer/hooks.js.map +1 -1
  84. package/dist/installer/index.d.ts +5 -1
  85. package/dist/installer/index.d.ts.map +1 -1
  86. package/dist/installer/index.js +2108 -2064
  87. package/dist/installer/index.js.map +1 -1
  88. package/dist/installer/migrate.d.ts +28 -0
  89. package/dist/installer/migrate.d.ts.map +1 -0
  90. package/dist/installer/migrate.js +99 -0
  91. package/dist/installer/migrate.js.map +1 -0
  92. package/dist/shared/types.d.ts +60 -0
  93. package/dist/shared/types.d.ts.map +1 -1
  94. package/package.json +3 -1
  95. package/.claude/agents/document-writer.md +0 -152
  96. package/.claude/agents/explore-medium.md +0 -25
  97. package/.claude/agents/explore.md +0 -86
  98. package/.claude/agents/frontend-engineer-high.md +0 -24
  99. package/.claude/agents/frontend-engineer-low.md +0 -23
  100. package/.claude/agents/frontend-engineer.md +0 -89
  101. package/.claude/agents/librarian-low.md +0 -22
  102. package/.claude/agents/librarian.md +0 -70
  103. package/.claude/agents/metis.md +0 -85
  104. package/.claude/agents/momus.md +0 -97
  105. package/.claude/agents/multimodal-looker.md +0 -39
  106. package/.claude/agents/olympian-high.md +0 -39
  107. package/.claude/agents/olympian-low.md +0 -29
  108. package/.claude/agents/olympian.md +0 -71
  109. package/.claude/agents/oracle-low.md +0 -23
  110. package/.claude/agents/oracle-medium.md +0 -28
  111. package/.claude/agents/oracle.md +0 -77
  112. package/.claude/agents/prometheus.md +0 -126
  113. package/.claude/agents/qa-tester.md +0 -220
  114. package/.claude/commands/analyze/skill.md +0 -14
  115. package/.claude/commands/analyze.md +0 -14
  116. package/.claude/commands/ascent/skill.md +0 -152
  117. package/.claude/commands/ascent.md +0 -152
  118. package/.claude/commands/cancel-ascent.md +0 -9
  119. package/.claude/commands/complete-plan.md +0 -101
  120. package/.claude/commands/deepinit.md +0 -114
  121. package/.claude/commands/deepsearch/skill.md +0 -15
  122. package/.claude/commands/deepsearch.md +0 -15
  123. package/.claude/commands/doctor.md +0 -190
  124. package/.claude/commands/olympus/skill.md +0 -82
  125. package/.claude/commands/olympus-default.md +0 -26
  126. package/.claude/commands/plan.md +0 -37
  127. package/.claude/commands/prometheus/skill.md +0 -41
  128. package/.claude/commands/prometheus.md +0 -41
  129. package/.claude/commands/review/skill.md +0 -40
  130. package/.claude/commands/review.md +0 -40
  131. package/.claude/commands/ultrawork/skill.md +0 -90
  132. package/.claude/commands/ultrawork.md +0 -90
  133. package/.claude/commands/update.md +0 -38
  134. package/dist/features/boulder-state/constants.d.ts +0 -20
  135. package/dist/features/boulder-state/constants.d.ts.map +0 -1
  136. package/dist/features/boulder-state/constants.js +0 -20
  137. package/dist/features/boulder-state/constants.js.map +0 -1
  138. package/dist/features/boulder-state/index.d.ts +0 -12
  139. package/dist/features/boulder-state/index.d.ts.map +0 -1
  140. package/dist/features/boulder-state/index.js +0 -13
  141. package/dist/features/boulder-state/index.js.map +0 -1
  142. package/dist/features/boulder-state/storage.d.ts +0 -58
  143. package/dist/features/boulder-state/storage.d.ts.map +0 -1
  144. package/dist/features/boulder-state/storage.js +0 -174
  145. package/dist/features/boulder-state/storage.js.map +0 -1
  146. package/dist/features/boulder-state/types.d.ts +0 -48
  147. package/dist/features/boulder-state/types.d.ts.map +0 -1
  148. package/dist/features/boulder-state/types.js +0 -10
  149. package/dist/features/boulder-state/types.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Stop Hook Registrations
3
+ *
4
+ * Hooks that fire when Claude Code is about to stop/idle.
5
+ * These hooks can prevent stopping if work remains.
6
+ */
7
+ export declare function registerStopHooks(): void;
8
+ //# sourceMappingURL=stop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../../src/hooks/registrations/stop.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,wBAAgB,iBAAiB,IAAI,IAAI,CAoBxC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Stop Hook Registrations
3
+ *
4
+ * Hooks that fire when Claude Code is about to stop/idle.
5
+ * These hooks can prevent stopping if work remains.
6
+ */
7
+ import { registerHook } from '../registry.js';
8
+ import { checkPersistentModes, createHookOutput } from '../persistent-mode/index.js';
9
+ export function registerStopHooks() {
10
+ // Persistent Mode (unified handler for ascent, ultrawork, todos)
11
+ registerHook({
12
+ name: 'persistentMode',
13
+ event: 'Stop',
14
+ priority: 10,
15
+ handler: async (ctx) => {
16
+ const sessionId = ctx.sessionId;
17
+ const directory = ctx.directory || process.cwd();
18
+ const result = await checkPersistentModes(sessionId, directory);
19
+ const output = createHookOutput(result);
20
+ return {
21
+ continue: output.continue,
22
+ message: output.message,
23
+ reason: output.reason
24
+ };
25
+ }
26
+ });
27
+ }
28
+ //# sourceMappingURL=stop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stop.js","sourceRoot":"","sources":["../../../src/hooks/registrations/stop.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAGrF,MAAM,UAAU,iBAAiB;IAC/B,iEAAiE;IACjE,YAAY,CAAC;QACX,IAAI,EAAE,gBAAgB;QACtB,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,KAAK,EAAE,GAAgB,EAAuB,EAAE;YACvD,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;YAChC,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAEjD,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAChE,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;YAExC,OAAO;gBACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * UserPromptSubmit Hook Registrations
3
+ *
4
+ * Hooks that fire when the user submits a prompt.
5
+ */
6
+ export declare function registerUserPromptSubmitHooks(): void;
7
+ //# sourceMappingURL=user-prompt-submit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-prompt-submit.d.ts","sourceRoot":"","sources":["../../../src/hooks/registrations/user-prompt-submit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkCH,wBAAgB,6BAA6B,IAAI,IAAI,CAuGpD"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * UserPromptSubmit Hook Registrations
3
+ *
4
+ * Hooks that fire when the user submits a prompt.
5
+ */
6
+ import { registerHook } from '../registry.js';
7
+ import { detectKeywordsWithType, removeCodeBlocks } from '../keyword-detector/index.js';
8
+ import { createAutoSlashCommandHook } from '../auto-slash-command/index.js';
9
+ import { createThinkModeHook } from '../think-mode/index.js';
10
+ import { activateUltrawork } from '../ultrawork-state/index.js';
11
+ import { ULTRAWORK_MESSAGE, ULTRATHINK_MESSAGE, SEARCH_MESSAGE, ANALYZE_MESSAGE } from '../../installer/hooks.js';
12
+ /**
13
+ * Extract prompt text from various input formats
14
+ */
15
+ function getPromptText(ctx) {
16
+ if (ctx.prompt) {
17
+ return ctx.prompt;
18
+ }
19
+ if (ctx.message?.content) {
20
+ return ctx.message.content;
21
+ }
22
+ if (ctx.parts) {
23
+ return ctx.parts
24
+ .filter(p => p.type === 'text' && p.text)
25
+ .map(p => p.text)
26
+ .join(' ');
27
+ }
28
+ return '';
29
+ }
30
+ export function registerUserPromptSubmitHooks() {
31
+ // Keyword Detector (highest priority - activates modes)
32
+ registerHook({
33
+ name: 'keywordDetector',
34
+ event: 'UserPromptSubmit',
35
+ priority: 10,
36
+ handler: (ctx) => {
37
+ const promptText = getPromptText(ctx);
38
+ if (!promptText) {
39
+ return { continue: true };
40
+ }
41
+ const cleanedText = removeCodeBlocks(promptText);
42
+ const keywords = detectKeywordsWithType(cleanedText);
43
+ if (keywords.length === 0) {
44
+ return { continue: true };
45
+ }
46
+ const hasUltrawork = keywords.some(k => k.type === 'ultrawork');
47
+ const hasUltrathink = keywords.some(k => k.type === 'ultrathink');
48
+ const hasSearch = keywords.some(k => k.type === 'search');
49
+ const hasAnalyze = keywords.some(k => k.type === 'analyze');
50
+ if (hasUltrawork) {
51
+ activateUltrawork(promptText, ctx.sessionId, ctx.directory || process.cwd());
52
+ return { continue: true, message: ULTRAWORK_MESSAGE };
53
+ }
54
+ if (hasUltrathink) {
55
+ return { continue: true, message: ULTRATHINK_MESSAGE };
56
+ }
57
+ if (hasSearch) {
58
+ return { continue: true, message: SEARCH_MESSAGE };
59
+ }
60
+ if (hasAnalyze) {
61
+ return { continue: true, message: ANALYZE_MESSAGE };
62
+ }
63
+ return { continue: true };
64
+ }
65
+ });
66
+ // Auto Slash Command (expand custom slash commands)
67
+ registerHook({
68
+ name: 'autoSlashCommand',
69
+ event: 'UserPromptSubmit',
70
+ priority: 20,
71
+ handler: (ctx) => {
72
+ if (!ctx.parts) {
73
+ return { continue: true };
74
+ }
75
+ const hook = createAutoSlashCommandHook();
76
+ const result = hook.processMessage({ sessionId: ctx.sessionId || '' }, ctx.parts);
77
+ if (result.detected && result.injectedMessage) {
78
+ return { continue: true, message: result.injectedMessage };
79
+ }
80
+ return { continue: true };
81
+ }
82
+ });
83
+ // Think Mode (activate extended thinking)
84
+ registerHook({
85
+ name: 'thinkMode',
86
+ event: 'UserPromptSubmit',
87
+ priority: 30,
88
+ handler: (ctx) => {
89
+ if (!ctx.message || !ctx.parts) {
90
+ return { continue: true };
91
+ }
92
+ const hook = createThinkModeHook();
93
+ const sessionId = ctx.sessionId || 'default';
94
+ // Build ThinkModeInput with proper types
95
+ const thinkModeInput = {
96
+ parts: ctx.parts,
97
+ message: {
98
+ model: ctx.message.model && ctx.message.model.providerId && ctx.message.model.modelId
99
+ ? { providerId: ctx.message.model.providerId, modelId: ctx.message.model.modelId }
100
+ : undefined
101
+ }
102
+ };
103
+ const state = hook.processChatParams(sessionId, thinkModeInput);
104
+ if (state.requested && state.modelSwitched) {
105
+ return {
106
+ continue: true,
107
+ message: '[Think Mode Activated] Switched to high-reasoning model variant.'
108
+ };
109
+ }
110
+ return { continue: true };
111
+ }
112
+ });
113
+ }
114
+ //# sourceMappingURL=user-prompt-submit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-prompt-submit.js","sourceRoot":"","sources":["../../../src/hooks/registrations/user-prompt-submit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAGlC;;GAEG;AACH,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AK,CAAC,OAAO,EAAE;wBAClF,CAAC,CAAC,SAAS;iBACd;aACF,CAAC;YAEF,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;YAEhE,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;gBAC3C,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,kEAAkE;iBAC5E,CAAC;YACJ,CAAC;YAED,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC5B,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Hook Registry
3
+ *
4
+ * Central registry for all hooks. Hooks are organized by event type
5
+ * and sorted by priority (lower runs first).
6
+ */
7
+ import type { HookDefinition, HookEvent } from './types.js';
8
+ /**
9
+ * Register a hook with the registry.
10
+ * Hooks are sorted by priority after registration.
11
+ *
12
+ * @param hook - The hook definition to register
13
+ */
14
+ export declare function registerHook(hook: HookDefinition): void;
15
+ /**
16
+ * Get all hooks registered for a specific event.
17
+ *
18
+ * @param event - The event type to get hooks for
19
+ * @returns Array of hooks sorted by priority
20
+ */
21
+ export declare function getHooksForEvent(event: HookEvent): HookDefinition[];
22
+ /**
23
+ * Get all registered hooks across all events.
24
+ *
25
+ * @returns Flat array of all hooks
26
+ */
27
+ export declare function getAllHooks(): HookDefinition[];
28
+ /**
29
+ * Clear all registered hooks.
30
+ * Primarily used for testing.
31
+ */
32
+ export declare function clearHooks(): void;
33
+ /**
34
+ * Get the count of hooks by event type.
35
+ *
36
+ * @returns Map of event type to hook count
37
+ */
38
+ export declare function getHookCounts(): Map<HookEvent, number>;
39
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/hooks/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5D;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAMvD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,cAAc,EAAE,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,cAAc,EAAE,CAE9C;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAEjC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAMtD"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Hook Registry
3
+ *
4
+ * Central registry for all hooks. Hooks are organized by event type
5
+ * and sorted by priority (lower runs first).
6
+ */
7
+ /** Map of event type to registered hooks */
8
+ const hooks = new Map();
9
+ /**
10
+ * Register a hook with the registry.
11
+ * Hooks are sorted by priority after registration.
12
+ *
13
+ * @param hook - The hook definition to register
14
+ */
15
+ export function registerHook(hook) {
16
+ const eventHooks = hooks.get(hook.event) || [];
17
+ eventHooks.push(hook);
18
+ // Sort by priority (lower first, default 100)
19
+ eventHooks.sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));
20
+ hooks.set(hook.event, eventHooks);
21
+ }
22
+ /**
23
+ * Get all hooks registered for a specific event.
24
+ *
25
+ * @param event - The event type to get hooks for
26
+ * @returns Array of hooks sorted by priority
27
+ */
28
+ export function getHooksForEvent(event) {
29
+ return hooks.get(event) || [];
30
+ }
31
+ /**
32
+ * Get all registered hooks across all events.
33
+ *
34
+ * @returns Flat array of all hooks
35
+ */
36
+ export function getAllHooks() {
37
+ return Array.from(hooks.values()).flat();
38
+ }
39
+ /**
40
+ * Clear all registered hooks.
41
+ * Primarily used for testing.
42
+ */
43
+ export function clearHooks() {
44
+ hooks.clear();
45
+ }
46
+ /**
47
+ * Get the count of hooks by event type.
48
+ *
49
+ * @returns Map of event type to hook count
50
+ */
51
+ export function getHookCounts() {
52
+ const counts = new Map();
53
+ for (const [event, eventHooks] of hooks) {
54
+ counts.set(event, eventHooks.length);
55
+ }
56
+ return counts;
57
+ }
58
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/hooks/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,4CAA4C;AAC5C,MAAM,KAAK,GAAqC,IAAI,GAAG,EAAE,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAoB;IAC/C,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC/C,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,8CAA8C;IAC9C,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC;IACrE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAgB;IAC/C,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC5C,KAAK,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,KAAK,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Hook Router
3
+ *
4
+ * Routes hook events to registered handlers with timeout protection,
5
+ * error isolation, and config-based enable/disable.
6
+ */
7
+ import type { HookContext, HookResult, HookEvent } from './types.js';
8
+ /**
9
+ * Route a hook event to all registered handlers.
10
+ *
11
+ * Execution:
12
+ * - Hooks are executed in priority order (lower first)
13
+ * - Each hook has a configurable timeout (default 100ms)
14
+ * - Failed hooks are logged and skipped (graceful degradation)
15
+ * - Messages from all hooks are aggregated
16
+ *
17
+ * @param event - The hook event type
18
+ * @param context - Context for the event
19
+ * @returns Aggregated result from all hooks
20
+ */
21
+ export declare function routeHook(event: HookEvent, context: HookContext): Promise<HookResult>;
22
+ /**
23
+ * Route a hook event and return just the continue decision.
24
+ * Convenience method for simple blocking checks.
25
+ *
26
+ * @param event - The hook event type
27
+ * @param context - Context for the event
28
+ * @returns Whether to continue
29
+ */
30
+ export declare function shouldContinue(event: HookEvent, context: HookContext): Promise<boolean>;
31
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/hooks/router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA6ErE;;;;;;;;;;;;GAYG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAuErB;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,OAAO,CAAC,CAGlB"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Hook Router
3
+ *
4
+ * Routes hook events to registered handlers with timeout protection,
5
+ * error isolation, and config-based enable/disable.
6
+ */
7
+ import { getHooksForEvent } from './registry.js';
8
+ import { loadConfig } from '../config/loader.js';
9
+ /**
10
+ * Get hook timeout from config (default 100ms).
11
+ */
12
+ function getHookTimeout(config) {
13
+ // Look for hooks.timeout or default to 100ms
14
+ const hooksConfig = config.hooks;
15
+ if (hooksConfig && typeof hooksConfig.timeoutMs === 'number') {
16
+ return hooksConfig.timeoutMs;
17
+ }
18
+ return 100;
19
+ }
20
+ /**
21
+ * Check if a specific hook is enabled in config.
22
+ */
23
+ function isHookEnabled(config, hookName) {
24
+ const hooksConfig = config.hooks;
25
+ // Check global hooks.enabled flag
26
+ if (hooksConfig && typeof hooksConfig.enabled === 'boolean' && !hooksConfig.enabled) {
27
+ return false;
28
+ }
29
+ // Check hook-specific config
30
+ if (hooksConfig && hookName in hooksConfig) {
31
+ const hookConfig = hooksConfig[hookName];
32
+ if (typeof hookConfig === 'object' && hookConfig !== null) {
33
+ const enabled = hookConfig.enabled;
34
+ if (typeof enabled === 'boolean') {
35
+ return enabled;
36
+ }
37
+ }
38
+ }
39
+ // Default to enabled
40
+ return true;
41
+ }
42
+ /**
43
+ * Execute a function with timeout protection.
44
+ *
45
+ * @param fn - Function to execute
46
+ * @param timeoutMs - Timeout in milliseconds
47
+ * @returns Result or null if timed out
48
+ */
49
+ async function executeWithTimeout(fn, timeoutMs) {
50
+ return Promise.race([
51
+ Promise.resolve(fn()),
52
+ new Promise((resolve) => setTimeout(() => resolve(null), timeoutMs))
53
+ ]);
54
+ }
55
+ /**
56
+ * Check if a tool name matches a hook matcher.
57
+ *
58
+ * @param matcher - String or RegExp matcher
59
+ * @param toolName - Tool name to match
60
+ * @returns Whether the tool matches
61
+ */
62
+ function matchesTool(matcher, toolName) {
63
+ if (!matcher || !toolName)
64
+ return true;
65
+ const regex = typeof matcher === 'string'
66
+ ? new RegExp(matcher, 'i')
67
+ : matcher;
68
+ return regex.test(toolName);
69
+ }
70
+ /**
71
+ * Route a hook event to all registered handlers.
72
+ *
73
+ * Execution:
74
+ * - Hooks are executed in priority order (lower first)
75
+ * - Each hook has a configurable timeout (default 100ms)
76
+ * - Failed hooks are logged and skipped (graceful degradation)
77
+ * - Messages from all hooks are aggregated
78
+ *
79
+ * @param event - The hook event type
80
+ * @param context - Context for the event
81
+ * @returns Aggregated result from all hooks
82
+ */
83
+ export async function routeHook(event, context) {
84
+ const config = loadConfig();
85
+ const hooks = getHooksForEvent(event);
86
+ const hookTimeout = getHookTimeout(config);
87
+ // Aggregate results
88
+ let shouldContinue = true;
89
+ const messages = [];
90
+ let reason;
91
+ let modifiedInput = context.toolInput;
92
+ let modifiedMessages = context.messages;
93
+ for (const hook of hooks) {
94
+ // Check if hook is globally or specifically disabled
95
+ if (!isHookEnabled(config, hook.name)) {
96
+ continue;
97
+ }
98
+ // Check matcher for tool hooks
99
+ if (!matchesTool(hook.matcher, context.toolName)) {
100
+ continue;
101
+ }
102
+ try {
103
+ const result = await executeWithTimeout(() => hook.handler({
104
+ ...context,
105
+ toolInput: modifiedInput,
106
+ messages: modifiedMessages
107
+ }), hookTimeout);
108
+ if (result === null) {
109
+ console.error(`[hook-router] ${hook.name} timed out after ${hookTimeout}ms`);
110
+ continue;
111
+ }
112
+ // Handle continue=false (block action)
113
+ if (!result.continue) {
114
+ shouldContinue = false;
115
+ reason = result.reason;
116
+ }
117
+ // Collect message if present
118
+ if (result.message) {
119
+ messages.push(result.message);
120
+ }
121
+ // Update modified input for subsequent hooks
122
+ if (result.modifiedInput !== undefined) {
123
+ modifiedInput = result.modifiedInput;
124
+ }
125
+ // Update modified messages for MessagesTransform hooks
126
+ if (result.modifiedMessages !== undefined) {
127
+ modifiedMessages = result.modifiedMessages;
128
+ }
129
+ }
130
+ catch (error) {
131
+ // Log error and continue to next hook (graceful degradation)
132
+ console.error(`[hook-router] ${hook.name} error:`, error);
133
+ }
134
+ }
135
+ return {
136
+ continue: shouldContinue,
137
+ message: messages.length > 0 ? messages.join('\n\n---\n\n') : undefined,
138
+ reason,
139
+ modifiedInput: modifiedInput !== context.toolInput ? modifiedInput : undefined,
140
+ modifiedMessages: modifiedMessages !== context.messages ? modifiedMessages : undefined
141
+ };
142
+ }
143
+ /**
144
+ * Route a hook event and return just the continue decision.
145
+ * Convenience method for simple blocking checks.
146
+ *
147
+ * @param event - The hook event type
148
+ * @param context - Context for the event
149
+ * @returns Whether to continue
150
+ */
151
+ export async function shouldContinue(event, context) {
152
+ const result = await routeHook(event, context);
153
+ return result.continue;
154
+ }
155
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/hooks/router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD;;GAEG;AACH,SAAS,cAAc,CAAC,MAAoB;IAC1C,6CAA6C;IAC7C,MAAM,WAAW,GAAI,MAAkC,CAAC,KAA4C,CAAC;IACrG,IAAI,WAAW,IAAI,OAAO,WAAW,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC7D,OAAO,WAAW,CAAC,SAAS,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,MAAoB,EAAE,QAAgB;IAC3D,MAAM,WAAW,GAAI,MAAkC,CAAC,KAA4C,CAAC;IAErG,kCAAkC;IAClC,IAAI,WAAW,IAAI,OAAO,WAAW,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QACpF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6BAA6B;IAC7B,IAAI,WAAW,IAAI,Q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Aa,KAAK,SAAS,EAAE,CAAC;gBACvC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;YACvC,CAAC;YAED,uDAAuD;YACvD,IAAI,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBAC1C,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;YAC7C,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,6DAA6D;YAC7D,OAAO,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,IAAI,SAAS,EAAE,KAAK,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,cAAc;QACxB,OAAO,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS;QACvE,MAAM;QACN,aAAa,EAAE,aAAa,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;QAC9E,gBAAgB,EAAE,gBAAgB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;KACvF,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,KAAgB,EAChB,OAAoB;IAEpB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzB,CAAC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Unified Hook Types for Olympus
3
+ *
4
+ * These types define the interface for the hook router system that
5
+ * routes Claude Code events to registered hooks.
6
+ */
7
+ /**
8
+ * Hook events that can be registered for.
9
+ * Maps to Claude Code's native hook system events.
10
+ */
11
+ export type HookEvent = 'UserPromptSubmit' | 'SessionStart' | 'Stop' | 'PreToolUse' | 'PostToolUse' | 'Notification' | 'MessagesTransform';
12
+ /**
13
+ * Context passed to hook handlers.
14
+ * Contains information about the current event being processed.
15
+ */
16
+ export interface HookContext {
17
+ /** Session identifier */
18
+ sessionId?: string;
19
+ /** Current working directory */
20
+ directory?: string;
21
+ /** Tool name (for PreToolUse/PostToolUse) */
22
+ toolName?: string;
23
+ /** Tool input parameters (for PreToolUse/PostToolUse) */
24
+ toolInput?: unknown;
25
+ /** Tool output result (for PostToolUse) */
26
+ toolOutput?: unknown;
27
+ /** User prompt text (for UserPromptSubmit) */
28
+ prompt?: string;
29
+ /** Message content with model info (for UserPromptSubmit) */
30
+ message?: {
31
+ content?: string;
32
+ model?: {
33
+ modelId?: string;
34
+ providerId?: string;
35
+ };
36
+ };
37
+ /** Message parts array (for UserPromptSubmit) */
38
+ parts?: Array<{
39
+ type: string;
40
+ text?: string;
41
+ }>;
42
+ /** Messages array (for MessagesTransform) */
43
+ messages?: Array<unknown>;
44
+ /** Notification event data (for Notification) */
45
+ event?: {
46
+ type: string;
47
+ properties?: unknown;
48
+ };
49
+ }
50
+ /**
51
+ * Result returned by hook handlers.
52
+ */
53
+ export interface HookResult {
54
+ /** Whether to continue processing (false blocks the action) */
55
+ continue: boolean;
56
+ /** Message to inject into the conversation */
57
+ message?: string;
58
+ /** Reason for blocking (when continue is false) */
59
+ reason?: string;
60
+ /** Modified tool input (for PreToolUse hooks that modify input) */
61
+ modifiedInput?: unknown;
62
+ /** Modified messages (for MessagesTransform hooks) */
63
+ modifiedMessages?: Array<unknown>;
64
+ }
65
+ /**
66
+ * Definition of a hook that can be registered with the router.
67
+ */
68
+ export interface HookDefinition {
69
+ /** Unique name for the hook (used for config enable/disable) */
70
+ name: string;
71
+ /** Event this hook responds to */
72
+ event: HookEvent;
73
+ /** Optional regex or string matcher for tool-specific hooks */
74
+ matcher?: string | RegExp;
75
+ /** Priority (lower runs first, default 100) */
76
+ priority?: number;
77
+ /** Whether the hook is enabled (defaults to true) */
78
+ enabled?: boolean;
79
+ /** The handler function */
80
+ handler: (ctx: HookContext) => Promise<HookResult> | HookResult;
81
+ }
82
+ /**
83
+ * Per-hook configuration options.
84
+ */
85
+ export interface HookOptions {
86
+ /** Whether the hook is enabled */
87
+ enabled?: boolean;
88
+ /** Hook-specific options */
89
+ [key: string]: unknown;
90
+ }
91
+ /**
92
+ * Global hook configuration.
93
+ */
94
+ export interface HooksConfig {
95
+ /** Global hook enable/disable */
96
+ enabled?: boolean;
97
+ /** Individual hook timeout in milliseconds (default: 100) */
98
+ hookTimeoutMs?: number;
99
+ /** Per-hook configuration keyed by hook name */
100
+ [hookName: string]: HookOptions | boolean | number | undefined;
101
+ }
102
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hooks/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,MAAM,SAAS,GACjB,kBAAkB,GAClB,cAAc,GACd,MAAM,GACN,YAAY,GACZ,aAAa,GACb,cAAc,GACd,mBAAmB,CAAC;AAExB;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAC;YAAC,UAAU,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAClF,iDAAiD;IACjD,KA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ACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;CAChE"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Unified Hook Types for Olympus
3
+ *
4
+ * These types define the interface for the hook router system that
5
+ * routes Claude Code events to registered hooks.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/hooks/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}