@alumbwe/anvil 1.0.41 → 1.0.49

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.
Files changed (241) hide show
  1. package/bin/anvil.js +18 -0
  2. package/package.json +13 -6
  3. package/src/agents/bundled-agents.generated.ts +1 -1
  4. package/src/entry.ts +5 -0
  5. package/src/index.tsx +27 -4
  6. package/src/login/plain-login.ts +60 -0
  7. package/src/login/supabase-auth.ts +346 -0
  8. package/src/pre-init/client-env.ts +17 -0
  9. package/src/utils/anvil-client.ts +4 -0
  10. package/src/utils/auth.ts +16 -4
  11. package/src/utils/client-env-defaults.ts +28 -0
  12. package/src/utils/config-dir.ts +1 -1
  13. package/vendor/@anvil/common/src/constants/deepseek-direct.ts +30 -1
  14. package/vendor/@anvil/common/src/util/project-ignore.ts +4 -3
  15. package/vendor/@anvil/sdk/dist/index.cjs +46 -10
  16. package/vendor/@anvil/sdk/dist/index.mjs +46 -10
  17. package/src/commands/__tests__/anvil-command-aliases.test.ts +0 -56
  18. package/src/commands/__tests__/bash-command.test.ts +0 -445
  19. package/src/commands/__tests__/command-args.test.ts +0 -349
  20. package/src/commands/__tests__/copy-conversation-clipboard.test.ts +0 -108
  21. package/src/commands/__tests__/copy-conversation.test.ts +0 -226
  22. package/src/commands/__tests__/diagnostics-command.test.ts +0 -35
  23. package/src/commands/__tests__/image.test.ts +0 -99
  24. package/src/commands/__tests__/init.test.ts +0 -456
  25. package/src/commands/__tests__/new-command-rotates-chat.test.ts +0 -91
  26. package/src/commands/__tests__/process-diagnostics.test.ts +0 -54
  27. package/src/commands/__tests__/prompt-builders.test.ts +0 -28
  28. package/src/commands/__tests__/router-input.test.ts +0 -298
  29. package/src/components/__tests__/ad-banner.test.tsx +0 -83
  30. package/src/components/__tests__/anvil-landing-heading-row.test.tsx +0 -91
  31. package/src/components/__tests__/anvil-model-selector.test.tsx +0 -519
  32. package/src/components/__tests__/anvil-offer-invariants.test.ts +0 -54
  33. package/src/components/__tests__/anvil-takeover-prompt.test.tsx +0 -212
  34. package/src/components/__tests__/chat-input-bar.test.tsx +0 -130
  35. package/src/components/__tests__/grid-layout.integration.test.tsx +0 -304
  36. package/src/components/__tests__/grid-layout.test.tsx +0 -1051
  37. package/src/components/__tests__/message-block.completion.test.tsx +0 -104
  38. package/src/components/__tests__/message-block.streaming.test.tsx +0 -78
  39. package/src/components/__tests__/message-with-agents.test.tsx +0 -579
  40. package/src/components/__tests__/multiline-input.test.tsx +0 -1132
  41. package/src/components/__tests__/queue-panel.test.tsx +0 -398
  42. package/src/components/__tests__/selectable-list.test.ts +0 -232
  43. package/src/components/__tests__/status-bar.test.tsx +0 -44
  44. package/src/components/__tests__/status-indicator.test.tsx +0 -204
  45. package/src/components/__tests__/terminal-thinking-orb.test.tsx +0 -111
  46. package/src/components/__tests__/user-error-banner.test.tsx +0 -102
  47. package/src/components/ask-user/__tests__/multiple-choice-form.test.ts +0 -432
  48. package/src/components/ask-user/__tests__/validation.test.ts +0 -213
  49. package/src/components/tools/__tests__/apply-patch.test.tsx +0 -84
  50. package/src/components/tools/__tests__/code-search.test.tsx +0 -45
  51. package/src/components/tools/__tests__/gravity-index.test.ts +0 -76
  52. package/src/components/tools/__tests__/render-ui.test.tsx +0 -92
  53. package/src/components/tools/__tests__/run-terminal-command.test.ts +0 -233
  54. package/src/contexts/__tests__/chat-runtime-context.test.tsx +0 -149
  55. package/src/data/slash-commands.test.ts +0 -24
  56. package/src/hooks/__tests__/holds-live-anvil-slot.test.ts +0 -49
  57. package/src/hooks/__tests__/session-fetch-signal.test.ts +0 -63
  58. package/src/hooks/__tests__/use-activity-query.test.ts +0 -1000
  59. package/src/hooks/__tests__/use-ask-user-bridge.test.ts +0 -176
  60. package/src/hooks/__tests__/use-auth-query.test.ts +0 -21
  61. package/src/hooks/__tests__/use-chat-input-remount.test.tsx +0 -66
  62. package/src/hooks/__tests__/use-clipboard.test.tsx +0 -73
  63. package/src/hooks/__tests__/use-connection-status.test.ts +0 -112
  64. package/src/hooks/__tests__/use-directory-browser.test.ts +0 -203
  65. package/src/hooks/__tests__/use-gravity-ad.test.ts +0 -73
  66. package/src/hooks/__tests__/use-grid-layout.test.ts +0 -349
  67. package/src/hooks/__tests__/use-input-history.test.ts +0 -699
  68. package/src/hooks/__tests__/use-message-queue-editing.test.tsx +0 -209
  69. package/src/hooks/__tests__/use-message-queue.test.tsx +0 -71
  70. package/src/hooks/__tests__/use-path-tab-completion.test.ts +0 -315
  71. package/src/hooks/__tests__/use-queue-controls.test.ts +0 -68
  72. package/src/hooks/__tests__/use-queue-ui.test.tsx +0 -83
  73. package/src/hooks/__tests__/use-searchable-list.test.ts +0 -359
  74. package/src/hooks/__tests__/use-send-message-timer.test.ts +0 -146
  75. package/src/hooks/__tests__/use-suggestion-engine-mention.test.ts +0 -361
  76. package/src/hooks/__tests__/use-suggestion-engine.test.ts +0 -485
  77. package/src/hooks/__tests__/use-terminal-focus.test.ts +0 -66
  78. package/src/hooks/__tests__/use-terminal-layout.test.ts +0 -675
  79. package/src/hooks/__tests__/use-timeout.test.ts +0 -330
  80. package/src/hooks/__tests__/use-usage-query.test.ts +0 -502
  81. package/src/hooks/__tests__/use-user-details-query.test.ts +0 -195
  82. package/src/hooks/helpers/__tests__/send-message.test.ts +0 -1918
  83. package/src/init/__tests__/init-direnv.test.ts +0 -526
  84. package/src/state/__tests__/chat-store-focus.test.ts +0 -22
  85. package/src/state/__tests__/feedback-store.test.ts +0 -257
  86. package/src/utils/__tests__/active-run.test.ts +0 -140
  87. package/src/utils/__tests__/activity-tracker.test.ts +0 -440
  88. package/src/utils/__tests__/agent-display.test.ts +0 -139
  89. package/src/utils/__tests__/analytics-client.test.ts +0 -262
  90. package/src/utils/__tests__/anonymous-id.test.ts +0 -74
  91. package/src/utils/__tests__/anvil-api.test.ts +0 -578
  92. package/src/utils/__tests__/anvil-instance-owner.test.ts +0 -69
  93. package/src/utils/__tests__/anvil-model-navigation.test.ts +0 -102
  94. package/src/utils/__tests__/anvil-premium-reset.test.ts +0 -79
  95. package/src/utils/__tests__/anvil-referral-cache.test.ts +0 -116
  96. package/src/utils/__tests__/anvil-session-api.test.ts +0 -215
  97. package/src/utils/__tests__/anvil-session-display.test.ts +0 -23
  98. package/src/utils/__tests__/anvil-streak-line.test.ts +0 -217
  99. package/src/utils/__tests__/arrays.test.ts +0 -264
  100. package/src/utils/__tests__/bash-context-processor.test.ts +0 -38
  101. package/src/utils/__tests__/block-processor.test.ts +0 -810
  102. package/src/utils/__tests__/chat-history.test.ts +0 -203
  103. package/src/utils/__tests__/chat-input-key-intercept.test.ts +0 -40
  104. package/src/utils/__tests__/chat-meta.test.ts +0 -130
  105. package/src/utils/__tests__/clipboard-linux.test.ts +0 -359
  106. package/src/utils/__tests__/clipboard.test.ts +0 -910
  107. package/src/utils/__tests__/code-search-summary.test.ts +0 -84
  108. package/src/utils/__tests__/collapse-helpers.test.ts +0 -1109
  109. package/src/utils/__tests__/error-handling.test.ts +0 -658
  110. package/src/utils/__tests__/exit-cleanly.test.ts +0 -110
  111. package/src/utils/__tests__/feedback-helpers.test.ts +0 -444
  112. package/src/utils/__tests__/feedback-submission.test.ts +0 -26
  113. package/src/utils/__tests__/fetch-usage.test.ts +0 -355
  114. package/src/utils/__tests__/fingerprint.test.ts +0 -144
  115. package/src/utils/__tests__/fixtures/terminal-command-broker-child.ts +0 -7
  116. package/src/utils/__tests__/fixtures/terminal-command-broker-entry.ts +0 -3
  117. package/src/utils/__tests__/fixtures/terminal-command-broker-owner.ts +0 -33
  118. package/src/utils/__tests__/format-elapsed-time.test.ts +0 -103
  119. package/src/utils/__tests__/format-timeout.test.ts +0 -87
  120. package/src/utils/__tests__/image-dimensions.test.ts +0 -249
  121. package/src/utils/__tests__/image-processor.test.ts +0 -209
  122. package/src/utils/__tests__/implementor-helpers.test.ts +0 -1458
  123. package/src/utils/__tests__/keyboard-actions.test.ts +0 -660
  124. package/src/utils/__tests__/layout-helpers.test.ts +0 -36
  125. package/src/utils/__tests__/lazy-response-ads.test.ts +0 -167
  126. package/src/utils/__tests__/log-shipper.test.ts +0 -53
  127. package/src/utils/__tests__/markdown-renderer.test.tsx +0 -421
  128. package/src/utils/__tests__/message-block-helpers.test.ts +0 -1263
  129. package/src/utils/__tests__/message-updater.test.ts +0 -645
  130. package/src/utils/__tests__/osc-timeout-scenarios.test.ts +0 -172
  131. package/src/utils/__tests__/pending-attachments.test.ts +0 -277
  132. package/src/utils/__tests__/polling-backoff.test.ts +0 -51
  133. package/src/utils/__tests__/queue-panel-actions.test.ts +0 -148
  134. package/src/utils/__tests__/run-state-storage.test.ts +0 -919
  135. package/src/utils/__tests__/safe-json.test.ts +0 -77
  136. package/src/utils/__tests__/sdk-event-handlers.test.ts +0 -685
  137. package/src/utils/__tests__/send-message-helpers.test.ts +0 -1898
  138. package/src/utils/__tests__/send-message-timer.test.ts +0 -64
  139. package/src/utils/__tests__/settings.test.ts +0 -99
  140. package/src/utils/__tests__/strings.test.ts +0 -192
  141. package/src/utils/__tests__/terminal-color-detection.test.ts +0 -425
  142. package/src/utils/__tests__/terminal-command-broker.test.ts +0 -528
  143. package/src/utils/__tests__/terminal-enter-detection.test.ts +0 -77
  144. package/src/utils/__tests__/terminal-io.test.ts +0 -137
  145. package/src/utils/__tests__/terminal-protocol-controller.test.ts +0 -119
  146. package/src/utils/__tests__/text-layout.test.ts +0 -82
  147. package/src/utils/__tests__/theme-platform-detection.test.ts +0 -125
  148. package/src/utils/__tests__/think-tag-parser.test.ts +0 -159
  149. package/src/utils/__tests__/trace-writer.test.ts +0 -223
  150. package/src/utils/__tests__/trim-chat-logs.test.ts +0 -78
  151. package/src/utils/__tests__/usage-banner-state.test.ts +0 -298
  152. package/src/utils/__tests__/validation-error-formatting.test.ts +0 -126
  153. package/src/utils/__tests__/windows-terminal-health.test.ts +0 -101
  154. package/src/utils/__tests__/write-file-atomic.test.ts +0 -127
  155. package/vendor/@anvil/common/src/__tests__/agent-validation.test.ts +0 -846
  156. package/vendor/@anvil/common/src/__tests__/anvil-model-availability.test.ts +0 -101
  157. package/vendor/@anvil/common/src/__tests__/anvil-models.test.ts +0 -1408
  158. package/vendor/@anvil/common/src/__tests__/anvil-public-data-use-copy.test.ts +0 -258
  159. package/vendor/@anvil/common/src/__tests__/anvil-referral-tiers.test.ts +0 -48
  160. package/vendor/@anvil/common/src/__tests__/anvil-spend-ceilings.test.ts +0 -282
  161. package/vendor/@anvil/common/src/__tests__/anvil-trust.test.ts +0 -526
  162. package/vendor/@anvil/common/src/__tests__/deepseek-direct.test.ts +0 -68
  163. package/vendor/@anvil/common/src/__tests__/disposable-email.test.ts +0 -132
  164. package/vendor/@anvil/common/src/__tests__/dynamic-agent-template-schema.test.ts +0 -422
  165. package/vendor/@anvil/common/src/__tests__/env-ci.test.ts +0 -167
  166. package/vendor/@anvil/common/src/__tests__/env-process.test.ts +0 -145
  167. package/vendor/@anvil/common/src/__tests__/foreign-client-shipped-agents.test.ts +0 -234
  168. package/vendor/@anvil/common/src/__tests__/foreign-client-signals.test.ts +0 -379
  169. package/vendor/@anvil/common/src/__tests__/free-agents.test.ts +0 -807
  170. package/vendor/@anvil/common/src/__tests__/gravity-capi.test.ts +0 -154
  171. package/vendor/@anvil/common/src/__tests__/handlesteps-parsing.test.ts +0 -246
  172. package/vendor/@anvil/common/src/__tests__/kimi-k3-god-only.test.ts +0 -77
  173. package/vendor/@anvil/common/src/__tests__/model-config.test.ts +0 -89
  174. package/vendor/@anvil/common/src/__tests__/project-file-tree.test.ts +0 -298
  175. package/vendor/@anvil/common/src/__tests__/provisioned-model-tiers.test.ts +0 -116
  176. package/vendor/@anvil/common/src/__tests__/reasoning-effort.test.ts +0 -167
  177. package/vendor/@anvil/common/src/__tests__/reddit-capi.test.ts +0 -132
  178. package/vendor/@anvil/common/src/__tests__/response-ad-positions.test.ts +0 -72
  179. package/vendor/@anvil/common/src/__tests__/user-state.test.ts +0 -30
  180. package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding-gate.test.ts +0 -63
  181. package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding.test.ts +0 -246
  182. package/vendor/@anvil/common/src/constants/__tests__/cf-worker-signals.test.ts +0 -106
  183. package/vendor/@anvil/common/src/testing/TESTING_PATTERNS.md +0 -351
  184. package/vendor/@anvil/common/src/testing/anvil-offer-invariants.ts +0 -169
  185. package/vendor/@anvil/common/src/testing/errors.ts +0 -33
  186. package/vendor/@anvil/common/src/testing/fixtures/agent-runtime.ts +0 -334
  187. package/vendor/@anvil/common/src/testing/impl/agent-runtime.ts +0 -6
  188. package/vendor/@anvil/common/src/testing/index.ts +0 -84
  189. package/vendor/@anvil/common/src/testing/mock-modules.ts +0 -53
  190. package/vendor/@anvil/common/src/testing/mock-types.ts +0 -123
  191. package/vendor/@anvil/common/src/testing/mocks/analytics.ts +0 -261
  192. package/vendor/@anvil/common/src/testing/mocks/child-process.ts +0 -93
  193. package/vendor/@anvil/common/src/testing/mocks/crypto.ts +0 -218
  194. package/vendor/@anvil/common/src/testing/mocks/database.ts +0 -337
  195. package/vendor/@anvil/common/src/testing/mocks/fetch.ts +0 -219
  196. package/vendor/@anvil/common/src/testing/mocks/filesystem.ts +0 -166
  197. package/vendor/@anvil/common/src/testing/mocks/index.ts +0 -101
  198. package/vendor/@anvil/common/src/testing/mocks/logger.ts +0 -135
  199. package/vendor/@anvil/common/src/testing/mocks/stream.ts +0 -313
  200. package/vendor/@anvil/common/src/testing/mocks/timers.ts +0 -132
  201. package/vendor/@anvil/common/src/testing/mocks/tree-sitter.ts +0 -127
  202. package/vendor/@anvil/common/src/testing/setup.ts +0 -282
  203. package/vendor/@anvil/common/src/tools/__tests__/compile-tool-definitions.test.ts +0 -34
  204. package/vendor/@anvil/common/src/tools/params/__tests__/coerce-to-array.test.ts +0 -213
  205. package/vendor/@anvil/common/src/tools/params/__tests__/read-docs.test.ts +0 -47
  206. package/vendor/@anvil/common/src/tools/params/__tests__/render-ui.test.ts +0 -65
  207. package/vendor/@anvil/common/src/tools/params/tool/__tests__/run-terminal-command-timeout.test.ts +0 -49
  208. package/vendor/@anvil/common/src/types/__tests__/dynamic-agent-template.test.ts +0 -20
  209. package/vendor/@anvil/common/src/util/__tests__/ad-user-agent.test.ts +0 -26
  210. package/vendor/@anvil/common/src/util/__tests__/analytics-dispatcher.test.ts +0 -122
  211. package/vendor/@anvil/common/src/util/__tests__/analytics-log.test.ts +0 -102
  212. package/vendor/@anvil/common/src/util/__tests__/analytics-sampling.test.ts +0 -143
  213. package/vendor/@anvil/common/src/util/__tests__/anvil-streak.test.ts +0 -202
  214. package/vendor/@anvil/common/src/util/__tests__/anvil-usage-summary.test.ts +0 -193
  215. package/vendor/@anvil/common/src/util/__tests__/axiom-only-log.test.ts +0 -140
  216. package/vendor/@anvil/common/src/util/__tests__/client-user-agent.test.ts +0 -148
  217. package/vendor/@anvil/common/src/util/__tests__/engagement-tracker.test.ts +0 -115
  218. package/vendor/@anvil/common/src/util/__tests__/env-file-path.test.ts +0 -57
  219. package/vendor/@anvil/common/src/util/__tests__/error-abort.test.ts +0 -774
  220. package/vendor/@anvil/common/src/util/__tests__/error-api-details.test.ts +0 -206
  221. package/vendor/@anvil/common/src/util/__tests__/file-read-limits.test.ts +0 -173
  222. package/vendor/@anvil/common/src/util/__tests__/format-code-search.test.ts +0 -60
  223. package/vendor/@anvil/common/src/util/__tests__/log-mirror.test.ts +0 -31
  224. package/vendor/@anvil/common/src/util/__tests__/messages.test.ts +0 -1252
  225. package/vendor/@anvil/common/src/util/__tests__/partial-json-delta.test.ts +0 -505
  226. package/vendor/@anvil/common/src/util/__tests__/path.test.ts +0 -22
  227. package/vendor/@anvil/common/src/util/__tests__/project-ignore.test.ts +0 -90
  228. package/vendor/@anvil/common/src/util/__tests__/promise.test.ts +0 -325
  229. package/vendor/@anvil/common/src/util/__tests__/rate-limit.test.ts +0 -28
  230. package/vendor/@anvil/common/src/util/__tests__/reddit-anvil-retention.test.ts +0 -130
  231. package/vendor/@anvil/common/src/util/__tests__/saxy.test.ts +0 -1008
  232. package/vendor/@anvil/common/src/util/__tests__/split-data.test.ts +0 -289
  233. package/vendor/@anvil/common/src/util/__tests__/string.test.ts +0 -239
  234. package/vendor/@anvil/common/src/util/__tests__/thread-title.test.ts +0 -70
  235. package/vendor/@anvil/common/src/util/__tests__/tool-result-media-order.test.ts +0 -108
  236. package/vendor/@anvil/common/src/util/__tests__/ttft-histogram.test.ts +0 -180
  237. package/vendor/@anvil/common/src/util/__tests__/with-timeout.test.ts +0 -24
  238. package/vendor/@anvil/common/src/util/__tests__/zoned-time.test.ts +0 -88
  239. package/vendor/@anvil/common/src/util/skills.test.ts +0 -44
  240. package/vendor/@anvil/sdk/dist/index.cjs.map +0 -440
  241. package/vendor/@anvil/sdk/dist/index.mjs.map +0 -440
