Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/extension/src/protocol/stdio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { StdioMessage } from './types.ts'
const openObject = { additionalProperties: true } as const
const bridgeInfoSchema = Type.Object(
{
project: Type.Optional(Type.String()),
project: Type.Optional(Type.Union([Type.String(), Type.Null()])),
version: Type.Optional(Type.String()),
build: Type.Optional(Type.String()),
protocol: Type.Optional(Type.Number()),
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/protocol/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface PendingToolCall {
}

export interface BridgeInfo {
project?: string
project?: string | null
version?: string
build?: string
protocol?: number
Expand Down
29 changes: 29 additions & 0 deletions packages/extension/test/integration/extension-stdio-smoke.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { execSync } from 'node:child_process'
import * as fs from 'node:fs'
import { tmpdir } from 'node:os'
import path from 'node:path'

import { getUnavailableReason } from '#src/connection/status.ts'
Expand Down Expand Up @@ -134,6 +135,34 @@ describe.skipIf(!elixirAvailable || !projectAvailable)(
expect(info?.plugins?.map((plugin) => plugin.name)).toContain('DemoPlugin')
})

it('starts an umbrella bridge and serves AST requests without an application name', async () => {
const cwd = fs.mkdtempSync(path.join(tmpdir(), 'pi-elixir-umbrella-'))

try {
fs.mkdirSync(path.join(cwd, 'apps'))
fs.writeFileSync(
path.join(cwd, 'mix.exs'),
'defmodule Umbrella.MixProject do\n use Mix.Project\n def project, do: [apps_path: "apps"]\nend\n'
)
fs.copyFileSync(path.join(cwd, 'mix.exs'), path.join(cwd, 'fixture.ex'))
startEmbeddedInBackground(cwd)
await waitForReady(cwd)

expect(getBridgeInfo(cwd)?.project).toBeNull()
const result = await callEmbeddedTool(cwd, 'ex_ast_search', {
pattern: 'defmodule _ do _ end',
path: 'fixture.ex'
})

expect(result.isError).toBe(false)
expect(structuredPayload(result).kind).toBe('ast_search')
expect(result.text).toContain('Umbrella.MixProject')
} finally {
stopEmbedded(cwd)
fs.rmSync(cwd, { recursive: true, force: true })
}
})

it('routes Pi.LLM.complete through the extension request handler', async () => {
const result = await callEmbeddedTool(PROJECT_DIR, 'project_eval', {
target: 'bridge',
Expand Down
7 changes: 7 additions & 0 deletions packages/extension/test/protocol-stdio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ describe('decodeStdioMessage', () => {
})
})

it('accepts a ready message without an umbrella application name', () => {
const message = { type: 'ready', info: { project: null } }

expect(decodeStdioMessage(message)).toEqual(message)
})

it('rejects malformed known messages instead of casting them', () => {
expect(decodeStdioMessage({ type: 'ready', info: { project: 42 } })).toBeNull()
expect(decodeStdioMessage({ type: 'result', id: '1', text: '42', isError: false })).toBeNull()
expect(
decodeStdioMessage({
Expand Down
Loading