@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,289 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import { splitData } from '../split-data'
|
|
4
|
+
|
|
5
|
+
describe('splitData - base cases', () => {
|
|
6
|
+
it('returns primitive as-is in an array', () => {
|
|
7
|
+
expect(splitData({ data: 42 })).toEqual([42])
|
|
8
|
+
expect(splitData({ data: 'hello' })).toEqual(['hello'])
|
|
9
|
+
expect(splitData({ data: null })).toEqual([null])
|
|
10
|
+
expect(splitData({ data: undefined })).toEqual([undefined])
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('returns non-plain objects as-is', () => {
|
|
14
|
+
const date = new Date()
|
|
15
|
+
const regex = /abc/
|
|
16
|
+
|
|
17
|
+
expect(splitData({ data: date })).toEqual([date])
|
|
18
|
+
expect(splitData({ data: regex })).toEqual([regex])
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('splits short strings when maxChunkSize is small', () => {
|
|
22
|
+
const input = { msg: 'abcdef'.repeat(10) } // 60 chars
|
|
23
|
+
|
|
24
|
+
const chunks = splitData({ data: input, maxChunkSize: 30 })
|
|
25
|
+
|
|
26
|
+
expect(chunks.length).toBeGreaterThan(1)
|
|
27
|
+
const combined = chunks.map((c) => c.msg).join('')
|
|
28
|
+
expect(combined).toBe(input.msg)
|
|
29
|
+
expect(chunks.every((c) => JSON.stringify(c).length <= 30)).toBe(true)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('splits deeply nested strings with small maxChunkSize', () => {
|
|
33
|
+
const input = { a: { b: { c: 'xyz123'.repeat(10) } } }
|
|
34
|
+
|
|
35
|
+
const chunks = splitData({ data: input, maxChunkSize: 50 })
|
|
36
|
+
|
|
37
|
+
expect(chunks.length).toBeGreaterThan(1)
|
|
38
|
+
const reconstructed = chunks.map((c) => c.a?.b?.c ?? '').join('')
|
|
39
|
+
expect(reconstructed).toBe('xyz123'.repeat(10))
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('handles arrays with long values', () => {
|
|
43
|
+
const input = ['abcde'.repeat(5), '12345'.repeat(5)]
|
|
44
|
+
const chunks = splitData({ data: input, maxChunkSize: 40 })
|
|
45
|
+
|
|
46
|
+
const combined = chunks
|
|
47
|
+
.flat()
|
|
48
|
+
.filter((v) => typeof v === 'string')
|
|
49
|
+
.join('')
|
|
50
|
+
expect(combined.startsWith(input.join('').slice(0, combined.length))).toBe(
|
|
51
|
+
true,
|
|
52
|
+
)
|
|
53
|
+
expect(chunks.every((c) => JSON.stringify(c).length <= 40)).toBe(true)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('preserves numbers and booleans', () => {
|
|
57
|
+
const input = {
|
|
58
|
+
flag: true,
|
|
59
|
+
num: 123,
|
|
60
|
+
str: 'hello world'.repeat(5),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const chunks = splitData({ data: input, maxChunkSize: 50 })
|
|
64
|
+
|
|
65
|
+
expect(chunks.length).toBeGreaterThan(1)
|
|
66
|
+
expect(chunks.every((c) => JSON.stringify(c).length <= 50)).toBe(true)
|
|
67
|
+
expect(chunks.some((c) => c.flag === true)).toBe(true)
|
|
68
|
+
expect(chunks.some((c) => c.num === 123)).toBe(true)
|
|
69
|
+
expect(chunks.map((c) => c.str).join('')).toBe(input.str)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('splits multiple string fields independently', () => {
|
|
73
|
+
const input = {
|
|
74
|
+
a: 'A'.repeat(20),
|
|
75
|
+
b: 'B'.repeat(20),
|
|
76
|
+
}
|
|
77
|
+
const chunks = splitData({ data: input, maxChunkSize: 30 })
|
|
78
|
+
|
|
79
|
+
expect(chunks.length).toBeGreaterThan(1)
|
|
80
|
+
|
|
81
|
+
const aCombined = chunks.map((c) => c.a ?? '').join('')
|
|
82
|
+
const bCombined = chunks.map((c) => c.b ?? '').join('')
|
|
83
|
+
|
|
84
|
+
expect(aCombined).toBe(input.a)
|
|
85
|
+
expect(bCombined).toBe(input.b)
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
describe('splitData - array and string-specific splitting', () => {
|
|
90
|
+
it('splits long strings into smaller string chunks', () => {
|
|
91
|
+
const input = '12345678901234567890'
|
|
92
|
+
const chunks = splitData({ data: input, maxChunkSize: 5 })
|
|
93
|
+
|
|
94
|
+
expect(Array.isArray(chunks)).toBe(true)
|
|
95
|
+
chunks.forEach((chunk) => {
|
|
96
|
+
expect(typeof chunk).toBe('string')
|
|
97
|
+
expect(chunk.length).toBeLessThanOrEqual(5)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
expect(chunks.join('')).toBe(input)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('splits arrays into smaller arrays with sliced strings', () => {
|
|
104
|
+
const input = ['1', '2', '3333333333', '4', '5']
|
|
105
|
+
const maxSize = 15
|
|
106
|
+
const chunks = splitData({ data: input, maxChunkSize: maxSize })
|
|
107
|
+
|
|
108
|
+
expect(Array.isArray(chunks)).toBe(true)
|
|
109
|
+
chunks.forEach((chunk) => {
|
|
110
|
+
expect(Array.isArray(chunk)).toBe(true)
|
|
111
|
+
expect(JSON.stringify(chunk).length).toBeLessThanOrEqual(maxSize)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
const joined = chunks.flat().join('')
|
|
115
|
+
expect(joined.startsWith(input.join('').slice(0, joined.length))).toBe(true)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
it('splits plain objects with long strings into smaller objects', () => {
|
|
119
|
+
const input = {
|
|
120
|
+
a: 'aaa'.repeat(10),
|
|
121
|
+
b: 'bbb'.repeat(10),
|
|
122
|
+
}
|
|
123
|
+
const maxSize = 40
|
|
124
|
+
const chunks = splitData({ data: input, maxChunkSize: maxSize })
|
|
125
|
+
|
|
126
|
+
expect(Array.isArray(chunks)).toBe(true)
|
|
127
|
+
chunks.forEach((chunk) => {
|
|
128
|
+
expect(typeof chunk).toBe('object')
|
|
129
|
+
expect(JSON.stringify(chunk).length).toBeLessThanOrEqual(maxSize)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const aJoined = chunks.map((c) => c.a ?? '').join('')
|
|
133
|
+
const bJoined = chunks.map((c) => c.b ?? '').join('')
|
|
134
|
+
expect(aJoined.startsWith(input.a.slice(0, aJoined.length))).toBe(true)
|
|
135
|
+
expect(bJoined.startsWith(input.b.slice(0, bJoined.length))).toBe(true)
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
it('preserves numbers and booleans in split arrays', () => {
|
|
139
|
+
const input = ['x'.repeat(20), 123, false, 'y'.repeat(10)]
|
|
140
|
+
const maxSize = 20
|
|
141
|
+
|
|
142
|
+
const chunks = splitData({ data: input, maxChunkSize: maxSize })
|
|
143
|
+
|
|
144
|
+
expect(Array.isArray(chunks)).toBe(true)
|
|
145
|
+
chunks.forEach((chunk) => {
|
|
146
|
+
expect(Array.isArray(chunk)).toBe(true)
|
|
147
|
+
expect(JSON.stringify(chunk).length).toBeLessThanOrEqual(maxSize)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
const flattened = chunks.flat()
|
|
151
|
+
expect(flattened.includes(123)).toBe(true)
|
|
152
|
+
expect(flattened.includes(false)).toBe(true)
|
|
153
|
+
const strCombined = flattened.filter((v) => typeof v === 'string').join('')
|
|
154
|
+
expect(strCombined.startsWith('x'.repeat(20) + 'y'.repeat(10))).toBe(true)
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('splits hybrid nested array/object structures within size limits', () => {
|
|
158
|
+
const input = [
|
|
159
|
+
{ msg: 'x'.repeat(25) },
|
|
160
|
+
{ val: 42 },
|
|
161
|
+
{ msg: 'y'.repeat(25) },
|
|
162
|
+
]
|
|
163
|
+
const maxSize = 30
|
|
164
|
+
|
|
165
|
+
const chunks = splitData({ data: input, maxChunkSize: maxSize })
|
|
166
|
+
|
|
167
|
+
expect(Array.isArray(chunks)).toBe(true)
|
|
168
|
+
chunks.forEach((chunk) => {
|
|
169
|
+
expect(Array.isArray(chunk)).toBe(true)
|
|
170
|
+
expect(JSON.stringify(chunk).length).toBeLessThanOrEqual(maxSize)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
const joinedMsg = chunks
|
|
174
|
+
.flat()
|
|
175
|
+
.map((c) => c.msg ?? '')
|
|
176
|
+
.join('')
|
|
177
|
+
expect(joinedMsg.startsWith('x'.repeat(25) + 'y'.repeat(25))).toBe(true)
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
it('efficiently combines array elements while respecting maxSize', () => {
|
|
181
|
+
const input = [
|
|
182
|
+
'short',
|
|
183
|
+
'strings',
|
|
184
|
+
'that',
|
|
185
|
+
'can',
|
|
186
|
+
'fit',
|
|
187
|
+
'together',
|
|
188
|
+
'verylongstringthatwontfit.............................overflowing',
|
|
189
|
+
'more',
|
|
190
|
+
'short',
|
|
191
|
+
'ones',
|
|
192
|
+
]
|
|
193
|
+
const maxSize = 50
|
|
194
|
+
|
|
195
|
+
const chunks = splitData({ data: input, maxChunkSize: maxSize })
|
|
196
|
+
|
|
197
|
+
expect(chunks).toEqual([
|
|
198
|
+
['short', 'strings', 'that', 'can', 'fit', 'together'],
|
|
199
|
+
['verylongstringthatwontfit.....................'], // exactly 50 chars
|
|
200
|
+
['........overflowing', 'more', 'short', 'ones'],
|
|
201
|
+
])
|
|
202
|
+
|
|
203
|
+
chunks.forEach((chunk) => {
|
|
204
|
+
expect(JSON.stringify(chunk).length).toBeLessThanOrEqual(maxSize)
|
|
205
|
+
})
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
it('efficiently combines object properties while respecting maxSize', () => {
|
|
209
|
+
const input = {
|
|
210
|
+
a: 'short',
|
|
211
|
+
b: 'strings',
|
|
212
|
+
c: 'that',
|
|
213
|
+
d: 'can',
|
|
214
|
+
e: 'fit',
|
|
215
|
+
f: 'together',
|
|
216
|
+
long: 'abcde'.repeat(15),
|
|
217
|
+
g: 'more',
|
|
218
|
+
h: 'short',
|
|
219
|
+
i: 'ones',
|
|
220
|
+
}
|
|
221
|
+
const maxSize = 75
|
|
222
|
+
|
|
223
|
+
const chunks = splitData({ data: input, maxChunkSize: maxSize })
|
|
224
|
+
|
|
225
|
+
expect(chunks).toEqual([
|
|
226
|
+
{
|
|
227
|
+
a: 'short',
|
|
228
|
+
b: 'strings',
|
|
229
|
+
c: 'that',
|
|
230
|
+
d: 'can',
|
|
231
|
+
e: 'fit',
|
|
232
|
+
f: 'together',
|
|
233
|
+
},
|
|
234
|
+
{ long: 'abcde'.repeat(12) + 'abcd' }, // exactly 75 chars
|
|
235
|
+
{ long: 'e' + 'abcde'.repeat(2), g: 'more', h: 'short', i: 'ones' },
|
|
236
|
+
])
|
|
237
|
+
|
|
238
|
+
chunks.forEach((chunk) => {
|
|
239
|
+
expect(JSON.stringify(chunk).length).toBeLessThanOrEqual(maxSize)
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
it('handles escaped characters at split points', () => {
|
|
244
|
+
const input = 'testing"testing'
|
|
245
|
+
const maxSize = 10
|
|
246
|
+
|
|
247
|
+
const chunks = splitData({ data: input, maxChunkSize: maxSize })
|
|
248
|
+
|
|
249
|
+
expect(chunks).toEqual([
|
|
250
|
+
'testing', // only length 9, but testing" would be 11
|
|
251
|
+
'"testin', // length 10
|
|
252
|
+
'g', // length 3
|
|
253
|
+
])
|
|
254
|
+
chunks.forEach((chunk) => {
|
|
255
|
+
expect(JSON.stringify(chunk).length).toBeLessThanOrEqual(maxSize)
|
|
256
|
+
})
|
|
257
|
+
})
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
describe('splitData - nested object splitting', () => {
|
|
261
|
+
it('maintains object structure when splitting nested long strings', () => {
|
|
262
|
+
const input = {
|
|
263
|
+
a: 'short',
|
|
264
|
+
b: {
|
|
265
|
+
c: 'strings',
|
|
266
|
+
long: 'verylongstringthatwontfit...................overflowing',
|
|
267
|
+
},
|
|
268
|
+
d: 'more',
|
|
269
|
+
}
|
|
270
|
+
const maxSize = 50
|
|
271
|
+
|
|
272
|
+
const chunks = splitData({ data: input, maxChunkSize: maxSize })
|
|
273
|
+
|
|
274
|
+
expect(chunks).toEqual([
|
|
275
|
+
{
|
|
276
|
+
a: 'short',
|
|
277
|
+
b: {
|
|
278
|
+
c: 'strings',
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
b: {
|
|
283
|
+
long: 'verylongstringthatwontfit........', // exactly 50 chars
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
{ b: { long: '...........overflowing' }, d: 'more' }, // 50 chars
|
|
287
|
+
])
|
|
288
|
+
})
|
|
289
|
+
})
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import { pluralize } from '../string'
|
|
4
|
+
|
|
5
|
+
describe('pluralize', () => {
|
|
6
|
+
it('should handle singular and plural cases correctly', () => {
|
|
7
|
+
expect(pluralize(1, 'test')).toBe('1 test')
|
|
8
|
+
expect(pluralize(0, 'test')).toBe('0 tests')
|
|
9
|
+
expect(pluralize(2, 'test')).toBe('2 tests')
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('should handle words ending in y', () => {
|
|
13
|
+
expect(pluralize(1, 'city')).toBe('1 city')
|
|
14
|
+
expect(pluralize(2, 'city')).toBe('2 cities')
|
|
15
|
+
expect(pluralize(3, 'repository')).toBe('3 repositories')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('should handle words ending in f/fe', () => {
|
|
19
|
+
expect(pluralize(1, 'leaf')).toBe('1 leaf')
|
|
20
|
+
expect(pluralize(2, 'leaf')).toBe('2 leaves')
|
|
21
|
+
expect(pluralize(1, 'knife')).toBe('1 knife')
|
|
22
|
+
expect(pluralize(2, 'knife')).toBe('2 knives')
|
|
23
|
+
expect(pluralize(1, 'life')).toBe('1 life')
|
|
24
|
+
expect(pluralize(3, 'life')).toBe('3 lives')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('should handle words ending in s, sh, ch, x, z, o', () => {
|
|
28
|
+
expect(pluralize(2, 'bus')).toBe('2 buses')
|
|
29
|
+
expect(pluralize(2, 'box')).toBe('2 boxes')
|
|
30
|
+
expect(pluralize(2, 'church')).toBe('2 churches')
|
|
31
|
+
expect(pluralize(2, 'dish')).toBe('2 dishes')
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('should handle regular plurals', () => {
|
|
35
|
+
expect(pluralize(1, 'agent')).toBe('1 agent')
|
|
36
|
+
expect(pluralize(0, 'agent')).toBe('0 agents')
|
|
37
|
+
expect(pluralize(5, 'member')).toBe('5 members')
|
|
38
|
+
expect(pluralize(10, 'invitation')).toBe('10 invitations')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('should return only the word when includeCount is false', () => {
|
|
42
|
+
expect(pluralize(1, 'answer', { includeCount: false })).toBe('answer')
|
|
43
|
+
expect(pluralize(2, 'answer', { includeCount: false })).toBe('answers')
|
|
44
|
+
expect(pluralize(1, 'question', { includeCount: false })).toBe('question')
|
|
45
|
+
expect(pluralize(5, 'question', { includeCount: false })).toBe('questions')
|
|
46
|
+
expect(pluralize(2, 'city', { includeCount: false })).toBe('cities')
|
|
47
|
+
expect(pluralize(2, 'leaf', { includeCount: false })).toBe('leaves')
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// Tech/CS irregular plurals (truly irregular, no derivable pattern)
|
|
51
|
+
it('should handle truly irregular plurals', () => {
|
|
52
|
+
// Common irregulars
|
|
53
|
+
expect(pluralize(2, 'person')).toBe('2 people')
|
|
54
|
+
expect(pluralize(2, 'child')).toBe('2 children')
|
|
55
|
+
expect(pluralize(2, 'mouse')).toBe('2 mice')
|
|
56
|
+
|
|
57
|
+
// -ex/-ix → -ices (no reliable rule, must be hardcoded)
|
|
58
|
+
expect(pluralize(2, 'index')).toBe('2 indices')
|
|
59
|
+
expect(pluralize(2, 'vertex')).toBe('2 vertices')
|
|
60
|
+
expect(pluralize(2, 'matrix')).toBe('2 matrices')
|
|
61
|
+
expect(pluralize(2, 'appendix')).toBe('2 appendices')
|
|
62
|
+
|
|
63
|
+
// Latin -um → -a
|
|
64
|
+
expect(pluralize(2, 'datum')).toBe('2 data')
|
|
65
|
+
expect(pluralize(2, 'medium')).toBe('2 media')
|
|
66
|
+
expect(pluralize(2, 'criterion')).toBe('2 criteria')
|
|
67
|
+
expect(pluralize(2, 'phenomenon')).toBe('2 phenomena')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
// Derived rule: -sis → -ses
|
|
71
|
+
it('should handle -sis → -ses by rule', () => {
|
|
72
|
+
expect(pluralize(2, 'analysis')).toBe('2 analyses')
|
|
73
|
+
expect(pluralize(2, 'basis')).toBe('2 bases')
|
|
74
|
+
expect(pluralize(2, 'hypothesis')).toBe('2 hypotheses')
|
|
75
|
+
expect(pluralize(2, 'thesis')).toBe('2 theses')
|
|
76
|
+
expect(pluralize(2, 'parenthesis')).toBe('2 parentheses')
|
|
77
|
+
expect(pluralize(2, 'synopsis')).toBe('2 synopses')
|
|
78
|
+
expect(pluralize(2, 'crisis')).toBe('2 crises')
|
|
79
|
+
expect(pluralize(2, 'diagnosis')).toBe('2 diagnoses')
|
|
80
|
+
expect(pluralize(2, 'ellipsis')).toBe('2 ellipses')
|
|
81
|
+
// Any new -sis word should work without adding to list
|
|
82
|
+
expect(pluralize(2, 'oasis')).toBe('2 oases')
|
|
83
|
+
expect(pluralize(2, 'genesis')).toBe('2 geneses')
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
// Derived rule: -xis → -xes
|
|
87
|
+
it('should handle -xis → -xes by rule', () => {
|
|
88
|
+
expect(pluralize(2, 'axis')).toBe('2 axes')
|
|
89
|
+
// Any new -xis word should work without adding to list
|
|
90
|
+
expect(pluralize(2, 'praxis')).toBe('2 praxes')
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
// Derived rule: -ware stays unchanged
|
|
94
|
+
it('should handle -ware words staying unchanged by rule', () => {
|
|
95
|
+
expect(pluralize(2, 'software')).toBe('2 software')
|
|
96
|
+
expect(pluralize(2, 'hardware')).toBe('2 hardware')
|
|
97
|
+
expect(pluralize(2, 'firmware')).toBe('2 firmware')
|
|
98
|
+
expect(pluralize(2, 'malware')).toBe('2 malware')
|
|
99
|
+
expect(pluralize(2, 'middleware')).toBe('2 middleware')
|
|
100
|
+
expect(pluralize(2, 'freeware')).toBe('2 freeware')
|
|
101
|
+
expect(pluralize(2, 'shareware')).toBe('2 shareware')
|
|
102
|
+
// Any new -ware word should work without adding to list
|
|
103
|
+
expect(pluralize(2, 'spyware')).toBe('2 spyware')
|
|
104
|
+
expect(pluralize(2, 'bloatware')).toBe('2 bloatware')
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
// Derived rule: -ics stays unchanged
|
|
108
|
+
it('should handle -ics words staying unchanged by rule', () => {
|
|
109
|
+
expect(pluralize(2, 'analytics')).toBe('2 analytics')
|
|
110
|
+
expect(pluralize(2, 'graphics')).toBe('2 graphics')
|
|
111
|
+
expect(pluralize(2, 'physics')).toBe('2 physics')
|
|
112
|
+
expect(pluralize(2, 'mathematics')).toBe('2 mathematics')
|
|
113
|
+
expect(pluralize(2, 'statistics')).toBe('2 statistics')
|
|
114
|
+
expect(pluralize(2, 'logistics')).toBe('2 logistics')
|
|
115
|
+
expect(pluralize(2, 'economics')).toBe('2 economics')
|
|
116
|
+
// Any new -ics word should work without adding to list
|
|
117
|
+
expect(pluralize(2, 'semantics')).toBe('2 semantics')
|
|
118
|
+
expect(pluralize(2, 'heuristics')).toBe('2 heuristics')
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('should handle other unchanging plurals', () => {
|
|
122
|
+
// Data terms (hardcoded because 'data' is special case)
|
|
123
|
+
expect(pluralize(2, 'data')).toBe('2 data')
|
|
124
|
+
expect(pluralize(2, 'metadata')).toBe('2 metadata')
|
|
125
|
+
expect(pluralize(2, 'feedback')).toBe('2 feedback')
|
|
126
|
+
|
|
127
|
+
// Other words ending in -s that don't change
|
|
128
|
+
expect(pluralize(2, 'series')).toBe('2 series')
|
|
129
|
+
expect(pluralize(2, 'chassis')).toBe('2 chassis')
|
|
130
|
+
expect(pluralize(2, 'species')).toBe('2 species')
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it('should handle tech -o endings', () => {
|
|
134
|
+
// Words that add -es (default for -o)
|
|
135
|
+
expect(pluralize(2, 'hero')).toBe('2 heroes')
|
|
136
|
+
expect(pluralize(2, 'echo')).toBe('2 echoes')
|
|
137
|
+
expect(pluralize(2, 'veto')).toBe('2 vetoes')
|
|
138
|
+
|
|
139
|
+
// Tech terms that just add -s
|
|
140
|
+
expect(pluralize(2, 'photo')).toBe('2 photos')
|
|
141
|
+
expect(pluralize(2, 'video')).toBe('2 videos')
|
|
142
|
+
expect(pluralize(2, 'audio')).toBe('2 audios')
|
|
143
|
+
expect(pluralize(2, 'logo')).toBe('2 logos')
|
|
144
|
+
expect(pluralize(2, 'demo')).toBe('2 demos')
|
|
145
|
+
expect(pluralize(2, 'repo')).toBe('2 repos')
|
|
146
|
+
expect(pluralize(2, 'memo')).toBe('2 memos')
|
|
147
|
+
expect(pluralize(2, 'typo')).toBe('2 typos')
|
|
148
|
+
expect(pluralize(2, 'intro')).toBe('2 intros')
|
|
149
|
+
expect(pluralize(2, 'macro')).toBe('2 macros')
|
|
150
|
+
expect(pluralize(2, 'scenario')).toBe('2 scenarios')
|
|
151
|
+
expect(pluralize(2, 'portfolio')).toBe('2 portfolios')
|
|
152
|
+
expect(pluralize(2, 'ratio')).toBe('2 ratios')
|
|
153
|
+
expect(pluralize(2, 'zero')).toBe('2 zeros')
|
|
154
|
+
expect(pluralize(2, 'silo')).toBe('2 silos') // data silos
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('should handle -f/-fe endings', () => {
|
|
158
|
+
// Words that change -f to -ves (default behavior)
|
|
159
|
+
expect(pluralize(2, 'half')).toBe('2 halves')
|
|
160
|
+
expect(pluralize(2, 'shelf')).toBe('2 shelves')
|
|
161
|
+
expect(pluralize(2, 'self')).toBe('2 selves')
|
|
162
|
+
expect(pluralize(2, 'leaf')).toBe('2 leaves')
|
|
163
|
+
|
|
164
|
+
// -fe to -ves
|
|
165
|
+
expect(pluralize(2, 'knife')).toBe('2 knives')
|
|
166
|
+
expect(pluralize(2, 'life')).toBe('2 lives')
|
|
167
|
+
|
|
168
|
+
// Tech/design terms that just add -s
|
|
169
|
+
expect(pluralize(2, 'proof')).toBe('2 proofs') // mathematical proofs
|
|
170
|
+
expect(pluralize(2, 'brief')).toBe('2 briefs') // design briefs
|
|
171
|
+
expect(pluralize(2, 'chief')).toBe('2 chiefs') // tech leads
|
|
172
|
+
expect(pluralize(2, 'staff')).toBe('2 staffs')
|
|
173
|
+
expect(pluralize(2, 'serif')).toBe('2 serifs') // font serifs
|
|
174
|
+
expect(pluralize(2, 'motif')).toBe('2 motifs') // design motifs
|
|
175
|
+
expect(pluralize(2, 'gif')).toBe('2 gifs')
|
|
176
|
+
expect(pluralize(2, 'pdf')).toBe('2 pdfs')
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('should handle words ending in -y with vowel before', () => {
|
|
180
|
+
// vowel + y -> just add -s
|
|
181
|
+
expect(pluralize(2, 'key')).toBe('2 keys')
|
|
182
|
+
expect(pluralize(2, 'monkey')).toBe('2 monkeys')
|
|
183
|
+
expect(pluralize(2, 'toy')).toBe('2 toys')
|
|
184
|
+
expect(pluralize(2, 'boy')).toBe('2 boys')
|
|
185
|
+
expect(pluralize(2, 'day')).toBe('2 days')
|
|
186
|
+
expect(pluralize(2, 'way')).toBe('2 ways')
|
|
187
|
+
expect(pluralize(2, 'tray')).toBe('2 trays')
|
|
188
|
+
expect(pluralize(2, 'valley')).toBe('2 valleys')
|
|
189
|
+
expect(pluralize(2, 'donkey')).toBe('2 donkeys')
|
|
190
|
+
expect(pluralize(2, 'essay')).toBe('2 essays')
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it('should handle words ending in -ful', () => {
|
|
194
|
+
expect(pluralize(2, 'cupful')).toBe('2 cupfuls')
|
|
195
|
+
expect(pluralize(2, 'handful')).toBe('2 handfuls')
|
|
196
|
+
expect(pluralize(2, 'spoonful')).toBe('2 spoonfuls')
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
it('should handle words already ending in -s', () => {
|
|
200
|
+
expect(pluralize(2, 'bus')).toBe('2 buses')
|
|
201
|
+
expect(pluralize(2, 'lens')).toBe('2 lenses')
|
|
202
|
+
expect(pluralize(2, 'gas')).toBe('2 gases')
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
it('should handle words ending in -z', () => {
|
|
206
|
+
// Single z doubles
|
|
207
|
+
expect(pluralize(2, 'quiz')).toBe('2 quizzes')
|
|
208
|
+
expect(pluralize(2, 'fez')).toBe('2 fezzes')
|
|
209
|
+
// Double z just adds -es
|
|
210
|
+
expect(pluralize(2, 'buzz')).toBe('2 buzzes')
|
|
211
|
+
expect(pluralize(2, 'fizz')).toBe('2 fizzes')
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
it('should handle common tech terms', () => {
|
|
215
|
+
// Regular tech plurals
|
|
216
|
+
expect(pluralize(2, 'schema')).toBe('2 schemas')
|
|
217
|
+
expect(pluralize(2, 'API')).toBe('2 APIs')
|
|
218
|
+
expect(pluralize(2, 'SDK')).toBe('2 SDKs')
|
|
219
|
+
expect(pluralize(2, 'URL')).toBe('2 URLs')
|
|
220
|
+
expect(pluralize(2, 'CLI')).toBe('2 CLIs')
|
|
221
|
+
expect(pluralize(2, 'bug')).toBe('2 bugs')
|
|
222
|
+
expect(pluralize(2, 'feature')).toBe('2 features')
|
|
223
|
+
expect(pluralize(2, 'commit')).toBe('2 commits')
|
|
224
|
+
expect(pluralize(2, 'branch')).toBe('2 branches')
|
|
225
|
+
expect(pluralize(2, 'merge')).toBe('2 merges')
|
|
226
|
+
expect(pluralize(2, 'deploy')).toBe('2 deploys')
|
|
227
|
+
expect(pluralize(2, 'release')).toBe('2 releases')
|
|
228
|
+
expect(pluralize(2, 'sprint')).toBe('2 sprints')
|
|
229
|
+
expect(pluralize(2, 'ticket')).toBe('2 tickets')
|
|
230
|
+
expect(pluralize(2, 'endpoint')).toBe('2 endpoints')
|
|
231
|
+
expect(pluralize(2, 'webhook')).toBe('2 webhooks')
|
|
232
|
+
expect(pluralize(2, 'callback')).toBe('2 callbacks')
|
|
233
|
+
expect(pluralize(2, 'payload')).toBe('2 payloads')
|
|
234
|
+
expect(pluralize(2, 'token')).toBe('2 tokens')
|
|
235
|
+
expect(pluralize(2, 'query')).toBe('2 queries')
|
|
236
|
+
expect(pluralize(2, 'dependency')).toBe('2 dependencies')
|
|
237
|
+
})
|
|
238
|
+
})
|
|
239
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
sanitizeThreadTitle,
|
|
5
|
+
THREAD_TITLE_MAX_CHARS,
|
|
6
|
+
} from '../thread-title'
|
|
7
|
+
|
|
8
|
+
// titles come straight from a model, so this has to cope with every way it ignores the prompt
|
|
9
|
+
|
|
10
|
+
describe('sanitizeThreadTitle', () => {
|
|
11
|
+
test('strips the label the model prepends despite being told not to', () => {
|
|
12
|
+
expect(sanitizeThreadTitle('Title: Fix The Login Bug')).toBe(
|
|
13
|
+
'Fix The Login Bug',
|
|
14
|
+
)
|
|
15
|
+
expect(sanitizeThreadTitle('TITLE:Fix The Login Bug')).toBe(
|
|
16
|
+
'Fix The Login Bug',
|
|
17
|
+
)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test('strips wrapping quotes, straight and smart', () => {
|
|
21
|
+
expect(sanitizeThreadTitle('"Fix The Login Bug"')).toBe('Fix The Login Bug')
|
|
22
|
+
expect(sanitizeThreadTitle('“Fix The Login Bug”')).toBe('Fix The Login Bug')
|
|
23
|
+
expect(sanitizeThreadTitle("'Fix The Login Bug'")).toBe('Fix The Login Bug')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('keeps quotes that are part of the title', () => {
|
|
27
|
+
expect(sanitizeThreadTitle('Rename The "main" Branch')).toBe(
|
|
28
|
+
'Rename The "main" Branch',
|
|
29
|
+
)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test('drops trailing sentence punctuation but not internal punctuation', () => {
|
|
33
|
+
expect(sanitizeThreadTitle('Fix the login bug.')).toBe('Fix the login bug')
|
|
34
|
+
expect(sanitizeThreadTitle('Fix login, logout, and reset!!')).toBe(
|
|
35
|
+
'Fix login, logout, and reset',
|
|
36
|
+
)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test('a quoted sentence loses both the quotes and the period', () => {
|
|
40
|
+
// order matters: quotes come off first, otherwise the period stays hidden behind the quote
|
|
41
|
+
expect(sanitizeThreadTitle('"Fix the login bug."')).toBe('Fix the login bug')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test('collapses the multi-line preamble case into a single line', () => {
|
|
45
|
+
// the title lands in a one-line tab label; an embedded newline would break the layout
|
|
46
|
+
expect(sanitizeThreadTitle(' Fix The\nLogin\tBug ')).toBe(
|
|
47
|
+
'Fix The Login Bug',
|
|
48
|
+
)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test('never exceeds the width the label is drawn at', () => {
|
|
52
|
+
expect(sanitizeThreadTitle('A '.repeat(200))).toHaveLength(
|
|
53
|
+
THREAD_TITLE_MAX_CHARS,
|
|
54
|
+
)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('returns null when nothing usable is left', () => {
|
|
58
|
+
// null keeps the placeholder the caller already showed instead of blanking the label
|
|
59
|
+
for (const raw of ['', ' ', '"..."', 'Title:', '!!!', '“”']) {
|
|
60
|
+
expect(sanitizeThreadTitle(raw)).toBeNull()
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('a non-latin title survives intact', () => {
|
|
65
|
+
// the agent is told to answer in the user's language; stripping it would be worse than no title
|
|
66
|
+
expect(sanitizeThreadTitle('«Исправить вход в систему».')).toBe(
|
|
67
|
+
'«Исправить вход в систему»',
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
})
|