Port the useful dynamic-vault MCP direction from Domenico Lupinetti's proposal into the current mounted-workspace model. Durable external MCP registration is now vault-neutral, Node MCP resolves active mounted vaults from explicit env or Tolaria vaults.json, and vault context includes root AGENTS.md instructions per active vault. Based-on: https://github.com/refactoringhq/tolaria/pull/603 Co-authored-by: Domenico Lupinetti <domenico@translated.net>
24 lines
621 B
JavaScript
24 lines
621 B
JavaScript
import { readFile } from 'node:fs/promises'
|
|
import path from 'node:path'
|
|
import { vaultContext } from './vault.js'
|
|
|
|
export async function readAgentInstructions(vaultPath) {
|
|
const instructionsPath = path.join(vaultPath, 'AGENTS.md')
|
|
try {
|
|
return {
|
|
path: instructionsPath,
|
|
content: await readFile(instructionsPath, 'utf8'),
|
|
}
|
|
} catch (error) {
|
|
if (error?.code === 'ENOENT') return null
|
|
throw error
|
|
}
|
|
}
|
|
|
|
export async function vaultContextWithInstructions(vaultPath) {
|
|
return {
|
|
...(await vaultContext(vaultPath)),
|
|
agentInstructions: await readAgentInstructions(vaultPath),
|
|
}
|
|
}
|