oh-my-opencode 4.5.1 → 4.6.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/opencode-qa/SKILL.md +194 -0
- package/.agents/skills/opencode-qa/references/cli-commands.md +188 -0
- package/.agents/skills/opencode-qa/references/db-investigation.md +197 -0
- package/.agents/skills/opencode-qa/references/events-hooks.md +110 -0
- package/.agents/skills/opencode-qa/references/sdk.md +96 -0
- package/.agents/skills/opencode-qa/references/server-api.md +200 -0
- package/.agents/skills/opencode-qa/references/testing-harness.md +218 -0
- package/.agents/skills/opencode-qa/references/tui-tmux.md +52 -0
- package/.agents/skills/opencode-qa/scripts/db-session-by-id.sh +53 -0
- package/.agents/skills/opencode-qa/scripts/db-session-by-name.sh +57 -0
- package/.agents/skills/opencode-qa/scripts/db-session-by-text.sh +158 -0
- package/.agents/skills/opencode-qa/scripts/export-roundtrip.sh +57 -0
- package/.agents/skills/opencode-qa/scripts/lib/common.sh +216 -0
- package/.agents/skills/opencode-qa/scripts/server-smoke.sh +64 -0
- package/.agents/skills/opencode-qa/scripts/sse-hook-probe.sh +106 -0
- package/.agents/skills/opencode-qa/scripts/tui-smoke.sh +89 -0
- package/README.ja.md +43 -18
- package/README.ko.md +43 -18
- package/README.md +92 -24
- package/README.ru.md +43 -18
- package/README.zh-cn.md +55 -24
- package/bin/oh-my-opencode.js +49 -3
- package/bin/oh-my-opencode.test.ts +202 -0
- package/bin/platform.d.ts +7 -1
- package/bin/platform.js +23 -4
- package/bin/platform.test.ts +97 -10
- package/dist/cli/cleanup-command.d.ts +4 -0
- package/dist/cli/cleanup.d.ts +11 -0
- package/dist/cli/cli-program.d.ts +19 -0
- package/dist/cli/index.js +30085 -26385
- package/dist/cli/install-codex/codex-cache-bundled-mcps.d.ts +5 -0
- package/dist/cli/install-codex/codex-cache-command-shim.d.ts +1 -0
- package/dist/cli/install-codex/codex-cache-legacy-bins.d.ts +3 -0
- package/dist/cli/install-codex/codex-cache-local-dependencies.d.ts +1 -0
- package/dist/cli/install-codex/codex-cache-paths.d.ts +2 -0
- package/dist/cli/install-codex/codex-cache.d.ts +32 -0
- package/dist/cli/install-codex/codex-cleanup-config.d.ts +6 -0
- package/dist/cli/install-codex/codex-cleanup.d.ts +21 -0
- package/dist/cli/install-codex/codex-config-mcp.d.ts +1 -0
- package/dist/cli/install-codex/codex-config-permissions.d.ts +1 -0
- package/dist/cli/install-codex/codex-config-reasoning.d.ts +1 -0
- package/dist/cli/install-codex/codex-config-toml.d.ts +12 -0
- package/dist/cli/install-codex/codex-hook-trust.d.ts +6 -0
- package/dist/cli/install-codex/codex-installation-detection.d.ts +36 -0
- package/dist/cli/install-codex/codex-marketplace-snapshot.d.ts +15 -0
- package/dist/cli/install-codex/codex-marketplace.d.ts +9 -0
- package/dist/cli/install-codex/codex-multi-agent-v2-config.d.ts +1 -0
- package/dist/cli/install-codex/codex-package-layout.d.ts +1 -0
- package/dist/cli/install-codex/codex-process.d.ts +2 -0
- package/dist/cli/install-codex/codex-project-local-cleanup-best-effort.d.ts +7 -0
- package/dist/cli/install-codex/codex-project-local-cleanup.d.ts +35 -0
- package/dist/cli/install-codex/git-bash.d.ts +35 -0
- package/dist/cli/install-codex/index.d.ts +11 -0
- package/dist/cli/install-codex/install-codex.d.ts +17 -0
- package/dist/cli/install-codex/link-cached-plugin-agents.d.ts +12 -0
- package/dist/cli/install-codex/toml-section-editor.d.ts +11 -0
- package/dist/cli/install-codex/types.d.ts +76 -0
- package/dist/cli/run/event-state.d.ts +1 -0
- package/dist/cli/run/poll-for-completion.d.ts +1 -0
- package/dist/cli/run/prompt-start.d.ts +7 -0
- package/dist/cli/star-request.d.ts +11 -0
- package/dist/cli/tui-install-prompts.d.ts +3 -2
- package/dist/cli/types.d.ts +8 -0
- package/dist/config/schema/agent-names.d.ts +4 -1
- package/dist/config/schema/commands.d.ts +1 -2
- package/dist/config/schema/hooks.d.ts +0 -1
- package/dist/config/schema/oh-my-opencode-config.d.ts +5 -3
- package/dist/create-hooks.d.ts +0 -1
- package/dist/create-managers.d.ts +1 -0
- package/dist/features/background-agent/parent-wake-message-activity.d.ts +23 -0
- package/dist/features/background-agent/parent-wake-notifier.d.ts +0 -1
- package/dist/features/boulder-state/storage.d.ts +1 -1
- package/dist/features/builtin-commands/templates/refactor.d.ts +1 -1
- package/dist/features/builtin-commands/templates/remove-ai-slops.d.ts +2 -2
- package/dist/features/builtin-commands/types.d.ts +1 -1
- package/dist/features/builtin-skills/skill-file-loader.d.ts +4 -0
- package/dist/features/builtin-skills/skills/debugging.d.ts +2 -0
- package/dist/features/builtin-skills/skills/index.d.ts +5 -1
- package/dist/features/builtin-skills/skills/init-deep.d.ts +2 -0
- package/dist/features/builtin-skills/skills/remove-ai-slops.d.ts +2 -0
- package/dist/features/builtin-skills/skills/security-research.d.ts +2 -0
- package/dist/features/builtin-skills/skills/security-review.d.ts +2 -0
- package/dist/features/opencode-runtime-skills/index.d.ts +2 -0
- package/dist/features/opencode-runtime-skills/runtime-skill-config.d.ts +17 -0
- package/dist/features/opencode-runtime-skills/skill-markdown.d.ts +7 -0
- package/dist/features/opencode-runtime-skills/source-server.d.ts +8 -0
- package/dist/hooks/claude-code-hooks/hook-text.d.ts +2 -0
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/session-recovery/storage/latest-assistant-message.d.ts +5 -0
- package/dist/hooks/session-recovery/storage/thinking-prepend.d.ts +3 -0
- package/dist/hooks/thinking-block-validator/hook.d.ts +0 -18
- package/dist/hooks/todo-continuation-enforcer/pending-question-detection.d.ts +4 -0
- package/dist/index.js +1949 -1913
- package/dist/oh-my-opencode.schema.json +4 -2
- package/dist/plugin/hooks/create-core-hooks.d.ts +0 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +1 -2
- package/dist/plugin/messages-transform.d.ts +8 -1
- package/dist/plugin/user-abort-interrupted-recovery-guard.d.ts +6 -0
- package/dist/plugin-handlers/config-handler.d.ts +2 -1
- package/dist/shared/external-plugin-detector.d.ts +8 -0
- package/dist/shared/prompt-async-gate/message-inspection-error.d.ts +1 -0
- package/dist/shared/prompt-async-gate/pending-tool-turn.d.ts +1 -0
- package/dist/shared/prompt-async-gate/prompt-message-state.d.ts +8 -0
- package/dist/shared/prompt-async-gate/recent-dispatches.d.ts +14 -0
- package/dist/shared/prompt-async-gate/semantic-dedupe.d.ts +7 -0
- package/dist/shared/prompt-async-gate/session-idle-dispatch.d.ts +1 -0
- package/dist/shared/prompt-async-gate/timing.d.ts +1 -0
- package/dist/shared/prompt-async-gate/types.d.ts +2 -0
- package/dist/shared/prompt-async-gate.d.ts +1 -1
- package/dist/shared/prompt-timeout-context.d.ts +2 -0
- package/dist/testing/create-plugin-module.d.ts +5 -1
- package/dist/tools/delegate-task/sync-prompt-sender.d.ts +2 -2
- package/package.json +38 -18
- package/packages/ast-grep-mcp/dist/cli.js +245 -40
- package/packages/git-bash-mcp/dist/cli.js +367 -0
- package/packages/lsp-tools-mcp/dist/cli.js +1 -1
- package/packages/omo-codex/marketplace.json +17 -0
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +35 -0
- package/packages/omo-codex/plugin/.mcp.json +25 -0
- package/packages/omo-codex/plugin/README.md +13 -0
- package/packages/omo-codex/plugin/components/comment-checker/.gitattributes +13 -0
- package/packages/omo-codex/plugin/components/comment-checker/.github/CODEOWNERS +12 -0
- package/packages/omo-codex/plugin/components/comment-checker/.github/ISSUE_TEMPLATE/bug.yml +40 -0
- package/packages/omo-codex/plugin/components/comment-checker/.github/ISSUE_TEMPLATE/feature.yml +27 -0
- package/packages/omo-codex/plugin/components/comment-checker/.github/branch-ruleset.json +45 -0
- package/packages/omo-codex/plugin/components/comment-checker/.github/dependabot.yml +16 -0
- package/packages/omo-codex/plugin/components/comment-checker/.github/pull_request_template.md +19 -0
- package/packages/omo-codex/plugin/components/comment-checker/.github/workflows/ci.yml +47 -0
- package/packages/omo-codex/plugin/components/comment-checker/.github/workflows/publish.yml +51 -0
- package/packages/omo-codex/plugin/components/comment-checker/AGENTS.md +35 -0
- package/packages/omo-codex/plugin/components/comment-checker/CHANGELOG.md +33 -0
- package/packages/omo-codex/plugin/components/comment-checker/LICENSE +21 -0
- package/packages/omo-codex/plugin/components/comment-checker/NOTICE +6 -0
- package/packages/omo-codex/plugin/components/comment-checker/README.md +87 -0
- package/packages/omo-codex/plugin/components/comment-checker/biome.json +48 -0
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +17 -0
- package/packages/omo-codex/plugin/components/comment-checker/package.json +57 -0
- package/packages/omo-codex/plugin/components/comment-checker/skills/comment-checker/SKILL.md +16 -0
- package/packages/omo-codex/plugin/components/comment-checker/src/cli.ts +12 -0
- package/packages/omo-codex/plugin/components/comment-checker/src/codex-hook.ts +205 -0
- package/packages/omo-codex/plugin/components/comment-checker/src/core.ts +361 -0
- package/packages/omo-codex/plugin/components/comment-checker/src/runner.ts +195 -0
- package/packages/omo-codex/plugin/components/comment-checker/test/codex-hook-newline.test.ts +52 -0
- package/packages/omo-codex/plugin/components/comment-checker/test/codex-hook.test.ts +368 -0
- package/packages/omo-codex/plugin/components/comment-checker/test/fixtures/post-tool-use.json +15 -0
- package/packages/omo-codex/plugin/components/comment-checker/test/package-smoke.test.ts +93 -0
- package/packages/omo-codex/plugin/components/comment-checker/test/runner.test.ts +66 -0
- package/packages/omo-codex/plugin/components/comment-checker/tsconfig.build.json +12 -0
- package/packages/omo-codex/plugin/components/comment-checker/tsconfig.json +27 -0
- package/packages/omo-codex/plugin/components/comment-checker/vitest.config.ts +9 -0
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +29 -0
- package/packages/omo-codex/plugin/components/git-bash/package.json +23 -0
- package/packages/omo-codex/plugin/components/git-bash/src/cli.ts +33 -0
- package/packages/omo-codex/plugin/components/git-bash/src/codex-hook.ts +180 -0
- package/packages/omo-codex/plugin/components/git-bash/src/index.ts +10 -0
- package/packages/omo-codex/plugin/components/git-bash/test/codex-hook.test.ts +195 -0
- package/packages/omo-codex/plugin/components/git-bash/tsconfig.build.json +13 -0
- package/packages/omo-codex/plugin/components/git-bash/tsconfig.json +25 -0
- package/packages/omo-codex/plugin/components/lsp/.gitattributes +13 -0
- package/packages/omo-codex/plugin/components/lsp/.github/CODEOWNERS +1 -0
- package/packages/omo-codex/plugin/components/lsp/.github/ISSUE_TEMPLATE/bug.yml +26 -0
- package/packages/omo-codex/plugin/components/lsp/.github/ISSUE_TEMPLATE/feature.yml +19 -0
- package/packages/omo-codex/plugin/components/lsp/.github/branch-ruleset.json +45 -0
- package/packages/omo-codex/plugin/components/lsp/.github/dependabot.yml +11 -0
- package/packages/omo-codex/plugin/components/lsp/.github/pull_request_template.md +11 -0
- package/packages/omo-codex/plugin/components/lsp/.github/workflows/ci.yml +56 -0
- package/packages/omo-codex/plugin/components/lsp/.github/workflows/publish.yml +60 -0
- package/packages/omo-codex/plugin/components/lsp/.mcp.json +9 -0
- package/packages/omo-codex/plugin/components/lsp/AGENTS.md +25 -0
- package/packages/omo-codex/plugin/components/lsp/CHANGELOG.md +25 -0
- package/packages/omo-codex/plugin/components/lsp/LICENSE +21 -0
- package/packages/omo-codex/plugin/components/lsp/NOTICE +3 -0
- package/packages/omo-codex/plugin/components/lsp/README.md +148 -0
- package/packages/omo-codex/plugin/components/lsp/biome.json +48 -0
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +17 -0
- package/packages/omo-codex/plugin/components/lsp/package.json +64 -0
- package/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.mjs +46 -0
- package/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.test.mjs +104 -0
- package/packages/omo-codex/plugin/components/lsp/scripts/clean-dist.mjs +5 -0
- package/packages/omo-codex/plugin/components/lsp/scripts/test.mjs +8 -0
- package/packages/omo-codex/plugin/components/lsp/skills/lsp/SKILL.md +35 -0
- package/packages/omo-codex/plugin/components/lsp/src/cli.ts +44 -0
- package/packages/omo-codex/plugin/components/lsp/src/codex-hook-cli.ts +33 -0
- package/packages/omo-codex/plugin/components/lsp/src/codex-hook.ts +277 -0
- package/packages/omo-codex/plugin/components/lsp/test/codex-hook-cli.test.ts +28 -0
- package/packages/omo-codex/plugin/components/lsp/test/codex-hook-errors.test.ts +55 -0
- package/packages/omo-codex/plugin/components/lsp/test/codex-hook.test.ts +358 -0
- package/packages/omo-codex/plugin/components/lsp/test/fixtures/broken.py +1 -0
- package/packages/omo-codex/plugin/components/lsp/test/fixtures/post-tool-use.json +15 -0
- package/packages/omo-codex/plugin/components/lsp/test/package-smoke.test.ts +155 -0
- package/packages/omo-codex/plugin/components/lsp/tsconfig.build.json +12 -0
- package/packages/omo-codex/plugin/components/lsp/tsconfig.json +27 -0
- package/packages/omo-codex/plugin/components/lsp/vitest.config.ts +9 -0
- package/packages/omo-codex/plugin/components/rules/.codex-plugin/plugin.json +3 -0
- package/packages/omo-codex/plugin/components/rules/.gitattributes +13 -0
- package/packages/omo-codex/plugin/components/rules/.github/CODEOWNERS +12 -0
- package/packages/omo-codex/plugin/components/rules/.github/ISSUE_TEMPLATE/bug.yml +49 -0
- package/packages/omo-codex/plugin/components/rules/.github/ISSUE_TEMPLATE/feature.yml +27 -0
- package/packages/omo-codex/plugin/components/rules/.github/branch-ruleset.json +45 -0
- package/packages/omo-codex/plugin/components/rules/.github/dependabot.yml +16 -0
- package/packages/omo-codex/plugin/components/rules/.github/pull_request_template.md +20 -0
- package/packages/omo-codex/plugin/components/rules/.github/workflows/ci.yml +47 -0
- package/packages/omo-codex/plugin/components/rules/.github/workflows/publish.yml +51 -0
- package/packages/omo-codex/plugin/components/rules/AGENTS.md +34 -0
- package/packages/omo-codex/plugin/components/rules/CHANGELOG.md +19 -0
- package/packages/omo-codex/plugin/components/rules/LICENSE +21 -0
- package/packages/omo-codex/plugin/components/rules/NOTICE +15 -0
- package/packages/omo-codex/plugin/components/rules/README.md +124 -0
- package/packages/omo-codex/plugin/components/rules/biome.json +48 -0
- package/packages/omo-codex/plugin/components/rules/bundled-rules/hephaestus.md +209 -0
- package/packages/omo-codex/plugin/components/rules/bundled-rules/windows-git-bash.md +10 -0
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +54 -0
- package/packages/omo-codex/plugin/components/rules/package.json +62 -0
- package/packages/omo-codex/plugin/components/rules/scripts/bench-codex-rules.mjs +268 -0
- package/packages/omo-codex/plugin/components/rules/skills/rules/SKILL.md +34 -0
- package/packages/omo-codex/plugin/components/rules/src/cli.ts +143 -0
- package/packages/omo-codex/plugin/components/rules/src/codex-hook-options.ts +4 -0
- package/packages/omo-codex/plugin/components/rules/src/codex-hook.ts +238 -0
- package/packages/omo-codex/plugin/components/rules/src/config.ts +107 -0
- package/packages/omo-codex/plugin/components/rules/src/context-pressure.ts +26 -0
- package/packages/omo-codex/plugin/components/rules/src/debug-log.ts +65 -0
- package/packages/omo-codex/plugin/components/rules/src/dynamic-target-fingerprints.ts +98 -0
- package/packages/omo-codex/plugin/components/rules/src/hook-output.ts +19 -0
- package/packages/omo-codex/plugin/components/rules/src/path-utils.ts +29 -0
- package/packages/omo-codex/plugin/components/rules/src/persistent-cache.ts +234 -0
- package/packages/omo-codex/plugin/components/rules/src/post-compact-budget.ts +104 -0
- package/packages/omo-codex/plugin/components/rules/src/post-compact-claim.ts +13 -0
- package/packages/omo-codex/plugin/components/rules/src/post-compact-state.ts +45 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/cache.ts +64 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/constants.ts +115 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/engine.ts +535 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/errors.ts +13 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/finder-cache.ts +73 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/finder-paths.ts +47 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/finder-sources.ts +50 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/finder.ts +207 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/formatter.ts +123 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/matcher.ts +142 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/ordering.ts +33 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/parser.ts +326 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/plugin-root.ts +55 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/project-root.ts +30 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/scanner.ts +162 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/truncator.ts +67 -0
- package/packages/omo-codex/plugin/components/rules/src/rules/types.ts +141 -0
- package/packages/omo-codex/plugin/components/rules/src/rules-engine-factory.ts +24 -0
- package/packages/omo-codex/plugin/components/rules/src/session-state-lock.ts +47 -0
- package/packages/omo-codex/plugin/components/rules/src/static-injection.ts +56 -0
- package/packages/omo-codex/plugin/components/rules/src/tool-paths.ts +192 -0
- package/packages/omo-codex/plugin/components/rules/src/transcript-rule-filter.ts +44 -0
- package/packages/omo-codex/plugin/components/rules/src/transcript-search.ts +108 -0
- package/packages/omo-codex/plugin/components/rules/test/bundled-rules-priority.test.ts +107 -0
- package/packages/omo-codex/plugin/components/rules/test/bundled-rules.test.ts +268 -0
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-context-pressure.test.ts +243 -0
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-performance.test.ts +99 -0
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-budget.test.ts +132 -0
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-context.test.ts +156 -0
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-dedup.test.ts +299 -0
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-lock.test.ts +46 -0
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-process.test.ts +83 -0
- package/packages/omo-codex/plugin/components/rules/test/codex-hook.test.ts +667 -0
- package/packages/omo-codex/plugin/components/rules/test/engine.test.ts +192 -0
- package/packages/omo-codex/plugin/components/rules/test/finder.test.ts +102 -0
- package/packages/omo-codex/plugin/components/rules/test/formatter.test.ts +168 -0
- package/packages/omo-codex/plugin/components/rules/test/hook-output.test.ts +42 -0
- package/packages/omo-codex/plugin/components/rules/test/matcher.test.ts +206 -0
- package/packages/omo-codex/plugin/components/rules/test/package-smoke.test.ts +153 -0
- package/packages/omo-codex/plugin/components/rules/test/persistent-cache.test.ts +63 -0
- package/packages/omo-codex/plugin/components/rules/test/post-compact-budget.test.ts +172 -0
- package/packages/omo-codex/plugin/components/rules/test/post-compact-test-fixture.ts +196 -0
- package/packages/omo-codex/plugin/components/rules/test/scanner.test.ts +63 -0
- package/packages/omo-codex/plugin/components/rules/test/tool-paths.test.ts +198 -0
- package/packages/omo-codex/plugin/components/rules/test/windows-git-bash-bundled-rule.test.ts +97 -0
- package/packages/omo-codex/plugin/components/rules/tsconfig.build.json +12 -0
- package/packages/omo-codex/plugin/components/rules/tsconfig.json +27 -0
- package/packages/omo-codex/plugin/components/rules/vitest.config.ts +8 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/.gitattributes +13 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/AGENTS.md +43 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/CHANGELOG.md +5 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/LICENSE +21 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/NOTICE +5 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/README.md +55 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/biome.json +48 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/directive.md +52 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/hooks/hooks.json +28 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/package.json +53 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/src/boulder-reader.ts +167 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/src/cli.ts +52 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/src/codex-hook.ts +66 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/src/directive.ts +6 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/src/index.ts +5 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/src/types.ts +23 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/test/boulder-reader.test.ts +63 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/test/cli.test.ts +124 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/test/codex-hook.test.ts +182 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/test/fixtures/boulder-completed.json +19 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/test/fixtures/boulder-mixed-platforms.json +27 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/test/fixtures/boulder-single-codex-work.json +19 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/test/fixtures/plan-all-done.md +5 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/test/fixtures/plan-with-nested-checkboxes.md +11 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/test/fixtures/plan-with-unchecked.md +6 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/tsconfig.build.json +12 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/tsconfig.json +27 -0
- package/packages/omo-codex/plugin/components/start-work-continuation/vitest.config.ts +10 -0
- package/packages/omo-codex/plugin/components/telemetry/AGENTS.md +37 -0
- package/packages/omo-codex/plugin/components/telemetry/README.md +102 -0
- package/packages/omo-codex/plugin/components/telemetry/biome.json +48 -0
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +16 -0
- package/packages/omo-codex/plugin/components/telemetry/package.json +56 -0
- package/packages/omo-codex/plugin/components/telemetry/src/atomic-write.ts +22 -0
- package/packages/omo-codex/plugin/components/telemetry/src/cli.ts +69 -0
- package/packages/omo-codex/plugin/components/telemetry/src/codex-hook.ts +49 -0
- package/packages/omo-codex/plugin/components/telemetry/src/data-path.ts +45 -0
- package/packages/omo-codex/plugin/components/telemetry/src/env-flags.ts +43 -0
- package/packages/omo-codex/plugin/components/telemetry/src/posthog-activity-state.ts +81 -0
- package/packages/omo-codex/plugin/components/telemetry/src/posthog.ts +165 -0
- package/packages/omo-codex/plugin/components/telemetry/src/product-identity.ts +35 -0
- package/packages/omo-codex/plugin/components/telemetry/test/codex-hook.test.ts +270 -0
- package/packages/omo-codex/plugin/components/telemetry/tsconfig.build.json +12 -0
- package/packages/omo-codex/plugin/components/telemetry/tsconfig.json +27 -0
- package/packages/omo-codex/plugin/components/telemetry/vitest.config.ts +8 -0
- package/packages/omo-codex/plugin/components/ultrawork/AGENTS.md +41 -0
- package/packages/omo-codex/plugin/components/ultrawork/CHANGELOG.md +25 -0
- package/packages/omo-codex/plugin/components/ultrawork/LICENSE +21 -0
- package/packages/omo-codex/plugin/components/ultrawork/NOTICE +5 -0
- package/packages/omo-codex/plugin/components/ultrawork/README.md +60 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/codex-ultrawork-reviewer.toml +18 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/explorer.toml +82 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/librarian.toml +222 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/metis.toml +65 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/momus.toml +69 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/plan.toml +164 -0
- package/packages/omo-codex/plugin/components/ultrawork/biome.json +48 -0
- package/packages/omo-codex/plugin/components/ultrawork/directive.md +290 -0
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +16 -0
- package/packages/omo-codex/plugin/components/ultrawork/package.json +54 -0
- package/packages/omo-codex/plugin/components/ultrawork/src/cli.ts +50 -0
- package/packages/omo-codex/plugin/components/ultrawork/src/codex-hook.ts +84 -0
- package/packages/omo-codex/plugin/components/ultrawork/src/directive.ts +3 -0
- package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook.test.ts +275 -0
- package/packages/omo-codex/plugin/components/ultrawork/test/package-smoke.test.ts +103 -0
- package/packages/omo-codex/plugin/components/ultrawork/tsconfig.build.json +12 -0
- package/packages/omo-codex/plugin/components/ultrawork/tsconfig.json +27 -0
- package/packages/omo-codex/plugin/components/ulw-loop/.gitattributes +13 -0
- package/packages/omo-codex/plugin/components/ulw-loop/AGENTS.md +48 -0
- package/packages/omo-codex/plugin/components/ulw-loop/CHANGELOG.md +7 -0
- package/packages/omo-codex/plugin/components/ulw-loop/LICENSE +21 -0
- package/packages/omo-codex/plugin/components/ulw-loop/NOTICE +6 -0
- package/packages/omo-codex/plugin/components/ulw-loop/README.md +74 -0
- package/packages/omo-codex/plugin/components/ulw-loop/biome.json +48 -0
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +29 -0
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +55 -0
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/.gitkeep +0 -0
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +44 -0
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/agents/openai.yaml +6 -0
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +230 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/.gitkeep +0 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint.ts +155 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-arg-parser.ts +95 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-commands.ts +156 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-output.ts +63 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-steering.ts +94 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli.ts +40 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-instruction.ts +129 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-snapshot.ts +139 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/codex-hook.ts +177 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/evidence.ts +122 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/goal-status.ts +88 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/paths.ts +73 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-crud.ts +113 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-io.ts +124 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate.ts +102 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/review-blockers.ts +81 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/steering.ts +270 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/types.ts +277 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint.test.ts +213 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-commands.test.ts +375 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-helpers.test.ts +250 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-steering.test.ts +407 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/codex-goal-instruction.test.ts +169 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/codex-goal-snapshot.test.ts +156 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/codex-hook.test.ts +275 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/evidence-criteria-gate.test.ts +100 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/evidence.test.ts +263 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/.gitkeep +0 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/codex-goal-snapshot.json +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/sample-brief.md +5 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/sample-plan.json +108 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/sample-quality-gate.json +18 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/steering-proposal.json +8 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/user-prompt-submit.json +10 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/goal-status.test.ts +327 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/package-smoke.test.ts +261 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/paths.test.ts +62 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/plan-crud.test.ts +256 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/plan-io.test.ts +239 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate.test.ts +203 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/review-blockers.test.ts +180 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/steering.test.ts +353 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/types.test.ts +79 -0
- package/packages/omo-codex/plugin/components/ulw-loop/tsconfig.build.json +12 -0
- package/packages/omo-codex/plugin/components/ulw-loop/tsconfig.json +27 -0
- package/packages/omo-codex/plugin/components/ulw-loop/vitest.config.ts +10 -0
- package/packages/omo-codex/plugin/hooks/hooks.json +160 -0
- package/packages/omo-codex/plugin/package-lock.json +1769 -0
- package/packages/omo-codex/plugin/package.json +28 -0
- package/packages/omo-codex/plugin/scripts/build-bundled-mcp-runtimes.mjs +65 -0
- package/packages/omo-codex/plugin/scripts/build-components.mjs +24 -0
- package/packages/omo-codex/plugin/scripts/hook-status-message.mjs +46 -0
- package/packages/omo-codex/plugin/scripts/sync-hook-status-messages.mjs +87 -0
- package/packages/omo-codex/plugin/scripts/sync-skills.mjs +75 -0
- package/packages/omo-codex/plugin/skills/comment-checker/SKILL.md +16 -0
- package/packages/omo-codex/plugin/skills/debugging/SKILL.md +116 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/00-setup.md +108 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/02-investigate.md +130 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/04-oracle-triple.md +136 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/05-escalate.md +69 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/06-fix.md +116 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/08-qa.md +94 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/09-cleanup.md +164 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/partial-runtime-evidence.md +229 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/bundled-js-binary.md +415 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/go.md +252 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/native-binary.md +484 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/node.md +260 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/python.md +248 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/rust.md +234 -0
- package/packages/omo-codex/plugin/skills/debugging/references/tools/ghidra.md +212 -0
- package/packages/omo-codex/plugin/skills/debugging/references/tools/playwright-cli.md +194 -0
- package/packages/omo-codex/plugin/skills/debugging/references/tools/pwndbg.md +263 -0
- package/packages/omo-codex/plugin/skills/debugging/references/tools/pwntools.md +265 -0
- package/packages/omo-codex/plugin/skills/frontend-ui-ux/SKILL.md +77 -0
- package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +325 -0
- package/packages/omo-codex/plugin/skills/lsp/SKILL.md +35 -0
- package/packages/omo-codex/plugin/skills/programming/SKILL.md +463 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/README.md +90 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/backend-stack.md +641 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/bootstrap.md +328 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/bubbletea-v2.md +360 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/cobra-stack.md +468 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/concurrency.md +362 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/data-modeling.md +329 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/error-handling.md +359 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/golangci-strict.md +236 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/grpc-connect.md +375 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/libraries.md +337 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/one-liners.md +202 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/sqlc-pgx.md +471 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/testing.md +467 -0
- package/packages/omo-codex/plugin/skills/programming/references/go/type-patterns.md +298 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/README.md +314 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/async-anyio.md +442 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/data-modeling.md +233 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/data-processing.md +133 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/error-handling.md +218 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/fastapi-stack.md +316 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/httpx2-optimization.md +360 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/libraries.md +307 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/one-liners.md +268 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/orjson-stack.md +378 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/pydantic-ai.md +285 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/pyproject-strict.md +232 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/textual-tui.md +201 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/type-patterns.md +176 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/README.md +317 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/async-tokio.md +299 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/axum-stack.md +467 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/cargo-strict.md +317 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/clap-stack.md +409 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/concurrency.md +375 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/libraries.md +439 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/one-liners.md +291 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/proptest-insta.md +429 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/type-state.md +354 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/unsafe-discipline.md +250 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/zero-cost-safety.md +527 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust-ub/README.md +289 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust-ub/miri-sanitizers-loom.md +411 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust-ub/ub-taxonomy.md +269 -0
- package/packages/omo-codex/plugin/skills/programming/references/typescript/README.md +195 -0
- package/packages/omo-codex/plugin/skills/programming/references/typescript/backend-hono.md +672 -0
- package/packages/omo-codex/plugin/skills/programming/references/typescript/bootstrap.md +199 -0
- package/packages/omo-codex/plugin/skills/programming/references/typescript/data-modeling.md +202 -0
- package/packages/omo-codex/plugin/skills/programming/references/typescript/error-handling.md +169 -0
- package/packages/omo-codex/plugin/skills/programming/references/typescript/tsconfig-strict.md +152 -0
- package/packages/omo-codex/plugin/skills/programming/references/typescript/type-patterns.md +196 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/check-no-excuse-rules.sh +173 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/new-project.py +138 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/templates/.editorconfig +13 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/templates/.golangci.yml +95 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/templates/AGENTS.md.tmpl +24 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/templates/README.md.tmpl +12 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/templates/Taskfile.yml +40 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/templates/ci.yml +37 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/templates/config.go +24 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/templates/gitignore +15 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/templates/main.go.tmpl +22 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/go/templates/run.go +15 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/python/check-no-excuse-rules.py +687 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/python/new-project.py +172 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/python/new-script.py +116 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/rust/check-no-excuse-rules.py +296 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/rust/check-no-excuse-rules.sh +158 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/rust/new-project.py +175 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/check-no-excuse-rules.ts +282 -0
- package/packages/omo-codex/plugin/skills/programming/scripts/typescript/new-project.ts +177 -0
- package/packages/omo-codex/plugin/skills/refactor/SKILL.md +779 -0
- package/packages/omo-codex/plugin/skills/remove-ai-slops/SKILL.md +333 -0
- package/packages/omo-codex/plugin/skills/review-work/SKILL.md +574 -0
- package/packages/omo-codex/plugin/skills/rules/SKILL.md +34 -0
- package/packages/omo-codex/plugin/skills/start-work/SKILL.md +149 -0
- package/packages/omo-codex/plugin/skills/ulw-loop/.gitkeep +0 -0
- package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +44 -0
- package/packages/omo-codex/plugin/skills/ulw-loop/agents/openai.yaml +6 -0
- package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +230 -0
- package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +399 -0
- package/packages/omo-codex/plugin/test/aggregate.test.mjs +345 -0
- package/packages/omo-codex/plugin/test/component-bin-names.test.mjs +66 -0
- package/packages/omo-codex/plugin/test/hook-status-message.test.mjs +195 -0
- package/packages/omo-codex/plugin/test/install-time-build-runtime.test.mjs +34 -0
- package/packages/omo-codex/plugin/test/mcp-research-servers.test.mjs +21 -0
- package/packages/omo-codex/plugin/test/node-install-surface.test.mjs +48 -0
- package/packages/omo-codex/plugin/test/subagent-guidance.test.mjs +76 -0
- package/packages/omo-codex/plugin/test/sync-hook-status-messages.test.mjs +66 -0
- package/packages/omo-codex/plugin/test/sync-skills.test.mjs +229 -0
- package/packages/omo-codex/scripts/install/agents.mjs +84 -0
- package/packages/omo-codex/scripts/install/cache.mjs +247 -0
- package/packages/omo-codex/scripts/install/cli-args.mjs +112 -0
- package/packages/omo-codex/scripts/install/command-shim.mjs +1 -0
- package/packages/omo-codex/scripts/install/config.mjs +264 -0
- package/packages/omo-codex/scripts/install/delegated-command.mjs +25 -0
- package/packages/omo-codex/scripts/install/git-bash.mjs +99 -0
- package/packages/omo-codex/scripts/install/git-bash.test.mjs +174 -0
- package/packages/omo-codex/scripts/install/hook-trust.mjs +84 -0
- package/packages/omo-codex/scripts/install/legacy-bins.mjs +57 -0
- package/packages/omo-codex/scripts/install/marketplace.mjs +104 -0
- package/packages/omo-codex/scripts/install/mcp-runtime-cache.mjs +81 -0
- package/packages/omo-codex/scripts/install/multi-agent-v2-config.mjs +38 -0
- package/packages/omo-codex/scripts/install/permissions.d.mts +1 -0
- package/packages/omo-codex/scripts/install/permissions.mjs +26 -0
- package/packages/omo-codex/scripts/install/process.mjs +19 -0
- package/packages/omo-codex/scripts/install/project-local-cleanup.mjs +229 -0
- package/packages/omo-codex/scripts/install/reasoning-config.mjs +14 -0
- package/packages/omo-codex/scripts/install/snapshot.mjs +54 -0
- package/packages/omo-codex/scripts/install/source-package-build.mjs +20 -0
- package/packages/omo-codex/scripts/install/toml-editor.mjs +64 -0
- package/packages/omo-codex/scripts/install/utils.mjs +15 -0
- package/packages/omo-codex/scripts/install-agent-links.test.mjs +104 -0
- package/packages/omo-codex/scripts/install-bin-links.test.mjs +123 -0
- package/packages/omo-codex/scripts/install-cache-copy.test.mjs +30 -0
- package/packages/omo-codex/scripts/install-cli-args.test.mjs +146 -0
- package/packages/omo-codex/scripts/install-config-autonomous.test.mjs +48 -0
- package/packages/omo-codex/scripts/install-config-reasoning.test.mjs +62 -0
- package/packages/omo-codex/scripts/install-config.test.mjs +324 -0
- package/packages/omo-codex/scripts/install-local-entrypoint.test.mjs +129 -0
- package/packages/omo-codex/scripts/install-local-git-bash-preflight.test.mjs +145 -0
- package/packages/omo-codex/scripts/install-local.mjs +275 -0
- package/packages/omo-codex/scripts/install-local.test.mjs +394 -0
- package/packages/omo-codex/scripts/install-mcp-runtime.test.mjs +233 -0
- package/packages/omo-codex/scripts/install-packaged-local.test.mjs +67 -0
- package/packages/omo-codex/scripts/install-project-local-cleanup.test.mjs +277 -0
- package/packages/omo-codex/scripts/install-test-fixtures.mjs +58 -0
- package/packages/omo-codex/scripts/sync-telemetry-component.mjs +115 -0
- package/packages/omo-codex/scripts/sync-telemetry-component.test.mjs +94 -0
- package/packages/shared-skills/index.mjs +5 -0
- package/packages/shared-skills/package.json +14 -0
- package/packages/shared-skills/skills/debugging/SKILL.md +116 -0
- package/packages/shared-skills/skills/debugging/references/methodology/00-setup.md +108 -0
- package/packages/shared-skills/skills/debugging/references/methodology/02-investigate.md +130 -0
- package/packages/shared-skills/skills/debugging/references/methodology/04-oracle-triple.md +136 -0
- package/packages/shared-skills/skills/debugging/references/methodology/05-escalate.md +69 -0
- package/packages/shared-skills/skills/debugging/references/methodology/06-fix.md +116 -0
- package/packages/shared-skills/skills/debugging/references/methodology/08-qa.md +94 -0
- package/packages/shared-skills/skills/debugging/references/methodology/09-cleanup.md +164 -0
- package/packages/shared-skills/skills/debugging/references/methodology/partial-runtime-evidence.md +229 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/bundled-js-binary.md +415 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/go.md +252 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/native-binary.md +484 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/node.md +260 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/python.md +248 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/rust.md +234 -0
- package/packages/shared-skills/skills/debugging/references/tools/ghidra.md +212 -0
- package/packages/shared-skills/skills/debugging/references/tools/playwright-cli.md +194 -0
- package/packages/shared-skills/skills/debugging/references/tools/pwndbg.md +263 -0
- package/packages/shared-skills/skills/debugging/references/tools/pwntools.md +265 -0
- package/packages/shared-skills/skills/frontend-ui-ux/SKILL.md +77 -0
- package/packages/shared-skills/skills/init-deep/SKILL.md +309 -0
- package/packages/shared-skills/skills/programming/SKILL.md +463 -0
- package/packages/shared-skills/skills/programming/references/go/README.md +90 -0
- package/packages/shared-skills/skills/programming/references/go/backend-stack.md +641 -0
- package/packages/shared-skills/skills/programming/references/go/bootstrap.md +328 -0
- package/packages/shared-skills/skills/programming/references/go/bubbletea-v2.md +360 -0
- package/packages/shared-skills/skills/programming/references/go/cobra-stack.md +468 -0
- package/packages/shared-skills/skills/programming/references/go/concurrency.md +362 -0
- package/packages/shared-skills/skills/programming/references/go/data-modeling.md +329 -0
- package/packages/shared-skills/skills/programming/references/go/error-handling.md +359 -0
- package/packages/shared-skills/skills/programming/references/go/golangci-strict.md +236 -0
- package/packages/shared-skills/skills/programming/references/go/grpc-connect.md +375 -0
- package/packages/shared-skills/skills/programming/references/go/libraries.md +337 -0
- package/packages/shared-skills/skills/programming/references/go/one-liners.md +202 -0
- package/packages/shared-skills/skills/programming/references/go/sqlc-pgx.md +471 -0
- package/packages/shared-skills/skills/programming/references/go/testing.md +467 -0
- package/packages/shared-skills/skills/programming/references/go/type-patterns.md +298 -0
- package/packages/shared-skills/skills/programming/references/python/README.md +314 -0
- package/packages/shared-skills/skills/programming/references/python/async-anyio.md +442 -0
- package/packages/shared-skills/skills/programming/references/python/data-modeling.md +233 -0
- package/packages/shared-skills/skills/programming/references/python/data-processing.md +133 -0
- package/packages/shared-skills/skills/programming/references/python/error-handling.md +218 -0
- package/packages/shared-skills/skills/programming/references/python/fastapi-stack.md +316 -0
- package/packages/shared-skills/skills/programming/references/python/httpx2-optimization.md +360 -0
- package/packages/shared-skills/skills/programming/references/python/libraries.md +307 -0
- package/packages/shared-skills/skills/programming/references/python/one-liners.md +268 -0
- package/packages/shared-skills/skills/programming/references/python/orjson-stack.md +378 -0
- package/packages/shared-skills/skills/programming/references/python/pydantic-ai.md +285 -0
- package/packages/shared-skills/skills/programming/references/python/pyproject-strict.md +232 -0
- package/packages/shared-skills/skills/programming/references/python/textual-tui.md +201 -0
- package/packages/shared-skills/skills/programming/references/python/type-patterns.md +176 -0
- package/packages/shared-skills/skills/programming/references/rust/README.md +317 -0
- package/packages/shared-skills/skills/programming/references/rust/async-tokio.md +299 -0
- package/packages/shared-skills/skills/programming/references/rust/axum-stack.md +467 -0
- package/packages/shared-skills/skills/programming/references/rust/cargo-strict.md +317 -0
- package/packages/shared-skills/skills/programming/references/rust/clap-stack.md +409 -0
- package/packages/shared-skills/skills/programming/references/rust/concurrency.md +375 -0
- package/packages/shared-skills/skills/programming/references/rust/libraries.md +439 -0
- package/packages/shared-skills/skills/programming/references/rust/one-liners.md +291 -0
- package/packages/shared-skills/skills/programming/references/rust/proptest-insta.md +429 -0
- package/packages/shared-skills/skills/programming/references/rust/type-state.md +354 -0
- package/packages/shared-skills/skills/programming/references/rust/unsafe-discipline.md +250 -0
- package/packages/shared-skills/skills/programming/references/rust/zero-cost-safety.md +527 -0
- package/packages/shared-skills/skills/programming/references/rust-ub/README.md +289 -0
- package/packages/shared-skills/skills/programming/references/rust-ub/miri-sanitizers-loom.md +411 -0
- package/packages/shared-skills/skills/programming/references/rust-ub/ub-taxonomy.md +269 -0
- package/packages/shared-skills/skills/programming/references/typescript/README.md +195 -0
- package/packages/shared-skills/skills/programming/references/typescript/backend-hono.md +672 -0
- package/packages/shared-skills/skills/programming/references/typescript/bootstrap.md +199 -0
- package/packages/shared-skills/skills/programming/references/typescript/data-modeling.md +202 -0
- package/packages/shared-skills/skills/programming/references/typescript/error-handling.md +169 -0
- package/packages/shared-skills/skills/programming/references/typescript/tsconfig-strict.md +152 -0
- package/packages/shared-skills/skills/programming/references/typescript/type-patterns.md +196 -0
- package/packages/shared-skills/skills/programming/scripts/go/check-no-excuse-rules.sh +173 -0
- package/packages/shared-skills/skills/programming/scripts/go/new-project.py +138 -0
- package/packages/shared-skills/skills/programming/scripts/go/templates/.editorconfig +13 -0
- package/packages/shared-skills/skills/programming/scripts/go/templates/.golangci.yml +95 -0
- package/packages/shared-skills/skills/programming/scripts/go/templates/AGENTS.md.tmpl +24 -0
- package/packages/shared-skills/skills/programming/scripts/go/templates/README.md.tmpl +12 -0
- package/packages/shared-skills/skills/programming/scripts/go/templates/Taskfile.yml +40 -0
- package/packages/shared-skills/skills/programming/scripts/go/templates/ci.yml +37 -0
- package/packages/shared-skills/skills/programming/scripts/go/templates/config.go +24 -0
- package/packages/shared-skills/skills/programming/scripts/go/templates/gitignore +15 -0
- package/packages/shared-skills/skills/programming/scripts/go/templates/main.go.tmpl +22 -0
- package/packages/shared-skills/skills/programming/scripts/go/templates/run.go +15 -0
- package/packages/shared-skills/skills/programming/scripts/python/check-no-excuse-rules.py +687 -0
- package/packages/shared-skills/skills/programming/scripts/python/new-project.py +172 -0
- package/packages/shared-skills/skills/programming/scripts/python/new-script.py +116 -0
- package/packages/shared-skills/skills/programming/scripts/rust/check-no-excuse-rules.py +296 -0
- package/packages/shared-skills/skills/programming/scripts/rust/check-no-excuse-rules.sh +158 -0
- package/packages/shared-skills/skills/programming/scripts/rust/new-project.py +175 -0
- package/packages/shared-skills/skills/programming/scripts/typescript/check-no-excuse-rules.ts +282 -0
- package/packages/shared-skills/skills/programming/scripts/typescript/new-project.ts +177 -0
- package/packages/shared-skills/skills/refactor/SKILL.md +763 -0
- package/packages/shared-skills/skills/remove-ai-slops/SKILL.md +317 -0
- package/packages/shared-skills/skills/review-work/SKILL.md +574 -0
- package/packages/shared-skills/skills/start-work/SKILL.md +149 -0
- package/packages/shared-skills/skills/ulw-plan/SKILL.md +383 -0
- package/postinstall.mjs +6 -2
- package/dist/features/builtin-commands/templates/init-deep.d.ts +0 -1
- package/dist/features/builtin-skills/skills/ai-slop-remover.d.ts +0 -2
- package/dist/hooks/context-window-monitor.d.ts +0 -19
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Data Processing — Polars + DuckDB
|
|
2
|
+
|
|
3
|
+
## The rule
|
|
4
|
+
|
|
5
|
+
NEVER pandas. Polars (with numpy) plus DuckDB. Pandas is 10-50x slower, has weaker types, and the modern Python data ecosystem has moved on.
|
|
6
|
+
|
|
7
|
+
## Quick decision tree
|
|
8
|
+
|
|
9
|
+
| Operation | Use | Why |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| `.csv` / `.parquet` / `.json` direct query | DuckDB | Zero memory load, SQL ergonomics |
|
|
12
|
+
| `.duckdb` file | DuckDB | Native format |
|
|
13
|
+
| Filter (any size) | Polars | 128x faster than DuckDB for filtering |
|
|
14
|
+
| Sort | Polars | 12x faster |
|
|
15
|
+
| Multi-table join | DuckDB | 3x faster, more join types |
|
|
16
|
+
| Heavy GROUP BY aggregation | DuckDB | 4x faster on large datasets |
|
|
17
|
+
| Window function | Polars | 3-5x faster |
|
|
18
|
+
| Pivot / melt / string ops | Polars | 2x faster |
|
|
19
|
+
| Larger than RAM | Polars streaming or DuckDB out-of-core | Both handle OOM |
|
|
20
|
+
| Mixed pipeline | Hybrid (zero-copy via Arrow) | Use each tool's strengths |
|
|
21
|
+
|
|
22
|
+
For the deep version (per-operation benchmarks, OOM strategies, full execution templates), load the **`data-scientist`** skill - it lives in this same skill set and is the source of truth for performance numbers.
|
|
23
|
+
|
|
24
|
+
## Standard imports
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import numpy as np
|
|
28
|
+
import polars as pl
|
|
29
|
+
import duckdb
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## DuckDB direct file query (zero memory load)
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
result = duckdb.sql("""
|
|
36
|
+
SELECT category, SUM(amount) AS total
|
|
37
|
+
FROM 'data.csv'
|
|
38
|
+
WHERE date >= '2026-01-01'
|
|
39
|
+
GROUP BY category
|
|
40
|
+
ORDER BY total DESC
|
|
41
|
+
""").pl() # zero-copy → Polars DataFrame
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`.pl()` returns Polars; `.df()` would return pandas - never use `.df()`.
|
|
45
|
+
|
|
46
|
+
## Polars lazy pipeline
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
result = (
|
|
50
|
+
pl.scan_csv("data.csv") # lazy, no read yet
|
|
51
|
+
.filter(pl.col("amount") > 1000)
|
|
52
|
+
.filter(pl.col("status") == "active")
|
|
53
|
+
.sort("amount", descending=True)
|
|
54
|
+
.head(100)
|
|
55
|
+
.collect() # execute optimised plan
|
|
56
|
+
)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`scan_*` over `read_*` for files; `lazy()` then `collect()` for in-memory frames. Polars optimises the entire plan before execution (predicate pushdown, projection pushdown, common subexpression elimination).
|
|
60
|
+
|
|
61
|
+
## Streaming for OOM data
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
result = (
|
|
65
|
+
pl.scan_csv("huge.csv")
|
|
66
|
+
.filter(pl.col("active"))
|
|
67
|
+
.group_by("category")
|
|
68
|
+
.agg([
|
|
69
|
+
pl.len().alias("count"),
|
|
70
|
+
pl.sum("amount").alias("total"),
|
|
71
|
+
])
|
|
72
|
+
.collect(streaming=True)
|
|
73
|
+
)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Hybrid pipeline (most realistic shape)
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
# Phase 1: DuckDB for the join (3x faster)
|
|
80
|
+
joined = duckdb.sql("""
|
|
81
|
+
SELECT o.*, c.region, p.category
|
|
82
|
+
FROM 'orders.parquet' o
|
|
83
|
+
JOIN 'customers.parquet' c ON o.customer_id = c.id
|
|
84
|
+
JOIN 'products.parquet' p ON o.product_id = p.id
|
|
85
|
+
""").pl()
|
|
86
|
+
|
|
87
|
+
# Phase 2: Polars for filtering and transformation (128x + 2x faster)
|
|
88
|
+
processed = (
|
|
89
|
+
joined
|
|
90
|
+
.filter(pl.col("amount") > 100)
|
|
91
|
+
.with_columns([
|
|
92
|
+
(pl.col("amount") * 1.1).alias("amount_with_tax"),
|
|
93
|
+
])
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Phase 3: DuckDB for final aggregation (4x faster) - register Polars frame by name
|
|
97
|
+
duckdb.register("processed", processed)
|
|
98
|
+
final = duckdb.sql("""
|
|
99
|
+
SELECT region, category, SUM(amount_with_tax) AS revenue
|
|
100
|
+
FROM processed
|
|
101
|
+
GROUP BY region, category
|
|
102
|
+
ORDER BY revenue DESC
|
|
103
|
+
""").pl()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Type safety with Polars
|
|
107
|
+
|
|
108
|
+
Polars supports schema overrides at read time, and `.cast()` for explicit conversion. Avoid implicit coercion in hot paths.
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
schema = {"id": pl.Int64, "amount": pl.Float64, "date": pl.Date}
|
|
112
|
+
df = pl.read_csv("data.csv", schema_overrides=schema)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
basedpyright understands `polars-stubs`, which ship with polars itself. No extra type stubs to install.
|
|
116
|
+
|
|
117
|
+
## Things you might miss from pandas (and how to do them in Polars)
|
|
118
|
+
|
|
119
|
+
| pandas | polars |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `df.iloc[5]` | `df.row(5)` (named tuple) or `df[5]` (single-row frame) |
|
|
122
|
+
| `df.loc[df["x"] > 5]` | `df.filter(pl.col("x") > 5)` |
|
|
123
|
+
| `df["x"].apply(fn)` | `df["x"].map_elements(fn)` (slow path) or use native expressions |
|
|
124
|
+
| `df.merge(...)` | `df.join(other, on="key")` |
|
|
125
|
+
| `df.groupby(...).agg(...)` | `df.group_by(...).agg(...)` |
|
|
126
|
+
| `pd.read_csv(...).dtypes` | `pl.read_csv(...).schema` |
|
|
127
|
+
| `df.to_dict("records")` | `df.to_dicts()` |
|
|
128
|
+
|
|
129
|
+
## Sources
|
|
130
|
+
|
|
131
|
+
- Polars docs: <https://docs.pola.rs>
|
|
132
|
+
- DuckDB Python API: <https://duckdb.org/docs/api/python/overview>
|
|
133
|
+
- Cross-reference - this skill set's `data-scientist` skill (load it for the deep version)
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Error Handling
|
|
2
|
+
|
|
3
|
+
Typed errors, exhaustive matching, union returns, and resource safety.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Typed errors — no bare strings
|
|
8
|
+
|
|
9
|
+
Error types carry structured data. Pattern matching works. Callers know exactly what can go wrong.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from typing import NewType
|
|
14
|
+
|
|
15
|
+
UserId = NewType("UserId", int)
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True, slots=True)
|
|
18
|
+
class UserNotFoundError(Exception):
|
|
19
|
+
user_id: UserId
|
|
20
|
+
|
|
21
|
+
def __str__(self) -> str: # REQUIRED — see note below
|
|
22
|
+
return f"user {self.user_id} not found"
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True, slots=True)
|
|
25
|
+
class PermissionDeniedError(Exception):
|
|
26
|
+
user_id: UserId
|
|
27
|
+
required_role: str
|
|
28
|
+
|
|
29
|
+
def __str__(self) -> str:
|
|
30
|
+
return f"user {self.user_id} needs role {self.required_role}"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**`__str__` is mandatory** on dataclass exceptions. `@dataclass` replaces `Exception.__init__`, so `self.args` is always `()`. Without `__str__`, `str(e)` returns an empty string and logging/monitoring breaks.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
# BAD
|
|
37
|
+
raise ValueError("user not found")
|
|
38
|
+
raise ValueError("permission denied")
|
|
39
|
+
|
|
40
|
+
# GOOD
|
|
41
|
+
raise UserNotFoundError(user_id=uid)
|
|
42
|
+
raise PermissionDeniedError(user_id=uid, required_role="admin")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Union returns — expected failures without exceptions
|
|
48
|
+
|
|
49
|
+
For failures that are **expected** (not found, validation error, permission denied), return a union instead of raising. Exceptions are for **unexpected** failures (network down, OOM, corrupted data).
|
|
50
|
+
|
|
51
|
+
### Define the outcome types
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
@dataclass(frozen=True, slots=True)
|
|
55
|
+
class User:
|
|
56
|
+
id: UserId
|
|
57
|
+
name: str
|
|
58
|
+
|
|
59
|
+
@dataclass(frozen=True, slots=True)
|
|
60
|
+
class UserNotFound:
|
|
61
|
+
id: UserId
|
|
62
|
+
|
|
63
|
+
@dataclass(frozen=True, slots=True)
|
|
64
|
+
class PermissionDenied:
|
|
65
|
+
id: UserId
|
|
66
|
+
reason: str
|
|
67
|
+
|
|
68
|
+
type GetUserResult = User | UserNotFound | PermissionDenied
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Handle exhaustively
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from typing import assert_never
|
|
75
|
+
|
|
76
|
+
def handle_result(result: GetUserResult) -> str:
|
|
77
|
+
match result:
|
|
78
|
+
case User(name=name):
|
|
79
|
+
return f"Found: {name}"
|
|
80
|
+
case UserNotFound(id=uid):
|
|
81
|
+
return f"No user with id {uid}"
|
|
82
|
+
case PermissionDenied(reason=reason):
|
|
83
|
+
return f"Denied: {reason}"
|
|
84
|
+
case _ as unreachable:
|
|
85
|
+
assert_never(unreachable)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`assert_never` in the default case: if you add a new variant to `GetUserResult` without handling it here, the type checker errors. No silent fall-through.
|
|
89
|
+
|
|
90
|
+
### When to use which
|
|
91
|
+
|
|
92
|
+
**The heuristic**: caller is 1-2 levels away and MUST handle it → union return. Error should propagate up many layers to a boundary → exception.
|
|
93
|
+
|
|
94
|
+
| Scenario | Pattern | Why |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| Repository → service (caller handles it) | Union return (`User \| UserNotFound`) | Caller is right there, must handle both |
|
|
97
|
+
| Validation at boundary (parsing input) | Exception (typed, with fields) | Propagates up to HTTP/CLI handler |
|
|
98
|
+
| Infrastructure failure (network, OOM) | Exception | Can't handle locally, must propagate |
|
|
99
|
+
| Service → service (deep internal) | Exception (typed) | Union boilerplate across many layers is worse than exceptions |
|
|
100
|
+
| HTTP handler → response | Catch exceptions, convert to response | Boundary code catches and translates |
|
|
101
|
+
|
|
102
|
+
**Practical tradeoff**: union returns are safest (type checker forces handling) but create boilerplate when every caller in a chain must `match`. If the error would just propagate through 3+ layers unchanged, use a typed exception instead.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Exhaustive match — every match needs a default
|
|
107
|
+
|
|
108
|
+
Every `match` statement ends with `case _: assert_never(x)`. No exceptions.
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from enum import StrEnum
|
|
112
|
+
from typing import assert_never
|
|
113
|
+
|
|
114
|
+
class Status(StrEnum):
|
|
115
|
+
PENDING = "pending"
|
|
116
|
+
ACTIVE = "active"
|
|
117
|
+
DELETED = "deleted"
|
|
118
|
+
|
|
119
|
+
def describe(status: Status) -> str:
|
|
120
|
+
match status:
|
|
121
|
+
case Status.PENDING:
|
|
122
|
+
return "waiting"
|
|
123
|
+
case Status.ACTIVE:
|
|
124
|
+
return "live"
|
|
125
|
+
case Status.DELETED:
|
|
126
|
+
return "gone"
|
|
127
|
+
case _ as unreachable:
|
|
128
|
+
assert_never(unreachable)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Add a new enum member? The type checker tells you every `match` that needs updating.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Context managers — resource safety
|
|
136
|
+
|
|
137
|
+
If it has `.close()`, `.shutdown()`, `.disconnect()`, or `.release()`, wrap it in `with`.
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
# BAD
|
|
141
|
+
f = open("data.txt")
|
|
142
|
+
data = f.read()
|
|
143
|
+
f.close() # forgotten? leaked
|
|
144
|
+
|
|
145
|
+
# GOOD
|
|
146
|
+
from pathlib import Path
|
|
147
|
+
|
|
148
|
+
data = Path("data.txt").read_text()
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Async resources
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
import httpx
|
|
155
|
+
|
|
156
|
+
async def fetch_users() -> list[User]:
|
|
157
|
+
async with httpx.AsyncClient() as client:
|
|
158
|
+
response = await client.get("https://api.example.com/users")
|
|
159
|
+
response.raise_for_status()
|
|
160
|
+
return [User(**u) for u in response.json()]
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Custom context manager
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
from contextlib import asynccontextmanager
|
|
167
|
+
from collections.abc import AsyncIterator
|
|
168
|
+
|
|
169
|
+
@asynccontextmanager
|
|
170
|
+
async def managed_connection(url: str) -> AsyncIterator[Connection]:
|
|
171
|
+
conn = await connect(url)
|
|
172
|
+
try:
|
|
173
|
+
yield conn
|
|
174
|
+
finally:
|
|
175
|
+
await conn.close()
|
|
176
|
+
|
|
177
|
+
async with managed_connection("postgres://...") as conn:
|
|
178
|
+
await conn.execute("SELECT 1")
|
|
179
|
+
# conn is closed here, guaranteed
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Exception hierarchy — when you do raise
|
|
185
|
+
|
|
186
|
+
Keep exception hierarchies shallow and specific.
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
class AppError(Exception):
|
|
190
|
+
"""Base for all application errors."""
|
|
191
|
+
|
|
192
|
+
@dataclass(frozen=True, slots=True)
|
|
193
|
+
class NotFoundError(AppError):
|
|
194
|
+
entity: str
|
|
195
|
+
id: int
|
|
196
|
+
|
|
197
|
+
def __str__(self) -> str:
|
|
198
|
+
return f"{self.entity} {self.id} not found"
|
|
199
|
+
|
|
200
|
+
@dataclass(frozen=True, slots=True)
|
|
201
|
+
class ConflictError(AppError):
|
|
202
|
+
entity: str
|
|
203
|
+
field: str
|
|
204
|
+
value: str
|
|
205
|
+
|
|
206
|
+
def __str__(self) -> str:
|
|
207
|
+
return f"{self.entity}.{self.field} = {self.value!r} already exists"
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Callers catch `AppError` at the boundary, or specific subtypes where they can do something useful.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Sources
|
|
215
|
+
|
|
216
|
+
- Python docs: [typing — assert_never](https://docs.python.org/3/library/typing.html#typing.assert_never)
|
|
217
|
+
- Python docs: [contextlib](https://docs.python.org/3/library/contextlib.html)
|
|
218
|
+
- Python docs: [match statement](https://docs.python.org/3/reference/compound_stmts.html#the-match-statement)
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# FastAPI + SQLAlchemy 2.x async + Postgres + Pydantic v2
|
|
2
|
+
|
|
3
|
+
The canonical web API stack. Async end-to-end, type-safe end-to-end, OpenAPI-generated end-to-end.
|
|
4
|
+
|
|
5
|
+
## Project layout
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
myapi/
|
|
9
|
+
├── pyproject.toml
|
|
10
|
+
├── alembic.ini
|
|
11
|
+
├── migrations/
|
|
12
|
+
│ └── env.py
|
|
13
|
+
├── src/
|
|
14
|
+
│ └── myapi/
|
|
15
|
+
│ ├── __init__.py
|
|
16
|
+
│ ├── main.py # FastAPI app + lifespan
|
|
17
|
+
│ ├── config.py # pydantic-settings
|
|
18
|
+
│ ├── db.py # engine, session factory, dependency
|
|
19
|
+
│ ├── models.py # SQLAlchemy declarative models
|
|
20
|
+
│ ├── schemas.py # Pydantic request/response models
|
|
21
|
+
│ └── routers/
|
|
22
|
+
│ ├── __init__.py
|
|
23
|
+
│ └── users.py
|
|
24
|
+
└── tests/
|
|
25
|
+
├── conftest.py
|
|
26
|
+
└── test_users.py
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Dependencies
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
uv add fastapi 'sqlalchemy[asyncio]>=2.0' asyncpg 'pydantic[email]>=2' pydantic-settings 'uvicorn[standard]' orjson
|
|
33
|
+
uv add --dev httpx pytest alembic
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`orjson` is mandatory: set `default_response_class=ORJSONResponse` on the FastAPI app. Pydantic-typed responses bypass it (Pydantic v2's `model_dump_json` is already Rust-backed); raw `dict` / `list` returns are accelerated. For SSE / NDJSON streams, call `orjson.dumps(...)` per chunk inside `StreamingResponse`. See `orjson-stack.md` for the decision tree, flag reference, and benchmarks.
|
|
37
|
+
|
|
38
|
+
## Configuration (`config.py`)
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from functools import lru_cache
|
|
42
|
+
|
|
43
|
+
from pydantic import Field, PostgresDsn
|
|
44
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Settings(BaseSettings):
|
|
48
|
+
model_config = SettingsConfigDict(env_file=".env", env_prefix="MYAPI_")
|
|
49
|
+
|
|
50
|
+
database_url: PostgresDsn
|
|
51
|
+
debug: bool = False
|
|
52
|
+
cors_origins: list[str] = Field(default_factory=list)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@lru_cache
|
|
56
|
+
def get_settings() -> Settings:
|
|
57
|
+
return Settings() # type: ignore[call-arg] # pydantic populates from env
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Wait — that comment violates the no-excuse rule. Use proper field defaults instead. Real version:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
class Settings(BaseSettings):
|
|
64
|
+
model_config = SettingsConfigDict(env_file=".env", env_prefix="MYAPI_")
|
|
65
|
+
database_url: PostgresDsn
|
|
66
|
+
debug: bool = False
|
|
67
|
+
cors_origins: list[str] = Field(default_factory=list)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Construct via `Settings(_env_file=".env")` if needed in tests; in production it reads from env.
|
|
71
|
+
|
|
72
|
+
## Database (`db.py`)
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from collections.abc import AsyncIterator
|
|
76
|
+
from typing import Annotated
|
|
77
|
+
|
|
78
|
+
from fastapi import Depends
|
|
79
|
+
from sqlalchemy.ext.asyncio import (
|
|
80
|
+
AsyncEngine,
|
|
81
|
+
AsyncSession,
|
|
82
|
+
async_sessionmaker,
|
|
83
|
+
create_async_engine,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
from myapi.config import get_settings
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def make_engine() -> AsyncEngine:
|
|
90
|
+
settings = get_settings()
|
|
91
|
+
return create_async_engine(
|
|
92
|
+
str(settings.database_url),
|
|
93
|
+
echo=settings.debug,
|
|
94
|
+
pool_pre_ping=True,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
_engine = make_engine()
|
|
99
|
+
_SessionFactory = async_sessionmaker(_engine, expire_on_commit=False)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
async def get_session() -> AsyncIterator[AsyncSession]:
|
|
103
|
+
async with _SessionFactory() as session:
|
|
104
|
+
yield session
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
SessionDep = Annotated[AsyncSession, Depends(get_session)]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`expire_on_commit=False` is essential for FastAPI - otherwise attribute access after commit triggers an implicit refresh and errors out under async.
|
|
111
|
+
|
|
112
|
+
## Models (`models.py`)
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from datetime import datetime, UTC
|
|
116
|
+
from sqlalchemy import DateTime, String, func
|
|
117
|
+
from sqlalchemy.orm import (
|
|
118
|
+
DeclarativeBase,
|
|
119
|
+
Mapped,
|
|
120
|
+
MappedAsDataclass,
|
|
121
|
+
mapped_column,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class Base(MappedAsDataclass, DeclarativeBase):
|
|
126
|
+
pass
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class User(Base):
|
|
130
|
+
__tablename__ = "users"
|
|
131
|
+
|
|
132
|
+
id: Mapped[int] = mapped_column(primary_key=True, init=False)
|
|
133
|
+
email: Mapped[str] = mapped_column(String(255), unique=True, index=True)
|
|
134
|
+
name: Mapped[str] = mapped_column(String(100))
|
|
135
|
+
created_at: Mapped[datetime] = mapped_column(
|
|
136
|
+
DateTime(timezone=True),
|
|
137
|
+
server_default=func.now(),
|
|
138
|
+
init=False,
|
|
139
|
+
)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`MappedAsDataclass` makes `User(email=..., name=...)` work as a real dataclass constructor. `init=False` excludes the auto-generated columns (`id`, `created_at`) from `__init__`.
|
|
143
|
+
|
|
144
|
+
## Schemas (`schemas.py`)
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from datetime import datetime
|
|
148
|
+
from pydantic import BaseModel, ConfigDict, EmailStr
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class UserCreate(BaseModel):
|
|
152
|
+
email: EmailStr
|
|
153
|
+
name: str
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class UserRead(BaseModel):
|
|
157
|
+
model_config = ConfigDict(from_attributes=True) # SQLAlchemy → Pydantic
|
|
158
|
+
|
|
159
|
+
id: int
|
|
160
|
+
email: EmailStr
|
|
161
|
+
name: str
|
|
162
|
+
created_at: datetime
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Always have a separate `*Create` (input) and `*Read` (output) model. Never expose your ORM model as the API model.
|
|
166
|
+
|
|
167
|
+
## Routers (`routers/users.py`)
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from fastapi import APIRouter, HTTPException, status
|
|
171
|
+
from sqlalchemy import select
|
|
172
|
+
|
|
173
|
+
from myapi.db import SessionDep
|
|
174
|
+
from myapi.models import User
|
|
175
|
+
from myapi.schemas import UserCreate, UserRead
|
|
176
|
+
|
|
177
|
+
router = APIRouter(prefix="/users", tags=["users"])
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@router.post("", response_model=UserRead, status_code=status.HTTP_201_CREATED)
|
|
181
|
+
async def create_user(payload: UserCreate, session: SessionDep) -> User:
|
|
182
|
+
user = User(email=payload.email, name=payload.name)
|
|
183
|
+
session.add(user)
|
|
184
|
+
await session.commit()
|
|
185
|
+
await session.refresh(user)
|
|
186
|
+
return user
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
@router.get("/{user_id}", response_model=UserRead)
|
|
190
|
+
async def get_user(user_id: int, session: SessionDep) -> User:
|
|
191
|
+
result = await session.execute(select(User).where(User.id == user_id))
|
|
192
|
+
user = result.scalar_one_or_none()
|
|
193
|
+
if user is None:
|
|
194
|
+
raise HTTPException(status.HTTP_404_NOT_FOUND, "User not found")
|
|
195
|
+
return user
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@router.get("", response_model=list[UserRead])
|
|
199
|
+
async def list_users(session: SessionDep, limit: int = 100) -> list[User]:
|
|
200
|
+
result = await session.execute(select(User).limit(limit))
|
|
201
|
+
return list(result.scalars().all())
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Application (`main.py`)
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
from contextlib import asynccontextmanager
|
|
208
|
+
from collections.abc import AsyncIterator
|
|
209
|
+
|
|
210
|
+
from fastapi import FastAPI
|
|
211
|
+
|
|
212
|
+
from myapi.config import get_settings
|
|
213
|
+
from myapi.routers import users
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@asynccontextmanager
|
|
217
|
+
async def lifespan(_: FastAPI) -> AsyncIterator[None]:
|
|
218
|
+
# Startup: warm up engine pool, run migrations check, etc.
|
|
219
|
+
yield
|
|
220
|
+
# Shutdown: close engine
|
|
221
|
+
from myapi.db import _engine
|
|
222
|
+
await _engine.dispose()
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def create_app() -> FastAPI:
|
|
226
|
+
settings = get_settings()
|
|
227
|
+
app = FastAPI(
|
|
228
|
+
title="My API",
|
|
229
|
+
debug=settings.debug,
|
|
230
|
+
lifespan=lifespan,
|
|
231
|
+
)
|
|
232
|
+
app.include_router(users.router)
|
|
233
|
+
return app
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
app = create_app()
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Run with:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
uv run uvicorn myapi.main:app --host 0.0.0.0 --port 8000 --reload
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Migrations (Alembic + async)
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
uv run alembic init -t async migrations
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
In `migrations/env.py` replace the `target_metadata` line:
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
from myapi.models import Base
|
|
255
|
+
target_metadata = Base.metadata
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Set `sqlalchemy.url` in `alembic.ini` to your async URL or override via `env.py`:
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
from myapi.config import get_settings
|
|
262
|
+
config.set_main_option("sqlalchemy.url", str(get_settings().database_url))
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Generate and apply:
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
uv run alembic revision --autogenerate -m "create users"
|
|
269
|
+
uv run alembic upgrade head
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Tests (`tests/test_users.py`)
|
|
273
|
+
|
|
274
|
+
```python
|
|
275
|
+
import pytest
|
|
276
|
+
from httpx import ASGITransport, AsyncClient
|
|
277
|
+
|
|
278
|
+
from myapi.main import app
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
@pytest.mark.anyio
|
|
282
|
+
async def test_create_and_get_user() -> None:
|
|
283
|
+
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
|
284
|
+
create_response = await client.post(
|
|
285
|
+
"/users",
|
|
286
|
+
json={"email": "alice@example.com", "name": "Alice"},
|
|
287
|
+
)
|
|
288
|
+
assert create_response.status_code == 201
|
|
289
|
+
user_id = create_response.json()["id"]
|
|
290
|
+
|
|
291
|
+
get_response = await client.get(f"/users/{user_id}")
|
|
292
|
+
assert get_response.status_code == 200
|
|
293
|
+
assert get_response.json()["email"] == "alice@example.com"
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
For database-backed tests, run a Postgres container in CI (`testcontainers-python` or `docker-compose`) and apply migrations against a test schema. SQLite-as-test-db breaks once you use Postgres-specific types (`JSONB`, `tsvector`, arrays).
|
|
297
|
+
|
|
298
|
+
## Common pitfalls
|
|
299
|
+
|
|
300
|
+
| Pitfall | Fix |
|
|
301
|
+
|---|---|
|
|
302
|
+
| `MissingGreenlet` exception when accessing relationships after commit | `expire_on_commit=False` on the session factory |
|
|
303
|
+
| Connection pool exhausted under load | Set `pool_size`, `max_overflow` in `create_async_engine` |
|
|
304
|
+
| Pydantic v1 syntax (`from pydantic import ...; class X(BaseModel): class Config: orm_mode = True`) | v2 uses `model_config = ConfigDict(from_attributes=True)` |
|
|
305
|
+
| Returning ORM objects without `response_model` | FastAPI serialises with `from_attributes=True` automatically; declare `response_model` so OpenAPI is correct |
|
|
306
|
+
| `await session.execute(...)` returning Sequence | Wrap with `list(result.scalars().all())` to satisfy strict types |
|
|
307
|
+
| `func.now()` returning naive datetime | Use `DateTime(timezone=True)` and `created_at: Mapped[datetime]` with `UTC`-aware default |
|
|
308
|
+
|
|
309
|
+
## Sources
|
|
310
|
+
|
|
311
|
+
- FastAPI: <https://fastapi.tiangolo.com>
|
|
312
|
+
- SQLAlchemy 2.x async: <https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html>
|
|
313
|
+
- SQLAlchemy MappedAsDataclass: <https://docs.sqlalchemy.org/en/20/orm/dataclasses.html>
|
|
314
|
+
- asyncpg: <https://magicstack.github.io/asyncpg/current/>
|
|
315
|
+
- Pydantic v2 migration: <https://docs.pydantic.dev/latest/migration/>
|
|
316
|
+
- Alembic async: <https://alembic.sqlalchemy.org/en/latest/cookbook.html#using-asyncio-with-alembic>
|