@@ -7,6 +7,9 @@ import fileListerDefinition from '../file-explorer/file-lister'
77
88import type { PrintModeEvent } from '@codebuff/common/types/print-mode'
99
10+ const apiKey = process . env [ API_KEY_ENV_VAR ]
11+ const describeWithApiKey = apiKey ? describe : describe . skip
12+
1013/**
1114 * Integration tests for agents that use the read_subtree tool.
1215 * These tests verify that the SDK properly initializes the session state
@@ -17,15 +20,13 @@ import type { PrintModeEvent } from '@codebuff/common/types/print-mode'
1720 * - file-lister directly uses the read_subtree tool
1821 * - file-picker spawns file-lister as a subagent, adding complexity
1922 * - Testing file-lister directly verifies the core functionality
23+ *
24+ * These tests require CODEBUFF_API_KEY to be set and are skipped otherwise.
2025 */
21- describe ( 'File Lister Agent Integration - read_subtree tool' , ( ) => {
26+ describeWithApiKey ( 'File Lister Agent Integration - read_subtree tool' , ( ) => {
2227 it (
2328 'should find relevant files using read_subtree tool' ,
2429 async ( ) => {
25- const apiKey = process . env [ API_KEY_ENV_VAR ]
26- if ( ! apiKey ) {
27- throw new Error ( 'API key not found' )
28- }
2930
3031 // Create mock project files that the file-lister should be able to find
3132 const projectFiles : Record < string , string > = {
@@ -142,10 +143,6 @@ export interface User {
142143 it (
143144 'should use the file tree from session state' ,
144145 async ( ) => {
145- const apiKey = process . env [ API_KEY_ENV_VAR ]
146- if ( ! apiKey ) {
147- throw new Error ( 'API key not found' )
148- }
149146
150147 // Create a different set of project files with a specific structure
151148 const projectFiles : Record < string , string > = {
@@ -196,10 +193,6 @@ export interface User {
196193 it (
197194 'should respect directories parameter' ,
198195 async ( ) => {
199- const apiKey = process . env [ API_KEY_ENV_VAR ]
200- if ( ! apiKey ) {
201- throw new Error ( 'API key not found' )
202- }
203196
204197 // Create project with multiple top-level directories
205198 const projectFiles : Record < string , string > = {
@@ -252,19 +245,17 @@ export interface User {
252245 * Integration tests for the file-picker agent that spawns subagents.
253246 * The file-picker spawns file-lister as a subagent to find files.
254247 * This tests the spawn_agents tool functionality through the SDK.
248+ *
249+ * These tests require CODEBUFF_API_KEY to be set and are skipped otherwise.
255250 */
256- describe ( 'File Picker Agent Integration - spawn_agents tool' , ( ) => {
251+ describeWithApiKey ( 'File Picker Agent Integration - spawn_agents tool' , ( ) => {
257252 // Note: This test requires the local agent definitions to be used for both
258253 // file-picker AND its spawned file-lister subagent. Currently, the spawned
259254 // agent may resolve to the server version which has the old parsing bug.
260255 // Skip until we have a way to ensure spawned agents use local definitions.
261256 it . skip (
262257 'should spawn file-lister subagent and find relevant files' ,
263258 async ( ) => {
264- const apiKey = process . env [ API_KEY_ENV_VAR ]
265- if ( ! apiKey ) {
266- throw new Error ( 'API key not found' )
267- }
268259
269260 // Create mock project files
270261 const projectFiles : Record < string , string > = {
0 commit comments