| 1 | import assert from 'node:assert/strict'; |
| 2 | import { readFile } from 'node:fs/promises'; |
| 3 | import { fileURLToPath } from 'node:url'; |
| 4 | import { join } from 'node:path'; |
| 5 | import { test } from 'node:test'; |
| 6 | |
| 7 | import { AGENT_DEFS, findAgent } from '../dist/index.js'; |
| 8 | |
| 9 | const repoRoot = fileURLToPath(new URL('../../../', import.meta.url)); |
| 10 | |
| 11 | test('Trae CLI is registered as a public ACP runtime', () => { |
| 12 | const traeCli = findAgent('trae-cli'); |
| 13 | |
| 14 | assert.ok(traeCli, 'trae-cli should be registered'); |
| 15 | assert.equal(traeCli.name, 'Trae CLI'); |
| 16 | assert.equal(traeCli.bin, 'traecli'); |
| 17 | assert.equal(traeCli.streamFormat, 'acp-json-rpc'); |
| 18 | assert.equal(traeCli.promptViaStdin, undefined); |
| 19 | assert.equal(traeCli.kind, undefined); |
| 20 | assert.ok(AGENT_DEFS.includes(traeCli)); |
| 21 | }); |
| 22 | |
| 23 | test('Trae CLI ACP launch uses yolo mode for non-interactive studio runs', () => { |
| 24 | const traeCli = findAgent('trae-cli'); |
| 25 | |
| 26 | assert.deepEqual(traeCli.buildArgs('', { cwd: '/tmp/html-video-project' }), [ |
| 27 | 'acp', |
| 28 | 'serve', |
| 29 | '--yolo', |
| 30 | ]); |
| 31 | }); |
| 32 | |
| 33 | test('Trae CLI public surface does not expose internal COCO details', async () => { |
| 34 | const files = await Promise.all([ |
| 35 | readFile(join(repoRoot, 'packages/runtime/src/defs/trae-cli.ts'), 'utf8'), |
| 36 | readFile(join(repoRoot, 'packages/runtime/src/registry.ts'), 'utf8'), |
| 37 | readFile(join(repoRoot, 'README.md'), 'utf8'), |
| 38 | readFile(join(repoRoot, 'README.zh-CN.md'), 'utf8'), |
| 39 | ]); |
| 40 | const publicSurface = files.join('\n').toLowerCase(); |
| 41 | |
| 42 | for (const forbidden of [ |
| 43 | 'coco', |
| 44 | 'code.byted.org', |
| 45 | 'codebase-api.byted.org', |
| 46 | 'bytedance', |
| 47 | '/users/bytedance', |
| 48 | 'bytedance sso', |
| 49 | 'install_coco', |
| 50 | ]) { |
| 51 | assert.equal( |
| 52 | publicSurface.includes(forbidden), |
| 53 | false, |
| 54 | `public surface should not contain ${forbidden}`, |
| 55 | ); |
| 56 | } |
| 57 | }); |
| 58 |