@agent-native/core 0.49.16 → 0.49.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/action.d.ts +8 -0
  2. package/dist/action.d.ts.map +1 -1
  3. package/dist/action.js +3 -0
  4. package/dist/action.js.map +1 -1
  5. package/dist/agent/production-agent.d.ts +4 -0
  6. package/dist/agent/production-agent.d.ts.map +1 -1
  7. package/dist/agent/production-agent.js.map +1 -1
  8. package/dist/cli/skills.d.ts +2 -2
  9. package/dist/cli/skills.d.ts.map +1 -1
  10. package/dist/cli/skills.js +13 -12
  11. package/dist/cli/skills.js.map +1 -1
  12. package/dist/extensions/web-search-tool.d.ts +28 -7
  13. package/dist/extensions/web-search-tool.d.ts.map +1 -1
  14. package/dist/extensions/web-search-tool.js +89 -6
  15. package/dist/extensions/web-search-tool.js.map +1 -1
  16. package/dist/onboarding/default-steps.js +1 -1
  17. package/dist/onboarding/default-steps.js.map +1 -1
  18. package/dist/secrets/register-framework-secrets.js +4 -4
  19. package/dist/secrets/register-framework-secrets.js.map +1 -1
  20. package/dist/server/action-discovery.d.ts.map +1 -1
  21. package/dist/server/action-discovery.js +3 -0
  22. package/dist/server/action-discovery.js.map +1 -1
  23. package/dist/server/action-routes.d.ts.map +1 -1
  24. package/dist/server/action-routes.js +34 -6
  25. package/dist/server/action-routes.js.map +1 -1
  26. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  27. package/dist/server/agent-chat-plugin.js +6 -4
  28. package/dist/server/agent-chat-plugin.js.map +1 -1
  29. package/dist/server/credential-provider.d.ts +5 -0
  30. package/dist/server/credential-provider.d.ts.map +1 -1
  31. package/dist/server/credential-provider.js +8 -0
  32. package/dist/server/credential-provider.js.map +1 -1
  33. package/dist/server/index.d.ts +1 -1
  34. package/dist/server/index.d.ts.map +1 -1
  35. package/dist/server/index.js +1 -1
  36. package/dist/server/index.js.map +1 -1
  37. package/package.json +1 -1
@@ -1 +1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AAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,aAAa,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3E,MAAM,qBAAqB,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CACzB,CAAC;QACF,MAAM,UAAU,GAAG,qBAAqB;YACtC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,mFAAmF,CAAC;QACxF,KAAK,CAAC,KAAK,CACT,0BAA0B,aAAa,IAAI,iBAAiB,wBAAwB;YAClF,8EAA8E;YAC9E,UAAU,CACb,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,SAAS,CAAC,KAAK,CAAC,mBAAmB,EAAE;YACnC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC7D,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;SACnC,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC","sourcesContent":["/**\n * `agent-native skills` is the friendly install surface for app-backed skills.\n * The lower-level `app-skill` commands remain the packaging primitives; this\n * command handles the common \"install Assets for my agent\" path in one step.\n */\n\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { spawn } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { createCliTelemetry, type CliTelemetry } from \"./telemetry.js\";\nimport {\n buildAppSkillPack,\n ensureAppSkill,\n loadAppSkillManifest,\n normalizeAppSkillManifest,\n type AppSkillManifest,\n type LoadedAppSkillManifest,\n} from \"./app-skill.js\";\nimport {\n resolveClients,\n runConnect,\n writeConnectClientPreferences,\n} from \"./connect.js\";\nimport {\n CONTEXT_XRAY_SKILL_MD,\n installLocalContextXray,\n} from \"./context-xray-local.js\";\nimport { CLIENTS, type ClientId } from \"./mcp-config-writers.js\";\nimport { PR_VISUAL_RECAP_SETUP, writePrVisualRecapWorkflow } from \"./recap.js\";\n\nconst HELP = `npx @agent-native/core@latest skills\n\nUsage:\n npx @agent-native/core@latest skills list\n npx @agent-native/core@latest skills status [assets|design-exploration|visual-plan|visual-recap|context-xray] [--client codex|claude-code|all] [--scope user|project] [--json]\n npx @agent-native/core@latest skills update [assets|design-exploration|visual-plan|visual-recap|context-xray] [--client codex|claude-code|all] [--scope user|project] [--dry-run] [--json]\n npx @agent-native/core@latest skills add assets|design-exploration|visual-plan|visual-recap|context-xray [--client codex|claude-code|claude-code-cli|cowork|all] [--scope user|project] [--mcp-url <url>] [--no-connect] [--with-github-action] [--yes] [--dry-run] [--json]\n npx @agent-native/core@latest skills add <manifest-or-app-dir|skill-repo> [--skill <name>] [--client ...] [--yes]\n\nExamples:\n npx @agent-native/core@latest skills add assets\n npx @agent-native/core@latest skills add design-exploration\n npx @agent-native/core@latest skills add visual-plan\n npx @agent-native/core@latest skills add visual-recap\n npx @agent-native/core@latest skills add visual-recap --with-github-action\n npx @agent-native/core@latest skills status visual-plan\n npx @agent-native/core@latest skills update visual-plan\n npx @agent-native/core@latest skills add visual-plan --no-connect\n npx @agent-native/core@latest skills add context-xray --client all\n npx @agent-native/core@latest skills add assets --client claude-code\n npx @agent-native/core@latest skills add assets --mcp-url https://my-app.ngrok-free.dev\n npx @agent-native/core@latest skills add ./dist/assets-skill --client codex\n npx @agent-native/core@latest skills add BuilderIO/skills --client codex --scope project\n npx @agent-native/core@latest skills add BuilderIO/skills --with-github-action\n\nThe add command installs the SKILL.md instructions, registers the app-backed\nMCP connector, and then authenticates it in one step so you do not hit an OAuth\nwall on the first tool call. By default, add targets every supported local\nclient this CLI can configure (Claude Code, Claude Code CLI, Codex, and Cowork);\npass --client to narrow it. Authentication reuses \"npx @agent-native/core@latest connect\":\nOAuth-capable clients (Claude Code) get a URL-only entry and a /mcp authenticate\nprompt, while Codex / Cowork run the browser device-code flow. In a\nnon-interactive shell or CI the auth step is skipped and the exact\n\"npx @agent-native/core@latest connect <url> --client all\" command is printed instead.\n\nRunning \"npx @agent-native/skills@latest add ...\" directly installs instructions only;\nuse this Agent Native CLI path when you want MCP setup and auth too. Pass --no-connect to\nregister the connector without authenticating (leave auth to the host or run\n\"npx @agent-native/core@latest connect\" later). Pass --mcp-url to register that connector against\na custom origin (an ngrok tunnel, a local dev server, or a self-hosted\ndeployment) instead of the built-in hosted default — a bare origin gets the\nstandard /_agent-native/mcp path appended. Use app-skill pack for marketplace\nbundles and custom adapter output.\n\nWhen installing visual-recap interactively, the CLI offers to add the optional PR\nVisual Recap GitHub Action. Pass --with-github-action to write it directly, then\nrun \"npx @agent-native/core@latest recap setup\" / \"npx @agent-native/core@latest recap doctor\" to configure and\nverify GitHub Actions.\n\nThe status/update commands inspect copied Agent Native skill folders and refresh\ntheir instruction files from the current @agent-native/core package.`;\n\nconst ASSETS_SKILL_MD = `---\nname: assets\ndescription: >-\n Use Assets for image or video generation requests, brand-safe media,\n human picker UI, search/list/export actions, and cross-app asset selection.\n Prefer this over generic image tools when installed.\nmetadata:\n visibility: exported\n---\n\n# Assets\n\nUse the Assets app when a workflow needs reusable brand media, a human picker,\nor generated image/video assets that another app can reference by ID and URL.\nWhen this skill is available, route plain image-generation requests here instead\nof using a generic image generator.\n\n## Choose The Path\n\n- Use \\`open-asset-picker\\` when a person should browse, search, generate, and\n select an asset in UI. Pass \\`mediaType: \"image\"\\` by default, or\n \\`mediaType: \"video\"\\` for video libraries. When the user asks to create a\n specific image and choose the best option, pass \\`prompt\\`,\n \\`autoGenerate: true\\`, and \\`count: 3\\` so the picker opens with candidates\n to preview and select.\n- Use unattended actions when the agent already knows what to do:\n \\`search-assets\\`, \\`list-assets\\`, \\`generate-image\\`,\n \\`generate-image-batch\\`, \\`generate-video\\`,\n \\`refresh-generation-run\\`, and \\`export-asset\\`.\n- Use browser/deep-link fallback when the host cannot render MCP Apps inline.\n Surface the returned picker link. If it opens in a normal browser tab, have\n the user select an asset there and paste back the copied handoff summary.\n Treat Codex, Claude Code, and Claude Desktop Code as link-out hosts; do not\n promise inline MCP App rendering there.\n If the skill instructions are available but the MCP tool namespace has not\n appeared yet, use the Assets browser fallback URL shape instead of switching\n to a generic generator:\n \\`https://assets.agent-native.com/library?mediaType=image&prompt=...&autoGenerate=1&count=3\\`.\n When reporting the final selected image in Codex or Claude Code, include the\n asset link and, if an inline preview is important, download the selected\n \\`previewUrl\\`/\\`downloadUrl\\` to a local temp image and embed that absolute\n local path. Remote CDN markdown images can fail to render in code-editor chat\n surfaces.\n\n## Image And Video Workflows\n\n1. Pick or match the library with \\`list-libraries\\` or \\`match-library\\`.\n2. For images, call \\`generate-image\\` or \\`generate-image-batch\\`. Image\n actions are synchronous: one batch call should return the finished image\n candidates, so do not poll or regenerate unless a returned slot failed.\n3. For videos, call \\`generate-video\\` and poll \\`refresh-generation-run\\`\n until the run completes.\n4. Preserve returned \\`assetId\\`, \\`runId\\`, \\`previewUrl\\`, \\`downloadUrl\\`,\n media type, and dimensions so the caller can attach or embed the result.\n\n## Cross-App Use\n\n- Hosted default: connect \\`https://assets.agent-native.com/_agent-native/mcp\\`.\n Do not put shared secrets in skill files.\n- For CLI/code-editor clients, keep any \\`npx @agent-native/core@latest connect\\` command\n running until browser authorization finishes. Stopping it early can leave the\n browser approved but the local MCP config unwritten. Restart or reload the\n agent client after installing or connecting if Assets tools do not appear in\n the live session.\n- Local customization: use \\`npx @agent-native/core@latest app-skill launch --local\\` from an\n Assets app-skill manifest, or pass \\`--into <path>\\` for editable source.\n- Do not call image/video providers directly from another app. Assets owns\n generation, picker UI, search/list/export, and asset context.\n- If an Assets tool call returns \\`Session terminated\\`, \\`needs auth\\`, or\n another connector/session error, do not keep retrying the tool. Stop and give\n the user the reconnect step: in Claude Code run \\`/mcp\\` and choose\n Authenticate/Reconnect for the Assets connector; from any terminal run\n \\`npx -y @agent-native/core@latest reconnect https://assets.agent-native.com\\` — this\n re-authenticates WITHOUT reinstalling. Never reinstall from scratch just to fix\n auth. Continue once the connector is available.\n- Do not hand-roll MCP HTTP requests with curl from the agent session. Use the\n host-exposed Assets tools after restart/reload, or use the returned\n browser/deep-link fallback.\n- If a batch image generation request times out in browser fallback, retry with\n \\`count: 1\\` only after telling the user the multi-candidate request timed out.\n- If you inspect local MCP config, redact \\`Authorization\\`, \\`http_headers\\`,\n and token values. Never paste bearer tokens into chat or logs.\n`;\n\nconst DESIGN_EXPLORATION_SKILL_MD = `---\nname: design-exploration\ndescription: >-\n Use Design for UI/UX exploration, side-by-side design directions,\n interactive prototype previews, user selection, iteration, and design-to-code\n handoff through the hosted Design MCP app.\nmetadata:\n visibility: exported\n---\n\n# Design Exploration\n\nUse the Design app when a workflow needs visual UI exploration, prototype\niteration, or a human-in-the-loop choice among design directions.\n\n## Choose The Path\n\n- Use \\`create-design\\` first to create a project shell. Do not report the\n design as ready until it has renderable HTML.\n- For open-ended UX exploration, generate distinct, complete HTML directions\n (2-5, three by default) and call \\`present-design-variants\\`. The inline\n Design MCP app shows the options, lets the user pick one, and persists the\n selected variant.\n- If the Design app opens as a browser link instead of inline (CLI hosts like\n Codex / Claude Code, where the deep link carries \\`handoff=chat\\`), the user\n picks a direction there and the editor shows a copyable summary — ask them to\n paste it back into chat so you can continue from the chosen direction. The\n \\`present-design-variants\\` result's \\`fallbackInstructions\\` describe this.\n- For direct refinements to an already chosen direction, call\n \\`get-design-snapshot\\`, edit from the current tuned HTML, then call\n \\`generate-design\\`.\n- Use \\`export-coding-handoff\\` when the user wants to implement the chosen\n design in a codebase.\n\n## Exploration Defaults\n\n1. Default to three variants unless the user asks for a different count\n (\\`present-design-variants\\` accepts 2-5; three is the sweet spot).\n2. Make variants structurally and stylistically distinct, not just color swaps.\n3. Each variant must be a complete standalone HTML document that renders\n without a build step.\n4. For product UI redesigns, prefer cleaner hierarchy, progressive disclosure,\n and realistic controls over decorative mockups.\n5. After \\`present-design-variants\\`, wait for the user's pick before\n generating the next version. If they say \"I like #2 but...\", snapshot the\n chosen design and refine that direction with \\`generate-design\\`.\n\n## Cross-App Use\n\n- Hosted default: connect \\`https://design.agent-native.com/_agent-native/mcp\\`.\n Do not put shared secrets in skill files.\n- For CLI/code-editor clients, keep any \\`npx @agent-native/core@latest connect\\` command\n running until browser authorization finishes. Stopping it early can leave the\n browser approved but the local MCP config unwritten. Restart or reload the\n agent client after installing or connecting if Design tools do not appear in\n the live session.\n- Dispatch can expose Design alongside other apps. Use Design for UI/UX design\n tasks, Assets for image/media selection, Slides for decks, and so on.\n- Keep the loop visual: surface the inline MCP App or the returned \"Open\n design\" link instead of pasting large HTML blobs into chat.\n- If a Design tool call returns \\`Session terminated\\`, \\`needs auth\\`, or\n another connector/session error, do not keep retrying the tool. Stop and give\n the user the reconnect step: in Claude Code run \\`/mcp\\` and choose\n Authenticate/Reconnect for the Design connector; from any terminal run\n \\`npx -y @agent-native/core@latest reconnect https://design.agent-native.com\\` — this\n re-authenticates WITHOUT reinstalling. Never reinstall from scratch just to fix\n auth. Continue once the connector is available.\n- Do not hand-roll MCP HTTP requests with curl from the agent session. Use the\n host-exposed Design tools after restart/reload, or use the returned\n browser/deep-link fallback.\n- If you inspect local MCP config, redact \\`Authorization\\`, \\`http_headers\\`,\n and token values. Never paste bearer tokens into chat or logs.\n`;\n\n/**\n * Setup/auth block for the `/visual-plan` skill. Interpolated into\n * `VISUAL_PLANS_SKILL_MD` below so the install + one-step authenticate\n * instructions are single-sourced. The materialized SKILL.md copies under\n * `templates/plan/.agents/skills/*`, top-level `skills/*`, and\n * `.agents/skills/*` are guarded byte-identical by `skills.sync.spec.ts`.\n */\nconst PLAN_SETUP_AUTH_MD = `## Setup & Authentication\n\nThere are two ways into Plans.\n\n**Coding agent (CLI).** Install once with the Agent-Native CLI. The command\ninstalls the Plans skills, registers the hosted Plans MCP connector, and runs\nauth/setup for the selected local client(s) in the same step (a one-time browser\nsign-in at setup — this is intended), so the first tool call in that client does\nnot hit an OAuth wall:\n\n\\`\\`\\`bash\nnpx @agent-native/core@latest skills add visual-plan\n\\`\\`\\`\n\nAfter that, \\`/visual-plan\\` and \\`/visual-recap\\` are the two installed slash\ncommands. The other planning modes (\\`create-ui-plan\\`, \\`create-prototype-plan\\`,\n\\`create-plan-design\\`, \\`create-visual-questions\\`) are MCP tools reachable from\n\\`/visual-plan\\`, not separate slash commands. Pass \\`--no-connect\\` to register\nthe connector without authenticating, then run\n\\`npx @agent-native/core@latest connect https://plan.agent-native.com --client all\\`\nwhenever you are ready, or choose a narrower \\`--client\\`. Auth and MCP tool\nloading are per client config/session.\n\n**Browser (people you share with).** Open the Plans editor and create & edit\nwith no sign-up — you work as a guest. Sign in only when you want to save or\nshare; signing in claims the plans you made as a guest into your account.\n\nSharing and commenting require an account: public/shared plans are viewable by\nanyone with the link, but commenting on them needs an agent-native account.\n\nFor fully offline, no-account use, run the Plans app locally and sync plans to\nyour repo as MDX. This local mode is a separate advanced path, not the default\nhosted flow.\n\nIf a Plans tool returns \\`needs auth\\`, \\`Unauthorized\\`, or \\`Session terminated\\`,\ndo not keep retrying the tool. Stop and give the user the reconnect step for the\nclient they are using: Codex/Codex Desktop should run\n\\`npx -y @agent-native/core@latest reconnect https://plan.agent-native.com --client codex\\`\nand start a new Codex session; Claude Code should run \\`/mcp\\` and choose\nAuthenticate/Reconnect for the plan connector, or run the reconnect command with\n\\`--client claude-code\\` and restart Claude. To refresh every local client config\nthat already has the Plan entry, use \\`--client all\\`, then restart/reload each\nclient. Reconnect re-authenticates WITHOUT reinstalling and finds the entry by\nURL regardless of connector name. Never reinstall from scratch just to fix auth.\nContinue once the connector is available.\n\nHosted default: connect \\`https://plan.agent-native.com/_agent-native/mcp\\`. Do\nnot put shared secrets in skill files.`;\n\n// Single-source shared cores. Each partial is a heading-less BODY string that\n// begins and ends with its own SHARED-CORE marker comment, so the marker-region\n// sync guard can extract and compare it across the skills that consume it. The\n// skill constants below interpolate these partials at module-eval time; the\n// distributed artifact stays a flat string, so distribution is unchanged.\n//\n// Consumers:\n// WIREFRAME_QUALITY_CORE — visual-plan, visual-recap (surface-agnostic)\n// CANVAS_SURFACE_CORE — visual-plan modes (canvas/artboard mechanics)\n// DOCUMENT_QUALITY_CORE — visual-plan\n// EXEMPLAR_CORE — visual-plan\n\n// Surface-agnostic HTML wireframe quality rules. Applies equally to a standalone\n// WireframeBlock/<Screen> (visual-recap) and to a canvas artboard (visual-plan).\n// Do not put canvas/artboard placement mechanics here.\nconst WIREFRAME_QUALITY_CORE = `<!-- SHARED-CORE:wireframe-quality START -->\n\n**A wireframe is an HTML mockup. The renderer owns the look; you write the\ncontent.** Set \\`data.html\\` to a self-contained, semantic HTML fragment of the\nscreen and set \\`data.surface\\`. The renderer owns the surface footprint/aspect,\nthe dark/light theme, the hand-drawn font, and the rough.js sketch overlay — you\nnever write \\`<html>\\`/\\`<body>\\`/\\`<script>\\`/\\`<style>\\` tags or any\nwidth/height/coordinates. You write real HTML layout and real product\ncontent; the renderer styles and roughens it.\n\n**A wireframe block's data is an HTML screen plus a surface:**\n\n\\`\\`\\`json\n{\n \"surface\": \"browser\",\n \"html\": \"<div style=\\\\\"display:flex;flex-direction:column;gap:10px;padding:16px;height:100%\\\\\"><h1>Sign in</h1><p class=\\\\\"wf-muted\\\\\">Use your work email to continue.</p><div class=\\\\\"wf-card\\\\\" style=\\\\\"display:flex;flex-direction:column;gap:10px\\\\\"><label>Email<input value=\\\\\"jane@acme.co\\\\\" /></label><label>Password<input value=\\\\\"••••••••\\\\\" /></label><label style=\\\\\"display:flex;align-items:center;gap:8px\\\\\"><input type=\\\\\"checkbox\\\\\" checked /> Remember me</label><button class=\\\\\"primary\\\\\">Sign in</button></div><a href=\\\\\"#\\\\\">Forgot password?</a></div>\"\n}\n\\`\\`\\`\n\n**Write PLAIN semantic HTML and let the renderer style it.** Bare elements\n(\\`h1\\`/\\`h2\\`/\\`h3\\`, \\`p\\`, \\`button\\`, \\`input\\`, \\`<input type=\"checkbox\">\\`, \\`a\\`, \\`hr\\`)\nare auto-themed — no classes needed. Helper classes carry the rest:\n\n- \\`.wf-card\\` / \\`.wf-box\\` — a bordered, padded container (a panel, a list item).\n- \\`.wf-pill\\` / \\`.wf-chip\\` — a rounded tag or filter; add \\`.accent\\`\n (\\`<span class=\"wf-pill accent\">\\`) for the accent-filled variant.\n- \\`.wf-muted\\` — secondary/muted text (or use \\`<small>\\`).\n- \\`button.primary\\` or any element with \\`[data-primary]\\` — the accent-filled\n primary button.\n\n**Use the \\`--wf-*\\` tokens for any custom color, never hex.** The renderer flips\nthese on light/dark, so reading them is what keeps a mockup correct in both\nthemes. For any inline border, background, or text color, reference a token:\n\\`style=\"border:1.4px solid var(--wf-line)\"\\`. The tokens are \\`--wf-ink\\` (text),\n\\`--wf-muted\\` (secondary text), \\`--wf-line\\` (borders/dividers), \\`--wf-paper\\`\n(page background), \\`--wf-card\\` (raised surface), \\`--wf-accent\\` /\n\\`--wf-accent-fg\\` / \\`--wf-accent-soft\\` (brand action), \\`--wf-warn\\`, \\`--wf-ok\\`,\nand \\`--wf-radius\\`. Never hard-code a hex color and never set \\`font-family\\` — the\nrenderer owns the sketch/clean font.\n\n**Lay out with inline \\`style\\` flex/grid.** You write the real layout —\n\\`display:flex; flex-direction:column; gap:10px; padding:16px\\` and so on — and the\nrenderer never repositions anything. Compose the actual product: reproduce the\ncurrent screen, then show the modification. Real labels, real counts, real dates,\nreal button text grounded in the screen you read; not lorem or gray bars.\n\n**Surface presets — match the real footprint, never default to desktop+mobile.**\nPick the \\`surface\\` that matches what the user will actually see:\n\n- \\`browser\\`: a web page that needs a browser chrome frame around it.\n- \\`desktop\\`: a full desktop app page or app shell.\n- \\`mobile\\`: a phone screen, only when the work is genuinely mobile.\n- \\`popover\\`: a small floating menu, dropdown, or inline popover.\n- \\`panel\\`: a side panel, inspector, or sidebar widget.\n\nA sidebar popover renders as a small surface, not a desktop page and a phone\nframe. Do not emit \\`desktop\\` + \\`mobile\\` variants unless responsive behavior\nactually changes the layout. For a component or widget, show one broader\napp-context frame only when placement affects understanding, then the focused\ncomponent states.\n\n**Model the actual component shell for small surfaces.** A rendered UI change\nbelongs in a wireframe; reserve \\`diagram\\` for architecture, dependency, state,\nor data-flow relationships. Popovers, dropdown menus, command palettes, and\ncontext menus use \\`surface: \"popover\"\\` unless the surrounding page placement is\nthe point of the change. Dialogs, sheets, inspectors, sidebars, and long\nproperty panels use the matching \\`panel\\` / \\`desktop\\` surface as appropriate.\nShow the real chrome: trigger or anchor when it matters, title/header row,\ntop-right actions, separators, fields, options, selected states, body content,\nand footer actions that are visible in the workflow.\n\n**Modify, don't redesign.** When the task changes an existing screen, reproduce\nthe current screen's real layout and footprint FIRST, then change only the delta\nand call it out with a single annotation. Do not restack the page into a new\nlayout. For net-new surfaces, compose from the real app shell. Inspect the\nactual app components before drawing an existing product: sidebar density,\ntoolbar actions, overflow menus, property panels, and framework chrome should\nmatch the product unless the plan intentionally changes them.\n\n**Keep product screens pure.** A product wireframe shows the app state a user\nwould actually see. Do not embed file contracts, architecture arrows, repo pills,\nmode explanations, or implementation callouts inside the screen just to explain\nthe plan. Put those in canvas annotations, a separate diagram, or the document\nbody. Secondary UI such as properties, history, sync, export, or agent controls\nshould appear where the real product would put them: an overflow popover, sheet,\npanel, or separate framework sidebar state, not a generic permanent right\ninspector unless that inspector is the actual design.\n\n**Classify mockup scope before implementation.** Before turning a plan mockup\ninto source code, decide whether each artboard represents the whole page/app\nshell, a route body inside an existing shell, or a component/sub-surface. If an\nartboard includes navigation, sidebars, auth banners, or a signup/login form,\nmap those pieces to the real shared shell/auth components instead of nesting the\nentire mockup inside the current page. When a mockup references the product's\nstandard signup/login page, find and reuse that existing implementation; do not\napproximate it from the wireframe.\n\n**Zoom in on sub-surfaces, don't redraw the page.** For a small sub-surface (a\npopover, menu, dialog, toast), show the full screen once, then add a small\nseparate artboard whose \\`html\\` contains ONLY that sub-surface — do not re-draw\nthe whole page around it, and do not scale a duplicate up. Pick the matching\n\\`surface\\` (e.g. \\`popover\\`) so the footprint is right; never widen a popover to\npage width.\n\n**Loading / skeleton states.** Set \\`data.skeleton: true\\` on the wireframe and\nfill the \\`html\\` with neutral, textless placeholder geometry — boxes and bars\nbuilt as \\`<div>\\`s with \\`background:var(--wf-line)\\` and explicit heights/widths,\nno labels or copy. The renderer drops borders, sketch, and color into the\nskeleton register automatically. Never escape to a \\`custom-html\\` document block\nto fake a loader.\n\n**Editing an existing mockup.** To change one element, text, or color in an\nexisting html mockup, call \\`update-visual-plan\\`\nwith \\`contentPatches: [{ op: \"patch-wireframe-html\", blockId, edits: [{ find,\nreplace }] }]\\`. Each \\`find\\` is a unique snippet of the current html (read it\nfirst with \\`get-visual-plan\\`); set \\`all: true\\` on an edit to replace every\noccurrence. The result is re-sanitized.\n\n**Treat the wireframe border as part of the visible design.** Always wrap HTML\nwireframe content in a root container with real inner padding before drawing\ncards, fields, pills, labels, or controls. Use at least 14-16px of padding,\n\\`box-sizing: border-box\\`, \\`height: 100%\\`, and \\`gap\\` between child rows so the\nfirst row never sits flush against the screen border. Keep text away from\nborders: every container, field, button, menu item, and annotation needs enough\npadding and line-height to read cleanly in the rendered Plan view.\n\n**Lay out children safely so they never collide.** Use HTML flex/grid with\n\\`gap\\`, \\`min-width: 0\\`, and sensible overflow. Avoid negative margins, absolute\npositioning, or fixed child widths that can collide when the renderer switches\nbetween light/dark, sketch/clean, or different zoom levels.\n\n**Do not wrap intentionally single-line labels.** For toolbars, tab rails,\nbreadcrumbs, chip/filter rows, branch and file names, file chips, and code\nfilenames — any deliberately single-line row — do not let long text wrap. Put\n\\`white-space: nowrap\\` on the row (and \\`overflow: hidden; text-overflow: ellipsis\\`\non the individual labels that can grow), so the wireframe demonstrates the actual\nlayout behavior instead of producing ugly stacked or vertical text. Use\nhorizontally scrollable or clipped rails for overflow.\n\n**Fill the frame; keep labels short.** Each artboard is a fixed-size surface — compose enough realistic HTML to fill it top to bottom with even vertical rhythm; never leave a large empty band. On desktop/app-shell sidebars, let the nav stack flex to fill (\\`flex:1\\`) and add any persistent bottom action/status after it so the rail reads complete in taller frames. On mobile especially, flow real rows down the whole screen (status bar, header, then list/detail content) rather than a header floating above a gap. Keep every label short enough to sit on one line within its column — shorten the copy rather than relying on the frame to absorb it (long labels wrap or clip).\n\n**Persistent chrome bars span the full frame width.** Top bars, app headers,\ntoolbars, and bottom tab/nav bars are full-width chrome, not centered content.\nLay each one out as a single flex row that fills the frame\n(\\`style=\"display:flex;align-items:center;width:100%\"\\`) and push trailing actions\nto the right edge with a flex spacer (\\`<div style=\"flex:1\"></div>\\`) between the\nleading group and the trailing group — never center a bar inside a narrow,\ncentered block, and never let it collapse to the width of its contents. In a\nBefore/After pair the bar stays full-width in BOTH states even when one state has\nfewer controls; the spacer absorbs the difference so the remaining controls hold\ntheir edge alignment instead of sliding to the center.\n\n**Pin bottom bars to the bottom of the frame.** For mobile tab bars, footers, and\nany persistent bottom action row, make the frame itself a flex column at\n\\`height:100%\\` (\\`style=\"display:flex;flex-direction:column;height:100%\"\\`), give the\nscrolling body \\`flex:1\\` so it absorbs the slack, and place the bar as the LAST\nchild of the frame (or set \\`margin-top:auto\\` on it). The bar then sits flush at\nthe bottom of the surface instead of floating directly under the content with an\nempty band beneath it.\n\n**Before / after must be comparable.** When showing a state change, preserve the\nunchanged controls in both states so the reviewer can see exactly what moved or\nappeared; do not show an added control as a generic box floating elsewhere in\nthe surface. Place the new/changed affordance where the implementation puts it —\nfor example, a new \\`Edit with AI\\` action in a popover header belongs in the\ntop-right header slot, aligned with the title, not in the body or footer. Use\nthe same frame size, scale, outer padding, border radius, and visual density on\nboth sides unless the change itself alters those properties, and let the frame\nheight fit the content rather than leaving a tall empty lower half.\n\n**Name the states with the column header, never inside the frame.** For\ndocument-body wireframes (recaps), put the two\nstates in a \\`columns\\` block and set each column's \\`label\\` to \\`Before\\` and\n\\`After\\` — the renderer draws that label as an \\`h4\\` heading above each frame. Do\nNOT bake a \\`Before\\`/\\`After\\` pill, title, or heading into the wireframe \\`html\\`: a\nlabel placed inside reads as part of the product UI, lands in a random corner,\nand clutters the comparison. The column header is the one and only place the\nstate name belongs. On a canvas, place the two state artboards as neighbors with\nframe labels — never encode Before/After inside the html.\n\n**Let the surface choose side-by-side vs. stacked.** For document-body\nwireframes (recaps), the \\`columns\\` renderer lays\nnarrow surfaces (\\`mobile\\`, \\`popover\\`, \\`panel\\`) out side by side, and\nautomatically stacks wide surfaces (\\`desktop\\`, \\`browser\\`) vertically at full\ndocument width so a large frame is never crushed into a half-width column and\ncropped. Author both wireframes with the real \\`surface\\` and the matching\n\\`Before\\`/\\`After\\` column labels; do not hand-stack the pair into separate\ntop-level wireframes or duplicate the state name as body content.\n\n**Good example — a contacts list, surface \\`browser\\`.** A small, real screen\ncomposed from the helper classes and tokens, layout in inline flex, no fonts or\nhex colors:\n\n\\`\\`\\`html\n<div\n style=\"display:flex;flex-direction:column;gap:12px;padding:16px;height:100%\"\n>\n <div style=\"display:flex;align-items:center;justify-content:space-between\">\n <h1>Contacts</h1>\n <button class=\"primary\">New contact</button>\n </div>\n <div style=\"display:flex;gap:6px\">\n <span class=\"wf-pill accent\">All 128</span>\n <span class=\"wf-pill\">Favorites</span>\n <span class=\"wf-pill\">Archived</span>\n </div>\n <div\n class=\"wf-card\"\n style=\"display:flex;flex-direction:column;gap:0;padding:0\"\n >\n <div\n style=\"display:flex;align-items:center;gap:10px;padding:10px 12px;border-bottom:1.4px solid var(--wf-line)\"\n >\n <div\n style=\"width:32px;height:32px;border-radius:999px;background:var(--wf-accent-soft)\"\n ></div>\n <div style=\"flex:1\">\n <strong>Jane Cooper</strong><br /><small>jane@acme.co</small>\n </div>\n <span class=\"wf-pill\">Lead</span>\n </div>\n <div style=\"display:flex;align-items:center;gap:10px;padding:10px 12px\">\n <div\n style=\"width:32px;height:32px;border-radius:999px;background:var(--wf-accent-soft)\"\n ></div>\n <div style=\"flex:1\">\n <strong>Marcus Lee</strong><br /><small>marcus@globex.io</small>\n </div>\n <span class=\"wf-pill\">Customer</span>\n </div>\n </div>\n</div>\n\\`\\`\\`\n\n<!-- SHARED-CORE:wireframe-quality END -->`;\n\n// Progressive-disclosure reference file. `WIREFRAME_QUALITY_CORE` is the single\n// source of truth for HTML wireframe quality; it is materialized verbatim into a\n// sibling `references/wireframe.md` in EVERY plan skill dir (visual-plan and\n// visual-recap), instead of being interpolated inline into each SKILL.md body.\n// The SKILL.md bodies carry only `WIREFRAME_REFERENCE_POINTER`, which tells the\n// agent to read this file before authoring any wireframe. Keeping the reference\n// body byte-identical to the core (markers included) lets the sync guard assert\n// the on-disk copies never drift from the canonical constant.\nexport const WIREFRAME_REFERENCE_MD = `# HTML wireframe quality — single source of truth\n\nThis file is the canonical quality bar for HTML wireframes / \\`<Screen>\\` /\n\\`WireframeBlock\\` content, shared word for word by \\`/visual-plan\\` and\n\\`/visual-recap\\`. Read it in full before authoring ANY wireframe; do not\nauthor wireframes from memory or paraphrase these rules per command.\n\n${WIREFRAME_QUALITY_CORE}\n`;\n\n// Short pointer that replaces the inline wireframe-quality core in each SKILL.md\n// body. Authoring quality lives in the sibling reference file so the SKILL.md\n// stays lean (progressive disclosure); the agent loads the detail on demand.\nconst WIREFRAME_REFERENCE_POINTER = `UI recap/plan wireframes must meet a strict quality bar — full-width chrome,\npinned bottom bars, real product content, before/after comparability, the right\n\\`surface\\` preset, \\`--wf-*\\` tokens instead of hex, and no \\`<html>\\`/\\`<style>\\`/font\ntags. Before authoring ANY wireframe / \\`<Screen>\\` / \\`WireframeBlock\\`, READ\n\\`references/wireframe.md\\` in this skill directory — it is the single source of\ntruth for HTML wireframe quality, shared word for word with \\`/visual-plan\\`\nand \\`/visual-recap\\`. Do not author wireframes from memory.`;\n\n// Canvas/artboard placement mechanics. Used only by visual-plan modes\n// (visual-recap renders standalone wireframes, not a canvas).\nconst CANVAS_SURFACE_CORE = `<!-- SHARED-CORE:canvas-surface START -->\n\n**The coordinate rule.** The \\`surface\\` locks each artboard's footprint and\naspect — never set artboard width/height and never use coordinates inside the\nwireframe HTML; board-level artboard \\`x\\`/\\`y\\` IS allowed when it creates clear\nlanes. Let canvas auto-placement handle simple one-row boards.\n\n**Lay out mixed canvases in lanes.** When a canvas contains broad browser /\ndesktop frames plus compact \\`mobile\\`, \\`popover\\`, or \\`panel\\` surfaces, do not put\neverything in one horizontal strip. Use board-level artboard \\`x\\`/\\`y\\` to reserve\nlanes with generous empty space: main flow on one row, compact surfaces in their\nown column or row, and loading/error states in a lower row. Keep at least 96px\nbetween rendered artboard rectangles plus room for annotation gutters. Connect\nonly neighboring steps; never draw a long connector that skips across unrelated\nframes. Before handoff, inspect the top canvas at default zoom and move any\nframe whose label, connector, or annotation crosses another frame.\n\n**Canvas annotations are designer notes on the artboard.** When a top canvas is\npresent, sprinkle Figma-style notes near the frames they explain: a short\nheading, supporting text, and bullets — plain text layers, never bordered or\nshadowed cards, and never a box around a frame. The renderer spaces notes away\nfrom frames, so place each note by the frame it describes. Use an arrow only to\npoint at one specific control or transition; for a broad frame-level note, write\ntext beside the frame with no connector. Connectors are for real sequences only —\nnever fake \"Step 1 → Step 2\" lines between independent states.\n\n**Do not create overlapping annotations.** Anchor each ordinary note to the\nframe it explains with \\`targetId\\` + \\`placement\\` (top/right/bottom/left), and\nomit \\`type\\` or use \\`type: \"note\"\\`. The renderer parks notes in a gutter beside\nthe frame and lays them out automatically. Do not use \\`type: \"callout\"\\`,\n\\`type: \"text\"\\`, \\`type: \"arrow\"\\`, x/y, or points for ordinary notes; those are\nfreeform review-markup layers and must be reserved for intentional markup in\nopen canvas space. Reserve arrows for a note that must point at one specific\ncontrol inside a frame; a note that simply sits beside its frame needs no arrow.\n\n**Patching.** Edit one wireframe, canvas annotation, diagram, or block with targeted \\`contentPatches\\`\n(for example \\`patch-wireframe-html\\`, \\`patch-diagram-html\\`, \\`update-block\\`,\n\\`replace-blocks\\`, \\`update-canvas-annotation\\`) rather\nthan regenerating the whole plan. \\`contentPatches\\` are part of the public MCP\naction schema, so Claude Code, Codex, Cursor, and other hosts can make surgical\nedits. If an agent is working from exported source files, use\n\\`read-visual-plan-source\\` / \\`patch-visual-plan-source\\`: \\`plan.mdx\\` holds\nfrontmatter plus markdown/document blocks, \\`canvas.mdx\\` holds\n\\`<DesignBoard>/<Section>/<Artboard>/<Screen>/<Annotation>/<Connector>\\`, and the\npatch action normalizes the MDX back into the same JSON runtime model. JSON is\nthe canonical runtime shape; MDX is the repo-friendly authoring/export surface.\nIn the browser, humans edit \\`rich-text\\` prose inline; agents should still use\n\\`update-rich-text\\` content patches or source patches for prose, and use\ncomments/structured patches for canvas, artboard, wireframe, and diagram edits.\nNever send a partial top-level \\`content\\` object as a shortcut to add a canvas,\nframe, or block: \\`content\\` is a full structured replacement, so omitted blocks\nor surfaces can disappear. If a full replacement is truly unavoidable, read the\ncomplete source/JSON first, include every existing block and surface in the new\npayload, and verify the source/export immediately after the update.\n\n**Never emit a titled artboard with no interior wireframe content.** Every artboard\nyou place on the canvas must carry an \\`html\\` wireframe or reference a wireframe\nblock via \\`blockId\\`; when using \\`blockId\\`, the referenced \\`wireframe\\` /\n\\`legacy-wireframe\\` block must remain in the plan. If you remove a duplicate\nwireframe from the document body, first move its \\`data\\` inline onto the\ncorresponding \\`content.canvas.frames[*].wireframe\\` / \\`legacyWireframe\\`. A\nlabel-only frame or a frame pointing at a deleted block renders empty and is\nrejected at parse time. If you only have a title, write it as a section header or\nannotation, not an empty artboard.\n\n**UI mockups belong in the top visual review area.** Static UI/product visuals\nlive on the canvas; multi-step UI flows get both canvas wireframes and a\nprototype. When the user asks for a mockup, UI state, loading state, layout,\nscreen, or visual comparison, make the canvas the primary home for that static\nvisual. When the user asks for a prototype or the plan contains a sequence the\nreviewer must feel, keep the canvas artboards and add \\`content.prototype\\` so the\ntop surface shows Wireframes / Prototype tabs. Architecture/code diagrams stay\ninline in the document (the SKILL.md Visual Surface Choice section owns that\nrule) unless the user explicitly asks for a spatial board. Document blocks\ncan explain, compare, or map implementation, but they should not host the\nprimary UI mockup or prototype just because \\`custom-html\\`, screenshots, or prose\nare easier to produce. If the canvas/prototype surface cannot represent the\nrequested UI fidelity, still keep the closest top-surface representation and\ncall out or extend the needed renderer capability. A skeleton/loading mockup\nalso lives in a canvas artboard — never move a mockup out of the canvas.\n\nFor abstract product concepts, use the canvas to create the first \"I get it\"\nmoment: one real app state near the top showing how the concept appears to a\nuser, followed by separate annotations or diagrams for mechanics. Do not make\nthe first artboard a hybrid of app UI and architecture notes; the app screen\nshould be inspectable as product UI on its own.\n\n**Legacy kit tree.** Older plans set a \\`screen\\` array of \\`{ el, ...props }\\` kit\nnodes instead of \\`html\\`; the renderer still accepts and displays it, but new\nplans emit \\`html\\`. Do not author fresh kit-tree screens - write the HTML mockup\ninstead. Likewise, old or imported plans may carry coordinate-based regions or\nfree-float x/y on notes; those are legacy escape hatches the renderer still\nshows but you must never produce. The gutter parks notes by \\`targetId\\` +\n\\`placement\\`, and the coordinate rule at the top of this file governs all\nnew-plan placement.\n\n<!-- SHARED-CORE:canvas-surface END -->`;\n\nconst DOCUMENT_QUALITY_CORE = `<!-- SHARED-CORE:document-quality START -->\n\n**The document is a serious technical plan, not marketing.** Write it the way a\nstrong Claude or Codex implementation plan reads: outcome-first, prose-first,\nself-contained, and specific. State the objective and what \"done\" means, the\nscope and non-goals, the proposed approach with the key decisions and their\nrationale, ordered steps that name real files, symbols, actions, and data\nshapes, the risks, and a closing verification step (tests, build, or a checkable\nbehavior). Replace vague prose with specifics; never ship a step like \"make it\nwork.\" No hero art, gradients, logos, nav bars, slogans, value props, giant\nlanding-page headings, or marketing cards unless the user explicitly asks.\n\n**Every published plan must stand alone.** Even when the agent is revising an\nexisting plan, the output is a plan to do the work, not a changelog of the\nconversation. Do not write phrases like \"preserve the previous plan\", \"do not\ndrop the old idea\", \"as discussed above\", \"this revision\", \"unlike the prior\nversion\", or \"correction from the earlier plan\". Fold the right decisions into\nthe plan as normal objective, architecture, scope, and roadmap prose. A reviewer\nwho opens the plan from a link with no chat history should understand it. Avoid\nnegative framing that only makes sense against absent context (\"not the old\nmode\", \"not just X\") unless the contrast is defined in the plan and genuinely\nhelps; state the positive model directly.\n\n**Make abstract plans instantly legible.** If the idea is broad, strategic, or\nintended for a third-party reviewer, put one concrete product snapshot near the\ntop before dense architecture, mode tables, manifests, or roadmaps. For\nUI-capable concepts, that snapshot is usually a top-canvas app state plus a\nshort paragraph that says what the user sees and what changes under the hood.\nThen put mechanics, data flow, sync boundaries, and implementation detail in\nseparate diagrams or document sections.\n\n**Preserve the user's level of abstraction.** A motivating use case is not\nautomatically the architecture. When the prompt describes a broader framework,\nproduct mode, or reusable primitive, separate the reusable core from specific\napps, providers, customers, scripts, or launch examples. Use the concrete\nexample to make the plan understandable, then make clear which parts are core,\nwhich are app-specific adapters, and which are future examples.\n\n**When top visuals exist, they and the document never duplicate each other.**\nFor UI work, the UI story lives in the top visual surface: canvas artboards for\nstatic inspection, plus prototype tabs when the flow should be functional. The\ndocument carries the technical depth the visuals cannot show — concrete\nfile/symbol maps, API and data contracts, code snippets, migration or\nimplementation phases, risks, and validation. For architecture/code reviews,\ninvert that: the document is the visual surface, and each recommendation\ncarries its own nearby inline \\`diagram\\` / \\`data-model\\` block plus file\nevidence (the \\`diagram\\` bullet below owns how to author those diagrams).\nRepeat a wireframe in the document only for a genuinely new detail view or\ncomparison. Skip the visual surface entirely for non-visual work and write a\nclean rich document. For a simple binary UI visual choice, show the two\ndirections in the canvas only; do not repeat the same options as body\nwireframes or prose. Put the actual choice in the bottom \"Open Questions\" form.\n\n**Use the right block, and make it carry substance.** For the authoritative,\nmachine-checked list of block types and their data schemas, call \\`get-plan-blocks\\`\n— it returns the live registry vocabulary (type, MDX tag, placement, key fields)\nso you never emit a block the editor cannot render or round-trip:\n\n- \\`rich-text\\` for plan prose with real bold/italic/code/links and nested lists.\n- \\`annotated-code\\` for the file map: when a load-bearing file is worth\n highlighting, prefer the annotated walkthrough over a bare \\`code\\` block — carry\n the real, syntax-highlighted code AND anchor short margin notes to the lines\n that actually change (the new action, the changed schema, the wiring point), so\n the reader sees what matters and why instead of code for code's sake. Each\n annotation is \\`{ lines: \"12\" | \"12-18\"; label?; note }\\`; keep a few high-signal\n notes per file, not one per line. Highlight only the files worth reading; never\n an exhaustive list of every touched file, and never a prose-only description of\n a file. Drop to a plain \\`code\\` block only for a throwaway snippet with nothing\n to call out. When more than one file matters, group the blocks in a vertical\n \\`tabs\\` block (the standard tab primitive) rather than a bespoke container. If\n the exact code is unknown, show the smallest plausible planned shape or a\n commented stub naming what to fill in. (\\`code-tabs\\` and \\`implementation-map\\`\n are legacy: their renderers stay for old plans, but do not author new ones.)\n- For a decision: if the reviewer must still pick between a genuinely-open\n either/or, put it in the bottom Open Questions \\`question-form\\` as a \\`single\\`\n question — one option per real alternative, each with a short detail and\n \\`recommended: true\\` on the one you would choose; do not also restate the same\n choice elsewhere. If you have already committed to an approach, state it as\n settled prose or a \\`callout\\` with \\`tone=\"decision\"\\`, optionally with a\n \\`columns\\` block for a side-by-side comparison of the options you weighed — not\n as a confusing mid-document form for a question you have already answered.\n- \\`columns\\` for side-by-side before/after or current/target comparisons where\n each side needs real nested blocks; label the columns clearly and avoid\n stacking comparison blocks vertically when parallel reading is the point.\n- \\`diagram\\` for two-dimensional architecture, dependency, data-flow, or state\n relationships, only when it clarifies something real. Prefer standard\n two-dimensional layouts — paired before/after panels, layered diagrams,\n swimlanes, dependency maps, matrices, or grouped regions; do not default to\n left-to-right chains, and use a line only when the relationship is truly a\n sequence. For architecture/code\n diagrams, prefer \\`data.html\\` / \\`data.css\\` with semantic HTML and inline SVG so\n the diagram can use panels, layers, matrices, arrows, annotations, and\n responsive layout directly. Author diagram HTML with renderer-owned primitives\n like \\`.diagram-panel\\`, \\`.diagram-card\\`, \\`.diagram-node\\`, \\`.diagram-box\\`,\n \\`.diagram-pill\\`, \\`.diagram-muted\\`, and \\`[data-rough]\\`; they map to the plan's\n Tailwind theme variables through \\`--wf-ink\\`, \\`--wf-muted\\`, \\`--wf-line\\`,\n \\`--wf-paper\\`, \\`--wf-card\\`, \\`--wf-accent\\`, \\`--wf-accent-soft\\`, \\`--wf-warn\\`, and\n \\`--wf-ok\\`, and switch to Excalifont plus rough.js outlines in sketchy mode. Do not\n set \\`font-family\\` and do not hard-code hex, rgb, or hsl colors in diagram HTML\n or CSS. Leave room for the sketch font: keep labels short, give nodes generous\n width, and place boundary/annotation labels in unused space instead of over\n nodes; labels must not overlap nodes, connectors, or each other. For small\n text/SVG changes to an existing HTML diagram, use \\`patch-diagram-html\\` with a\n unique \\`find\\`/\\`replace\\` snippet instead of resending the whole \\`data.html\\`\n string. Use legacy \\`nodes\\` / \\`edges\\` only for small previews or truly\n sequential flows. In architecture/code plans, prefer a repeated section rhythm:\n recommendation title, confidence and category badges, code-path evidence, a\n local before/after or current/target spatial diagram, then concise\n Problem/Solution/Why text.\n- \\`tabs\\` for multiple states, directions, or comparisons. A tab that reveals\n only prose usually means the plan is under-specified — include a relevant\n visual unless the tab is intentionally document-only.\n- \\`table\\`, \\`checklist\\`, \\`callout\\` for scannable structure.\n\n**Open questions live at the bottom as a form when answers would change the\nplan.** Surface answerable unresolved decisions in a final \\`question-form\\`\nblock titled \"Open Questions\" so the renderer presents it as a distinct section.\nThat bottom form is the ONLY place that enumerates the open questions: never add\na second \"Open Questions\" heading, list, or recap of the same questions earlier\nin the document. A one-line pointer in the overview prose (\"a few decisions are\nstill open — see Open Questions below\") is fine, but do not reproduce the\nquestion list or a parallel questions/decisions section above it.\nUse \\`single\\` or \\`multi\\` for clear choices, \\`freeform\\` for constraints,\n\\`recommended: true\\` for the default you would pick, and option \\`wireframe\\` /\n\\`diagram\\` previews only when the options are not already visible in the top\ncanvas. \\`single\\` and \\`multi\\` questions always render a write-in field so a\nreviewer can answer with a custom option — never add an explicit \"Other\" option\nyourself; set \\`allowOther: false\\` only when a free-text answer makes no sense.\nKeep non-answerable assumptions or risks as concise \\`callout\\` blocks in\nthe relevant section. Never bury a questions/decisions wall inside the plan\nnarrative, and never ask the same question twice.\n\nFor complex plans, do not end without an open-question audit. If architecture,\nscope, UX, data shape, rollout, provider mapping, or ownership still depends on\na choice, either commit to a recommendation with rationale or add it to the\nbottom form with a recommended default. A complex plan with no open questions is\nfine only when every meaningful decision has been explicitly made.\n\n**Verification must exercise the real workflow.** The final verification section\nshould go beyond typecheck/unit tests when the plan changes UI, local files,\nsync, providers, browser behavior, or multi-app flows. Include at least one\nend-to-end smoke that matches the user journey, such as a fresh repo/folder,\nreal manifest or data fixture, browser interaction, save/sync action, and an\non-disk or database assertion. Name the command or manual browser path when it\nis known.\n\n**\\`custom-html\\` is a bounded escape hatch only** — a single complete fragment\ninside a block, never \\`html\\`/\\`head\\`/\\`body\\`/\\`script\\` tags, never a generic\nplaceholder, density demo, or proof that custom HTML works. Prefer the native\nblocks for normal plans. For architecture/code reviews, use \\`diagram\\`\n\\`data.html\\` / \\`data.css\\` for rich local HTML/SVG diagrams instead of\n\\`custom-html\\`. For UI/product work, \\`custom-html\\` is never the primary home for a\nrequested mockup, UI state, or visual comparison. If UI fidelity requires\nHTML/CSS, image capture, or real React/CSS, the product fix is canvas support\nfor that artifact type, not moving the mockup into the document.\n\n**Before handoff, open the plan and check it.** Fix overlap, excessive\nwhitespace, clipped fragments, misleading inactive controls, poor contrast, and\nunreadable diagrams before asking for approval.\n\n<!-- SHARED-CORE:document-quality END -->`;\n\nconst EXEMPLAR_CORE = `<!-- SHARED-CORE:exemplar START -->\n\n**GOOD.** A UI-first plan for a todo app: a canvas with a \\`desktop\\` artboard whose\n\\`data.html\\` is a real flex layout — a sidebar of links (\\`Inbox 12\\`, \\`Today 4\\`,\n\\`Done\\`), a main column with an \\`<h1>Today</h1>\\`, accent \\`.wf-pill\\`s for the\nfilters, a muted section label \\`OVERDUE\\`, and \\`.wf-card\\` task rows carrying real\ntitles, due dates, and a primary \\`button.primary\\` — styled only through bare\nelements, helper classes, and \\`--wf-*\\` tokens, so the renderer applies the\ncorrect desktop footprint, theme, and one subtle whole-frame wobble. Plain-text\ndesigner notes sit spaced off the frame, pointing only at the controls that need\nexplanation. Below it, a Claude/Codex-grade document: objective and\ndone-criteria, a few \\`code\\` blocks (grouped in a vertical \\`tabs\\` block when\nmore than one) showing the real shape of the load-bearing files, a \\`callout\\`\nwith \\`tone=\"decision\"\\` stating the chosen approach with a \\`columns\\` block\nweighing the two real options behind it,\nand a validation step — none of it repeating the canvas. If the task also\nchanges a multi-step completion flow, the same top area includes a Prototype tab\nwhose screens use the same labels and states as the canvas artboards, with\n\\`data-goto\\` controls for the sequence. This is the bar.\n\n**GOOD.** A broad product-architecture plan opens with a plain recommendation\nand one concrete app state before the abstraction. The first canvas artboard is\npure product UI that matches the current app shell; nearby notes explain the\nuser-visible delta. A separate diagram below shows the mechanics, such as file\nor data flow. The document then separates the reusable core from app/provider\nadapters and examples, covers contracts, folder or schema shape, sync\nboundaries, roadmap, non-goals, a bottom Open Questions form for unresolved\ndecisions, and a verification section with at least one realistic end-to-end\nsmoke. A reviewer who was not in the chat gets the idea from the top snapshot\nbefore reading the technical plan.\n\n**GOOD.** A \\`/visual-plan\\` for a backend architecture review: no top canvas.\nThe document opens with context and a legend, then repeats recommendation cards:\ntitle, confidence/category badges, a monospace grid of real file paths, one\ninline two-dimensional before/after or layered architecture diagram, and terse\nProblem/Solution/Why bullets using the codebase's vocabulary. The diagram uses\nspace to show boundaries, layers, and ownership; it is not a default\nleft-to-right chain. The plan ends with a top recommendation and a bottom\nquestion-form only if the next architecture direction is genuinely open. This is\nbetter than a top canvas because each diagram is local to the claim it supports.\n\n**BAD.** A \\`data.html\\` with hard-coded hex colors, a \\`font-family\\`, or fixed\npixel width/height; gray placeholder bars \"insinuating\" text on a non-skeleton\nframe; a forced desktop + mobile pair for a popover; floating bordered\nannotation cards hugging the frames; a fresh hand-authored kit-tree \\`screen\\`\ninstead of \\`html\\`; a multi-step UI flow with only static frames and no prototype\ntab; a mockup escaped into a document \\`custom-html\\` block; and a marketing-style\ndocument with a hero heading and value props that just restates what the canvas\nalready shows. Also bad: an architecture-only plan forced into a top canvas of\nlabeled boxes with overlapping text, where the actual code evidence and\nrecommendations live elsewhere; a product wireframe that mixes a real screen\nwith repo names, file-contract arrows, architecture explanations, or a made-up\npermanent inspector; and a plan that describes itself as a revision of a prior\nconversation instead of a standalone proposal. Never produce this.\n\n<!-- SHARED-CORE:exemplar END -->`;\n\n// Progressive-disclosure reference files. Like `WIREFRAME_REFERENCE_MD`, each of\n// the canvas / document-quality / exemplar cores is the single source of truth\n// for its topic and is materialized verbatim into a sibling `references/*.md`\n// file in the visual-plan skill dir instead of being interpolated inline into\n// the SKILL.md body. The body carries only the matching `*_REFERENCE_POINTER`.\n// Keeping each reference body byte-identical to its core (markers included) lets\n// the sync guard assert the on-disk copies never drift from the constant.\nexport const CANVAS_REFERENCE_MD = `# Canvas & artboard placement — single source of truth\n\nThis file is the canonical guide for how the visual-plan canvas works: artboard\nplacement, lane layout, annotations, patching, and the legacy kit tree. Read it\nin full before authoring or editing any canvas/artboard content; do not author\ncanvas layouts from memory or paraphrase these rules per mode.\n\n${CANVAS_SURFACE_CORE}\n`;\n\nexport const DOCUMENT_QUALITY_REFERENCE_MD = `# Plan document quality — single source of truth\n\nThis file is the canonical quality bar for the plan document below the canvas:\nhow it reads, which blocks to use, how open questions are surfaced, and the\npre-handoff check. Read it in full before authoring the plan document; it is the\nquality bar. Do not write the document from memory or paraphrase these rules per\nmode.\n\n${DOCUMENT_QUALITY_CORE}\n`;\n\nexport const EXEMPLAR_REFERENCE_MD = `# Good vs. bad exemplar — single source of truth\n\nThis file is the canonical worked example of a great plan (and the anti-patterns\nto avoid). Read it alongside the document-quality and canvas references before\nauthoring a plan; it is the bar these plans must clear.\n\n${EXEMPLAR_CORE}\n`;\n\n// Short pointers that replace the inline canvas / document-quality / exemplar\n// cores in the SKILL.md body. Authoring detail lives in the sibling reference\n// files so the SKILL.md stays lean (progressive disclosure); the agent loads the\n// detail on demand.\nconst CANVAS_REFERENCE_POINTER = `The canvas is the single source of truth for static UI mockups: the \\`surface\\`\nlocks each artboard's footprint, mixed surfaces lay out\nin lanes, annotations are plain-text designer notes anchored by\n\\`targetId\\`/\\`placement\\`, and edits are surgical \\`contentPatches\\`. Before\nauthoring or editing ANY canvas, artboard, or annotation, READ\n\\`references/canvas.md\\` in this skill directory — it is the single source of truth\nfor canvas/artboard mechanics. Do not author canvas layouts from memory.`;\n\nconst DOCUMENT_QUALITY_REFERENCE_POINTER = `The document is a serious technical plan, not marketing: outcome-first,\nprose-first, self-contained, built from the right native blocks, with open\nquestions in a single bottom \\`question-form\\` and a pre-handoff visual check.\nBefore authoring the plan document, READ \\`references/document-quality.md\\` in this\nskill directory — it is the single source of truth for the document quality bar.\nDo not write the document from memory.`;\n\nconst EXEMPLAR_REFERENCE_POINTER = `For a worked example of the bar — a great UI-first plan and \\`/visual-plan\\`, plus\nthe anti-patterns to avoid — READ \\`references/exemplar.md\\` in this skill\ndirectory before authoring a plan.`;\n\nexport const VISUAL_PLANS_SKILL_MD = `---\nname: visual-plan\ndescription: >-\n Use Agent-Native Plans when coding-agent work needs a reviewable plan\n published as an interactive document — inline diagrams, annotated code\n walkthroughs, file trees, optional UI wireframes or prototypes, open-question\n forms, and comments — before implementation starts.\nmetadata:\n visibility: exported\n---\n\n# Agent-Native Plans\n\nAgent-Native Plans is structured visual planning mode for coding agents. Build\nthe plan you would normally write in Markdown, but as a scannable document with\neditable blocks mixed in: inline diagrams, code snippets,\nopen questions, and an optional top visual review area (wireframe canvas, live\nprototype, or both in tabs). Architecture and backend plans stay document-only;\nUI and product plans start with the top canvas/prototype (the Visual Surface\nChoice section owns that rule).\n\n\\`/visual-plan\\` is the packaged command and main entry point. Choose the review\nmode from the task: UI-first when the work is primarily product UI and review\nshould start with screens, prototype-first when review should start with a\nfunctional live prototype, design-first when review needs full-fidelity branded\nscreens, or visual-intake when the user explicitly wants a questionnaire before\nplanning. When a Codex, Claude Code, Markdown, or pasted plan already exists,\n\\`/visual-plan\\` uses that source plan as the starting point and builds the review\nsurface from it instead of starting over.\n\n## When To Use\n\nCreate or adapt a visual plan when work is multi-file, ambiguous, long-running,\nrisky, or UI-heavy, when architecture / data flow / UI direction / options /\nopen questions would benefit from inline diagrams or structured blocks, when the\nuser needs to react to a direction before you implement, or when an existing text\nplan needs a richer review surface.\n\n## Plan Discipline\n\n- **Gate hard.** A polished visual plan is the most expensive plan form; only\n invest when a wrong direction is costly. Skip it for trivial, unambiguous work\n — typos, one-line fixes, a single well-specified function, anything whose diff\n you could describe in one sentence — and just make the change. Never pad a plan\n with filler and never ship a single-step plan.\n- **Research before you draft.** Read the real files, actions, schema, and\n patterns first; name actual files, symbols, and data shapes instead of\n inventing them. Check existing \\`actions/\\` before proposing endpoints and prefer\n named client helpers over raw fetch. Delegate wide exploration to a sub-agent.\n Lead with reuse: for each step, name what it reuses — existing actions, schema,\n components, helpers — before what it adds, so the plan explains the genuinely new\n delta instead of redescribing what already exists.\n- **Decide the hard-to-reverse bets first.** For non-trivial backend, data, or API\n work, sketch where the feature is headed, then call out the decisions that are\n expensive to undo once data or callers depend on them — wire format, public ids,\n data-model shape, auth and ownership boundaries — and get those right in the plan\n even if most of the feature ships later. Then scope to the smallest first cut that\n proves the approach without foreclosing it, stating both what is in and what is\n explicitly deferred.\n- **Keep examples at the right altitude.** When the user's idea is a broad\n framework, product, or operating-model change, do not collapse it into the\n first concrete example, provider, or sync path they mention. Separate the core\n abstraction from motivating examples and app/provider adapters. Use examples\n to make the plan legible, but label them as examples unless they are the whole\n requested scope.\n- **Publish standalone plans.** If the user pasted, referenced, or already has a\n Codex / Claude Code / Markdown plan, treat it as source material, but rewrite\n the published plan as a clean standalone proposal. Preserve the source plan's\n useful intent and codebase facts, label inferred visuals as inferred, and avoid\n revision language such as \"preserve the prior plan\", \"do not drop the old\n idea\", \"unlike the previous version\", or \"this revision changes...\". A reader\n who never saw the chat or earlier drafts should understand the plan.\n- **Make the first read concrete.** If the plan is meant to be shared with\n someone outside the chat, or if the concept is abstract, lead near the top with\n one concrete product example before mode tables, architecture, or roadmaps. For\n UI-capable concepts, that usually means a top-canvas app state that shows the\n real user workflow in product terms. Do not rely on phrases that only make\n sense in conversation, and do not frame the plan as \"not the old idea\"; state\n the positive model directly.\n- **Planning is read-only.** Make no source edits while building or reviewing the\n plan. Start editing only after the user approves the direction.\n- **Clarify vs. assume.** Do not ask how to build it — explore and present the\n approach and options in the plan. Ask a clarifying question only when an\n ambiguity would change the design and you cannot resolve it from the code; use\n the host agent's normal ask-user-question flow and batch 2-4 high-leverage\n questions before finalizing. Do not call \\`create-visual-questions\\` from\n \\`/visual-plan\\`. Otherwise state the assumption explicitly and proceed, and\n keep anything unresolved in the plan's single bottom \\`question-form\\` Open\n Questions block. For complex plans, do a final open-question pass before\n handoff: if a decision would affect architecture, scope, UX, data shape, or\n rollout, either decide it in the plan with rationale or put it in that bottom\n form with a recommended default.\n- **The plan is the approval gate.** After surfacing it, ask the user to review\n and approve before you write code, and name which files/areas the work touches.\n Presenting the plan and requesting sign-off is the approval step — do not ask a\n separate \"does this look good?\" question.\n- **The document is the source of truth, not the chat.** When scope shifts,\n update the plan with \\`update-visual-plan\\` rather than only changing course in\n chat, and make the updated document stand alone. Do not describe the update as\n a correction to an earlier draft inside the plan itself. Re-read the approved\n plan before major steps.\n\n## Always Publish As An Agent-Native Plan — Never Inline\n\nThe deliverable is ALWAYS a published Agent-Native Plan created via the Plan\nMCP connector (\\`plan\\` server, or legacy \\`agent-native-plans\\`). NEVER hand the\nplan over as inline chat content — no Markdown prose, ASCII sketch, table, or\nfenced wireframe. If the connector's tools are missing, do NOT fall back to\ninline output: the usual cause is a connector that did not finish connecting\nthis session (it registers zero tools), not auth. Stop and give the user the\nexact restore step for their current client: in Codex/Codex Desktop run\n\\`npx -y @agent-native/core@latest reconnect https://plan.agent-native.com --client codex\\`\nand start a new Codex session; in Claude Code run \\`/mcp\\` and choose\nAuthenticate/Reconnect (or run the same reconnect command with\n\\`--client claude-code\\` and restart Claude). Auth is stored per client\nconfig/session, so one client's reconnect does not make another running client\nload tools. Never reinstall from scratch just to fix auth. Publish once the tool\nis reachable. Local-files privacy mode (after Tool Guidance) is the only\nexception.\n\n## Core Workflow\n\n1. Follow the host agent's normal planning flow: inspect the codebase, delegate\n wide exploration when useful, gather the info needed, and ask native\n clarifying questions as needed before generating the plan. If a source plan\n already exists, gather its exact text from the user's paste, a referenced\n file, or recent visible agent context; do not invent source text.\n2. Call \\`get-plan-blocks\\` for the authoritative block catalog — do not author\n from memorized tags. Then call the mode-matched create tool:\n \\`create-visual-plan\\` for document-first plans (architecture, backend, data,\n refactor, API), \\`create-ui-plan\\` for UI-first plans, \\`create-prototype-plan\\`\n for prototype-first plans, \\`create-plan-design\\` for design-first plans,\n \\`create-visual-questions\\` only when the user explicitly asks for a visual\n intake questionnaire. When a source plan already exists,\n pass it as \\`planText\\` and preserve the original plan's useful intent while\n producing a standalone plan document, not a revision memo.\n3. For UI/product plans, compose the top canvas first with the primary\n wireframes and annotated states, then write the document with native blocks\n (see \\`references/canvas.md\\` and \\`references/document-quality.md\\`). For\n broad product architecture plans with a user-facing implication, add a\n concrete \"what this looks like in the app\" visual before the abstract\n architecture or mode tables. Keep the document close to the standalone\n Markdown plan the agent would normally output. If an existing plan was\n provided, carry forward the right facts and decisions without referring to\n the previous draft or explaining how this version differs. For non-visual\n plans, skip the top visual surface (Visual Surface Choice below owns the rule)\n and put \\`diagram\\`, \\`data-model\\`,\n \\`api-endpoint\\`, \\`diff\\`, \\`file-tree\\`, \\`code\\`, and \\`annotated-code\\` blocks\n directly next to the relevant prose.\n4. Surface the returned Plans link or inline MCP App and ask the user to review.\n Always include the actual URL in chat so the next step is a click in CLI or\n other text-only hosts. When the host exposes an embedded browser/preview panel\n and a tool can open arbitrary URLs there, open the returned plan URL\n automatically for convenient review — a convenience and smoke test, never the\n only handoff or the access\n model. Plans should load out of the box for the local agent and local browser\n session; if a signed-in embedded browser cannot read a local plan that an\n anonymous/tool check can read, fix the app/action ownership or access path\n rather than patching one plan by hand. For high-stakes plans (architecture,\n backend, data, multi-file, or risky), also kick off the self-review pass in\n **Self-Review Before Handoff** while the user reads, instead of blocking the\n handoff on it.\n5. Call \\`get-plan-feedback\\` before editing, after review, after any long pause,\n and before the final response. Treat \\`anchorDetails\\`, resolver intent, recent\n review events, and any focused screenshots from browser handoff as the source\n of truth for exactly what changed and exactly what each comment points at.\n6. Apply changes with \\`update-visual-plan\\`, preferring targeted \\`contentPatches\\`.\n Treat the top-level \\`content\\` payload as a full replacement, not a merge; do\n not send a partial \\`content\\` object to add a canvas or one block. If a full\n replacement is unavoidable, first read the complete plan source/content, carry\n forward every existing block and visual surface, and verify the source/export\n afterward so the document body was not truncated. When the user wants\n source-control friendly edits, use \\`patch-visual-plan-source\\` against the MDX\n files instead of regenerating the plan.\n7. Export with \\`export-visual-plan\\` only when the user wants a shareable receipt\n or repo-check-in artifacts.\n\n## Self-Review Before Handoff\n\nFor high-stakes plans — architecture, backend, data-model, migration, multi-file,\nor otherwise risky work — run one adversarial self-review pass before treating the\nplan as final. Skip it for small, UI-only, or single-decision plans where the cost\noutweighs the value. Keep the pass cheap and non-blocking:\n\n- **Surface the plan first, review concurrently.** Post the link and let the user\n start reading, then run the review in parallel — never make the user wait on it.\n- **Review the written plan; do not re-research.** Critique the plan text and its\n own blocks. The grounding was already done while drafting, so the review checks\n the output instead of re-exploring the repo.\n- **Spawn one skeptical reviewer** whose only job is to find what is weak, missing,\n or wrong — not to praise. Point it at: hard-to-reverse decisions made implicitly\n or not at all (wire format, public ids, data-model shape, auth, ownership); steps\n not anchored in real files or symbols; a menu of options where the plan should\n commit to one; obvious missing decisions (\"what happens when X?\", \"why not Y?\");\n and padding or single-step filler.\n- **Fix vs. ask.** Apply clear-cut fixes yourself with \\`update-visual-plan\\`\n \\`contentPatches\\` — vague non-goals, unanchored claims, an obvious missing\n decision. Route genuine judgment calls back to the user instead: add them to the\n bottom \\`question-form\\` Open Questions block or batch them into the normal\n ask-user-question flow. Do not silently decide them.\n- **Do not surprise the user mid-read.** On a large plan, apply the patches before\n the editor loads; otherwise note briefly that a self-review is running so the\n plan changing under them is expected. When you next respond, summarize what the\n review changed and what it surfaced for the user to decide.\n\n## Visual Surface Choice\n\nChoose the surface before creating the plan or after reading the source plan. Do\nnot add visual chrome by default:\n\nFor UI/product plans, the top canvas is usually the primary review surface. Put\nthe first meaningful wireframes there, not buried as document-body blocks. Use\nmultiple canvas artboards when states matter, such as the default view, an\noverflow menu or popover, a side panel, loading, or error. Put short annotations\nbeside frames with \\`targetId\\` plus \\`placement\\`; keep implementation details,\ntradeoffs, file maps, data contracts, risks, and verification in the document\nbody below the canvas.\n\nKeep product wireframes and explanatory/meta diagrams separate. Start with pure\nscreens that look like the app state under discussion, without callout prose or\narchitecture notes embedded inside the UI. Put arrows, labels, contracts, data\nflow, and mode explanations in separate annotations, separate canvas diagrams,\nor the document body.\n\nWhen the plan touches an existing app, inspect the current shell/components\nbefore drawing. The first artboard should look like the real app at the same\ndensity: existing sidebars, toolbar placement, overflow menus, app chrome, and\nframework agent chrome stay in their real places. Model secondary surfaces as\nseparate states, such as a top-right overflow popover, sheet, panel, loading\nstate, or separate AgentSidebar, rather than inventing a permanent inspector or\nfolding framework chrome into the product UI.\n\n- **No visual surface** for architecture-only, backend-only, data migration,\n copy-only, or otherwise non-visual plans. Do not use the top canvas for\n architecture diagrams, dependency maps, file plans, API contracts, or\n data-flow-only reviews. Use a strong document with local inline diagrams\n only when relationships need a visual explanation, usually one spatial diagram\n per recommendation or decision. Prefer grouped regions, layers, quadrants,\n matrices, or before/after panels over a single-axis chain unless the\n relationship is truly sequential.\n- **Canvas only** for one static screen, a before/after comparison, a component\n state, a small popover, or a visual direction that does not require clicking.\n Put those wireframes in \\`content.canvas\\` and omit \\`content.prototype\\`.\n- **Canvas + prototype** for multi-step UI flows, onboarding, wizards,\n review/approval flows, navigation changes, or anything where the reviewer\n needs to operate the behavior. Keep the static wireframes in\n \\`content.canvas\\`, add the aligned functional prototype in\n \\`content.prototype\\`, and rely on the top visual tabs to switch between them.\n- **Prototype-first** when the user asks to operate the UI or when interaction is\n the main question. Use \\`create-prototype-plan\\`, which still preserves static\n mocks where useful.\n\nFor mixed canvas + prototype plans, reuse the same real labels, app statuses,\nand screen ids across both surfaces. The canvas is the inspectable static reference;\nthe prototype is the interactive version of that same flow, not a separate\ndesign direction.\n\n## Wireframe quality — read \\`references/wireframe.md\\`\n\nUI recap/plan wireframes must meet a strict quality bar — full-width chrome,\npinned bottom bars, real product content, before/after comparability, the right\n\\`surface\\` preset, \\`--wf-*\\` tokens instead of hex, and no \\`<html>\\`/\\`<style>\\`/font\ntags. Before authoring ANY wireframe / \\`<Screen>\\` / \\`WireframeBlock\\`, READ\n\\`references/wireframe.md\\` in this skill directory — it is the single source of\ntruth for HTML wireframe quality, shared word for word with \\`/visual-plan\\`\nand \\`/visual-recap\\`. Do not author wireframes from memory.\n\n## Canvas — read \\`references/canvas.md\\`\n\nThe canvas is the single source of truth for static UI mockups: the \\`surface\\`\nlocks each artboard's footprint, mixed surfaces lay out\nin lanes, annotations are plain-text designer notes anchored by\n\\`targetId\\`/\\`placement\\`, and edits are surgical \\`contentPatches\\`. Before\nauthoring or editing ANY canvas, artboard, or annotation, READ\n\\`references/canvas.md\\` in this skill directory — it is the single source of truth\nfor canvas/artboard mechanics. Do not author canvas layouts from memory.\n\n## Document quality — read \\`references/document-quality.md\\`\n\nThe document is a serious technical plan, not marketing: outcome-first,\nprose-first, self-contained, built from the right native blocks, with open\nquestions in a single bottom \\`question-form\\` and a pre-handoff visual check.\nBefore authoring the plan document, READ \\`references/document-quality.md\\` in this\nskill directory — it is the single source of truth for the document quality bar.\nDo not write the document from memory.\n\n## Good vs. bad exemplar — read \\`references/exemplar.md\\`\n\nFor a worked example of the bar — a great UI-first plan and \\`/visual-plan\\`, plus\nthe anti-patterns to avoid — READ \\`references/exemplar.md\\` in this skill\ndirectory before authoring a plan.\n\n## Tool Guidance\n\n- \\`create-visual-plan\\`: start one structured visual plan per agent task/run, or\n import an existing text plan by passing \\`planText\\`; \\`content\\` may include no\n visual surface, canvas only, or canvas + prototype.\n- \\`create-ui-plan\\`: start a UI-first plan when the work is primarily product UI.\n- \\`create-prototype-plan\\`: start a prototype-first plan with a functional top\n review surface.\n- \\`create-plan-design\\`: start a full-fidelity branded Design-tab plan with an\n optional matching Prototype tab.\n- \\`convert-visual-plan-to-prototype\\`: convert an existing HTML wireframe canvas\n into a prototype plan.\n- \\`create-visual-questions\\`: use only when the user explicitly asks for a visual\n intake questionnaire, not as \\`/visual-plan\\` preflight.\n- \\`update-visual-plan\\`: revise content, status, or comments with targeted\n \\`contentPatches\\` (see Core Workflow step 6).\n- \\`read-visual-plan-source\\`: read the normalized plan as \\`plan.mdx\\`,\n optional \\`canvas.mdx\\`, optional \\`.plan-state.json\\`, and JSON.\n- \\`patch-visual-plan-source\\`: apply granular MDX AST patches by stable block,\n artboard, annotation, component, or wireframe-node id.\n- \\`import-visual-plan-source\\`: create or replace a plan from an MDX folder.\n- \\`get-visual-plan\\`: read the current structured plan, exported HTML, and\n annotations; it also returns the MDX folder for source workflows.\n- \\`get-plan-feedback\\`: read unconsumed human feedback. Use it frequently; it\n returns grouped threads, exact anchor details, expected resolver, and recent\n review-event payloads so agents can act only on the comments meant for them.\n- \\`get-plan-blocks\\`: resolve block tags before authoring — do not memorize tags;\n call this first to get the authoritative tag names, required fields, and prop\n shapes from the live block registry.\n- \\`export-visual-plan\\`: export HTML, Markdown fallback, structured JSON, and MDX\n files for repo check-in.\n\nWhen the user critiques a plan's look or structure, fix the renderer or this\nskill — never hand-edit one stored plan. Turn feedback into better guidance.\n\n## Local-Files Privacy Mode\n\nUse local-files privacy mode when the user explicitly asks for no DB writes,\nno hosted Plan app, no Plan MCP publish, fully local files, offline/private\nplanning, or when \\`AGENT_NATIVE_PLANS_MODE=local-files\\` is set. In this mode the\nplan data must never be sent to the Plan MCP server or Plan app action surface.\n\nThe local-files contract is:\n\n- Read source context from local files and shell commands only.\n- Write the plan as a local MDX folder under \\`plans/<slug>/\\`: \\`plan.mdx\\`,\n optional \\`canvas.mdx\\`, optional \\`prototype.mdx\\`, and optional\n \\`.plan-state.json\\`.\n- Run \\`npx @agent-native/core@latest plan local preview --dir plans/<slug> --kind plan\\` after\n writing or updating the folder. Report the returned local URL or the\n \\`/local-plans/<slug>\\` route if the local Plan app is running with the same\n \\`PLAN_LOCAL_DIR\\`.\n- Do **not** call \\`create-visual-plan\\`, \\`create-ui-plan\\`,\n \\`create-prototype-plan\\`, \\`create-plan-design\\`, \\`import-visual-plan-source\\`,\n \\`update-visual-plan\\`, \\`patch-visual-plan-source\\`, \\`get-plan-feedback\\`,\n \\`export-visual-plan\\`, or any hosted Plan tool for that plan.\n- Treat feedback as file or chat feedback: update the MDX files directly, rerun\n the local preview command, and summarize the new local URL/path. Hosted\n comments, sharing, history, and publish/export receipts are unavailable until\n the user explicitly opts into publishing.\n\nLocal-files mode prevents plan content from going to the Agent-Native Plan\ndatabase. It does not by itself make the coding agent's language model local;\nfor that stronger privacy boundary, the host agent/model must also be local or\notherwise approved by the user.\n\n## Interpreting comment anchors\n\n\\`get-plan-feedback\\` returns rich anchors — read them before acting on any comment.\n\n- **Coordinate frames.** \\`targetX\\`/\\`targetY\\` are percentages *within* the\n element named by \\`targetSelector\\`/\\`targetKind\\`. Bare \\`x\\`/\\`y\\` are percentages\n of the whole plan document. \\`canvasX\\`/\\`canvasY\\` are raw board-world pixels on\n the design canvas (board size given when available).\n- **Wireframe pins.** Anchors on wireframes include \\`targetNodeId\\` and\n \\`targetNodePath\\` (e.g. \\`card > list > listItem \"Acme Inc\"\\`) identifying the\n exact kit node. Use \\`targetNodeId\\` directly with wireframe node patch ops;\n use \\`data-design-id\\` values from design artboards with\n \\`update-design-element-style\\`. Prefer the node id/path over raw coordinates;\n fall back to coordinates plus the focused screenshot (red ring marks the exact\n point) only when no node id is present.\n- **Text quotes.** Resolve \\`textQuote\\` against current prose using\n \\`contextBefore\\`/\\`contextAfter\\` for disambiguation. If \\`ambiguous: true\\`, ask\n the user — do not guess which occurrence is meant.\n- **Detached comments.** \\`get-plan-feedback\\` flags threads whose quoted text no\n longer exists as \\`detached\\` (in \\`detachedThreads\\`). Reconcile these against\n rewritten content — never silently drop them.\n- **Routing.** \\`resolutionTarget\\` is the only routing signal: act on \\`agent\\`,\n treat \\`human\\` as context only. \\`@mentions\\` are people to notify, never a\n routing signal.\n- **Two-axis state.** Mark every ingested comment as consumed\n (\\`consumedCommentIds\\` on \\`update-visual-plan\\`). Set \\`status=resolved\\` only on\n agent-targeted comments you actually addressed; leave human-targeted comments\n open.\n\n## Visibility & Sharing\n\nUse \\`set-resource-visibility\\` to change who can see a plan (e.g. public, login,\nor org-scoped). Use \\`share-resource\\` to grant specific users or roles access\nby email or role. Gate visibility before sharing any plan that covers\nunreleased or private work — default to the narrowest scope that meets the\nreview need.\n\n## Setup & Authentication\n\nThere are two ways into Plans.\n\n**Coding agent (CLI).** Install once with the Agent-Native CLI. The command\ninstalls the Plans skills, registers the hosted Plans MCP connector, and runs\nauth/setup for the selected local client(s) in the same step (a one-time browser\nsign-in at setup — this is intended), so the first tool call in that client does\nnot hit an OAuth wall:\n\n\\`\\`\\`bash\nnpx @agent-native/core@latest skills add visual-plan\n\\`\\`\\`\n\nAfter that, \\`/visual-plan\\` and \\`/visual-recap\\` are the two installed slash\ncommands. The other planning modes (\\`create-ui-plan\\`, \\`create-prototype-plan\\`,\n\\`create-plan-design\\`, \\`create-visual-questions\\`) are MCP tools reachable from\n\\`/visual-plan\\`, not separate slash commands. Pass \\`--no-connect\\` to register\nthe connector without authenticating, then run\n\\`npx @agent-native/core@latest connect https://plan.agent-native.com --client all\\`\nwhenever you are ready, or choose a narrower \\`--client\\`. Auth and MCP tool\nloading are per client config/session.\n\n**Browser (people you share with).** Open the Plans editor and create & edit\nwith no sign-up — you work as a guest. Sign in only when you want to save or\nshare; signing in claims the plans you made as a guest into your account.\n\nSharing and commenting require an account: public/shared plans are viewable by\nanyone with the link, but commenting on them needs an agent-native account.\n\nFor fully offline, no-account use, run the Plans app locally and sync plans to\nyour repo as MDX. This local mode is a separate advanced path, not the default\nhosted flow.\n\nIf a Plans tool returns \\`needs auth\\`, \\`Unauthorized\\`, or \\`Session terminated\\`,\ndo not keep retrying the tool. Stop and give the user the reconnect step for the\nclient they are using: Codex/Codex Desktop should run\n\\`npx -y @agent-native/core@latest reconnect https://plan.agent-native.com --client codex\\`\nand start a new Codex session; Claude Code should run \\`/mcp\\` and choose\nAuthenticate/Reconnect for the plan connector, or run the reconnect command with\n\\`--client claude-code\\` and restart Claude. To refresh every local client config\nthat already has the Plan entry, use \\`--client all\\`, then restart/reload each\nclient. Reconnect re-authenticates WITHOUT reinstalling and finds the entry by\nURL regardless of connector name. Never reinstall from scratch just to fix auth.\nContinue once the connector is available.\n\nHosted default: connect \\`https://plan.agent-native.com/_agent-native/mcp\\`. Do\nnot put shared secrets in skill files.\n`;\n\nexport const VISUAL_RECAP_SKILL_MD = `---\nname: visual-recap\ndescription: >-\n Use Agent-Native Plans to turn a code change, PR diff, or git diff into a\n visual recap plan for high-altitude review — schema, API, file, and\n before/after changes as grounded structured blocks instead of a wall of diff.\nmetadata:\n visibility: exported\n---\n\n# Visual Recap\n\n\\`/visual-recap\\` creates a visual plan built **from** a diff, not toward one. It\nis the reverse of forward planning: instead of describing the change you are\nabout to make, you describe the change that was just made, at a higher altitude\nthan line-by-line review. The same plan data model serves both directions —\nschema, API, file, and architecture changes become the same \\`data-model\\`,\n\\`api-endpoint\\`, \\`file-tree\\`, and \\`diagram\\` blocks a forward plan would use, only\nnow they summarize work that exists. A reviewer scans the shape of the change\nbefore spending attention on the literal lines.\n\n## Local-Files Privacy Mode Exception\n\nUse local-files privacy mode when the user explicitly asks for no DB writes,\nno hosted Plan app, no Plan MCP publish, fully local files, offline/private\nrecaps, or when \\`AGENT_NATIVE_PLANS_MODE=local-files\\` is set. This is the only\nexception to the hosted publish rule below.\n\nIn local-files mode:\n\n- Read the diff/stat/source context from local files and shell commands only.\n The existing \\`npx @agent-native/core@latest recap collect-diff\\`, \\`scan\\`, and\n \\`build-prompt --local-files\\` helpers are safe to use because they operate on\n local files and do not write to the Plan database.\n- Write the recap as a local MDX folder under \\`plans/<slug>/\\`: \\`plan.mdx\\`,\n optional \\`canvas.mdx\\`, optional \\`prototype.mdx\\`, and optional\n \\`.plan-state.json\\`. Set \\`kind: \"recap\"\\` and \\`localOnly: true\\` in\n frontmatter/state when authoring the source.\n- Run \\`npx @agent-native/core@latest plan local preview --dir plans/<slug> --kind recap\\` after\n writing or updating the folder. Report the returned local URL or the\n \\`/local-plans/<slug>\\` route if the local Plan app is running with the same\n \\`PLAN_LOCAL_DIR\\`.\n- Do **not** call \\`create-visual-recap\\`, \\`create-visual-plan\\`,\n \\`import-visual-plan-source\\`, \\`update-visual-plan\\`,\n \\`patch-visual-plan-source\\`, \\`get-plan-feedback\\`, \\`export-visual-plan\\`,\n \\`set-resource-visibility\\`, or any hosted Plan tool for that recap.\n- Treat review feedback as file or chat feedback: update the MDX files directly,\n rerun the local preview command, and summarize the new local URL/path.\n Hosted comments, sharing, screenshots, usage attachment, and PR sticky comment\n publishing are unavailable until the user explicitly opts into publishing.\n\nLocal-files mode prevents recap content from going to the Agent-Native Plan\ndatabase. It does not by itself make the coding agent's language model local;\nfor that stronger privacy boundary, the host agent/model must also be local or\notherwise approved by the user.\n\n## Always Publish As An Agent-Native Plan — Never Inline\n\nThe deliverable is ALWAYS a published Agent-Native Plan, created with the\n\\`create-visual-recap\\` tool on the Plan MCP connector. The connector is usually\nexposed as the \\`plan\\` server, but older installed agents may expose the same\nhosted connector as \\`agent-native-plans\\`; both names are valid. NEVER hand the\nrecap to the user as inline chat content — not Markdown prose, not an ASCII\nsketch, not a table, not a fenced \"wireframe\", not a \"here's the recap\" summary.\nA recap's entire value is the hosted, interactive, annotatable plan; an inline\nsummary is not a recap, it is the thing a recap replaces. The only supported\noutput is to publish the plan and return its absolute URL.\n\nExcept for the explicit local-files privacy mode above, if neither the \\`plan\\`\nnor legacy \\`agent-native-plans\\` Plan MCP tools are available, do NOT improvise an\ninline recap as a fallback. Do not report the connector as disconnected just\nbecause it is named \\`agent-native-plans\\` instead of \\`plan\\`. The usual cause is a\nconnector that did not finish connecting this session (it registers zero tools),\nNOT necessarily an auth problem — so do not assume the user must authenticate.\nStop and tell the user how to restore it for their current client: in\nCodex/Codex Desktop, run\n\\`npx -y @agent-native/core@latest reconnect https://plan.agent-native.com --client codex\\`\nand start a new Codex session; in Claude Code, run \\`/mcp\\` and choose\nAuthenticate/Reconnect, or run the reconnect command with \\`--client claude-code\\`\nand restart Claude. Auth is stored per client config/session; \\`--client all\\`\nrefreshes every local client config that already has the Plan entry, but each\nrunning client still has to reload its MCP tools. Reconnect re-authenticates\nWITHOUT reinstalling and finds the entry by URL regardless of connector name.\nNever reinstall from scratch just to fix auth. Then publish once the tool is\nreachable. Falling back to inline content is a defect, not a degraded mode.\n\n## When To Use\n\nBuild a recap when a PR or commit is large, multi-file, or touches schema, API\ncontracts, or architecture, and a reviewer would benefit from seeing the change\nmapped to structured blocks before reading the raw diff. A GitHub Action can\ngenerate one automatically from a PR diff; an agent can generate one on request\n(\"recap this PR\", \"show me what this branch changed\"). Skip it for small,\nsingle-file, or obvious diffs — a recap is review overhead, and a tiny change\nreviews faster as plain diff.\n\n## Recap The Whole Work Unit\n\nWhen \\`/visual-recap\\` is invoked in a chat thread after work has already happened,\nthe default scope is the whole current work unit/thread, not only the most recent\nuser message, tool action, or follow-up fix. Gather the thread-owned changes\nacross the conversation: original implementation work, later bug fixes, UI\nfollow-ups, tests, changesets, skill/instruction updates, generated plan/source\nartifacts, and any local import/linking fixes needed to make the recap open.\n\nUse the current diff plus conversation context to separate thread-owned changes\nfrom unrelated dirty work that existed before the thread. Exclude unrelated\npre-existing edits. If the scope is genuinely ambiguous and cannot be inferred,\nstate the assumption or ask a concise question before publishing.\n\nWhen updating an existing recap after feedback, revise the recap so it still\ncovers the whole thread/work unit plus the new correction. Do not replace a broad\nrecap with a narrow recap of only the latest feedback unless the user explicitly\nasks for that narrower scope.\n\n## Keep The Recap Body Lean\n\nDo not add boilerplate intro, disclaimer, provenance, or summary prose blocks to\nthe generated plan body. In particular, do not create a \\`rich-text\\` block just to\nsay the recap is an aid, that the reviewer should still review the diff, how many\nfiles changed, or which ref/working tree generated the recap. The plan title,\nbrief, and \\`file-tree\\` (which carries the per-file change stats) already carry\nthat context.\n\nOnly add prose blocks when they tell the reviewer something specific about the\nchange that the structured blocks do not: the objective, a real compatibility\nrisk, an important decision visible in the diff, or a grounded review note.\n\n## Recaps Must Be Substantial\n\nLean is not the same as thin. A recap is not a single wireframe plus one\nsentence — that under-serves the reviewer as much as boilerplate prose over-serves\nthem. Alongside the visual/structural headline (wireframes, \\`data-model\\`,\n\\`api-endpoint\\`, \\`diagram\\`), a substantial recap also carries the implementation\nevidence:\n\n- A short surface/state inventory before authoring: list the changed routes,\n components, popovers/dialogs, role/access states, empty/error states, and\n shared abstractions visible in the diff. The final recap must either represent\n each meaningful item with a block or intentionally omit it because it is tiny,\n redundant, or not user-visible.\n- A \\`file-tree\\` of the changed files with each entry's \\`change\\` flag, so the\n reviewer sees the footprint of the work at a glance.\n- The split \\`diff\\` of the KEY changed files, grouped under a \\`## Key changes\\`\n \\`rich-text\\` heading in a single horizontal \\`tabs\\` block (the default\n orientation, one file per tab), with a one-line \\`summary\\` and a few\n \\`annotations\\` on each — so the reviewer can drop from the high-altitude shape\n straight into the load-bearing code. Use horizontal file tabs, not a vertical\n side rail, so the selected file has enough width for the side-by-side diff.\n\nSkip the diff appendix only for a genuinely tiny change that reviews faster as\nplain diff (see \"When To Use\"); for any change worth recapping, the file-tree and\nkey-change diffs belong in the plan.\n\n## Canonical Shape And Budgets\n\nA strong recap follows one skeleton, top to bottom:\n\n1. UI-impact headline — wireframes first, when the diff changed rendered UI.\n2. Short outcome narrative (\\`rich-text\\`): what changed and why, 1-3 paragraphs.\n3. \\`data-model\\` / \\`api-endpoint\\` blocks for schema and contract changes.\n4. \\`file-tree\\` of the changed files with \\`change\\` flags.\n5. \\`## Key changes\\` — one horizontal \\`tabs\\` block of \\`diff\\` / \\`annotated-code\\`.\n\nBudgets that keep the recap reviewable:\n\n- 3-8 key-change tabs. Fewer than 3 on a large change under-serves the\n reviewer; more than 8 stops being a summary.\n- Keep each diff/annotated-code excerpt focused — prefer under ~150 lines per\n tab; summarize or link the rest of a long file instead of dumping it.\n- Title at most ~70 characters; brief 1-3 sentences.\n\n**GOOD.** A 25-file auth change: Before/After wireframes of the login surface,\na two-paragraph narrative, a diff-aware \\`data-model\\` of the sessions table, an\n\\`api-endpoint\\` for the new refresh route, a \\`file-tree\\` with change flags, and\n\\`## Key changes\\` with five focused tabs, each with a one-line \\`summary\\` and a\nfew annotations on the load-bearing hunks.\n\n**BAD.** One giant unsegmented diff dump with no summaries or annotations; or a\nsparse three-block recap of a 40-file change (one wireframe, one sentence, one\nfile list) that forces the reviewer back into the raw diff anyway.\n\n## UI Impact Needs Wireframes\n\nWhen the diff changes rendered UI, layout, density, visual state, interaction\naffordances, navigation, controls, menus, dialogs, or design tokens, the recap\nMUST include one or more wireframes. Prose and file diffs are not a substitute\nfor showing what changed visually.\n\nBefore choosing wireframes, make a UI coverage pass from the diff:\n\n- Identify the entry surface where the change appears, such as a page header,\n list row, toolbar, route shell, or menu trigger.\n- Identify the interaction surface that opens or changes, such as a popover,\n dialog, tab, sheet, dropdown, inline editor, or toast.\n- Identify the resulting destination or persistent state, such as a public page,\n read-only view, empty state, error state, loading state, permission-denied\n state, or saved/shared state.\n- Identify access or role variants when permissions change. Owner/admin/editor\n versus viewer/non-manager differences are visual behavior and need a compact\n matrix, paired wireframes, or clearly labeled state sequence.\n\nFor UI-heavy PRs, a single before/after of the entry surface is not enough.\nShow the changed entry point, the main changed interaction surface, and the\nresulting/destination state. Add more states when the diff adds tabs, role-based\ncontrols, public/private visibility, invite/manage flows, destructive controls,\nor empty/error branches.\n\nChoose the smallest visual surface that makes the review clear:\n\n- Use a \\`Before\\` / \\`After\\` wireframe pair when the reviewer benefits from direct\n comparison, such as a removed or added control, a changed state, layout\n density, ordering, navigation, or a visible component replacement.\n \\`references/wireframe.md\\` owns how to lay that pair out (columns vs.\n vertical stack by geometry).\n- Use an after-only wireframe when the change is purely additive or the \"before\"\n state would only show absence without adding review value.\n- Use more than two wireframes when the UI change is flow-dependent, responsive,\n or stateful; show the meaningful states in order instead of forcing a single\n before/after pair.\n- For tiny surfaces like menus, popovers, dialogs, toasts, or panels, use the\n matching \\`surface\\` (\\`popover\\`, \\`panel\\`, etc.) and show the focused sub-surface.\n Do not redraw a full page unless placement in the page is itself part of the\n change.\n\nGround each wireframe in the changed UI behavior, component names, file paths,\nand diff-visible labels/states. If exact pixels are inferred rather than\ncaptured, say so in the wireframe caption or a concise annotation. For\nlocal/manual recaps, import or update the plan source that holds the wireframes\nso the rendered recap opens with the UI visual available.\n\n## Wireframe Quality — read \\`references/wireframe.md\\`\n\nUI recap/plan wireframes must meet a strict quality bar — full-width chrome,\npinned bottom bars, real product content, before/after comparability, the right\n\\`surface\\` preset, \\`--wf-*\\` tokens instead of hex, and no \\`<html>\\`/\\`<style>\\`/font\ntags. Before authoring ANY wireframe / \\`<Screen>\\` / \\`WireframeBlock\\`, READ\n\\`references/wireframe.md\\` in this skill directory — it is the single source of\ntruth for HTML wireframe quality, shared word for word with \\`/visual-plan\\`\nand \\`/visual-recap\\`. Do not author wireframes from memory.\n\nUse the standard \\`WireframeBlock\\` / \\`<Screen>\\` format so the Plan viewer owns the\nsurface frame, theme, and sketchy/clean toggle. HTML wireframes are appropriate\nwhen placement precision matters, especially popovers, menus, dialogs, and dense\nforms. For HTML\nwireframes, keep \\`renderMode\\` unset or \\`wireframe\\` unless a design-only editable\nmockup is explicitly required, because \\`renderMode=\"design\"\\` disables the\nsketchy rough overlay.\n\nWhen a browser tool is available, render a UI-impact recap in the Plan viewer\nand visually inspect it at the current theme before sharing. If any label,\nannotation, toolbar, or wireframe content overlaps another element, fix the MDX\nand re-import before reporting the link. A text-match screenshot is not enough;\nvisually inspect the captured image. When no browser is available (for example\na headless CI agent), state that in the recap handoff instead.\n\n## Open And Report The Recap\n\nIn local-files privacy mode, report the local preview URL/path from\n\\`npx @agent-native/core@latest plan local preview\\` or the \\`/local-plans/<slug>\\` route for a local\nPlan app using the same \\`PLAN_LOCAL_DIR\\`. Do not invent a hosted URL and do not\npublish just to get an absolute Plan link.\n\nAfter creating the recap, link the reviewer to the rendered plan with an\n**absolute URL on the origin whose database actually holds the plan**. That\norigin is the Plan MCP server you just created the recap through — NOT whatever\ndev server you happen to know is running. The create tool returns the correct\nlink; report THAT. Never make the primary link a local \\`plan.mdx\\` file, a local\nmirror folder, or a relative path such as \\`/plans/<id>\\`.\n\nWhen the recap is posted to a PR for a private repo, the plan link is not a\npublic URL. Make the PR comment/handoff copy explicit: reviewers may need to\nsign in to Agent-Native Plans with an account that has access to the owning\norganization before the link loads. Use wording like: \"Private repo recap:\nsign in with access to this org if the plan does not open.\" Do not imply the\nlink is broken or public when access is gated by repo/org visibility.\n\nA recap lives only in the database of the MCP that created it. A separately\nrunning local dev server (e.g. \\`http://localhost:8081\\`) has its OWN database and\nwill NOT contain a recap created through the hosted MCP, so a hand-built\n\\`localhost\\` link returns \"Plan not found\". This is the most common recap\nmistake — do not guess an origin you have not confirmed shares the MCP's data.\n\nResolve the URL in this order:\n\n1. Use the absolute URL the create tool RETURNS — \\`openLink.webUrl\\`, else the\n \\`visualUrl\\` in the returned \\`plan.mdx\\` frontmatter, else \\`url\\`/\\`path\\`\n resolved against the MCP server's own origin (for the hosted MCP that is\n \\`https://plan.agent-native.com\\`). This always points at the database that has\n the plan.\n2. Use a \\`localhost\\`/dev origin ONLY when the recap was created through a Plan\n MCP bound to that same origin — i.e. that MCP's url is\n \\`http://localhost:<port>/_agent-native/mcp\\`. Creating through the hosted MCP\n and linking to localhost is the exact mismatch that 404s.\n3. If only a plan id is available, build the MCP origin's absolute URL\n (hosted: \\`https://plan.agent-native.com/plans/<id>\\`) and say it was inferred.\n\nIf the user wants to review on localhost but the recap was created through the\nhosted MCP, say so plainly: the local dev server cannot see it. To view a recap\non localhost (e.g. to exercise un-deployed local renderer changes), they must\nconnect a LOCAL Plan MCP (\\`http://localhost:<port>/_agent-native/mcp\\`) and\nre-create the recap through it so it lands in the local database; offer to do\nthat rather than handing over a localhost URL that will not resolve.\n\nWhen running in Codex and the Browser/in-app side browser tools are available,\nopen the returned absolute recap URL there automatically after creation. Still\ninclude the same absolute URL in the final response. Local mirror files like\n\\`plans/<slug>/plan.mdx\\` may be mentioned only as secondary source-control\nartifacts, not as the main way to open the recap.\n\n## Diff → Block Mapping\n\nMap each kind of change to the block that carries it, derived mechanically from\nthe actual diff. The names below are the CONCEPTUAL block types, not the JSX\ntags — resolve every conceptual name to its exact tag + prop schema with the\n\\`get-plan-blocks\\` tool (see \"Block reference\" below) before authoring.\n\n- **Schema / migration change** → \\`data-model\\` for the resulting entities,\n fields, and relations. Flag what moved per field/entity with\n \\`change: \"added\" | \"modified\" | \"removed\" | \"renamed\"\\`, and for a changed type\n set \\`was\\` to the prior value (e.g. the old column type) — grounded in the real\n migration diff. That diff-aware \\`data-model\\` is the headline; reach for a split\n \\`diff\\` of the literal SQL only when the exact statement still matters, not by\n default.\n- **API / action / route change** → \\`api-endpoint\\` with the method, path,\n params, request, and responses as they are after the change. Flag each changed\n param/response with \\`change\\` (and \\`was\\` on a param whose type/shape changed),\n and set \\`change\\` on the endpoint root for a wholly added or removed route. Mark\n removed endpoints with \\`deprecated: true\\` and explain in prose.\n Keep multiple API endpoints in the normal single-column document flow unless\n they are an explicit before/after contract comparison.\n Author each request/response example as a SINGLE valid JSON value — one\n top-level object or array, parseable on its own — so it renders in the\n collapsible JSON explorer. Do not put \\`//\\` or \\`/* */\\` comments, prose,\n trailing commas, or two or more concatenated top-level objects inside one\n example; a non-parseable body falls back to flat text and loses the explorer.\n When an endpoint has several distinct message shapes (for example separate\n websocket frame types, or a success body versus an error body), give each its\n OWN example with its own label rather than cramming them into one body.\n- **Compatibility-sensitive change** → short \\`rich-text\\` notes beside the\n relevant \\`data-model\\` / \\`api-endpoint\\` block. Name the changed field,\n endpoint, or behavior and mark whether it is breaking, risky, or non-breaking;\n pair that note with a split \\`diff\\` for the literal lines.\n- **Any meaningful code hunk** → \\`diff\\` with \\`mode: \"split\"\\`, carrying the real\n \\`before\\` / \\`after\\` text and the \\`filename\\` / \\`language\\`. Split mode is the\n default for recap code review because before/after legibility is the point;\n use \\`mode: \"unified\"\\` only for a genuinely narrow standalone hunk where\n side-by-side would hide the code. Give every \\`diff\\` a one-line \\`summary\\`\n saying what the hunk changes and why; it renders as a description above the\n code so the reviewer reads intent first. Never leave a diff unlabeled.\n For the KEY changed files, attach \\`annotations\\` to the \\`diff\\` so the recap\n calls out what each important hunk does — this is the headline affordance for\n annotating the key files updated. Each annotation anchors to the AFTER-side\n line numbers by default (set \\`side: \"before\"\\` to point at removed lines). Keep\n it to a few high-signal notes per file, not one per line.\n When several key files each need a substantial diff, introduce the group with a\n \\`rich-text\\` heading block whose markdown is \\`## Key changes\\`, then place the\n \\`diff\\` blocks under it in a reusable \\`tabs\\` block with horizontal orientation\n (the default — omit \\`orientation\\`) so the selected file's split diff gets the\n full document width. Let that heading label the section — do NOT also set a\n \\`title\\` on the \\`tabs\\` block. Keep each tab label to the file path or a short\n basename plus directory hint.\n If the recap ends with more than one supporting diff, that trailing diff\n appendix should be one horizontal \\`tabs\\` block under its own \\`## Key changes\\`\n heading, not a stack of separate \\`diff\\` blocks.\n- **Brand-new file or a substantial added block with no meaningful \"before\"** →\n \\`annotated-code\\` rather than a one-sided split \\`diff\\`. Carry the real new code\n with its \\`filename\\` / \\`language\\` and anchor a few high-signal notes to the lines\n that matter so the reviewer reads what the new code does, not code for code's\n sake. Keep split \\`diff\\` for true before/after hunks where the removed lines\n still carry meaning, and group several annotated walkthroughs in a horizontal\n \\`tabs\\` block the same way diffs are grouped.\n- **Files added / removed / renamed** → \\`file-tree\\` with each entry's \\`change\\`\n flag (\\`added\\`, \\`removed\\`, \\`modified\\`, \\`renamed\\`) and a short \\`note\\`; attach a\n \\`snippet\\` only when one tells the reviewer something the path does not.\n- **Rendered UI / interaction change** → one or more wireframes showing the\n visible UI delta before the reviewer reads code. Use \\`Before\\` / \\`After\\`\n wireframes when the comparison clarifies the change; otherwise use after-only\n or a short state/flow sequence. Use realistic UI surfaces: for a popover\n change, show a popover with its title row, top-right actions, options/fields,\n tabs, selected/disabled states, people/lists/rows, and any opened prompt/menu\n anchored to the correct trigger. If a route was added, show the route body and\n the unavailable/empty state when the diff implements one. If permissions\n changed, show what managers can do and what viewers/non-managers see instead.\n Keep the body lean: the wireframe carries the UI story, while the file tree\n and \\`diff\\` blocks carry implementation evidence.\n- **Architecture or data-flow shift** → \\`diagram\\` with \\`data.html\\` / \\`data.css\\`\n as a two-panel before/after, layered, or swimlane layout, or \\`mermaid\\` for a\n quick graph. Use two-dimensional layouts; do not reduce a structural change to\n a left-to-right chain. Do not use \\`diagram\\` as a stand-in for rendered UI\n controls; UI changes need \\`wireframe\\` blocks.\n Author diagram HTML/CSS with the renderer-owned \\`.diagram-*\\` primitives\n (\\`.diagram-panel\\`, \\`.diagram-node\\`, \\`.diagram-pill\\`, \\`[data-rough]\\`, …) and\n the same \\`--wf-*\\` theme tokens \\`references/wireframe.md\\` defines — never\n \\`font-family\\`, hex, rgb/hsl literals, or one-off dark/light palettes.\n- **Outcome-first narrative** → \\`rich-text\\` for the \"what changed and why\" prose:\n the objective the diff served, the key decisions visible in it, and the risks a\n reviewer should weigh. This is the only place the model writes freely.\n\n## Block reference — call \\`get-plan-blocks\\`, do not memorize tags\n\nThe conceptual block names above (\\`api-endpoint\\`, \\`data-model\\`, \\`json-explorer\\`,\n\\`tabs\\`, …) are NOT the JSX tags you author with, and the exact tags, required\nfields, and prop shapes change as the block library evolves. Do not author from\nmemorized tags — they drift and silently produce a wrong tag (\\`ApiEndpoint\\`\ninstead of \\`Endpoint\\`, \\`JsonExplorer\\` instead of \\`Json\\`, \\`Tabs\\` instead of\n\\`TabsBlock\\`) that errors on import.\n\n**Before writing any structured plan content, call \\`get-plan-blocks\\` on the Plan\nMCP connector (\\`plan\\` or legacy \\`agent-native-plans\\`).** It returns the\nauthoritative, always-current block\nvocabulary generated live from the app's own block registry — the same config\nthe renderer and MDX round-trip use — so it can never be stale even if this\nSKILL.md is an old installed copy:\n\n- \\`get-plan-blocks\\` (default \\`format: \"reference\"\\`) → a compact table of every\n block's runtime \\`type\\`, exact MDX \\`<Tag>\\`, placement, and key data fields.\n This is your map from each conceptual name above to its real tag and props.\n- \\`get-plan-blocks\\` with \\`format: \"schema\"\\` → the full per-block JSON Schema\n plus a worked example for each block, when you need exact field types,\n enums, or nesting (e.g. \\`Diff.annotations\\`, \\`Endpoint.params[].in\\`,\n \\`DataModel.entities[].fields[]\\`).\n\nAuthor the recap source against the tags and schemas that call returns. The\ncomplete set of valid block-level tags is whatever \\`get-plan-blocks\\` lists;\nany other capitalized tag at the block level is rejected on import with an\n\"Unknown plan block\" / \"did you mean\" error. Lowercase HTML tags inside\n\\`rich-text\\`/markdown prose (\\`<div>\\`, \\`<span>\\`, \\`<code>\\`, \\`<br>\\`, …) are always\nfine — only capitalized component-style block tags are validated.\n\nA few recap-specific authoring rules the registry table cannot encode:\n\n- Every block takes a REQUIRED \\`id\\` (unique across the whole plan) plus the\n shared optional \\`summary\\` / \\`editable\\` envelope; give a block a heading by\n placing a \\`rich-text\\` block with a Markdown \\`###\\` heading directly above it\n (blocks no longer take a \\`title\\`).\n- \\`Endpoint\\`: prose \\`description\\` is the MDX **children** (body between the\n tags), not an attribute; for a WebSocket upgrade use \\`method=\"GET\"\\`. Each\n request/response \\`example\\` is a JSON **string** (the renderer parses it into\n the JSON explorer), so keep it a single parseable JSON value.\n- \\`TabsBlock\\`: the whole \\`tabs\\` array (including nested child blocks) is ONE\n JSON \\`tabs={[…]}\\` prop — there is NO nested \\`<Tab>\\` element.\n- \\`WireframeBlock\\`: its body is a single \\`<Screen surface ... html=… />\\` subtree\n (nested MDX, not a flat prop); \\`html\\` must be a single-quoted string or static\n template literal, never a dynamic \\`html={someVar}\\` expression. See\n \\`references/wireframe.md\\` for the HTML rules.\n- \\`Diagram\\`: the whole payload is one \\`data={{ html?, css?, nodes?, edges?, … }}\\`\n attribute and requires either \\`html\\` or at least one node; \\`Mermaid\\` is its\n own separate block (\\`source\\` text), not a \\`Diagram\\` prop.\n\n## Before / After Is The Headline\n\nThe recap's center of gravity is the before/after comparison. For document-body\ncomparisons there are two primitives, and they cover the whole need together:\n\n- **\\`columns\\`** — the side-by-side container, for **structured** comparisons.\n Use two columns labeled \\`Before\\` and \\`After\\`, each holding a block (commonly a\n \\`data-model\\`, \\`api-endpoint\\`, or \\`rich-text\\`), so the reviewer reads the old\n shape against the new shape in one glance. This is the right primitive for\n \"the schema went from X to Y\" or \"the endpoint contract changed like this.\"\n Do not use \\`columns\\` simply to compact or group a list of API endpoints.\n- **\\`diff\\`** — for **code**. It renders the literal removed and added lines. Use\n it for the actual hunks. Use split mode by default for recap code review;\n reserve \\`mode: \"unified\"\\` for genuinely narrow standalone hunks where\n side-by-side would hide the code. Key-file diff groups should use horizontal\n tabs so split diffs get the full document width.\n\nFor UI diffs, wireframes are the visual comparison primitive. Use before/after\nwireframes when the comparison clarifies the change; use after-only or a state\nsequence when that better matches the change. The visual headline must show\nexact placement, realistic chrome, and adequate padding before any abstract\nexplanation. Do not stop at the first visible affordance when the diff adds a\nflow; show the entry point, the opened surface, and the resulting state or page\nso the reviewer can trace the actual user path. \\`references/wireframe.md\\` owns\nthe before/after layout choice —\nthe \\`columns\\` renderer keeps narrow surfaces side by side and auto-stacks wide\n\\`desktop\\`/\\`browser\\` frames vertically; never hand-build a side-by-side\nwireframe layout in \\`custom-html\\`. For document-body\ncomparisons, there is no other multi-column primitive — \\`columns\\` plus the\n\\`diff\\` block are the whole comparison vocabulary. Do not hand-build side-by-side\nlayouts in \\`custom-html\\`, and do not stack two \\`data-model\\` blocks vertically\nand call it a comparison when \\`columns\\` exists to put them side by side.\n\n## Grounding Rule\n\nStructured blocks are **true by construction** only if they are derived from the\nactual changed lines. The \\`diff\\`, \\`data-model\\`, \\`api-endpoint\\`, and \\`file-tree\\`\nblocks MUST be built mechanically from the real diff — real paths, real fields,\nreal method/path, real before/after text — never inferred, rounded, or invented.\nThe model writes only the prose: the \"why\", the narrative, the risk read. A\nconfidently wrong recap is dangerous in a review context, because a reviewer who\ntrusts the summary may skip the very line the summary got wrong. When the diff\ndoes not contain a fact, leave it out rather than guess; mark anything the model\ninferred (not extracted) as inferred in prose.\n\n## Security\n\n- **Gate visibility.** Recaps of a private repo are org/login-gated — set the\n plan's visibility to the owning org or login, never auto-public. A recap can\n expose unreleased schema, internal endpoints, and architecture; treat it like\n the source it summarizes. Any PR comment or handoff that links to the recap\n must say that private-repo recaps require signing in with access to the owning\n org if the link does not load.\n- **Never transcribe secrets.** A diff can contain API keys, tokens, webhook\n URLs, signing secrets, \\`.env\\` values, or credential-looking literals. Do not\n copy any of these into a \\`diff\\`, \\`file-tree\\` snippet, \\`api-endpoint\\`, or prose\n block — redact them (\\`sk-•••\\`, \\`<redacted>\\`). This mirrors the repo's\n hardcoded-secret rule: obviously fake placeholders only, never the real value,\n in any block, caption, or note.\n\n## Bidirectional Loop\n\nBecause a recap is a real, editable plan, the same review loop as forward plans\napplies: a reviewer can annotate any block, and the coding agent reads\n\\`get-plan-feedback\\` to drive fixes back into the code — annotation → agent →\ndiff, the same close-the-loop flow forward plans use. After a reviewer annotates\na block, call \\`get-plan-feedback\\` to read the structured feedback, then either\nupdate the recap with \\`create-visual-recap\\` (passing the existing \\`planId\\` to\nreplace it in place) or apply targeted changes with \\`update-visual-plan\\`. The\nloop is live and wired. The one thing not yet automatic is PR-comment-triggered\nre-runs: the GitHub Action creates an initial recap per PR, but it does not yet\nre-run automatically when new review feedback is posted in GitHub — that\nauto-re-run is the remaining fast-follow.\n\n## Related Skills\n\n- **visual-plan** — the canonical command and the source of the shared Wireframe\n & Canvas and Document Quality cores; a recap follows the same block discipline\n in reverse.\n- **comment anchors** — recap comments use the same anchor rules as forward\n plans; see \"Interpreting comment anchors\" in the visual-plan skill for\n coordinate frames, wireframe node ids, text-quote resolution, detached\n threads, routing via \\`resolutionTarget\\`, and two-axis consumed/resolved state.\n- **security** — data scoping, secret handling, and the hardcoded-secret rule the\n recap's redaction and visibility gating mirror.\n- **sharing** — org/login-gated visibility for the plan that holds the recap.\n`;\n\nexport const BUILT_IN_APP_SKILLS = {\n assets: {\n skillName: \"assets\",\n manifest: normalizeAppSkillManifest({\n schemaVersion: 1,\n id: \"assets\",\n displayName: \"Assets\",\n description:\n \"Create, search, select, and export brand image and video assets from the Assets app.\",\n hosted: {\n url: \"https://assets.agent-native.com\",\n mcpUrl: \"https://assets.agent-native.com/_agent-native/mcp\",\n },\n mcp: { serverName: \"agent-native-assets\" },\n auth: {\n mode: \"oauth\",\n setup:\n \"Authenticate with the Assets MCP connector in the host app. No shared secrets are stored in skill files.\",\n },\n surfaces: [\n {\n id: \"asset-picker\",\n action: \"open-asset-picker\",\n path: \"/picker\",\n mediaTypes: [\"image\", \"video\"],\n defaultMediaType: \"image\",\n },\n ],\n skills: [\n {\n path: \"skills/assets\",\n visibility: \"exported\",\n exportAs: \"assets\",\n },\n ],\n hostAdapters: [\n \"codex-plugin\",\n \"claude-marketplace\",\n \"vercel-skills\",\n \"plain-skill\",\n \"claude-skill\",\n \"chatgpt-mcp\",\n \"generic-mcp\",\n ],\n }),\n skillMarkdown: ASSETS_SKILL_MD,\n },\n design: {\n skillName: \"design-exploration\",\n manifest: normalizeAppSkillManifest({\n schemaVersion: 1,\n id: \"design\",\n displayName: \"Design\",\n description:\n \"Explore, compare, iterate, and export interactive UI design prototypes from the Design app.\",\n hosted: {\n url: \"https://design.agent-native.com\",\n mcpUrl: \"https://design.agent-native.com/_agent-native/mcp\",\n },\n mcp: { serverName: \"agent-native-design\" },\n auth: {\n mode: \"oauth\",\n setup:\n \"Authenticate with the Design MCP connector in the host app. No shared secrets are stored in skill files.\",\n },\n surfaces: [\n {\n id: \"design-exploration\",\n action: \"present-design-variants\",\n path: \"/design\",\n },\n ],\n skills: [\n {\n path: \"skills/design-exploration\",\n visibility: \"exported\",\n exportAs: \"design-exploration\",\n },\n ],\n hostAdapters: [\n \"codex-plugin\",\n \"claude-marketplace\",\n \"vercel-skills\",\n \"plain-skill\",\n \"claude-skill\",\n \"chatgpt-mcp\",\n \"generic-mcp\",\n ],\n }),\n skillMarkdown: DESIGN_EXPLORATION_SKILL_MD,\n },\n \"visual-plans\": {\n skillName: \"visual-plan\",\n extraSkills: {\n \"visual-recap\": VISUAL_RECAP_SKILL_MD,\n },\n // Sibling reference files materialized alongside each skill's SKILL.md\n // (progressive disclosure). Keyed by skill name -> relative path -> content.\n // Both plan skills ship the same canonical wireframe-quality reference; the\n // canvas / document-quality / exemplar references are visual-plan only.\n extraFiles: {\n \"visual-plan\": {\n \"references/wireframe.md\": WIREFRAME_REFERENCE_MD,\n \"references/canvas.md\": CANVAS_REFERENCE_MD,\n \"references/document-quality.md\": DOCUMENT_QUALITY_REFERENCE_MD,\n \"references/exemplar.md\": EXEMPLAR_REFERENCE_MD,\n },\n \"visual-recap\": { \"references/wireframe.md\": WIREFRAME_REFERENCE_MD },\n },\n manifest: normalizeAppSkillManifest({\n schemaVersion: 1,\n id: \"visual-plans\",\n displayName: \"Agent-Native Plan\",\n description:\n \"Generate and review coding-agent plans as structured documents with inline diagrams, annotated code walkthroughs, file trees, annotations, feedback, and HTML export.\",\n hosted: {\n url: \"https://plan.agent-native.com\",\n mcpUrl: \"https://plan.agent-native.com/_agent-native/mcp\",\n },\n mcp: { serverName: \"plan\", aliases: [\"agent-native-plans\"] },\n auth: {\n mode: \"oauth\",\n setup:\n \"Install with the Agent-Native CLI to add the /visual-plan and /visual-recap skills plus the Plan MCP connector. Authenticate only for hosted/account-backed sharing.\",\n },\n surfaces: [\n {\n id: \"visual-plan\",\n action: \"create-visual-plan\",\n path: \"/plans\",\n description:\n \"Create a general coding-agent plan. Architecture/code plans default to inline document blocks; top canvas/prototype surfaces are optional for UI/product review.\",\n },\n {\n id: \"visual-recap\",\n action: \"create-visual-recap\",\n path: \"/plans\",\n description:\n \"Create a visual recap plan from a PR, commit, branch, or git diff for high-altitude review.\",\n },\n ],\n skills: [\n {\n path: \"skills/visual-plan\",\n visibility: \"exported\",\n exportAs: \"visual-plan\",\n },\n {\n path: \"skills/visual-recap\",\n visibility: \"exported\",\n exportAs: \"visual-recap\",\n },\n ],\n hostAdapters: [\n \"codex-plugin\",\n \"claude-marketplace\",\n \"vercel-skills\",\n \"plain-skill\",\n \"claude-skill\",\n \"chatgpt-mcp\",\n \"generic-mcp\",\n ],\n }),\n skillMarkdown: VISUAL_PLANS_SKILL_MD,\n },\n \"context-xray\": {\n skillName: \"context-xray\",\n localOnly: true,\n manifest: normalizeAppSkillManifest({\n schemaVersion: 1,\n id: \"context-xray\",\n displayName: \"Context X-Ray\",\n description:\n \"Visualize local Codex and Claude Code context usage with warnings and optimization tips.\",\n hosted: {\n url: \"https://context-xray.agent-native.com\",\n mcpUrl: \"https://context-xray.agent-native.com/_agent-native/mcp\",\n },\n mcp: { serverName: \"agent-native-context-xray\" },\n auth: { mode: \"none\" },\n surfaces: [\n {\n id: \"context-xray-report\",\n path: \"/\",\n },\n ],\n skills: [\n {\n path: \"skills/context-xray\",\n visibility: \"exported\",\n exportAs: \"context-xray\",\n },\n ],\n hostAdapters: [\"plain-skill\", \"claude-skill\"],\n }),\n skillMarkdown: CONTEXT_XRAY_SKILL_MD,\n },\n} satisfies Record<\n string,\n {\n manifest: AppSkillManifest;\n skillMarkdown: string;\n skillName: string;\n extraSkills?: Record<string, string>;\n /**\n * Extra sibling files materialized alongside a skill's SKILL.md, for\n * progressive disclosure (e.g. `references/wireframe.md`). Keyed by skill\n * name, then by skill-relative path -> file content.\n */\n extraFiles?: Record<string, Record<string, string>>;\n localOnly?: boolean;\n }\n>;\n\ntype BuiltInAppSkillId = keyof typeof BUILT_IN_APP_SKILLS;\n\nexport const AGENT_NATIVE_SKILL_METADATA_FILE = \"agent-native-skill.json\";\n\nconst BUILT_IN_APP_SKILL_ALIASES = {\n assets: \"assets\",\n asset: \"assets\",\n \"asset-generation\": \"assets\",\n images: \"assets\",\n image: \"assets\",\n \"image-generation\": \"assets\",\n \"agent-native-assets\": \"assets\",\n \"agent-native-images\": \"assets\",\n design: \"design\",\n \"ui-design\": \"design\",\n \"ux-design\": \"design\",\n \"design-exploration\": \"design\",\n \"ux-exploration\": \"design\",\n \"agent-native-design\": \"design\",\n \"agent-native-design-exploration\": \"design\",\n \"visual-plans\": \"visual-plans\",\n \"visual-plan\": \"visual-plans\",\n \"visual-recap\": \"visual-plans\",\n \"visual-recaps\": \"visual-plans\",\n \"code-review-recap\": \"visual-plans\",\n \"code-review-recaps\": \"visual-plans\",\n \"html-plan\": \"visual-plans\",\n \"plan-mode\": \"visual-plans\",\n plannotate: \"visual-plans\",\n plannotator: \"visual-plans\",\n \"agent-native-visual-plans\": \"visual-plans\",\n \"context-xray\": \"context-xray\",\n \"local-context-xray\": \"context-xray\",\n xray: \"context-xray\",\n \"context-window\": \"context-xray\",\n \"context-usage\": \"context-xray\",\n \"agent-native-context-xray\": \"context-xray\",\n} satisfies Record<string, BuiltInAppSkillId>;\n\nconst BUILT_IN_APP_SKILL_DISPLAY_ALIASES = {\n assets: [\"images\", \"image-generation\", \"agent-native-images\"],\n design: [\n \"design-exploration\",\n \"ux-exploration\",\n \"agent-native-design-exploration\",\n ],\n \"visual-plans\": [\n \"visual-plan\",\n \"visual-recap\",\n \"code-review-recap\",\n \"html-plan\",\n \"plannotate\",\n ],\n \"context-xray\": [\"xray\", \"context-window\", \"context-usage\"],\n} satisfies Record<BuiltInAppSkillId, string[]>;\n\nconst CLIENT_LABELS: Record<ClientId, string> = {\n \"claude-code\": \"Claude Code\",\n \"claude-code-cli\": \"Claude Code CLI\",\n codex: \"Codex\",\n cowork: \"Claude Cowork\",\n};\n\nconst CLIENT_HINTS: Record<ClientId, string> = {\n \"claude-code\": \".mcp.json or ~/.claude.json\",\n \"claude-code-cli\": \".mcp.json or ~/.claude.json\",\n codex: \"$CODEX_HOME/config.toml or ~/.codex/config.toml\",\n cowork: \"~/.cowork/mcp.json\",\n};\n\ntype SkillsCommand = \"list\" | \"add\" | \"status\" | \"update\" | \"help\";\n\nexport interface ParsedSkillsArgs {\n command: SkillsCommand;\n target?: string;\n client: string;\n clientExplicit: boolean;\n clients?: ClientId[];\n plainSkillNames?: string[];\n scope: string;\n scopeExplicit: boolean;\n yes: boolean;\n dryRun: boolean;\n printJson: boolean;\n instructions: boolean;\n mcp: boolean;\n /**\n * Run the browser/device auth flow after registering a hosted MCP connector\n * so the user does not hit an OAuth wall on the first tool call. Default true;\n * `--no-connect` opts out and leaves authentication for the host/`agent-native\n * connect`.\n */\n connect: boolean;\n /**\n * Optional MCP URL override. When set, the skill's hosted MCP connector is\n * registered against this URL instead of the built-in hosted default — e.g.\n * an ngrok tunnel, a local dev origin, or a self-hosted deployment.\n */\n mcpUrl?: string;\n /**\n * When installing the visual-plan skill, also write the PR Visual Recap\n * GitHub Action workflow into `.github/workflows/` so PRs get automatic\n * recaps. Only applies to the `visual-plan` target.\n */\n withGithubAction?: boolean;\n /**\n * Set once the PR Visual Recap workflow decision has already been made up\n * front (in `runSkills`, before any install/registration) so the per-target\n * `addAgentNativeSkill` doesn't prompt for it again mid-flow. The chosen\n * value lands in `withGithubAction`.\n */\n githubActionResolved?: boolean;\n /**\n * Plain skill repos can add a managed AGENTS.md / CLAUDE.md block for skills\n * that only become automatic through project instructions.\n */\n updateInstructions?: boolean;\n /**\n * When `--with-github-action` is set and the existing workflow file differs\n * from the bundled template, overwrite it. Without this flag the command\n * refuses and prints a message.\n */\n force?: boolean;\n}\n\nexport interface SkillsAddResult {\n id: string;\n displayName: string;\n instructionSource?: string;\n skillNames: string[];\n skillsAgents: string[];\n mcpUrl: string;\n mcpClients: ClientId[];\n dryRun: boolean;\n commands: string[];\n local?: boolean;\n scriptPath?: string;\n written?: string[];\n /**\n * True when the install also kicked off (or prepared) the browser/device auth\n * flow for the hosted MCP connector. False when connect was skipped\n * (`--no-connect`, no-auth skills, or non-interactive without a connect step).\n */\n connected?: boolean;\n /**\n * The exact `npx @agent-native/core@latest connect <url>` command to run when interactive auth\n * was skipped (non-interactive shell / CI). Empty when connect ran inline or\n * was not needed.\n */\n connectCommand?: string;\n /**\n * When `--with-github-action` installed the PR Visual Recap workflow, the\n * repo-relative path it was written to (and whether it overwrote an existing\n * file).\n */\n githubActionPath?: string;\n githubActionExisted?: boolean;\n githubActionSuggestedCommand?: string;\n}\n\ninterface SkillInstallMetadata {\n schemaVersion: 1;\n source: \"agent-native\";\n appSkillId: string;\n displayName: string;\n skillName: string;\n contentHash: string;\n mcpUrl: string;\n installedAt: string;\n updateCommand: string;\n}\n\ninterface SkillFolderBundle {\n appSkillId: BuiltInAppSkillId;\n displayName: string;\n skillName: string;\n mcpUrl: string;\n files: Record<string, string>;\n contentHash: string;\n}\n\ninterface SkillInstallState {\n appSkillId: BuiltInAppSkillId;\n displayName: string;\n skillName: string;\n path: string;\n root: string;\n scope: \"project\" | \"user\";\n client: string;\n latestHash: string;\n installedHash: string | null;\n metadataHash?: string;\n current: boolean;\n managed: boolean;\n}\n\ninterface SkillInstallTarget {\n id: string;\n displayName: string;\n loaded: LoadedAppSkillManifest;\n skillNames: string[];\n materializeInstructions(outDir: string): string;\n cleanup?: () => void;\n}\n\ninterface RunCommandOptions {\n stdio?: \"inherit\" | \"stderr\" | \"silent\";\n}\n\ninterface RunSkillsOptions {\n baseDir?: string;\n isInteractive?: () => boolean;\n log?: (message: string) => void;\n promptClients?: (\n context: SkillsClientPromptContext,\n ) => Promise<ClientId[] | null>;\n promptSkills?: (\n context: SkillsTargetPromptContext,\n ) => Promise<string[] | null>;\n promptGithubAction?: (\n context: SkillsGithubActionPromptContext,\n ) => Promise<boolean | null>;\n promptScope?: (\n context: SkillsScopePromptContext,\n ) => Promise<\"project\" | \"user\" | null>;\n runCommand?: (\n cmd: string,\n args: string[],\n options?: RunCommandOptions,\n ) => Promise<number>;\n /**\n * Injectable connect/auth entrypoint (defaults to the real `agent-native\n * connect`). Tests stub this so the install flow does not perform a real\n * browser/device OAuth round-trip.\n */\n runConnect?: (args: string[]) => Promise<void>;\n /**\n * Best-effort install-funnel telemetry. Created once per `runSkills` run and\n * threaded through resolution/install/connect so each `track` is fire-and-\n * forget and never blocks or throws into the install flow. Absent when\n * `addAgentNativeSkill` is called directly (e.g. tests).\n */\n telemetry?: CliTelemetry;\n}\n\ninterface SkillsClientPromptContext {\n initialClients: ClientId[];\n options: Array<{ value: ClientId; label: string; hint: string }>;\n}\n\ninterface SkillsTargetPromptContext {\n initialTargets: string[];\n options: Array<{ value: string; label: string; hint: string }>;\n}\n\ninterface SkillsGithubActionPromptContext {\n workflowPath: string;\n setupCommand: string;\n}\n\ninterface SkillsScopePromptContext {\n initialScope: \"project\" | \"user\";\n}\n\nfunction normalizeKnownSkillTarget(\n value: string | undefined,\n): BuiltInAppSkillId | undefined {\n const key = value?.trim().toLowerCase();\n if (!key) return undefined;\n return BUILT_IN_APP_SKILL_ALIASES[key];\n}\n\nfunction isKnownSkill(value: string | undefined): boolean {\n return Boolean(normalizeKnownSkillTarget(value));\n}\n\nfunction isLocalOnlyBuiltInSkill(\n entry: (typeof BUILT_IN_APP_SKILLS)[BuiltInAppSkillId] | null | undefined,\n): boolean {\n return Boolean(entry && \"localOnly\" in entry && entry.localOnly);\n}\n\nfunction builtInExtraSkills(\n entry: (typeof BUILT_IN_APP_SKILLS)[BuiltInAppSkillId],\n): Record<string, string> {\n return \"extraSkills\" in entry && entry.extraSkills ? entry.extraSkills : {};\n}\n\n/**\n * Sibling reference files for a skill (skill name -> relative path -> content),\n * materialized alongside its SKILL.md for progressive disclosure.\n */\nfunction builtInExtraFiles(\n entry: (typeof BUILT_IN_APP_SKILLS)[BuiltInAppSkillId],\n): Record<string, Record<string, string>> {\n return \"extraFiles\" in entry && entry.extraFiles ? entry.extraFiles : {};\n}\n\nfunction builtInSkillNames(\n entry: (typeof BUILT_IN_APP_SKILLS)[BuiltInAppSkillId],\n): string[] {\n return [entry.skillName, ...Object.keys(builtInExtraSkills(entry))];\n}\n\n/**\n * When a target names a single skill that lives inside a multi-skill bundle\n * (the plan bundle ships both `visual-plan` and `visual-recap`), restrict the\n * install to just that skill. The bundle aliases (`visual-plans`, `plannotate`,\n * …) return undefined so they install every skill in the bundle.\n */\nfunction builtInOnlySkillNames(target: string): string[] | undefined {\n const normalized = target.trim().toLowerCase();\n if (normalized === \"visual-plan\") return [\"visual-plan\"];\n if (normalized === \"visual-recap\" || normalized === \"visual-recaps\") {\n return [\"visual-recap\"];\n }\n return undefined;\n}\n\nfunction stableSkillHash(files: Record<string, string>): string {\n const hash = createHash(\"sha256\");\n for (const rel of Object.keys(files).sort()) {\n if (rel === AGENT_NATIVE_SKILL_METADATA_FILE) continue;\n hash.update(rel);\n hash.update(\"\\0\");\n hash.update(files[rel]);\n hash.update(\"\\0\");\n }\n return hash.digest(\"hex\").slice(0, 16);\n}\n\nfunction skillFilesForBuiltIn(\n appSkillId: BuiltInAppSkillId,\n): Record<string, SkillFolderBundle> {\n const entry = BUILT_IN_APP_SKILLS[appSkillId];\n const skills: Record<string, string> = {\n [entry.skillName]: entry.skillMarkdown,\n ...builtInExtraSkills(entry),\n };\n const extraFiles = builtInExtraFiles(entry);\n const out: Record<string, SkillFolderBundle> = {};\n for (const [skillName, skillMarkdown] of Object.entries(skills)) {\n const files = {\n \"SKILL.md\": skillMarkdown,\n ...(extraFiles[skillName] ?? {}),\n };\n out[skillName] = {\n appSkillId,\n displayName: entry.manifest.displayName,\n skillName,\n mcpUrl: isLocalOnlyBuiltInSkill(entry)\n ? \"\"\n : entry.manifest.hosted.mcpUrl,\n files,\n contentHash: stableSkillHash(files),\n };\n }\n return out;\n}\n\nfunction latestSkillBundlesForTargets(\n appSkillIds: BuiltInAppSkillId[],\n): Record<string, SkillFolderBundle> {\n const out: Record<string, SkillFolderBundle> = {};\n for (const appSkillId of appSkillIds) {\n Object.assign(out, skillFilesForBuiltIn(appSkillId));\n }\n return out;\n}\n\nfunction writeSkillFolder(\n dir: string,\n bundle: SkillFolderBundle,\n installedAt = new Date().toISOString(),\n): void {\n fs.rmSync(dir, { recursive: true, force: true });\n fs.mkdirSync(dir, { recursive: true });\n for (const [rel, content] of Object.entries(bundle.files)) {\n const target = path.join(dir, rel);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, content, \"utf-8\");\n }\n const metadata: SkillInstallMetadata = {\n schemaVersion: 1,\n source: \"agent-native\",\n appSkillId: bundle.appSkillId,\n displayName: bundle.displayName,\n skillName: bundle.skillName,\n contentHash: bundle.contentHash,\n mcpUrl: bundle.mcpUrl,\n installedAt,\n updateCommand: `npx @agent-native/core@latest skills update ${bundle.skillName}`,\n };\n fs.writeFileSync(\n path.join(dir, AGENT_NATIVE_SKILL_METADATA_FILE),\n `${JSON.stringify(metadata, null, 2)}\\n`,\n \"utf-8\",\n );\n}\n\n/**\n * The skills directory a built-in skill's instructions are copied into for a\n * given agent + scope. Mirrors the layout the skills installer uses so\n * `skills status` / `skills update` find the folders again.\n */\nfunction builtInSkillsRootForAgent(\n agent: string,\n scope: \"project\" | \"user\",\n baseDir: string,\n): string {\n const home = homeDir() ?? baseDir;\n if (scope === \"project\") {\n return agent === \"codex\"\n ? path.join(baseDir, \".agents\", \"skills\")\n : path.join(baseDir, \".claude\", \"skills\");\n }\n if (agent === \"codex\") {\n return process.env.CODEX_HOME\n ? path.join(process.env.CODEX_HOME, \"skills\")\n : path.join(home, \".codex\", \"skills\");\n }\n return path.join(home, \".claude\", \"skills\");\n}\n\n/**\n * Write a built-in skill's instruction folders straight into each client's\n * skills directory. Built-in skills ship their SKILL.md inside this package, so\n * there is no need to shell out to the separate @agent-native/skills installer\n * (which would have to be published to npm first). Returns the written folders.\n */\nfunction installBuiltInInstructions(input: {\n appSkillId: BuiltInAppSkillId;\n onlySkillNames?: string[];\n skillsAgents: string[];\n scope: \"project\" | \"user\";\n baseDir: string;\n dryRun?: boolean;\n}): string[] {\n const bundles = Object.values(skillFilesForBuiltIn(input.appSkillId)).filter(\n (bundle) =>\n !input.onlySkillNames || input.onlySkillNames.includes(bundle.skillName),\n );\n const written: string[] = [];\n for (const agent of input.skillsAgents) {\n const root = builtInSkillsRootForAgent(agent, input.scope, input.baseDir);\n for (const bundle of bundles) {\n const dir = path.join(root, bundle.skillName);\n if (!input.dryRun) writeSkillFolder(dir, bundle);\n written.push(dir);\n }\n }\n return written;\n}\n\nfunction listSkillFolderFiles(dir: string): Record<string, string> {\n const out: Record<string, string> = {};\n const walk = (current: string, prefix = \"\") => {\n for (const entry of fs.readdirSync(current, { withFileTypes: true })) {\n const rel = prefix ? `${prefix}/${entry.name}` : entry.name;\n const abs = path.join(current, entry.name);\n if (entry.isDirectory()) {\n walk(abs, rel);\n continue;\n }\n if (!entry.isFile() || rel === AGENT_NATIVE_SKILL_METADATA_FILE) continue;\n out[rel] = fs.readFileSync(abs, \"utf-8\");\n }\n };\n if (fs.existsSync(dir)) walk(dir);\n return out;\n}\n\nfunction readSkillInstallMetadata(\n dir: string,\n): SkillInstallMetadata | undefined {\n const file = path.join(dir, AGENT_NATIVE_SKILL_METADATA_FILE);\n if (!fs.existsSync(file)) return undefined;\n try {\n const parsed = JSON.parse(fs.readFileSync(file, \"utf-8\"));\n if (\n parsed &&\n parsed.source === \"agent-native\" &&\n typeof parsed.skillName === \"string\" &&\n typeof parsed.contentHash === \"string\"\n ) {\n return parsed as SkillInstallMetadata;\n }\n } catch {}\n return undefined;\n}\n\nfunction homeDir(): string | undefined {\n return process.env.HOME || os.homedir();\n}\n\nfunction skillSearchRoots(input: {\n baseDir: string;\n clients: ClientId[];\n scopes: Array<\"project\" | \"user\">;\n}): Array<{\n root: string;\n scope: \"project\" | \"user\";\n client: string;\n}> {\n const roots: Array<{\n root: string;\n scope: \"project\" | \"user\";\n client: string;\n }> = [];\n const clientSet = new Set(input.clients);\n const includeAll = input.clients.length === 0;\n const hasClient = (client: ClientId) => includeAll || clientSet.has(client);\n const add = (\n root: string | undefined,\n scope: \"project\" | \"user\",\n client: string,\n ) => {\n if (root) roots.push({ root, scope, client });\n };\n\n if (input.scopes.includes(\"project\")) {\n if (hasClient(\"codex\")) {\n add(path.join(input.baseDir, \".agents\", \"skills\"), \"project\", \"codex\");\n }\n if (hasClient(\"claude-code\") || hasClient(\"claude-code-cli\")) {\n add(\n path.join(input.baseDir, \".claude\", \"skills\"),\n \"project\",\n \"claude-code\",\n );\n }\n if (includeAll) add(path.join(input.baseDir, \"skills\"), \"project\", \"repo\");\n }\n\n if (input.scopes.includes(\"user\")) {\n const home = homeDir();\n if (hasClient(\"codex\")) {\n add(\n process.env.CODEX_HOME\n ? path.join(process.env.CODEX_HOME, \"skills\")\n : undefined,\n \"user\",\n \"codex\",\n );\n add(\n home ? path.join(home, \".codex\", \"skills\") : undefined,\n \"user\",\n \"codex\",\n );\n }\n if (hasClient(\"claude-code\") || hasClient(\"claude-code-cli\")) {\n add(\n home ? path.join(home, \".claude\", \"skills\") : undefined,\n \"user\",\n \"claude-code\",\n );\n }\n }\n\n const seen = new Set<string>();\n return roots.filter((entry) => {\n const key = `${entry.scope}:${entry.client}:${path.resolve(entry.root)}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n\nfunction targetIdsForStatus(parsed: ParsedSkillsArgs): BuiltInAppSkillId[] {\n if (!parsed.target) {\n return (Object.keys(BUILT_IN_APP_SKILLS) as BuiltInAppSkillId[]).filter(\n (id) => !isLocalOnlyBuiltInSkill(BUILT_IN_APP_SKILLS[id]),\n );\n }\n const known = normalizeKnownSkillTarget(parsed.target);\n if (!known) {\n throw new Error(\n `Unknown built-in skill: ${parsed.target}. Run \"npx @agent-native/core@latest skills list\".`,\n );\n }\n if (isLocalOnlyBuiltInSkill(BUILT_IN_APP_SKILLS[known])) {\n throw new Error(\n `${BUILT_IN_APP_SKILLS[known].manifest.displayName} is installed as a local command and cannot be refreshed with skills update yet.`,\n );\n }\n return [known];\n}\n\nfunction scopeFilterForStatus(\n parsed: ParsedSkillsArgs,\n): Array<\"project\" | \"user\"> {\n return parsed.scopeExplicit\n ? [parsed.scope as \"project\" | \"user\"]\n : [\"project\", \"user\"];\n}\n\nfunction clientFilterForStatus(parsed: ParsedSkillsArgs): ClientId[] {\n return parsed.clientExplicit ? resolveClients(parsed.client) : [];\n}\n\nfunction collectSkillInstallStates(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n): SkillInstallState[] {\n const appSkillIds = targetIdsForStatus(parsed);\n const latest = latestSkillBundlesForTargets(appSkillIds);\n const roots = skillSearchRoots({\n baseDir: options.baseDir ?? process.cwd(),\n clients: clientFilterForStatus(parsed),\n scopes: scopeFilterForStatus(parsed),\n });\n const states: SkillInstallState[] = [];\n const seenDirs = new Set<string>();\n\n for (const root of roots) {\n for (const bundle of Object.values(latest)) {\n const dir = path.join(root.root, bundle.skillName);\n const resolvedDir = path.resolve(dir);\n if (seenDirs.has(resolvedDir) || !fs.existsSync(dir)) continue;\n if (!fs.existsSync(path.join(dir, \"SKILL.md\"))) continue;\n seenDirs.add(resolvedDir);\n const files = listSkillFolderFiles(dir);\n const installedHash =\n Object.keys(files).length > 0 ? stableSkillHash(files) : null;\n const metadata = readSkillInstallMetadata(dir);\n states.push({\n appSkillId: bundle.appSkillId,\n displayName: bundle.displayName,\n skillName: bundle.skillName,\n path: dir,\n root: root.root,\n scope: root.scope,\n client: root.client,\n latestHash: bundle.contentHash,\n installedHash,\n metadataHash: metadata?.contentHash,\n current: installedHash === bundle.contentHash,\n managed: metadata?.source === \"agent-native\",\n });\n }\n }\n\n return states.sort((a, b) =>\n `${a.skillName}:${a.path}`.localeCompare(`${b.skillName}:${b.path}`),\n );\n}\n\nfunction updateSkillInstallStates(\n states: SkillInstallState[],\n dryRun: boolean,\n): SkillInstallState[] {\n const latest = latestSkillBundlesForTargets([\n ...new Set(states.map((state) => state.appSkillId)),\n ]);\n const updated: SkillInstallState[] = [];\n for (const state of states) {\n if (state.current && state.managed) continue;\n const bundle = latest[state.skillName];\n if (!bundle) continue;\n if (!dryRun) writeSkillFolder(state.path, bundle);\n updated.push({\n ...state,\n current: !dryRun,\n installedHash: dryRun ? state.installedHash : bundle.contentHash,\n metadataHash: dryRun ? state.metadataHash : bundle.contentHash,\n });\n }\n return updated;\n}\n\nfunction normalizeClientIds(values: unknown): ClientId[] {\n if (!Array.isArray(values)) return [];\n const seen = new Set<ClientId>();\n const out: ClientId[] = [];\n for (const value of values) {\n if (typeof value !== \"string\") continue;\n const id = value.toLowerCase();\n if (!(CLIENTS as string[]).includes(id)) continue;\n const client = id as ClientId;\n if (seen.has(client)) continue;\n seen.add(client);\n out.push(client);\n }\n return out;\n}\n\nfunction clientPromptOptions(): SkillsClientPromptContext[\"options\"] {\n return CLIENTS.map((client) => ({\n value: client,\n label: CLIENT_LABELS[client],\n hint: CLIENT_HINTS[client],\n }));\n}\n\n// For now the interactive installer offers only the two plan skills, each as\n// an independently selectable entry (uncheck one to install just the other).\n// The other built-in skills stay installable via `agent-native skills add\n// <name>` but are hidden from the default checklist. The values are the real\n// slash-command names so users see exactly what they are installing.\nconst PLAN_SKILL_PROMPT_OPTIONS: SkillsTargetPromptContext[\"options\"] = [\n {\n value: \"visual-plan\",\n label: \"visual-plan\",\n hint: \"Reviewable coding-agent plan: diagrams, annotated code, file trees, open questions.\",\n },\n {\n value: \"visual-recap\",\n label: \"visual-recap\",\n hint: \"Turn a PR, commit, branch, or git diff into a high-altitude visual recap.\",\n },\n];\n\nfunction skillPromptOptions(): SkillsTargetPromptContext[\"options\"] {\n return PLAN_SKILL_PROMPT_OPTIONS;\n}\n\nfunction prVisualRecapWorkflowPath(baseDir: string): string {\n return path.join(baseDir, \".github\", \"workflows\", \"pr-visual-recap.yml\");\n}\n\nfunction prVisualRecapWorkflowDisplayPath(): string {\n return path.join(\".github\", \"workflows\", \"pr-visual-recap.yml\");\n}\n\nfunction prVisualRecapInstallCommand(): string {\n return \"npx @agent-native/core@latest skills add visual-recap --with-github-action\";\n}\n\nfunction prVisualRecapSetupCommand(): string {\n return \"npx @agent-native/core@latest recap setup\";\n}\n\nasync function promptForGithubAction(\n context: SkillsGithubActionPromptContext,\n): Promise<boolean | null> {\n const clack = await import(\"@clack/prompts\");\n const result = await clack.confirm({\n message:\n \"Optional: add automatic PR Visual Recaps? (GitHub Action)\\n\" +\n \" Posts a human-friendly recap on every pull request — a high-altitude\\n\" +\n \" overview of what the PR does, with annotated code, diagrams, and\\n\" +\n \" before/after notes instead of a raw diff.\\n\" +\n ` Writes ${context.workflowPath}; ${context.setupCommand} finishes the GitHub secrets.`,\n initialValue: false,\n });\n if (clack.isCancel(result)) {\n clack.cancel(\"Skipped PR Visual Recap workflow.\");\n return null;\n }\n return Boolean(result);\n}\n\nfunction shouldPrompt(parsed: ParsedSkillsArgs, options: RunSkillsOptions) {\n if (parsed.yes || parsed.printJson) return false;\n if (options.isInteractive) return options.isInteractive();\n if (process.env.AGENT_NATIVE_NO_PROMPT === \"1\") return false;\n if (process.env.CI === \"true\") return false;\n return !!process.stdin.isTTY && !!process.stdout.isTTY;\n}\n\nasync function promptForClients(\n context: SkillsClientPromptContext,\n): Promise<ClientId[] | null> {\n const clack = await import(\"@clack/prompts\");\n const result = await clack.multiselect({\n message:\n \"Install the MCP connector for which local agents?\\n\" +\n \" (space toggles, enter confirms; saved for next time)\",\n options: context.options,\n initialValues: context.initialClients,\n required: true,\n });\n if (clack.isCancel(result)) {\n clack.cancel(\"Cancelled.\");\n return null;\n }\n return normalizeClientIds(result);\n}\n\nasync function promptForScope(\n context: SkillsScopePromptContext,\n): Promise<\"project\" | \"user\" | null> {\n const clack = await import(\"@clack/prompts\");\n const result = await clack.select({\n message: \"Where do you want to install these skills?\",\n options: [\n {\n value: \"project\",\n label: \"Project\",\n hint: \"This repo only (.agents / .claude in the current directory) — committed with your project\",\n },\n {\n value: \"user\",\n label: \"User\",\n hint: \"Your home directory (~/.codex, ~/.claude) — available across all projects\",\n },\n ],\n initialValue: context.initialScope,\n });\n if (clack.isCancel(result)) {\n clack.cancel(\"Cancelled.\");\n return null;\n }\n return result === \"project\" ? \"project\" : \"user\";\n}\n\nasync function promptForSkills(\n context: SkillsTargetPromptContext,\n): Promise<string[] | null> {\n const clack = await import(\"@clack/prompts\");\n const result = await clack.multiselect({\n message:\n \"Which Agent Native skills do you want to install?\\n\" +\n \" (space toggles, enter confirms)\",\n options: context.options,\n initialValues: context.initialTargets,\n required: true,\n });\n if (clack.isCancel(result)) {\n clack.cancel(\"Cancelled.\");\n return null;\n }\n if (!Array.isArray(result)) return [];\n return result.filter((value): value is string => typeof value === \"string\");\n}\n\nasync function resolveSkillsClients(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n): Promise<ClientId[] | null> {\n if (parsed.clientExplicit || !shouldPrompt(parsed, options)) {\n return resolveClients(parsed.client);\n }\n const initialClients = resolveClients(\"all\");\n const prompt = options.promptClients ?? promptForClients;\n const selected = normalizeClientIds(\n await prompt({\n initialClients,\n options: clientPromptOptions(),\n }),\n );\n if (selected.length === 0) return null;\n if (!parsed.dryRun) {\n try {\n writeConnectClientPreferences(selected);\n } catch {}\n }\n return selected;\n}\n\nasync function resolveSkillTargets(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n): Promise<string[] | null> {\n if (parsed.target || !shouldPrompt(parsed, options)) {\n return [parsed.target ?? \"assets\"];\n }\n const prompt = options.promptSkills ?? promptForSkills;\n const promptOptions = skillPromptOptions();\n // The interactive multiselect skill picker is about to be shown (no --skill /\n // target passed and we are interactive) — record the funnel \"prompted\" step.\n options.telemetry?.track(\"skills_cli skills prompted\", {\n availableCount: promptOptions.length,\n available: promptOptions.map((option) => option.value).join(\",\"),\n });\n const selected = await prompt({\n initialTargets: [\"visual-plan\", \"visual-recap\"],\n options: promptOptions,\n });\n if (!selected || selected.length === 0) return null;\n // Both plan skills share one MCP connector, so when both are selected install\n // them through the bundle target — that registers/authenticates the connector\n // once instead of twice.\n const planSubskills = [\"visual-plan\", \"visual-recap\"];\n if (planSubskills.every((skill) => selected.includes(skill))) {\n return [\n \"visual-plans\",\n ...selected.filter((s) => !planSubskills.includes(s)),\n ];\n }\n return selected;\n}\n\nexport function parseSkillsArgs(argv: string[]): ParsedSkillsArgs {\n const first = argv[0];\n let command: SkillsCommand = \"list\";\n let args = argv;\n if (first === \"help\" || first === \"--help\" || first === \"-h\") {\n command = \"help\";\n args = argv.slice(1);\n } else if (\n first === \"list\" ||\n first === \"add\" ||\n first === \"status\" ||\n first === \"update\"\n ) {\n command = first;\n args = argv.slice(1);\n } else if (first) {\n command = \"add\";\n }\n\n const out: ParsedSkillsArgs = {\n command,\n client: \"all\",\n clientExplicit: false,\n scope: \"user\",\n scopeExplicit: false,\n yes: false,\n dryRun: false,\n printJson: false,\n instructions: true,\n mcp: true,\n connect: true,\n };\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n const eat = (flag: string): string | undefined => {\n if (arg === flag) {\n const next = args[++i];\n if (!next || next.startsWith(\"-\")) {\n throw new Error(`Missing value for ${flag}.`);\n }\n return next;\n }\n if (arg.startsWith(`${flag}=`)) {\n const value = arg.slice(flag.length + 1);\n if (!value) throw new Error(`Missing value for ${flag}.`);\n return value;\n }\n return undefined;\n };\n let value: string | undefined;\n if ((value = eat(\"--client\")) !== undefined) {\n out.client = value;\n out.clientExplicit = true;\n } else if ((value = eat(\"--skill\")) !== undefined) {\n out.plainSkillNames = [...(out.plainSkillNames ?? []), value];\n } else if ((value = eat(\"-s\")) !== undefined) {\n out.plainSkillNames = [...(out.plainSkillNames ?? []), value];\n } else if ((value = eat(\"--scope\")) !== undefined) {\n out.scope = value;\n out.scopeExplicit = true;\n } else if ((value = eat(\"--mcp-url\")) !== undefined) out.mcpUrl = value;\n else if (arg === \"--yes\" || arg === \"-y\") out.yes = true;\n else if (arg === \"--dry-run\") out.dryRun = true;\n else if (arg === \"--json\") out.printJson = true;\n else if (arg === \"--mcp-only\") out.instructions = false;\n else if (arg === \"--instructions-only\" || arg === \"--no-mcp\")\n out.mcp = false;\n else if (arg === \"--no-connect\" || arg === \"--skip-connect\")\n out.connect = false;\n else if (arg === \"--with-github-action\" || arg === \"--with-github-actions\")\n out.withGithubAction = true;\n else if (arg === \"--update-instructions\") out.updateInstructions = true;\n else if (arg === \"--no-update-instructions\") out.updateInstructions = false;\n else if (arg === \"--force\") out.force = true;\n else if (arg.startsWith(\"-\")) throw new Error(`Unknown option: ${arg}`);\n else if (!out.target) out.target = arg;\n else throw new Error(`Unexpected argument: ${arg}`);\n }\n\n if (out.scope !== \"user\" && out.scope !== \"project\") {\n throw new Error(\"--scope must be either user or project.\");\n }\n return out;\n}\n\nfunction loadSkillTarget(\n target: string,\n onlySkillNames?: string[],\n): SkillInstallTarget {\n const knownTarget = normalizeKnownSkillTarget(target);\n if (knownTarget) {\n const builtIn = BUILT_IN_APP_SKILLS[knownTarget];\n const skillNames = builtInSkillNames(builtIn).filter(\n (name) => !onlySkillNames || onlySkillNames.includes(name),\n );\n return {\n id: builtIn.manifest.id,\n displayName: builtIn.manifest.displayName,\n loaded: {\n manifest: builtIn.manifest,\n file: `<built-in:${builtIn.manifest.id}>`,\n dir: process.cwd(),\n },\n skillNames,\n materializeInstructions(outDir) {\n const bundles = skillFilesForBuiltIn(knownTarget);\n for (const bundle of Object.values(bundles)) {\n if (onlySkillNames && !onlySkillNames.includes(bundle.skillName)) {\n continue;\n }\n writeSkillFolder(\n path.join(outDir, \"skills\", bundle.skillName),\n bundle,\n );\n }\n return outDir;\n },\n };\n }\n\n const resolved = path.resolve(target);\n const manifestFile = fs.statSync(resolved).isDirectory()\n ? path.join(resolved, \"agent-native.app-skill.json\")\n : resolved;\n const loaded = loadAppSkillManifest(manifestFile);\n return {\n id: loaded.manifest.id,\n displayName: loaded.manifest.displayName,\n loaded,\n skillNames: loaded.manifest.skills\n .filter(\n (skill) =>\n skill.visibility === \"exported\" || skill.visibility === \"both\",\n )\n .map((skill) => skill.exportAs ?? path.basename(skill.path)),\n materializeInstructions(outDir) {\n const packed = buildAppSkillPack(loaded, outDir);\n const vercelAdapter = path.join(\n packed.outDir,\n \"adapters\",\n \"vercel-skills\",\n );\n return fs.existsSync(vercelAdapter) ? vercelAdapter : packed.outDir;\n },\n };\n}\n\nfunction skillsAgentsForClients(clients: ClientId[]): string[] {\n const agents = new Set<string>();\n for (const client of clients) {\n if (client === \"codex\") agents.add(\"codex\");\n if (client === \"claude-code\" || client === \"claude-code-cli\") {\n agents.add(\"claude-code\");\n }\n }\n return [...agents];\n}\n\nfunction shellArg(value: string): string {\n if (/^[A-Za-z0-9_/:=.,@+-]+$/.test(value)) return value;\n return `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\n\nfunction commandString(cmd: string, args: string[]): string {\n return [cmd, ...args].map(shellArg).join(\" \");\n}\n\nfunction clientArgForClients(clients: ClientId[]): string {\n if (clients.length === CLIENTS.length) return \"all\";\n if (clients.length === 1) return clients[0];\n return clients.join(\",\");\n}\n\nfunction preserveMcpUrlAppPathOverride(\n target: SkillInstallTarget,\n input: string | undefined,\n): SkillInstallTarget {\n if (!input) return target;\n let parsed: URL;\n try {\n parsed = new URL(input);\n } catch {\n return target;\n }\n const trimmedPath = parsed.pathname.replace(/\\/+$/, \"\");\n const appPath = trimmedPath.endsWith(\"/_agent-native/mcp\")\n ? trimmedPath.slice(0, -\"/_agent-native/mcp\".length).replace(/\\/+$/, \"\")\n : trimmedPath;\n if (!appPath) return target;\n const url = `${parsed.origin}${appPath}`;\n return {\n ...target,\n loaded: {\n ...target.loaded,\n manifest: {\n ...target.loaded.manifest,\n hosted: { url, mcpUrl: `${url}/_agent-native/mcp` },\n },\n },\n };\n}\n\nfunction dryRunInstallCommand(\n parsed: ParsedSkillsArgs,\n target: string,\n): string {\n const clients = parsed.clients ?? resolveClients(parsed.client);\n const args = [\n \"@agent-native/core@latest\",\n \"skills\",\n \"add\",\n target,\n \"--client\",\n clientArgForClients(clients),\n \"--scope\",\n parsed.scope,\n ];\n if (parsed.mcpUrl) args.push(\"--mcp-url\", parsed.mcpUrl);\n if (parsed.instructions && !parsed.mcp) args.push(\"--instructions-only\");\n if (!parsed.instructions && parsed.mcp) args.push(\"--mcp-only\");\n if (!parsed.connect) args.push(\"--no-connect\");\n if (parsed.withGithubAction) args.push(\"--with-github-action\");\n if (parsed.updateInstructions === true) args.push(\"--update-instructions\");\n if (parsed.updateInstructions === false)\n args.push(\"--no-update-instructions\");\n if (parsed.yes || isKnownSkill(target)) args.push(\"--yes\");\n return commandString(\"npx\", args);\n}\n\nasync function runCommand(\n cmd: string,\n args: string[],\n options: RunCommandOptions = {},\n): Promise<number> {\n return new Promise((resolve, reject) => {\n const pipeToStderr = options.stdio === \"stderr\";\n const silent = options.stdio === \"silent\";\n const stdoutChunks: Buffer[] = [];\n const stderrChunks: Buffer[] = [];\n const child = spawn(cmd, args, {\n stdio: pipeToStderr || silent ? [\"inherit\", \"pipe\", \"pipe\"] : \"inherit\",\n shell: process.platform === \"win32\",\n env: process.env,\n });\n if (pipeToStderr) {\n child.stdout?.on(\"data\", (chunk) => process.stderr.write(chunk));\n child.stderr?.on(\"data\", (chunk) => process.stderr.write(chunk));\n } else if (silent) {\n child.stdout?.on(\"data\", (chunk) =>\n stdoutChunks.push(Buffer.from(chunk)),\n );\n child.stderr?.on(\"data\", (chunk) =>\n stderrChunks.push(Buffer.from(chunk)),\n );\n }\n child.on(\"error\", reject);\n child.on(\"exit\", (code, signal) => {\n if (signal) {\n reject(new Error(`${cmd} was interrupted by ${signal}.`));\n return;\n }\n if (silent && code !== 0) {\n for (const chunk of stdoutChunks) process.stderr.write(chunk);\n for (const chunk of stderrChunks) process.stderr.write(chunk);\n }\n resolve(code ?? 0);\n });\n });\n}\n\n/**\n * Resolve a `--mcp-url` override into the `{ url, mcpUrl }` pair the manifest\n * expects. Accepts a bare origin (`https://x.ngrok-free.dev`) — appending the\n * standard `/_agent-native/mcp` path — or a full MCP URL already ending in it.\n */\nfunction resolveMcpUrlOverride(input: string): { url: string; mcpUrl: string } {\n let parsed: URL;\n try {\n parsed = new URL(input);\n } catch {\n throw new Error(`--mcp-url must be a valid URL (got \"${input}\").`);\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n throw new Error(\"--mcp-url must use http:// or https://.\");\n }\n const origin = parsed.origin;\n const trimmedPath = parsed.pathname.replace(/\\/+$/, \"\");\n const mcpUrl = trimmedPath.endsWith(\"/_agent-native/mcp\")\n ? `${origin}${trimmedPath}`\n : `${origin}/_agent-native/mcp`;\n return { url: origin, mcpUrl };\n}\n\n/** Return a copy of the install target with its hosted MCP URL overridden. */\nfunction withMcpUrlOverride(\n target: SkillInstallTarget,\n input: string,\n): SkillInstallTarget {\n const { url, mcpUrl } = resolveMcpUrlOverride(input);\n return {\n ...target,\n loaded: {\n ...target.loaded,\n manifest: { ...target.loaded.manifest, hosted: { url, mcpUrl } },\n },\n };\n}\n\nfunction isPlainSkillRepoPath(target: string): boolean {\n const resolved = path.resolve(target);\n if (!fs.existsSync(resolved)) return false;\n const stat = fs.statSync(resolved);\n if (!stat.isDirectory()) return false;\n const hasDirectSkill = fs.existsSync(path.join(resolved, \"SKILL.md\"));\n const skillsDir = path.join(resolved, \"skills\");\n const hasSkillsDir =\n fs.existsSync(skillsDir) &&\n fs\n .readdirSync(skillsDir, { withFileTypes: true })\n .some(\n (entry) =>\n entry.isDirectory() &&\n fs.existsSync(path.join(skillsDir, entry.name, \"SKILL.md\")),\n );\n const hasAppSkillManifest = fs.existsSync(\n path.join(resolved, \"agent-native.app-skill.json\"),\n );\n return !hasAppSkillManifest && (hasDirectSkill || hasSkillsDir);\n}\n\nfunction isGithubSkillRepoTarget(target: string): boolean {\n if (/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+(?:#.+)?$/.test(target)) {\n return true;\n }\n try {\n const url = new URL(target);\n return url.hostname === \"github.com\";\n } catch {\n return false;\n }\n}\n\nfunction isPlainSkillRepoTarget(target: string): boolean {\n return isPlainSkillRepoPath(target) || isGithubSkillRepoTarget(target);\n}\n\nfunction agentNativeSkillsInstallArgs(\n parsed: ParsedSkillsArgs,\n target: string,\n clients: ClientId[],\n): string[] {\n const args = [\n \"--yes\",\n \"@agent-native/skills@latest\",\n \"add\",\n target,\n \"--client\",\n clientArgForClients(clients),\n \"--scope\",\n parsed.scope,\n ];\n if (parsed.withGithubAction) args.push(\"--with-github-action\");\n if (parsed.force) args.push(\"--force\");\n for (const skill of parsed.plainSkillNames ?? []) {\n args.push(\"--skill\", skill);\n }\n if (parsed.updateInstructions === true) args.push(\"--update-instructions\");\n if (parsed.updateInstructions === false)\n args.push(\"--no-update-instructions\");\n if (parsed.yes) args.push(\"--yes\");\n return args;\n}\n\nasync function addPlainSkillRepo(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n): Promise<SkillsAddResult> {\n const target = parsed.target!;\n if (!parsed.instructions && parsed.mcp) {\n throw new Error(\n \"Plain skill repositories only install skill instructions. Run without --mcp-only.\",\n );\n }\n if (parsed.mcpUrl) {\n throw new Error(\n \"--mcp-url only applies to app-backed Agent Native skills.\",\n );\n }\n\n const clients = parsed.clients ?? resolveClients(parsed.client);\n const skillsAgents = skillsAgentsForClients(clients);\n if (skillsAgents.length === 0) {\n throw new Error(\n \"Plain skill repositories can only install instructions for Codex or Claude Code clients.\",\n );\n }\n const args = agentNativeSkillsInstallArgs(parsed, target, clients);\n if (!parsed.dryRun) {\n const code = await (options.runCommand ?? runCommand)(\"npx\", args, {\n stdio: parsed.yes ? \"silent\" : \"inherit\",\n });\n if (code !== 0)\n throw new Error(\n `npx @agent-native/skills@latest add exited with ${code}.`,\n );\n }\n options.telemetry?.track(\"skills_cli install completed\", {\n skills: target,\n clients: clients.join(\",\"),\n scope: parsed.scope,\n dryRun: Boolean(parsed.dryRun),\n });\n return {\n id: target,\n displayName: target,\n skillNames: [],\n skillsAgents,\n mcpUrl: \"\",\n mcpClients: [],\n dryRun: parsed.dryRun,\n commands: [commandString(\"npx\", args)],\n local: true,\n };\n}\n\n/**\n * Whether we can run the interactive browser/device auth flow. CI and\n * non-TTY shells must not block on a browser approval, so we skip the inline\n * flow there and surface the exact `agent-native connect` command instead.\n */\nfunction canRunInteractiveConnect(options: RunSkillsOptions): boolean {\n if (options.isInteractive) return options.isInteractive();\n if (process.env.AGENT_NATIVE_NO_PROMPT === \"1\") return false;\n if (process.env.CI === \"true\") return false;\n return !!process.stdin.isTTY && !!process.stdout.isTTY;\n}\n\n/** Build the `npx @agent-native/core@latest connect <url> --client … --scope …` command. */\nfunction connectCommandFor(\n hostedUrl: string,\n clients: ClientId[],\n scope: string,\n): string {\n const args = [\n \"@agent-native/core@latest\",\n \"connect\",\n hostedUrl,\n \"--client\",\n clientArgForClients(clients),\n \"--scope\",\n scope,\n ];\n return commandString(\"npx\", args);\n}\n\n/**\n * Authenticate the freshly-registered hosted MCP connector so the user does not\n * hit the OAuth wall on their first tool call. Reuses the existing\n * `agent-native connect` flow (OAuth-capable clients get URL-only config plus a\n * `/mcp` authenticate prompt; Codex / Cowork run the browser device-code flow).\n * In non-interactive shells we skip the inline flow and return the command to\n * run instead. Failures here are non-fatal: the connector is already registered,\n * so the user can authenticate later.\n */\nasync function connectAfterEnsure(\n installTarget: SkillInstallTarget,\n clients: ClientId[],\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n): Promise<{ connected: boolean; connectCommand: string }> {\n const hostedUrl = installTarget.loaded.manifest.hosted.url;\n const authMode = installTarget.loaded.manifest.auth?.mode ?? \"oauth\";\n const connectCommand = connectCommandFor(hostedUrl, clients, parsed.scope);\n\n // Skills whose connector needs no auth (e.g. open/local-only) never need the\n // connect step.\n if (authMode === \"none\") {\n return { connected: false, connectCommand: \"\" };\n }\n\n if (!canRunInteractiveConnect(options)) {\n options.log?.(\n `Authentication skipped (non-interactive). To finish auth, run: ${connectCommand}`,\n );\n return { connected: false, connectCommand };\n }\n\n options.log?.(`Authenticating ${installTarget.displayName}…`);\n options.telemetry?.track(\"skills_cli connect started\");\n try {\n await (options.runConnect ?? runConnect)([\n hostedUrl,\n \"--client\",\n clientArgForClients(clients),\n \"--scope\",\n parsed.scope,\n ]);\n options.telemetry?.track(\"skills_cli connect completed\");\n return { connected: true, connectCommand: \"\" };\n } catch (err: any) {\n // Non-fatal: the MCP connector is registered. Surface the manual command.\n options.telemetry?.track(\"skills_cli connect failed\", {\n error: err?.message ?? String(err),\n });\n options.log?.(\n `Could not finish authentication automatically (${err?.message ?? err}). ` +\n `Run it later with: ${connectCommand}`,\n );\n return { connected: false, connectCommand };\n }\n}\n\nexport async function addAgentNativeSkill(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions = {},\n): Promise<SkillsAddResult> {\n const target = parsed.target ?? \"assets\";\n const knownTarget = normalizeKnownSkillTarget(target);\n // For multi-skill bundles (the plan bundle), a single-skill target installs\n // only that skill. `installsRecap` controls the PR Visual Recap github-action\n // offer, which is only relevant when the recap skill is part of the install.\n const onlySkillNames = knownTarget\n ? builtInOnlySkillNames(target)\n : undefined;\n const installsRecap =\n knownTarget === \"visual-plans\" &&\n (!onlySkillNames || onlySkillNames.includes(\"visual-recap\"));\n if (!knownTarget && isPlainSkillRepoTarget(target)) {\n return addPlainSkillRepo({ ...parsed, target }, options);\n }\n if (!knownTarget && !fs.existsSync(path.resolve(target))) {\n throw new Error(\n `Unknown skill or manifest path: ${target}. Run \"npx @agent-native/core@latest skills list\".`,\n );\n }\n const knownBuiltIn = knownTarget ? BUILT_IN_APP_SKILLS[knownTarget] : null;\n if (isLocalOnlyBuiltInSkill(knownBuiltIn)) {\n if (parsed.mcpUrl) {\n throw new Error(\n \"Context X-Ray is installed locally and does not use --mcp-url yet.\",\n );\n }\n if (!parsed.instructions && parsed.mcp) {\n throw new Error(\n \"Context X-Ray does not need MCP config yet. Run without --mcp-only.\",\n );\n }\n const clients = parsed.clients ?? resolveClients(parsed.client);\n const skillsAgents = skillsAgentsForClients(clients);\n if (parsed.dryRun) {\n const githubActionPath =\n parsed.withGithubAction && knownTarget === \"visual-plans\"\n ? prVisualRecapWorkflowDisplayPath()\n : undefined;\n options.telemetry?.track(\"skills_cli install completed\", {\n skills: knownBuiltIn.skillName,\n clients: clients.join(\",\"),\n scope: parsed.scope,\n dryRun: true,\n });\n return {\n id: knownBuiltIn.manifest.id,\n displayName: knownBuiltIn.manifest.displayName,\n skillNames: [knownBuiltIn.skillName],\n skillsAgents,\n mcpUrl: \"\",\n mcpClients: [],\n dryRun: true,\n local: true,\n commands: [dryRunInstallCommand(parsed, target)],\n githubActionPath,\n };\n }\n const localInstall = installLocalContextXray({\n baseDir: options.baseDir ?? process.cwd(),\n clients,\n scope: parsed.scope,\n });\n options.telemetry?.track(\"skills_cli install completed\", {\n skills: knownBuiltIn.skillName,\n clients: clients.join(\",\"),\n scope: parsed.scope,\n dryRun: false,\n });\n return {\n id: knownBuiltIn.manifest.id,\n displayName: knownBuiltIn.manifest.displayName,\n instructionSource: localInstall.scriptPath,\n skillNames: [knownBuiltIn.skillName],\n skillsAgents,\n mcpUrl: \"\",\n mcpClients: [],\n dryRun: false,\n local: true,\n scriptPath: localInstall.scriptPath,\n written: localInstall.written,\n commands: localInstall.commands,\n };\n }\n let installTarget = loadSkillTarget(target, onlySkillNames);\n if (parsed.mcpUrl) {\n installTarget = withMcpUrlOverride(installTarget, parsed.mcpUrl);\n }\n const clients = parsed.clients ?? resolveClients(parsed.client);\n installTarget = preserveMcpUrlAppPathOverride(installTarget, parsed.mcpUrl);\n const skillsAgents = skillsAgentsForClients(clients);\n if (parsed.dryRun) {\n try {\n const githubActionPath =\n parsed.withGithubAction && installsRecap\n ? prVisualRecapWorkflowDisplayPath()\n : undefined;\n const githubActionSuggestedCommand =\n installsRecap && !parsed.withGithubAction\n ? prVisualRecapInstallCommand()\n : undefined;\n options.telemetry?.track(\"skills_cli install completed\", {\n skills: installTarget.skillNames.join(\",\"),\n clients: clients.join(\",\"),\n scope: parsed.scope,\n dryRun: true,\n });\n return {\n id: installTarget.id,\n displayName: installTarget.displayName,\n skillNames: installTarget.skillNames,\n skillsAgents,\n mcpUrl: installTarget.loaded.manifest.hosted.mcpUrl,\n mcpClients: clients,\n dryRun: true,\n commands: [dryRunInstallCommand(parsed, target)],\n githubActionPath,\n githubActionSuggestedCommand,\n };\n } finally {\n installTarget.cleanup?.();\n }\n }\n const commands: string[] = [];\n const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), \"an-skills-add-\"));\n let instructionSource: string | undefined;\n let instructionsWritten: string[] | undefined;\n let connected = false;\n let connectCommand: string | undefined;\n\n try {\n if (parsed.instructions) {\n if (skillsAgents.length === 0) {\n if (!parsed.mcp) {\n throw new Error(\n \"Skill instructions can only be installed for Codex or Claude Code clients. Use an MCP-capable client or omit --instructions-only.\",\n );\n }\n } else if (knownTarget) {\n // Built-in skills ship their instructions inside this package, so copy\n // the skill folders straight into each client's skills directory. This\n // avoids shelling out to the separate @agent-native/skills installer\n // (which would need to be published to npm to run via npx).\n instructionsWritten = installBuiltInInstructions({\n appSkillId: knownTarget,\n onlySkillNames,\n skillsAgents,\n scope: parsed.scope as \"project\" | \"user\",\n baseDir: options.baseDir ?? process.cwd(),\n dryRun: parsed.dryRun,\n });\n instructionSource = instructionsWritten[0];\n commands.push(...instructionsWritten.map((dir) => `write ${dir}`));\n } else {\n // External app-skill manifests / plain skill repos still go through the\n // standalone installer, which knows how to pack adapters and fetch\n // remote skill collections.\n instructionSource = installTarget.materializeInstructions(tmpRoot);\n const args = [\n \"--yes\",\n \"@agent-native/skills@latest\",\n \"add\",\n instructionSource,\n \"--copy\",\n ...installTarget.skillNames.flatMap((skill) => [\"--skill\", skill]),\n ...skillsAgents.flatMap((agent) => [\"-a\", agent]),\n ...(parsed.scope === \"user\" ? [\"-g\"] : []),\n ...(parsed.yes || knownTarget ? [\"-y\"] : []),\n ];\n commands.push(commandString(\"npx\", args));\n if (!parsed.dryRun) {\n const code = await (options.runCommand ?? runCommand)(\"npx\", args, {\n stdio: \"silent\",\n });\n if (code !== 0)\n throw new Error(\n `npx @agent-native/skills@latest add exited with ${code}.`,\n );\n }\n }\n }\n\n // Skill instructions are now on disk (built-in folders copied or external\n // pack materialized) — record the install before MCP registration/connect.\n options.telemetry?.track(\"skills_cli install completed\", {\n skills: installTarget.skillNames.join(\",\"),\n clients: clients.join(\",\"),\n scope: parsed.scope,\n dryRun: Boolean(parsed.dryRun),\n });\n\n if (parsed.mcp) {\n commands.push(\n `npx @agent-native/core@latest app-skill ensure --manifest ${installTarget.loaded.file} --client ${parsed.client} --scope ${parsed.scope} --yes`,\n );\n if (!parsed.dryRun) {\n await ensureAppSkill(installTarget.loaded, {\n clients,\n scope: parsed.scope,\n baseDir: options.baseDir,\n yes: parsed.yes || Boolean(knownTarget),\n confirm: true,\n log: options.log,\n });\n options.telemetry?.track(\"skills_cli mcp registered\", {\n skills: installTarget.skillNames.join(\",\"),\n });\n\n // One-step install + authenticate: after registering a hosted MCP\n // connector, kick off the existing connect/device-code flow so the user\n // does not hit an OAuth wall on the first tool call. `--no-connect`\n // opts out; non-interactive shells get the exact command to run.\n if (parsed.connect) {\n const result = await connectAfterEnsure(\n installTarget,\n clients,\n parsed,\n options,\n );\n connected = result.connected;\n connectCommand = result.connectCommand || undefined;\n if (connectCommand) commands.push(connectCommand);\n }\n }\n }\n\n // `--with-github-action`: also drop the PR Visual Recap workflow into the\n // repo so PRs get automatic recaps. Only meaningful for the plan family.\n const baseDir = options.baseDir ?? process.cwd();\n let withGithubAction = Boolean(parsed.withGithubAction);\n let githubActionPath: string | undefined;\n let githubActionExisted: boolean | undefined;\n let githubActionSuggestedCommand: string | undefined;\n if (\n installsRecap &&\n !withGithubAction &&\n !fs.existsSync(prVisualRecapWorkflowPath(baseDir))\n ) {\n // Normally the recap decision is made up front in `runSkills` (so it's\n // resolved here). Only prompt inline when a direct caller invoked\n // addAgentNativeSkill without going through that up-front step.\n if (!parsed.githubActionResolved && shouldPrompt(parsed, options)) {\n const prompt = options.promptGithubAction ?? promptForGithubAction;\n const choice = await prompt({\n workflowPath: prVisualRecapWorkflowDisplayPath(),\n setupCommand: prVisualRecapSetupCommand(),\n });\n if (choice === null) {\n options.telemetry?.track(\"skills_cli cancelled\", {\n step: \"github-action\",\n });\n }\n withGithubAction = choice === true;\n }\n if (!withGithubAction) {\n githubActionSuggestedCommand = prVisualRecapInstallCommand();\n }\n }\n\n if (withGithubAction) {\n if (!installsRecap) {\n options.log?.(\n \"--with-github-action only applies to the visual-recap skill; skipping the workflow.\",\n );\n } else {\n const writeResult = writePrVisualRecapWorkflow(baseDir, {\n force: Boolean(parsed.force),\n });\n if (writeResult.status === \"refused\") {\n throw new Error(`recap workflow: ${writeResult.message}`);\n }\n githubActionPath = writeResult.path;\n githubActionExisted =\n writeResult.status === \"written\" ? writeResult.existed : false;\n commands.push(`write ${writeResult.path}`);\n options.telemetry?.track(\"skills_cli github action added\");\n }\n }\n\n return {\n id: installTarget.id,\n displayName: installTarget.displayName,\n instructionSource,\n skillNames: installTarget.skillNames,\n skillsAgents,\n mcpUrl: installTarget.loaded.manifest.hosted.mcpUrl,\n mcpClients: clients,\n dryRun: parsed.dryRun,\n commands,\n written: instructionsWritten,\n connected,\n connectCommand,\n githubActionPath,\n githubActionExisted,\n githubActionSuggestedCommand,\n };\n } finally {\n fs.rmSync(tmpRoot, { recursive: true, force: true });\n installTarget.cleanup?.();\n }\n}\n\nfunction listSkills() {\n return Object.values(BUILT_IN_APP_SKILLS).map((entry) => ({\n id: entry.manifest.id,\n aliases:\n BUILT_IN_APP_SKILL_DISPLAY_ALIASES[\n entry.manifest.id as BuiltInAppSkillId\n ] ?? [],\n name: entry.manifest.displayName,\n description: entry.manifest.description,\n mcpUrl: isLocalOnlyBuiltInSkill(entry) ? \"\" : entry.manifest.hosted.mcpUrl,\n local: isLocalOnlyBuiltInSkill(entry),\n }));\n}\n\nfunction skillStateJson(state: SkillInstallState) {\n return {\n appSkillId: state.appSkillId,\n displayName: state.displayName,\n skillName: state.skillName,\n path: state.path,\n scope: state.scope,\n client: state.client,\n status: state.current ? \"current\" : \"stale\",\n managed: state.managed,\n installedHash: state.installedHash,\n latestHash: state.latestHash,\n metadataHash: state.metadataHash,\n };\n}\n\nfunction formatSkillState(state: SkillInstallState): string {\n const status = state.current ? \"current\" : \"stale\";\n const managed = state.managed ? \"managed\" : \"unmarked\";\n const hashes =\n state.installedHash && !state.current\n ? ` (${state.installedHash} -> ${state.latestHash})`\n : \"\";\n return `${state.skillName.padEnd(22)} ${status.padEnd(7)} ${state.scope}/${state.client} ${managed}${hashes}\\n ${state.path}`;\n}\n\nfunction runSkillsStatusOrUpdate(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n update: boolean,\n): void {\n const before = collectSkillInstallStates(parsed, options);\n const changed = update ? updateSkillInstallStates(before, parsed.dryRun) : [];\n const after =\n update && !parsed.dryRun\n ? collectSkillInstallStates(parsed, options)\n : before;\n\n if (parsed.printJson) {\n const outputStates = update && !parsed.dryRun ? after : before;\n process.stdout.write(\n `${JSON.stringify(\n {\n ok: true,\n command: parsed.command,\n dryRun: parsed.dryRun,\n found: before.length,\n stale: outputStates.filter((state) => !state.current).length,\n updated: changed.length,\n skills: outputStates.map(skillStateJson),\n },\n null,\n 2,\n )}\\n`,\n );\n return;\n }\n\n if (before.length === 0) {\n const target = parsed.target ? ` for ${parsed.target}` : \"\";\n process.stdout.write(\n `No installed Agent Native skill copies found${target}.\\nRun \"npx @agent-native/core@latest skills add ${parsed.target ?? \"visual-plan\"}\" to install one.\\n`,\n );\n return;\n }\n\n if (update) {\n if (parsed.dryRun) {\n process.stdout.write(\n changed.length\n ? `Would update ${changed.length} skill folder${changed.length === 1 ? \"\" : \"s\"}:\\n`\n : \"All discovered skill folders are already current.\\n\",\n );\n } else {\n process.stdout.write(\n changed.length\n ? `Updated ${changed.length} skill folder${changed.length === 1 ? \"\" : \"s\"}.\\n`\n : \"All discovered skill folders are already current.\\n\",\n );\n }\n }\n\n const rows = (update && parsed.dryRun ? before : after).map(formatSkillState);\n process.stdout.write(`${rows.join(\"\\n\")}\\n`);\n}\n\n/**\n * Resolve the CLI version the same way `index.ts` does — read it from the\n * package.json two levels up from the compiled module (dist/cli/skills.js →\n * ../../package.json). Best-effort: falls back to \"unknown\".\n */\nfunction readCliVersion(): string {\n try {\n const here = path.dirname(fileURLToPath(import.meta.url));\n const pkg = JSON.parse(\n fs.readFileSync(path.resolve(here, \"../../package.json\"), \"utf8\"),\n ) as { version?: unknown };\n return typeof pkg.version === \"string\" ? pkg.version : \"unknown\";\n } catch {\n return \"unknown\";\n }\n}\n\nexport async function runSkills(\n argv: string[],\n options: RunSkillsOptions = {},\n): Promise<void> {\n const parsed = parseSkillsArgs(argv);\n const log = parsed.printJson\n ? undefined\n : (message: string) => process.stdout.write(`${message}\\n`);\n\n if (parsed.command === \"help\") {\n process.stdout.write(`${HELP}\\n`);\n return;\n }\n\n // `@agent-native/skills` now delegates its interactive install to this\n // function. For plain skill repos we still shell out to\n // `npx @agent-native/skills@latest add …`; this env guard tells that child process\n // to run its OWN headless installer instead of bouncing back into core,\n // which would otherwise be an infinite skills → core → skills loop.\n process.env.AGENT_NATIVE_SKILLS_DIRECT = \"1\";\n\n // Best-effort install-funnel telemetry. Created once per run and flushed in a\n // finally so events send on success, error, and cancellation — the CLI is\n // short-lived, so flushing before exit is essential or the events never send.\n const startedAt = Date.now();\n const telemetry =\n options.telemetry ??\n createCliTelemetry({\n cli: \"core\",\n cliVersion: readCliVersion(),\n command: parsed.command,\n interactive: shouldPrompt(parsed, options),\n });\n const optionsWithTelemetry: RunSkillsOptions = { ...options, telemetry };\n\n try {\n telemetry.track(\"skills_cli started\");\n\n if (parsed.command === \"list\") {\n const skills = listSkills();\n telemetry.track(\"skills_cli skills listed\", {\n availableCount: skills.length,\n available: skills.map((skill) => skill.id).join(\",\"),\n });\n if (parsed.printJson) {\n process.stdout.write(`${JSON.stringify(skills, null, 2)}\\n`);\n return;\n }\n for (const skill of skills) {\n const description = skill.description.replace(/[.?!]?$/, \".\");\n const aliases = skill.aliases.length\n ? ` Aliases: ${skill.aliases.join(\", \")}.`\n : \"\";\n const target = skill.local ? \"local command\" : skill.mcpUrl;\n process.stdout.write(\n `${skill.id.padEnd(12)} ${description}${aliases} (${target})\\n`,\n );\n }\n return;\n }\n\n if (parsed.command === \"status\" || parsed.command === \"update\") {\n runSkillsStatusOrUpdate(parsed, options, parsed.command === \"update\");\n return;\n }\n\n const targets = await resolveSkillTargets(parsed, optionsWithTelemetry);\n if (!targets) {\n telemetry.track(\"skills_cli cancelled\", { step: \"skills\" });\n return;\n }\n const preselected = Boolean(parsed.target);\n telemetry.track(\"skills_cli skills selected\", {\n selected: targets.join(\",\"),\n selectedCount: targets.length,\n // Best-effort \"took everything offered\" signal: compare against the\n // interactive picker's option count (the plan sub-skills collapse into a\n // single bundle target, so this is approximate, like the standalone CLI).\n selectedAll: targets.length === skillPromptOptions().length,\n preselected,\n });\n\n const clients = await resolveSkillsClients(parsed, optionsWithTelemetry);\n if (!clients) {\n telemetry.track(\"skills_cli cancelled\", { step: \"clients\" });\n return;\n }\n telemetry.track(\"skills_cli clients selected\", {\n clients: clients.join(\",\"),\n clientCount: clients.length,\n });\n\n // Ask where to install (project vs user) unless an explicit --scope was\n // passed or we are running non-interactively.\n if (!parsed.scopeExplicit && shouldPrompt(parsed, options)) {\n const promptScope = options.promptScope ?? promptForScope;\n const scope = await promptScope({ initialScope: \"project\" });\n if (!scope) {\n telemetry.track(\"skills_cli cancelled\", { step: \"scope\" });\n return;\n }\n parsed.scope = scope;\n }\n telemetry.track(\"skills_cli scope selected\", { scope: parsed.scope });\n\n // Decide the optional PR Visual Recap GitHub Action UP FRONT — before any\n // install or MCP registration — so every prompt is answered before we touch\n // disk. The choice is threaded into each install via `withGithubAction` +\n // `githubActionResolved` (so addAgentNativeSkill doesn't re-prompt mid-flow).\n const recapBaseDir = options.baseDir ?? process.cwd();\n const anyRecapTarget = targets.some((target) => {\n if (normalizeKnownSkillTarget(target) !== \"visual-plans\") return false;\n const only = builtInOnlySkillNames(target);\n return !only || only.includes(\"visual-recap\");\n });\n if (\n anyRecapTarget &&\n !parsed.withGithubAction &&\n !fs.existsSync(prVisualRecapWorkflowPath(recapBaseDir)) &&\n shouldPrompt(parsed, options)\n ) {\n const prompt = options.promptGithubAction ?? promptForGithubAction;\n const choice = await prompt({\n workflowPath: prVisualRecapWorkflowDisplayPath(),\n setupCommand: prVisualRecapSetupCommand(),\n });\n if (choice === null) {\n telemetry.track(\"skills_cli cancelled\", { step: \"github-action\" });\n }\n parsed.withGithubAction = choice === true;\n parsed.githubActionResolved = true;\n }\n\n const results: SkillsAddResult[] = [];\n for (const target of targets) {\n results.push(\n await addAgentNativeSkill(\n {\n ...parsed,\n target,\n client: clientArgForClients(clients),\n clients,\n },\n {\n ...optionsWithTelemetry,\n log,\n },\n ),\n );\n }\n\n // The add flow succeeded for every target — record the funnel completion\n // before printing output (output below cannot fail the install).\n const completedSkills = [\n ...new Set(results.flatMap((result) => result.skillNames)),\n ];\n const completedClients = [\n ...new Set(results.flatMap((result) => result.mcpClients)),\n ];\n telemetry.track(\"skills_cli completed\", {\n skills: completedSkills.join(\",\"),\n clients: completedClients.join(\",\"),\n scope: parsed.scope,\n durationMs: Date.now() - startedAt,\n });\n\n if (parsed.printJson) {\n process.stdout.write(\n `${JSON.stringify(results.length === 1 ? results[0] : results, null, 2)}\\n`,\n );\n return;\n }\n\n if (parsed.dryRun) {\n process.stdout.write(\n `${results.flatMap((result) => result.commands).join(\"\\n\")}\\n`,\n );\n return;\n }\n\n const installedNames = results\n .map((result) => result.displayName)\n .join(\", \");\n const skillsAgents = [\n ...new Set(results.flatMap((result) => result.skillsAgents)),\n ];\n const mcpClients = [\n ...new Set(results.flatMap((result) => result.mcpClients)),\n ];\n const mcpUrls = [\n ...new Set(results.map((result) => result.mcpUrl).filter(Boolean)),\n ];\n const localCommands = [\n ...new Set(\n results\n .filter((result) => result.local)\n .flatMap((result) => result.commands),\n ),\n ];\n const authConnected = results.some((result) => result.connected);\n const pendingConnectCommands = [\n ...new Set(\n results\n .map((result) => result.connectCommand)\n .filter((command): command is string => Boolean(command)),\n ),\n ];\n const authLine = authConnected\n ? \"Authentication: completed.\"\n : pendingConnectCommands.length\n ? `Authentication: pending — run ${pendingConnectCommands.join(\" && \")}`\n : \"\";\n const githubActions = [\n ...new Set(\n results\n .map((result) => result.githubActionPath)\n .filter((p): p is string => Boolean(p)),\n ),\n ];\n const githubActionLine = githubActions.length\n ? `PR Visual Recap workflow: wrote ${githubActions.join(\", \")}.\\nNext: run ${prVisualRecapSetupCommand()} to configure GitHub secrets/variables, or set them manually:\\n ${PR_VISUAL_RECAP_SETUP.join(\"\\n \")}`\n : \"\";\n const githubActionSuggestions = [\n ...new Set(\n results\n .map((result) => result.githubActionSuggestedCommand)\n .filter((command): command is string => Boolean(command)),\n ),\n ];\n const githubActionSuggestionLine = githubActionSuggestions.length\n ? `Optional PR Visual Recap workflow: run ${githubActionSuggestions.join(\n \" && \",\n )} to add automatic recap comments on pull requests.`\n : \"\";\n const clack = await import(\"@clack/prompts\");\n const summary = [\n skillsAgents.length\n ? `Skill instructions ${skillsAgents.join(\", \")}`\n : \"Skill instructions skipped\",\n mcpClients.length\n ? `MCP config ${mcpClients.join(\", \")}`\n : \"MCP config not required\",\n mcpUrls.length ? `MCP URL ${mcpUrls.join(\", \")}` : \"\",\n authConnected\n ? \"Authentication completed\"\n : pendingConnectCommands.length\n ? `Authentication pending — run ${pendingConnectCommands.join(\" && \")}`\n : \"\",\n localCommands.length\n ? `Local command ${localCommands.join(\", \")}`\n : \"\",\n ].filter(Boolean);\n clack.note(\n summary.join(\"\\n\"),\n `Installed ${installedNames} skill${results.length === 1 ? \"\" : \"s\"}`,\n );\n\n // GitHub Action follow-ups — kept as exact, copy-pasteable command lines.\n for (const line of [githubActionLine, githubActionSuggestionLine].filter(\n Boolean,\n )) {\n process.stdout.write(`${line}\\n`);\n }\n\n const slashCommands = completedSkills.map((name) => `/${name}`).join(\" \");\n const configuredEveryClient = CLIENTS.every((client) =>\n clients.includes(client),\n );\n const clientHint = configuredEveryClient\n ? \"\"\n : \"\\n Add another client later with --client <client> (e.g. --client claude-code).\";\n clack.outro(\n `✅ All set! Start using ${slashCommands || \"your new skills\"} in your agent client.` +\n `\\n You may need to reload the client for the skill + MCP server to appear.` +\n clientHint,\n );\n } catch (error) {\n telemetry.track(\"skills_cli failed\", {\n command: parsed.command,\n error: error instanceof Error ? error.message : String(error),\n durationMs: Date.now() - startedAt,\n });\n throw error;\n } finally {\n await telemetry.flush();\n }\n}\n"]}
1
+ {"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/cli/skills.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAqB,MAAM,gBAAgB,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,yBAAyB,GAG1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EACd,UAAU,EACV,6BAA6B,GAC9B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,qBAAqB,EACrB,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E,UAAU,CACb,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,SAAS,CAAC,KAAK,CAAC,mBAAmB,EAAE;YACnC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC7D,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;SACnC,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC","sourcesContent":["/**\n * `agent-native skills` is the friendly install surface for app-backed skills.\n * The lower-level `app-skill` commands remain the packaging primitives; this\n * command handles the common \"install Assets for my agent\" path in one step.\n */\n\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { spawn } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { createCliTelemetry, type CliTelemetry } from \"./telemetry.js\";\nimport {\n buildAppSkillPack,\n ensureAppSkill,\n loadAppSkillManifest,\n normalizeAppSkillManifest,\n type AppSkillManifest,\n type LoadedAppSkillManifest,\n} from \"./app-skill.js\";\nimport {\n resolveClients,\n runConnect,\n writeConnectClientPreferences,\n} from \"./connect.js\";\nimport {\n CONTEXT_XRAY_SKILL_MD,\n installLocalContextXray,\n} from \"./context-xray-local.js\";\nimport { CLIENTS, type ClientId } from \"./mcp-config-writers.js\";\nimport { PR_VISUAL_RECAP_SETUP, writePrVisualRecapWorkflow } from \"./recap.js\";\n\nconst HELP = `npx @agent-native/core@latest skills\n\nUsage:\n npx @agent-native/core@latest skills list\n npx @agent-native/core@latest skills status [assets|design-exploration|visual-plan|visual-recap|context-xray] [--client codex|claude-code|all] [--scope user|project] [--json]\n npx @agent-native/core@latest skills update [assets|design-exploration|visual-plan|visual-recap|context-xray] [--client codex|claude-code|all] [--scope user|project] [--dry-run] [--json]\n npx @agent-native/core@latest skills add assets|design-exploration|visual-plan|visual-recap|context-xray [--client codex|claude-code|claude-code-cli|cowork|all] [--scope user|project] [--mcp-url <url>] [--no-connect] [--with-github-action] [--yes] [--dry-run] [--json]\n npx @agent-native/core@latest skills add <manifest-or-app-dir|skill-repo> [--skill <name>] [--client ...] [--yes]\n\nExamples:\n npx @agent-native/core@latest skills add assets\n npx @agent-native/core@latest skills add design-exploration\n npx @agent-native/core@latest skills add visual-plan\n npx @agent-native/core@latest skills add visual-recap\n npx @agent-native/core@latest skills add visual-recap --with-github-action\n npx @agent-native/core@latest skills status visual-plan\n npx @agent-native/core@latest skills update visual-plan\n npx @agent-native/core@latest skills add visual-plan --no-connect\n npx @agent-native/core@latest skills add context-xray --client all\n npx @agent-native/core@latest skills add assets --client claude-code\n npx @agent-native/core@latest skills add assets --mcp-url https://my-app.ngrok-free.dev\n npx @agent-native/core@latest skills add ./dist/assets-skill --client codex\n npx @agent-native/core@latest skills add BuilderIO/skills --client codex --scope project\n npx @agent-native/core@latest skills add BuilderIO/skills --with-github-action\n\nThe add command installs the SKILL.md instructions, registers the app-backed\nMCP connector, and then authenticates it in one step so you do not hit an OAuth\nwall on the first tool call. By default, add targets every supported local\nclient this CLI can configure (Claude Code, Claude Code CLI, Codex, and Cowork);\npass --client to narrow it. Authentication reuses \"npx @agent-native/core@latest connect\":\nOAuth-capable clients (Claude Code) get a URL-only entry and a /mcp authenticate\nprompt, while Codex / Cowork run the browser device-code flow. In a\nnon-interactive shell or CI the auth step is skipped and the exact\n\"npx @agent-native/core@latest connect <url> --client all\" command is printed instead.\n\nRunning \"npx @agent-native/skills@latest add ...\" directly installs instructions only;\nuse this Agent Native CLI path when you want MCP setup and auth too. Pass --no-connect to\nregister the connector without authenticating (leave auth to the host or run\n\"npx @agent-native/core@latest connect\" later). Pass --mcp-url to register that connector against\na custom origin (an ngrok tunnel, a local dev server, or a self-hosted\ndeployment) instead of the built-in hosted default — a bare origin gets the\nstandard /_agent-native/mcp path appended. Use app-skill pack for marketplace\nbundles and custom adapter output.\n\nWhen installing visual-recap interactively, the CLI offers to add the optional PR\nVisual Recap GitHub Action. Pass --with-github-action to write it directly, then\nrun \"npx @agent-native/core@latest recap setup\" / \"npx @agent-native/core@latest recap doctor\" to configure and\nverify GitHub Actions.\n\nThe status/update commands inspect copied Agent Native skill folders and refresh\ntheir instruction files from the current @agent-native/core package.`;\n\nconst ASSETS_SKILL_MD = `---\nname: assets\ndescription: >-\n Use Assets for image or video generation requests, brand-safe media,\n human picker UI, search/list/export actions, and cross-app asset selection.\n Prefer this over generic image tools when installed.\nmetadata:\n visibility: exported\n---\n\n# Assets\n\nUse the Assets app when a workflow needs reusable brand media, a human picker,\nor generated image/video assets that another app can reference by ID and URL.\nWhen this skill is available, route plain image-generation requests here instead\nof using a generic image generator.\n\n## Choose The Path\n\n- Use \\`open-asset-picker\\` when a person should browse, search, generate, and\n select an asset in UI. Pass \\`mediaType: \"image\"\\` by default, or\n \\`mediaType: \"video\"\\` for video libraries. When the user asks to create a\n specific image and choose the best option, pass \\`prompt\\`,\n \\`autoGenerate: true\\`, and \\`count: 3\\` so the picker opens with candidates\n to preview and select.\n- Use unattended actions when the agent already knows what to do:\n \\`search-assets\\`, \\`list-assets\\`, \\`generate-image\\`,\n \\`generate-image-batch\\`, \\`generate-video\\`,\n \\`refresh-generation-run\\`, and \\`export-asset\\`.\n- Use browser/deep-link fallback when the host cannot render MCP Apps inline.\n Surface the returned picker link. If it opens in a normal browser tab, have\n the user select an asset there and paste back the copied handoff summary.\n Treat Codex, Claude Code, and Claude Desktop Code as link-out hosts; do not\n promise inline MCP App rendering there.\n If the skill instructions are available but the MCP tool namespace has not\n appeared yet, use the Assets browser fallback URL shape instead of switching\n to a generic generator:\n \\`https://assets.agent-native.com/library?mediaType=image&prompt=...&autoGenerate=1&count=3\\`.\n When reporting the final selected image in Codex or Claude Code, include the\n asset link and, if an inline preview is important, download the selected\n \\`previewUrl\\`/\\`downloadUrl\\` to a local temp image and embed that absolute\n local path. Remote CDN markdown images can fail to render in code-editor chat\n surfaces.\n\n## Image And Video Workflows\n\n1. Pick or match the library with \\`list-libraries\\` or \\`match-library\\`.\n2. For images, call \\`generate-image\\` or \\`generate-image-batch\\`. Image\n actions are synchronous: one batch call should return the finished image\n candidates, so do not poll or regenerate unless a returned slot failed.\n3. For videos, call \\`generate-video\\` and poll \\`refresh-generation-run\\`\n until the run completes.\n4. Preserve returned \\`assetId\\`, \\`runId\\`, \\`previewUrl\\`, \\`downloadUrl\\`,\n media type, and dimensions so the caller can attach or embed the result.\n\n## Cross-App Use\n\n- Hosted default: connect \\`https://assets.agent-native.com/_agent-native/mcp\\`.\n Do not put shared secrets in skill files.\n- For CLI/code-editor clients, keep any \\`npx @agent-native/core@latest connect\\` command\n running until browser authorization finishes. Stopping it early can leave the\n browser approved but the local MCP config unwritten. Restart or reload the\n agent client after installing or connecting if Assets tools do not appear in\n the live session.\n- Local customization: use \\`npx @agent-native/core@latest app-skill launch --local\\` from an\n Assets app-skill manifest, or pass \\`--into <path>\\` for editable source.\n- Do not call image/video providers directly from another app. Assets owns\n generation, picker UI, search/list/export, and asset context.\n- If an Assets tool call returns \\`Session terminated\\`, \\`needs auth\\`, or\n another connector/session error, do not keep retrying the tool. Stop and give\n the user the reconnect step: in Claude Code run \\`/mcp\\` and choose\n Authenticate/Reconnect for the Assets connector; from any terminal run\n \\`npx -y @agent-native/core@latest reconnect https://assets.agent-native.com\\` — this\n re-authenticates WITHOUT reinstalling. Never reinstall from scratch just to fix\n auth. Continue once the connector is available.\n- Do not hand-roll MCP HTTP requests with curl from the agent session. Use the\n host-exposed Assets tools after restart/reload, or use the returned\n browser/deep-link fallback.\n- If a batch image generation request times out in browser fallback, retry with\n \\`count: 1\\` only after telling the user the multi-candidate request timed out.\n- If you inspect local MCP config, redact \\`Authorization\\`, \\`http_headers\\`,\n and token values. Never paste bearer tokens into chat or logs.\n`;\n\nconst DESIGN_EXPLORATION_SKILL_MD = `---\nname: design-exploration\ndescription: >-\n Use Design for UI/UX exploration, side-by-side design directions,\n interactive prototype previews, user selection, iteration, and design-to-code\n handoff through the hosted Design MCP app.\nmetadata:\n visibility: exported\n---\n\n# Design Exploration\n\nUse the Design app when a workflow needs visual UI exploration, prototype\niteration, or a human-in-the-loop choice among design directions.\n\n## Choose The Path\n\n- Use \\`create-design\\` first to create a project shell. Do not report the\n design as ready until it has renderable HTML.\n- For open-ended UX exploration, generate distinct, complete HTML directions\n (2-5, three by default) and call \\`present-design-variants\\`. The inline\n Design MCP app shows the options, lets the user pick one, and persists the\n selected variant.\n- If the Design app opens as a browser link instead of inline (CLI hosts like\n Codex / Claude Code, where the deep link carries \\`handoff=chat\\`), the user\n picks a direction there and the editor shows a copyable summary — ask them to\n paste it back into chat so you can continue from the chosen direction. The\n \\`present-design-variants\\` result's \\`fallbackInstructions\\` describe this.\n- For direct refinements to an already chosen direction, call\n \\`get-design-snapshot\\`, edit from the current tuned HTML, then call\n \\`generate-design\\`.\n- Use \\`export-coding-handoff\\` when the user wants to implement the chosen\n design in a codebase.\n\n## Exploration Defaults\n\n1. Default to three variants unless the user asks for a different count\n (\\`present-design-variants\\` accepts 2-5; three is the sweet spot).\n2. Make variants structurally and stylistically distinct, not just color swaps.\n3. Each variant must be a complete standalone HTML document that renders\n without a build step.\n4. For product UI redesigns, prefer cleaner hierarchy, progressive disclosure,\n and realistic controls over decorative mockups.\n5. After \\`present-design-variants\\`, wait for the user's pick before\n generating the next version. If they say \"I like #2 but...\", snapshot the\n chosen design and refine that direction with \\`generate-design\\`.\n\n## Cross-App Use\n\n- Hosted default: connect \\`https://design.agent-native.com/_agent-native/mcp\\`.\n Do not put shared secrets in skill files.\n- For CLI/code-editor clients, keep any \\`npx @agent-native/core@latest connect\\` command\n running until browser authorization finishes. Stopping it early can leave the\n browser approved but the local MCP config unwritten. Restart or reload the\n agent client after installing or connecting if Design tools do not appear in\n the live session.\n- Dispatch can expose Design alongside other apps. Use Design for UI/UX design\n tasks, Assets for image/media selection, Slides for decks, and so on.\n- Keep the loop visual: surface the inline MCP App or the returned \"Open\n design\" link instead of pasting large HTML blobs into chat.\n- If a Design tool call returns \\`Session terminated\\`, \\`needs auth\\`, or\n another connector/session error, do not keep retrying the tool. Stop and give\n the user the reconnect step: in Claude Code run \\`/mcp\\` and choose\n Authenticate/Reconnect for the Design connector; from any terminal run\n \\`npx -y @agent-native/core@latest reconnect https://design.agent-native.com\\` — this\n re-authenticates WITHOUT reinstalling. Never reinstall from scratch just to fix\n auth. Continue once the connector is available.\n- Do not hand-roll MCP HTTP requests with curl from the agent session. Use the\n host-exposed Design tools after restart/reload, or use the returned\n browser/deep-link fallback.\n- If you inspect local MCP config, redact \\`Authorization\\`, \\`http_headers\\`,\n and token values. Never paste bearer tokens into chat or logs.\n`;\n\n/**\n * Setup/auth block for the `/visual-plan` skill. Interpolated into\n * `VISUAL_PLANS_SKILL_MD` below so the install + one-step authenticate\n * instructions are single-sourced. The materialized SKILL.md copies under\n * `templates/plan/.agents/skills/*`, top-level `skills/*`, and\n * `.agents/skills/*` are guarded byte-identical by `skills.sync.spec.ts`.\n */\nconst PLAN_SETUP_AUTH_MD = `## Setup & Authentication\n\nThere are two ways into Plans.\n\n**Coding agent (CLI).** Install once with the Agent-Native CLI. The command\ninstalls the Plans skills, registers the hosted Plans MCP connector, and runs\nauth/setup for the selected local client(s) in the same step (a one-time browser\nsign-in at setup — this is intended), so the first tool call in that client does\nnot hit an OAuth wall:\n\n\\`\\`\\`bash\nnpx @agent-native/core@latest skills add visual-plan\n\\`\\`\\`\n\nAfter that, \\`/visual-plan\\` and \\`/visual-recap\\` are the two installed slash\ncommands. The other planning modes (\\`create-ui-plan\\`, \\`create-prototype-plan\\`,\n\\`create-plan-design\\`, \\`create-visual-questions\\`) are MCP tools reachable from\n\\`/visual-plan\\`, not separate slash commands. Pass \\`--no-connect\\` to register\nthe connector without authenticating, then run\n\\`npx @agent-native/core@latest connect https://plan.agent-native.com --client all\\`\nwhenever you are ready, or choose a narrower \\`--client\\`. Auth and MCP tool\nloading are per client config/session.\n\n**Browser (people you share with).** Open the Plans editor and create & edit\nwith no sign-up — you work as a guest. Sign in only when you want to save or\nshare; signing in claims the plans you made as a guest into your account.\n\nSharing and commenting require an account: public/shared plans are viewable by\nanyone with the link, but commenting on them needs an agent-native account.\n\nFor fully offline, no-account use, run the Plans app locally and sync plans to\nyour repo as MDX. This local mode is a separate advanced path, not the default\nhosted flow.\n\nIf a Plans tool returns \\`needs auth\\`, \\`Unauthorized\\`, or \\`Session terminated\\`,\ndo not keep retrying the tool. Stop and give the user the reconnect step for the\nclient they are using: Codex/Codex Desktop should run\n\\`npx -y @agent-native/core@latest reconnect https://plan.agent-native.com --client codex\\`\nand start a new Codex session; Claude Code should run \\`/mcp\\` and choose\nAuthenticate/Reconnect for the plan connector, or run the reconnect command with\n\\`--client claude-code\\` and restart Claude. To refresh every local client config\nthat already has the Plan entry, use \\`--client all\\`, then restart/reload each\nclient. Reconnect re-authenticates WITHOUT reinstalling and finds the entry by\nURL regardless of connector name. Never reinstall from scratch just to fix auth.\nContinue once the connector is available.\n\nHosted default: connect \\`https://plan.agent-native.com/_agent-native/mcp\\`. Do\nnot put shared secrets in skill files.`;\n\n// Single-source shared cores. Each partial is a heading-less BODY string that\n// begins and ends with its own SHARED-CORE marker comment, so the marker-region\n// sync guard can extract and compare it across the skills that consume it. The\n// skill constants below interpolate these partials at module-eval time; the\n// distributed artifact stays a flat string, so distribution is unchanged.\n//\n// Consumers:\n// WIREFRAME_QUALITY_CORE — visual-plan, visual-recap (surface-agnostic)\n// CANVAS_SURFACE_CORE — visual-plan modes (canvas/artboard mechanics)\n// DOCUMENT_QUALITY_CORE — visual-plan\n// EXEMPLAR_CORE — visual-plan\n\n// Surface-agnostic HTML wireframe quality rules. Applies equally to a standalone\n// WireframeBlock/<Screen> (visual-recap) and to a canvas artboard (visual-plan).\n// Do not put canvas/artboard placement mechanics here.\nconst WIREFRAME_QUALITY_CORE = `<!-- SHARED-CORE:wireframe-quality START -->\n\n**A wireframe is an HTML mockup. The renderer owns the look; you write the\ncontent.** Set \\`data.html\\` to a self-contained, semantic HTML fragment of the\nscreen and set \\`data.surface\\`. The renderer owns the surface footprint/aspect,\nthe dark/light theme, the hand-drawn font, and the rough.js sketch overlay — you\nnever write \\`<html>\\`/\\`<body>\\`/\\`<script>\\`/\\`<style>\\` tags or any\nwidth/height/coordinates. You write real HTML layout and real product\ncontent; the renderer styles and roughens it.\n\n**A wireframe block's data is an HTML screen plus a surface:**\n\n\\`\\`\\`json\n{\n \"surface\": \"browser\",\n \"html\": \"<div style=\\\\\"display:flex;flex-direction:column;gap:10px;padding:16px;height:100%\\\\\"><h1>Sign in</h1><p class=\\\\\"wf-muted\\\\\">Use your work email to continue.</p><div class=\\\\\"wf-card\\\\\" style=\\\\\"display:flex;flex-direction:column;gap:10px\\\\\"><label>Email<input value=\\\\\"jane@acme.co\\\\\" /></label><label>Password<input value=\\\\\"••••••••\\\\\" /></label><label style=\\\\\"display:flex;align-items:center;gap:8px\\\\\"><input type=\\\\\"checkbox\\\\\" checked /> Remember me</label><button class=\\\\\"primary\\\\\">Sign in</button></div><a href=\\\\\"#\\\\\">Forgot password?</a></div>\"\n}\n\\`\\`\\`\n\n**Write PLAIN semantic HTML and let the renderer style it.** Bare elements\n(\\`h1\\`/\\`h2\\`/\\`h3\\`, \\`p\\`, \\`button\\`, \\`input\\`, \\`<input type=\"checkbox\">\\`, \\`a\\`, \\`hr\\`)\nare auto-themed — no classes needed. Helper classes carry the rest:\n\n- \\`.wf-card\\` / \\`.wf-box\\` — a bordered, padded container (a panel, a list item).\n- \\`.wf-pill\\` / \\`.wf-chip\\` — a rounded tag or filter; add \\`.accent\\`\n (\\`<span class=\"wf-pill accent\">\\`) for the accent-filled variant.\n- \\`.wf-muted\\` — secondary/muted text (or use \\`<small>\\`).\n- \\`button.primary\\` or any element with \\`[data-primary]\\` — the accent-filled\n primary button.\n\n**Use the \\`--wf-*\\` tokens for any custom color, never hex.** The renderer flips\nthese on light/dark, so reading them is what keeps a mockup correct in both\nthemes. For any inline border, background, or text color, reference a token:\n\\`style=\"border:1.4px solid var(--wf-line)\"\\`. The tokens are \\`--wf-ink\\` (text),\n\\`--wf-muted\\` (secondary text), \\`--wf-line\\` (borders/dividers), \\`--wf-paper\\`\n(page background), \\`--wf-card\\` (raised surface), \\`--wf-accent\\` /\n\\`--wf-accent-fg\\` / \\`--wf-accent-soft\\` (brand action), \\`--wf-warn\\`, \\`--wf-ok\\`,\nand \\`--wf-radius\\`. Never hard-code a hex color and never set \\`font-family\\` — the\nrenderer owns the sketch/clean font.\n\n**Lay out with inline \\`style\\` flex/grid.** You write the real layout —\n\\`display:flex; flex-direction:column; gap:10px; padding:16px\\` and so on — and the\nrenderer never repositions anything. Compose the actual product: reproduce the\ncurrent screen, then show the modification. Real labels, real counts, real dates,\nreal button text grounded in the screen you read; not lorem or gray bars.\n\n**Surface presets — match the real footprint, never default to desktop+mobile.**\nPick the \\`surface\\` that matches what the user will actually see:\n\n- \\`browser\\`: a web page that needs a browser chrome frame around it.\n- \\`desktop\\`: a full desktop app page or app shell.\n- \\`mobile\\`: a phone screen, only when the work is genuinely mobile.\n- \\`popover\\`: a small floating menu, dropdown, or inline popover.\n- \\`panel\\`: a side panel, inspector, or sidebar widget.\n\nA sidebar popover renders as a small surface, not a desktop page and a phone\nframe. Do not emit \\`desktop\\` + \\`mobile\\` variants unless responsive behavior\nactually changes the layout. For a component or widget, show one broader\napp-context frame only when placement affects understanding, then the focused\ncomponent states.\n\n**Model the actual component shell for small surfaces.** A rendered UI change\nbelongs in a wireframe; reserve \\`diagram\\` for architecture, dependency, state,\nor data-flow relationships. Popovers, dropdown menus, command palettes, and\ncontext menus use \\`surface: \"popover\"\\` unless the surrounding page placement is\nthe point of the change. Dialogs, sheets, inspectors, sidebars, and long\nproperty panels use the matching \\`panel\\` / \\`desktop\\` surface as appropriate.\nShow the real chrome: trigger or anchor when it matters, title/header row,\ntop-right actions, separators, fields, options, selected states, body content,\nand footer actions that are visible in the workflow.\n\n**Modify, don't redesign.** When the task changes an existing screen, reproduce\nthe current screen's real layout and footprint FIRST, then change only the delta\nand call it out with a single annotation. Do not restack the page into a new\nlayout. For net-new surfaces, compose from the real app shell. Inspect the\nactual app components before drawing an existing product: sidebar density,\ntoolbar actions, overflow menus, property panels, and framework chrome should\nmatch the product unless the plan intentionally changes them.\n\n**Keep product screens pure.** A product wireframe shows the app state a user\nwould actually see. Do not embed file contracts, architecture arrows, repo pills,\nmode explanations, or implementation callouts inside the screen just to explain\nthe plan. Put those in canvas annotations, a separate diagram, or the document\nbody. Secondary UI such as properties, history, sync, export, or agent controls\nshould appear where the real product would put them: an overflow popover, sheet,\npanel, or separate framework sidebar state, not a generic permanent right\ninspector unless that inspector is the actual design.\n\n**Classify mockup scope before implementation.** Before turning a plan mockup\ninto source code, decide whether each artboard represents the whole page/app\nshell, a route body inside an existing shell, or a component/sub-surface. If an\nartboard includes navigation, sidebars, auth banners, or a signup/login form,\nmap those pieces to the real shared shell/auth components instead of nesting the\nentire mockup inside the current page. When a mockup references the product's\nstandard signup/login page, find and reuse that existing implementation; do not\napproximate it from the wireframe.\n\n**Zoom in on sub-surfaces, don't redraw the page.** For a small sub-surface (a\npopover, menu, dialog, toast), show the full screen once, then add a small\nseparate artboard whose \\`html\\` contains ONLY that sub-surface — do not re-draw\nthe whole page around it, and do not scale a duplicate up. Pick the matching\n\\`surface\\` (e.g. \\`popover\\`) so the footprint is right; never widen a popover to\npage width.\n\n**Loading / skeleton states.** Set \\`data.skeleton: true\\` on the wireframe and\nfill the \\`html\\` with neutral, textless placeholder geometry — boxes and bars\nbuilt as \\`<div>\\`s with \\`background:var(--wf-line)\\` and explicit heights/widths,\nno labels or copy. The renderer drops borders, sketch, and color into the\nskeleton register automatically. Never escape to a \\`custom-html\\` document block\nto fake a loader.\n\n**Editing an existing mockup.** To change one element, text, or color in an\nexisting html mockup, call \\`update-visual-plan\\`\nwith \\`contentPatches: [{ op: \"patch-wireframe-html\", blockId, edits: [{ find,\nreplace }] }]\\`. Each \\`find\\` is a unique snippet of the current html (read it\nfirst with \\`get-visual-plan\\`); set \\`all: true\\` on an edit to replace every\noccurrence. The result is re-sanitized.\n\n**Treat the wireframe border as part of the visible design.** Always wrap HTML\nwireframe content in a root container with real inner padding before drawing\ncards, fields, pills, labels, or controls. Use at least 14-16px of padding,\n\\`box-sizing: border-box\\`, \\`height: 100%\\`, and \\`gap\\` between child rows so the\nfirst row never sits flush against the screen border. Keep text away from\nborders: every container, field, button, menu item, and annotation needs enough\npadding and line-height to read cleanly in the rendered Plan view.\n\n**Lay out children safely so they never collide.** Use HTML flex/grid with\n\\`gap\\`, \\`min-width: 0\\`, and sensible overflow. Avoid negative margins, absolute\npositioning, or fixed child widths that can collide when the renderer switches\nbetween light/dark, sketch/clean, or different zoom levels.\n\n**Do not wrap intentionally single-line labels.** For toolbars, tab rails,\nbreadcrumbs, chip/filter rows, branch and file names, file chips, and code\nfilenames — any deliberately single-line row — do not let long text wrap. Put\n\\`white-space: nowrap\\` on the row (and \\`overflow: hidden; text-overflow: ellipsis\\`\non the individual labels that can grow), so the wireframe demonstrates the actual\nlayout behavior instead of producing ugly stacked or vertical text. Use\nhorizontally scrollable or clipped rails for overflow.\n\n**Fill the frame; keep labels short.** Each artboard is a fixed-size surface — compose enough realistic HTML to fill it top to bottom with even vertical rhythm; never leave a large empty band. On desktop/app-shell sidebars, let the nav stack flex to fill (\\`flex:1\\`) and add any persistent bottom action/status after it so the rail reads complete in taller frames. On mobile especially, flow real rows down the whole screen (status bar, header, then list/detail content) rather than a header floating above a gap. Keep every label short enough to sit on one line within its column — shorten the copy rather than relying on the frame to absorb it (long labels wrap or clip).\n\n**Persistent chrome bars span the full frame width.** Top bars, app headers,\ntoolbars, and bottom tab/nav bars are full-width chrome, not centered content.\nLay each one out as a single flex row that fills the frame\n(\\`style=\"display:flex;align-items:center;width:100%\"\\`) and push trailing actions\nto the right edge with a flex spacer (\\`<div style=\"flex:1\"></div>\\`) between the\nleading group and the trailing group — never center a bar inside a narrow,\ncentered block, and never let it collapse to the width of its contents. In a\nBefore/After pair the bar stays full-width in BOTH states even when one state has\nfewer controls; the spacer absorbs the difference so the remaining controls hold\ntheir edge alignment instead of sliding to the center.\n\n**Pin bottom bars to the bottom of the frame.** For mobile tab bars, footers, and\nany persistent bottom action row, make the frame itself a flex column at\n\\`height:100%\\` (\\`style=\"display:flex;flex-direction:column;height:100%\"\\`), give the\nscrolling body \\`flex:1\\` so it absorbs the slack, and place the bar as the LAST\nchild of the frame (or set \\`margin-top:auto\\` on it). The bar then sits flush at\nthe bottom of the surface instead of floating directly under the content with an\nempty band beneath it.\n\n**Before / after must be comparable.** When showing a state change, preserve the\nunchanged controls in both states so the reviewer can see exactly what moved or\nappeared; do not show an added control as a generic box floating elsewhere in\nthe surface. Place the new/changed affordance where the implementation puts it —\nfor example, a new \\`Edit with AI\\` action in a popover header belongs in the\ntop-right header slot, aligned with the title, not in the body or footer. Use\nthe same frame size, scale, outer padding, border radius, and visual density on\nboth sides unless the change itself alters those properties, and let the frame\nheight fit the content rather than leaving a tall empty lower half.\n\n**Name the states with the column header, never inside the frame.** For\ndocument-body wireframes (recaps), put the two\nstates in a \\`columns\\` block and set each column's \\`label\\` to \\`Before\\` and\n\\`After\\` — the renderer draws that label as an \\`h4\\` heading above each frame. Do\nNOT bake a \\`Before\\`/\\`After\\` pill, title, or heading into the wireframe \\`html\\`: a\nlabel placed inside reads as part of the product UI, lands in a random corner,\nand clutters the comparison. The column header is the one and only place the\nstate name belongs. On a canvas, place the two state artboards as neighbors with\nframe labels — never encode Before/After inside the html.\n\n**Let the surface choose side-by-side vs. stacked.** For document-body\nwireframes (recaps), the \\`columns\\` renderer lays\nnarrow surfaces (\\`mobile\\`, \\`popover\\`, \\`panel\\`) out side by side, and\nautomatically stacks wide surfaces (\\`desktop\\`, \\`browser\\`) vertically at full\ndocument width so a large frame is never crushed into a half-width column and\ncropped. Author both wireframes with the real \\`surface\\` and the matching\n\\`Before\\`/\\`After\\` column labels; do not hand-stack the pair into separate\ntop-level wireframes or duplicate the state name as body content.\n\n**Good example — a contacts list, surface \\`browser\\`.** A small, real screen\ncomposed from the helper classes and tokens, layout in inline flex, no fonts or\nhex colors:\n\n\\`\\`\\`html\n<div\n style=\"display:flex;flex-direction:column;gap:12px;padding:16px;height:100%\"\n>\n <div style=\"display:flex;align-items:center;justify-content:space-between\">\n <h1>Contacts</h1>\n <button class=\"primary\">New contact</button>\n </div>\n <div style=\"display:flex;gap:6px\">\n <span class=\"wf-pill accent\">All 128</span>\n <span class=\"wf-pill\">Favorites</span>\n <span class=\"wf-pill\">Archived</span>\n </div>\n <div\n class=\"wf-card\"\n style=\"display:flex;flex-direction:column;gap:0;padding:0\"\n >\n <div\n style=\"display:flex;align-items:center;gap:10px;padding:10px 12px;border-bottom:1.4px solid var(--wf-line)\"\n >\n <div\n style=\"width:32px;height:32px;border-radius:999px;background:var(--wf-accent-soft)\"\n ></div>\n <div style=\"flex:1\">\n <strong>Jane Cooper</strong><br /><small>jane@acme.co</small>\n </div>\n <span class=\"wf-pill\">Lead</span>\n </div>\n <div style=\"display:flex;align-items:center;gap:10px;padding:10px 12px\">\n <div\n style=\"width:32px;height:32px;border-radius:999px;background:var(--wf-accent-soft)\"\n ></div>\n <div style=\"flex:1\">\n <strong>Marcus Lee</strong><br /><small>marcus@globex.io</small>\n </div>\n <span class=\"wf-pill\">Customer</span>\n </div>\n </div>\n</div>\n\\`\\`\\`\n\n<!-- SHARED-CORE:wireframe-quality END -->`;\n\n// Progressive-disclosure reference file. `WIREFRAME_QUALITY_CORE` is the single\n// source of truth for HTML wireframe quality; it is materialized verbatim into a\n// sibling `references/wireframe.md` in EVERY plan skill dir (visual-plan and\n// visual-recap), instead of being interpolated inline into each SKILL.md body.\n// The SKILL.md bodies carry only `WIREFRAME_REFERENCE_POINTER`, which tells the\n// agent to read this file before authoring any wireframe. Keeping the reference\n// body byte-identical to the core (markers included) lets the sync guard assert\n// the on-disk copies never drift from the canonical constant.\nexport const WIREFRAME_REFERENCE_MD = `# HTML wireframe quality — single source of truth\n\nThis file is the canonical quality bar for HTML wireframes / \\`<Screen>\\` /\n\\`WireframeBlock\\` content, shared word for word by \\`/visual-plan\\` and\n\\`/visual-recap\\`. Read it in full before authoring ANY wireframe; do not\nauthor wireframes from memory or paraphrase these rules per command.\n\n${WIREFRAME_QUALITY_CORE}\n`;\n\n// Short pointer that replaces the inline wireframe-quality core in each SKILL.md\n// body. Authoring quality lives in the sibling reference file so the SKILL.md\n// stays lean (progressive disclosure); the agent loads the detail on demand.\nconst WIREFRAME_REFERENCE_POINTER = `UI recap/plan wireframes must meet a strict quality bar — full-width chrome,\npinned bottom bars, real product content, before/after comparability, the right\n\\`surface\\` preset, \\`--wf-*\\` tokens instead of hex, and no \\`<html>\\`/\\`<style>\\`/font\ntags. Before authoring ANY wireframe / \\`<Screen>\\` / \\`WireframeBlock\\`, READ\n\\`references/wireframe.md\\` in this skill directory — it is the single source of\ntruth for HTML wireframe quality, shared word for word with \\`/visual-plan\\`\nand \\`/visual-recap\\`. Do not author wireframes from memory.`;\n\n// Canvas/artboard placement mechanics. Used only by visual-plan modes\n// (visual-recap renders standalone wireframes, not a canvas).\nconst CANVAS_SURFACE_CORE = `<!-- SHARED-CORE:canvas-surface START -->\n\n**The coordinate rule.** The \\`surface\\` locks each artboard's footprint and\naspect — never set artboard width/height and never use coordinates inside the\nwireframe HTML; board-level artboard \\`x\\`/\\`y\\` IS allowed when it creates clear\nlanes. Let canvas auto-placement handle simple one-row boards.\n\n**Lay out mixed canvases in lanes.** When a canvas contains broad browser /\ndesktop frames plus compact \\`mobile\\`, \\`popover\\`, or \\`panel\\` surfaces, do not put\neverything in one horizontal strip. Use board-level artboard \\`x\\`/\\`y\\` to reserve\nlanes with generous empty space: main flow on one row, compact surfaces in their\nown column or row, and loading/error states in a lower row. Keep at least 96px\nbetween rendered artboard rectangles plus room for annotation gutters. Connect\nonly neighboring steps; never draw a long connector that skips across unrelated\nframes. Before handoff, inspect the top canvas at default zoom and move any\nframe whose label, connector, or annotation crosses another frame.\n\n**Canvas annotations are designer notes on the artboard.** When a top canvas is\npresent, sprinkle Figma-style notes near the frames they explain: a short\nheading, supporting text, and bullets — plain text layers, never bordered or\nshadowed cards, and never a box around a frame. The renderer spaces notes away\nfrom frames, so place each note by the frame it describes. Use an arrow only to\npoint at one specific control or transition; for a broad frame-level note, write\ntext beside the frame with no connector. Connectors are for real sequences only —\nnever fake \"Step 1 → Step 2\" lines between independent states.\n\n**Do not create overlapping annotations.** Anchor each ordinary note to the\nframe it explains with \\`targetId\\` + \\`placement\\` (top/right/bottom/left), and\nomit \\`type\\` or use \\`type: \"note\"\\`. The renderer parks notes in a gutter beside\nthe frame and lays them out automatically. Do not use \\`type: \"callout\"\\`,\n\\`type: \"text\"\\`, \\`type: \"arrow\"\\`, x/y, or points for ordinary notes; those are\nfreeform review-markup layers and must be reserved for intentional markup in\nopen canvas space. Reserve arrows for a note that must point at one specific\ncontrol inside a frame; a note that simply sits beside its frame needs no arrow.\n\n**Patching.** Edit one wireframe, canvas annotation, diagram, or block with targeted \\`contentPatches\\`\n(for example \\`patch-wireframe-html\\`, \\`patch-diagram-html\\`, \\`update-block\\`,\n\\`replace-blocks\\`, \\`update-canvas-annotation\\`) rather\nthan regenerating the whole plan. \\`contentPatches\\` are part of the public MCP\naction schema, so Claude Code, Codex, Cursor, and other hosts can make surgical\nedits. If an agent is working from exported source files, use\n\\`read-visual-plan-source\\` / \\`patch-visual-plan-source\\`: \\`plan.mdx\\` holds\nfrontmatter plus markdown/document blocks, \\`canvas.mdx\\` holds\n\\`<DesignBoard>/<Section>/<Artboard>/<Screen>/<Annotation>/<Connector>\\`, and the\npatch action normalizes the MDX back into the same JSON runtime model. JSON is\nthe canonical runtime shape; MDX is the repo-friendly authoring/export surface.\nIn the browser, humans edit \\`rich-text\\` prose inline; agents should still use\n\\`update-rich-text\\` content patches or source patches for prose, and use\ncomments/structured patches for canvas, artboard, wireframe, and diagram edits.\nNever send a partial top-level \\`content\\` object as a shortcut to add a canvas,\nframe, or block: \\`content\\` is a full structured replacement, so omitted blocks\nor surfaces can disappear. If a full replacement is truly unavoidable, read the\ncomplete source/JSON first, include every existing block and surface in the new\npayload, and verify the source/export immediately after the update.\n\n**Never emit a titled artboard with no interior wireframe content.** Every artboard\nyou place on the canvas must carry an \\`html\\` wireframe or reference a wireframe\nblock via \\`blockId\\`; when using \\`blockId\\`, the referenced \\`wireframe\\` /\n\\`legacy-wireframe\\` block must remain in the plan. If you remove a duplicate\nwireframe from the document body, first move its \\`data\\` inline onto the\ncorresponding \\`content.canvas.frames[*].wireframe\\` / \\`legacyWireframe\\`. A\nlabel-only frame or a frame pointing at a deleted block renders empty and is\nrejected at parse time. If you only have a title, write it as a section header or\nannotation, not an empty artboard.\n\n**UI mockups belong in the top visual review area.** Static UI/product visuals\nlive on the canvas; multi-step UI flows get both canvas wireframes and a\nprototype. When the user asks for a mockup, UI state, loading state, layout,\nscreen, or visual comparison, make the canvas the primary home for that static\nvisual. When the user asks for a prototype or the plan contains a sequence the\nreviewer must feel, keep the canvas artboards and add \\`content.prototype\\` so the\ntop surface shows Wireframes / Prototype tabs. Architecture/code diagrams stay\ninline in the document (the SKILL.md Visual Surface Choice section owns that\nrule) unless the user explicitly asks for a spatial board. Document blocks\ncan explain, compare, or map implementation, but they should not host the\nprimary UI mockup or prototype just because \\`custom-html\\`, screenshots, or prose\nare easier to produce. If the canvas/prototype surface cannot represent the\nrequested UI fidelity, still keep the closest top-surface representation and\ncall out or extend the needed renderer capability. A skeleton/loading mockup\nalso lives in a canvas artboard — never move a mockup out of the canvas.\n\nFor abstract product concepts, use the canvas to create the first \"I get it\"\nmoment: one real app state near the top showing how the concept appears to a\nuser, followed by separate annotations or diagrams for mechanics. Do not make\nthe first artboard a hybrid of app UI and architecture notes; the app screen\nshould be inspectable as product UI on its own.\n\n**Legacy kit tree.** Older plans set a \\`screen\\` array of \\`{ el, ...props }\\` kit\nnodes instead of \\`html\\`; the renderer still accepts and displays it, but new\nplans emit \\`html\\`. Do not author fresh kit-tree screens - write the HTML mockup\ninstead. Likewise, old or imported plans may carry coordinate-based regions or\nfree-float x/y on notes; those are legacy escape hatches the renderer still\nshows but you must never produce. The gutter parks notes by \\`targetId\\` +\n\\`placement\\`, and the coordinate rule at the top of this file governs all\nnew-plan placement.\n\n<!-- SHARED-CORE:canvas-surface END -->`;\n\nconst DOCUMENT_QUALITY_CORE = `<!-- SHARED-CORE:document-quality START -->\n\n**The document is a serious technical plan, not marketing.** Write it the way a\nstrong Claude or Codex implementation plan reads: outcome-first, prose-first,\nself-contained, and specific. State the objective and what \"done\" means, the\nscope and non-goals, the proposed approach with the key decisions and their\nrationale, ordered steps that name real files, symbols, actions, and data\nshapes, the risks, and a closing verification step (tests, build, or a checkable\nbehavior). Replace vague prose with specifics; never ship a step like \"make it\nwork.\" No hero art, gradients, logos, nav bars, slogans, value props, giant\nlanding-page headings, or marketing cards unless the user explicitly asks.\n\n**Every published plan must stand alone.** Even when the agent is revising an\nexisting plan, the output is a plan to do the work, not a changelog of the\nconversation. Do not write phrases like \"preserve the previous plan\", \"do not\ndrop the old idea\", \"as discussed above\", \"this revision\", \"unlike the prior\nversion\", or \"correction from the earlier plan\". Fold the right decisions into\nthe plan as normal objective, architecture, scope, and roadmap prose. A reviewer\nwho opens the plan from a link with no chat history should understand it. Avoid\nnegative framing that only makes sense against absent context (\"not the old\nmode\", \"not just X\") unless the contrast is defined in the plan and genuinely\nhelps; state the positive model directly.\n\n**Make abstract plans instantly legible.** If the idea is broad, strategic, or\nintended for a third-party reviewer, put one concrete product snapshot near the\ntop before dense architecture, mode tables, manifests, or roadmaps. For\nUI-capable concepts, that snapshot is usually a top-canvas app state plus a\nshort paragraph that says what the user sees and what changes under the hood.\nThen put mechanics, data flow, sync boundaries, and implementation detail in\nseparate diagrams or document sections.\n\n**Preserve the user's level of abstraction.** A motivating use case is not\nautomatically the architecture. When the prompt describes a broader framework,\nproduct mode, or reusable primitive, separate the reusable core from specific\napps, providers, customers, scripts, or launch examples. Use the concrete\nexample to make the plan understandable, then make clear which parts are core,\nwhich are app-specific adapters, and which are future examples.\n\n**When top visuals exist, they and the document never duplicate each other.**\nFor UI work, the UI story lives in the top visual surface: canvas artboards for\nstatic inspection, plus prototype tabs when the flow should be functional. The\ndocument carries the technical depth the visuals cannot show — concrete\nfile/symbol maps, API and data contracts, code snippets, migration or\nimplementation phases, risks, and validation. For architecture/code reviews,\ninvert that: the document is the visual surface, and each recommendation\ncarries its own nearby inline \\`diagram\\` / \\`data-model\\` block plus file\nevidence (the \\`diagram\\` bullet below owns how to author those diagrams).\nRepeat a wireframe in the document only for a genuinely new detail view or\ncomparison. Skip the visual surface entirely for non-visual work and write a\nclean rich document. For a simple binary UI visual choice, show the two\ndirections in the canvas only; do not repeat the same options as body\nwireframes or prose. Put the actual choice in the bottom \"Open Questions\" form.\n\n**Use the right block, and make it carry substance.** For the authoritative,\nmachine-checked list of block types and their data schemas, call \\`get-plan-blocks\\`\n— it returns the live registry vocabulary (type, MDX tag, placement, key fields)\nso you never emit a block the editor cannot render or round-trip:\n\n- \\`rich-text\\` for plan prose with real bold/italic/code/links and nested lists.\n- \\`annotated-code\\` for the file map: when a load-bearing file is worth\n highlighting, prefer the annotated walkthrough over a bare \\`code\\` block — carry\n the real, syntax-highlighted code AND anchor short margin notes to the lines\n that actually change (the new action, the changed schema, the wiring point), so\n the reader sees what matters and why instead of code for code's sake. Each\n annotation is \\`{ lines: \"12\" | \"12-18\"; label?; note }\\`; keep a few high-signal\n notes per file, not one per line. Highlight only the files worth reading; never\n an exhaustive list of every touched file, and never a prose-only description of\n a file. Drop to a plain \\`code\\` block only for a throwaway snippet with nothing\n to call out. When more than one file matters, group the blocks in a vertical\n \\`tabs\\` block (the standard tab primitive) rather than a bespoke container. If\n the exact code is unknown, show the smallest plausible planned shape or a\n commented stub naming what to fill in. (\\`code-tabs\\` and \\`implementation-map\\`\n are legacy: their renderers stay for old plans, but do not author new ones.)\n- For a decision: if the reviewer must still pick between a genuinely-open\n either/or, put it in the bottom Open Questions \\`question-form\\` as a \\`single\\`\n question — one option per real alternative, each with a short detail and\n \\`recommended: true\\` on the one you would choose; do not also restate the same\n choice elsewhere. If you have already committed to an approach, state it as\n settled prose or a \\`callout\\` with \\`tone=\"decision\"\\`, optionally with a\n \\`columns\\` block for a side-by-side comparison of the options you weighed — not\n as a confusing mid-document form for a question you have already answered.\n- \\`columns\\` for side-by-side before/after or current/target comparisons where\n each side needs real nested blocks; label the columns clearly and avoid\n stacking comparison blocks vertically when parallel reading is the point.\n- \\`diagram\\` for two-dimensional architecture, dependency, data-flow, or state\n relationships, only when it clarifies something real. Prefer standard\n two-dimensional layouts — paired before/after panels, layered diagrams,\n swimlanes, dependency maps, matrices, or grouped regions; do not default to\n left-to-right chains, and use a line only when the relationship is truly a\n sequence. For architecture/code\n diagrams, prefer \\`data.html\\` / \\`data.css\\` with semantic HTML and inline SVG so\n the diagram can use panels, layers, matrices, arrows, annotations, and\n responsive layout directly. Author diagram HTML with renderer-owned primitives\n like \\`.diagram-panel\\`, \\`.diagram-card\\`, \\`.diagram-node\\`, \\`.diagram-box\\`,\n \\`.diagram-pill\\`, \\`.diagram-muted\\`, and \\`[data-rough]\\`; they map to the plan's\n Tailwind theme variables through \\`--wf-ink\\`, \\`--wf-muted\\`, \\`--wf-line\\`,\n \\`--wf-paper\\`, \\`--wf-card\\`, \\`--wf-accent\\`, \\`--wf-accent-soft\\`, \\`--wf-warn\\`, and\n \\`--wf-ok\\`, and switch to Excalifont plus rough.js outlines in sketchy mode. Do not\n set \\`font-family\\` and do not hard-code hex, rgb, or hsl colors in diagram HTML\n or CSS. Leave room for the sketch font: keep labels short, give nodes generous\n width, and place boundary/annotation labels in unused space instead of over\n nodes; labels must not overlap nodes, connectors, or each other. For small\n text/SVG changes to an existing HTML diagram, use \\`patch-diagram-html\\` with a\n unique \\`find\\`/\\`replace\\` snippet instead of resending the whole \\`data.html\\`\n string. Use legacy \\`nodes\\` / \\`edges\\` only for small previews or truly\n sequential flows. In architecture/code plans, prefer a repeated section rhythm:\n recommendation title, confidence and category badges, code-path evidence, a\n local before/after or current/target spatial diagram, then concise\n Problem/Solution/Why text.\n- \\`tabs\\` for multiple states, directions, or comparisons. A tab that reveals\n only prose usually means the plan is under-specified — include a relevant\n visual unless the tab is intentionally document-only.\n- \\`table\\`, \\`checklist\\`, \\`callout\\` for scannable structure.\n\n**Open questions live at the bottom as a form when answers would change the\nplan.** Surface answerable unresolved decisions in a final \\`question-form\\`\nblock titled \"Open Questions\" so the renderer presents it as a distinct section.\nThat bottom form is the ONLY place that enumerates the open questions: never add\na second \"Open Questions\" heading, list, or recap of the same questions earlier\nin the document. A one-line pointer in the overview prose (\"a few decisions are\nstill open — see Open Questions below\") is fine, but do not reproduce the\nquestion list or a parallel questions/decisions section above it.\nUse \\`single\\` or \\`multi\\` for clear choices, \\`freeform\\` for constraints,\n\\`recommended: true\\` for the default you would pick, and option \\`wireframe\\` /\n\\`diagram\\` previews only when the options are not already visible in the top\ncanvas. \\`single\\` and \\`multi\\` questions always render a write-in field so a\nreviewer can answer with a custom option — never add an explicit \"Other\" option\nyourself; set \\`allowOther: false\\` only when a free-text answer makes no sense.\nKeep non-answerable assumptions or risks as concise \\`callout\\` blocks in\nthe relevant section. Never bury a questions/decisions wall inside the plan\nnarrative, and never ask the same question twice.\n\nFor complex plans, do not end without an open-question audit. If architecture,\nscope, UX, data shape, rollout, provider mapping, or ownership still depends on\na choice, either commit to a recommendation with rationale or add it to the\nbottom form with a recommended default. A complex plan with no open questions is\nfine only when every meaningful decision has been explicitly made.\n\n**Verification must exercise the real workflow.** The final verification section\nshould go beyond typecheck/unit tests when the plan changes UI, local files,\nsync, providers, browser behavior, or multi-app flows. Include at least one\nend-to-end smoke that matches the user journey, such as a fresh repo/folder,\nreal manifest or data fixture, browser interaction, save/sync action, and an\non-disk or database assertion. Name the command or manual browser path when it\nis known.\n\n**\\`custom-html\\` is a bounded escape hatch only** — a single complete fragment\ninside a block, never \\`html\\`/\\`head\\`/\\`body\\`/\\`script\\` tags, never a generic\nplaceholder, density demo, or proof that custom HTML works. Prefer the native\nblocks for normal plans. For architecture/code reviews, use \\`diagram\\`\n\\`data.html\\` / \\`data.css\\` for rich local HTML/SVG diagrams instead of\n\\`custom-html\\`. For UI/product work, \\`custom-html\\` is never the primary home for a\nrequested mockup, UI state, or visual comparison. If UI fidelity requires\nHTML/CSS, image capture, or real React/CSS, the product fix is canvas support\nfor that artifact type, not moving the mockup into the document.\n\n**Before handoff, open the plan and check it.** Fix overlap, excessive\nwhitespace, clipped fragments, misleading inactive controls, poor contrast, and\nunreadable diagrams before asking for approval.\n\n<!-- SHARED-CORE:document-quality END -->`;\n\nconst EXEMPLAR_CORE = `<!-- SHARED-CORE:exemplar START -->\n\n**GOOD.** A UI-first plan for a todo app: a canvas with a \\`desktop\\` artboard whose\n\\`data.html\\` is a real flex layout — a sidebar of links (\\`Inbox 12\\`, \\`Today 4\\`,\n\\`Done\\`), a main column with an \\`<h1>Today</h1>\\`, accent \\`.wf-pill\\`s for the\nfilters, a muted section label \\`OVERDUE\\`, and \\`.wf-card\\` task rows carrying real\ntitles, due dates, and a primary \\`button.primary\\` — styled only through bare\nelements, helper classes, and \\`--wf-*\\` tokens, so the renderer applies the\ncorrect desktop footprint, theme, and one subtle whole-frame wobble. Plain-text\ndesigner notes sit spaced off the frame, pointing only at the controls that need\nexplanation. Below it, a Claude/Codex-grade document: objective and\ndone-criteria, a few \\`code\\` blocks (grouped in a vertical \\`tabs\\` block when\nmore than one) showing the real shape of the load-bearing files, a \\`callout\\`\nwith \\`tone=\"decision\"\\` stating the chosen approach with a \\`columns\\` block\nweighing the two real options behind it,\nand a validation step — none of it repeating the canvas. If the task also\nchanges a multi-step completion flow, the same top area includes a Prototype tab\nwhose screens use the same labels and states as the canvas artboards, with\n\\`data-goto\\` controls for the sequence. This is the bar.\n\n**GOOD.** A broad product-architecture plan opens with a plain recommendation\nand one concrete app state before the abstraction. The first canvas artboard is\npure product UI that matches the current app shell; nearby notes explain the\nuser-visible delta. A separate diagram below shows the mechanics, such as file\nor data flow. The document then separates the reusable core from app/provider\nadapters and examples, covers contracts, folder or schema shape, sync\nboundaries, roadmap, non-goals, a bottom Open Questions form for unresolved\ndecisions, and a verification section with at least one realistic end-to-end\nsmoke. A reviewer who was not in the chat gets the idea from the top snapshot\nbefore reading the technical plan.\n\n**GOOD.** A \\`/visual-plan\\` for a backend architecture review: no top canvas.\nThe document opens with context and a legend, then repeats recommendation cards:\ntitle, confidence/category badges, a monospace grid of real file paths, one\ninline two-dimensional before/after or layered architecture diagram, and terse\nProblem/Solution/Why bullets using the codebase's vocabulary. The diagram uses\nspace to show boundaries, layers, and ownership; it is not a default\nleft-to-right chain. The plan ends with a top recommendation and a bottom\nquestion-form only if the next architecture direction is genuinely open. This is\nbetter than a top canvas because each diagram is local to the claim it supports.\n\n**BAD.** A \\`data.html\\` with hard-coded hex colors, a \\`font-family\\`, or fixed\npixel width/height; gray placeholder bars \"insinuating\" text on a non-skeleton\nframe; a forced desktop + mobile pair for a popover; floating bordered\nannotation cards hugging the frames; a fresh hand-authored kit-tree \\`screen\\`\ninstead of \\`html\\`; a multi-step UI flow with only static frames and no prototype\ntab; a mockup escaped into a document \\`custom-html\\` block; and a marketing-style\ndocument with a hero heading and value props that just restates what the canvas\nalready shows. Also bad: an architecture-only plan forced into a top canvas of\nlabeled boxes with overlapping text, where the actual code evidence and\nrecommendations live elsewhere; a product wireframe that mixes a real screen\nwith repo names, file-contract arrows, architecture explanations, or a made-up\npermanent inspector; and a plan that describes itself as a revision of a prior\nconversation instead of a standalone proposal. Never produce this.\n\n<!-- SHARED-CORE:exemplar END -->`;\n\n// Progressive-disclosure reference files. Like `WIREFRAME_REFERENCE_MD`, each of\n// the canvas / document-quality / exemplar cores is the single source of truth\n// for its topic and is materialized verbatim into a sibling `references/*.md`\n// file in the visual-plan skill dir instead of being interpolated inline into\n// the SKILL.md body. The body carries only the matching `*_REFERENCE_POINTER`.\n// Keeping each reference body byte-identical to its core (markers included) lets\n// the sync guard assert the on-disk copies never drift from the constant.\nexport const CANVAS_REFERENCE_MD = `# Canvas & artboard placement — single source of truth\n\nThis file is the canonical guide for how the visual-plan canvas works: artboard\nplacement, lane layout, annotations, patching, and the legacy kit tree. Read it\nin full before authoring or editing any canvas/artboard content; do not author\ncanvas layouts from memory or paraphrase these rules per mode.\n\n${CANVAS_SURFACE_CORE}\n`;\n\nexport const DOCUMENT_QUALITY_REFERENCE_MD = `# Plan document quality — single source of truth\n\nThis file is the canonical quality bar for the plan document below the canvas:\nhow it reads, which blocks to use, how open questions are surfaced, and the\npre-handoff check. Read it in full before authoring the plan document; it is the\nquality bar. Do not write the document from memory or paraphrase these rules per\nmode.\n\n${DOCUMENT_QUALITY_CORE}\n`;\n\nexport const EXEMPLAR_REFERENCE_MD = `# Good vs. bad exemplar — single source of truth\n\nThis file is the canonical worked example of a great plan (and the anti-patterns\nto avoid). Read it alongside the document-quality and canvas references before\nauthoring a plan; it is the bar these plans must clear.\n\n${EXEMPLAR_CORE}\n`;\n\n// Short pointers that replace the inline canvas / document-quality / exemplar\n// cores in the SKILL.md body. Authoring detail lives in the sibling reference\n// files so the SKILL.md stays lean (progressive disclosure); the agent loads the\n// detail on demand.\nconst CANVAS_REFERENCE_POINTER = `The canvas is the single source of truth for static UI mockups: the \\`surface\\`\nlocks each artboard's footprint, mixed surfaces lay out\nin lanes, annotations are plain-text designer notes anchored by\n\\`targetId\\`/\\`placement\\`, and edits are surgical \\`contentPatches\\`. Before\nauthoring or editing ANY canvas, artboard, or annotation, READ\n\\`references/canvas.md\\` in this skill directory — it is the single source of truth\nfor canvas/artboard mechanics. Do not author canvas layouts from memory.`;\n\nconst DOCUMENT_QUALITY_REFERENCE_POINTER = `The document is a serious technical plan, not marketing: outcome-first,\nprose-first, self-contained, built from the right native blocks, with open\nquestions in a single bottom \\`question-form\\` and a pre-handoff visual check.\nBefore authoring the plan document, READ \\`references/document-quality.md\\` in this\nskill directory — it is the single source of truth for the document quality bar.\nDo not write the document from memory.`;\n\nconst EXEMPLAR_REFERENCE_POINTER = `For a worked example of the bar — a great UI-first plan and \\`/visual-plan\\`, plus\nthe anti-patterns to avoid — READ \\`references/exemplar.md\\` in this skill\ndirectory before authoring a plan.`;\n\nexport const VISUAL_PLANS_SKILL_MD = `---\nname: visual-plan\ndescription: >-\n Turn ordinary text plans into rich interactive visual plans with diagrams,\n file maps, annotated code, open questions, and UI/prototype review when\n useful.\nmetadata:\n visibility: exported\n---\n\n# Agent-Native Plans\n\nAgent-Native Plans is structured visual planning mode for coding agents. Build\nthe plan you would normally write in Markdown, but as a scannable document with\neditable blocks mixed in: inline diagrams, code snippets,\nopen questions, and an optional top visual review area (wireframe canvas, live\nprototype, or both in tabs). Architecture and backend plans stay document-only;\nUI and product plans start with the top canvas/prototype (the Visual Surface\nChoice section owns that rule).\n\n\\`/visual-plan\\` is the packaged command and main entry point. Choose the review\nmode from the task: UI-first when the work is primarily product UI and review\nshould start with screens, prototype-first when review should start with a\nfunctional live prototype, design-first when review needs full-fidelity branded\nscreens, or visual-intake when the user explicitly wants a questionnaire before\nplanning. When a Codex, Claude Code, Markdown, or pasted plan already exists,\n\\`/visual-plan\\` uses that source plan as the starting point and builds the review\nsurface from it instead of starting over.\n\n## When To Use\n\nCreate or adapt a visual plan when work is multi-file, ambiguous, long-running,\nrisky, or UI-heavy, when architecture / data flow / UI direction / options /\nopen questions would benefit from inline diagrams or structured blocks, when the\nuser needs to react to a direction before you implement, or when an existing text\nplan needs a richer review surface.\n\n## Plan Discipline\n\n- **Gate hard.** A polished visual plan is the most expensive plan form; only\n invest when a wrong direction is costly. Skip it for trivial, unambiguous work\n — typos, one-line fixes, a single well-specified function, anything whose diff\n you could describe in one sentence — and just make the change. Never pad a plan\n with filler and never ship a single-step plan.\n- **Research before you draft.** Read the real files, actions, schema, and\n patterns first; name actual files, symbols, and data shapes instead of\n inventing them. Check existing \\`actions/\\` before proposing endpoints and prefer\n named client helpers over raw fetch. Delegate wide exploration to a sub-agent.\n Lead with reuse: for each step, name what it reuses — existing actions, schema,\n components, helpers — before what it adds, so the plan explains the genuinely new\n delta instead of redescribing what already exists.\n- **Decide the hard-to-reverse bets first.** For non-trivial backend, data, or API\n work, sketch where the feature is headed, then call out the decisions that are\n expensive to undo once data or callers depend on them — wire format, public ids,\n data-model shape, auth and ownership boundaries — and get those right in the plan\n even if most of the feature ships later. Then scope to the smallest first cut that\n proves the approach without foreclosing it, stating both what is in and what is\n explicitly deferred.\n- **Keep examples at the right altitude.** When the user's idea is a broad\n framework, product, or operating-model change, do not collapse it into the\n first concrete example, provider, or sync path they mention. Separate the core\n abstraction from motivating examples and app/provider adapters. Use examples\n to make the plan legible, but label them as examples unless they are the whole\n requested scope.\n- **Publish standalone plans.** If the user pasted, referenced, or already has a\n Codex / Claude Code / Markdown plan, treat it as source material, but rewrite\n the published plan as a clean standalone proposal. Preserve the source plan's\n useful intent and codebase facts, label inferred visuals as inferred, and avoid\n revision language such as \"preserve the prior plan\", \"do not drop the old\n idea\", \"unlike the previous version\", or \"this revision changes...\". A reader\n who never saw the chat or earlier drafts should understand the plan.\n- **Make the first read concrete.** If the plan is meant to be shared with\n someone outside the chat, or if the concept is abstract, lead near the top with\n one concrete product example before mode tables, architecture, or roadmaps. For\n UI-capable concepts, that usually means a top-canvas app state that shows the\n real user workflow in product terms. Do not rely on phrases that only make\n sense in conversation, and do not frame the plan as \"not the old idea\"; state\n the positive model directly.\n- **Planning is read-only.** Make no source edits while building or reviewing the\n plan. Start editing only after the user approves the direction.\n- **Clarify vs. assume.** Do not ask how to build it — explore and present the\n approach and options in the plan. Ask a clarifying question only when an\n ambiguity would change the design and you cannot resolve it from the code; use\n the host agent's normal ask-user-question flow and batch 2-4 high-leverage\n questions before finalizing. Do not call \\`create-visual-questions\\` from\n \\`/visual-plan\\`. Otherwise state the assumption explicitly and proceed, and\n keep anything unresolved in the plan's single bottom \\`question-form\\` Open\n Questions block. For complex plans, do a final open-question pass before\n handoff: if a decision would affect architecture, scope, UX, data shape, or\n rollout, either decide it in the plan with rationale or put it in that bottom\n form with a recommended default.\n- **The plan is the approval gate.** After surfacing it, ask the user to review\n and approve before you write code, and name which files/areas the work touches.\n Presenting the plan and requesting sign-off is the approval step — do not ask a\n separate \"does this look good?\" question.\n- **The document is the source of truth, not the chat.** When scope shifts,\n update the plan with \\`update-visual-plan\\` rather than only changing course in\n chat, and make the updated document stand alone. Do not describe the update as\n a correction to an earlier draft inside the plan itself. Re-read the approved\n plan before major steps.\n\n## Always Publish As An Agent-Native Plan — Never Inline\n\nThe deliverable is ALWAYS a published Agent-Native Plan created via the Plan\nMCP connector (\\`plan\\` server, or legacy \\`agent-native-plans\\`). NEVER hand the\nplan over as inline chat content — no Markdown prose, ASCII sketch, table, or\nfenced wireframe. If the connector's tools are missing, do NOT fall back to\ninline output: the usual cause is a connector that did not finish connecting\nthis session (it registers zero tools), not auth. Stop and give the user the\nexact restore step for their current client: in Codex/Codex Desktop run\n\\`npx -y @agent-native/core@latest reconnect https://plan.agent-native.com --client codex\\`\nand start a new Codex session; in Claude Code run \\`/mcp\\` and choose\nAuthenticate/Reconnect (or run the same reconnect command with\n\\`--client claude-code\\` and restart Claude). Auth is stored per client\nconfig/session, so one client's reconnect does not make another running client\nload tools. Never reinstall from scratch just to fix auth. Publish once the tool\nis reachable. Local-files privacy mode (after Tool Guidance) is the only\nexception.\n\n## Core Workflow\n\n1. Follow the host agent's normal planning flow: inspect the codebase, delegate\n wide exploration when useful, gather the info needed, and ask native\n clarifying questions as needed before generating the plan. If a source plan\n already exists, gather its exact text from the user's paste, a referenced\n file, or recent visible agent context; do not invent source text.\n2. Call \\`get-plan-blocks\\` for the authoritative block catalog — do not author\n from memorized tags. Then call the mode-matched create tool:\n \\`create-visual-plan\\` for document-first plans (architecture, backend, data,\n refactor, API), \\`create-ui-plan\\` for UI-first plans, \\`create-prototype-plan\\`\n for prototype-first plans, \\`create-plan-design\\` for design-first plans,\n \\`create-visual-questions\\` only when the user explicitly asks for a visual\n intake questionnaire. When a source plan already exists,\n pass it as \\`planText\\` and preserve the original plan's useful intent while\n producing a standalone plan document, not a revision memo.\n3. For UI/product plans, compose the top canvas first with the primary\n wireframes and annotated states, then write the document with native blocks\n (see \\`references/canvas.md\\` and \\`references/document-quality.md\\`). For\n broad product architecture plans with a user-facing implication, add a\n concrete \"what this looks like in the app\" visual before the abstract\n architecture or mode tables. Keep the document close to the standalone\n Markdown plan the agent would normally output. If an existing plan was\n provided, carry forward the right facts and decisions without referring to\n the previous draft or explaining how this version differs. For non-visual\n plans, skip the top visual surface (Visual Surface Choice below owns the rule)\n and put \\`diagram\\`, \\`data-model\\`,\n \\`api-endpoint\\`, \\`diff\\`, \\`file-tree\\`, \\`code\\`, and \\`annotated-code\\` blocks\n directly next to the relevant prose.\n4. Surface the returned Plans link or inline MCP App and ask the user to review.\n Always include the actual URL in chat so the next step is a click in CLI or\n other text-only hosts. When the host exposes an embedded browser/preview panel\n and a tool can open arbitrary URLs there, open the returned plan URL\n automatically for convenient review — a convenience and smoke test, never the\n only handoff or the access\n model. Plans should load out of the box for the local agent and local browser\n session; if a signed-in embedded browser cannot read a local plan that an\n anonymous/tool check can read, fix the app/action ownership or access path\n rather than patching one plan by hand. For high-stakes plans (architecture,\n backend, data, multi-file, or risky), also kick off the self-review pass in\n **Self-Review Before Handoff** while the user reads, instead of blocking the\n handoff on it.\n5. Call \\`get-plan-feedback\\` before editing, after review, after any long pause,\n and before the final response. Treat \\`anchorDetails\\`, resolver intent, recent\n review events, and any focused screenshots from browser handoff as the source\n of truth for exactly what changed and exactly what each comment points at.\n6. Apply changes with \\`update-visual-plan\\`, preferring targeted \\`contentPatches\\`.\n Treat the top-level \\`content\\` payload as a full replacement, not a merge; do\n not send a partial \\`content\\` object to add a canvas or one block. If a full\n replacement is unavoidable, first read the complete plan source/content, carry\n forward every existing block and visual surface, and verify the source/export\n afterward so the document body was not truncated. When the user wants\n source-control friendly edits, use \\`patch-visual-plan-source\\` against the MDX\n files instead of regenerating the plan.\n7. Export with \\`export-visual-plan\\` only when the user wants a shareable receipt\n or repo-check-in artifacts.\n\n## Self-Review Before Handoff\n\nFor high-stakes plans — architecture, backend, data-model, migration, multi-file,\nor otherwise risky work — run one adversarial self-review pass before treating the\nplan as final. Skip it for small, UI-only, or single-decision plans where the cost\noutweighs the value. Keep the pass cheap and non-blocking:\n\n- **Surface the plan first, review concurrently.** Post the link and let the user\n start reading, then run the review in parallel — never make the user wait on it.\n- **Review the written plan; do not re-research.** Critique the plan text and its\n own blocks. The grounding was already done while drafting, so the review checks\n the output instead of re-exploring the repo.\n- **Spawn one skeptical reviewer** whose only job is to find what is weak, missing,\n or wrong — not to praise. Point it at: hard-to-reverse decisions made implicitly\n or not at all (wire format, public ids, data-model shape, auth, ownership); steps\n not anchored in real files or symbols; a menu of options where the plan should\n commit to one; obvious missing decisions (\"what happens when X?\", \"why not Y?\");\n and padding or single-step filler.\n- **Fix vs. ask.** Apply clear-cut fixes yourself with \\`update-visual-plan\\`\n \\`contentPatches\\` — vague non-goals, unanchored claims, an obvious missing\n decision. Route genuine judgment calls back to the user instead: add them to the\n bottom \\`question-form\\` Open Questions block or batch them into the normal\n ask-user-question flow. Do not silently decide them.\n- **Do not surprise the user mid-read.** On a large plan, apply the patches before\n the editor loads; otherwise note briefly that a self-review is running so the\n plan changing under them is expected. When you next respond, summarize what the\n review changed and what it surfaced for the user to decide.\n\n## Visual Surface Choice\n\nChoose the surface before creating the plan or after reading the source plan. Do\nnot add visual chrome by default:\n\nFor UI/product plans, the top canvas is usually the primary review surface. Put\nthe first meaningful wireframes there, not buried as document-body blocks. Use\nmultiple canvas artboards when states matter, such as the default view, an\noverflow menu or popover, a side panel, loading, or error. Put short annotations\nbeside frames with \\`targetId\\` plus \\`placement\\`; keep implementation details,\ntradeoffs, file maps, data contracts, risks, and verification in the document\nbody below the canvas.\n\nKeep product wireframes and explanatory/meta diagrams separate. Start with pure\nscreens that look like the app state under discussion, without callout prose or\narchitecture notes embedded inside the UI. Put arrows, labels, contracts, data\nflow, and mode explanations in separate annotations, separate canvas diagrams,\nor the document body.\n\nWhen the plan touches an existing app, inspect the current shell/components\nbefore drawing. The first artboard should look like the real app at the same\ndensity: existing sidebars, toolbar placement, overflow menus, app chrome, and\nframework agent chrome stay in their real places. Model secondary surfaces as\nseparate states, such as a top-right overflow popover, sheet, panel, loading\nstate, or separate AgentSidebar, rather than inventing a permanent inspector or\nfolding framework chrome into the product UI.\n\n- **No visual surface** for architecture-only, backend-only, data migration,\n copy-only, or otherwise non-visual plans. Do not use the top canvas for\n architecture diagrams, dependency maps, file plans, API contracts, or\n data-flow-only reviews. Use a strong document with local inline diagrams\n only when relationships need a visual explanation, usually one spatial diagram\n per recommendation or decision. Prefer grouped regions, layers, quadrants,\n matrices, or before/after panels over a single-axis chain unless the\n relationship is truly sequential.\n- **Canvas only** for one static screen, a before/after comparison, a component\n state, a small popover, or a visual direction that does not require clicking.\n Put those wireframes in \\`content.canvas\\` and omit \\`content.prototype\\`.\n- **Canvas + prototype** for multi-step UI flows, onboarding, wizards,\n review/approval flows, navigation changes, or anything where the reviewer\n needs to operate the behavior. Keep the static wireframes in\n \\`content.canvas\\`, add the aligned functional prototype in\n \\`content.prototype\\`, and rely on the top visual tabs to switch between them.\n- **Prototype-first** when the user asks to operate the UI or when interaction is\n the main question. Use \\`create-prototype-plan\\`, which still preserves static\n mocks where useful.\n\nFor mixed canvas + prototype plans, reuse the same real labels, app statuses,\nand screen ids across both surfaces. The canvas is the inspectable static reference;\nthe prototype is the interactive version of that same flow, not a separate\ndesign direction.\n\n## Wireframe quality — read \\`references/wireframe.md\\`\n\nUI recap/plan wireframes must meet a strict quality bar — full-width chrome,\npinned bottom bars, real product content, before/after comparability, the right\n\\`surface\\` preset, \\`--wf-*\\` tokens instead of hex, and no \\`<html>\\`/\\`<style>\\`/font\ntags. Before authoring ANY wireframe / \\`<Screen>\\` / \\`WireframeBlock\\`, READ\n\\`references/wireframe.md\\` in this skill directory — it is the single source of\ntruth for HTML wireframe quality, shared word for word with \\`/visual-plan\\`\nand \\`/visual-recap\\`. Do not author wireframes from memory.\n\n## Canvas — read \\`references/canvas.md\\`\n\nThe canvas is the single source of truth for static UI mockups: the \\`surface\\`\nlocks each artboard's footprint, mixed surfaces lay out\nin lanes, annotations are plain-text designer notes anchored by\n\\`targetId\\`/\\`placement\\`, and edits are surgical \\`contentPatches\\`. Before\nauthoring or editing ANY canvas, artboard, or annotation, READ\n\\`references/canvas.md\\` in this skill directory — it is the single source of truth\nfor canvas/artboard mechanics. Do not author canvas layouts from memory.\n\n## Document quality — read \\`references/document-quality.md\\`\n\nThe document is a serious technical plan, not marketing: outcome-first,\nprose-first, self-contained, built from the right native blocks, with open\nquestions in a single bottom \\`question-form\\` and a pre-handoff visual check.\nBefore authoring the plan document, READ \\`references/document-quality.md\\` in this\nskill directory — it is the single source of truth for the document quality bar.\nDo not write the document from memory.\n\n## Good vs. bad exemplar — read \\`references/exemplar.md\\`\n\nFor a worked example of the bar — a great UI-first plan and \\`/visual-plan\\`, plus\nthe anti-patterns to avoid — READ \\`references/exemplar.md\\` in this skill\ndirectory before authoring a plan.\n\n## Tool Guidance\n\n- \\`create-visual-plan\\`: start one structured visual plan per agent task/run, or\n import an existing text plan by passing \\`planText\\`; \\`content\\` may include no\n visual surface, canvas only, or canvas + prototype.\n- \\`create-ui-plan\\`: start a UI-first plan when the work is primarily product UI.\n- \\`create-prototype-plan\\`: start a prototype-first plan with a functional top\n review surface.\n- \\`create-plan-design\\`: start a full-fidelity branded Design-tab plan with an\n optional matching Prototype tab.\n- \\`convert-visual-plan-to-prototype\\`: convert an existing HTML wireframe canvas\n into a prototype plan.\n- \\`create-visual-questions\\`: use only when the user explicitly asks for a visual\n intake questionnaire, not as \\`/visual-plan\\` preflight.\n- \\`update-visual-plan\\`: revise content, status, or comments with targeted\n \\`contentPatches\\` (see Core Workflow step 6).\n- \\`read-visual-plan-source\\`: read the normalized plan as \\`plan.mdx\\`,\n optional \\`canvas.mdx\\`, optional \\`.plan-state.json\\`, and JSON.\n- \\`patch-visual-plan-source\\`: apply granular MDX AST patches by stable block,\n artboard, annotation, component, or wireframe-node id.\n- \\`import-visual-plan-source\\`: create or replace a plan from an MDX folder.\n- \\`get-visual-plan\\`: read the current structured plan, exported HTML, and\n annotations; it also returns the MDX folder for source workflows.\n- \\`get-plan-feedback\\`: read unconsumed human feedback. Use it frequently; it\n returns grouped threads, exact anchor details, expected resolver, and recent\n review-event payloads so agents can act only on the comments meant for them.\n- \\`get-plan-blocks\\`: resolve block tags before authoring — do not memorize tags;\n call this first to get the authoritative tag names, required fields, and prop\n shapes from the live block registry.\n- \\`export-visual-plan\\`: export HTML, Markdown fallback, structured JSON, and MDX\n files for repo check-in.\n\nWhen the user critiques a plan's look or structure, fix the renderer or this\nskill — never hand-edit one stored plan. Turn feedback into better guidance.\n\n## Local-Files Privacy Mode\n\nUse local-files privacy mode when the user explicitly asks for no DB writes,\nno hosted Plan app, no Plan MCP publish, fully local files, offline/private\nplanning, or when \\`AGENT_NATIVE_PLANS_MODE=local-files\\` is set. In this mode the\nplan data must never be sent to the Plan MCP server or Plan app action surface.\n\nThe local-files contract is:\n\n- Read source context from local files and shell commands only.\n- Write the plan as a local MDX folder under \\`plans/<slug>/\\`: \\`plan.mdx\\`,\n optional \\`canvas.mdx\\`, optional \\`prototype.mdx\\`, and optional\n \\`.plan-state.json\\`.\n- Run \\`npx @agent-native/core@latest plan local preview --dir plans/<slug> --kind plan\\` after\n writing or updating the folder. Report the returned local URL or the\n \\`/local-plans/<slug>\\` route if the local Plan app is running with the same\n \\`PLAN_LOCAL_DIR\\`.\n- Do **not** call \\`create-visual-plan\\`, \\`create-ui-plan\\`,\n \\`create-prototype-plan\\`, \\`create-plan-design\\`, \\`import-visual-plan-source\\`,\n \\`update-visual-plan\\`, \\`patch-visual-plan-source\\`, \\`get-plan-feedback\\`,\n \\`export-visual-plan\\`, or any hosted Plan tool for that plan.\n- Treat feedback as file or chat feedback: update the MDX files directly, rerun\n the local preview command, and summarize the new local URL/path. Hosted\n comments, sharing, history, and publish/export receipts are unavailable until\n the user explicitly opts into publishing.\n\nLocal-files mode prevents plan content from going to the Agent-Native Plan\ndatabase. It does not by itself make the coding agent's language model local;\nfor that stronger privacy boundary, the host agent/model must also be local or\notherwise approved by the user.\n\n## Interpreting comment anchors\n\n\\`get-plan-feedback\\` returns rich anchors — read them before acting on any comment.\n\n- **Coordinate frames.** \\`targetX\\`/\\`targetY\\` are percentages *within* the\n element named by \\`targetSelector\\`/\\`targetKind\\`. Bare \\`x\\`/\\`y\\` are percentages\n of the whole plan document. \\`canvasX\\`/\\`canvasY\\` are raw board-world pixels on\n the design canvas (board size given when available).\n- **Wireframe pins.** Anchors on wireframes include \\`targetNodeId\\` and\n \\`targetNodePath\\` (e.g. \\`card > list > listItem \"Acme Inc\"\\`) identifying the\n exact kit node. Use \\`targetNodeId\\` directly with wireframe node patch ops;\n use \\`data-design-id\\` values from design artboards with\n \\`update-design-element-style\\`. Prefer the node id/path over raw coordinates;\n fall back to coordinates plus the focused screenshot (red ring marks the exact\n point) only when no node id is present.\n- **Text quotes.** Resolve \\`textQuote\\` against current prose using\n \\`contextBefore\\`/\\`contextAfter\\` for disambiguation. If \\`ambiguous: true\\`, ask\n the user — do not guess which occurrence is meant.\n- **Detached comments.** \\`get-plan-feedback\\` flags threads whose quoted text no\n longer exists as \\`detached\\` (in \\`detachedThreads\\`). Reconcile these against\n rewritten content — never silently drop them.\n- **Routing.** \\`resolutionTarget\\` is the only routing signal: act on \\`agent\\`,\n treat \\`human\\` as context only. \\`@mentions\\` are people to notify, never a\n routing signal.\n- **Two-axis state.** Mark every ingested comment as consumed\n (\\`consumedCommentIds\\` on \\`update-visual-plan\\`). Set \\`status=resolved\\` only on\n agent-targeted comments you actually addressed; leave human-targeted comments\n open.\n\n## Visibility & Sharing\n\nUse \\`set-resource-visibility\\` to change who can see a plan (e.g. public, login,\nor org-scoped). Use \\`share-resource\\` to grant specific users or roles access\nby email or role. Gate visibility before sharing any plan that covers\nunreleased or private work — default to the narrowest scope that meets the\nreview need.\n\n## Setup & Authentication\n\nThere are two ways into Plans.\n\n**Coding agent (CLI).** Install once with the Agent-Native CLI. The command\ninstalls the Plans skills, registers the hosted Plans MCP connector, and runs\nauth/setup for the selected local client(s) in the same step (a one-time browser\nsign-in at setup — this is intended), so the first tool call in that client does\nnot hit an OAuth wall:\n\n\\`\\`\\`bash\nnpx @agent-native/core@latest skills add visual-plan\n\\`\\`\\`\n\nAfter that, \\`/visual-plan\\` and \\`/visual-recap\\` are the two installed slash\ncommands. The other planning modes (\\`create-ui-plan\\`, \\`create-prototype-plan\\`,\n\\`create-plan-design\\`, \\`create-visual-questions\\`) are MCP tools reachable from\n\\`/visual-plan\\`, not separate slash commands. Pass \\`--no-connect\\` to register\nthe connector without authenticating, then run\n\\`npx @agent-native/core@latest connect https://plan.agent-native.com --client all\\`\nwhenever you are ready, or choose a narrower \\`--client\\`. Auth and MCP tool\nloading are per client config/session.\n\n**Browser (people you share with).** Open the Plans editor and create & edit\nwith no sign-up — you work as a guest. Sign in only when you want to save or\nshare; signing in claims the plans you made as a guest into your account.\n\nSharing and commenting require an account: public/shared plans are viewable by\nanyone with the link, but commenting on them needs an agent-native account.\n\nFor fully offline, no-account use, run the Plans app locally and sync plans to\nyour repo as MDX. This local mode is a separate advanced path, not the default\nhosted flow.\n\nIf a Plans tool returns \\`needs auth\\`, \\`Unauthorized\\`, or \\`Session terminated\\`,\ndo not keep retrying the tool. Stop and give the user the reconnect step for the\nclient they are using: Codex/Codex Desktop should run\n\\`npx -y @agent-native/core@latest reconnect https://plan.agent-native.com --client codex\\`\nand start a new Codex session; Claude Code should run \\`/mcp\\` and choose\nAuthenticate/Reconnect for the plan connector, or run the reconnect command with\n\\`--client claude-code\\` and restart Claude. To refresh every local client config\nthat already has the Plan entry, use \\`--client all\\`, then restart/reload each\nclient. Reconnect re-authenticates WITHOUT reinstalling and finds the entry by\nURL regardless of connector name. Never reinstall from scratch just to fix auth.\nContinue once the connector is available.\n\nHosted default: connect \\`https://plan.agent-native.com/_agent-native/mcp\\`. Do\nnot put shared secrets in skill files.\n`;\n\nexport const VISUAL_RECAP_SKILL_MD = `---\nname: visual-recap\ndescription: >-\n Turn a PR, branch, commit, or git diff into an interactive visual recap with\n diagrams, file maps, API/schema summaries, annotated diffs, and focused review\n notes.\nmetadata:\n visibility: exported\n---\n\n# Visual Recap\n\n\\`/visual-recap\\` creates a visual plan built **from** a diff, not toward one. It\nis the reverse of forward planning: instead of describing the change you are\nabout to make, you describe the change that was just made, at a higher altitude\nthan line-by-line review. The same plan data model serves both directions —\nschema, API, file, and architecture changes become the same \\`data-model\\`,\n\\`api-endpoint\\`, \\`file-tree\\`, and \\`diagram\\` blocks a forward plan would use, only\nnow they summarize work that exists. A reviewer scans the shape of the change\nbefore spending attention on the literal lines.\n\n## Local-Files Privacy Mode Exception\n\nUse local-files privacy mode when the user explicitly asks for no DB writes,\nno hosted Plan app, no Plan MCP publish, fully local files, offline/private\nrecaps, or when \\`AGENT_NATIVE_PLANS_MODE=local-files\\` is set. This is the only\nexception to the hosted publish rule below.\n\nIn local-files mode:\n\n- Read the diff/stat/source context from local files and shell commands only.\n The existing \\`npx @agent-native/core@latest recap collect-diff\\`, \\`scan\\`, and\n \\`build-prompt --local-files\\` helpers are safe to use because they operate on\n local files and do not write to the Plan database.\n- Write the recap as a local MDX folder under \\`plans/<slug>/\\`: \\`plan.mdx\\`,\n optional \\`canvas.mdx\\`, optional \\`prototype.mdx\\`, and optional\n \\`.plan-state.json\\`. Set \\`kind: \"recap\"\\` and \\`localOnly: true\\` in\n frontmatter/state when authoring the source.\n- Run \\`npx @agent-native/core@latest plan local preview --dir plans/<slug> --kind recap\\` after\n writing or updating the folder. Report the returned local URL or the\n \\`/local-plans/<slug>\\` route if the local Plan app is running with the same\n \\`PLAN_LOCAL_DIR\\`.\n- Do **not** call \\`create-visual-recap\\`, \\`create-visual-plan\\`,\n \\`import-visual-plan-source\\`, \\`update-visual-plan\\`,\n \\`patch-visual-plan-source\\`, \\`get-plan-feedback\\`, \\`export-visual-plan\\`,\n \\`set-resource-visibility\\`, or any hosted Plan tool for that recap.\n- Treat review feedback as file or chat feedback: update the MDX files directly,\n rerun the local preview command, and summarize the new local URL/path.\n Hosted comments, sharing, screenshots, usage attachment, and PR sticky comment\n publishing are unavailable until the user explicitly opts into publishing.\n\nLocal-files mode prevents recap content from going to the Agent-Native Plan\ndatabase. It does not by itself make the coding agent's language model local;\nfor that stronger privacy boundary, the host agent/model must also be local or\notherwise approved by the user.\n\n## Always Publish As An Agent-Native Plan — Never Inline\n\nThe deliverable is ALWAYS a published Agent-Native Plan, created with the\n\\`create-visual-recap\\` tool on the Plan MCP connector. The connector is usually\nexposed as the \\`plan\\` server, but older installed agents may expose the same\nhosted connector as \\`agent-native-plans\\`; both names are valid. NEVER hand the\nrecap to the user as inline chat content — not Markdown prose, not an ASCII\nsketch, not a table, not a fenced \"wireframe\", not a \"here's the recap\" summary.\nA recap's entire value is the hosted, interactive, annotatable plan; an inline\nsummary is not a recap, it is the thing a recap replaces. The only supported\noutput is to publish the plan and return its absolute URL.\n\nExcept for the explicit local-files privacy mode above, if neither the \\`plan\\`\nnor legacy \\`agent-native-plans\\` Plan MCP tools are available, do NOT improvise an\ninline recap as a fallback. Do not report the connector as disconnected just\nbecause it is named \\`agent-native-plans\\` instead of \\`plan\\`. The usual cause is a\nconnector that did not finish connecting this session (it registers zero tools),\nNOT necessarily an auth problem — so do not assume the user must authenticate.\nStop and tell the user how to restore it for their current client: in\nCodex/Codex Desktop, run\n\\`npx -y @agent-native/core@latest reconnect https://plan.agent-native.com --client codex\\`\nand start a new Codex session; in Claude Code, run \\`/mcp\\` and choose\nAuthenticate/Reconnect, or run the reconnect command with \\`--client claude-code\\`\nand restart Claude. Auth is stored per client config/session; \\`--client all\\`\nrefreshes every local client config that already has the Plan entry, but each\nrunning client still has to reload its MCP tools. Reconnect re-authenticates\nWITHOUT reinstalling and finds the entry by URL regardless of connector name.\nNever reinstall from scratch just to fix auth. Then publish once the tool is\nreachable. Falling back to inline content is a defect, not a degraded mode.\n\n## When To Use\n\nBuild a recap when a PR or commit is large, multi-file, or touches schema, API\ncontracts, or architecture, and a reviewer would benefit from seeing the change\nmapped to structured blocks before reading the raw diff. A GitHub Action can\ngenerate one automatically from a PR diff; an agent can generate one on request\n(\"recap this PR\", \"show me what this branch changed\"). Skip it for small,\nsingle-file, or obvious diffs — a recap is review overhead, and a tiny change\nreviews faster as plain diff.\n\n## Recap The Whole Work Unit\n\nWhen \\`/visual-recap\\` is invoked in a chat thread after work has already happened,\nthe default scope is the whole current work unit/thread, not only the most recent\nuser message, tool action, or follow-up fix. Gather the thread-owned changes\nacross the conversation: original implementation work, later bug fixes, UI\nfollow-ups, tests, changesets, skill/instruction updates, generated plan/source\nartifacts, and any local import/linking fixes needed to make the recap open.\n\nUse the current diff plus conversation context to separate thread-owned changes\nfrom unrelated dirty work that existed before the thread. Exclude unrelated\npre-existing edits. If the scope is genuinely ambiguous and cannot be inferred,\nstate the assumption or ask a concise question before publishing.\n\nWhen updating an existing recap after feedback, revise the recap so it still\ncovers the whole thread/work unit plus the new correction. Do not replace a broad\nrecap with a narrow recap of only the latest feedback unless the user explicitly\nasks for that narrower scope.\n\n## Keep The Recap Body Lean\n\nDo not add boilerplate intro, disclaimer, provenance, or summary prose blocks to\nthe generated plan body. In particular, do not create a \\`rich-text\\` block just to\nsay the recap is an aid, that the reviewer should still review the diff, how many\nfiles changed, or which ref/working tree generated the recap. The plan title,\nbrief, and \\`file-tree\\` (which carries the per-file change stats) already carry\nthat context.\n\nOnly add prose blocks when they tell the reviewer something specific about the\nchange that the structured blocks do not: the objective, a real compatibility\nrisk, an important decision visible in the diff, or a grounded review note.\n\n## Recaps Must Be Substantial\n\nLean is not the same as thin. A recap is not a single wireframe plus one\nsentence — that under-serves the reviewer as much as boilerplate prose over-serves\nthem. Alongside the visual/structural headline (wireframes, \\`data-model\\`,\n\\`api-endpoint\\`, \\`diagram\\`), a substantial recap also carries the implementation\nevidence:\n\n- A short surface/state inventory before authoring: list the changed routes,\n components, popovers/dialogs, role/access states, empty/error states, and\n shared abstractions visible in the diff. The final recap must either represent\n each meaningful item with a block or intentionally omit it because it is tiny,\n redundant, or not user-visible.\n- A \\`file-tree\\` of the changed files with each entry's \\`change\\` flag, so the\n reviewer sees the footprint of the work at a glance.\n- The split \\`diff\\` of the KEY changed files, grouped under a \\`## Key changes\\`\n \\`rich-text\\` heading in a single horizontal \\`tabs\\` block (the default\n orientation, one file per tab), with a one-line \\`summary\\` and a few\n \\`annotations\\` on each — so the reviewer can drop from the high-altitude shape\n straight into the load-bearing code. Use horizontal file tabs, not a vertical\n side rail, so the selected file has enough width for the side-by-side diff.\n\nSkip the diff appendix only for a genuinely tiny change that reviews faster as\nplain diff (see \"When To Use\"); for any change worth recapping, the file-tree and\nkey-change diffs belong in the plan.\n\n## Canonical Shape And Budgets\n\nA strong recap follows one skeleton, top to bottom:\n\n1. UI-impact headline — wireframes first, when the diff changed rendered UI.\n2. Short outcome narrative (\\`rich-text\\`): what changed and why, 1-3 paragraphs.\n3. \\`data-model\\` / \\`api-endpoint\\` blocks for schema and contract changes.\n4. \\`file-tree\\` of the changed files with \\`change\\` flags.\n5. \\`## Key changes\\` — one horizontal \\`tabs\\` block of \\`diff\\` / \\`annotated-code\\`.\n\nBudgets that keep the recap reviewable:\n\n- 3-8 key-change tabs. Fewer than 3 on a large change under-serves the\n reviewer; more than 8 stops being a summary.\n- Keep each diff/annotated-code excerpt focused — prefer under ~150 lines per\n tab; summarize or link the rest of a long file instead of dumping it.\n- Title at most ~70 characters; brief 1-3 sentences.\n\n**GOOD.** A 25-file auth change: Before/After wireframes of the login surface,\na two-paragraph narrative, a diff-aware \\`data-model\\` of the sessions table, an\n\\`api-endpoint\\` for the new refresh route, a \\`file-tree\\` with change flags, and\n\\`## Key changes\\` with five focused tabs, each with a one-line \\`summary\\` and a\nfew annotations on the load-bearing hunks.\n\n**BAD.** One giant unsegmented diff dump with no summaries or annotations; or a\nsparse three-block recap of a 40-file change (one wireframe, one sentence, one\nfile list) that forces the reviewer back into the raw diff anyway.\n\n## UI Impact Needs Wireframes\n\nWhen the diff changes rendered UI, layout, density, visual state, interaction\naffordances, navigation, controls, menus, dialogs, or design tokens, the recap\nMUST include one or more wireframes. Prose and file diffs are not a substitute\nfor showing what changed visually.\n\nBefore choosing wireframes, make a UI coverage pass from the diff:\n\n- Identify the entry surface where the change appears, such as a page header,\n list row, toolbar, route shell, or menu trigger.\n- Identify the interaction surface that opens or changes, such as a popover,\n dialog, tab, sheet, dropdown, inline editor, or toast.\n- Identify the resulting destination or persistent state, such as a public page,\n read-only view, empty state, error state, loading state, permission-denied\n state, or saved/shared state.\n- Identify access or role variants when permissions change. Owner/admin/editor\n versus viewer/non-manager differences are visual behavior and need a compact\n matrix, paired wireframes, or clearly labeled state sequence.\n\nFor UI-heavy PRs, a single before/after of the entry surface is not enough.\nShow the changed entry point, the main changed interaction surface, and the\nresulting/destination state. Add more states when the diff adds tabs, role-based\ncontrols, public/private visibility, invite/manage flows, destructive controls,\nor empty/error branches.\n\nChoose the smallest visual surface that makes the review clear:\n\n- Use a \\`Before\\` / \\`After\\` wireframe pair when the reviewer benefits from direct\n comparison, such as a removed or added control, a changed state, layout\n density, ordering, navigation, or a visible component replacement.\n \\`references/wireframe.md\\` owns how to lay that pair out (columns vs.\n vertical stack by geometry).\n- Use an after-only wireframe when the change is purely additive or the \"before\"\n state would only show absence without adding review value.\n- Use more than two wireframes when the UI change is flow-dependent, responsive,\n or stateful; show the meaningful states in order instead of forcing a single\n before/after pair.\n- For tiny surfaces like menus, popovers, dialogs, toasts, or panels, use the\n matching \\`surface\\` (\\`popover\\`, \\`panel\\`, etc.) and show the focused sub-surface.\n Do not redraw a full page unless placement in the page is itself part of the\n change.\n\nGround each wireframe in the changed UI behavior, component names, file paths,\nand diff-visible labels/states. If exact pixels are inferred rather than\ncaptured, say so in the wireframe caption or a concise annotation. For\nlocal/manual recaps, import or update the plan source that holds the wireframes\nso the rendered recap opens with the UI visual available.\n\n## Wireframe Quality — read \\`references/wireframe.md\\`\n\nUI recap/plan wireframes must meet a strict quality bar — full-width chrome,\npinned bottom bars, real product content, before/after comparability, the right\n\\`surface\\` preset, \\`--wf-*\\` tokens instead of hex, and no \\`<html>\\`/\\`<style>\\`/font\ntags. Before authoring ANY wireframe / \\`<Screen>\\` / \\`WireframeBlock\\`, READ\n\\`references/wireframe.md\\` in this skill directory — it is the single source of\ntruth for HTML wireframe quality, shared word for word with \\`/visual-plan\\`\nand \\`/visual-recap\\`. Do not author wireframes from memory.\n\nUse the standard \\`WireframeBlock\\` / \\`<Screen>\\` format so the Plan viewer owns the\nsurface frame, theme, and sketchy/clean toggle. HTML wireframes are appropriate\nwhen placement precision matters, especially popovers, menus, dialogs, and dense\nforms. For HTML\nwireframes, keep \\`renderMode\\` unset or \\`wireframe\\` unless a design-only editable\nmockup is explicitly required, because \\`renderMode=\"design\"\\` disables the\nsketchy rough overlay.\n\nWhen a browser tool is available, render a UI-impact recap in the Plan viewer\nand visually inspect it at the current theme before sharing. If any label,\nannotation, toolbar, or wireframe content overlaps another element, fix the MDX\nand re-import before reporting the link. A text-match screenshot is not enough;\nvisually inspect the captured image. When no browser is available (for example\na headless CI agent), state that in the recap handoff instead.\n\n## Open And Report The Recap\n\nIn local-files privacy mode, report the local preview URL/path from\n\\`npx @agent-native/core@latest plan local preview\\` or the \\`/local-plans/<slug>\\` route for a local\nPlan app using the same \\`PLAN_LOCAL_DIR\\`. Do not invent a hosted URL and do not\npublish just to get an absolute Plan link.\n\nAfter creating the recap, link the reviewer to the rendered plan with an\n**absolute URL on the origin whose database actually holds the plan**. That\norigin is the Plan MCP server you just created the recap through — NOT whatever\ndev server you happen to know is running. The create tool returns the correct\nlink; report THAT. Never make the primary link a local \\`plan.mdx\\` file, a local\nmirror folder, or a relative path such as \\`/plans/<id>\\`.\n\nWhen the recap is posted to a PR for a private repo, the plan link is not a\npublic URL. Make the PR comment/handoff copy explicit: reviewers may need to\nsign in to Agent-Native Plans with an account that has access to the owning\norganization before the link loads. Use wording like: \"Private repo recap:\nsign in with access to this org if the plan does not open.\" Do not imply the\nlink is broken or public when access is gated by repo/org visibility.\n\nA recap lives only in the database of the MCP that created it. A separately\nrunning local dev server (e.g. \\`http://localhost:8081\\`) has its OWN database and\nwill NOT contain a recap created through the hosted MCP, so a hand-built\n\\`localhost\\` link returns \"Plan not found\". This is the most common recap\nmistake — do not guess an origin you have not confirmed shares the MCP's data.\n\nResolve the URL in this order:\n\n1. Use the absolute URL the create tool RETURNS — \\`openLink.webUrl\\`, else the\n \\`visualUrl\\` in the returned \\`plan.mdx\\` frontmatter, else \\`url\\`/\\`path\\`\n resolved against the MCP server's own origin (for the hosted MCP that is\n \\`https://plan.agent-native.com\\`). This always points at the database that has\n the plan.\n2. Use a \\`localhost\\`/dev origin ONLY when the recap was created through a Plan\n MCP bound to that same origin — i.e. that MCP's url is\n \\`http://localhost:<port>/_agent-native/mcp\\`. Creating through the hosted MCP\n and linking to localhost is the exact mismatch that 404s.\n3. If only a plan id is available, build the MCP origin's absolute URL\n (hosted: \\`https://plan.agent-native.com/plans/<id>\\`) and say it was inferred.\n\nIf the user wants to review on localhost but the recap was created through the\nhosted MCP, say so plainly: the local dev server cannot see it. To view a recap\non localhost (e.g. to exercise un-deployed local renderer changes), they must\nconnect a LOCAL Plan MCP (\\`http://localhost:<port>/_agent-native/mcp\\`) and\nre-create the recap through it so it lands in the local database; offer to do\nthat rather than handing over a localhost URL that will not resolve.\n\nWhen running in Codex and the Browser/in-app side browser tools are available,\nopen the returned absolute recap URL there automatically after creation. Still\ninclude the same absolute URL in the final response. Local mirror files like\n\\`plans/<slug>/plan.mdx\\` may be mentioned only as secondary source-control\nartifacts, not as the main way to open the recap.\n\n## Diff → Block Mapping\n\nMap each kind of change to the block that carries it, derived mechanically from\nthe actual diff. The names below are the CONCEPTUAL block types, not the JSX\ntags — resolve every conceptual name to its exact tag + prop schema with the\n\\`get-plan-blocks\\` tool (see \"Block reference\" below) before authoring.\n\n- **Schema / migration change** → \\`data-model\\` for the resulting entities,\n fields, and relations. Flag what moved per field/entity with\n \\`change: \"added\" | \"modified\" | \"removed\" | \"renamed\"\\`, and for a changed type\n set \\`was\\` to the prior value (e.g. the old column type) — grounded in the real\n migration diff. That diff-aware \\`data-model\\` is the headline; reach for a split\n \\`diff\\` of the literal SQL only when the exact statement still matters, not by\n default.\n- **API / action / route change** → \\`api-endpoint\\` with the method, path,\n params, request, and responses as they are after the change. Flag each changed\n param/response with \\`change\\` (and \\`was\\` on a param whose type/shape changed),\n and set \\`change\\` on the endpoint root for a wholly added or removed route. Mark\n removed endpoints with \\`deprecated: true\\` and explain in prose.\n Keep multiple API endpoints in the normal single-column document flow unless\n they are an explicit before/after contract comparison.\n Author each request/response example as a SINGLE valid JSON value — one\n top-level object or array, parseable on its own — so it renders in the\n collapsible JSON explorer. Do not put \\`//\\` or \\`/* */\\` comments, prose,\n trailing commas, or two or more concatenated top-level objects inside one\n example; a non-parseable body falls back to flat text and loses the explorer.\n When an endpoint has several distinct message shapes (for example separate\n websocket frame types, or a success body versus an error body), give each its\n OWN example with its own label rather than cramming them into one body.\n- **Compatibility-sensitive change** → short \\`rich-text\\` notes beside the\n relevant \\`data-model\\` / \\`api-endpoint\\` block. Name the changed field,\n endpoint, or behavior and mark whether it is breaking, risky, or non-breaking;\n pair that note with a split \\`diff\\` for the literal lines.\n- **Any meaningful code hunk** → \\`diff\\` with \\`mode: \"split\"\\`, carrying the real\n \\`before\\` / \\`after\\` text and the \\`filename\\` / \\`language\\`. Split mode is the\n default for recap code review because before/after legibility is the point;\n use \\`mode: \"unified\"\\` only for a genuinely narrow standalone hunk where\n side-by-side would hide the code. Give every \\`diff\\` a one-line \\`summary\\`\n saying what the hunk changes and why; it renders as a description above the\n code so the reviewer reads intent first. Never leave a diff unlabeled.\n For the KEY changed files, attach \\`annotations\\` to the \\`diff\\` so the recap\n calls out what each important hunk does — this is the headline affordance for\n annotating the key files updated. Each annotation anchors to the AFTER-side\n line numbers by default (set \\`side: \"before\"\\` to point at removed lines). Keep\n it to a few high-signal notes per file, not one per line.\n When several key files each need a substantial diff, introduce the group with a\n \\`rich-text\\` heading block whose markdown is \\`## Key changes\\`, then place the\n \\`diff\\` blocks under it in a reusable \\`tabs\\` block with horizontal orientation\n (the default — omit \\`orientation\\`) so the selected file's split diff gets the\n full document width. Let that heading label the section — do NOT also set a\n \\`title\\` on the \\`tabs\\` block. Keep each tab label to the file path or a short\n basename plus directory hint.\n If the recap ends with more than one supporting diff, that trailing diff\n appendix should be one horizontal \\`tabs\\` block under its own \\`## Key changes\\`\n heading, not a stack of separate \\`diff\\` blocks.\n- **Brand-new file or a substantial added block with no meaningful \"before\"** →\n \\`annotated-code\\` rather than a one-sided split \\`diff\\`. Carry the real new code\n with its \\`filename\\` / \\`language\\` and anchor a few high-signal notes to the lines\n that matter so the reviewer reads what the new code does, not code for code's\n sake. Keep split \\`diff\\` for true before/after hunks where the removed lines\n still carry meaning, and group several annotated walkthroughs in a horizontal\n \\`tabs\\` block the same way diffs are grouped.\n- **Files added / removed / renamed** → \\`file-tree\\` with each entry's \\`change\\`\n flag (\\`added\\`, \\`removed\\`, \\`modified\\`, \\`renamed\\`) and a short \\`note\\`; attach a\n \\`snippet\\` only when one tells the reviewer something the path does not.\n- **Rendered UI / interaction change** → one or more wireframes showing the\n visible UI delta before the reviewer reads code. Use \\`Before\\` / \\`After\\`\n wireframes when the comparison clarifies the change; otherwise use after-only\n or a short state/flow sequence. Use realistic UI surfaces: for a popover\n change, show a popover with its title row, top-right actions, options/fields,\n tabs, selected/disabled states, people/lists/rows, and any opened prompt/menu\n anchored to the correct trigger. If a route was added, show the route body and\n the unavailable/empty state when the diff implements one. If permissions\n changed, show what managers can do and what viewers/non-managers see instead.\n Keep the body lean: the wireframe carries the UI story, while the file tree\n and \\`diff\\` blocks carry implementation evidence.\n- **Architecture or data-flow shift** → \\`diagram\\` with \\`data.html\\` / \\`data.css\\`\n as a two-panel before/after, layered, or swimlane layout, or \\`mermaid\\` for a\n quick graph. Use two-dimensional layouts; do not reduce a structural change to\n a left-to-right chain. Do not use \\`diagram\\` as a stand-in for rendered UI\n controls; UI changes need \\`wireframe\\` blocks.\n Author diagram HTML/CSS with the renderer-owned \\`.diagram-*\\` primitives\n (\\`.diagram-panel\\`, \\`.diagram-node\\`, \\`.diagram-pill\\`, \\`[data-rough]\\`, …) and\n the same \\`--wf-*\\` theme tokens \\`references/wireframe.md\\` defines — never\n \\`font-family\\`, hex, rgb/hsl literals, or one-off dark/light palettes.\n- **Outcome-first narrative** → \\`rich-text\\` for the \"what changed and why\" prose:\n the objective the diff served, the key decisions visible in it, and the risks a\n reviewer should weigh. This is the only place the model writes freely.\n\n## Block reference — call \\`get-plan-blocks\\`, do not memorize tags\n\nThe conceptual block names above (\\`api-endpoint\\`, \\`data-model\\`, \\`json-explorer\\`,\n\\`tabs\\`, …) are NOT the JSX tags you author with, and the exact tags, required\nfields, and prop shapes change as the block library evolves. Do not author from\nmemorized tags — they drift and silently produce a wrong tag (\\`ApiEndpoint\\`\ninstead of \\`Endpoint\\`, \\`JsonExplorer\\` instead of \\`Json\\`, \\`Tabs\\` instead of\n\\`TabsBlock\\`) that errors on import.\n\n**Before writing any structured plan content, call \\`get-plan-blocks\\` on the Plan\nMCP connector (\\`plan\\` or legacy \\`agent-native-plans\\`).** It returns the\nauthoritative, always-current block\nvocabulary generated live from the app's own block registry — the same config\nthe renderer and MDX round-trip use — so it can never be stale even if this\nSKILL.md is an old installed copy:\n\n- \\`get-plan-blocks\\` (default \\`format: \"reference\"\\`) → a compact table of every\n block's runtime \\`type\\`, exact MDX \\`<Tag>\\`, placement, and key data fields.\n This is your map from each conceptual name above to its real tag and props.\n- \\`get-plan-blocks\\` with \\`format: \"schema\"\\` → the full per-block JSON Schema\n plus a worked example for each block, when you need exact field types,\n enums, or nesting (e.g. \\`Diff.annotations\\`, \\`Endpoint.params[].in\\`,\n \\`DataModel.entities[].fields[]\\`).\n\nAuthor the recap source against the tags and schemas that call returns. The\ncomplete set of valid block-level tags is whatever \\`get-plan-blocks\\` lists;\nany other capitalized tag at the block level is rejected on import with an\n\"Unknown plan block\" / \"did you mean\" error. Lowercase HTML tags inside\n\\`rich-text\\`/markdown prose (\\`<div>\\`, \\`<span>\\`, \\`<code>\\`, \\`<br>\\`, …) are always\nfine — only capitalized component-style block tags are validated.\n\nA few recap-specific authoring rules the registry table cannot encode:\n\n- Every block takes a REQUIRED \\`id\\` (unique across the whole plan) plus the\n shared optional \\`summary\\` / \\`editable\\` envelope; give a block a heading by\n placing a \\`rich-text\\` block with a Markdown \\`###\\` heading directly above it\n (blocks no longer take a \\`title\\`).\n- \\`Endpoint\\`: prose \\`description\\` is the MDX **children** (body between the\n tags), not an attribute; for a WebSocket upgrade use \\`method=\"GET\"\\`. Each\n request/response \\`example\\` is a JSON **string** (the renderer parses it into\n the JSON explorer), so keep it a single parseable JSON value.\n- \\`TabsBlock\\`: the whole \\`tabs\\` array (including nested child blocks) is ONE\n JSON \\`tabs={[…]}\\` prop — there is NO nested \\`<Tab>\\` element.\n- \\`WireframeBlock\\`: its body is a single \\`<Screen surface ... html=… />\\` subtree\n (nested MDX, not a flat prop); \\`html\\` must be a single-quoted string or static\n template literal, never a dynamic \\`html={someVar}\\` expression. See\n \\`references/wireframe.md\\` for the HTML rules.\n- \\`Diagram\\`: the whole payload is one \\`data={{ html?, css?, nodes?, edges?, … }}\\`\n attribute and requires either \\`html\\` or at least one node; \\`Mermaid\\` is its\n own separate block (\\`source\\` text), not a \\`Diagram\\` prop.\n\n## Before / After Is The Headline\n\nThe recap's center of gravity is the before/after comparison. For document-body\ncomparisons there are two primitives, and they cover the whole need together:\n\n- **\\`columns\\`** — the side-by-side container, for **structured** comparisons.\n Use two columns labeled \\`Before\\` and \\`After\\`, each holding a block (commonly a\n \\`data-model\\`, \\`api-endpoint\\`, or \\`rich-text\\`), so the reviewer reads the old\n shape against the new shape in one glance. This is the right primitive for\n \"the schema went from X to Y\" or \"the endpoint contract changed like this.\"\n Do not use \\`columns\\` simply to compact or group a list of API endpoints.\n- **\\`diff\\`** — for **code**. It renders the literal removed and added lines. Use\n it for the actual hunks. Use split mode by default for recap code review;\n reserve \\`mode: \"unified\"\\` for genuinely narrow standalone hunks where\n side-by-side would hide the code. Key-file diff groups should use horizontal\n tabs so split diffs get the full document width.\n\nFor UI diffs, wireframes are the visual comparison primitive. Use before/after\nwireframes when the comparison clarifies the change; use after-only or a state\nsequence when that better matches the change. The visual headline must show\nexact placement, realistic chrome, and adequate padding before any abstract\nexplanation. Do not stop at the first visible affordance when the diff adds a\nflow; show the entry point, the opened surface, and the resulting state or page\nso the reviewer can trace the actual user path. \\`references/wireframe.md\\` owns\nthe before/after layout choice —\nthe \\`columns\\` renderer keeps narrow surfaces side by side and auto-stacks wide\n\\`desktop\\`/\\`browser\\` frames vertically; never hand-build a side-by-side\nwireframe layout in \\`custom-html\\`. For document-body\ncomparisons, there is no other multi-column primitive — \\`columns\\` plus the\n\\`diff\\` block are the whole comparison vocabulary. Do not hand-build side-by-side\nlayouts in \\`custom-html\\`, and do not stack two \\`data-model\\` blocks vertically\nand call it a comparison when \\`columns\\` exists to put them side by side.\n\n## Grounding Rule\n\nStructured blocks are **true by construction** only if they are derived from the\nactual changed lines. The \\`diff\\`, \\`data-model\\`, \\`api-endpoint\\`, and \\`file-tree\\`\nblocks MUST be built mechanically from the real diff — real paths, real fields,\nreal method/path, real before/after text — never inferred, rounded, or invented.\nThe model writes only the prose: the \"why\", the narrative, the risk read. A\nconfidently wrong recap is dangerous in a review context, because a reviewer who\ntrusts the summary may skip the very line the summary got wrong. When the diff\ndoes not contain a fact, leave it out rather than guess; mark anything the model\ninferred (not extracted) as inferred in prose.\n\n## Security\n\n- **Gate visibility.** Recaps of a private repo are org/login-gated — set the\n plan's visibility to the owning org or login, never auto-public. A recap can\n expose unreleased schema, internal endpoints, and architecture; treat it like\n the source it summarizes. Any PR comment or handoff that links to the recap\n must say that private-repo recaps require signing in with access to the owning\n org if the link does not load.\n- **Never transcribe secrets.** A diff can contain API keys, tokens, webhook\n URLs, signing secrets, \\`.env\\` values, or credential-looking literals. Do not\n copy any of these into a \\`diff\\`, \\`file-tree\\` snippet, \\`api-endpoint\\`, or prose\n block — redact them (\\`sk-•••\\`, \\`<redacted>\\`). This mirrors the repo's\n hardcoded-secret rule: obviously fake placeholders only, never the real value,\n in any block, caption, or note.\n\n## Bidirectional Loop\n\nBecause a recap is a real, editable plan, the same review loop as forward plans\napplies: a reviewer can annotate any block, and the coding agent reads\n\\`get-plan-feedback\\` to drive fixes back into the code — annotation → agent →\ndiff, the same close-the-loop flow forward plans use. After a reviewer annotates\na block, call \\`get-plan-feedback\\` to read the structured feedback, then either\nupdate the recap with \\`create-visual-recap\\` (passing the existing \\`planId\\` to\nreplace it in place) or apply targeted changes with \\`update-visual-plan\\`. The\nloop is live and wired. The one thing not yet automatic is PR-comment-triggered\nre-runs: the GitHub Action creates an initial recap per PR, but it does not yet\nre-run automatically when new review feedback is posted in GitHub — that\nauto-re-run is the remaining fast-follow.\n\n## Related Skills\n\n- **visual-plan** — the canonical command and the source of the shared Wireframe\n & Canvas and Document Quality cores; a recap follows the same block discipline\n in reverse.\n- **comment anchors** — recap comments use the same anchor rules as forward\n plans; see \"Interpreting comment anchors\" in the visual-plan skill for\n coordinate frames, wireframe node ids, text-quote resolution, detached\n threads, routing via \\`resolutionTarget\\`, and two-axis consumed/resolved state.\n- **security** — data scoping, secret handling, and the hardcoded-secret rule the\n recap's redaction and visibility gating mirror.\n- **sharing** — org/login-gated visibility for the plan that holds the recap.\n`;\n\nexport const BUILT_IN_APP_SKILLS = {\n assets: {\n skillName: \"assets\",\n manifest: normalizeAppSkillManifest({\n schemaVersion: 1,\n id: \"assets\",\n displayName: \"Assets\",\n description:\n \"Create, search, select, and export brand image and video assets from the Assets app.\",\n hosted: {\n url: \"https://assets.agent-native.com\",\n mcpUrl: \"https://assets.agent-native.com/_agent-native/mcp\",\n },\n mcp: { serverName: \"agent-native-assets\" },\n auth: {\n mode: \"oauth\",\n setup:\n \"Authenticate with the Assets MCP connector in the host app. No shared secrets are stored in skill files.\",\n },\n surfaces: [\n {\n id: \"asset-picker\",\n action: \"open-asset-picker\",\n path: \"/picker\",\n mediaTypes: [\"image\", \"video\"],\n defaultMediaType: \"image\",\n },\n ],\n skills: [\n {\n path: \"skills/assets\",\n visibility: \"exported\",\n exportAs: \"assets\",\n },\n ],\n hostAdapters: [\n \"codex-plugin\",\n \"claude-marketplace\",\n \"vercel-skills\",\n \"plain-skill\",\n \"claude-skill\",\n \"chatgpt-mcp\",\n \"generic-mcp\",\n ],\n }),\n skillMarkdown: ASSETS_SKILL_MD,\n },\n design: {\n skillName: \"design-exploration\",\n manifest: normalizeAppSkillManifest({\n schemaVersion: 1,\n id: \"design\",\n displayName: \"Design\",\n description:\n \"Explore, compare, iterate, and export interactive UI design prototypes from the Design app.\",\n hosted: {\n url: \"https://design.agent-native.com\",\n mcpUrl: \"https://design.agent-native.com/_agent-native/mcp\",\n },\n mcp: { serverName: \"agent-native-design\" },\n auth: {\n mode: \"oauth\",\n setup:\n \"Authenticate with the Design MCP connector in the host app. No shared secrets are stored in skill files.\",\n },\n surfaces: [\n {\n id: \"design-exploration\",\n action: \"present-design-variants\",\n path: \"/design\",\n },\n ],\n skills: [\n {\n path: \"skills/design-exploration\",\n visibility: \"exported\",\n exportAs: \"design-exploration\",\n },\n ],\n hostAdapters: [\n \"codex-plugin\",\n \"claude-marketplace\",\n \"vercel-skills\",\n \"plain-skill\",\n \"claude-skill\",\n \"chatgpt-mcp\",\n \"generic-mcp\",\n ],\n }),\n skillMarkdown: DESIGN_EXPLORATION_SKILL_MD,\n },\n \"visual-plans\": {\n skillName: \"visual-plan\",\n extraSkills: {\n \"visual-recap\": VISUAL_RECAP_SKILL_MD,\n },\n // Sibling reference files materialized alongside each skill's SKILL.md\n // (progressive disclosure). Keyed by skill name -> relative path -> content.\n // Both plan skills ship the same canonical wireframe-quality reference; the\n // canvas / document-quality / exemplar references are visual-plan only.\n extraFiles: {\n \"visual-plan\": {\n \"references/wireframe.md\": WIREFRAME_REFERENCE_MD,\n \"references/canvas.md\": CANVAS_REFERENCE_MD,\n \"references/document-quality.md\": DOCUMENT_QUALITY_REFERENCE_MD,\n \"references/exemplar.md\": EXEMPLAR_REFERENCE_MD,\n },\n \"visual-recap\": { \"references/wireframe.md\": WIREFRAME_REFERENCE_MD },\n },\n manifest: normalizeAppSkillManifest({\n schemaVersion: 1,\n id: \"visual-plans\",\n displayName: \"Agent-Native Plan\",\n description:\n \"Create rich interactive visual plans and recaps with diagrams, file maps, annotated code and diffs, API/schema summaries, feedback, and HTML export.\",\n hosted: {\n url: \"https://plan.agent-native.com\",\n mcpUrl: \"https://plan.agent-native.com/_agent-native/mcp\",\n },\n mcp: { serverName: \"plan\", aliases: [\"agent-native-plans\"] },\n auth: {\n mode: \"oauth\",\n setup:\n \"Install with the Agent-Native CLI to add the /visual-plan and /visual-recap skills plus the Plan MCP connector. Authenticate only for hosted/account-backed sharing.\",\n },\n surfaces: [\n {\n id: \"visual-plan\",\n action: \"create-visual-plan\",\n path: \"/plans\",\n description:\n \"Create a rich interactive visual plan instead of a plain-text plan, with diagrams, file maps, annotated code, questions, and optional UI/prototype review.\",\n },\n {\n id: \"visual-recap\",\n action: \"create-visual-recap\",\n path: \"/plans\",\n description:\n \"Create an interactive visual recap from a PR, commit, branch, or git diff so reviewers see the shape of the change before raw diff review.\",\n },\n ],\n skills: [\n {\n path: \"skills/visual-plan\",\n visibility: \"exported\",\n exportAs: \"visual-plan\",\n },\n {\n path: \"skills/visual-recap\",\n visibility: \"exported\",\n exportAs: \"visual-recap\",\n },\n ],\n hostAdapters: [\n \"codex-plugin\",\n \"claude-marketplace\",\n \"vercel-skills\",\n \"plain-skill\",\n \"claude-skill\",\n \"chatgpt-mcp\",\n \"generic-mcp\",\n ],\n }),\n skillMarkdown: VISUAL_PLANS_SKILL_MD,\n },\n \"context-xray\": {\n skillName: \"context-xray\",\n localOnly: true,\n manifest: normalizeAppSkillManifest({\n schemaVersion: 1,\n id: \"context-xray\",\n displayName: \"Context X-Ray\",\n description:\n \"Visualize local Codex and Claude Code context usage with warnings and optimization tips.\",\n hosted: {\n url: \"https://context-xray.agent-native.com\",\n mcpUrl: \"https://context-xray.agent-native.com/_agent-native/mcp\",\n },\n mcp: { serverName: \"agent-native-context-xray\" },\n auth: { mode: \"none\" },\n surfaces: [\n {\n id: \"context-xray-report\",\n path: \"/\",\n },\n ],\n skills: [\n {\n path: \"skills/context-xray\",\n visibility: \"exported\",\n exportAs: \"context-xray\",\n },\n ],\n hostAdapters: [\"plain-skill\", \"claude-skill\"],\n }),\n skillMarkdown: CONTEXT_XRAY_SKILL_MD,\n },\n} satisfies Record<\n string,\n {\n manifest: AppSkillManifest;\n skillMarkdown: string;\n skillName: string;\n extraSkills?: Record<string, string>;\n /**\n * Extra sibling files materialized alongside a skill's SKILL.md, for\n * progressive disclosure (e.g. `references/wireframe.md`). Keyed by skill\n * name, then by skill-relative path -> file content.\n */\n extraFiles?: Record<string, Record<string, string>>;\n localOnly?: boolean;\n }\n>;\n\ntype BuiltInAppSkillId = keyof typeof BUILT_IN_APP_SKILLS;\n\nexport const AGENT_NATIVE_SKILL_METADATA_FILE = \"agent-native-skill.json\";\n\nconst BUILT_IN_APP_SKILL_ALIASES = {\n assets: \"assets\",\n asset: \"assets\",\n \"asset-generation\": \"assets\",\n images: \"assets\",\n image: \"assets\",\n \"image-generation\": \"assets\",\n \"agent-native-assets\": \"assets\",\n \"agent-native-images\": \"assets\",\n design: \"design\",\n \"ui-design\": \"design\",\n \"ux-design\": \"design\",\n \"design-exploration\": \"design\",\n \"ux-exploration\": \"design\",\n \"agent-native-design\": \"design\",\n \"agent-native-design-exploration\": \"design\",\n \"visual-plans\": \"visual-plans\",\n \"visual-plan\": \"visual-plans\",\n \"visual-recap\": \"visual-plans\",\n \"visual-recaps\": \"visual-plans\",\n \"code-review-recap\": \"visual-plans\",\n \"code-review-recaps\": \"visual-plans\",\n \"html-plan\": \"visual-plans\",\n \"plan-mode\": \"visual-plans\",\n plannotate: \"visual-plans\",\n plannotator: \"visual-plans\",\n \"agent-native-visual-plans\": \"visual-plans\",\n \"context-xray\": \"context-xray\",\n \"local-context-xray\": \"context-xray\",\n xray: \"context-xray\",\n \"context-window\": \"context-xray\",\n \"context-usage\": \"context-xray\",\n \"agent-native-context-xray\": \"context-xray\",\n} satisfies Record<string, BuiltInAppSkillId>;\n\nconst BUILT_IN_APP_SKILL_DISPLAY_ALIASES = {\n assets: [\"images\", \"image-generation\", \"agent-native-images\"],\n design: [\n \"design-exploration\",\n \"ux-exploration\",\n \"agent-native-design-exploration\",\n ],\n \"visual-plans\": [\n \"visual-plan\",\n \"visual-recap\",\n \"code-review-recap\",\n \"html-plan\",\n \"plannotate\",\n ],\n \"context-xray\": [\"xray\", \"context-window\", \"context-usage\"],\n} satisfies Record<BuiltInAppSkillId, string[]>;\n\nconst CLIENT_LABELS: Record<ClientId, string> = {\n \"claude-code\": \"Claude Code\",\n \"claude-code-cli\": \"Claude Code CLI\",\n codex: \"Codex\",\n cowork: \"Claude Cowork\",\n};\n\nconst CLIENT_HINTS: Record<ClientId, string> = {\n \"claude-code\": \".mcp.json or ~/.claude.json\",\n \"claude-code-cli\": \".mcp.json or ~/.claude.json\",\n codex: \"$CODEX_HOME/config.toml or ~/.codex/config.toml\",\n cowork: \"~/.cowork/mcp.json\",\n};\n\ntype SkillsCommand = \"list\" | \"add\" | \"status\" | \"update\" | \"help\";\n\nexport interface ParsedSkillsArgs {\n command: SkillsCommand;\n target?: string;\n client: string;\n clientExplicit: boolean;\n clients?: ClientId[];\n plainSkillNames?: string[];\n scope: string;\n scopeExplicit: boolean;\n yes: boolean;\n dryRun: boolean;\n printJson: boolean;\n instructions: boolean;\n mcp: boolean;\n /**\n * Run the browser/device auth flow after registering a hosted MCP connector\n * so the user does not hit an OAuth wall on the first tool call. Default true;\n * `--no-connect` opts out and leaves authentication for the host/`agent-native\n * connect`.\n */\n connect: boolean;\n /**\n * Optional MCP URL override. When set, the skill's hosted MCP connector is\n * registered against this URL instead of the built-in hosted default — e.g.\n * an ngrok tunnel, a local dev origin, or a self-hosted deployment.\n */\n mcpUrl?: string;\n /**\n * When installing the visual-plan skill, also write the PR Visual Recap\n * GitHub Action workflow into `.github/workflows/` so PRs get automatic\n * recaps. Only applies to the `visual-plan` target.\n */\n withGithubAction?: boolean;\n /**\n * Set once the PR Visual Recap workflow decision has already been made up\n * front (in `runSkills`, before any install/registration) so the per-target\n * `addAgentNativeSkill` doesn't prompt for it again mid-flow. The chosen\n * value lands in `withGithubAction`.\n */\n githubActionResolved?: boolean;\n /**\n * Plain skill repos can add a managed AGENTS.md / CLAUDE.md block for skills\n * that only become automatic through project instructions.\n */\n updateInstructions?: boolean;\n /**\n * When `--with-github-action` is set and the existing workflow file differs\n * from the bundled template, overwrite it. Without this flag the command\n * refuses and prints a message.\n */\n force?: boolean;\n}\n\nexport interface SkillsAddResult {\n id: string;\n displayName: string;\n instructionSource?: string;\n skillNames: string[];\n skillsAgents: string[];\n mcpUrl: string;\n mcpClients: ClientId[];\n dryRun: boolean;\n commands: string[];\n local?: boolean;\n scriptPath?: string;\n written?: string[];\n /**\n * True when the install also kicked off (or prepared) the browser/device auth\n * flow for the hosted MCP connector. False when connect was skipped\n * (`--no-connect`, no-auth skills, or non-interactive without a connect step).\n */\n connected?: boolean;\n /**\n * The exact `npx @agent-native/core@latest connect <url>` command to run when interactive auth\n * was skipped (non-interactive shell / CI). Empty when connect ran inline or\n * was not needed.\n */\n connectCommand?: string;\n /**\n * When `--with-github-action` installed the PR Visual Recap workflow, the\n * repo-relative path it was written to (and whether it overwrote an existing\n * file).\n */\n githubActionPath?: string;\n githubActionExisted?: boolean;\n githubActionSuggestedCommand?: string;\n}\n\ninterface SkillInstallMetadata {\n schemaVersion: 1;\n source: \"agent-native\";\n appSkillId: string;\n displayName: string;\n skillName: string;\n contentHash: string;\n mcpUrl: string;\n installedAt: string;\n updateCommand: string;\n}\n\ninterface SkillFolderBundle {\n appSkillId: BuiltInAppSkillId;\n displayName: string;\n skillName: string;\n mcpUrl: string;\n files: Record<string, string>;\n contentHash: string;\n}\n\ninterface SkillInstallState {\n appSkillId: BuiltInAppSkillId;\n displayName: string;\n skillName: string;\n path: string;\n root: string;\n scope: \"project\" | \"user\";\n client: string;\n latestHash: string;\n installedHash: string | null;\n metadataHash?: string;\n current: boolean;\n managed: boolean;\n}\n\ninterface SkillInstallTarget {\n id: string;\n displayName: string;\n loaded: LoadedAppSkillManifest;\n skillNames: string[];\n materializeInstructions(outDir: string): string;\n cleanup?: () => void;\n}\n\ninterface RunCommandOptions {\n stdio?: \"inherit\" | \"stderr\" | \"silent\";\n}\n\ninterface RunSkillsOptions {\n baseDir?: string;\n isInteractive?: () => boolean;\n log?: (message: string) => void;\n promptClients?: (\n context: SkillsClientPromptContext,\n ) => Promise<ClientId[] | null>;\n promptSkills?: (\n context: SkillsTargetPromptContext,\n ) => Promise<string[] | null>;\n promptGithubAction?: (\n context: SkillsGithubActionPromptContext,\n ) => Promise<boolean | null>;\n promptScope?: (\n context: SkillsScopePromptContext,\n ) => Promise<\"project\" | \"user\" | null>;\n runCommand?: (\n cmd: string,\n args: string[],\n options?: RunCommandOptions,\n ) => Promise<number>;\n /**\n * Injectable connect/auth entrypoint (defaults to the real `agent-native\n * connect`). Tests stub this so the install flow does not perform a real\n * browser/device OAuth round-trip.\n */\n runConnect?: (args: string[]) => Promise<void>;\n /**\n * Best-effort install-funnel telemetry. Created once per `runSkills` run and\n * threaded through resolution/install/connect so each `track` is fire-and-\n * forget and never blocks or throws into the install flow. Absent when\n * `addAgentNativeSkill` is called directly (e.g. tests).\n */\n telemetry?: CliTelemetry;\n}\n\ninterface SkillsClientPromptContext {\n initialClients: ClientId[];\n options: Array<{ value: ClientId; label: string; hint: string }>;\n}\n\ninterface SkillsTargetPromptContext {\n initialTargets: string[];\n options: Array<{ value: string; label: string; hint: string }>;\n}\n\ninterface SkillsGithubActionPromptContext {\n workflowPath: string;\n setupCommand: string;\n}\n\ninterface SkillsScopePromptContext {\n initialScope: \"project\" | \"user\";\n}\n\nfunction normalizeKnownSkillTarget(\n value: string | undefined,\n): BuiltInAppSkillId | undefined {\n const key = value?.trim().toLowerCase();\n if (!key) return undefined;\n return BUILT_IN_APP_SKILL_ALIASES[key];\n}\n\nfunction isKnownSkill(value: string | undefined): boolean {\n return Boolean(normalizeKnownSkillTarget(value));\n}\n\nfunction isLocalOnlyBuiltInSkill(\n entry: (typeof BUILT_IN_APP_SKILLS)[BuiltInAppSkillId] | null | undefined,\n): boolean {\n return Boolean(entry && \"localOnly\" in entry && entry.localOnly);\n}\n\nfunction builtInExtraSkills(\n entry: (typeof BUILT_IN_APP_SKILLS)[BuiltInAppSkillId],\n): Record<string, string> {\n return \"extraSkills\" in entry && entry.extraSkills ? entry.extraSkills : {};\n}\n\n/**\n * Sibling reference files for a skill (skill name -> relative path -> content),\n * materialized alongside its SKILL.md for progressive disclosure.\n */\nfunction builtInExtraFiles(\n entry: (typeof BUILT_IN_APP_SKILLS)[BuiltInAppSkillId],\n): Record<string, Record<string, string>> {\n return \"extraFiles\" in entry && entry.extraFiles ? entry.extraFiles : {};\n}\n\nfunction builtInSkillNames(\n entry: (typeof BUILT_IN_APP_SKILLS)[BuiltInAppSkillId],\n): string[] {\n return [entry.skillName, ...Object.keys(builtInExtraSkills(entry))];\n}\n\n/**\n * When a target names a single skill that lives inside a multi-skill bundle\n * (the plan bundle ships both `visual-plan` and `visual-recap`), restrict the\n * install to just that skill. The bundle aliases (`visual-plans`, `plannotate`,\n * …) return undefined so they install every skill in the bundle.\n */\nfunction builtInOnlySkillNames(target: string): string[] | undefined {\n const normalized = target.trim().toLowerCase();\n if (normalized === \"visual-plan\") return [\"visual-plan\"];\n if (normalized === \"visual-recap\" || normalized === \"visual-recaps\") {\n return [\"visual-recap\"];\n }\n return undefined;\n}\n\nfunction stableSkillHash(files: Record<string, string>): string {\n const hash = createHash(\"sha256\");\n for (const rel of Object.keys(files).sort()) {\n if (rel === AGENT_NATIVE_SKILL_METADATA_FILE) continue;\n hash.update(rel);\n hash.update(\"\\0\");\n hash.update(files[rel]);\n hash.update(\"\\0\");\n }\n return hash.digest(\"hex\").slice(0, 16);\n}\n\nfunction skillFilesForBuiltIn(\n appSkillId: BuiltInAppSkillId,\n): Record<string, SkillFolderBundle> {\n const entry = BUILT_IN_APP_SKILLS[appSkillId];\n const skills: Record<string, string> = {\n [entry.skillName]: entry.skillMarkdown,\n ...builtInExtraSkills(entry),\n };\n const extraFiles = builtInExtraFiles(entry);\n const out: Record<string, SkillFolderBundle> = {};\n for (const [skillName, skillMarkdown] of Object.entries(skills)) {\n const files = {\n \"SKILL.md\": skillMarkdown,\n ...(extraFiles[skillName] ?? {}),\n };\n out[skillName] = {\n appSkillId,\n displayName: entry.manifest.displayName,\n skillName,\n mcpUrl: isLocalOnlyBuiltInSkill(entry)\n ? \"\"\n : entry.manifest.hosted.mcpUrl,\n files,\n contentHash: stableSkillHash(files),\n };\n }\n return out;\n}\n\nfunction latestSkillBundlesForTargets(\n appSkillIds: BuiltInAppSkillId[],\n): Record<string, SkillFolderBundle> {\n const out: Record<string, SkillFolderBundle> = {};\n for (const appSkillId of appSkillIds) {\n Object.assign(out, skillFilesForBuiltIn(appSkillId));\n }\n return out;\n}\n\nfunction writeSkillFolder(\n dir: string,\n bundle: SkillFolderBundle,\n installedAt = new Date().toISOString(),\n): void {\n fs.rmSync(dir, { recursive: true, force: true });\n fs.mkdirSync(dir, { recursive: true });\n for (const [rel, content] of Object.entries(bundle.files)) {\n const target = path.join(dir, rel);\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, content, \"utf-8\");\n }\n const metadata: SkillInstallMetadata = {\n schemaVersion: 1,\n source: \"agent-native\",\n appSkillId: bundle.appSkillId,\n displayName: bundle.displayName,\n skillName: bundle.skillName,\n contentHash: bundle.contentHash,\n mcpUrl: bundle.mcpUrl,\n installedAt,\n updateCommand: `npx @agent-native/core@latest skills update ${bundle.skillName}`,\n };\n fs.writeFileSync(\n path.join(dir, AGENT_NATIVE_SKILL_METADATA_FILE),\n `${JSON.stringify(metadata, null, 2)}\\n`,\n \"utf-8\",\n );\n}\n\n/**\n * The skills directory a built-in skill's instructions are copied into for a\n * given agent + scope. Mirrors the layout the skills installer uses so\n * `skills status` / `skills update` find the folders again.\n */\nfunction builtInSkillsRootForAgent(\n agent: string,\n scope: \"project\" | \"user\",\n baseDir: string,\n): string {\n const home = homeDir() ?? baseDir;\n if (scope === \"project\") {\n return agent === \"codex\"\n ? path.join(baseDir, \".agents\", \"skills\")\n : path.join(baseDir, \".claude\", \"skills\");\n }\n if (agent === \"codex\") {\n return process.env.CODEX_HOME\n ? path.join(process.env.CODEX_HOME, \"skills\")\n : path.join(home, \".codex\", \"skills\");\n }\n return path.join(home, \".claude\", \"skills\");\n}\n\n/**\n * Write a built-in skill's instruction folders straight into each client's\n * skills directory. Built-in skills ship their SKILL.md inside this package, so\n * there is no need to shell out to the separate @agent-native/skills installer\n * (which would have to be published to npm first). Returns the written folders.\n */\nfunction installBuiltInInstructions(input: {\n appSkillId: BuiltInAppSkillId;\n onlySkillNames?: string[];\n skillsAgents: string[];\n scope: \"project\" | \"user\";\n baseDir: string;\n dryRun?: boolean;\n}): string[] {\n const bundles = Object.values(skillFilesForBuiltIn(input.appSkillId)).filter(\n (bundle) =>\n !input.onlySkillNames || input.onlySkillNames.includes(bundle.skillName),\n );\n const written: string[] = [];\n for (const agent of input.skillsAgents) {\n const root = builtInSkillsRootForAgent(agent, input.scope, input.baseDir);\n for (const bundle of bundles) {\n const dir = path.join(root, bundle.skillName);\n if (!input.dryRun) writeSkillFolder(dir, bundle);\n written.push(dir);\n }\n }\n return written;\n}\n\nfunction listSkillFolderFiles(dir: string): Record<string, string> {\n const out: Record<string, string> = {};\n const walk = (current: string, prefix = \"\") => {\n for (const entry of fs.readdirSync(current, { withFileTypes: true })) {\n const rel = prefix ? `${prefix}/${entry.name}` : entry.name;\n const abs = path.join(current, entry.name);\n if (entry.isDirectory()) {\n walk(abs, rel);\n continue;\n }\n if (!entry.isFile() || rel === AGENT_NATIVE_SKILL_METADATA_FILE) continue;\n out[rel] = fs.readFileSync(abs, \"utf-8\");\n }\n };\n if (fs.existsSync(dir)) walk(dir);\n return out;\n}\n\nfunction readSkillInstallMetadata(\n dir: string,\n): SkillInstallMetadata | undefined {\n const file = path.join(dir, AGENT_NATIVE_SKILL_METADATA_FILE);\n if (!fs.existsSync(file)) return undefined;\n try {\n const parsed = JSON.parse(fs.readFileSync(file, \"utf-8\"));\n if (\n parsed &&\n parsed.source === \"agent-native\" &&\n typeof parsed.skillName === \"string\" &&\n typeof parsed.contentHash === \"string\"\n ) {\n return parsed as SkillInstallMetadata;\n }\n } catch {}\n return undefined;\n}\n\nfunction homeDir(): string | undefined {\n return process.env.HOME || os.homedir();\n}\n\nfunction skillSearchRoots(input: {\n baseDir: string;\n clients: ClientId[];\n scopes: Array<\"project\" | \"user\">;\n}): Array<{\n root: string;\n scope: \"project\" | \"user\";\n client: string;\n}> {\n const roots: Array<{\n root: string;\n scope: \"project\" | \"user\";\n client: string;\n }> = [];\n const clientSet = new Set(input.clients);\n const includeAll = input.clients.length === 0;\n const hasClient = (client: ClientId) => includeAll || clientSet.has(client);\n const add = (\n root: string | undefined,\n scope: \"project\" | \"user\",\n client: string,\n ) => {\n if (root) roots.push({ root, scope, client });\n };\n\n if (input.scopes.includes(\"project\")) {\n if (hasClient(\"codex\")) {\n add(path.join(input.baseDir, \".agents\", \"skills\"), \"project\", \"codex\");\n }\n if (hasClient(\"claude-code\") || hasClient(\"claude-code-cli\")) {\n add(\n path.join(input.baseDir, \".claude\", \"skills\"),\n \"project\",\n \"claude-code\",\n );\n }\n if (includeAll) add(path.join(input.baseDir, \"skills\"), \"project\", \"repo\");\n }\n\n if (input.scopes.includes(\"user\")) {\n const home = homeDir();\n if (hasClient(\"codex\")) {\n add(\n process.env.CODEX_HOME\n ? path.join(process.env.CODEX_HOME, \"skills\")\n : undefined,\n \"user\",\n \"codex\",\n );\n add(\n home ? path.join(home, \".codex\", \"skills\") : undefined,\n \"user\",\n \"codex\",\n );\n }\n if (hasClient(\"claude-code\") || hasClient(\"claude-code-cli\")) {\n add(\n home ? path.join(home, \".claude\", \"skills\") : undefined,\n \"user\",\n \"claude-code\",\n );\n }\n }\n\n const seen = new Set<string>();\n return roots.filter((entry) => {\n const key = `${entry.scope}:${entry.client}:${path.resolve(entry.root)}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n\nfunction targetIdsForStatus(parsed: ParsedSkillsArgs): BuiltInAppSkillId[] {\n if (!parsed.target) {\n return (Object.keys(BUILT_IN_APP_SKILLS) as BuiltInAppSkillId[]).filter(\n (id) => !isLocalOnlyBuiltInSkill(BUILT_IN_APP_SKILLS[id]),\n );\n }\n const known = normalizeKnownSkillTarget(parsed.target);\n if (!known) {\n throw new Error(\n `Unknown built-in skill: ${parsed.target}. Run \"npx @agent-native/core@latest skills list\".`,\n );\n }\n if (isLocalOnlyBuiltInSkill(BUILT_IN_APP_SKILLS[known])) {\n throw new Error(\n `${BUILT_IN_APP_SKILLS[known].manifest.displayName} is installed as a local command and cannot be refreshed with skills update yet.`,\n );\n }\n return [known];\n}\n\nfunction scopeFilterForStatus(\n parsed: ParsedSkillsArgs,\n): Array<\"project\" | \"user\"> {\n return parsed.scopeExplicit\n ? [parsed.scope as \"project\" | \"user\"]\n : [\"project\", \"user\"];\n}\n\nfunction clientFilterForStatus(parsed: ParsedSkillsArgs): ClientId[] {\n return parsed.clientExplicit ? resolveClients(parsed.client) : [];\n}\n\nfunction collectSkillInstallStates(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n): SkillInstallState[] {\n const appSkillIds = targetIdsForStatus(parsed);\n const latest = latestSkillBundlesForTargets(appSkillIds);\n const roots = skillSearchRoots({\n baseDir: options.baseDir ?? process.cwd(),\n clients: clientFilterForStatus(parsed),\n scopes: scopeFilterForStatus(parsed),\n });\n const states: SkillInstallState[] = [];\n const seenDirs = new Set<string>();\n\n for (const root of roots) {\n for (const bundle of Object.values(latest)) {\n const dir = path.join(root.root, bundle.skillName);\n const resolvedDir = path.resolve(dir);\n if (seenDirs.has(resolvedDir) || !fs.existsSync(dir)) continue;\n if (!fs.existsSync(path.join(dir, \"SKILL.md\"))) continue;\n seenDirs.add(resolvedDir);\n const files = listSkillFolderFiles(dir);\n const installedHash =\n Object.keys(files).length > 0 ? stableSkillHash(files) : null;\n const metadata = readSkillInstallMetadata(dir);\n states.push({\n appSkillId: bundle.appSkillId,\n displayName: bundle.displayName,\n skillName: bundle.skillName,\n path: dir,\n root: root.root,\n scope: root.scope,\n client: root.client,\n latestHash: bundle.contentHash,\n installedHash,\n metadataHash: metadata?.contentHash,\n current: installedHash === bundle.contentHash,\n managed: metadata?.source === \"agent-native\",\n });\n }\n }\n\n return states.sort((a, b) =>\n `${a.skillName}:${a.path}`.localeCompare(`${b.skillName}:${b.path}`),\n );\n}\n\nfunction updateSkillInstallStates(\n states: SkillInstallState[],\n dryRun: boolean,\n): SkillInstallState[] {\n const latest = latestSkillBundlesForTargets([\n ...new Set(states.map((state) => state.appSkillId)),\n ]);\n const updated: SkillInstallState[] = [];\n for (const state of states) {\n if (state.current && state.managed) continue;\n const bundle = latest[state.skillName];\n if (!bundle) continue;\n if (!dryRun) writeSkillFolder(state.path, bundle);\n updated.push({\n ...state,\n current: !dryRun,\n installedHash: dryRun ? state.installedHash : bundle.contentHash,\n metadataHash: dryRun ? state.metadataHash : bundle.contentHash,\n });\n }\n return updated;\n}\n\nfunction normalizeClientIds(values: unknown): ClientId[] {\n if (!Array.isArray(values)) return [];\n const seen = new Set<ClientId>();\n const out: ClientId[] = [];\n for (const value of values) {\n if (typeof value !== \"string\") continue;\n const id = value.toLowerCase();\n if (!(CLIENTS as string[]).includes(id)) continue;\n const client = id as ClientId;\n if (seen.has(client)) continue;\n seen.add(client);\n out.push(client);\n }\n return out;\n}\n\nfunction clientPromptOptions(): SkillsClientPromptContext[\"options\"] {\n return CLIENTS.map((client) => ({\n value: client,\n label: CLIENT_LABELS[client],\n hint: CLIENT_HINTS[client],\n }));\n}\n\n// For now the interactive installer offers only the two plan skills, each as\n// an independently selectable entry (uncheck one to install just the other).\n// The other built-in skills stay installable via `agent-native skills add\n// <name>` but are hidden from the default checklist. The values are the real\n// slash-command names so users see exactly what they are installing.\nconst PLAN_SKILL_PROMPT_OPTIONS: SkillsTargetPromptContext[\"options\"] = [\n {\n value: \"visual-plan\",\n label: \"visual-plan\",\n hint: \"Rich interactive visual plan that turns ordinary text plans into diagrams, file maps, annotated code, questions, and UI/prototype review.\",\n },\n {\n value: \"visual-recap\",\n label: \"visual-recap\",\n hint: \"Interactive visual recap that maps PRs/diffs with diagrams, annotated diffs, API/schema summaries, and review notes.\",\n },\n];\n\nfunction skillPromptOptions(): SkillsTargetPromptContext[\"options\"] {\n return PLAN_SKILL_PROMPT_OPTIONS;\n}\n\nfunction prVisualRecapWorkflowPath(baseDir: string): string {\n return path.join(baseDir, \".github\", \"workflows\", \"pr-visual-recap.yml\");\n}\n\nfunction prVisualRecapWorkflowDisplayPath(): string {\n return path.join(\".github\", \"workflows\", \"pr-visual-recap.yml\");\n}\n\nfunction prVisualRecapInstallCommand(): string {\n return \"npx @agent-native/core@latest skills add visual-recap --with-github-action\";\n}\n\nfunction prVisualRecapSetupCommand(): string {\n return \"npx @agent-native/core@latest recap setup\";\n}\n\nasync function promptForGithubAction(\n context: SkillsGithubActionPromptContext,\n): Promise<boolean | null> {\n const clack = await import(\"@clack/prompts\");\n const result = await clack.confirm({\n message:\n \"Optional: add automatic PR Visual Recaps? (GitHub Action)\\n\" +\n \" Posts a human-friendly recap on every pull request — a high-altitude\\n\" +\n \" overview of what the PR does, with annotated code, diagrams, and\\n\" +\n \" before/after notes instead of a raw diff.\\n\" +\n ` Writes ${context.workflowPath}; ${context.setupCommand} finishes the GitHub secrets.`,\n initialValue: false,\n });\n if (clack.isCancel(result)) {\n clack.cancel(\"Skipped PR Visual Recap workflow.\");\n return null;\n }\n return Boolean(result);\n}\n\nfunction shouldPrompt(parsed: ParsedSkillsArgs, options: RunSkillsOptions) {\n if (parsed.yes || parsed.printJson) return false;\n if (options.isInteractive) return options.isInteractive();\n if (process.env.AGENT_NATIVE_NO_PROMPT === \"1\") return false;\n if (process.env.CI === \"true\") return false;\n return !!process.stdin.isTTY && !!process.stdout.isTTY;\n}\n\nasync function promptForClients(\n context: SkillsClientPromptContext,\n): Promise<ClientId[] | null> {\n const clack = await import(\"@clack/prompts\");\n const result = await clack.multiselect({\n message:\n \"Install the MCP connector for which local agents?\\n\" +\n \" (space toggles, enter confirms; saved for next time)\",\n options: context.options,\n initialValues: context.initialClients,\n required: true,\n });\n if (clack.isCancel(result)) {\n clack.cancel(\"Cancelled.\");\n return null;\n }\n return normalizeClientIds(result);\n}\n\nasync function promptForScope(\n context: SkillsScopePromptContext,\n): Promise<\"project\" | \"user\" | null> {\n const clack = await import(\"@clack/prompts\");\n const result = await clack.select({\n message: \"Where do you want to install these skills?\",\n options: [\n {\n value: \"project\",\n label: \"Project\",\n hint: \"This repo only (.agents / .claude in the current directory) — committed with your project\",\n },\n {\n value: \"user\",\n label: \"User\",\n hint: \"Your home directory (~/.codex, ~/.claude) — available across all projects\",\n },\n ],\n initialValue: context.initialScope,\n });\n if (clack.isCancel(result)) {\n clack.cancel(\"Cancelled.\");\n return null;\n }\n return result === \"project\" ? \"project\" : \"user\";\n}\n\nasync function promptForSkills(\n context: SkillsTargetPromptContext,\n): Promise<string[] | null> {\n const clack = await import(\"@clack/prompts\");\n const result = await clack.multiselect({\n message:\n \"Which Agent Native skills do you want to install?\\n\" +\n \" (space toggles, enter confirms)\",\n options: context.options,\n initialValues: context.initialTargets,\n required: true,\n });\n if (clack.isCancel(result)) {\n clack.cancel(\"Cancelled.\");\n return null;\n }\n if (!Array.isArray(result)) return [];\n return result.filter((value): value is string => typeof value === \"string\");\n}\n\nasync function resolveSkillsClients(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n): Promise<ClientId[] | null> {\n if (parsed.clientExplicit || !shouldPrompt(parsed, options)) {\n return resolveClients(parsed.client);\n }\n const initialClients = resolveClients(\"all\");\n const prompt = options.promptClients ?? promptForClients;\n const selected = normalizeClientIds(\n await prompt({\n initialClients,\n options: clientPromptOptions(),\n }),\n );\n if (selected.length === 0) return null;\n if (!parsed.dryRun) {\n try {\n writeConnectClientPreferences(selected);\n } catch {}\n }\n return selected;\n}\n\nasync function resolveSkillTargets(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n): Promise<string[] | null> {\n if (parsed.target || !shouldPrompt(parsed, options)) {\n return [parsed.target ?? \"assets\"];\n }\n const prompt = options.promptSkills ?? promptForSkills;\n const promptOptions = skillPromptOptions();\n // The interactive multiselect skill picker is about to be shown (no --skill /\n // target passed and we are interactive) — record the funnel \"prompted\" step.\n options.telemetry?.track(\"skills_cli skills prompted\", {\n availableCount: promptOptions.length,\n available: promptOptions.map((option) => option.value).join(\",\"),\n });\n const selected = await prompt({\n initialTargets: [\"visual-plan\", \"visual-recap\"],\n options: promptOptions,\n });\n if (!selected || selected.length === 0) return null;\n // Both plan skills share one MCP connector, so when both are selected install\n // them through the bundle target — that registers/authenticates the connector\n // once instead of twice.\n const planSubskills = [\"visual-plan\", \"visual-recap\"];\n if (planSubskills.every((skill) => selected.includes(skill))) {\n return [\n \"visual-plans\",\n ...selected.filter((s) => !planSubskills.includes(s)),\n ];\n }\n return selected;\n}\n\nexport function parseSkillsArgs(argv: string[]): ParsedSkillsArgs {\n const first = argv[0];\n let command: SkillsCommand = \"list\";\n let args = argv;\n if (first === \"help\" || first === \"--help\" || first === \"-h\") {\n command = \"help\";\n args = argv.slice(1);\n } else if (\n first === \"list\" ||\n first === \"add\" ||\n first === \"status\" ||\n first === \"update\"\n ) {\n command = first;\n args = argv.slice(1);\n } else if (first) {\n command = \"add\";\n }\n\n const out: ParsedSkillsArgs = {\n command,\n client: \"all\",\n clientExplicit: false,\n scope: \"user\",\n scopeExplicit: false,\n yes: false,\n dryRun: false,\n printJson: false,\n instructions: true,\n mcp: true,\n connect: true,\n };\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n const eat = (flag: string): string | undefined => {\n if (arg === flag) {\n const next = args[++i];\n if (!next || next.startsWith(\"-\")) {\n throw new Error(`Missing value for ${flag}.`);\n }\n return next;\n }\n if (arg.startsWith(`${flag}=`)) {\n const value = arg.slice(flag.length + 1);\n if (!value) throw new Error(`Missing value for ${flag}.`);\n return value;\n }\n return undefined;\n };\n let value: string | undefined;\n if ((value = eat(\"--client\")) !== undefined) {\n out.client = value;\n out.clientExplicit = true;\n } else if ((value = eat(\"--skill\")) !== undefined) {\n out.plainSkillNames = [...(out.plainSkillNames ?? []), value];\n } else if ((value = eat(\"-s\")) !== undefined) {\n out.plainSkillNames = [...(out.plainSkillNames ?? []), value];\n } else if ((value = eat(\"--scope\")) !== undefined) {\n out.scope = value;\n out.scopeExplicit = true;\n } else if ((value = eat(\"--mcp-url\")) !== undefined) out.mcpUrl = value;\n else if (arg === \"--yes\" || arg === \"-y\") out.yes = true;\n else if (arg === \"--dry-run\") out.dryRun = true;\n else if (arg === \"--json\") out.printJson = true;\n else if (arg === \"--mcp-only\") out.instructions = false;\n else if (arg === \"--instructions-only\" || arg === \"--no-mcp\")\n out.mcp = false;\n else if (arg === \"--no-connect\" || arg === \"--skip-connect\")\n out.connect = false;\n else if (arg === \"--with-github-action\" || arg === \"--with-github-actions\")\n out.withGithubAction = true;\n else if (arg === \"--update-instructions\") out.updateInstructions = true;\n else if (arg === \"--no-update-instructions\") out.updateInstructions = false;\n else if (arg === \"--force\") out.force = true;\n else if (arg.startsWith(\"-\")) throw new Error(`Unknown option: ${arg}`);\n else if (!out.target) out.target = arg;\n else throw new Error(`Unexpected argument: ${arg}`);\n }\n\n if (out.scope !== \"user\" && out.scope !== \"project\") {\n throw new Error(\"--scope must be either user or project.\");\n }\n return out;\n}\n\nfunction loadSkillTarget(\n target: string,\n onlySkillNames?: string[],\n): SkillInstallTarget {\n const knownTarget = normalizeKnownSkillTarget(target);\n if (knownTarget) {\n const builtIn = BUILT_IN_APP_SKILLS[knownTarget];\n const skillNames = builtInSkillNames(builtIn).filter(\n (name) => !onlySkillNames || onlySkillNames.includes(name),\n );\n return {\n id: builtIn.manifest.id,\n displayName: builtIn.manifest.displayName,\n loaded: {\n manifest: builtIn.manifest,\n file: `<built-in:${builtIn.manifest.id}>`,\n dir: process.cwd(),\n },\n skillNames,\n materializeInstructions(outDir) {\n const bundles = skillFilesForBuiltIn(knownTarget);\n for (const bundle of Object.values(bundles)) {\n if (onlySkillNames && !onlySkillNames.includes(bundle.skillName)) {\n continue;\n }\n writeSkillFolder(\n path.join(outDir, \"skills\", bundle.skillName),\n bundle,\n );\n }\n return outDir;\n },\n };\n }\n\n const resolved = path.resolve(target);\n const manifestFile = fs.statSync(resolved).isDirectory()\n ? path.join(resolved, \"agent-native.app-skill.json\")\n : resolved;\n const loaded = loadAppSkillManifest(manifestFile);\n return {\n id: loaded.manifest.id,\n displayName: loaded.manifest.displayName,\n loaded,\n skillNames: loaded.manifest.skills\n .filter(\n (skill) =>\n skill.visibility === \"exported\" || skill.visibility === \"both\",\n )\n .map((skill) => skill.exportAs ?? path.basename(skill.path)),\n materializeInstructions(outDir) {\n const packed = buildAppSkillPack(loaded, outDir);\n const vercelAdapter = path.join(\n packed.outDir,\n \"adapters\",\n \"vercel-skills\",\n );\n return fs.existsSync(vercelAdapter) ? vercelAdapter : packed.outDir;\n },\n };\n}\n\nfunction skillsAgentsForClients(clients: ClientId[]): string[] {\n const agents = new Set<string>();\n for (const client of clients) {\n if (client === \"codex\") agents.add(\"codex\");\n if (client === \"claude-code\" || client === \"claude-code-cli\") {\n agents.add(\"claude-code\");\n }\n }\n return [...agents];\n}\n\nfunction shellArg(value: string): string {\n if (/^[A-Za-z0-9_/:=.,@+-]+$/.test(value)) return value;\n return `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\n\nfunction commandString(cmd: string, args: string[]): string {\n return [cmd, ...args].map(shellArg).join(\" \");\n}\n\nfunction clientArgForClients(clients: ClientId[]): string {\n if (clients.length === CLIENTS.length) return \"all\";\n if (clients.length === 1) return clients[0];\n return clients.join(\",\");\n}\n\nfunction preserveMcpUrlAppPathOverride(\n target: SkillInstallTarget,\n input: string | undefined,\n): SkillInstallTarget {\n if (!input) return target;\n let parsed: URL;\n try {\n parsed = new URL(input);\n } catch {\n return target;\n }\n const trimmedPath = parsed.pathname.replace(/\\/+$/, \"\");\n const appPath = trimmedPath.endsWith(\"/_agent-native/mcp\")\n ? trimmedPath.slice(0, -\"/_agent-native/mcp\".length).replace(/\\/+$/, \"\")\n : trimmedPath;\n if (!appPath) return target;\n const url = `${parsed.origin}${appPath}`;\n return {\n ...target,\n loaded: {\n ...target.loaded,\n manifest: {\n ...target.loaded.manifest,\n hosted: { url, mcpUrl: `${url}/_agent-native/mcp` },\n },\n },\n };\n}\n\nfunction dryRunInstallCommand(\n parsed: ParsedSkillsArgs,\n target: string,\n): string {\n const clients = parsed.clients ?? resolveClients(parsed.client);\n const args = [\n \"@agent-native/core@latest\",\n \"skills\",\n \"add\",\n target,\n \"--client\",\n clientArgForClients(clients),\n \"--scope\",\n parsed.scope,\n ];\n if (parsed.mcpUrl) args.push(\"--mcp-url\", parsed.mcpUrl);\n if (parsed.instructions && !parsed.mcp) args.push(\"--instructions-only\");\n if (!parsed.instructions && parsed.mcp) args.push(\"--mcp-only\");\n if (!parsed.connect) args.push(\"--no-connect\");\n if (parsed.withGithubAction) args.push(\"--with-github-action\");\n if (parsed.updateInstructions === true) args.push(\"--update-instructions\");\n if (parsed.updateInstructions === false)\n args.push(\"--no-update-instructions\");\n if (parsed.yes || isKnownSkill(target)) args.push(\"--yes\");\n return commandString(\"npx\", args);\n}\n\nasync function runCommand(\n cmd: string,\n args: string[],\n options: RunCommandOptions = {},\n): Promise<number> {\n return new Promise((resolve, reject) => {\n const pipeToStderr = options.stdio === \"stderr\";\n const silent = options.stdio === \"silent\";\n const stdoutChunks: Buffer[] = [];\n const stderrChunks: Buffer[] = [];\n const child = spawn(cmd, args, {\n stdio: pipeToStderr || silent ? [\"inherit\", \"pipe\", \"pipe\"] : \"inherit\",\n shell: process.platform === \"win32\",\n env: process.env,\n });\n if (pipeToStderr) {\n child.stdout?.on(\"data\", (chunk) => process.stderr.write(chunk));\n child.stderr?.on(\"data\", (chunk) => process.stderr.write(chunk));\n } else if (silent) {\n child.stdout?.on(\"data\", (chunk) =>\n stdoutChunks.push(Buffer.from(chunk)),\n );\n child.stderr?.on(\"data\", (chunk) =>\n stderrChunks.push(Buffer.from(chunk)),\n );\n }\n child.on(\"error\", reject);\n child.on(\"exit\", (code, signal) => {\n if (signal) {\n reject(new Error(`${cmd} was interrupted by ${signal}.`));\n return;\n }\n if (silent && code !== 0) {\n for (const chunk of stdoutChunks) process.stderr.write(chunk);\n for (const chunk of stderrChunks) process.stderr.write(chunk);\n }\n resolve(code ?? 0);\n });\n });\n}\n\n/**\n * Resolve a `--mcp-url` override into the `{ url, mcpUrl }` pair the manifest\n * expects. Accepts a bare origin (`https://x.ngrok-free.dev`) — appending the\n * standard `/_agent-native/mcp` path — or a full MCP URL already ending in it.\n */\nfunction resolveMcpUrlOverride(input: string): { url: string; mcpUrl: string } {\n let parsed: URL;\n try {\n parsed = new URL(input);\n } catch {\n throw new Error(`--mcp-url must be a valid URL (got \"${input}\").`);\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n throw new Error(\"--mcp-url must use http:// or https://.\");\n }\n const origin = parsed.origin;\n const trimmedPath = parsed.pathname.replace(/\\/+$/, \"\");\n const mcpUrl = trimmedPath.endsWith(\"/_agent-native/mcp\")\n ? `${origin}${trimmedPath}`\n : `${origin}/_agent-native/mcp`;\n return { url: origin, mcpUrl };\n}\n\n/** Return a copy of the install target with its hosted MCP URL overridden. */\nfunction withMcpUrlOverride(\n target: SkillInstallTarget,\n input: string,\n): SkillInstallTarget {\n const { url, mcpUrl } = resolveMcpUrlOverride(input);\n return {\n ...target,\n loaded: {\n ...target.loaded,\n manifest: { ...target.loaded.manifest, hosted: { url, mcpUrl } },\n },\n };\n}\n\nfunction isPlainSkillRepoPath(target: string): boolean {\n const resolved = path.resolve(target);\n if (!fs.existsSync(resolved)) return false;\n const stat = fs.statSync(resolved);\n if (!stat.isDirectory()) return false;\n const hasDirectSkill = fs.existsSync(path.join(resolved, \"SKILL.md\"));\n const skillsDir = path.join(resolved, \"skills\");\n const hasSkillsDir =\n fs.existsSync(skillsDir) &&\n fs\n .readdirSync(skillsDir, { withFileTypes: true })\n .some(\n (entry) =>\n entry.isDirectory() &&\n fs.existsSync(path.join(skillsDir, entry.name, \"SKILL.md\")),\n );\n const hasAppSkillManifest = fs.existsSync(\n path.join(resolved, \"agent-native.app-skill.json\"),\n );\n return !hasAppSkillManifest && (hasDirectSkill || hasSkillsDir);\n}\n\nfunction isGithubSkillRepoTarget(target: string): boolean {\n if (/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+(?:#.+)?$/.test(target)) {\n return true;\n }\n try {\n const url = new URL(target);\n return url.hostname === \"github.com\";\n } catch {\n return false;\n }\n}\n\nfunction isPlainSkillRepoTarget(target: string): boolean {\n return isPlainSkillRepoPath(target) || isGithubSkillRepoTarget(target);\n}\n\nfunction agentNativeSkillsInstallArgs(\n parsed: ParsedSkillsArgs,\n target: string,\n clients: ClientId[],\n): string[] {\n const args = [\n \"--yes\",\n \"@agent-native/skills@latest\",\n \"add\",\n target,\n \"--client\",\n clientArgForClients(clients),\n \"--scope\",\n parsed.scope,\n ];\n if (parsed.withGithubAction) args.push(\"--with-github-action\");\n if (parsed.force) args.push(\"--force\");\n if (!parsed.connect) args.push(\"--no-connect\");\n for (const skill of parsed.plainSkillNames ?? []) {\n args.push(\"--skill\", skill);\n }\n if (parsed.updateInstructions === true) args.push(\"--update-instructions\");\n if (parsed.updateInstructions === false)\n args.push(\"--no-update-instructions\");\n if (parsed.yes) args.push(\"--yes\");\n return args;\n}\n\nasync function addPlainSkillRepo(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n): Promise<SkillsAddResult> {\n const target = parsed.target!;\n if (!parsed.instructions && parsed.mcp) {\n throw new Error(\n \"Plain skill repositories only install skill instructions. Run without --mcp-only.\",\n );\n }\n if (parsed.mcpUrl) {\n throw new Error(\n \"--mcp-url only applies to app-backed Agent Native skills.\",\n );\n }\n\n const clients = parsed.clients ?? resolveClients(parsed.client);\n const skillsAgents = skillsAgentsForClients(clients);\n if (skillsAgents.length === 0) {\n throw new Error(\n \"Plain skill repositories can only install instructions for Codex or Claude Code clients.\",\n );\n }\n const args = agentNativeSkillsInstallArgs(parsed, target, clients);\n if (!parsed.dryRun) {\n const code = await (options.runCommand ?? runCommand)(\"npx\", args, {\n stdio: parsed.yes ? \"silent\" : \"inherit\",\n });\n if (code !== 0)\n throw new Error(\n `npx @agent-native/skills@latest add exited with ${code}.`,\n );\n }\n options.telemetry?.track(\"skills_cli install completed\", {\n skills: target,\n clients: clients.join(\",\"),\n scope: parsed.scope,\n dryRun: Boolean(parsed.dryRun),\n });\n return {\n id: target,\n displayName: target,\n skillNames: [],\n skillsAgents,\n mcpUrl: \"\",\n mcpClients: [],\n dryRun: parsed.dryRun,\n commands: [commandString(\"npx\", args)],\n local: true,\n };\n}\n\n/**\n * Whether we can run the interactive browser/device auth flow. CI and\n * non-TTY shells must not block on a browser approval, so we skip the inline\n * flow there and surface the exact `agent-native connect` command instead.\n */\nfunction canRunInteractiveConnect(options: RunSkillsOptions): boolean {\n if (options.isInteractive) return options.isInteractive();\n if (process.env.AGENT_NATIVE_NO_PROMPT === \"1\") return false;\n if (process.env.CI === \"true\") return false;\n return !!process.stdin.isTTY && !!process.stdout.isTTY;\n}\n\n/** Build the `npx @agent-native/core@latest connect <url> --client … --scope …` command. */\nfunction connectCommandFor(\n hostedUrl: string,\n clients: ClientId[],\n scope: string,\n): string {\n const args = [\n \"@agent-native/core@latest\",\n \"connect\",\n hostedUrl,\n \"--client\",\n clientArgForClients(clients),\n \"--scope\",\n scope,\n ];\n return commandString(\"npx\", args);\n}\n\n/**\n * Authenticate the freshly-registered hosted MCP connector so the user does not\n * hit the OAuth wall on their first tool call. Reuses the existing\n * `agent-native connect` flow (OAuth-capable clients get URL-only config plus a\n * `/mcp` authenticate prompt; Codex / Cowork run the browser device-code flow).\n * In non-interactive shells we skip the inline flow and return the command to\n * run instead. Failures here are non-fatal: the connector is already registered,\n * so the user can authenticate later.\n */\nasync function connectAfterEnsure(\n installTarget: SkillInstallTarget,\n clients: ClientId[],\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n): Promise<{ connected: boolean; connectCommand: string }> {\n const hostedUrl = installTarget.loaded.manifest.hosted.url;\n const authMode = installTarget.loaded.manifest.auth?.mode ?? \"oauth\";\n const connectCommand = connectCommandFor(hostedUrl, clients, parsed.scope);\n\n // Skills whose connector needs no auth (e.g. open/local-only) never need the\n // connect step.\n if (authMode === \"none\") {\n return { connected: false, connectCommand: \"\" };\n }\n\n if (!canRunInteractiveConnect(options)) {\n options.log?.(\n `Authentication skipped (non-interactive). To finish auth, run: ${connectCommand}`,\n );\n return { connected: false, connectCommand };\n }\n\n options.log?.(`Authenticating ${installTarget.displayName}…`);\n options.telemetry?.track(\"skills_cli connect started\");\n try {\n await (options.runConnect ?? runConnect)([\n hostedUrl,\n \"--client\",\n clientArgForClients(clients),\n \"--scope\",\n parsed.scope,\n ]);\n options.telemetry?.track(\"skills_cli connect completed\");\n return { connected: true, connectCommand: \"\" };\n } catch (err: any) {\n // Non-fatal: the MCP connector is registered. Surface the manual command.\n options.telemetry?.track(\"skills_cli connect failed\", {\n error: err?.message ?? String(err),\n });\n options.log?.(\n `Could not finish authentication automatically (${err?.message ?? err}). ` +\n `Run it later with: ${connectCommand}`,\n );\n return { connected: false, connectCommand };\n }\n}\n\nexport async function addAgentNativeSkill(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions = {},\n): Promise<SkillsAddResult> {\n const target = parsed.target ?? \"assets\";\n const knownTarget = normalizeKnownSkillTarget(target);\n // For multi-skill bundles (the plan bundle), a single-skill target installs\n // only that skill. `installsRecap` controls the PR Visual Recap github-action\n // offer, which is only relevant when the recap skill is part of the install.\n const onlySkillNames = knownTarget\n ? builtInOnlySkillNames(target)\n : undefined;\n const installsRecap =\n knownTarget === \"visual-plans\" &&\n (!onlySkillNames || onlySkillNames.includes(\"visual-recap\"));\n if (!knownTarget && isPlainSkillRepoTarget(target)) {\n return addPlainSkillRepo({ ...parsed, target }, options);\n }\n if (!knownTarget && !fs.existsSync(path.resolve(target))) {\n throw new Error(\n `Unknown skill or manifest path: ${target}. Run \"npx @agent-native/core@latest skills list\".`,\n );\n }\n const knownBuiltIn = knownTarget ? BUILT_IN_APP_SKILLS[knownTarget] : null;\n if (isLocalOnlyBuiltInSkill(knownBuiltIn)) {\n if (parsed.mcpUrl) {\n throw new Error(\n \"Context X-Ray is installed locally and does not use --mcp-url yet.\",\n );\n }\n if (!parsed.instructions && parsed.mcp) {\n throw new Error(\n \"Context X-Ray does not need MCP config yet. Run without --mcp-only.\",\n );\n }\n const clients = parsed.clients ?? resolveClients(parsed.client);\n const skillsAgents = skillsAgentsForClients(clients);\n if (parsed.dryRun) {\n const githubActionPath =\n parsed.withGithubAction && knownTarget === \"visual-plans\"\n ? prVisualRecapWorkflowDisplayPath()\n : undefined;\n options.telemetry?.track(\"skills_cli install completed\", {\n skills: knownBuiltIn.skillName,\n clients: clients.join(\",\"),\n scope: parsed.scope,\n dryRun: true,\n });\n return {\n id: knownBuiltIn.manifest.id,\n displayName: knownBuiltIn.manifest.displayName,\n skillNames: [knownBuiltIn.skillName],\n skillsAgents,\n mcpUrl: \"\",\n mcpClients: [],\n dryRun: true,\n local: true,\n commands: [dryRunInstallCommand(parsed, target)],\n githubActionPath,\n };\n }\n const localInstall = installLocalContextXray({\n baseDir: options.baseDir ?? process.cwd(),\n clients,\n scope: parsed.scope,\n });\n options.telemetry?.track(\"skills_cli install completed\", {\n skills: knownBuiltIn.skillName,\n clients: clients.join(\",\"),\n scope: parsed.scope,\n dryRun: false,\n });\n return {\n id: knownBuiltIn.manifest.id,\n displayName: knownBuiltIn.manifest.displayName,\n instructionSource: localInstall.scriptPath,\n skillNames: [knownBuiltIn.skillName],\n skillsAgents,\n mcpUrl: \"\",\n mcpClients: [],\n dryRun: false,\n local: true,\n scriptPath: localInstall.scriptPath,\n written: localInstall.written,\n commands: localInstall.commands,\n };\n }\n let installTarget = loadSkillTarget(target, onlySkillNames);\n if (parsed.mcpUrl) {\n installTarget = withMcpUrlOverride(installTarget, parsed.mcpUrl);\n }\n const clients = parsed.clients ?? resolveClients(parsed.client);\n installTarget = preserveMcpUrlAppPathOverride(installTarget, parsed.mcpUrl);\n const skillsAgents = skillsAgentsForClients(clients);\n if (parsed.dryRun) {\n try {\n const githubActionPath =\n parsed.withGithubAction && installsRecap\n ? prVisualRecapWorkflowDisplayPath()\n : undefined;\n const githubActionSuggestedCommand =\n installsRecap && !parsed.withGithubAction\n ? prVisualRecapInstallCommand()\n : undefined;\n options.telemetry?.track(\"skills_cli install completed\", {\n skills: installTarget.skillNames.join(\",\"),\n clients: clients.join(\",\"),\n scope: parsed.scope,\n dryRun: true,\n });\n return {\n id: installTarget.id,\n displayName: installTarget.displayName,\n skillNames: installTarget.skillNames,\n skillsAgents,\n mcpUrl: installTarget.loaded.manifest.hosted.mcpUrl,\n mcpClients: clients,\n dryRun: true,\n commands: [dryRunInstallCommand(parsed, target)],\n githubActionPath,\n githubActionSuggestedCommand,\n };\n } finally {\n installTarget.cleanup?.();\n }\n }\n const commands: string[] = [];\n const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), \"an-skills-add-\"));\n let instructionSource: string | undefined;\n let instructionsWritten: string[] | undefined;\n let connected = false;\n let connectCommand: string | undefined;\n\n try {\n if (parsed.instructions) {\n if (skillsAgents.length === 0) {\n if (!parsed.mcp) {\n throw new Error(\n \"Skill instructions can only be installed for Codex or Claude Code clients. Use an MCP-capable client or omit --instructions-only.\",\n );\n }\n } else if (knownTarget) {\n // Built-in skills ship their instructions inside this package, so copy\n // the skill folders straight into each client's skills directory. This\n // avoids shelling out to the separate @agent-native/skills installer\n // (which would need to be published to npm to run via npx).\n instructionsWritten = installBuiltInInstructions({\n appSkillId: knownTarget,\n onlySkillNames,\n skillsAgents,\n scope: parsed.scope as \"project\" | \"user\",\n baseDir: options.baseDir ?? process.cwd(),\n dryRun: parsed.dryRun,\n });\n instructionSource = instructionsWritten[0];\n commands.push(...instructionsWritten.map((dir) => `write ${dir}`));\n } else {\n // External app-skill manifests / plain skill repos still go through the\n // standalone installer, which knows how to pack adapters and fetch\n // remote skill collections.\n instructionSource = installTarget.materializeInstructions(tmpRoot);\n const args = [\n \"--yes\",\n \"@agent-native/skills@latest\",\n \"add\",\n instructionSource,\n \"--copy\",\n ...installTarget.skillNames.flatMap((skill) => [\"--skill\", skill]),\n ...skillsAgents.flatMap((agent) => [\"-a\", agent]),\n ...(parsed.scope === \"user\" ? [\"-g\"] : []),\n ...(parsed.yes || knownTarget ? [\"-y\"] : []),\n ];\n commands.push(commandString(\"npx\", args));\n if (!parsed.dryRun) {\n const code = await (options.runCommand ?? runCommand)(\"npx\", args, {\n stdio: \"silent\",\n });\n if (code !== 0)\n throw new Error(\n `npx @agent-native/skills@latest add exited with ${code}.`,\n );\n }\n }\n }\n\n // Skill instructions are now on disk (built-in folders copied or external\n // pack materialized) — record the install before MCP registration/connect.\n options.telemetry?.track(\"skills_cli install completed\", {\n skills: installTarget.skillNames.join(\",\"),\n clients: clients.join(\",\"),\n scope: parsed.scope,\n dryRun: Boolean(parsed.dryRun),\n });\n\n if (parsed.mcp) {\n commands.push(\n `npx @agent-native/core@latest app-skill ensure --manifest ${installTarget.loaded.file} --client ${parsed.client} --scope ${parsed.scope} --yes`,\n );\n if (!parsed.dryRun) {\n await ensureAppSkill(installTarget.loaded, {\n clients,\n scope: parsed.scope,\n baseDir: options.baseDir,\n yes: parsed.yes || Boolean(knownTarget),\n confirm: true,\n log: options.log,\n });\n options.telemetry?.track(\"skills_cli mcp registered\", {\n skills: installTarget.skillNames.join(\",\"),\n });\n\n // One-step install + authenticate: after registering a hosted MCP\n // connector, kick off the existing connect/device-code flow so the user\n // does not hit an OAuth wall on the first tool call. `--no-connect`\n // opts out; non-interactive shells get the exact command to run.\n if (parsed.connect) {\n const result = await connectAfterEnsure(\n installTarget,\n clients,\n parsed,\n options,\n );\n connected = result.connected;\n connectCommand = result.connectCommand || undefined;\n if (connectCommand) commands.push(connectCommand);\n }\n }\n }\n\n // `--with-github-action`: also drop the PR Visual Recap workflow into the\n // repo so PRs get automatic recaps. Only meaningful for the plan family.\n const baseDir = options.baseDir ?? process.cwd();\n let withGithubAction = Boolean(parsed.withGithubAction);\n let githubActionPath: string | undefined;\n let githubActionExisted: boolean | undefined;\n let githubActionSuggestedCommand: string | undefined;\n if (\n installsRecap &&\n !withGithubAction &&\n !fs.existsSync(prVisualRecapWorkflowPath(baseDir))\n ) {\n // Normally the recap decision is made up front in `runSkills` (so it's\n // resolved here). Only prompt inline when a direct caller invoked\n // addAgentNativeSkill without going through that up-front step.\n if (!parsed.githubActionResolved && shouldPrompt(parsed, options)) {\n const prompt = options.promptGithubAction ?? promptForGithubAction;\n const choice = await prompt({\n workflowPath: prVisualRecapWorkflowDisplayPath(),\n setupCommand: prVisualRecapSetupCommand(),\n });\n if (choice === null) {\n options.telemetry?.track(\"skills_cli cancelled\", {\n step: \"github-action\",\n });\n }\n withGithubAction = choice === true;\n }\n if (!withGithubAction) {\n githubActionSuggestedCommand = prVisualRecapInstallCommand();\n }\n }\n\n if (withGithubAction) {\n if (!installsRecap) {\n options.log?.(\n \"--with-github-action only applies to the visual-recap skill; skipping the workflow.\",\n );\n } else {\n const writeResult = writePrVisualRecapWorkflow(baseDir, {\n force: Boolean(parsed.force),\n });\n if (writeResult.status === \"refused\") {\n throw new Error(`recap workflow: ${writeResult.message}`);\n }\n githubActionPath = writeResult.path;\n githubActionExisted =\n writeResult.status === \"written\" ? writeResult.existed : false;\n commands.push(`write ${writeResult.path}`);\n options.telemetry?.track(\"skills_cli github action added\");\n }\n }\n\n return {\n id: installTarget.id,\n displayName: installTarget.displayName,\n instructionSource,\n skillNames: installTarget.skillNames,\n skillsAgents,\n mcpUrl: installTarget.loaded.manifest.hosted.mcpUrl,\n mcpClients: clients,\n dryRun: parsed.dryRun,\n commands,\n written: instructionsWritten,\n connected,\n connectCommand,\n githubActionPath,\n githubActionExisted,\n githubActionSuggestedCommand,\n };\n } finally {\n fs.rmSync(tmpRoot, { recursive: true, force: true });\n installTarget.cleanup?.();\n }\n}\n\nfunction listSkills() {\n return Object.values(BUILT_IN_APP_SKILLS).map((entry) => ({\n id: entry.manifest.id,\n aliases:\n BUILT_IN_APP_SKILL_DISPLAY_ALIASES[\n entry.manifest.id as BuiltInAppSkillId\n ] ?? [],\n name: entry.manifest.displayName,\n description: entry.manifest.description,\n mcpUrl: isLocalOnlyBuiltInSkill(entry) ? \"\" : entry.manifest.hosted.mcpUrl,\n local: isLocalOnlyBuiltInSkill(entry),\n }));\n}\n\nfunction skillStateJson(state: SkillInstallState) {\n return {\n appSkillId: state.appSkillId,\n displayName: state.displayName,\n skillName: state.skillName,\n path: state.path,\n scope: state.scope,\n client: state.client,\n status: state.current ? \"current\" : \"stale\",\n managed: state.managed,\n installedHash: state.installedHash,\n latestHash: state.latestHash,\n metadataHash: state.metadataHash,\n };\n}\n\nfunction formatSkillState(state: SkillInstallState): string {\n const status = state.current ? \"current\" : \"stale\";\n const managed = state.managed ? \"managed\" : \"unmarked\";\n const hashes =\n state.installedHash && !state.current\n ? ` (${state.installedHash} -> ${state.latestHash})`\n : \"\";\n return `${state.skillName.padEnd(22)} ${status.padEnd(7)} ${state.scope}/${state.client} ${managed}${hashes}\\n ${state.path}`;\n}\n\nfunction runSkillsStatusOrUpdate(\n parsed: ParsedSkillsArgs,\n options: RunSkillsOptions,\n update: boolean,\n): void {\n const before = collectSkillInstallStates(parsed, options);\n const changed = update ? updateSkillInstallStates(before, parsed.dryRun) : [];\n const after =\n update && !parsed.dryRun\n ? collectSkillInstallStates(parsed, options)\n : before;\n\n if (parsed.printJson) {\n const outputStates = update && !parsed.dryRun ? after : before;\n process.stdout.write(\n `${JSON.stringify(\n {\n ok: true,\n command: parsed.command,\n dryRun: parsed.dryRun,\n found: before.length,\n stale: outputStates.filter((state) => !state.current).length,\n updated: changed.length,\n skills: outputStates.map(skillStateJson),\n },\n null,\n 2,\n )}\\n`,\n );\n return;\n }\n\n if (before.length === 0) {\n const target = parsed.target ? ` for ${parsed.target}` : \"\";\n process.stdout.write(\n `No installed Agent Native skill copies found${target}.\\nRun \"npx @agent-native/core@latest skills add ${parsed.target ?? \"visual-plan\"}\" to install one.\\n`,\n );\n return;\n }\n\n if (update) {\n if (parsed.dryRun) {\n process.stdout.write(\n changed.length\n ? `Would update ${changed.length} skill folder${changed.length === 1 ? \"\" : \"s\"}:\\n`\n : \"All discovered skill folders are already current.\\n\",\n );\n } else {\n process.stdout.write(\n changed.length\n ? `Updated ${changed.length} skill folder${changed.length === 1 ? \"\" : \"s\"}.\\n`\n : \"All discovered skill folders are already current.\\n\",\n );\n }\n }\n\n const rows = (update && parsed.dryRun ? before : after).map(formatSkillState);\n process.stdout.write(`${rows.join(\"\\n\")}\\n`);\n}\n\n/**\n * Resolve the CLI version the same way `index.ts` does — read it from the\n * package.json two levels up from the compiled module (dist/cli/skills.js →\n * ../../package.json). Best-effort: falls back to \"unknown\".\n */\nfunction readCliVersion(): string {\n try {\n const here = path.dirname(fileURLToPath(import.meta.url));\n const pkg = JSON.parse(\n fs.readFileSync(path.resolve(here, \"../../package.json\"), \"utf8\"),\n ) as { version?: unknown };\n return typeof pkg.version === \"string\" ? pkg.version : \"unknown\";\n } catch {\n return \"unknown\";\n }\n}\n\nexport async function runSkills(\n argv: string[],\n options: RunSkillsOptions = {},\n): Promise<void> {\n const parsed = parseSkillsArgs(argv);\n const log = parsed.printJson\n ? undefined\n : (message: string) => process.stdout.write(`${message}\\n`);\n\n if (parsed.command === \"help\") {\n process.stdout.write(`${HELP}\\n`);\n return;\n }\n\n // `@agent-native/skills` now delegates its interactive install to this\n // function. For plain skill repos we still shell out to\n // `npx @agent-native/skills@latest add …`; this env guard tells that child process\n // to run its OWN headless installer instead of bouncing back into core,\n // which would otherwise be an infinite skills → core → skills loop.\n process.env.AGENT_NATIVE_SKILLS_DIRECT = \"1\";\n\n // Best-effort install-funnel telemetry. Created once per run and flushed in a\n // finally so events send on success, error, and cancellation — the CLI is\n // short-lived, so flushing before exit is essential or the events never send.\n const startedAt = Date.now();\n const telemetry =\n options.telemetry ??\n createCliTelemetry({\n cli: \"core\",\n cliVersion: readCliVersion(),\n command: parsed.command,\n interactive: shouldPrompt(parsed, options),\n });\n const optionsWithTelemetry: RunSkillsOptions = { ...options, telemetry };\n\n try {\n telemetry.track(\"skills_cli started\");\n\n if (parsed.command === \"list\") {\n const skills = listSkills();\n telemetry.track(\"skills_cli skills listed\", {\n availableCount: skills.length,\n available: skills.map((skill) => skill.id).join(\",\"),\n });\n if (parsed.printJson) {\n process.stdout.write(`${JSON.stringify(skills, null, 2)}\\n`);\n return;\n }\n for (const skill of skills) {\n const description = skill.description.replace(/[.?!]?$/, \".\");\n const aliases = skill.aliases.length\n ? ` Aliases: ${skill.aliases.join(\", \")}.`\n : \"\";\n const target = skill.local ? \"local command\" : skill.mcpUrl;\n process.stdout.write(\n `${skill.id.padEnd(12)} ${description}${aliases} (${target})\\n`,\n );\n }\n return;\n }\n\n if (parsed.command === \"status\" || parsed.command === \"update\") {\n runSkillsStatusOrUpdate(parsed, options, parsed.command === \"update\");\n return;\n }\n\n const targets = await resolveSkillTargets(parsed, optionsWithTelemetry);\n if (!targets) {\n telemetry.track(\"skills_cli cancelled\", { step: \"skills\" });\n return;\n }\n const preselected = Boolean(parsed.target);\n telemetry.track(\"skills_cli skills selected\", {\n selected: targets.join(\",\"),\n selectedCount: targets.length,\n // Best-effort \"took everything offered\" signal: compare against the\n // interactive picker's option count (the plan sub-skills collapse into a\n // single bundle target, so this is approximate, like the standalone CLI).\n selectedAll: targets.length === skillPromptOptions().length,\n preselected,\n });\n\n const clients = await resolveSkillsClients(parsed, optionsWithTelemetry);\n if (!clients) {\n telemetry.track(\"skills_cli cancelled\", { step: \"clients\" });\n return;\n }\n telemetry.track(\"skills_cli clients selected\", {\n clients: clients.join(\",\"),\n clientCount: clients.length,\n });\n\n // Ask where to install (project vs user) unless an explicit --scope was\n // passed or we are running non-interactively.\n if (!parsed.scopeExplicit && shouldPrompt(parsed, options)) {\n const promptScope = options.promptScope ?? promptForScope;\n const scope = await promptScope({ initialScope: \"project\" });\n if (!scope) {\n telemetry.track(\"skills_cli cancelled\", { step: \"scope\" });\n return;\n }\n parsed.scope = scope;\n }\n telemetry.track(\"skills_cli scope selected\", { scope: parsed.scope });\n\n // Decide the optional PR Visual Recap GitHub Action UP FRONT — before any\n // install or MCP registration — so every prompt is answered before we touch\n // disk. The choice is threaded into each install via `withGithubAction` +\n // `githubActionResolved` (so addAgentNativeSkill doesn't re-prompt mid-flow).\n const recapBaseDir = options.baseDir ?? process.cwd();\n const anyRecapTarget = targets.some((target) => {\n if (normalizeKnownSkillTarget(target) !== \"visual-plans\") return false;\n const only = builtInOnlySkillNames(target);\n return !only || only.includes(\"visual-recap\");\n });\n if (\n anyRecapTarget &&\n !parsed.withGithubAction &&\n !fs.existsSync(prVisualRecapWorkflowPath(recapBaseDir)) &&\n shouldPrompt(parsed, options)\n ) {\n const prompt = options.promptGithubAction ?? promptForGithubAction;\n const choice = await prompt({\n workflowPath: prVisualRecapWorkflowDisplayPath(),\n setupCommand: prVisualRecapSetupCommand(),\n });\n if (choice === null) {\n telemetry.track(\"skills_cli cancelled\", { step: \"github-action\" });\n }\n parsed.withGithubAction = choice === true;\n parsed.githubActionResolved = true;\n }\n\n const results: SkillsAddResult[] = [];\n for (const target of targets) {\n results.push(\n await addAgentNativeSkill(\n {\n ...parsed,\n target,\n client: clientArgForClients(clients),\n clients,\n },\n {\n ...optionsWithTelemetry,\n log,\n },\n ),\n );\n }\n\n // The add flow succeeded for every target — record the funnel completion\n // before printing output (output below cannot fail the install).\n const completedSkills = [\n ...new Set(results.flatMap((result) => result.skillNames)),\n ];\n const completedClients = [\n ...new Set(results.flatMap((result) => result.mcpClients)),\n ];\n telemetry.track(\"skills_cli completed\", {\n skills: completedSkills.join(\",\"),\n clients: completedClients.join(\",\"),\n scope: parsed.scope,\n durationMs: Date.now() - startedAt,\n });\n\n if (parsed.printJson) {\n process.stdout.write(\n `${JSON.stringify(results.length === 1 ? results[0] : results, null, 2)}\\n`,\n );\n return;\n }\n\n if (parsed.dryRun) {\n process.stdout.write(\n `${results.flatMap((result) => result.commands).join(\"\\n\")}\\n`,\n );\n return;\n }\n\n const installedNames = results\n .map((result) => result.displayName)\n .join(\", \");\n const skillsAgents = [\n ...new Set(results.flatMap((result) => result.skillsAgents)),\n ];\n const mcpClients = [\n ...new Set(results.flatMap((result) => result.mcpClients)),\n ];\n const mcpUrls = [\n ...new Set(results.map((result) => result.mcpUrl).filter(Boolean)),\n ];\n const localCommands = [\n ...new Set(\n results\n .filter((result) => result.local)\n .flatMap((result) => result.commands),\n ),\n ];\n const authConnected = results.some((result) => result.connected);\n const pendingConnectCommands = [\n ...new Set(\n results\n .map((result) => result.connectCommand)\n .filter((command): command is string => Boolean(command)),\n ),\n ];\n const authLine = authConnected\n ? \"Authentication: completed.\"\n : pendingConnectCommands.length\n ? `Authentication: pending — run ${pendingConnectCommands.join(\" && \")}`\n : \"\";\n const githubActions = [\n ...new Set(\n results\n .map((result) => result.githubActionPath)\n .filter((p): p is string => Boolean(p)),\n ),\n ];\n const githubActionLine = githubActions.length\n ? `PR Visual Recap workflow: wrote ${githubActions.join(\", \")}.\\nNext: run ${prVisualRecapSetupCommand()} to configure GitHub secrets/variables, or set them manually:\\n ${PR_VISUAL_RECAP_SETUP.join(\"\\n \")}`\n : \"\";\n const githubActionSuggestions = [\n ...new Set(\n results\n .map((result) => result.githubActionSuggestedCommand)\n .filter((command): command is string => Boolean(command)),\n ),\n ];\n const githubActionSuggestionLine = githubActionSuggestions.length\n ? `Optional PR Visual Recap workflow: run ${githubActionSuggestions.join(\n \" && \",\n )} to add automatic recap comments on pull requests.`\n : \"\";\n const clack = await import(\"@clack/prompts\");\n const summary = [\n skillsAgents.length\n ? `Skill instructions ${skillsAgents.join(\", \")}`\n : \"Skill instructions skipped\",\n mcpClients.length\n ? `MCP config ${mcpClients.join(\", \")}`\n : \"MCP config not required\",\n mcpUrls.length ? `MCP URL ${mcpUrls.join(\", \")}` : \"\",\n authConnected\n ? \"Authentication completed\"\n : pendingConnectCommands.length\n ? `Authentication pending — run ${pendingConnectCommands.join(\" && \")}`\n : \"\",\n localCommands.length\n ? `Local command ${localCommands.join(\", \")}`\n : \"\",\n ].filter(Boolean);\n clack.note(\n summary.join(\"\\n\"),\n `Installed ${installedNames} skill${results.length === 1 ? \"\" : \"s\"}`,\n );\n\n // GitHub Action follow-ups — kept as exact, copy-pasteable command lines.\n for (const line of [githubActionLine, githubActionSuggestionLine].filter(\n Boolean,\n )) {\n process.stdout.write(`${line}\\n`);\n }\n\n const slashCommands = completedSkills.map((name) => `/${name}`).join(\" \");\n const configuredEveryClient = CLIENTS.every((client) =>\n clients.includes(client),\n );\n const clientHint = configuredEveryClient\n ? \"\"\n : \"\\n Add another client later with --client <client> (e.g. --client claude-code).\";\n clack.outro(\n `✅ All set! Start using ${slashCommands || \"your new skills\"} in your agent client.` +\n `\\n You may need to reload the client for the skill + MCP server to appear.` +\n clientHint,\n );\n } catch (error) {\n telemetry.track(\"skills_cli failed\", {\n command: parsed.command,\n error: error instanceof Error ? error.message : String(error),\n durationMs: Date.now() - startedAt,\n });\n throw error;\n } finally {\n await telemetry.flush();\n }\n}\n"]}