Skip to content

Commit 577c800

Browse files
V48 (impl-only): Codebase Try multi-tool registry
Host read/list/run tools + full LSP; useTools schema and Try prompts for multi-call Discovery comprehension before 1.D23.
1 parent d0e8063 commit 577c800

7 files changed

Lines changed: 559 additions & 120 deletions

File tree

packages/asset-packs-pipelines/syntheses/deposit/src/__tests__/deposit-agent-prompt-contracts.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ const SPECS: DepositAgentPromptSpec[] = [
123123
agent: DepositCodebaseComprehensionAgent,
124124
identity:
125125
'You are the SynthesizeAssetPacks Discovery agent that comprehends the depositor Host checkout (sourceCheckoutCatalog).',
126-
requirements: 'You receive: repository coordinates, sourceCheckoutCatalog paths, fileTree structure,',
127-
wrapper: 'Return ONLY {"comprehension": {...}}',
126+
requirements: 'Inputs may include: repository coordinates, sourceCheckoutCatalog paths, fileTree,',
127+
wrapper: 'comprehension + optional useTools on Try/Retry',
128128
schemaFields: [
129129
'summary',
130130
'capabilities',
@@ -134,10 +134,10 @@ const SPECS: DepositAgentPromptSpec[] = [
134134
'structureInsights',
135135
],
136136
ptrr: [
137-
'Plan: combine absolute measurements, LSP signals, file-tree structure, and key file',
138-
'Try: synthesize the codebase knowledge map — capabilities, knowledge areas, notable',
139-
'Refine: ensure the map is source-safe, grounded in provided sourceCheckoutCatalog evidence',
140-
'Retry: return a minimal source-safe knowledge map grounded in path list and measurements',
137+
'Plan (no tools): design a multi-tool Host checkout exploration strategy',
138+
'Try: EXECUTE rich multi-tool exploration then synthesize the knowledge map.',
139+
'Refine (no tools): ensure the map is source-safe, grounded in tool results',
140+
'Retry: if prior Try missed tools or evidence, select additional useTools',
141141
],
142142
boundaryOutput: {
143143
comprehension: {

packages/asset-packs-pipelines/syntheses/deposit/src/agents/discovery/deposit-codebase-comprehension-agent.ts

Lines changed: 119 additions & 105 deletions
Large diffs are not rendered by default.

packages/asset-packs-pipelines/syntheses/domain/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"./tools/DepositDepositoryAssetPackSearchTool": "./src/tools/DepositDepositoryAssetPackSearchTool.ts",
5050
"./tools/AssetPackCloneVCSRepositoryTool": "./src/tools/AssetPackCloneVCSRepositoryTool.ts",
5151
"./tools/lsp-setup-tools": "./src/tools/lsp-setup-tools.ts",
52+
"./tools/discovery-host-workspace-tools": "./src/tools/discovery-host-workspace-tools.ts",
5253
"./types/PipelineSchemas": "./src/types/PipelineSchemas.ts",
5354
"./types/AssetPackWrittenAssetType": "./src/types/AssetPackWrittenAssetType.ts",
5455
"./agents/finish/upload-asset-packs-for-review-agent": "./src/agents/finish/upload-asset-packs-for-review-agent.ts",
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
* Host workspace tools for Discovery codebase Try multi-tool exploration.
3+
*/
4+
import * as fs from 'node:fs';
5+
import * as os from 'node:os';
6+
import * as path from 'node:path';
7+
import {
8+
HOST_WORKSPACE_TOOL_NAMES,
9+
runHostWorkspaceListDir,
10+
runHostWorkspaceReadFile,
11+
runHostWorkspaceRunCommand,
12+
} from '../tools/discovery-host-workspace-tools';
13+
14+
describe('discovery host workspace tools', () => {
15+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'bitcode-host-ws-'));
16+
17+
beforeAll(() => {
18+
fs.writeFileSync(path.join(root, 'hello.js'), 'export const x = 1;\n', 'utf8');
19+
fs.mkdirSync(path.join(root, 'src'));
20+
fs.writeFileSync(path.join(root, 'src', 'a.ts'), 'export type A = number;\n', 'utf8');
21+
});
22+
23+
afterAll(() => {
24+
fs.rmSync(root, { recursive: true, force: true });
25+
});
26+
27+
it('exports stable registry names', () => {
28+
expect(HOST_WORKSPACE_TOOL_NAMES.readFile).toBe('host-workspace-read-file');
29+
expect(HOST_WORKSPACE_TOOL_NAMES.listDir).toBe('host-workspace-list-dir');
30+
expect(HOST_WORKSPACE_TOOL_NAMES.runCommand).toBe('host-workspace-run-command');
31+
});
32+
33+
it('reads files under workspaceRoot and refuses escape', async () => {
34+
const ok = await runHostWorkspaceReadFile({
35+
workspaceRoot: root,
36+
path: 'hello.js',
37+
});
38+
expect(ok.ok).toBe(true);
39+
expect(ok.content).toContain('export const x');
40+
41+
const escape = await runHostWorkspaceReadFile({
42+
workspaceRoot: root,
43+
path: '../outside',
44+
});
45+
expect(escape.ok).toBe(false);
46+
});
47+
48+
it('lists directories', async () => {
49+
const listed = await runHostWorkspaceListDir({
50+
workspaceRoot: root,
51+
path: '.',
52+
});
53+
expect(listed.ok).toBe(true);
54+
expect(listed.entries?.some((e) => e.name === 'src')).toBe(true);
55+
});
56+
57+
it('runs allowlisted commands and rejects shell meta / forbidden git', async () => {
58+
const ls = await runHostWorkspaceRunCommand({
59+
workspaceRoot: root,
60+
command: 'ls',
61+
args: ['-1'],
62+
});
63+
expect(ls.ok).toBe(true);
64+
expect(ls.stdout).toMatch(/hello\.js|src/);
65+
66+
const bad = await runHostWorkspaceRunCommand({
67+
workspaceRoot: root,
68+
command: 'rm',
69+
args: ['-rf', '/'],
70+
});
71+
expect(bad.ok).toBe(false);
72+
73+
const meta = await runHostWorkspaceRunCommand({
74+
workspaceRoot: root,
75+
command: 'ls',
76+
args: ['; echo pwned'],
77+
});
78+
expect(meta.ok).toBe(false);
79+
80+
const gitPush = await runHostWorkspaceRunCommand({
81+
workspaceRoot: root,
82+
command: 'git',
83+
args: ['push', 'origin', 'main'],
84+
});
85+
expect(gitPush.ok).toBe(false);
86+
});
87+
});

packages/asset-packs-pipelines/syntheses/domain/src/__tests__/lsp-setup-tools.test.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44
import {
55
ALL_LSP_QUERY_TOOLS,
6-
DISCOVERY_CODEBASE_COMPREHENSION_LSP_TOOLS,
76
SETUP_LSP_INITIALIZE_TOOLS,
87
LSP_TOOL_NAMES,
98
setupLspForWorkspace,
@@ -40,12 +39,22 @@ describe('Setup LSP tools for subsequent phases', () => {
4039
expect(initTools.length).toBeGreaterThan(0);
4140
});
4241

43-
it('binds Discovery codebase comprehension to the full LSP suite', () => {
42+
it('binds Discovery codebase comprehension to LSP suite + host workspace tools', () => {
4443
const discovery = getAssetPackPipelineToolsForAgent('DepositCodebaseComprehensionAgent');
45-
expect(discovery.map((t) => (t as any).name)).toEqual(
46-
DISCOVERY_CODEBASE_COMPREHENSION_LSP_TOOLS.map((t) => (t as any).name),
44+
const names = discovery.map((t) => (t as any).name);
45+
expect(names).toEqual(
46+
expect.arrayContaining([
47+
LSP_TOOL_NAMES.workspaceSymbols,
48+
LSP_TOOL_NAMES.documentSymbols,
49+
LSP_TOOL_NAMES.definition,
50+
LSP_TOOL_NAMES.references,
51+
'host-workspace-read-file',
52+
'host-workspace-list-dir',
53+
'host-workspace-run-command',
54+
]),
4755
);
48-
expect(discovery.length).toBeGreaterThanOrEqual(5);
56+
// Full LSP suite + 3 host tools
57+
expect(discovery.length).toBeGreaterThanOrEqual(ALL_LSP_QUERY_TOOLS.length + 3);
4958
});
5059

5160
it('setupLspForWorkspace registers tools and marks readiness for later phases', async () => {

0 commit comments

Comments
 (0)