@alumbwe/anvil 1.0.20 → 1.0.22
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/package.json +74 -70
- package/src/agents/bundled-agents.generated.ts +4 -4
- package/src/chat.tsx +1703 -1698
- package/src/cli-args.ts +134 -134
- package/src/components/status-bar.tsx +331 -313
- package/src/hooks/helpers/send-message.ts +663 -654
- package/src/hooks/use-send-message.ts +806 -773
- package/src/index.tsx +473 -473
- package/src/state/chat-store.ts +553 -544
- package/src/utils/create-run-config.ts +121 -121
- package/src/utils/format-compact-number.ts +37 -0
- package/vendor/@anvil/common/package.json +27 -0
- package/vendor/@anvil/common/src/__tests__/agent-validation.test.ts +846 -0
- package/vendor/@anvil/common/src/__tests__/anvil-model-availability.test.ts +101 -0
- package/vendor/@anvil/common/src/__tests__/anvil-models.test.ts +1408 -0
- package/vendor/@anvil/common/src/__tests__/anvil-public-data-use-copy.test.ts +258 -0
- package/vendor/@anvil/common/src/__tests__/anvil-referral-tiers.test.ts +48 -0
- package/vendor/@anvil/common/src/__tests__/anvil-spend-ceilings.test.ts +282 -0
- package/vendor/@anvil/common/src/__tests__/anvil-trust.test.ts +526 -0
- package/vendor/@anvil/common/src/__tests__/deepseek-direct.test.ts +68 -0
- package/vendor/@anvil/common/src/__tests__/disposable-email.test.ts +132 -0
- package/vendor/@anvil/common/src/__tests__/dynamic-agent-template-schema.test.ts +422 -0
- package/vendor/@anvil/common/src/__tests__/env-ci.test.ts +167 -0
- package/vendor/@anvil/common/src/__tests__/env-process.test.ts +145 -0
- package/vendor/@anvil/common/src/__tests__/foreign-client-shipped-agents.test.ts +234 -0
- package/vendor/@anvil/common/src/__tests__/foreign-client-signals.test.ts +379 -0
- package/vendor/@anvil/common/src/__tests__/free-agents.test.ts +807 -0
- package/vendor/@anvil/common/src/__tests__/gravity-capi.test.ts +154 -0
- package/vendor/@anvil/common/src/__tests__/handlesteps-parsing.test.ts +246 -0
- package/vendor/@anvil/common/src/__tests__/kimi-k3-god-only.test.ts +77 -0
- package/vendor/@anvil/common/src/__tests__/model-config.test.ts +89 -0
- package/vendor/@anvil/common/src/__tests__/project-file-tree.test.ts +298 -0
- package/vendor/@anvil/common/src/__tests__/provisioned-model-tiers.test.ts +116 -0
- package/vendor/@anvil/common/src/__tests__/reasoning-effort.test.ts +167 -0
- package/vendor/@anvil/common/src/__tests__/reddit-capi.test.ts +132 -0
- package/vendor/@anvil/common/src/__tests__/response-ad-positions.test.ts +72 -0
- package/vendor/@anvil/common/src/__tests__/user-state.test.ts +30 -0
- package/vendor/@anvil/common/src/actions.ts +215 -0
- package/vendor/@anvil/common/src/analytics-core.ts +69 -0
- package/vendor/@anvil/common/src/analytics.ts +93 -0
- package/vendor/@anvil/common/src/api-keys/constants.ts +26 -0
- package/vendor/@anvil/common/src/browser-actions.ts +413 -0
- package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding-gate.test.ts +63 -0
- package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding.test.ts +246 -0
- package/vendor/@anvil/common/src/constants/__tests__/cf-worker-signals.test.ts +106 -0
- package/vendor/@anvil/common/src/constants/agents.ts +99 -0
- package/vendor/@anvil/common/src/constants/analytics-events.ts +435 -0
- package/vendor/@anvil/common/src/constants/anthropic.ts +73 -0
- package/vendor/@anvil/common/src/constants/anvil-data-use.ts +81 -0
- package/vendor/@anvil/common/src/constants/anvil-errors.ts +7 -0
- package/vendor/@anvil/common/src/constants/anvil-gemini-thinker.ts +21 -0
- package/vendor/@anvil/common/src/constants/anvil-model-ids.ts +11 -0
- package/vendor/@anvil/common/src/constants/anvil-models.ts +2130 -0
- package/vendor/@anvil/common/src/constants/anvil-onboarding-gate.ts +55 -0
- package/vendor/@anvil/common/src/constants/anvil-onboarding.ts +307 -0
- package/vendor/@anvil/common/src/constants/anvil-referral-tiers.ts +87 -0
- package/vendor/@anvil/common/src/constants/anvil-signup-block.ts +68 -0
- package/vendor/@anvil/common/src/constants/anvil-spend-ceilings.ts +450 -0
- package/vendor/@anvil/common/src/constants/anvil-trust.ts +976 -0
- package/vendor/@anvil/common/src/constants/auth.ts +18 -0
- package/vendor/@anvil/common/src/constants/byok.ts +2 -0
- package/vendor/@anvil/common/src/constants/cf-worker-signals.ts +132 -0
- package/vendor/@anvil/common/src/constants/composio.ts +34 -0
- package/vendor/@anvil/common/src/constants/deepseek-direct.ts +55 -0
- package/vendor/@anvil/common/src/constants/feedback.ts +13 -0
- package/vendor/@anvil/common/src/constants/foreign-client-signals.ts +272 -0
- package/vendor/@anvil/common/src/constants/free-agents.ts +777 -0
- package/vendor/@anvil/common/src/constants/gemini.ts +15 -0
- package/vendor/@anvil/common/src/constants/grant-priorities.ts +13 -0
- package/vendor/@anvil/common/src/constants/hosts.ts +6 -0
- package/vendor/@anvil/common/src/constants/images.ts +51 -0
- package/vendor/@anvil/common/src/constants/index.ts +7 -0
- package/vendor/@anvil/common/src/constants/knowledge.ts +35 -0
- package/vendor/@anvil/common/src/constants/limits.ts +23 -0
- package/vendor/@anvil/common/src/constants/model-config.ts +277 -0
- package/vendor/@anvil/common/src/constants/openrouter-attribution.ts +8 -0
- package/vendor/@anvil/common/src/constants/paths.ts +69 -0
- package/vendor/@anvil/common/src/constants/provider-routes.ts +317 -0
- package/vendor/@anvil/common/src/constants/reasoning-effort.ts +79 -0
- package/vendor/@anvil/common/src/constants/skills.ts +60 -0
- package/vendor/@anvil/common/src/constants/subscription-plans.ts +49 -0
- package/vendor/@anvil/common/src/constants/ui.ts +25 -0
- package/vendor/@anvil/common/src/env-ci.ts +36 -0
- package/vendor/@anvil/common/src/env-process.ts +95 -0
- package/vendor/@anvil/common/src/env-schema.ts +95 -0
- package/vendor/@anvil/common/src/env.ts +24 -0
- package/vendor/@anvil/common/src/gravity-capi.ts +207 -0
- package/vendor/@anvil/common/src/mcp/client.ts +233 -0
- package/vendor/@anvil/common/src/old-constants.ts +10 -0
- package/vendor/@anvil/common/src/project-file-tree.ts +355 -0
- package/vendor/@anvil/common/src/reddit-capi.ts +254 -0
- package/vendor/@anvil/common/src/schemas/feedback.ts +52 -0
- package/vendor/@anvil/common/src/schemas/logs.ts +66 -0
- package/vendor/@anvil/common/src/templates/agent-validation.ts +392 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/LICENSE +202 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/README.md +294 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/01-basic-diff-reviewer.ts +17 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/02-intermediate-git-committer.ts +78 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/03-advanced-file-explorer.ts +73 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/my-custom-agent.ts +40 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/package.json +6 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/skills/README.md +65 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/skills/example-skill/SKILL.md +29 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/types/agent-definition.ts +497 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/types/tools.ts +444 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/types/util-types.ts +178 -0
- package/vendor/@anvil/common/src/testing/TESTING_PATTERNS.md +351 -0
- package/vendor/@anvil/common/src/testing/anvil-offer-invariants.ts +169 -0
- package/vendor/@anvil/common/src/testing/errors.ts +33 -0
- package/vendor/@anvil/common/src/testing/fixtures/agent-runtime.ts +334 -0
- package/vendor/@anvil/common/src/testing/impl/agent-runtime.ts +6 -0
- package/vendor/@anvil/common/src/testing/index.ts +84 -0
- package/vendor/@anvil/common/src/testing/mock-modules.ts +53 -0
- package/vendor/@anvil/common/src/testing/mock-types.ts +123 -0
- package/vendor/@anvil/common/src/testing/mocks/analytics.ts +261 -0
- package/vendor/@anvil/common/src/testing/mocks/child-process.ts +93 -0
- package/vendor/@anvil/common/src/testing/mocks/crypto.ts +218 -0
- package/vendor/@anvil/common/src/testing/mocks/database.ts +337 -0
- package/vendor/@anvil/common/src/testing/mocks/fetch.ts +219 -0
- package/vendor/@anvil/common/src/testing/mocks/filesystem.ts +166 -0
- package/vendor/@anvil/common/src/testing/mocks/index.ts +101 -0
- package/vendor/@anvil/common/src/testing/mocks/logger.ts +135 -0
- package/vendor/@anvil/common/src/testing/mocks/stream.ts +313 -0
- package/vendor/@anvil/common/src/testing/mocks/timers.ts +132 -0
- package/vendor/@anvil/common/src/testing/mocks/tree-sitter.ts +127 -0
- package/vendor/@anvil/common/src/testing/setup.ts +282 -0
- package/vendor/@anvil/common/src/testing-env-ci.ts +15 -0
- package/vendor/@anvil/common/src/testing-env-process.ts +78 -0
- package/vendor/@anvil/common/src/tools/__tests__/compile-tool-definitions.test.ts +34 -0
- package/vendor/@anvil/common/src/tools/compile-tool-definitions.ts +157 -0
- package/vendor/@anvil/common/src/tools/constants.ts +117 -0
- package/vendor/@anvil/common/src/tools/list.ts +190 -0
- package/vendor/@anvil/common/src/tools/params/__tests__/coerce-to-array.test.ts +213 -0
- package/vendor/@anvil/common/src/tools/params/__tests__/read-docs.test.ts +47 -0
- package/vendor/@anvil/common/src/tools/params/__tests__/render-ui.test.ts +65 -0
- package/vendor/@anvil/common/src/tools/params/tool/__tests__/run-terminal-command-timeout.test.ts +49 -0
- package/vendor/@anvil/common/src/tools/params/tool/add-message.ts +39 -0
- package/vendor/@anvil/common/src/tools/params/tool/add-subgoal.ts +57 -0
- package/vendor/@anvil/common/src/tools/params/tool/apply-patch.ts +110 -0
- package/vendor/@anvil/common/src/tools/params/tool/ask-user.ts +181 -0
- package/vendor/@anvil/common/src/tools/params/tool/browser-logs.ts +85 -0
- package/vendor/@anvil/common/src/tools/params/tool/cloud-plan-ready.ts +94 -0
- package/vendor/@anvil/common/src/tools/params/tool/code-search.ts +159 -0
- package/vendor/@anvil/common/src/tools/params/tool/composio.ts +131 -0
- package/vendor/@anvil/common/src/tools/params/tool/create-plan.ts +80 -0
- package/vendor/@anvil/common/src/tools/params/tool/end-turn.ts +57 -0
- package/vendor/@anvil/common/src/tools/params/tool/find-files.ts +60 -0
- package/vendor/@anvil/common/src/tools/params/tool/glob.ts +80 -0
- package/vendor/@anvil/common/src/tools/params/tool/gravity-index.ts +93 -0
- package/vendor/@anvil/common/src/tools/params/tool/list-directory.ts +58 -0
- package/vendor/@anvil/common/src/tools/params/tool/lookup-agent-info.ts +37 -0
- package/vendor/@anvil/common/src/tools/params/tool/propose-str-replace.ts +103 -0
- package/vendor/@anvil/common/src/tools/params/tool/propose-write-file.ts +71 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-docs.ts +90 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-files.ts +109 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-subtree.ts +79 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-url.ts +81 -0
- package/vendor/@anvil/common/src/tools/params/tool/render-ui.ts +168 -0
- package/vendor/@anvil/common/src/tools/params/tool/run-file-change-hooks.ts +57 -0
- package/vendor/@anvil/common/src/tools/params/tool/run-terminal-command.ts +211 -0
- package/vendor/@anvil/common/src/tools/params/tool/screenshot.ts +97 -0
- package/vendor/@anvil/common/src/tools/params/tool/set-messages.ts +44 -0
- package/vendor/@anvil/common/src/tools/params/tool/set-output.ts +61 -0
- package/vendor/@anvil/common/src/tools/params/tool/skill.ts +59 -0
- package/vendor/@anvil/common/src/tools/params/tool/spawn-agent-inline.ts +56 -0
- package/vendor/@anvil/common/src/tools/params/tool/spawn-agents.ts +154 -0
- package/vendor/@anvil/common/src/tools/params/tool/str-replace.ts +107 -0
- package/vendor/@anvil/common/src/tools/params/tool/suggest-followups.ts +97 -0
- package/vendor/@anvil/common/src/tools/params/tool/task-completed.ts +61 -0
- package/vendor/@anvil/common/src/tools/params/tool/think-deeply.ts +56 -0
- package/vendor/@anvil/common/src/tools/params/tool/update-subgoal.ts +89 -0
- package/vendor/@anvil/common/src/tools/params/tool/vision-analyze.ts +82 -0
- package/vendor/@anvil/common/src/tools/params/tool/web-search.ts +73 -0
- package/vendor/@anvil/common/src/tools/params/tool/write-file.ts +71 -0
- package/vendor/@anvil/common/src/tools/params/tool/write-todos.ts +67 -0
- package/vendor/@anvil/common/src/tools/params/utils.ts +150 -0
- package/vendor/@anvil/common/src/tools/utils.ts +24 -0
- package/vendor/@anvil/common/src/types/__tests__/dynamic-agent-template.test.ts +20 -0
- package/vendor/@anvil/common/src/types/agent-template.ts +215 -0
- package/vendor/@anvil/common/src/types/anvil-session.ts +535 -0
- package/vendor/@anvil/common/src/types/anvil-streak.ts +6 -0
- package/vendor/@anvil/common/src/types/anvil-usage.ts +64 -0
- package/vendor/@anvil/common/src/types/api/agents/publish.ts +61 -0
- package/vendor/@anvil/common/src/types/bun-test.d.ts +5 -0
- package/vendor/@anvil/common/src/types/contracts/agent-runtime.ts +75 -0
- package/vendor/@anvil/common/src/types/contracts/analytics.ts +9 -0
- package/vendor/@anvil/common/src/types/contracts/bigquery.ts +55 -0
- package/vendor/@anvil/common/src/types/contracts/billing.ts +46 -0
- package/vendor/@anvil/common/src/types/contracts/client.ts +53 -0
- package/vendor/@anvil/common/src/types/contracts/database.ts +112 -0
- package/vendor/@anvil/common/src/types/contracts/env.ts +203 -0
- package/vendor/@anvil/common/src/types/contracts/llm.ts +191 -0
- package/vendor/@anvil/common/src/types/contracts/logger.ts +14 -0
- package/vendor/@anvil/common/src/types/contracts/logs.ts +34 -0
- package/vendor/@anvil/common/src/types/contracts/trace.ts +21 -0
- package/vendor/@anvil/common/src/types/dynamic-agent-template.ts +328 -0
- package/vendor/@anvil/common/src/types/filesystem.ts +10 -0
- package/vendor/@anvil/common/src/types/function-params.ts +33 -0
- package/vendor/@anvil/common/src/types/grant.ts +20 -0
- package/vendor/@anvil/common/src/types/gravity-index.ts +170 -0
- package/vendor/@anvil/common/src/types/json.ts +29 -0
- package/vendor/@anvil/common/src/types/mcp.ts +24 -0
- package/vendor/@anvil/common/src/types/messages/anvil-message.ts +58 -0
- package/vendor/@anvil/common/src/types/messages/content-part.ts +59 -0
- package/vendor/@anvil/common/src/types/messages/data-content.ts +14 -0
- package/vendor/@anvil/common/src/types/messages/provider-metadata.ts +13 -0
- package/vendor/@anvil/common/src/types/organization.ts +118 -0
- package/vendor/@anvil/common/src/types/print-mode.ts +121 -0
- package/vendor/@anvil/common/src/types/publisher.ts +67 -0
- package/vendor/@anvil/common/src/types/session-state.ts +149 -0
- package/vendor/@anvil/common/src/types/skill.ts +86 -0
- package/vendor/@anvil/common/src/types/source.ts +11 -0
- package/vendor/@anvil/common/src/types/spawn.ts +13 -0
- package/vendor/@anvil/common/src/types/subscription.ts +67 -0
- package/vendor/@anvil/common/src/types/usage.ts +16 -0
- package/vendor/@anvil/common/src/types/util.ts +3 -0
- package/vendor/@anvil/common/src/util/__tests__/ad-user-agent.test.ts +26 -0
- package/vendor/@anvil/common/src/util/__tests__/analytics-dispatcher.test.ts +122 -0
- package/vendor/@anvil/common/src/util/__tests__/analytics-log.test.ts +102 -0
- package/vendor/@anvil/common/src/util/__tests__/analytics-sampling.test.ts +143 -0
- package/vendor/@anvil/common/src/util/__tests__/anvil-streak.test.ts +202 -0
- package/vendor/@anvil/common/src/util/__tests__/anvil-usage-summary.test.ts +193 -0
- package/vendor/@anvil/common/src/util/__tests__/axiom-only-log.test.ts +140 -0
- package/vendor/@anvil/common/src/util/__tests__/client-user-agent.test.ts +148 -0
- package/vendor/@anvil/common/src/util/__tests__/engagement-tracker.test.ts +115 -0
- package/vendor/@anvil/common/src/util/__tests__/env-file-path.test.ts +57 -0
- package/vendor/@anvil/common/src/util/__tests__/error-abort.test.ts +774 -0
- package/vendor/@anvil/common/src/util/__tests__/error-api-details.test.ts +206 -0
- package/vendor/@anvil/common/src/util/__tests__/file-read-limits.test.ts +173 -0
- package/vendor/@anvil/common/src/util/__tests__/format-code-search.test.ts +60 -0
- package/vendor/@anvil/common/src/util/__tests__/log-mirror.test.ts +31 -0
- package/vendor/@anvil/common/src/util/__tests__/messages.test.ts +1252 -0
- package/vendor/@anvil/common/src/util/__tests__/partial-json-delta.test.ts +505 -0
- package/vendor/@anvil/common/src/util/__tests__/path.test.ts +22 -0
- package/vendor/@anvil/common/src/util/__tests__/project-ignore.test.ts +90 -0
- package/vendor/@anvil/common/src/util/__tests__/promise.test.ts +325 -0
- package/vendor/@anvil/common/src/util/__tests__/rate-limit.test.ts +28 -0
- package/vendor/@anvil/common/src/util/__tests__/reddit-anvil-retention.test.ts +130 -0
- package/vendor/@anvil/common/src/util/__tests__/saxy.test.ts +1008 -0
- package/vendor/@anvil/common/src/util/__tests__/split-data.test.ts +289 -0
- package/vendor/@anvil/common/src/util/__tests__/string.test.ts +239 -0
- package/vendor/@anvil/common/src/util/__tests__/thread-title.test.ts +70 -0
- package/vendor/@anvil/common/src/util/__tests__/tool-result-media-order.test.ts +108 -0
- package/vendor/@anvil/common/src/util/__tests__/ttft-histogram.test.ts +180 -0
- package/vendor/@anvil/common/src/util/__tests__/with-timeout.test.ts +24 -0
- package/vendor/@anvil/common/src/util/__tests__/zoned-time.test.ts +88 -0
- package/vendor/@anvil/common/src/util/ad-user-agent.ts +25 -0
- package/vendor/@anvil/common/src/util/agent-file-utils.ts +110 -0
- package/vendor/@anvil/common/src/util/agent-id-parsing.ts +136 -0
- package/vendor/@anvil/common/src/util/agent-name-normalization.ts +38 -0
- package/vendor/@anvil/common/src/util/agent-name-resolver.ts +86 -0
- package/vendor/@anvil/common/src/util/analytics-dispatcher.ts +82 -0
- package/vendor/@anvil/common/src/util/analytics-log.ts +78 -0
- package/vendor/@anvil/common/src/util/analytics-sampling.ts +255 -0
- package/vendor/@anvil/common/src/util/anvil-model-availability.ts +102 -0
- package/vendor/@anvil/common/src/util/anvil-privacy.ts +82 -0
- package/vendor/@anvil/common/src/util/anvil-streak-line.ts +103 -0
- package/vendor/@anvil/common/src/util/anvil-streak.ts +156 -0
- package/vendor/@anvil/common/src/util/anvil-usage-summary.ts +125 -0
- package/vendor/@anvil/common/src/util/array.ts +31 -0
- package/vendor/@anvil/common/src/util/axiom-only-log.ts +124 -0
- package/vendor/@anvil/common/src/util/cache-debug.ts +171 -0
- package/vendor/@anvil/common/src/util/client-user-agent.ts +114 -0
- package/vendor/@anvil/common/src/util/credentials.ts +26 -0
- package/vendor/@anvil/common/src/util/currency.ts +25 -0
- package/vendor/@anvil/common/src/util/dates.ts +81 -0
- package/vendor/@anvil/common/src/util/disposable-email.ts +277 -0
- package/vendor/@anvil/common/src/util/engagement-tracker.ts +129 -0
- package/vendor/@anvil/common/src/util/env-file-path.ts +40 -0
- package/vendor/@anvil/common/src/util/error.ts +562 -0
- package/vendor/@anvil/common/src/util/file-read-limits.ts +236 -0
- package/vendor/@anvil/common/src/util/file.ts +339 -0
- package/vendor/@anvil/common/src/util/format-code-search.ts +115 -0
- package/vendor/@anvil/common/src/util/lazy-response-ads.ts +92 -0
- package/vendor/@anvil/common/src/util/log-data.ts +57 -0
- package/vendor/@anvil/common/src/util/log-ingest.ts +58 -0
- package/vendor/@anvil/common/src/util/log-mirror.ts +34 -0
- package/vendor/@anvil/common/src/util/lru-cache.ts +67 -0
- package/vendor/@anvil/common/src/util/messages.ts +685 -0
- package/vendor/@anvil/common/src/util/min-heap.ts +87 -0
- package/vendor/@anvil/common/src/util/model-utils.ts +4 -0
- package/vendor/@anvil/common/src/util/object.ts +128 -0
- package/vendor/@anvil/common/src/util/partial-json-delta.ts +89 -0
- package/vendor/@anvil/common/src/util/path.ts +15 -0
- package/vendor/@anvil/common/src/util/project-ignore.ts +119 -0
- package/vendor/@anvil/common/src/util/promise.ts +73 -0
- package/vendor/@anvil/common/src/util/random.ts +15 -0
- package/vendor/@anvil/common/src/util/rate-limit.ts +56 -0
- package/vendor/@anvil/common/src/util/reddit-anvil-retention.ts +60 -0
- package/vendor/@anvil/common/src/util/reddit-capi-events.ts +36 -0
- package/vendor/@anvil/common/src/util/response-ad-positions.ts +54 -0
- package/vendor/@anvil/common/src/util/saxy.ts +741 -0
- package/vendor/@anvil/common/src/util/skills.test.ts +44 -0
- package/vendor/@anvil/common/src/util/skills.ts +36 -0
- package/vendor/@anvil/common/src/util/split-data.ts +259 -0
- package/vendor/@anvil/common/src/util/stop-sequence.ts +61 -0
- package/vendor/@anvil/common/src/util/string.ts +426 -0
- package/vendor/@anvil/common/src/util/system-info.ts +53 -0
- package/vendor/@anvil/common/src/util/thread-title.ts +46 -0
- package/vendor/@anvil/common/src/util/ttft-histogram.ts +73 -0
- package/vendor/@anvil/common/src/util/xml-parser.ts +27 -0
- package/vendor/@anvil/common/src/util/xml.ts +17 -0
- package/vendor/@anvil/common/src/util/zod-schema.ts +25 -0
- package/vendor/@anvil/common/src/util/zoned-time.ts +136 -0
- package/vendor/@anvil/common/src/utils/ask-user-bridge.ts +44 -0
- package/vendor/@anvil/sdk/dist/index.cjs +52297 -0
- package/vendor/@anvil/sdk/dist/index.cjs.map +440 -0
- package/vendor/@anvil/sdk/dist/index.d.ts +4277 -0
- package/vendor/@anvil/sdk/dist/index.mjs +52290 -0
- package/vendor/@anvil/sdk/dist/index.mjs.map +440 -0
- package/vendor/@anvil/sdk/dist/vendor/ai.cjs +30886 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/arm64-linux/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-darwin/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-linux/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-c-sharp.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-cpp.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-go.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-java.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-javascript.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-python.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-ruby.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-rust.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-tsx.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-typescript.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter.wasm +0 -0
- package/vendor/@anvil/sdk/package.json +21 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { mock } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
export interface MockTreeNode {
|
|
4
|
+
text: string
|
|
5
|
+
type?: string
|
|
6
|
+
startPosition?: { row: number; column: number }
|
|
7
|
+
endPosition?: { row: number; column: number }
|
|
8
|
+
children?: MockTreeNode[]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface MockTree {
|
|
12
|
+
rootNode: MockTreeNode
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MockCapture {
|
|
16
|
+
name: string
|
|
17
|
+
node: MockTreeNode
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface MockParser {
|
|
21
|
+
parse: (input: string) => MockTree | null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface MockQuery {
|
|
25
|
+
captures: (node: MockTreeNode) => MockCapture[]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface CreateMockParserOptions {
|
|
29
|
+
tree?: MockTree | null
|
|
30
|
+
parseImpl?: (input: string) => MockTree | null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface CreateMockQueryOptions {
|
|
34
|
+
captures?: MockCapture[]
|
|
35
|
+
capturesImpl?: (node: MockTreeNode) => MockCapture[]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function createMockCapture(name: string, text: string): MockCapture {
|
|
39
|
+
return {
|
|
40
|
+
name,
|
|
41
|
+
node: { text },
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function createMockTreeSitterCaptures(
|
|
46
|
+
items: Array<{ name: string; text: string }>,
|
|
47
|
+
): MockCapture[] {
|
|
48
|
+
return items.map(({ name, text }) => createMockCapture(name, text))
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function createMockTree(rootNodeText: string = 'mock tree'): MockTree {
|
|
52
|
+
return {
|
|
53
|
+
rootNode: { text: rootNodeText },
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function createMockTreeSitterParser(
|
|
58
|
+
options: CreateMockParserOptions = {},
|
|
59
|
+
): MockParser {
|
|
60
|
+
const { tree, parseImpl } = options
|
|
61
|
+
const defaultTree = createMockTree()
|
|
62
|
+
const parseFn = parseImpl ?? (() => tree ?? defaultTree)
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
parse: mock(parseFn),
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function createMockTreeSitterQuery(
|
|
70
|
+
options: CreateMockQueryOptions = {},
|
|
71
|
+
): MockQuery {
|
|
72
|
+
const { captures = [], capturesImpl } = options
|
|
73
|
+
const capturesFn = capturesImpl ?? (() => captures)
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
captures: mock(capturesFn),
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface CreateMockLanguageConfigOptions {
|
|
81
|
+
extensions?: string[]
|
|
82
|
+
wasmFile?: string
|
|
83
|
+
queryText?: string
|
|
84
|
+
parser?: MockParser | null
|
|
85
|
+
query?: MockQuery | null
|
|
86
|
+
captures?: MockCapture[]
|
|
87
|
+
tree?: MockTree | null
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function createMockLanguageConfig(
|
|
91
|
+
options: CreateMockLanguageConfigOptions = {},
|
|
92
|
+
): {
|
|
93
|
+
extensions: string[]
|
|
94
|
+
wasmFile: string
|
|
95
|
+
queryText: string
|
|
96
|
+
parser: MockParser | null
|
|
97
|
+
query: MockQuery | null
|
|
98
|
+
} {
|
|
99
|
+
const {
|
|
100
|
+
extensions = ['.ts'],
|
|
101
|
+
wasmFile = 'tree-sitter-typescript.wasm',
|
|
102
|
+
queryText = 'mock query',
|
|
103
|
+
parser,
|
|
104
|
+
query,
|
|
105
|
+
captures,
|
|
106
|
+
tree,
|
|
107
|
+
} = options
|
|
108
|
+
|
|
109
|
+
const finalQuery =
|
|
110
|
+
query ??
|
|
111
|
+
(captures
|
|
112
|
+
? createMockTreeSitterQuery({ captures })
|
|
113
|
+
: createMockTreeSitterQuery())
|
|
114
|
+
const finalParser =
|
|
115
|
+
parser ??
|
|
116
|
+
(tree !== undefined
|
|
117
|
+
? createMockTreeSitterParser({ tree })
|
|
118
|
+
: createMockTreeSitterParser())
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
extensions,
|
|
122
|
+
wasmFile,
|
|
123
|
+
queryText,
|
|
124
|
+
parser: finalParser,
|
|
125
|
+
query: finalQuery,
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test setup utilities for common patterns.
|
|
3
|
+
*
|
|
4
|
+
* Provides helper functions for setting up and tearing down test fixtures
|
|
5
|
+
* in a consistent way across the codebase.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createTestSetup, TestSetupResult } from '@anvil/common/testing/setup'
|
|
10
|
+
*
|
|
11
|
+
* describe('my test', () => {
|
|
12
|
+
* const setup = createTestSetup()
|
|
13
|
+
*
|
|
14
|
+
* beforeEach(() => setup.beforeEach())
|
|
15
|
+
* afterEach(() => setup.afterEach())
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { setupAnalyticsMocks } from './mocks/analytics'
|
|
21
|
+
import { setupCryptoMocks } from './mocks/crypto'
|
|
22
|
+
import { setupDbSpies } from './mocks/database'
|
|
23
|
+
import { createMockLogger } from './mocks/logger'
|
|
24
|
+
import { resetToolCallIdCounter } from './mocks/stream'
|
|
25
|
+
|
|
26
|
+
import type {
|
|
27
|
+
AnalyticsSpies,
|
|
28
|
+
TrackEventFn,
|
|
29
|
+
FlushAnalyticsFn,
|
|
30
|
+
} from './mocks/analytics'
|
|
31
|
+
import type { CryptoMockSpies } from './mocks/crypto'
|
|
32
|
+
import type { DbSpies } from './mocks/database'
|
|
33
|
+
import type { MockLogger } from './mocks/logger'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Options for creating a test setup.
|
|
37
|
+
*/
|
|
38
|
+
export interface CreateTestSetupOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Whether to set up analytics mocks.
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
analytics?: boolean
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether to set up crypto mocks.
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
crypto?: boolean
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether to set up database mocks.
|
|
53
|
+
* Requires passing the db module.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
database?: boolean
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The database module to mock (required if database is true).
|
|
60
|
+
* Must have insert and update methods that are functions.
|
|
61
|
+
*/
|
|
62
|
+
dbModule?: {
|
|
63
|
+
insert: (...args: unknown[]) => unknown
|
|
64
|
+
update: (...args: unknown[]) => unknown
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The analytics module to mock (required if analytics is true).
|
|
69
|
+
*/
|
|
70
|
+
analyticsModule?: {
|
|
71
|
+
trackEvent: TrackEventFn
|
|
72
|
+
flushAnalytics: FlushAnalyticsFn
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Prefix for crypto mock UUIDs.
|
|
77
|
+
* @default 'test'
|
|
78
|
+
*/
|
|
79
|
+
cryptoPrefix?: string
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Result of creating a test setup.
|
|
84
|
+
*/
|
|
85
|
+
export interface TestSetupResult {
|
|
86
|
+
/** The mock logger instance */
|
|
87
|
+
logger: MockLogger
|
|
88
|
+
|
|
89
|
+
/** Analytics spies (if enabled) */
|
|
90
|
+
analyticsSpy?: AnalyticsSpies
|
|
91
|
+
|
|
92
|
+
/** Crypto spies (if enabled) */
|
|
93
|
+
cryptoSpy?: CryptoMockSpies
|
|
94
|
+
|
|
95
|
+
/** Database spies (if enabled) */
|
|
96
|
+
dbSpy?: DbSpies
|
|
97
|
+
|
|
98
|
+
/** Call this in beforeEach */
|
|
99
|
+
beforeEach: () => void
|
|
100
|
+
|
|
101
|
+
/** Call this in afterEach */
|
|
102
|
+
afterEach: () => void
|
|
103
|
+
|
|
104
|
+
/** Restore all mocks */
|
|
105
|
+
restore: () => void
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Creates a test setup with common mocks pre-configured.
|
|
110
|
+
*
|
|
111
|
+
* @param options - Configuration options
|
|
112
|
+
* @returns A test setup result with mocks and lifecycle methods
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* import * as analytics from '@anvil/common/analytics'
|
|
117
|
+
* const db = createMockDbOperations()
|
|
118
|
+
*
|
|
119
|
+
* describe('my test', () => {
|
|
120
|
+
* const setup = createTestSetup({
|
|
121
|
+
* analytics: true,
|
|
122
|
+
* analyticsModule: analytics,
|
|
123
|
+
* database: true,
|
|
124
|
+
* dbModule: db,
|
|
125
|
+
* })
|
|
126
|
+
*
|
|
127
|
+
* beforeEach(() => setup.beforeEach())
|
|
128
|
+
* afterEach(() => setup.afterEach())
|
|
129
|
+
*
|
|
130
|
+
* it('does something', () => {
|
|
131
|
+
* expect(setup.analyticsSpy.trackEvent).toHaveBeenCalled()
|
|
132
|
+
* })
|
|
133
|
+
* })
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export function createTestSetup(
|
|
137
|
+
options: CreateTestSetupOptions = {},
|
|
138
|
+
): TestSetupResult {
|
|
139
|
+
const {
|
|
140
|
+
analytics = true,
|
|
141
|
+
crypto = true,
|
|
142
|
+
database = false,
|
|
143
|
+
dbModule,
|
|
144
|
+
analyticsModule,
|
|
145
|
+
cryptoPrefix = 'test',
|
|
146
|
+
} = options
|
|
147
|
+
|
|
148
|
+
const logger = createMockLogger()
|
|
149
|
+
let analyticsSpy: AnalyticsSpies | undefined
|
|
150
|
+
let cryptoSpy: CryptoMockSpies | undefined
|
|
151
|
+
let dbSpy: DbSpies | undefined
|
|
152
|
+
|
|
153
|
+
const beforeEach = (): void => {
|
|
154
|
+
// Reset tool call ID counter for deterministic tests
|
|
155
|
+
resetToolCallIdCounter()
|
|
156
|
+
|
|
157
|
+
// Set up analytics mocks
|
|
158
|
+
if (analytics && analyticsModule) {
|
|
159
|
+
analyticsSpy = setupAnalyticsMocks(analyticsModule)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Set up crypto mocks
|
|
163
|
+
if (crypto) {
|
|
164
|
+
cryptoSpy = setupCryptoMocks({ prefix: cryptoPrefix, sequential: true })
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Set up database mocks
|
|
168
|
+
if (database && dbModule) {
|
|
169
|
+
dbSpy = setupDbSpies(dbModule)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const afterEach = (): void => {
|
|
174
|
+
// Restore all mocks
|
|
175
|
+
analyticsSpy?.restore()
|
|
176
|
+
cryptoSpy?.restore()
|
|
177
|
+
dbSpy?.restore()
|
|
178
|
+
|
|
179
|
+
// Reset the spies
|
|
180
|
+
analyticsSpy = undefined
|
|
181
|
+
cryptoSpy = undefined
|
|
182
|
+
dbSpy = undefined
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const restore = afterEach
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
logger,
|
|
189
|
+
get analyticsSpy() {
|
|
190
|
+
return analyticsSpy
|
|
191
|
+
},
|
|
192
|
+
get cryptoSpy() {
|
|
193
|
+
return cryptoSpy
|
|
194
|
+
},
|
|
195
|
+
get dbSpy() {
|
|
196
|
+
return dbSpy
|
|
197
|
+
},
|
|
198
|
+
beforeEach,
|
|
199
|
+
afterEach,
|
|
200
|
+
restore,
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* A simple sleep function for async tests.
|
|
206
|
+
*
|
|
207
|
+
* @param ms - Milliseconds to sleep
|
|
208
|
+
* @returns A promise that resolves after the specified time
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* await sleep(100) // Wait 100ms
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export function sleep(ms: number): Promise<void> {
|
|
216
|
+
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Waits for a condition to be true, polling at the specified interval.
|
|
221
|
+
*
|
|
222
|
+
* @param condition - Function that returns true when the condition is met
|
|
223
|
+
* @param timeout - Maximum time to wait in ms
|
|
224
|
+
* @param interval - Polling interval in ms
|
|
225
|
+
* @returns A promise that resolves when the condition is met
|
|
226
|
+
* @throws Error if the timeout is reached
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```typescript
|
|
230
|
+
* await waitFor(() => document.querySelector('.loaded') !== null)
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
export async function waitFor(
|
|
234
|
+
condition: () => boolean | Promise<boolean>,
|
|
235
|
+
timeout: number = 5000,
|
|
236
|
+
interval: number = 50,
|
|
237
|
+
): Promise<void> {
|
|
238
|
+
const start = Date.now()
|
|
239
|
+
|
|
240
|
+
while (Date.now() - start < timeout) {
|
|
241
|
+
const result = await condition()
|
|
242
|
+
if (result) {
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
await sleep(interval)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
throw new Error(`waitFor timed out after ${timeout}ms`)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Wraps a function to capture its call arguments.
|
|
253
|
+
* Useful for verifying function calls in tests.
|
|
254
|
+
*
|
|
255
|
+
* @param fn - The function to wrap
|
|
256
|
+
* @returns An object with the wrapped function and captured calls
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```typescript
|
|
260
|
+
* const { fn, calls } = captureCallArgs((a: number, b: string) => a + b.length)
|
|
261
|
+
*
|
|
262
|
+
* fn(1, 'hello')
|
|
263
|
+
* fn(2, 'world')
|
|
264
|
+
*
|
|
265
|
+
* expect(calls).toEqual([
|
|
266
|
+
* [1, 'hello'],
|
|
267
|
+
* [2, 'world'],
|
|
268
|
+
* ])
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
export function captureCallArgs<T extends unknown[], R>(
|
|
272
|
+
fn: (...args: T) => R,
|
|
273
|
+
): { fn: (...args: T) => R; calls: T[] } {
|
|
274
|
+
const calls: T[] = []
|
|
275
|
+
|
|
276
|
+
const wrappedFn = (...args: T): R => {
|
|
277
|
+
calls.push(args)
|
|
278
|
+
return fn(...args)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return { fn: wrappedFn, calls }
|
|
282
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CiEnv } from './types/contracts/env'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Test-only helpers for CI env snapshots.
|
|
5
|
+
* Keep production code using `@anvil/common/env-ci`.
|
|
6
|
+
*/
|
|
7
|
+
export const createTestCiEnv = (overrides: Partial<CiEnv> = {}): CiEnv => ({
|
|
8
|
+
CI: undefined,
|
|
9
|
+
GITHUB_ACTIONS: undefined,
|
|
10
|
+
RENDER: undefined,
|
|
11
|
+
IS_PULL_REQUEST: undefined,
|
|
12
|
+
ANVIL_GITHUB_TOKEN: undefined,
|
|
13
|
+
ANVIL_API_KEY: 'test-api-key',
|
|
14
|
+
...overrides,
|
|
15
|
+
})
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { BaseEnv, ProcessEnv } from './types/contracts/env'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Test-only helpers for process env snapshots.
|
|
5
|
+
* Keep production code using `@anvil/common/env-process`.
|
|
6
|
+
*/
|
|
7
|
+
export const createTestBaseEnv = (
|
|
8
|
+
overrides: Partial<BaseEnv> = {},
|
|
9
|
+
): BaseEnv => ({
|
|
10
|
+
SHELL: undefined,
|
|
11
|
+
COMSPEC: undefined,
|
|
12
|
+
HOME: '/home/test',
|
|
13
|
+
USERPROFILE: undefined,
|
|
14
|
+
APPDATA: undefined,
|
|
15
|
+
XDG_CONFIG_HOME: undefined,
|
|
16
|
+
TERM: 'xterm-256color',
|
|
17
|
+
TERM_PROGRAM: undefined,
|
|
18
|
+
TERM_BACKGROUND: undefined,
|
|
19
|
+
TERMINAL_EMULATOR: undefined,
|
|
20
|
+
COLORFGBG: undefined,
|
|
21
|
+
NODE_ENV: 'test',
|
|
22
|
+
NODE_PATH: undefined,
|
|
23
|
+
PATH: '/usr/bin',
|
|
24
|
+
...overrides,
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const createTestProcessEnv = (
|
|
28
|
+
overrides: Partial<ProcessEnv> = {},
|
|
29
|
+
): ProcessEnv => ({
|
|
30
|
+
...createTestBaseEnv(),
|
|
31
|
+
|
|
32
|
+
// Terminal-specific
|
|
33
|
+
KITTY_WINDOW_ID: undefined,
|
|
34
|
+
SIXEL_SUPPORT: undefined,
|
|
35
|
+
ZED_NODE_ENV: undefined,
|
|
36
|
+
|
|
37
|
+
// VS Code family detection
|
|
38
|
+
VSCODE_THEME_KIND: undefined,
|
|
39
|
+
VSCODE_COLOR_THEME_KIND: undefined,
|
|
40
|
+
VSCODE_GIT_IPC_HANDLE: undefined,
|
|
41
|
+
VSCODE_PID: undefined,
|
|
42
|
+
VSCODE_CWD: undefined,
|
|
43
|
+
VSCODE_NLS_CONFIG: undefined,
|
|
44
|
+
|
|
45
|
+
// Cursor editor detection
|
|
46
|
+
CURSOR_PORT: undefined,
|
|
47
|
+
CURSOR: undefined,
|
|
48
|
+
|
|
49
|
+
// JetBrains IDE detection
|
|
50
|
+
JETBRAINS_REMOTE_RUN: undefined,
|
|
51
|
+
IDEA_INITIAL_DIRECTORY: undefined,
|
|
52
|
+
IDE_CONFIG_DIR: undefined,
|
|
53
|
+
JB_IDE_CONFIG_DIR: undefined,
|
|
54
|
+
|
|
55
|
+
// Editor preferences
|
|
56
|
+
VISUAL: undefined,
|
|
57
|
+
EDITOR: undefined,
|
|
58
|
+
ANVIL_CLI_EDITOR: undefined,
|
|
59
|
+
ANVIL_EDITOR: undefined,
|
|
60
|
+
|
|
61
|
+
// Theme preferences
|
|
62
|
+
OPEN_TUI_THEME: undefined,
|
|
63
|
+
OPENTUI_THEME: undefined,
|
|
64
|
+
|
|
65
|
+
// Anvil CLI-specific
|
|
66
|
+
ANVIL_IS_BINARY: undefined,
|
|
67
|
+
ANVIL_CLI_VERSION: undefined,
|
|
68
|
+
ANVIL_CLI_TARGET: undefined,
|
|
69
|
+
ANVIL_RG_PATH: undefined,
|
|
70
|
+
ANVIL_WASM_DIR: undefined,
|
|
71
|
+
|
|
72
|
+
// Build/CI flags
|
|
73
|
+
VERBOSE: undefined,
|
|
74
|
+
OVERRIDE_TARGET: undefined,
|
|
75
|
+
OVERRIDE_PLATFORM: undefined,
|
|
76
|
+
OVERRIDE_ARCH: undefined,
|
|
77
|
+
...overrides,
|
|
78
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
import z from 'zod/v4'
|
|
3
|
+
|
|
4
|
+
import { compileToolDefinitions } from '../compile-tool-definitions'
|
|
5
|
+
|
|
6
|
+
// These tests feed synthetic schemas so they exercise the compile logic
|
|
7
|
+
// directly and stay stable as real tools are added, removed, or reshaped.
|
|
8
|
+
describe('compileToolDefinitions', () => {
|
|
9
|
+
test('emits gravity index action enum values', () => {
|
|
10
|
+
const definitions = compileToolDefinitions()
|
|
11
|
+
|
|
12
|
+
expect(definitions).toContain('export interface GravityIndexParams {')
|
|
13
|
+
expect(definitions).not.toContain('export type GravityIndexParams =')
|
|
14
|
+
expect(definitions).toContain(
|
|
15
|
+
'"action": "search" | "browse" | "list_categories" | "get_service" | "report_integration"',
|
|
16
|
+
)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('keeps object tool schemas as interfaces', () => {
|
|
20
|
+
const objectSchema = z.object({ query: z.string() })
|
|
21
|
+
const definitions = compileToolDefinitions([
|
|
22
|
+
{ name: 'web_search', inputSchema: objectSchema },
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
expect(definitions).toContain('export interface WebSearchParams {')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('compiles every published tool by default', () => {
|
|
29
|
+
const definitions = compileToolDefinitions()
|
|
30
|
+
|
|
31
|
+
expect(definitions).toContain('export type ToolName =')
|
|
32
|
+
expect(definitions).toContain('export interface ToolParamsMap {')
|
|
33
|
+
})
|
|
34
|
+
})
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import z from 'zod/v4'
|
|
2
|
+
|
|
3
|
+
import { publishedTools } from './constants'
|
|
4
|
+
import { toolParams } from './list'
|
|
5
|
+
|
|
6
|
+
/** A tool name plus the Zod schema describing its parameters. */
|
|
7
|
+
export interface ToolSchemaEntry {
|
|
8
|
+
/** Snake_case tool name, e.g. 'web_search'. */
|
|
9
|
+
name: string
|
|
10
|
+
/** Zod schema for the tool's parameters. */
|
|
11
|
+
inputSchema: z.ZodType
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The published tools and their parameter schemas, in published order. */
|
|
15
|
+
function getPublishedToolEntries(): ToolSchemaEntry[] {
|
|
16
|
+
return publishedTools.map((toolName) => ({
|
|
17
|
+
name: toolName,
|
|
18
|
+
inputSchema: toolParams[toolName].inputSchema,
|
|
19
|
+
}))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Compiles tool definitions into a single TypeScript definition file content.
|
|
24
|
+
* This generates type definitions for the given tools and their parameters.
|
|
25
|
+
*
|
|
26
|
+
* Defaults to every published tool; callers (e.g. tests) may pass an explicit
|
|
27
|
+
* list to compile definitions for a specific set of schemas instead.
|
|
28
|
+
*/
|
|
29
|
+
export function compileToolDefinitions(
|
|
30
|
+
tools: ToolSchemaEntry[] = getPublishedToolEntries(),
|
|
31
|
+
): string {
|
|
32
|
+
const toolInterfaces = tools
|
|
33
|
+
.map(({ name: toolName, inputSchema: parameterSchema }) => {
|
|
34
|
+
// Convert Zod schema to TypeScript interface using JSON schema
|
|
35
|
+
let typeDefinition: string
|
|
36
|
+
let jsonSchema: unknown
|
|
37
|
+
try {
|
|
38
|
+
jsonSchema = z.toJSONSchema(parameterSchema, { io: 'input' })
|
|
39
|
+
typeDefinition = jsonSchemaToTypeScript(jsonSchema)
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.warn(`Failed to convert schema for ${toolName}:`, error)
|
|
42
|
+
typeDefinition = '{ [key: string]: any }'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const typeName = `${toPascalCase(toolName)}Params`
|
|
46
|
+
const declaration = canEmitInterface(jsonSchema)
|
|
47
|
+
? `export interface ${typeName} ${typeDefinition}`
|
|
48
|
+
: `export type ${typeName} = ${typeDefinition}`
|
|
49
|
+
|
|
50
|
+
return `/**
|
|
51
|
+
* ${parameterSchema.description || `Parameters for ${toolName} tool`}
|
|
52
|
+
*/
|
|
53
|
+
${declaration}`
|
|
54
|
+
})
|
|
55
|
+
.join('\n\n')
|
|
56
|
+
|
|
57
|
+
const toolUnion = tools.map(({ name }) => `'${name}'`).join(' | ')
|
|
58
|
+
|
|
59
|
+
const toolParamsMap = tools
|
|
60
|
+
.map(({ name }) => ` '${name}': ${toPascalCase(name)}Params`)
|
|
61
|
+
.join('\n')
|
|
62
|
+
|
|
63
|
+
return `/**
|
|
64
|
+
* Union type of all available tool names
|
|
65
|
+
*/
|
|
66
|
+
export type ToolName = ${toolUnion}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Map of tool names to their parameter types
|
|
70
|
+
*/
|
|
71
|
+
export interface ToolParamsMap {
|
|
72
|
+
${toolParamsMap}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
${toolInterfaces}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get parameters type for a specific tool
|
|
79
|
+
*/
|
|
80
|
+
export type GetToolParams<T extends ToolName> = ToolParamsMap[T]
|
|
81
|
+
`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Converts kebab-case to PascalCase
|
|
86
|
+
* e.g., 'write-file' -> 'WriteFile'
|
|
87
|
+
*/
|
|
88
|
+
function toPascalCase(str: string): string {
|
|
89
|
+
return str
|
|
90
|
+
.split(/[-_]/)
|
|
91
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
92
|
+
.join('')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Converts JSON Schema to TypeScript interface definition
|
|
97
|
+
*/
|
|
98
|
+
function jsonSchemaToTypeScript(schema: any): string {
|
|
99
|
+
if (schema.type === 'object' && schema.properties) {
|
|
100
|
+
const properties = Object.entries(schema.properties).map(
|
|
101
|
+
([key, prop]: [string, any]) => {
|
|
102
|
+
const isOptional = !schema.required?.includes(key)
|
|
103
|
+
const propType = getTypeFromJsonSchema(prop)
|
|
104
|
+
const comment = prop.description ? ` /** ${prop.description} */\n` : ''
|
|
105
|
+
return `${comment} "${key}"${isOptional ? '?' : ''}: ${propType}`
|
|
106
|
+
},
|
|
107
|
+
)
|
|
108
|
+
return `{\n${properties.join('\n')}\n}`
|
|
109
|
+
}
|
|
110
|
+
return getTypeFromJsonSchema(schema)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function canEmitInterface(schema: any): boolean {
|
|
114
|
+
return (
|
|
115
|
+
schema.type === 'object' &&
|
|
116
|
+
!!schema.properties &&
|
|
117
|
+
!schema.anyOf &&
|
|
118
|
+
!schema.oneOf
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Gets TypeScript type from JSON Schema property
|
|
124
|
+
*/
|
|
125
|
+
function getTypeFromJsonSchema(prop: any): string {
|
|
126
|
+
if (prop.const !== undefined) {
|
|
127
|
+
return JSON.stringify(prop.const)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (prop.type === 'string') {
|
|
131
|
+
if (prop.enum) {
|
|
132
|
+
return prop.enum.map((v: string) => JSON.stringify(v)).join(' | ')
|
|
133
|
+
}
|
|
134
|
+
return 'string'
|
|
135
|
+
}
|
|
136
|
+
if (prop.type === 'number' || prop.type === 'integer') return 'number'
|
|
137
|
+
if (prop.type === 'boolean') return 'boolean'
|
|
138
|
+
if (prop.type === 'array') {
|
|
139
|
+
const itemType = prop.items ? getTypeFromJsonSchema(prop.items) : 'any'
|
|
140
|
+
return `${itemType}[]`
|
|
141
|
+
}
|
|
142
|
+
if (prop.type === 'object') {
|
|
143
|
+
if (prop.properties) {
|
|
144
|
+
return jsonSchemaToTypeScript(prop)
|
|
145
|
+
}
|
|
146
|
+
if (prop.additionalProperties) {
|
|
147
|
+
const valueType = getTypeFromJsonSchema(prop.additionalProperties)
|
|
148
|
+
return `Record<string, ${valueType}>`
|
|
149
|
+
}
|
|
150
|
+
return 'Record<string, any>'
|
|
151
|
+
}
|
|
152
|
+
if (prop.anyOf || prop.oneOf) {
|
|
153
|
+
const schemas = prop.anyOf || prop.oneOf
|
|
154
|
+
return schemas.map((s: any) => getTypeFromJsonSchema(s)).join(' | ')
|
|
155
|
+
}
|
|
156
|
+
return 'any'
|
|
157
|
+
}
|