oh-my-opencode 4.10.0 → 4.11.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/.agents/skills/codex-qa/SKILL.md +96 -0
- package/.agents/skills/codex-qa/references/app-server.md +63 -0
- package/.agents/skills/codex-qa/references/components-hooks.md +38 -0
- package/.agents/skills/codex-qa/references/docker-qa.md +62 -0
- package/.agents/skills/codex-qa/references/install-verify.md +57 -0
- package/.agents/skills/codex-qa/references/isolation.md +57 -0
- package/.agents/skills/codex-qa/references/logging-debug.md +60 -0
- package/.agents/skills/codex-qa/scripts/app-server-drive.sh +76 -0
- package/.agents/skills/codex-qa/scripts/hook-unit-probe.sh +69 -0
- package/.agents/skills/codex-qa/scripts/install-verify.sh +60 -0
- package/.agents/skills/codex-qa/scripts/lib/app-server-client.mjs +117 -0
- package/.agents/skills/codex-qa/scripts/lib/common.sh +180 -0
- package/.agents/skills/codex-qa/scripts/lib/mock-model.mjs +56 -0
- package/.agents/skills/codex-qa/scripts/tui-smoke.sh +71 -0
- package/.agents/skills/opencode-qa/SKILL.md +8 -1
- package/.agents/skills/opencode-qa/references/docker-qa.md +72 -0
- package/.agents/skills/tech-debt-audit/SKILL.md +14 -14
- package/.agents/skills/work-with-pr/SKILL.md +77 -53
- package/.opencode/skills/work-with-pr/SKILL.md +79 -55
- package/README.ja.md +3 -3
- package/README.ko.md +3 -3
- package/README.md +2 -2
- package/README.ru.md +3 -3
- package/README.zh-cn.md +3 -3
- package/THIRD-PARTY-NOTICES.md +205 -0
- package/dist/agents/dynamic-agent-prompt-types.d.ts +1 -1
- package/dist/agents/index.d.ts +0 -1
- package/dist/agents/prometheus/index.d.ts +0 -1
- package/dist/agents/prometheus/system-prompt.d.ts +0 -2
- package/dist/cli/config-manager/add-tui-plugin-to-tui-config.d.ts +7 -0
- package/dist/cli/doctor/checks/codex-components.d.ts +4 -4
- package/dist/cli/doctor/checks/codex-runtime-wrapper.d.ts +7 -0
- package/dist/cli/doctor/checks/codex.d.ts +1 -1
- package/dist/cli/doctor/checks/config.d.ts +1 -1
- package/dist/cli/doctor/checks/dependencies.d.ts +1 -2
- package/dist/cli/doctor/checks/index.d.ts +1 -1
- package/dist/cli/doctor/checks/model-resolution.d.ts +1 -1
- package/dist/cli/doctor/checks/system.d.ts +1 -1
- package/dist/cli/doctor/checks/team-mode.d.ts +1 -1
- package/dist/cli/doctor/checks/tools-gh.d.ts +1 -1
- package/dist/cli/doctor/checks/tools-mcp.d.ts +1 -1
- package/dist/cli/doctor/checks/tools.d.ts +2 -1
- package/dist/cli/doctor/checks/tui-plugin-config.d.ts +7 -1
- package/dist/cli/doctor/framework/constants.d.ts +32 -0
- package/dist/cli/doctor/framework/spawn-with-timeout.d.ts +8 -0
- package/dist/cli/doctor/framework/types.d.ts +147 -0
- package/dist/cli/doctor/index.d.ts +4 -4
- package/dist/cli/doctor/runner.d.ts +1 -1
- package/dist/cli/index.js +9717 -7523
- package/dist/cli/install-ast-grep-sg.d.ts +10 -0
- package/dist/cli/install-codex/codex-cache-bins.d.ts +1 -21
- package/dist/cli/install-codex/codex-cache-bundled-mcps.d.ts +1 -5
- package/dist/cli/install-codex/codex-cache-command-shim.d.ts +1 -1
- package/dist/cli/install-codex/codex-cache-fs.d.ts +1 -3
- package/dist/cli/install-codex/codex-cache-install.d.ts +1 -13
- package/dist/cli/install-codex/codex-cache-legacy-bins.d.ts +1 -3
- package/dist/cli/install-codex/codex-cache-local-dependencies.d.ts +1 -1
- package/dist/cli/install-codex/codex-cache-mcp-manifest.d.ts +1 -2
- package/dist/cli/install-codex/codex-cache-paths.d.ts +1 -2
- package/dist/cli/install-codex/codex-cache-prune.d.ts +1 -10
- package/dist/cli/install-codex/codex-cache.d.ts +1 -4
- package/dist/cli/install-codex/codex-cached-marketplace-manifest.d.ts +1 -6
- package/dist/cli/install-codex/codex-cleanup-config.d.ts +1 -6
- package/dist/cli/install-codex/codex-cleanup.d.ts +1 -25
- package/dist/cli/install-codex/codex-config-agents.d.ts +1 -3
- package/dist/cli/install-codex/codex-config-features.d.ts +1 -1
- package/dist/cli/install-codex/codex-config-marketplaces.d.ts +1 -6
- package/dist/cli/install-codex/codex-config-permissions.d.ts +1 -1
- package/dist/cli/install-codex/codex-config-plugins.d.ts +1 -9
- package/dist/cli/install-codex/codex-config-reasoning.d.ts +1 -2
- package/dist/cli/install-codex/codex-config-toml-sections.d.ts +1 -9
- package/dist/cli/install-codex/codex-config-toml.d.ts +1 -13
- package/dist/cli/install-codex/codex-hook-trust.d.ts +1 -6
- package/dist/cli/install-codex/codex-installation-detection.d.ts +1 -36
- package/dist/cli/install-codex/codex-installer-bin-dir.d.ts +1 -8
- package/dist/cli/install-codex/codex-marketplace-snapshot.d.ts +1 -15
- package/dist/cli/install-codex/codex-marketplace.d.ts +1 -9
- package/dist/cli/install-codex/codex-model-catalog.d.ts +1 -13
- package/dist/cli/install-codex/codex-multi-agent-v2-config.d.ts +1 -12
- package/dist/cli/install-codex/codex-package-layout.d.ts +1 -1
- package/dist/cli/install-codex/codex-process.d.ts +1 -7
- package/dist/cli/install-codex/codex-project-local-cleanup-best-effort.d.ts +1 -7
- package/dist/cli/install-codex/codex-project-local-cleanup.d.ts +1 -35
- package/dist/cli/install-codex/git-bash.d.ts +1 -35
- package/dist/cli/install-codex/index.d.ts +1 -11
- package/dist/cli/install-codex/install-codex.d.ts +1 -10
- package/dist/cli/install-codex/lazycodex-version-stamp.d.ts +1 -19
- package/dist/cli/install-codex/link-cached-plugin-agents.d.ts +1 -20
- package/dist/cli/install-codex/lsp-daemon-reaper.d.ts +1 -5
- package/dist/cli/install-codex/toml-section-editor.d.ts +1 -11
- package/dist/cli/install-codex/types.d.ts +1 -76
- package/dist/cli/mcp-oauth/login.d.ts +1 -1
- package/dist/cli-node/index.js +9774 -7525
- package/dist/config/index.d.ts +1 -1
- package/dist/config/schema/agent-names.d.ts +1 -1
- package/dist/config/schema/codegraph.d.ts +9 -0
- package/dist/config/schema/git-env-prefix.d.ts +1 -5
- package/dist/config/schema/hooks.d.ts +3 -0
- package/dist/config/schema/monitor.d.ts +15 -0
- package/dist/config/schema/oh-my-opencode-config.d.ts +27 -16
- package/dist/config/schema/openclaw.d.ts +5 -4
- package/dist/config/schema/team-mode.d.ts +1 -16
- package/dist/config/schema/tmux.d.ts +4 -5
- package/dist/config/schema/tui.d.ts +10 -0
- package/dist/config/schema.d.ts +2 -0
- package/dist/config/validate.d.ts +8 -0
- package/dist/create-hooks.d.ts +5 -0
- package/dist/create-managers.d.ts +7 -0
- package/dist/create-runtime-tmux-config.d.ts +1 -1
- package/dist/create-tools.d.ts +1 -1
- package/dist/features/background-agent/error-classifier.d.ts +2 -2
- package/dist/features/background-agent/manager.d.ts +29 -2
- package/dist/features/background-agent/parent-wake-dispatched-tracker.d.ts +8 -0
- package/dist/features/background-agent/parent-wake-notifier.d.ts +4 -0
- package/dist/features/background-agent/spawner/fallback-agent.d.ts +3 -2
- package/dist/features/background-agent/spawner/task-prompt-body.d.ts +5 -6
- package/dist/features/background-agent/task-snapshot.d.ts +2 -0
- package/dist/features/background-agent/types.d.ts +7 -0
- package/dist/features/builtin-commands/templates/refactor-sections/intro-and-analysis.d.ts +1 -1
- package/dist/features/builtin-commands/templates/refactor-sections/plan-and-execution.d.ts +1 -1
- package/dist/features/builtin-commands/templates/refactor-sections/team-mode-addendum.d.ts +1 -1
- package/dist/features/builtin-commands/templates/refactor-sections/verification-and-tooling.d.ts +1 -1
- package/dist/features/builtin-commands/templates/remove-ai-slops.d.ts +1 -1
- package/dist/features/builtin-skills/index.d.ts +1 -2
- package/dist/features/builtin-skills/skill-file-loader.d.ts +1 -4
- package/dist/features/builtin-skills/skills/agent-browser-skill.d.ts +1 -2
- package/dist/features/builtin-skills/skills/agent-browser-template.d.ts +1 -2
- package/dist/features/builtin-skills/skills/debugging.d.ts +1 -2
- package/dist/features/builtin-skills/skills/dev-browser.d.ts +1 -2
- package/dist/features/builtin-skills/skills/frontend.d.ts +1 -0
- package/dist/features/builtin-skills/skills/git-master-sections/commit-atomic-planning.d.ts +1 -1
- package/dist/features/builtin-skills/skills/git-master-sections/commit-context-analysis.d.ts +1 -1
- package/dist/features/builtin-skills/skills/git-master-sections/commit-execution-verification.d.ts +1 -1
- package/dist/features/builtin-skills/skills/git-master-sections/commit-workflow.d.ts +1 -1
- package/dist/features/builtin-skills/skills/git-master-sections/history-search-workflow.d.ts +1 -1
- package/dist/features/builtin-skills/skills/git-master-sections/overview.d.ts +1 -1
- package/dist/features/builtin-skills/skills/git-master-sections/quick-reference.d.ts +1 -1
- package/dist/features/builtin-skills/skills/git-master-sections/rebase-workflow.d.ts +1 -1
- package/dist/features/builtin-skills/skills/git-master-skill-metadata.d.ts +1 -2
- package/dist/features/builtin-skills/skills/git-master.d.ts +1 -2
- package/dist/features/builtin-skills/skills/index.d.ts +1 -13
- package/dist/features/builtin-skills/skills/init-deep.d.ts +1 -2
- package/dist/features/builtin-skills/skills/playwright-cli.d.ts +1 -10
- package/dist/features/builtin-skills/skills/playwright-mcp-skill.d.ts +1 -2
- package/dist/features/builtin-skills/skills/playwright.d.ts +1 -2
- package/dist/features/builtin-skills/skills/remove-ai-slops.d.ts +1 -2
- package/dist/features/builtin-skills/skills/review-work.d.ts +1 -2
- package/dist/features/builtin-skills/skills/security-research.d.ts +1 -2
- package/dist/features/builtin-skills/skills/security-review.d.ts +1 -2
- package/dist/features/builtin-skills/skills/team-mode.d.ts +1 -2
- package/dist/features/builtin-skills/skills/visual-qa.d.ts +1 -2
- package/dist/features/builtin-skills/skills.d.ts +1 -12
- package/dist/features/builtin-skills/types.d.ts +1 -15
- package/dist/features/claude-code-agent-loader/agent-definitions-loader.d.ts +1 -3
- package/dist/features/claude-code-agent-loader/claude-model-mapper.d.ts +1 -4
- package/dist/features/claude-code-agent-loader/index.d.ts +1 -5
- package/dist/features/claude-code-agent-loader/json-agent-loader.d.ts +1 -2
- package/dist/features/claude-code-agent-loader/loader.d.ts +1 -5
- package/dist/features/claude-code-agent-loader/opencode-config-agents-reader.d.ts +1 -2
- package/dist/features/claude-code-agent-loader/types.d.ts +1 -29
- package/dist/features/claude-code-command-loader/index.d.ts +1 -2
- package/dist/features/claude-code-command-loader/loader-cache.d.ts +1 -6
- package/dist/features/claude-code-command-loader/loader.d.ts +1 -8
- package/dist/features/claude-code-command-loader/types.d.ts +1 -42
- package/dist/features/claude-code-mcp-loader/configure-allowed-env-vars.d.ts +1 -5
- package/dist/features/claude-code-mcp-loader/index.d.ts +1 -11
- package/dist/features/claude-code-mcp-loader/loader.d.ts +1 -4
- package/dist/features/claude-code-mcp-loader/scope-filter.d.ts +1 -2
- package/dist/features/claude-code-mcp-loader/transformer.d.ts +1 -2
- package/dist/features/claude-code-mcp-loader/types.d.ts +1 -43
- package/dist/features/claude-code-plugin-loader/agent-loader.d.ts +1 -3
- package/dist/features/claude-code-plugin-loader/command-loader.d.ts +1 -3
- package/dist/features/claude-code-plugin-loader/discovery-core.d.ts +1 -2
- package/dist/features/claude-code-plugin-loader/discovery-paths.d.ts +1 -3
- package/dist/features/claude-code-plugin-loader/discovery.d.ts +1 -3
- package/dist/features/claude-code-plugin-loader/hook-loader.d.ts +1 -2
- package/dist/features/claude-code-plugin-loader/index.d.ts +1 -10
- package/dist/features/claude-code-plugin-loader/install-path-resolver.d.ts +1 -1
- package/dist/features/claude-code-plugin-loader/installed-plugin-database.d.ts +1 -3
- package/dist/features/claude-code-plugin-loader/loaded-plugin.d.ts +1 -2
- package/dist/features/claude-code-plugin-loader/loader.d.ts +1 -36
- package/dist/features/claude-code-plugin-loader/mcp-server-loader.d.ts +1 -3
- package/dist/features/claude-code-plugin-loader/plugin-key.d.ts +1 -1
- package/dist/features/claude-code-plugin-loader/plugin-manifest.d.ts +1 -4
- package/dist/features/claude-code-plugin-loader/plugin-path-resolver.d.ts +1 -2
- package/dist/features/claude-code-plugin-loader/plugin-settings.d.ts +1 -3
- package/dist/features/claude-code-plugin-loader/scope-filter.d.ts +1 -2
- package/dist/features/claude-code-plugin-loader/skill-loader.d.ts +1 -3
- package/dist/features/claude-code-plugin-loader/types.d.ts +1 -240
- package/dist/features/claude-tasks/types.d.ts +4 -4
- package/dist/features/hook-message-injector/sdk-message-lookup.d.ts +9 -2
- package/dist/features/mcp-oauth/callback-server.d.ts +1 -19
- package/dist/features/mcp-oauth/dcr.d.ts +1 -34
- package/dist/features/mcp-oauth/discovery.d.ts +1 -8
- package/dist/features/mcp-oauth/oauth-authorization-flow.d.ts +1 -26
- package/dist/features/mcp-oauth/provider.d.ts +1 -30
- package/dist/features/mcp-oauth/refresh-mutex.d.ts +1 -26
- package/dist/features/mcp-oauth/resource-indicator.d.ts +1 -0
- package/dist/features/mcp-oauth/schema.d.ts +1 -0
- package/dist/features/mcp-oauth/step-up.d.ts +1 -8
- package/dist/features/mcp-oauth/storage.d.ts +1 -17
- package/dist/features/monitor/batcher.d.ts +36 -0
- package/dist/features/monitor/envelope.d.ts +9 -0
- package/dist/features/monitor/filter.d.ts +10 -0
- package/dist/features/monitor/index.d.ts +2 -0
- package/dist/features/monitor/line-stream.d.ts +29 -0
- package/dist/features/monitor/manager-internals.d.ts +65 -0
- package/dist/features/monitor/manager.d.ts +35 -0
- package/dist/features/monitor/monitor-state-factory.d.ts +24 -0
- package/dist/features/monitor/output-injector-session-inspect.d.ts +9 -0
- package/dist/features/monitor/output-injector-types.d.ts +48 -0
- package/dist/features/monitor/output-injector.d.ts +21 -0
- package/dist/features/monitor/permission.d.ts +33 -0
- package/dist/features/monitor/pipeline.d.ts +26 -0
- package/dist/features/monitor/process.d.ts +21 -0
- package/dist/features/monitor/ring-buffer.d.ts +25 -0
- package/dist/features/monitor/types.d.ts +83 -0
- package/dist/features/opencode-runtime-skills/index.d.ts +1 -2
- package/dist/features/opencode-runtime-skills/runtime-skill-config.d.ts +1 -17
- package/dist/features/opencode-runtime-skills/skill-markdown.d.ts +1 -7
- package/dist/features/opencode-runtime-skills/source-server.d.ts +1 -24
- package/dist/features/opencode-skill-loader/allowed-tools-parser.d.ts +1 -1
- package/dist/features/opencode-skill-loader/config-source-discovery.d.ts +1 -7
- package/dist/features/opencode-skill-loader/git-master-template-injection.d.ts +1 -20
- package/dist/features/opencode-skill-loader/index.d.ts +1 -16
- package/dist/features/opencode-skill-loader/loaded-skill-from-path.d.ts +1 -9
- package/dist/features/opencode-skill-loader/loaded-skill-template-extractor.d.ts +1 -2
- package/dist/features/opencode-skill-loader/loader.d.ts +1 -21
- package/dist/features/opencode-skill-loader/merger/builtin-skill-converter.d.ts +1 -3
- package/dist/features/opencode-skill-loader/merger/config-skill-entry-loader.d.ts +1 -3
- package/dist/features/opencode-skill-loader/merger/scope-priority.d.ts +1 -2
- package/dist/features/opencode-skill-loader/merger/skill-definition-merger.d.ts +1 -3
- package/dist/features/opencode-skill-loader/merger/skills-config-normalizer.d.ts +1 -11
- package/dist/features/opencode-skill-loader/merger.d.ts +1 -7
- package/dist/features/opencode-skill-loader/opencode-config-skills-reader.d.ts +1 -5
- package/dist/features/opencode-skill-loader/skill-content.d.ts +1 -5
- package/dist/features/opencode-skill-loader/skill-deduplication.d.ts +1 -2
- package/dist/features/opencode-skill-loader/skill-definition-record.d.ts +1 -5
- package/dist/features/opencode-skill-loader/skill-directory-loader.d.ts +1 -8
- package/dist/features/opencode-skill-loader/skill-discovery.d.ts +1 -4
- package/dist/features/opencode-skill-loader/skill-mcp-config.d.ts +1 -3
- package/dist/features/opencode-skill-loader/skill-resolution-options.d.ts +1 -9
- package/dist/features/opencode-skill-loader/skill-template-resolver.d.ts +1 -11
- package/dist/features/opencode-skill-loader/types.d.ts +1 -34
- package/dist/features/skill-mcp-manager/cleanup.d.ts +1 -8
- package/dist/features/skill-mcp-manager/connection-type.d.ts +1 -7
- package/dist/features/skill-mcp-manager/connection.d.ts +1 -14
- package/dist/features/skill-mcp-manager/env-cleaner.d.ts +1 -2
- package/dist/features/skill-mcp-manager/error-redaction.d.ts +1 -10
- package/dist/features/skill-mcp-manager/http-client.d.ts +1 -19
- package/dist/features/skill-mcp-manager/index.d.ts +1 -2
- package/dist/features/skill-mcp-manager/manager.d.ts +1 -27
- package/dist/features/skill-mcp-manager/oauth-handler.d.ts +1 -17
- package/dist/features/skill-mcp-manager/stdio-client.d.ts +1 -16
- package/dist/features/skill-mcp-manager/types.d.ts +1 -79
- package/dist/features/team-mode/member-parser.d.ts +1 -16
- package/dist/features/team-mode/team-layout-tmux/close-team-member-pane.d.ts +1 -4
- package/dist/features/team-mode/team-layout-tmux/index.d.ts +1 -1
- package/dist/features/team-mode/team-layout-tmux/layout.d.ts +1 -37
- package/dist/features/team-mode/team-layout-tmux/rebalance-team-window.d.ts +1 -9
- package/dist/features/team-mode/team-layout-tmux/resolve-caller-tmux-session.d.ts +1 -9
- package/dist/features/team-mode/team-layout-tmux/sweep-stale-team-sessions.d.ts +1 -8
- package/dist/features/team-mode/team-mailbox/ack.d.ts +1 -2
- package/dist/features/team-mode/team-mailbox/inbox.d.ts +1 -3
- package/dist/features/team-mode/team-mailbox/index.d.ts +1 -7
- package/dist/features/team-mode/team-mailbox/pending-delivery-recovery.d.ts +1 -31
- package/dist/features/team-mode/team-mailbox/poll.d.ts +1 -10
- package/dist/features/team-mode/team-mailbox/reservation.d.ts +1 -11
- package/dist/features/team-mode/team-mailbox/send.d.ts +1 -30
- package/dist/features/team-mode/team-registry/index.d.ts +1 -3
- package/dist/features/team-mode/team-registry/loader.d.ts +1 -12
- package/dist/features/team-mode/team-registry/paths.d.ts +1 -28
- package/dist/features/team-mode/team-registry/team-spec-input-normalizer.d.ts +1 -6
- package/dist/features/team-mode/team-registry/validator.d.ts +1 -10
- package/dist/features/team-mode/team-runtime/shutdown-helpers.d.ts +1 -1
- package/dist/features/team-mode/team-state-store/active-resume.d.ts +1 -5
- package/dist/features/team-mode/team-state-store/creating-resume.d.ts +1 -4
- package/dist/features/team-mode/team-state-store/deleting-resume.d.ts +1 -4
- package/dist/features/team-mode/team-state-store/error-normalization.d.ts +1 -2
- package/dist/features/team-mode/team-state-store/index.d.ts +1 -1
- package/dist/features/team-mode/team-state-store/locks.d.ts +1 -15
- package/dist/features/team-mode/team-state-store/reservation-reconciliation.d.ts +1 -4
- package/dist/features/team-mode/team-state-store/resume-report.d.ts +1 -7
- package/dist/features/team-mode/team-state-store/resume.d.ts +1 -5
- package/dist/features/team-mode/team-state-store/runtime-cleanup.d.ts +1 -4
- package/dist/features/team-mode/team-state-store/session-liveness.d.ts +1 -9
- package/dist/features/team-mode/team-state-store/store.d.ts +1 -21
- package/dist/features/team-mode/team-state-store/worker-resume-status.d.ts +1 -9
- package/dist/features/team-mode/team-tasklist/claim.d.ts +1 -10
- package/dist/features/team-mode/team-tasklist/dependencies.d.ts +1 -2
- package/dist/features/team-mode/team-tasklist/get.d.ts +1 -3
- package/dist/features/team-mode/team-tasklist/index.d.ts +1 -6
- package/dist/features/team-mode/team-tasklist/list.d.ts +1 -8
- package/dist/features/team-mode/team-tasklist/store.d.ts +1 -3
- package/dist/features/team-mode/team-tasklist/test-support.d.ts +1 -9
- package/dist/features/team-mode/team-tasklist/update.d.ts +1 -9
- package/dist/features/team-mode/team-worktree/cleanup.d.ts +1 -3
- package/dist/features/team-mode/team-worktree/index.d.ts +1 -2
- package/dist/features/team-mode/team-worktree/manager.d.ts +1 -15
- package/dist/features/team-mode/tools/lifecycle-create-tool.d.ts +2 -2
- package/dist/features/team-mode/tools/lifecycle-inline-spec.d.ts +2 -2
- package/dist/features/team-mode/tools/lifecycle-participant.d.ts +2 -2
- package/dist/features/team-mode/tools/lifecycle-test-fixture.d.ts +8 -8
- package/dist/features/team-mode/tools/messaging-live-delivery-recipient.d.ts +2 -2
- package/dist/features/team-mode/tools/messaging-live-delivery-reservation.d.ts +1 -1
- package/dist/features/team-mode/tools/messaging-live-delivery-state.d.ts +1 -1
- package/dist/features/team-mode/tools/messaging-live-delivery.d.ts +1 -1
- package/dist/features/team-mode/tools/messaging-runtime.d.ts +2 -2
- package/dist/features/team-mode/tools/query.d.ts +3 -3
- package/dist/features/team-mode/tools/tasks.d.ts +2 -2
- package/dist/features/team-mode/types.d.ts +1 -343
- package/dist/features/tui-sidebar/compute-view.d.ts +10 -0
- package/dist/features/tui-sidebar/config-validator.d.ts +2 -0
- package/dist/features/tui-sidebar/constants.d.ts +10 -0
- package/dist/features/tui-sidebar/derivers.d.ts +10 -0
- package/dist/features/tui-sidebar/element-helpers.d.ts +9 -0
- package/dist/features/tui-sidebar/loop-reader.d.ts +2 -0
- package/dist/features/tui-sidebar/mirror-io.d.ts +3 -0
- package/dist/features/tui-sidebar/mirror-manager.d.ts +28 -0
- package/dist/features/tui-sidebar/mirror-path.d.ts +3 -0
- package/dist/features/tui-sidebar/render-view.d.ts +15 -0
- package/dist/features/tui-sidebar/roster-resolver.d.ts +2 -0
- package/dist/features/tui-sidebar/snapshot-builder.d.ts +28 -0
- package/dist/features/tui-sidebar/snapshot-schema.d.ts +41 -0
- package/dist/features/tui-sidebar/state-types.d.ts +72 -0
- package/dist/hooks/ast-grep-sg-provision/hook.d.ts +19 -0
- package/dist/hooks/ast-grep-sg-provision/index.d.ts +1 -0
- package/dist/hooks/auto-slash-command/constants.d.ts +1 -5
- package/dist/hooks/auto-slash-command/detector.d.ts +1 -15
- package/dist/hooks/auto-slash-command/processed-command-store.d.ts +1 -7
- package/dist/hooks/auto-slash-command/types.d.ts +1 -48
- package/dist/hooks/auto-update-checker/constants.d.ts +3 -3
- package/dist/hooks/codegraph-bootstrap/command-runner.d.ts +16 -0
- package/dist/hooks/codegraph-bootstrap/hook.d.ts +34 -0
- package/dist/hooks/codegraph-bootstrap/index.d.ts +1 -0
- package/dist/hooks/codegraph-bootstrap/project-root.d.ts +1 -0
- package/dist/hooks/codegraph-bootstrap/status.d.ts +11 -0
- package/dist/hooks/delegate-task-retry/guidance.d.ts +1 -2
- package/dist/hooks/delegate-task-retry/patterns.d.ts +2 -11
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/monitor-status-injector/hook.d.ts +30 -0
- package/dist/hooks/monitor-status-injector/index.d.ts +2 -0
- package/dist/hooks/runtime-fallback/auto-retry-signal.d.ts +1 -4
- package/dist/hooks/runtime-fallback/error-classifier.d.ts +7 -6
- package/dist/hooks/runtime-fallback/fallback-state.d.ts +3 -2
- package/dist/hooks/runtime-fallback/test-timeout-clock.test-support.d.ts +6 -0
- package/dist/hooks/tool-pair-validator/tool-part-ids.d.ts +2 -1
- package/dist/index.js +89513 -95172
- package/dist/interactive-bash-availability.d.ts +1 -0
- package/dist/mcp/codegraph.d.ts +16 -0
- package/dist/mcp/index.d.ts +10 -2
- package/dist/mcp/shared/ancestor-cli-resolver.d.ts +25 -0
- package/dist/mcp/types.d.ts +1 -1
- package/dist/oh-my-opencode.schema.json +139 -16
- package/dist/openclaw/config.d.ts +1 -8
- package/dist/openclaw/daemon.d.ts +1 -1
- package/dist/openclaw/dispatcher.d.ts +1 -12
- package/dist/openclaw/gateway-url-validation.d.ts +1 -1
- package/dist/openclaw/index.d.ts +1 -5
- package/dist/openclaw/reply-listener-discord.d.ts +1 -4
- package/dist/openclaw/reply-listener-injection.d.ts +1 -10
- package/dist/openclaw/reply-listener-log.d.ts +1 -2
- package/dist/openclaw/reply-listener-paths.d.ts +1 -7
- package/dist/openclaw/reply-listener-poll-loop.d.ts +1 -3
- package/dist/openclaw/reply-listener-process.d.ts +1 -4
- package/dist/openclaw/reply-listener-signature.d.ts +1 -2
- package/dist/openclaw/reply-listener-sleep.d.ts +1 -1
- package/dist/openclaw/reply-listener-spawn.d.ts +1 -5
- package/dist/openclaw/reply-listener-start.d.ts +1 -9
- package/dist/openclaw/reply-listener-startup.d.ts +1 -12
- package/dist/openclaw/reply-listener-state.d.ts +1 -29
- package/dist/openclaw/reply-listener-status.d.ts +1 -4
- package/dist/openclaw/reply-listener-stop.d.ts +1 -7
- package/dist/openclaw/reply-listener-telegram.d.ts +1 -4
- package/dist/openclaw/reply-listener.d.ts +1 -5
- package/dist/openclaw/runtime-dispatch.d.ts +1 -17
- package/dist/openclaw/session-registry-lock.d.ts +1 -2
- package/dist/openclaw/session-registry-paths.d.ts +1 -9
- package/dist/openclaw/session-registry-storage.d.ts +1 -4
- package/dist/openclaw/session-registry-types.d.ts +1 -11
- package/dist/openclaw/session-registry.d.ts +1 -8
- package/dist/openclaw/tmux.d.ts +1 -8
- package/dist/openclaw/types.d.ts +1 -42
- package/dist/plugin/event-error-utils.d.ts +2 -1
- package/dist/plugin/hooks/create-core-hooks.d.ts +5 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts +3 -1
- package/dist/plugin/hooks/create-transform-hooks.d.ts +4 -1
- package/dist/plugin/messages-transform.d.ts +1 -0
- package/dist/plugin/skill-context.d.ts +2 -0
- package/dist/plugin/tool-registry-factories.d.ts +2 -1
- package/dist/plugin/tool-registry-gated-tools.d.ts +7 -0
- package/dist/plugin/tool-registry.d.ts +1 -1
- package/dist/plugin/types.d.ts +2 -9
- package/dist/plugin-handlers/prometheus-agent-config-builder.d.ts +1 -0
- package/dist/shared/archive-entry-validator.d.ts +1 -6
- package/dist/shared/bun-file-shim.d.ts +1 -8
- package/dist/shared/bun-spawn-shim.d.ts +1 -43
- package/dist/shared/bun-which-shim.d.ts +1 -1
- package/dist/shared/classify-path-environment.d.ts +1 -3
- package/dist/shared/command-executor/embedded-commands.d.ts +1 -7
- package/dist/shared/command-executor/execute-command.d.ts +1 -1
- package/dist/shared/command-executor/execute-hook-command.d.ts +1 -23
- package/dist/shared/command-executor/home-directory.d.ts +1 -1
- package/dist/shared/command-executor/resolve-commands-in-text.d.ts +1 -1
- package/dist/shared/command-executor/shell-path.d.ts +1 -2
- package/dist/shared/command-executor.d.ts +1 -4
- package/dist/shared/git-worktree/collect-git-diff-stats.d.ts +1 -2
- package/dist/shared/git-worktree/format-file-changes.d.ts +1 -2
- package/dist/shared/git-worktree/index.d.ts +1 -7
- package/dist/shared/git-worktree/parse-diff-numstat.d.ts +1 -2
- package/dist/shared/git-worktree/parse-status-porcelain-line.d.ts +1 -6
- package/dist/shared/git-worktree/parse-status-porcelain.d.ts +1 -2
- package/dist/shared/git-worktree/types.d.ts +1 -7
- package/dist/shared/internal-initiator-marker.d.ts +1 -46
- package/dist/shared/logger.d.ts +3 -11
- package/dist/shared/migration/agent-category.d.ts +1 -19
- package/dist/shared/migration/agent-names.d.ts +1 -6
- package/dist/shared/migration/config-migration.d.ts +1 -1
- package/dist/shared/migration/hook-names.d.ts +1 -6
- package/dist/shared/migration/migrations-sidecar.d.ts +1 -41
- package/dist/shared/migration/model-versions.d.ts +1 -22
- package/dist/shared/migration.d.ts +1 -5
- package/dist/shared/model-suggestion-retry.d.ts +39 -17
- package/dist/shared/plugin-identity.d.ts +8 -8
- package/dist/shared/posthog.d.ts +3 -0
- package/dist/shared/process-stream-reader.d.ts +1 -3
- package/dist/shared/prompt-async-gate/message-inspection-error.d.ts +1 -1
- package/dist/shared/prompt-async-gate/pending-tool-turn.d.ts +1 -11
- package/dist/shared/prompt-async-gate/prompt-message-state.d.ts +1 -9
- package/dist/shared/prompt-async-gate/queue.d.ts +1 -8
- package/dist/shared/prompt-async-gate/recent-dispatches.d.ts +1 -14
- package/dist/shared/prompt-async-gate/reservations.d.ts +1 -9
- package/dist/shared/prompt-async-gate/semantic-dedupe.d.ts +1 -7
- package/dist/shared/prompt-async-gate/session-idle-dispatch.d.ts +1 -16
- package/dist/shared/prompt-async-gate/timing.d.ts +1 -9
- package/dist/shared/prompt-async-gate/types.d.ts +1 -123
- package/dist/shared/prompt-async-gate.d.ts +3 -7
- package/dist/shared/prompt-failure-classifier.d.ts +1 -9
- package/dist/shared/session-idle-settle.d.ts +1 -12
- package/dist/shared/shell-env.d.ts +1 -1
- package/dist/shared/skill-path-resolver.d.ts +1 -1
- package/dist/shared/tmux/cmux-detect.d.ts +1 -8
- package/dist/shared/tmux/constants.d.ts +1 -5
- package/dist/shared/tmux/runner.d.ts +2 -13
- package/dist/shared/tmux/tmux-utils/adapter-deps.d.ts +9 -0
- package/dist/shared/tmux/tmux-utils/environment.d.ts +2 -4
- package/dist/shared/tmux/tmux-utils/layout.d.ts +4 -17
- package/dist/shared/tmux/tmux-utils/pane-close.d.ts +3 -10
- package/dist/shared/tmux/tmux-utils/pane-command.d.ts +1 -2
- package/dist/shared/tmux/tmux-utils/pane-dimensions.d.ts +2 -4
- package/dist/shared/tmux/tmux-utils/pane-replace.d.ts +1 -11
- package/dist/shared/tmux/tmux-utils/pane-spawn.d.ts +1 -13
- package/dist/shared/tmux/tmux-utils/server-health.d.ts +2 -15
- package/dist/shared/tmux/tmux-utils/session-spawn.d.ts +3 -14
- package/dist/shared/tmux/tmux-utils/spawn-process.d.ts +1 -1
- package/dist/shared/tmux/tmux-utils/stale-session-sweep.d.ts +4 -17
- package/dist/shared/tmux/tmux-utils/window-spawn.d.ts +1 -13
- package/dist/shared/tmux/types.d.ts +1 -4
- package/dist/shared/write-file-atomically.d.ts +2 -0
- package/dist/shared/zip-entry-listing/powershell-zip-entry-listing.d.ts +1 -4
- package/dist/shared/zip-entry-listing/python-zip-entry-listing.d.ts +1 -3
- package/dist/shared/zip-entry-listing/read-zip-symlink-target.d.ts +1 -1
- package/dist/shared/zip-entry-listing/tar-zip-entry-listing.d.ts +1 -3
- package/dist/shared/zip-entry-listing/zipinfo-zip-entry-listing.d.ts +1 -4
- package/dist/shared/zip-entry-listing.d.ts +1 -4
- package/dist/skills/ast-grep/LICENSE +21 -0
- package/dist/skills/ast-grep/README.md +136 -0
- package/dist/skills/ast-grep/SKILL.md +272 -0
- package/dist/skills/ast-grep/SOURCE +1 -0
- package/dist/skills/ast-grep/install.ps1 +235 -0
- package/dist/skills/ast-grep/install.sh +286 -0
- package/dist/skills/ast-grep/references/cli.md +231 -0
- package/dist/skills/ast-grep/references/install.md +166 -0
- package/dist/skills/ast-grep/references/patterns.md +147 -0
- package/dist/skills/ast-grep/references/pitfalls.md +303 -0
- package/dist/skills/ast-grep/references/recipes.md +402 -0
- package/dist/skills/ast-grep/references/sgconfig.md +248 -0
- package/dist/skills/ast-grep/references/yaml-rules.md +509 -0
- package/dist/skills/ast-grep/scripts/ast_grep_helper.py +748 -0
- package/dist/skills/ast-grep/tests/smoke.ps1 +123 -0
- package/dist/skills/ast-grep/tests/smoke.sh +212 -0
- package/dist/skills/debugging/SKILL.md +116 -0
- package/dist/skills/debugging/references/methodology/00-setup.md +108 -0
- package/dist/skills/debugging/references/methodology/02-investigate.md +130 -0
- package/dist/skills/debugging/references/methodology/04-oracle-triple.md +136 -0
- package/dist/skills/debugging/references/methodology/05-escalate.md +69 -0
- package/dist/skills/debugging/references/methodology/06-fix.md +116 -0
- package/dist/skills/debugging/references/methodology/08-qa.md +94 -0
- package/dist/skills/debugging/references/methodology/09-cleanup.md +164 -0
- package/dist/skills/debugging/references/methodology/partial-runtime-evidence.md +229 -0
- package/dist/skills/debugging/references/runtimes/bundled-js-binary.md +415 -0
- package/dist/skills/debugging/references/runtimes/go.md +252 -0
- package/dist/skills/debugging/references/runtimes/native-binary.md +484 -0
- package/dist/skills/debugging/references/runtimes/node.md +260 -0
- package/dist/skills/debugging/references/runtimes/python.md +248 -0
- package/dist/skills/debugging/references/runtimes/rust.md +234 -0
- package/dist/skills/debugging/references/tools/ghidra.md +212 -0
- package/dist/skills/debugging/references/tools/playwright-cli.md +194 -0
- package/dist/skills/debugging/references/tools/pwndbg.md +263 -0
- package/dist/skills/debugging/references/tools/pwntools.md +265 -0
- package/dist/skills/frontend/ATTRIBUTION.md +127 -0
- package/dist/skills/frontend/LICENSE-Apache-2.0.txt +201 -0
- package/dist/skills/frontend/SKILL.md +113 -0
- package/dist/skills/frontend/references/design/README.md +240 -0
- package/dist/skills/frontend/references/design/_INDEX.md +189 -0
- package/dist/skills/frontend/references/design/airbnb.md +390 -0
- package/dist/skills/frontend/references/design/airtable.md +89 -0
- package/dist/skills/frontend/references/design/apple.md +247 -0
- package/dist/skills/frontend/references/design/binance.md +345 -0
- package/dist/skills/frontend/references/design/bmw.md +180 -0
- package/dist/skills/frontend/references/design/brutalist-skill.md +92 -0
- package/dist/skills/frontend/references/design/bugatti.md +268 -0
- package/dist/skills/frontend/references/design/cal.md +259 -0
- package/dist/skills/frontend/references/design/claude.md +312 -0
- package/dist/skills/frontend/references/design/clay.md +304 -0
- package/dist/skills/frontend/references/design/clickhouse.md +281 -0
- package/dist/skills/frontend/references/design/cohere.md +266 -0
- package/dist/skills/frontend/references/design/coinbase.md +129 -0
- package/dist/skills/frontend/references/design/composio.md +307 -0
- package/dist/skills/frontend/references/design/cursor.md +309 -0
- package/dist/skills/frontend/references/design/design-system-architecture.md +217 -0
- package/dist/skills/frontend/references/design/elevenlabs.md +265 -0
- package/dist/skills/frontend/references/design/expo.md +281 -0
- package/dist/skills/frontend/references/design/ferrari.md +314 -0
- package/dist/skills/frontend/references/design/figma.md +220 -0
- package/dist/skills/frontend/references/design/framer.md +246 -0
- package/dist/skills/frontend/references/design/gpt-tasteskill.md +74 -0
- package/dist/skills/frontend/references/design/hashicorp.md +278 -0
- package/dist/skills/frontend/references/design/ibm.md +332 -0
- package/dist/skills/frontend/references/design/image-to-code-skill.md +1228 -0
- package/dist/skills/frontend/references/design/imagegen-brandkit.md +798 -0
- package/dist/skills/frontend/references/design/imagegen-frontend-mobile.md +1465 -0
- package/dist/skills/frontend/references/design/imagegen-frontend-web.md +686 -0
- package/dist/skills/frontend/references/design/intercom.md +146 -0
- package/dist/skills/frontend/references/design/kraken.md +125 -0
- package/dist/skills/frontend/references/design/lamborghini.md +288 -0
- package/dist/skills/frontend/references/design/linear.app.md +367 -0
- package/dist/skills/frontend/references/design/lovable.md +298 -0
- package/dist/skills/frontend/references/design/mastercard.md +365 -0
- package/dist/skills/frontend/references/design/meta.md +366 -0
- package/dist/skills/frontend/references/design/minimalist-skill.md +85 -0
- package/dist/skills/frontend/references/design/minimax.md +257 -0
- package/dist/skills/frontend/references/design/mintlify.md +326 -0
- package/dist/skills/frontend/references/design/miro.md +108 -0
- package/dist/skills/frontend/references/design/mistral.ai.md +261 -0
- package/dist/skills/frontend/references/design/mongodb.md +266 -0
- package/dist/skills/frontend/references/design/nike.md +363 -0
- package/dist/skills/frontend/references/design/notion.md +309 -0
- package/dist/skills/frontend/references/design/nvidia.md +293 -0
- package/dist/skills/frontend/references/design/ollama.md +267 -0
- package/dist/skills/frontend/references/design/opencode.ai.md +281 -0
- package/dist/skills/frontend/references/design/output-skill.md +49 -0
- package/dist/skills/frontend/references/design/pinterest.md +230 -0
- package/dist/skills/frontend/references/design/playstation.md +364 -0
- package/dist/skills/frontend/references/design/posthog.md +256 -0
- package/dist/skills/frontend/references/design/raycast.md +268 -0
- package/dist/skills/frontend/references/design/react-dev-tooling-skill.md +230 -0
- package/dist/skills/frontend/references/design/redesign-skill.md +178 -0
- package/dist/skills/frontend/references/design/renault.md +311 -0
- package/dist/skills/frontend/references/design/replicate.md +261 -0
- package/dist/skills/frontend/references/design/resend.md +303 -0
- package/dist/skills/frontend/references/design/revolut.md +185 -0
- package/dist/skills/frontend/references/design/runwayml.md +244 -0
- package/dist/skills/frontend/references/design/sanity.md +357 -0
- package/dist/skills/frontend/references/design/sentry.md +262 -0
- package/dist/skills/frontend/references/design/shopify.md +350 -0
- package/dist/skills/frontend/references/design/soft-skill.md +98 -0
- package/dist/skills/frontend/references/design/spacex.md +194 -0
- package/dist/skills/frontend/references/design/spotify.md +246 -0
- package/dist/skills/frontend/references/design/starbucks.md +580 -0
- package/dist/skills/frontend/references/design/stitch-skill.md +184 -0
- package/dist/skills/frontend/references/design/stripe.md +322 -0
- package/dist/skills/frontend/references/design/supabase.md +255 -0
- package/dist/skills/frontend/references/design/superhuman.md +252 -0
- package/dist/skills/frontend/references/design/taste-skill.md +226 -0
- package/dist/skills/frontend/references/design/tesla.md +286 -0
- package/dist/skills/frontend/references/design/theverge.md +339 -0
- package/dist/skills/frontend/references/design/together.ai.md +263 -0
- package/dist/skills/frontend/references/design/uber.md +295 -0
- package/dist/skills/frontend/references/design/vercel.md +310 -0
- package/dist/skills/frontend/references/design/vodafone.md +423 -0
- package/dist/skills/frontend/references/design/voltagent.md +323 -0
- package/dist/skills/frontend/references/design/warp.md +253 -0
- package/dist/skills/frontend/references/design/webflow.md +92 -0
- package/dist/skills/frontend/references/design/wired.md +278 -0
- package/dist/skills/frontend/references/design/wise.md +173 -0
- package/dist/skills/frontend/references/design/x.ai.md +257 -0
- package/dist/skills/frontend/references/design/zapier.md +328 -0
- package/dist/skills/frontend/references/perfection/README.md +160 -0
- package/dist/skills/frontend/references/perfection/react-perf-tooling.md +127 -0
- package/dist/skills/frontend/references/ui-ux-db/README.md +273 -0
- package/dist/skills/frontend/references/ui-ux-db/data/charts.csv +26 -0
- package/dist/skills/frontend/references/ui-ux-db/data/colors.csv +97 -0
- package/dist/skills/frontend/references/ui-ux-db/data/icons.csv +101 -0
- package/dist/skills/frontend/references/ui-ux-db/data/landing.csv +31 -0
- package/dist/skills/frontend/references/ui-ux-db/data/products.csv +97 -0
- package/dist/skills/frontend/references/ui-ux-db/data/react-performance.csv +45 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/astro.csv +54 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/flutter.csv +53 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/html-tailwind.csv +56 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/jetpack-compose.csv +53 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/nextjs.csv +53 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/nuxt-ui.csv +51 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/nuxtjs.csv +59 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/react-native.csv +52 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/react.csv +54 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/shadcn.csv +61 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/svelte.csv +54 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/swiftui.csv +51 -0
- package/dist/skills/frontend/references/ui-ux-db/data/stacks/vue.csv +50 -0
- package/dist/skills/frontend/references/ui-ux-db/data/styles.csv +68 -0
- package/dist/skills/frontend/references/ui-ux-db/data/typography.csv +58 -0
- package/dist/skills/frontend/references/ui-ux-db/data/ui-reasoning.csv +101 -0
- package/dist/skills/frontend/references/ui-ux-db/data/ux-guidelines.csv +100 -0
- package/dist/skills/frontend/references/ui-ux-db/data/web-interface.csv +31 -0
- package/dist/skills/frontend/references/ui-ux-db/scripts/core.py +253 -0
- package/dist/skills/frontend/references/ui-ux-db/scripts/design_system.py +1067 -0
- package/dist/skills/frontend/references/ui-ux-db/scripts/search.py +114 -0
- package/dist/skills/frontend/scripts/perfection/lighthouse-audit.py +201 -0
- package/dist/skills/git-master/SKILL.md +100 -0
- package/dist/skills/git-master/agents/openai.yaml +13 -0
- package/dist/skills/init-deep/SKILL.md +309 -0
- package/dist/skills/lcx-contribute-bug-fix/SKILL.md +242 -0
- package/dist/skills/lcx-contribute-bug-fix/agents/openai.yaml +12 -0
- package/dist/skills/lcx-contribute-bug-fix/scripts/create-pr-body.mjs +107 -0
- package/dist/skills/lcx-doctor/SKILL.md +93 -0
- package/dist/skills/lcx-doctor/agents/openai.yaml +11 -0
- package/dist/skills/lcx-report-bug/SKILL.md +237 -0
- package/dist/skills/lcx-report-bug/agents/openai.yaml +11 -0
- package/dist/skills/lsp-setup/SKILL.md +139 -0
- package/dist/skills/lsp-setup/references/bash/README.md +60 -0
- package/dist/skills/lsp-setup/references/c-cpp/README.md +61 -0
- package/dist/skills/lsp-setup/references/csharp/README.md +71 -0
- package/dist/skills/lsp-setup/references/dart/README.md +48 -0
- package/dist/skills/lsp-setup/references/elixir/README.md +51 -0
- package/dist/skills/lsp-setup/references/go/README.md +57 -0
- package/dist/skills/lsp-setup/references/haskell/README.md +57 -0
- package/dist/skills/lsp-setup/references/java/README.md +57 -0
- package/dist/skills/lsp-setup/references/julia/README.md +60 -0
- package/dist/skills/lsp-setup/references/kotlin/README.md +59 -0
- package/dist/skills/lsp-setup/references/lua/README.md +66 -0
- package/dist/skills/lsp-setup/references/php/README.md +62 -0
- package/dist/skills/lsp-setup/references/python/README.md +71 -0
- package/dist/skills/lsp-setup/references/ruby/README.md +53 -0
- package/dist/skills/lsp-setup/references/rust/README.md +59 -0
- package/dist/skills/lsp-setup/references/swift/README.md +51 -0
- package/dist/skills/lsp-setup/references/terraform/README.md +62 -0
- package/dist/skills/lsp-setup/references/typescript/README.md +77 -0
- package/dist/skills/lsp-setup/references/yaml/README.md +70 -0
- package/dist/skills/lsp-setup/references/zig/README.md +49 -0
- package/dist/skills/lsp-setup/scripts/detect-lsp.ts +210 -0
- package/dist/skills/lsp-setup/scripts/lsp-server-table.ts +177 -0
- package/dist/skills/lsp-setup/scripts/tsconfig.json +17 -0
- package/dist/skills/lsp-setup/scripts/verify-lsp.ts +147 -0
- package/dist/skills/programming/SKILL.md +463 -0
- package/dist/skills/programming/references/go/README.md +90 -0
- package/dist/skills/programming/references/go/backend-stack.md +641 -0
- package/dist/skills/programming/references/go/bootstrap.md +328 -0
- package/dist/skills/programming/references/go/bubbletea-v2.md +360 -0
- package/dist/skills/programming/references/go/cobra-stack.md +468 -0
- package/dist/skills/programming/references/go/concurrency.md +362 -0
- package/dist/skills/programming/references/go/data-modeling.md +329 -0
- package/dist/skills/programming/references/go/error-handling.md +359 -0
- package/dist/skills/programming/references/go/golangci-strict.md +236 -0
- package/dist/skills/programming/references/go/grpc-connect.md +375 -0
- package/dist/skills/programming/references/go/libraries.md +337 -0
- package/dist/skills/programming/references/go/one-liners.md +202 -0
- package/dist/skills/programming/references/go/sqlc-pgx.md +471 -0
- package/dist/skills/programming/references/go/testing.md +467 -0
- package/dist/skills/programming/references/go/type-patterns.md +298 -0
- package/dist/skills/programming/references/python/README.md +314 -0
- package/dist/skills/programming/references/python/async-anyio.md +442 -0
- package/dist/skills/programming/references/python/data-modeling.md +233 -0
- package/dist/skills/programming/references/python/data-processing.md +133 -0
- package/dist/skills/programming/references/python/error-handling.md +218 -0
- package/dist/skills/programming/references/python/fastapi-stack.md +316 -0
- package/dist/skills/programming/references/python/httpx2-optimization.md +360 -0
- package/dist/skills/programming/references/python/libraries.md +307 -0
- package/dist/skills/programming/references/python/one-liners.md +268 -0
- package/dist/skills/programming/references/python/orjson-stack.md +378 -0
- package/dist/skills/programming/references/python/pydantic-ai.md +285 -0
- package/dist/skills/programming/references/python/pyproject-strict.md +232 -0
- package/dist/skills/programming/references/python/textual-tui.md +201 -0
- package/dist/skills/programming/references/python/type-patterns.md +176 -0
- package/dist/skills/programming/references/rust/README.md +317 -0
- package/dist/skills/programming/references/rust/async-tokio.md +299 -0
- package/dist/skills/programming/references/rust/axum-stack.md +467 -0
- package/dist/skills/programming/references/rust/cargo-strict.md +317 -0
- package/dist/skills/programming/references/rust/clap-stack.md +409 -0
- package/dist/skills/programming/references/rust/concurrency.md +375 -0
- package/dist/skills/programming/references/rust/libraries.md +439 -0
- package/dist/skills/programming/references/rust/one-liners.md +291 -0
- package/dist/skills/programming/references/rust/proptest-insta.md +429 -0
- package/dist/skills/programming/references/rust/type-state.md +354 -0
- package/dist/skills/programming/references/rust/unsafe-discipline.md +250 -0
- package/dist/skills/programming/references/rust/zero-cost-safety.md +527 -0
- package/dist/skills/programming/references/rust-ub/README.md +289 -0
- package/dist/skills/programming/references/rust-ub/miri-sanitizers-loom.md +411 -0
- package/dist/skills/programming/references/rust-ub/ub-taxonomy.md +269 -0
- package/dist/skills/programming/references/typescript/README.md +195 -0
- package/dist/skills/programming/references/typescript/backend-hono.md +672 -0
- package/dist/skills/programming/references/typescript/bootstrap.md +199 -0
- package/dist/skills/programming/references/typescript/data-modeling.md +202 -0
- package/dist/skills/programming/references/typescript/error-handling.md +169 -0
- package/dist/skills/programming/references/typescript/tsconfig-strict.md +152 -0
- package/dist/skills/programming/references/typescript/type-patterns.md +196 -0
- package/dist/skills/programming/scripts/go/check-no-excuse-rules.sh +173 -0
- package/dist/skills/programming/scripts/go/new-project.py +138 -0
- package/dist/skills/programming/scripts/go/templates/.editorconfig +13 -0
- package/dist/skills/programming/scripts/go/templates/.golangci.yml +95 -0
- package/dist/skills/programming/scripts/go/templates/AGENTS.md.tmpl +24 -0
- package/dist/skills/programming/scripts/go/templates/README.md.tmpl +12 -0
- package/dist/skills/programming/scripts/go/templates/Taskfile.yml +40 -0
- package/dist/skills/programming/scripts/go/templates/ci.yml +37 -0
- package/dist/skills/programming/scripts/go/templates/config.go +24 -0
- package/dist/skills/programming/scripts/go/templates/gitignore +15 -0
- package/dist/skills/programming/scripts/go/templates/main.go.tmpl +22 -0
- package/dist/skills/programming/scripts/go/templates/run.go +15 -0
- package/dist/skills/programming/scripts/python/check-no-excuse-rules.py +687 -0
- package/dist/skills/programming/scripts/python/new-project.py +172 -0
- package/dist/skills/programming/scripts/python/new-script.py +116 -0
- package/dist/skills/programming/scripts/rust/check-no-excuse-rules.py +296 -0
- package/dist/skills/programming/scripts/rust/check-no-excuse-rules.sh +158 -0
- package/dist/skills/programming/scripts/rust/new-project.py +175 -0
- package/dist/skills/programming/scripts/typescript/check-no-excuse-rules.ts +282 -0
- package/dist/skills/programming/scripts/typescript/new-project.ts +177 -0
- package/dist/skills/refactor/SKILL.md +754 -0
- package/dist/skills/remove-ai-slops/SKILL.md +317 -0
- package/dist/skills/review-work/SKILL.md +594 -0
- package/dist/skills/start-work/SKILL.md +178 -0
- package/dist/skills/ultraresearch/SKILL.md +230 -0
- package/dist/skills/ulw-plan/SKILL.md +69 -0
- package/dist/skills/ulw-plan/agents/openai.yaml +7 -0
- package/dist/skills/ulw-plan/references/full-workflow.md +99 -0
- package/dist/skills/ulw-plan/references/intent-clear.md +44 -0
- package/dist/skills/ulw-plan/references/intent-unclear.md +44 -0
- package/dist/skills/ulw-plan/scripts/scaffold-plan.mjs +301 -0
- package/dist/skills/visual-qa/SKILL.md +235 -0
- package/dist/skills/visual-qa/references/agent-browser-setup.md +44 -0
- package/dist/skills/visual-qa/scripts/ansi.test.ts +45 -0
- package/dist/skills/visual-qa/scripts/ansi.ts +17 -0
- package/dist/skills/visual-qa/scripts/cli.test.ts +73 -0
- package/dist/skills/visual-qa/scripts/cli.ts +82 -0
- package/dist/skills/visual-qa/scripts/east-asian-width.test.ts +60 -0
- package/dist/skills/visual-qa/scripts/east-asian-width.ts +72 -0
- package/dist/skills/visual-qa/scripts/image-diff.test.ts +70 -0
- package/dist/skills/visual-qa/scripts/image-diff.ts +109 -0
- package/dist/skills/visual-qa/scripts/png-crc.ts +27 -0
- package/dist/skills/visual-qa/scripts/png-decode.test.ts +44 -0
- package/dist/skills/visual-qa/scripts/png-decode.ts +206 -0
- package/dist/skills/visual-qa/scripts/png-synth.ts +57 -0
- package/dist/skills/visual-qa/scripts/skill-prompt-contract.test.ts +127 -0
- package/dist/skills/visual-qa/scripts/tui-grid.test.ts +57 -0
- package/dist/skills/visual-qa/scripts/tui-grid.ts +88 -0
- package/dist/skills/visual-qa/scripts/types.ts +54 -0
- package/dist/tools/delegate-task/background-task-description.d.ts +2 -0
- package/dist/tools/delegate-task/constants.d.ts +13 -1
- package/dist/tools/delegate-task/model-selection.d.ts +3 -17
- package/dist/tools/delegate-task/model-string-parser.d.ts +1 -9
- package/dist/tools/delegate-task/sync-result-fetcher.d.ts +1 -0
- package/dist/tools/delegate-task/sync-session-poller.d.ts +1 -0
- package/dist/tools/delegate-task/types.d.ts +59 -2
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/monitor/create-monitor-tools.d.ts +4 -0
- package/dist/tools/monitor/index.d.ts +1 -0
- package/dist/tools/monitor/monitor-list.d.ts +7 -0
- package/dist/tools/monitor/monitor-output.d.ts +3 -0
- package/dist/tools/monitor/monitor-start.d.ts +9 -0
- package/dist/tools/monitor/monitor-stop.d.ts +16 -0
- package/dist/tools/skill/native-skills.d.ts +2 -2
- package/dist/tools/skill/scope-priority.d.ts +1 -4
- package/dist/tools/skill/skill-matcher.d.ts +1 -5
- package/dist/tools/task/types.d.ts +10 -10
- package/dist/tui.d.ts +4 -0
- package/dist/tui.js +69330 -0
- package/package.json +57 -36
- package/packages/git-bash-mcp/dist/cli.js +225 -55
- package/packages/lsp-core/package.json +41 -0
- package/packages/lsp-core/src/index.ts +28 -0
- package/packages/lsp-core/src/lsp/cleanup-errors.ts +5 -0
- package/packages/lsp-core/src/lsp/client-wrapper.ts +173 -0
- package/packages/lsp-core/src/lsp/client.ts +172 -0
- package/packages/lsp-core/src/lsp/config-loader.ts +266 -0
- package/packages/lsp-core/src/lsp/connection.ts +73 -0
- package/packages/lsp-core/src/lsp/constants.ts +11 -0
- package/packages/lsp-core/src/lsp/directory-diagnostics.ts +154 -0
- package/packages/lsp-core/src/lsp/effective-extension.ts +10 -0
- package/packages/lsp-core/src/lsp/errors.ts +63 -0
- package/packages/lsp-core/src/lsp/formatters.ts +141 -0
- package/packages/lsp-core/src/lsp/infer-extension.ts +66 -0
- package/packages/lsp-core/src/lsp/json-rpc-connection.ts +296 -0
- package/packages/lsp-core/src/lsp/language-mappings.ts +173 -0
- package/packages/lsp-core/src/lsp/manager.ts +369 -0
- package/packages/lsp-core/src/lsp/process-signal-cleanup.ts +21 -0
- package/packages/lsp-core/src/lsp/process.ts +202 -0
- package/packages/lsp-core/src/lsp/server-definitions.ts +176 -0
- package/packages/lsp-core/src/lsp/server-install-state.ts +70 -0
- package/packages/lsp-core/src/lsp/server-installation.ts +45 -0
- package/packages/lsp-core/src/lsp/server-resolution.ts +104 -0
- package/packages/lsp-core/src/lsp/startup-failure.ts +1 -0
- package/packages/lsp-core/src/lsp/transport.ts +299 -0
- package/packages/lsp-core/src/lsp/types.ts +126 -0
- package/packages/lsp-core/src/lsp/utils.test.ts +72 -0
- package/packages/lsp-core/src/lsp/utils.ts +40 -0
- package/packages/lsp-core/src/lsp/workspace-edit.ts +206 -0
- package/packages/lsp-core/src/mcp-protocol-pin.test.ts +68 -0
- package/packages/lsp-core/src/mcp.ts +95 -0
- package/packages/lsp-core/src/missing-dependency-result.ts +19 -0
- package/packages/lsp-core/src/request-context.ts +22 -0
- package/packages/lsp-core/src/tool-surface.test.ts +157 -0
- package/packages/lsp-core/src/tools/definitions.ts +141 -0
- package/packages/lsp-core/src/tools/diagnostics.ts +97 -0
- package/packages/lsp-core/src/tools/index.ts +10 -0
- package/packages/lsp-core/src/tools/install-decision.ts +39 -0
- package/packages/lsp-core/src/tools/navigation.ts +86 -0
- package/packages/lsp-core/src/tools/parameters.ts +49 -0
- package/packages/lsp-core/src/tools/rename.ts +72 -0
- package/packages/lsp-core/src/tools/result.ts +5 -0
- package/packages/lsp-core/src/tools/runtime.ts +21 -0
- package/packages/lsp-core/src/tools/schema.ts +9 -0
- package/packages/lsp-core/src/tools/status.ts +28 -0
- package/packages/lsp-core/src/tools/symbols.ts +99 -0
- package/packages/lsp-core/src/tools/types.ts +104 -0
- package/packages/lsp-core/src/tools.ts +1 -0
- package/packages/lsp-daemon/dist/cli.js +712 -527
- package/packages/lsp-daemon/dist/daemon-client.d.ts +1 -1
- package/packages/lsp-daemon/dist/daemon-server.js +1 -1
- package/packages/lsp-daemon/dist/index.d.ts +1 -1
- package/packages/lsp-daemon/dist/index.js +687 -500
- package/packages/lsp-daemon/dist/proxy.d.ts +3 -2
- package/packages/lsp-daemon/dist/proxy.js +16 -40
- package/packages/lsp-daemon/dist/request-routing.d.ts +2 -2
- package/packages/lsp-daemon/dist/request-routing.js +2 -2
- package/packages/lsp-daemon/package.json +2 -1
- package/packages/lsp-tools-mcp/dist/cli.js +3348 -15
- package/packages/lsp-tools-mcp/dist/lsp/cleanup-errors.d.ts +1 -1
- package/packages/lsp-tools-mcp/dist/lsp/client-wrapper.d.ts +1 -13
- package/packages/lsp-tools-mcp/dist/lsp/client.d.ts +1 -20
- package/packages/lsp-tools-mcp/dist/lsp/config-loader.d.ts +1 -16
- package/packages/lsp-tools-mcp/dist/lsp/connection.d.ts +1 -4
- package/packages/lsp-tools-mcp/dist/lsp/constants.d.ts +1 -10
- package/packages/lsp-tools-mcp/dist/lsp/directory-diagnostics.d.ts +1 -3
- package/packages/lsp-tools-mcp/dist/lsp/effective-extension.d.ts +1 -1
- package/packages/lsp-tools-mcp/dist/lsp/errors.d.ts +1 -35
- package/packages/lsp-tools-mcp/dist/lsp/formatters.d.ts +1 -12
- package/packages/lsp-tools-mcp/dist/lsp/infer-extension.d.ts +1 -1
- package/packages/lsp-tools-mcp/dist/lsp/json-rpc-connection.d.ts +1 -36
- package/packages/lsp-tools-mcp/dist/lsp/language-mappings.d.ts +1 -4
- package/packages/lsp-tools-mcp/dist/lsp/manager.d.ts +1 -46
- package/packages/lsp-tools-mcp/dist/lsp/manager.js +1390 -265
- package/packages/lsp-tools-mcp/dist/lsp/process-signal-cleanup.d.ts +1 -1
- package/packages/lsp-tools-mcp/dist/lsp/process.d.ts +1 -25
- package/packages/lsp-tools-mcp/dist/lsp/server-definitions.d.ts +1 -4
- package/packages/lsp-tools-mcp/dist/lsp/server-install-state.d.ts +1 -12
- package/packages/lsp-tools-mcp/dist/lsp/server-installation.d.ts +1 -1
- package/packages/lsp-tools-mcp/dist/lsp/server-resolution.d.ts +1 -11
- package/packages/lsp-tools-mcp/dist/lsp/startup-failure.d.ts +1 -3
- package/packages/lsp-tools-mcp/dist/lsp/transport.d.ts +1 -35
- package/packages/lsp-tools-mcp/dist/lsp/types.d.ts +1 -124
- package/packages/lsp-tools-mcp/dist/lsp/utils.d.ts +1 -0
- package/packages/lsp-tools-mcp/dist/lsp/workspace-edit.d.ts +1 -11
- package/packages/lsp-tools-mcp/dist/mcp.d.ts +1 -30
- package/packages/lsp-tools-mcp/dist/mcp.js +3312 -70
- package/packages/lsp-tools-mcp/dist/missing-dependency-result.d.ts +1 -2
- package/packages/lsp-tools-mcp/dist/request-context.d.ts +1 -7
- package/packages/lsp-tools-mcp/dist/request-context.js +16 -10
- package/packages/lsp-tools-mcp/dist/tools.d.ts +1 -90
- package/packages/lsp-tools-mcp/dist/tools.js +3028 -439
- package/packages/lsp-tools-mcp/package.json +3 -1
- package/packages/omo-codex/THIRD-PARTY-NOTICES.md +155 -0
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/.mcp.json +6 -5
- package/packages/omo-codex/plugin/README.md +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +1637 -1245
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/scripts/generate-manifests.mjs +8 -52
- package/packages/omo-codex/plugin/components/bootstrap/src/provision.ts +35 -143
- package/packages/omo-codex/plugin/components/bootstrap/src/setup.ts +11 -11
- package/packages/omo-codex/plugin/components/bootstrap/test/environment.test.ts +3 -2
- package/packages/omo-codex/plugin/components/bootstrap/test/provision.test.ts +37 -37
- package/packages/omo-codex/plugin/components/codegraph/dist/cli.js +2205 -0
- package/packages/omo-codex/plugin/components/codegraph/dist/serve.d.ts +32 -0
- package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +1603 -0
- package/packages/omo-codex/plugin/components/codegraph/package.json +27 -0
- package/packages/omo-codex/plugin/components/codegraph/src/cli.ts +55 -0
- package/packages/omo-codex/plugin/components/codegraph/src/hook-types.ts +83 -0
- package/packages/omo-codex/plugin/components/codegraph/src/hook.ts +108 -0
- package/packages/omo-codex/plugin/components/codegraph/src/serve.ts +191 -0
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker.ts +213 -0
- package/packages/omo-codex/plugin/components/codegraph/test/hook.test.ts +563 -0
- package/packages/omo-codex/plugin/components/codegraph/test/serve.test.ts +401 -0
- package/packages/omo-codex/plugin/components/codegraph/tsconfig.build.json +13 -0
- package/packages/omo-codex/plugin/components/codegraph/tsconfig.json +25 -0
- package/packages/omo-codex/plugin/components/comment-checker/dist/cli.js +610 -7
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +4 -3
- package/packages/omo-codex/plugin/components/comment-checker/src/apply-patch.ts +28 -156
- package/packages/omo-codex/plugin/components/comment-checker/src/core-values.ts +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/src/core.ts +2 -2
- package/packages/omo-codex/plugin/components/comment-checker/src/request-extractor.ts +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/src/runner.ts +6 -2
- package/packages/omo-codex/plugin/components/comment-checker/test/core.test.ts +38 -35
- package/packages/omo-codex/plugin/components/comment-checker/test/fixtures/apply-patch-mixed-requests.ts +60 -0
- package/packages/omo-codex/plugin/components/git-bash/dist/cli.js +155 -26
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +2 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/biome.json +48 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/directive.md +11 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/cli.js +223 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/codex-hook.d.ts +2 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/codex-hook.js +123 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/directive.d.ts +2 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/directive.js +5 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/index.d.ts +4 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/index.js +3 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/state.d.ts +9 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/state.js +45 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/types.d.ts +39 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/types.js +1 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +17 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +44 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/cli.ts +56 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/codex-hook.ts +129 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/directive.ts +13 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/index.ts +4 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/state.ts +62 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/types.ts +38 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/test/cli.test.ts +124 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/test/codex-hook.test.ts +346 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/tsconfig.build.json +12 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/tsconfig.json +27 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/vitest.config.ts +10 -0
- package/packages/omo-codex/plugin/components/lsp/dist/cli.js +3738 -28
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/bundled-rules/hephaestus.md +1 -1
- package/packages/omo-codex/plugin/components/rules/dist/cli.js +4565 -89
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +4 -3
- package/packages/omo-codex/plugin/components/rules/src/cli.ts +16 -3
- package/packages/omo-codex/plugin/components/rules/src/config.ts +3 -3
- package/packages/omo-codex/plugin/components/rules/src/dynamic-target-fingerprints.ts +6 -6
- package/packages/omo-codex/plugin/components/rules/src/event-budget.ts +1 -1
- package/packages/omo-codex/plugin/components/rules/src/persistent-cache.ts +1 -1
- package/packages/omo-codex/plugin/components/rules/src/post-compact-budget.ts +1 -1
- package/packages/omo-codex/plugin/components/rules/src/rules-engine-factory.ts +9 -4
- package/packages/omo-codex/plugin/components/rules/src/static-injection.ts +3 -3
- package/packages/omo-codex/plugin/components/rules/src/transcript-rule-filter.ts +1 -1
- package/packages/omo-codex/plugin/components/rules/test/bundled-rules-priority.test.ts +4 -4
- package/packages/omo-codex/plugin/components/rules/test/bundled-rules.test.ts +1 -1
- package/packages/omo-codex/plugin/components/rules/test/dynamic-target-fingerprints.test.ts +1 -1
- package/packages/omo-codex/plugin/components/rules/test/engine.test.ts +3 -3
- package/packages/omo-codex/plugin/components/rules/test/finder.test.ts +2 -2
- package/packages/omo-codex/plugin/components/rules/test/formatter.test.ts +2 -2
- package/packages/omo-codex/plugin/components/rules/test/matcher.test.ts +2 -2
- package/packages/omo-codex/plugin/components/rules/test/parser.test.ts +1 -1
- package/packages/omo-codex/plugin/components/rules/test/post-compact-budget.test.ts +1 -1
- package/packages/omo-codex/plugin/components/rules/test/rules-engine-consumption.test.ts +92 -0
- package/packages/omo-codex/plugin/components/rules/test/scanner.test.ts +1 -1
- package/packages/omo-codex/plugin/components/rules/test/sources.test.ts +4 -4
- package/packages/omo-codex/plugin/components/rules/test/windows-git-bash-bundled-rule.test.ts +1 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/cli.js +394 -37
- 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 +4 -3
- package/packages/omo-codex/plugin/components/start-work-continuation/src/boulder-reader.ts +20 -147
- package/packages/omo-codex/plugin/components/start-work-continuation/src/codex-hook.ts +1 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/src/index.ts +1 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/test/boulder-reader.test.ts +151 -27
- package/packages/omo-codex/plugin/components/start-work-continuation/test/codex-hook.test.ts +87 -49
- package/packages/omo-codex/plugin/components/telemetry/LICENSE +21 -0
- package/packages/omo-codex/plugin/components/telemetry/NOTICE +6 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +5869 -42
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +5783 -108
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +4 -5
- package/packages/omo-codex/plugin/components/telemetry/src/codex-hook.ts +3 -3
- package/packages/omo-codex/plugin/components/telemetry/src/posthog.ts +92 -142
- package/packages/omo-codex/plugin/components/telemetry/src/product-identity.ts +59 -3
- package/packages/omo-codex/plugin/components/telemetry/test/codex-hook-diagnostics.test.ts +3 -3
- package/packages/omo-codex/plugin/components/telemetry/test/diagnostics.test.ts +13 -7
- package/packages/omo-codex/plugin/components/ultrawork/AGENTS.md +2 -2
- package/packages/omo-codex/plugin/components/ultrawork/README.md +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/explorer.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-clone-fidelity-reviewer.toml +31 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-code-reviewer.toml +29 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-executor.toml +24 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-gate-reviewer.toml +23 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-qa-executor.toml +22 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/librarian.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/plan.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/directive.md +104 -156
- package/packages/omo-codex/plugin/components/ultrawork/dist/cli.js +162 -37
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +4 -3
- package/packages/omo-codex/plugin/components/ultrawork/scripts/sync-directive.mjs +11 -0
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +47 -20
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/full-workflow.md +55 -88
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/intent-clear.md +44 -0
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/intent-unclear.md +44 -0
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/scripts/scaffold-plan.mjs +301 -0
- package/packages/omo-codex/plugin/components/ultrawork/src/codex-hook.ts +2 -2
- package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook-test-helpers.ts +101 -0
- package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook-trigger-policy.test.ts +111 -0
- package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook.test.ts +24 -128
- package/packages/omo-codex/plugin/components/ultrawork/test/directive-source.test.ts +16 -0
- package/packages/omo-codex/plugin/components/ultrawork/test/package-smoke.test.ts +4 -2
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-reconciliation.d.ts +5 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-reconciliation.js +79 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.d.ts +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.js +56 -82
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.js +38 -144
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-subcommands.d.ts +10 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-subcommands.js +173 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +2419 -32
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.js +13 -9
- package/packages/omo-codex/plugin/components/ulw-loop/dist/domain-types.d.ts +60 -12
- package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.d.ts +3 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.js +67 -10
- package/packages/omo-codex/plugin/components/ulw-loop/dist/goal-status.d.ts +3 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/goal-status.js +14 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.d.ts +2 -6
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.js +49 -39
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-goal-factory.d.ts +8 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-goal-factory.js +109 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-blockers.d.ts +5 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-blockers.js +41 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-fields.d.ts +8 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-fields.js +39 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.d.ts +13 -6
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.js +176 -105
- 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/references/full-workflow.md +17 -17
- package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-reconciliation.ts +100 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint.ts +162 -85
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-commands.ts +62 -136
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-subcommands.ts +250 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-instruction.ts +18 -9
- package/packages/omo-codex/plugin/components/ulw-loop/src/domain-types.ts +67 -4
- package/packages/omo-codex/plugin/components/ulw-loop/src/evidence.ts +124 -18
- package/packages/omo-codex/plugin/components/ulw-loop/src/goal-status.ts +16 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-crud.ts +131 -54
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-goal-factory.ts +124 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-blockers.ts +48 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-fields.ts +44 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate.ts +230 -138
- package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-final.test.ts +186 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-status.test.ts +85 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint.test.ts +120 -192
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-checkpoint.test.ts +215 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-commands.test.ts +1 -195
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-complete-goals.test.ts +15 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-create-goals.test.ts +172 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-helpers.test.ts +0 -6
- package/packages/omo-codex/plugin/components/ulw-loop/test/codex-goal-instruction.test.ts +39 -8
- package/packages/omo-codex/plugin/components/ulw-loop/test/evidence-criteria-gate.test.ts +29 -1
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/artifacts/browser-screenshot.txt +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/artifacts/cli-pass.txt +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/artifacts/code-review.md +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/artifacts/data-diff.txt +5 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/artifacts/gate-review.md +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/artifacts/http-dump.txt +4 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/artifacts/rejection.txt +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/checkpoint-builders.ts +98 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/quality-gate-builder.ts +91 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/sample-quality-gate.json +110 -8
- package/packages/omo-codex/plugin/components/ulw-loop/test/goal-status.test.ts +35 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/plan-crud.test.ts +11 -1
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-blockers.test.ts +102 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-doc.test.ts +38 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-roles.test.ts +131 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate.test.ts +150 -176
- package/packages/omo-codex/plugin/components/ulw-loop/test/skill-contract.test.ts +12 -0
- package/packages/omo-codex/plugin/hooks/hooks.json +38 -17
- package/packages/omo-codex/plugin/package-lock.json +144 -49
- package/packages/omo-codex/plugin/package.json +4 -2
- package/packages/omo-codex/plugin/scripts/auto-update.mjs +2 -0
- package/packages/omo-codex/plugin/scripts/build-bundled-mcp-runtimes.mjs +0 -5
- package/packages/omo-codex/plugin/scripts/build-components.mjs +29 -5
- package/packages/omo-codex/plugin/scripts/hook-status-message.mjs +2 -0
- package/packages/omo-codex/plugin/scripts/migrate-omo-sot/editor.mjs +125 -0
- package/packages/omo-codex/plugin/scripts/migrate-omo-sot/jsonc.mjs +43 -0
- package/packages/omo-codex/plugin/scripts/migrate-omo-sot/scaffold.mjs +29 -0
- package/packages/omo-codex/plugin/scripts/migrate-omo-sot.mjs +121 -0
- package/packages/omo-codex/plugin/scripts/sync-skills.mjs +5 -5
- package/packages/omo-codex/plugin/shared/package.json +24 -0
- package/packages/omo-codex/plugin/shared/src/config-loader.ts +28 -0
- package/packages/omo-codex/plugin/shared/test/config-loader.test.ts +105 -0
- package/packages/omo-codex/plugin/shared/tsconfig.build.json +9 -0
- package/packages/omo-codex/plugin/shared/tsconfig.json +16 -0
- package/packages/omo-codex/plugin/skills/ast-grep/LICENSE +21 -0
- package/packages/omo-codex/plugin/skills/ast-grep/README.md +136 -0
- package/packages/omo-codex/plugin/skills/ast-grep/SKILL.md +272 -0
- package/packages/omo-codex/plugin/skills/ast-grep/SOURCE +1 -0
- package/packages/omo-codex/plugin/skills/ast-grep/install.ps1 +235 -0
- package/packages/omo-codex/plugin/skills/ast-grep/install.sh +286 -0
- package/packages/omo-codex/plugin/skills/ast-grep/references/cli.md +231 -0
- package/packages/omo-codex/plugin/skills/ast-grep/references/install.md +166 -0
- package/packages/omo-codex/plugin/skills/ast-grep/references/patterns.md +147 -0
- package/packages/omo-codex/plugin/skills/ast-grep/references/pitfalls.md +303 -0
- package/packages/omo-codex/plugin/skills/ast-grep/references/recipes.md +402 -0
- package/packages/omo-codex/plugin/skills/ast-grep/references/sgconfig.md +248 -0
- package/packages/omo-codex/plugin/skills/ast-grep/references/yaml-rules.md +509 -0
- package/packages/omo-codex/plugin/skills/ast-grep/scripts/ast_grep_helper.py +748 -0
- package/packages/omo-codex/plugin/skills/ast-grep/tests/smoke.ps1 +123 -0
- package/packages/omo-codex/plugin/skills/ast-grep/tests/smoke.sh +212 -0
- package/packages/omo-codex/plugin/skills/frontend/ATTRIBUTION.md +127 -0
- package/packages/omo-codex/plugin/skills/frontend/LICENSE-Apache-2.0.txt +201 -0
- package/packages/omo-codex/plugin/skills/frontend/SKILL.md +113 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/README.md +240 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/_INDEX.md +189 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/airbnb.md +390 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/airtable.md +89 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/apple.md +247 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/binance.md +345 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/bmw.md +180 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/brutalist-skill.md +92 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/bugatti.md +268 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/cal.md +259 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/claude.md +312 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/clay.md +304 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/clickhouse.md +281 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/cohere.md +266 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/coinbase.md +129 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/composio.md +307 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/cursor.md +309 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/design-system-architecture.md +217 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/elevenlabs.md +265 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/expo.md +281 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/ferrari.md +314 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/figma.md +220 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/framer.md +246 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/gpt-tasteskill.md +74 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/hashicorp.md +278 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/ibm.md +332 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/image-to-code-skill.md +1228 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/imagegen-brandkit.md +798 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/imagegen-frontend-mobile.md +1465 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/imagegen-frontend-web.md +686 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/intercom.md +146 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/kraken.md +125 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/lamborghini.md +288 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/linear.app.md +367 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/lovable.md +298 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/mastercard.md +365 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/meta.md +366 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/minimalist-skill.md +85 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/minimax.md +257 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/mintlify.md +326 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/miro.md +108 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/mistral.ai.md +261 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/mongodb.md +266 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/nike.md +363 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/notion.md +309 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/nvidia.md +293 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/ollama.md +267 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/opencode.ai.md +281 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/output-skill.md +49 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/pinterest.md +230 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/playstation.md +364 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/posthog.md +256 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/raycast.md +268 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/react-dev-tooling-skill.md +230 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/redesign-skill.md +178 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/renault.md +311 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/replicate.md +261 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/resend.md +303 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/revolut.md +185 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/runwayml.md +244 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/sanity.md +357 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/sentry.md +262 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/shopify.md +350 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/soft-skill.md +98 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/spacex.md +194 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/spotify.md +246 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/starbucks.md +580 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/stitch-skill.md +184 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/stripe.md +322 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/supabase.md +255 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/superhuman.md +252 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/taste-skill.md +226 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/tesla.md +286 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/theverge.md +339 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/together.ai.md +263 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/uber.md +295 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/vercel.md +310 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/vodafone.md +423 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/voltagent.md +323 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/warp.md +253 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/webflow.md +92 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/wired.md +278 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/wise.md +173 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/x.ai.md +257 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/zapier.md +328 -0
- package/packages/omo-codex/plugin/skills/frontend/references/perfection/README.md +160 -0
- package/packages/omo-codex/plugin/skills/frontend/references/perfection/react-perf-tooling.md +127 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/README.md +273 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/charts.csv +26 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/colors.csv +97 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/icons.csv +101 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/landing.csv +31 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/products.csv +97 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/react-performance.csv +45 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/astro.csv +54 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/flutter.csv +53 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/html-tailwind.csv +56 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/jetpack-compose.csv +53 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/nextjs.csv +53 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/nuxt-ui.csv +51 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/nuxtjs.csv +59 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/react-native.csv +52 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/react.csv +54 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/shadcn.csv +61 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/svelte.csv +54 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/swiftui.csv +51 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/stacks/vue.csv +50 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/styles.csv +68 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/typography.csv +58 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/ui-reasoning.csv +101 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/ux-guidelines.csv +100 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/data/web-interface.csv +31 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/scripts/core.py +253 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/scripts/design_system.py +1067 -0
- package/packages/omo-codex/plugin/skills/frontend/references/ui-ux-db/scripts/search.py +114 -0
- package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/lighthouse-audit.py +201 -0
- package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +3 -3
- package/packages/omo-codex/plugin/skills/refactor/SKILL.md +14 -23
- package/packages/omo-codex/plugin/skills/remove-ai-slops/SKILL.md +2 -2
- package/packages/omo-codex/plugin/skills/review-work/SKILL.md +2 -2
- package/packages/omo-codex/plugin/skills/start-work/SKILL.md +3 -3
- package/packages/omo-codex/plugin/skills/ultraresearch/SKILL.md +2 -2
- package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +17 -17
- package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +47 -20
- package/packages/omo-codex/plugin/skills/ulw-plan/references/full-workflow.md +55 -88
- package/packages/omo-codex/plugin/skills/ulw-plan/references/intent-clear.md +44 -0
- package/packages/omo-codex/plugin/skills/ulw-plan/references/intent-unclear.md +44 -0
- package/packages/omo-codex/plugin/skills/ulw-plan/scripts/scaffold-plan.mjs +301 -0
- package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +19 -3
- package/packages/omo-codex/plugin/skills/visual-qa/references/agent-browser-setup.md +44 -0
- package/packages/omo-codex/plugin/test/aggregate-agents.test.mjs +119 -11
- package/packages/omo-codex/plugin/test/aggregate-build.test.mjs +2 -4
- package/packages/omo-codex/plugin/test/aggregate-hooks.test.mjs +29 -2
- package/packages/omo-codex/plugin/test/aggregate-manifest.test.mjs +2 -0
- package/packages/omo-codex/plugin/test/aggregate-mcp.test.mjs +12 -12
- package/packages/omo-codex/plugin/test/auto-update.test.mjs +26 -0
- package/packages/omo-codex/plugin/test/component-bundled-cli.test.mjs +287 -0
- package/packages/omo-codex/plugin/test/component-hook-contract-cases.mjs +199 -0
- package/packages/omo-codex/plugin/test/hook-status-message.test.mjs +38 -2
- package/packages/omo-codex/plugin/test/index.js +13 -0
- package/packages/omo-codex/plugin/test/install-time-build-runtime.test.mjs +4 -5
- package/packages/omo-codex/plugin/test/mcp-research-servers.test.mjs +5 -3
- package/packages/omo-codex/plugin/test/migrate-omo-sot.test.mjs +179 -0
- package/packages/omo-codex/plugin/test/payload-equivalence.test.mjs +109 -0
- package/packages/omo-codex/plugin/test/scaffold-plan.test.mjs +165 -0
- package/packages/omo-codex/plugin/test/sync-skills-orchestration.test.mjs +6 -6
- package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +2 -3
- package/packages/omo-codex/plugin/test/sync-skills.test.mjs +37 -1
- package/packages/omo-codex/scripts/install-bin-links.test.mjs +3 -3
- package/packages/omo-codex/scripts/install-cache-copy.test.mjs +1 -1
- package/packages/omo-codex/scripts/install-cli-args.test.mjs +1 -1
- package/packages/omo-codex/scripts/install-config-autonomous-features.test.mjs +1 -1
- package/packages/omo-codex/scripts/install-config-autonomous.test.mjs +1 -1
- package/packages/omo-codex/scripts/install-config-git-bash.test.mjs +1 -1
- package/packages/omo-codex/scripts/install-config-preservation.test.mjs +1 -1
- package/packages/omo-codex/scripts/install-config-reasoning.test.mjs +1 -2
- package/packages/omo-codex/scripts/install-config.test.mjs +8 -6
- package/packages/omo-codex/scripts/install-delegated-command.test.mjs +1 -1
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +13377 -0
- package/packages/omo-codex/scripts/install-generated-bundle.test.mjs +55 -0
- package/packages/omo-codex/scripts/install-git-bash-mcp-env.test.mjs +3 -4
- package/packages/omo-codex/scripts/install-hook-targets.test.mjs +1 -1
- package/packages/omo-codex/scripts/install-local.mjs +54 -237
- package/packages/omo-codex/scripts/install-local.test.mjs +8 -1
- package/packages/omo-codex/scripts/install-marketplace-cache.test.mjs +3 -3
- package/packages/omo-codex/scripts/install-mcp-runtime.test.mjs +34 -77
- package/packages/omo-codex/scripts/install-packaged-local.test.mjs +8 -4
- package/packages/omo-codex/scripts/install-project-local-cleanup.test.mjs +1 -1
- package/packages/shared-skills/package.json +6 -1
- package/packages/shared-skills/skills/ast-grep/LICENSE +21 -0
- package/packages/shared-skills/skills/ast-grep/README.md +136 -0
- package/packages/shared-skills/skills/ast-grep/SKILL.md +272 -0
- package/packages/shared-skills/skills/ast-grep/SOURCE +1 -0
- package/packages/shared-skills/skills/ast-grep/install.ps1 +235 -0
- package/packages/shared-skills/skills/ast-grep/install.sh +286 -0
- package/packages/shared-skills/skills/ast-grep/references/cli.md +231 -0
- package/packages/shared-skills/skills/ast-grep/references/install.md +166 -0
- package/packages/shared-skills/skills/ast-grep/references/patterns.md +147 -0
- package/packages/shared-skills/skills/ast-grep/references/pitfalls.md +303 -0
- package/packages/shared-skills/skills/ast-grep/references/recipes.md +402 -0
- package/packages/shared-skills/skills/ast-grep/references/sgconfig.md +248 -0
- package/packages/shared-skills/skills/ast-grep/references/yaml-rules.md +509 -0
- package/packages/shared-skills/skills/ast-grep/scripts/ast_grep_helper.py +748 -0
- package/packages/shared-skills/skills/ast-grep/tests/smoke.ps1 +123 -0
- package/packages/shared-skills/skills/ast-grep/tests/smoke.sh +212 -0
- package/packages/shared-skills/skills/frontend/ATTRIBUTION.md +127 -0
- package/packages/shared-skills/skills/frontend/LICENSE-Apache-2.0.txt +201 -0
- package/packages/shared-skills/skills/frontend/SKILL.md +113 -0
- package/packages/shared-skills/skills/frontend/references/design/README.md +240 -0
- package/packages/shared-skills/skills/frontend/references/design/_INDEX.md +189 -0
- package/packages/shared-skills/skills/frontend/references/design/airbnb.md +390 -0
- package/packages/shared-skills/skills/frontend/references/design/airtable.md +89 -0
- package/packages/shared-skills/skills/frontend/references/design/apple.md +247 -0
- package/packages/shared-skills/skills/frontend/references/design/binance.md +345 -0
- package/packages/shared-skills/skills/frontend/references/design/bmw.md +180 -0
- package/packages/shared-skills/skills/frontend/references/design/brutalist-skill.md +92 -0
- package/packages/shared-skills/skills/frontend/references/design/bugatti.md +268 -0
- package/packages/shared-skills/skills/frontend/references/design/cal.md +259 -0
- package/packages/shared-skills/skills/frontend/references/design/claude.md +312 -0
- package/packages/shared-skills/skills/frontend/references/design/clay.md +304 -0
- package/packages/shared-skills/skills/frontend/references/design/clickhouse.md +281 -0
- package/packages/shared-skills/skills/frontend/references/design/cohere.md +266 -0
- package/packages/shared-skills/skills/frontend/references/design/coinbase.md +129 -0
- package/packages/shared-skills/skills/frontend/references/design/composio.md +307 -0
- package/packages/shared-skills/skills/frontend/references/design/cursor.md +309 -0
- package/packages/shared-skills/skills/frontend/references/design/design-system-architecture.md +217 -0
- package/packages/shared-skills/skills/frontend/references/design/elevenlabs.md +265 -0
- package/packages/shared-skills/skills/frontend/references/design/expo.md +281 -0
- package/packages/shared-skills/skills/frontend/references/design/ferrari.md +314 -0
- package/packages/shared-skills/skills/frontend/references/design/figma.md +220 -0
- package/packages/shared-skills/skills/frontend/references/design/framer.md +246 -0
- package/packages/shared-skills/skills/frontend/references/design/gpt-tasteskill.md +74 -0
- package/packages/shared-skills/skills/frontend/references/design/hashicorp.md +278 -0
- package/packages/shared-skills/skills/frontend/references/design/ibm.md +332 -0
- package/packages/shared-skills/skills/frontend/references/design/image-to-code-skill.md +1228 -0
- package/packages/shared-skills/skills/frontend/references/design/imagegen-brandkit.md +798 -0
- package/packages/shared-skills/skills/frontend/references/design/imagegen-frontend-mobile.md +1465 -0
- package/packages/shared-skills/skills/frontend/references/design/imagegen-frontend-web.md +686 -0
- package/packages/shared-skills/skills/frontend/references/design/intercom.md +146 -0
- package/packages/shared-skills/skills/frontend/references/design/kraken.md +125 -0
- package/packages/shared-skills/skills/frontend/references/design/lamborghini.md +288 -0
- package/packages/shared-skills/skills/frontend/references/design/linear.app.md +367 -0
- package/packages/shared-skills/skills/frontend/references/design/lovable.md +298 -0
- package/packages/shared-skills/skills/frontend/references/design/mastercard.md +365 -0
- package/packages/shared-skills/skills/frontend/references/design/meta.md +366 -0
- package/packages/shared-skills/skills/frontend/references/design/minimalist-skill.md +85 -0
- package/packages/shared-skills/skills/frontend/references/design/minimax.md +257 -0
- package/packages/shared-skills/skills/frontend/references/design/mintlify.md +326 -0
- package/packages/shared-skills/skills/frontend/references/design/miro.md +108 -0
- package/packages/shared-skills/skills/frontend/references/design/mistral.ai.md +261 -0
- package/packages/shared-skills/skills/frontend/references/design/mongodb.md +266 -0
- package/packages/shared-skills/skills/frontend/references/design/nike.md +363 -0
- package/packages/shared-skills/skills/frontend/references/design/notion.md +309 -0
- package/packages/shared-skills/skills/frontend/references/design/nvidia.md +293 -0
- package/packages/shared-skills/skills/frontend/references/design/ollama.md +267 -0
- package/packages/shared-skills/skills/frontend/references/design/opencode.ai.md +281 -0
- package/packages/shared-skills/skills/frontend/references/design/output-skill.md +49 -0
- package/packages/shared-skills/skills/frontend/references/design/pinterest.md +230 -0
- package/packages/shared-skills/skills/frontend/references/design/playstation.md +364 -0
- package/packages/shared-skills/skills/frontend/references/design/posthog.md +256 -0
- package/packages/shared-skills/skills/frontend/references/design/raycast.md +268 -0
- package/packages/shared-skills/skills/frontend/references/design/react-dev-tooling-skill.md +230 -0
- package/packages/shared-skills/skills/frontend/references/design/redesign-skill.md +178 -0
- package/packages/shared-skills/skills/frontend/references/design/renault.md +311 -0
- package/packages/shared-skills/skills/frontend/references/design/replicate.md +261 -0
- package/packages/shared-skills/skills/frontend/references/design/resend.md +303 -0
- package/packages/shared-skills/skills/frontend/references/design/revolut.md +185 -0
- package/packages/shared-skills/skills/frontend/references/design/runwayml.md +244 -0
- package/packages/shared-skills/skills/frontend/references/design/sanity.md +357 -0
- package/packages/shared-skills/skills/frontend/references/design/sentry.md +262 -0
- package/packages/shared-skills/skills/frontend/references/design/shopify.md +350 -0
- package/packages/shared-skills/skills/frontend/references/design/soft-skill.md +98 -0
- package/packages/shared-skills/skills/frontend/references/design/spacex.md +194 -0
- package/packages/shared-skills/skills/frontend/references/design/spotify.md +246 -0
- package/packages/shared-skills/skills/frontend/references/design/starbucks.md +580 -0
- package/packages/shared-skills/skills/frontend/references/design/stitch-skill.md +184 -0
- package/packages/shared-skills/skills/frontend/references/design/stripe.md +322 -0
- package/packages/shared-skills/skills/frontend/references/design/supabase.md +255 -0
- package/packages/shared-skills/skills/frontend/references/design/superhuman.md +252 -0
- package/packages/shared-skills/skills/frontend/references/design/taste-skill.md +226 -0
- package/packages/shared-skills/skills/frontend/references/design/tesla.md +286 -0
- package/packages/shared-skills/skills/frontend/references/design/theverge.md +339 -0
- package/packages/shared-skills/skills/frontend/references/design/together.ai.md +263 -0
- package/packages/shared-skills/skills/frontend/references/design/uber.md +295 -0
- package/packages/shared-skills/skills/frontend/references/design/vercel.md +310 -0
- package/packages/shared-skills/skills/frontend/references/design/vodafone.md +423 -0
- package/packages/shared-skills/skills/frontend/references/design/voltagent.md +323 -0
- package/packages/shared-skills/skills/frontend/references/design/warp.md +253 -0
- package/packages/shared-skills/skills/frontend/references/design/webflow.md +92 -0
- package/packages/shared-skills/skills/frontend/references/design/wired.md +278 -0
- package/packages/shared-skills/skills/frontend/references/design/wise.md +173 -0
- package/packages/shared-skills/skills/frontend/references/design/x.ai.md +257 -0
- package/packages/shared-skills/skills/frontend/references/design/zapier.md +328 -0
- package/packages/shared-skills/skills/frontend/references/perfection/README.md +160 -0
- package/packages/shared-skills/skills/frontend/references/perfection/react-perf-tooling.md +127 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/README.md +273 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/charts.csv +26 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/colors.csv +97 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/icons.csv +101 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/landing.csv +31 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/products.csv +97 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/react-performance.csv +45 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/astro.csv +54 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/flutter.csv +53 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/html-tailwind.csv +56 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/jetpack-compose.csv +53 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/nextjs.csv +53 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/nuxt-ui.csv +51 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/nuxtjs.csv +59 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/react-native.csv +52 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/react.csv +54 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/shadcn.csv +61 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/svelte.csv +54 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/swiftui.csv +51 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/stacks/vue.csv +50 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/styles.csv +68 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/typography.csv +58 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/ui-reasoning.csv +101 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/ux-guidelines.csv +100 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/data/web-interface.csv +31 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/scripts/core.py +253 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/scripts/design_system.py +1067 -0
- package/packages/shared-skills/skills/frontend/references/ui-ux-db/scripts/search.py +114 -0
- package/packages/shared-skills/skills/frontend/scripts/perfection/lighthouse-audit.py +201 -0
- package/packages/shared-skills/skills/init-deep/SKILL.md +1 -1
- package/packages/shared-skills/skills/refactor/SKILL.md +12 -21
- package/packages/shared-skills/skills/review-work/SKILL.md +11 -9
- package/packages/shared-skills/skills/start-work/SKILL.md +5 -4
- package/packages/shared-skills/skills/ultraresearch/SKILL.md +9 -8
- package/packages/shared-skills/skills/ulw-plan/SKILL.md +69 -0
- package/packages/shared-skills/skills/ulw-plan/agents/openai.yaml +7 -0
- package/packages/shared-skills/skills/ulw-plan/references/full-workflow.md +99 -0
- package/packages/shared-skills/skills/ulw-plan/references/intent-clear.md +44 -0
- package/packages/shared-skills/skills/ulw-plan/references/intent-unclear.md +44 -0
- package/packages/shared-skills/skills/ulw-plan/scripts/scaffold-plan.mjs +301 -0
- package/packages/shared-skills/skills/visual-qa/SKILL.md +17 -1
- package/packages/shared-skills/skills/visual-qa/references/agent-browser-setup.md +44 -0
- package/packages/shared-skills/skills/visual-qa/scripts/skill-prompt-contract.test.ts +48 -4
- package/dist/cli/doctor/constants.d.ts +0 -32
- package/dist/cli/doctor/spawn-with-timeout.d.ts +0 -8
- package/dist/cli/doctor/types.d.ts +0 -148
- package/dist/features/builtin-skills/skills/frontend-ui-ux.d.ts +0 -2
- package/dist/mcp/ast-grep.d.ts +0 -11
- package/packages/ast-grep-mcp/dist/cli.js +0 -1159
- package/packages/lsp-tools-mcp/dist/lsp/cleanup-errors.js +0 -6
- package/packages/lsp-tools-mcp/dist/lsp/client-wrapper.js +0 -132
- package/packages/lsp-tools-mcp/dist/lsp/client.js +0 -131
- package/packages/lsp-tools-mcp/dist/lsp/config-loader.js +0 -220
- package/packages/lsp-tools-mcp/dist/lsp/connection.js +0 -66
- package/packages/lsp-tools-mcp/dist/lsp/constants.js +0 -10
- package/packages/lsp-tools-mcp/dist/lsp/directory-diagnostics.js +0 -125
- package/packages/lsp-tools-mcp/dist/lsp/effective-extension.js +0 -8
- package/packages/lsp-tools-mcp/dist/lsp/errors.js +0 -56
- package/packages/lsp-tools-mcp/dist/lsp/formatters.js +0 -106
- package/packages/lsp-tools-mcp/dist/lsp/infer-extension.js +0 -59
- package/packages/lsp-tools-mcp/dist/lsp/json-rpc-connection.js +0 -247
- package/packages/lsp-tools-mcp/dist/lsp/language-mappings.js +0 -170
- package/packages/lsp-tools-mcp/dist/lsp/process-signal-cleanup.js +0 -17
- package/packages/lsp-tools-mcp/dist/lsp/process.js +0 -153
- package/packages/lsp-tools-mcp/dist/lsp/server-definitions.js +0 -170
- package/packages/lsp-tools-mcp/dist/lsp/server-install-state.js +0 -51
- package/packages/lsp-tools-mcp/dist/lsp/server-installation.js +0 -40
- package/packages/lsp-tools-mcp/dist/lsp/server-resolution.js +0 -86
- package/packages/lsp-tools-mcp/dist/lsp/startup-failure.js +0 -35
- package/packages/lsp-tools-mcp/dist/lsp/transport.js +0 -241
- package/packages/lsp-tools-mcp/dist/lsp/types.js +0 -1
- package/packages/lsp-tools-mcp/dist/lsp/workspace-edit.js +0 -175
- package/packages/lsp-tools-mcp/dist/missing-dependency-result.js +0 -14
- package/packages/omo-codex/plugin/components/bootstrap/manifests/ast-grep.json +0 -22
- package/packages/omo-codex/plugin/components/comment-checker/dist/apply-patch.d.ts +0 -7
- package/packages/omo-codex/plugin/components/comment-checker/dist/apply-patch.js +0 -173
- package/packages/omo-codex/plugin/components/comment-checker/dist/codex-hook.d.ts +0 -22
- package/packages/omo-codex/plugin/components/comment-checker/dist/codex-hook.js +0 -165
- package/packages/omo-codex/plugin/components/comment-checker/dist/core-values.d.ts +0 -1
- package/packages/omo-codex/plugin/components/comment-checker/dist/core-values.js +0 -1
- package/packages/omo-codex/plugin/components/comment-checker/dist/core.d.ts +0 -5
- package/packages/omo-codex/plugin/components/comment-checker/dist/core.js +0 -4
- package/packages/omo-codex/plugin/components/comment-checker/dist/hook-input.d.ts +0 -6
- package/packages/omo-codex/plugin/components/comment-checker/dist/hook-input.js +0 -10
- package/packages/omo-codex/plugin/components/comment-checker/dist/record.d.ts +0 -2
- package/packages/omo-codex/plugin/components/comment-checker/dist/record.js +0 -11
- package/packages/omo-codex/plugin/components/comment-checker/dist/request-extractor.d.ts +0 -3
- package/packages/omo-codex/plugin/components/comment-checker/dist/request-extractor.js +0 -104
- package/packages/omo-codex/plugin/components/comment-checker/dist/runner.d.ts +0 -26
- package/packages/omo-codex/plugin/components/comment-checker/dist/runner.js +0 -144
- package/packages/omo-codex/plugin/components/comment-checker/dist/types.d.ts +0 -43
- package/packages/omo-codex/plugin/components/comment-checker/dist/types.js +0 -1
- package/packages/omo-codex/plugin/components/comment-checker/src/record.ts +0 -11
- package/packages/omo-codex/plugin/components/rules/dist/codex-hook-options.d.ts +0 -5
- package/packages/omo-codex/plugin/components/rules/dist/codex-hook-options.js +0 -1
- package/packages/omo-codex/plugin/components/rules/dist/codex-hook.d.ts +0 -47
- package/packages/omo-codex/plugin/components/rules/dist/codex-hook.js +0 -127
- package/packages/omo-codex/plugin/components/rules/dist/config.d.ts +0 -2
- package/packages/omo-codex/plugin/components/rules/dist/config.js +0 -100
- package/packages/omo-codex/plugin/components/rules/dist/context-pressure.d.ts +0 -2
- package/packages/omo-codex/plugin/components/rules/dist/context-pressure.js +0 -26
- package/packages/omo-codex/plugin/components/rules/dist/debug-log.d.ts +0 -8
- package/packages/omo-codex/plugin/components/rules/dist/debug-log.js +0 -36
- package/packages/omo-codex/plugin/components/rules/dist/dynamic-target-fingerprints.d.ts +0 -7
- package/packages/omo-codex/plugin/components/rules/dist/dynamic-target-fingerprints.js +0 -65
- package/packages/omo-codex/plugin/components/rules/dist/event-budget.d.ts +0 -3
- package/packages/omo-codex/plugin/components/rules/dist/event-budget.js +0 -14
- package/packages/omo-codex/plugin/components/rules/dist/hook-output.d.ts +0 -2
- package/packages/omo-codex/plugin/components/rules/dist/hook-output.js +0 -24
- package/packages/omo-codex/plugin/components/rules/dist/path-utils.d.ts +0 -4
- package/packages/omo-codex/plugin/components/rules/dist/path-utils.js +0 -24
- package/packages/omo-codex/plugin/components/rules/dist/persistent-cache.d.ts +0 -13
- package/packages/omo-codex/plugin/components/rules/dist/persistent-cache.js +0 -172
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-budget.d.ts +0 -6
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-budget.js +0 -74
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-claim.d.ts +0 -4
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-claim.js +0 -6
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-directive.d.ts +0 -1
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-directive.js +0 -32
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-state.d.ts +0 -13
- package/packages/omo-codex/plugin/components/rules/dist/post-compact-state.js +0 -29
- package/packages/omo-codex/plugin/components/rules/dist/rules/cache.d.ts +0 -9
- package/packages/omo-codex/plugin/components/rules/dist/rules/cache.js +0 -51
- package/packages/omo-codex/plugin/components/rules/dist/rules/constants.d.ts +0 -70
- package/packages/omo-codex/plugin/components/rules/dist/rules/constants.js +0 -101
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-cache.d.ts +0 -5
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-cache.js +0 -60
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-loader.d.ts +0 -6
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-dynamic-loader.js +0 -61
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-loader.d.ts +0 -7
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-loader.js +0 -60
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-paths.d.ts +0 -11
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-paths.js +0 -75
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-static-loader.d.ts +0 -6
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-static-loader.js +0 -29
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-types.d.ts +0 -44
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine-types.js +0 -1
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine.d.ts +0 -5
- package/packages/omo-codex/plugin/components/rules/dist/rules/engine.js +0 -85
- package/packages/omo-codex/plugin/components/rules/dist/rules/errors.d.ts +0 -6
- package/packages/omo-codex/plugin/components/rules/dist/rules/errors.js +0 -12
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-cache.d.ts +0 -14
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-cache.js +0 -51
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-paths.d.ts +0 -6
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-paths.js +0 -33
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-sources.d.ts +0 -5
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder-sources.js +0 -40
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder.d.ts +0 -28
- package/packages/omo-codex/plugin/components/rules/dist/rules/finder.js +0 -146
- package/packages/omo-codex/plugin/components/rules/dist/rules/formatter.d.ts +0 -7
- package/packages/omo-codex/plugin/components/rules/dist/rules/formatter.js +0 -112
- package/packages/omo-codex/plugin/components/rules/dist/rules/matcher.d.ts +0 -18
- package/packages/omo-codex/plugin/components/rules/dist/rules/matcher.js +0 -93
- package/packages/omo-codex/plugin/components/rules/dist/rules/ordering.d.ts +0 -3
- package/packages/omo-codex/plugin/components/rules/dist/rules/ordering.js +0 -27
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser-frontmatter.d.ts +0 -7
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser-frontmatter.js +0 -30
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser-yaml.d.ts +0 -2
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser-yaml.js +0 -237
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser.d.ts +0 -3
- package/packages/omo-codex/plugin/components/rules/dist/rules/parser.js +0 -31
- package/packages/omo-codex/plugin/components/rules/dist/rules/plugin-root.d.ts +0 -1
- package/packages/omo-codex/plugin/components/rules/dist/rules/plugin-root.js +0 -48
- package/packages/omo-codex/plugin/components/rules/dist/rules/project-root.d.ts +0 -1
- package/packages/omo-codex/plugin/components/rules/dist/rules/project-root.js +0 -23
- package/packages/omo-codex/plugin/components/rules/dist/rules/scanner.d.ts +0 -14
- package/packages/omo-codex/plugin/components/rules/dist/rules/scanner.js +0 -111
- package/packages/omo-codex/plugin/components/rules/dist/rules/sources.d.ts +0 -3
- package/packages/omo-codex/plugin/components/rules/dist/rules/sources.js +0 -9
- package/packages/omo-codex/plugin/components/rules/dist/rules/truncator.d.ts +0 -18
- package/packages/omo-codex/plugin/components/rules/dist/rules/truncator.js +0 -59
- package/packages/omo-codex/plugin/components/rules/dist/rules/types.d.ts +0 -126
- package/packages/omo-codex/plugin/components/rules/dist/rules/types.js +0 -8
- package/packages/omo-codex/plugin/components/rules/dist/rules-engine-factory.d.ts +0 -6
- package/packages/omo-codex/plugin/components/rules/dist/rules-engine-factory.js +0 -20
- package/packages/omo-codex/plugin/components/rules/dist/session-state-lock.d.ts +0 -3
- package/packages/omo-codex/plugin/components/rules/dist/session-state-lock.js +0 -41
- package/packages/omo-codex/plugin/components/rules/dist/sparkshell-awareness.d.ts +0 -10
- package/packages/omo-codex/plugin/components/rules/dist/sparkshell-awareness.js +0 -90
- package/packages/omo-codex/plugin/components/rules/dist/static-injection.d.ts +0 -3
- package/packages/omo-codex/plugin/components/rules/dist/static-injection.js +0 -128
- package/packages/omo-codex/plugin/components/rules/dist/tool-paths.d.ts +0 -6
- package/packages/omo-codex/plugin/components/rules/dist/tool-paths.js +0 -168
- package/packages/omo-codex/plugin/components/rules/dist/transcript-rule-filter.d.ts +0 -4
- package/packages/omo-codex/plugin/components/rules/dist/transcript-rule-filter.js +0 -49
- package/packages/omo-codex/plugin/components/rules/dist/transcript-search.d.ts +0 -4
- package/packages/omo-codex/plugin/components/rules/dist/transcript-search.js +0 -91
- package/packages/omo-codex/plugin/components/rules/src/rules/cache.ts +0 -64
- package/packages/omo-codex/plugin/components/rules/src/rules/constants.ts +0 -122
- package/packages/omo-codex/plugin/components/rules/src/rules/engine-dynamic-cache.ts +0 -87
- package/packages/omo-codex/plugin/components/rules/src/rules/engine-dynamic-loader.ts +0 -94
- package/packages/omo-codex/plugin/components/rules/src/rules/engine-loader.ts +0 -84
- package/packages/omo-codex/plugin/components/rules/src/rules/engine-paths.ts +0 -103
- package/packages/omo-codex/plugin/components/rules/src/rules/engine-static-loader.ts +0 -43
- package/packages/omo-codex/plugin/components/rules/src/rules/engine-types.ts +0 -45
- package/packages/omo-codex/plugin/components/rules/src/rules/engine.ts +0 -123
- package/packages/omo-codex/plugin/components/rules/src/rules/errors.ts +0 -13
- package/packages/omo-codex/plugin/components/rules/src/rules/finder-cache.ts +0 -73
- package/packages/omo-codex/plugin/components/rules/src/rules/finder-paths.ts +0 -47
- package/packages/omo-codex/plugin/components/rules/src/rules/finder-sources.ts +0 -45
- package/packages/omo-codex/plugin/components/rules/src/rules/finder.ts +0 -220
- package/packages/omo-codex/plugin/components/rules/src/rules/formatter.ts +0 -149
- package/packages/omo-codex/plugin/components/rules/src/rules/matcher.ts +0 -142
- package/packages/omo-codex/plugin/components/rules/src/rules/ordering.ts +0 -33
- package/packages/omo-codex/plugin/components/rules/src/rules/parser-frontmatter.ts +0 -39
- package/packages/omo-codex/plugin/components/rules/src/rules/parser-yaml.ts +0 -271
- package/packages/omo-codex/plugin/components/rules/src/rules/parser.ts +0 -35
- package/packages/omo-codex/plugin/components/rules/src/rules/plugin-root.ts +0 -55
- package/packages/omo-codex/plugin/components/rules/src/rules/project-root.ts +0 -30
- package/packages/omo-codex/plugin/components/rules/src/rules/scanner.ts +0 -162
- package/packages/omo-codex/plugin/components/rules/src/rules/sources.ts +0 -13
- package/packages/omo-codex/plugin/components/rules/src/rules/truncator.ts +0 -84
- package/packages/omo-codex/plugin/components/rules/src/rules/types.ts +0 -141
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/boulder-reader.d.ts +0 -16
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/boulder-reader.js +0 -146
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/cli.d.ts +0 -2
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/codex-hook.d.ts +0 -2
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/codex-hook.js +0 -80
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/directive.d.ts +0 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/directive.js +0 -2
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/index.d.ts +0 -5
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/index.js +0 -3
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/types.d.ts +0 -20
- package/packages/omo-codex/plugin/components/start-work-continuation/dist/types.js +0 -1
- package/packages/omo-codex/plugin/components/telemetry/dist/atomic-write.d.ts +0 -1
- package/packages/omo-codex/plugin/components/telemetry/dist/atomic-write.js +0 -18
- package/packages/omo-codex/plugin/components/telemetry/dist/cli.d.ts +0 -2
- package/packages/omo-codex/plugin/components/telemetry/dist/codex-hook.d.ts +0 -15
- package/packages/omo-codex/plugin/components/telemetry/dist/codex-hook.js +0 -42
- package/packages/omo-codex/plugin/components/telemetry/dist/data-path.d.ts +0 -10
- package/packages/omo-codex/plugin/components/telemetry/dist/data-path.js +0 -35
- package/packages/omo-codex/plugin/components/telemetry/dist/diagnostics.d.ts +0 -12
- package/packages/omo-codex/plugin/components/telemetry/dist/diagnostics.js +0 -108
- package/packages/omo-codex/plugin/components/telemetry/dist/env-flags.d.ts +0 -4
- package/packages/omo-codex/plugin/components/telemetry/dist/env-flags.js +0 -31
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog-activity-state.d.ts +0 -8
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog-activity-state.js +0 -68
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.d.ts +0 -21
- package/packages/omo-codex/plugin/components/telemetry/dist/product-identity.d.ts +0 -8
- package/packages/omo-codex/plugin/components/telemetry/dist/product-identity.js +0 -29
- package/packages/omo-codex/plugin/components/telemetry/src/atomic-write.ts +0 -22
- package/packages/omo-codex/plugin/components/telemetry/src/data-path.ts +0 -45
- package/packages/omo-codex/plugin/components/telemetry/src/diagnostics.ts +0 -154
- package/packages/omo-codex/plugin/components/telemetry/src/env-flags.ts +0 -43
- package/packages/omo-codex/plugin/components/telemetry/src/posthog-activity-state.ts +0 -97
- package/packages/omo-codex/plugin/components/ultrawork/agents/codex-ultrawork-reviewer.toml +0 -21
- package/packages/omo-codex/plugin/components/ultrawork/dist/cli.d.ts +0 -2
- package/packages/omo-codex/plugin/components/ultrawork/dist/codex-hook.d.ts +0 -7
- package/packages/omo-codex/plugin/components/ultrawork/dist/codex-hook.js +0 -122
- package/packages/omo-codex/plugin/components/ultrawork/dist/directive.d.ts +0 -1
- package/packages/omo-codex/plugin/components/ultrawork/dist/directive.js +0 -2
- package/packages/omo-codex/plugin/skills/frontend-ui-ux/SKILL.md +0 -77
- package/packages/omo-codex/plugin/test/start-work-skill.test.mjs +0 -85
- package/packages/omo-codex/plugin/test/ulw-plan-skill.test.mjs +0 -89
- package/packages/omo-codex/scripts/atomic-write.test.mjs +0 -82
- package/packages/omo-codex/scripts/install/agent-source-roots.mjs +0 -13
- package/packages/omo-codex/scripts/install/agents.d.mts +0 -18
- package/packages/omo-codex/scripts/install/agents.mjs +0 -227
- package/packages/omo-codex/scripts/install/atomic-write.mjs +0 -59
- package/packages/omo-codex/scripts/install/bin-dir.d.mts +0 -7
- package/packages/omo-codex/scripts/install/bin-dir.mjs +0 -20
- package/packages/omo-codex/scripts/install/bin-links.d.mts +0 -18
- package/packages/omo-codex/scripts/install/bin-links.mjs +0 -276
- package/packages/omo-codex/scripts/install/cache.mjs +0 -295
- package/packages/omo-codex/scripts/install/cached-marketplace-manifest.mjs +0 -21
- package/packages/omo-codex/scripts/install/cli-args.mjs +0 -149
- package/packages/omo-codex/scripts/install/command-shim.mjs +0 -1
- package/packages/omo-codex/scripts/install/config.d.mts +0 -35
- package/packages/omo-codex/scripts/install/config.mjs +0 -267
- package/packages/omo-codex/scripts/install/delegated-command.mjs +0 -29
- package/packages/omo-codex/scripts/install/git-bash-mcp-env.d.mts +0 -5
- package/packages/omo-codex/scripts/install/git-bash-mcp-env.mjs +0 -28
- package/packages/omo-codex/scripts/install/git-bash.d.mts +0 -23
- package/packages/omo-codex/scripts/install/git-bash.mjs +0 -107
- package/packages/omo-codex/scripts/install/git-bash.test.mjs +0 -209
- package/packages/omo-codex/scripts/install/hook-targets.mjs +0 -46
- package/packages/omo-codex/scripts/install/hook-trust.d.mts +0 -10
- package/packages/omo-codex/scripts/install/hook-trust.mjs +0 -84
- package/packages/omo-codex/scripts/install/lazycodex-version-stamp.mjs +0 -102
- package/packages/omo-codex/scripts/install/legacy-bins.mjs +0 -66
- package/packages/omo-codex/scripts/install/marketplace.mjs +0 -104
- package/packages/omo-codex/scripts/install/mcp-runtime-cache.mjs +0 -81
- package/packages/omo-codex/scripts/install/model-catalog.mjs +0 -74
- package/packages/omo-codex/scripts/install/multi-agent-v2-config.mjs +0 -50
- package/packages/omo-codex/scripts/install/permissions.d.mts +0 -1
- package/packages/omo-codex/scripts/install/permissions.mjs +0 -37
- package/packages/omo-codex/scripts/install/process.mjs +0 -22
- package/packages/omo-codex/scripts/install/project-local-cleanup.mjs +0 -228
- package/packages/omo-codex/scripts/install/reasoning-config.mjs +0 -72
- package/packages/omo-codex/scripts/install/snapshot.mjs +0 -53
- package/packages/omo-codex/scripts/install/source-package-build.mjs +0 -20
- package/packages/omo-codex/scripts/install/toml-editor.mjs +0 -64
- package/packages/omo-codex/scripts/install/utils.mjs +0 -15
- package/packages/omo-codex/scripts/sync-telemetry-component.mjs +0 -116
- package/packages/omo-codex/scripts/sync-telemetry-component.test.mjs +0 -94
- package/packages/shared-skills/skills/frontend-ui-ux/SKILL.md +0 -77
- /package/dist/cli/doctor/{doctor-target.d.ts → framework/doctor-target.d.ts} +0 -0
- /package/dist/cli/doctor/{format-default.d.ts → framework/format-default.d.ts} +0 -0
- /package/dist/cli/doctor/{format-shared.d.ts → framework/format-shared.d.ts} +0 -0
- /package/dist/cli/doctor/{format-status.d.ts → framework/format-status.d.ts} +0 -0
- /package/dist/cli/doctor/{format-verbose.d.ts → framework/format-verbose.d.ts} +0 -0
- /package/dist/cli/doctor/{formatter.d.ts → framework/formatter.d.ts} +0 -0
- /package/packages/omo-codex/plugin/components/{comment-checker → codegraph}/dist/cli.d.ts +0 -0
- /package/packages/omo-codex/plugin/components/{rules → lazycodex-executor-verify}/dist/cli.d.ts +0 -0
|
@@ -1,118 +1,4594 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
for (let key of __getOwnPropNames(mod))
|
|
23
|
+
if (!__hasOwnProp.call(to, key))
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
26
|
+
enumerable: true
|
|
27
|
+
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
|
+
|
|
34
|
+
// ../../../node_modules/.bun/picomatch@4.0.4/node_modules/picomatch/lib/constants.js
|
|
35
|
+
var require_constants = __commonJS((exports, module) => {
|
|
36
|
+
var WIN_SLASH = "\\\\/";
|
|
37
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
38
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
39
|
+
var DOT_LITERAL = "\\.";
|
|
40
|
+
var PLUS_LITERAL = "\\+";
|
|
41
|
+
var QMARK_LITERAL = "\\?";
|
|
42
|
+
var SLASH_LITERAL = "\\/";
|
|
43
|
+
var ONE_CHAR = "(?=.)";
|
|
44
|
+
var QMARK = "[^/]";
|
|
45
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
46
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
47
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
48
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
49
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
50
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
51
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
52
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
53
|
+
var STAR = `${QMARK}*?`;
|
|
54
|
+
var SEP = "/";
|
|
55
|
+
var POSIX_CHARS = {
|
|
56
|
+
DOT_LITERAL,
|
|
57
|
+
PLUS_LITERAL,
|
|
58
|
+
QMARK_LITERAL,
|
|
59
|
+
SLASH_LITERAL,
|
|
60
|
+
ONE_CHAR,
|
|
61
|
+
QMARK,
|
|
62
|
+
END_ANCHOR,
|
|
63
|
+
DOTS_SLASH,
|
|
64
|
+
NO_DOT,
|
|
65
|
+
NO_DOTS,
|
|
66
|
+
NO_DOT_SLASH,
|
|
67
|
+
NO_DOTS_SLASH,
|
|
68
|
+
QMARK_NO_DOT,
|
|
69
|
+
STAR,
|
|
70
|
+
START_ANCHOR,
|
|
71
|
+
SEP
|
|
72
|
+
};
|
|
73
|
+
var WINDOWS_CHARS = {
|
|
74
|
+
...POSIX_CHARS,
|
|
75
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
76
|
+
QMARK: WIN_NO_SLASH,
|
|
77
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
78
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
79
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
80
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
81
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
82
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
83
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
84
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
85
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
86
|
+
SEP: "\\"
|
|
87
|
+
};
|
|
88
|
+
var POSIX_REGEX_SOURCE = {
|
|
89
|
+
__proto__: null,
|
|
90
|
+
alnum: "a-zA-Z0-9",
|
|
91
|
+
alpha: "a-zA-Z",
|
|
92
|
+
ascii: "\\x00-\\x7F",
|
|
93
|
+
blank: " \\t",
|
|
94
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
95
|
+
digit: "0-9",
|
|
96
|
+
graph: "\\x21-\\x7E",
|
|
97
|
+
lower: "a-z",
|
|
98
|
+
print: "\\x20-\\x7E ",
|
|
99
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
100
|
+
space: " \\t\\r\\n\\v\\f",
|
|
101
|
+
upper: "A-Z",
|
|
102
|
+
word: "A-Za-z0-9_",
|
|
103
|
+
xdigit: "A-Fa-f0-9"
|
|
104
|
+
};
|
|
105
|
+
module.exports = {
|
|
106
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
107
|
+
MAX_LENGTH: 1024 * 64,
|
|
108
|
+
POSIX_REGEX_SOURCE,
|
|
109
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
110
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
111
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
112
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
113
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
114
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
115
|
+
REPLACEMENTS: {
|
|
116
|
+
__proto__: null,
|
|
117
|
+
"***": "*",
|
|
118
|
+
"**/**": "**",
|
|
119
|
+
"**/**/**": "**"
|
|
120
|
+
},
|
|
121
|
+
CHAR_0: 48,
|
|
122
|
+
CHAR_9: 57,
|
|
123
|
+
CHAR_UPPERCASE_A: 65,
|
|
124
|
+
CHAR_LOWERCASE_A: 97,
|
|
125
|
+
CHAR_UPPERCASE_Z: 90,
|
|
126
|
+
CHAR_LOWERCASE_Z: 122,
|
|
127
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
128
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
129
|
+
CHAR_ASTERISK: 42,
|
|
130
|
+
CHAR_AMPERSAND: 38,
|
|
131
|
+
CHAR_AT: 64,
|
|
132
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
133
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
134
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
135
|
+
CHAR_COLON: 58,
|
|
136
|
+
CHAR_COMMA: 44,
|
|
137
|
+
CHAR_DOT: 46,
|
|
138
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
139
|
+
CHAR_EQUAL: 61,
|
|
140
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
141
|
+
CHAR_FORM_FEED: 12,
|
|
142
|
+
CHAR_FORWARD_SLASH: 47,
|
|
143
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
144
|
+
CHAR_HASH: 35,
|
|
145
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
146
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
147
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
148
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
149
|
+
CHAR_LINE_FEED: 10,
|
|
150
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
151
|
+
CHAR_PERCENT: 37,
|
|
152
|
+
CHAR_PLUS: 43,
|
|
153
|
+
CHAR_QUESTION_MARK: 63,
|
|
154
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
155
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
156
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
157
|
+
CHAR_SEMICOLON: 59,
|
|
158
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
159
|
+
CHAR_SPACE: 32,
|
|
160
|
+
CHAR_TAB: 9,
|
|
161
|
+
CHAR_UNDERSCORE: 95,
|
|
162
|
+
CHAR_VERTICAL_LINE: 124,
|
|
163
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
164
|
+
extglobChars(chars) {
|
|
165
|
+
return {
|
|
166
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
167
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
168
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
169
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
170
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
globChars(win32) {
|
|
174
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// ../../../node_modules/.bun/picomatch@4.0.4/node_modules/picomatch/lib/utils.js
|
|
180
|
+
var require_utils = __commonJS((exports) => {
|
|
181
|
+
var {
|
|
182
|
+
REGEX_BACKSLASH,
|
|
183
|
+
REGEX_REMOVE_BACKSLASH,
|
|
184
|
+
REGEX_SPECIAL_CHARS,
|
|
185
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
186
|
+
} = require_constants();
|
|
187
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
188
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
189
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
190
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
191
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
192
|
+
exports.isWindows = () => {
|
|
193
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
194
|
+
const platform = navigator.platform.toLowerCase();
|
|
195
|
+
return platform === "win32" || platform === "windows";
|
|
196
|
+
}
|
|
197
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
198
|
+
return process.platform === "win32";
|
|
199
|
+
}
|
|
200
|
+
return false;
|
|
201
|
+
};
|
|
202
|
+
exports.removeBackslashes = (str) => {
|
|
203
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
204
|
+
return match === "\\" ? "" : match;
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
208
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
209
|
+
if (idx === -1)
|
|
210
|
+
return input;
|
|
211
|
+
if (input[idx - 1] === "\\")
|
|
212
|
+
return exports.escapeLast(input, char, idx - 1);
|
|
213
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
214
|
+
};
|
|
215
|
+
exports.removePrefix = (input, state = {}) => {
|
|
216
|
+
let output = input;
|
|
217
|
+
if (output.startsWith("./")) {
|
|
218
|
+
output = output.slice(2);
|
|
219
|
+
state.prefix = "./";
|
|
220
|
+
}
|
|
221
|
+
return output;
|
|
222
|
+
};
|
|
223
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
224
|
+
const prepend = options.contains ? "" : "^";
|
|
225
|
+
const append = options.contains ? "" : "$";
|
|
226
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
227
|
+
if (state.negated === true) {
|
|
228
|
+
output = `(?:^(?!${output}).*$)`;
|
|
229
|
+
}
|
|
230
|
+
return output;
|
|
231
|
+
};
|
|
232
|
+
exports.basename = (path, { windows } = {}) => {
|
|
233
|
+
const segs = path.split(windows ? /[\\/]/ : "/");
|
|
234
|
+
const last = segs[segs.length - 1];
|
|
235
|
+
if (last === "") {
|
|
236
|
+
return segs[segs.length - 2];
|
|
237
|
+
}
|
|
238
|
+
return last;
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// ../../../node_modules/.bun/picomatch@4.0.4/node_modules/picomatch/lib/scan.js
|
|
243
|
+
var require_scan = __commonJS((exports, module) => {
|
|
244
|
+
var utils = require_utils();
|
|
245
|
+
var {
|
|
246
|
+
CHAR_ASTERISK,
|
|
247
|
+
CHAR_AT,
|
|
248
|
+
CHAR_BACKWARD_SLASH,
|
|
249
|
+
CHAR_COMMA,
|
|
250
|
+
CHAR_DOT,
|
|
251
|
+
CHAR_EXCLAMATION_MARK,
|
|
252
|
+
CHAR_FORWARD_SLASH,
|
|
253
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
254
|
+
CHAR_LEFT_PARENTHESES,
|
|
255
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
256
|
+
CHAR_PLUS,
|
|
257
|
+
CHAR_QUESTION_MARK,
|
|
258
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
259
|
+
CHAR_RIGHT_PARENTHESES,
|
|
260
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
261
|
+
} = require_constants();
|
|
262
|
+
var isPathSeparator = (code) => {
|
|
263
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
264
|
+
};
|
|
265
|
+
var depth = (token) => {
|
|
266
|
+
if (token.isPrefix !== true) {
|
|
267
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
var scan = (input, options) => {
|
|
271
|
+
const opts = options || {};
|
|
272
|
+
const length = input.length - 1;
|
|
273
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
274
|
+
const slashes = [];
|
|
275
|
+
const tokens = [];
|
|
276
|
+
const parts = [];
|
|
277
|
+
let str = input;
|
|
278
|
+
let index = -1;
|
|
279
|
+
let start = 0;
|
|
280
|
+
let lastIndex = 0;
|
|
281
|
+
let isBrace = false;
|
|
282
|
+
let isBracket = false;
|
|
283
|
+
let isGlob = false;
|
|
284
|
+
let isExtglob = false;
|
|
285
|
+
let isGlobstar = false;
|
|
286
|
+
let braceEscaped = false;
|
|
287
|
+
let backslashes = false;
|
|
288
|
+
let negated = false;
|
|
289
|
+
let negatedExtglob = false;
|
|
290
|
+
let finished = false;
|
|
291
|
+
let braces = 0;
|
|
292
|
+
let prev;
|
|
293
|
+
let code;
|
|
294
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
295
|
+
const eos = () => index >= length;
|
|
296
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
297
|
+
const advance = () => {
|
|
298
|
+
prev = code;
|
|
299
|
+
return str.charCodeAt(++index);
|
|
300
|
+
};
|
|
301
|
+
while (index < length) {
|
|
302
|
+
code = advance();
|
|
303
|
+
let next;
|
|
304
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
305
|
+
backslashes = token.backslashes = true;
|
|
306
|
+
code = advance();
|
|
307
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
308
|
+
braceEscaped = true;
|
|
309
|
+
}
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
313
|
+
braces++;
|
|
314
|
+
while (eos() !== true && (code = advance())) {
|
|
315
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
316
|
+
backslashes = token.backslashes = true;
|
|
317
|
+
advance();
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
321
|
+
braces++;
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
325
|
+
isBrace = token.isBrace = true;
|
|
326
|
+
isGlob = token.isGlob = true;
|
|
327
|
+
finished = true;
|
|
328
|
+
if (scanToEnd === true) {
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
334
|
+
isBrace = token.isBrace = true;
|
|
335
|
+
isGlob = token.isGlob = true;
|
|
336
|
+
finished = true;
|
|
337
|
+
if (scanToEnd === true) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
343
|
+
braces--;
|
|
344
|
+
if (braces === 0) {
|
|
345
|
+
braceEscaped = false;
|
|
346
|
+
isBrace = token.isBrace = true;
|
|
347
|
+
finished = true;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (scanToEnd === true) {
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
358
|
+
slashes.push(index);
|
|
359
|
+
tokens.push(token);
|
|
360
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
361
|
+
if (finished === true)
|
|
362
|
+
continue;
|
|
363
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
364
|
+
start += 2;
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
lastIndex = index + 1;
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
if (opts.noext !== true) {
|
|
371
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
372
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
373
|
+
isGlob = token.isGlob = true;
|
|
374
|
+
isExtglob = token.isExtglob = true;
|
|
375
|
+
finished = true;
|
|
376
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
377
|
+
negatedExtglob = true;
|
|
378
|
+
}
|
|
379
|
+
if (scanToEnd === true) {
|
|
380
|
+
while (eos() !== true && (code = advance())) {
|
|
381
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
382
|
+
backslashes = token.backslashes = true;
|
|
383
|
+
code = advance();
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
387
|
+
isGlob = token.isGlob = true;
|
|
388
|
+
finished = true;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if (code === CHAR_ASTERISK) {
|
|
398
|
+
if (prev === CHAR_ASTERISK)
|
|
399
|
+
isGlobstar = token.isGlobstar = true;
|
|
400
|
+
isGlob = token.isGlob = true;
|
|
401
|
+
finished = true;
|
|
402
|
+
if (scanToEnd === true) {
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
408
|
+
isGlob = token.isGlob = true;
|
|
409
|
+
finished = true;
|
|
410
|
+
if (scanToEnd === true) {
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
416
|
+
while (eos() !== true && (next = advance())) {
|
|
417
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
418
|
+
backslashes = token.backslashes = true;
|
|
419
|
+
advance();
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
423
|
+
isBracket = token.isBracket = true;
|
|
424
|
+
isGlob = token.isGlob = true;
|
|
425
|
+
finished = true;
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (scanToEnd === true) {
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
435
|
+
negated = token.negated = true;
|
|
436
|
+
start++;
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
440
|
+
isGlob = token.isGlob = true;
|
|
441
|
+
if (scanToEnd === true) {
|
|
442
|
+
while (eos() !== true && (code = advance())) {
|
|
443
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
444
|
+
backslashes = token.backslashes = true;
|
|
445
|
+
code = advance();
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
449
|
+
finished = true;
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
if (isGlob === true) {
|
|
458
|
+
finished = true;
|
|
459
|
+
if (scanToEnd === true) {
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (opts.noext === true) {
|
|
466
|
+
isExtglob = false;
|
|
467
|
+
isGlob = false;
|
|
468
|
+
}
|
|
469
|
+
let base = str;
|
|
470
|
+
let prefix = "";
|
|
471
|
+
let glob = "";
|
|
472
|
+
if (start > 0) {
|
|
473
|
+
prefix = str.slice(0, start);
|
|
474
|
+
str = str.slice(start);
|
|
475
|
+
lastIndex -= start;
|
|
476
|
+
}
|
|
477
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
478
|
+
base = str.slice(0, lastIndex);
|
|
479
|
+
glob = str.slice(lastIndex);
|
|
480
|
+
} else if (isGlob === true) {
|
|
481
|
+
base = "";
|
|
482
|
+
glob = str;
|
|
483
|
+
} else {
|
|
484
|
+
base = str;
|
|
485
|
+
}
|
|
486
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
487
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
488
|
+
base = base.slice(0, -1);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (opts.unescape === true) {
|
|
492
|
+
if (glob)
|
|
493
|
+
glob = utils.removeBackslashes(glob);
|
|
494
|
+
if (base && backslashes === true) {
|
|
495
|
+
base = utils.removeBackslashes(base);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
const state = {
|
|
499
|
+
prefix,
|
|
500
|
+
input,
|
|
501
|
+
start,
|
|
502
|
+
base,
|
|
503
|
+
glob,
|
|
504
|
+
isBrace,
|
|
505
|
+
isBracket,
|
|
506
|
+
isGlob,
|
|
507
|
+
isExtglob,
|
|
508
|
+
isGlobstar,
|
|
509
|
+
negated,
|
|
510
|
+
negatedExtglob
|
|
511
|
+
};
|
|
512
|
+
if (opts.tokens === true) {
|
|
513
|
+
state.maxDepth = 0;
|
|
514
|
+
if (!isPathSeparator(code)) {
|
|
515
|
+
tokens.push(token);
|
|
516
|
+
}
|
|
517
|
+
state.tokens = tokens;
|
|
518
|
+
}
|
|
519
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
520
|
+
let prevIndex;
|
|
521
|
+
for (let idx = 0;idx < slashes.length; idx++) {
|
|
522
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
523
|
+
const i = slashes[idx];
|
|
524
|
+
const value = input.slice(n, i);
|
|
525
|
+
if (opts.tokens) {
|
|
526
|
+
if (idx === 0 && start !== 0) {
|
|
527
|
+
tokens[idx].isPrefix = true;
|
|
528
|
+
tokens[idx].value = prefix;
|
|
529
|
+
} else {
|
|
530
|
+
tokens[idx].value = value;
|
|
531
|
+
}
|
|
532
|
+
depth(tokens[idx]);
|
|
533
|
+
state.maxDepth += tokens[idx].depth;
|
|
534
|
+
}
|
|
535
|
+
if (idx !== 0 || value !== "") {
|
|
536
|
+
parts.push(value);
|
|
537
|
+
}
|
|
538
|
+
prevIndex = i;
|
|
539
|
+
}
|
|
540
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
541
|
+
const value = input.slice(prevIndex + 1);
|
|
542
|
+
parts.push(value);
|
|
543
|
+
if (opts.tokens) {
|
|
544
|
+
tokens[tokens.length - 1].value = value;
|
|
545
|
+
depth(tokens[tokens.length - 1]);
|
|
546
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
state.slashes = slashes;
|
|
550
|
+
state.parts = parts;
|
|
551
|
+
}
|
|
552
|
+
return state;
|
|
553
|
+
};
|
|
554
|
+
module.exports = scan;
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
// ../../../node_modules/.bun/picomatch@4.0.4/node_modules/picomatch/lib/parse.js
|
|
558
|
+
var require_parse = __commonJS((exports, module) => {
|
|
559
|
+
var constants = require_constants();
|
|
560
|
+
var utils = require_utils();
|
|
561
|
+
var {
|
|
562
|
+
MAX_LENGTH,
|
|
563
|
+
POSIX_REGEX_SOURCE,
|
|
564
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
565
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
566
|
+
REPLACEMENTS
|
|
567
|
+
} = constants;
|
|
568
|
+
var expandRange = (args, options) => {
|
|
569
|
+
if (typeof options.expandRange === "function") {
|
|
570
|
+
return options.expandRange(...args, options);
|
|
571
|
+
}
|
|
572
|
+
args.sort();
|
|
573
|
+
const value = `[${args.join("-")}]`;
|
|
574
|
+
try {
|
|
575
|
+
new RegExp(value);
|
|
576
|
+
} catch (ex) {
|
|
577
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
578
|
+
}
|
|
579
|
+
return value;
|
|
580
|
+
};
|
|
581
|
+
var syntaxError = (type, char) => {
|
|
582
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
583
|
+
};
|
|
584
|
+
var splitTopLevel = (input) => {
|
|
585
|
+
const parts = [];
|
|
586
|
+
let bracket = 0;
|
|
587
|
+
let paren = 0;
|
|
588
|
+
let quote = 0;
|
|
589
|
+
let value = "";
|
|
590
|
+
let escaped = false;
|
|
591
|
+
for (const ch of input) {
|
|
592
|
+
if (escaped === true) {
|
|
593
|
+
value += ch;
|
|
594
|
+
escaped = false;
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
if (ch === "\\") {
|
|
598
|
+
value += ch;
|
|
599
|
+
escaped = true;
|
|
600
|
+
continue;
|
|
601
|
+
}
|
|
602
|
+
if (ch === '"') {
|
|
603
|
+
quote = quote === 1 ? 0 : 1;
|
|
604
|
+
value += ch;
|
|
605
|
+
continue;
|
|
606
|
+
}
|
|
607
|
+
if (quote === 0) {
|
|
608
|
+
if (ch === "[") {
|
|
609
|
+
bracket++;
|
|
610
|
+
} else if (ch === "]" && bracket > 0) {
|
|
611
|
+
bracket--;
|
|
612
|
+
} else if (bracket === 0) {
|
|
613
|
+
if (ch === "(") {
|
|
614
|
+
paren++;
|
|
615
|
+
} else if (ch === ")" && paren > 0) {
|
|
616
|
+
paren--;
|
|
617
|
+
} else if (ch === "|" && paren === 0) {
|
|
618
|
+
parts.push(value);
|
|
619
|
+
value = "";
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
value += ch;
|
|
625
|
+
}
|
|
626
|
+
parts.push(value);
|
|
627
|
+
return parts;
|
|
628
|
+
};
|
|
629
|
+
var isPlainBranch = (branch) => {
|
|
630
|
+
let escaped = false;
|
|
631
|
+
for (const ch of branch) {
|
|
632
|
+
if (escaped === true) {
|
|
633
|
+
escaped = false;
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
if (ch === "\\") {
|
|
637
|
+
escaped = true;
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
641
|
+
return false;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return true;
|
|
645
|
+
};
|
|
646
|
+
var normalizeSimpleBranch = (branch) => {
|
|
647
|
+
let value = branch.trim();
|
|
648
|
+
let changed = true;
|
|
649
|
+
while (changed === true) {
|
|
650
|
+
changed = false;
|
|
651
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
652
|
+
value = value.slice(2, -1);
|
|
653
|
+
changed = true;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
if (!isPlainBranch(value)) {
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
return value.replace(/\\(.)/g, "$1");
|
|
660
|
+
};
|
|
661
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
662
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
663
|
+
for (let i = 0;i < values.length; i++) {
|
|
664
|
+
for (let j = i + 1;j < values.length; j++) {
|
|
665
|
+
const a = values[i];
|
|
666
|
+
const b = values[j];
|
|
667
|
+
const char = a[0];
|
|
668
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
672
|
+
return true;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
return false;
|
|
677
|
+
};
|
|
678
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
679
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
let bracket = 0;
|
|
683
|
+
let paren = 0;
|
|
684
|
+
let quote = 0;
|
|
685
|
+
let escaped = false;
|
|
686
|
+
for (let i = 1;i < pattern.length; i++) {
|
|
687
|
+
const ch = pattern[i];
|
|
688
|
+
if (escaped === true) {
|
|
689
|
+
escaped = false;
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
if (ch === "\\") {
|
|
693
|
+
escaped = true;
|
|
694
|
+
continue;
|
|
695
|
+
}
|
|
696
|
+
if (ch === '"') {
|
|
697
|
+
quote = quote === 1 ? 0 : 1;
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
if (quote === 1) {
|
|
701
|
+
continue;
|
|
702
|
+
}
|
|
703
|
+
if (ch === "[") {
|
|
704
|
+
bracket++;
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
if (ch === "]" && bracket > 0) {
|
|
708
|
+
bracket--;
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
if (bracket > 0) {
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
if (ch === "(") {
|
|
715
|
+
paren++;
|
|
716
|
+
continue;
|
|
717
|
+
}
|
|
718
|
+
if (ch === ")") {
|
|
719
|
+
paren--;
|
|
720
|
+
if (paren === 0) {
|
|
721
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
return {
|
|
725
|
+
type: pattern[0],
|
|
726
|
+
body: pattern.slice(2, i),
|
|
727
|
+
end: i
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
var getStarExtglobSequenceOutput = (pattern) => {
|
|
734
|
+
let index = 0;
|
|
735
|
+
const chars = [];
|
|
736
|
+
while (index < pattern.length) {
|
|
737
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
738
|
+
if (!match || match.type !== "*") {
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
742
|
+
if (branches.length !== 1) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
746
|
+
if (!branch || branch.length !== 1) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
chars.push(branch);
|
|
750
|
+
index += match.end + 1;
|
|
751
|
+
}
|
|
752
|
+
if (chars.length < 1) {
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
756
|
+
return `${source}*`;
|
|
757
|
+
};
|
|
758
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
759
|
+
let depth = 0;
|
|
760
|
+
let value = pattern.trim();
|
|
761
|
+
let match = parseRepeatedExtglob(value);
|
|
762
|
+
while (match) {
|
|
763
|
+
depth++;
|
|
764
|
+
value = match.body.trim();
|
|
765
|
+
match = parseRepeatedExtglob(value);
|
|
766
|
+
}
|
|
767
|
+
return depth;
|
|
768
|
+
};
|
|
769
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
770
|
+
if (options.maxExtglobRecursion === false) {
|
|
771
|
+
return { risky: false };
|
|
772
|
+
}
|
|
773
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
774
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
775
|
+
if (branches.length > 1) {
|
|
776
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
777
|
+
return { risky: true };
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
for (const branch of branches) {
|
|
781
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
782
|
+
if (safeOutput) {
|
|
783
|
+
return { risky: true, safeOutput };
|
|
784
|
+
}
|
|
785
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
786
|
+
return { risky: true };
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return { risky: false };
|
|
790
|
+
};
|
|
791
|
+
var parse = (input, options) => {
|
|
792
|
+
if (typeof input !== "string") {
|
|
793
|
+
throw new TypeError("Expected a string");
|
|
794
|
+
}
|
|
795
|
+
input = REPLACEMENTS[input] || input;
|
|
796
|
+
const opts = { ...options };
|
|
797
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
798
|
+
let len = input.length;
|
|
799
|
+
if (len > max) {
|
|
800
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
801
|
+
}
|
|
802
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
803
|
+
const tokens = [bos];
|
|
804
|
+
const capture = opts.capture ? "" : "?:";
|
|
805
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
806
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
807
|
+
const {
|
|
808
|
+
DOT_LITERAL,
|
|
809
|
+
PLUS_LITERAL,
|
|
810
|
+
SLASH_LITERAL,
|
|
811
|
+
ONE_CHAR,
|
|
812
|
+
DOTS_SLASH,
|
|
813
|
+
NO_DOT,
|
|
814
|
+
NO_DOT_SLASH,
|
|
815
|
+
NO_DOTS_SLASH,
|
|
816
|
+
QMARK,
|
|
817
|
+
QMARK_NO_DOT,
|
|
818
|
+
STAR,
|
|
819
|
+
START_ANCHOR
|
|
820
|
+
} = PLATFORM_CHARS;
|
|
821
|
+
const globstar = (opts2) => {
|
|
822
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
823
|
+
};
|
|
824
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
825
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
826
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
827
|
+
if (opts.capture) {
|
|
828
|
+
star = `(${star})`;
|
|
829
|
+
}
|
|
830
|
+
if (typeof opts.noext === "boolean") {
|
|
831
|
+
opts.noextglob = opts.noext;
|
|
832
|
+
}
|
|
833
|
+
const state = {
|
|
834
|
+
input,
|
|
835
|
+
index: -1,
|
|
836
|
+
start: 0,
|
|
837
|
+
dot: opts.dot === true,
|
|
838
|
+
consumed: "",
|
|
839
|
+
output: "",
|
|
840
|
+
prefix: "",
|
|
841
|
+
backtrack: false,
|
|
842
|
+
negated: false,
|
|
843
|
+
brackets: 0,
|
|
844
|
+
braces: 0,
|
|
845
|
+
parens: 0,
|
|
846
|
+
quotes: 0,
|
|
847
|
+
globstar: false,
|
|
848
|
+
tokens
|
|
849
|
+
};
|
|
850
|
+
input = utils.removePrefix(input, state);
|
|
851
|
+
len = input.length;
|
|
852
|
+
const extglobs = [];
|
|
853
|
+
const braces = [];
|
|
854
|
+
const stack = [];
|
|
855
|
+
let prev = bos;
|
|
856
|
+
let value;
|
|
857
|
+
const eos = () => state.index === len - 1;
|
|
858
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
859
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
860
|
+
const remaining = () => input.slice(state.index + 1);
|
|
861
|
+
const consume = (value2 = "", num = 0) => {
|
|
862
|
+
state.consumed += value2;
|
|
863
|
+
state.index += num;
|
|
864
|
+
};
|
|
865
|
+
const append = (token) => {
|
|
866
|
+
state.output += token.output != null ? token.output : token.value;
|
|
867
|
+
consume(token.value);
|
|
868
|
+
};
|
|
869
|
+
const negate = () => {
|
|
870
|
+
let count = 1;
|
|
871
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
872
|
+
advance();
|
|
873
|
+
state.start++;
|
|
874
|
+
count++;
|
|
875
|
+
}
|
|
876
|
+
if (count % 2 === 0) {
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
state.negated = true;
|
|
880
|
+
state.start++;
|
|
881
|
+
return true;
|
|
882
|
+
};
|
|
883
|
+
const increment = (type) => {
|
|
884
|
+
state[type]++;
|
|
885
|
+
stack.push(type);
|
|
886
|
+
};
|
|
887
|
+
const decrement = (type) => {
|
|
888
|
+
state[type]--;
|
|
889
|
+
stack.pop();
|
|
890
|
+
};
|
|
891
|
+
const push = (tok) => {
|
|
892
|
+
if (prev.type === "globstar") {
|
|
893
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
894
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
895
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
896
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
897
|
+
prev.type = "star";
|
|
898
|
+
prev.value = "*";
|
|
899
|
+
prev.output = star;
|
|
900
|
+
state.output += prev.output;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
904
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
905
|
+
}
|
|
906
|
+
if (tok.value || tok.output)
|
|
907
|
+
append(tok);
|
|
908
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
909
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
910
|
+
prev.value += tok.value;
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
tok.prev = prev;
|
|
914
|
+
tokens.push(tok);
|
|
915
|
+
prev = tok;
|
|
916
|
+
};
|
|
917
|
+
const extglobOpen = (type, value2) => {
|
|
918
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
919
|
+
token.prev = prev;
|
|
920
|
+
token.parens = state.parens;
|
|
921
|
+
token.output = state.output;
|
|
922
|
+
token.startIndex = state.index;
|
|
923
|
+
token.tokensIndex = tokens.length;
|
|
924
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
925
|
+
increment("parens");
|
|
926
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
927
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
928
|
+
extglobs.push(token);
|
|
929
|
+
};
|
|
930
|
+
const extglobClose = (token) => {
|
|
931
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
932
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
933
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
934
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
935
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : undefined;
|
|
936
|
+
const open = tokens[token.tokensIndex];
|
|
937
|
+
open.type = "text";
|
|
938
|
+
open.value = literal;
|
|
939
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
940
|
+
for (let i = token.tokensIndex + 1;i < tokens.length; i++) {
|
|
941
|
+
tokens[i].value = "";
|
|
942
|
+
tokens[i].output = "";
|
|
943
|
+
delete tokens[i].suffix;
|
|
944
|
+
}
|
|
945
|
+
state.output = token.output + open.output;
|
|
946
|
+
state.backtrack = true;
|
|
947
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
948
|
+
decrement("parens");
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
952
|
+
let rest;
|
|
953
|
+
if (token.type === "negate") {
|
|
954
|
+
let extglobStar = star;
|
|
955
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
956
|
+
extglobStar = globstar(opts);
|
|
957
|
+
}
|
|
958
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
959
|
+
output = token.close = `)$))${extglobStar}`;
|
|
960
|
+
}
|
|
961
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
962
|
+
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
963
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
964
|
+
}
|
|
965
|
+
if (token.prev.type === "bos") {
|
|
966
|
+
state.negatedExtglob = true;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
push({ type: "paren", extglob: true, value, output });
|
|
970
|
+
decrement("parens");
|
|
971
|
+
};
|
|
972
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
973
|
+
let backslashes = false;
|
|
974
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
975
|
+
if (first === "\\") {
|
|
976
|
+
backslashes = true;
|
|
977
|
+
return m;
|
|
978
|
+
}
|
|
979
|
+
if (first === "?") {
|
|
980
|
+
if (esc) {
|
|
981
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
982
|
+
}
|
|
983
|
+
if (index === 0) {
|
|
984
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
985
|
+
}
|
|
986
|
+
return QMARK.repeat(chars.length);
|
|
987
|
+
}
|
|
988
|
+
if (first === ".") {
|
|
989
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
990
|
+
}
|
|
991
|
+
if (first === "*") {
|
|
992
|
+
if (esc) {
|
|
993
|
+
return esc + first + (rest ? star : "");
|
|
994
|
+
}
|
|
995
|
+
return star;
|
|
996
|
+
}
|
|
997
|
+
return esc ? m : `\\${m}`;
|
|
998
|
+
});
|
|
999
|
+
if (backslashes === true) {
|
|
1000
|
+
if (opts.unescape === true) {
|
|
1001
|
+
output = output.replace(/\\/g, "");
|
|
1002
|
+
} else {
|
|
1003
|
+
output = output.replace(/\\+/g, (m) => {
|
|
1004
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
if (output === input && opts.contains === true) {
|
|
1009
|
+
state.output = input;
|
|
1010
|
+
return state;
|
|
1011
|
+
}
|
|
1012
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
1013
|
+
return state;
|
|
1014
|
+
}
|
|
1015
|
+
while (!eos()) {
|
|
1016
|
+
value = advance();
|
|
1017
|
+
if (value === "\x00") {
|
|
1018
|
+
continue;
|
|
1019
|
+
}
|
|
1020
|
+
if (value === "\\") {
|
|
1021
|
+
const next = peek();
|
|
1022
|
+
if (next === "/" && opts.bash !== true) {
|
|
1023
|
+
continue;
|
|
1024
|
+
}
|
|
1025
|
+
if (next === "." || next === ";") {
|
|
1026
|
+
continue;
|
|
1027
|
+
}
|
|
1028
|
+
if (!next) {
|
|
1029
|
+
value += "\\";
|
|
1030
|
+
push({ type: "text", value });
|
|
1031
|
+
continue;
|
|
1032
|
+
}
|
|
1033
|
+
const match = /^\\+/.exec(remaining());
|
|
1034
|
+
let slashes = 0;
|
|
1035
|
+
if (match && match[0].length > 2) {
|
|
1036
|
+
slashes = match[0].length;
|
|
1037
|
+
state.index += slashes;
|
|
1038
|
+
if (slashes % 2 !== 0) {
|
|
1039
|
+
value += "\\";
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
if (opts.unescape === true) {
|
|
1043
|
+
value = advance();
|
|
1044
|
+
} else {
|
|
1045
|
+
value += advance();
|
|
1046
|
+
}
|
|
1047
|
+
if (state.brackets === 0) {
|
|
1048
|
+
push({ type: "text", value });
|
|
1049
|
+
continue;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1053
|
+
if (opts.posix !== false && value === ":") {
|
|
1054
|
+
const inner = prev.value.slice(1);
|
|
1055
|
+
if (inner.includes("[")) {
|
|
1056
|
+
prev.posix = true;
|
|
1057
|
+
if (inner.includes(":")) {
|
|
1058
|
+
const idx = prev.value.lastIndexOf("[");
|
|
1059
|
+
const pre = prev.value.slice(0, idx);
|
|
1060
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
1061
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
1062
|
+
if (posix) {
|
|
1063
|
+
prev.value = pre + posix;
|
|
1064
|
+
state.backtrack = true;
|
|
1065
|
+
advance();
|
|
1066
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
1067
|
+
bos.output = ONE_CHAR;
|
|
1068
|
+
}
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
1075
|
+
value = `\\${value}`;
|
|
1076
|
+
}
|
|
1077
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
1078
|
+
value = `\\${value}`;
|
|
1079
|
+
}
|
|
1080
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
1081
|
+
value = "^";
|
|
1082
|
+
}
|
|
1083
|
+
prev.value += value;
|
|
1084
|
+
append({ value });
|
|
1085
|
+
continue;
|
|
1086
|
+
}
|
|
1087
|
+
if (state.quotes === 1 && value !== '"') {
|
|
1088
|
+
value = utils.escapeRegex(value);
|
|
1089
|
+
prev.value += value;
|
|
1090
|
+
append({ value });
|
|
1091
|
+
continue;
|
|
1092
|
+
}
|
|
1093
|
+
if (value === '"') {
|
|
1094
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1095
|
+
if (opts.keepQuotes === true) {
|
|
1096
|
+
push({ type: "text", value });
|
|
1097
|
+
}
|
|
1098
|
+
continue;
|
|
1099
|
+
}
|
|
1100
|
+
if (value === "(") {
|
|
1101
|
+
increment("parens");
|
|
1102
|
+
push({ type: "paren", value });
|
|
1103
|
+
continue;
|
|
1104
|
+
}
|
|
1105
|
+
if (value === ")") {
|
|
1106
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
1107
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
1108
|
+
}
|
|
1109
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
1110
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1111
|
+
extglobClose(extglobs.pop());
|
|
1112
|
+
continue;
|
|
1113
|
+
}
|
|
1114
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
1115
|
+
decrement("parens");
|
|
1116
|
+
continue;
|
|
1117
|
+
}
|
|
1118
|
+
if (value === "[") {
|
|
1119
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1120
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
1121
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1122
|
+
}
|
|
1123
|
+
value = `\\${value}`;
|
|
1124
|
+
} else {
|
|
1125
|
+
increment("brackets");
|
|
1126
|
+
}
|
|
1127
|
+
push({ type: "bracket", value });
|
|
1128
|
+
continue;
|
|
1129
|
+
}
|
|
1130
|
+
if (value === "]") {
|
|
1131
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1132
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1133
|
+
continue;
|
|
1134
|
+
}
|
|
1135
|
+
if (state.brackets === 0) {
|
|
1136
|
+
if (opts.strictBrackets === true) {
|
|
1137
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
1138
|
+
}
|
|
1139
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1140
|
+
continue;
|
|
1141
|
+
}
|
|
1142
|
+
decrement("brackets");
|
|
1143
|
+
const prevValue = prev.value.slice(1);
|
|
1144
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
1145
|
+
value = `/${value}`;
|
|
1146
|
+
}
|
|
1147
|
+
prev.value += value;
|
|
1148
|
+
append({ value });
|
|
1149
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
1150
|
+
continue;
|
|
1151
|
+
}
|
|
1152
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
1153
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1154
|
+
if (opts.literalBrackets === true) {
|
|
1155
|
+
state.output += escaped;
|
|
1156
|
+
prev.value = escaped;
|
|
1157
|
+
continue;
|
|
1158
|
+
}
|
|
1159
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1160
|
+
state.output += prev.value;
|
|
1161
|
+
continue;
|
|
1162
|
+
}
|
|
1163
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1164
|
+
increment("braces");
|
|
1165
|
+
const open = {
|
|
1166
|
+
type: "brace",
|
|
1167
|
+
value,
|
|
1168
|
+
output: "(",
|
|
1169
|
+
outputIndex: state.output.length,
|
|
1170
|
+
tokensIndex: state.tokens.length
|
|
1171
|
+
};
|
|
1172
|
+
braces.push(open);
|
|
1173
|
+
push(open);
|
|
1174
|
+
continue;
|
|
1175
|
+
}
|
|
1176
|
+
if (value === "}") {
|
|
1177
|
+
const brace = braces[braces.length - 1];
|
|
1178
|
+
if (opts.nobrace === true || !brace) {
|
|
1179
|
+
push({ type: "text", value, output: value });
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
let output = ")";
|
|
1183
|
+
if (brace.dots === true) {
|
|
1184
|
+
const arr = tokens.slice();
|
|
1185
|
+
const range = [];
|
|
1186
|
+
for (let i = arr.length - 1;i >= 0; i--) {
|
|
1187
|
+
tokens.pop();
|
|
1188
|
+
if (arr[i].type === "brace") {
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
if (arr[i].type !== "dots") {
|
|
1192
|
+
range.unshift(arr[i].value);
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
output = expandRange(range, opts);
|
|
1196
|
+
state.backtrack = true;
|
|
1197
|
+
}
|
|
1198
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1199
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1200
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1201
|
+
brace.value = brace.output = "\\{";
|
|
1202
|
+
value = output = "\\}";
|
|
1203
|
+
state.output = out;
|
|
1204
|
+
for (const t of toks) {
|
|
1205
|
+
state.output += t.output || t.value;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
push({ type: "brace", value, output });
|
|
1209
|
+
decrement("braces");
|
|
1210
|
+
braces.pop();
|
|
1211
|
+
continue;
|
|
1212
|
+
}
|
|
1213
|
+
if (value === "|") {
|
|
1214
|
+
if (extglobs.length > 0) {
|
|
1215
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
1216
|
+
}
|
|
1217
|
+
push({ type: "text", value });
|
|
1218
|
+
continue;
|
|
1219
|
+
}
|
|
1220
|
+
if (value === ",") {
|
|
1221
|
+
let output = value;
|
|
1222
|
+
const brace = braces[braces.length - 1];
|
|
1223
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1224
|
+
brace.comma = true;
|
|
1225
|
+
output = "|";
|
|
1226
|
+
}
|
|
1227
|
+
push({ type: "comma", value, output });
|
|
1228
|
+
continue;
|
|
1229
|
+
}
|
|
1230
|
+
if (value === "/") {
|
|
1231
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1232
|
+
state.start = state.index + 1;
|
|
1233
|
+
state.consumed = "";
|
|
1234
|
+
state.output = "";
|
|
1235
|
+
tokens.pop();
|
|
1236
|
+
prev = bos;
|
|
1237
|
+
continue;
|
|
1238
|
+
}
|
|
1239
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
1240
|
+
continue;
|
|
1241
|
+
}
|
|
1242
|
+
if (value === ".") {
|
|
1243
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1244
|
+
if (prev.value === ".")
|
|
1245
|
+
prev.output = DOT_LITERAL;
|
|
1246
|
+
const brace = braces[braces.length - 1];
|
|
1247
|
+
prev.type = "dots";
|
|
1248
|
+
prev.output += value;
|
|
1249
|
+
prev.value += value;
|
|
1250
|
+
brace.dots = true;
|
|
1251
|
+
continue;
|
|
1252
|
+
}
|
|
1253
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1254
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
1255
|
+
continue;
|
|
1256
|
+
}
|
|
1257
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
if (value === "?") {
|
|
1261
|
+
const isGroup = prev && prev.value === "(";
|
|
1262
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1263
|
+
extglobOpen("qmark", value);
|
|
1264
|
+
continue;
|
|
1265
|
+
}
|
|
1266
|
+
if (prev && prev.type === "paren") {
|
|
1267
|
+
const next = peek();
|
|
1268
|
+
let output = value;
|
|
1269
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
1270
|
+
output = `\\${value}`;
|
|
1271
|
+
}
|
|
1272
|
+
push({ type: "text", value, output });
|
|
1273
|
+
continue;
|
|
1274
|
+
}
|
|
1275
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1276
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
1277
|
+
continue;
|
|
1278
|
+
}
|
|
1279
|
+
push({ type: "qmark", value, output: QMARK });
|
|
1280
|
+
continue;
|
|
1281
|
+
}
|
|
1282
|
+
if (value === "!") {
|
|
1283
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1284
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1285
|
+
extglobOpen("negate", value);
|
|
1286
|
+
continue;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1290
|
+
negate();
|
|
1291
|
+
continue;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
if (value === "+") {
|
|
1295
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1296
|
+
extglobOpen("plus", value);
|
|
1297
|
+
continue;
|
|
1298
|
+
}
|
|
1299
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1300
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1301
|
+
continue;
|
|
1302
|
+
}
|
|
1303
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1304
|
+
push({ type: "plus", value });
|
|
1305
|
+
continue;
|
|
1306
|
+
}
|
|
1307
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
1308
|
+
continue;
|
|
1309
|
+
}
|
|
1310
|
+
if (value === "@") {
|
|
1311
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1312
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
1313
|
+
continue;
|
|
1314
|
+
}
|
|
1315
|
+
push({ type: "text", value });
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
if (value !== "*") {
|
|
1319
|
+
if (value === "$" || value === "^") {
|
|
1320
|
+
value = `\\${value}`;
|
|
1321
|
+
}
|
|
1322
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1323
|
+
if (match) {
|
|
1324
|
+
value += match[0];
|
|
1325
|
+
state.index += match[0].length;
|
|
1326
|
+
}
|
|
1327
|
+
push({ type: "text", value });
|
|
1328
|
+
continue;
|
|
1329
|
+
}
|
|
1330
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1331
|
+
prev.type = "star";
|
|
1332
|
+
prev.star = true;
|
|
1333
|
+
prev.value += value;
|
|
1334
|
+
prev.output = star;
|
|
1335
|
+
state.backtrack = true;
|
|
1336
|
+
state.globstar = true;
|
|
1337
|
+
consume(value);
|
|
1338
|
+
continue;
|
|
1339
|
+
}
|
|
1340
|
+
let rest = remaining();
|
|
1341
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1342
|
+
extglobOpen("star", value);
|
|
1343
|
+
continue;
|
|
1344
|
+
}
|
|
1345
|
+
if (prev.type === "star") {
|
|
1346
|
+
if (opts.noglobstar === true) {
|
|
1347
|
+
consume(value);
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1350
|
+
const prior = prev.prev;
|
|
1351
|
+
const before = prior.prev;
|
|
1352
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1353
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1354
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1355
|
+
push({ type: "star", value, output: "" });
|
|
1356
|
+
continue;
|
|
1357
|
+
}
|
|
1358
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1359
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1360
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1361
|
+
push({ type: "star", value, output: "" });
|
|
1362
|
+
continue;
|
|
1363
|
+
}
|
|
1364
|
+
while (rest.slice(0, 3) === "/**") {
|
|
1365
|
+
const after = input[state.index + 4];
|
|
1366
|
+
if (after && after !== "/") {
|
|
1367
|
+
break;
|
|
1368
|
+
}
|
|
1369
|
+
rest = rest.slice(3);
|
|
1370
|
+
consume("/**", 3);
|
|
1371
|
+
}
|
|
1372
|
+
if (prior.type === "bos" && eos()) {
|
|
1373
|
+
prev.type = "globstar";
|
|
1374
|
+
prev.value += value;
|
|
1375
|
+
prev.output = globstar(opts);
|
|
1376
|
+
state.output = prev.output;
|
|
1377
|
+
state.globstar = true;
|
|
1378
|
+
consume(value);
|
|
1379
|
+
continue;
|
|
1380
|
+
}
|
|
1381
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1382
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1383
|
+
prior.output = `(?:${prior.output}`;
|
|
1384
|
+
prev.type = "globstar";
|
|
1385
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1386
|
+
prev.value += value;
|
|
1387
|
+
state.globstar = true;
|
|
1388
|
+
state.output += prior.output + prev.output;
|
|
1389
|
+
consume(value);
|
|
1390
|
+
continue;
|
|
1391
|
+
}
|
|
1392
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1393
|
+
const end = rest[1] !== undefined ? "|$" : "";
|
|
1394
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1395
|
+
prior.output = `(?:${prior.output}`;
|
|
1396
|
+
prev.type = "globstar";
|
|
1397
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1398
|
+
prev.value += value;
|
|
1399
|
+
state.output += prior.output + prev.output;
|
|
1400
|
+
state.globstar = true;
|
|
1401
|
+
consume(value + advance());
|
|
1402
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1403
|
+
continue;
|
|
1404
|
+
}
|
|
1405
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
1406
|
+
prev.type = "globstar";
|
|
1407
|
+
prev.value += value;
|
|
1408
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1409
|
+
state.output = prev.output;
|
|
1410
|
+
state.globstar = true;
|
|
1411
|
+
consume(value + advance());
|
|
1412
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1413
|
+
continue;
|
|
1414
|
+
}
|
|
1415
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1416
|
+
prev.type = "globstar";
|
|
1417
|
+
prev.output = globstar(opts);
|
|
1418
|
+
prev.value += value;
|
|
1419
|
+
state.output += prev.output;
|
|
1420
|
+
state.globstar = true;
|
|
1421
|
+
consume(value);
|
|
1422
|
+
continue;
|
|
1423
|
+
}
|
|
1424
|
+
const token = { type: "star", value, output: star };
|
|
1425
|
+
if (opts.bash === true) {
|
|
1426
|
+
token.output = ".*?";
|
|
1427
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
1428
|
+
token.output = nodot + token.output;
|
|
1429
|
+
}
|
|
1430
|
+
push(token);
|
|
1431
|
+
continue;
|
|
1432
|
+
}
|
|
1433
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1434
|
+
token.output = value;
|
|
1435
|
+
push(token);
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1439
|
+
if (prev.type === "dot") {
|
|
1440
|
+
state.output += NO_DOT_SLASH;
|
|
1441
|
+
prev.output += NO_DOT_SLASH;
|
|
1442
|
+
} else if (opts.dot === true) {
|
|
1443
|
+
state.output += NO_DOTS_SLASH;
|
|
1444
|
+
prev.output += NO_DOTS_SLASH;
|
|
1445
|
+
} else {
|
|
1446
|
+
state.output += nodot;
|
|
1447
|
+
prev.output += nodot;
|
|
1448
|
+
}
|
|
1449
|
+
if (peek() !== "*") {
|
|
1450
|
+
state.output += ONE_CHAR;
|
|
1451
|
+
prev.output += ONE_CHAR;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
push(token);
|
|
1455
|
+
}
|
|
1456
|
+
while (state.brackets > 0) {
|
|
1457
|
+
if (opts.strictBrackets === true)
|
|
1458
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1459
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
1460
|
+
decrement("brackets");
|
|
1461
|
+
}
|
|
1462
|
+
while (state.parens > 0) {
|
|
1463
|
+
if (opts.strictBrackets === true)
|
|
1464
|
+
throw new SyntaxError(syntaxError("closing", ")"));
|
|
1465
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
1466
|
+
decrement("parens");
|
|
1467
|
+
}
|
|
1468
|
+
while (state.braces > 0) {
|
|
1469
|
+
if (opts.strictBrackets === true)
|
|
1470
|
+
throw new SyntaxError(syntaxError("closing", "}"));
|
|
1471
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
1472
|
+
decrement("braces");
|
|
1473
|
+
}
|
|
1474
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1475
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1476
|
+
}
|
|
1477
|
+
if (state.backtrack === true) {
|
|
1478
|
+
state.output = "";
|
|
1479
|
+
for (const token of state.tokens) {
|
|
1480
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1481
|
+
if (token.suffix) {
|
|
1482
|
+
state.output += token.suffix;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
return state;
|
|
1487
|
+
};
|
|
1488
|
+
parse.fastpaths = (input, options) => {
|
|
1489
|
+
const opts = { ...options };
|
|
1490
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1491
|
+
const len = input.length;
|
|
1492
|
+
if (len > max) {
|
|
1493
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1494
|
+
}
|
|
1495
|
+
input = REPLACEMENTS[input] || input;
|
|
1496
|
+
const {
|
|
1497
|
+
DOT_LITERAL,
|
|
1498
|
+
SLASH_LITERAL,
|
|
1499
|
+
ONE_CHAR,
|
|
1500
|
+
DOTS_SLASH,
|
|
1501
|
+
NO_DOT,
|
|
1502
|
+
NO_DOTS,
|
|
1503
|
+
NO_DOTS_SLASH,
|
|
1504
|
+
STAR,
|
|
1505
|
+
START_ANCHOR
|
|
1506
|
+
} = constants.globChars(opts.windows);
|
|
1507
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1508
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1509
|
+
const capture = opts.capture ? "" : "?:";
|
|
1510
|
+
const state = { negated: false, prefix: "" };
|
|
1511
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
1512
|
+
if (opts.capture) {
|
|
1513
|
+
star = `(${star})`;
|
|
1514
|
+
}
|
|
1515
|
+
const globstar = (opts2) => {
|
|
1516
|
+
if (opts2.noglobstar === true)
|
|
1517
|
+
return star;
|
|
1518
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1519
|
+
};
|
|
1520
|
+
const create = (str) => {
|
|
1521
|
+
switch (str) {
|
|
1522
|
+
case "*":
|
|
1523
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
1524
|
+
case ".*":
|
|
1525
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1526
|
+
case "*.*":
|
|
1527
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1528
|
+
case "*/*":
|
|
1529
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1530
|
+
case "**":
|
|
1531
|
+
return nodot + globstar(opts);
|
|
1532
|
+
case "**/*":
|
|
1533
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1534
|
+
case "**/*.*":
|
|
1535
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1536
|
+
case "**/.*":
|
|
1537
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1538
|
+
default: {
|
|
1539
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1540
|
+
if (!match)
|
|
1541
|
+
return;
|
|
1542
|
+
const source2 = create(match[1]);
|
|
1543
|
+
if (!source2)
|
|
1544
|
+
return;
|
|
1545
|
+
return source2 + DOT_LITERAL + match[2];
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
const output = utils.removePrefix(input, state);
|
|
1550
|
+
let source = create(output);
|
|
1551
|
+
if (source && opts.strictSlashes !== true) {
|
|
1552
|
+
source += `${SLASH_LITERAL}?`;
|
|
1553
|
+
}
|
|
1554
|
+
return source;
|
|
1555
|
+
};
|
|
1556
|
+
module.exports = parse;
|
|
1557
|
+
});
|
|
1558
|
+
|
|
1559
|
+
// ../../../node_modules/.bun/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js
|
|
1560
|
+
var require_picomatch = __commonJS((exports, module) => {
|
|
1561
|
+
var scan = require_scan();
|
|
1562
|
+
var parse = require_parse();
|
|
1563
|
+
var utils = require_utils();
|
|
1564
|
+
var constants = require_constants();
|
|
1565
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1566
|
+
var picomatch = (glob, options, returnState = false) => {
|
|
1567
|
+
if (Array.isArray(glob)) {
|
|
1568
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
1569
|
+
const arrayMatcher = (str) => {
|
|
1570
|
+
for (const isMatch of fns) {
|
|
1571
|
+
const state2 = isMatch(str);
|
|
1572
|
+
if (state2)
|
|
1573
|
+
return state2;
|
|
1574
|
+
}
|
|
1575
|
+
return false;
|
|
1576
|
+
};
|
|
1577
|
+
return arrayMatcher;
|
|
1578
|
+
}
|
|
1579
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1580
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
1581
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
1582
|
+
}
|
|
1583
|
+
const opts = options || {};
|
|
1584
|
+
const posix = opts.windows;
|
|
1585
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1586
|
+
const state = regex.state;
|
|
1587
|
+
delete regex.state;
|
|
1588
|
+
let isIgnored = () => false;
|
|
1589
|
+
if (opts.ignore) {
|
|
1590
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
1591
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1592
|
+
}
|
|
1593
|
+
const matcher = (input, returnObject = false) => {
|
|
1594
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
1595
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
1596
|
+
if (typeof opts.onResult === "function") {
|
|
1597
|
+
opts.onResult(result);
|
|
1598
|
+
}
|
|
1599
|
+
if (isMatch === false) {
|
|
1600
|
+
result.isMatch = false;
|
|
1601
|
+
return returnObject ? result : false;
|
|
1602
|
+
}
|
|
1603
|
+
if (isIgnored(input)) {
|
|
1604
|
+
if (typeof opts.onIgnore === "function") {
|
|
1605
|
+
opts.onIgnore(result);
|
|
1606
|
+
}
|
|
1607
|
+
result.isMatch = false;
|
|
1608
|
+
return returnObject ? result : false;
|
|
1609
|
+
}
|
|
1610
|
+
if (typeof opts.onMatch === "function") {
|
|
1611
|
+
opts.onMatch(result);
|
|
1612
|
+
}
|
|
1613
|
+
return returnObject ? result : true;
|
|
1614
|
+
};
|
|
1615
|
+
if (returnState) {
|
|
1616
|
+
matcher.state = state;
|
|
1617
|
+
}
|
|
1618
|
+
return matcher;
|
|
1619
|
+
};
|
|
1620
|
+
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
1621
|
+
if (typeof input !== "string") {
|
|
1622
|
+
throw new TypeError("Expected input to be a string");
|
|
1623
|
+
}
|
|
1624
|
+
if (input === "") {
|
|
1625
|
+
return { isMatch: false, output: "" };
|
|
1626
|
+
}
|
|
1627
|
+
const opts = options || {};
|
|
1628
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1629
|
+
let match = input === glob;
|
|
1630
|
+
let output = match && format ? format(input) : input;
|
|
1631
|
+
if (match === false) {
|
|
1632
|
+
output = format ? format(input) : input;
|
|
1633
|
+
match = output === glob;
|
|
1634
|
+
}
|
|
1635
|
+
if (match === false || opts.capture === true) {
|
|
1636
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
1637
|
+
match = picomatch.matchBase(input, regex, options, posix);
|
|
1638
|
+
} else {
|
|
1639
|
+
match = regex.exec(output);
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
return { isMatch: Boolean(match), match, output };
|
|
1643
|
+
};
|
|
1644
|
+
picomatch.matchBase = (input, glob, options) => {
|
|
1645
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
1646
|
+
return regex.test(utils.basename(input));
|
|
1647
|
+
};
|
|
1648
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
1649
|
+
picomatch.parse = (pattern, options) => {
|
|
1650
|
+
if (Array.isArray(pattern))
|
|
1651
|
+
return pattern.map((p) => picomatch.parse(p, options));
|
|
1652
|
+
return parse(pattern, { ...options, fastpaths: false });
|
|
1653
|
+
};
|
|
1654
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
1655
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1656
|
+
if (returnOutput === true) {
|
|
1657
|
+
return state.output;
|
|
1658
|
+
}
|
|
1659
|
+
const opts = options || {};
|
|
1660
|
+
const prepend = opts.contains ? "" : "^";
|
|
1661
|
+
const append = opts.contains ? "" : "$";
|
|
1662
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
1663
|
+
if (state && state.negated === true) {
|
|
1664
|
+
source = `^(?!${source}).*$`;
|
|
1665
|
+
}
|
|
1666
|
+
const regex = picomatch.toRegex(source, options);
|
|
1667
|
+
if (returnState === true) {
|
|
1668
|
+
regex.state = state;
|
|
1669
|
+
}
|
|
1670
|
+
return regex;
|
|
1671
|
+
};
|
|
1672
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1673
|
+
if (!input || typeof input !== "string") {
|
|
1674
|
+
throw new TypeError("Expected a non-empty string");
|
|
1675
|
+
}
|
|
1676
|
+
let parsed = { negated: false, fastpaths: true };
|
|
1677
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
1678
|
+
parsed.output = parse.fastpaths(input, options);
|
|
1679
|
+
}
|
|
1680
|
+
if (!parsed.output) {
|
|
1681
|
+
parsed = parse(input, options);
|
|
1682
|
+
}
|
|
1683
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
1684
|
+
};
|
|
1685
|
+
picomatch.toRegex = (source, options) => {
|
|
1686
|
+
try {
|
|
1687
|
+
const opts = options || {};
|
|
1688
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
1689
|
+
} catch (err) {
|
|
1690
|
+
if (options && options.debug === true)
|
|
1691
|
+
throw err;
|
|
1692
|
+
return /$^/;
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
picomatch.constants = constants;
|
|
1696
|
+
module.exports = picomatch;
|
|
1697
|
+
});
|
|
1698
|
+
|
|
1699
|
+
// ../../../node_modules/.bun/picomatch@4.0.4/node_modules/picomatch/index.js
|
|
1700
|
+
var require_picomatch2 = __commonJS((exports, module) => {
|
|
1701
|
+
var pico = require_picomatch();
|
|
1702
|
+
var utils = require_utils();
|
|
1703
|
+
function picomatch(glob, options, returnState = false) {
|
|
1704
|
+
if (options && (options.windows === null || options.windows === undefined)) {
|
|
1705
|
+
options = { ...options, windows: utils.isWindows() };
|
|
1706
|
+
}
|
|
1707
|
+
return pico(glob, options, returnState);
|
|
1708
|
+
}
|
|
1709
|
+
Object.assign(picomatch, pico);
|
|
1710
|
+
module.exports = picomatch;
|
|
1711
|
+
});
|
|
1712
|
+
|
|
1713
|
+
// components/rules/src/cli.ts
|
|
2
1714
|
import { stdin as processStdin, stdout as processStdout } from "node:process";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1715
|
+
|
|
1716
|
+
// ../../rules-engine/src/engine/cache.ts
|
|
1717
|
+
var DYNAMIC_SESSION_KEY = "__pi-rules-session__";
|
|
1718
|
+
function createSessionState(cwd) {
|
|
1719
|
+
return {
|
|
1720
|
+
cwd,
|
|
1721
|
+
staticDedup: new Set,
|
|
1722
|
+
dynamicDedup: new Map,
|
|
1723
|
+
dynamicTargetFingerprints: new Map,
|
|
1724
|
+
loadedRules: [],
|
|
1725
|
+
diagnostics: []
|
|
1726
|
+
};
|
|
8
1727
|
}
|
|
9
|
-
|
|
10
|
-
|
|
1728
|
+
function staticDedupKey(cwd, rulePath, contentHash) {
|
|
1729
|
+
return `${cwd}::${rulePath}::${contentHash}`;
|
|
11
1730
|
}
|
|
12
|
-
|
|
13
|
-
|
|
1731
|
+
function dynamicDedupKey(rulePath, contentHash) {
|
|
1732
|
+
return `${rulePath}::${contentHash}`;
|
|
14
1733
|
}
|
|
15
|
-
|
|
16
|
-
|
|
1734
|
+
function markStaticInjected(state, rule) {
|
|
1735
|
+
const key = staticDedupKey(state.cwd ?? "", rule.realPath, rule.contentHash);
|
|
1736
|
+
if (state.staticDedup.has(key)) {
|
|
1737
|
+
return false;
|
|
1738
|
+
}
|
|
1739
|
+
state.staticDedup.add(key);
|
|
1740
|
+
return true;
|
|
17
1741
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1742
|
+
function markDynamicInjected(state, rule) {
|
|
1743
|
+
let keys = state.dynamicDedup.get(DYNAMIC_SESSION_KEY);
|
|
1744
|
+
if (keys === undefined) {
|
|
1745
|
+
keys = new Set;
|
|
1746
|
+
state.dynamicDedup.set(DYNAMIC_SESSION_KEY, keys);
|
|
1747
|
+
}
|
|
1748
|
+
const key = dynamicDedupKey(rule.realPath, rule.contentHash);
|
|
1749
|
+
if (keys.has(key)) {
|
|
1750
|
+
return false;
|
|
1751
|
+
}
|
|
1752
|
+
keys.add(key);
|
|
1753
|
+
return true;
|
|
21
1754
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1755
|
+
function isStaticInjected(state, rule) {
|
|
1756
|
+
return state.staticDedup.has(staticDedupKey(state.cwd ?? "", rule.realPath, rule.contentHash));
|
|
1757
|
+
}
|
|
1758
|
+
function isDynamicInjected(state, rule) {
|
|
1759
|
+
return state.dynamicDedup.get(DYNAMIC_SESSION_KEY)?.has(dynamicDedupKey(rule.realPath, rule.contentHash)) === true;
|
|
1760
|
+
}
|
|
1761
|
+
function clearSession(state) {
|
|
1762
|
+
state.staticDedup.clear();
|
|
1763
|
+
state.dynamicDedup.clear();
|
|
1764
|
+
state.dynamicTargetFingerprints.clear();
|
|
1765
|
+
state.loadedRules.length = 0;
|
|
1766
|
+
state.diagnostics.length = 0;
|
|
1767
|
+
}
|
|
1768
|
+
// ../../rules-engine/src/engine/constants.ts
|
|
1769
|
+
var PROJECT_MARKERS = [
|
|
1770
|
+
".git",
|
|
1771
|
+
"pnpm-workspace.yaml",
|
|
1772
|
+
"package.json",
|
|
1773
|
+
"pyproject.toml",
|
|
1774
|
+
"Cargo.toml",
|
|
1775
|
+
"go.mod",
|
|
1776
|
+
".venv"
|
|
1777
|
+
];
|
|
1778
|
+
var PROJECT_RULE_SUBDIRS = [
|
|
1779
|
+
[".omo", "rules"],
|
|
1780
|
+
[".claude", "rules"],
|
|
1781
|
+
[".cursor", "rules"],
|
|
1782
|
+
[".github", "instructions"]
|
|
1783
|
+
];
|
|
1784
|
+
var PROJECT_SINGLE_FILES = [".github/copilot-instructions.md", "CONTEXT.md"];
|
|
1785
|
+
var USER_HOME_RULE_SUBDIRS = [".omo/rules", ".opencode/rules", ".claude/rules"];
|
|
1786
|
+
var USER_HOME_SINGLE_FILES = [];
|
|
1787
|
+
var BUNDLED_RULE_SUBDIR = "bundled-rules";
|
|
1788
|
+
var RULE_FILE_EXTENSIONS = [".md", ".mdc"];
|
|
1789
|
+
var SOURCE_PRIORITY = new Map([
|
|
1790
|
+
[".omo/rules", 0],
|
|
1791
|
+
[".claude/rules", 1],
|
|
1792
|
+
[".cursor/rules", 2],
|
|
1793
|
+
[".github/instructions", 3],
|
|
1794
|
+
[".github/copilot-instructions.md", 4],
|
|
1795
|
+
["CONTEXT.md", 7],
|
|
1796
|
+
["~/.omo/rules", 100],
|
|
1797
|
+
["~/.opencode/rules", 101],
|
|
1798
|
+
["~/.claude/rules", 102],
|
|
1799
|
+
["plugin-bundled", 200]
|
|
1800
|
+
]);
|
|
1801
|
+
var GLOBAL_DISTANCE = 9999;
|
|
1802
|
+
var DEFAULT_MAX_RULE_CHARS = 12000;
|
|
1803
|
+
var DEFAULT_MAX_SCAN_FILES = 1000;
|
|
1804
|
+
var DEFAULT_MAX_RESULT_CHARS = 40000;
|
|
1805
|
+
var DEFAULT_POST_COMPACT_MAX_RULE_CHARS = 3500;
|
|
1806
|
+
var DEFAULT_POST_COMPACT_MAX_RESULT_CHARS = 4000;
|
|
1807
|
+
var DEFAULT_DYNAMIC_MAX_RULE_CHARS = 4000;
|
|
1808
|
+
var DEFAULT_DYNAMIC_MAX_RESULT_CHARS = 1e4;
|
|
1809
|
+
var DEFAULT_PROMPT_MAX_RULE_CHARS = 6000;
|
|
1810
|
+
var DEFAULT_PROMPT_MAX_RESULT_CHARS = 16000;
|
|
1811
|
+
var TRUNCATION_NOTICE = `
|
|
1812
|
+
|
|
1813
|
+
[Truncated. Full: {path}]`;
|
|
1814
|
+
var SCANNER_EXCLUDED_DIRS = [
|
|
1815
|
+
"node_modules",
|
|
1816
|
+
".git",
|
|
1817
|
+
"dist",
|
|
1818
|
+
"build",
|
|
1819
|
+
".turbo",
|
|
1820
|
+
".next",
|
|
1821
|
+
"coverage"
|
|
1822
|
+
];
|
|
1823
|
+
// ../../rules-engine/src/engine/engine-dynamic-cache.ts
|
|
1824
|
+
import { dirname as dirname2, resolve as resolve2 } from "node:path";
|
|
1825
|
+
|
|
1826
|
+
// ../../rules-engine/src/engine/engine-paths.ts
|
|
1827
|
+
import { realpathSync } from "node:fs";
|
|
1828
|
+
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
1829
|
+
var ROOT_SINGLE_FILE_SOURCES = new Set(PROJECT_SINGLE_FILES.filter((source) => !source.includes("/")));
|
|
1830
|
+
function isCandidateWithinProjectCached(candidate, projectRoot, projectMembership) {
|
|
1831
|
+
if (projectMembership === undefined) {
|
|
1832
|
+
return isCandidateWithinProject(candidate, projectRoot);
|
|
1833
|
+
}
|
|
1834
|
+
const cacheKey = `${projectRoot ?? ""}\x00${candidate.realPath}`;
|
|
1835
|
+
const cached = projectMembership.get(cacheKey);
|
|
1836
|
+
if (cached !== undefined) {
|
|
1837
|
+
return cached;
|
|
1838
|
+
}
|
|
1839
|
+
const isWithinProject = isCandidateWithinProject(candidate, projectRoot);
|
|
1840
|
+
projectMembership.set(cacheKey, isWithinProject);
|
|
1841
|
+
return isWithinProject;
|
|
1842
|
+
}
|
|
1843
|
+
function isSameOrChildPath(childPath, parentPath) {
|
|
1844
|
+
const childRelativePath = relative(parentPath, resolve(childPath));
|
|
1845
|
+
return childRelativePath === "" || !childRelativePath.startsWith("..") && !isAbsolute(childRelativePath);
|
|
1846
|
+
}
|
|
1847
|
+
function isRootSingleFile(candidate) {
|
|
1848
|
+
return candidate.distance === 0 && candidate.isSingleFile && ROOT_SINGLE_FILE_SOURCES.has(candidate.source);
|
|
1849
|
+
}
|
|
1850
|
+
function pathBasesForTarget(projectRoot, targetFile, candidate) {
|
|
1851
|
+
const targetBasename = basename(targetFile);
|
|
1852
|
+
if (projectRoot === null) {
|
|
1853
|
+
return { projectRelative: targetBasename, basename: targetBasename };
|
|
1854
|
+
}
|
|
1855
|
+
const projectRelative = toPosixPath(relative(projectRoot, targetFile));
|
|
1856
|
+
const scopeDirectory = scopeDirectoryForCandidate(projectRoot, candidate);
|
|
1857
|
+
if (scopeDirectory === null) {
|
|
1858
|
+
return { projectRelative, basename: targetBasename };
|
|
1859
|
+
}
|
|
1860
|
+
return {
|
|
1861
|
+
projectRelative,
|
|
1862
|
+
scopeRelative: toPosixPath(relative(scopeDirectory, targetFile)),
|
|
1863
|
+
basename: targetBasename
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
function toPosixPath(path) {
|
|
1867
|
+
return path.replaceAll("\\", "/");
|
|
1868
|
+
}
|
|
1869
|
+
function isCandidateWithinProject(candidate, projectRoot) {
|
|
1870
|
+
if (candidate.isGlobal) {
|
|
1871
|
+
return true;
|
|
1872
|
+
}
|
|
1873
|
+
if (projectRoot === null) {
|
|
1874
|
+
return false;
|
|
1875
|
+
}
|
|
1876
|
+
const relativeRealPath = relative(realPathOrResolved(projectRoot), realPathOrResolved(candidate.realPath));
|
|
1877
|
+
return relativeRealPath === "" || !relativeRealPath.startsWith("..") && !isAbsolute(relativeRealPath);
|
|
1878
|
+
}
|
|
1879
|
+
function realPathOrResolved(path) {
|
|
1880
|
+
try {
|
|
1881
|
+
return realpathSync.native(path);
|
|
1882
|
+
} catch {
|
|
1883
|
+
return resolve(path);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
function scopeDirectoryForCandidate(projectRoot, candidate) {
|
|
1887
|
+
if (candidate.isGlobal) {
|
|
1888
|
+
return null;
|
|
1889
|
+
}
|
|
1890
|
+
if (candidate.isSingleFile) {
|
|
1891
|
+
return dirname(candidate.path);
|
|
1892
|
+
}
|
|
1893
|
+
const sourceIndex = candidate.relativePath.indexOf(candidate.source);
|
|
1894
|
+
if (sourceIndex === -1) {
|
|
1895
|
+
return projectRoot;
|
|
1896
|
+
}
|
|
1897
|
+
const scopeRelativeDirectory = candidate.relativePath.slice(0, sourceIndex).replace(/\/$/, "");
|
|
1898
|
+
return scopeRelativeDirectory.length === 0 ? projectRoot : join(projectRoot, scopeRelativeDirectory);
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
// ../../rules-engine/src/engine/ordering.ts
|
|
1902
|
+
function sortCandidates(candidates) {
|
|
1903
|
+
return candidates.map((candidate, index) => ({ candidate, index })).sort((left, right) => compareCandidates(left.candidate, right.candidate) || left.index - right.index).map(({ candidate }) => candidate);
|
|
1904
|
+
}
|
|
1905
|
+
function compareCandidates(a, b) {
|
|
1906
|
+
return compareBoolean(a.isGlobal, b.isGlobal) || compareNumber(a.distance, b.distance) || compareNumber(SOURCE_PRIORITY.get(a.source) ?? Infinity, SOURCE_PRIORITY.get(b.source) ?? Infinity) || compareString(a.relativePath, b.relativePath) || compareString(a.realPath, b.realPath);
|
|
1907
|
+
}
|
|
1908
|
+
function compareBoolean(a, b) {
|
|
1909
|
+
return Number(a) - Number(b);
|
|
1910
|
+
}
|
|
1911
|
+
function compareNumber(a, b) {
|
|
1912
|
+
return a - b;
|
|
1913
|
+
}
|
|
1914
|
+
function compareString(a, b) {
|
|
1915
|
+
if (a < b)
|
|
1916
|
+
return -1;
|
|
1917
|
+
if (a > b)
|
|
1918
|
+
return 1;
|
|
1919
|
+
return 0;
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
// ../../rules-engine/src/engine/engine-dynamic-cache.ts
|
|
1923
|
+
var MAX_DYNAMIC_MATCH_CACHE_ENTRIES = 4096;
|
|
1924
|
+
function matchDynamicRuleCached(cache, projectRoot, targetFile, candidate, loadedRule, matchRuleImpl) {
|
|
1925
|
+
const cacheKey = dynamicMatchCacheKey(projectRoot, targetFile, candidate, loadedRule.contentHash);
|
|
1926
|
+
if (cache.has(cacheKey)) {
|
|
1927
|
+
const cachedReason = cache.get(cacheKey) ?? null;
|
|
1928
|
+
cache.delete(cacheKey);
|
|
1929
|
+
cache.set(cacheKey, cachedReason);
|
|
1930
|
+
return cachedReason;
|
|
1931
|
+
}
|
|
1932
|
+
const matchResult = matchRuleImpl({
|
|
1933
|
+
frontmatter: loadedRule.frontmatter,
|
|
1934
|
+
isSingleFile: candidate.isSingleFile,
|
|
1935
|
+
pathBases: pathBasesForTarget(projectRoot, targetFile, candidate)
|
|
1936
|
+
});
|
|
1937
|
+
const reason = matchResult.matched ? matchResult.reason : null;
|
|
1938
|
+
setDynamicMatchCacheEntry(cache, cacheKey, reason);
|
|
1939
|
+
return reason;
|
|
1940
|
+
}
|
|
1941
|
+
function findSortedCandidatesCached(cache, findCandidates, options) {
|
|
1942
|
+
const cacheKey = candidateDiscoveryCacheKey(options);
|
|
1943
|
+
const cached = cache.get(cacheKey);
|
|
1944
|
+
if (cached !== undefined) {
|
|
1945
|
+
return cached;
|
|
1946
|
+
}
|
|
1947
|
+
const candidates = sortCandidates(findCandidates(options));
|
|
1948
|
+
cache.set(cacheKey, candidates);
|
|
1949
|
+
return candidates;
|
|
1950
|
+
}
|
|
1951
|
+
function setDynamicMatchCacheEntry(cache, cacheKey, reason) {
|
|
1952
|
+
if (cache.size >= MAX_DYNAMIC_MATCH_CACHE_ENTRIES) {
|
|
1953
|
+
const oldestCacheKey = cache.keys().next().value;
|
|
1954
|
+
if (oldestCacheKey !== undefined) {
|
|
1955
|
+
cache.delete(oldestCacheKey);
|
|
34
1956
|
}
|
|
1957
|
+
}
|
|
1958
|
+
cache.set(cacheKey, reason);
|
|
35
1959
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1960
|
+
function dynamicMatchCacheKey(projectRoot, targetFile, candidate, contentHash) {
|
|
1961
|
+
return [
|
|
1962
|
+
projectRoot ?? "",
|
|
1963
|
+
toPosixPath(resolve2(targetFile)),
|
|
1964
|
+
candidate.realPath,
|
|
1965
|
+
candidate.relativePath,
|
|
1966
|
+
candidate.source,
|
|
1967
|
+
candidate.isGlobal ? "global" : "project",
|
|
1968
|
+
candidate.isSingleFile ? "single" : "multi",
|
|
1969
|
+
String(candidate.distance),
|
|
1970
|
+
contentHash
|
|
1971
|
+
].join("\x00");
|
|
1972
|
+
}
|
|
1973
|
+
function candidateDiscoveryCacheKey(options) {
|
|
1974
|
+
return [
|
|
1975
|
+
options.projectRoot ?? "",
|
|
1976
|
+
options.targetFile === null ? "" : dirname2(resolve2(options.targetFile)),
|
|
1977
|
+
...[...options.disabledSources ?? []].sort()
|
|
1978
|
+
].join("\x00");
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
// ../../rules-engine/src/engine/matcher.ts
|
|
1982
|
+
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
1983
|
+
import { createHash } from "node:crypto";
|
|
1984
|
+
var compiledPatternSets = new Map;
|
|
1985
|
+
function matchRule(input) {
|
|
1986
|
+
if (input.isSingleFile) {
|
|
1987
|
+
return { matched: true, reason: "single-file" };
|
|
1988
|
+
}
|
|
1989
|
+
if (input.frontmatter.alwaysApply === true) {
|
|
1990
|
+
return { matched: true, reason: "alwaysApply" };
|
|
1991
|
+
}
|
|
1992
|
+
const patterns = normalizeGlobs(input.frontmatter);
|
|
1993
|
+
if (patterns.length === 0) {
|
|
1994
|
+
return noMatch();
|
|
1995
|
+
}
|
|
1996
|
+
const pathBases = normalizedPathBases(input.pathBases);
|
|
1997
|
+
const { positivePatterns, negativeMatchers } = compiledPatternSetFor(patterns);
|
|
1998
|
+
for (const { pattern, isMatch } of positivePatterns) {
|
|
1999
|
+
for (const pathBase of pathBases) {
|
|
2000
|
+
if (!isMatch(pathBase)) {
|
|
2001
|
+
continue;
|
|
2002
|
+
}
|
|
2003
|
+
if (isExcluded(pathBase, negativeMatchers)) {
|
|
2004
|
+
return noMatch();
|
|
2005
|
+
}
|
|
2006
|
+
return { matched: true, reason: { kind: "glob", pattern } };
|
|
46
2007
|
}
|
|
2008
|
+
}
|
|
2009
|
+
return noMatch();
|
|
47
2010
|
}
|
|
48
|
-
function
|
|
2011
|
+
function normalizeGlobs(frontmatter) {
|
|
2012
|
+
const patterns = [
|
|
2013
|
+
...normalizePatternList(frontmatter.globs),
|
|
2014
|
+
...normalizePatternList(frontmatter.paths),
|
|
2015
|
+
...normalizePatternList(frontmatter.applyTo)
|
|
2016
|
+
];
|
|
2017
|
+
return [...new Set(patterns.map(normalizePath))];
|
|
2018
|
+
}
|
|
2019
|
+
function hashContent(body) {
|
|
2020
|
+
return createHash("sha256").update(body).digest("hex");
|
|
2021
|
+
}
|
|
2022
|
+
function normalizePatternList(patterns) {
|
|
2023
|
+
if (patterns === undefined) {
|
|
2024
|
+
return [];
|
|
2025
|
+
}
|
|
2026
|
+
return Array.isArray(patterns) ? patterns : [patterns];
|
|
2027
|
+
}
|
|
2028
|
+
function normalizePath(path) {
|
|
2029
|
+
return path.replaceAll("\\", "/");
|
|
2030
|
+
}
|
|
2031
|
+
function normalizedPathBases(pathBases) {
|
|
2032
|
+
const normalizedBases = [normalizePath(pathBases.projectRelative)];
|
|
2033
|
+
if (pathBases.scopeRelative !== undefined) {
|
|
2034
|
+
normalizedBases.push(normalizePath(pathBases.scopeRelative));
|
|
2035
|
+
}
|
|
2036
|
+
normalizedBases.push(normalizePath(pathBases.basename));
|
|
2037
|
+
return normalizedBases;
|
|
2038
|
+
}
|
|
2039
|
+
function compiledPatternSetFor(patterns) {
|
|
2040
|
+
const cacheKey = JSON.stringify(patterns);
|
|
2041
|
+
const cached = compiledPatternSets.get(cacheKey);
|
|
2042
|
+
if (cached !== undefined) {
|
|
2043
|
+
return cached;
|
|
2044
|
+
}
|
|
2045
|
+
const compiled = compilePatternSet(patterns);
|
|
2046
|
+
compiledPatternSets.set(cacheKey, compiled);
|
|
2047
|
+
return compiled;
|
|
2048
|
+
}
|
|
2049
|
+
function compilePatternSet(patterns) {
|
|
2050
|
+
const positivePatterns = [];
|
|
2051
|
+
const negativeMatchers = [];
|
|
2052
|
+
for (const pattern of patterns) {
|
|
2053
|
+
if (pattern.startsWith("!")) {
|
|
2054
|
+
negativeMatchers.push(createGlobMatcher(pattern.slice(1)));
|
|
2055
|
+
continue;
|
|
2056
|
+
}
|
|
2057
|
+
positivePatterns.push({ pattern, isMatch: createGlobMatcher(pattern) });
|
|
2058
|
+
}
|
|
2059
|
+
return { positivePatterns, negativeMatchers };
|
|
2060
|
+
}
|
|
2061
|
+
function createGlobMatcher(pattern) {
|
|
2062
|
+
return import_picomatch.default(normalizePath(pattern), { bash: true, dot: true });
|
|
2063
|
+
}
|
|
2064
|
+
function isExcluded(pathBase, negativeMatchers) {
|
|
2065
|
+
for (const isMatch of negativeMatchers) {
|
|
2066
|
+
if (isMatch(pathBase)) {
|
|
2067
|
+
return true;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
return false;
|
|
2071
|
+
}
|
|
2072
|
+
function noMatch() {
|
|
2073
|
+
return { matched: false, reason: { kind: "no-match" } };
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
// ../../rules-engine/src/engine/parser-frontmatter.ts
|
|
2077
|
+
var FRONTMATTER_OPENING = `---
|
|
2078
|
+
`;
|
|
2079
|
+
var FRONTMATTER_OPENING_CRLF = `---\r
|
|
2080
|
+
`;
|
|
2081
|
+
function stripBom(content) {
|
|
2082
|
+
return content.startsWith("\uFEFF") ? content.slice(1) : content;
|
|
2083
|
+
}
|
|
2084
|
+
function getOpeningDelimiterLength(content) {
|
|
2085
|
+
if (content.startsWith(FRONTMATTER_OPENING_CRLF))
|
|
2086
|
+
return FRONTMATTER_OPENING_CRLF.length;
|
|
2087
|
+
if (content.startsWith(FRONTMATTER_OPENING))
|
|
2088
|
+
return FRONTMATTER_OPENING.length;
|
|
2089
|
+
return 0;
|
|
2090
|
+
}
|
|
2091
|
+
function findClosingDelimiter(content, openingLength) {
|
|
2092
|
+
let lineStart = openingLength;
|
|
2093
|
+
while (lineStart <= content.length) {
|
|
2094
|
+
const nextNewline = content.indexOf(`
|
|
2095
|
+
`, lineStart);
|
|
2096
|
+
const lineEnd = nextNewline === -1 ? content.length : nextNewline;
|
|
2097
|
+
const line = content.slice(lineStart, lineEnd).replace(/\r$/, "");
|
|
2098
|
+
if (line === "---") {
|
|
2099
|
+
return {
|
|
2100
|
+
start: lineStart,
|
|
2101
|
+
bodyStart: nextNewline === -1 ? content.length : nextNewline + 1
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
2104
|
+
if (nextNewline === -1)
|
|
2105
|
+
break;
|
|
2106
|
+
lineStart = nextNewline + 1;
|
|
2107
|
+
}
|
|
2108
|
+
return null;
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
// ../../rules-engine/src/engine/errors.ts
|
|
2112
|
+
class UnsupportedRuleSourceError extends Error {
|
|
2113
|
+
constructor(message) {
|
|
2114
|
+
super(message);
|
|
2115
|
+
this.name = "UnsupportedRuleSourceError";
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
class RuleFrontmatterParseError extends Error {
|
|
2120
|
+
constructor(message) {
|
|
2121
|
+
super(message);
|
|
2122
|
+
this.name = "RuleFrontmatterParseError";
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
// ../../rules-engine/src/engine/parser-yaml.ts
|
|
2127
|
+
function parseYamlFrontmatter(yamlContent) {
|
|
2128
|
+
const lines = yamlContent.replace(/\r\n/g, `
|
|
2129
|
+
`).split(`
|
|
2130
|
+
`);
|
|
2131
|
+
const frontmatter = {};
|
|
2132
|
+
const globValues = [];
|
|
2133
|
+
const seenGlobs = new Set;
|
|
2134
|
+
let lineIndex = 0;
|
|
2135
|
+
while (lineIndex < lines.length) {
|
|
2136
|
+
const rawLine = lines[lineIndex];
|
|
2137
|
+
if (rawLine === undefined)
|
|
2138
|
+
break;
|
|
2139
|
+
const line = stripComment(rawLine).trim();
|
|
2140
|
+
if (line.length === 0) {
|
|
2141
|
+
lineIndex += 1;
|
|
2142
|
+
continue;
|
|
2143
|
+
}
|
|
2144
|
+
const colonIndex = line.indexOf(":");
|
|
2145
|
+
if (colonIndex === -1) {
|
|
2146
|
+
throw new RuleFrontmatterParseError(`Expected key-value pair on line ${lineIndex + 1}`);
|
|
2147
|
+
}
|
|
2148
|
+
const key = line.slice(0, colonIndex).trim();
|
|
2149
|
+
const rawValue = line.slice(colonIndex + 1).trim();
|
|
2150
|
+
if (key === "description") {
|
|
2151
|
+
frontmatter.description = parseStringValue(rawValue);
|
|
2152
|
+
lineIndex += 1;
|
|
2153
|
+
continue;
|
|
2154
|
+
}
|
|
2155
|
+
if (key === "alwaysApply") {
|
|
2156
|
+
frontmatter.alwaysApply = parseBooleanValue(rawValue, lineIndex + 1);
|
|
2157
|
+
lineIndex += 1;
|
|
2158
|
+
continue;
|
|
2159
|
+
}
|
|
2160
|
+
if (key === "globs" || key === "paths" || key === "applyTo") {
|
|
2161
|
+
const parsed = parseGlobValue(rawValue, lines, lineIndex);
|
|
2162
|
+
for (const glob of parsed.values) {
|
|
2163
|
+
if (!seenGlobs.has(glob)) {
|
|
2164
|
+
seenGlobs.add(glob);
|
|
2165
|
+
globValues.push(glob);
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
lineIndex += parsed.consumed;
|
|
2169
|
+
continue;
|
|
2170
|
+
}
|
|
2171
|
+
lineIndex += 1;
|
|
2172
|
+
}
|
|
2173
|
+
const singleGlob = globValues[0];
|
|
2174
|
+
if (globValues.length === 1 && singleGlob !== undefined) {
|
|
2175
|
+
frontmatter.globs = singleGlob;
|
|
2176
|
+
} else if (globValues.length > 1) {
|
|
2177
|
+
frontmatter.globs = globValues;
|
|
2178
|
+
}
|
|
2179
|
+
return frontmatter;
|
|
2180
|
+
}
|
|
2181
|
+
function parseBooleanValue(value, lineNumber) {
|
|
2182
|
+
if (value === "true")
|
|
2183
|
+
return true;
|
|
2184
|
+
if (value === "false")
|
|
2185
|
+
return false;
|
|
2186
|
+
throw new RuleFrontmatterParseError(`Expected boolean on line ${lineNumber}`);
|
|
2187
|
+
}
|
|
2188
|
+
function parseGlobValue(rawValue, lines, lineIndex) {
|
|
2189
|
+
if (rawValue.startsWith("[")) {
|
|
2190
|
+
return { values: parseInlineArray(rawValue), consumed: 1 };
|
|
2191
|
+
}
|
|
2192
|
+
if (rawValue.length === 0) {
|
|
2193
|
+
return parseMultilineArray(lines, lineIndex);
|
|
2194
|
+
}
|
|
2195
|
+
const quotedScalar = isQuotedScalar(rawValue);
|
|
2196
|
+
const value = parseStringValue(rawValue);
|
|
2197
|
+
if (!quotedScalar && value.includes(",")) {
|
|
2198
|
+
return {
|
|
2199
|
+
values: value.split(",").map((item) => item.trim()).filter(Boolean),
|
|
2200
|
+
consumed: 1
|
|
2201
|
+
};
|
|
2202
|
+
}
|
|
2203
|
+
return { values: [value], consumed: 1 };
|
|
2204
|
+
}
|
|
2205
|
+
function isQuotedScalar(value) {
|
|
2206
|
+
return value.startsWith('"') || value.startsWith("'");
|
|
2207
|
+
}
|
|
2208
|
+
function parseMultilineArray(lines, lineIndex) {
|
|
2209
|
+
const values = [];
|
|
2210
|
+
let consumed = 1;
|
|
2211
|
+
for (let index = lineIndex + 1;index < lines.length; index += 1) {
|
|
2212
|
+
const rawLine = lines[index];
|
|
2213
|
+
if (rawLine === undefined)
|
|
2214
|
+
break;
|
|
2215
|
+
const lineWithoutComment = stripComment(rawLine);
|
|
2216
|
+
if (lineWithoutComment.trim().length === 0) {
|
|
2217
|
+
consumed += 1;
|
|
2218
|
+
continue;
|
|
2219
|
+
}
|
|
2220
|
+
const arrayItem = lineWithoutComment.match(/^\s+-\s*(.*)$/);
|
|
2221
|
+
if (arrayItem === null)
|
|
2222
|
+
break;
|
|
2223
|
+
values.push(parseStringValue(arrayItem[1] ?? ""));
|
|
2224
|
+
consumed += 1;
|
|
2225
|
+
}
|
|
2226
|
+
return { values: values.filter(Boolean), consumed };
|
|
2227
|
+
}
|
|
2228
|
+
function parseInlineArray(value) {
|
|
2229
|
+
const closingBracketIndex = findClosingBracket(value);
|
|
2230
|
+
if (closingBracketIndex === -1) {
|
|
2231
|
+
throw new RuleFrontmatterParseError("Unclosed inline array");
|
|
2232
|
+
}
|
|
2233
|
+
const trailing = value.slice(closingBracketIndex + 1).trim();
|
|
2234
|
+
if (trailing.length > 0) {
|
|
2235
|
+
throw new RuleFrontmatterParseError("Unexpected content after inline array");
|
|
2236
|
+
}
|
|
2237
|
+
const content = value.slice(1, closingBracketIndex).trim();
|
|
2238
|
+
if (content.length === 0)
|
|
2239
|
+
return [];
|
|
2240
|
+
return splitCommaSeparated(content).map(parseStringValue).filter(Boolean);
|
|
2241
|
+
}
|
|
2242
|
+
function findClosingBracket(value) {
|
|
2243
|
+
let quote = null;
|
|
2244
|
+
let escaped = false;
|
|
2245
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
2246
|
+
const character = value[index];
|
|
2247
|
+
if (character === undefined)
|
|
2248
|
+
continue;
|
|
2249
|
+
if (escaped) {
|
|
2250
|
+
escaped = false;
|
|
2251
|
+
continue;
|
|
2252
|
+
}
|
|
2253
|
+
if (quote !== null && character === "\\") {
|
|
2254
|
+
escaped = true;
|
|
2255
|
+
continue;
|
|
2256
|
+
}
|
|
2257
|
+
if (character === '"' || character === "'") {
|
|
2258
|
+
if (quote === null)
|
|
2259
|
+
quote = character;
|
|
2260
|
+
else if (quote === character)
|
|
2261
|
+
quote = null;
|
|
2262
|
+
continue;
|
|
2263
|
+
}
|
|
2264
|
+
if (quote === null && character === "]")
|
|
2265
|
+
return index;
|
|
2266
|
+
}
|
|
2267
|
+
return -1;
|
|
2268
|
+
}
|
|
2269
|
+
function splitCommaSeparated(value) {
|
|
2270
|
+
const values = [];
|
|
2271
|
+
let current = "";
|
|
2272
|
+
let quote = null;
|
|
2273
|
+
let escaped = false;
|
|
2274
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
2275
|
+
const character = value[index];
|
|
2276
|
+
if (character === undefined)
|
|
2277
|
+
continue;
|
|
2278
|
+
if (escaped) {
|
|
2279
|
+
current += character;
|
|
2280
|
+
escaped = false;
|
|
2281
|
+
continue;
|
|
2282
|
+
}
|
|
2283
|
+
if (quote !== null && character === "\\") {
|
|
2284
|
+
current += character;
|
|
2285
|
+
escaped = true;
|
|
2286
|
+
continue;
|
|
2287
|
+
}
|
|
2288
|
+
if (character === '"' || character === "'") {
|
|
2289
|
+
if (quote === null)
|
|
2290
|
+
quote = character;
|
|
2291
|
+
else if (quote === character)
|
|
2292
|
+
quote = null;
|
|
2293
|
+
current += character;
|
|
2294
|
+
continue;
|
|
2295
|
+
}
|
|
2296
|
+
if (quote === null && character === ",") {
|
|
2297
|
+
values.push(current.trim());
|
|
2298
|
+
current = "";
|
|
2299
|
+
continue;
|
|
2300
|
+
}
|
|
2301
|
+
current += character;
|
|
2302
|
+
}
|
|
2303
|
+
if (quote !== null) {
|
|
2304
|
+
throw new RuleFrontmatterParseError("Unclosed quoted value");
|
|
2305
|
+
}
|
|
2306
|
+
values.push(current.trim());
|
|
2307
|
+
return values.filter(Boolean);
|
|
2308
|
+
}
|
|
2309
|
+
function parseStringValue(value) {
|
|
2310
|
+
if (value.length === 0)
|
|
2311
|
+
return "";
|
|
2312
|
+
if (value.startsWith('"'))
|
|
2313
|
+
return parseJsonString(value);
|
|
2314
|
+
if (value.startsWith("'") && value.endsWith("'"))
|
|
2315
|
+
return value.slice(1, -1);
|
|
2316
|
+
if (value.startsWith("'"))
|
|
2317
|
+
throw new RuleFrontmatterParseError("Unclosed quoted value");
|
|
2318
|
+
return value;
|
|
2319
|
+
}
|
|
2320
|
+
function parseJsonString(value) {
|
|
2321
|
+
try {
|
|
2322
|
+
const parsedValue = JSON.parse(value);
|
|
2323
|
+
if (typeof parsedValue !== "string") {
|
|
2324
|
+
throw new RuleFrontmatterParseError("Expected JSON-quoted string");
|
|
2325
|
+
}
|
|
2326
|
+
return parsedValue;
|
|
2327
|
+
} catch (error) {
|
|
2328
|
+
if (error instanceof RuleFrontmatterParseError)
|
|
2329
|
+
throw error;
|
|
2330
|
+
throw new RuleFrontmatterParseError("Invalid JSON-quoted string");
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
function stripComment(line) {
|
|
2334
|
+
let quote = null;
|
|
2335
|
+
let escaped = false;
|
|
2336
|
+
for (let index = 0;index < line.length; index += 1) {
|
|
2337
|
+
const character = line[index];
|
|
2338
|
+
if (character === undefined)
|
|
2339
|
+
continue;
|
|
2340
|
+
if (escaped) {
|
|
2341
|
+
escaped = false;
|
|
2342
|
+
continue;
|
|
2343
|
+
}
|
|
2344
|
+
if (quote !== null && character === "\\") {
|
|
2345
|
+
escaped = true;
|
|
2346
|
+
continue;
|
|
2347
|
+
}
|
|
2348
|
+
if (character === '"' || character === "'") {
|
|
2349
|
+
if (quote === null)
|
|
2350
|
+
quote = character;
|
|
2351
|
+
else if (quote === character)
|
|
2352
|
+
quote = null;
|
|
2353
|
+
continue;
|
|
2354
|
+
}
|
|
2355
|
+
if (quote === null && character === "#")
|
|
2356
|
+
return line.slice(0, index);
|
|
2357
|
+
}
|
|
2358
|
+
return line;
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
// ../../rules-engine/src/engine/parser.ts
|
|
2362
|
+
function parseRule(content) {
|
|
2363
|
+
const normalizedContent = stripBom(content);
|
|
2364
|
+
const openingLength = getOpeningDelimiterLength(normalizedContent);
|
|
2365
|
+
if (openingLength === 0) {
|
|
2366
|
+
return { frontmatter: {}, body: normalizedContent };
|
|
2367
|
+
}
|
|
2368
|
+
const closingDelimiter = findClosingDelimiter(normalizedContent, openingLength);
|
|
2369
|
+
if (closingDelimiter === null) {
|
|
2370
|
+
return {
|
|
2371
|
+
frontmatter: {},
|
|
2372
|
+
body: normalizedContent,
|
|
2373
|
+
diagnostic: "Missing closing frontmatter delimiter"
|
|
2374
|
+
};
|
|
2375
|
+
}
|
|
2376
|
+
const yamlContent = normalizedContent.slice(openingLength, closingDelimiter.start);
|
|
2377
|
+
const body = normalizedContent.slice(closingDelimiter.bodyStart);
|
|
2378
|
+
try {
|
|
2379
|
+
return { frontmatter: parseYamlFrontmatter(yamlContent), body };
|
|
2380
|
+
} catch (error) {
|
|
2381
|
+
const message = error instanceof Error ? error.message : "Invalid YAML frontmatter";
|
|
2382
|
+
return {
|
|
2383
|
+
frontmatter: {},
|
|
2384
|
+
body: normalizedContent,
|
|
2385
|
+
diagnostic: `Malformed frontmatter: ${message}`
|
|
2386
|
+
};
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
// ../../rules-engine/src/engine/engine-loader.ts
|
|
2391
|
+
function loadCandidate(candidate, deps, diagnostics, projectRoot, loadedRuleContent, projectMembership) {
|
|
2392
|
+
if (!isCandidateWithinProjectCached(candidate, projectRoot, projectMembership)) {
|
|
2393
|
+
diagnostics.push({
|
|
2394
|
+
severity: "warning",
|
|
2395
|
+
source: candidate.path,
|
|
2396
|
+
message: "Rule file resolves outside project root"
|
|
2397
|
+
});
|
|
2398
|
+
return null;
|
|
2399
|
+
}
|
|
2400
|
+
const cachedContent = loadedRuleContent?.get(candidate.realPath);
|
|
2401
|
+
if (cachedContent !== undefined) {
|
|
2402
|
+
return loadedRuleFromContent(candidate, cachedContent, diagnostics);
|
|
2403
|
+
}
|
|
2404
|
+
const content = deps.readFile(candidate.path);
|
|
2405
|
+
if (content === null) {
|
|
2406
|
+
loadedRuleContent?.set(candidate.realPath, null);
|
|
2407
|
+
diagnostics.push({ severity: "warning", source: candidate.path, message: "Unable to read rule file" });
|
|
2408
|
+
return null;
|
|
2409
|
+
}
|
|
2410
|
+
const parsed = parseRule(content);
|
|
2411
|
+
const loadedContent = {
|
|
2412
|
+
frontmatter: parsed.frontmatter,
|
|
2413
|
+
body: parsed.body,
|
|
2414
|
+
contentHash: hashContent(content),
|
|
2415
|
+
...parsed.diagnostic === undefined ? {} : { diagnostic: parsed.diagnostic }
|
|
2416
|
+
};
|
|
2417
|
+
loadedRuleContent?.set(candidate.realPath, loadedContent);
|
|
2418
|
+
return loadedRuleFromContent(candidate, loadedContent, diagnostics);
|
|
2419
|
+
}
|
|
2420
|
+
function ruleDedupKey(rule) {
|
|
2421
|
+
return `${rule.realPath}::${rule.contentHash}`;
|
|
2422
|
+
}
|
|
2423
|
+
function staticMatchReason(rule) {
|
|
2424
|
+
if (rule.frontmatter.alwaysApply === true) {
|
|
2425
|
+
return "alwaysApply";
|
|
2426
|
+
}
|
|
2427
|
+
if (rule.isSingleFile) {
|
|
2428
|
+
return "single-file";
|
|
2429
|
+
}
|
|
2430
|
+
return null;
|
|
2431
|
+
}
|
|
2432
|
+
function loadedRuleFromContent(candidate, content, diagnostics) {
|
|
2433
|
+
if (content === null) {
|
|
2434
|
+
diagnostics.push({ severity: "warning", source: candidate.path, message: "Unable to read rule file" });
|
|
2435
|
+
return null;
|
|
2436
|
+
}
|
|
2437
|
+
if (content.diagnostic !== undefined) {
|
|
2438
|
+
diagnostics.push({ severity: "warning", source: candidate.path, message: content.diagnostic });
|
|
2439
|
+
}
|
|
2440
|
+
return {
|
|
2441
|
+
...candidate,
|
|
2442
|
+
frontmatter: content.frontmatter,
|
|
2443
|
+
body: content.body,
|
|
2444
|
+
contentHash: content.contentHash,
|
|
2445
|
+
matchReason: { kind: "no-match" }
|
|
2446
|
+
};
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
// ../../rules-engine/src/engine/finder.ts
|
|
2450
|
+
import { homedir } from "node:os";
|
|
2451
|
+
import { join as join4, resolve as resolve6 } from "node:path";
|
|
2452
|
+
|
|
2453
|
+
// ../../rules-engine/src/engine/finder-cache.ts
|
|
2454
|
+
import { existsSync as existsSync2, realpathSync as realpathSync3, statSync as statSync2 } from "node:fs";
|
|
2455
|
+
|
|
2456
|
+
// ../../rules-engine/src/engine/scanner.ts
|
|
2457
|
+
import { existsSync, lstatSync, readdirSync, realpathSync as realpathSync2, statSync } from "node:fs";
|
|
2458
|
+
import { isAbsolute as isAbsolute2, join as join2, resolve as resolve3 } from "node:path";
|
|
2459
|
+
function scanRuleFiles(options) {
|
|
2460
|
+
const rootPath = toAbsolutePath(options.rootDir);
|
|
2461
|
+
if (!existsSync(rootPath)) {
|
|
2462
|
+
return [];
|
|
2463
|
+
}
|
|
2464
|
+
let rootStats;
|
|
2465
|
+
try {
|
|
2466
|
+
rootStats = statSync(rootPath);
|
|
2467
|
+
} catch {
|
|
2468
|
+
return [];
|
|
2469
|
+
}
|
|
2470
|
+
if (!rootStats.isDirectory()) {
|
|
2471
|
+
return [];
|
|
2472
|
+
}
|
|
2473
|
+
const results = [];
|
|
2474
|
+
const visitedDirectories = new Set;
|
|
2475
|
+
const excludedDirs = new Set(options.excludedDirs ?? SCANNER_EXCLUDED_DIRS);
|
|
2476
|
+
const maxDepth = options.maxDepth ?? 10;
|
|
2477
|
+
const maxFiles = normalizeMaxFiles(options.maxFiles);
|
|
2478
|
+
scanDirectory(rootPath, 0, maxDepth, maxFiles, excludedDirs, visitedDirectories, results);
|
|
2479
|
+
return results;
|
|
2480
|
+
}
|
|
2481
|
+
function normalizeMaxFiles(maxFiles) {
|
|
2482
|
+
const value = maxFiles ?? DEFAULT_MAX_SCAN_FILES;
|
|
2483
|
+
if (!Number.isFinite(value) || value < 0)
|
|
2484
|
+
return DEFAULT_MAX_SCAN_FILES;
|
|
2485
|
+
return Math.floor(value);
|
|
2486
|
+
}
|
|
2487
|
+
function toAbsolutePath(filePath) {
|
|
2488
|
+
return isAbsolute2(filePath) ? filePath : resolve3(filePath);
|
|
2489
|
+
}
|
|
2490
|
+
function scanDirectory(directoryPath, depth, maxDepth, maxFiles, excludedDirs, visitedDirectories, results) {
|
|
2491
|
+
if (results.length >= maxFiles) {
|
|
2492
|
+
return;
|
|
2493
|
+
}
|
|
2494
|
+
let realDirectoryPath;
|
|
2495
|
+
try {
|
|
2496
|
+
realDirectoryPath = realpathSync2.native(directoryPath);
|
|
2497
|
+
} catch {
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
if (visitedDirectories.has(realDirectoryPath)) {
|
|
2501
|
+
return;
|
|
2502
|
+
}
|
|
2503
|
+
visitedDirectories.add(realDirectoryPath);
|
|
2504
|
+
let entries;
|
|
2505
|
+
try {
|
|
2506
|
+
entries = readdirSync(directoryPath, { withFileTypes: true }).sort((leftEntry, rightEntry) => leftEntry.name.localeCompare(rightEntry.name));
|
|
2507
|
+
} catch {
|
|
2508
|
+
return;
|
|
2509
|
+
}
|
|
2510
|
+
for (const entry of entries) {
|
|
2511
|
+
if (results.length >= maxFiles) {
|
|
2512
|
+
return;
|
|
2513
|
+
}
|
|
2514
|
+
const entryPath = join2(directoryPath, entry.name);
|
|
2515
|
+
if (entry.isDirectory()) {
|
|
2516
|
+
if (!excludedDirs.has(entry.name) && depth < maxDepth) {
|
|
2517
|
+
scanDirectory(entryPath, depth + 1, maxDepth, maxFiles, excludedDirs, visitedDirectories, results);
|
|
2518
|
+
}
|
|
2519
|
+
continue;
|
|
2520
|
+
}
|
|
2521
|
+
if (entry.isSymbolicLink()) {
|
|
2522
|
+
scanSymbolicLink(entryPath, entry.name, depth, maxDepth, maxFiles, excludedDirs, visitedDirectories, results);
|
|
2523
|
+
continue;
|
|
2524
|
+
}
|
|
2525
|
+
if (entry.isFile() && isRuleFile(entry.name)) {
|
|
2526
|
+
results.push({ path: entryPath, realPath: resolveRealPath(entryPath) });
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
function scanSymbolicLink(linkPath, linkName, depth, maxDepth, maxFiles, excludedDirs, visitedDirectories, results) {
|
|
2531
|
+
if (results.length >= maxFiles) {
|
|
2532
|
+
return;
|
|
2533
|
+
}
|
|
2534
|
+
let targetStats;
|
|
2535
|
+
try {
|
|
2536
|
+
targetStats = statSync(linkPath);
|
|
2537
|
+
} catch {
|
|
2538
|
+
return;
|
|
2539
|
+
}
|
|
2540
|
+
if (targetStats.isDirectory()) {
|
|
2541
|
+
if (!excludedDirs.has(linkName) && depth < maxDepth) {
|
|
2542
|
+
scanDirectory(linkPath, depth + 1, maxDepth, maxFiles, excludedDirs, visitedDirectories, results);
|
|
2543
|
+
}
|
|
2544
|
+
return;
|
|
2545
|
+
}
|
|
2546
|
+
if (targetStats.isFile() && isRuleFile(linkName)) {
|
|
2547
|
+
results.push({ path: linkPath, realPath: resolveRealPath(linkPath) });
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
function isRuleFile(fileName) {
|
|
2551
|
+
return RULE_FILE_EXTENSIONS.some((extension) => fileName.endsWith(extension));
|
|
2552
|
+
}
|
|
2553
|
+
function resolveRealPath(filePath) {
|
|
2554
|
+
try {
|
|
2555
|
+
const realPath = realpathSync2.native(filePath);
|
|
2556
|
+
const fileStats = lstatSync(filePath);
|
|
2557
|
+
return fileStats.isSymbolicLink() ? realPath : filePath;
|
|
2558
|
+
} catch {
|
|
2559
|
+
return filePath;
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
// ../../rules-engine/src/engine/finder-cache.ts
|
|
2564
|
+
function createRuleDiscoveryCache() {
|
|
2565
|
+
return { scannedRuleFiles: new Map, singleFileInfo: new Map };
|
|
2566
|
+
}
|
|
2567
|
+
function scanRuleFilesCached(rootDir, cache) {
|
|
2568
|
+
if (cache === undefined) {
|
|
2569
|
+
return scanRuleFiles({ rootDir });
|
|
2570
|
+
}
|
|
2571
|
+
const cached = cache.scannedRuleFiles.get(rootDir);
|
|
2572
|
+
if (cached !== undefined) {
|
|
2573
|
+
return cached;
|
|
2574
|
+
}
|
|
2575
|
+
const scannedFiles = scanRuleFiles({ rootDir });
|
|
2576
|
+
cache.scannedRuleFiles.set(rootDir, scannedFiles);
|
|
2577
|
+
return scannedFiles;
|
|
2578
|
+
}
|
|
2579
|
+
function singleFileInfoCached(filePath, cache) {
|
|
2580
|
+
if (cache === undefined) {
|
|
2581
|
+
return readSingleFileInfo(filePath);
|
|
2582
|
+
}
|
|
2583
|
+
const cached = cache.singleFileInfo.get(filePath);
|
|
2584
|
+
if (cached !== undefined) {
|
|
2585
|
+
return cached;
|
|
2586
|
+
}
|
|
2587
|
+
const fileInfo = readSingleFileInfo(filePath);
|
|
2588
|
+
cache.singleFileInfo.set(filePath, fileInfo);
|
|
2589
|
+
return fileInfo;
|
|
2590
|
+
}
|
|
2591
|
+
function readSingleFileInfo(filePath) {
|
|
2592
|
+
if (!existsSync2(filePath)) {
|
|
2593
|
+
return null;
|
|
2594
|
+
}
|
|
2595
|
+
try {
|
|
2596
|
+
if (!statSync2(filePath).isFile()) {
|
|
2597
|
+
return null;
|
|
2598
|
+
}
|
|
2599
|
+
return { path: filePath, realPath: resolveRealPath2(filePath) };
|
|
2600
|
+
} catch {
|
|
2601
|
+
return null;
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
function resolveRealPath2(filePath) {
|
|
2605
|
+
try {
|
|
2606
|
+
return realpathSync3.native(filePath);
|
|
2607
|
+
} catch {
|
|
2608
|
+
return filePath;
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
// ../../rules-engine/src/engine/finder-paths.ts
|
|
2613
|
+
import { dirname as dirname3, posix, relative as relative2, resolve as resolve4 } from "node:path";
|
|
2614
|
+
function getWalkDirectories(projectRoot, targetFile) {
|
|
2615
|
+
if (targetFile === null) {
|
|
2616
|
+
return [{ directory: projectRoot, distance: 0 }];
|
|
2617
|
+
}
|
|
2618
|
+
const startDirectory = dirname3(resolve4(targetFile));
|
|
2619
|
+
if (!isSameOrChildPath2(startDirectory, projectRoot)) {
|
|
2620
|
+
return [{ directory: projectRoot, distance: 0 }];
|
|
2621
|
+
}
|
|
2622
|
+
const walkDirectories = [];
|
|
2623
|
+
let currentDirectory = startDirectory;
|
|
2624
|
+
let distance = 0;
|
|
2625
|
+
while (true) {
|
|
2626
|
+
walkDirectories.push({ directory: currentDirectory, distance });
|
|
2627
|
+
if (currentDirectory === projectRoot) {
|
|
2628
|
+
break;
|
|
2629
|
+
}
|
|
2630
|
+
const parentDirectory = dirname3(currentDirectory);
|
|
2631
|
+
if (parentDirectory === currentDirectory) {
|
|
2632
|
+
break;
|
|
2633
|
+
}
|
|
2634
|
+
currentDirectory = parentDirectory;
|
|
2635
|
+
distance += 1;
|
|
2636
|
+
}
|
|
2637
|
+
return walkDirectories;
|
|
2638
|
+
}
|
|
2639
|
+
function toRelativePath(rootDirectory, filePath) {
|
|
2640
|
+
return posix.normalize(relative2(rootDirectory, filePath).replace(/\\/g, "/"));
|
|
2641
|
+
}
|
|
2642
|
+
function isSameOrChildPath2(childPath, parentPath) {
|
|
2643
|
+
const childRelativePath = relative2(parentPath, childPath);
|
|
2644
|
+
return childRelativePath === "" || !childRelativePath.startsWith("..") && !childRelativePath.startsWith("/");
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
// ../../rules-engine/src/engine/finder-sources.ts
|
|
2648
|
+
function toProjectRuleSource(parentDirectory, subDirectory) {
|
|
2649
|
+
const source = `${parentDirectory}/${subDirectory}`;
|
|
2650
|
+
switch (source) {
|
|
2651
|
+
case ".omo/rules":
|
|
2652
|
+
case ".claude/rules":
|
|
2653
|
+
case ".cursor/rules":
|
|
2654
|
+
case ".github/instructions":
|
|
2655
|
+
return source;
|
|
2656
|
+
default:
|
|
2657
|
+
throw new UnsupportedRuleSourceError(`Unsupported project rule source: ${source}`);
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2660
|
+
function toProjectSingleFileSource(ruleFile) {
|
|
2661
|
+
switch (ruleFile) {
|
|
2662
|
+
case ".github/copilot-instructions.md":
|
|
2663
|
+
case "CONTEXT.md":
|
|
2664
|
+
return ruleFile;
|
|
2665
|
+
default:
|
|
2666
|
+
throw new UnsupportedRuleSourceError(`Unsupported project single-file source: ${ruleFile}`);
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
function toUserHomeRuleSource(ruleSubdir) {
|
|
2670
|
+
const source = `~/${ruleSubdir}`;
|
|
2671
|
+
switch (source) {
|
|
2672
|
+
case "~/.omo/rules":
|
|
2673
|
+
case "~/.opencode/rules":
|
|
2674
|
+
case "~/.claude/rules":
|
|
2675
|
+
return source;
|
|
2676
|
+
default:
|
|
2677
|
+
throw new UnsupportedRuleSourceError(`Unsupported user-home rule source: ${source}`);
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
function toUserHomeSingleFileSource(ruleFile) {
|
|
2681
|
+
const source = `~/${ruleFile}`;
|
|
2682
|
+
switch (source) {
|
|
2683
|
+
default:
|
|
2684
|
+
throw new UnsupportedRuleSourceError(`Unsupported user-home single-file source: ${source}`);
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
// ../../rules-engine/src/engine/plugin-root.ts
|
|
2689
|
+
import { statSync as statSync3 } from "node:fs";
|
|
2690
|
+
import { join as join3, resolve as resolve5 } from "node:path";
|
|
2691
|
+
import { fileURLToPath } from "node:url";
|
|
2692
|
+
function resolvePluginRulesRoot(pluginRoot, moduleUrl = import.meta.url) {
|
|
2693
|
+
const configuredRoot = pluginRoot ?? process.env["PLUGIN_ROOT"];
|
|
2694
|
+
if (configuredRoot !== undefined && configuredRoot.trim().length > 0) {
|
|
2695
|
+
return resolveRulesComponentRoot(resolve5(configuredRoot));
|
|
2696
|
+
}
|
|
2697
|
+
return fileURLToPath(new URL("../../..", moduleUrl));
|
|
2698
|
+
}
|
|
2699
|
+
function resolveRulesComponentRoot(pluginRoot) {
|
|
2700
|
+
const componentRoot = join3(pluginRoot, "components", "rules");
|
|
2701
|
+
return isDirectory(componentRoot) ? componentRoot : pluginRoot;
|
|
2702
|
+
}
|
|
2703
|
+
function isDirectory(path) {
|
|
2704
|
+
try {
|
|
2705
|
+
return statSync3(path).isDirectory();
|
|
2706
|
+
} catch {
|
|
2707
|
+
return false;
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
// ../../rules-engine/src/engine/finder.ts
|
|
2712
|
+
var WINDOWS_GIT_BASH_BUNDLED_RULE_PATH = "bundled-rules/windows-git-bash.md";
|
|
2713
|
+
function findRuleCandidates(options) {
|
|
2714
|
+
const skipUserHome = options.skipUserHome ?? false;
|
|
2715
|
+
const disabledSources = options.disabledSources ?? new Set;
|
|
2716
|
+
const candidates = [];
|
|
2717
|
+
const homeDirectory = resolve6(options.homeDir ?? homedir());
|
|
2718
|
+
if (options.projectRoot !== null) {
|
|
2719
|
+
candidates.push(...findProjectCandidates(options.projectRoot, options.targetFile, disabledSources, options.cache));
|
|
2720
|
+
}
|
|
2721
|
+
const pluginBundledOptions = {
|
|
2722
|
+
disabledSources,
|
|
2723
|
+
...options.cache === undefined ? {} : { cache: options.cache },
|
|
2724
|
+
...options.pluginRoot === undefined ? {} : { pluginRoot: options.pluginRoot },
|
|
2725
|
+
...options.platform === undefined ? {} : { platform: options.platform }
|
|
2726
|
+
};
|
|
2727
|
+
candidates.push(...findPluginBundledCandidates(pluginBundledOptions));
|
|
2728
|
+
if (!skipUserHome) {
|
|
2729
|
+
candidates.push(...findUserHomeCandidates(homeDirectory, disabledSources, options.cache));
|
|
2730
|
+
}
|
|
2731
|
+
return candidates;
|
|
2732
|
+
}
|
|
2733
|
+
function findPluginBundledCandidates(options = {}) {
|
|
2734
|
+
if (options.disabledSources?.has("plugin-bundled") === true) {
|
|
2735
|
+
return [];
|
|
2736
|
+
}
|
|
2737
|
+
const pluginRoot = resolvePluginRulesRoot(options.pluginRoot);
|
|
2738
|
+
const ruleDirectory = join4(pluginRoot, BUNDLED_RULE_SUBDIR);
|
|
2739
|
+
const platform = options.platform ?? process.platform;
|
|
2740
|
+
const candidates = [];
|
|
2741
|
+
for (const scannedFile of scanRuleFilesCached(ruleDirectory, options.cache)) {
|
|
2742
|
+
const candidate = {
|
|
2743
|
+
path: scannedFile.path,
|
|
2744
|
+
realPath: scannedFile.realPath,
|
|
2745
|
+
source: "plugin-bundled",
|
|
2746
|
+
distance: GLOBAL_DISTANCE,
|
|
2747
|
+
isGlobal: true,
|
|
2748
|
+
isSingleFile: false,
|
|
2749
|
+
relativePath: toRelativePath(pluginRoot, scannedFile.path)
|
|
2750
|
+
};
|
|
2751
|
+
if (isPluginBundledCandidateEnabled(candidate, platform)) {
|
|
2752
|
+
candidates.push(candidate);
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
return candidates;
|
|
2756
|
+
}
|
|
2757
|
+
function isPluginBundledCandidateEnabled(candidate, platform) {
|
|
2758
|
+
return candidate.relativePath !== WINDOWS_GIT_BASH_BUNDLED_RULE_PATH || platform === "win32";
|
|
2759
|
+
}
|
|
2760
|
+
function findProjectCandidates(projectRoot, targetFile, disabledSources, cache) {
|
|
2761
|
+
const rootDirectory = resolve6(projectRoot);
|
|
2762
|
+
const walkDirectories = getWalkDirectories(rootDirectory, targetFile);
|
|
2763
|
+
const candidates = [];
|
|
2764
|
+
for (const walkDirectory of walkDirectories) {
|
|
2765
|
+
for (const [parentDirectory, subDirectory] of PROJECT_RULE_SUBDIRS) {
|
|
2766
|
+
const source = toProjectRuleSource(parentDirectory, subDirectory);
|
|
2767
|
+
if (disabledSources.has(source)) {
|
|
2768
|
+
continue;
|
|
2769
|
+
}
|
|
2770
|
+
const ruleDirectory = join4(walkDirectory.directory, parentDirectory, subDirectory);
|
|
2771
|
+
for (const scannedFile of scanRuleFilesCached(ruleDirectory, cache)) {
|
|
2772
|
+
candidates.push({
|
|
2773
|
+
path: scannedFile.path,
|
|
2774
|
+
realPath: scannedFile.realPath,
|
|
2775
|
+
source,
|
|
2776
|
+
distance: targetFile === null ? 0 : walkDirectory.distance,
|
|
2777
|
+
isGlobal: false,
|
|
2778
|
+
isSingleFile: false,
|
|
2779
|
+
relativePath: toRelativePath(rootDirectory, scannedFile.path)
|
|
2780
|
+
});
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
for (const walkDirectory of walkDirectories) {
|
|
2785
|
+
for (const ruleFile of PROJECT_SINGLE_FILES) {
|
|
2786
|
+
const source = toProjectSingleFileSource(ruleFile);
|
|
2787
|
+
if (disabledSources.has(source)) {
|
|
2788
|
+
continue;
|
|
2789
|
+
}
|
|
2790
|
+
const filePath = join4(walkDirectory.directory, ruleFile);
|
|
2791
|
+
const fileInfo = singleFileInfoCached(filePath, cache);
|
|
2792
|
+
if (fileInfo === null) {
|
|
2793
|
+
continue;
|
|
2794
|
+
}
|
|
2795
|
+
candidates.push({
|
|
2796
|
+
path: fileInfo.path,
|
|
2797
|
+
realPath: fileInfo.realPath,
|
|
2798
|
+
source,
|
|
2799
|
+
distance: targetFile === null ? 0 : walkDirectory.distance,
|
|
2800
|
+
isGlobal: false,
|
|
2801
|
+
isSingleFile: true,
|
|
2802
|
+
relativePath: toRelativePath(rootDirectory, filePath)
|
|
2803
|
+
});
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
return candidates;
|
|
2807
|
+
}
|
|
2808
|
+
function findUserHomeCandidates(homeDirectory, disabledSources, cache) {
|
|
2809
|
+
const candidates = [];
|
|
2810
|
+
for (const ruleSubdir of USER_HOME_RULE_SUBDIRS) {
|
|
2811
|
+
const source = toUserHomeRuleSource(ruleSubdir);
|
|
2812
|
+
if (disabledSources.has(source)) {
|
|
2813
|
+
continue;
|
|
2814
|
+
}
|
|
2815
|
+
const ruleDirectory = join4(homeDirectory, ruleSubdir);
|
|
2816
|
+
for (const scannedFile of scanRuleFilesCached(ruleDirectory, cache)) {
|
|
2817
|
+
candidates.push({
|
|
2818
|
+
path: scannedFile.path,
|
|
2819
|
+
realPath: scannedFile.realPath,
|
|
2820
|
+
source,
|
|
2821
|
+
distance: GLOBAL_DISTANCE,
|
|
2822
|
+
isGlobal: true,
|
|
2823
|
+
isSingleFile: false,
|
|
2824
|
+
relativePath: toRelativePath(homeDirectory, scannedFile.path)
|
|
2825
|
+
});
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
for (const ruleFile of USER_HOME_SINGLE_FILES) {
|
|
2829
|
+
const source = toUserHomeSingleFileSource(ruleFile);
|
|
2830
|
+
if (disabledSources.has(source)) {
|
|
2831
|
+
continue;
|
|
2832
|
+
}
|
|
2833
|
+
const filePath = join4(homeDirectory, ruleFile);
|
|
2834
|
+
const fileInfo = singleFileInfoCached(filePath, cache);
|
|
2835
|
+
if (fileInfo === null) {
|
|
2836
|
+
continue;
|
|
2837
|
+
}
|
|
2838
|
+
candidates.push({
|
|
2839
|
+
path: fileInfo.path,
|
|
2840
|
+
realPath: fileInfo.realPath,
|
|
2841
|
+
source,
|
|
2842
|
+
distance: GLOBAL_DISTANCE,
|
|
2843
|
+
isGlobal: true,
|
|
2844
|
+
isSingleFile: true,
|
|
2845
|
+
relativePath: toRelativePath(homeDirectory, filePath)
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
return candidates;
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
// ../../rules-engine/src/engine/sources.ts
|
|
2852
|
+
var DEFAULT_AUTO_DISABLED_SOURCES = ["AGENTS.md", "~/.claude/rules", "~/.claude/CLAUDE.md"];
|
|
2853
|
+
function disabledSourcesFromConfig(config) {
|
|
2854
|
+
if (config.enabledSources === "auto") {
|
|
2855
|
+
return new Set(DEFAULT_AUTO_DISABLED_SOURCES);
|
|
2856
|
+
}
|
|
2857
|
+
const enabledSources = new Set(config.enabledSources);
|
|
2858
|
+
return new Set([...SOURCE_PRIORITY.keys()].filter((source) => !enabledSources.has(source)));
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
// ../../rules-engine/src/engine/engine-dynamic-loader.ts
|
|
2862
|
+
function loadDynamicCandidates(config, deps, cwd, targetPaths, dynamicMatchCache) {
|
|
2863
|
+
const rules = [];
|
|
2864
|
+
const diagnostics = [];
|
|
2865
|
+
const seenRules = new Set;
|
|
2866
|
+
const loadedRuleContent = new Map;
|
|
2867
|
+
const projectMembership = new Map;
|
|
2868
|
+
const disabledSources = disabledSourcesFromConfig(config);
|
|
2869
|
+
const discoveryCache = createRuleDiscoveryCache();
|
|
2870
|
+
const candidateDiscoveryCache = new Map;
|
|
2871
|
+
const cwdProjectRoot = deps.findProjectRoot(cwd);
|
|
2872
|
+
for (const targetFile of uniqueStrings(targetPaths)) {
|
|
2873
|
+
const projectRoot = cwdProjectRoot !== null && isSameOrChildPath(targetFile, cwdProjectRoot) ? cwdProjectRoot : deps.findProjectRoot(targetFile);
|
|
2874
|
+
const findOptions = {
|
|
2875
|
+
projectRoot,
|
|
2876
|
+
targetFile,
|
|
2877
|
+
cache: discoveryCache
|
|
2878
|
+
};
|
|
2879
|
+
if (disabledSources !== undefined) {
|
|
2880
|
+
findOptions.disabledSources = disabledSources;
|
|
2881
|
+
}
|
|
2882
|
+
const candidates = findSortedCandidatesCached(candidateDiscoveryCache, deps.findCandidates, findOptions);
|
|
2883
|
+
for (const candidate of candidates) {
|
|
2884
|
+
const loadedRule = loadCandidate(candidate, deps, diagnostics, projectRoot, loadedRuleContent, projectMembership);
|
|
2885
|
+
if (loadedRule === null) {
|
|
2886
|
+
continue;
|
|
2887
|
+
}
|
|
2888
|
+
const matchReason = matchDynamicRuleCached(dynamicMatchCache, projectRoot, targetFile, candidate, loadedRule, deps.matchRule ?? matchRule);
|
|
2889
|
+
if (matchReason === null) {
|
|
2890
|
+
continue;
|
|
2891
|
+
}
|
|
2892
|
+
const dedupKey = ruleDedupKey(loadedRule);
|
|
2893
|
+
if (seenRules.has(dedupKey)) {
|
|
2894
|
+
continue;
|
|
2895
|
+
}
|
|
2896
|
+
seenRules.add(dedupKey);
|
|
2897
|
+
rules.push({ ...loadedRule, matchReason });
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
return { rules: sortCandidates(rules), diagnostics };
|
|
2901
|
+
}
|
|
2902
|
+
function uniqueStrings(values) {
|
|
2903
|
+
const uniqueValues = [];
|
|
2904
|
+
const seenValues = new Set;
|
|
2905
|
+
for (const value of values) {
|
|
2906
|
+
if (seenValues.has(value)) {
|
|
2907
|
+
continue;
|
|
2908
|
+
}
|
|
2909
|
+
seenValues.add(value);
|
|
2910
|
+
uniqueValues.push(value);
|
|
2911
|
+
}
|
|
2912
|
+
return uniqueValues;
|
|
2913
|
+
}
|
|
2914
|
+
// ../../rules-engine/src/engine/engine-static-loader.ts
|
|
2915
|
+
function loadStaticCandidates(candidates, deps, projectRoot) {
|
|
2916
|
+
const rules = [];
|
|
2917
|
+
const diagnostics = [];
|
|
2918
|
+
let rootSingleFileSelected = false;
|
|
2919
|
+
for (const candidate of sortCandidates(candidates)) {
|
|
2920
|
+
if (isDedupedRootSingleFile(candidate, rootSingleFileSelected)) {
|
|
2921
|
+
continue;
|
|
2922
|
+
}
|
|
2923
|
+
const loadedRule = loadCandidate(candidate, deps, diagnostics, projectRoot);
|
|
2924
|
+
if (loadedRule === null) {
|
|
2925
|
+
continue;
|
|
2926
|
+
}
|
|
2927
|
+
const matchReason = staticMatchReason(loadedRule);
|
|
2928
|
+
if (matchReason === null) {
|
|
2929
|
+
continue;
|
|
2930
|
+
}
|
|
2931
|
+
if (isRootSingleFile(candidate)) {
|
|
2932
|
+
rootSingleFileSelected = true;
|
|
2933
|
+
}
|
|
2934
|
+
rules.push({ ...loadedRule, matchReason });
|
|
2935
|
+
}
|
|
2936
|
+
return { rules: sortCandidates(rules), diagnostics };
|
|
2937
|
+
}
|
|
2938
|
+
function isDedupedRootSingleFile(candidate, rootSingleFileSelected) {
|
|
2939
|
+
return rootSingleFileSelected && isRootSingleFile(candidate);
|
|
2940
|
+
}
|
|
2941
|
+
// ../../rules-engine/src/engine/truncator.ts
|
|
2942
|
+
function truncationNotice(relativePath) {
|
|
2943
|
+
return TRUNCATION_NOTICE.replace("{path}", relativePath);
|
|
2944
|
+
}
|
|
2945
|
+
function isNeverTruncatedRule(relativePath) {
|
|
2946
|
+
const normalized = relativePath.replace(/\\/g, "/");
|
|
2947
|
+
const segments = normalized.split("/").filter((segment) => segment.length > 0);
|
|
2948
|
+
const filename = segments.at(-1) ?? normalized;
|
|
2949
|
+
return filename.toLowerCase() === "hephaestus.md";
|
|
2950
|
+
}
|
|
2951
|
+
function safeSliceEnd(body, end) {
|
|
2952
|
+
if (end <= 0) {
|
|
2953
|
+
return 0;
|
|
2954
|
+
}
|
|
2955
|
+
const lastCodeUnit = body.charCodeAt(end - 1);
|
|
2956
|
+
if (lastCodeUnit >= 55296 && lastCodeUnit <= 56319) {
|
|
2957
|
+
return end - 1;
|
|
2958
|
+
}
|
|
2959
|
+
return end;
|
|
2960
|
+
}
|
|
2961
|
+
function truncateRule(body, options) {
|
|
2962
|
+
if (isNeverTruncatedRule(options.relativePath)) {
|
|
2963
|
+
return { body, truncated: false, originalLength: body.length };
|
|
2964
|
+
}
|
|
2965
|
+
if (body.length <= options.maxChars) {
|
|
2966
|
+
return { body, truncated: false, originalLength: body.length };
|
|
2967
|
+
}
|
|
2968
|
+
const notice = truncationNotice(options.relativePath);
|
|
2969
|
+
if (options.maxChars < notice.length) {
|
|
2970
|
+
return { body: notice, truncated: true, originalLength: body.length };
|
|
2971
|
+
}
|
|
2972
|
+
const sliceEnd = safeSliceEnd(body, options.maxChars - notice.length);
|
|
2973
|
+
return { body: `${body.slice(0, sliceEnd)}${notice}`, truncated: true, originalLength: body.length };
|
|
2974
|
+
}
|
|
2975
|
+
function truncateBudget(input) {
|
|
2976
|
+
const results = [];
|
|
2977
|
+
let remainingBudget = input.maxResultChars;
|
|
2978
|
+
for (const rule of input.rules) {
|
|
2979
|
+
if (isNeverTruncatedRule(rule.relativePath)) {
|
|
2980
|
+
results.push({ body: rule.body, truncated: false, relativePath: rule.relativePath });
|
|
2981
|
+
remainingBudget -= rule.body.length;
|
|
2982
|
+
continue;
|
|
2983
|
+
}
|
|
2984
|
+
if (remainingBudget >= rule.body.length) {
|
|
2985
|
+
results.push({ body: rule.body, truncated: false, relativePath: rule.relativePath });
|
|
2986
|
+
remainingBudget -= rule.body.length;
|
|
2987
|
+
continue;
|
|
2988
|
+
}
|
|
2989
|
+
const notice = truncationNotice(rule.relativePath);
|
|
2990
|
+
if (remainingBudget <= notice.length) {
|
|
2991
|
+
break;
|
|
2992
|
+
}
|
|
2993
|
+
const sliceEnd = safeSliceEnd(rule.body, remainingBudget - notice.length);
|
|
2994
|
+
const body = `${rule.body.slice(0, sliceEnd)}${notice}`;
|
|
2995
|
+
results.push({ body, truncated: true, relativePath: rule.relativePath });
|
|
2996
|
+
remainingBudget -= body.length;
|
|
2997
|
+
}
|
|
2998
|
+
return results;
|
|
2999
|
+
}
|
|
3000
|
+
|
|
3001
|
+
// ../../rules-engine/src/engine/formatter.ts
|
|
3002
|
+
function formatRule(rule) {
|
|
3003
|
+
const body = normalizeRuleBody(rule.body);
|
|
3004
|
+
if (body.length === 0) {
|
|
3005
|
+
return `Instructions from: ${rule.path}`;
|
|
3006
|
+
}
|
|
3007
|
+
return `Instructions from: ${rule.path}
|
|
3008
|
+
|
|
3009
|
+
${body}`;
|
|
3010
|
+
}
|
|
3011
|
+
function truncateRules(rules, options) {
|
|
3012
|
+
const perRuleNormalized = rules.map((rule) => ({
|
|
3013
|
+
path: rule.path,
|
|
3014
|
+
relativePath: rule.relativePath,
|
|
3015
|
+
body: normalizeRuleBody(rule.body),
|
|
3016
|
+
source: rule.source
|
|
3017
|
+
}));
|
|
3018
|
+
const perRuleResultChars = Math.floor(options.maxResultChars / Math.max(1, perRuleNormalized.length));
|
|
3019
|
+
const perRuleBudgeted = perRuleNormalized.map((rule) => ({
|
|
3020
|
+
path: rule.path,
|
|
3021
|
+
relativePath: rule.relativePath,
|
|
3022
|
+
body: isNeverTruncatedRule(rule.relativePath) ? rule.body : truncateRule(rule.body, {
|
|
3023
|
+
maxChars: Math.min(options.maxRuleChars, perRuleResultChars),
|
|
3024
|
+
relativePath: rule.relativePath
|
|
3025
|
+
}).body
|
|
3026
|
+
}));
|
|
3027
|
+
const budgetedRules = truncateBudget({
|
|
3028
|
+
rules: perRuleBudgeted.map((rule) => ({ body: rule.body, relativePath: rule.relativePath })),
|
|
3029
|
+
maxResultChars: options.maxResultChars
|
|
3030
|
+
});
|
|
3031
|
+
const truncatedRules = [];
|
|
3032
|
+
for (let index = 0;index < budgetedRules.length; index += 1) {
|
|
3033
|
+
const sourceRule = perRuleBudgeted[index];
|
|
3034
|
+
const budgetedRule = budgetedRules[index];
|
|
3035
|
+
if (sourceRule === undefined || budgetedRule === undefined) {
|
|
3036
|
+
continue;
|
|
3037
|
+
}
|
|
3038
|
+
truncatedRules.push({
|
|
3039
|
+
path: sourceRule.path,
|
|
3040
|
+
relativePath: budgetedRule.relativePath,
|
|
3041
|
+
body: budgetedRule.body
|
|
3042
|
+
});
|
|
3043
|
+
}
|
|
3044
|
+
return truncatedRules;
|
|
3045
|
+
}
|
|
3046
|
+
function formatStaticBlock(rules, options) {
|
|
3047
|
+
if (rules.length === 0) {
|
|
3048
|
+
return "";
|
|
3049
|
+
}
|
|
3050
|
+
if (options.maxResultChars <= 0) {
|
|
3051
|
+
return "";
|
|
3052
|
+
}
|
|
3053
|
+
const orderedRules = orderStaticRules(uniqueRulesByBody(rules));
|
|
3054
|
+
return ["## Project Instructions", "", truncateRules(orderedRules, options).map(formatRule).join(`
|
|
3055
|
+
|
|
3056
|
+
`)].join(`
|
|
3057
|
+
`);
|
|
3058
|
+
}
|
|
3059
|
+
function orderStaticRules(rules) {
|
|
3060
|
+
const hephaestusRules = [];
|
|
3061
|
+
const otherRules = [];
|
|
3062
|
+
for (const rule of rules) {
|
|
3063
|
+
if (isHephaestusRule(rule)) {
|
|
3064
|
+
hephaestusRules.push(rule);
|
|
3065
|
+
continue;
|
|
3066
|
+
}
|
|
3067
|
+
otherRules.push(rule);
|
|
3068
|
+
}
|
|
3069
|
+
return [...hephaestusRules, ...otherRules];
|
|
3070
|
+
}
|
|
3071
|
+
function isHephaestusRule(rule) {
|
|
3072
|
+
return displayFilename(rule).toLowerCase() === "hephaestus.md";
|
|
3073
|
+
}
|
|
3074
|
+
function displayFilename(rule) {
|
|
3075
|
+
const normalizedPath = rule.relativePath.length > 0 ? rule.relativePath : rule.path;
|
|
3076
|
+
const segments = normalizedPath.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0);
|
|
3077
|
+
return segments.at(-1) ?? normalizedPath;
|
|
3078
|
+
}
|
|
3079
|
+
function uniqueRulesByBody(rules) {
|
|
3080
|
+
const uniqueRules = [];
|
|
3081
|
+
const seenBodies = new Set;
|
|
3082
|
+
const userDescriptions = new Set;
|
|
3083
|
+
for (const rule of rules) {
|
|
3084
|
+
const descriptionKey = rule.frontmatter.description?.trim();
|
|
3085
|
+
if (rule.source === "plugin-bundled" && descriptionKey !== undefined && userDescriptions.has(descriptionKey)) {
|
|
3086
|
+
continue;
|
|
3087
|
+
}
|
|
3088
|
+
const bodyKey = normalizeRuleBody(rule.body);
|
|
3089
|
+
if (seenBodies.has(bodyKey)) {
|
|
3090
|
+
continue;
|
|
3091
|
+
}
|
|
3092
|
+
seenBodies.add(bodyKey);
|
|
3093
|
+
if (descriptionKey !== undefined && rule.source !== "plugin-bundled") {
|
|
3094
|
+
userDescriptions.add(descriptionKey);
|
|
3095
|
+
}
|
|
3096
|
+
uniqueRules.push(rule);
|
|
3097
|
+
}
|
|
3098
|
+
return uniqueRules;
|
|
3099
|
+
}
|
|
3100
|
+
function formatDynamicBlock(rules, targetRelativePath, options) {
|
|
3101
|
+
if (rules.length === 0) {
|
|
3102
|
+
return "";
|
|
3103
|
+
}
|
|
3104
|
+
return [
|
|
3105
|
+
`Additional project instructions matched for ${targetRelativePath}:`,
|
|
3106
|
+
"",
|
|
3107
|
+
truncateRules(rules, options).map(formatRule).join(`
|
|
3108
|
+
|
|
3109
|
+
`)
|
|
3110
|
+
].join(`
|
|
3111
|
+
`);
|
|
3112
|
+
}
|
|
3113
|
+
function normalizeRuleBody(body) {
|
|
3114
|
+
return body.replace(/\r\n/g, `
|
|
3115
|
+
`).replace(/\r/g, `
|
|
3116
|
+
`).trim();
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
// ../../rules-engine/src/engine/engine.ts
|
|
3120
|
+
function defaultConfig() {
|
|
3121
|
+
return {
|
|
3122
|
+
disabled: false,
|
|
3123
|
+
mode: "both",
|
|
3124
|
+
maxRuleChars: DEFAULT_MAX_RULE_CHARS,
|
|
3125
|
+
maxResultChars: DEFAULT_MAX_RESULT_CHARS,
|
|
3126
|
+
postCompactMaxRuleChars: DEFAULT_POST_COMPACT_MAX_RULE_CHARS,
|
|
3127
|
+
postCompactMaxResultChars: DEFAULT_POST_COMPACT_MAX_RESULT_CHARS,
|
|
3128
|
+
dynamicMaxRuleChars: DEFAULT_DYNAMIC_MAX_RULE_CHARS,
|
|
3129
|
+
dynamicMaxResultChars: DEFAULT_DYNAMIC_MAX_RESULT_CHARS,
|
|
3130
|
+
promptMaxRuleChars: DEFAULT_PROMPT_MAX_RULE_CHARS,
|
|
3131
|
+
promptMaxResultChars: DEFAULT_PROMPT_MAX_RESULT_CHARS,
|
|
3132
|
+
enabledSources: "auto"
|
|
3133
|
+
};
|
|
3134
|
+
}
|
|
3135
|
+
function createEngine(config, deps) {
|
|
3136
|
+
const state = createSessionState();
|
|
3137
|
+
const dynamicMatchCache = new Map;
|
|
3138
|
+
function loadStaticRules(cwd) {
|
|
3139
|
+
state.cwd = cwd;
|
|
3140
|
+
if (config.disabled || config.mode === "off" || config.mode === "dynamic") {
|
|
3141
|
+
return emptyLoadResult(state);
|
|
3142
|
+
}
|
|
3143
|
+
const projectRoot = deps.findProjectRoot(cwd);
|
|
3144
|
+
const findOptions = {
|
|
3145
|
+
projectRoot,
|
|
3146
|
+
targetFile: null
|
|
3147
|
+
};
|
|
3148
|
+
const disabledSources = disabledSourcesFromConfig(config);
|
|
3149
|
+
if (disabledSources !== undefined) {
|
|
3150
|
+
findOptions.disabledSources = disabledSources;
|
|
3151
|
+
}
|
|
3152
|
+
const candidates = deps.findCandidates(findOptions);
|
|
3153
|
+
const result = loadStaticCandidates(candidates, deps, projectRoot);
|
|
3154
|
+
storeLastLoad(state, result.rules, result.diagnostics);
|
|
3155
|
+
return result;
|
|
3156
|
+
}
|
|
3157
|
+
function loadDynamicRules(cwd, targetPaths) {
|
|
3158
|
+
state.cwd = cwd;
|
|
3159
|
+
if (config.disabled || config.mode === "off" || config.mode === "static" || targetPaths.length === 0) {
|
|
3160
|
+
return emptyLoadResult(state);
|
|
3161
|
+
}
|
|
3162
|
+
const result = loadDynamicCandidates(config, deps, cwd, targetPaths, dynamicMatchCache);
|
|
3163
|
+
storeLastLoad(state, result.rules, result.diagnostics);
|
|
3164
|
+
return result;
|
|
3165
|
+
}
|
|
3166
|
+
return {
|
|
3167
|
+
state,
|
|
3168
|
+
config,
|
|
3169
|
+
loadStaticRules,
|
|
3170
|
+
loadDynamicRules,
|
|
3171
|
+
formatStatic: (rules) => formatStaticBlock(rules, { maxRuleChars: config.maxRuleChars, maxResultChars: config.maxResultChars }),
|
|
3172
|
+
formatDynamic: (rules, target) => formatDynamicBlock(rules, target, {
|
|
3173
|
+
maxRuleChars: config.maxRuleChars,
|
|
3174
|
+
maxResultChars: config.maxResultChars
|
|
3175
|
+
}),
|
|
3176
|
+
resetSession: (cwd) => {
|
|
3177
|
+
clearSession(state);
|
|
3178
|
+
dynamicMatchCache.clear();
|
|
3179
|
+
if (cwd !== undefined) {
|
|
3180
|
+
state.cwd = cwd;
|
|
3181
|
+
}
|
|
3182
|
+
},
|
|
3183
|
+
isStaticInjected: (rule) => isStaticInjected(state, rule),
|
|
3184
|
+
isDynamicInjected: (rule) => isDynamicInjected(state, rule),
|
|
3185
|
+
markStaticInjected: (rule) => markStaticInjected(state, rule),
|
|
3186
|
+
markDynamicInjected: (rule) => markDynamicInjected(state, rule)
|
|
3187
|
+
};
|
|
3188
|
+
}
|
|
3189
|
+
function storeLastLoad(state, rules, diagnostics) {
|
|
3190
|
+
state.loadedRules.length = 0;
|
|
3191
|
+
state.loadedRules.push(...rules);
|
|
3192
|
+
state.diagnostics.length = 0;
|
|
3193
|
+
state.diagnostics.push(...diagnostics);
|
|
3194
|
+
}
|
|
3195
|
+
function emptyLoadResult(state) {
|
|
3196
|
+
storeLastLoad(state, [], []);
|
|
3197
|
+
return { rules: [], diagnostics: [] };
|
|
3198
|
+
}
|
|
3199
|
+
// ../../rules-engine/src/engine/project-root.ts
|
|
3200
|
+
import { existsSync as existsSync3, statSync as statSync4 } from "node:fs";
|
|
3201
|
+
import { dirname as dirname4, join as join5, resolve as resolve7 } from "node:path";
|
|
3202
|
+
function findProjectRoot(startPath, markers = PROJECT_MARKERS) {
|
|
3203
|
+
const resolvedStartPath = resolve7(startPath);
|
|
3204
|
+
if (!existsSync3(resolvedStartPath)) {
|
|
3205
|
+
return null;
|
|
3206
|
+
}
|
|
3207
|
+
const startStats = statSync4(resolvedStartPath);
|
|
3208
|
+
let currentDirectory = startStats.isDirectory() ? resolvedStartPath : dirname4(resolvedStartPath);
|
|
3209
|
+
const filesystemRoot = resolve7("/");
|
|
3210
|
+
while (true) {
|
|
3211
|
+
for (const marker of markers) {
|
|
3212
|
+
if (existsSync3(join5(currentDirectory, marker))) {
|
|
3213
|
+
return currentDirectory;
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
const parentDirectory = dirname4(currentDirectory);
|
|
3217
|
+
if (currentDirectory === filesystemRoot || parentDirectory === currentDirectory) {
|
|
3218
|
+
return null;
|
|
3219
|
+
}
|
|
3220
|
+
currentDirectory = parentDirectory;
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
// components/rules/src/config.ts
|
|
3224
|
+
function configFromEnvironment(env = process.env) {
|
|
3225
|
+
const config = defaultConfig();
|
|
3226
|
+
const disableBundledRules = isTruthy(firstEnv(env, "CODEX_RULES_DISABLE_BUNDLED", "PI_RULES_DISABLE_BUNDLED"));
|
|
3227
|
+
config.disabled = isTruthy(firstEnv(env, "CODEX_RULES_DISABLED", "PI_RULES_DISABLED"));
|
|
3228
|
+
config.mode = parseMode(firstEnv(env, "CODEX_RULES_MODE", "PI_RULES_MODE")) ?? config.mode;
|
|
3229
|
+
config.maxRuleChars = parsePositiveInteger(firstEnv(env, "CODEX_RULES_MAX_RULE_CHARS", "PI_RULES_MAX_RULE_CHARS")) ?? config.maxRuleChars;
|
|
3230
|
+
config.maxResultChars = parsePositiveInteger(firstEnv(env, "CODEX_RULES_MAX_RESULT_CHARS", "PI_RULES_MAX_RESULT_CHARS")) ?? config.maxResultChars;
|
|
3231
|
+
config.postCompactMaxRuleChars = parsePositiveInteger(firstEnv(env, "CODEX_RULES_POST_COMPACT_MAX_RULE_CHARS", "PI_RULES_POST_COMPACT_MAX_RULE_CHARS")) ?? config.postCompactMaxRuleChars;
|
|
3232
|
+
config.postCompactMaxResultChars = parsePositiveInteger(firstEnv(env, "CODEX_RULES_POST_COMPACT_MAX_RESULT_CHARS", "PI_RULES_POST_COMPACT_MAX_RESULT_CHARS")) ?? config.postCompactMaxResultChars;
|
|
3233
|
+
config.dynamicMaxRuleChars = parsePositiveInteger(firstEnv(env, "CODEX_RULES_DYNAMIC_MAX_RULE_CHARS", "PI_RULES_DYNAMIC_MAX_RULE_CHARS")) ?? config.dynamicMaxRuleChars;
|
|
3234
|
+
config.dynamicMaxResultChars = parsePositiveInteger(firstEnv(env, "CODEX_RULES_DYNAMIC_MAX_RESULT_CHARS", "PI_RULES_DYNAMIC_MAX_RESULT_CHARS")) ?? config.dynamicMaxResultChars;
|
|
3235
|
+
config.promptMaxRuleChars = parsePositiveInteger(firstEnv(env, "CODEX_RULES_PROMPT_MAX_RULE_CHARS", "PI_RULES_PROMPT_MAX_RULE_CHARS")) ?? config.promptMaxRuleChars;
|
|
3236
|
+
config.promptMaxResultChars = parsePositiveInteger(firstEnv(env, "CODEX_RULES_PROMPT_MAX_RESULT_CHARS", "PI_RULES_PROMPT_MAX_RESULT_CHARS")) ?? config.promptMaxResultChars;
|
|
3237
|
+
config.enabledSources = parseEnabledSources(firstEnv(env, "CODEX_RULES_ENABLED_SOURCES", "PI_RULES_ENABLED_SOURCES"), disableBundledRules);
|
|
3238
|
+
return config;
|
|
3239
|
+
}
|
|
3240
|
+
function firstEnv(env, ...names) {
|
|
3241
|
+
for (const name of names) {
|
|
3242
|
+
const value = env[name];
|
|
3243
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
3244
|
+
return value;
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
return;
|
|
3248
|
+
}
|
|
3249
|
+
function isTruthy(value) {
|
|
3250
|
+
if (value === undefined)
|
|
3251
|
+
return false;
|
|
3252
|
+
return ["1", "true", "yes", "on"].includes(value.trim().toLowerCase());
|
|
3253
|
+
}
|
|
3254
|
+
function parseMode(value) {
|
|
3255
|
+
if (value === undefined)
|
|
3256
|
+
return;
|
|
3257
|
+
const normalized = value.trim().toLowerCase();
|
|
3258
|
+
switch (normalized) {
|
|
3259
|
+
case "static":
|
|
3260
|
+
case "dynamic":
|
|
3261
|
+
case "both":
|
|
3262
|
+
case "off":
|
|
3263
|
+
return normalized;
|
|
3264
|
+
default:
|
|
3265
|
+
return;
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
function parsePositiveInteger(value) {
|
|
3269
|
+
if (value === undefined)
|
|
3270
|
+
return;
|
|
3271
|
+
const parsed = Number.parseInt(value.trim(), 10);
|
|
3272
|
+
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : undefined;
|
|
3273
|
+
}
|
|
3274
|
+
function parseEnabledSources(value, disableBundledRules) {
|
|
3275
|
+
if (value === undefined || value.trim().toLowerCase() === "auto") {
|
|
3276
|
+
return disableBundledRules ? sourcesWithoutBundledRules() : "auto";
|
|
3277
|
+
}
|
|
3278
|
+
const sources = [];
|
|
3279
|
+
for (const rawSource of value.split(",")) {
|
|
3280
|
+
const source = toRuleSource(rawSource.trim());
|
|
3281
|
+
if (source === null) {
|
|
3282
|
+
continue;
|
|
3283
|
+
}
|
|
3284
|
+
sources.push(source);
|
|
3285
|
+
}
|
|
3286
|
+
const enabledSources = disableBundledRules ? sources.filter((source) => source !== "plugin-bundled") : sources;
|
|
3287
|
+
return enabledSources;
|
|
3288
|
+
}
|
|
3289
|
+
function sourcesWithoutBundledRules() {
|
|
3290
|
+
return [...SOURCE_PRIORITY.keys()].filter((source) => source !== "plugin-bundled");
|
|
3291
|
+
}
|
|
3292
|
+
function toRuleSource(value) {
|
|
3293
|
+
switch (value) {
|
|
3294
|
+
case ".omo/rules":
|
|
3295
|
+
case ".claude/rules":
|
|
3296
|
+
case ".cursor/rules":
|
|
3297
|
+
case ".github/instructions":
|
|
3298
|
+
case ".github/copilot-instructions.md":
|
|
3299
|
+
case "CONTEXT.md":
|
|
3300
|
+
case "plugin-bundled":
|
|
3301
|
+
case "~/.omo/rules":
|
|
3302
|
+
case "~/.opencode/rules":
|
|
3303
|
+
case "~/.claude/rules":
|
|
3304
|
+
return value;
|
|
3305
|
+
default:
|
|
3306
|
+
return null;
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
|
|
3310
|
+
// components/rules/src/context-pressure.ts
|
|
3311
|
+
import { readFileSync } from "node:fs";
|
|
3312
|
+
var CONTEXT_PRESSURE_MARKERS = [
|
|
3313
|
+
"context compacted",
|
|
3314
|
+
"context_length_exceeded",
|
|
3315
|
+
"skill descriptions were shortened",
|
|
3316
|
+
"context_too_large",
|
|
3317
|
+
"codex ran out of room in the model's context window",
|
|
3318
|
+
"your input exceeds the context window",
|
|
3319
|
+
"long threads and multiple compactions"
|
|
3320
|
+
];
|
|
3321
|
+
function hasContextPressureMarker(text) {
|
|
3322
|
+
const normalizedText = text.toLowerCase();
|
|
3323
|
+
return CONTEXT_PRESSURE_MARKERS.some((marker) => normalizedText.includes(marker));
|
|
3324
|
+
}
|
|
3325
|
+
function transcriptHasContextPressureMarker(transcriptPath) {
|
|
3326
|
+
if (transcriptPath === undefined || transcriptPath === null)
|
|
3327
|
+
return false;
|
|
3328
|
+
try {
|
|
3329
|
+
return hasContextPressureMarker(readFileSync(transcriptPath, "utf8"));
|
|
3330
|
+
} catch (error) {
|
|
3331
|
+
if (error instanceof Error)
|
|
3332
|
+
return false;
|
|
3333
|
+
throw error;
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
|
|
3337
|
+
// components/rules/src/debug-log.ts
|
|
3338
|
+
import { performance } from "node:perf_hooks";
|
|
3339
|
+
import { debuglog } from "node:util";
|
|
3340
|
+
var debug = debuglog("codex-rules");
|
|
3341
|
+
var noopTimer = {
|
|
3342
|
+
lap: () => {},
|
|
3343
|
+
done: () => {}
|
|
3344
|
+
};
|
|
3345
|
+
function createHookDebugTimer(hookName) {
|
|
3346
|
+
if (!debug.enabled) {
|
|
3347
|
+
return noopTimer;
|
|
3348
|
+
}
|
|
3349
|
+
const startMs = performance.now();
|
|
3350
|
+
let lastMs = startMs;
|
|
3351
|
+
return {
|
|
3352
|
+
lap: (phase, fields = {}) => {
|
|
3353
|
+
const nowMs = performance.now();
|
|
3354
|
+
writeDebugLine(hookName, phase, nowMs - lastMs, nowMs - startMs, fields);
|
|
3355
|
+
lastMs = nowMs;
|
|
3356
|
+
},
|
|
3357
|
+
done: (fields = {}) => {
|
|
3358
|
+
const nowMs = performance.now();
|
|
3359
|
+
writeDebugLine(hookName, "done", nowMs - lastMs, nowMs - startMs, fields);
|
|
3360
|
+
lastMs = nowMs;
|
|
3361
|
+
}
|
|
3362
|
+
};
|
|
3363
|
+
}
|
|
3364
|
+
function writeDebugLine(hookName, phase, durationMs, totalMs, fields) {
|
|
3365
|
+
debug("%s phase=%s ms=%s total_ms=%s%s", hookName, phase, durationMs.toFixed(3), totalMs.toFixed(3), formatFields(fields));
|
|
3366
|
+
}
|
|
3367
|
+
function formatFields(fields) {
|
|
3368
|
+
const entries = Object.entries(fields);
|
|
3369
|
+
if (entries.length === 0) {
|
|
3370
|
+
return "";
|
|
3371
|
+
}
|
|
3372
|
+
return ` ${entries.map(([key, value]) => `${key}=${String(value)}`).join(" ")}`;
|
|
3373
|
+
}
|
|
3374
|
+
|
|
3375
|
+
// components/rules/src/dynamic-target-fingerprints.ts
|
|
3376
|
+
import { statSync as statSync5 } from "node:fs";
|
|
3377
|
+
import { resolve as resolve9 } from "node:path";
|
|
3378
|
+
|
|
3379
|
+
// components/rules/src/path-utils.ts
|
|
3380
|
+
import { isAbsolute as isAbsolute3, relative as relative3, resolve as resolve8 } from "node:path";
|
|
3381
|
+
function displayPath(cwd, filePath) {
|
|
3382
|
+
const rel = isAbsolute3(filePath) ? relative3(cwd, filePath) : filePath;
|
|
3383
|
+
return toPosixPath2(rel);
|
|
3384
|
+
}
|
|
3385
|
+
function isSameOrChildPath3(childPath, parentPath) {
|
|
3386
|
+
const childRelativePath = relative3(parentPath, resolve8(childPath));
|
|
3387
|
+
return childRelativePath === "" || !childRelativePath.startsWith("..") && !isAbsolute3(childRelativePath);
|
|
3388
|
+
}
|
|
3389
|
+
function toPosixPath2(path) {
|
|
3390
|
+
return path.replaceAll("\\", "/");
|
|
3391
|
+
}
|
|
3392
|
+
function uniqueStrings2(values) {
|
|
3393
|
+
const uniqueValues = [];
|
|
3394
|
+
const seenValues = new Set;
|
|
3395
|
+
for (const value of values) {
|
|
3396
|
+
if (seenValues.has(value)) {
|
|
3397
|
+
continue;
|
|
3398
|
+
}
|
|
3399
|
+
seenValues.add(value);
|
|
3400
|
+
uniqueValues.push(value);
|
|
3401
|
+
}
|
|
3402
|
+
return uniqueValues;
|
|
3403
|
+
}
|
|
3404
|
+
|
|
3405
|
+
// components/rules/src/dynamic-target-fingerprints.ts
|
|
3406
|
+
function fingerprintDynamicTargets(cwd, targetPaths, config) {
|
|
3407
|
+
const disabledSources = disabledSourcesFromConfig(config);
|
|
3408
|
+
const discoveryCache = createRuleDiscoveryCache();
|
|
3409
|
+
const cwdProjectRoot = findProjectRoot(cwd);
|
|
3410
|
+
const fingerprints = [];
|
|
3411
|
+
for (const targetPath of uniqueStrings2(targetPaths)) {
|
|
3412
|
+
const projectRoot = cwdProjectRoot !== null && isSameOrChildPath3(targetPath, cwdProjectRoot) ? cwdProjectRoot : findProjectRoot(targetPath);
|
|
3413
|
+
const findOptions = {
|
|
3414
|
+
projectRoot,
|
|
3415
|
+
targetFile: targetPath,
|
|
3416
|
+
cache: discoveryCache
|
|
3417
|
+
};
|
|
3418
|
+
if (disabledSources !== undefined) {
|
|
3419
|
+
findOptions.disabledSources = disabledSources;
|
|
3420
|
+
}
|
|
3421
|
+
const candidates = findRuleCandidates(findOptions);
|
|
3422
|
+
const candidateFingerprint = sortCandidates(candidates).map(fingerprintCandidate).join("\x01");
|
|
3423
|
+
const cacheKey = dynamicTargetCacheKey(targetPath);
|
|
3424
|
+
fingerprints.push({
|
|
3425
|
+
targetPath,
|
|
3426
|
+
cacheKey,
|
|
3427
|
+
fingerprint: hashContent([
|
|
3428
|
+
"v1",
|
|
3429
|
+
config.enabledSources === "auto" ? "auto" : config.enabledSources.join(","),
|
|
3430
|
+
projectRoot ?? "",
|
|
3431
|
+
cacheKey,
|
|
3432
|
+
candidateFingerprint
|
|
3433
|
+
].join("\x00"))
|
|
3434
|
+
});
|
|
3435
|
+
}
|
|
3436
|
+
return fingerprints;
|
|
3437
|
+
}
|
|
3438
|
+
function fingerprintCandidate(candidate) {
|
|
3439
|
+
return [
|
|
3440
|
+
candidate.realPath,
|
|
3441
|
+
candidate.relativePath,
|
|
3442
|
+
candidate.source,
|
|
3443
|
+
candidate.isGlobal ? "global" : "project",
|
|
3444
|
+
candidate.isSingleFile ? "single" : "multi",
|
|
3445
|
+
String(candidate.distance),
|
|
3446
|
+
fileFingerprint(candidate.path)
|
|
3447
|
+
].join("\x00");
|
|
3448
|
+
}
|
|
3449
|
+
function fileFingerprint(filePath) {
|
|
3450
|
+
try {
|
|
3451
|
+
const stats = statSync5(filePath, { bigint: true });
|
|
3452
|
+
return `${stats.mtimeNs}:${stats.ctimeNs}:${stats.size}`;
|
|
3453
|
+
} catch {
|
|
3454
|
+
return "missing";
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
function dynamicTargetCacheKey(targetPath) {
|
|
3458
|
+
return toPosixPath2(resolve9(targetPath));
|
|
3459
|
+
}
|
|
3460
|
+
|
|
3461
|
+
// components/rules/src/event-budget.ts
|
|
3462
|
+
function withDynamicBudget(config) {
|
|
3463
|
+
return {
|
|
3464
|
+
...config,
|
|
3465
|
+
maxRuleChars: Math.min(config.maxRuleChars, config.dynamicMaxRuleChars),
|
|
3466
|
+
maxResultChars: Math.min(config.maxResultChars, config.dynamicMaxResultChars)
|
|
3467
|
+
};
|
|
3468
|
+
}
|
|
3469
|
+
function withPromptBudget(config) {
|
|
3470
|
+
return {
|
|
3471
|
+
...config,
|
|
3472
|
+
maxRuleChars: Math.min(config.maxRuleChars, config.promptMaxRuleChars),
|
|
3473
|
+
maxResultChars: Math.min(config.maxResultChars, config.promptMaxResultChars)
|
|
3474
|
+
};
|
|
3475
|
+
}
|
|
3476
|
+
|
|
3477
|
+
// components/rules/src/hook-output.ts
|
|
3478
|
+
var MAX_ADDITIONAL_CONTEXT_CHARS = 32000;
|
|
3479
|
+
function formatAdditionalContextOutput(eventName, additionalContext) {
|
|
3480
|
+
const normalizedContext = limitAdditionalContext(normalizeAdditionalContext(additionalContext));
|
|
3481
|
+
if (normalizedContext.length === 0)
|
|
3482
|
+
return "";
|
|
3483
|
+
return `${JSON.stringify({
|
|
3484
|
+
hookSpecificOutput: {
|
|
3485
|
+
hookEventName: eventName,
|
|
3486
|
+
additionalContext: normalizedContext
|
|
3487
|
+
}
|
|
3488
|
+
})}
|
|
3489
|
+
`;
|
|
3490
|
+
}
|
|
3491
|
+
function normalizeAdditionalContext(additionalContext) {
|
|
3492
|
+
return additionalContext.replace(/\r\n/g, `
|
|
3493
|
+
`).replace(/\r/g, `
|
|
3494
|
+
`).trim();
|
|
3495
|
+
}
|
|
3496
|
+
function limitAdditionalContext(additionalContext) {
|
|
3497
|
+
if (additionalContext.length <= MAX_ADDITIONAL_CONTEXT_CHARS)
|
|
3498
|
+
return additionalContext;
|
|
3499
|
+
const marker = `
|
|
3500
|
+
|
|
3501
|
+
[Truncated hook additional context to ${MAX_ADDITIONAL_CONTEXT_CHARS} chars to avoid Codex context overflow.]`;
|
|
3502
|
+
if (marker.length >= MAX_ADDITIONAL_CONTEXT_CHARS)
|
|
3503
|
+
return marker.slice(0, MAX_ADDITIONAL_CONTEXT_CHARS);
|
|
3504
|
+
const head = additionalContext.slice(0, MAX_ADDITIONAL_CONTEXT_CHARS - marker.length).replace(/[ \t\r\n]+$/, "");
|
|
3505
|
+
return `${head}${marker}`;
|
|
3506
|
+
}
|
|
3507
|
+
|
|
3508
|
+
// components/rules/src/persistent-cache.ts
|
|
3509
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync as rmSync2, writeFileSync } from "node:fs";
|
|
3510
|
+
import { homedir as homedir2 } from "node:os";
|
|
3511
|
+
import { dirname as dirname6, join as join6 } from "node:path";
|
|
3512
|
+
|
|
3513
|
+
// components/rules/src/post-compact-state.ts
|
|
3514
|
+
function postCompactKindState(kinds) {
|
|
3515
|
+
if (kinds.size === 0) {
|
|
3516
|
+
return;
|
|
3517
|
+
}
|
|
3518
|
+
return {
|
|
3519
|
+
...kinds.has("static") ? { static: true } : {},
|
|
3520
|
+
...kinds.has("dynamic") ? { dynamic: true } : {}
|
|
3521
|
+
};
|
|
3522
|
+
}
|
|
3523
|
+
function postCompactPendingKinds(state) {
|
|
3524
|
+
const pendingKinds = new Set;
|
|
3525
|
+
if (state.compacted === true || state.postCompactPending?.static === true) {
|
|
3526
|
+
pendingKinds.add("static");
|
|
3527
|
+
}
|
|
3528
|
+
if (state.compacted === true || state.postCompactPending?.dynamic === true) {
|
|
3529
|
+
pendingKinds.add("dynamic");
|
|
3530
|
+
}
|
|
3531
|
+
return pendingKinds;
|
|
3532
|
+
}
|
|
3533
|
+
function postCompactRecoveringKinds(state) {
|
|
3534
|
+
const recoveringKinds = new Set;
|
|
3535
|
+
if (state.postCompactRecovering?.static === true) {
|
|
3536
|
+
recoveringKinds.add("static");
|
|
3537
|
+
}
|
|
3538
|
+
if (state.postCompactRecovering?.dynamic === true) {
|
|
3539
|
+
recoveringKinds.add("dynamic");
|
|
3540
|
+
}
|
|
3541
|
+
return recoveringKinds;
|
|
3542
|
+
}
|
|
3543
|
+
|
|
3544
|
+
// components/rules/src/session-state-lock.ts
|
|
3545
|
+
import { mkdirSync, rmSync } from "node:fs";
|
|
3546
|
+
import { dirname as dirname5 } from "node:path";
|
|
3547
|
+
var SESSION_STATE_LOCK_CONTENDED = Symbol("session-state-lock-contended");
|
|
3548
|
+
var LOCK_RETRY_COUNT = 20;
|
|
3549
|
+
var LOCK_RETRY_DELAY_MS = 5;
|
|
3550
|
+
var LOCK_SLEEP_VIEW = new Int32Array(new SharedArrayBuffer(4));
|
|
3551
|
+
function withSessionStateLock(cachePath, callback) {
|
|
3552
|
+
const lockPath = `${cachePath}.lock`;
|
|
3553
|
+
mkdirSync(dirname5(cachePath), { recursive: true });
|
|
3554
|
+
for (let attempt = 0;attempt < LOCK_RETRY_COUNT; attempt += 1) {
|
|
49
3555
|
try {
|
|
50
|
-
|
|
51
|
-
|
|
3556
|
+
mkdirSync(lockPath);
|
|
3557
|
+
try {
|
|
3558
|
+
return callback();
|
|
3559
|
+
} finally {
|
|
3560
|
+
rmSync(lockPath, { recursive: true, force: true });
|
|
3561
|
+
}
|
|
3562
|
+
} catch (error) {
|
|
3563
|
+
if (errorCode(error) === "EEXIST") {
|
|
3564
|
+
sleepSync(LOCK_RETRY_DELAY_MS);
|
|
3565
|
+
continue;
|
|
3566
|
+
}
|
|
3567
|
+
throw error;
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
return SESSION_STATE_LOCK_CONTENDED;
|
|
3571
|
+
}
|
|
3572
|
+
function errorCode(error) {
|
|
3573
|
+
if (!isRecord(error)) {
|
|
3574
|
+
return;
|
|
3575
|
+
}
|
|
3576
|
+
return Reflect.get(error, "code");
|
|
3577
|
+
}
|
|
3578
|
+
function isRecord(value) {
|
|
3579
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3580
|
+
}
|
|
3581
|
+
function sleepSync(milliseconds) {
|
|
3582
|
+
Atomics.wait(LOCK_SLEEP_VIEW, 0, 0, milliseconds);
|
|
3583
|
+
}
|
|
3584
|
+
|
|
3585
|
+
// components/rules/src/persistent-cache.ts
|
|
3586
|
+
function hydrateEngineState(engine, cachePath) {
|
|
3587
|
+
const state = readSessionState(cachePath);
|
|
3588
|
+
engine.state.staticDedup.clear();
|
|
3589
|
+
engine.state.dynamicDedup.clear();
|
|
3590
|
+
engine.state.dynamicTargetFingerprints.clear();
|
|
3591
|
+
for (const key of state.staticDedup) {
|
|
3592
|
+
engine.state.staticDedup.add(key);
|
|
3593
|
+
}
|
|
3594
|
+
for (const [scope, keys] of Object.entries(state.dynamicDedup)) {
|
|
3595
|
+
engine.state.dynamicDedup.set(scope, new Set(keys));
|
|
3596
|
+
}
|
|
3597
|
+
for (const [targetKey, fingerprint] of Object.entries(state.dynamicTargetFingerprints ?? {})) {
|
|
3598
|
+
engine.state.dynamicTargetFingerprints.set(targetKey, fingerprint);
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
function persistEngineState(engine, cachePath, completedPostCompactKind) {
|
|
3602
|
+
const currentState = readSessionState(cachePath);
|
|
3603
|
+
const dynamicDedup = {};
|
|
3604
|
+
for (const [scope, keys] of engine.state.dynamicDedup.entries()) {
|
|
3605
|
+
dynamicDedup[scope] = [...keys];
|
|
3606
|
+
}
|
|
3607
|
+
const postCompactPending = nextPostCompactPending(currentState, completedPostCompactKind);
|
|
3608
|
+
const postCompactRecovering = nextPostCompactRecovering(currentState, completedPostCompactKind);
|
|
3609
|
+
writeSessionState(cachePath, {
|
|
3610
|
+
staticDedup: [...engine.state.staticDedup],
|
|
3611
|
+
dynamicDedup,
|
|
3612
|
+
dynamicTargetFingerprints: Object.fromEntries(engine.state.dynamicTargetFingerprints.entries()),
|
|
3613
|
+
...postCompactPending === undefined ? {} : { postCompactPending },
|
|
3614
|
+
...postCompactRecovering === undefined ? {} : { postCompactRecovering }
|
|
3615
|
+
});
|
|
3616
|
+
}
|
|
3617
|
+
function clearSessionState(cachePath) {
|
|
3618
|
+
rmSync2(cachePath, { force: true });
|
|
3619
|
+
}
|
|
3620
|
+
function markSessionCompacted(cachePath) {
|
|
3621
|
+
const state = readSessionState(cachePath);
|
|
3622
|
+
writeSessionState(cachePath, {
|
|
3623
|
+
staticDedup: [],
|
|
3624
|
+
dynamicDedup: state.dynamicDedup,
|
|
3625
|
+
...state.dynamicTargetFingerprints === undefined ? {} : { dynamicTargetFingerprints: state.dynamicTargetFingerprints },
|
|
3626
|
+
postCompactPending: { static: true, dynamic: true }
|
|
3627
|
+
});
|
|
3628
|
+
}
|
|
3629
|
+
function hasPostCompactPending(cachePath) {
|
|
3630
|
+
const state = readSessionState(cachePath);
|
|
3631
|
+
return postCompactPendingKinds(state).size > 0 || postCompactRecoveringKinds(state).size > 0;
|
|
3632
|
+
}
|
|
3633
|
+
function claimPostCompactPending(cachePath, kind) {
|
|
3634
|
+
const result = withSessionStateLock(cachePath, () => {
|
|
3635
|
+
const state = readSessionState(cachePath);
|
|
3636
|
+
const pendingKinds = postCompactPendingKinds(state);
|
|
3637
|
+
if (!pendingKinds.has(kind)) {
|
|
3638
|
+
return "not-pending";
|
|
3639
|
+
}
|
|
3640
|
+
pendingKinds.delete(kind);
|
|
3641
|
+
const recoveringKinds = postCompactRecoveringKinds(state);
|
|
3642
|
+
recoveringKinds.add(kind);
|
|
3643
|
+
writeSessionState(cachePath, stateWithPostCompactKinds(state, pendingKinds, recoveringKinds));
|
|
3644
|
+
return "claimed";
|
|
3645
|
+
});
|
|
3646
|
+
return result === SESSION_STATE_LOCK_CONTENDED ? "contended" : result;
|
|
3647
|
+
}
|
|
3648
|
+
function isPostCompactRecoveryInProgress(cachePath, kind) {
|
|
3649
|
+
return postCompactRecoveringKinds(readSessionState(cachePath)).has(kind);
|
|
3650
|
+
}
|
|
3651
|
+
function completePostCompactRecovery(cachePath, kind) {
|
|
3652
|
+
withSessionStateLock(cachePath, () => {
|
|
3653
|
+
const state = readSessionState(cachePath);
|
|
3654
|
+
const pendingKinds = postCompactPendingKinds(state);
|
|
3655
|
+
const recoveringKinds = postCompactRecoveringKinds(state);
|
|
3656
|
+
recoveringKinds.delete(kind);
|
|
3657
|
+
writeSessionState(cachePath, stateWithPostCompactKinds(state, pendingKinds, recoveringKinds));
|
|
3658
|
+
});
|
|
3659
|
+
}
|
|
3660
|
+
function sessionCachePath(sessionId, pluginDataRoot) {
|
|
3661
|
+
const root = pluginDataRoot ?? process.env["PLUGIN_DATA"] ?? join6(homedir2(), ".codex", "codex-rules");
|
|
3662
|
+
return join6(root, "sessions", `${safePathSegment(sessionId)}.json`);
|
|
3663
|
+
}
|
|
3664
|
+
function readSessionState(cachePath) {
|
|
3665
|
+
try {
|
|
3666
|
+
const parsed = JSON.parse(readFileSync2(cachePath, "utf8"));
|
|
3667
|
+
if (!isSerializedSessionState(parsed))
|
|
3668
|
+
return emptyState();
|
|
3669
|
+
return parsed;
|
|
3670
|
+
} catch {
|
|
3671
|
+
return emptyState();
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
function writeSessionState(cachePath, state) {
|
|
3675
|
+
mkdirSync2(dirname6(cachePath), { recursive: true });
|
|
3676
|
+
writeFileSync(cachePath, `${JSON.stringify(state)}
|
|
3677
|
+
`);
|
|
3678
|
+
}
|
|
3679
|
+
function emptyState() {
|
|
3680
|
+
return { staticDedup: [], dynamicDedup: {}, dynamicTargetFingerprints: {} };
|
|
3681
|
+
}
|
|
3682
|
+
function nextPostCompactPending(state, completedKind) {
|
|
3683
|
+
const pendingKinds = postCompactPendingKinds(state);
|
|
3684
|
+
if (completedKind !== undefined) {
|
|
3685
|
+
pendingKinds.delete(completedKind);
|
|
3686
|
+
}
|
|
3687
|
+
if (pendingKinds.size === 0) {
|
|
3688
|
+
return;
|
|
3689
|
+
}
|
|
3690
|
+
return {
|
|
3691
|
+
...pendingKinds.has("static") ? { static: true } : {},
|
|
3692
|
+
...pendingKinds.has("dynamic") ? { dynamic: true } : {}
|
|
3693
|
+
};
|
|
3694
|
+
}
|
|
3695
|
+
function nextPostCompactRecovering(state, completedKind) {
|
|
3696
|
+
const recoveringKinds = postCompactRecoveringKinds(state);
|
|
3697
|
+
if (completedKind !== undefined) {
|
|
3698
|
+
recoveringKinds.delete(completedKind);
|
|
3699
|
+
}
|
|
3700
|
+
return postCompactKindState(recoveringKinds);
|
|
3701
|
+
}
|
|
3702
|
+
function stateWithPostCompactKinds(state, pendingKinds, recoveringKinds) {
|
|
3703
|
+
const postCompactPending = postCompactKindState(pendingKinds);
|
|
3704
|
+
const postCompactRecovering = postCompactKindState(recoveringKinds);
|
|
3705
|
+
return {
|
|
3706
|
+
staticDedup: state.staticDedup,
|
|
3707
|
+
dynamicDedup: state.dynamicDedup,
|
|
3708
|
+
...state.dynamicTargetFingerprints === undefined ? {} : { dynamicTargetFingerprints: state.dynamicTargetFingerprints },
|
|
3709
|
+
...postCompactPending === undefined ? {} : { postCompactPending },
|
|
3710
|
+
...postCompactRecovering === undefined ? {} : { postCompactRecovering }
|
|
3711
|
+
};
|
|
3712
|
+
}
|
|
3713
|
+
function safePathSegment(value) {
|
|
3714
|
+
return value.replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 120) || "unknown-session";
|
|
3715
|
+
}
|
|
3716
|
+
function isSerializedSessionState(value) {
|
|
3717
|
+
if (!isRecord2(value) || !Array.isArray(value["staticDedup"]) || !isRecord2(value["dynamicDedup"])) {
|
|
3718
|
+
return false;
|
|
3719
|
+
}
|
|
3720
|
+
const staticDedup = value["staticDedup"];
|
|
3721
|
+
const dynamicDedup = value["dynamicDedup"];
|
|
3722
|
+
const dynamicTargetFingerprints = value["dynamicTargetFingerprints"];
|
|
3723
|
+
const postCompactPending = value["postCompactPending"];
|
|
3724
|
+
const postCompactRecovering = value["postCompactRecovering"];
|
|
3725
|
+
const compacted = value["compacted"];
|
|
3726
|
+
return staticDedup.every((item) => typeof item === "string") && Object.values(dynamicDedup).every((item) => Array.isArray(item) && item.every((nestedItem) => typeof nestedItem === "string")) && (dynamicTargetFingerprints === undefined || isRecord2(dynamicTargetFingerprints) && Object.entries(dynamicTargetFingerprints).every(([targetKey, fingerprint]) => typeof targetKey === "string" && typeof fingerprint === "string")) && (postCompactPending === undefined || isPostCompactPendingState(postCompactPending)) && (postCompactRecovering === undefined || isPostCompactPendingState(postCompactRecovering)) && (compacted === undefined || typeof compacted === "boolean");
|
|
3727
|
+
}
|
|
3728
|
+
function isPostCompactPendingState(value) {
|
|
3729
|
+
return isRecord2(value) && (value["static"] === undefined || typeof value["static"] === "boolean") && (value["dynamic"] === undefined || typeof value["dynamic"] === "boolean");
|
|
3730
|
+
}
|
|
3731
|
+
function isRecord2(value) {
|
|
3732
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3733
|
+
}
|
|
3734
|
+
|
|
3735
|
+
// components/rules/src/transcript-search.ts
|
|
3736
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
3737
|
+
function readTranscriptSearchText(transcriptPath, options = {}) {
|
|
3738
|
+
try {
|
|
3739
|
+
const rawTranscript = readFileSync3(transcriptPath, "utf8");
|
|
3740
|
+
if (options.latestCompactedReplacementOnly === true) {
|
|
3741
|
+
return latestCompactedReplacementSearchText(rawTranscript);
|
|
52
3742
|
}
|
|
53
|
-
|
|
54
|
-
|
|
3743
|
+
return [rawTranscript, ...collectJsonLineStrings(rawTranscript)].join(`
|
|
3744
|
+
`);
|
|
3745
|
+
} catch (error) {
|
|
3746
|
+
if (!(error instanceof Error)) {
|
|
3747
|
+
throw error;
|
|
3748
|
+
}
|
|
3749
|
+
return null;
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
function latestCompactedReplacementSearchText(rawTranscript) {
|
|
3753
|
+
const lines = rawTranscript.split(/\r?\n/);
|
|
3754
|
+
let latestCompactedLineIndex = -1;
|
|
3755
|
+
let replacementHistory = null;
|
|
3756
|
+
for (const [index, line] of lines.entries()) {
|
|
3757
|
+
const parsed = parseJsonLine(line);
|
|
3758
|
+
if (!isRecord3(parsed) || parsed["type"] !== "compacted") {
|
|
3759
|
+
continue;
|
|
3760
|
+
}
|
|
3761
|
+
const payload = parsed["payload"];
|
|
3762
|
+
if (!isRecord3(payload)) {
|
|
3763
|
+
continue;
|
|
3764
|
+
}
|
|
3765
|
+
const candidateReplacementHistory = payload["replacement_history"];
|
|
3766
|
+
if (!Array.isArray(candidateReplacementHistory)) {
|
|
3767
|
+
continue;
|
|
3768
|
+
}
|
|
3769
|
+
latestCompactedLineIndex = index;
|
|
3770
|
+
replacementHistory = candidateReplacementHistory;
|
|
3771
|
+
}
|
|
3772
|
+
if (replacementHistory === null) {
|
|
3773
|
+
return null;
|
|
3774
|
+
}
|
|
3775
|
+
const values = [];
|
|
3776
|
+
collectStrings(replacementHistory, values);
|
|
3777
|
+
const laterTranscript = lines.slice(latestCompactedLineIndex + 1).join(`
|
|
3778
|
+
`);
|
|
3779
|
+
values.push(laterTranscript, ...collectJsonLineStrings(laterTranscript));
|
|
3780
|
+
return values.join(`
|
|
3781
|
+
`);
|
|
3782
|
+
}
|
|
3783
|
+
function collectJsonLineStrings(rawTranscript) {
|
|
3784
|
+
const values = [];
|
|
3785
|
+
for (const line of rawTranscript.split(/\r?\n/)) {
|
|
3786
|
+
const parsed = parseJsonLine(line);
|
|
3787
|
+
if (parsed !== null) {
|
|
3788
|
+
collectStrings(parsed, values);
|
|
55
3789
|
}
|
|
3790
|
+
}
|
|
3791
|
+
return values;
|
|
3792
|
+
}
|
|
3793
|
+
function parseJsonLine(line) {
|
|
3794
|
+
if (line.trim().length === 0) {
|
|
3795
|
+
return null;
|
|
3796
|
+
}
|
|
3797
|
+
try {
|
|
3798
|
+
const parsed = JSON.parse(line);
|
|
3799
|
+
return parsed;
|
|
3800
|
+
} catch (error) {
|
|
3801
|
+
if (!(error instanceof Error)) {
|
|
3802
|
+
throw error;
|
|
3803
|
+
}
|
|
3804
|
+
return null;
|
|
3805
|
+
}
|
|
3806
|
+
}
|
|
3807
|
+
function collectStrings(value, output) {
|
|
3808
|
+
if (typeof value === "string") {
|
|
3809
|
+
output.push(value);
|
|
3810
|
+
return;
|
|
3811
|
+
}
|
|
3812
|
+
if (Array.isArray(value)) {
|
|
3813
|
+
for (const item of value) {
|
|
3814
|
+
collectStrings(item, output);
|
|
3815
|
+
}
|
|
3816
|
+
return;
|
|
3817
|
+
}
|
|
3818
|
+
if (!isRecord3(value)) {
|
|
3819
|
+
return;
|
|
3820
|
+
}
|
|
3821
|
+
for (const item of Object.values(value)) {
|
|
3822
|
+
collectStrings(item, output);
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
function isRecord3(value) {
|
|
3826
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3827
|
+
}
|
|
3828
|
+
|
|
3829
|
+
// components/rules/src/post-compact-budget.ts
|
|
3830
|
+
var DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT = 95;
|
|
3831
|
+
var ESTIMATED_TRANSCRIPT_CHARS_PER_TOKEN = 3;
|
|
3832
|
+
var PROJECTED_INJECTION_CHARS_PER_TOKEN = 2;
|
|
3833
|
+
var POST_COMPACT_RESERVED_CONTEXT_PERCENT = 5;
|
|
3834
|
+
var POST_COMPACT_MIN_RESERVED_TOKENS = 8000;
|
|
3835
|
+
var POST_COMPACT_MIN_GUIDE_CHARS = 500;
|
|
3836
|
+
var FALLBACK_CONTEXT_WINDOW_TOKENS = 200000;
|
|
3837
|
+
var MODEL_CONTEXT_BUDGETS = [
|
|
3838
|
+
{ slug: "gpt-5.5", contextWindowTokens: 272000, effectivePercent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT },
|
|
3839
|
+
{ slug: "gpt-5.4-mini", contextWindowTokens: 272000, effectivePercent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT },
|
|
3840
|
+
{
|
|
3841
|
+
slug: "codex-auto-review",
|
|
3842
|
+
contextWindowTokens: 272000,
|
|
3843
|
+
effectivePercent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT
|
|
3844
|
+
}
|
|
3845
|
+
];
|
|
3846
|
+
function withPostCompactBudget(config, context) {
|
|
3847
|
+
const postCompactMaxResultChars = dynamicPostCompactMaxResultChars(context) ?? config.postCompactMaxResultChars;
|
|
3848
|
+
const maxResultChars = Math.min(config.maxResultChars, config.postCompactMaxResultChars, postCompactMaxResultChars);
|
|
3849
|
+
const maxRuleChars = Math.min(config.maxRuleChars, config.postCompactMaxRuleChars, maxResultChars);
|
|
3850
|
+
return {
|
|
3851
|
+
...config,
|
|
3852
|
+
maxRuleChars,
|
|
3853
|
+
maxResultChars
|
|
3854
|
+
};
|
|
3855
|
+
}
|
|
3856
|
+
function dynamicPostCompactMaxResultChars(context) {
|
|
3857
|
+
if (context === undefined || context.transcriptPath === null) {
|
|
3858
|
+
return;
|
|
3859
|
+
}
|
|
3860
|
+
const transcript = estimateTranscript(context.transcriptPath);
|
|
3861
|
+
if (transcript === undefined) {
|
|
3862
|
+
return;
|
|
3863
|
+
}
|
|
3864
|
+
if (hasContextPressureMarker(transcript.text)) {
|
|
3865
|
+
return POST_COMPACT_MIN_GUIDE_CHARS;
|
|
3866
|
+
}
|
|
3867
|
+
const modelBudget = modelContextBudgetFor(context.model) ?? fallbackModelContextBudget();
|
|
3868
|
+
const effectiveContextWindow = Math.floor(modelBudget.contextWindowTokens * modelBudget.effectivePercent / 100);
|
|
3869
|
+
const reservedTokens = Math.max(POST_COMPACT_MIN_RESERVED_TOKENS, Math.floor(effectiveContextWindow * POST_COMPACT_RESERVED_CONTEXT_PERCENT / 100));
|
|
3870
|
+
const injectableTokens = Math.max(0, effectiveContextWindow - reservedTokens - transcript.tokens);
|
|
3871
|
+
return Math.max(POST_COMPACT_MIN_GUIDE_CHARS, Math.floor(injectableTokens * PROJECTED_INJECTION_CHARS_PER_TOKEN));
|
|
3872
|
+
}
|
|
3873
|
+
function modelContextBudgetFor(model) {
|
|
3874
|
+
const normalizedModel = model.trim().toLowerCase();
|
|
3875
|
+
for (const budget of MODEL_CONTEXT_BUDGETS) {
|
|
3876
|
+
if (normalizedModel === budget.slug || normalizedModel.endsWith(`.${budget.slug}`) || normalizedModel.endsWith(`/${budget.slug}`)) {
|
|
3877
|
+
return budget;
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
return;
|
|
3881
|
+
}
|
|
3882
|
+
function fallbackModelContextBudget() {
|
|
3883
|
+
return {
|
|
3884
|
+
slug: "unknown",
|
|
3885
|
+
contextWindowTokens: FALLBACK_CONTEXT_WINDOW_TOKENS,
|
|
3886
|
+
effectivePercent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT
|
|
3887
|
+
};
|
|
3888
|
+
}
|
|
3889
|
+
function estimateTranscript(transcriptPath) {
|
|
3890
|
+
const transcriptText = readTranscriptSearchText(transcriptPath, { latestCompactedReplacementOnly: true }) ?? readTranscriptSearchText(transcriptPath);
|
|
3891
|
+
if (transcriptText === null) {
|
|
3892
|
+
return;
|
|
3893
|
+
}
|
|
3894
|
+
return {
|
|
3895
|
+
text: transcriptText,
|
|
3896
|
+
tokens: Math.ceil(Buffer.byteLength(transcriptText, "utf8") / ESTIMATED_TRANSCRIPT_CHARS_PER_TOKEN)
|
|
3897
|
+
};
|
|
3898
|
+
}
|
|
3899
|
+
|
|
3900
|
+
// components/rules/src/post-compact-claim.ts
|
|
3901
|
+
function claimedPostCompactKind(result, kind) {
|
|
3902
|
+
return result === "claimed" ? kind : undefined;
|
|
3903
|
+
}
|
|
3904
|
+
function shouldSkipPostCompactClaim(result, recoveryInProgress) {
|
|
3905
|
+
return result === "contended" || result === "not-pending" && recoveryInProgress;
|
|
3906
|
+
}
|
|
3907
|
+
|
|
3908
|
+
// components/rules/src/rules-engine-factory.ts
|
|
3909
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
3910
|
+
import { dirname as dirname7 } from "node:path";
|
|
3911
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
3912
|
+
var componentRoot = dirname7(dirname7(fileURLToPath2(import.meta.url)));
|
|
3913
|
+
function createRulesEngine(options, config = configFromEnvironment(options.env)) {
|
|
3914
|
+
const platform = options.platform ?? process.platform;
|
|
3915
|
+
const pluginRoot = options.env?.["PLUGIN_ROOT"] ?? process.env["PLUGIN_ROOT"] ?? componentRoot;
|
|
3916
|
+
return createEngine(config, {
|
|
3917
|
+
findCandidates: (finderOptions) => findRuleCandidates({ ...finderOptions, platform, pluginRoot }),
|
|
3918
|
+
findProjectRoot,
|
|
3919
|
+
readFile: (path) => {
|
|
3920
|
+
try {
|
|
3921
|
+
return readFileSync4(path, "utf8");
|
|
3922
|
+
} catch {
|
|
3923
|
+
return null;
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
});
|
|
3927
|
+
}
|
|
3928
|
+
|
|
3929
|
+
// components/rules/src/static-injection.ts
|
|
3930
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
3931
|
+
|
|
3932
|
+
// components/rules/src/post-compact-directive.ts
|
|
3933
|
+
var DIRECTIVE_HEADER = [
|
|
3934
|
+
"## MANDATORY: POST-COMPACTION RULE RECOVERY",
|
|
3935
|
+
"",
|
|
3936
|
+
"Context compaction DROPPED the project rule files listed below from your context.",
|
|
3937
|
+
"YOU MUST READ THE FOLLOWING RULES with your file-reading tool RIGHT NOW, BEFORE ANY OTHER ACTION. NO EXCUSES.",
|
|
3938
|
+
"Do not plan, answer, edit, or run anything until EVERY file below has been read end to end:",
|
|
3939
|
+
""
|
|
3940
|
+
].join(`
|
|
3941
|
+
`);
|
|
3942
|
+
var DIRECTIVE_FOOTER = `
|
|
3943
|
+
Operating without these rules is a protocol violation. Reconstructing them from memory is NOT reading. READ THEM ALL. NO EXCUSES.`;
|
|
3944
|
+
function buildPostCompactReadDirective(rulePaths, maxChars) {
|
|
3945
|
+
const paths = uniqueStrings2([...rulePaths]);
|
|
3946
|
+
if (paths.length === 0) {
|
|
3947
|
+
return "";
|
|
3948
|
+
}
|
|
3949
|
+
const lines = [];
|
|
3950
|
+
let usedChars = DIRECTIVE_HEADER.length + DIRECTIVE_FOOTER.length;
|
|
3951
|
+
let omittedCount = 0;
|
|
3952
|
+
for (const rulePath of paths) {
|
|
3953
|
+
const line = `- ${rulePath}`;
|
|
3954
|
+
if (lines.length > 0 && usedChars + line.length + 1 > maxChars) {
|
|
3955
|
+
omittedCount += 1;
|
|
3956
|
+
continue;
|
|
3957
|
+
}
|
|
3958
|
+
lines.push(line);
|
|
3959
|
+
usedChars += line.length + 1;
|
|
3960
|
+
}
|
|
3961
|
+
if (omittedCount > 0) {
|
|
3962
|
+
lines.push(`- (+${omittedCount} more rule files omitted - rescan the project rule directories and read those too)`);
|
|
3963
|
+
}
|
|
3964
|
+
return `${DIRECTIVE_HEADER}${lines.join(`
|
|
3965
|
+
`)}${DIRECTIVE_FOOTER}`;
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
// components/rules/src/sparkshell-awareness.ts
|
|
3969
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
3970
|
+
import { join as join7 } from "node:path";
|
|
3971
|
+
var SPARKSHELL_AWARENESS_MARKER = "## Sparkshell Runtime";
|
|
3972
|
+
var SPARKSHELL_AWARENESS_DEDUP_KEY = "__omo_sparkshell_awareness__";
|
|
3973
|
+
function isCodexAppServerActive(env = process.env) {
|
|
3974
|
+
const originator = env["CODEX_INTERNAL_ORIGINATOR_OVERRIDE"]?.toLowerCase() ?? "";
|
|
3975
|
+
const bundleIdentifier = env["__CFBundleIdentifier"]?.toLowerCase() ?? "";
|
|
3976
|
+
const shellActive = isTruthy2(env["CODEX_SHELL"]);
|
|
3977
|
+
return shellActive && (originator.includes("codex desktop") || originator.includes("codex app") || bundleIdentifier === "com.openai.codex");
|
|
3978
|
+
}
|
|
3979
|
+
function isSparkShellAppServerConfigured(env = process.env) {
|
|
3980
|
+
const codexSocketPath = env["CODEX_APP_SERVER_SOCKET"]?.trim() ?? "";
|
|
3981
|
+
const omoSocketPath = env["OMO_SPARKSHELL_APP_SERVER_SOCKET"]?.trim() ?? "";
|
|
3982
|
+
return codexSocketPath.length > 0 || omoSocketPath.length > 0;
|
|
3983
|
+
}
|
|
3984
|
+
function resolveOmoInvocation(env = process.env, deps = {}) {
|
|
3985
|
+
const fileExists = deps.fileExists ?? existsSync4;
|
|
3986
|
+
const platform = deps.platform ?? process.platform;
|
|
3987
|
+
const binNames = platform === "win32" ? ["omo.cmd", "omo.exe", "omo"] : ["omo"];
|
|
3988
|
+
const pathDelimiter = platform === "win32" ? ";" : ":";
|
|
3989
|
+
const pathEntries = (env["PATH"] ?? "").split(pathDelimiter).filter((entry) => entry.trim().length > 0);
|
|
3990
|
+
for (const pathEntry of pathEntries) {
|
|
3991
|
+
for (const binName of binNames) {
|
|
3992
|
+
if (fileExists(join7(pathEntry, binName)))
|
|
3993
|
+
return "omo";
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
for (const candidateDir of omoCandidateBinDirs(env)) {
|
|
3997
|
+
for (const binName of binNames) {
|
|
3998
|
+
const candidate = join7(candidateDir, binName);
|
|
3999
|
+
if (fileExists(candidate))
|
|
4000
|
+
return candidate;
|
|
4001
|
+
}
|
|
4002
|
+
}
|
|
4003
|
+
return null;
|
|
4004
|
+
}
|
|
4005
|
+
function omoCandidateBinDirs(env) {
|
|
4006
|
+
const dirs = [];
|
|
4007
|
+
const localBinDir = env["CODEX_LOCAL_BIN_DIR"]?.trim() ?? "";
|
|
4008
|
+
if (localBinDir.length > 0)
|
|
4009
|
+
dirs.push(localBinDir);
|
|
4010
|
+
const home = env["HOME"]?.trim() || env["USERPROFILE"]?.trim() || "";
|
|
4011
|
+
const codexHome = env["CODEX_HOME"]?.trim() || (home.length > 0 ? join7(home, ".codex") : "");
|
|
4012
|
+
if (codexHome.length > 0)
|
|
4013
|
+
dirs.push(join7(codexHome, "bin"));
|
|
4014
|
+
if (home.length > 0)
|
|
4015
|
+
dirs.push(join7(home, ".local", "bin"));
|
|
4016
|
+
return dirs;
|
|
4017
|
+
}
|
|
4018
|
+
function getSparkShellRuntimeAwareness(env = process.env, deps = {}) {
|
|
4019
|
+
const override = env["OMO_SPARKSHELL_AWARENESS"] ?? env["LAZYCODEX_SPARKSHELL_AWARENESS"];
|
|
4020
|
+
if (isFalsy(override)) {
|
|
4021
|
+
return "";
|
|
4022
|
+
}
|
|
4023
|
+
if (!isTruthy2(override) && !isCodexAppServerActive(env) && !isSparkShellAppServerConfigured(env)) {
|
|
4024
|
+
return "";
|
|
4025
|
+
}
|
|
4026
|
+
const resolved = resolveOmoInvocation(env, deps);
|
|
4027
|
+
const invocation = resolved ?? (isTruthy2(override) ? "omo" : null);
|
|
4028
|
+
if (invocation === null) {
|
|
4029
|
+
return "";
|
|
4030
|
+
}
|
|
4031
|
+
const command = /\s/.test(invocation) ? `"${invocation}"` : invocation;
|
|
4032
|
+
return [
|
|
4033
|
+
SPARKSHELL_AWARENESS_MARKER,
|
|
4034
|
+
"",
|
|
4035
|
+
`- Prefer \`${command} sparkshell <command>\` for repo inspection, CLI smoke tests, git/history checks, and bounded verification before falling back to raw shell commands.`,
|
|
4036
|
+
`- Use \`${command} sparkshell --shell '<command>'\` only when shell metacharacters are required.`,
|
|
4037
|
+
`- Use \`${command} sparkshell --tmux-pane <pane-id> --tail-lines 400\` to inspect an existing tmux pane. Tail lines must stay between 100 and 1000.`,
|
|
4038
|
+
"- When no native sidecar or appserver is available, Sparkshell silently falls back to raw command execution. `OMO_SPARKSHELL_BIN` selects a native sidecar path.",
|
|
4039
|
+
"- When `CODEX_THREAD_ID` identifies a Codex session, Sparkshell appends recent session context (first/latest user request + last 5 conversation messages) after the shell result so output consumers stay aligned with the session goals. `OMO_SPARKSHELL_SESSION_CONTEXT=0` disables it.",
|
|
4040
|
+
`- Route potentially huge output (full log files, big diffs, \`cat\`/\`grep\` over large artifacts) through \`${command} sparkshell\` instead of reading it raw: oversized output is condensed to a budget while preserving error signatures, repeated patterns, session-goal-relevant lines, and head/tail. Tune with \`--budget <chars>\`; disable with \`OMO_SPARKSHELL_CONDENSE=0\`.`,
|
|
4041
|
+
"- Oversized output is first summarized by the spark model (`codex exec`, default `gpt-5.3-codex-spark`) fed with the session context: the summary reproduces the output as-is (no masking) and ends with a `[sparkshell caption]` line describing what ran and which lines were omitted. `OMO_SPARKSHELL_SPARK=0` skips the model and uses deterministic condensation directly."
|
|
4042
|
+
].join(`
|
|
4043
|
+
`);
|
|
4044
|
+
}
|
|
4045
|
+
function isTruthy2(value) {
|
|
4046
|
+
if (value === undefined) {
|
|
4047
|
+
return false;
|
|
4048
|
+
}
|
|
4049
|
+
return ["1", "true", "yes", "on"].includes(value.trim().toLowerCase());
|
|
4050
|
+
}
|
|
4051
|
+
function isFalsy(value) {
|
|
4052
|
+
if (value === undefined) {
|
|
4053
|
+
return false;
|
|
4054
|
+
}
|
|
4055
|
+
return ["0", "false", "no", "off"].includes(value.trim().toLowerCase());
|
|
4056
|
+
}
|
|
4057
|
+
|
|
4058
|
+
// components/rules/src/transcript-rule-filter.ts
|
|
4059
|
+
function filterRulesAlreadyInTranscript(rules, transcriptPath, markInjected, options = {}) {
|
|
4060
|
+
if (rules.length === 0 || transcriptPath === null) {
|
|
4061
|
+
return [...rules];
|
|
4062
|
+
}
|
|
4063
|
+
const transcriptText = readTranscriptSearchText(transcriptPath, options);
|
|
4064
|
+
return filterRulesNotInTranscriptText(rules, transcriptText, markInjected);
|
|
4065
|
+
}
|
|
4066
|
+
function filterRulesNotInTranscriptText(rules, transcriptText, markInjected) {
|
|
4067
|
+
if (rules.length === 0 || transcriptText === null) {
|
|
4068
|
+
return [...rules];
|
|
4069
|
+
}
|
|
4070
|
+
const pendingRules = [];
|
|
4071
|
+
for (const rule of rules) {
|
|
4072
|
+
if (isRuleAlreadyInTranscript(rule, transcriptText)) {
|
|
4073
|
+
markInjected(rule);
|
|
4074
|
+
continue;
|
|
4075
|
+
}
|
|
4076
|
+
pendingRules.push(rule);
|
|
4077
|
+
}
|
|
4078
|
+
return pendingRules;
|
|
4079
|
+
}
|
|
4080
|
+
function isRuleAlreadyInTranscript(rule, transcriptText) {
|
|
4081
|
+
const staticReferenceNeedles = [
|
|
4082
|
+
`- [${displayFilename2(rule)}]{${rule.path}}`,
|
|
4083
|
+
`- [${displayFilename2(rule)}]{${rule.realPath}}`
|
|
4084
|
+
];
|
|
4085
|
+
if (staticReferenceNeedles.some((needle) => transcriptText.includes(needle))) {
|
|
4086
|
+
return true;
|
|
4087
|
+
}
|
|
4088
|
+
const bodyNeedle = rule.body.trim().slice(0, 2000);
|
|
4089
|
+
if (bodyNeedle.length === 0 || !transcriptText.includes(bodyNeedle)) {
|
|
4090
|
+
return false;
|
|
4091
|
+
}
|
|
4092
|
+
const markers = [
|
|
4093
|
+
`Instructions from: ${rule.path}`,
|
|
4094
|
+
`Instructions from: ${rule.realPath}`,
|
|
4095
|
+
rule.relativePath.length === 0 ? null : rule.relativePath
|
|
4096
|
+
].filter((marker) => marker !== null);
|
|
4097
|
+
return markers.some((marker) => transcriptText.includes(marker));
|
|
4098
|
+
}
|
|
4099
|
+
function displayFilename2(rule) {
|
|
4100
|
+
const normalizedPath = rule.relativePath.length > 0 ? rule.relativePath : rule.path;
|
|
4101
|
+
const segments = normalizedPath.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0);
|
|
4102
|
+
return segments.at(-1) ?? normalizedPath;
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4105
|
+
// components/rules/src/static-injection.ts
|
|
4106
|
+
function runStaticInjection(cwd, transcriptPath, eventName, cachePath, options, completedPostCompactChannel, transcriptSearchOptions = {}, model) {
|
|
4107
|
+
const config = configFromEnvironment(options.env);
|
|
4108
|
+
if (config.disabled || config.mode === "off" || config.mode === "dynamic") {
|
|
4109
|
+
if (completedPostCompactChannel !== undefined) {
|
|
4110
|
+
completePostCompactRecovery(cachePath, completedPostCompactChannel);
|
|
4111
|
+
}
|
|
4112
|
+
return "";
|
|
4113
|
+
}
|
|
4114
|
+
if (completedPostCompactChannel !== undefined) {
|
|
4115
|
+
return runPostCompactRecovery({
|
|
4116
|
+
cwd,
|
|
4117
|
+
transcriptPath,
|
|
4118
|
+
eventName,
|
|
4119
|
+
cachePath,
|
|
4120
|
+
options,
|
|
4121
|
+
channel: completedPostCompactChannel,
|
|
4122
|
+
model: model ?? "",
|
|
4123
|
+
config
|
|
4124
|
+
});
|
|
4125
|
+
}
|
|
4126
|
+
const effectiveConfig = eventName === "UserPromptSubmit" ? withPromptBudget(config) : config;
|
|
4127
|
+
const engine = createRulesEngine(options, effectiveConfig);
|
|
4128
|
+
hydrateEngineState(engine, cachePath);
|
|
4129
|
+
engine.state.cwd = cwd;
|
|
4130
|
+
const loaded = engine.loadStaticRules(cwd);
|
|
4131
|
+
const rules = filterRulesAlreadyInTranscript(loaded.rules.filter((rule) => !engine.isStaticInjected(rule)), transcriptPath, (rule) => {
|
|
4132
|
+
engine.markStaticInjected(rule);
|
|
4133
|
+
}, transcriptSearchOptions);
|
|
4134
|
+
const sparkshellAwareness = engine.state.staticDedup.has(SPARKSHELL_AWARENESS_DEDUP_KEY) ? "" : getSparkShellRuntimeAwareness(options.env);
|
|
4135
|
+
if (rules.length === 0 && sparkshellAwareness.length === 0) {
|
|
4136
|
+
persistEngineState(engine, cachePath);
|
|
4137
|
+
return "";
|
|
4138
|
+
}
|
|
4139
|
+
const block = engine.formatStatic(rules);
|
|
4140
|
+
for (const rule of rules) {
|
|
4141
|
+
engine.markStaticInjected(rule);
|
|
4142
|
+
}
|
|
4143
|
+
if (sparkshellAwareness.length > 0) {
|
|
4144
|
+
engine.state.staticDedup.add(SPARKSHELL_AWARENESS_DEDUP_KEY);
|
|
4145
|
+
}
|
|
4146
|
+
persistEngineState(engine, cachePath);
|
|
4147
|
+
return formatAdditionalContextOutput(eventName, combineStaticContext(block, sparkshellAwareness));
|
|
4148
|
+
}
|
|
4149
|
+
function runPostCompactRecovery(input) {
|
|
4150
|
+
const effectiveConfig = withPostCompactBudget(input.config, {
|
|
4151
|
+
model: input.model,
|
|
4152
|
+
transcriptPath: input.transcriptPath
|
|
4153
|
+
});
|
|
4154
|
+
const engine = createRulesEngine(input.options, effectiveConfig);
|
|
4155
|
+
hydrateEngineState(engine, input.cachePath);
|
|
4156
|
+
engine.state.cwd = input.cwd;
|
|
4157
|
+
const loaded = engine.loadStaticRules(input.cwd);
|
|
4158
|
+
const transcriptText = readRecoveryTranscriptText(input.transcriptPath);
|
|
4159
|
+
const missingRules = filterRulesNotInTranscriptText(loaded.rules.filter((rule) => !engine.isStaticInjected(rule)), transcriptText, (rule) => {
|
|
4160
|
+
engine.markStaticInjected(rule);
|
|
4161
|
+
});
|
|
4162
|
+
const dynamicRulePaths = recoverDynamicRulePaths(engine, transcriptText, loaded.rules);
|
|
4163
|
+
const sparkshellAwareness = engine.state.staticDedup.has(SPARKSHELL_AWARENESS_DEDUP_KEY) ? "" : getSparkShellRuntimeAwareness(input.options.env);
|
|
4164
|
+
if (missingRules.length === 0 && dynamicRulePaths.length === 0 && sparkshellAwareness.length === 0) {
|
|
4165
|
+
persistEngineState(engine, input.cachePath, input.channel);
|
|
4166
|
+
return "";
|
|
4167
|
+
}
|
|
4168
|
+
const fullBodyRules = missingRules.filter((rule) => isNeverTruncatedRule(ruleDisplayPath(rule)));
|
|
4169
|
+
const listedRules = missingRules.filter((rule) => !isNeverTruncatedRule(ruleDisplayPath(rule)));
|
|
4170
|
+
const bodyBlock = fullBodyRules.length === 0 ? "" : engine.formatStatic(fullBodyRules);
|
|
4171
|
+
const directive = buildPostCompactReadDirective([...listedRules.map((rule) => rule.path), ...dynamicRulePaths], effectiveConfig.maxResultChars);
|
|
4172
|
+
for (const rule of missingRules) {
|
|
4173
|
+
engine.markStaticInjected(rule);
|
|
4174
|
+
}
|
|
4175
|
+
if (sparkshellAwareness.length > 0) {
|
|
4176
|
+
engine.state.staticDedup.add(SPARKSHELL_AWARENESS_DEDUP_KEY);
|
|
4177
|
+
}
|
|
4178
|
+
persistEngineState(engine, input.cachePath, input.channel);
|
|
4179
|
+
return formatAdditionalContextOutput(input.eventName, combineStaticContext(bodyBlock, directive, sparkshellAwareness));
|
|
4180
|
+
}
|
|
4181
|
+
function readRecoveryTranscriptText(transcriptPath) {
|
|
4182
|
+
if (transcriptPath === null) {
|
|
4183
|
+
return null;
|
|
4184
|
+
}
|
|
4185
|
+
return readTranscriptSearchText(transcriptPath, { latestCompactedReplacementOnly: true }) ?? readTranscriptSearchText(transcriptPath);
|
|
4186
|
+
}
|
|
4187
|
+
function recoverDynamicRulePaths(engine, transcriptText, staticRules) {
|
|
4188
|
+
const staticRulePaths = new Set(staticRules.map((rule) => rule.realPath));
|
|
4189
|
+
const recoveredPaths = new Set;
|
|
4190
|
+
for (const dedupKeys of engine.state.dynamicDedup.values()) {
|
|
4191
|
+
for (const dedupKey of dedupKeys) {
|
|
4192
|
+
const separatorIndex = dedupKey.lastIndexOf("::");
|
|
4193
|
+
if (separatorIndex <= 0) {
|
|
4194
|
+
continue;
|
|
4195
|
+
}
|
|
4196
|
+
const rulePath = dedupKey.slice(0, separatorIndex);
|
|
4197
|
+
if (staticRulePaths.has(rulePath)) {
|
|
4198
|
+
continue;
|
|
4199
|
+
}
|
|
4200
|
+
if (transcriptText !== null && transcriptText.includes(rulePath)) {
|
|
4201
|
+
continue;
|
|
4202
|
+
}
|
|
4203
|
+
if (!existsSync5(rulePath)) {
|
|
4204
|
+
continue;
|
|
4205
|
+
}
|
|
4206
|
+
recoveredPaths.add(rulePath);
|
|
4207
|
+
}
|
|
4208
|
+
}
|
|
4209
|
+
return [...recoveredPaths].sort();
|
|
4210
|
+
}
|
|
4211
|
+
function ruleDisplayPath(rule) {
|
|
4212
|
+
return rule.relativePath.length > 0 ? rule.relativePath : rule.path;
|
|
4213
|
+
}
|
|
4214
|
+
function combineStaticContext(...blocks) {
|
|
4215
|
+
return blocks.filter((block) => block.trim().length > 0).join(`
|
|
4216
|
+
|
|
4217
|
+
`);
|
|
4218
|
+
}
|
|
4219
|
+
|
|
4220
|
+
// components/rules/src/tool-paths.ts
|
|
4221
|
+
import { existsSync as existsSync6, statSync as statSync6 } from "node:fs";
|
|
4222
|
+
import { isAbsolute as isAbsolute4, resolve as resolve10 } from "node:path";
|
|
4223
|
+
var COMMAND_TOOL_NAMES = new Set(["bash", "shell_command", "exec_command"]);
|
|
4224
|
+
var TRACKED_TOOL_NAMES = new Set([
|
|
4225
|
+
"read",
|
|
4226
|
+
"read_file",
|
|
4227
|
+
"mcp__filesystem__read_file",
|
|
4228
|
+
"mcp__filesystem__read_multiple_files",
|
|
4229
|
+
"mcp__filesystem__write_file",
|
|
4230
|
+
"mcp__filesystem__edit_file",
|
|
4231
|
+
"write",
|
|
4232
|
+
"edit",
|
|
4233
|
+
"multiedit",
|
|
4234
|
+
"multi_edit",
|
|
4235
|
+
"apply_patch",
|
|
4236
|
+
"bash",
|
|
4237
|
+
"shell_command",
|
|
4238
|
+
"exec_command"
|
|
4239
|
+
]);
|
|
4240
|
+
function extractCodexToolPaths(input, cwd) {
|
|
4241
|
+
const toolName = input.tool_name.toLowerCase();
|
|
4242
|
+
if (!TRACKED_TOOL_NAMES.has(toolName) || isFailedToolResponse(input.tool_response)) {
|
|
4243
|
+
return [];
|
|
4244
|
+
}
|
|
4245
|
+
const paths = new Set;
|
|
4246
|
+
const toolInput = isRecord4(input.tool_input) ? input.tool_input : {};
|
|
4247
|
+
addCommonPathFields(paths, toolInput, cwd);
|
|
4248
|
+
addPatchPayloadPaths(paths, toolInput, cwd);
|
|
4249
|
+
addPatchRecordPaths(paths, toolInput["files"], cwd);
|
|
4250
|
+
addPatchRecordPaths(paths, toolInput["changes"], cwd);
|
|
4251
|
+
if (COMMAND_TOOL_NAMES.has(toolName)) {
|
|
4252
|
+
const command = stringProperty(toolInput, "command") ?? stringProperty(toolInput, "cmd");
|
|
4253
|
+
const workdir = stringProperty(toolInput, "workdir") ?? stringProperty(toolInput, "cwd");
|
|
4254
|
+
addCommandPaths(paths, command, workdir === undefined ? cwd : resolvePath(cwd, workdir));
|
|
4255
|
+
}
|
|
4256
|
+
return [...paths];
|
|
4257
|
+
}
|
|
4258
|
+
function addCommonPathFields(paths, input, cwd) {
|
|
4259
|
+
for (const key of ["path", "filePath", "file_path", "target", "targetPath", "target_path"]) {
|
|
4260
|
+
addPath(paths, input[key], cwd, false);
|
|
4261
|
+
}
|
|
4262
|
+
for (const key of ["paths", "filePaths", "file_paths"]) {
|
|
4263
|
+
addPathArray(paths, input[key], cwd, false);
|
|
4264
|
+
}
|
|
4265
|
+
}
|
|
4266
|
+
function addPatchPayloadPaths(paths, input, cwd) {
|
|
4267
|
+
for (const key of ["input", "patch", "command", "cmd"]) {
|
|
4268
|
+
const value = input[key];
|
|
4269
|
+
if (typeof value === "string") {
|
|
4270
|
+
addPatchHeaderPaths(paths, value, cwd);
|
|
4271
|
+
}
|
|
4272
|
+
}
|
|
4273
|
+
}
|
|
4274
|
+
function addPatchHeaderPaths(paths, patch, cwd) {
|
|
4275
|
+
for (const line of patch.split(`
|
|
4276
|
+
`)) {
|
|
4277
|
+
for (const prefix of ["*** Add File: ", "*** Update File: ", "*** Move to: "]) {
|
|
4278
|
+
if (line.startsWith(prefix)) {
|
|
4279
|
+
addPath(paths, line.slice(prefix.length).trim(), cwd, false);
|
|
4280
|
+
}
|
|
4281
|
+
}
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
function addPatchRecordPaths(paths, value, cwd) {
|
|
4285
|
+
if (!Array.isArray(value))
|
|
4286
|
+
return;
|
|
4287
|
+
for (const item of value) {
|
|
4288
|
+
if (typeof item === "string") {
|
|
4289
|
+
addPath(paths, item, cwd, false);
|
|
4290
|
+
continue;
|
|
4291
|
+
}
|
|
4292
|
+
if (!isRecord4(item))
|
|
4293
|
+
continue;
|
|
4294
|
+
addCommonPathFields(paths, item, cwd);
|
|
4295
|
+
for (const key of ["movePath", "move_path", "to", "from"]) {
|
|
4296
|
+
addPath(paths, item[key], cwd, false);
|
|
4297
|
+
}
|
|
4298
|
+
}
|
|
4299
|
+
}
|
|
4300
|
+
function addCommandPaths(paths, command, cwd) {
|
|
4301
|
+
if (command === undefined)
|
|
4302
|
+
return;
|
|
4303
|
+
for (const token of tokenizeShell(command)) {
|
|
4304
|
+
if (token.length === 0 || token.startsWith("-") || token.includes("*")) {
|
|
4305
|
+
continue;
|
|
4306
|
+
}
|
|
4307
|
+
addPath(paths, token, cwd, true);
|
|
4308
|
+
}
|
|
4309
|
+
}
|
|
4310
|
+
function addPathArray(paths, value, cwd, mustExist) {
|
|
4311
|
+
if (!Array.isArray(value))
|
|
4312
|
+
return;
|
|
4313
|
+
for (const item of value) {
|
|
4314
|
+
addPath(paths, item, cwd, mustExist);
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
function addPath(paths, value, cwd, mustExist) {
|
|
4318
|
+
if (typeof value !== "string" || value.length === 0 || looksLikeUrl(value)) {
|
|
4319
|
+
return;
|
|
4320
|
+
}
|
|
4321
|
+
const path = resolvePath(cwd, value);
|
|
4322
|
+
if (mustExist && !isExistingFile(path)) {
|
|
4323
|
+
return;
|
|
4324
|
+
}
|
|
4325
|
+
paths.add(path);
|
|
4326
|
+
}
|
|
4327
|
+
function resolvePath(cwd, filePath) {
|
|
4328
|
+
return isAbsolute4(filePath) ? filePath : resolve10(cwd, filePath);
|
|
4329
|
+
}
|
|
4330
|
+
function isExistingFile(filePath) {
|
|
4331
|
+
try {
|
|
4332
|
+
return existsSync6(filePath) && statSync6(filePath).isFile();
|
|
4333
|
+
} catch {
|
|
4334
|
+
return false;
|
|
4335
|
+
}
|
|
4336
|
+
}
|
|
4337
|
+
function looksLikeUrl(value) {
|
|
4338
|
+
return /^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(value);
|
|
4339
|
+
}
|
|
4340
|
+
function stringProperty(value, key) {
|
|
4341
|
+
const property = value[key];
|
|
4342
|
+
return typeof property === "string" && property.length > 0 ? property : undefined;
|
|
4343
|
+
}
|
|
4344
|
+
function tokenizeShell(command) {
|
|
4345
|
+
const tokens = [];
|
|
4346
|
+
let current = "";
|
|
4347
|
+
let quote = null;
|
|
4348
|
+
let escaped = false;
|
|
4349
|
+
for (const character of command) {
|
|
4350
|
+
if (escaped) {
|
|
4351
|
+
current += character;
|
|
4352
|
+
escaped = false;
|
|
4353
|
+
continue;
|
|
4354
|
+
}
|
|
4355
|
+
if (character === "\\") {
|
|
4356
|
+
escaped = true;
|
|
4357
|
+
continue;
|
|
4358
|
+
}
|
|
4359
|
+
if ((character === "'" || character === '"') && quote === null) {
|
|
4360
|
+
quote = character;
|
|
4361
|
+
continue;
|
|
4362
|
+
}
|
|
4363
|
+
if (quote === character) {
|
|
4364
|
+
quote = null;
|
|
4365
|
+
continue;
|
|
4366
|
+
}
|
|
4367
|
+
if (quote === null && /\s/.test(character)) {
|
|
4368
|
+
if (current.length > 0) {
|
|
4369
|
+
tokens.push(current);
|
|
4370
|
+
current = "";
|
|
4371
|
+
}
|
|
4372
|
+
continue;
|
|
4373
|
+
}
|
|
4374
|
+
current += character;
|
|
4375
|
+
}
|
|
4376
|
+
if (current.length > 0) {
|
|
4377
|
+
tokens.push(current);
|
|
4378
|
+
}
|
|
4379
|
+
return tokens;
|
|
4380
|
+
}
|
|
4381
|
+
function isRecord4(value) {
|
|
4382
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4383
|
+
}
|
|
4384
|
+
function isFailedToolResponse(value) {
|
|
4385
|
+
if (!isRecord4(value))
|
|
4386
|
+
return false;
|
|
4387
|
+
return value["isError"] === true || value["is_error"] === true || value["error"] === true || value["status"] === "error";
|
|
4388
|
+
}
|
|
4389
|
+
|
|
4390
|
+
// components/rules/src/codex-hook.ts
|
|
4391
|
+
async function runSessionStartHook(input, options = {}) {
|
|
4392
|
+
const cachePath = sessionCachePath(input.session_id, options.pluginDataRoot);
|
|
4393
|
+
if (input.source === "clear") {
|
|
4394
|
+
clearSessionState(cachePath);
|
|
4395
|
+
} else if (input.source !== "resume" && input.source !== "compact" && !hasPostCompactPending(cachePath)) {
|
|
4396
|
+
clearSessionState(cachePath);
|
|
4397
|
+
}
|
|
4398
|
+
const postCompactClaim = input.source === "clear" ? "not-pending" : claimPostCompactPending(cachePath, "static");
|
|
4399
|
+
const completedPostCompactKind = claimedPostCompactKind(postCompactClaim, "static") ?? (input.source === "compact" && postCompactClaim === "not-pending" ? "static" : undefined);
|
|
4400
|
+
if (shouldSkipPostCompactClaim(postCompactClaim, input.source === "compact" && isPostCompactRecoveryInProgress(cachePath, "static"))) {
|
|
4401
|
+
return "";
|
|
4402
|
+
}
|
|
4403
|
+
const transcriptPath = input.source === "clear" ? null : input.transcript_path;
|
|
4404
|
+
return runStaticInjection(input.cwd, transcriptPath, "SessionStart", cachePath, options, completedPostCompactKind, { latestCompactedReplacementOnly: completedPostCompactKind !== undefined }, input.model);
|
|
4405
|
+
}
|
|
4406
|
+
async function runPostCompactHook(input, options = {}) {
|
|
4407
|
+
markSessionCompacted(sessionCachePath(input.session_id, options.pluginDataRoot));
|
|
4408
|
+
return "";
|
|
4409
|
+
}
|
|
4410
|
+
async function runUserPromptSubmitHook(input, options = {}) {
|
|
4411
|
+
if (hasContextPressureMarker(input.prompt)) {
|
|
4412
|
+
return "";
|
|
4413
|
+
}
|
|
4414
|
+
const cachePath = sessionCachePath(input.session_id, options.pluginDataRoot);
|
|
4415
|
+
const postCompactClaim = claimPostCompactPending(cachePath, "static");
|
|
4416
|
+
if (postCompactClaim === "not-pending" && transcriptHasContextPressureMarker(input.transcript_path)) {
|
|
4417
|
+
return "";
|
|
4418
|
+
}
|
|
4419
|
+
const completedPostCompactKind = claimedPostCompactKind(postCompactClaim, "static");
|
|
4420
|
+
if (shouldSkipPostCompactClaim(postCompactClaim, isPostCompactRecoveryInProgress(cachePath, "static"))) {
|
|
4421
|
+
return "";
|
|
4422
|
+
}
|
|
4423
|
+
return runStaticInjection(input.cwd, input.transcript_path, "UserPromptSubmit", cachePath, options, completedPostCompactKind, { latestCompactedReplacementOnly: completedPostCompactKind !== undefined }, input.model);
|
|
4424
|
+
}
|
|
4425
|
+
async function runPostToolUseHook(input, options = {}) {
|
|
4426
|
+
const debugTimer = createHookDebugTimer("PostToolUse");
|
|
4427
|
+
const config = configFromEnvironment(options.env);
|
|
4428
|
+
debugTimer.lap("config", { disabled: config.disabled, mode: config.mode });
|
|
4429
|
+
if (config.disabled || config.mode === "off" || config.mode === "static") {
|
|
4430
|
+
debugTimer.done({ outputBytes: 0, reason: "disabled" });
|
|
4431
|
+
return "";
|
|
4432
|
+
}
|
|
4433
|
+
const targetPaths = extractCodexToolPaths(input, input.cwd);
|
|
4434
|
+
debugTimer.lap("extract", {
|
|
4435
|
+
targets: targetPaths.length,
|
|
4436
|
+
uniqueTargets: uniqueStrings2(targetPaths).length,
|
|
4437
|
+
tool: input.tool_name
|
|
4438
|
+
});
|
|
4439
|
+
const firstTargetPath = targetPaths[0];
|
|
4440
|
+
if (firstTargetPath === undefined) {
|
|
4441
|
+
debugTimer.done({ outputBytes: 0, reason: "no-target" });
|
|
4442
|
+
return "";
|
|
4443
|
+
}
|
|
4444
|
+
const cachePath = sessionCachePath(input.session_id, options.pluginDataRoot);
|
|
4445
|
+
const postCompactClaim = claimPostCompactPending(cachePath, "dynamic");
|
|
4446
|
+
if (postCompactClaim === "not-pending" && transcriptHasContextPressureMarker(input.transcript_path)) {
|
|
4447
|
+
debugTimer.done({ outputBytes: 0, reason: "context-pressure-transcript" });
|
|
4448
|
+
return "";
|
|
4449
|
+
}
|
|
4450
|
+
const completedPostCompactKind = claimedPostCompactKind(postCompactClaim, "dynamic");
|
|
4451
|
+
if (shouldSkipPostCompactClaim(postCompactClaim, isPostCompactRecoveryInProgress(cachePath, "dynamic"))) {
|
|
4452
|
+
debugTimer.done({ outputBytes: 0, reason: "post-compact-recovery-in-progress" });
|
|
4453
|
+
return "";
|
|
4454
|
+
}
|
|
4455
|
+
const dynamicConfig = withDynamicBudget(config);
|
|
4456
|
+
const engine = createRulesEngine(options, completedPostCompactKind !== undefined ? withPostCompactBudget(dynamicConfig, { model: input.model, transcriptPath: input.transcript_path }) : dynamicConfig);
|
|
4457
|
+
hydrateEngineState(engine, cachePath);
|
|
4458
|
+
debugTimer.lap("hydrate", {
|
|
4459
|
+
dynamicDedupScopes: engine.state.dynamicDedup.size,
|
|
4460
|
+
dynamicTargetFingerprints: engine.state.dynamicTargetFingerprints.size,
|
|
4461
|
+
staticDedup: engine.state.staticDedup.size
|
|
4462
|
+
});
|
|
4463
|
+
const dynamicTargetFingerprints = fingerprintDynamicTargets(input.cwd, targetPaths, config);
|
|
4464
|
+
debugTimer.lap("fingerprint", { fingerprints: dynamicTargetFingerprints.length });
|
|
4465
|
+
const pendingTargetFingerprints = dynamicTargetFingerprints.filter((target) => engine.state.dynamicTargetFingerprints.get(target.cacheKey) !== target.fingerprint);
|
|
4466
|
+
debugTimer.lap("pending", { pending: pendingTargetFingerprints.length });
|
|
4467
|
+
if (pendingTargetFingerprints.length === 0) {
|
|
4468
|
+
persistEngineState(engine, cachePath, completedPostCompactKind);
|
|
4469
|
+
debugTimer.lap("persist", { reason: "no-pending" });
|
|
4470
|
+
debugTimer.done({ outputBytes: 0, reason: "no-pending" });
|
|
4471
|
+
return "";
|
|
4472
|
+
}
|
|
4473
|
+
const loaded = engine.loadDynamicRules(input.cwd, pendingTargetFingerprints.map((target) => target.targetPath));
|
|
4474
|
+
debugTimer.lap("load", { diagnostics: loaded.diagnostics.length, loadedRules: loaded.rules.length });
|
|
4475
|
+
const rules = filterRulesAlreadyInTranscript(loaded.rules.filter((rule) => !engine.isStaticInjected(rule) && !engine.isDynamicInjected(rule)), input.transcript_path, (rule) => {
|
|
4476
|
+
engine.markDynamicInjected(rule);
|
|
4477
|
+
}, { latestCompactedReplacementOnly: completedPostCompactKind !== undefined });
|
|
4478
|
+
debugTimer.lap("filter", { rules: rules.length });
|
|
4479
|
+
for (const target of pendingTargetFingerprints) {
|
|
4480
|
+
engine.state.dynamicTargetFingerprints.set(target.cacheKey, target.fingerprint);
|
|
4481
|
+
}
|
|
4482
|
+
if (rules.length === 0) {
|
|
4483
|
+
persistEngineState(engine, cachePath, completedPostCompactKind);
|
|
4484
|
+
debugTimer.lap("persist", { reason: "no-rules" });
|
|
4485
|
+
debugTimer.done({ outputBytes: 0, reason: "no-rules" });
|
|
4486
|
+
return "";
|
|
4487
|
+
}
|
|
4488
|
+
const firstPendingTargetPath = pendingTargetFingerprints[0]?.targetPath ?? firstTargetPath;
|
|
4489
|
+
const block = engine.formatDynamic(rules, displayPath(input.cwd, firstPendingTargetPath));
|
|
4490
|
+
debugTimer.lap("format", { blockChars: block.length, rules: rules.length });
|
|
4491
|
+
for (const rule of rules) {
|
|
4492
|
+
engine.markDynamicInjected(rule);
|
|
4493
|
+
}
|
|
4494
|
+
persistEngineState(engine, cachePath, completedPostCompactKind);
|
|
4495
|
+
debugTimer.lap("persist", { reason: "emit" });
|
|
4496
|
+
const output = formatAdditionalContextOutput("PostToolUse", block);
|
|
4497
|
+
debugTimer.done({ outputBytes: Buffer.byteLength(output), reason: "emit" });
|
|
4498
|
+
return output;
|
|
4499
|
+
}
|
|
4500
|
+
|
|
4501
|
+
// components/rules/src/cli.ts
|
|
4502
|
+
var command = process.argv[2];
|
|
4503
|
+
var subcommand = process.argv[3];
|
|
4504
|
+
if (command === "hook" && subcommand === "session-start") {
|
|
4505
|
+
await runHookCli("SessionStart");
|
|
4506
|
+
} else if (command === "hook" && subcommand === "user-prompt-submit") {
|
|
4507
|
+
await runHookCli("UserPromptSubmit");
|
|
4508
|
+
} else if (command === "hook" && subcommand === "post-tool-use") {
|
|
4509
|
+
await runHookCli("PostToolUse");
|
|
4510
|
+
} else if (command === "hook" && subcommand === "post-compact") {
|
|
4511
|
+
await runHookCli("PostCompact");
|
|
4512
|
+
} else {
|
|
4513
|
+
process.stderr.write(`Usage: omo-rules hook [session-start|user-prompt-submit|post-tool-use|post-compact]
|
|
4514
|
+
`);
|
|
4515
|
+
process.exitCode = 1;
|
|
4516
|
+
}
|
|
4517
|
+
async function runHookCli(eventName) {
|
|
4518
|
+
const raw = await readStdin();
|
|
4519
|
+
if (raw.trim().length === 0)
|
|
4520
|
+
return;
|
|
4521
|
+
const parsed = parseHookInput(raw);
|
|
4522
|
+
if (!parsed)
|
|
4523
|
+
return;
|
|
4524
|
+
const pluginDataRoot = process.env["PLUGIN_DATA"];
|
|
4525
|
+
const options = pluginDataRoot === undefined ? {} : { pluginDataRoot };
|
|
4526
|
+
const output = await runHook(eventName, parsed, options);
|
|
4527
|
+
await writeStdout(output);
|
|
4528
|
+
}
|
|
4529
|
+
async function runHook(eventName, parsed, options) {
|
|
4530
|
+
switch (eventName) {
|
|
4531
|
+
case "SessionStart":
|
|
4532
|
+
return isCodexSessionStartInput(parsed) ? await runSessionStartHook(parsed, options) : "";
|
|
4533
|
+
case "UserPromptSubmit":
|
|
4534
|
+
return isCodexUserPromptSubmitInput(parsed) ? await runUserPromptSubmitHook(parsed, options) : "";
|
|
4535
|
+
case "PostToolUse":
|
|
4536
|
+
return isCodexPostToolUseInput(parsed) ? await runPostToolUseHook(parsed, options) : "";
|
|
4537
|
+
case "PostCompact":
|
|
4538
|
+
return isCodexPostCompactInput(parsed) ? await runPostCompactHook(parsed, options) : "";
|
|
4539
|
+
}
|
|
4540
|
+
}
|
|
4541
|
+
function parseHookInput(raw) {
|
|
4542
|
+
try {
|
|
4543
|
+
const parsed = JSON.parse(raw);
|
|
4544
|
+
return parsed;
|
|
4545
|
+
} catch {
|
|
4546
|
+
return;
|
|
4547
|
+
}
|
|
56
4548
|
}
|
|
57
4549
|
function isCodexSessionStartInput(value) {
|
|
58
|
-
|
|
59
|
-
value["hook_event_name"] === "SessionStart" &&
|
|
60
|
-
typeof value["session_id"] === "string" &&
|
|
61
|
-
isStringOrNull(value["transcript_path"]) &&
|
|
62
|
-
typeof value["cwd"] === "string" &&
|
|
63
|
-
typeof value["model"] === "string" &&
|
|
64
|
-
typeof value["permission_mode"] === "string" &&
|
|
65
|
-
typeof value["source"] === "string");
|
|
4550
|
+
return isRecord5(value) && value["hook_event_name"] === "SessionStart" && typeof value["session_id"] === "string" && isStringOrNull(value["transcript_path"]) && typeof value["cwd"] === "string" && typeof value["model"] === "string" && typeof value["permission_mode"] === "string" && typeof value["source"] === "string";
|
|
66
4551
|
}
|
|
67
4552
|
function isCodexUserPromptSubmitInput(value) {
|
|
68
|
-
|
|
69
|
-
value["hook_event_name"] === "UserPromptSubmit" &&
|
|
70
|
-
typeof value["session_id"] === "string" &&
|
|
71
|
-
typeof value["turn_id"] === "string" &&
|
|
72
|
-
isStringOrNull(value["transcript_path"]) &&
|
|
73
|
-
typeof value["cwd"] === "string" &&
|
|
74
|
-
typeof value["model"] === "string" &&
|
|
75
|
-
typeof value["permission_mode"] === "string" &&
|
|
76
|
-
typeof value["prompt"] === "string");
|
|
4553
|
+
return isRecord5(value) && value["hook_event_name"] === "UserPromptSubmit" && typeof value["session_id"] === "string" && typeof value["turn_id"] === "string" && isStringOrNull(value["transcript_path"]) && typeof value["cwd"] === "string" && typeof value["model"] === "string" && typeof value["permission_mode"] === "string" && typeof value["prompt"] === "string";
|
|
77
4554
|
}
|
|
78
4555
|
function isCodexPostToolUseInput(value) {
|
|
79
|
-
|
|
80
|
-
value["hook_event_name"] === "PostToolUse" &&
|
|
81
|
-
typeof value["session_id"] === "string" &&
|
|
82
|
-
typeof value["turn_id"] === "string" &&
|
|
83
|
-
isStringOrNull(value["transcript_path"]) &&
|
|
84
|
-
typeof value["cwd"] === "string" &&
|
|
85
|
-
typeof value["model"] === "string" &&
|
|
86
|
-
typeof value["permission_mode"] === "string" &&
|
|
87
|
-
typeof value["tool_name"] === "string" &&
|
|
88
|
-
typeof value["tool_use_id"] === "string");
|
|
4556
|
+
return isRecord5(value) && value["hook_event_name"] === "PostToolUse" && typeof value["session_id"] === "string" && typeof value["turn_id"] === "string" && isStringOrNull(value["transcript_path"]) && typeof value["cwd"] === "string" && typeof value["model"] === "string" && typeof value["permission_mode"] === "string" && typeof value["tool_name"] === "string" && typeof value["tool_use_id"] === "string";
|
|
89
4557
|
}
|
|
90
4558
|
function isCodexPostCompactInput(value) {
|
|
91
|
-
|
|
92
|
-
value["hook_event_name"] === "PostCompact" &&
|
|
93
|
-
typeof value["session_id"] === "string" &&
|
|
94
|
-
typeof value["turn_id"] === "string" &&
|
|
95
|
-
isStringOrNull(value["transcript_path"]) &&
|
|
96
|
-
typeof value["cwd"] === "string" &&
|
|
97
|
-
typeof value["model"] === "string" &&
|
|
98
|
-
(value["trigger"] === "manual" || value["trigger"] === "auto"));
|
|
4559
|
+
return isRecord5(value) && value["hook_event_name"] === "PostCompact" && typeof value["session_id"] === "string" && typeof value["turn_id"] === "string" && isStringOrNull(value["transcript_path"]) && typeof value["cwd"] === "string" && typeof value["model"] === "string" && (value["trigger"] === "manual" || value["trigger"] === "auto");
|
|
99
4560
|
}
|
|
100
4561
|
function isStringOrNull(value) {
|
|
101
|
-
|
|
4562
|
+
return typeof value === "string" || value === null;
|
|
102
4563
|
}
|
|
103
|
-
function
|
|
104
|
-
|
|
4564
|
+
function isRecord5(value) {
|
|
4565
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
105
4566
|
}
|
|
106
4567
|
function readStdin() {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
4568
|
+
return new Promise((resolve11, reject) => {
|
|
4569
|
+
let data = "";
|
|
4570
|
+
processStdin.setEncoding("utf8");
|
|
4571
|
+
processStdin.on("data", (chunk) => {
|
|
4572
|
+
data += chunk;
|
|
4573
|
+
});
|
|
4574
|
+
processStdin.once("error", reject);
|
|
4575
|
+
processStdin.once("end", () => {
|
|
4576
|
+
processStdin.pause();
|
|
4577
|
+
resolve11(data);
|
|
4578
|
+
});
|
|
4579
|
+
processStdin.resume();
|
|
4580
|
+
});
|
|
4581
|
+
}
|
|
4582
|
+
function writeStdout(output) {
|
|
4583
|
+
if (output.length === 0)
|
|
4584
|
+
return Promise.resolve();
|
|
4585
|
+
return new Promise((resolve11, reject) => {
|
|
4586
|
+
processStdout.write(output, (error) => {
|
|
4587
|
+
if (error) {
|
|
4588
|
+
reject(error);
|
|
4589
|
+
return;
|
|
4590
|
+
}
|
|
4591
|
+
resolve11();
|
|
117
4592
|
});
|
|
4593
|
+
});
|
|
118
4594
|
}
|