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,100 @@
|
|
|
1
|
+
import { SOURCE_PRIORITY } from "./rules/constants.js";
|
|
2
|
+
import { defaultConfig } from "./rules/engine.js";
|
|
3
|
+
export function configFromEnvironment(env = process.env) {
|
|
4
|
+
const config = defaultConfig();
|
|
5
|
+
const disableBundledRules = isTruthy(firstEnv(env, "CODEX_RULES_DISABLE_BUNDLED", "PI_RULES_DISABLE_BUNDLED"));
|
|
6
|
+
config.disabled = isTruthy(firstEnv(env, "CODEX_RULES_DISABLED", "PI_RULES_DISABLED"));
|
|
7
|
+
config.mode = parseMode(firstEnv(env, "CODEX_RULES_MODE", "PI_RULES_MODE")) ?? config.mode;
|
|
8
|
+
config.maxRuleChars =
|
|
9
|
+
parsePositiveInteger(firstEnv(env, "CODEX_RULES_MAX_RULE_CHARS", "PI_RULES_MAX_RULE_CHARS")) ??
|
|
10
|
+
config.maxRuleChars;
|
|
11
|
+
config.maxResultChars =
|
|
12
|
+
parsePositiveInteger(firstEnv(env, "CODEX_RULES_MAX_RESULT_CHARS", "PI_RULES_MAX_RESULT_CHARS")) ??
|
|
13
|
+
config.maxResultChars;
|
|
14
|
+
config.postCompactMaxRuleChars =
|
|
15
|
+
parsePositiveInteger(firstEnv(env, "CODEX_RULES_POST_COMPACT_MAX_RULE_CHARS", "PI_RULES_POST_COMPACT_MAX_RULE_CHARS")) ?? config.postCompactMaxRuleChars;
|
|
16
|
+
config.postCompactMaxResultChars =
|
|
17
|
+
parsePositiveInteger(firstEnv(env, "CODEX_RULES_POST_COMPACT_MAX_RESULT_CHARS", "PI_RULES_POST_COMPACT_MAX_RESULT_CHARS")) ?? config.postCompactMaxResultChars;
|
|
18
|
+
config.dynamicMaxRuleChars =
|
|
19
|
+
parsePositiveInteger(firstEnv(env, "CODEX_RULES_DYNAMIC_MAX_RULE_CHARS", "PI_RULES_DYNAMIC_MAX_RULE_CHARS")) ??
|
|
20
|
+
config.dynamicMaxRuleChars;
|
|
21
|
+
config.dynamicMaxResultChars =
|
|
22
|
+
parsePositiveInteger(firstEnv(env, "CODEX_RULES_DYNAMIC_MAX_RESULT_CHARS", "PI_RULES_DYNAMIC_MAX_RESULT_CHARS")) ?? config.dynamicMaxResultChars;
|
|
23
|
+
config.promptMaxRuleChars =
|
|
24
|
+
parsePositiveInteger(firstEnv(env, "CODEX_RULES_PROMPT_MAX_RULE_CHARS", "PI_RULES_PROMPT_MAX_RULE_CHARS")) ??
|
|
25
|
+
config.promptMaxRuleChars;
|
|
26
|
+
config.promptMaxResultChars =
|
|
27
|
+
parsePositiveInteger(firstEnv(env, "CODEX_RULES_PROMPT_MAX_RESULT_CHARS", "PI_RULES_PROMPT_MAX_RESULT_CHARS")) ??
|
|
28
|
+
config.promptMaxResultChars;
|
|
29
|
+
config.enabledSources = parseEnabledSources(firstEnv(env, "CODEX_RULES_ENABLED_SOURCES", "PI_RULES_ENABLED_SOURCES"), disableBundledRules);
|
|
30
|
+
return config;
|
|
31
|
+
}
|
|
32
|
+
function firstEnv(env, ...names) {
|
|
33
|
+
for (const name of names) {
|
|
34
|
+
const value = env[name];
|
|
35
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
function isTruthy(value) {
|
|
42
|
+
if (value === undefined)
|
|
43
|
+
return false;
|
|
44
|
+
return ["1", "true", "yes", "on"].includes(value.trim().toLowerCase());
|
|
45
|
+
}
|
|
46
|
+
function parseMode(value) {
|
|
47
|
+
if (value === undefined)
|
|
48
|
+
return undefined;
|
|
49
|
+
const normalized = value.trim().toLowerCase();
|
|
50
|
+
switch (normalized) {
|
|
51
|
+
case "static":
|
|
52
|
+
case "dynamic":
|
|
53
|
+
case "both":
|
|
54
|
+
case "off":
|
|
55
|
+
return normalized;
|
|
56
|
+
default:
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function parsePositiveInteger(value) {
|
|
61
|
+
if (value === undefined)
|
|
62
|
+
return undefined;
|
|
63
|
+
const parsed = Number.parseInt(value.trim(), 10);
|
|
64
|
+
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : undefined;
|
|
65
|
+
}
|
|
66
|
+
function parseEnabledSources(value, disableBundledRules) {
|
|
67
|
+
if (value === undefined || value.trim().toLowerCase() === "auto") {
|
|
68
|
+
return disableBundledRules ? sourcesWithoutBundledRules() : "auto";
|
|
69
|
+
}
|
|
70
|
+
const sources = [];
|
|
71
|
+
for (const rawSource of value.split(",")) {
|
|
72
|
+
const source = toRuleSource(rawSource.trim());
|
|
73
|
+
if (source === null) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
sources.push(source);
|
|
77
|
+
}
|
|
78
|
+
const enabledSources = disableBundledRules ? sources.filter((source) => source !== "plugin-bundled") : sources;
|
|
79
|
+
return enabledSources;
|
|
80
|
+
}
|
|
81
|
+
function sourcesWithoutBundledRules() {
|
|
82
|
+
return [...SOURCE_PRIORITY.keys()].filter((source) => source !== "plugin-bundled");
|
|
83
|
+
}
|
|
84
|
+
function toRuleSource(value) {
|
|
85
|
+
switch (value) {
|
|
86
|
+
case ".omo/rules":
|
|
87
|
+
case ".claude/rules":
|
|
88
|
+
case ".cursor/rules":
|
|
89
|
+
case ".github/instructions":
|
|
90
|
+
case ".github/copilot-instructions.md":
|
|
91
|
+
case "CONTEXT.md":
|
|
92
|
+
case "plugin-bundled":
|
|
93
|
+
case "~/.omo/rules":
|
|
94
|
+
case "~/.opencode/rules":
|
|
95
|
+
case "~/.claude/rules":
|
|
96
|
+
return value;
|
|
97
|
+
default:
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
const CONTEXT_PRESSURE_MARKERS = [
|
|
3
|
+
"context compacted",
|
|
4
|
+
"context_length_exceeded",
|
|
5
|
+
"skill descriptions were shortened",
|
|
6
|
+
"context_too_large",
|
|
7
|
+
"codex ran out of room in the model's context window",
|
|
8
|
+
"your input exceeds the context window",
|
|
9
|
+
"long threads and multiple compactions",
|
|
10
|
+
];
|
|
11
|
+
export function hasContextPressureMarker(text) {
|
|
12
|
+
const normalizedText = text.toLowerCase();
|
|
13
|
+
return CONTEXT_PRESSURE_MARKERS.some((marker) => normalizedText.includes(marker));
|
|
14
|
+
}
|
|
15
|
+
export function transcriptHasContextPressureMarker(transcriptPath) {
|
|
16
|
+
if (transcriptPath === undefined || transcriptPath === null)
|
|
17
|
+
return false;
|
|
18
|
+
try {
|
|
19
|
+
return hasContextPressureMarker(readFileSync(transcriptPath, "utf8"));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error instanceof Error)
|
|
23
|
+
return false;
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type DebugFieldValue = boolean | number | string | null;
|
|
2
|
+
type DebugFields = Record<string, DebugFieldValue>;
|
|
3
|
+
export interface HookDebugTimer {
|
|
4
|
+
lap(phase: string, fields?: DebugFields): void;
|
|
5
|
+
done(fields?: DebugFields): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function createHookDebugTimer(hookName: string): HookDebugTimer;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { performance } from "node:perf_hooks";
|
|
2
|
+
import { debuglog } from "node:util";
|
|
3
|
+
const debug = debuglog("codex-rules");
|
|
4
|
+
const noopTimer = {
|
|
5
|
+
lap: () => { },
|
|
6
|
+
done: () => { },
|
|
7
|
+
};
|
|
8
|
+
export function createHookDebugTimer(hookName) {
|
|
9
|
+
if (!debug.enabled) {
|
|
10
|
+
return noopTimer;
|
|
11
|
+
}
|
|
12
|
+
const startMs = performance.now();
|
|
13
|
+
let lastMs = startMs;
|
|
14
|
+
return {
|
|
15
|
+
lap: (phase, fields = {}) => {
|
|
16
|
+
const nowMs = performance.now();
|
|
17
|
+
writeDebugLine(hookName, phase, nowMs - lastMs, nowMs - startMs, fields);
|
|
18
|
+
lastMs = nowMs;
|
|
19
|
+
},
|
|
20
|
+
done: (fields = {}) => {
|
|
21
|
+
const nowMs = performance.now();
|
|
22
|
+
writeDebugLine(hookName, "done", nowMs - lastMs, nowMs - startMs, fields);
|
|
23
|
+
lastMs = nowMs;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function writeDebugLine(hookName, phase, durationMs, totalMs, fields) {
|
|
28
|
+
debug("%s phase=%s ms=%s total_ms=%s%s", hookName, phase, durationMs.toFixed(3), totalMs.toFixed(3), formatFields(fields));
|
|
29
|
+
}
|
|
30
|
+
function formatFields(fields) {
|
|
31
|
+
const entries = Object.entries(fields);
|
|
32
|
+
if (entries.length === 0) {
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
return ` ${entries.map(([key, value]) => `${key}=${String(value)}`).join(" ")}`;
|
|
36
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PiRulesConfig } from "./rules/types.js";
|
|
2
|
+
export interface DynamicTargetFingerprint {
|
|
3
|
+
targetPath: string;
|
|
4
|
+
cacheKey: string;
|
|
5
|
+
fingerprint: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function fingerprintDynamicTargets(cwd: string, targetPaths: ReadonlyArray<string>, config: PiRulesConfig): DynamicTargetFingerprint[];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { isSameOrChildPath, toPosixPath, uniqueStrings } from "./path-utils.js";
|
|
4
|
+
import { createRuleDiscoveryCache, findRuleCandidates } from "./rules/finder.js";
|
|
5
|
+
import { hashContent } from "./rules/matcher.js";
|
|
6
|
+
import { sortCandidates } from "./rules/ordering.js";
|
|
7
|
+
import { findProjectRoot } from "./rules/project-root.js";
|
|
8
|
+
import { disabledSourcesFromConfig } from "./rules/sources.js";
|
|
9
|
+
export function fingerprintDynamicTargets(cwd, targetPaths, config) {
|
|
10
|
+
const disabledSources = disabledSourcesFromConfig(config);
|
|
11
|
+
const discoveryCache = createRuleDiscoveryCache();
|
|
12
|
+
const cwdProjectRoot = findProjectRoot(cwd);
|
|
13
|
+
const fingerprints = [];
|
|
14
|
+
for (const targetPath of uniqueStrings(targetPaths)) {
|
|
15
|
+
const projectRoot = cwdProjectRoot !== null && isSameOrChildPath(targetPath, cwdProjectRoot)
|
|
16
|
+
? cwdProjectRoot
|
|
17
|
+
: findProjectRoot(targetPath);
|
|
18
|
+
const findOptions = {
|
|
19
|
+
projectRoot,
|
|
20
|
+
targetFile: targetPath,
|
|
21
|
+
cache: discoveryCache,
|
|
22
|
+
};
|
|
23
|
+
if (disabledSources !== undefined) {
|
|
24
|
+
findOptions.disabledSources = disabledSources;
|
|
25
|
+
}
|
|
26
|
+
const candidates = findRuleCandidates(findOptions);
|
|
27
|
+
const candidateFingerprint = sortCandidates(candidates).map(fingerprintCandidate).join("\u0001");
|
|
28
|
+
const cacheKey = dynamicTargetCacheKey(targetPath);
|
|
29
|
+
fingerprints.push({
|
|
30
|
+
targetPath,
|
|
31
|
+
cacheKey,
|
|
32
|
+
fingerprint: hashContent([
|
|
33
|
+
"v1",
|
|
34
|
+
config.enabledSources === "auto" ? "auto" : config.enabledSources.join(","),
|
|
35
|
+
projectRoot ?? "",
|
|
36
|
+
cacheKey,
|
|
37
|
+
candidateFingerprint,
|
|
38
|
+
].join("\u0000")),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return fingerprints;
|
|
42
|
+
}
|
|
43
|
+
function fingerprintCandidate(candidate) {
|
|
44
|
+
return [
|
|
45
|
+
candidate.realPath,
|
|
46
|
+
candidate.relativePath,
|
|
47
|
+
candidate.source,
|
|
48
|
+
candidate.isGlobal ? "global" : "project",
|
|
49
|
+
candidate.isSingleFile ? "single" : "multi",
|
|
50
|
+
String(candidate.distance),
|
|
51
|
+
fileFingerprint(candidate.path),
|
|
52
|
+
].join("\u0000");
|
|
53
|
+
}
|
|
54
|
+
function fileFingerprint(filePath) {
|
|
55
|
+
try {
|
|
56
|
+
const stats = statSync(filePath, { bigint: true });
|
|
57
|
+
return `${stats.mtimeNs}:${stats.ctimeNs}:${stats.size}`;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return "missing";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function dynamicTargetCacheKey(targetPath) {
|
|
64
|
+
return toPosixPath(resolve(targetPath));
|
|
65
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function withDynamicBudget(config) {
|
|
2
|
+
return {
|
|
3
|
+
...config,
|
|
4
|
+
maxRuleChars: Math.min(config.maxRuleChars, config.dynamicMaxRuleChars),
|
|
5
|
+
maxResultChars: Math.min(config.maxResultChars, config.dynamicMaxResultChars),
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export function withPromptBudget(config) {
|
|
9
|
+
return {
|
|
10
|
+
...config,
|
|
11
|
+
maxRuleChars: Math.min(config.maxRuleChars, config.promptMaxRuleChars),
|
|
12
|
+
maxResultChars: Math.min(config.maxResultChars, config.promptMaxResultChars),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const MAX_ADDITIONAL_CONTEXT_CHARS = 32_000;
|
|
2
|
+
export function formatAdditionalContextOutput(eventName, additionalContext) {
|
|
3
|
+
const normalizedContext = limitAdditionalContext(normalizeAdditionalContext(additionalContext));
|
|
4
|
+
if (normalizedContext.length === 0)
|
|
5
|
+
return "";
|
|
6
|
+
return `${JSON.stringify({
|
|
7
|
+
hookSpecificOutput: {
|
|
8
|
+
hookEventName: eventName,
|
|
9
|
+
additionalContext: normalizedContext,
|
|
10
|
+
},
|
|
11
|
+
})}\n`;
|
|
12
|
+
}
|
|
13
|
+
function normalizeAdditionalContext(additionalContext) {
|
|
14
|
+
return additionalContext.replace(/\r\n/g, "\n").replace(/\r/g, "\n").trim();
|
|
15
|
+
}
|
|
16
|
+
function limitAdditionalContext(additionalContext) {
|
|
17
|
+
if (additionalContext.length <= MAX_ADDITIONAL_CONTEXT_CHARS)
|
|
18
|
+
return additionalContext;
|
|
19
|
+
const marker = `\n\n[Truncated hook additional context to ${MAX_ADDITIONAL_CONTEXT_CHARS} chars to avoid Codex context overflow.]`;
|
|
20
|
+
if (marker.length >= MAX_ADDITIONAL_CONTEXT_CHARS)
|
|
21
|
+
return marker.slice(0, MAX_ADDITIONAL_CONTEXT_CHARS);
|
|
22
|
+
const head = additionalContext.slice(0, MAX_ADDITIONAL_CONTEXT_CHARS - marker.length).replace(/[ \t\r\n]+$/, "");
|
|
23
|
+
return `${head}${marker}`;
|
|
24
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function displayPath(cwd: string, filePath: string): string;
|
|
2
|
+
export declare function isSameOrChildPath(childPath: string, parentPath: string): boolean;
|
|
3
|
+
export declare function toPosixPath(path: string): string;
|
|
4
|
+
export declare function uniqueStrings(values: ReadonlyArray<string>): string[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
2
|
+
export function displayPath(cwd, filePath) {
|
|
3
|
+
const rel = isAbsolute(filePath) ? relative(cwd, filePath) : filePath;
|
|
4
|
+
return toPosixPath(rel);
|
|
5
|
+
}
|
|
6
|
+
export function isSameOrChildPath(childPath, parentPath) {
|
|
7
|
+
const childRelativePath = relative(parentPath, resolve(childPath));
|
|
8
|
+
return childRelativePath === "" || (!childRelativePath.startsWith("..") && !isAbsolute(childRelativePath));
|
|
9
|
+
}
|
|
10
|
+
export function toPosixPath(path) {
|
|
11
|
+
return path.replaceAll("\\", "/");
|
|
12
|
+
}
|
|
13
|
+
export function uniqueStrings(values) {
|
|
14
|
+
const uniqueValues = [];
|
|
15
|
+
const seenValues = new Set();
|
|
16
|
+
for (const value of values) {
|
|
17
|
+
if (seenValues.has(value)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
seenValues.add(value);
|
|
21
|
+
uniqueValues.push(value);
|
|
22
|
+
}
|
|
23
|
+
return uniqueValues;
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PostCompactPendingKind } from "./post-compact-state.js";
|
|
2
|
+
import type { Engine } from "./rules/engine.js";
|
|
3
|
+
export type PostCompactClaimResult = "claimed" | "not-pending" | "contended";
|
|
4
|
+
export declare function hydrateEngineState(engine: Engine, cachePath: string): void;
|
|
5
|
+
export declare function persistEngineState(engine: Engine, cachePath: string, completedPostCompactKind?: PostCompactPendingKind): void;
|
|
6
|
+
export declare function clearSessionState(cachePath: string): void;
|
|
7
|
+
export declare function markSessionCompacted(cachePath: string): void;
|
|
8
|
+
export declare function hasPostCompactPending(cachePath: string): boolean;
|
|
9
|
+
export declare function isPostCompactPending(cachePath: string, kind: PostCompactPendingKind): boolean;
|
|
10
|
+
export declare function claimPostCompactPending(cachePath: string, kind: PostCompactPendingKind): PostCompactClaimResult;
|
|
11
|
+
export declare function isPostCompactRecoveryInProgress(cachePath: string, kind: PostCompactPendingKind): boolean;
|
|
12
|
+
export declare function completePostCompactRecovery(cachePath: string, kind: PostCompactPendingKind): void;
|
|
13
|
+
export declare function sessionCachePath(sessionId: string, pluginDataRoot: string | undefined): string;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { postCompactKindState, postCompactPendingKinds, postCompactRecoveringKinds, } from "./post-compact-state.js";
|
|
5
|
+
import { SESSION_STATE_LOCK_CONTENDED, withSessionStateLock } from "./session-state-lock.js";
|
|
6
|
+
export function hydrateEngineState(engine, cachePath) {
|
|
7
|
+
const state = readSessionState(cachePath);
|
|
8
|
+
engine.state.staticDedup.clear();
|
|
9
|
+
engine.state.dynamicDedup.clear();
|
|
10
|
+
engine.state.dynamicTargetFingerprints.clear();
|
|
11
|
+
for (const key of state.staticDedup) {
|
|
12
|
+
engine.state.staticDedup.add(key);
|
|
13
|
+
}
|
|
14
|
+
for (const [scope, keys] of Object.entries(state.dynamicDedup)) {
|
|
15
|
+
engine.state.dynamicDedup.set(scope, new Set(keys));
|
|
16
|
+
}
|
|
17
|
+
for (const [targetKey, fingerprint] of Object.entries(state.dynamicTargetFingerprints ?? {})) {
|
|
18
|
+
engine.state.dynamicTargetFingerprints.set(targetKey, fingerprint);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function persistEngineState(engine, cachePath, completedPostCompactKind) {
|
|
22
|
+
const currentState = readSessionState(cachePath);
|
|
23
|
+
const dynamicDedup = {};
|
|
24
|
+
for (const [scope, keys] of engine.state.dynamicDedup.entries()) {
|
|
25
|
+
dynamicDedup[scope] = [...keys];
|
|
26
|
+
}
|
|
27
|
+
const postCompactPending = nextPostCompactPending(currentState, completedPostCompactKind);
|
|
28
|
+
const postCompactRecovering = nextPostCompactRecovering(currentState, completedPostCompactKind);
|
|
29
|
+
writeSessionState(cachePath, {
|
|
30
|
+
staticDedup: [...engine.state.staticDedup],
|
|
31
|
+
dynamicDedup,
|
|
32
|
+
dynamicTargetFingerprints: Object.fromEntries(engine.state.dynamicTargetFingerprints.entries()),
|
|
33
|
+
...(postCompactPending === undefined ? {} : { postCompactPending }),
|
|
34
|
+
...(postCompactRecovering === undefined ? {} : { postCompactRecovering }),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export function clearSessionState(cachePath) {
|
|
38
|
+
rmSync(cachePath, { force: true });
|
|
39
|
+
}
|
|
40
|
+
export function markSessionCompacted(cachePath) {
|
|
41
|
+
const state = readSessionState(cachePath);
|
|
42
|
+
// Compaction drops injected static rule bodies, so pre-compaction static
|
|
43
|
+
// dedup marks must not suppress the post-compact recovery directive.
|
|
44
|
+
// Dynamic dedup survives: those rules are recovered as read-directive paths.
|
|
45
|
+
writeSessionState(cachePath, {
|
|
46
|
+
staticDedup: [],
|
|
47
|
+
dynamicDedup: state.dynamicDedup,
|
|
48
|
+
...(state.dynamicTargetFingerprints === undefined
|
|
49
|
+
? {}
|
|
50
|
+
: { dynamicTargetFingerprints: state.dynamicTargetFingerprints }),
|
|
51
|
+
postCompactPending: { static: true, dynamic: true },
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export function hasPostCompactPending(cachePath) {
|
|
55
|
+
const state = readSessionState(cachePath);
|
|
56
|
+
return postCompactPendingKinds(state).size > 0 || postCompactRecoveringKinds(state).size > 0;
|
|
57
|
+
}
|
|
58
|
+
export function isPostCompactPending(cachePath, kind) {
|
|
59
|
+
return postCompactPendingKinds(readSessionState(cachePath)).has(kind);
|
|
60
|
+
}
|
|
61
|
+
export function claimPostCompactPending(cachePath, kind) {
|
|
62
|
+
const result = withSessionStateLock(cachePath, () => {
|
|
63
|
+
const state = readSessionState(cachePath);
|
|
64
|
+
const pendingKinds = postCompactPendingKinds(state);
|
|
65
|
+
if (!pendingKinds.has(kind)) {
|
|
66
|
+
return "not-pending";
|
|
67
|
+
}
|
|
68
|
+
pendingKinds.delete(kind);
|
|
69
|
+
const recoveringKinds = postCompactRecoveringKinds(state);
|
|
70
|
+
recoveringKinds.add(kind);
|
|
71
|
+
writeSessionState(cachePath, stateWithPostCompactKinds(state, pendingKinds, recoveringKinds));
|
|
72
|
+
return "claimed";
|
|
73
|
+
});
|
|
74
|
+
return result === SESSION_STATE_LOCK_CONTENDED ? "contended" : result;
|
|
75
|
+
}
|
|
76
|
+
export function isPostCompactRecoveryInProgress(cachePath, kind) {
|
|
77
|
+
return postCompactRecoveringKinds(readSessionState(cachePath)).has(kind);
|
|
78
|
+
}
|
|
79
|
+
export function completePostCompactRecovery(cachePath, kind) {
|
|
80
|
+
withSessionStateLock(cachePath, () => {
|
|
81
|
+
const state = readSessionState(cachePath);
|
|
82
|
+
const pendingKinds = postCompactPendingKinds(state);
|
|
83
|
+
const recoveringKinds = postCompactRecoveringKinds(state);
|
|
84
|
+
recoveringKinds.delete(kind);
|
|
85
|
+
writeSessionState(cachePath, stateWithPostCompactKinds(state, pendingKinds, recoveringKinds));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
export function sessionCachePath(sessionId, pluginDataRoot) {
|
|
89
|
+
const root = pluginDataRoot ?? process.env["PLUGIN_DATA"] ?? join(homedir(), ".codex", "codex-rules");
|
|
90
|
+
return join(root, "sessions", `${safePathSegment(sessionId)}.json`);
|
|
91
|
+
}
|
|
92
|
+
function readSessionState(cachePath) {
|
|
93
|
+
try {
|
|
94
|
+
const parsed = JSON.parse(readFileSync(cachePath, "utf8"));
|
|
95
|
+
if (!isSerializedSessionState(parsed))
|
|
96
|
+
return emptyState();
|
|
97
|
+
return parsed;
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return emptyState();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function writeSessionState(cachePath, state) {
|
|
104
|
+
mkdirSync(dirname(cachePath), { recursive: true });
|
|
105
|
+
writeFileSync(cachePath, `${JSON.stringify(state)}\n`);
|
|
106
|
+
}
|
|
107
|
+
function emptyState() {
|
|
108
|
+
return { staticDedup: [], dynamicDedup: {}, dynamicTargetFingerprints: {} };
|
|
109
|
+
}
|
|
110
|
+
function nextPostCompactPending(state, completedKind) {
|
|
111
|
+
const pendingKinds = postCompactPendingKinds(state);
|
|
112
|
+
if (completedKind !== undefined) {
|
|
113
|
+
pendingKinds.delete(completedKind);
|
|
114
|
+
}
|
|
115
|
+
if (pendingKinds.size === 0) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
...(pendingKinds.has("static") ? { static: true } : {}),
|
|
120
|
+
...(pendingKinds.has("dynamic") ? { dynamic: true } : {}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function nextPostCompactRecovering(state, completedKind) {
|
|
124
|
+
const recoveringKinds = postCompactRecoveringKinds(state);
|
|
125
|
+
if (completedKind !== undefined) {
|
|
126
|
+
recoveringKinds.delete(completedKind);
|
|
127
|
+
}
|
|
128
|
+
return postCompactKindState(recoveringKinds);
|
|
129
|
+
}
|
|
130
|
+
function stateWithPostCompactKinds(state, pendingKinds, recoveringKinds) {
|
|
131
|
+
const postCompactPending = postCompactKindState(pendingKinds);
|
|
132
|
+
const postCompactRecovering = postCompactKindState(recoveringKinds);
|
|
133
|
+
return {
|
|
134
|
+
staticDedup: state.staticDedup,
|
|
135
|
+
dynamicDedup: state.dynamicDedup,
|
|
136
|
+
...(state.dynamicTargetFingerprints === undefined
|
|
137
|
+
? {}
|
|
138
|
+
: { dynamicTargetFingerprints: state.dynamicTargetFingerprints }),
|
|
139
|
+
...(postCompactPending === undefined ? {} : { postCompactPending }),
|
|
140
|
+
...(postCompactRecovering === undefined ? {} : { postCompactRecovering }),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function safePathSegment(value) {
|
|
144
|
+
return value.replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 120) || "unknown-session";
|
|
145
|
+
}
|
|
146
|
+
function isSerializedSessionState(value) {
|
|
147
|
+
if (!isRecord(value) || !Array.isArray(value["staticDedup"]) || !isRecord(value["dynamicDedup"])) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
const staticDedup = value["staticDedup"];
|
|
151
|
+
const dynamicDedup = value["dynamicDedup"];
|
|
152
|
+
const dynamicTargetFingerprints = value["dynamicTargetFingerprints"];
|
|
153
|
+
const postCompactPending = value["postCompactPending"];
|
|
154
|
+
const postCompactRecovering = value["postCompactRecovering"];
|
|
155
|
+
const compacted = value["compacted"];
|
|
156
|
+
return (staticDedup.every((item) => typeof item === "string") &&
|
|
157
|
+
Object.values(dynamicDedup).every((item) => Array.isArray(item) && item.every((nestedItem) => typeof nestedItem === "string")) &&
|
|
158
|
+
(dynamicTargetFingerprints === undefined ||
|
|
159
|
+
(isRecord(dynamicTargetFingerprints) &&
|
|
160
|
+
Object.entries(dynamicTargetFingerprints).every(([targetKey, fingerprint]) => typeof targetKey === "string" && typeof fingerprint === "string"))) &&
|
|
161
|
+
(postCompactPending === undefined || isPostCompactPendingState(postCompactPending)) &&
|
|
162
|
+
(postCompactRecovering === undefined || isPostCompactPendingState(postCompactRecovering)) &&
|
|
163
|
+
(compacted === undefined || typeof compacted === "boolean"));
|
|
164
|
+
}
|
|
165
|
+
function isPostCompactPendingState(value) {
|
|
166
|
+
return (isRecord(value) &&
|
|
167
|
+
(value["static"] === undefined || typeof value["static"] === "boolean") &&
|
|
168
|
+
(value["dynamic"] === undefined || typeof value["dynamic"] === "boolean"));
|
|
169
|
+
}
|
|
170
|
+
function isRecord(value) {
|
|
171
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
172
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PiRulesConfig } from "./rules/types.js";
|
|
2
|
+
export interface PostCompactBudgetContext {
|
|
3
|
+
readonly model: string;
|
|
4
|
+
readonly transcriptPath: string | null;
|
|
5
|
+
}
|
|
6
|
+
export declare function withPostCompactBudget(config: PiRulesConfig, context?: PostCompactBudgetContext): PiRulesConfig;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { hasContextPressureMarker } from "./context-pressure.js";
|
|
2
|
+
import { readTranscriptSearchText } from "./transcript-search.js";
|
|
3
|
+
const DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT = 95;
|
|
4
|
+
const ESTIMATED_TRANSCRIPT_CHARS_PER_TOKEN = 3;
|
|
5
|
+
const PROJECTED_INJECTION_CHARS_PER_TOKEN = 2;
|
|
6
|
+
const POST_COMPACT_RESERVED_CONTEXT_PERCENT = 5;
|
|
7
|
+
const POST_COMPACT_MIN_RESERVED_TOKENS = 8_000;
|
|
8
|
+
const POST_COMPACT_MIN_GUIDE_CHARS = 500;
|
|
9
|
+
const FALLBACK_CONTEXT_WINDOW_TOKENS = 200_000;
|
|
10
|
+
const MODEL_CONTEXT_BUDGETS = [
|
|
11
|
+
{ slug: "gpt-5.5", contextWindowTokens: 272_000, effectivePercent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT },
|
|
12
|
+
{ slug: "gpt-5.4-mini", contextWindowTokens: 272_000, effectivePercent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT },
|
|
13
|
+
{
|
|
14
|
+
slug: "codex-auto-review",
|
|
15
|
+
contextWindowTokens: 272_000,
|
|
16
|
+
effectivePercent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT,
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
export function withPostCompactBudget(config, context) {
|
|
20
|
+
const postCompactMaxResultChars = dynamicPostCompactMaxResultChars(context) ?? config.postCompactMaxResultChars;
|
|
21
|
+
const maxResultChars = Math.min(config.maxResultChars, config.postCompactMaxResultChars, postCompactMaxResultChars);
|
|
22
|
+
const maxRuleChars = Math.min(config.maxRuleChars, config.postCompactMaxRuleChars, maxResultChars);
|
|
23
|
+
return {
|
|
24
|
+
...config,
|
|
25
|
+
maxRuleChars,
|
|
26
|
+
maxResultChars,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function dynamicPostCompactMaxResultChars(context) {
|
|
30
|
+
if (context === undefined || context.transcriptPath === null) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const transcript = estimateTranscript(context.transcriptPath);
|
|
34
|
+
if (transcript === undefined) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
if (hasContextPressureMarker(transcript.text)) {
|
|
38
|
+
return POST_COMPACT_MIN_GUIDE_CHARS;
|
|
39
|
+
}
|
|
40
|
+
const modelBudget = modelContextBudgetFor(context.model) ?? fallbackModelContextBudget();
|
|
41
|
+
const effectiveContextWindow = Math.floor((modelBudget.contextWindowTokens * modelBudget.effectivePercent) / 100);
|
|
42
|
+
const reservedTokens = Math.max(POST_COMPACT_MIN_RESERVED_TOKENS, Math.floor((effectiveContextWindow * POST_COMPACT_RESERVED_CONTEXT_PERCENT) / 100));
|
|
43
|
+
const injectableTokens = Math.max(0, effectiveContextWindow - reservedTokens - transcript.tokens);
|
|
44
|
+
return Math.max(POST_COMPACT_MIN_GUIDE_CHARS, Math.floor(injectableTokens * PROJECTED_INJECTION_CHARS_PER_TOKEN));
|
|
45
|
+
}
|
|
46
|
+
function modelContextBudgetFor(model) {
|
|
47
|
+
const normalizedModel = model.trim().toLowerCase();
|
|
48
|
+
for (const budget of MODEL_CONTEXT_BUDGETS) {
|
|
49
|
+
if (normalizedModel === budget.slug ||
|
|
50
|
+
normalizedModel.endsWith(`.${budget.slug}`) ||
|
|
51
|
+
normalizedModel.endsWith(`/${budget.slug}`)) {
|
|
52
|
+
return budget;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
function fallbackModelContextBudget() {
|
|
58
|
+
return {
|
|
59
|
+
slug: "unknown",
|
|
60
|
+
contextWindowTokens: FALLBACK_CONTEXT_WINDOW_TOKENS,
|
|
61
|
+
effectivePercent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function estimateTranscript(transcriptPath) {
|
|
65
|
+
const transcriptText = readTranscriptSearchText(transcriptPath, { latestCompactedReplacementOnly: true }) ??
|
|
66
|
+
readTranscriptSearchText(transcriptPath);
|
|
67
|
+
if (transcriptText === null) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
text: transcriptText,
|
|
72
|
+
tokens: Math.ceil(Buffer.byteLength(transcriptText, "utf8") / ESTIMATED_TRANSCRIPT_CHARS_PER_TOKEN),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PostCompactClaimResult } from "./persistent-cache.js";
|
|
2
|
+
import type { PostCompactPendingKind } from "./post-compact-state.js";
|
|
3
|
+
export declare function claimedPostCompactKind<T extends PostCompactPendingKind>(result: PostCompactClaimResult, kind: T): T | undefined;
|
|
4
|
+
export declare function shouldSkipPostCompactClaim(result: PostCompactClaimResult, recoveryInProgress: boolean): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function claimedPostCompactKind(result, kind) {
|
|
2
|
+
return result === "claimed" ? kind : undefined;
|
|
3
|
+
}
|
|
4
|
+
export function shouldSkipPostCompactClaim(result, recoveryInProgress) {
|
|
5
|
+
return result === "contended" || (result === "not-pending" && recoveryInProgress);
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildPostCompactReadDirective(rulePaths: ReadonlyArray<string>, maxChars: number): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { uniqueStrings } from "./path-utils.js";
|
|
2
|
+
const DIRECTIVE_HEADER = [
|
|
3
|
+
"## MANDATORY: POST-COMPACTION RULE RECOVERY",
|
|
4
|
+
"",
|
|
5
|
+
"Context compaction DROPPED the project rule files listed below from your context.",
|
|
6
|
+
"YOU MUST READ THE FOLLOWING RULES with your file-reading tool RIGHT NOW, BEFORE ANY OTHER ACTION. NO EXCUSES.",
|
|
7
|
+
"Do not plan, answer, edit, or run anything until EVERY file below has been read end to end:",
|
|
8
|
+
"",
|
|
9
|
+
].join("\n");
|
|
10
|
+
const DIRECTIVE_FOOTER = "\nOperating without these rules is a protocol violation. Reconstructing them from memory is NOT reading. READ THEM ALL. NO EXCUSES.";
|
|
11
|
+
export function buildPostCompactReadDirective(rulePaths, maxChars) {
|
|
12
|
+
const paths = uniqueStrings([...rulePaths]);
|
|
13
|
+
if (paths.length === 0) {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
const lines = [];
|
|
17
|
+
let usedChars = DIRECTIVE_HEADER.length + DIRECTIVE_FOOTER.length;
|
|
18
|
+
let omittedCount = 0;
|
|
19
|
+
for (const rulePath of paths) {
|
|
20
|
+
const line = `- ${rulePath}`;
|
|
21
|
+
if (lines.length > 0 && usedChars + line.length + 1 > maxChars) {
|
|
22
|
+
omittedCount += 1;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
lines.push(line);
|
|
26
|
+
usedChars += line.length + 1;
|
|
27
|
+
}
|
|
28
|
+
if (omittedCount > 0) {
|
|
29
|
+
lines.push(`- (+${omittedCount} more rule files omitted - rescan the project rule directories and read those too)`);
|
|
30
|
+
}
|
|
31
|
+
return `${DIRECTIVE_HEADER}${lines.join("\n")}${DIRECTIVE_FOOTER}`;
|
|
32
|
+
}
|