oh-my-claude-sisyphus 1.4.1 → 1.6.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/dist/agents/document-writer.d.ts +11 -0
- package/dist/agents/document-writer.d.ts.map +1 -0
- package/dist/agents/document-writer.js +209 -0
- package/dist/agents/document-writer.js.map +1 -0
- package/dist/agents/explore.d.ts +12 -0
- package/dist/agents/explore.d.ts.map +1 -0
- package/dist/agents/explore.js +103 -0
- package/dist/agents/explore.js.map +1 -0
- package/dist/agents/frontend-engineer.d.ts +11 -0
- package/dist/agents/frontend-engineer.d.ts.map +1 -0
- package/dist/agents/frontend-engineer.js +115 -0
- package/dist/agents/frontend-engineer.js.map +1 -0
- package/dist/agents/index.d.ts +17 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +21 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/librarian.d.ts +12 -0
- package/dist/agents/librarian.d.ts.map +1 -0
- package/dist/agents/librarian.js +103 -0
- package/dist/agents/librarian.js.map +1 -0
- package/dist/agents/metis.d.ts +12 -0
- package/dist/agents/metis.d.ts.map +1 -0
- package/dist/agents/metis.js +117 -0
- package/dist/agents/metis.js.map +1 -0
- package/dist/agents/momus.d.ts +12 -0
- package/dist/agents/momus.d.ts.map +1 -0
- package/dist/agents/momus.js +128 -0
- package/dist/agents/momus.js.map +1 -0
- package/dist/agents/multimodal-looker.d.ts +11 -0
- package/dist/agents/multimodal-looker.d.ts.map +1 -0
- package/dist/agents/multimodal-looker.js +70 -0
- package/dist/agents/multimodal-looker.js.map +1 -0
- package/dist/agents/oracle.d.ts +13 -0
- package/dist/agents/oracle.d.ts.map +1 -0
- package/dist/agents/oracle.js +149 -0
- package/dist/agents/oracle.js.map +1 -0
- package/dist/agents/orchestrator-sisyphus.d.ts +11 -0
- package/dist/agents/orchestrator-sisyphus.d.ts.map +1 -0
- package/dist/agents/orchestrator-sisyphus.js +115 -0
- package/dist/agents/orchestrator-sisyphus.js.map +1 -0
- package/dist/agents/prometheus.d.ts +12 -0
- package/dist/agents/prometheus.d.ts.map +1 -0
- package/dist/agents/prometheus.js +156 -0
- package/dist/agents/prometheus.js.map +1 -0
- package/dist/agents/sisyphus-junior.d.ts +12 -0
- package/dist/agents/sisyphus-junior.d.ts.map +1 -0
- package/dist/agents/sisyphus-junior.js +93 -0
- package/dist/agents/sisyphus-junior.js.map +1 -0
- package/dist/agents/types.d.ts +120 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +38 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/agents/utils.d.ts +49 -0
- package/dist/agents/utils.d.ts.map +1 -0
- package/dist/agents/utils.js +164 -0
- package/dist/agents/utils.js.map +1 -0
- package/dist/features/auto-update.d.ts +52 -0
- package/dist/features/auto-update.d.ts.map +1 -1
- package/dist/features/auto-update.js +167 -0
- package/dist/features/auto-update.js.map +1 -1
- package/dist/features/background-agent/concurrency.d.ts +53 -0
- package/dist/features/background-agent/concurrency.d.ts.map +1 -0
- package/dist/features/background-agent/concurrency.js +121 -0
- package/dist/features/background-agent/concurrency.js.map +1 -0
- package/dist/features/background-agent/index.d.ts +12 -0
- package/dist/features/background-agent/index.d.ts.map +1 -0
- package/dist/features/background-agent/index.js +12 -0
- package/dist/features/background-agent/index.js.map +1 -0
- package/dist/features/background-agent/manager.d.ts +134 -0
- package/dist/features/background-agent/manager.d.ts.map +1 -0
- package/dist/features/background-agent/manager.js +412 -0
- package/dist/features/background-agent/manager.js.map +1 -0
- package/dist/features/background-agent/types.d.ts +99 -0
- package/dist/features/background-agent/types.d.ts.map +1 -0
- package/dist/features/background-agent/types.js +9 -0
- package/dist/features/background-agent/types.js.map +1 -0
- package/dist/features/boulder-state/constants.d.ts +20 -0
- package/dist/features/boulder-state/constants.d.ts.map +1 -0
- package/dist/features/boulder-state/constants.js +20 -0
- package/dist/features/boulder-state/constants.js.map +1 -0
- package/dist/features/boulder-state/index.d.ts +12 -0
- package/dist/features/boulder-state/index.d.ts.map +1 -0
- package/dist/features/boulder-state/index.js +13 -0
- package/dist/features/boulder-state/index.js.map +1 -0
- package/dist/features/boulder-state/storage.d.ts +58 -0
- package/dist/features/boulder-state/storage.d.ts.map +1 -0
- package/dist/features/boulder-state/storage.js +174 -0
- package/dist/features/boulder-state/storage.js.map +1 -0
- package/dist/features/boulder-state/types.d.ts +48 -0
- package/dist/features/boulder-state/types.d.ts.map +1 -0
- package/dist/features/boulder-state/types.js +10 -0
- package/dist/features/boulder-state/types.js.map +1 -0
- package/dist/features/builtin-skills/index.d.ts +10 -0
- package/dist/features/builtin-skills/index.d.ts.map +1 -0
- package/dist/features/builtin-skills/index.js +10 -0
- package/dist/features/builtin-skills/index.js.map +1 -0
- package/dist/features/builtin-skills/skills.d.ts +21 -0
- package/dist/features/builtin-skills/skills.d.ts.map +1 -0
- package/dist/features/builtin-skills/skills.js +367 -0
- package/dist/features/builtin-skills/skills.js.map +1 -0
- package/dist/features/builtin-skills/types.d.ts +60 -0
- package/dist/features/builtin-skills/types.d.ts.map +1 -0
- package/dist/features/builtin-skills/types.js +9 -0
- package/dist/features/builtin-skills/types.js.map +1 -0
- package/dist/features/context-injector/collector.d.ts +56 -0
- package/dist/features/context-injector/collector.d.ts.map +1 -0
- package/dist/features/context-injector/collector.js +122 -0
- package/dist/features/context-injector/collector.js.map +1 -0
- package/dist/features/context-injector/index.d.ts +12 -0
- package/dist/features/context-injector/index.d.ts.map +1 -0
- package/dist/features/context-injector/index.js +13 -0
- package/dist/features/context-injector/index.js.map +1 -0
- package/dist/features/context-injector/injector.d.ts +47 -0
- package/dist/features/context-injector/injector.d.ts.map +1 -0
- package/dist/features/context-injector/injector.js +103 -0
- package/dist/features/context-injector/injector.js.map +1 -0
- package/dist/features/context-injector/types.d.ts +103 -0
- package/dist/features/context-injector/types.d.ts.map +1 -0
- package/dist/features/context-injector/types.js +11 -0
- package/dist/features/context-injector/types.js.map +1 -0
- package/dist/features/index.d.ts +5 -1
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/index.js +25 -1
- package/dist/features/index.js.map +1 -1
- package/dist/hooks/agent-usage-reminder/constants.d.ts +17 -0
- package/dist/hooks/agent-usage-reminder/constants.d.ts.map +1 -0
- package/dist/hooks/agent-usage-reminder/constants.js +58 -0
- package/dist/hooks/agent-usage-reminder/constants.js.map +1 -0
- package/dist/hooks/agent-usage-reminder/index.d.ts +36 -0
- package/dist/hooks/agent-usage-reminder/index.d.ts.map +1 -0
- package/dist/hooks/agent-usage-reminder/index.js +89 -0
- package/dist/hooks/agent-usage-reminder/index.js.map +1 -0
- package/dist/hooks/agent-usage-reminder/storage.d.ts +12 -0
- package/dist/hooks/agent-usage-reminder/storage.d.ts.map +1 -0
- package/dist/hooks/agent-usage-reminder/storage.js +39 -0
- package/dist/hooks/agent-usage-reminder/storage.js.map +1 -0
- package/dist/hooks/agent-usage-reminder/types.d.ts +14 -0
- package/dist/hooks/agent-usage-reminder/types.d.ts.map +1 -0
- package/dist/hooks/agent-usage-reminder/types.js +9 -0
- package/dist/hooks/agent-usage-reminder/types.js.map +1 -0
- package/dist/hooks/auto-slash-command/constants.d.ts +19 -0
- package/dist/hooks/auto-slash-command/constants.d.ts.map +1 -0
- package/dist/hooks/auto-slash-command/constants.js +28 -0
- package/dist/hooks/auto-slash-command/constants.js.map +1 -0
- package/dist/hooks/auto-slash-command/detector.d.ts +33 -0
- package/dist/hooks/auto-slash-command/detector.d.ts.map +1 -0
- package/dist/hooks/auto-slash-command/detector.js +73 -0
- package/dist/hooks/auto-slash-command/detector.js.map +1 -0
- package/dist/hooks/auto-slash-command/executor.d.ts +29 -0
- package/dist/hooks/auto-slash-command/executor.d.ts.map +1 -0
- package/dist/hooks/auto-slash-command/executor.js +214 -0
- package/dist/hooks/auto-slash-command/executor.js.map +1 -0
- package/dist/hooks/auto-slash-command/index.d.ts +53 -0
- package/dist/hooks/auto-slash-command/index.d.ts.map +1 -0
- package/dist/hooks/auto-slash-command/index.js +105 -0
- package/dist/hooks/auto-slash-command/index.js.map +1 -0
- package/dist/hooks/auto-slash-command/types.d.ts +77 -0
- package/dist/hooks/auto-slash-command/types.d.ts.map +1 -0
- package/dist/hooks/auto-slash-command/types.js +9 -0
- package/dist/hooks/auto-slash-command/types.js.map +1 -0
- package/dist/hooks/background-notification/index.d.ts +60 -0
- package/dist/hooks/background-notification/index.d.ts.map +1 -0
- package/dist/hooks/background-notification/index.js +180 -0
- package/dist/hooks/background-notification/index.js.map +1 -0
- package/dist/hooks/background-notification/types.d.ts +64 -0
- package/dist/hooks/background-notification/types.d.ts.map +1 -0
- package/dist/hooks/background-notification/types.js +8 -0
- package/dist/hooks/background-notification/types.js.map +1 -0
- package/dist/hooks/bridge.d.ts +68 -0
- package/dist/hooks/bridge.d.ts.map +1 -0
- package/dist/hooks/bridge.js +225 -0
- package/dist/hooks/bridge.js.map +1 -0
- package/dist/hooks/comment-checker/constants.d.ts +28 -0
- package/dist/hooks/comment-checker/constants.d.ts.map +1 -0
- package/dist/hooks/comment-checker/constants.js +189 -0
- package/dist/hooks/comment-checker/constants.js.map +1 -0
- package/dist/hooks/comment-checker/filters.d.ts +39 -0
- package/dist/hooks/comment-checker/filters.d.ts.map +1 -0
- package/dist/hooks/comment-checker/filters.js +126 -0
- package/dist/hooks/comment-checker/filters.js.map +1 -0
- package/dist/hooks/comment-checker/index.d.ts +58 -0
- package/dist/hooks/comment-checker/index.d.ts.map +1 -0
- package/dist/hooks/comment-checker/index.js +298 -0
- package/dist/hooks/comment-checker/index.js.map +1 -0
- package/dist/hooks/comment-checker/types.d.ts +88 -0
- package/dist/hooks/comment-checker/types.d.ts.map +1 -0
- package/dist/hooks/comment-checker/types.js +9 -0
- package/dist/hooks/comment-checker/types.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/constants.d.ts +28 -0
- package/dist/hooks/context-window-limit-recovery/constants.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/constants.js +85 -0
- package/dist/hooks/context-window-limit-recovery/constants.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/index.d.ts +62 -0
- package/dist/hooks/context-window-limit-recovery/index.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/index.js +201 -0
- package/dist/hooks/context-window-limit-recovery/index.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/parser.d.ts +31 -0
- package/dist/hooks/context-window-limit-recovery/parser.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/parser.js +241 -0
- package/dist/hooks/context-window-limit-recovery/parser.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/types.d.ts +84 -0
- package/dist/hooks/context-window-limit-recovery/types.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/types.js +34 -0
- package/dist/hooks/context-window-limit-recovery/types.js.map +1 -0
- package/dist/hooks/directory-readme-injector/constants.d.ts +15 -0
- package/dist/hooks/directory-readme-injector/constants.d.ts.map +1 -0
- package/dist/hooks/directory-readme-injector/constants.js +17 -0
- package/dist/hooks/directory-readme-injector/constants.js.map +1 -0
- package/dist/hooks/directory-readme-injector/index.d.ts +41 -0
- package/dist/hooks/directory-readme-injector/index.d.ts.map +1 -0
- package/dist/hooks/directory-readme-injector/index.js +162 -0
- package/dist/hooks/directory-readme-injector/index.js.map +1 -0
- package/dist/hooks/directory-readme-injector/storage.d.ts +20 -0
- package/dist/hooks/directory-readme-injector/storage.d.ts.map +1 -0
- package/dist/hooks/directory-readme-injector/storage.js +56 -0
- package/dist/hooks/directory-readme-injector/storage.js.map +1 -0
- package/dist/hooks/directory-readme-injector/types.d.ts +20 -0
- package/dist/hooks/directory-readme-injector/types.d.ts.map +1 -0
- package/dist/hooks/directory-readme-injector/types.js +9 -0
- package/dist/hooks/directory-readme-injector/types.js.map +1 -0
- package/dist/hooks/edit-error-recovery/index.d.ts +62 -0
- package/dist/hooks/edit-error-recovery/index.d.ts.map +1 -0
- package/dist/hooks/edit-error-recovery/index.js +89 -0
- package/dist/hooks/edit-error-recovery/index.js.map +1 -0
- package/dist/hooks/empty-message-sanitizer/constants.d.ts +33 -0
- package/dist/hooks/empty-message-sanitizer/constants.d.ts.map +1 -0
- package/dist/hooks/empty-message-sanitizer/constants.js +37 -0
- package/dist/hooks/empty-message-sanitizer/constants.js.map +1 -0
- package/dist/hooks/empty-message-sanitizer/index.d.ts +59 -0
- package/dist/hooks/empty-message-sanitizer/index.d.ts.map +1 -0
- package/dist/hooks/empty-message-sanitizer/index.js +171 -0
- package/dist/hooks/empty-message-sanitizer/index.js.map +1 -0
- package/dist/hooks/empty-message-sanitizer/types.d.ts +79 -0
- package/dist/hooks/empty-message-sanitizer/types.d.ts.map +1 -0
- package/dist/hooks/empty-message-sanitizer/types.js +10 -0
- package/dist/hooks/empty-message-sanitizer/types.js.map +1 -0
- package/dist/hooks/index.d.ts +31 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +69 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/keyword-detector/index.d.ts +40 -0
- package/dist/hooks/keyword-detector/index.d.ts.map +1 -0
- package/dist/hooks/keyword-detector/index.js +88 -0
- package/dist/hooks/keyword-detector/index.js.map +1 -0
- package/dist/hooks/non-interactive-env/constants.d.ts +35 -0
- package/dist/hooks/non-interactive-env/constants.d.ts.map +1 -0
- package/dist/hooks/non-interactive-env/constants.js +69 -0
- package/dist/hooks/non-interactive-env/constants.js.map +1 -0
- package/dist/hooks/non-interactive-env/detector.d.ts +2 -0
- package/dist/hooks/non-interactive-env/detector.d.ts.map +1 -0
- package/dist/hooks/non-interactive-env/detector.js +16 -0
- package/dist/hooks/non-interactive-env/detector.js.map +1 -0
- package/dist/hooks/non-interactive-env/index.d.ts +14 -0
- package/dist/hooks/non-interactive-env/index.d.ts.map +1 -0
- package/dist/hooks/non-interactive-env/index.js +72 -0
- package/dist/hooks/non-interactive-env/index.js.map +1 -0
- package/dist/hooks/non-interactive-env/types.d.ts +14 -0
- package/dist/hooks/non-interactive-env/types.d.ts.map +1 -0
- package/dist/hooks/non-interactive-env/types.js +2 -0
- package/dist/hooks/non-interactive-env/types.js.map +1 -0
- package/dist/hooks/preemptive-compaction/constants.d.ts +48 -0
- package/dist/hooks/preemptive-compaction/constants.d.ts.map +1 -0
- package/dist/hooks/preemptive-compaction/constants.js +90 -0
- package/dist/hooks/preemptive-compaction/constants.js.map +1 -0
- package/dist/hooks/preemptive-compaction/index.d.ts +55 -0
- package/dist/hooks/preemptive-compaction/index.d.ts.map +1 -0
- package/dist/hooks/preemptive-compaction/index.js +237 -0
- package/dist/hooks/preemptive-compaction/index.js.map +1 -0
- package/dist/hooks/preemptive-compaction/types.d.ts +76 -0
- package/dist/hooks/preemptive-compaction/types.d.ts.map +1 -0
- package/dist/hooks/preemptive-compaction/types.js +9 -0
- package/dist/hooks/preemptive-compaction/types.js.map +1 -0
- package/dist/hooks/ralph-loop/index.d.ts +60 -0
- package/dist/hooks/ralph-loop/index.d.ts.map +1 -0
- package/dist/hooks/ralph-loop/index.js +155 -0
- package/dist/hooks/ralph-loop/index.js.map +1 -0
- package/dist/hooks/rules-injector/constants.d.ts +25 -0
- package/dist/hooks/rules-injector/constants.d.ts.map +1 -0
- package/dist/hooks/rules-injector/constants.js +40 -0
- package/dist/hooks/rules-injector/constants.js.map +1 -0
- package/dist/hooks/rules-injector/finder.d.ts +24 -0
- package/dist/hooks/rules-injector/finder.d.ts.map +1 -0
- package/dist/hooks/rules-injector/finder.js +215 -0
- package/dist/hooks/rules-injector/finder.js.map +1 -0
- package/dist/hooks/rules-injector/index.d.ts +45 -0
- package/dist/hooks/rules-injector/index.d.ts.map +1 -0
- package/dist/hooks/rules-injector/index.js +187 -0
- package/dist/hooks/rules-injector/index.js.map +1 -0
- package/dist/hooks/rules-injector/matcher.d.ts +25 -0
- package/dist/hooks/rules-injector/matcher.d.ts.map +1 -0
- package/dist/hooks/rules-injector/matcher.js +70 -0
- package/dist/hooks/rules-injector/matcher.js.map +1 -0
- package/dist/hooks/rules-injector/parser.d.ts +20 -0
- package/dist/hooks/rules-injector/parser.d.ts.map +1 -0
- package/dist/hooks/rules-injector/parser.js +179 -0
- package/dist/hooks/rules-injector/parser.js.map +1 -0
- package/dist/hooks/rules-injector/storage.d.ts +26 -0
- package/dist/hooks/rules-injector/storage.d.ts.map +1 -0
- package/dist/hooks/rules-injector/storage.js +61 -0
- package/dist/hooks/rules-injector/storage.js.map +1 -0
- package/dist/hooks/rules-injector/types.d.ts +101 -0
- package/dist/hooks/rules-injector/types.d.ts.map +1 -0
- package/dist/hooks/rules-injector/types.js +10 -0
- package/dist/hooks/rules-injector/types.js.map +1 -0
- package/dist/hooks/session-recovery/constants.d.ts +56 -0
- package/dist/hooks/session-recovery/constants.d.ts.map +1 -0
- package/dist/hooks/session-recovery/constants.js +78 -0
- package/dist/hooks/session-recovery/constants.js.map +1 -0
- package/dist/hooks/session-recovery/index.d.ts +53 -0
- package/dist/hooks/session-recovery/index.d.ts.map +1 -0
- package/dist/hooks/session-recovery/index.js +321 -0
- package/dist/hooks/session-recovery/index.js.map +1 -0
- package/dist/hooks/session-recovery/storage.d.ts +76 -0
- package/dist/hooks/session-recovery/storage.d.ts.map +1 -0
- package/dist/hooks/session-recovery/storage.js +383 -0
- package/dist/hooks/session-recovery/storage.js.map +1 -0
- package/dist/hooks/session-recovery/types.d.ts +145 -0
- package/dist/hooks/session-recovery/types.d.ts.map +1 -0
- package/dist/hooks/session-recovery/types.js +8 -0
- package/dist/hooks/session-recovery/types.js.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/constants.d.ts +23 -0
- package/dist/hooks/sisyphus-orchestrator/constants.d.ts.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/constants.js +142 -0
- package/dist/hooks/sisyphus-orchestrator/constants.js.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/index.d.ts +113 -0
- package/dist/hooks/sisyphus-orchestrator/index.d.ts.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/index.js +283 -0
- package/dist/hooks/sisyphus-orchestrator/index.js.map +1 -0
- package/dist/hooks/think-mode/detector.d.ts +28 -0
- package/dist/hooks/think-mode/detector.d.ts.map +1 -0
- package/dist/hooks/think-mode/detector.js +105 -0
- package/dist/hooks/think-mode/detector.js.map +1 -0
- package/dist/hooks/think-mode/index.d.ts +70 -0
- package/dist/hooks/think-mode/index.d.ts.map +1 -0
- package/dist/hooks/think-mode/index.js +144 -0
- package/dist/hooks/think-mode/index.js.map +1 -0
- package/dist/hooks/think-mode/switcher.d.ts +39 -0
- package/dist/hooks/think-mode/switcher.d.ts.map +1 -0
- package/dist/hooks/think-mode/switcher.js +180 -0
- package/dist/hooks/think-mode/switcher.js.map +1 -0
- package/dist/hooks/think-mode/types.d.ts +60 -0
- package/dist/hooks/think-mode/types.d.ts.map +1 -0
- package/dist/hooks/think-mode/types.js +9 -0
- package/dist/hooks/think-mode/types.js.map +1 -0
- package/dist/hooks/thinking-block-validator/constants.d.ts +37 -0
- package/dist/hooks/thinking-block-validator/constants.d.ts.map +1 -0
- package/dist/hooks/thinking-block-validator/constants.js +50 -0
- package/dist/hooks/thinking-block-validator/constants.js.map +1 -0
- package/dist/hooks/thinking-block-validator/index.d.ts +66 -0
- package/dist/hooks/thinking-block-validator/index.d.ts.map +1 -0
- package/dist/hooks/thinking-block-validator/index.js +205 -0
- package/dist/hooks/thinking-block-validator/index.js.map +1 -0
- package/dist/hooks/thinking-block-validator/types.d.ts +67 -0
- package/dist/hooks/thinking-block-validator/types.d.ts.map +1 -0
- package/dist/hooks/thinking-block-validator/types.js +9 -0
- package/dist/hooks/thinking-block-validator/types.js.map +1 -0
- package/dist/hooks/todo-continuation/index.d.ts +39 -0
- package/dist/hooks/todo-continuation/index.d.ts.map +1 -0
- package/dist/hooks/todo-continuation/index.js +140 -0
- package/dist/hooks/todo-continuation/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/installer/index.d.ts +1 -1
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +232 -1
- package/dist/installer/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install.sh +181 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/hooks/directory-readme-injector/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,4DAA4D;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CACzC,oBAAoB,EACpB,kBAAkB,CACnB,CAAC;AAEF,oCAAoC;AACpC,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAE3C,0CAA0C;AAC1C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directory README Injector Hook
|
|
3
|
+
*
|
|
4
|
+
* Automatically injects relevant README content from directories when files are accessed.
|
|
5
|
+
* Walks up the directory tree from accessed files to find and inject README.md files.
|
|
6
|
+
*
|
|
7
|
+
* Ported from oh-my-opencode's directory-readme-injector hook.
|
|
8
|
+
* Adapted for Claude Code's shell hook system.
|
|
9
|
+
*/
|
|
10
|
+
export * from './types.js';
|
|
11
|
+
export * from './constants.js';
|
|
12
|
+
export * from './storage.js';
|
|
13
|
+
/**
|
|
14
|
+
* Create directory README injector hook for Claude Code.
|
|
15
|
+
*
|
|
16
|
+
* @param workingDirectory - The working directory for resolving paths
|
|
17
|
+
* @returns Hook handlers for tool execution
|
|
18
|
+
*/
|
|
19
|
+
export declare function createDirectoryReadmeInjectorHook(workingDirectory: string): {
|
|
20
|
+
/**
|
|
21
|
+
* Process a tool execution and inject READMEs if relevant.
|
|
22
|
+
*/
|
|
23
|
+
processToolExecution: (toolName: string, filePath: string, sessionID: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Get READMEs for a specific file without marking as injected.
|
|
26
|
+
*/
|
|
27
|
+
getReadmesForFile: (filePath: string) => string[];
|
|
28
|
+
/**
|
|
29
|
+
* Clear session cache when session ends.
|
|
30
|
+
*/
|
|
31
|
+
clearSession: (sessionID: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Check if a tool triggers README injection.
|
|
34
|
+
*/
|
|
35
|
+
isTrackedTool: (toolName: string) => boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Get README paths for a file (simple utility function).
|
|
39
|
+
*/
|
|
40
|
+
export declare function getReadmesForPath(filePath: string, workingDirectory?: string): string[];
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/directory-readme-injector/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAsC7B;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,gBAAgB,EAAE,MAAM;IAyFtE;;OAEG;qCAES,MAAM,YACN,MAAM,aACL,MAAM,KAChB,MAAM;IAQT;;OAEG;kCAC2B,MAAM,KAAG,MAAM,EAAE;IAQ/C;;OAEG;8BACuB,MAAM,KAAG,IAAI;IAKvC;;OAEG;8BACuB,MAAM,KAAG,OAAO;EAI7C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,MAAM,GACxB,MAAM,EAAE,CAIV"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directory README Injector Hook
|
|
3
|
+
*
|
|
4
|
+
* Automatically injects relevant README content from directories when files are accessed.
|
|
5
|
+
* Walks up the directory tree from accessed files to find and inject README.md files.
|
|
6
|
+
*
|
|
7
|
+
* Ported from oh-my-opencode's directory-readme-injector hook.
|
|
8
|
+
* Adapted for Claude Code's shell hook system.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
11
|
+
import { dirname, join, resolve } from 'node:path';
|
|
12
|
+
import { loadInjectedPaths, saveInjectedPaths, clearInjectedPaths, } from './storage.js';
|
|
13
|
+
import { README_FILENAME, TRACKED_TOOLS } from './constants.js';
|
|
14
|
+
// Re-export submodules
|
|
15
|
+
export * from './types.js';
|
|
16
|
+
export * from './constants.js';
|
|
17
|
+
export * from './storage.js';
|
|
18
|
+
/**
|
|
19
|
+
* Simple token estimation (4 chars per token)
|
|
20
|
+
*/
|
|
21
|
+
const CHARS_PER_TOKEN = 4;
|
|
22
|
+
const DEFAULT_MAX_README_TOKENS = 5000;
|
|
23
|
+
/**
|
|
24
|
+
* Simple truncation for README content
|
|
25
|
+
*/
|
|
26
|
+
function truncateContent(content, maxTokens = DEFAULT_MAX_README_TOKENS) {
|
|
27
|
+
const estimatedTokens = Math.ceil(content.length / CHARS_PER_TOKEN);
|
|
28
|
+
if (estimatedTokens <= maxTokens) {
|
|
29
|
+
return { result: content, truncated: false };
|
|
30
|
+
}
|
|
31
|
+
const maxChars = maxTokens * CHARS_PER_TOKEN;
|
|
32
|
+
const truncated = content.slice(0, maxChars);
|
|
33
|
+
return {
|
|
34
|
+
result: truncated,
|
|
35
|
+
truncated: true,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create directory README injector hook for Claude Code.
|
|
40
|
+
*
|
|
41
|
+
* @param workingDirectory - The working directory for resolving paths
|
|
42
|
+
* @returns Hook handlers for tool execution
|
|
43
|
+
*/
|
|
44
|
+
export function createDirectoryReadmeInjectorHook(workingDirectory) {
|
|
45
|
+
const sessionCaches = new Map();
|
|
46
|
+
function getSessionCache(sessionID) {
|
|
47
|
+
if (!sessionCaches.has(sessionID)) {
|
|
48
|
+
sessionCaches.set(sessionID, loadInjectedPaths(sessionID));
|
|
49
|
+
}
|
|
50
|
+
return sessionCaches.get(sessionID);
|
|
51
|
+
}
|
|
52
|
+
function resolveFilePath(path) {
|
|
53
|
+
if (!path)
|
|
54
|
+
return null;
|
|
55
|
+
if (path.startsWith('/'))
|
|
56
|
+
return path;
|
|
57
|
+
return resolve(workingDirectory, path);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Find README.md files by walking up the directory tree.
|
|
61
|
+
* Returns paths in order from root to leaf.
|
|
62
|
+
*/
|
|
63
|
+
function findReadmeMdUp(startDir) {
|
|
64
|
+
const found = [];
|
|
65
|
+
let current = startDir;
|
|
66
|
+
while (true) {
|
|
67
|
+
const readmePath = join(current, README_FILENAME);
|
|
68
|
+
if (existsSync(readmePath)) {
|
|
69
|
+
found.push(readmePath);
|
|
70
|
+
}
|
|
71
|
+
// Stop at working directory root
|
|
72
|
+
if (current === workingDirectory)
|
|
73
|
+
break;
|
|
74
|
+
const parent = dirname(current);
|
|
75
|
+
// Stop at filesystem root
|
|
76
|
+
if (parent === current)
|
|
77
|
+
break;
|
|
78
|
+
// Stop if we've gone outside the working directory
|
|
79
|
+
if (!parent.startsWith(workingDirectory))
|
|
80
|
+
break;
|
|
81
|
+
current = parent;
|
|
82
|
+
}
|
|
83
|
+
// Return in order from root to leaf (reverse the array)
|
|
84
|
+
return found.reverse();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Process a file path and return README content to inject.
|
|
88
|
+
*/
|
|
89
|
+
function processFilePathForReadmes(filePath, sessionID) {
|
|
90
|
+
const resolved = resolveFilePath(filePath);
|
|
91
|
+
if (!resolved)
|
|
92
|
+
return '';
|
|
93
|
+
const dir = dirname(resolved);
|
|
94
|
+
const cache = getSessionCache(sessionID);
|
|
95
|
+
const readmePaths = findReadmeMdUp(dir);
|
|
96
|
+
let output = '';
|
|
97
|
+
for (const readmePath of readmePaths) {
|
|
98
|
+
const readmeDir = dirname(readmePath);
|
|
99
|
+
if (cache.has(readmeDir))
|
|
100
|
+
continue;
|
|
101
|
+
try {
|
|
102
|
+
const content = readFileSync(readmePath, 'utf-8');
|
|
103
|
+
const { result, truncated } = truncateContent(content);
|
|
104
|
+
const truncationNotice = truncated
|
|
105
|
+
? `\n\n[Note: Content was truncated to save context window space. For full context, please read the file directly: ${readmePath}]`
|
|
106
|
+
: '';
|
|
107
|
+
output += `\n\n[Project README: ${readmePath}]\n${result}${truncationNotice}`;
|
|
108
|
+
cache.add(readmeDir);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// Skip files that can't be read
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (output) {
|
|
115
|
+
saveInjectedPaths(sessionID, cache);
|
|
116
|
+
}
|
|
117
|
+
return output;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
/**
|
|
121
|
+
* Process a tool execution and inject READMEs if relevant.
|
|
122
|
+
*/
|
|
123
|
+
processToolExecution: (toolName, filePath, sessionID) => {
|
|
124
|
+
if (!TRACKED_TOOLS.includes(toolName.toLowerCase())) {
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
return processFilePathForReadmes(filePath, sessionID);
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* Get READMEs for a specific file without marking as injected.
|
|
131
|
+
*/
|
|
132
|
+
getReadmesForFile: (filePath) => {
|
|
133
|
+
const resolved = resolveFilePath(filePath);
|
|
134
|
+
if (!resolved)
|
|
135
|
+
return [];
|
|
136
|
+
const dir = dirname(resolved);
|
|
137
|
+
return findReadmeMdUp(dir);
|
|
138
|
+
},
|
|
139
|
+
/**
|
|
140
|
+
* Clear session cache when session ends.
|
|
141
|
+
*/
|
|
142
|
+
clearSession: (sessionID) => {
|
|
143
|
+
sessionCaches.delete(sessionID);
|
|
144
|
+
clearInjectedPaths(sessionID);
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* Check if a tool triggers README injection.
|
|
148
|
+
*/
|
|
149
|
+
isTrackedTool: (toolName) => {
|
|
150
|
+
return TRACKED_TOOLS.includes(toolName.toLowerCase());
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get README paths for a file (simple utility function).
|
|
156
|
+
*/
|
|
157
|
+
export function getReadmesForPath(filePath, workingDirectory) {
|
|
158
|
+
const cwd = workingDirectory || process.cwd();
|
|
159
|
+
const hook = createDirectoryReadmeInjectorHook(cwd);
|
|
160
|
+
return hook.getReadmesForFile(filePath);
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/directory-readme-injector/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directory README Injector Storage
|
|
3
|
+
*
|
|
4
|
+
* Persistent storage for tracking which directory READMEs have been injected per session.
|
|
5
|
+
*
|
|
6
|
+
* Ported from oh-my-opencode's directory-readme-injector hook.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Load set of injected directory paths for a session.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadInjectedPaths(sessionID: string): Set<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Save set of injected directory paths for a session.
|
|
14
|
+
*/
|
|
15
|
+
export declare function saveInjectedPaths(sessionID: string, paths: Set<string>): void;
|
|
16
|
+
/**
|
|
17
|
+
* Clear injected paths for a session.
|
|
18
|
+
*/
|
|
19
|
+
export declare function clearInjectedPaths(sessionID: string): void;
|
|
20
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/hooks/directory-readme-injector/storage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoBH;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAWhE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAY7E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAK1D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directory README Injector Storage
|
|
3
|
+
*
|
|
4
|
+
* Persistent storage for tracking which directory READMEs have been injected per session.
|
|
5
|
+
*
|
|
6
|
+
* Ported from oh-my-opencode's directory-readme-injector hook.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, } from 'node:fs';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { README_INJECTOR_STORAGE } from './constants.js';
|
|
11
|
+
/**
|
|
12
|
+
* Get storage file path for a session.
|
|
13
|
+
*/
|
|
14
|
+
function getStoragePath(sessionID) {
|
|
15
|
+
return join(README_INJECTOR_STORAGE, `${sessionID}.json`);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Load set of injected directory paths for a session.
|
|
19
|
+
*/
|
|
20
|
+
export function loadInjectedPaths(sessionID) {
|
|
21
|
+
const filePath = getStoragePath(sessionID);
|
|
22
|
+
if (!existsSync(filePath))
|
|
23
|
+
return new Set();
|
|
24
|
+
try {
|
|
25
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
26
|
+
const data = JSON.parse(content);
|
|
27
|
+
return new Set(data.injectedPaths);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return new Set();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Save set of injected directory paths for a session.
|
|
35
|
+
*/
|
|
36
|
+
export function saveInjectedPaths(sessionID, paths) {
|
|
37
|
+
if (!existsSync(README_INJECTOR_STORAGE)) {
|
|
38
|
+
mkdirSync(README_INJECTOR_STORAGE, { recursive: true });
|
|
39
|
+
}
|
|
40
|
+
const data = {
|
|
41
|
+
sessionID,
|
|
42
|
+
injectedPaths: Array.from(paths),
|
|
43
|
+
updatedAt: Date.now(),
|
|
44
|
+
};
|
|
45
|
+
writeFileSync(getStoragePath(sessionID), JSON.stringify(data, null, 2));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Clear injected paths for a session.
|
|
49
|
+
*/
|
|
50
|
+
export function clearInjectedPaths(sessionID) {
|
|
51
|
+
const filePath = getStoragePath(sessionID);
|
|
52
|
+
if (existsSync(filePath)) {
|
|
53
|
+
unlinkSync(filePath);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/hooks/directory-readme-injector/storage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGzD;;GAEG;AACH,SAAS,cAAc,CAAC,SAAiB;IACvC,OAAO,IAAI,CAAC,uBAAuB,EAAE,GAAG,SAAS,OAAO,CAAC,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,MAAM,QAAQ,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAC3C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,GAAG,EAAE,CAAC;IAE5C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChD,MAAM,IAAI,GAAsB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpD,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,KAAkB;IACrE,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE,CAAC;QACzC,SAAS,CAAC,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,IAAI,GAAsB;QAC9B,SAAS;QACT,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;QAChC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACtB,CAAC;IAEF,aAAa,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,MAAM,QAAQ,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAC3C,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,UAAU,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directory README Injector Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for tracking injected README files per session.
|
|
5
|
+
*
|
|
6
|
+
* Ported from oh-my-opencode's directory-readme-injector hook.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Storage data for tracking which directory READMEs have been injected
|
|
10
|
+
* into a session's context.
|
|
11
|
+
*/
|
|
12
|
+
export interface InjectedPathsData {
|
|
13
|
+
/** Session identifier */
|
|
14
|
+
sessionID: string;
|
|
15
|
+
/** List of directory paths whose READMEs have been injected */
|
|
16
|
+
injectedPaths: string[];
|
|
17
|
+
/** Timestamp of last update */
|
|
18
|
+
updatedAt: number;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/directory-readme-injector/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/directory-readme-injector/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit Error Recovery Hook
|
|
3
|
+
*
|
|
4
|
+
* Detects Edit tool errors caused by AI mistakes and injects
|
|
5
|
+
* a recovery reminder to guide corrective action.
|
|
6
|
+
*
|
|
7
|
+
* Common Edit tool failures:
|
|
8
|
+
* - oldString and newString must be different (trying to "edit" to same content)
|
|
9
|
+
* - oldString not found (wrong assumption about file content)
|
|
10
|
+
* - oldString found multiple times (ambiguous match, need more context)
|
|
11
|
+
*
|
|
12
|
+
* Ported from oh-my-opencode's edit-error-recovery hook.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Known Edit tool error patterns that indicate the AI made a mistake
|
|
16
|
+
*/
|
|
17
|
+
export declare const EDIT_ERROR_PATTERNS: readonly ["oldString and newString must be different", "oldString not found", "oldString found multiple times", "old_string not found", "old_string and new_string must be different"];
|
|
18
|
+
/**
|
|
19
|
+
* System reminder injected when Edit tool fails due to AI mistake
|
|
20
|
+
* Short, direct, and commanding - forces immediate corrective action
|
|
21
|
+
*/
|
|
22
|
+
export declare const EDIT_ERROR_REMINDER = "\n[EDIT ERROR - IMMEDIATE ACTION REQUIRED]\n\nYou made an Edit mistake. STOP and do this NOW:\n\n1. READ the file immediately to see its ACTUAL current state\n2. VERIFY what the content really looks like (your assumption was wrong)\n3. APOLOGIZE briefly to the user for the error\n4. CONTINUE with corrected action based on the real file content\n\nDO NOT attempt another edit until you've read and verified the file state.\n";
|
|
23
|
+
/**
|
|
24
|
+
* Check if an output contains an edit error pattern
|
|
25
|
+
*/
|
|
26
|
+
export declare function detectEditError(output: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Inject the edit error recovery reminder into the output
|
|
29
|
+
*/
|
|
30
|
+
export declare function injectEditErrorRecovery(output: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Hook input interface for tool execution
|
|
33
|
+
*/
|
|
34
|
+
export interface ToolExecuteInput {
|
|
35
|
+
tool: string;
|
|
36
|
+
sessionId: string;
|
|
37
|
+
callId: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Hook output interface for tool execution
|
|
41
|
+
*/
|
|
42
|
+
export interface ToolExecuteOutput {
|
|
43
|
+
title: string;
|
|
44
|
+
output: string;
|
|
45
|
+
metadata?: unknown;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates the edit error recovery hook for Claude Code.
|
|
49
|
+
* This is the main export for hook registration.
|
|
50
|
+
*/
|
|
51
|
+
export declare function createEditErrorRecoveryHook(): {
|
|
52
|
+
/**
|
|
53
|
+
* After tool execution, check for Edit errors and inject recovery reminder.
|
|
54
|
+
*/
|
|
55
|
+
afterToolExecute: (input: ToolExecuteInput, output: ToolExecuteOutput) => ToolExecuteOutput;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Process edit tool output and inject recovery if needed.
|
|
59
|
+
* Simplified function for direct use without hook context.
|
|
60
|
+
*/
|
|
61
|
+
export declare function processEditOutput(toolName: string, output: string): string;
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/edit-error-recovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB,wLAMtB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,mBAAmB,8aAW/B,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAKvD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAK9D;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,2BAA2B;IAEvC;;OAEG;8BAEM,gBAAgB,UACf,iBAAiB,KACxB,iBAAiB;EAevB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAK1E"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit Error Recovery Hook
|
|
3
|
+
*
|
|
4
|
+
* Detects Edit tool errors caused by AI mistakes and injects
|
|
5
|
+
* a recovery reminder to guide corrective action.
|
|
6
|
+
*
|
|
7
|
+
* Common Edit tool failures:
|
|
8
|
+
* - oldString and newString must be different (trying to "edit" to same content)
|
|
9
|
+
* - oldString not found (wrong assumption about file content)
|
|
10
|
+
* - oldString found multiple times (ambiguous match, need more context)
|
|
11
|
+
*
|
|
12
|
+
* Ported from oh-my-opencode's edit-error-recovery hook.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Known Edit tool error patterns that indicate the AI made a mistake
|
|
16
|
+
*/
|
|
17
|
+
export const EDIT_ERROR_PATTERNS = [
|
|
18
|
+
'oldString and newString must be different',
|
|
19
|
+
'oldString not found',
|
|
20
|
+
'oldString found multiple times',
|
|
21
|
+
'old_string not found',
|
|
22
|
+
'old_string and new_string must be different',
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* System reminder injected when Edit tool fails due to AI mistake
|
|
26
|
+
* Short, direct, and commanding - forces immediate corrective action
|
|
27
|
+
*/
|
|
28
|
+
export const EDIT_ERROR_REMINDER = `
|
|
29
|
+
[EDIT ERROR - IMMEDIATE ACTION REQUIRED]
|
|
30
|
+
|
|
31
|
+
You made an Edit mistake. STOP and do this NOW:
|
|
32
|
+
|
|
33
|
+
1. READ the file immediately to see its ACTUAL current state
|
|
34
|
+
2. VERIFY what the content really looks like (your assumption was wrong)
|
|
35
|
+
3. APOLOGIZE briefly to the user for the error
|
|
36
|
+
4. CONTINUE with corrected action based on the real file content
|
|
37
|
+
|
|
38
|
+
DO NOT attempt another edit until you've read and verified the file state.
|
|
39
|
+
`;
|
|
40
|
+
/**
|
|
41
|
+
* Check if an output contains an edit error pattern
|
|
42
|
+
*/
|
|
43
|
+
export function detectEditError(output) {
|
|
44
|
+
const outputLower = output.toLowerCase();
|
|
45
|
+
return EDIT_ERROR_PATTERNS.some((pattern) => outputLower.includes(pattern.toLowerCase()));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Inject the edit error recovery reminder into the output
|
|
49
|
+
*/
|
|
50
|
+
export function injectEditErrorRecovery(output) {
|
|
51
|
+
if (detectEditError(output)) {
|
|
52
|
+
return output + EDIT_ERROR_REMINDER;
|
|
53
|
+
}
|
|
54
|
+
return output;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates the edit error recovery hook for Claude Code.
|
|
58
|
+
* This is the main export for hook registration.
|
|
59
|
+
*/
|
|
60
|
+
export function createEditErrorRecoveryHook() {
|
|
61
|
+
return {
|
|
62
|
+
/**
|
|
63
|
+
* After tool execution, check for Edit errors and inject recovery reminder.
|
|
64
|
+
*/
|
|
65
|
+
afterToolExecute: (input, output) => {
|
|
66
|
+
if (input.tool.toLowerCase() !== 'edit') {
|
|
67
|
+
return output;
|
|
68
|
+
}
|
|
69
|
+
if (detectEditError(output.output)) {
|
|
70
|
+
return {
|
|
71
|
+
...output,
|
|
72
|
+
output: output.output + EDIT_ERROR_REMINDER,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return output;
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Process edit tool output and inject recovery if needed.
|
|
81
|
+
* Simplified function for direct use without hook context.
|
|
82
|
+
*/
|
|
83
|
+
export function processEditOutput(toolName, output) {
|
|
84
|
+
if (toolName.toLowerCase() !== 'edit') {
|
|
85
|
+
return output;
|
|
86
|
+
}
|
|
87
|
+
return injectEditErrorRecovery(output);
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/edit-error-recovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,2CAA2C;IAC3C,qBAAqB;IACrB,gCAAgC;IAChC,sBAAsB;IACtB,6CAA6C;CACrC,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;CAWlC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACzC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAC1C,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAC5C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAc;IACpD,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,MAAM,GAAG,mBAAmB,CAAC;IACtC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAoBD;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO;QACL;;WAEG;QACH,gBAAgB,EAAE,CAChB,KAAuB,EACvB,MAAyB,EACN,EAAE;YACrB,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;gBACxC,OAAO,MAAM,CAAC;YAChB,CAAC;YAED,IAAI,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnC,OAAO;oBACL,GAAG,MAAM;oBACT,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,mBAAmB;iBAC5C,CAAC;YACJ,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,MAAc;IAChE,IAAI,QAAQ,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Empty Message Sanitizer Constants
|
|
3
|
+
*
|
|
4
|
+
* Constants for the empty message sanitizer hook.
|
|
5
|
+
*
|
|
6
|
+
* Adapted from oh-my-opencode's empty-message-sanitizer hook.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Placeholder text injected for empty messages
|
|
10
|
+
* This prevents API errors about empty content
|
|
11
|
+
*/
|
|
12
|
+
export declare const PLACEHOLDER_TEXT = "[user interrupted]";
|
|
13
|
+
/**
|
|
14
|
+
* Tool-related part types that count as valid content
|
|
15
|
+
*/
|
|
16
|
+
export declare const TOOL_PART_TYPES: Set<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Hook name identifier
|
|
19
|
+
*/
|
|
20
|
+
export declare const HOOK_NAME = "empty-message-sanitizer";
|
|
21
|
+
/**
|
|
22
|
+
* Debug log prefix
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEBUG_PREFIX = "[empty-message-sanitizer]";
|
|
25
|
+
/**
|
|
26
|
+
* Error message patterns for debugging
|
|
27
|
+
*/
|
|
28
|
+
export declare const ERROR_PATTERNS: {
|
|
29
|
+
EMPTY_CONTENT: string;
|
|
30
|
+
EMPTY_TEXT: string;
|
|
31
|
+
NO_VALID_PARTS: string;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/hooks/empty-message-sanitizer/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,eAAe,aAI1B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS,4BAA4B,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,YAAY,8BAA8B,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,cAAc;;;;CAI1B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Empty Message Sanitizer Constants
|
|
3
|
+
*
|
|
4
|
+
* Constants for the empty message sanitizer hook.
|
|
5
|
+
*
|
|
6
|
+
* Adapted from oh-my-opencode's empty-message-sanitizer hook.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Placeholder text injected for empty messages
|
|
10
|
+
* This prevents API errors about empty content
|
|
11
|
+
*/
|
|
12
|
+
export const PLACEHOLDER_TEXT = '[user interrupted]';
|
|
13
|
+
/**
|
|
14
|
+
* Tool-related part types that count as valid content
|
|
15
|
+
*/
|
|
16
|
+
export const TOOL_PART_TYPES = new Set([
|
|
17
|
+
'tool',
|
|
18
|
+
'tool_use',
|
|
19
|
+
'tool_result',
|
|
20
|
+
]);
|
|
21
|
+
/**
|
|
22
|
+
* Hook name identifier
|
|
23
|
+
*/
|
|
24
|
+
export const HOOK_NAME = 'empty-message-sanitizer';
|
|
25
|
+
/**
|
|
26
|
+
* Debug log prefix
|
|
27
|
+
*/
|
|
28
|
+
export const DEBUG_PREFIX = '[empty-message-sanitizer]';
|
|
29
|
+
/**
|
|
30
|
+
* Error message patterns for debugging
|
|
31
|
+
*/
|
|
32
|
+
export const ERROR_PATTERNS = {
|
|
33
|
+
EMPTY_CONTENT: 'all messages must have non-empty content',
|
|
34
|
+
EMPTY_TEXT: 'message contains empty text part',
|
|
35
|
+
NO_VALID_PARTS: 'message has no valid content parts',
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/hooks/empty-message-sanitizer/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IACrC,MAAM;IACN,UAAU;IACV,aAAa;CACd,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,yBAAyB,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,2BAA2B,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,aAAa,EAAE,0CAA0C;IACzD,UAAU,EAAE,kCAAkC;IAC9C,cAAc,EAAE,oCAAoC;CACrD,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Empty Message Sanitizer Hook
|
|
3
|
+
*
|
|
4
|
+
* Sanitizes empty messages to prevent API errors.
|
|
5
|
+
* According to the Anthropic API spec, all messages must have non-empty content
|
|
6
|
+
* except for the optional final assistant message.
|
|
7
|
+
*
|
|
8
|
+
* This hook:
|
|
9
|
+
* 1. Detects messages with no valid content (empty text or no parts)
|
|
10
|
+
* 2. Injects placeholder text to prevent API errors
|
|
11
|
+
* 3. Marks injected content as synthetic
|
|
12
|
+
*
|
|
13
|
+
* NOTE: This sanitizer would ideally run on a message transform hook that executes
|
|
14
|
+
* AFTER all other message processing. In the shell hooks system, this should be
|
|
15
|
+
* invoked at the last stage before messages are sent to the API.
|
|
16
|
+
*
|
|
17
|
+
* Adapted from oh-my-opencode's empty-message-sanitizer hook.
|
|
18
|
+
*/
|
|
19
|
+
import type { MessagePart, MessageWithParts, EmptyMessageSanitizerInput, EmptyMessageSanitizerOutput, EmptyMessageSanitizerConfig } from './types.js';
|
|
20
|
+
/**
|
|
21
|
+
* Check if a part has non-empty text content
|
|
22
|
+
*/
|
|
23
|
+
export declare function hasTextContent(part: MessagePart): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a part is a tool-related part
|
|
26
|
+
*/
|
|
27
|
+
export declare function isToolPart(part: MessagePart): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check if message parts contain valid content
|
|
30
|
+
* Valid content = non-empty text OR tool parts
|
|
31
|
+
*/
|
|
32
|
+
export declare function hasValidContent(parts: MessagePart[]): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Sanitize a single message to ensure it has valid content
|
|
35
|
+
*/
|
|
36
|
+
export declare function sanitizeMessage(message: MessageWithParts, isLastMessage: boolean, placeholderText?: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Sanitize all messages in the input
|
|
39
|
+
*/
|
|
40
|
+
export declare function sanitizeMessages(input: EmptyMessageSanitizerInput, config?: EmptyMessageSanitizerConfig): EmptyMessageSanitizerOutput;
|
|
41
|
+
/**
|
|
42
|
+
* Create empty message sanitizer hook for Claude Code shell hooks
|
|
43
|
+
*
|
|
44
|
+
* This hook ensures all messages have valid content before being sent to the API.
|
|
45
|
+
* It should be called at the last stage of message processing.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createEmptyMessageSanitizerHook(config?: EmptyMessageSanitizerConfig): {
|
|
48
|
+
/**
|
|
49
|
+
* Sanitize messages (called during message transform phase)
|
|
50
|
+
*/
|
|
51
|
+
sanitize: (input: EmptyMessageSanitizerInput) => EmptyMessageSanitizerOutput;
|
|
52
|
+
/**
|
|
53
|
+
* Get hook name
|
|
54
|
+
*/
|
|
55
|
+
getName: () => string;
|
|
56
|
+
};
|
|
57
|
+
export type { MessagePart, MessageInfo, MessageWithParts, EmptyMessageSanitizerInput, EmptyMessageSanitizerOutput, EmptyMessageSanitizerConfig, } from './types.js';
|
|
58
|
+
export { PLACEHOLDER_TEXT, TOOL_PART_TYPES, HOOK_NAME, DEBUG_PREFIX, ERROR_PATTERNS, } from './constants.js';
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/empty-message-sanitizer/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAWH,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AAcpB;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAMzD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAErD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAE7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,OAAO,EACtB,eAAe,GAAE,MAAyB,GACzC,OAAO,CAwET;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,0BAA0B,EACjC,MAAM,CAAC,EAAE,2BAA2B,GACnC,2BAA2B,CAyB7B;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,MAAM,CAAC,EAAE,2BAA2B;IAIhF;;OAEG;sBACe,0BAA0B,KAAG,2BAA2B;IAI1E;;OAEG;mBACU,MAAM;EAItB;AAGD,YAAY,EACV,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,YAAY,EACZ,cAAc,GACf,MAAM,gBAAgB,CAAC"}
|