olympus-ai 1.0.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/LICENSE +21 -0
- package/README.md +691 -0
- package/dist/__tests__/example.test.d.ts +2 -0
- package/dist/__tests__/example.test.d.ts.map +1 -0
- package/dist/__tests__/example.test.js +20 -0
- package/dist/__tests__/example.test.js.map +1 -0
- package/dist/__tests__/hooks.test.d.ts +2 -0
- package/dist/__tests__/hooks.test.d.ts.map +1 -0
- package/dist/__tests__/hooks.test.js +644 -0
- package/dist/__tests__/hooks.test.js.map +1 -0
- package/dist/__tests__/installer.test.d.ts +2 -0
- package/dist/__tests__/installer.test.d.ts.map +1 -0
- package/dist/__tests__/installer.test.js +369 -0
- package/dist/__tests__/installer.test.js.map +1 -0
- package/dist/__tests__/model-routing.test.d.ts +2 -0
- package/dist/__tests__/model-routing.test.d.ts.map +1 -0
- package/dist/__tests__/model-routing.test.js +814 -0
- package/dist/__tests__/model-routing.test.js.map +1 -0
- package/dist/__tests__/skills.test.d.ts +2 -0
- package/dist/__tests__/skills.test.d.ts.map +1 -0
- package/dist/__tests__/skills.test.js +126 -0
- package/dist/__tests__/skills.test.js.map +1 -0
- package/dist/__tests__/types.test.d.ts +2 -0
- package/dist/__tests__/types.test.d.ts.map +1 -0
- package/dist/__tests__/types.test.js +77 -0
- package/dist/__tests__/types.test.js.map +1 -0
- package/dist/agents/definitions.d.ts +105 -0
- package/dist/agents/definitions.d.ts.map +1 -0
- package/dist/agents/definitions.js +1379 -0
- package/dist/agents/definitions.js.map +1 -0
- 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 +21 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +27 -0
- package/dist/agents/index.js.map +1 -0
- 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/olympian.d.ts +12 -0
- package/dist/agents/olympian.d.ts.map +1 -0
- package/dist/agents/olympian.js +93 -0
- package/dist/agents/olympian.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 +191 -0
- package/dist/agents/oracle.js.map +1 -0
- package/dist/agents/orchestrator-olympus.d.ts +11 -0
- package/dist/agents/orchestrator-olympus.d.ts.map +1 -0
- package/dist/agents/orchestrator-olympus.js +115 -0
- package/dist/agents/orchestrator-olympus.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/qa-tester.d.ts +16 -0
- package/dist/agents/qa-tester.d.ts.map +1 -0
- package/dist/agents/qa-tester.js +367 -0
- package/dist/agents/qa-tester.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/cli/index.d.ts +13 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +496 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/index.d.ts +78 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +148 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +5 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +49 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +380 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/features/auto-update.d.ts +187 -0
- package/dist/features/auto-update.d.ts.map +1 -0
- package/dist/features/auto-update.js +539 -0
- package/dist/features/auto-update.js.map +1 -0
- 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/background-tasks.d.ts +99 -0
- package/dist/features/background-tasks.d.ts.map +1 -0
- package/dist/features/background-tasks.js +265 -0
- package/dist/features/background-tasks.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 +1082 -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/continuation-enforcement.d.ts +36 -0
- package/dist/features/continuation-enforcement.d.ts.map +1 -0
- package/dist/features/continuation-enforcement.js +175 -0
- package/dist/features/continuation-enforcement.js.map +1 -0
- package/dist/features/index.d.ts +12 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +49 -0
- package/dist/features/index.js.map +1 -0
- package/dist/features/magic-keywords.d.ts +28 -0
- package/dist/features/magic-keywords.d.ts.map +1 -0
- package/dist/features/magic-keywords.js +421 -0
- package/dist/features/magic-keywords.js.map +1 -0
- package/dist/features/model-routing/index.d.ts +34 -0
- package/dist/features/model-routing/index.d.ts.map +1 -0
- package/dist/features/model-routing/index.js +48 -0
- package/dist/features/model-routing/index.js.map +1 -0
- package/dist/features/model-routing/prompts/haiku.d.ts +54 -0
- package/dist/features/model-routing/prompts/haiku.d.ts.map +1 -0
- package/dist/features/model-routing/prompts/haiku.js +141 -0
- package/dist/features/model-routing/prompts/haiku.js.map +1 -0
- package/dist/features/model-routing/prompts/index.d.ts +45 -0
- package/dist/features/model-routing/prompts/index.d.ts.map +1 -0
- package/dist/features/model-routing/prompts/index.js +116 -0
- package/dist/features/model-routing/prompts/index.js.map +1 -0
- package/dist/features/model-routing/prompts/opus.d.ts +34 -0
- package/dist/features/model-routing/prompts/opus.d.ts.map +1 -0
- package/dist/features/model-routing/prompts/opus.js +153 -0
- package/dist/features/model-routing/prompts/opus.js.map +1 -0
- package/dist/features/model-routing/prompts/sonnet.d.ts +38 -0
- package/dist/features/model-routing/prompts/sonnet.d.ts.map +1 -0
- package/dist/features/model-routing/prompts/sonnet.js +149 -0
- package/dist/features/model-routing/prompts/sonnet.js.map +1 -0
- package/dist/features/model-routing/router.d.ts +92 -0
- package/dist/features/model-routing/router.d.ts.map +1 -0
- package/dist/features/model-routing/router.js +267 -0
- package/dist/features/model-routing/router.js.map +1 -0
- package/dist/features/model-routing/rules.d.ts +32 -0
- package/dist/features/model-routing/rules.d.ts.map +1 -0
- package/dist/features/model-routing/rules.js +224 -0
- package/dist/features/model-routing/rules.js.map +1 -0
- package/dist/features/model-routing/scorer.d.ts +35 -0
- package/dist/features/model-routing/scorer.d.ts.map +1 -0
- package/dist/features/model-routing/scorer.js +241 -0
- package/dist/features/model-routing/scorer.js.map +1 -0
- package/dist/features/model-routing/signals.d.ts +26 -0
- package/dist/features/model-routing/signals.d.ts.map +1 -0
- package/dist/features/model-routing/signals.js +283 -0
- package/dist/features/model-routing/signals.js.map +1 -0
- package/dist/features/model-routing/types.d.ts +195 -0
- package/dist/features/model-routing/types.d.ts.map +1 -0
- package/dist/features/model-routing/types.js +86 -0
- package/dist/features/model-routing/types.js.map +1 -0
- 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/ascent-verifier/index.d.ts +72 -0
- package/dist/hooks/ascent-verifier/index.d.ts.map +1 -0
- package/dist/hooks/ascent-verifier/index.js +223 -0
- package/dist/hooks/ascent-verifier/index.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 +321 -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 +35 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +81 -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/olympus-orchestrator/constants.d.ts +23 -0
- package/dist/hooks/olympus-orchestrator/constants.d.ts.map +1 -0
- package/dist/hooks/olympus-orchestrator/constants.js +142 -0
- package/dist/hooks/olympus-orchestrator/constants.js.map +1 -0
- package/dist/hooks/olympus-orchestrator/index.d.ts +113 -0
- package/dist/hooks/olympus-orchestrator/index.d.ts.map +1 -0
- package/dist/hooks/olympus-orchestrator/index.js +283 -0
- package/dist/hooks/olympus-orchestrator/index.js.map +1 -0
- package/dist/hooks/persistent-mode/index.d.ts +40 -0
- package/dist/hooks/persistent-mode/index.d.ts.map +1 -0
- package/dist/hooks/persistent-mode/index.js +322 -0
- package/dist/hooks/persistent-mode/index.js.map +1 -0
- package/dist/hooks/plugin-patterns/index.d.ts +107 -0
- package/dist/hooks/plugin-patterns/index.d.ts.map +1 -0
- package/dist/hooks/plugin-patterns/index.js +289 -0
- package/dist/hooks/plugin-patterns/index.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 +227 -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/ralph-verifier/index.d.ts +72 -0
- package/dist/hooks/ralph-verifier/index.d.ts.map +1 -0
- package/dist/hooks/ralph-verifier/index.js +223 -0
- package/dist/hooks/ralph-verifier/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/the-ascent/index.d.ts +60 -0
- package/dist/hooks/the-ascent/index.d.ts.map +1 -0
- package/dist/hooks/the-ascent/index.js +155 -0
- package/dist/hooks/the-ascent/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 +35 -0
- package/dist/hooks/thinking-block-validator/index.d.ts.map +1 -0
- package/dist/hooks/thinking-block-validator/index.js +156 -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/hooks/ultrawork-state/index.d.ts +60 -0
- package/dist/hooks/ultrawork-state/index.d.ts.map +1 -0
- package/dist/hooks/ultrawork-state/index.js +207 -0
- package/dist/hooks/ultrawork-state/index.js.map +1 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +175 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/hooks.d.ts +196 -0
- package/dist/installer/hooks.d.ts.map +1 -0
- package/dist/installer/hooks.js +1385 -0
- package/dist/installer/hooks.js.map +1 -0
- package/dist/installer/index.d.ts +92 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +2249 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/servers.d.ts +77 -0
- package/dist/mcp/servers.d.ts.map +1 -0
- package/dist/mcp/servers.js +122 -0
- package/dist/mcp/servers.js.map +1 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +5 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/types.d.ts +159 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +5 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/tools/ast-tools.d.ts +63 -0
- package/dist/tools/ast-tools.d.ts.map +1 -0
- package/dist/tools/ast-tools.js +450 -0
- package/dist/tools/ast-tools.js.map +1 -0
- package/dist/tools/index.d.ts +52 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +120 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/lsp/client.d.ts +201 -0
- package/dist/tools/lsp/client.d.ts.map +1 -0
- package/dist/tools/lsp/client.js +454 -0
- package/dist/tools/lsp/client.js.map +1 -0
- package/dist/tools/lsp/index.d.ts +9 -0
- package/dist/tools/lsp/index.d.ts.map +1 -0
- package/dist/tools/lsp/index.js +7 -0
- package/dist/tools/lsp/index.js.map +1 -0
- package/dist/tools/lsp/servers.d.ts +37 -0
- package/dist/tools/lsp/servers.d.ts.map +1 -0
- package/dist/tools/lsp/servers.js +149 -0
- package/dist/tools/lsp/servers.js.map +1 -0
- package/dist/tools/lsp/utils.d.ts +58 -0
- package/dist/tools/lsp/utils.d.ts.map +1 -0
- package/dist/tools/lsp/utils.js +236 -0
- package/dist/tools/lsp/utils.js.map +1 -0
- package/dist/tools/lsp-tools.d.ts +151 -0
- package/dist/tools/lsp-tools.d.ts.map +1 -0
- package/dist/tools/lsp-tools.js +358 -0
- package/dist/tools/lsp-tools.js.map +1 -0
- package/package.json +85 -0
- package/scripts/claude-sisyphus.sh +9 -0
- package/scripts/install.sh +1774 -0
- package/scripts/keyword-detector.mjs +209 -0
- package/scripts/keyword-detector.sh +71 -0
- package/scripts/persistent-mode.mjs +241 -0
- package/scripts/persistent-mode.sh +300 -0
- package/scripts/post-tool-verifier.mjs +217 -0
- package/scripts/post-tool-verifier.sh +196 -0
- package/scripts/pre-tool-enforcer.mjs +99 -0
- package/scripts/pre-tool-enforcer.sh +76 -0
- package/scripts/sisyphus-aliases.sh +18 -0
- package/scripts/stop-continuation.sh +31 -0
- package/scripts/test-pr25.sh +525 -0
- package/scripts/uninstall.sh +171 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules Injector Hook
|
|
3
|
+
*
|
|
4
|
+
* Automatically injects relevant rule files when Claude accesses files.
|
|
5
|
+
* Supports project-level (.claude/rules, .github/instructions) and
|
|
6
|
+
* user-level (~/.claude/rules) rule files.
|
|
7
|
+
*
|
|
8
|
+
* Ported from oh-my-opencode's rules-injector hook.
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync } from 'fs';
|
|
11
|
+
import { homedir } from 'os';
|
|
12
|
+
import { relative, resolve } from 'path';
|
|
13
|
+
import { findProjectRoot, findRuleFiles } from './finder.js';
|
|
14
|
+
import { createContentHash, isDuplicateByContentHash, isDuplicateByRealPath, shouldApplyRule, } from './matcher.js';
|
|
15
|
+
import { parseRuleFrontmatter } from './parser.js';
|
|
16
|
+
import { clearInjectedRules, loadInjectedRules, saveInjectedRules, } from './storage.js';
|
|
17
|
+
import { TRACKED_TOOLS } from './constants.js';
|
|
18
|
+
// Re-export all submodules
|
|
19
|
+
export * from './types.js';
|
|
20
|
+
export * from './constants.js';
|
|
21
|
+
export * from './finder.js';
|
|
22
|
+
export * from './parser.js';
|
|
23
|
+
export * from './matcher.js';
|
|
24
|
+
export * from './storage.js';
|
|
25
|
+
/**
|
|
26
|
+
* Create a rules injector hook for Claude Code.
|
|
27
|
+
*
|
|
28
|
+
* @param workingDirectory - The working directory for resolving paths
|
|
29
|
+
* @returns Hook handlers for tool execution
|
|
30
|
+
*/
|
|
31
|
+
export function createRulesInjectorHook(workingDirectory) {
|
|
32
|
+
const sessionCaches = new Map();
|
|
33
|
+
function getSessionCache(sessionId) {
|
|
34
|
+
if (!sessionCaches.has(sessionId)) {
|
|
35
|
+
sessionCaches.set(sessionId, loadInjectedRules(sessionId));
|
|
36
|
+
}
|
|
37
|
+
return sessionCaches.get(sessionId);
|
|
38
|
+
}
|
|
39
|
+
function resolveFilePath(path) {
|
|
40
|
+
if (!path)
|
|
41
|
+
return null;
|
|
42
|
+
if (path.startsWith('/'))
|
|
43
|
+
return path;
|
|
44
|
+
return resolve(workingDirectory, path);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Process a file path and return rules to inject.
|
|
48
|
+
*/
|
|
49
|
+
function processFilePathForRules(filePath, sessionId) {
|
|
50
|
+
const resolved = resolveFilePath(filePath);
|
|
51
|
+
if (!resolved)
|
|
52
|
+
return [];
|
|
53
|
+
const projectRoot = findProjectRoot(resolved);
|
|
54
|
+
const cache = getSessionCache(sessionId);
|
|
55
|
+
const home = homedir();
|
|
56
|
+
const ruleFileCandidates = findRuleFiles(projectRoot, home, resolved);
|
|
57
|
+
const toInject = [];
|
|
58
|
+
for (const candidate of ruleFileCandidates) {
|
|
59
|
+
if (isDuplicateByRealPath(candidate.realPath, cache.realPaths))
|
|
60
|
+
continue;
|
|
61
|
+
try {
|
|
62
|
+
const rawContent = readFileSync(candidate.path, 'utf-8');
|
|
63
|
+
const { metadata, body } = parseRuleFrontmatter(rawContent);
|
|
64
|
+
let matchReason;
|
|
65
|
+
if (candidate.isSingleFile) {
|
|
66
|
+
matchReason = 'copilot-instructions (always apply)';
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const matchResult = shouldApplyRule(metadata, resolved, projectRoot);
|
|
70
|
+
if (!matchResult.applies)
|
|
71
|
+
continue;
|
|
72
|
+
matchReason = matchResult.reason ?? 'matched';
|
|
73
|
+
}
|
|
74
|
+
const contentHash = createContentHash(body);
|
|
75
|
+
if (isDuplicateByContentHash(contentHash, cache.contentHashes))
|
|
76
|
+
continue;
|
|
77
|
+
const relativePath = projectRoot
|
|
78
|
+
? relative(projectRoot, candidate.path)
|
|
79
|
+
: candidate.path;
|
|
80
|
+
toInject.push({
|
|
81
|
+
relativePath,
|
|
82
|
+
matchReason,
|
|
83
|
+
content: body,
|
|
84
|
+
distance: candidate.distance,
|
|
85
|
+
});
|
|
86
|
+
cache.realPaths.add(candidate.realPath);
|
|
87
|
+
cache.contentHashes.add(contentHash);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Skip files that can't be read
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (toInject.length > 0) {
|
|
94
|
+
// Sort by distance (closest first)
|
|
95
|
+
toInject.sort((a, b) => a.distance - b.distance);
|
|
96
|
+
saveInjectedRules(sessionId, cache);
|
|
97
|
+
}
|
|
98
|
+
return toInject;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Format rules for injection into output.
|
|
102
|
+
*/
|
|
103
|
+
function formatRulesForInjection(rules) {
|
|
104
|
+
if (rules.length === 0)
|
|
105
|
+
return '';
|
|
106
|
+
let output = '';
|
|
107
|
+
for (const rule of rules) {
|
|
108
|
+
output += `\n\n[Rule: ${rule.relativePath}]\n[Match: ${rule.matchReason}]\n${rule.content}`;
|
|
109
|
+
}
|
|
110
|
+
return output;
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
/**
|
|
114
|
+
* Process a tool execution and inject rules if relevant.
|
|
115
|
+
*/
|
|
116
|
+
processToolExecution: (toolName, filePath, sessionId) => {
|
|
117
|
+
if (!TRACKED_TOOLS.includes(toolName.toLowerCase())) {
|
|
118
|
+
return '';
|
|
119
|
+
}
|
|
120
|
+
const rules = processFilePathForRules(filePath, sessionId);
|
|
121
|
+
return formatRulesForInjection(rules);
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* Get rules for a specific file without marking as injected.
|
|
125
|
+
*/
|
|
126
|
+
getRulesForFile: (filePath) => {
|
|
127
|
+
const resolved = resolveFilePath(filePath);
|
|
128
|
+
if (!resolved)
|
|
129
|
+
return [];
|
|
130
|
+
const projectRoot = findProjectRoot(resolved);
|
|
131
|
+
const home = homedir();
|
|
132
|
+
const ruleFileCandidates = findRuleFiles(projectRoot, home, resolved);
|
|
133
|
+
const rules = [];
|
|
134
|
+
for (const candidate of ruleFileCandidates) {
|
|
135
|
+
try {
|
|
136
|
+
const rawContent = readFileSync(candidate.path, 'utf-8');
|
|
137
|
+
const { metadata, body } = parseRuleFrontmatter(rawContent);
|
|
138
|
+
let matchReason;
|
|
139
|
+
if (candidate.isSingleFile) {
|
|
140
|
+
matchReason = 'copilot-instructions (always apply)';
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const matchResult = shouldApplyRule(metadata, resolved, projectRoot);
|
|
144
|
+
if (!matchResult.applies)
|
|
145
|
+
continue;
|
|
146
|
+
matchReason = matchResult.reason ?? 'matched';
|
|
147
|
+
}
|
|
148
|
+
const relativePath = projectRoot
|
|
149
|
+
? relative(projectRoot, candidate.path)
|
|
150
|
+
: candidate.path;
|
|
151
|
+
rules.push({
|
|
152
|
+
relativePath,
|
|
153
|
+
matchReason,
|
|
154
|
+
content: body,
|
|
155
|
+
distance: candidate.distance,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
// Skip files that can't be read
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return rules.sort((a, b) => a.distance - b.distance);
|
|
163
|
+
},
|
|
164
|
+
/**
|
|
165
|
+
* Clear session cache when session ends.
|
|
166
|
+
*/
|
|
167
|
+
clearSession: (sessionId) => {
|
|
168
|
+
sessionCaches.delete(sessionId);
|
|
169
|
+
clearInjectedRules(sessionId);
|
|
170
|
+
},
|
|
171
|
+
/**
|
|
172
|
+
* Check if a tool triggers rule injection.
|
|
173
|
+
*/
|
|
174
|
+
isTrackedTool: (toolName) => {
|
|
175
|
+
return TRACKED_TOOLS.includes(toolName.toLowerCase());
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get rules for a file path (simple utility function).
|
|
181
|
+
*/
|
|
182
|
+
export function getRulesForPath(filePath, workingDirectory) {
|
|
183
|
+
const cwd = workingDirectory || process.cwd();
|
|
184
|
+
const hook = createRulesInjectorHook(cwd);
|
|
185
|
+
return hook.getRulesForFile(filePath);
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/rules-injector/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,2BAA2B;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAU7B;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,gBAAwB;IAC9D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEtD,SAAS,eAAe,CAAC,SAAiB;QACxC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,aAAa,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC;IACvC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AAQ,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules Matcher
|
|
3
|
+
*
|
|
4
|
+
* Matches rules against file paths using glob patterns.
|
|
5
|
+
*
|
|
6
|
+
* Ported from oh-my-opencode's rules-injector hook.
|
|
7
|
+
*/
|
|
8
|
+
import type { RuleMetadata, MatchResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Check if a rule should apply to the current file based on metadata.
|
|
11
|
+
*/
|
|
12
|
+
export declare function shouldApplyRule(metadata: RuleMetadata, currentFilePath: string, projectRoot: string | null): MatchResult;
|
|
13
|
+
/**
|
|
14
|
+
* Check if realPath already exists in cache (symlink deduplication).
|
|
15
|
+
*/
|
|
16
|
+
export declare function isDuplicateByRealPath(realPath: string, cache: Set<string>): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Create SHA-256 hash of content, truncated to 16 chars.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createContentHash(content: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Check if content hash already exists in cache.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isDuplicateByContentHash(hash: string, cache: Set<string>): boolean;
|
|
25
|
+
//# sourceMappingURL=matcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matcher.d.ts","sourceRoot":"","sources":["../../../src/hooks/rules-injector/matcher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmB5D;;GAEG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,YAAY,EACtB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAAG,IAAI,GACzB,WAAW,CA6Bb;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAEnF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAElF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules Matcher
|
|
3
|
+
*
|
|
4
|
+
* Matches rules against file paths using glob patterns.
|
|
5
|
+
*
|
|
6
|
+
* Ported from oh-my-opencode's rules-injector hook.
|
|
7
|
+
*/
|
|
8
|
+
import { createHash } from 'crypto';
|
|
9
|
+
import { relative } from 'path';
|
|
10
|
+
/**
|
|
11
|
+
* Simple glob pattern matcher.
|
|
12
|
+
* Supports basic patterns like *.ts, **\/*.js, src/**\/*.py
|
|
13
|
+
*/
|
|
14
|
+
function matchGlob(pattern, filePath) {
|
|
15
|
+
// Convert glob pattern to regex
|
|
16
|
+
const regexStr = pattern
|
|
17
|
+
.replace(/\./g, '\\.') // Escape dots
|
|
18
|
+
.replace(/\*\*/g, '<<<GLOBSTAR>>>') // Temporarily replace **
|
|
19
|
+
.replace(/\*/g, '[^/]*') // * matches any characters except /
|
|
20
|
+
.replace(/<<<GLOBSTAR>>>/g, '.*') // ** matches anything including /
|
|
21
|
+
.replace(/\?/g, '.'); // ? matches single character
|
|
22
|
+
const regex = new RegExp(`^${regexStr}$`);
|
|
23
|
+
return regex.test(filePath);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Check if a rule should apply to the current file based on metadata.
|
|
27
|
+
*/
|
|
28
|
+
export function shouldApplyRule(metadata, currentFilePath, projectRoot) {
|
|
29
|
+
if (metadata.alwaysApply === true) {
|
|
30
|
+
return { applies: true, reason: 'alwaysApply' };
|
|
31
|
+
}
|
|
32
|
+
const globs = metadata.globs;
|
|
33
|
+
if (!globs) {
|
|
34
|
+
return { applies: false };
|
|
35
|
+
}
|
|
36
|
+
const patterns = Array.isArray(globs) ? globs : [globs];
|
|
37
|
+
if (patterns.length === 0) {
|
|
38
|
+
return { applies: false };
|
|
39
|
+
}
|
|
40
|
+
const relativePath = projectRoot
|
|
41
|
+
? relative(projectRoot, currentFilePath)
|
|
42
|
+
: currentFilePath;
|
|
43
|
+
// Normalize path separators to forward slashes for matching
|
|
44
|
+
const normalizedPath = relativePath.replace(/\\/g, '/');
|
|
45
|
+
for (const pattern of patterns) {
|
|
46
|
+
if (matchGlob(pattern, normalizedPath)) {
|
|
47
|
+
return { applies: true, reason: `glob: ${pattern}` };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { applies: false };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if realPath already exists in cache (symlink deduplication).
|
|
54
|
+
*/
|
|
55
|
+
export function isDuplicateByRealPath(realPath, cache) {
|
|
56
|
+
return cache.has(realPath);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create SHA-256 hash of content, truncated to 16 chars.
|
|
60
|
+
*/
|
|
61
|
+
export function createContentHash(content) {
|
|
62
|
+
return createHash('sha256').update(content).digest('hex').slice(0, 16);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check if content hash already exists in cache.
|
|
66
|
+
*/
|
|
67
|
+
export function isDuplicateByContentHash(hash, cache) {
|
|
68
|
+
return cache.has(hash);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=matcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matcher.js","sourceRoot":"","sources":["../../../src/hooks/rules-injector/matcher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGhC;;;GAGG;AACH,SAAS,SAAS,CAAC,OAAe,EAAE,QAAgB;IAClD,gCAAgC;IACh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Y,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAExD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,SAAS,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,CAAC;YACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,OAAO,EAAE,EAAE,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB,EAAE,KAAkB;IACxE,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAY,EAAE,KAAkB;IACvE,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses YAML frontmatter from rule files.
|
|
5
|
+
* Supports multiple formats for compatibility.
|
|
6
|
+
*
|
|
7
|
+
* Ported from oh-my-opencode's rules-injector hook.
|
|
8
|
+
*/
|
|
9
|
+
import type { RuleFrontmatterResult } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Parse YAML frontmatter from rule file content.
|
|
12
|
+
* Supports:
|
|
13
|
+
* - Single string: globs: "**\/*.py"
|
|
14
|
+
* - Inline array: globs: ["**\/*.py", "src/**\/*.ts"]
|
|
15
|
+
* - Multi-line array with dashes
|
|
16
|
+
* - Comma-separated: globs: "**\/*.py, src/**\/*.ts"
|
|
17
|
+
* - Claude Code 'paths' field (alias for globs)
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseRuleFrontmatter(content: string): RuleFrontmatterResult;
|
|
20
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/hooks/rules-injector/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAgB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEtE;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAiB3E"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses YAML frontmatter from rule files.
|
|
5
|
+
* Supports multiple formats for compatibility.
|
|
6
|
+
*
|
|
7
|
+
* Ported from oh-my-opencode's rules-injector hook.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Parse YAML frontmatter from rule file content.
|
|
11
|
+
* Supports:
|
|
12
|
+
* - Single string: globs: "**\/*.py"
|
|
13
|
+
* - Inline array: globs: ["**\/*.py", "src/**\/*.ts"]
|
|
14
|
+
* - Multi-line array with dashes
|
|
15
|
+
* - Comma-separated: globs: "**\/*.py, src/**\/*.ts"
|
|
16
|
+
* - Claude Code 'paths' field (alias for globs)
|
|
17
|
+
*/
|
|
18
|
+
export function parseRuleFrontmatter(content) {
|
|
19
|
+
const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
20
|
+
const match = content.match(frontmatterRegex);
|
|
21
|
+
if (!match) {
|
|
22
|
+
return { metadata: {}, body: content };
|
|
23
|
+
}
|
|
24
|
+
const yamlContent = match[1];
|
|
25
|
+
const body = match[2];
|
|
26
|
+
try {
|
|
27
|
+
const metadata = parseYamlContent(yamlContent);
|
|
28
|
+
return { metadata, body };
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return { metadata: {}, body: content };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parse YAML content without external library.
|
|
36
|
+
*/
|
|
37
|
+
function parseYamlContent(yamlContent) {
|
|
38
|
+
const lines = yamlContent.split('\n');
|
|
39
|
+
const metadata = {};
|
|
40
|
+
let i = 0;
|
|
41
|
+
while (i < lines.length) {
|
|
42
|
+
const line = lines[i];
|
|
43
|
+
const colonIndex = line.indexOf(':');
|
|
44
|
+
if (colonIndex === -1) {
|
|
45
|
+
i++;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const key = line.slice(0, colonIndex).trim();
|
|
49
|
+
const rawValue = line.slice(colonIndex + 1).trim();
|
|
50
|
+
if (key === 'description') {
|
|
51
|
+
metadata.description = parseStringValue(rawValue);
|
|
52
|
+
}
|
|
53
|
+
else if (key === 'alwaysApply') {
|
|
54
|
+
metadata.alwaysApply = rawValue === 'true';
|
|
55
|
+
}
|
|
56
|
+
else if (key === 'globs' || key === 'paths' || key === 'applyTo') {
|
|
57
|
+
const { value, consumed } = parseArrayOrStringValue(rawValue, lines, i);
|
|
58
|
+
// Merge paths into globs (Claude Code compatibility)
|
|
59
|
+
metadata.globs = mergeGlobs(metadata.globs, value);
|
|
60
|
+
i += consumed;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
i++;
|
|
64
|
+
}
|
|
65
|
+
return metadata;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Parse a string value, removing surrounding quotes.
|
|
69
|
+
*/
|
|
70
|
+
function parseStringValue(value) {
|
|
71
|
+
if (!value)
|
|
72
|
+
return '';
|
|
73
|
+
// Remove surrounding quotes
|
|
74
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
75
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
76
|
+
return value.slice(1, -1);
|
|
77
|
+
}
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Parse array or string value from YAML.
|
|
82
|
+
* Returns the parsed value and number of lines consumed.
|
|
83
|
+
*/
|
|
84
|
+
function parseArrayOrStringValue(rawValue, lines, currentIndex) {
|
|
85
|
+
// Case 1: Inline array ["a", "b", "c"]
|
|
86
|
+
if (rawValue.startsWith('[')) {
|
|
87
|
+
return { value: parseInlineArray(rawValue), consumed: 1 };
|
|
88
|
+
}
|
|
89
|
+
// Case 2: Multi-line array (value is empty, next lines start with " - ")
|
|
90
|
+
if (!rawValue || rawValue === '') {
|
|
91
|
+
const arrayItems = [];
|
|
92
|
+
let consumed = 1;
|
|
93
|
+
for (let j = currentIndex + 1; j < lines.length; j++) {
|
|
94
|
+
const nextLine = lines[j];
|
|
95
|
+
// Check if this is an array item (starts with whitespace + dash)
|
|
96
|
+
const arrayMatch = nextLine.match(/^\s+-\s*(.*)$/);
|
|
97
|
+
if (arrayMatch) {
|
|
98
|
+
const itemValue = parseStringValue(arrayMatch[1].trim());
|
|
99
|
+
if (itemValue) {
|
|
100
|
+
arrayItems.push(itemValue);
|
|
101
|
+
}
|
|
102
|
+
consumed++;
|
|
103
|
+
}
|
|
104
|
+
else if (nextLine.trim() === '') {
|
|
105
|
+
// Skip empty lines within array
|
|
106
|
+
consumed++;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// Not an array item, stop
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (arrayItems.length > 0) {
|
|
114
|
+
return { value: arrayItems, consumed };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Case 3: Comma-separated patterns in single string
|
|
118
|
+
const stringValue = parseStringValue(rawValue);
|
|
119
|
+
if (stringValue.includes(',')) {
|
|
120
|
+
const items = stringValue
|
|
121
|
+
.split(',')
|
|
122
|
+
.map((s) => s.trim())
|
|
123
|
+
.filter((s) => s.length > 0);
|
|
124
|
+
return { value: items, consumed: 1 };
|
|
125
|
+
}
|
|
126
|
+
// Case 4: Single string value
|
|
127
|
+
return { value: stringValue, consumed: 1 };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Parse inline JSON-like array: ["a", "b", "c"]
|
|
131
|
+
*/
|
|
132
|
+
function parseInlineArray(value) {
|
|
133
|
+
// Remove brackets
|
|
134
|
+
const content = value.slice(1, value.lastIndexOf(']')).trim();
|
|
135
|
+
if (!content)
|
|
136
|
+
return [];
|
|
137
|
+
const items = [];
|
|
138
|
+
let current = '';
|
|
139
|
+
let inQuote = false;
|
|
140
|
+
let quoteChar = '';
|
|
141
|
+
for (let i = 0; i < content.length; i++) {
|
|
142
|
+
const char = content[i];
|
|
143
|
+
if (!inQuote && (char === '"' || char === "'")) {
|
|
144
|
+
inQuote = true;
|
|
145
|
+
quoteChar = char;
|
|
146
|
+
}
|
|
147
|
+
else if (inQuote && char === quoteChar) {
|
|
148
|
+
inQuote = false;
|
|
149
|
+
quoteChar = '';
|
|
150
|
+
}
|
|
151
|
+
else if (!inQuote && char === ',') {
|
|
152
|
+
const trimmed = current.trim();
|
|
153
|
+
if (trimmed) {
|
|
154
|
+
items.push(parseStringValue(trimmed));
|
|
155
|
+
}
|
|
156
|
+
current = '';
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
current += char;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Don't forget the last item
|
|
163
|
+
const trimmed = current.trim();
|
|
164
|
+
if (trimmed) {
|
|
165
|
+
items.push(parseStringValue(trimmed));
|
|
166
|
+
}
|
|
167
|
+
return items;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Merge two globs values (for combining paths and globs).
|
|
171
|
+
*/
|
|
172
|
+
function mergeGlobs(existing, newValue) {
|
|
173
|
+
if (!existing)
|
|
174
|
+
return newValue;
|
|
175
|
+
const existingArray = Array.isArray(existing) ? existing : [existing];
|
|
176
|
+
const newArray = Array.isArray(newValue) ? newValue : [newValue];
|
|
177
|
+
return [...existingArray, ...newArray];
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/hooks/rules-injector/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,MAAM,gBAAgB,GAAG,6CAA6C,CAAC;IACvE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAE9C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACzC,CAAC;IAED,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAEtB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAC/C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACzC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAC,WAAmB;IAC3C,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAiB,EAAE,CAAC;IAElC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,UAAU,GA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AC,CAAC,QAAQ,CAAC,CAAC;IAEjE,OAAO,CAAC,GAAG,aAAa,EAAE,GAAG,QAAQ,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules Storage
|
|
3
|
+
*
|
|
4
|
+
* Persistent storage for tracking injected rules per session.
|
|
5
|
+
*
|
|
6
|
+
* Ported from oh-my-opencode's rules-injector hook.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Load injected rules for a session.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadInjectedRules(sessionId: string): {
|
|
12
|
+
contentHashes: Set<string>;
|
|
13
|
+
realPaths: Set<string>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Save injected rules for a session.
|
|
17
|
+
*/
|
|
18
|
+
export declare function saveInjectedRules(sessionId: string, data: {
|
|
19
|
+
contentHashes: Set<string>;
|
|
20
|
+
realPaths: Set<string>;
|
|
21
|
+
}): void;
|
|
22
|
+
/**
|
|
23
|
+
* Clear injected rules for a session.
|
|
24
|
+
*/
|
|
25
|
+
export declare function clearInjectedRules(sessionId: string): void;
|
|
26
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/hooks/rules-injector/storage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoBH;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG;IACpD,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB,CAgBA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE;IAAE,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,GAC3D,IAAI,CAaN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAK1D"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules Storage
|
|
3
|
+
*
|
|
4
|
+
* Persistent storage for tracking injected rules per session.
|
|
5
|
+
*
|
|
6
|
+
* Ported from oh-my-opencode's rules-injector hook.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, } from 'fs';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
import { RULES_INJECTOR_STORAGE } from './constants.js';
|
|
11
|
+
/**
|
|
12
|
+
* Get storage path for a session.
|
|
13
|
+
*/
|
|
14
|
+
function getStoragePath(sessionId) {
|
|
15
|
+
return join(RULES_INJECTOR_STORAGE, `${sessionId}.json`);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Load injected rules for a session.
|
|
19
|
+
*/
|
|
20
|
+
export function loadInjectedRules(sessionId) {
|
|
21
|
+
const filePath = getStoragePath(sessionId);
|
|
22
|
+
if (!existsSync(filePath)) {
|
|
23
|
+
return { contentHashes: new Set(), realPaths: new Set() };
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
27
|
+
const data = JSON.parse(content);
|
|
28
|
+
return {
|
|
29
|
+
contentHashes: new Set(data.injectedHashes),
|
|
30
|
+
realPaths: new Set(data.injectedRealPaths ?? []),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return { contentHashes: new Set(), realPaths: new Set() };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Save injected rules for a session.
|
|
39
|
+
*/
|
|
40
|
+
export function saveInjectedRules(sessionId, data) {
|
|
41
|
+
if (!existsSync(RULES_INJECTOR_STORAGE)) {
|
|
42
|
+
mkdirSync(RULES_INJECTOR_STORAGE, { recursive: true });
|
|
43
|
+
}
|
|
44
|
+
const storageData = {
|
|
45
|
+
sessionId,
|
|
46
|
+
injectedHashes: [...data.contentHashes],
|
|
47
|
+
injectedRealPaths: [...data.realPaths],
|
|
48
|
+
updatedAt: Date.now(),
|
|
49
|
+
};
|
|
50
|
+
writeFileSync(getStoragePath(sessionId), JSON.stringify(storageData, null, 2));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Clear injected rules for a session.
|
|
54
|
+
*/
|
|
55
|
+
export function clearInjectedRules(sessionId) {
|
|
56
|
+
const filePath = getStoragePath(sessionId);
|
|
57
|
+
if (existsSync(filePath)) {
|
|
58
|
+
unlinkSync(filePath);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/hooks/rules-injector/storage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,UAAU,GACX,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAGxD;;GAEG;AACH,SAAS,cAAc,CAAC,SAAiB;IACvC,OAAO,IAAI,CAAC,sBAAsB,EAAE,GAAG,SAAS,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IAIjD,MAAM,QAAQ,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAC3C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,aAAa,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;IAC5D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