btca-server 1.0.962 → 2.0.1

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 (43) hide show
  1. package/package.json +3 -3
  2. package/src/agent/agent.test.ts +31 -24
  3. package/src/agent/index.ts +8 -2
  4. package/src/agent/loop.ts +303 -346
  5. package/src/agent/service.ts +252 -233
  6. package/src/agent/types.ts +2 -2
  7. package/src/collections/index.ts +2 -1
  8. package/src/collections/service.ts +352 -345
  9. package/src/config/config.test.ts +3 -1
  10. package/src/config/index.ts +615 -727
  11. package/src/config/remote.ts +214 -369
  12. package/src/context/index.ts +6 -12
  13. package/src/context/transaction.ts +23 -30
  14. package/src/effect/errors.ts +45 -0
  15. package/src/effect/layers.ts +26 -0
  16. package/src/effect/runtime.ts +19 -0
  17. package/src/effect/services.ts +154 -0
  18. package/src/index.ts +291 -369
  19. package/src/metrics/index.ts +46 -46
  20. package/src/pricing/models-dev.ts +104 -106
  21. package/src/providers/auth.ts +159 -200
  22. package/src/providers/index.ts +19 -2
  23. package/src/providers/model.ts +115 -135
  24. package/src/providers/openai.ts +3 -3
  25. package/src/resources/impls/git.ts +123 -146
  26. package/src/resources/impls/npm.test.ts +16 -5
  27. package/src/resources/impls/npm.ts +66 -75
  28. package/src/resources/index.ts +6 -1
  29. package/src/resources/schema.ts +7 -6
  30. package/src/resources/service.test.ts +13 -12
  31. package/src/resources/service.ts +153 -112
  32. package/src/stream/index.ts +1 -1
  33. package/src/stream/service.test.ts +5 -5
  34. package/src/stream/service.ts +282 -293
  35. package/src/tools/glob.ts +126 -141
  36. package/src/tools/grep.ts +205 -210
  37. package/src/tools/index.ts +8 -4
  38. package/src/tools/list.ts +118 -140
  39. package/src/tools/read.ts +209 -235
  40. package/src/tools/virtual-sandbox.ts +91 -83
  41. package/src/validation/index.ts +18 -22
  42. package/src/vfs/virtual-fs.test.ts +37 -25
  43. package/src/vfs/virtual-fs.ts +218 -216
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btca-server",
3
- "version": "1.0.962",
3
+ "version": "2.0.1",
4
4
  "description": "BTCA server for answering questions about your codebase using OpenCode AI",
5
5
  "author": "Ben Davis",
6
6
  "license": "MIT",
@@ -56,9 +56,9 @@
56
56
  "@ai-sdk/openai": "^3.0.18",
57
57
  "@ai-sdk/openai-compatible": "^2.0.18",
58
58
  "@btca/shared": "workspace:*",
59
+ "@effect/platform-bun": "4.0.0-beta.20",
59
60
  "ai": "^6.0.49",
60
- "better-result": "^2.6.0",
61
- "hono": "^4.7.11",
61
+ "effect": "4.0.0-beta.20",
62
62
  "just-bash": "^2.7.0",
63
63
  "opencode-ai": "^1.1.36",
64
64
  "vercel-minimax-ai-provider": "^0.0.2",
@@ -3,14 +3,21 @@ import { promises as fs } from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import os from 'node:os';
5
5
 
6
- import { Agent } from './service.ts';
7
- import { Config } from '../config/index.ts';
6
+ import { createAgentService } from './service.ts';
7
+ import { load as loadConfig } from '../config/index.ts';
8
8
  import type { CollectionResult } from '../collections/types.ts';
9
9
  import {
10
10
  getVirtualCollectionMetadata,
11
11
  setVirtualCollectionMetadata
12
12
  } from '../collections/virtual-metadata.ts';
13
- import { VirtualFs } from '../vfs/virtual-fs.ts';
13
+ import {
14
+ createVirtualFs,
15
+ hasVirtualFs,
16
+ mkdirVirtualFs,
17
+ writeVirtualFsFile
18
+ } from '../vfs/virtual-fs.ts';
19
+
20
+ const Config = { load: loadConfig } as const;
14
21
 
