Skip to content

Commit 95ced76

Browse files
fix: list and count extension-type integrations when a live IDE bridge serves them
The CLI presented extension-type integrations as categorically unusable ("not available from the CLI"). That is stale: with VS Code and the Altimate extension open on the project, the workspace engine discovers the bridge, allowlists the extension tools into the session, and serves them — verified end to end (compile + warehouse materialization) on 2026-09-03. - `datamate_manager list-integrations`: with a live bridge for the project, list extension-type rows, mark them "(via VS Code)" and count them; without one, keep them omitted but say they serve while VS Code with the Altimate extension is open on this project — a state, not an impossibility. - Attach announcement: append "Plus N extension tools via the connected VS Code window" when the bridge is serving them. Absent extension tools stay unwarned — that is the normal no-IDE case, never `missing`. - New `liveBridge()` probe in engine-probes: a read-only mirror of the engine's sidecar discovery (cwd prefix match, else the sole live bridge); dead pids are skipped, never GC'd — stale-sidecar cleanup stays with the engine and the extension. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MaT4GH2aCGEmTg6bBPZBeU
1 parent 6b8361d commit 95ced76

8 files changed

Lines changed: 259 additions & 14 deletions

File tree

‎packages/opencode/src/altimate/tools/datamate.ts‎

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { Log } from "@/altimate/util/log"
1515
import { DATAMATE_KEY, readDatamateTransportFromIde } from "../datamate-transport"
1616
// altimate_change - workspace mode owns the datamate key
1717
import { managedWorkspaceLoaded } from "../workspace/engine-overlay"
18+
// altimate_change - extension-type rows depend on a live IDE bridge
19+
import { liveBridge } from "../workspace/engine-probes"
1820

1921
const log = Log.create({ service: "datamate" })
2022