@@ -1,298 +0,0 @@
1
- import os from 'os'
2
- import path from 'path'
3
-
4
- import { describe, expect, it } from 'bun:test'
5
-
6
- import {
7
- flattenTree,
8
- getAllPathsWithDirectories,
9
- getProjectFileTree,
10
- isFileIgnored,
11
- } from '../project-file-tree'
12
- import { createMockFs } from '../testing/mocks/filesystem'
13
-
14
- /**
15
- * Builds a mock fs from relative file paths under `root`, inferring
16
- * intermediate directories.
17
- */
18
- function createFsWithFiles(root: string, files: string[]) {
19
- const fileRecords: Record<string, string> = {}
20
- const dirChildren: Record<string, Set<string>> = { [root]: new Set() }
21
- for (const file of files) {
22
- fileRecords[path.join(root, file)] = ''
23
- let child = path.join(root, file)
24
- let dir = path.dirname(child)
25
- while (true) {
26
- ;(dirChildren[dir] ??= new Set()).add(path.basename(child))
27
- if (dir === root) break
28
- child = dir
29
- dir = path.dirname(dir)
30
- }
31
- }
32
- return createMockFs({
33
- files: fileRecords,
34
- directories: Object.fromEntries(
35
- Object.entries(dirChildren).map(([dir, names]) => [dir, [...names]]),
36
- ),
37
- })
38
- }
39
-
40
- describe('getProjectFileTree', () => {
41
- it('scans the home directory shallowly instead of returning nothing', async () => {
42
- const home = os.homedir()
43
- const fs = createFsWithFiles(home, [
44
- 'top-level.txt',
45
- 'proj/README.md',
46
- 'proj/docs/guide.md',
47
- 'proj/docs/deep/too-deep.md',
48
- '.hidden/secret.txt',
49
- ])
50
-
51
- const tree = await getProjectFileTree({ projectRoot: home, fs })
52
- const paths = getAllPathsWithDirectories(tree).map((p) => p.path)
53
-
54
- // Files up to 3 levels deep are included
55
- expect(paths).toContain('top-level.txt')
56
- expect(paths).toContain(path.join('proj', 'README.md'))
57
- expect(paths).toContain(path.join('proj', 'docs', 'guide.md'))
58
- // The depth-3 directory shows up as a node, but its contents do not
59
- expect(paths).toContain(path.join('proj', 'docs', 'deep'))
60
- expect(paths).not.toContain(
61
- path.join('proj', 'docs', 'deep', 'too-deep.md'),
62
- )
63
- // Dotfiles are still excluded
64
- expect(paths.some((p) => p.includes('.hidden'))).toBe(false)
65
- })
66
-
67
- it('scans regular project roots without a depth limit', async () => {
68
- const root = '/repo'
69
- const fs = createFsWithFiles(root, ['a/b/c/d/e.txt'])
70
-
71
- const tree = await getProjectFileTree({ projectRoot: root, fs })
72
- const paths = getAllPathsWithDirectories(tree).map((p) => p.path)
73
-
74
- expect(paths).toContain(path.join('a', 'b', 'c', 'd', 'e.txt'))
75
- })
76
-
77
- it('records file paths with forward slashes', async () => {
78
- // `ignore` and the glob patterns the model writes are both POSIX-only, and
79
- // `ignore` answers false for a backslash path rather than throwing. Storing
80
- // anything but forward slashes here makes nested rules stop pruning on
81
- // Windows, which is how build output ends up eating the maxFiles budget.
82
- const root = '/repo'
83
- const fs = createFsWithFiles(root, ['app/src/main/Inventory.kt'])
84
-
85
- const tree = await getProjectFileTree({ projectRoot: root, fs })
86
-
87
- const filePaths = flattenTree(tree).map((node) => node.filePath)
88
- expect(filePaths).toEqual(['app/src/main/Inventory.kt'])
89
- })
90
-
91
- it('prunes directories ignored by a rule in a nested .gitignore', async () => {
92
- const root = '/repo'
93
- const fs = createFsWithFiles(root, [
94
- 'app/.gitignore',
95
- 'app/build/output.class',
96
- 'app/src/Inventory.kt',
97
- ])
98
- ;(fs.readFile as any).mockImplementation(async (filePath: string) =>
99
- String(filePath).endsWith('.gitignore') ? 'build/\n' : '',
100
- )
101
-
102
- const tree = await getProjectFileTree({ projectRoot: root, fs })
103
-
104
- const filePaths = flattenTree(tree).map((node) => node.filePath)
105
- expect(filePaths).toContain('app/src/Inventory.kt')
106
- expect(filePaths).not.toContain('app/build/output.class')
107
- })
108
-
109
- it('keeps nested rules scoped to their own directory even when its name contains glob syntax', async () => {
110
- const root = '/repo'
111
- const fs = createFsWithFiles(root, [
112
- '[4K- HDR]/.gitignore',
113
- '[4K- HDR]/x/logs',
114
- '[4K- HDR]/keep.ts',
115
- 'a/x/logs',
116
- ])
117
- ;(fs.readFile as any).mockImplementation(async (filePath: string) =>
118
- String(filePath).endsWith('.gitignore') ? 'logs\n' : '',
119
- )
120
-
121
- const filePaths = flattenTree(
122
- await getProjectFileTree({ projectRoot: root, fs }),
123
- ).map((node) => node.filePath)
124
-
125
- expect(filePaths).toContain('[4K- HDR]/keep.ts')
126
- expect(filePaths).not.toContain('[4K- HDR]/x/logs')
127
- expect(filePaths).toContain('a/x/logs')
128
- })
129
-
130
- it('keeps anchored rules in a nested .gitignore anchored to that directory', async () => {
131
- const root = '/repo'
132
- const fs = createFsWithFiles(root, [
133
- 'pkg/.gitignore',
134
- 'pkg/dist/a.js',
135
- 'pkg/sub/dist/b.js',
136
- ])
137
- ;(fs.readFile as any).mockImplementation(async (filePath: string) =>
138
- String(filePath) === path.join(root, 'pkg', '.gitignore')
139
- ? '/dist\n'
140
- : '',
141
- )
142
-
143
- const filePaths = flattenTree(
144
- await getProjectFileTree({ projectRoot: root, fs }),
145
- ).map((node) => node.filePath)
146
-
147
- expect(filePaths).not.toContain('pkg/dist/a.js')
148
- expect(filePaths).toContain('pkg/sub/dist/b.js')
149
- })
150
-
151
- it('does not let a nested negation re-include a file under a directory excluded by an ancestor', async () => {
152
- const root = '/repo'
153
- const fs = createFsWithFiles(root, [
154
- '.gitignore',
155
- 'pkg/.gitignore',
156
- 'pkg/dist/index.css',
157
- 'pkg/src/a.ts',
158
- ])
159
- ;(fs.readFile as any).mockImplementation(async (filePath: string) => {
160
- const p = String(filePath)
161
- if (p === path.join(root, '.gitignore')) return 'dist/\n'
162
- if (p === path.join(root, 'pkg', '.gitignore'))
163
- return '!dist/index.css\n'
164
- return ''
165
- })
166
-
167
- const filePaths = flattenTree(
168
- await getProjectFileTree({ projectRoot: root, fs }),
169
- ).map((node) => node.filePath)
170
-
171
- expect(filePaths).toContain('pkg/src/a.ts')
172
- expect(filePaths).not.toContain('pkg/dist/index.css')
173
- })
174
-
175
- it('skips ignore rules that cannot be compiled without dropping the rest of the file', async () => {
176
- const root = '/repo'
177
- const fs = createFsWithFiles(root, [
178
- '.gitignore',
179
- 'build/out.js',
180
- 'src/main.ts',
181
- ])
182
- ;(fs.readFile as any).mockImplementation(async (filePath: string) =>
183
- String(filePath).endsWith('.gitignore') ? '[~-a]\nbuild/\n' : '',
184
- )
185
-
186
- const filePaths = flattenTree(
187
- await getProjectFileTree({ projectRoot: root, fs }),
188
- ).map((node) => node.filePath)
189
-
190
- expect(filePaths).toContain('src/main.ts')
191
- expect(filePaths).not.toContain('build/out.js')
192
- })
193
- })
194
-
195
- describe('isFileIgnored', () => {
196
- it('can exempt env templates from defaults while preserving project rules', async () => {
197
- const root = '/repo'
198
- const withoutProjectRule = createFsWithFiles(root, ['.env.example'])
199
-
200
- expect(
201
- await isFileIgnored({
202
- filePath: '.env.example',
203
- projectRoot: root,
204
- fs: withoutProjectRule,
205
- }),
206
- ).toBe(true)
207
- expect(
208
- await isFileIgnored({
209
- filePath: '.env.example',
210
- projectRoot: root,
211
- fs: withoutProjectRule,
212
- allowEnvTemplate: true,
213
- }),
214
- ).toBe(false)
215
- expect(
216
- await isFileIgnored({
217
- filePath: '.env.local',
218
- projectRoot: root,
219
- fs: withoutProjectRule,
220
- allowEnvTemplate: true,
221
- }),
222
- ).toBe(true)
223
-
224
- const withProjectRule = createFsWithFiles(root, [
225
- '.gitignore',
226
- '.env.example',
227
- ])
228
- ;(withProjectRule.readFile as any).mockImplementation(
229
- async (filePath: string) =>
230
- String(filePath) === path.join(root, '.gitignore')
231
- ? '.env.example\n'
232
- : '',
233
- )
234
-
235
- expect(
236
- await isFileIgnored({
237
- filePath: '.env.example',
238
- projectRoot: root,
239
- fs: withProjectRule,
240
- allowEnvTemplate: true,
241
- }),
242
- ).toBe(true)
243
- })
244
-
245
- it('fails closed when an env template project rule is unreadable', async () => {
246
- const root = '/repo'
247
- const fs = createFsWithFiles(root, ['.gitignore', '.env.example'])
248
- ;(fs.readFile as any).mockImplementation(async (filePath: string) => {
249
- if (String(filePath) === path.join(root, '.gitignore')) {
250
- const error = new Error('permission denied') as Error & {
251
- code: string
252
- }
253
- error.code = 'EACCES'
254
- throw error
255
- }
256
- return 'API_KEY=example'
257
- })
258
-
259
- expect(
260
- await isFileIgnored({
261
- filePath: '.env.example',
262
- projectRoot: root,
263
- fs,
264
- allowEnvTemplate: true,
265
- }),
266
- ).toBe(true)
267
- })
268
-
269
- it('reads ignore rules at the filesystem root without looping', async () => {
270
- const root = path.parse(process.cwd()).root
271
- const fs = createMockFs({
272
- files: { [path.join(root, '.gitignore')]: 'readme.txt\n' },
273
- })
274
-
275
- expect(
276
- await isFileIgnored({ filePath: 'readme.txt', projectRoot: root, fs }),
277
- ).toBe(true)
278
- })
279
-
280
- it('keeps default-ignored directories excluded despite a root negation', async () => {
281
- const root = '/repo'
282
- const fs = createFsWithFiles(root, [
283
- '.gitignore',
284
- 'node_modules/pkg/README.md',
285
- ])
286
- ;(fs.readFile as any).mockImplementation(async (filePath: string) =>
287
- String(filePath) === path.join(root, '.gitignore') ? '!*.md\n' : '',
288
- )
289
-
290
- expect(
291
- await isFileIgnored({
292
- filePath: 'node_modules/pkg/README.md',
293
- projectRoot: root,
294
- fs,
295
- }),
296
- ).toBe(true)
297
- })
298
- })
@@ -1,116 +0,0 @@
1
- /**
2
- * The provisioned `-max` tiers.
3
- *
4
- * These are granted per account rather than picked, so the invariant is the
5
- * opposite of a normal model's: every catalog must NOT contain them. A client
6
- * that rendered one would offer a row most accounts cannot run, and the
7
- * request would fail at admission rather than at the picker — the confusing
8
- * shape a hidden tier always takes when it leaks into a selectable list.
9
- *
10
- * Each tier is pinned to exactly one root, like every other free-mode model,
11
- * and each root is pinned to exactly that tier: a root that also accepted the
12
- * base model would be a second, unmetered door onto it — which is what the
13
- * retired `base2-free-glm-crof` route turned out to be.
14
- */
15
- import { describe, expect, test } from 'bun:test'
16
-
17
- import {
18
- FREE_MODE_AGENT_MODELS,
19
- ANVIL_CLI_BASE3_AGENT_ID_BY_MODEL,
20
- ANVIL_ROOT_AGENT_IDS,
21
- ANVIL_WEB_BASE3_AGENT_ID_BY_MODEL,
22
- isFreeModeAllowedAgentModel,
23
- } from '../constants/free-agents'
24
- import {
25
- ANVIL_DEEPSEEK_V4_FLASH_MAX_MODEL_ID,
26
- ANVIL_DEEPSEEK_V4_FLASH_MODEL_ID,
27
- ANVIL_DEEPSEEK_V4_PRO_MAX_MODEL_ID,
28
- ANVIL_DEEPSEEK_V4_PRO_MODEL_ID,
29
- ANVIL_GPT_5_6_LUNA_MAX_MODEL_ID,
30
- ANVIL_GPT_5_6_LUNA_MODEL_ID,
31
- ANVIL_MODELS,
32
- ANVIL_PROVISIONED_MODELS,
33
- ANVIL_WEB_ALL_MODELS,
34
- ANVIL_WEB_MODELS,
35
- ANVIL_WEB_PREMIUM_MODEL_IDS,
36
- ANVIL_WEB_STANDARD_MODEL_IDS,
37
- SUPPORTED_ANVIL_MODELS,
38
- resolveSupportedAnvilModel,
39
- } from '../constants/anvil-models'
40
-
41
- /** tier -> the root that runs it, and the base model it extends. */
42
- const TIERS: Array<{ id: string; root: string; base: string }> = [
43
- {
44
- id: ANVIL_DEEPSEEK_V4_PRO_MAX_MODEL_ID,
45
- root: 'base2-free-deepseek-pro-max',
46
- base: ANVIL_DEEPSEEK_V4_PRO_MODEL_ID,
47
- },
48
- {
49
- id: ANVIL_DEEPSEEK_V4_FLASH_MAX_MODEL_ID,
50
- root: 'base2-free-deepseek-flash-max',
51
- base: ANVIL_DEEPSEEK_V4_FLASH_MODEL_ID,
52
- },
53
- {
54
- id: ANVIL_GPT_5_6_LUNA_MAX_MODEL_ID,
55
- root: 'base2-free-luna-max',
56
- base: ANVIL_GPT_5_6_LUNA_MODEL_ID,
57
- },
58
- ]
59
-
60
- describe('provisioned tiers are never offered from a catalog', () => {
61
- test('the tier list is not empty', () => {
62
- // Floor: an empty list makes every case below vacuous.
63
- expect(ANVIL_PROVISIONED_MODELS.length).toBe(TIERS.length)
64
- })
65
-
66
- const catalogs: Array<[string, readonly string[]]> = [
67
- ['SUPPORTED_ANVIL_MODELS', SUPPORTED_ANVIL_MODELS.map((m) => m.id)],
68
- ['ANVIL_MODELS', ANVIL_MODELS.map((m) => m.id)],
69
- ['ANVIL_WEB_MODELS', ANVIL_WEB_MODELS.map((m) => m.id)],
70
- ['ANVIL_WEB_ALL_MODELS', ANVIL_WEB_ALL_MODELS.map((m) => m.id)],
71
- ['ANVIL_WEB_PREMIUM_MODEL_IDS', [...ANVIL_WEB_PREMIUM_MODEL_IDS]],
72
- ['ANVIL_WEB_STANDARD_MODEL_IDS', [...ANVIL_WEB_STANDARD_MODEL_IDS]],
73
- ]
74
-
75
- test.each(catalogs)('%s omits every provisioned tier', (_name, ids) => {
76
- for (const tier of TIERS) expect(ids).not.toContain(tier.id)
77
- })
78
-
79
- test('a saved preference for a tier falls back to a pickable model', () => {
80
- for (const tier of TIERS) {
81
- expect(resolveSupportedAnvilModel(tier.id)).not.toBe(tier.id)
82
- }
83
- })
84
-
85
- test('no base3 root map resolves a provisioned tier', () => {
86
- for (const tier of TIERS) {
87
- expect(ANVIL_WEB_BASE3_AGENT_ID_BY_MODEL[tier.id]).toBeUndefined()
88
- expect(ANVIL_CLI_BASE3_AGENT_ID_BY_MODEL[tier.id]).toBeUndefined()
89
- }
90
- })
91
- })
92
-
93
- describe('each tier is pinned to exactly one root', () => {
94
- test.each(TIERS)('$id runs on $root and nothing else', (tier) => {
95
- expect(FREE_MODE_AGENT_MODELS[tier.root]?.has(tier.id)).toBe(true)
96
- expect(isFreeModeAllowedAgentModel(tier.root, tier.id)).toBe(true)
97
- })
98
-
99
- test.each(TIERS)('$root cannot run the base model $base', (tier) => {
100
- // A second, unmetered door onto the base model otherwise.
101
- expect(isFreeModeAllowedAgentModel(tier.root, tier.base)).toBe(false)
102
- })
103
-
104
- test.each(TIERS)('$root is a registered root agent', (tier) => {
105
- // A root absent from this list is treated as a subagent, so a top-level
106
- // request on it fails the hierarchy check instead of running.
107
- expect(ANVIL_ROOT_AGENT_IDS).toContain(tier.root)
108
- })
109
-
110
- test.each(TIERS)('the base model does not run on $root', (tier) => {
111
- const rootForBase = Object.entries(FREE_MODE_AGENT_MODELS).filter(
112
- ([agentId, models]) => models.has(tier.base) && agentId === tier.root,
113
- )
114
- expect(rootForBase).toEqual([])
115
- })
116
- })
@@ -1,167 +0,0 @@
1
- import { describe, expect, test } from 'bun:test'
2
-
3
- import type { AnvilModelOption } from '../constants/anvil-models'
4
- import {
5
- clampReasoningEffort,
6
- reasoningEffortRank,
7
- REASONING_EFFORTS,
8
- type ReasoningEffort,
9
- } from '../constants/reasoning-effort'
10
- import {
11
- EFFORTS_THROUGH_HIGH,
12
- EFFORTS_THROUGH_MAX,
13
- EFFORTS_THROUGH_XHIGH,
14
- ANVIL_DEEPSEEK_V4_FLASH_MODEL_ID,
15
- ANVIL_DEEPSEEK_V4_PRO_MODEL_ID,
16
- ANVIL_FABLE_5_MODEL_ID,
17
- ANVIL_GLM_V52_MODEL_ID,
18
- ANVIL_GPT_5_6_LUNA_MODEL_ID,
19
- ANVIL_KIMI_K3_ECO_MODEL_ID,
20
- ANVIL_MIMO_V25_MODEL_ID,
21
- ANVIL_MINIMAX_M3_MODEL_ID,
22
- ANVIL_MUSE_SPARK_12_CONTRIBUTOR_MODEL_ID,
23
- ANVIL_WEB_ALL_MODELS,
24
- getAnvilModelDefaultEffort,
25
- getAnvilModelEfforts,
26
- getAnvilModelReasoningEffort,
27
- resolveAnvilReasoningEffort,
28
- SUPPORTED_ANVIL_MODELS,
29
- } from '../constants/anvil-models'
30
-
31
- describe('the shared effort ladder', () => {
32
- test('is ordered ascending, because the clamp does index arithmetic on it', () => {
33
- // clampReasoningEffort answers "the most this model allows, but no more
34
- // than was asked". That is only meaningful if position implies magnitude,
35
- // so a reorder here would silently invert every clamp in the product.
36
- expect(REASONING_EFFORTS).toEqual([
37
- 'minimal',
38
- 'low',
39
- 'medium',
40
- 'high',
41
- 'xhigh',
42
- 'max',
43
- 'ultra',
44
- ])
45
- expect(reasoningEffortRank('low')).toBeLessThan(reasoningEffortRank('high'))
46
- expect(reasoningEffortRank('high')).toBeLessThan(
47
- reasoningEffortRank('xhigh'),
48
- )
49
- })
50
-
51
- test('clamps DOWN to the ceiling rather than falling back to a default', () => {
52
- // The distinction that matters on a reroute: a user on xhigh whose request
53
- // lands on a model topping out at high should get high — the closest thing
54
- // to what they chose — not that model's default, which could be lower.
55
- expect(clampReasoningEffort('xhigh', EFFORTS_THROUGH_HIGH, 'low')).toBe(
56
- 'high',
57
- )
58
- expect(clampReasoningEffort('ultra', EFFORTS_THROUGH_XHIGH, 'low')).toBe(
59
- 'xhigh',
60
- )
61
- // Exactly on a rung is that rung.
62
- expect(clampReasoningEffort('medium', EFFORTS_THROUGH_HIGH, 'high')).toBe(
63
- 'medium',
64
- )
65
- // Nothing recognizable asked for: the caller's fallback, not a guess.
66
- expect(clampReasoningEffort(undefined, EFFORTS_THROUGH_HIGH, 'high')).toBe(
67
- 'high',
68
- )
69
- expect(clampReasoningEffort('bogus', EFFORTS_THROUGH_HIGH, 'high')).toBe(
70
- 'high',
71
- )
72
- // Below everything on offer: the least of them, never nothing.
73
- expect(clampReasoningEffort('low', ['high', 'xhigh'], 'xhigh')).toBe('high')
74
- })
75
- })
76
-
77
- // `as const satisfies AnvilModelOption` gives each row a narrow literal
78
- // type, so the union has no `efforts` property at all unless every member
79
- // declares one. Widening once here keeps the invariants readable.
80
- const ALL_ROWS: readonly AnvilModelOption[] = [
81
- ...SUPPORTED_ANVIL_MODELS,
82
- ...ANVIL_WEB_ALL_MODELS,
83
- ]
84
-
85
- describe('per-model effort ladders', () => {
86
- test('every ladder contains its default', () => {
87
- for (const model of ALL_ROWS) {
88
- if (!model.efforts?.length) continue
89
- const dflt = getAnvilModelDefaultEffort(model.id)!
90
- expect({
91
- id: model.id,
92
- containsDefault: model.efforts.includes(dflt),
93
- }).toEqual({ id: model.id, containsDefault: true })
94
- }
95
- })
96
-
97
- test('every ladder rung is a rung of the shared vocabulary', () => {
98
- for (const model of ALL_ROWS) {
99
- for (const effort of model.efforts ?? []) {
100
- expect(REASONING_EFFORTS).toContain(effort)
101
- }
102
- }
103
- })
104
-
105
- test('Muse Spark and Luna expose their complete native ladders', () => {
106
- expect(getAnvilModelEfforts(ANVIL_MUSE_SPARK_12_CONTRIBUTOR_MODEL_ID)).toEqual(
107
- EFFORTS_THROUGH_XHIGH,
108
- )
109
- expect(getAnvilModelEfforts(ANVIL_GPT_5_6_LUNA_MODEL_ID)).toEqual(
110
- EFFORTS_THROUGH_MAX,
111
- )
112
- expect(
113
- resolveAnvilReasoningEffort(ANVIL_MUSE_SPARK_12_CONTRIBUTOR_MODEL_ID, undefined),
114
- ).toBe('xhigh')
115
- expect(
116
- resolveAnvilReasoningEffort(ANVIL_GPT_5_6_LUNA_MODEL_ID, undefined),
117
- ).toBe('high')
118
- })
119
-
120
- test('Claude Fable 5 exposes every enabled effort', () => {
121
- expect(getAnvilModelEfforts(ANVIL_FABLE_5_MODEL_ID)).toEqual(
122
- EFFORTS_THROUGH_MAX,
123
- )
124
- expect(getAnvilModelDefaultEffort(ANVIL_FABLE_5_MODEL_ID)).toBe(
125
- 'high',
126
- )
127
- })
128
-
129
- test('DeepSeek exposes the three native V4 efforts on both models', () => {
130
- // One ladder since the Pro 08/13 GA build: DeepSeek documents the same
131
- // requested→actual mapping for flash and pro, and low is a real template on
132
- // both. Medium is not, on either, so it must not appear as a rung.
133
- for (const id of [
134
- ANVIL_DEEPSEEK_V4_PRO_MODEL_ID,
135
- ANVIL_DEEPSEEK_V4_FLASH_MODEL_ID,
136
- ]) {
137
- expect(getAnvilModelEfforts(id)).toEqual(['low', 'high', 'max'])
138
- expect(resolveAnvilReasoningEffort(id, undefined)).toBe('high')
139
- expect(getAnvilModelReasoningEffort(id)).toBe('high')
140
- expect(resolveAnvilReasoningEffort(id, 'medium')).toBe('high')
141
- expect(resolveAnvilReasoningEffort(id, 'max')).toBe('max')
142
- expect(resolveAnvilReasoningEffort(id, 'low')).toBe('low')
143
- }
144
- })
145
-
146
- test('binary, adaptive, and ignored controls do not masquerade as ladders', () => {
147
- for (const id of [
148
- ANVIL_MINIMAX_M3_MODEL_ID,
149
- ANVIL_MIMO_V25_MODEL_ID,
150
- ANVIL_GLM_V52_MODEL_ID,
151
- ANVIL_KIMI_K3_ECO_MODEL_ID,
152
- ]) {
153
- expect(getAnvilModelEfforts(id)).toBeNull()
154
- expect(resolveAnvilReasoningEffort(id, 'low')).toBeNull()
155
- }
156
- expect(resolveAnvilReasoningEffort('some/unknown-model', 'high')).toBeNull()
157
- })
158
-
159
- test('a dated provider snapshot resolves like the undated id', () => {
160
- expect(
161
- resolveAnvilReasoningEffort(
162
- `${ANVIL_MUSE_SPARK_12_CONTRIBUTOR_MODEL_ID}-20260901`,
163
- 'low',
164
- ),
165
- ).toBe('low')
166
- })
167
- })