oh-my-opencode 4.8.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/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/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 +1922 -785
- 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/codex-multi-agent-v2-config.d.ts +11 -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/run/runnable-agent-resolver.d.ts +11 -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 +92552 -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/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/formatter.ts +7 -8
- package/packages/omo-codex/plugin/components/rules/src/rules/truncator.ts +17 -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/formatter.test.ts +20 -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 +104 -0
- package/packages/omo-codex/plugin/scripts/migrate-codex-config.mjs +23 -6
- 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 +261 -0
- 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 +5 -3
- 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 +22 -10
- 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,27 @@
|
|
|
1
|
+
import { SOURCE_PRIORITY } from "./constants.js";
|
|
2
|
+
export function sortCandidates(candidates) {
|
|
3
|
+
return candidates
|
|
4
|
+
.map((candidate, index) => ({ candidate, index }))
|
|
5
|
+
.sort((left, right) => compareCandidates(left.candidate, right.candidate) || left.index - right.index)
|
|
6
|
+
.map(({ candidate }) => candidate);
|
|
7
|
+
}
|
|
8
|
+
export function compareCandidates(a, b) {
|
|
9
|
+
return (compareBoolean(a.isGlobal, b.isGlobal) ||
|
|
10
|
+
compareNumber(a.distance, b.distance) ||
|
|
11
|
+
compareNumber(SOURCE_PRIORITY.get(a.source) ?? Infinity, SOURCE_PRIORITY.get(b.source) ?? Infinity) ||
|
|
12
|
+
compareString(a.relativePath, b.relativePath) ||
|
|
13
|
+
compareString(a.realPath, b.realPath));
|
|
14
|
+
}
|
|
15
|
+
function compareBoolean(a, b) {
|
|
16
|
+
return Number(a) - Number(b);
|
|
17
|
+
}
|
|
18
|
+
function compareNumber(a, b) {
|
|
19
|
+
return a - b;
|
|
20
|
+
}
|
|
21
|
+
function compareString(a, b) {
|
|
22
|
+
if (a < b)
|
|
23
|
+
return -1;
|
|
24
|
+
if (a > b)
|
|
25
|
+
return 1;
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type ClosingDelimiter = {
|
|
2
|
+
readonly start: number;
|
|
3
|
+
readonly bodyStart: number;
|
|
4
|
+
};
|
|
5
|
+
export declare function stripBom(content: string): string;
|
|
6
|
+
export declare function getOpeningDelimiterLength(content: string): number;
|
|
7
|
+
export declare function findClosingDelimiter(content: string, openingLength: number): ClosingDelimiter | null;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const FRONTMATTER_OPENING = "---\n";
|
|
2
|
+
const FRONTMATTER_OPENING_CRLF = "---\r\n";
|
|
3
|
+
export function stripBom(content) {
|
|
4
|
+
return content.startsWith("\uFEFF") ? content.slice(1) : content;
|
|
5
|
+
}
|
|
6
|
+
export function getOpeningDelimiterLength(content) {
|
|
7
|
+
if (content.startsWith(FRONTMATTER_OPENING_CRLF))
|
|
8
|
+
return FRONTMATTER_OPENING_CRLF.length;
|
|
9
|
+
if (content.startsWith(FRONTMATTER_OPENING))
|
|
10
|
+
return FRONTMATTER_OPENING.length;
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
export function findClosingDelimiter(content, openingLength) {
|
|
14
|
+
let lineStart = openingLength;
|
|
15
|
+
while (lineStart <= content.length) {
|
|
16
|
+
const nextNewline = content.indexOf("\n", lineStart);
|
|
17
|
+
const lineEnd = nextNewline === -1 ? content.length : nextNewline;
|
|
18
|
+
const line = content.slice(lineStart, lineEnd).replace(/\r$/, "");
|
|
19
|
+
if (line === "---") {
|
|
20
|
+
return {
|
|
21
|
+
start: lineStart,
|
|
22
|
+
bodyStart: nextNewline === -1 ? content.length : nextNewline + 1,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (nextNewline === -1)
|
|
26
|
+
break;
|
|
27
|
+
lineStart = nextNewline + 1;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { RuleFrontmatterParseError } from "./errors.js";
|
|
2
|
+
export function parseYamlFrontmatter(yamlContent) {
|
|
3
|
+
const lines = yamlContent.replace(/\r\n/g, "\n").split("\n");
|
|
4
|
+
const frontmatter = {};
|
|
5
|
+
const globValues = [];
|
|
6
|
+
const seenGlobs = new Set();
|
|
7
|
+
let lineIndex = 0;
|
|
8
|
+
while (lineIndex < lines.length) {
|
|
9
|
+
const rawLine = lines[lineIndex];
|
|
10
|
+
if (rawLine === undefined)
|
|
11
|
+
break;
|
|
12
|
+
const line = stripComment(rawLine).trim();
|
|
13
|
+
if (line.length === 0) {
|
|
14
|
+
lineIndex += 1;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const colonIndex = line.indexOf(":");
|
|
18
|
+
if (colonIndex === -1) {
|
|
19
|
+
throw new RuleFrontmatterParseError(`Expected key-value pair on line ${lineIndex + 1}`);
|
|
20
|
+
}
|
|
21
|
+
const key = line.slice(0, colonIndex).trim();
|
|
22
|
+
const rawValue = line.slice(colonIndex + 1).trim();
|
|
23
|
+
if (key === "description") {
|
|
24
|
+
frontmatter.description = parseStringValue(rawValue);
|
|
25
|
+
lineIndex += 1;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (key === "alwaysApply") {
|
|
29
|
+
frontmatter.alwaysApply = parseBooleanValue(rawValue, lineIndex + 1);
|
|
30
|
+
lineIndex += 1;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (key === "globs" || key === "paths" || key === "applyTo") {
|
|
34
|
+
const parsed = parseGlobValue(rawValue, lines, lineIndex);
|
|
35
|
+
for (const glob of parsed.values) {
|
|
36
|
+
if (!seenGlobs.has(glob)) {
|
|
37
|
+
seenGlobs.add(glob);
|
|
38
|
+
globValues.push(glob);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
lineIndex += parsed.consumed;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
lineIndex += 1;
|
|
45
|
+
}
|
|
46
|
+
const singleGlob = globValues[0];
|
|
47
|
+
if (globValues.length === 1 && singleGlob !== undefined) {
|
|
48
|
+
frontmatter.globs = singleGlob;
|
|
49
|
+
}
|
|
50
|
+
else if (globValues.length > 1) {
|
|
51
|
+
frontmatter.globs = globValues;
|
|
52
|
+
}
|
|
53
|
+
return frontmatter;
|
|
54
|
+
}
|
|
55
|
+
function parseBooleanValue(value, lineNumber) {
|
|
56
|
+
if (value === "true")
|
|
57
|
+
return true;
|
|
58
|
+
if (value === "false")
|
|
59
|
+
return false;
|
|
60
|
+
throw new RuleFrontmatterParseError(`Expected boolean on line ${lineNumber}`);
|
|
61
|
+
}
|
|
62
|
+
function parseGlobValue(rawValue, lines, lineIndex) {
|
|
63
|
+
if (rawValue.startsWith("[")) {
|
|
64
|
+
return { values: parseInlineArray(rawValue), consumed: 1 };
|
|
65
|
+
}
|
|
66
|
+
if (rawValue.length === 0) {
|
|
67
|
+
return parseMultilineArray(lines, lineIndex);
|
|
68
|
+
}
|
|
69
|
+
const quotedScalar = isQuotedScalar(rawValue);
|
|
70
|
+
const value = parseStringValue(rawValue);
|
|
71
|
+
if (!quotedScalar && value.includes(",")) {
|
|
72
|
+
return {
|
|
73
|
+
values: value
|
|
74
|
+
.split(",")
|
|
75
|
+
.map((item) => item.trim())
|
|
76
|
+
.filter(Boolean),
|
|
77
|
+
consumed: 1,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return { values: [value], consumed: 1 };
|
|
81
|
+
}
|
|
82
|
+
function isQuotedScalar(value) {
|
|
83
|
+
return value.startsWith('"') || value.startsWith("'");
|
|
84
|
+
}
|
|
85
|
+
function parseMultilineArray(lines, lineIndex) {
|
|
86
|
+
const values = [];
|
|
87
|
+
let consumed = 1;
|
|
88
|
+
for (let index = lineIndex + 1; index < lines.length; index += 1) {
|
|
89
|
+
const rawLine = lines[index];
|
|
90
|
+
if (rawLine === undefined)
|
|
91
|
+
break;
|
|
92
|
+
const lineWithoutComment = stripComment(rawLine);
|
|
93
|
+
if (lineWithoutComment.trim().length === 0) {
|
|
94
|
+
consumed += 1;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const arrayItem = lineWithoutComment.match(/^\s+-\s*(.*)$/);
|
|
98
|
+
if (arrayItem === null)
|
|
99
|
+
break;
|
|
100
|
+
values.push(parseStringValue(arrayItem[1] ?? ""));
|
|
101
|
+
consumed += 1;
|
|
102
|
+
}
|
|
103
|
+
return { values: values.filter(Boolean), consumed };
|
|
104
|
+
}
|
|
105
|
+
function parseInlineArray(value) {
|
|
106
|
+
const closingBracketIndex = findClosingBracket(value);
|
|
107
|
+
if (closingBracketIndex === -1) {
|
|
108
|
+
throw new RuleFrontmatterParseError("Unclosed inline array");
|
|
109
|
+
}
|
|
110
|
+
const trailing = value.slice(closingBracketIndex + 1).trim();
|
|
111
|
+
if (trailing.length > 0) {
|
|
112
|
+
throw new RuleFrontmatterParseError("Unexpected content after inline array");
|
|
113
|
+
}
|
|
114
|
+
const content = value.slice(1, closingBracketIndex).trim();
|
|
115
|
+
if (content.length === 0)
|
|
116
|
+
return [];
|
|
117
|
+
return splitCommaSeparated(content).map(parseStringValue).filter(Boolean);
|
|
118
|
+
}
|
|
119
|
+
function findClosingBracket(value) {
|
|
120
|
+
let quote = null;
|
|
121
|
+
let escaped = false;
|
|
122
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
123
|
+
const character = value[index];
|
|
124
|
+
if (character === undefined)
|
|
125
|
+
continue;
|
|
126
|
+
if (escaped) {
|
|
127
|
+
escaped = false;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (quote !== null && character === "\\") {
|
|
131
|
+
escaped = true;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (character === '"' || character === "'") {
|
|
135
|
+
if (quote === null)
|
|
136
|
+
quote = character;
|
|
137
|
+
else if (quote === character)
|
|
138
|
+
quote = null;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (quote === null && character === "]")
|
|
142
|
+
return index;
|
|
143
|
+
}
|
|
144
|
+
return -1;
|
|
145
|
+
}
|
|
146
|
+
function splitCommaSeparated(value) {
|
|
147
|
+
const values = [];
|
|
148
|
+
let current = "";
|
|
149
|
+
let quote = null;
|
|
150
|
+
let escaped = false;
|
|
151
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
152
|
+
const character = value[index];
|
|
153
|
+
if (character === undefined)
|
|
154
|
+
continue;
|
|
155
|
+
if (escaped) {
|
|
156
|
+
current += character;
|
|
157
|
+
escaped = false;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (quote !== null && character === "\\") {
|
|
161
|
+
current += character;
|
|
162
|
+
escaped = true;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (character === '"' || character === "'") {
|
|
166
|
+
if (quote === null)
|
|
167
|
+
quote = character;
|
|
168
|
+
else if (quote === character)
|
|
169
|
+
quote = null;
|
|
170
|
+
current += character;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (quote === null && character === ",") {
|
|
174
|
+
values.push(current.trim());
|
|
175
|
+
current = "";
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
current += character;
|
|
179
|
+
}
|
|
180
|
+
if (quote !== null) {
|
|
181
|
+
throw new RuleFrontmatterParseError("Unclosed quoted value");
|
|
182
|
+
}
|
|
183
|
+
values.push(current.trim());
|
|
184
|
+
return values.filter(Boolean);
|
|
185
|
+
}
|
|
186
|
+
function parseStringValue(value) {
|
|
187
|
+
if (value.length === 0)
|
|
188
|
+
return "";
|
|
189
|
+
if (value.startsWith('"'))
|
|
190
|
+
return parseJsonString(value);
|
|
191
|
+
if (value.startsWith("'") && value.endsWith("'"))
|
|
192
|
+
return value.slice(1, -1);
|
|
193
|
+
if (value.startsWith("'"))
|
|
194
|
+
throw new RuleFrontmatterParseError("Unclosed quoted value");
|
|
195
|
+
return value;
|
|
196
|
+
}
|
|
197
|
+
function parseJsonString(value) {
|
|
198
|
+
try {
|
|
199
|
+
const parsedValue = JSON.parse(value);
|
|
200
|
+
if (typeof parsedValue !== "string") {
|
|
201
|
+
throw new RuleFrontmatterParseError("Expected JSON-quoted string");
|
|
202
|
+
}
|
|
203
|
+
return parsedValue;
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
if (error instanceof RuleFrontmatterParseError)
|
|
207
|
+
throw error;
|
|
208
|
+
throw new RuleFrontmatterParseError("Invalid JSON-quoted string");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function stripComment(line) {
|
|
212
|
+
let quote = null;
|
|
213
|
+
let escaped = false;
|
|
214
|
+
for (let index = 0; index < line.length; index += 1) {
|
|
215
|
+
const character = line[index];
|
|
216
|
+
if (character === undefined)
|
|
217
|
+
continue;
|
|
218
|
+
if (escaped) {
|
|
219
|
+
escaped = false;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (quote !== null && character === "\\") {
|
|
223
|
+
escaped = true;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (character === '"' || character === "'") {
|
|
227
|
+
if (quote === null)
|
|
228
|
+
quote = character;
|
|
229
|
+
else if (quote === character)
|
|
230
|
+
quote = null;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (quote === null && character === "#")
|
|
234
|
+
return line.slice(0, index);
|
|
235
|
+
}
|
|
236
|
+
return line;
|
|
237
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { findClosingDelimiter, getOpeningDelimiterLength, stripBom } from "./parser-frontmatter.js";
|
|
2
|
+
import { parseYamlFrontmatter } from "./parser-yaml.js";
|
|
3
|
+
/** Parse markdown rule content and extract the supported YAML frontmatter subset. */
|
|
4
|
+
export function parseRule(content) {
|
|
5
|
+
const normalizedContent = stripBom(content);
|
|
6
|
+
const openingLength = getOpeningDelimiterLength(normalizedContent);
|
|
7
|
+
if (openingLength === 0) {
|
|
8
|
+
return { frontmatter: {}, body: normalizedContent };
|
|
9
|
+
}
|
|
10
|
+
const closingDelimiter = findClosingDelimiter(normalizedContent, openingLength);
|
|
11
|
+
if (closingDelimiter === null) {
|
|
12
|
+
return {
|
|
13
|
+
frontmatter: {},
|
|
14
|
+
body: normalizedContent,
|
|
15
|
+
diagnostic: "Missing closing frontmatter delimiter",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const yamlContent = normalizedContent.slice(openingLength, closingDelimiter.start);
|
|
19
|
+
const body = normalizedContent.slice(closingDelimiter.bodyStart);
|
|
20
|
+
try {
|
|
21
|
+
return { frontmatter: parseYamlFrontmatter(yamlContent), body };
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const message = error instanceof Error ? error.message : "Invalid YAML frontmatter";
|
|
25
|
+
return {
|
|
26
|
+
frontmatter: {},
|
|
27
|
+
body: normalizedContent,
|
|
28
|
+
diagnostic: `Malformed frontmatter: ${message}`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolvePluginRulesRoot(pluginRoot: string | undefined, moduleUrl?: string): string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const PLUGIN_MANIFEST_PATH = join(".codex-plugin", "plugin.json");
|
|
5
|
+
export function resolvePluginRulesRoot(pluginRoot, moduleUrl = import.meta.url) {
|
|
6
|
+
const configuredRoot = pluginRoot ?? process.env["PLUGIN_ROOT"];
|
|
7
|
+
if (configuredRoot !== undefined && configuredRoot.trim().length > 0) {
|
|
8
|
+
return resolveRulesComponentRoot(resolve(configuredRoot));
|
|
9
|
+
}
|
|
10
|
+
const discoveredRoot = findNearestPluginRoot(dirname(fileURLToPath(moduleUrl)));
|
|
11
|
+
if (discoveredRoot !== null) {
|
|
12
|
+
return resolveRulesComponentRoot(discoveredRoot);
|
|
13
|
+
}
|
|
14
|
+
return fileURLToPath(new URL("../../..", moduleUrl));
|
|
15
|
+
}
|
|
16
|
+
function findNearestPluginRoot(startDirectory) {
|
|
17
|
+
let currentDirectory = resolve(startDirectory);
|
|
18
|
+
while (true) {
|
|
19
|
+
if (isFile(join(currentDirectory, PLUGIN_MANIFEST_PATH))) {
|
|
20
|
+
return currentDirectory;
|
|
21
|
+
}
|
|
22
|
+
const parentDirectory = dirname(currentDirectory);
|
|
23
|
+
if (parentDirectory === currentDirectory) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
currentDirectory = parentDirectory;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function resolveRulesComponentRoot(pluginRoot) {
|
|
30
|
+
const componentRoot = join(pluginRoot, "components", "rules");
|
|
31
|
+
return isDirectory(componentRoot) ? componentRoot : pluginRoot;
|
|
32
|
+
}
|
|
33
|
+
function isFile(path) {
|
|
34
|
+
try {
|
|
35
|
+
return statSync(path).isFile();
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function isDirectory(path) {
|
|
42
|
+
try {
|
|
43
|
+
return statSync(path).isDirectory();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findProjectRoot(startPath: string, markers?: ReadonlyArray<string>): string | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { existsSync, statSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { PROJECT_MARKERS } from "./constants.js";
|
|
4
|
+
export function findProjectRoot(startPath, markers = PROJECT_MARKERS) {
|
|
5
|
+
const resolvedStartPath = resolve(startPath);
|
|
6
|
+
if (!existsSync(resolvedStartPath)) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const startStats = statSync(resolvedStartPath);
|
|
10
|
+
let currentDirectory = startStats.isDirectory() ? resolvedStartPath : dirname(resolvedStartPath);
|
|
11
|
+
const filesystemRoot = resolve("/");
|
|
12
|
+
while (true) {
|
|
13
|
+
for (const marker of markers) {
|
|
14
|
+
if (existsSync(join(currentDirectory, marker))) {
|
|
15
|
+
return currentDirectory;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (currentDirectory === filesystemRoot) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
currentDirectory = dirname(currentDirectory);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ScanOptions {
|
|
2
|
+
rootDir: string;
|
|
3
|
+
excludedDirs?: ReadonlyArray<string>;
|
|
4
|
+
/** Maximum recursion depth. Default: 10 */
|
|
5
|
+
maxDepth?: number;
|
|
6
|
+
maxFiles?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ScannedFile {
|
|
9
|
+
/** Absolute path as encountered (may be a symlink). */
|
|
10
|
+
path: string;
|
|
11
|
+
/** Real (resolved) path; same as path if not a symlink. */
|
|
12
|
+
realPath: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function scanRuleFiles(options: ScanOptions): ScannedFile[];
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { existsSync, lstatSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
3
|
+
import { DEFAULT_MAX_SCAN_FILES, RULE_FILE_EXTENSIONS, SCANNER_EXCLUDED_DIRS } from "./constants.js";
|
|
4
|
+
export function scanRuleFiles(options) {
|
|
5
|
+
const rootPath = toAbsolutePath(options.rootDir);
|
|
6
|
+
if (!existsSync(rootPath)) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
let rootStats;
|
|
10
|
+
try {
|
|
11
|
+
rootStats = statSync(rootPath);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
if (!rootStats.isDirectory()) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
const results = [];
|
|
20
|
+
const visitedDirectories = new Set();
|
|
21
|
+
const excludedDirs = new Set(options.excludedDirs ?? SCANNER_EXCLUDED_DIRS);
|
|
22
|
+
const maxDepth = options.maxDepth ?? 10;
|
|
23
|
+
const maxFiles = normalizeMaxFiles(options.maxFiles);
|
|
24
|
+
scanDirectory(rootPath, 0, maxDepth, maxFiles, excludedDirs, visitedDirectories, results);
|
|
25
|
+
return results;
|
|
26
|
+
}
|
|
27
|
+
function normalizeMaxFiles(maxFiles) {
|
|
28
|
+
const value = maxFiles ?? DEFAULT_MAX_SCAN_FILES;
|
|
29
|
+
if (!Number.isFinite(value) || value < 0)
|
|
30
|
+
return DEFAULT_MAX_SCAN_FILES;
|
|
31
|
+
return Math.floor(value);
|
|
32
|
+
}
|
|
33
|
+
function toAbsolutePath(filePath) {
|
|
34
|
+
return isAbsolute(filePath) ? filePath : resolve(filePath);
|
|
35
|
+
}
|
|
36
|
+
function scanDirectory(directoryPath, depth, maxDepth, maxFiles, excludedDirs, visitedDirectories, results) {
|
|
37
|
+
if (results.length >= maxFiles) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let realDirectoryPath;
|
|
41
|
+
try {
|
|
42
|
+
realDirectoryPath = realpathSync.native(directoryPath);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (visitedDirectories.has(realDirectoryPath)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
visitedDirectories.add(realDirectoryPath);
|
|
51
|
+
let entries;
|
|
52
|
+
try {
|
|
53
|
+
entries = readdirSync(directoryPath, { withFileTypes: true }).sort((leftEntry, rightEntry) => leftEntry.name.localeCompare(rightEntry.name));
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
for (const entry of entries) {
|
|
59
|
+
if (results.length >= maxFiles) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const entryPath = join(directoryPath, entry.name);
|
|
63
|
+
if (entry.isDirectory()) {
|
|
64
|
+
if (!excludedDirs.has(entry.name) && depth < maxDepth) {
|
|
65
|
+
scanDirectory(entryPath, depth + 1, maxDepth, maxFiles, excludedDirs, visitedDirectories, results);
|
|
66
|
+
}
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (entry.isSymbolicLink()) {
|
|
70
|
+
scanSymbolicLink(entryPath, entry.name, depth, maxDepth, maxFiles, excludedDirs, visitedDirectories, results);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (entry.isFile() && isRuleFile(entry.name)) {
|
|
74
|
+
results.push({ path: entryPath, realPath: resolveRealPath(entryPath) });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function scanSymbolicLink(linkPath, linkName, depth, maxDepth, maxFiles, excludedDirs, visitedDirectories, results) {
|
|
79
|
+
if (results.length >= maxFiles) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let targetStats;
|
|
83
|
+
try {
|
|
84
|
+
targetStats = statSync(linkPath);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (targetStats.isDirectory()) {
|
|
90
|
+
if (!excludedDirs.has(linkName) && depth < maxDepth) {
|
|
91
|
+
scanDirectory(linkPath, depth + 1, maxDepth, maxFiles, excludedDirs, visitedDirectories, results);
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (targetStats.isFile() && isRuleFile(linkName)) {
|
|
96
|
+
results.push({ path: linkPath, realPath: resolveRealPath(linkPath) });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function isRuleFile(fileName) {
|
|
100
|
+
return RULE_FILE_EXTENSIONS.some((extension) => fileName.endsWith(extension));
|
|
101
|
+
}
|
|
102
|
+
function resolveRealPath(filePath) {
|
|
103
|
+
try {
|
|
104
|
+
const realPath = realpathSync.native(filePath);
|
|
105
|
+
const fileStats = lstatSync(filePath);
|
|
106
|
+
return fileStats.isSymbolicLink() ? realPath : filePath;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return filePath;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SOURCE_PRIORITY } from "./constants.js";
|
|
2
|
+
export const DEFAULT_AUTO_DISABLED_SOURCES = ["AGENTS.md", "~/.claude/rules", "~/.claude/CLAUDE.md"];
|
|
3
|
+
export function disabledSourcesFromConfig(config) {
|
|
4
|
+
if (config.enabledSources === "auto") {
|
|
5
|
+
return new Set(DEFAULT_AUTO_DISABLED_SOURCES);
|
|
6
|
+
}
|
|
7
|
+
const enabledSources = new Set(config.enabledSources);
|
|
8
|
+
return new Set([...SOURCE_PRIORITY.keys()].filter((source) => !enabledSources.has(source)));
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TruncationResult } from "./types.js";
|
|
2
|
+
type BudgetRule = {
|
|
3
|
+
body: string;
|
|
4
|
+
relativePath: string;
|
|
5
|
+
};
|
|
6
|
+
type BudgetResult = BudgetRule & {
|
|
7
|
+
truncated: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function isNeverTruncatedRule(relativePath: string): boolean;
|
|
10
|
+
export declare function truncateRule(body: string, options: {
|
|
11
|
+
maxChars: number;
|
|
12
|
+
relativePath: string;
|
|
13
|
+
}): TruncationResult;
|
|
14
|
+
export declare function truncateBudget(input: {
|
|
15
|
+
rules: ReadonlyArray<BudgetRule>;
|
|
16
|
+
maxResultChars: number;
|
|
17
|
+
}): BudgetResult[];
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { TRUNCATION_NOTICE } from "./constants.js";
|
|
2
|
+
function truncationNotice(relativePath) {
|
|
3
|
+
return TRUNCATION_NOTICE.replace("{path}", relativePath);
|
|
4
|
+
}
|
|
5
|
+
export function isNeverTruncatedRule(relativePath) {
|
|
6
|
+
const normalized = relativePath.replace(/\\/g, "/");
|
|
7
|
+
const segments = normalized.split("/").filter((segment) => segment.length > 0);
|
|
8
|
+
const filename = segments.at(-1) ?? normalized;
|
|
9
|
+
return filename.toLowerCase() === "hephaestus.md";
|
|
10
|
+
}
|
|
11
|
+
function safeSliceEnd(body, end) {
|
|
12
|
+
if (end <= 0) {
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
const lastCodeUnit = body.charCodeAt(end - 1);
|
|
16
|
+
if (lastCodeUnit >= 0xd800 && lastCodeUnit <= 0xdbff) {
|
|
17
|
+
return end - 1;
|
|
18
|
+
}
|
|
19
|
+
return end;
|
|
20
|
+
}
|
|
21
|
+
export function truncateRule(body, options) {
|
|
22
|
+
if (isNeverTruncatedRule(options.relativePath)) {
|
|
23
|
+
return { body, truncated: false, originalLength: body.length };
|
|
24
|
+
}
|
|
25
|
+
if (body.length <= options.maxChars) {
|
|
26
|
+
return { body, truncated: false, originalLength: body.length };
|
|
27
|
+
}
|
|
28
|
+
const notice = truncationNotice(options.relativePath);
|
|
29
|
+
if (options.maxChars < notice.length) {
|
|
30
|
+
return { body: notice, truncated: true, originalLength: body.length };
|
|
31
|
+
}
|
|
32
|
+
const sliceEnd = safeSliceEnd(body, options.maxChars - notice.length);
|
|
33
|
+
return { body: `${body.slice(0, sliceEnd)}${notice}`, truncated: true, originalLength: body.length };
|
|
34
|
+
}
|
|
35
|
+
export function truncateBudget(input) {
|
|
36
|
+
const results = [];
|
|
37
|
+
let remainingBudget = input.maxResultChars;
|
|
38
|
+
for (const rule of input.rules) {
|
|
39
|
+
if (isNeverTruncatedRule(rule.relativePath)) {
|
|
40
|
+
results.push({ body: rule.body, truncated: false, relativePath: rule.relativePath });
|
|
41
|
+
remainingBudget -= rule.body.length;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (remainingBudget >= rule.body.length) {
|
|
45
|
+
results.push({ body: rule.body, truncated: false, relativePath: rule.relativePath });
|
|
46
|
+
remainingBudget -= rule.body.length;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const notice = truncationNotice(rule.relativePath);
|
|
50
|
+
if (remainingBudget <= notice.length) {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
const sliceEnd = safeSliceEnd(rule.body, remainingBudget - notice.length);
|
|
54
|
+
const body = `${rule.body.slice(0, sliceEnd)}${notice}`;
|
|
55
|
+
results.push({ body, truncated: true, relativePath: rule.relativePath });
|
|
56
|
+
remainingBudget -= body.length;
|
|
57
|
+
}
|
|
58
|
+
return results;
|
|
59
|
+
}
|