Agent interop
This page is synchronized from
CurateLabs/graphforge-vscodeat revision7da03dd66908.
Every command in commands.md is a stable ID callable via
vscode.commands.executeCommand("graphforge.<id>", ...) — no Command Palette click required.
This makes GraphForge drivable end-to-end by an in-editor coding agent (a Cursor agent, GitHub
Copilot Agent Mode, or any other extension calling the VS Code command API), not just by a
human clicking through menus.
The core loop
Section titled “The core loop”flowchart TD A["checkEnvironment({ silent: true })"] -->|runtime.active == 'none'| B["setupNativeBinding or setupPythonBinding"] A -->|project.open == false| C["initializeProjectHere or openProject(path)"] A -->|runtime + project ready| D["runQuery({ cypher, params }) or a verb command"] B --> A C --> A D -->|result.error present| B D -->|success| E["Read the result from the return value or the opened document"]- Check Environment —
executeCommand("graphforge.checkEnvironment", { silent: true }). Inspectruntime.active("node" | "python" | "none"),nodeBinding.available,python.available, andproject.open; the returnednextActionstring always names the exact next command to run. - Setup / Init if needed — if no runtime is usable, run
graphforge.setupNativeBindingand/orgraphforge.setupPythonBinding. If a runtime is ready but no project is open, rungraphforge.initializeProjectHere(new project) orgraphforge.openProject(path)(existing project —pathis a plain string arg, no picker needed). Re-run step 1 to confirm. - Run Query / Rank — call
graphforge.runQuery({ cypher, params })for Cypher, or one of the analyst verb commands (these still walk a QuickPick today). - Read the result — either the
executeCommandreturn value, or the opened JSON document the command also writes for a human pairing with the agent. On failure, the returned object’serror/code/nextActionfields tell you exactly what to do next — never a bare exception or a silent no-op.
What’s structured vs. interactive
Section titled “What’s structured vs. interactive”| Command | Accepts args to skip prompts | Returns |
|---|---|---|
graphforge.checkEnvironment |
{ silent?: boolean } |
EnvironmentReport always |
graphforge.openProject |
pathArg?: string |
— |
graphforge.runQuery / runQueryWithParams |
{ cypher?: string; params?: Record<string, unknown> } |
QueryResult ({ columns, rows, rowCount, algorithm? }) or a structured { error, code?, nextAction } |
graphforge.rank / cluster / paths / analyze / similar / find (and …Advanced…) |
Not yet — still QuickPick-driven | Verb result object ({ verb, by, label, columns, rows, rowCount, algorithm? }), { error }, or { cancelled: true } |
graphforge.setupNativeBinding / setupPythonBinding / initializeProjectHere / loadOntology / showResultGraphAdvanced |
No — these are inherently human choices (which folder, which binding source) | — |
For a command not listed above, treat it as QuickPick/dialog-driven unless
src/test/extension.test.ts (source of truth, in the repository) says otherwise.
Runtime awareness
Section titled “Runtime awareness”graphforge.runtime (default auto) selects which engine backs a given call — see
install.md for the full Node-vs-Python policy. An agent that needs the advanced
Node-only surfaces (checkpoints, embedding spaces, indexing, invocation descriptors, composite
transactions, knowledge-ledger writes) should check nodeBinding.available from
checkEnvironment before calling them, since the Python bridge does not back those yet.