oh-my-opencode 4.8.1 → 4.9.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/dist/agents/prometheus/system-prompt.d.ts +1 -1
- package/dist/agents/sisyphus/claude-fable-5.d.ts +19 -0
- package/dist/agents/sisyphus/claude-opus-4-7.d.ts +3 -1
- package/dist/agents/sisyphus/claude-opus-4-8.d.ts +19 -0
- package/dist/agents/sisyphus/index.d.ts +4 -0
- package/dist/agents/types.d.ts +2 -2
- package/dist/cli/doctor/checks/codex.d.ts +1 -0
- package/dist/cli/doctor/checks/dependencies.d.ts +2 -2
- package/dist/cli/doctor/checks/tools-gh.d.ts +8 -1
- package/dist/cli/doctor/index.d.ts +1 -0
- package/dist/cli/doctor/types.d.ts +2 -0
- package/dist/cli/index.js +1908 -787
- package/dist/cli/install-codex/codex-config-permissions.d.ts +1 -1
- package/dist/cli/install-codex/codex-config-plugins.d.ts +1 -0
- package/dist/cli/install-codex/codex-config-toml.d.ts +1 -0
- package/dist/cli/install-codex/codex-installer-bin-dir.d.ts +8 -0
- package/dist/cli/install-codex/install-codex.d.ts +1 -8
- package/dist/cli/install-codex/lsp-daemon-reaper.d.ts +5 -0
- package/dist/cli/sparkshell-condense.d.ts +10 -0
- package/dist/cli/sparkshell-parse.d.ts +3 -0
- package/dist/cli/sparkshell-session-context.d.ts +20 -0
- package/dist/cli/sparkshell-spark.d.ts +23 -0
- package/dist/cli/sparkshell.d.ts +8 -1
- package/dist/cli-node/index.js +92564 -0
- package/dist/config/schema/agent-names.d.ts +2 -0
- package/dist/config/schema/hooks.d.ts +0 -2
- package/dist/config/schema/keyword-detector.d.ts +0 -6
- package/dist/config/schema/oh-my-opencode-config.d.ts +2 -4
- package/dist/create-hooks.d.ts +0 -2
- package/dist/features/background-agent/parent-wake-dedupe.d.ts +2 -0
- package/dist/features/background-agent/parent-wake-flush-runner.d.ts +2 -0
- package/dist/features/background-agent/parent-wake-prompt-dispatch.d.ts +1 -0
- package/dist/features/background-agent/parent-wake-session-history.d.ts +4 -0
- package/dist/features/background-agent/parent-wake-session-inspector.d.ts +1 -0
- package/dist/features/builtin-commands/templates/handoff.d.ts +1 -1
- package/dist/features/builtin-skills/index.d.ts +1 -1
- package/dist/features/builtin-skills/skills.d.ts +4 -0
- package/dist/features/opencode-runtime-skills/source-server.d.ts +16 -1
- package/dist/features/opencode-skill-loader/skill-definition-record.d.ts +2 -0
- package/dist/features/team-mode/tools/lifecycle-test-fixture.d.ts +2 -0
- package/dist/features/team-mode/types.d.ts +1 -0
- package/dist/features/tmux-subagent/failed-readiness-cache.d.ts +28 -0
- package/dist/features/tmux-subagent/manager.d.ts +1 -9
- package/dist/features/tmux-subagent/resolve-server-url.d.ts +3 -0
- package/dist/hooks/anthropic-context-window-limit-recovery/executor.d.ts +1 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/keyword-detector/constants.d.ts +0 -4
- package/dist/hooks/keyword-detector/ultrawork/source-detector.d.ts +1 -1
- package/dist/index.js +9001 -1795
- package/dist/oh-my-opencode.schema.json +2 -4
- package/dist/plugin/chat-params.d.ts +1 -8
- package/dist/plugin/hooks/create-core-hooks.d.ts +0 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts +0 -2
- package/dist/plugin/hooks/create-transform-hooks.d.ts +1 -2
- package/dist/plugin/messages-transform.d.ts +0 -1
- package/dist/shared/model-availability.d.ts +10 -2
- package/dist/shared/module-resolution-failure.d.ts +7 -0
- package/package.json +25 -18
- package/packages/ast-grep-mcp/dist/cli.js +2 -10
- package/packages/git-bash-mcp/dist/cli.js +11 -4
- package/packages/lsp-daemon/dist/cli.d.ts +2 -0
- package/packages/lsp-daemon/dist/cli.js +3711 -0
- package/packages/lsp-daemon/dist/daemon-client.d.ts +19 -0
- package/packages/lsp-daemon/dist/daemon-client.js +114 -0
- package/packages/lsp-daemon/dist/daemon-server.d.ts +12 -0
- package/packages/lsp-daemon/dist/daemon-server.js +106 -0
- package/packages/lsp-daemon/dist/ensure-daemon.d.ts +21 -0
- package/packages/lsp-daemon/dist/ensure-daemon.js +97 -0
- package/packages/lsp-daemon/dist/index.d.ts +5 -0
- package/packages/lsp-daemon/dist/index.js +3573 -0
- package/packages/lsp-daemon/dist/lock.d.ts +7 -0
- package/packages/lsp-daemon/dist/lock.js +61 -0
- package/packages/lsp-daemon/dist/package.json +6 -0
- package/packages/lsp-daemon/dist/paths.d.ts +11 -0
- package/packages/lsp-daemon/dist/paths.js +49 -0
- package/packages/lsp-daemon/dist/proxy.d.ts +10 -0
- package/packages/lsp-daemon/dist/proxy.js +61 -0
- package/packages/lsp-daemon/dist/request-routing.d.ts +9 -0
- package/packages/lsp-daemon/dist/request-routing.js +44 -0
- package/packages/lsp-daemon/dist/run-daemon.d.ts +1 -0
- package/packages/lsp-daemon/dist/run-daemon.js +11 -0
- package/packages/lsp-daemon/dist/socket-jsonrpc.d.ts +5 -0
- package/packages/lsp-daemon/dist/socket-jsonrpc.js +25 -0
- package/packages/lsp-daemon/package.json +38 -0
- package/packages/lsp-tools-mcp/dist/cli.js +0 -0
- package/packages/lsp-tools-mcp/dist/lsp/client-wrapper.js +40 -17
- package/packages/lsp-tools-mcp/dist/lsp/client.js +11 -9
- package/packages/lsp-tools-mcp/dist/lsp/config-loader.js +5 -5
- package/packages/lsp-tools-mcp/dist/lsp/directory-diagnostics.js +5 -3
- package/packages/lsp-tools-mcp/dist/lsp/effective-extension.d.ts +1 -0
- package/packages/lsp-tools-mcp/dist/lsp/effective-extension.js +8 -0
- package/packages/lsp-tools-mcp/dist/lsp/infer-extension.js +3 -2
- package/packages/lsp-tools-mcp/dist/lsp/language-mappings.js +1 -0
- package/packages/lsp-tools-mcp/dist/lsp/server-definitions.js +12 -0
- package/packages/lsp-tools-mcp/dist/lsp/server-install-state.d.ts +12 -0
- package/packages/lsp-tools-mcp/dist/lsp/server-install-state.js +51 -0
- package/packages/lsp-tools-mcp/dist/lsp/workspace-edit.js +2 -1
- package/packages/lsp-tools-mcp/dist/request-context.d.ts +7 -0
- package/packages/lsp-tools-mcp/dist/request-context.js +14 -0
- package/packages/lsp-tools-mcp/dist/tools.js +44 -1
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +46 -33
- package/packages/omo-codex/plugin/.mcp.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/dist/apply-patch.d.ts +7 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/apply-patch.js +173 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/cli.d.ts +2 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/cli.js +10 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/codex-hook.d.ts +22 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/codex-hook.js +165 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/core-values.d.ts +1 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/core-values.js +1 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/core.d.ts +5 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/core.js +4 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/hook-input.d.ts +6 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/hook-input.js +10 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/record.d.ts +2 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/record.js +11 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/request-extractor.d.ts +3 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/request-extractor.js +104 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/runner.d.ts +26 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/runner.js +144 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/types.d.ts +43 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/types.js +1 -0
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
- package/packages/omo-codex/plugin/components/git-bash/dist/cli.d.ts +2 -0
- package/packages/omo-codex/plugin/components/git-bash/dist/cli.js +29 -0
- package/packages/omo-codex/plugin/components/git-bash/dist/codex-hook.d.ts +28 -0
- package/packages/omo-codex/plugin/components/git-bash/dist/codex-hook.js +137 -0
- package/packages/omo-codex/plugin/components/git-bash/dist/index.d.ts +1 -0
- package/packages/omo-codex/plugin/components/git-bash/dist/index.js +1 -0
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +5 -2
- package/packages/omo-codex/plugin/components/lsp/.mcp.json +1 -1
- package/packages/omo-codex/plugin/components/lsp/dist/cli.d.ts +2 -0
- package/packages/omo-codex/plugin/components/lsp/dist/cli.js +42 -0
- package/packages/omo-codex/plugin/components/lsp/dist/codex-hook-cli.d.ts +2 -0
- package/packages/omo-codex/plugin/components/lsp/dist/codex-hook-cli.js +40 -0
- package/packages/omo-codex/plugin/components/lsp/dist/codex-hook.d.ts +16 -0
- package/packages/omo-codex/plugin/components/lsp/dist/codex-hook.js +180 -0
- package/packages/omo-codex/plugin/components/lsp/dist/lsp-session-state.d.ts +12 -0
- package/packages/omo-codex/plugin/components/lsp/dist/lsp-session-state.js +95 -0
- package/packages/omo-codex/plugin/components/lsp/dist/mutated-file-paths.d.ts +6 -0
- package/packages/omo-codex/plugin/components/lsp/dist/mutated-file-paths.js +79 -0
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +7 -7
- package/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-daemon.mjs +68 -0
- package/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.mjs +45 -22
- package/packages/omo-codex/plugin/components/lsp/src/cli.ts +1 -1
- package/packages/omo-codex/plugin/components/lsp/src/codex-hook-cli.ts +1 -1
- package/packages/omo-codex/plugin/components/lsp/src/codex-hook.ts +6 -2
- package/packages/omo-codex/plugin/components/lsp/src/lsp-session-state.ts +4 -0
- package/packages/omo-codex/plugin/components/lsp/test/codex-hook-unavailable.test.ts +68 -0
- package/packages/omo-codex/plugin/components/lsp/test/package-smoke.test.ts +8 -20
- package/packages/omo-codex/plugin/components/rules/bundled-rules/hephaestus.md +69 -96
- package/packages/omo-codex/plugin/components/rules/dist/cli.d.ts +2 -0
- package/packages/omo-codex/plugin/components/rules/dist/cli.js +118 -0
- package/packages/omo-codex/plugin/components/rules/dist/codex-hook-options.d.ts +5 -0
- package/packages/omo-codex/plugin/components/rules/dist/codex-hook-options.js +1 -0
- package/packages/omo-codex/plugin/components/rules/dist/codex-hook.d.ts +47 -0
- package/packages/omo-codex/plugin/components/rules/dist/codex-hook.js +127 -0
- package/packages/omo-codex/plugin/components/rules/dist/config.d.ts +2 -0
- package/packages/omo-codex/plugin/components/rules/dist/config.js +100 -0
- package/packages/omo-codex/plugin/components/rules/dist/context-pressure.d.ts +2 -0
- package/packages/omo-codex/plugin/components/rules/dist/context-pressure.js +26 -0
- package/packages/omo-codex/plugin/components/rules/dist/debug-log.d.ts +8 -0
- package/packages/omo-codex/plugin/components/rules/dist/debug-log.js +36 -0
- package/packages/omo-codex/plugin/components/rules/dist/dynamic-target-fingerprints.d.ts +7 -0
- package/packages/omo-codex/plugin/components/rules/dist/dynamic-target-fingerprints.js +65 -0
- package/packages/omo-codex/plugin/components/rules/dist/event-budget.d.ts +3 -0
- package/packages/omo-codex/plugin/components/rules/dist/event-budget.js +14 -0
- package/packages/omo-codex/plugin/components/rules/dist/hook-output.d.ts +2 -0
- package/packages/omo-codex/plugin/components/rules/dist/hook-output.js +24 -0
- package/packages/omo-codex/plugin/components/rules/dist/path-utils.d.ts +4 -0
- package/packages/omo-codex/plugin/components/rules/dist/path-utils.js +24 -0
- package/packages/omo-codex/plugin/components/rules/dist/persistent-cache.d.ts +13 -0
- package/packages/omo-codex/plugin/components/rules/dist/persistent-cache.js +172 -0
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-budget.d.ts +6 -0
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-budget.js +74 -0
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-claim.d.ts +4 -0
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-claim.js +6 -0
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-directive.d.ts +1 -0
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-directive.js +32 -0
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-state.d.ts +13 -0
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-state.js +29 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/cache.d.ts +9 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/cache.js +51 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/constants.d.ts +70 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/constants.js +101 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-cache.d.ts +5 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-cache.js +60 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-loader.d.ts +6 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-loader.js +61 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-loader.d.ts +7 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-loader.js +60 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-paths.d.ts +11 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-paths.js +75 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-static-loader.d.ts +6 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-static-loader.js +29 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-types.d.ts +44 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-types.js +1 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine.d.ts +5 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine.js +85 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/errors.d.ts +6 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/errors.js +12 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-cache.d.ts +14 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-cache.js +51 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-paths.d.ts +6 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-paths.js +33 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-sources.d.ts +5 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-sources.js +40 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder.d.ts +28 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder.js +146 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/formatter.d.ts +7 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/formatter.js +112 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/matcher.d.ts +18 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/matcher.js +93 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/ordering.d.ts +3 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/ordering.js +27 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser-frontmatter.d.ts +7 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser-frontmatter.js +30 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser-yaml.d.ts +2 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser-yaml.js +237 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser.d.ts +3 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser.js +31 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/plugin-root.d.ts +1 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/plugin-root.js +48 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/project-root.d.ts +1 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/project-root.js +23 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/scanner.d.ts +14 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/scanner.js +111 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/sources.d.ts +3 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/sources.js +9 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/truncator.d.ts +18 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/truncator.js +59 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/types.d.ts +126 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules/types.js +8 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules-engine-factory.d.ts +6 -0
- package/packages/omo-codex/plugin/components/rules/dist/rules-engine-factory.js +20 -0
- package/packages/omo-codex/plugin/components/rules/dist/session-state-lock.d.ts +3 -0
- package/packages/omo-codex/plugin/components/rules/dist/session-state-lock.js +41 -0
- package/packages/omo-codex/plugin/components/rules/dist/sparkshell-awareness.d.ts +10 -0
- package/packages/omo-codex/plugin/components/rules/dist/sparkshell-awareness.js +90 -0
- package/packages/omo-codex/plugin/components/rules/dist/static-injection.d.ts +3 -0
- package/packages/omo-codex/plugin/components/rules/dist/static-injection.js +128 -0
- package/packages/omo-codex/plugin/components/rules/dist/tool-paths.d.ts +6 -0
- package/packages/omo-codex/plugin/components/rules/dist/tool-paths.js +168 -0
- package/packages/omo-codex/plugin/components/rules/dist/transcript-rule-filter.d.ts +4 -0
- package/packages/omo-codex/plugin/components/rules/dist/transcript-rule-filter.js +49 -0
- package/packages/omo-codex/plugin/components/rules/dist/transcript-search.d.ts +4 -0
- package/packages/omo-codex/plugin/components/rules/dist/transcript-search.js +91 -0
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/src/codex-hook.ts +4 -2
- package/packages/omo-codex/plugin/components/rules/src/config.ts +13 -0
- package/packages/omo-codex/plugin/components/rules/src/event-budget.ts +17 -0
- package/packages/omo-codex/plugin/components/rules/src/persistent-cache.ts +4 -1
- package/packages/omo-codex/plugin/components/rules/src/post-compact-directive.ts +39 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/constants.ts +16 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/engine.ts +8 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/types.ts +4 -0
- package/packages/omo-codex/plugin/components/rules/src/sparkshell-awareness.ts +53 -4
- package/packages/omo-codex/plugin/components/rules/src/static-injection.ts +127 -7
- package/packages/omo-codex/plugin/components/rules/src/transcript-rule-filter.ts +9 -1
- package/packages/omo-codex/plugin/components/rules/test/bundled-rules.test.ts +4 -2
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-budget.test.ts +7 -2
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-context.test.ts +9 -9
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-dedup.test.ts +10 -4
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-directive.test.ts +241 -0
- package/packages/omo-codex/plugin/components/rules/test/event-budget.test.ts +168 -0
- package/packages/omo-codex/plugin/components/rules/test/post-compact-budget.test.ts +4 -0
- package/packages/omo-codex/plugin/components/rules/test/sparkshell-awareness.test.ts +86 -3
- package/packages/omo-codex/plugin/components/start-work-continuation/directive.md +15 -15
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/boulder-reader.d.ts +16 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/boulder-reader.js +146 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/cli.d.ts +2 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/cli.js +49 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/codex-hook.d.ts +2 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/codex-hook.js +80 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/directive.d.ts +1 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/directive.js +2 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/index.d.ts +5 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/index.js +3 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/types.d.ts +20 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/types.js +1 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/start-work-continuation/package.json +1 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/test/codex-hook.test.ts +24 -2
- package/packages/omo-codex/plugin/components/telemetry/dist/atomic-write.d.ts +1 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/atomic-write.js +18 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/cli.d.ts +2 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +62 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/codex-hook.d.ts +15 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/codex-hook.js +42 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/data-path.d.ts +10 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/data-path.js +35 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/diagnostics.d.ts +12 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/diagnostics.js +108 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/env-flags.d.ts +4 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/env-flags.js +31 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog-activity-state.d.ts +8 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog-activity-state.js +68 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.d.ts +21 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +133 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/product-identity.d.ts +8 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/product-identity.js +29 -0
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/explorer.toml +5 -13
- package/packages/omo-codex/plugin/components/ultrawork/agents/librarian.toml +61 -185
- package/packages/omo-codex/plugin/components/ultrawork/agents/plan.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/directive.md +122 -117
- package/packages/omo-codex/plugin/components/ultrawork/dist/cli.d.ts +2 -0
- package/packages/omo-codex/plugin/components/ultrawork/dist/cli.js +48 -0
- package/packages/omo-codex/plugin/components/ultrawork/dist/codex-hook.d.ts +7 -0
- package/packages/omo-codex/plugin/components/ultrawork/dist/codex-hook.js +122 -0
- package/packages/omo-codex/plugin/components/ultrawork/dist/directive.d.ts +1 -0
- package/packages/omo-codex/plugin/components/ultrawork/dist/directive.js +2 -0
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +20 -11
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/full-workflow.md +17 -11
- package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook.test.ts +2 -5
- package/packages/omo-codex/plugin/components/ultrawork/test/package-smoke.test.ts +0 -71
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.d.ts +16 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.js +200 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-arg-parser.d.ts +17 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-arg-parser.js +97 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.d.ts +4 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.js +183 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.d.ts +6 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.js +55 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-steering.d.ts +12 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-steering.js +145 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.d.ts +2 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +39 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.d.ts +13 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.js +100 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-snapshot.d.ts +26 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-snapshot.js +97 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-hook.d.ts +28 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-hook.js +145 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/command-types.d.ts +34 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/command-types.js +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/constants.d.ts +16 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/constants.js +41 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/domain-types.d.ts +95 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/domain-types.js +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.d.ts +31 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.js +119 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/goal-status.d.ts +12 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/goal-status.js +69 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/paths.d.ts +16 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/paths.js +59 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.d.ts +48 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.js +119 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.d.ts +8 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.js +89 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.d.ts +6 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.js +123 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/review-blockers.d.ts +16 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/review-blockers.js +70 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/runtime.d.ts +10 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/runtime.js +13 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-types.d.ts +63 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-types.js +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering.d.ts +6 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering.js +292 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/types.d.ts +5 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/types.js +5 -0
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +14 -14
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +24 -25
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-commands.ts +17 -3
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli.ts +2 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-instruction.ts +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-entrypoint.test.ts +95 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/package-smoke.test.ts +0 -96
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate.test.ts +23 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/skill-contract.test.ts +46 -0
- package/packages/omo-codex/plugin/hooks/hooks.json +16 -16
- package/packages/omo-codex/plugin/package-lock.json +10 -9
- package/packages/omo-codex/plugin/package.json +27 -26
- package/packages/omo-codex/plugin/scripts/auto-update.mjs +64 -15
- package/packages/omo-codex/plugin/scripts/build-bundled-mcp-runtimes.mjs +16 -0
- package/packages/omo-codex/plugin/scripts/migrate-codex-config/multi-agent-v2-guard.mjs +82 -18
- package/packages/omo-codex/plugin/scripts/migrate-codex-config.mjs +2 -2
- package/packages/omo-codex/plugin/scripts/sync-skills.mjs +23 -11
- package/packages/omo-codex/plugin/scripts/sync-version.mjs +94 -0
- package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +9 -9
- package/packages/omo-codex/plugin/skills/lcx-contribute-bug-fix/SKILL.md +16 -1
- package/packages/omo-codex/plugin/skills/lcx-doctor/SKILL.md +93 -0
- package/packages/omo-codex/plugin/skills/lcx-doctor/agents/openai.yaml +11 -0
- package/packages/omo-codex/plugin/skills/lcx-report-bug/SKILL.md +17 -13
- package/packages/omo-codex/plugin/skills/lsp-setup/SKILL.md +139 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/bash/README.md +60 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/c-cpp/README.md +61 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/csharp/README.md +71 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/dart/README.md +48 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/elixir/README.md +51 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/go/README.md +57 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/haskell/README.md +57 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/java/README.md +57 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/julia/README.md +60 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/kotlin/README.md +59 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/lua/README.md +66 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/php/README.md +62 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/python/README.md +71 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/ruby/README.md +53 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/rust/README.md +59 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/swift/README.md +51 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/terraform/README.md +62 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/typescript/README.md +77 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/yaml/README.md +70 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/references/zig/README.md +49 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/scripts/detect-lsp.ts +210 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/scripts/lsp-server-table.ts +177 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/scripts/tsconfig.json +17 -0
- package/packages/omo-codex/plugin/skills/lsp-setup/scripts/verify-lsp.ts +147 -0
- package/packages/omo-codex/plugin/skills/refactor/SKILL.md +9 -9
- package/packages/omo-codex/plugin/skills/remove-ai-slops/SKILL.md +10 -10
- package/packages/omo-codex/plugin/skills/review-work/SKILL.md +20 -22
- package/packages/omo-codex/plugin/skills/start-work/SKILL.md +38 -61
- package/packages/omo-codex/plugin/skills/ultraresearch/SKILL.md +135 -677
- package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +14 -14
- package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +24 -25
- package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +20 -11
- package/packages/omo-codex/plugin/skills/ulw-plan/references/full-workflow.md +17 -11
- package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +9 -9
- package/packages/omo-codex/plugin/test/aggregate-build.test.mjs +2 -1
- package/packages/omo-codex/plugin/test/aggregate-mcp.test.mjs +1 -1
- package/packages/omo-codex/plugin/test/aggregate-plugin-fixture.mjs +5 -5
- package/packages/omo-codex/plugin/test/aggregate-skills.test.mjs +6 -6
- package/packages/omo-codex/plugin/test/auto-update-restart-notice.test.mjs +194 -0
- package/packages/omo-codex/plugin/test/auto-update.test.mjs +17 -0
- package/packages/omo-codex/plugin/test/lcx-bug-skills.test.mjs +15 -44
- package/packages/omo-codex/plugin/test/lsp-prebuild-layouts.test.mjs +140 -0
- package/packages/omo-codex/plugin/test/migrate-codex-config.test.mjs +189 -7
- package/packages/omo-codex/plugin/test/start-work-skill.test.mjs +9 -31
- package/packages/omo-codex/plugin/test/sync-skills-orchestration.test.mjs +68 -4
- package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +119 -0
- package/packages/omo-codex/plugin/test/sync-skills.test.mjs +11 -112
- package/packages/omo-codex/plugin/test/sync-version.test.mjs +68 -0
- package/packages/omo-codex/plugin/test/ultraresearch-skill-contract.test.mjs +126 -0
- package/packages/omo-codex/plugin/test/ulw-plan-skill.test.mjs +2 -2
- package/packages/omo-codex/scripts/install/bin-dir.mjs +20 -0
- package/packages/omo-codex/scripts/install/bin-links.mjs +43 -6
- package/packages/omo-codex/scripts/install/cache.mjs +4 -0
- package/packages/omo-codex/scripts/install/config.mjs +4 -4
- package/packages/omo-codex/scripts/install/delegated-command.mjs +5 -1
- package/packages/omo-codex/scripts/install/git-bash-mcp-env.mjs +28 -0
- package/packages/omo-codex/scripts/install/git-bash.mjs +12 -4
- package/packages/omo-codex/scripts/install/git-bash.test.mjs +39 -4
- package/packages/omo-codex/scripts/install/hook-targets.mjs +46 -0
- package/packages/omo-codex/scripts/install/multi-agent-v2-config.mjs +12 -2
- package/packages/omo-codex/scripts/install/process.mjs +1 -0
- package/packages/omo-codex/scripts/install-bin-links.test.mjs +131 -3
- package/packages/omo-codex/scripts/install-config-git-bash.test.mjs +91 -0
- package/packages/omo-codex/scripts/install-config.test.mjs +50 -44
- package/packages/omo-codex/scripts/install-delegated-command.test.mjs +78 -0
- package/packages/omo-codex/scripts/install-git-bash-mcp-env.test.mjs +93 -0
- package/packages/omo-codex/scripts/install-hook-targets.test.mjs +100 -0
- package/packages/omo-codex/scripts/install-lazycodex-version-stamp.test.mjs +3 -1
- package/packages/omo-codex/scripts/install-local.mjs +7 -18
- package/packages/omo-codex/scripts/install-local.test.mjs +34 -1
- package/packages/shared-skills/skills/lcx-contribute-bug-fix/SKILL.md +16 -1
- package/packages/shared-skills/skills/lcx-doctor/SKILL.md +93 -0
- package/packages/shared-skills/skills/lcx-doctor/agents/openai.yaml +11 -0
- package/packages/shared-skills/skills/lcx-report-bug/SKILL.md +17 -13
- package/packages/shared-skills/skills/lsp-setup/SKILL.md +139 -0
- package/packages/shared-skills/skills/lsp-setup/references/bash/README.md +60 -0
- package/packages/shared-skills/skills/lsp-setup/references/c-cpp/README.md +61 -0
- package/packages/shared-skills/skills/lsp-setup/references/csharp/README.md +71 -0
- package/packages/shared-skills/skills/lsp-setup/references/dart/README.md +48 -0
- package/packages/shared-skills/skills/lsp-setup/references/elixir/README.md +51 -0
- package/packages/shared-skills/skills/lsp-setup/references/go/README.md +57 -0
- package/packages/shared-skills/skills/lsp-setup/references/haskell/README.md +57 -0
- package/packages/shared-skills/skills/lsp-setup/references/java/README.md +57 -0
- package/packages/shared-skills/skills/lsp-setup/references/julia/README.md +60 -0
- package/packages/shared-skills/skills/lsp-setup/references/kotlin/README.md +59 -0
- package/packages/shared-skills/skills/lsp-setup/references/lua/README.md +66 -0
- package/packages/shared-skills/skills/lsp-setup/references/php/README.md +62 -0
- package/packages/shared-skills/skills/lsp-setup/references/python/README.md +71 -0
- package/packages/shared-skills/skills/lsp-setup/references/ruby/README.md +53 -0
- package/packages/shared-skills/skills/lsp-setup/references/rust/README.md +59 -0
- package/packages/shared-skills/skills/lsp-setup/references/swift/README.md +51 -0
- package/packages/shared-skills/skills/lsp-setup/references/terraform/README.md +62 -0
- package/packages/shared-skills/skills/lsp-setup/references/typescript/README.md +77 -0
- package/packages/shared-skills/skills/lsp-setup/references/yaml/README.md +70 -0
- package/packages/shared-skills/skills/lsp-setup/references/zig/README.md +49 -0
- package/packages/shared-skills/skills/lsp-setup/scripts/detect-lsp.ts +210 -0
- package/packages/shared-skills/skills/lsp-setup/scripts/lsp-server-table.ts +177 -0
- package/packages/shared-skills/skills/lsp-setup/scripts/tsconfig.json +17 -0
- package/packages/shared-skills/skills/lsp-setup/scripts/verify-lsp.ts +147 -0
- package/packages/shared-skills/skills/remove-ai-slops/SKILL.md +1 -1
- package/packages/shared-skills/skills/review-work/SKILL.md +10 -14
- package/packages/shared-skills/skills/start-work/SKILL.md +30 -59
- package/packages/shared-skills/skills/ultraresearch/SKILL.md +126 -667
- package/dist/hooks/anthropic-effort/hook.d.ts +0 -26
- package/dist/hooks/anthropic-effort/index.d.ts +0 -1
- package/dist/hooks/keyword-detector/analyze/default.d.ts +0 -12
- package/dist/hooks/keyword-detector/analyze/index.d.ts +0 -1
- package/dist/hooks/keyword-detector/search/default.d.ts +0 -12
- package/dist/hooks/keyword-detector/search/index.d.ts +0 -1
- package/dist/hooks/thinking-block-validator/hook.d.ts +0 -12
- package/dist/hooks/thinking-block-validator/index.d.ts +0 -1
- package/packages/omo-codex/plugin/components/ultrawork/test/directive-contract.test.ts +0 -18
- package/packages/omo-codex/plugin/test/global-review-debug-gate.test.mjs +0 -29
- package/packages/omo-codex/plugin/test/subagent-guidance.test.mjs +0 -151
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { clearSession, createSessionState, isDynamicInjected as isDynamicInjectedInState, isStaticInjected as isStaticInjectedInState, markDynamicInjected as markDynamicInjectedInState, markStaticInjected as markStaticInjectedInState, } from "./cache.js";
|
|
2
|
+
import { DEFAULT_DYNAMIC_MAX_RESULT_CHARS, DEFAULT_DYNAMIC_MAX_RULE_CHARS, DEFAULT_MAX_RESULT_CHARS, DEFAULT_MAX_RULE_CHARS, DEFAULT_POST_COMPACT_MAX_RESULT_CHARS, DEFAULT_POST_COMPACT_MAX_RULE_CHARS, DEFAULT_PROMPT_MAX_RESULT_CHARS, DEFAULT_PROMPT_MAX_RULE_CHARS, } from "./constants.js";
|
|
3
|
+
import { loadDynamicCandidates } from "./engine-dynamic-loader.js";
|
|
4
|
+
import { loadStaticCandidates } from "./engine-static-loader.js";
|
|
5
|
+
import { formatDynamicBlock, formatStaticBlock } from "./formatter.js";
|
|
6
|
+
import { disabledSourcesFromConfig } from "./sources.js";
|
|
7
|
+
export function defaultConfig() {
|
|
8
|
+
return {
|
|
9
|
+
disabled: false,
|
|
10
|
+
mode: "both",
|
|
11
|
+
maxRuleChars: DEFAULT_MAX_RULE_CHARS,
|
|
12
|
+
maxResultChars: DEFAULT_MAX_RESULT_CHARS,
|
|
13
|
+
postCompactMaxRuleChars: DEFAULT_POST_COMPACT_MAX_RULE_CHARS,
|
|
14
|
+
postCompactMaxResultChars: DEFAULT_POST_COMPACT_MAX_RESULT_CHARS,
|
|
15
|
+
dynamicMaxRuleChars: DEFAULT_DYNAMIC_MAX_RULE_CHARS,
|
|
16
|
+
dynamicMaxResultChars: DEFAULT_DYNAMIC_MAX_RESULT_CHARS,
|
|
17
|
+
promptMaxRuleChars: DEFAULT_PROMPT_MAX_RULE_CHARS,
|
|
18
|
+
promptMaxResultChars: DEFAULT_PROMPT_MAX_RESULT_CHARS,
|
|
19
|
+
enabledSources: "auto",
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function createEngine(config, deps) {
|
|
23
|
+
const state = createSessionState();
|
|
24
|
+
const dynamicMatchCache = new Map();
|
|
25
|
+
function loadStaticRules(cwd) {
|
|
26
|
+
state.cwd = cwd;
|
|
27
|
+
if (config.disabled || config.mode === "off" || config.mode === "dynamic") {
|
|
28
|
+
return emptyLoadResult(state);
|
|
29
|
+
}
|
|
30
|
+
const projectRoot = deps.findProjectRoot(cwd);
|
|
31
|
+
const findOptions = {
|
|
32
|
+
projectRoot,
|
|
33
|
+
targetFile: null,
|
|
34
|
+
};
|
|
35
|
+
const disabledSources = disabledSourcesFromConfig(config);
|
|
36
|
+
if (disabledSources !== undefined) {
|
|
37
|
+
findOptions.disabledSources = disabledSources;
|
|
38
|
+
}
|
|
39
|
+
const candidates = deps.findCandidates(findOptions);
|
|
40
|
+
const result = loadStaticCandidates(candidates, deps, projectRoot);
|
|
41
|
+
storeLastLoad(state, result.rules, result.diagnostics);
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
function loadDynamicRules(cwd, targetPaths) {
|
|
45
|
+
state.cwd = cwd;
|
|
46
|
+
if (config.disabled || config.mode === "off" || config.mode === "static" || targetPaths.length === 0) {
|
|
47
|
+
return emptyLoadResult(state);
|
|
48
|
+
}
|
|
49
|
+
const result = loadDynamicCandidates(config, deps, cwd, targetPaths, dynamicMatchCache);
|
|
50
|
+
storeLastLoad(state, result.rules, result.diagnostics);
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
state,
|
|
55
|
+
config,
|
|
56
|
+
loadStaticRules,
|
|
57
|
+
loadDynamicRules,
|
|
58
|
+
formatStatic: (rules) => formatStaticBlock(rules, { maxRuleChars: config.maxRuleChars, maxResultChars: config.maxResultChars }),
|
|
59
|
+
formatDynamic: (rules, target) => formatDynamicBlock(rules, target, {
|
|
60
|
+
maxRuleChars: config.maxRuleChars,
|
|
61
|
+
maxResultChars: config.maxResultChars,
|
|
62
|
+
}),
|
|
63
|
+
resetSession: (cwd) => {
|
|
64
|
+
clearSession(state);
|
|
65
|
+
dynamicMatchCache.clear();
|
|
66
|
+
if (cwd !== undefined) {
|
|
67
|
+
state.cwd = cwd;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
isStaticInjected: (rule) => isStaticInjectedInState(state, rule),
|
|
71
|
+
isDynamicInjected: (rule) => isDynamicInjectedInState(state, rule),
|
|
72
|
+
markStaticInjected: (rule) => markStaticInjectedInState(state, rule),
|
|
73
|
+
markDynamicInjected: (rule) => markDynamicInjectedInState(state, rule),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function storeLastLoad(state, rules, diagnostics) {
|
|
77
|
+
state.loadedRules.length = 0;
|
|
78
|
+
state.loadedRules.push(...rules);
|
|
79
|
+
state.diagnostics.length = 0;
|
|
80
|
+
state.diagnostics.push(...diagnostics);
|
|
81
|
+
}
|
|
82
|
+
function emptyLoadResult(state) {
|
|
83
|
+
storeLastLoad(state, [], []);
|
|
84
|
+
return { rules: [], diagnostics: [] };
|
|
85
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class UnsupportedRuleSourceError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "UnsupportedRuleSourceError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export class RuleFrontmatterParseError extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "RuleFrontmatterParseError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { scanRuleFiles } from "./scanner.js";
|
|
2
|
+
type ScannedRuleFiles = ReturnType<typeof scanRuleFiles>;
|
|
3
|
+
interface SingleFileInfo {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly realPath: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RuleDiscoveryCache {
|
|
8
|
+
readonly scannedRuleFiles: Map<string, ScannedRuleFiles>;
|
|
9
|
+
readonly singleFileInfo: Map<string, SingleFileInfo | null>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createRuleDiscoveryCache(): RuleDiscoveryCache;
|
|
12
|
+
export declare function scanRuleFilesCached(rootDir: string, cache: RuleDiscoveryCache | undefined): ScannedRuleFiles;
|
|
13
|
+
export declare function singleFileInfoCached(filePath: string, cache: RuleDiscoveryCache | undefined): SingleFileInfo | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { existsSync, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { scanRuleFiles } from "./scanner.js";
|
|
3
|
+
export function createRuleDiscoveryCache() {
|
|
4
|
+
return { scannedRuleFiles: new Map(), singleFileInfo: new Map() };
|
|
5
|
+
}
|
|
6
|
+
export function scanRuleFilesCached(rootDir, cache) {
|
|
7
|
+
if (cache === undefined) {
|
|
8
|
+
return scanRuleFiles({ rootDir });
|
|
9
|
+
}
|
|
10
|
+
const cached = cache.scannedRuleFiles.get(rootDir);
|
|
11
|
+
if (cached !== undefined) {
|
|
12
|
+
return cached;
|
|
13
|
+
}
|
|
14
|
+
const scannedFiles = scanRuleFiles({ rootDir });
|
|
15
|
+
cache.scannedRuleFiles.set(rootDir, scannedFiles);
|
|
16
|
+
return scannedFiles;
|
|
17
|
+
}
|
|
18
|
+
export function singleFileInfoCached(filePath, cache) {
|
|
19
|
+
if (cache === undefined) {
|
|
20
|
+
return readSingleFileInfo(filePath);
|
|
21
|
+
}
|
|
22
|
+
const cached = cache.singleFileInfo.get(filePath);
|
|
23
|
+
if (cached !== undefined) {
|
|
24
|
+
return cached;
|
|
25
|
+
}
|
|
26
|
+
const fileInfo = readSingleFileInfo(filePath);
|
|
27
|
+
cache.singleFileInfo.set(filePath, fileInfo);
|
|
28
|
+
return fileInfo;
|
|
29
|
+
}
|
|
30
|
+
function readSingleFileInfo(filePath) {
|
|
31
|
+
if (!existsSync(filePath)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
if (!statSync(filePath).isFile()) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return { path: filePath, realPath: resolveRealPath(filePath) };
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function resolveRealPath(filePath) {
|
|
45
|
+
try {
|
|
46
|
+
return realpathSync.native(filePath);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return filePath;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface WalkDirectory {
|
|
2
|
+
readonly directory: string;
|
|
3
|
+
readonly distance: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function getWalkDirectories(projectRoot: string, targetFile: string | null): WalkDirectory[];
|
|
6
|
+
export declare function toRelativePath(rootDirectory: string, filePath: string): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { dirname, posix, relative, resolve } from "node:path";
|
|
2
|
+
export function getWalkDirectories(projectRoot, targetFile) {
|
|
3
|
+
if (targetFile === null) {
|
|
4
|
+
return [{ directory: projectRoot, distance: 0 }];
|
|
5
|
+
}
|
|
6
|
+
const startDirectory = dirname(resolve(targetFile));
|
|
7
|
+
if (!isSameOrChildPath(startDirectory, projectRoot)) {
|
|
8
|
+
return [{ directory: projectRoot, distance: 0 }];
|
|
9
|
+
}
|
|
10
|
+
const walkDirectories = [];
|
|
11
|
+
let currentDirectory = startDirectory;
|
|
12
|
+
let distance = 0;
|
|
13
|
+
while (true) {
|
|
14
|
+
walkDirectories.push({ directory: currentDirectory, distance });
|
|
15
|
+
if (currentDirectory === projectRoot) {
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
const parentDirectory = dirname(currentDirectory);
|
|
19
|
+
if (parentDirectory === currentDirectory) {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
currentDirectory = parentDirectory;
|
|
23
|
+
distance += 1;
|
|
24
|
+
}
|
|
25
|
+
return walkDirectories;
|
|
26
|
+
}
|
|
27
|
+
export function toRelativePath(rootDirectory, filePath) {
|
|
28
|
+
return posix.normalize(relative(rootDirectory, filePath).replace(/\\/g, "/"));
|
|
29
|
+
}
|
|
30
|
+
function isSameOrChildPath(childPath, parentPath) {
|
|
31
|
+
const childRelativePath = relative(parentPath, childPath);
|
|
32
|
+
return childRelativePath === "" || (!childRelativePath.startsWith("..") && !childRelativePath.startsWith("/"));
|
|
33
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RuleSource } from "./types.js";
|
|
2
|
+
export declare function toProjectRuleSource(parentDirectory: string, subDirectory: string): RuleSource;
|
|
3
|
+
export declare function toProjectSingleFileSource(ruleFile: string): RuleSource;
|
|
4
|
+
export declare function toUserHomeRuleSource(ruleSubdir: string): RuleSource;
|
|
5
|
+
export declare function toUserHomeSingleFileSource(ruleFile: string): RuleSource;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { UnsupportedRuleSourceError } from "./errors.js";
|
|
2
|
+
export function toProjectRuleSource(parentDirectory, subDirectory) {
|
|
3
|
+
const source = `${parentDirectory}/${subDirectory}`;
|
|
4
|
+
switch (source) {
|
|
5
|
+
case ".omo/rules":
|
|
6
|
+
case ".claude/rules":
|
|
7
|
+
case ".cursor/rules":
|
|
8
|
+
case ".github/instructions":
|
|
9
|
+
return source;
|
|
10
|
+
default:
|
|
11
|
+
throw new UnsupportedRuleSourceError(`Unsupported project rule source: ${source}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function toProjectSingleFileSource(ruleFile) {
|
|
15
|
+
switch (ruleFile) {
|
|
16
|
+
case ".github/copilot-instructions.md":
|
|
17
|
+
case "CONTEXT.md":
|
|
18
|
+
return ruleFile;
|
|
19
|
+
default:
|
|
20
|
+
throw new UnsupportedRuleSourceError(`Unsupported project single-file source: ${ruleFile}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function toUserHomeRuleSource(ruleSubdir) {
|
|
24
|
+
const source = `~/${ruleSubdir}`;
|
|
25
|
+
switch (source) {
|
|
26
|
+
case "~/.omo/rules":
|
|
27
|
+
case "~/.opencode/rules":
|
|
28
|
+
case "~/.claude/rules":
|
|
29
|
+
return source;
|
|
30
|
+
default:
|
|
31
|
+
throw new UnsupportedRuleSourceError(`Unsupported user-home rule source: ${source}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function toUserHomeSingleFileSource(ruleFile) {
|
|
35
|
+
const source = `~/${ruleFile}`;
|
|
36
|
+
switch (source) {
|
|
37
|
+
default:
|
|
38
|
+
throw new UnsupportedRuleSourceError(`Unsupported user-home single-file source: ${source}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type RuleDiscoveryCache } from "./finder-cache.js";
|
|
2
|
+
import type { RuleCandidate } from "./types.js";
|
|
3
|
+
export type { RuleDiscoveryCache } from "./finder-cache.js";
|
|
4
|
+
export { createRuleDiscoveryCache } from "./finder-cache.js";
|
|
5
|
+
export interface FinderOptions {
|
|
6
|
+
/** Project root absolute path (use findProjectRoot to get this). */
|
|
7
|
+
projectRoot: string | null;
|
|
8
|
+
/** Target file path (used for distance calculation in dynamic injection mode). null for static mode. */
|
|
9
|
+
targetFile: string | null;
|
|
10
|
+
/** User home directory (default: os.homedir()). Injectable for tests. */
|
|
11
|
+
homeDir?: string;
|
|
12
|
+
/** Set of disabled sources to omit from discovery. Empty by default. */
|
|
13
|
+
disabledSources?: ReadonlySet<string>;
|
|
14
|
+
/** Whether to skip user-home rules. Default: false. */
|
|
15
|
+
skipUserHome?: boolean;
|
|
16
|
+
/** Plugin root directory. Defaults to PLUGIN_ROOT env or this package root. */
|
|
17
|
+
pluginRoot?: string;
|
|
18
|
+
platform?: NodeJS.Platform;
|
|
19
|
+
cache?: RuleDiscoveryCache;
|
|
20
|
+
}
|
|
21
|
+
interface PluginBundledFinderOptions {
|
|
22
|
+
readonly disabledSources?: ReadonlySet<string>;
|
|
23
|
+
readonly cache?: RuleDiscoveryCache;
|
|
24
|
+
readonly pluginRoot?: string;
|
|
25
|
+
readonly platform?: NodeJS.Platform;
|
|
26
|
+
}
|
|
27
|
+
export declare function findRuleCandidates(options: FinderOptions): RuleCandidate[];
|
|
28
|
+
export declare function findPluginBundledCandidates(options?: PluginBundledFinderOptions): RuleCandidate[];
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { BUNDLED_RULE_SUBDIR, GLOBAL_DISTANCE, PROJECT_RULE_SUBDIRS, PROJECT_SINGLE_FILES, USER_HOME_RULE_SUBDIRS, USER_HOME_SINGLE_FILES, } from "./constants.js";
|
|
4
|
+
import { scanRuleFilesCached, singleFileInfoCached } from "./finder-cache.js";
|
|
5
|
+
import { getWalkDirectories, toRelativePath } from "./finder-paths.js";
|
|
6
|
+
import { toProjectRuleSource, toProjectSingleFileSource, toUserHomeRuleSource, toUserHomeSingleFileSource, } from "./finder-sources.js";
|
|
7
|
+
import { resolvePluginRulesRoot } from "./plugin-root.js";
|
|
8
|
+
export { createRuleDiscoveryCache } from "./finder-cache.js";
|
|
9
|
+
const WINDOWS_GIT_BASH_BUNDLED_RULE_PATH = "bundled-rules/windows-git-bash.md";
|
|
10
|
+
export function findRuleCandidates(options) {
|
|
11
|
+
const skipUserHome = options.skipUserHome ?? false;
|
|
12
|
+
const disabledSources = options.disabledSources ?? new Set();
|
|
13
|
+
const candidates = [];
|
|
14
|
+
const homeDirectory = resolve(options.homeDir ?? homedir());
|
|
15
|
+
if (options.projectRoot !== null) {
|
|
16
|
+
candidates.push(...findProjectCandidates(options.projectRoot, options.targetFile, disabledSources, options.cache));
|
|
17
|
+
}
|
|
18
|
+
const pluginBundledOptions = {
|
|
19
|
+
disabledSources,
|
|
20
|
+
...(options.cache === undefined ? {} : { cache: options.cache }),
|
|
21
|
+
...(options.pluginRoot === undefined ? {} : { pluginRoot: options.pluginRoot }),
|
|
22
|
+
...(options.platform === undefined ? {} : { platform: options.platform }),
|
|
23
|
+
};
|
|
24
|
+
candidates.push(...findPluginBundledCandidates(pluginBundledOptions));
|
|
25
|
+
if (!skipUserHome) {
|
|
26
|
+
candidates.push(...findUserHomeCandidates(homeDirectory, disabledSources, options.cache));
|
|
27
|
+
}
|
|
28
|
+
return candidates;
|
|
29
|
+
}
|
|
30
|
+
export function findPluginBundledCandidates(options = {}) {
|
|
31
|
+
if (options.disabledSources?.has("plugin-bundled") === true) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
const pluginRoot = resolvePluginRulesRoot(options.pluginRoot);
|
|
35
|
+
const ruleDirectory = join(pluginRoot, BUNDLED_RULE_SUBDIR);
|
|
36
|
+
const platform = options.platform ?? process.platform;
|
|
37
|
+
const candidates = [];
|
|
38
|
+
for (const scannedFile of scanRuleFilesCached(ruleDirectory, options.cache)) {
|
|
39
|
+
const candidate = {
|
|
40
|
+
path: scannedFile.path,
|
|
41
|
+
realPath: scannedFile.realPath,
|
|
42
|
+
source: "plugin-bundled",
|
|
43
|
+
distance: GLOBAL_DISTANCE,
|
|
44
|
+
isGlobal: true,
|
|
45
|
+
isSingleFile: false,
|
|
46
|
+
relativePath: toRelativePath(pluginRoot, scannedFile.path),
|
|
47
|
+
};
|
|
48
|
+
if (isPluginBundledCandidateEnabled(candidate, platform)) {
|
|
49
|
+
candidates.push(candidate);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return candidates;
|
|
53
|
+
}
|
|
54
|
+
function isPluginBundledCandidateEnabled(candidate, platform) {
|
|
55
|
+
return candidate.relativePath !== WINDOWS_GIT_BASH_BUNDLED_RULE_PATH || platform === "win32";
|
|
56
|
+
}
|
|
57
|
+
function findProjectCandidates(projectRoot, targetFile, disabledSources, cache) {
|
|
58
|
+
const rootDirectory = resolve(projectRoot);
|
|
59
|
+
const walkDirectories = getWalkDirectories(rootDirectory, targetFile);
|
|
60
|
+
const candidates = [];
|
|
61
|
+
for (const walkDirectory of walkDirectories) {
|
|
62
|
+
for (const [parentDirectory, subDirectory] of PROJECT_RULE_SUBDIRS) {
|
|
63
|
+
const source = toProjectRuleSource(parentDirectory, subDirectory);
|
|
64
|
+
if (disabledSources.has(source)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const ruleDirectory = join(walkDirectory.directory, parentDirectory, subDirectory);
|
|
68
|
+
for (const scannedFile of scanRuleFilesCached(ruleDirectory, cache)) {
|
|
69
|
+
candidates.push({
|
|
70
|
+
path: scannedFile.path,
|
|
71
|
+
realPath: scannedFile.realPath,
|
|
72
|
+
source,
|
|
73
|
+
distance: targetFile === null ? 0 : walkDirectory.distance,
|
|
74
|
+
isGlobal: false,
|
|
75
|
+
isSingleFile: false,
|
|
76
|
+
relativePath: toRelativePath(rootDirectory, scannedFile.path),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
for (const walkDirectory of walkDirectories) {
|
|
82
|
+
for (const ruleFile of PROJECT_SINGLE_FILES) {
|
|
83
|
+
const source = toProjectSingleFileSource(ruleFile);
|
|
84
|
+
if (disabledSources.has(source)) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const filePath = join(walkDirectory.directory, ruleFile);
|
|
88
|
+
const fileInfo = singleFileInfoCached(filePath, cache);
|
|
89
|
+
if (fileInfo === null) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
candidates.push({
|
|
93
|
+
path: fileInfo.path,
|
|
94
|
+
realPath: fileInfo.realPath,
|
|
95
|
+
source,
|
|
96
|
+
distance: targetFile === null ? 0 : walkDirectory.distance,
|
|
97
|
+
isGlobal: false,
|
|
98
|
+
isSingleFile: true,
|
|
99
|
+
relativePath: toRelativePath(rootDirectory, filePath),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return candidates;
|
|
104
|
+
}
|
|
105
|
+
function findUserHomeCandidates(homeDirectory, disabledSources, cache) {
|
|
106
|
+
const candidates = [];
|
|
107
|
+
for (const ruleSubdir of USER_HOME_RULE_SUBDIRS) {
|
|
108
|
+
const source = toUserHomeRuleSource(ruleSubdir);
|
|
109
|
+
if (disabledSources.has(source)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const ruleDirectory = join(homeDirectory, ruleSubdir);
|
|
113
|
+
for (const scannedFile of scanRuleFilesCached(ruleDirectory, cache)) {
|
|
114
|
+
candidates.push({
|
|
115
|
+
path: scannedFile.path,
|
|
116
|
+
realPath: scannedFile.realPath,
|
|
117
|
+
source,
|
|
118
|
+
distance: GLOBAL_DISTANCE,
|
|
119
|
+
isGlobal: true,
|
|
120
|
+
isSingleFile: false,
|
|
121
|
+
relativePath: toRelativePath(homeDirectory, scannedFile.path),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const ruleFile of USER_HOME_SINGLE_FILES) {
|
|
126
|
+
const source = toUserHomeSingleFileSource(ruleFile);
|
|
127
|
+
if (disabledSources.has(source)) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const filePath = join(homeDirectory, ruleFile);
|
|
131
|
+
const fileInfo = singleFileInfoCached(filePath, cache);
|
|
132
|
+
if (fileInfo === null) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
candidates.push({
|
|
136
|
+
path: fileInfo.path,
|
|
137
|
+
realPath: fileInfo.realPath,
|
|
138
|
+
source,
|
|
139
|
+
distance: GLOBAL_DISTANCE,
|
|
140
|
+
isGlobal: true,
|
|
141
|
+
isSingleFile: true,
|
|
142
|
+
relativePath: toRelativePath(homeDirectory, filePath),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return candidates;
|
|
146
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LoadedRule } from "./types.js";
|
|
2
|
+
export interface FormatOptions {
|
|
3
|
+
maxRuleChars: number;
|
|
4
|
+
maxResultChars: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function formatStaticBlock(rules: ReadonlyArray<LoadedRule>, options: FormatOptions): string;
|
|
7
|
+
export declare function formatDynamicBlock(rules: ReadonlyArray<LoadedRule>, targetRelativePath: string, options: FormatOptions): string;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { isNeverTruncatedRule, truncateBudget, truncateRule } from "./truncator.js";
|
|
2
|
+
function formatRule(rule) {
|
|
3
|
+
const body = normalizeRuleBody(rule.body);
|
|
4
|
+
if (body.length === 0) {
|
|
5
|
+
return `Instructions from: ${rule.path}`;
|
|
6
|
+
}
|
|
7
|
+
return `Instructions from: ${rule.path}\n\n${body}`;
|
|
8
|
+
}
|
|
9
|
+
function truncateRules(rules, options) {
|
|
10
|
+
const perRuleNormalized = rules.map((rule) => ({
|
|
11
|
+
path: rule.path,
|
|
12
|
+
relativePath: rule.relativePath,
|
|
13
|
+
body: normalizeRuleBody(rule.body),
|
|
14
|
+
source: rule.source,
|
|
15
|
+
}));
|
|
16
|
+
const perRuleResultChars = Math.floor(options.maxResultChars / Math.max(1, perRuleNormalized.length));
|
|
17
|
+
const perRuleBudgeted = perRuleNormalized.map((rule) => ({
|
|
18
|
+
path: rule.path,
|
|
19
|
+
relativePath: rule.relativePath,
|
|
20
|
+
body: isNeverTruncatedRule(rule.relativePath)
|
|
21
|
+
? rule.body
|
|
22
|
+
: truncateRule(rule.body, {
|
|
23
|
+
maxChars: Math.min(options.maxRuleChars, perRuleResultChars),
|
|
24
|
+
relativePath: rule.relativePath,
|
|
25
|
+
}).body,
|
|
26
|
+
}));
|
|
27
|
+
const budgetedRules = truncateBudget({
|
|
28
|
+
rules: perRuleBudgeted.map((rule) => ({ body: rule.body, relativePath: rule.relativePath })),
|
|
29
|
+
maxResultChars: options.maxResultChars,
|
|
30
|
+
});
|
|
31
|
+
const truncatedRules = [];
|
|
32
|
+
for (let index = 0; index < budgetedRules.length; index += 1) {
|
|
33
|
+
const sourceRule = perRuleBudgeted[index];
|
|
34
|
+
const budgetedRule = budgetedRules[index];
|
|
35
|
+
if (sourceRule === undefined || budgetedRule === undefined) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
truncatedRules.push({
|
|
39
|
+
path: sourceRule.path,
|
|
40
|
+
relativePath: budgetedRule.relativePath,
|
|
41
|
+
body: budgetedRule.body,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return truncatedRules;
|
|
45
|
+
}
|
|
46
|
+
export function formatStaticBlock(rules, options) {
|
|
47
|
+
if (rules.length === 0) {
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
if (options.maxResultChars <= 0) {
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
const orderedRules = orderStaticRules(uniqueRulesByBody(rules));
|
|
54
|
+
return ["## Project Instructions", "", truncateRules(orderedRules, options).map(formatRule).join("\n\n")].join("\n");
|
|
55
|
+
}
|
|
56
|
+
function orderStaticRules(rules) {
|
|
57
|
+
const hephaestusRules = [];
|
|
58
|
+
const otherRules = [];
|
|
59
|
+
for (const rule of rules) {
|
|
60
|
+
if (isHephaestusRule(rule)) {
|
|
61
|
+
hephaestusRules.push(rule);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
otherRules.push(rule);
|
|
65
|
+
}
|
|
66
|
+
return [...hephaestusRules, ...otherRules];
|
|
67
|
+
}
|
|
68
|
+
function isHephaestusRule(rule) {
|
|
69
|
+
return displayFilename(rule).toLowerCase() === "hephaestus.md";
|
|
70
|
+
}
|
|
71
|
+
function displayFilename(rule) {
|
|
72
|
+
const normalizedPath = rule.relativePath.length > 0 ? rule.relativePath : rule.path;
|
|
73
|
+
const segments = normalizedPath
|
|
74
|
+
.replace(/\\/g, "/")
|
|
75
|
+
.split("/")
|
|
76
|
+
.filter((segment) => segment.length > 0);
|
|
77
|
+
return segments.at(-1) ?? normalizedPath;
|
|
78
|
+
}
|
|
79
|
+
function uniqueRulesByBody(rules) {
|
|
80
|
+
const uniqueRules = [];
|
|
81
|
+
const seenBodies = new Set();
|
|
82
|
+
const userDescriptions = new Set();
|
|
83
|
+
for (const rule of rules) {
|
|
84
|
+
const descriptionKey = rule.frontmatter.description?.trim();
|
|
85
|
+
if (rule.source === "plugin-bundled" && descriptionKey !== undefined && userDescriptions.has(descriptionKey)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const bodyKey = normalizeRuleBody(rule.body);
|
|
89
|
+
if (seenBodies.has(bodyKey)) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
seenBodies.add(bodyKey);
|
|
93
|
+
if (descriptionKey !== undefined && rule.source !== "plugin-bundled") {
|
|
94
|
+
userDescriptions.add(descriptionKey);
|
|
95
|
+
}
|
|
96
|
+
uniqueRules.push(rule);
|
|
97
|
+
}
|
|
98
|
+
return uniqueRules;
|
|
99
|
+
}
|
|
100
|
+
export function formatDynamicBlock(rules, targetRelativePath, options) {
|
|
101
|
+
if (rules.length === 0) {
|
|
102
|
+
return "";
|
|
103
|
+
}
|
|
104
|
+
return [
|
|
105
|
+
`Additional project instructions matched for ${targetRelativePath}:`,
|
|
106
|
+
"",
|
|
107
|
+
truncateRules(rules, options).map(formatRule).join("\n\n"),
|
|
108
|
+
].join("\n");
|
|
109
|
+
}
|
|
110
|
+
function normalizeRuleBody(body) {
|
|
111
|
+
return body.replace(/\r\n/g, "\n").replace(/\r/g, "\n").trim();
|
|
112
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MatchReason, RuleFrontmatter } from "./types.js";
|
|
2
|
+
export interface MatcherInput {
|
|
3
|
+
frontmatter: RuleFrontmatter;
|
|
4
|
+
isSingleFile: boolean;
|
|
5
|
+
/** Path bases to try matching against (POSIX-normalized). */
|
|
6
|
+
pathBases: {
|
|
7
|
+
projectRelative: string;
|
|
8
|
+
scopeRelative?: string;
|
|
9
|
+
basename: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface MatchResult {
|
|
13
|
+
matched: boolean;
|
|
14
|
+
reason: MatchReason;
|
|
15
|
+
}
|
|
16
|
+
export declare function matchRule(input: MatcherInput): MatchResult;
|
|
17
|
+
export declare function normalizeGlobs(frontmatter: RuleFrontmatter): string[];
|
|
18
|
+
export declare function hashContent(body: string): string;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import picomatch from "picomatch";
|
|
3
|
+
const compiledPatternSets = new Map();
|
|
4
|
+
export function matchRule(input) {
|
|
5
|
+
if (input.isSingleFile) {
|
|
6
|
+
return { matched: true, reason: "single-file" };
|
|
7
|
+
}
|
|
8
|
+
if (input.frontmatter.alwaysApply === true) {
|
|
9
|
+
return { matched: true, reason: "alwaysApply" };
|
|
10
|
+
}
|
|
11
|
+
const patterns = normalizeGlobs(input.frontmatter);
|
|
12
|
+
if (patterns.length === 0) {
|
|
13
|
+
return noMatch();
|
|
14
|
+
}
|
|
15
|
+
const pathBases = normalizedPathBases(input.pathBases);
|
|
16
|
+
const { positivePatterns, negativeMatchers } = compiledPatternSetFor(patterns);
|
|
17
|
+
for (const { pattern, isMatch } of positivePatterns) {
|
|
18
|
+
for (const pathBase of pathBases) {
|
|
19
|
+
if (!isMatch(pathBase)) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (isExcluded(pathBase, negativeMatchers)) {
|
|
23
|
+
return noMatch();
|
|
24
|
+
}
|
|
25
|
+
return { matched: true, reason: { kind: "glob", pattern } };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return noMatch();
|
|
29
|
+
}
|
|
30
|
+
export function normalizeGlobs(frontmatter) {
|
|
31
|
+
const patterns = [
|
|
32
|
+
...normalizePatternList(frontmatter.globs),
|
|
33
|
+
...normalizePatternList(frontmatter.paths),
|
|
34
|
+
...normalizePatternList(frontmatter.applyTo),
|
|
35
|
+
];
|
|
36
|
+
return [...new Set(patterns.map(normalizePath))];
|
|
37
|
+
}
|
|
38
|
+
export function hashContent(body) {
|
|
39
|
+
return createHash("sha256").update(body).digest("hex");
|
|
40
|
+
}
|
|
41
|
+
function normalizePatternList(patterns) {
|
|
42
|
+
if (patterns === undefined) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
return Array.isArray(patterns) ? patterns : [patterns];
|
|
46
|
+
}
|
|
47
|
+
function normalizePath(path) {
|
|
48
|
+
return path.replaceAll("\\", "/");
|
|
49
|
+
}
|
|
50
|
+
function normalizedPathBases(pathBases) {
|
|
51
|
+
const normalizedBases = [normalizePath(pathBases.projectRelative)];
|
|
52
|
+
if (pathBases.scopeRelative !== undefined) {
|
|
53
|
+
normalizedBases.push(normalizePath(pathBases.scopeRelative));
|
|
54
|
+
}
|
|
55
|
+
normalizedBases.push(normalizePath(pathBases.basename));
|
|
56
|
+
return normalizedBases;
|
|
57
|
+
}
|
|
58
|
+
function compiledPatternSetFor(patterns) {
|
|
59
|
+
const cacheKey = JSON.stringify(patterns);
|
|
60
|
+
const cached = compiledPatternSets.get(cacheKey);
|
|
61
|
+
if (cached !== undefined) {
|
|
62
|
+
return cached;
|
|
63
|
+
}
|
|
64
|
+
const compiled = compilePatternSet(patterns);
|
|
65
|
+
compiledPatternSets.set(cacheKey, compiled);
|
|
66
|
+
return compiled;
|
|
67
|
+
}
|
|
68
|
+
function compilePatternSet(patterns) {
|
|
69
|
+
const positivePatterns = [];
|
|
70
|
+
const negativeMatchers = [];
|
|
71
|
+
for (const pattern of patterns) {
|
|
72
|
+
if (pattern.startsWith("!")) {
|
|
73
|
+
negativeMatchers.push(createGlobMatcher(pattern.slice(1)));
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
positivePatterns.push({ pattern, isMatch: createGlobMatcher(pattern) });
|
|
77
|
+
}
|
|
78
|
+
return { positivePatterns, negativeMatchers };
|
|
79
|
+
}
|
|
80
|
+
function createGlobMatcher(pattern) {
|
|
81
|
+
return picomatch(normalizePath(pattern), { bash: true, dot: true });
|
|
82
|
+
}
|
|
83
|
+
function isExcluded(pathBase, negativeMatchers) {
|
|
84
|
+
for (const isMatch of negativeMatchers) {
|
|
85
|
+
if (isMatch(pathBase)) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
function noMatch() {
|
|
92
|
+
return { matched: false, reason: { kind: "no-match" } };
|
|
93
|
+
}
|