btca-server 1.0.962 → 2.0.0
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 +3 -3
- package/src/agent/agent.test.ts +31 -24
- package/src/agent/index.ts +8 -2
- package/src/agent/loop.ts +303 -346
- package/src/agent/service.ts +252 -233
- package/src/agent/types.ts +2 -2
- package/src/collections/index.ts +2 -1
- package/src/collections/service.ts +352 -345
- package/src/config/config.test.ts +3 -1
- package/src/config/index.ts +615 -727
- package/src/config/remote.ts +214 -369
- package/src/context/index.ts +6 -12
- package/src/context/transaction.ts +23 -30
- package/src/effect/errors.ts +45 -0
- package/src/effect/layers.ts +26 -0
- package/src/effect/runtime.ts +19 -0
- package/src/effect/services.ts +154 -0
- package/src/index.ts +291 -369
- package/src/metrics/index.ts +46 -46
- package/src/pricing/models-dev.ts +104 -106
- package/src/providers/auth.ts +159 -200
- package/src/providers/index.ts +19 -2
- package/src/providers/model.ts +115 -135
- package/src/providers/openai.ts +3 -3
- package/src/resources/impls/git.ts +123 -146
- package/src/resources/impls/npm.test.ts +16 -5
- package/src/resources/impls/npm.ts +66 -75
- package/src/resources/index.ts +6 -1
- package/src/resources/schema.ts +7 -6
- package/src/resources/service.test.ts +13 -12
- package/src/resources/service.ts +153 -112
- package/src/stream/index.ts +1 -1
- package/src/stream/service.test.ts +5 -5
- package/src/stream/service.ts +282 -293
- package/src/tools/glob.ts +126 -141
- package/src/tools/grep.ts +205 -210
- package/src/tools/index.ts +8 -4
- package/src/tools/list.ts +118 -140
- package/src/tools/read.ts +209 -235
- package/src/tools/virtual-sandbox.ts +91 -83
- package/src/validation/index.ts +18 -22
- package/src/vfs/virtual-fs.test.ts +37 -25
- 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": "
|
|
3
|
+
"version": "2.0.0",
|
|
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
|
-
"
|
|
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",
|
package/src/agent/agent.test.ts
CHANGED
|
@@ -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 {
|
|
7
|
-
import {
|
|
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 {
|
|
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 =
|
|
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 =
|
|
58
|
+
const agent = createAgentService(config);
|
|
52
59
|
|
|
53
|
-
const vfsId =
|
|
54
|
-
await
|
|
55
|
-
await
|
|
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 =
|
|
93
|
+
const agent = createAgentService(config);
|
|
87
94
|
|
|
88
|
-
const vfsId =
|
|
89
|
-
await
|
|
90
|
-
await
|
|
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 =
|
|
128
|
+
const agent = createAgentService(config);
|
|
122
129
|
|
|
123
|
-
const vfsId =
|
|
124
|
-
await
|
|
125
|
-
await
|
|
126
|
-
await
|
|
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(
|
|
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 =
|
|
170
|
+
const agent = createAgentService(config);
|
|
164
171
|
|
|
165
|
-
const vfsId =
|
|
166
|
-
await
|
|
167
|
-
await
|
|
168
|
-
await
|
|
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(
|
|
212
|
+
expect(hasVirtualFs(vfsId)).toBe(false);
|
|
206
213
|
expect(getVirtualCollectionMetadata(vfsId)).toBeUndefined();
|
|
207
214
|
}, 60000);
|
|
208
215
|
});
|
package/src/agent/index.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
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';
|