@@ -142,33 +144,41 @@ async function handleListIntegrations() {
142144
try {
143145
const catalog = await AltimateApi.listIntegrations()
144146
// altimate_change start — extension-type integrations are RPC into a live VS
145-
// Code host and cannot work from the CLI. Hide them from this surface (the
146-
// workspace UI still offers them) and say how many were hidden.
147-
const integrations = catalog.filter((i) => i.type !== "extension")
147+
// Code host. With a bridge running for this project they serve from the CLI
148+
// like any other integration, so list them; without one, keep them out of
149+
// the table and say how they come back — not that they never can. E2E
150+
// (2026-09-03) proved the full chain: compile_model/run_model over the
151+
// bridge materialized a model on the warehouse from a headless run.
152+
const extension = catalog.filter((i) => i.type === "extension")
153+
const bridged = extension.length > 0 && liveBridge(projectRoot())
154+
const integrations = bridged ? catalog : catalog.filter((i) => i.type !== "extension")
148155
const hidden = catalog.length - integrations.length
149-
const omitted =
150-
hidden > 0
151-
? `${hidden} extension-type integration${hidden === 1 ? " was" : "s were"} omitted — they require a live VS Code bridge and are not available from the CLI.`
156+
const footer = bridged
157+
? `${extension.length} extension-type integration${extension.length === 1 ? " is" : "s are"} served via the connected VS Code window.`
158+
: hidden > 0
159+
? `${hidden} extension-type integration${hidden === 1 ? " was" : "s were"} omitted — they serve while VS Code with the Altimate extension is open on this project.`
152160
: ""
153161
if (integrations.length === 0) {
154162
return {
155163
title: hidden > 0 ? `Integrations: none available on the CLI (${hidden} hidden)` : "Integrations: none found",
156-
metadata: { count: 0, hidden },
157-
output: omitted ? `No integrations available. ${omitted}` : "No integrations available.",
164+
metadata: { count: 0, hidden, bridge: bridged },
165+
output: footer ? `No integrations available. ${footer}` : "No integrations available.",
158166
}
159167
}
168+
const extensionIds = new Set(extension.map((i) => i.id))
160169
// altimate_change end
161170
const lines = ["ID | Name | Tools", "---|------|------"]
162171
for (const i of integrations) {
163172
const tools = i.tools?.map((t) => t.key).join(", ") ?? "none"
164-
lines.push(`${i.id} | ${i.name} | ${tools}`)
173+
// altimate_change — mark the rows the IDE bridge serves
174+
lines.push(`${i.id} | ${i.name}${extensionIds.has(i.id) ? " (via VS Code)" : ""} | ${tools}`)
165175
}
166176
// altimate_change start
167-
if (omitted) lines.push("", `(${omitted})`)
177+
if (footer) lines.push("", `(${footer})`)
168178
// altimate_change end
169179
return {
170180
title: `Integrations: ${integrations.length} available`,
171-
metadata: { count: integrations.length, hidden },
181+
metadata: { count: integrations.length, hidden, bridge: bridged },
172182
output: lines.join("\n"),
173183
}
174184
} catch (e) {

‎packages/opencode/src/altimate/workspace/engine-overlay.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
REPAIRABLE,
4444
TOOL_PREFIX,
4545
clearsFloor,
46+
describeExtensionServed,
4647
describeMissing,
4748
describeRefusal,
4849
engineEntry,
@@ -650,6 +651,10 @@ async function reconcile(sessionID: string, directory: string, state: DirectoryS
650651
// tools beyond the allowlist (knowledge, memory) when the workspace enables
651652
// them, so the "N of M declared" line counts only the declared ones present.
652653
const served = declared ? declared.keys.length - (missing?.length ?? 0) : present.size
654+
// Extension-declared tools appear in `present` only while the engine holds a
655+
// live IDE bridge; when they do they are real capability and the line names
656+
// them, but their absence is the normal no-IDE case, never `missing`.
657+
const extServed = declared ? declared.extensionKeys.filter((k) => present.has(k)).length : 0
653658
const outcome: Outcome = {
654659
kind: "attached",
655660
available: present.size,
@@ -671,7 +676,7 @@ async function reconcile(sessionID: string, directory: string, state: DirectoryS
671676
await notify({
672677
title: `Workspace "${workspace.name}"`,
673678
message: declared
674-
? `${served} of ${declared.keys.length} declared integration tools available.${describeMissing(missing ?? [])}`
679+
? `${served} of ${declared.keys.length} declared integration tools available.${describeMissing(missing ?? [])}${describeExtensionServed(extServed)}`
675680
: `${outcome.available} integration tools available.`,
676681
variant: missing && missing.length > 0 ? "warning" : "info",
677682
})

‎packages/opencode/src/altimate/workspace/engine-probes.ts‎

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
//
33
// Everything that asks the outside world a question: the binary, its
44
// version, the workspace allowlist, and the user-facing surfaces.
5-
import { statSync } from "fs"
5+
import { readFileSync, readdirSync, statSync } from "fs"
6+
import { homedir } from "os"
7+
import { isAbsolute, join, relative, resolve } from "path"
68
import launch from "cross-spawn"
79
import { which as whichBinary } from "@opencode-ai/core/util/which"
810
import { AltimateApi } from "@/altimate/api/client"
@@ -164,6 +166,53 @@ export async function declaredBounded(workspaceId: string): Promise<Declared | n
164166
}
165167
}
166168

169+
/** Whether a live VS Code bridge would serve `cwd`, resolved the way the
170+
* engine resolves it at spawn (see the engine's extensionRpcDiscovery): a
171+
* sidecar whose recorded workspaceFolders contain `cwd`, else the sole live
172+
* bridge. Read-only — a dead pid is skipped, never unlinked; GC of stale
173+
* sidecars belongs to the engine and the extension. Presentation only: the
174+
* engine remains the authority on what actually connects. */
175+
export function liveBridge(cwd: string, dir: string = join(homedir(), ".altimate", "extension-rpc")): boolean {
176+
if (syncInternals.liveBridge) return syncInternals.liveBridge(cwd)
177+
const bridges: string[][] = []
178+
try {
179+
for (const entry of readdirSync(dir)) {
180+
if (!entry.endsWith(".json")) continue
181+
try {
182+
const data = JSON.parse(readFileSync(join(dir, entry), "utf8")) as {
183+
socketPath?: string
184+
workspaceFolders?: string[]
185+
pid?: number
186+
}
187+
if (!data.socketPath) continue
188+
if (typeof data.pid === "number" && !pidAlive(data.pid)) continue
189+
bridges.push(data.workspaceFolders ?? [])
190+
} catch {
191+
// An unreadable sidecar is not a live bridge.
192+
}
193+
}
194+
} catch {
195+
return false
196+
}
197+
if (bridges.length === 0) return false
198+
const within = (folder: string) => {
199+
const rel = relative(resolve(folder), resolve(cwd))
200+
return rel === "" || (!rel.startsWith("..") && !isAbsolute(rel))
201+
}
202+
if (bridges.some((folders) => folders.some(within))) return true
203+
return bridges.length === 1
204+
}
205+
206+
function pidAlive(pid: number): boolean {
207+
try {
208+
process.kill(pid, 0)
209+
return true
210+
} catch (err) {
211+
// EPERM is a live process owned by someone else.
212+
return (err as NodeJS.ErrnoException).code === "EPERM"
213+
}
214+
}
215+
167216
export async function notify(toast: Toast): Promise<void> {
168217
if (syncInternals.notify) return syncInternals.notify(toast)
169218
try {

‎packages/opencode/src/altimate/workspace/engine-seams.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const syncInternals: {
2727
versionOf?: (bin: string) => Promise<string | null>
2828
fingerprint?: (bin: string) => string | null
2929
declared?: (workspaceId: string) => Promise<Declared | null>
30+
liveBridge?: (cwd: string) => boolean
3031
notify?: (toast: Toast) => Promise<void>
3132
printLine?: (line: string) => void
3233
/** Install-offer seams (see engine-offer.ts). */

‎packages/opencode/src/altimate/workspace/engine-types.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ export function describeMissing(missing: string[]): string {
214214
return ` Declared but not available: ${shown}${more}.`
215215
}
216216

217+
/** Extension-declared tools a connected IDE bridge is actually serving. Zero
218+
* is the normal no-IDE case and says nothing — absent extension tools are
219+
* expected, not missing, so they never join `describeMissing`. */
220+
export function describeExtensionServed(count: number): string {
221+
if (count === 0) return ""
222+
return ` Plus ${count} extension tool${count === 1 ? "" : "s"} via the connected VS Code window.`
223+
}
224+
217225
/** What each outcome MEANS, as tables over the whole union: a new variant
218226
* fails to compile until every table names it, and the safe answer is false. */
219227
export const SERVING: Record<Outcome["kind"], boolean> = {
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// altimate_change - new file
2+
//
3+
// `datamate_manager list-integrations` and extension-type rows. Extension
4+
// integrations are RPC into a live VS Code host: with a bridge running for
5+
// this project they serve from the CLI like any other integration; without
6+
// one they are dormant, not impossible. The listing must say which of those
7+
// is true rather than a blanket "not available from the CLI".
8+
import { afterEach, describe, expect, test } from "bun:test"
9+
import { initTool } from "../tool-fixture"
10+
import { tmpdir } from "../../fixture/fixture"
11+
import { Instance } from "../../../src/project/instance"
12+
import { AltimateApi } from "../../../src/altimate/api/client"
13+
import { DatamateManagerTool } from "../../../src/altimate/tools/datamate"
14+
import { syncInternals } from "../../../src/altimate/workspace/engine-seams"
15+
import { SessionID, MessageID } from "../../../src/session/schema"
16+
17+
const ctx = {
18+
sessionID: SessionID.make("ses_test"),
19+
messageID: MessageID.make("msg_test"),
20+
callID: "call_test",
21+
agent: "build",
22+
abort: AbortSignal.any([]),
23+
messages: [],
24+
metadata: () => {},
25+
ask: async () => {},
26+
}
27+
28+
const CATALOG = [
29+
{ id: "snowflake", name: "Snowflake", type: "connection", tools: [{ key: "execute_query" }] },
30+
{
31+
id: "power-user-for-dbt",
32+
name: "Power User for dbt",
33+
type: "extension",
34+
tools: [{ key: "compile_model" }, { key: "run_model" }],
35+
},
36+
]
37+
38+
const originalList = AltimateApi.listIntegrations
39+
const originalIsConfigured = AltimateApi.isConfigured
40+
41+
afterEach(() => {
42+
;(AltimateApi as unknown as { listIntegrations: typeof originalList }).listIntegrations = originalList
43+
;(AltimateApi as unknown as { isConfigured: typeof originalIsConfigured }).isConfigured = originalIsConfigured
44+
for (const key of Object.keys(syncInternals)) delete (syncInternals as Record<string, unknown>)[key]
45+
})
46+
47+
function serveCatalog(catalog: unknown[] = CATALOG): void {
48+
;(AltimateApi as unknown as { isConfigured: () => Promise<boolean> }).isConfigured = async () => true
49+
;(AltimateApi as unknown as { listIntegrations: () => Promise<unknown> }).listIntegrations = async () => catalog
50+
}
51+
52+
async function list() {
53+
await using tmp = await tmpdir()
54+
return await Instance.provide({
55+
directory: tmp.path,
56+
fn: async () => {
57+
const tool = await initTool(DatamateManagerTool)
58+
return tool.execute({ operation: "list-integrations" }, ctx as any)
59+
},
60+
})
61+
}
62+
63+
describe("datamate_manager list-integrations and extension-type integrations", () => {
64+
test("without a bridge they are omitted with copy that says how they come back", async () => {
65+
serveCatalog()
66+
syncInternals.liveBridge = () => false
67+
const result = await list()
68+
expect(result.metadata).toMatchObject({ count: 1, hidden: 1, bridge: false })
69+
expect(result.output).toContain("snowflake | Snowflake")
70+
expect(result.output).not.toContain("power-user-for-dbt")
71+
expect(result.output).toContain(
72+
"1 extension-type integration was omitted — they serve while VS Code with the Altimate extension is open on this project.",
73+
)
74+
expect(result.output).not.toContain("not available from the CLI")
75+
})
76+
77+
test("with a live bridge they are listed, marked, and counted", async () => {
78+
serveCatalog()
79+
syncInternals.liveBridge = () => true
80+
const result = await list()
81+
expect(result.metadata).toMatchObject({ count: 2, hidden: 0, bridge: true })
82+
expect(result.output).toContain("power-user-for-dbt | Power User for dbt (via VS Code) | compile_model, run_model")
83+
expect(result.output).toContain("1 extension-type integration is served via the connected VS Code window.")
84+
expect(result.title).toBe("Integrations: 2 available")
85+
})
86+
87+
test("a catalog with no extension rows never probes for a bridge", async () => {
88+
serveCatalog([CATALOG[0]])
89+
syncInternals.liveBridge = () => {
90+
throw new Error("must not probe")
91+
}
92+
const result = await list()
93+
expect(result.metadata).toMatchObject({ count: 1, hidden: 0, bridge: false })
94+
expect(result.output).not.toContain("extension-type")
95+
})
96+
})

‎packages/opencode/test/altimate/workspace/engine-overlay.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,21 @@ describe("beforeTurn — what a turn boundary does", () => {
425425
expect(h.toasts[0].message).toBe("2 integration tools available.")
426426
})
427427

428+
test("extension tools a live bridge serves are announced; absent ones are expected, not missing", async () => {
429+
const h = install({
430+
tools: { datamate_dbt_build_model: {}, datamate_dbt_compile_model: {}, datamate_get_projects: {} },
431+
declared: { keys: ["dbt_build_model", "dbt_compile_model"], extensionKeys: ["get_projects", "run_model"] },
432+
})
433+
await beforeTurn("s1")
434+
// `run_model` is declared extension-type but no bridge serves it: that is
435+
// the normal no-IDE case, so the outcome stays clean and unwarned.
436+
expect(settledOutcome("s1")).toEqual({ kind: "attached", available: 3, declared: 2, missing: [] })
437+
expect(h.toasts[0].message).toBe(
438+
"2 of 2 declared integration tools available. Plus 1 extension tool via the connected VS Code window.",
439+
)
440+
expect(h.toasts[0].variant).toBe("info")
441+
})
442+
428443
test("the inventory is announced per session, not per process", async () => {
429444
const h = install({})
430445
await beforeTurn("s1")

‎packages/opencode/test/altimate/workspace/engine-probes.test.ts‎

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { describe, expect, test } from "bun:test"
66
import { chmodSync, mkdtempSync, statSync, utimesSync, writeFileSync } from "node:fs"
77
import os from "node:os"
88
import path from "node:path"
9-
import { fingerprint, versionOf } from "../../../src/altimate/workspace/engine-probes"
9+
import { fingerprint, liveBridge, versionOf } from "../../../src/altimate/workspace/engine-probes"
1010

1111
const posix = process.platform !== "win32"
1212

@@ -59,3 +59,64 @@ describe("versionOf", () => {
5959
expect(await versionOf(path.join(os.tmpdir(), "definitely-not-here-" + process.pid))).toBeNull()
6060
})
6161
})
62+
63+
describe("liveBridge", () => {
64+
// A pid above any realistic pid_max, so the liveness check reports it dead —
65+
// the same trick the engine's own discovery tests use.
66+
const DEAD_PID = 2 ** 31 - 1
67+
68+
function sidecars(entries: Record<string, object>): string {
69+
const dir = mkdtempSync(path.join(os.tmpdir(), "bridge-sidecar-"))
70+
for (const [name, data] of Object.entries(entries)) {
71+
writeFileSync(path.join(dir, name), JSON.stringify(data))
72+
}
73+
return dir
74+
}
75+
76+
test("a live bridge recording this directory is found, from the folder or below it", () => {
77+
const cwd = mkdtempSync(path.join(os.tmpdir(), "bridge-ws-"))
78+
// A second live bridge keeps the single-bridge fallback out of play, so
79+
// these assertions exercise the cwd match alone.
80+
const dir = sidecars({
81+
"a.json": { socketPath: "/tmp/a.sock", workspaceFolders: [cwd], pid: process.pid },
82+
"b.json": { socketPath: "/tmp/b.sock", workspaceFolders: ["/somewhere/else"], pid: process.pid },
83+
})
84+
expect(liveBridge(cwd, dir)).toBe(true)
85+
expect(liveBridge(path.join(cwd, "models", "staging"), dir)).toBe(true)
86+
// A sibling directory that merely shares the prefix string is not within.
87+
expect(liveBridge(cwd + "-other", dir)).toBe(false)
88+
})
89+
90+
test("a dead bridge is skipped and its sidecar is left for the engine to GC", () => {
91+
const cwd = mkdtempSync(path.join(os.tmpdir(), "bridge-ws-"))
92+
const dir = sidecars({
93+
"a.json": { socketPath: "/tmp/a.sock", workspaceFolders: [cwd], pid: DEAD_PID },
94+
})
95+
expect(liveBridge(cwd, dir)).toBe(false)
96+
expect(statSync(path.join(dir, "a.json")).isFile()).toBe(true)
97+
})
98+
99+
test("the sole live bridge counts even for an unrelated directory; two decline to guess", () => {
100+
const cwd = mkdtempSync(path.join(os.tmpdir(), "bridge-ws-"))
101+
const one = sidecars({
102+
"a.json": { socketPath: "/tmp/a.sock", workspaceFolders: ["/somewhere/else"], pid: process.pid },
103+
})
104+
expect(liveBridge(cwd, one)).toBe(true)
105+
const two = sidecars({
106+
"a.json": { socketPath: "/tmp/a.sock", workspaceFolders: ["/somewhere/else"], pid: process.pid },
107+
"b.json": { socketPath: "/tmp/b.sock", workspaceFolders: ["/somewhere/third"], pid: process.pid },
108+
})
109+
expect(liveBridge(cwd, two)).toBe(false)
110+
})
111+
112+
test("garbage is not a bridge: no dir, no socketPath, unparseable JSON", () => {
113+
const cwd = mkdtempSync(path.join(os.tmpdir(), "bridge-ws-"))
114+
expect(liveBridge(cwd, path.join(os.tmpdir(), "no-such-dir-" + process.pid))).toBe(false)
115+
const dir = sidecars({
116+
"no-sock.json": { workspaceFolders: [cwd], pid: process.pid },
117+
})
118+
writeFileSync(path.join(dir, "broken.json"), "{not json")
119+
writeFileSync(path.join(dir, "not-a-sidecar.txt"), "ignored")
120+
expect(liveBridge(cwd, dir)).toBe(false)
121+
})
122+
})

0 commit comments

Comments
 (0)