@alumbwe/anvil 1.0.42 → 1.0.50

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 (238) 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/index.tsx +27 -4
  5. package/src/login/plain-login.ts +60 -0
  6. package/src/login/supabase-auth.ts +346 -0
  7. package/src/utils/anvil-client.ts +4 -0
  8. package/src/utils/auth.ts +16 -4
  9. package/src/utils/config-dir.ts +1 -1
  10. package/vendor/@anvil/common/src/constants/deepseek-direct.ts +30 -1
  11. package/vendor/@anvil/common/src/util/project-ignore.ts +4 -3
  12. package/vendor/@anvil/sdk/dist/index.cjs +46 -10
  13. package/vendor/@anvil/sdk/dist/index.mjs +46 -10
  14. package/src/commands/__tests__/anvil-command-aliases.test.ts +0 -56
  15. package/src/commands/__tests__/bash-command.test.ts +0 -445
  16. package/src/commands/__tests__/command-args.test.ts +0 -349
  17. package/src/commands/__tests__/copy-conversation-clipboard.test.ts +0 -108
  18. package/src/commands/__tests__/copy-conversation.test.ts +0 -226
  19. package/src/commands/__tests__/diagnostics-command.test.ts +0 -35
  20. package/src/commands/__tests__/image.test.ts +0 -99
  21. package/src/commands/__tests__/init.test.ts +0 -456
  22. package/src/commands/__tests__/new-command-rotates-chat.test.ts +0 -91
  23. package/src/commands/__tests__/process-diagnostics.test.ts +0 -54
  24. package/src/commands/__tests__/prompt-builders.test.ts +0 -28
  25. package/src/commands/__tests__/router-input.test.ts +0 -298
  26. package/src/components/__tests__/ad-banner.test.tsx +0 -83
  27. package/src/components/__tests__/anvil-landing-heading-row.test.tsx +0 -91
  28. package/src/components/__tests__/anvil-model-selector.test.tsx +0 -519
  29. package/src/components/__tests__/anvil-offer-invariants.test.ts +0 -54
  30. package/src/components/__tests__/anvil-takeover-prompt.test.tsx +0 -212
  31. package/src/components/__tests__/chat-input-bar.test.tsx +0 -130
  32. package/src/components/__tests__/grid-layout.integration.test.tsx +0 -304
  33. package/src/components/__tests__/grid-layout.test.tsx +0 -1051
  34. package/src/components/__tests__/message-block.completion.test.tsx +0 -104
  35. package/src/components/__tests__/message-block.streaming.test.tsx +0 -78
  36. package/src/components/__tests__/message-with-agents.test.tsx +0 -579
  37. package/src/components/__tests__/multiline-input.test.tsx +0 -1132
  38. package/src/components/__tests__/queue-panel.test.tsx +0 -398
  39. package/src/components/__tests__/selectable-list.test.ts +0 -232
  40. package/src/components/__tests__/status-bar.test.tsx +0 -44
  41. package/src/components/__tests__/status-indicator.test.tsx +0 -204
  42. package/src/components/__tests__/terminal-thinking-orb.test.tsx +0 -111
  43. package/src/components/__tests__/user-error-banner.test.tsx +0 -102
  44. package/src/components/ask-user/__tests__/multiple-choice-form.test.ts +0 -432
  45. package/src/components/ask-user/__tests__/validation.test.ts +0 -213
  46. package/src/components/tools/__tests__/apply-patch.test.tsx +0 -84
  47. package/src/components/tools/__tests__/code-search.test.tsx +0 -45
  48. package/src/components/tools/__tests__/gravity-index.test.ts +0 -76
  49. package/src/components/tools/__tests__/render-ui.test.tsx +0 -92
  50. package/src/components/tools/__tests__/run-terminal-command.test.ts +0 -233
  51. package/src/contexts/__tests__/chat-runtime-context.test.tsx +0 -149
  52. package/src/data/slash-commands.test.ts +0 -24
  53. package/src/hooks/__tests__/holds-live-anvil-slot.test.ts +0 -49
  54. package/src/hooks/__tests__/session-fetch-signal.test.ts +0 -63
  55. package/src/hooks/__tests__/use-activity-query.test.ts +0 -1000
  56. package/src/hooks/__tests__/use-ask-user-bridge.test.ts +0 -176
  57. package/src/hooks/__tests__/use-auth-query.test.ts +0 -21
  58. package/src/hooks/__tests__/use-chat-input-remount.test.tsx +0 -66
  59. package/src/hooks/__tests__/use-clipboard.test.tsx +0 -73
  60. package/src/hooks/__tests__/use-connection-status.test.ts +0 -112
  61. package/src/hooks/__tests__/use-directory-browser.test.ts +0 -203
  62. package/src/hooks/__tests__/use-gravity-ad.test.ts +0 -73
  63. package/src/hooks/__tests__/use-grid-layout.test.ts +0 -349
  64. package/src/hooks/__tests__/use-input-history.test.ts +0 -699
  65. package/src/hooks/__tests__/use-message-queue-editing.test.tsx +0 -209
  66. package/src/hooks/__tests__/use-message-queue.test.tsx +0 -71
  67. package/src/hooks/__tests__/use-path-tab-completion.test.ts +0 -315
  68. package/src/hooks/__tests__/use-queue-controls.test.ts +0 -68
  69. package/src/hooks/__tests__/use-queue-ui.test.tsx +0 -83
  70. package/src/hooks/__tests__/use-searchable-list.test.ts +0 -359
  71. package/src/hooks/__tests__/use-send-message-timer.test.ts +0 -146
  72. package/src/hooks/__tests__/use-suggestion-engine-mention.test.ts +0 -361
  73. package/src/hooks/__tests__/use-suggestion-engine.test.ts +0 -485
  74. package/src/hooks/__tests__/use-terminal-focus.test.ts +0 -66
  75. package/src/hooks/__tests__/use-terminal-layout.test.ts +0 -675
  76. package/src/hooks/__tests__/use-timeout.test.ts +0 -330
  77. package/src/hooks/__tests__/use-usage-query.test.ts +0 -502
  78. package/src/hooks/__tests__/use-user-details-query.test.ts +0 -195
  79. package/src/hooks/helpers/__tests__/send-message.test.ts +0 -1918
  80. package/src/init/__tests__/init-direnv.test.ts +0 -526
  81. package/src/state/__tests__/chat-store-focus.test.ts +0 -22
  82. package/src/state/__tests__/feedback-store.test.ts +0 -257
  83. package/src/utils/__tests__/active-run.test.ts +0 -140
  84. package/src/utils/__tests__/activity-tracker.test.ts +0 -440
  85. package/src/utils/__tests__/agent-display.test.ts +0 -139
  86. package/src/utils/__tests__/analytics-client.test.ts +0 -262
  87. package/src/utils/__tests__/anonymous-id.test.ts +0 -74
  88. package/src/utils/__tests__/anvil-api.test.ts +0 -578
  89. package/src/utils/__tests__/anvil-instance-owner.test.ts +0 -69
  90. package/src/utils/__tests__/anvil-model-navigation.test.ts +0 -102
  91. package/src/utils/__tests__/anvil-premium-reset.test.ts +0 -79
  92. package/src/utils/__tests__/anvil-referral-cache.test.ts +0 -116
  93. package/src/utils/__tests__/anvil-session-api.test.ts +0 -215
  94. package/src/utils/__tests__/anvil-session-display.test.ts +0 -23
  95. package/src/utils/__tests__/anvil-streak-line.test.ts +0 -217
  96. package/src/utils/__tests__/arrays.test.ts +0 -264
  97. package/src/utils/__tests__/bash-context-processor.test.ts +0 -38
  98. package/src/utils/__tests__/block-processor.test.ts +0 -810
  99. package/src/utils/__tests__/chat-history.test.ts +0 -203
  100. package/src/utils/__tests__/chat-input-key-intercept.test.ts +0 -40
  101. package/src/utils/__tests__/chat-meta.test.ts +0 -130
  102. package/src/utils/__tests__/clipboard-linux.test.ts +0 -359
  103. package/src/utils/__tests__/clipboard.test.ts +0 -910
  104. package/src/utils/__tests__/code-search-summary.test.ts +0 -84
  105. package/src/utils/__tests__/collapse-helpers.test.ts +0 -1109
  106. package/src/utils/__tests__/error-handling.test.ts +0 -658
  107. package/src/utils/__tests__/exit-cleanly.test.ts +0 -110
  108. package/src/utils/__tests__/feedback-helpers.test.ts +0 -444
  109. package/src/utils/__tests__/feedback-submission.test.ts +0 -26
  110. package/src/utils/__tests__/fetch-usage.test.ts +0 -355
  111. package/src/utils/__tests__/fingerprint.test.ts +0 -144
  112. package/src/utils/__tests__/fixtures/terminal-command-broker-child.ts +0 -7
  113. package/src/utils/__tests__/fixtures/terminal-command-broker-entry.ts +0 -3
  114. package/src/utils/__tests__/fixtures/terminal-command-broker-owner.ts +0 -33
  115. package/src/utils/__tests__/format-elapsed-time.test.ts +0 -103
  116. package/src/utils/__tests__/format-timeout.test.ts +0 -87
  117. package/src/utils/__tests__/image-dimensions.test.ts +0 -249
  118. package/src/utils/__tests__/image-processor.test.ts +0 -209
  119. package/src/utils/__tests__/implementor-helpers.test.ts +0 -1458
  120. package/src/utils/__tests__/keyboard-actions.test.ts +0 -660
  121. package/src/utils/__tests__/layout-helpers.test.ts +0 -36
  122. package/src/utils/__tests__/lazy-response-ads.test.ts +0 -167
  123. package/src/utils/__tests__/log-shipper.test.ts +0 -53
  124. package/src/utils/__tests__/markdown-renderer.test.tsx +0 -421
  125. package/src/utils/__tests__/message-block-helpers.test.ts +0 -1263
  126. package/src/utils/__tests__/message-updater.test.ts +0 -645
  127. package/src/utils/__tests__/osc-timeout-scenarios.test.ts +0 -172
  128. package/src/utils/__tests__/pending-attachments.test.ts +0 -277
  129. package/src/utils/__tests__/polling-backoff.test.ts +0 -51
  130. package/src/utils/__tests__/queue-panel-actions.test.ts +0 -148
  131. package/src/utils/__tests__/run-state-storage.test.ts +0 -919
  132. package/src/utils/__tests__/safe-json.test.ts +0 -77
  133. package/src/utils/__tests__/sdk-event-handlers.test.ts +0 -685
  134. package/src/utils/__tests__/send-message-helpers.test.ts +0 -1898
  135. package/src/utils/__tests__/send-message-timer.test.ts +0 -64
  136. package/src/utils/__tests__/settings.test.ts +0 -99
  137. package/src/utils/__tests__/strings.test.ts +0 -192
  138. package/src/utils/__tests__/terminal-color-detection.test.ts +0 -425
  139. package/src/utils/__tests__/terminal-command-broker.test.ts +0 -528
  140. package/src/utils/__tests__/terminal-enter-detection.test.ts +0 -77
  141. package/src/utils/__tests__/terminal-io.test.ts +0 -137
  142. package/src/utils/__tests__/terminal-protocol-controller.test.ts +0 -119
  143. package/src/utils/__tests__/text-layout.test.ts +0 -82
  144. package/src/utils/__tests__/theme-platform-detection.test.ts +0 -125
  145. package/src/utils/__tests__/think-tag-parser.test.ts +0 -159
  146. package/src/utils/__tests__/trace-writer.test.ts +0 -223
  147. package/src/utils/__tests__/trim-chat-logs.test.ts +0 -78
  148. package/src/utils/__tests__/usage-banner-state.test.ts +0 -298
  149. package/src/utils/__tests__/validation-error-formatting.test.ts +0 -126
  150. package/src/utils/__tests__/windows-terminal-health.test.ts +0 -101
  151. package/src/utils/__tests__/write-file-atomic.test.ts +0 -127
  152. package/vendor/@anvil/common/src/__tests__/agent-validation.test.ts +0 -846
  153. package/vendor/@anvil/common/src/__tests__/anvil-model-availability.test.ts +0 -101
  154. package/vendor/@anvil/common/src/__tests__/anvil-models.test.ts +0 -1408
  155. package/vendor/@anvil/common/src/__tests__/anvil-public-data-use-copy.test.ts +0 -258
  156. package/vendor/@anvil/common/src/__tests__/anvil-referral-tiers.test.ts +0 -48
  157. package/vendor/@anvil/common/src/__tests__/anvil-spend-ceilings.test.ts +0 -282
  158. package/vendor/@anvil/common/src/__tests__/anvil-trust.test.ts +0 -526
  159. package/vendor/@anvil/common/src/__tests__/deepseek-direct.test.ts +0 -68
  160. package/vendor/@anvil/common/src/__tests__/disposable-email.test.ts +0 -132
  161. package/vendor/@anvil/common/src/__tests__/dynamic-agent-template-schema.test.ts +0 -422
  162. package/vendor/@anvil/common/src/__tests__/env-ci.test.ts +0 -167
  163. package/vendor/@anvil/common/src/__tests__/env-process.test.ts +0 -145
  164. package/vendor/@anvil/common/src/__tests__/foreign-client-shipped-agents.test.ts +0 -234
  165. package/vendor/@anvil/common/src/__tests__/foreign-client-signals.test.ts +0 -379
  166. package/vendor/@anvil/common/src/__tests__/free-agents.test.ts +0 -807
  167. package/vendor/@anvil/common/src/__tests__/gravity-capi.test.ts +0 -154
  168. package/vendor/@anvil/common/src/__tests__/handlesteps-parsing.test.ts +0 -246
  169. package/vendor/@anvil/common/src/__tests__/kimi-k3-god-only.test.ts +0 -77
  170. package/vendor/@anvil/common/src/__tests__/model-config.test.ts +0 -89
  171. package/vendor/@anvil/common/src/__tests__/project-file-tree.test.ts +0 -298
  172. package/vendor/@anvil/common/src/__tests__/provisioned-model-tiers.test.ts +0 -116
  173. package/vendor/@anvil/common/src/__tests__/reasoning-effort.test.ts +0 -167
  174. package/vendor/@anvil/common/src/__tests__/reddit-capi.test.ts +0 -132
  175. package/vendor/@anvil/common/src/__tests__/response-ad-positions.test.ts +0 -72
  176. package/vendor/@anvil/common/src/__tests__/user-state.test.ts +0 -30
  177. package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding-gate.test.ts +0 -63
  178. package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding.test.ts +0 -246
  179. package/vendor/@anvil/common/src/constants/__tests__/cf-worker-signals.test.ts +0 -106
  180. package/vendor/@anvil/common/src/testing/TESTING_PATTERNS.md +0 -351
  181. package/vendor/@anvil/common/src/testing/anvil-offer-invariants.ts +0 -169
  182. package/vendor/@anvil/common/src/testing/errors.ts +0 -33
  183. package/vendor/@anvil/common/src/testing/fixtures/agent-runtime.ts +0 -334
  184. package/vendor/@anvil/common/src/testing/impl/agent-runtime.ts +0 -6
  185. package/vendor/@anvil/common/src/testing/index.ts +0 -84
  186. package/vendor/@anvil/common/src/testing/mock-modules.ts +0 -53
  187. package/vendor/@anvil/common/src/testing/mock-types.ts +0 -123
  188. package/vendor/@anvil/common/src/testing/mocks/analytics.ts +0 -261
  189. package/vendor/@anvil/common/src/testing/mocks/child-process.ts +0 -93
  190. package/vendor/@anvil/common/src/testing/mocks/crypto.ts +0 -218
  191. package/vendor/@anvil/common/src/testing/mocks/database.ts +0 -337
  192. package/vendor/@anvil/common/src/testing/mocks/fetch.ts +0 -219
  193. package/vendor/@anvil/common/src/testing/mocks/filesystem.ts +0 -166
  194. package/vendor/@anvil/common/src/testing/mocks/index.ts +0 -101
  195. package/vendor/@anvil/common/src/testing/mocks/logger.ts +0 -135
  196. package/vendor/@anvil/common/src/testing/mocks/stream.ts +0 -313
  197. package/vendor/@anvil/common/src/testing/mocks/timers.ts +0 -132
  198. package/vendor/@anvil/common/src/testing/mocks/tree-sitter.ts +0 -127
  199. package/vendor/@anvil/common/src/testing/setup.ts +0 -282
  200. package/vendor/@anvil/common/src/tools/__tests__/compile-tool-definitions.test.ts +0 -34
  201. package/vendor/@anvil/common/src/tools/params/__tests__/coerce-to-array.test.ts +0 -213
  202. package/vendor/@anvil/common/src/tools/params/__tests__/read-docs.test.ts +0 -47
  203. package/vendor/@anvil/common/src/tools/params/__tests__/render-ui.test.ts +0 -65
  204. package/vendor/@anvil/common/src/tools/params/tool/__tests__/run-terminal-command-timeout.test.ts +0 -49
  205. package/vendor/@anvil/common/src/types/__tests__/dynamic-agent-template.test.ts +0 -20
  206. package/vendor/@anvil/common/src/util/__tests__/ad-user-agent.test.ts +0 -26
  207. package/vendor/@anvil/common/src/util/__tests__/analytics-dispatcher.test.ts +0 -122
  208. package/vendor/@anvil/common/src/util/__tests__/analytics-log.test.ts +0 -102
  209. package/vendor/@anvil/common/src/util/__tests__/analytics-sampling.test.ts +0 -143
  210. package/vendor/@anvil/common/src/util/__tests__/anvil-streak.test.ts +0 -202
  211. package/vendor/@anvil/common/src/util/__tests__/anvil-usage-summary.test.ts +0 -193
  212. package/vendor/@anvil/common/src/util/__tests__/axiom-only-log.test.ts +0 -140
  213. package/vendor/@anvil/common/src/util/__tests__/client-user-agent.test.ts +0 -148
  214. package/vendor/@anvil/common/src/util/__tests__/engagement-tracker.test.ts +0 -115
  215. package/vendor/@anvil/common/src/util/__tests__/env-file-path.test.ts +0 -57
  216. package/vendor/@anvil/common/src/util/__tests__/error-abort.test.ts +0 -774
  217. package/vendor/@anvil/common/src/util/__tests__/error-api-details.test.ts +0 -206
  218. package/vendor/@anvil/common/src/util/__tests__/file-read-limits.test.ts +0 -173
  219. package/vendor/@anvil/common/src/util/__tests__/format-code-search.test.ts +0 -60
  220. package/vendor/@anvil/common/src/util/__tests__/log-mirror.test.ts +0 -31
  221. package/vendor/@anvil/common/src/util/__tests__/messages.test.ts +0 -1252
  222. package/vendor/@anvil/common/src/util/__tests__/partial-json-delta.test.ts +0 -505
  223. package/vendor/@anvil/common/src/util/__tests__/path.test.ts +0 -22
  224. package/vendor/@anvil/common/src/util/__tests__/project-ignore.test.ts +0 -90
  225. package/vendor/@anvil/common/src/util/__tests__/promise.test.ts +0 -325
  226. package/vendor/@anvil/common/src/util/__tests__/rate-limit.test.ts +0 -28
  227. package/vendor/@anvil/common/src/util/__tests__/reddit-anvil-retention.test.ts +0 -130
  228. package/vendor/@anvil/common/src/util/__tests__/saxy.test.ts +0 -1008
  229. package/vendor/@anvil/common/src/util/__tests__/split-data.test.ts +0 -289
  230. package/vendor/@anvil/common/src/util/__tests__/string.test.ts +0 -239
  231. package/vendor/@anvil/common/src/util/__tests__/thread-title.test.ts +0 -70
  232. package/vendor/@anvil/common/src/util/__tests__/tool-result-media-order.test.ts +0 -108
  233. package/vendor/@anvil/common/src/util/__tests__/ttft-histogram.test.ts +0 -180
  234. package/vendor/@anvil/common/src/util/__tests__/with-timeout.test.ts +0 -24
  235. package/vendor/@anvil/common/src/util/__tests__/zoned-time.test.ts +0 -88
  236. package/vendor/@anvil/common/src/util/skills.test.ts +0 -44
  237. package/vendor/@anvil/sdk/dist/index.cjs.map +0 -440
  238. 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
- })