{"version":3,"file":"plugin-canvases.d.ts","sourceRoot":"","sources":["../../../src/core/canvas/plugin-canvases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,OAAO,EAAqB,KAAK,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEnF;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAsB,GAAG,yBAAyB,EAAE,CAejH","sourcesContent":["/**\n * Canvas extensions that arrive inside an installed plugin.\n *\n * Design: `docs/canvas-extensions-design.md` §4.3. Discovery's three search roots\n * (`.agents/extensions`, `.github/extensions`, `~/.copilot/extensions`) describe\n * where a person *puts* a canvas by hand. They say nothing about where a package\n * manager puts one, and a plugin install lands in `~/.agents/plugins/<name>/`\n * instead — so a canvas plugin installed exactly as instructed was copied to disk\n * intact and then never listed, because nothing looked there.\n *\n * The plugin readers already resolve each plugin's canvas directories\n * (`NormalizedPlugin.canvasExtensions`), so this module is only the join: read\n * the plugins on the discovery path, and present their canvases in the shape\n * `discovery.ts` produces for everything else. Keeping the shape identical is\n * what lets the trust gate, the listing and `open` stay unaware that a plugin was\n * involved at all.\n */\n\nimport * as path from \"node:path\";\nimport { getAgentDir } from \"../../config.js\";\nimport { defaultPluginDirs } from \"../extensions/loader.js\";\nimport { discoverPlugins } from \"../extensions/plugins/index.js\";\nimport { pluginScopeOf } from \"../extensions/plugins/locations.js\";\nimport { CANVAS_ENTRY_FILE, type DiscoveredCanvasExtension } from \"./discovery.js\";\n\n/**\n * Canvases shipped by every plugin on the discovery path.\n *\n * Scope is derived from where the plugin lives, not from the canvas directory:\n * a plugin installed at project scope (or committed into the working tree) is\n * repository-supplied whichever subdirectory its canvas sits in, and that is the\n * question the trust gate asks. `pluginScopeOf`'s third answer, `repo`, folds\n * into `project` here — for a canvas the two mean the same thing, since neither\n * can distinguish \"I put this here\" from \"this arrived in the clone\".\n */\nexport function pluginCanvasExtensions(cwd: string, agentDir: string = getAgentDir()): DiscoveredCanvasExtension[] {\n\tconst found: DiscoveredCanvasExtension[] = [];\n\tfor (const plugin of discoverPlugins(defaultPluginDirs(cwd, agentDir))) {\n\t\tif (!plugin.canvasExtensions?.length) continue;\n\t\tconst scope = pluginScopeOf(plugin.root, cwd) === \"user\" ? \"user\" : \"project\";\n\t\tfor (const extension of plugin.canvasExtensions) {\n\t\t\tfound.push({\n\t\t\t\tid: extension.id,\n\t\t\t\tdir: extension.dir,\n\t\t\t\tentry: path.join(extension.dir, CANVAS_ENTRY_FILE),\n\t\t\t\tscope,\n\t\t\t});\n\t\t}\n\t}\n\treturn found;\n}\n"]}