15
22
  describe('Agent', () => {
16
23
  let testDir: string;
@@ -34,7 +41,7 @@ describe('Agent', () => {
34
41
  it('creates an agent service with ask and askStream methods', async () => {
35
42
  process.chdir(testDir);
36
43
  const config = await Config.load();
37
- const agent = Agent.create(config);
44
+ const agent = createAgentService(config);
38
45
 
39
46
  expect(agent).toBeDefined();
40
47
  expect(typeof agent.ask).toBe('function');
@@ -48,11 +55,11 @@ describe('Agent', () => {
48
55
  it('asks a question and receives an answer', async () => {
49
56
  process.chdir(testDir);
50
57
  const config = await Config.load();
51
- const agent = Agent.create(config);
58
+ const agent = createAgentService(config);
52
59
 
53
- const vfsId = VirtualFs.create();
54
- await VirtualFs.mkdir('/', { recursive: true }, vfsId);
55
- await VirtualFs.writeFile(
60
+ const vfsId = createVirtualFs();
61
+ await mkdirVirtualFs('/', { recursive: true }, vfsId);
62
+ await writeVirtualFsFile(
56
63
  '/README.md',
57
64
  '# Test Documentation\n\nThis is a test file. The answer to life is 42.',
58
65
  vfsId
@@ -83,11 +90,11 @@ describe('Agent', () => {
83
90
  it('handles askStream and receives events', async () => {
84
91
  process.chdir(testDir);
85
92
  const config = await Config.load();
86
- const agent = Agent.create(config);
93
+ const agent = createAgentService(config);
87
94
 
88
- const vfsId = VirtualFs.create();
89
- await VirtualFs.mkdir('/', { recursive: true }, vfsId);
90
- await VirtualFs.writeFile('/data.txt', 'The capital of France is Paris.', vfsId);
95
+ const vfsId = createVirtualFs();
96
+ await mkdirVirtualFs('/', { recursive: true }, vfsId);
97
+ await writeVirtualFsFile('/data.txt', 'The capital of France is Paris.', vfsId);
91
98
 
92
99
  const collection: CollectionResult = {
93
100
  path: '/',
@@ -118,12 +125,12 @@ describe('Agent', () => {
118
125
  it('cleans up virtual collections after ask', async () => {
119
126
  process.chdir(testDir);
120
127
  const config = await Config.load();
121
- const agent = Agent.create(config);
128
+ const agent = createAgentService(config);
122
129
 
123
- const vfsId = VirtualFs.create();
124
- await VirtualFs.mkdir('/', { recursive: true }, vfsId);
125
- await VirtualFs.mkdir('/docs', { recursive: true }, vfsId);
126
- await VirtualFs.writeFile('/docs/README.md', 'Virtual README\nThe answer is 42.', vfsId);
130
+ const vfsId = createVirtualFs();
131
+ await mkdirVirtualFs('/', { recursive: true }, vfsId);
132
+ await mkdirVirtualFs('/docs', { recursive: true }, vfsId);
133
+ await writeVirtualFsFile('/docs/README.md', 'Virtual README\nThe answer is 42.', vfsId);
127
134
 
128
135
  setVirtualCollectionMetadata({
129
136
  vfsId,
@@ -153,19 +160,19 @@ describe('Agent', () => {
153
160
  });
154
161
 
155
162
  expect(result).toBeDefined();
156
- expect(VirtualFs.has(vfsId)).toBe(false);
163
+ expect(hasVirtualFs(vfsId)).toBe(false);
157
164
  expect(getVirtualCollectionMetadata(vfsId)).toBeUndefined();
158
165
  }, 60000);
159
166
 
160
167
  it('cleans up virtual collections after askStream', async () => {
161
168
  process.chdir(testDir);
162
169
  const config = await Config.load();
163
- const agent = Agent.create(config);
170
+ const agent = createAgentService(config);
164
171
 
165
- const vfsId = VirtualFs.create();
166
- await VirtualFs.mkdir('/', { recursive: true }, vfsId);
167
- await VirtualFs.mkdir('/docs', { recursive: true }, vfsId);
168
- await VirtualFs.writeFile(
172
+ const vfsId = createVirtualFs();
173
+ await mkdirVirtualFs('/', { recursive: true }, vfsId);
174
+ await mkdirVirtualFs('/docs', { recursive: true }, vfsId);
175
+ await writeVirtualFsFile(
169
176
  '/docs/README.md',
170
177
  'Virtual README\nThe capital of France is Paris.',
171
178
  vfsId
@@ -202,7 +209,7 @@ describe('Agent', () => {
202
209
  // drain stream to trigger cleanup
203
210
  }
204
211
 
205
- expect(VirtualFs.has(vfsId)).toBe(false);
212
+ expect(hasVirtualFs(vfsId)).toBe(false);
206
213
  expect(getVirtualCollectionMetadata(vfsId)).toBeUndefined();
207
214
  }, 60000);
208
215
  });
@@ -1,3 +1,9 @@
1
- export { Agent } from './service.ts';
2
- export { AgentLoop } from './loop.ts';
1
+ export {
2
+ createAgentService,
3
+ AgentError,
4
+ InvalidProviderError,
5
+ InvalidModelError,
6
+ ProviderNotConnectedError
7
+ } from './service.ts';
8
+ export { runAgentLoop, streamAgentLoop } from './loop.ts';
3
9
  export type { AgentResult } from './types.ts';