opencode-repos 0.3.0 → 0.3.1
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/index.ts +10 -6
- package/package.json +1 -1
- package/src/__tests__/git.test.ts +33 -2
- package/src/git.ts +32 -5
- package/.sisyphus/boulder.json +0 -8
- package/.sisyphus/notepads/opencode-repos/decisions.md +0 -15
- package/.sisyphus/notepads/opencode-repos/learnings.md +0 -384
- package/.sisyphus/plans/opencode-repos.md +0 -987
- package/.tmux-sessionizer +0 -8
- package/TODO.md +0 -3
- package/oh-my-opencode/.github/FUNDING.yml +0 -15
- package/oh-my-opencode/.github/ISSUE_TEMPLATE/bug_report.yml +0 -129
- package/oh-my-opencode/.github/ISSUE_TEMPLATE/config.yml +0 -8
- package/oh-my-opencode/.github/ISSUE_TEMPLATE/feature_request.yml +0 -100
- package/oh-my-opencode/.github/ISSUE_TEMPLATE/general.yml +0 -83
- package/oh-my-opencode/.github/assets/google.jpg +0 -0
- package/oh-my-opencode/.github/assets/hero.jpg +0 -0
- package/oh-my-opencode/.github/assets/indent.jpg +0 -0
- package/oh-my-opencode/.github/assets/microsoft.jpg +0 -0
- package/oh-my-opencode/.github/assets/omo.png +0 -0
- package/oh-my-opencode/.github/assets/orchestrator-atlas.png +0 -0
- package/oh-my-opencode/.github/assets/sisyphus.png +0 -0
- package/oh-my-opencode/.github/assets/sisyphuslabs.png +0 -0
- package/oh-my-opencode/.github/pull_request_template.md +0 -34
- package/oh-my-opencode/.github/workflows/ci.yml +0 -138
- package/oh-my-opencode/.github/workflows/cla.yml +0 -41
- package/oh-my-opencode/.github/workflows/lint-workflows.yml +0 -22
- package/oh-my-opencode/.github/workflows/publish.yml +0 -165
- package/oh-my-opencode/.github/workflows/sisyphus-agent.yml +0 -500
- package/oh-my-opencode/.opencode/background-tasks.json +0 -27
- package/oh-my-opencode/.opencode/command/get-unpublished-changes.md +0 -84
- package/oh-my-opencode/.opencode/command/omomomo.md +0 -37
- package/oh-my-opencode/.opencode/command/publish.md +0 -257
- package/oh-my-opencode/AGENTS.md +0 -179
- package/oh-my-opencode/CLA.md +0 -58
- package/oh-my-opencode/CONTRIBUTING.md +0 -268
- package/oh-my-opencode/LICENSE.md +0 -82
- package/oh-my-opencode/README.ja.md +0 -370
- package/oh-my-opencode/README.md +0 -376
- package/oh-my-opencode/README.zh-cn.md +0 -380
- package/oh-my-opencode/assets/oh-my-opencode.schema.json +0 -2171
- package/oh-my-opencode/bin/oh-my-opencode.js +0 -80
- package/oh-my-opencode/bin/platform.js +0 -38
- package/oh-my-opencode/bin/platform.test.ts +0 -148
- package/oh-my-opencode/bun.lock +0 -314
- package/oh-my-opencode/bunfig.toml +0 -2
- package/oh-my-opencode/docs/category-skill-guide.md +0 -200
- package/oh-my-opencode/docs/cli-guide.md +0 -272
- package/oh-my-opencode/docs/configurations.md +0 -654
- package/oh-my-opencode/docs/features.md +0 -550
- package/oh-my-opencode/docs/guide/installation.md +0 -288
- package/oh-my-opencode/docs/guide/overview.md +0 -97
- package/oh-my-opencode/docs/guide/understanding-orchestration-system.md +0 -445
- package/oh-my-opencode/docs/orchestration-guide.md +0 -152
- package/oh-my-opencode/docs/ultrawork-manifesto.md +0 -197
- package/oh-my-opencode/package.json +0 -89
- package/oh-my-opencode/packages/darwin-arm64/bin/.gitkeep +0 -0
- package/oh-my-opencode/packages/darwin-arm64/package.json +0 -22
- package/oh-my-opencode/packages/darwin-x64/bin/.gitkeep +0 -0
- package/oh-my-opencode/packages/darwin-x64/package.json +0 -22
- package/oh-my-opencode/packages/linux-arm64/bin/.gitkeep +0 -0
- package/oh-my-opencode/packages/linux-arm64/package.json +0 -25
- package/oh-my-opencode/packages/linux-arm64-musl/bin/.gitkeep +0 -0
- package/oh-my-opencode/packages/linux-arm64-musl/package.json +0 -25
- package/oh-my-opencode/packages/linux-x64/bin/.gitkeep +0 -0
- package/oh-my-opencode/packages/linux-x64/package.json +0 -25
- package/oh-my-opencode/packages/linux-x64-musl/bin/.gitkeep +0 -0
- package/oh-my-opencode/packages/linux-x64-musl/package.json +0 -25
- package/oh-my-opencode/packages/windows-x64/bin/.gitkeep +0 -0
- package/oh-my-opencode/packages/windows-x64/package.json +0 -22
- package/oh-my-opencode/postinstall.mjs +0 -43
- package/oh-my-opencode/script/build-binaries.ts +0 -103
- package/oh-my-opencode/script/build-schema.ts +0 -28
- package/oh-my-opencode/script/generate-changelog.ts +0 -92
- package/oh-my-opencode/script/publish.ts +0 -344
- package/oh-my-opencode/signatures/cla.json +0 -676
- package/oh-my-opencode/src/agents/AGENTS.md +0 -67
- package/oh-my-opencode/src/agents/atlas.ts +0 -1383
- package/oh-my-opencode/src/agents/dynamic-agent-prompt-builder.ts +0 -400
- package/oh-my-opencode/src/agents/explore.ts +0 -122
- package/oh-my-opencode/src/agents/index.ts +0 -13
- package/oh-my-opencode/src/agents/librarian.ts +0 -326
- package/oh-my-opencode/src/agents/metis.ts +0 -315
- package/oh-my-opencode/src/agents/momus.test.ts +0 -57
- package/oh-my-opencode/src/agents/momus.ts +0 -444
- package/oh-my-opencode/src/agents/multimodal-looker.ts +0 -56
- package/oh-my-opencode/src/agents/oracle.ts +0 -122
- package/oh-my-opencode/src/agents/prometheus-prompt.test.ts +0 -22
- package/oh-my-opencode/src/agents/prometheus-prompt.ts +0 -1196
- package/oh-my-opencode/src/agents/sisyphus-junior.test.ts +0 -232
- package/oh-my-opencode/src/agents/sisyphus-junior.ts +0 -134
- package/oh-my-opencode/src/agents/sisyphus.ts +0 -633
- package/oh-my-opencode/src/agents/types.ts +0 -80
- package/oh-my-opencode/src/agents/utils.test.ts +0 -311
- package/oh-my-opencode/src/agents/utils.ts +0 -240
- package/oh-my-opencode/src/cli/AGENTS.md +0 -91
- package/oh-my-opencode/src/cli/config-manager.test.ts +0 -364
- package/oh-my-opencode/src/cli/config-manager.ts +0 -641
- package/oh-my-opencode/src/cli/doctor/checks/auth.test.ts +0 -114
- package/oh-my-opencode/src/cli/doctor/checks/auth.ts +0 -115
- package/oh-my-opencode/src/cli/doctor/checks/config.test.ts +0 -103
- package/oh-my-opencode/src/cli/doctor/checks/config.ts +0 -123
- package/oh-my-opencode/src/cli/doctor/checks/dependencies.test.ts +0 -152
- package/oh-my-opencode/src/cli/doctor/checks/dependencies.ts +0 -163
- package/oh-my-opencode/src/cli/doctor/checks/gh.test.ts +0 -151
- package/oh-my-opencode/src/cli/doctor/checks/gh.ts +0 -171
- package/oh-my-opencode/src/cli/doctor/checks/index.ts +0 -34
- package/oh-my-opencode/src/cli/doctor/checks/lsp.test.ts +0 -134
- package/oh-my-opencode/src/cli/doctor/checks/lsp.ts +0 -77
- package/oh-my-opencode/src/cli/doctor/checks/mcp.test.ts +0 -115
- package/oh-my-opencode/src/cli/doctor/checks/mcp.ts +0 -128
- package/oh-my-opencode/src/cli/doctor/checks/opencode.test.ts +0 -227
- package/oh-my-opencode/src/cli/doctor/checks/opencode.ts +0 -178
- package/oh-my-opencode/src/cli/doctor/checks/plugin.test.ts +0 -109
- package/oh-my-opencode/src/cli/doctor/checks/plugin.ts +0 -124
- package/oh-my-opencode/src/cli/doctor/checks/version.test.ts +0 -148
- package/oh-my-opencode/src/cli/doctor/checks/version.ts +0 -135
- package/oh-my-opencode/src/cli/doctor/constants.ts +0 -72
- package/oh-my-opencode/src/cli/doctor/formatter.test.ts +0 -218
- package/oh-my-opencode/src/cli/doctor/formatter.ts +0 -140
- package/oh-my-opencode/src/cli/doctor/index.ts +0 -11
- package/oh-my-opencode/src/cli/doctor/runner.test.ts +0 -153
- package/oh-my-opencode/src/cli/doctor/runner.ts +0 -132
- package/oh-my-opencode/src/cli/doctor/types.ts +0 -113
- package/oh-my-opencode/src/cli/get-local-version/formatter.ts +0 -66
- package/oh-my-opencode/src/cli/get-local-version/index.ts +0 -106
- package/oh-my-opencode/src/cli/get-local-version/types.ts +0 -14
- package/oh-my-opencode/src/cli/index.ts +0 -153
- package/oh-my-opencode/src/cli/install.ts +0 -523
- package/oh-my-opencode/src/cli/model-fallback.ts +0 -246
- package/oh-my-opencode/src/cli/run/completion.test.ts +0 -170
- package/oh-my-opencode/src/cli/run/completion.ts +0 -79
- package/oh-my-opencode/src/cli/run/events.test.ts +0 -155
- package/oh-my-opencode/src/cli/run/events.ts +0 -325
- package/oh-my-opencode/src/cli/run/index.ts +0 -2
- package/oh-my-opencode/src/cli/run/runner.ts +0 -159
- package/oh-my-opencode/src/cli/run/types.ts +0 -76
- package/oh-my-opencode/src/cli/types.ts +0 -40
- package/oh-my-opencode/src/config/index.ts +0 -26
- package/oh-my-opencode/src/config/schema.test.ts +0 -444
- package/oh-my-opencode/src/config/schema.ts +0 -339
- package/oh-my-opencode/src/features/AGENTS.md +0 -77
- package/oh-my-opencode/src/features/background-agent/concurrency.test.ts +0 -418
- package/oh-my-opencode/src/features/background-agent/concurrency.ts +0 -137
- package/oh-my-opencode/src/features/background-agent/index.ts +0 -3
- package/oh-my-opencode/src/features/background-agent/manager.test.ts +0 -1928
- package/oh-my-opencode/src/features/background-agent/manager.ts +0 -1335
- package/oh-my-opencode/src/features/background-agent/types.ts +0 -66
- package/oh-my-opencode/src/features/boulder-state/constants.ts +0 -13
- package/oh-my-opencode/src/features/boulder-state/index.ts +0 -3
- package/oh-my-opencode/src/features/boulder-state/storage.test.ts +0 -250
- package/oh-my-opencode/src/features/boulder-state/storage.ts +0 -150
- package/oh-my-opencode/src/features/boulder-state/types.ts +0 -26
- package/oh-my-opencode/src/features/builtin-commands/commands.ts +0 -89
- package/oh-my-opencode/src/features/builtin-commands/index.ts +0 -2
- package/oh-my-opencode/src/features/builtin-commands/templates/init-deep.ts +0 -300
- package/oh-my-opencode/src/features/builtin-commands/templates/ralph-loop.ts +0 -38
- package/oh-my-opencode/src/features/builtin-commands/templates/refactor.ts +0 -619
- package/oh-my-opencode/src/features/builtin-commands/templates/start-work.ts +0 -72
- package/oh-my-opencode/src/features/builtin-commands/types.ts +0 -9
- package/oh-my-opencode/src/features/builtin-skills/frontend-ui-ux/SKILL.md +0 -78
- package/oh-my-opencode/src/features/builtin-skills/git-master/SKILL.md +0 -1105
- package/oh-my-opencode/src/features/builtin-skills/index.ts +0 -2
- package/oh-my-opencode/src/features/builtin-skills/skills.ts +0 -1203
- package/oh-my-opencode/src/features/builtin-skills/types.ts +0 -16
- package/oh-my-opencode/src/features/claude-code-agent-loader/index.ts +0 -2
- package/oh-my-opencode/src/features/claude-code-agent-loader/loader.ts +0 -90
- package/oh-my-opencode/src/features/claude-code-agent-loader/types.ts +0 -17
- package/oh-my-opencode/src/features/claude-code-command-loader/index.ts +0 -2
- package/oh-my-opencode/src/features/claude-code-command-loader/loader.ts +0 -144
- package/oh-my-opencode/src/features/claude-code-command-loader/types.ts +0 -46
- package/oh-my-opencode/src/features/claude-code-mcp-loader/env-expander.ts +0 -27
- package/oh-my-opencode/src/features/claude-code-mcp-loader/index.ts +0 -11
- package/oh-my-opencode/src/features/claude-code-mcp-loader/loader.test.ts +0 -162
- package/oh-my-opencode/src/features/claude-code-mcp-loader/loader.ts +0 -113
- package/oh-my-opencode/src/features/claude-code-mcp-loader/transformer.ts +0 -53
- package/oh-my-opencode/src/features/claude-code-mcp-loader/types.ts +0 -42
- package/oh-my-opencode/src/features/claude-code-plugin-loader/index.ts +0 -3
- package/oh-my-opencode/src/features/claude-code-plugin-loader/loader.ts +0 -486
- package/oh-my-opencode/src/features/claude-code-plugin-loader/types.ts +0 -210
- package/oh-my-opencode/src/features/claude-code-session-state/index.ts +0 -1
- package/oh-my-opencode/src/features/claude-code-session-state/state.test.ts +0 -126
- package/oh-my-opencode/src/features/claude-code-session-state/state.ts +0 -37
- package/oh-my-opencode/src/features/context-injector/collector.test.ts +0 -330
- package/oh-my-opencode/src/features/context-injector/collector.ts +0 -85
- package/oh-my-opencode/src/features/context-injector/index.ts +0 -14
- package/oh-my-opencode/src/features/context-injector/injector.test.ts +0 -122
- package/oh-my-opencode/src/features/context-injector/injector.ts +0 -167
- package/oh-my-opencode/src/features/context-injector/types.ts +0 -91
- package/oh-my-opencode/src/features/hook-message-injector/constants.ts +0 -6
- package/oh-my-opencode/src/features/hook-message-injector/index.ts +0 -4
- package/oh-my-opencode/src/features/hook-message-injector/injector.ts +0 -195
- package/oh-my-opencode/src/features/hook-message-injector/types.ts +0 -47
- package/oh-my-opencode/src/features/opencode-skill-loader/async-loader.test.ts +0 -448
- package/oh-my-opencode/src/features/opencode-skill-loader/async-loader.ts +0 -180
- package/oh-my-opencode/src/features/opencode-skill-loader/blocking.test.ts +0 -210
- package/oh-my-opencode/src/features/opencode-skill-loader/blocking.ts +0 -62
- package/oh-my-opencode/src/features/opencode-skill-loader/discover-worker.ts +0 -59
- package/oh-my-opencode/src/features/opencode-skill-loader/index.ts +0 -4
- package/oh-my-opencode/src/features/opencode-skill-loader/loader.test.ts +0 -273
- package/oh-my-opencode/src/features/opencode-skill-loader/loader.ts +0 -259
- package/oh-my-opencode/src/features/opencode-skill-loader/merger.ts +0 -267
- package/oh-my-opencode/src/features/opencode-skill-loader/skill-content.test.ts +0 -267
- package/oh-my-opencode/src/features/opencode-skill-loader/skill-content.ts +0 -206
- package/oh-my-opencode/src/features/opencode-skill-loader/types.ts +0 -38
- package/oh-my-opencode/src/features/skill-mcp-manager/env-cleaner.test.ts +0 -201
- package/oh-my-opencode/src/features/skill-mcp-manager/env-cleaner.ts +0 -27
- package/oh-my-opencode/src/features/skill-mcp-manager/index.ts +0 -2
- package/oh-my-opencode/src/features/skill-mcp-manager/manager.test.ts +0 -611
- package/oh-my-opencode/src/features/skill-mcp-manager/manager.ts +0 -520
- package/oh-my-opencode/src/features/skill-mcp-manager/types.ts +0 -14
- package/oh-my-opencode/src/features/task-toast-manager/index.ts +0 -2
- package/oh-my-opencode/src/features/task-toast-manager/manager.test.ts +0 -249
- package/oh-my-opencode/src/features/task-toast-manager/manager.ts +0 -215
- package/oh-my-opencode/src/features/task-toast-manager/types.ts +0 -24
- package/oh-my-opencode/src/hooks/AGENTS.md +0 -73
- package/oh-my-opencode/src/hooks/agent-usage-reminder/constants.ts +0 -54
- package/oh-my-opencode/src/hooks/agent-usage-reminder/index.ts +0 -109
- package/oh-my-opencode/src/hooks/agent-usage-reminder/storage.ts +0 -42
- package/oh-my-opencode/src/hooks/agent-usage-reminder/types.ts +0 -6
- package/oh-my-opencode/src/hooks/anthropic-context-window-limit-recovery/executor.test.ts +0 -307
- package/oh-my-opencode/src/hooks/anthropic-context-window-limit-recovery/executor.ts +0 -485
- package/oh-my-opencode/src/hooks/anthropic-context-window-limit-recovery/index.ts +0 -151
- package/oh-my-opencode/src/hooks/anthropic-context-window-limit-recovery/parser.ts +0 -201
- package/oh-my-opencode/src/hooks/anthropic-context-window-limit-recovery/pruning-deduplication.test.ts +0 -33
- package/oh-my-opencode/src/hooks/anthropic-context-window-limit-recovery/pruning-deduplication.ts +0 -184
- package/oh-my-opencode/src/hooks/anthropic-context-window-limit-recovery/pruning-types.ts +0 -44
- package/oh-my-opencode/src/hooks/anthropic-context-window-limit-recovery/storage.test.ts +0 -77
- package/oh-my-opencode/src/hooks/anthropic-context-window-limit-recovery/storage.ts +0 -250
- package/oh-my-opencode/src/hooks/anthropic-context-window-limit-recovery/types.ts +0 -42
- package/oh-my-opencode/src/hooks/atlas/index.test.ts +0 -953
- package/oh-my-opencode/src/hooks/atlas/index.ts +0 -771
- package/oh-my-opencode/src/hooks/auto-slash-command/constants.ts +0 -12
- package/oh-my-opencode/src/hooks/auto-slash-command/detector.test.ts +0 -296
- package/oh-my-opencode/src/hooks/auto-slash-command/detector.ts +0 -65
- package/oh-my-opencode/src/hooks/auto-slash-command/executor.ts +0 -205
- package/oh-my-opencode/src/hooks/auto-slash-command/index.test.ts +0 -254
- package/oh-my-opencode/src/hooks/auto-slash-command/index.ts +0 -89
- package/oh-my-opencode/src/hooks/auto-slash-command/types.ts +0 -23
- package/oh-my-opencode/src/hooks/auto-update-checker/cache.ts +0 -93
- package/oh-my-opencode/src/hooks/auto-update-checker/checker.test.ts +0 -24
- package/oh-my-opencode/src/hooks/auto-update-checker/checker.ts +0 -284
- package/oh-my-opencode/src/hooks/auto-update-checker/constants.ts +0 -64
- package/oh-my-opencode/src/hooks/auto-update-checker/index.test.ts +0 -254
- package/oh-my-opencode/src/hooks/auto-update-checker/index.ts +0 -260
- package/oh-my-opencode/src/hooks/auto-update-checker/types.ts +0 -29
- package/oh-my-opencode/src/hooks/background-compaction/index.ts +0 -87
- package/oh-my-opencode/src/hooks/background-notification/index.ts +0 -28
- package/oh-my-opencode/src/hooks/background-notification/types.ts +0 -5
- package/oh-my-opencode/src/hooks/claude-code-hooks/AGENTS.md +0 -70
- package/oh-my-opencode/src/hooks/claude-code-hooks/config-loader.ts +0 -107
- package/oh-my-opencode/src/hooks/claude-code-hooks/config.ts +0 -103
- package/oh-my-opencode/src/hooks/claude-code-hooks/index.ts +0 -401
- package/oh-my-opencode/src/hooks/claude-code-hooks/plugin-config.ts +0 -12
- package/oh-my-opencode/src/hooks/claude-code-hooks/post-tool-use.ts +0 -199
- package/oh-my-opencode/src/hooks/claude-code-hooks/pre-compact.ts +0 -109
- package/oh-my-opencode/src/hooks/claude-code-hooks/pre-tool-use.ts +0 -172
- package/oh-my-opencode/src/hooks/claude-code-hooks/stop.ts +0 -118
- package/oh-my-opencode/src/hooks/claude-code-hooks/todo.ts +0 -76
- package/oh-my-opencode/src/hooks/claude-code-hooks/tool-input-cache.ts +0 -47
- package/oh-my-opencode/src/hooks/claude-code-hooks/transcript.ts +0 -252
- package/oh-my-opencode/src/hooks/claude-code-hooks/types.ts +0 -204
- package/oh-my-opencode/src/hooks/claude-code-hooks/user-prompt-submit.ts +0 -117
- package/oh-my-opencode/src/hooks/comment-checker/cli.test.ts +0 -68
- package/oh-my-opencode/src/hooks/comment-checker/cli.ts +0 -221
- package/oh-my-opencode/src/hooks/comment-checker/downloader.ts +0 -196
- package/oh-my-opencode/src/hooks/comment-checker/index.ts +0 -171
- package/oh-my-opencode/src/hooks/comment-checker/types.ts +0 -33
- package/oh-my-opencode/src/hooks/compaction-context-injector/index.ts +0 -61
- package/oh-my-opencode/src/hooks/context-window-monitor.ts +0 -99
- package/oh-my-opencode/src/hooks/delegate-task-retry/index.test.ts +0 -119
- package/oh-my-opencode/src/hooks/delegate-task-retry/index.ts +0 -136
- package/oh-my-opencode/src/hooks/directory-agents-injector/constants.ts +0 -9
- package/oh-my-opencode/src/hooks/directory-agents-injector/index.ts +0 -182
- package/oh-my-opencode/src/hooks/directory-agents-injector/storage.ts +0 -48
- package/oh-my-opencode/src/hooks/directory-agents-injector/types.ts +0 -5
- package/oh-my-opencode/src/hooks/directory-readme-injector/constants.ts +0 -9
- package/oh-my-opencode/src/hooks/directory-readme-injector/index.ts +0 -177
- package/oh-my-opencode/src/hooks/directory-readme-injector/storage.ts +0 -48
- package/oh-my-opencode/src/hooks/directory-readme-injector/types.ts +0 -5
- package/oh-my-opencode/src/hooks/edit-error-recovery/index.test.ts +0 -126
- package/oh-my-opencode/src/hooks/edit-error-recovery/index.ts +0 -57
- package/oh-my-opencode/src/hooks/empty-task-response-detector.ts +0 -27
- package/oh-my-opencode/src/hooks/index.ts +0 -32
- package/oh-my-opencode/src/hooks/interactive-bash-session/constants.ts +0 -15
- package/oh-my-opencode/src/hooks/interactive-bash-session/index.ts +0 -262
- package/oh-my-opencode/src/hooks/interactive-bash-session/storage.ts +0 -59
- package/oh-my-opencode/src/hooks/interactive-bash-session/types.ts +0 -11
- package/oh-my-opencode/src/hooks/keyword-detector/constants.ts +0 -300
- package/oh-my-opencode/src/hooks/keyword-detector/detector.ts +0 -52
- package/oh-my-opencode/src/hooks/keyword-detector/index.test.ts +0 -529
- package/oh-my-opencode/src/hooks/keyword-detector/index.ts +0 -100
- package/oh-my-opencode/src/hooks/keyword-detector/types.ts +0 -4
- package/oh-my-opencode/src/hooks/non-interactive-env/constants.ts +0 -70
- package/oh-my-opencode/src/hooks/non-interactive-env/detector.ts +0 -19
- package/oh-my-opencode/src/hooks/non-interactive-env/index.test.ts +0 -323
- package/oh-my-opencode/src/hooks/non-interactive-env/index.ts +0 -63
- package/oh-my-opencode/src/hooks/non-interactive-env/types.ts +0 -3
- package/oh-my-opencode/src/hooks/prometheus-md-only/constants.ts +0 -32
- package/oh-my-opencode/src/hooks/prometheus-md-only/index.test.ts +0 -488
- package/oh-my-opencode/src/hooks/prometheus-md-only/index.ts +0 -136
- package/oh-my-opencode/src/hooks/ralph-loop/constants.ts +0 -5
- package/oh-my-opencode/src/hooks/ralph-loop/index.test.ts +0 -835
- package/oh-my-opencode/src/hooks/ralph-loop/index.ts +0 -417
- package/oh-my-opencode/src/hooks/ralph-loop/storage.ts +0 -115
- package/oh-my-opencode/src/hooks/ralph-loop/types.ts +0 -19
- package/oh-my-opencode/src/hooks/rules-injector/constants.ts +0 -30
- package/oh-my-opencode/src/hooks/rules-injector/finder.test.ts +0 -381
- package/oh-my-opencode/src/hooks/rules-injector/finder.ts +0 -263
- package/oh-my-opencode/src/hooks/rules-injector/index.ts +0 -223
- package/oh-my-opencode/src/hooks/rules-injector/matcher.ts +0 -63
- package/oh-my-opencode/src/hooks/rules-injector/parser.test.ts +0 -226
- package/oh-my-opencode/src/hooks/rules-injector/parser.ts +0 -211
- package/oh-my-opencode/src/hooks/rules-injector/storage.ts +0 -59
- package/oh-my-opencode/src/hooks/rules-injector/types.ts +0 -57
- package/oh-my-opencode/src/hooks/session-notification-utils.ts +0 -140
- package/oh-my-opencode/src/hooks/session-notification.test.ts +0 -361
- package/oh-my-opencode/src/hooks/session-notification.ts +0 -330
- package/oh-my-opencode/src/hooks/session-recovery/constants.ts +0 -10
- package/oh-my-opencode/src/hooks/session-recovery/index.test.ts +0 -223
- package/oh-my-opencode/src/hooks/session-recovery/index.ts +0 -435
- package/oh-my-opencode/src/hooks/session-recovery/storage.ts +0 -390
- package/oh-my-opencode/src/hooks/session-recovery/types.ts +0 -98
- package/oh-my-opencode/src/hooks/start-work/index.test.ts +0 -402
- package/oh-my-opencode/src/hooks/start-work/index.ts +0 -242
- package/oh-my-opencode/src/hooks/task-resume-info/index.ts +0 -36
- package/oh-my-opencode/src/hooks/think-mode/detector.ts +0 -57
- package/oh-my-opencode/src/hooks/think-mode/index.test.ts +0 -353
- package/oh-my-opencode/src/hooks/think-mode/index.ts +0 -89
- package/oh-my-opencode/src/hooks/think-mode/switcher.test.ts +0 -461
- package/oh-my-opencode/src/hooks/think-mode/switcher.ts +0 -222
- package/oh-my-opencode/src/hooks/think-mode/types.ts +0 -21
- package/oh-my-opencode/src/hooks/thinking-block-validator/index.ts +0 -171
- package/oh-my-opencode/src/hooks/todo-continuation-enforcer.test.ts +0 -876
- package/oh-my-opencode/src/hooks/todo-continuation-enforcer.ts +0 -480
- package/oh-my-opencode/src/hooks/tool-output-truncator.test.ts +0 -168
- package/oh-my-opencode/src/hooks/tool-output-truncator.ts +0 -61
- package/oh-my-opencode/src/index.ts +0 -589
- package/oh-my-opencode/src/mcp/AGENTS.md +0 -70
- package/oh-my-opencode/src/mcp/context7.ts +0 -6
- package/oh-my-opencode/src/mcp/grep-app.ts +0 -6
- package/oh-my-opencode/src/mcp/index.test.ts +0 -86
- package/oh-my-opencode/src/mcp/index.ts +0 -32
- package/oh-my-opencode/src/mcp/types.ts +0 -9
- package/oh-my-opencode/src/mcp/websearch.ts +0 -10
- package/oh-my-opencode/src/plugin-config.test.ts +0 -119
- package/oh-my-opencode/src/plugin-config.ts +0 -135
- package/oh-my-opencode/src/plugin-handlers/config-handler.test.ts +0 -103
- package/oh-my-opencode/src/plugin-handlers/config-handler.ts +0 -399
- package/oh-my-opencode/src/plugin-handlers/index.ts +0 -1
- package/oh-my-opencode/src/plugin-state.ts +0 -30
- package/oh-my-opencode/src/shared/AGENTS.md +0 -63
- package/oh-my-opencode/src/shared/agent-tool-restrictions.ts +0 -44
- package/oh-my-opencode/src/shared/agent-variant.test.ts +0 -83
- package/oh-my-opencode/src/shared/agent-variant.ts +0 -40
- package/oh-my-opencode/src/shared/claude-config-dir.test.ts +0 -60
- package/oh-my-opencode/src/shared/claude-config-dir.ts +0 -11
- package/oh-my-opencode/src/shared/command-executor.ts +0 -225
- package/oh-my-opencode/src/shared/config-errors.ts +0 -18
- package/oh-my-opencode/src/shared/config-path.ts +0 -47
- package/oh-my-opencode/src/shared/data-path.ts +0 -22
- package/oh-my-opencode/src/shared/deep-merge.test.ts +0 -336
- package/oh-my-opencode/src/shared/deep-merge.ts +0 -53
- package/oh-my-opencode/src/shared/dynamic-truncator.ts +0 -193
- package/oh-my-opencode/src/shared/external-plugin-detector.test.ts +0 -133
- package/oh-my-opencode/src/shared/external-plugin-detector.ts +0 -132
- package/oh-my-opencode/src/shared/file-reference-resolver.ts +0 -85
- package/oh-my-opencode/src/shared/file-utils.ts +0 -40
- package/oh-my-opencode/src/shared/first-message-variant.test.ts +0 -32
- package/oh-my-opencode/src/shared/first-message-variant.ts +0 -28
- package/oh-my-opencode/src/shared/frontmatter.test.ts +0 -262
- package/oh-my-opencode/src/shared/frontmatter.ts +0 -31
- package/oh-my-opencode/src/shared/hook-disabled.ts +0 -22
- package/oh-my-opencode/src/shared/index.ts +0 -29
- package/oh-my-opencode/src/shared/jsonc-parser.test.ts +0 -266
- package/oh-my-opencode/src/shared/jsonc-parser.ts +0 -66
- package/oh-my-opencode/src/shared/logger.ts +0 -20
- package/oh-my-opencode/src/shared/migration.test.ts +0 -602
- package/oh-my-opencode/src/shared/migration.ts +0 -191
- package/oh-my-opencode/src/shared/model-resolver.test.ts +0 -101
- package/oh-my-opencode/src/shared/model-resolver.ts +0 -35
- package/oh-my-opencode/src/shared/model-sanitizer.ts +0 -12
- package/oh-my-opencode/src/shared/opencode-config-dir.test.ts +0 -318
- package/oh-my-opencode/src/shared/opencode-config-dir.ts +0 -142
- package/oh-my-opencode/src/shared/opencode-version.test.ts +0 -223
- package/oh-my-opencode/src/shared/opencode-version.ts +0 -72
- package/oh-my-opencode/src/shared/pattern-matcher.ts +0 -29
- package/oh-my-opencode/src/shared/permission-compat.test.ts +0 -134
- package/oh-my-opencode/src/shared/permission-compat.ts +0 -77
- package/oh-my-opencode/src/shared/session-cursor.test.ts +0 -66
- package/oh-my-opencode/src/shared/session-cursor.ts +0 -85
- package/oh-my-opencode/src/shared/shell-env.test.ts +0 -278
- package/oh-my-opencode/src/shared/shell-env.ts +0 -111
- package/oh-my-opencode/src/shared/snake-case.ts +0 -49
- package/oh-my-opencode/src/shared/system-directive.ts +0 -40
- package/oh-my-opencode/src/shared/tool-name.ts +0 -26
- package/oh-my-opencode/src/shared/zip-extractor.ts +0 -83
- package/oh-my-opencode/src/tools/AGENTS.md +0 -74
- package/oh-my-opencode/src/tools/ast-grep/cli.ts +0 -230
- package/oh-my-opencode/src/tools/ast-grep/constants.ts +0 -261
- package/oh-my-opencode/src/tools/ast-grep/downloader.ts +0 -128
- package/oh-my-opencode/src/tools/ast-grep/index.ts +0 -13
- package/oh-my-opencode/src/tools/ast-grep/tools.ts +0 -112
- package/oh-my-opencode/src/tools/ast-grep/types.ts +0 -61
- package/oh-my-opencode/src/tools/ast-grep/utils.ts +0 -102
- package/oh-my-opencode/src/tools/background-task/constants.ts +0 -7
- package/oh-my-opencode/src/tools/background-task/index.ts +0 -7
- package/oh-my-opencode/src/tools/background-task/tools.ts +0 -479
- package/oh-my-opencode/src/tools/background-task/types.ts +0 -16
- package/oh-my-opencode/src/tools/call-omo-agent/constants.ts +0 -7
- package/oh-my-opencode/src/tools/call-omo-agent/index.ts +0 -3
- package/oh-my-opencode/src/tools/call-omo-agent/tools.ts +0 -338
- package/oh-my-opencode/src/tools/call-omo-agent/types.ts +0 -27
- package/oh-my-opencode/src/tools/delegate-task/constants.ts +0 -205
- package/oh-my-opencode/src/tools/delegate-task/index.ts +0 -3
- package/oh-my-opencode/src/tools/delegate-task/tools.test.ts +0 -1575
- package/oh-my-opencode/src/tools/delegate-task/tools.ts +0 -885
- package/oh-my-opencode/src/tools/delegate-task/types.ts +0 -9
- package/oh-my-opencode/src/tools/glob/cli.test.ts +0 -158
- package/oh-my-opencode/src/tools/glob/cli.ts +0 -191
- package/oh-my-opencode/src/tools/glob/constants.ts +0 -12
- package/oh-my-opencode/src/tools/glob/index.ts +0 -3
- package/oh-my-opencode/src/tools/glob/tools.ts +0 -41
- package/oh-my-opencode/src/tools/glob/types.ts +0 -22
- package/oh-my-opencode/src/tools/glob/utils.ts +0 -26
- package/oh-my-opencode/src/tools/grep/cli.ts +0 -229
- package/oh-my-opencode/src/tools/grep/constants.ts +0 -127
- package/oh-my-opencode/src/tools/grep/downloader.test.ts +0 -103
- package/oh-my-opencode/src/tools/grep/downloader.ts +0 -145
- package/oh-my-opencode/src/tools/grep/index.ts +0 -3
- package/oh-my-opencode/src/tools/grep/tools.ts +0 -40
- package/oh-my-opencode/src/tools/grep/types.ts +0 -39
- package/oh-my-opencode/src/tools/grep/utils.ts +0 -53
- package/oh-my-opencode/src/tools/index.ts +0 -72
- package/oh-my-opencode/src/tools/interactive-bash/constants.ts +0 -18
- package/oh-my-opencode/src/tools/interactive-bash/index.ts +0 -4
- package/oh-my-opencode/src/tools/interactive-bash/tools.ts +0 -126
- package/oh-my-opencode/src/tools/interactive-bash/utils.ts +0 -71
- package/oh-my-opencode/src/tools/look-at/constants.ts +0 -3
- package/oh-my-opencode/src/tools/look-at/index.ts +0 -3
- package/oh-my-opencode/src/tools/look-at/tools.test.ts +0 -73
- package/oh-my-opencode/src/tools/look-at/tools.ts +0 -173
- package/oh-my-opencode/src/tools/look-at/types.ts +0 -4
- package/oh-my-opencode/src/tools/lsp/client.ts +0 -596
- package/oh-my-opencode/src/tools/lsp/config.test.ts +0 -130
- package/oh-my-opencode/src/tools/lsp/config.ts +0 -285
- package/oh-my-opencode/src/tools/lsp/constants.ts +0 -390
- package/oh-my-opencode/src/tools/lsp/index.ts +0 -7
- package/oh-my-opencode/src/tools/lsp/tools.ts +0 -261
- package/oh-my-opencode/src/tools/lsp/types.ts +0 -124
- package/oh-my-opencode/src/tools/lsp/utils.ts +0 -406
- package/oh-my-opencode/src/tools/session-manager/constants.ts +0 -97
- package/oh-my-opencode/src/tools/session-manager/index.ts +0 -3
- package/oh-my-opencode/src/tools/session-manager/storage.test.ts +0 -315
- package/oh-my-opencode/src/tools/session-manager/storage.ts +0 -238
- package/oh-my-opencode/src/tools/session-manager/tools.test.ts +0 -124
- package/oh-my-opencode/src/tools/session-manager/tools.ts +0 -146
- package/oh-my-opencode/src/tools/session-manager/types.ts +0 -99
- package/oh-my-opencode/src/tools/session-manager/utils.test.ts +0 -160
- package/oh-my-opencode/src/tools/session-manager/utils.ts +0 -199
- package/oh-my-opencode/src/tools/skill/constants.ts +0 -8
- package/oh-my-opencode/src/tools/skill/index.ts +0 -3
- package/oh-my-opencode/src/tools/skill/tools.test.ts +0 -239
- package/oh-my-opencode/src/tools/skill/tools.ts +0 -200
- package/oh-my-opencode/src/tools/skill/types.ts +0 -31
- package/oh-my-opencode/src/tools/skill-mcp/constants.ts +0 -3
- package/oh-my-opencode/src/tools/skill-mcp/index.ts +0 -3
- package/oh-my-opencode/src/tools/skill-mcp/tools.test.ts +0 -215
- package/oh-my-opencode/src/tools/skill-mcp/tools.ts +0 -172
- package/oh-my-opencode/src/tools/skill-mcp/types.ts +0 -8
- package/oh-my-opencode/src/tools/slashcommand/index.ts +0 -2
- package/oh-my-opencode/src/tools/slashcommand/tools.ts +0 -252
- package/oh-my-opencode/src/tools/slashcommand/types.ts +0 -28
- package/oh-my-opencode/test-setup.ts +0 -6
- package/oh-my-opencode/tsconfig.json +0 -20
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { relative, resolve } from "node:path";
|
|
5
|
-
import { findProjectRoot, findRuleFiles } from "./finder";
|
|
6
|
-
import {
|
|
7
|
-
createContentHash,
|
|
8
|
-
isDuplicateByContentHash,
|
|
9
|
-
isDuplicateByRealPath,
|
|
10
|
-
shouldApplyRule,
|
|
11
|
-
} from "./matcher";
|
|
12
|
-
import { parseRuleFrontmatter } from "./parser";
|
|
13
|
-
import {
|
|
14
|
-
clearInjectedRules,
|
|
15
|
-
loadInjectedRules,
|
|
16
|
-
saveInjectedRules,
|
|
17
|
-
} from "./storage";
|
|
18
|
-
import { createDynamicTruncator } from "../../shared/dynamic-truncator";
|
|
19
|
-
|
|
20
|
-
interface ToolExecuteInput {
|
|
21
|
-
tool: string;
|
|
22
|
-
sessionID: string;
|
|
23
|
-
callID: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface ToolExecuteOutput {
|
|
27
|
-
title: string;
|
|
28
|
-
output: string;
|
|
29
|
-
metadata: unknown;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface ToolExecuteBeforeOutput {
|
|
33
|
-
args: unknown;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface BatchToolCall {
|
|
37
|
-
tool: string;
|
|
38
|
-
parameters: Record<string, unknown>;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface EventInput {
|
|
42
|
-
event: {
|
|
43
|
-
type: string;
|
|
44
|
-
properties?: unknown;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
interface RuleToInject {
|
|
49
|
-
relativePath: string;
|
|
50
|
-
matchReason: string;
|
|
51
|
-
content: string;
|
|
52
|
-
distance: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const TRACKED_TOOLS = ["read", "write", "edit", "multiedit"];
|
|
56
|
-
|
|
57
|
-
export function createRulesInjectorHook(ctx: PluginInput) {
|
|
58
|
-
const sessionCaches = new Map<
|
|
59
|
-
string,
|
|
60
|
-
{ contentHashes: Set<string>; realPaths: Set<string> }
|
|
61
|
-
>();
|
|
62
|
-
const pendingBatchFiles = new Map<string, string[]>();
|
|
63
|
-
const truncator = createDynamicTruncator(ctx);
|
|
64
|
-
|
|
65
|
-
function getSessionCache(sessionID: string): {
|
|
66
|
-
contentHashes: Set<string>;
|
|
67
|
-
realPaths: Set<string>;
|
|
68
|
-
} {
|
|
69
|
-
if (!sessionCaches.has(sessionID)) {
|
|
70
|
-
sessionCaches.set(sessionID, loadInjectedRules(sessionID));
|
|
71
|
-
}
|
|
72
|
-
return sessionCaches.get(sessionID)!;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function resolveFilePath(path: string): string | null {
|
|
76
|
-
if (!path) return null;
|
|
77
|
-
if (path.startsWith("/")) return path;
|
|
78
|
-
return resolve(ctx.directory, path);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function processFilePathForInjection(
|
|
82
|
-
filePath: string,
|
|
83
|
-
sessionID: string,
|
|
84
|
-
output: ToolExecuteOutput
|
|
85
|
-
): Promise<void> {
|
|
86
|
-
const resolved = resolveFilePath(filePath);
|
|
87
|
-
if (!resolved) return;
|
|
88
|
-
|
|
89
|
-
const projectRoot = findProjectRoot(resolved);
|
|
90
|
-
const cache = getSessionCache(sessionID);
|
|
91
|
-
const home = homedir();
|
|
92
|
-
|
|
93
|
-
const ruleFileCandidates = findRuleFiles(projectRoot, home, resolved);
|
|
94
|
-
const toInject: RuleToInject[] = [];
|
|
95
|
-
|
|
96
|
-
for (const candidate of ruleFileCandidates) {
|
|
97
|
-
if (isDuplicateByRealPath(candidate.realPath, cache.realPaths)) continue;
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
const rawContent = readFileSync(candidate.path, "utf-8");
|
|
101
|
-
const { metadata, body } = parseRuleFrontmatter(rawContent);
|
|
102
|
-
|
|
103
|
-
let matchReason: string;
|
|
104
|
-
if (candidate.isSingleFile) {
|
|
105
|
-
matchReason = "copilot-instructions (always apply)";
|
|
106
|
-
} else {
|
|
107
|
-
const matchResult = shouldApplyRule(metadata, resolved, projectRoot);
|
|
108
|
-
if (!matchResult.applies) continue;
|
|
109
|
-
matchReason = matchResult.reason ?? "matched";
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const contentHash = createContentHash(body);
|
|
113
|
-
if (isDuplicateByContentHash(contentHash, cache.contentHashes)) continue;
|
|
114
|
-
|
|
115
|
-
const relativePath = projectRoot
|
|
116
|
-
? relative(projectRoot, candidate.path)
|
|
117
|
-
: candidate.path;
|
|
118
|
-
|
|
119
|
-
toInject.push({
|
|
120
|
-
relativePath,
|
|
121
|
-
matchReason,
|
|
122
|
-
content: body,
|
|
123
|
-
distance: candidate.distance,
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
cache.realPaths.add(candidate.realPath);
|
|
127
|
-
cache.contentHashes.add(contentHash);
|
|
128
|
-
} catch {}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (toInject.length === 0) return;
|
|
132
|
-
|
|
133
|
-
toInject.sort((a, b) => a.distance - b.distance);
|
|
134
|
-
|
|
135
|
-
for (const rule of toInject) {
|
|
136
|
-
const { result, truncated } = await truncator.truncate(sessionID, rule.content);
|
|
137
|
-
const truncationNotice = truncated
|
|
138
|
-
? `\n\n[Note: Content was truncated to save context window space. For full context, please read the file directly: ${rule.relativePath}]`
|
|
139
|
-
: "";
|
|
140
|
-
output.output += `\n\n[Rule: ${rule.relativePath}]\n[Match: ${rule.matchReason}]\n${result}${truncationNotice}`;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
saveInjectedRules(sessionID, cache);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function extractFilePathFromToolCall(call: BatchToolCall): string | null {
|
|
147
|
-
const params = call.parameters;
|
|
148
|
-
return (params?.filePath ?? params?.file_path ?? params?.path) as string | null;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const toolExecuteBefore = async (
|
|
152
|
-
input: ToolExecuteInput,
|
|
153
|
-
output: ToolExecuteBeforeOutput
|
|
154
|
-
) => {
|
|
155
|
-
if (input.tool.toLowerCase() !== "batch") return;
|
|
156
|
-
|
|
157
|
-
const args = output.args as { tool_calls?: BatchToolCall[] } | undefined;
|
|
158
|
-
if (!args?.tool_calls) return;
|
|
159
|
-
|
|
160
|
-
const filePaths: string[] = [];
|
|
161
|
-
for (const call of args.tool_calls) {
|
|
162
|
-
if (TRACKED_TOOLS.includes(call.tool.toLowerCase())) {
|
|
163
|
-
const filePath = extractFilePathFromToolCall(call);
|
|
164
|
-
if (filePath) {
|
|
165
|
-
filePaths.push(filePath);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (filePaths.length > 0) {
|
|
171
|
-
pendingBatchFiles.set(input.callID, filePaths);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const toolExecuteAfter = async (
|
|
176
|
-
input: ToolExecuteInput,
|
|
177
|
-
output: ToolExecuteOutput
|
|
178
|
-
) => {
|
|
179
|
-
const toolName = input.tool.toLowerCase();
|
|
180
|
-
|
|
181
|
-
if (TRACKED_TOOLS.includes(toolName)) {
|
|
182
|
-
await processFilePathForInjection(output.title, input.sessionID, output);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (toolName === "batch") {
|
|
187
|
-
const filePaths = pendingBatchFiles.get(input.callID);
|
|
188
|
-
if (filePaths) {
|
|
189
|
-
for (const filePath of filePaths) {
|
|
190
|
-
await processFilePathForInjection(filePath, input.sessionID, output);
|
|
191
|
-
}
|
|
192
|
-
pendingBatchFiles.delete(input.callID);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const eventHandler = async ({ event }: EventInput) => {
|
|
198
|
-
const props = event.properties as Record<string, unknown> | undefined;
|
|
199
|
-
|
|
200
|
-
if (event.type === "session.deleted") {
|
|
201
|
-
const sessionInfo = props?.info as { id?: string } | undefined;
|
|
202
|
-
if (sessionInfo?.id) {
|
|
203
|
-
sessionCaches.delete(sessionInfo.id);
|
|
204
|
-
clearInjectedRules(sessionInfo.id);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (event.type === "session.compacted") {
|
|
209
|
-
const sessionID = (props?.sessionID ??
|
|
210
|
-
(props?.info as { id?: string } | undefined)?.id) as string | undefined;
|
|
211
|
-
if (sessionID) {
|
|
212
|
-
sessionCaches.delete(sessionID);
|
|
213
|
-
clearInjectedRules(sessionID);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
return {
|
|
219
|
-
"tool.execute.before": toolExecuteBefore,
|
|
220
|
-
"tool.execute.after": toolExecuteAfter,
|
|
221
|
-
event: eventHandler,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { createHash } from "crypto"
|
|
2
|
-
import { relative } from "node:path"
|
|
3
|
-
import picomatch from "picomatch"
|
|
4
|
-
import type { RuleMetadata } from "./types"
|
|
5
|
-
|
|
6
|
-
export interface MatchResult {
|
|
7
|
-
applies: boolean
|
|
8
|
-
reason?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Check if a rule should apply to the current file based on metadata
|
|
13
|
-
*/
|
|
14
|
-
export function shouldApplyRule(
|
|
15
|
-
metadata: RuleMetadata,
|
|
16
|
-
currentFilePath: string,
|
|
17
|
-
projectRoot: string | null
|
|
18
|
-
): MatchResult {
|
|
19
|
-
if (metadata.alwaysApply === true) {
|
|
20
|
-
return { applies: true, reason: "alwaysApply" }
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const globs = metadata.globs
|
|
24
|
-
if (!globs) {
|
|
25
|
-
return { applies: false }
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const patterns = Array.isArray(globs) ? globs : [globs]
|
|
29
|
-
if (patterns.length === 0) {
|
|
30
|
-
return { applies: false }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const relativePath = projectRoot ? relative(projectRoot, currentFilePath) : currentFilePath
|
|
34
|
-
|
|
35
|
-
for (const pattern of patterns) {
|
|
36
|
-
if (picomatch.isMatch(relativePath, pattern, { dot: true, bash: true })) {
|
|
37
|
-
return { applies: true, reason: `glob: ${pattern}` }
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return { applies: false }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Check if realPath already exists in cache (symlink deduplication)
|
|
46
|
-
*/
|
|
47
|
-
export function isDuplicateByRealPath(realPath: string, cache: Set<string>): boolean {
|
|
48
|
-
return cache.has(realPath)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Create SHA-256 hash of content, truncated to 16 chars
|
|
53
|
-
*/
|
|
54
|
-
export function createContentHash(content: string): string {
|
|
55
|
-
return createHash("sha256").update(content).digest("hex").slice(0, 16)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Check if content hash already exists in cache
|
|
60
|
-
*/
|
|
61
|
-
export function isDuplicateByContentHash(hash: string, cache: Set<string>): boolean {
|
|
62
|
-
return cache.has(hash)
|
|
63
|
-
}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
import { parseRuleFrontmatter } from "./parser";
|
|
3
|
-
|
|
4
|
-
describe("parseRuleFrontmatter", () => {
|
|
5
|
-
describe("applyTo field (GitHub Copilot format)", () => {
|
|
6
|
-
it("should parse applyTo as single string", () => {
|
|
7
|
-
// #given frontmatter with applyTo as single string
|
|
8
|
-
const content = `---
|
|
9
|
-
applyTo: "*.ts"
|
|
10
|
-
---
|
|
11
|
-
Rule content here`;
|
|
12
|
-
|
|
13
|
-
// #when parsing
|
|
14
|
-
const result = parseRuleFrontmatter(content);
|
|
15
|
-
|
|
16
|
-
// #then globs should contain the pattern
|
|
17
|
-
expect(result.metadata.globs).toBe("*.ts");
|
|
18
|
-
expect(result.body).toBe("Rule content here");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should parse applyTo as inline array", () => {
|
|
22
|
-
// #given frontmatter with applyTo as inline array
|
|
23
|
-
const content = `---
|
|
24
|
-
applyTo: ["*.ts", "*.tsx"]
|
|
25
|
-
---
|
|
26
|
-
Rule content`;
|
|
27
|
-
|
|
28
|
-
// #when parsing
|
|
29
|
-
const result = parseRuleFrontmatter(content);
|
|
30
|
-
|
|
31
|
-
// #then globs should be array
|
|
32
|
-
expect(result.metadata.globs).toEqual(["*.ts", "*.tsx"]);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("should parse applyTo as multi-line array", () => {
|
|
36
|
-
// #given frontmatter with applyTo as multi-line array
|
|
37
|
-
const content = `---
|
|
38
|
-
applyTo:
|
|
39
|
-
- "*.ts"
|
|
40
|
-
- "src/**/*.js"
|
|
41
|
-
---
|
|
42
|
-
Content`;
|
|
43
|
-
|
|
44
|
-
// #when parsing
|
|
45
|
-
const result = parseRuleFrontmatter(content);
|
|
46
|
-
|
|
47
|
-
// #then globs should be array
|
|
48
|
-
expect(result.metadata.globs).toEqual(["*.ts", "src/**/*.js"]);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("should parse applyTo as comma-separated string", () => {
|
|
52
|
-
// #given frontmatter with comma-separated applyTo
|
|
53
|
-
const content = `---
|
|
54
|
-
applyTo: "*.ts, *.js"
|
|
55
|
-
---
|
|
56
|
-
Content`;
|
|
57
|
-
|
|
58
|
-
// #when parsing
|
|
59
|
-
const result = parseRuleFrontmatter(content);
|
|
60
|
-
|
|
61
|
-
// #then globs should be array
|
|
62
|
-
expect(result.metadata.globs).toEqual(["*.ts", "*.js"]);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("should merge applyTo and globs when both present", () => {
|
|
66
|
-
// #given frontmatter with both applyTo and globs
|
|
67
|
-
const content = `---
|
|
68
|
-
globs: "*.md"
|
|
69
|
-
applyTo: "*.ts"
|
|
70
|
-
---
|
|
71
|
-
Content`;
|
|
72
|
-
|
|
73
|
-
// #when parsing
|
|
74
|
-
const result = parseRuleFrontmatter(content);
|
|
75
|
-
|
|
76
|
-
// #then should merge both into globs array
|
|
77
|
-
expect(result.metadata.globs).toEqual(["*.md", "*.ts"]);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("should parse applyTo without quotes", () => {
|
|
81
|
-
// #given frontmatter with unquoted applyTo
|
|
82
|
-
const content = `---
|
|
83
|
-
applyTo: **/*.py
|
|
84
|
-
---
|
|
85
|
-
Python rules`;
|
|
86
|
-
|
|
87
|
-
// #when parsing
|
|
88
|
-
const result = parseRuleFrontmatter(content);
|
|
89
|
-
|
|
90
|
-
// #then should parse correctly
|
|
91
|
-
expect(result.metadata.globs).toBe("**/*.py");
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("should parse applyTo with description", () => {
|
|
95
|
-
// #given frontmatter with applyTo and description (GitHub Copilot style)
|
|
96
|
-
const content = `---
|
|
97
|
-
applyTo: "**/*.ts,**/*.tsx"
|
|
98
|
-
description: "TypeScript coding standards"
|
|
99
|
-
---
|
|
100
|
-
# TypeScript Guidelines`;
|
|
101
|
-
|
|
102
|
-
// #when parsing
|
|
103
|
-
const result = parseRuleFrontmatter(content);
|
|
104
|
-
|
|
105
|
-
// #then should parse both fields
|
|
106
|
-
expect(result.metadata.globs).toEqual(["**/*.ts", "**/*.tsx"]);
|
|
107
|
-
expect(result.metadata.description).toBe("TypeScript coding standards");
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe("existing globs/paths parsing (backward compatibility)", () => {
|
|
112
|
-
it("should still parse globs field correctly", () => {
|
|
113
|
-
// #given existing globs format
|
|
114
|
-
const content = `---
|
|
115
|
-
globs: ["*.py", "**/*.ts"]
|
|
116
|
-
---
|
|
117
|
-
Python/TypeScript rules`;
|
|
118
|
-
|
|
119
|
-
// #when parsing
|
|
120
|
-
const result = parseRuleFrontmatter(content);
|
|
121
|
-
|
|
122
|
-
// #then should work as before
|
|
123
|
-
expect(result.metadata.globs).toEqual(["*.py", "**/*.ts"]);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("should still parse paths field as alias", () => {
|
|
127
|
-
// #given paths field (Claude Code style)
|
|
128
|
-
const content = `---
|
|
129
|
-
paths: ["src/**"]
|
|
130
|
-
---
|
|
131
|
-
Source rules`;
|
|
132
|
-
|
|
133
|
-
// #when parsing
|
|
134
|
-
const result = parseRuleFrontmatter(content);
|
|
135
|
-
|
|
136
|
-
// #then should map to globs
|
|
137
|
-
expect(result.metadata.globs).toEqual(["src/**"]);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("should parse alwaysApply correctly", () => {
|
|
141
|
-
// #given frontmatter with alwaysApply
|
|
142
|
-
const content = `---
|
|
143
|
-
alwaysApply: true
|
|
144
|
-
---
|
|
145
|
-
Always apply this rule`;
|
|
146
|
-
|
|
147
|
-
// #when parsing
|
|
148
|
-
const result = parseRuleFrontmatter(content);
|
|
149
|
-
|
|
150
|
-
// #then should recognize alwaysApply
|
|
151
|
-
expect(result.metadata.alwaysApply).toBe(true);
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
describe("no frontmatter", () => {
|
|
156
|
-
it("should return empty metadata and full body for plain markdown", () => {
|
|
157
|
-
// #given markdown without frontmatter
|
|
158
|
-
const content = `# Instructions
|
|
159
|
-
This is a plain rule file without frontmatter.`;
|
|
160
|
-
|
|
161
|
-
// #when parsing
|
|
162
|
-
const result = parseRuleFrontmatter(content);
|
|
163
|
-
|
|
164
|
-
// #then should have empty metadata
|
|
165
|
-
expect(result.metadata).toEqual({});
|
|
166
|
-
expect(result.body).toBe(content);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("should handle empty content", () => {
|
|
170
|
-
// #given empty content
|
|
171
|
-
const content = "";
|
|
172
|
-
|
|
173
|
-
// #when parsing
|
|
174
|
-
const result = parseRuleFrontmatter(content);
|
|
175
|
-
|
|
176
|
-
// #then should return empty metadata and body
|
|
177
|
-
expect(result.metadata).toEqual({});
|
|
178
|
-
expect(result.body).toBe("");
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
describe("edge cases", () => {
|
|
183
|
-
it("should handle frontmatter with only applyTo", () => {
|
|
184
|
-
// #given minimal GitHub Copilot format
|
|
185
|
-
const content = `---
|
|
186
|
-
applyTo: "**"
|
|
187
|
-
---
|
|
188
|
-
Apply to all files`;
|
|
189
|
-
|
|
190
|
-
// #when parsing
|
|
191
|
-
const result = parseRuleFrontmatter(content);
|
|
192
|
-
|
|
193
|
-
// #then should parse correctly
|
|
194
|
-
expect(result.metadata.globs).toBe("**");
|
|
195
|
-
expect(result.body).toBe("Apply to all files");
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("should handle mixed array formats", () => {
|
|
199
|
-
// #given globs as multi-line and applyTo as inline
|
|
200
|
-
const content = `---
|
|
201
|
-
globs:
|
|
202
|
-
- "*.md"
|
|
203
|
-
applyTo: ["*.ts", "*.js"]
|
|
204
|
-
---
|
|
205
|
-
Mixed format`;
|
|
206
|
-
|
|
207
|
-
// #when parsing
|
|
208
|
-
const result = parseRuleFrontmatter(content);
|
|
209
|
-
|
|
210
|
-
// #then should merge both
|
|
211
|
-
expect(result.metadata.globs).toEqual(["*.md", "*.ts", "*.js"]);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it("should handle Windows-style line endings", () => {
|
|
215
|
-
// #given content with CRLF
|
|
216
|
-
const content = "---\r\napplyTo: \"*.ts\"\r\n---\r\nWindows content";
|
|
217
|
-
|
|
218
|
-
// #when parsing
|
|
219
|
-
const result = parseRuleFrontmatter(content);
|
|
220
|
-
|
|
221
|
-
// #then should parse correctly
|
|
222
|
-
expect(result.metadata.globs).toBe("*.ts");
|
|
223
|
-
expect(result.body).toBe("Windows content");
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
});
|