MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / start

Method start

freebuff/e2e/utils/freebuff-session.ts:20–59  ·  view source on GitHub ↗

* Start a freebuff binary in a tmux session. * Creates a temporary working directory to simulate a real user project.

(
    binaryPath: string,
    options?: {
      waitSeconds?: number
      width?: number
      height?: number
      initialFiles?: Record<string, string>
    },
  )

Source from the content-addressed store, hash-verified

18 * Creates a temporary working directory to simulate a real user project.
19 */
20 static async start(
21 binaryPath: string,
22 options?: {
23 waitSeconds?: number
24 width?: number
25 height?: number
26 initialFiles?: Record<string, string>
27 },
28 ): Promise<FreebuffSession> {
29 const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'freebuff-e2e-'))
30
31 // Create a minimal project so freebuff has something to work with
32 fs.writeFileSync(
33 path.join(tmpDir, 'README.md'),
34 '# E2E Test Project\n',
35 'utf-8',
36 )
37
38 // Write any initial files before starting the binary
39 if (options?.initialFiles) {
40 for (const [relativePath, content] of Object.entries(options.initialFiles)) {
41 const filePath = path.join(tmpDir, relativePath)
42 const dir = path.dirname(filePath)
43 if (!fs.existsSync(dir)) {
44 fs.mkdirSync(dir, { recursive: true })
45 }
46 fs.writeFileSync(filePath, content, 'utf-8')
47 }
48 }
49
50 const command = `cd '${tmpDir}' && '${binaryPath}'`
51 const sessionName = tmuxStart({
52 command,
53 waitSeconds: options?.waitSeconds ?? 4,
54 width: options?.width ?? 120,
55 height: options?.height ?? 30,
56 })
57
58 return new FreebuffSession(sessionName, tmpDir)
59 }
60
61 /** Write a file into the session's working directory. */
62 writeFile(relativePath: string, content: string): void {

Calls 1

tmuxStartFunction · 0.90

Tested by

no test coverage detected