Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 4x 4x 4x 4x 100x 12x 12x 12x 12x 100x 4x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 3x 3x 2x 2x 3x 3x 3x 2x 2x 2x 3x 3x 3x 3x 2x 2x 2x 2x 3x 1x 1x 2x 2x | import * as fs from "node:fs" import * as path from "node:path" import { spawnSync } from "node:child_process" import type * as vscode from "vscode" const KIT_MARKER = path.join(".agent", "MERIDIAN.md") export function bundledKitAgentDir(extensionPath: string): string { const bundled = path.join(extensionPath, "bundled", "kit", ".agent") if (fs.existsSync(path.join(bundled, "MERIDIAN.md"))) { return bundled } const monorepoAgent = path.join(extensionPath, "..", ".agent") if (fs.existsSync(path.join(monorepoAgent, "MERIDIAN.md"))) { return monorepoAgent } return bundled } export function workspaceProjectRoot( folders: readonly vscode.WorkspaceFolder[] | undefined, ): string | null { const first = folders?.[0] return first ? path.resolve(first.uri.fsPath) : null } function appendGitignoreAdapterEntries(gitignorePath: string): void { const entries = [".cursor/", ".claude/", ".agents/skills/", ".codex/", "AGENTS.md"] if (!fs.existsSync(gitignorePath)) { fs.writeFileSync( gitignorePath, "# Meridian IDE adapters (local symlinks)\n.cursor/\n.claude/\n.agents/skills/\n.codex/\nAGENTS.md\n", "utf8", ) return } const content = fs.readFileSync(gitignorePath, "utf8") let next = content for (const entry of entries) { if (content.split("\n").some((line) => line.trim() === entry)) { continue } if (!next.includes("Meridian IDE adapters")) { next += "\n# Meridian IDE adapters (local symlinks)\n" } next += `${entry}\n` } if (next !== content) { fs.writeFileSync(gitignorePath, next, "utf8") } } function chmodScripts(agentDir: string): void { const scriptsDir = path.join(agentDir, "scripts") if (!fs.existsSync(scriptsDir)) { return } for (const name of fs.readdirSync(scriptsDir)) { if (name.endsWith(".sh")) { try { fs.chmodSync(path.join(scriptsDir, name), 0o755) } catch { /* Windows may ignore */ } } } } function runAdapterSync(projectRoot: string, agentDir: string): string | null { const syncScript = path.join(agentDir, "scripts", "sync_cursor_kit.sh") if (!fs.existsSync(syncScript)) { return "sync_cursor_kit.sh not found in installed kit" } chmodScripts(agentDir) const bash = process.platform === "win32" ? "bash" : "bash" const result = spawnSync(bash, [syncScript], { cwd: projectRoot, encoding: "utf8", shell: false, }) if (result.status !== 0) { const err = (result.stderr || result.stdout || "").trim() return err || `sync exited with code ${result.status}` } return null } export type InstallKitResult = { ok: boolean message: string projectRoot: string } function runBootstrapDb(projectRoot: string, agentDir: string): string | null { const script = path.join(agentDir, "scripts", "bootstrap_meridian_db.py") if (!fs.existsSync(script)) { return null } const docs = path.join(projectRoot, "docs", "00_scope.md") if (!fs.existsSync(docs)) { return null } const python = process.platform === "win32" ? "python" : "python3" const result = spawnSync(python, [script, projectRoot], { cwd: projectRoot, encoding: "utf8", shell: false, }) if (result.status !== 0) { const err = (result.stderr || result.stdout || "").trim() return err || `bootstrap exited with code ${result.status}` } return (result.stdout || "").trim() || null } export function installBundledKit( projectRoot: string, extensionPath: string, options: { force?: boolean } = {}, ): InstallKitResult { const root = path.resolve(projectRoot) const src = bundledKitAgentDir(extensionPath) const dest = path.join(root, ".agent") if (!fs.existsSync(path.join(src, "MERIDIAN.md"))) { return { ok: false, message: `Bundled kit missing in extension at ${src}. Reinstall the extension.`, projectRoot: root, } } if (fs.existsSync(dest) && !options.force) { return { ok: false, message: ".agent/ already exists. Use Upgrade harness (force) to replace the kit and refresh adapters.", projectRoot: root, } } try { fs.cpSync(src, dest, { recursive: true, force: true }) chmodScripts(dest) } catch (err) { const msg = err instanceof Error ? err.message : String(err) return { ok: false, message: `Failed to copy kit: ${msg}`, projectRoot: root } } appendGitignoreAdapterEntries(path.join(root, ".gitignore")) const syncError = runAdapterSync(root, dest) const bootstrapMsg = runBootstrapDb(root, dest) const bootstrapNote = bootstrapMsg ? ` SQLite: ${bootstrapMsg}.` : "" if (syncError) { return { ok: true, message: `Kit installed at ${dest}. Adapter sync failed (${syncError}) — run .agent/scripts/sync_cursor_kit.sh manually.${bootstrapNote}`, projectRoot: root, } } return { ok: true, message: `Meridian harness installed: ${dest} (agents, skills, workflows) + IDE adapters synced.${bootstrapNote}`, projectRoot: root, } } export function kitInstalledAt(projectRoot: string): boolean { return fs.existsSync(path.join(path.resolve(projectRoot), KIT_MARKER)) } |