@hybridlabor-api/aos 4.13.2 → 4.14.1

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 (151) hide show
  1. package/.agents/AGENTS.md +8 -0
  2. package/.agents/nodes.json +5 -2
  3. package/.claude/hooks/conventional-commits.mjs +14 -15
  4. package/.claude/hooks/env-file-protection.mjs +14 -15
  5. package/.claude/hooks/go-gate.mjs +152 -10
  6. package/.claude/hooks/go-token.mjs +55 -0
  7. package/.claude/hooks/memb-inject.mjs +75 -62
  8. package/.claude/hooks/trail-autostart.mjs +27 -0
  9. package/.claude/hooks/trail-relay.mjs +1 -0
  10. package/.claude/settings.json +22 -4
  11. package/.claude/workflows/startcycle-dispatch.mjs +11 -4
  12. package/.opencode/plugins/bdb-aos.js +98 -121
  13. package/.opencode/plugins/lib/trail-autostart.js +38 -0
  14. package/CLAUDE.md +1 -1
  15. package/README.de.md +6 -6
  16. package/README.md +6 -6
  17. package/README.pt.md +6 -6
  18. package/THIRD_PARTY_NOTICES.md +19 -3
  19. package/assets/header-v5.png +0 -0
  20. package/bin/aos-acp.mjs +211 -0
  21. package/bin/aos-doctor.mjs +1 -1
  22. package/bin/aos-uninstall.mjs +2 -2
  23. package/docs/master-session-acp.md +51 -0
  24. package/installer.js +314 -42
  25. package/mcps/mcsc/packages/mcp/server.js +6 -7
  26. package/package.json +4 -3
  27. package/scripts/validate-skills.mjs +76 -0
  28. package/skills/basic/bdbmediastorm/SKILL.md +1 -1
  29. package/skills/basic/godmode-shipping/SKILL.md +3 -0
  30. package/skills/basic/master-session/SKILL.md +89 -0
  31. package/skills/basic/startcycle/SKILL.md +1 -1
  32. package/skills/basic/startcycle-graph/SKILL.md +2 -2
  33. package/skills/basic/startcycle-graph-user/SKILL.md +1 -1
  34. package/skills/basic/teamwork-preview/SKILL.md +1 -1
  35. package/skills/bdbrainstorm/SKILL.md +7 -1
  36. package/skills/global_config/agentic-harness-patterns/SKILL.md +257 -0
  37. package/skills/global_config/agentic-harness-patterns/metadata.json +10 -0
  38. package/skills/global_config/agentic-harness-patterns/references/agent-orchestration-pattern.md +97 -0
  39. package/skills/global_config/agentic-harness-patterns/references/bootstrap-sequence-pattern.md +106 -0
  40. package/skills/global_config/agentic-harness-patterns/references/context-engineering/compress-pattern.md +78 -0
  41. package/skills/global_config/agentic-harness-patterns/references/context-engineering/isolate-pattern.md +82 -0
  42. package/skills/global_config/agentic-harness-patterns/references/context-engineering/select-pattern.md +86 -0
  43. package/skills/global_config/agentic-harness-patterns/references/context-engineering-pattern.md +29 -0
  44. package/skills/global_config/agentic-harness-patterns/references/hook-lifecycle-pattern.md +111 -0
  45. package/skills/global_config/agentic-harness-patterns/references/memory-persistence-pattern.md +109 -0
  46. package/skills/global_config/agentic-harness-patterns/references/permission-gate-pattern.md +111 -0
  47. package/skills/global_config/agentic-harness-patterns/references/skill-runtime-pattern.md +104 -0
  48. package/skills/global_config/agentic-harness-patterns/references/task-decomposition-pattern.md +92 -0
  49. package/skills/global_config/agentic-harness-patterns/references/tool-registry-pattern.md +101 -0
  50. package/skills/global_config/agenttrail/SKILL.md +8 -0
  51. package/skills/global_config/agenttrail/bin/agenttrail.mjs +14 -0
  52. package/skills/global_config/agenttrail/bin/ensure.mjs +118 -0
  53. package/skills/global_config/aos-setup/scripts/aos-doctor.mjs +1 -1
  54. package/skills/global_config/bdb-visual-edit/SKILL.md +51 -0
  55. package/skills/global_config/bdb-visual-edit/references/vite-react-source-attr.md +59 -0
  56. package/skills/global_config/bdb-visual-edit/scripts/pick-snippet.js +27 -0
  57. package/skills/global_config/bdb-visual-edit/scripts/sanitize-element.mjs +123 -0
  58. package/skills/global_config/factory-collect/SKILL.md +74 -0
  59. package/skills/global_config/factory-human-digest/SKILL.md +92 -0
  60. package/skills/global_config/factory-lookback/SKILL.md +95 -0
  61. package/skills/global_config/factory-review-prs/SKILL.md +63 -0
  62. package/skills/global_config/git-pr-review/SKILL.md +3 -0
  63. package/skills/global_config/grilling/SKILL.md +2 -0
  64. package/skills/global_config/mcsc/SKILL.md +1 -1
  65. package/skills/global_config/plan-arbiter/SKILL.md +125 -0
  66. package/skills/global_config/plan-canvas/SKILL.md +62 -5
  67. package/skills/global_config/plan-canvas/scripts/lib/loopback-guard.js +19 -3
  68. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/README.md +285 -0
  69. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/agent-trail.js +129 -0
  70. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/board-client.js +124 -0
  71. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/demo-plan/canvas.mdx +19 -0
  72. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/demo-plan/plan.mdx +18 -0
  73. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/recap-demo/plan.mdx +72 -0
  74. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/README.md +29 -0
  75. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/architecture.json +30 -0
  76. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/builder/00_architecture.html +14950 -0
  77. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/builder/canvas.mdx +511 -0
  78. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/builder/plan.mdx +208 -0
  79. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/recap/plan.mdx +102 -0
  80. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/standard/plan.md +136 -0
  81. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/signup-storyboard/canvas.mdx +124 -0
  82. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/signup-storyboard/plan.mdx +37 -0
  83. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/index.js +188 -0
  84. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/kit.js +123 -0
  85. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/mdx.js +411 -0
  86. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/render.js +1291 -0
  87. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/architecture/meta.json +1 -0
  88. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/architecture/plan.mdx +195 -0
  89. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/architecture/standard.md +95 -0
  90. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/bugfix/meta.json +1 -0
  91. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/bugfix/plan.mdx +105 -0
  92. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/bugfix/standard.md +76 -0
  93. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/feature/canvas.mdx +81 -0
  94. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/feature/meta.json +1 -0
  95. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/feature/plan.mdx +145 -0
  96. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/feature/standard.md +76 -0
  97. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/migration/meta.json +1 -0
  98. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/migration/plan.mdx +172 -0
  99. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/migration/standard.md +100 -0
  100. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap/meta.json +1 -0
  101. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap/plan.mdx +67 -0
  102. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap/standard.md +49 -0
  103. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-board/canvas.mdx +63 -0
  104. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-board/meta.json +1 -0
  105. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-board/plan.mdx +49 -0
  106. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-board/standard.md +39 -0
  107. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-review/meta.json +1 -0
  108. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-review/plan.mdx +118 -0
  109. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-review/standard.md +57 -0
  110. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/release/meta.json +1 -0
  111. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/release/plan.mdx +173 -0
  112. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/release/standard.md +96 -0
  113. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/research/meta.json +1 -0
  114. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/research/plan.mdx +91 -0
  115. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/research/standard.md +54 -0
  116. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/show-control/canvas.mdx +53 -0
  117. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/show-control/meta.json +1 -0
  118. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/show-control/plan.mdx +225 -0
  119. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/show-control/standard.md +111 -0
  120. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/theme.css +472 -0
  121. package/skills/global_config/plan-canvas/scripts/lib/plan-builder/trail.js +216 -0
  122. package/skills/global_config/plan-canvas/scripts/lib/plan-canvas/markdown.js +1 -1
  123. package/skills/global_config/plan-canvas/scripts/lib/plan-canvas/server.js +37 -4
  124. package/skills/global_config/plan-canvas/scripts/lib/plan-canvas/ui.js +125 -29
  125. package/skills/global_config/plan-canvas/scripts/plan-canvas.js +196 -8
  126. package/skills/global_config/pr-recap/SKILL.md +47 -0
  127. package/skills/global_config/pr-recap/scripts/pr-recap.mjs +200 -0
  128. package/skills/global_config/quick-recap/SKILL.md +55 -0
  129. package/skills/global_config/stay-within-limits/SKILL.md +85 -0
  130. package/skills/global_config/triage/SKILL.md +3 -0
  131. package/skills/global_config/visual-edit/README.md +96 -0
  132. package/skills/global_config/visual-edit/SKILL.md +615 -0
  133. package/skills/global_config/visual-plan/README.md +93 -0
  134. package/skills/global_config/visual-plan/SKILL.md +544 -0
  135. package/skills/global_config/visual-plan/references/canvas.md +139 -0
  136. package/skills/global_config/visual-plan/references/connection.md +51 -0
  137. package/skills/global_config/visual-plan/references/document-quality.md +186 -0
  138. package/skills/global_config/visual-plan/references/exemplar.md +62 -0
  139. package/skills/global_config/visual-plan/references/local-files.md +99 -0
  140. package/skills/global_config/visual-plan/references/wireframe.md +319 -0
  141. package/skills/global_config/visual-recap/README.md +103 -0
  142. package/skills/global_config/visual-recap/SKILL.md +560 -0
  143. package/skills/global_config/visual-recap/references/connection.md +51 -0
  144. package/skills/global_config/visual-recap/references/local-files.md +99 -0
  145. package/skills/global_config/visual-recap/references/wireframe.md +319 -0
  146. package/skills/playbooks/pb-ci-fix/SKILL.md +49 -0
  147. package/skills/playbooks/pb-event-tracker/SKILL.md +45 -0
  148. package/skills/playbooks/pb-meeting-actions/SKILL.md +42 -0
  149. package/skills/playbooks/pb-project-new/SKILL.md +48 -0
  150. package/skills/playbooks/pb-week-plan/SKILL.md +45 -0
  151. package/assets/header-v4.jpg +0 -0
@@ -0,0 +1,615 @@
1
+ ---
2
+ name: visual-edit
3
+ description: Open and collaboratively edit a running local app in Design, with shared fallback previews and source handoff. Use when the user asks to inspect, share, or edit a real local app in Design.
4
+ category: design-ui-ux
5
+ source: BuilderIO/skills
6
+ ---
7
+
8
+ # Visual Edit
9
+
10
+ Use `/visual-edit` when the user wants to inspect or edit a real local app
11
+ visually instead of generating standalone Alpine HTML. The source of truth is
12
+ the running localhost app plus its route URLs. Design shows those routes as
13
+ iframe-backed screens on the infinite canvas.
14
+
15
+ The editor is hosted at `https://design.agent-native.com`. Never start local
16
+ Design; only the target app and bridge run locally.
17
+
18
+ See the [Visual Edit guide](https://github.com/BuilderIO/agent-native/blob/main/skills/visual-edit/README.md)
19
+ for a worked onboarding-flow example.
20
+
21
+ ## Fast local startup
22
+
23
+ - Do not install this skill into the target app or start a local Design server.
24
+ The skill belongs to the coding host; Design is always the hosted app above.
25
+ - If you need to start an Agent-Native framework app yourself, use
26
+ `AUTH_DISABLED=1` with its normal dev command. This is local-only and gives
27
+ the visual editor the framework's dev identity without a user login.
28
+ - If an agent-owned local server redirects a requested screen to its sign-in route,
29
+ restart that server with `AUTH_DISABLED=1` and probe the route again before
30
+ opening Design. Never present a sign-in page as the requested screen.
31
+ - Before calling `open-visual-edit`, verify the target URL responds. Start an
32
+ agent-owned dev server with its normal command when it is down, and wait for
33
+ the requested routes to respond before opening Design. Never leave a dead
34
+ localhost URL in the canvas.
35
+ - Preserve a server you did not start; use its existing authenticated browser
36
+ session or explain that the target app, rather than Design, requires login.
37
+ - When the user gives explicit paths, skip route inventory and place those
38
+ paths directly. Discover routes only when paths were not supplied.
39
+
40
+ ## Installation
41
+
42
+ `npx @agent-native/core@latest skills add visual-edit` installs the skill and
43
+ hosted Design MCP connector. `npx skills@latest add BuilderIO/agent-native
44
+ --skill visual-edit` installs instructions only; page-capable WebMCP hosts need
45
+ no connector installation.
46
+
47
+ ## Put Design Beside The Chat
48
+
49
+ Prefer the interactive MCP App from `open-visual-edit`: it keeps Design beside
50
+ chat and routes **Apply design updates** through the host's MCP Apps bridge. The
51
+ host may ask the user to confirm the current conversation. Otherwise,
52
+ `openUrl` is a credential-free, read-only fallback; never claim it is editable.
53
+
54
+ - Inline-browser hosts should open `https://design.agent-native.com/visual-edit`
55
+ and call its `open-visual-edit` WebMCP tool. It works signed in or out; the
56
+ one-time capability is not a Design account session. A page-capable browser
57
+ controller is enough, so Claude-in-Chrome, Claude Code browser tools, the
58
+ ChatGPT Chrome/browser extension, Puppeteer or Playwright MCP, CDP, and
59
+ similar JavaScript-capable controllers do not need the hosted MCP connector.
60
+ - VS Code uses its Design webview/deep link. Without page WebMCP, use the hosted
61
+ Design MCP connector and its normal OAuth/device authorization. Never replace
62
+ either path with a local Design server.
63
+
64
+ Inside Design, use **Show/Hide UI** from the `Cmd K` menu or press Figma's
65
+ `Shift \` shortcut to toggle all editing chrome so only the canvas remains.
66
+
67
+ ## Browser WebMCP (Default Without Connector)
68
+
69
+ Without a connected Design MCP, use a visible browser tab with a main-world
70
+ JavaScript evaluator. Prefer the host's inline browser; use external Chrome
71
+ only when requested or unavailable. Open
72
+ `https://design.agent-native.com/visual-edit`, keep it visible while tools
73
+ register, and read the title before work. Never enter, copy, or request
74
+ passwords, cookies, tokens, or codes. Signed-out loopback visual-edit works;
75
+ other pages that block tools behind sign-in still require a signed-in tab.
76
+ If the browser exposes CDP permissions, grant `local-network-access` to
77
+ `https://design.agent-native.com` before calling page tools; otherwise use the
78
+ page's Connect button and let the browser's permission prompt complete.
79
+
80
+ Use a native browser-session WebMCP bridge when the host provides one: list
81
+ once with `list-browser-session-webmcp-tools` and run with
82
+ `run-browser-session-webmcp-tool`, or use the `list-host-webmcp-tools` and
83
+ `run-host-webmcp-tool` pair. Preserve the exact discovered name, origin, and
84
+ args. Otherwise use the page-world API. Agent-Native pages expose this helper:
85
+
86
+ Example assumes signed-in or existing bridge; fresh signed-out loopback must add
87
+ the locally held `bridgeToken` described below.
88
+
89
+ ```js
90
+ const an = window.__agentNativeWebMcp;
91
+ const status = await an.ready({ waitMs: 20_000 });
92
+ if (status.state !== "ready") throw new Error(status.error ?? status.state);
93
+ const tools = await an.tools("visual-edit");
94
+ if (!tools.some((tool) => tool.name === "open-visual-edit")) {
95
+ throw new Error("open-visual-edit is not registered yet");
96
+ }
97
+ const result = await an.call("open-visual-edit", {
98
+ devServerUrl: "http://localhost:5173",
99
+ paths: ["/"],
100
+ navigate: true,
101
+ }, { waitMs: 2_000 });
102
+ if (result.state === "pending") {
103
+ // On the next evaluation, read the still-running call without replaying it.
104
+ an.result(result.id);
105
+ }
106
+ ```
107
+
108
+ If the helper is absent, use standard WebMCP directly. `document.modelContext`
109
+ is canonical; `navigator.modelContext` is deprecated:
110
+
111
+ ```js
112
+ const ctx = document.modelContext;
113
+ const tool = (await ctx.getTools()).find((candidate) => candidate.name === NAME);
114
+ if (!tool) throw new Error(`WebMCP tool not found: ${NAME}`);
115
+ const codex = typeof ctx.codexExecuteTool === "function" ||
116
+ typeof ctx.codexGetTools === "function";
117
+ const result = await ctx.executeTool(tool, codex ? ARGS : JSON.stringify(ARGS));
118
+ ```
119
+
120
+ The helper handles live discovery, partial registries, and pending calls. If a
121
+ call returns `state: "pending"`, read `an.result(id)` on the next evaluation;
122
+ never replay a write. For Claude Code or Cowork, `javascript_tool` runs this
123
+ page-world code with top-level `await`; for Codex open the page with
124
+ `cua.createBrowserTab("iab", url, { visible: true })`, then use CDP
125
+ `Runtime.evaluate` with `awaitPromise: true`; Puppeteer and Playwright MCP can
126
+ use their page evaluator. Playwright isolated worlds cannot see
127
+ `document.modelContext`. Keep evaluator output small, batch dependent calls,
128
+ and do not navigate inside a batch.
129
+
130
+ Tool descriptors are page-local. Do not copy them into the host, hand-build
131
+ authenticated HTTP requests, or replace named tools with clicks, typing, DOM
132
+ automation, or screenshots. UI automation remains appropriate for canvas work
133
+ without a named tool or when requested. If both bridges are unavailable after
134
+ one discovery and one independent evaluator check, use hosted MCP/CLI before
135
+ changing state.
136
+
137
+ For a fresh signed-out loopback connection, generate the bridge token locally,
138
+ start the durable bridge with it, and pass that same token once as the page
139
+ tool's `bridgeToken`; the page never returns it. Reuse a matching running
140
+ bridge without the token. Account-backed or private Design work requires a
141
+ signed-in session or the authenticated Design MCP connector. After canvas edits,
142
+ call `an.call("get-visual-edit-prompt", {}, { waitMs: 2_000 })` and apply the
143
+ returned handoff. The page tool may show an approval dialog; let the user
144
+ approve it and never bypass that consent.
145
+
146
+ ## Core Model
147
+
148
+ - Each screen is a URL-backed iframe, not copied HTML.
149
+ - Each screen keeps URL metadata: `connectionId`, `routeId`, `path`,
150
+ `url`, `bridgeUrl`, title, and viewport size.
151
+ - The owner edits through the local bridge. Shared
152
+ `/visual-edit/:designId?share=1` links render a sanitized inert snapshot,
153
+ refreshed on route or DOM changes; guests never reach the owner's localhost.
154
+ Guest edits stay pending until an owner or editor applies them to source.
155
+ - Authorized viewers and commenters on private designs can edit the shared
156
+ Visual Edit canvas and submit pending changes without writing design files.
157
+ The owner or editor applies those source changes.
158
+ - **The `/visual-edit` skill needs no Design account sign-in.**
159
+ `open-visual-edit` mints a five-minute, single-use capability for the exact
160
+ `/visual-edit/:designId` local-editor route. The MCP host redeems it outside
161
+ model-visible text, then opens the existing editor with localhost edit access.
162
+ A public `/visual-edit/:designId` route enables browser-only DOM editing of
163
+ public localhost snapshots; handoffs stay pending until applied. The owner
164
+ sees **Apply edits** when a recipient has pending changes.
165
+ This capability is not an account session: `/_agent-native/session` remains
166
+ signed out, and account-backed save/share/generate actions remain denied.
167
+ - Hosted MCP highlights `get-visual-edit-pending`; pass the visual-edit
168
+ design ID for a tab-free handoff. It returns a revision; after applying,
169
+ call `acknowledge-visual-edit-pending` with that revision, then pull again.
170
+ `empty` means no edits; `session-ended` means edits were lost;
171
+ `unknown` means the marker was unreadable, not proof of no change.
172
+ - Browser hosts can use page-local `get-visual-edit-prompt`.
173
+ - The `open-visual-edit` action is owned by Design. From another app, use the
174
+ hosted MCP server at `https://design.agent-native.com/mcp` or the page's
175
+ WebMCP helper, not `pnpm action` in the target app. The page path works
176
+ signed out only for loopback apps in public mode, using a short-lived
177
+ capability-scoped principal; hosted MCP uses its normal OAuth identity.
178
+ - Ordinary public links stay read-only. Public `/visual-edit/:designId` and
179
+ authorized private shares allow DOM-only edits, never source writes. Guest
180
+ Interact is blocked; snapshots strip active content and owner-local resources,
181
+ and persisted writes stay role-gated. Loopback is not a trust boundary because
182
+ tunnels can proxy remote callers.
183
+ - The live editor is same-origin through the local bridge proxy. This boots
184
+ CSR apps and root-relative assets, but it is still a localhost editing proxy:
185
+ app-origin cookies, WebSockets/HMR, SSE, and non-GET app API calls may need a
186
+ future dev-server/plugin integration for perfect parity with the app's own
187
+ origin.
188
+ - The canvas is the editing view; Interact runs the normal URL with rails and a
189
+ device bar. Interact preserves navigation, scrolling, links, and controls;
190
+ the canvas pans/zooms and suppresses native frame interaction.
191
+ - While a localhost screen has pending live visual edits, do not switch back to
192
+ Interact until the user either applies the edits to source or explicitly
193
+ aborts/discards the preview.
194
+ - Alt-drag duplicates a localhost frame and its URL metadata. Change the copy's
195
+ path/query for another state; preserve the order of named or numbered flows.
196
+ Shorthand like `localhost:1234/onboarding/1` means
197
+ `http://localhost:1234/onboarding/1`.
198
+
199
+ ## Useful Canvas Sets
200
+
201
+ Use a focused batch of 3-7 frames by default: one ordered frame per requested
202
+ route/query state, repeat routes at requested desktop/tablet/mobile viewports,
203
+ and include URL-addressable empty, loading, error, modal-open, or selected-item
204
+ states. Keep the Screens section readable so Layers remains useful while
205
+ editing. Do not expand beyond 7 frames unless the user explicitly asks for an
206
+ exhaustive audit or a complete route inventory.
207
+
208
+ Do not expand every discovered route or every viewport unless the user asks for
209
+ an exhaustive audit. Preserve the user's labels and sequence so the canvas
210
+ reads like the workflow they described.
211
+
212
+ ## Select And Reprompt
213
+
214
+ When a chat message begins with `[Reprompt selection]`, the selected subtree is
215
+ a hard write boundary. The only mutation path is `propose-node-rewrite` with
216
+ the exact `repromptId`, target, and `baseVersionHash` captured in
217
+ `design-reprompt-pending:<designId>:<fileId>`. Never use `apply-visual-edit`,
218
+ `apply-source-edit`, `write-source`, `write-local-file`, `edit-design`, or any
219
+ other content-writing action for that request. Clarifying questions are allowed,
220
+ but a requested change must remain a proposal.
221
+
222
+ Produce one variant by default. Produce two or three only when the instruction
223
+ asks for options. A retry includes `priorProposalId`; keep the same target and
224
+ base version, incorporate the feedback, and call `propose-node-rewrite` again.
225
+ The UI previews the returned subtree without persisting it.
226
+
227
+ Use `resolve-node-rewrite` for the accept/reject lifecycle. Accept applies the
228
+ chosen variant as one version-checked inline/Yjs content transaction so one
229
+ undo restores the prior structure; reject clears the proposal without changing
230
+ content. For conversational resolution such as "apply the second one," call
231
+ `view-screen`, read the active `design.reprompt.proposal`, and pass its
232
+ `proposalId` plus the zero-based `variantIndex` to `resolve-node-rewrite`.
233
+
234
+ ## Review Quality
235
+
236
+ Treat the running app as truth, preserving its component language, tokens, route
237
+ state, and content. Compare visual edits before/after at requested viewports and
238
+ check meaningful URL, hover, focus, scroll, and modal states.
239
+
240
+ ## Account And Sharing Model
241
+
242
+ - The capability permits live iframe inspection, session-local edits, undo/redo,
243
+ **Apply design updates**, and **Copy prompt**. These hand bounded source
244
+ instructions to the coding agent; they do not persist account-owned Design data.
245
+ - Public `/design/:id` links stay read-only without a signed-in owner/editor
246
+ session. Never use the local capability to upgrade that ordinary sharing
247
+ surface.
248
+ - Prefer links returned by Design actions or `/_agent-native/open` deep links;
249
+ never surface `_session=` tokens or hand-build capability URLs.
250
+ - Do not attempt account-backed write actions with the browser capability. The
251
+ trusted local `open-visual-edit` CLI call may register its bridge, create or
252
+ reuse its workspace-owned local design, and place screens without an account.
253
+ Direct source-file action writes, generation, saving into an account, and
254
+ sharing still require an authenticated action caller. If a signed-out visitor
255
+ wants those durable account operations, send them through the framework
256
+ sign-in return flow first.
257
+
258
+ ## Required Local Bridge
259
+
260
+ The live-edit bridge is unlocked by a shared secret (the "bridge token") that
261
+ must match on two sides: the local bridge process, and the user's connection row
262
+ in Design (which the browser reads to authorize the live-edit-bridge, read-file and
263
+ write-file endpoints). Get them to match by letting the
264
+ `open-visual-edit` action mint the token, then starting the
265
+ bridge with it. This is the only ordering that works for the remote-MCP flow -
266
+ the bridge cannot push its own token to the server without a CLI auth token, so
267
+ the server mints instead and the bridge adopts.
268
+ The `connectionId` (usually `localhost_...`) only identifies the row; never
269
+ pass it as `bridgeToken`.
270
+
271
+ For a fresh signed-out browser flow, generate the token locally, keep it in the
272
+ host process, and pass it once as the page tool's optional `bridgeToken`; the
273
+ page never returns it:
274
+
275
+ ```bash
276
+ BRIDGE_TOKEN="$(node -e 'process.stdout.write(require("node:crypto").randomBytes(32).toString("hex"))')"
277
+ AGENT_NATIVE_BRIDGE_TOKEN="$BRIDGE_TOKEN" npx @agent-native/core@latest design connect --url http://localhost:5173 --root . --daemon
278
+ ```
279
+
280
+ Reuse an existing matching connection without `bridgeToken`; hosted MCP can
281
+ mint the token when page WebMCP is unavailable.
282
+
283
+ From the target app repo, make sure its dev server is running, then:
284
+
285
+ **1. Discover routes without starting a durable bridge** (one-shot, exits):
286
+
287
+ ```bash
288
+ npx @agent-native/core@latest design connect --url http://localhost:5173 --root . --json
289
+ ```
290
+
291
+ This prints the manifest (routes + capabilities). Parse it to build
292
+ `routeManifest` for the next step. (Skip this if the user already gave explicit
293
+ paths/URLs to place.)
294
+
295
+ Inside the agent-native monorepo itself, use the workspace CLI instead of
296
+ `npx` — `npx` installs the last published `@agent-native/core`, which will not
297
+ contain local changes and costs a slow install on every call:
298
+
299
+ ```bash
300
+ pnpm dev:cli design connect --url http://localhost:5173 --root templates/<app> --json
301
+ ```
302
+
303
+ **2. For the hosted MCP path, call `open-visual-edit`** (see Action Flow below)
304
+ with NO `bridgeToken`.
305
+ The server mints one, stores it on the user's connection row, copies it into the
306
+ placed screens' metadata, and returns it to you as `bridgeToken`. Capture it.
307
+
308
+ **3. Start the persistent bridge adopting that token** (single line; prefer the
309
+ env var so the secret does not appear in `ps`):
310
+
311
+ ```bash
312
+ AGENT_NATIVE_BRIDGE_TOKEN="<bridgeToken from step 2>" npx @agent-native/core@latest design connect --url http://localhost:5173 --root . --daemon
313
+ ```
314
+
315
+ (Equivalently, pass `--bridge-token <token>`.) This starts a detached bridge on
316
+ `http://127.0.0.1:7331`, adopts the server-minted token — so bridge and row
317
+ agree and live-edit authorizes with no self-registration — and stays alive after
318
+ the command exits.
319
+
320
+ For a manual health/manifest check on the running bridge:
321
+
322
+ ```bash
323
+ curl http://127.0.0.1:7331/health
324
+ ```
325
+
326
+ `/health` needs no token. The full manifest at `/manifest.json` is
327
+ preview-token protected, so an unauthenticated `curl` of it returns
328
+ `{"ok":false,"error":"invalid or missing preview token"}` — that response means
329
+ the bridge is up, not that it is broken.
330
+
331
+ Only use `--json` for the step-1 route probe. Never use `--json`, `--once`,
332
+ or `--dry-run` for the durable step-3 bridge: they print the manifest and exit,
333
+ so Design falls back to a non-editable live iframe.
334
+
335
+ The bridge listens on a single fixed port (7331) and refuses to start for a
336
+ second, different app. It is detached with no log file, so if `--daemon` reports
337
+ a timeout, check for a stale process (`lsof -ti:7331`) before retrying.
338
+
339
+ If local Design uses PGlite, never invoke the in-process CLI against that server:
340
+ both open the same directory and the second owner is rejected. For a signed-out
341
+ local test, start Design with `AUTH_DISABLED=1`, open `/visual-edit`, and call
342
+ the server-action `open-visual-edit` through `window.__agentNativeWebMcp` after
343
+ it registers. This keeps one PGlite owner; `get-visual-edit-prompt` is only the
344
+ post-edit handoff. With auth enabled, sign in to hosted Design MCP or use shared
345
+ Postgres before using the CLI action.
346
+
347
+ ## Action Flow
348
+
349
+ When a browser is available, reuse the local bridge and call the Design page's
350
+ `open-visual-edit` WebMCP tool. For a fresh signed-out connection, pass the
351
+ locally held `bridgeToken`; it reads its preview manifest and challenge proof,
352
+ then sends both for validation. Hosted Design never fetches `127.0.0.1`. If the
353
+ page has no WebMCP, use the connected Design MCP server or its normal hosted
354
+ MCP fallback.
355
+
356
+ From another app, call the connected Design MCP tool
357
+ `mcp__agent-native-design__open-visual-edit` with the JSON arguments below. It
358
+ registers or refreshes the localhost bridge,
359
+ mints and stores the bridge token, creates or reuses a Design project, places
360
+ URL-backed screens, stores visual-edit context, and navigates to overview mode
361
+ in one call. Never run `pnpm action` from the target app's checkout: its local
362
+ registry does not contain Design actions.
363
+
364
+ Call it before starting the durable bridge: it does not contact the bridge, so
365
+ the server can mint `bridgeToken` for the bridge to adopt. Omit that input.
366
+
367
+ ```json
368
+ {
369
+ "title": "Docs homepage visual edit",
370
+ "devServerUrl": "http://localhost:5173",
371
+ "bridgeUrl": "http://127.0.0.1:7331",
372
+ "rootPath": "/absolute/path/to/app",
373
+ "routeManifest": { "...": "from /manifest.json" },
374
+ "paths": ["/", "/pricing", "/checkout?step=payment"]
375
+ }
376
+ ```
377
+
378
+ The action returns `designId`, `connectionId`, `bridgeToken`, `screens`,
379
+ `urlPath`, and credential-free `openUrl`. MCP App metadata carries the
380
+ hidden one-time launcher. Keep the ids for follow-ups
381
+ and pass the token to `design connect`; reusing the connection reuses its token.
382
+
383
+ ### Desktop and mobile side by side
384
+
385
+ Pass `viewports` to place every requested route once per viewport. Frames lay
386
+ out as a grid: one row per route, one column per viewport. Presets are
387
+ `desktop` (1280x900), `laptop` (1440x900), `tablet` (834x1112), and `mobile`
388
+ (390x844); an explicit `{ "label": "...", "width": N, "height": N }` also works.
389
+
390
+ ```json
391
+ {
392
+ "title": "Tasks responsive visual edit",
393
+ "devServerUrl": "http://localhost:5173",
394
+ "bridgeUrl": "http://127.0.0.1:7331",
395
+ "rootPath": "/absolute/path/to/app",
396
+ "paths": ["/tasks", "/inbox"],
397
+ "viewports": ["desktop", "mobile"]
398
+ }
399
+ ```
400
+
401
+ Prefer this over two separate calls with `defaultWidth`/`defaultHeight`: it
402
+ keeps each route's viewports aligned in a row and titles them
403
+ `Tasks — Desktop` / `Tasks — Mobile` so the canvas reads clearly. `viewports`
404
+ overrides `defaultWidth`/`defaultHeight`. With no `routes`/`paths`, it expands
405
+ every route in the localhost manifest, which is usually far more frames than
406
+ the user wants — name the paths.
407
+
408
+ ### Managing screens and breakpoints manually
409
+
410
+ Select a screen and use the right-rail **Screen** section to switch between
411
+ Static HTML and URL-backed modes, edit its route/path, choose a localhost
412
+ connection, add another URL screen, or remove the selected screen. URL mode
413
+ keeps the iframe live; switching to Static stores a sanitized snapshot of the
414
+ current frame, including its current client state when the page can provide it.
415
+ The same operations are available to a page-capable agent through
416
+ `add-localhost-screens`, `update-screen-source`, `add-breakpoint`, and
417
+ `remove-breakpoint`.
418
+
419
+ ### Adding more page frames later
420
+
421
+ Call `open-visual-edit` again with the same `designId` and `connectionId` and
422
+ only the new paths. Existing frames for the same route and viewport are
423
+ refreshed in place rather than duplicated, and a frame the user has dragged or
424
+ resized keeps its position unless you explicitly pass `x`/`y`/`width`/`height`.
425
+
426
+ ```json
427
+ {
428
+ "designId": "<existing-design-id>",
429
+ "connectionId": "<existing-connection-id>",
430
+ "devServerUrl": "http://localhost:5173",
431
+ "paths": ["/settings", "/team"],
432
+ "startY": 2200
433
+ }
434
+ ```
435
+
436
+ Do NOT add `defaultWidth`/`defaultHeight` just to restate the default size:
437
+ supplying either one marks the viewport as explicitly requested, which
438
+ overwrites frame sizes the user has already adjusted on the canvas.
439
+
440
+ For a numbered flow the user describes in chat, keep the labels and order:
441
+
442
+ ```json
443
+ {
444
+ "designId": "<existing-design-id>",
445
+ "connectionId": "<existing-connection-id>",
446
+ "devServerUrl": "http://localhost:1234",
447
+ "routes": [
448
+ { "url": "localhost:1234/onboarding/1", "title": "Screen 1" },
449
+ { "url": "localhost:1234/onboarding/2", "title": "Screen 2" },
450
+ { "url": "localhost:1234/onboarding/3", "title": "Screen 3" }
451
+ ]
452
+ }
453
+ ```
454
+
455
+ If no `routes` or `paths` are supplied, `open-visual-edit` uses every route
456
+ from the localhost manifest.
457
+
458
+ Fallback only when `open-visual-edit` is unavailable and hosted Design MCP is
459
+ authorized:
460
+
461
+ 1. Register or refresh the bridge with `connect-localhost`, passing the
462
+ `/manifest.json` result as `routeManifest` and `capabilities`.
463
+ 2. Create or reuse a Design project with `create-design`.
464
+ 3. Place URL-backed screens with `add-localhost-screens`.
465
+ 4. Navigate to overview mode with `navigate`.
466
+
467
+ The fallback still targets `https://design.agent-native.com`; only the app and
468
+ bridge URLs are localhost. Never run `pnpm action` from `templates/design`.
469
+
470
+ ## Open The Design Surface
471
+
472
+ - Use the `link`, `deepLink`, or MCP App embed returned by Design actions so the
473
+ user sees the canvas. Prefer the MCP App; its host launcher carries the
474
+ one-time capability. The credential-free `openUrl` is read-only fallback.
475
+ - Never return or open a hand-built `/design/:id?_session=...` URL.
476
+ - If the user is working in VS Code, the Agent-Native extension can open the
477
+ same URL via
478
+ `vscode://builder.agent-native/open?url=<encoded-design-url>`. Its
479
+ `Agent-Native: Open Design Canvas` command also starts the local bridge and
480
+ opens hosted Design in the VS Code side panel.
481
+ - Once `open-visual-edit` returns the expected `screenCount`, hand back the
482
+ link and stop. Do not open it yourself in a browser-automation tool to
483
+ screenshot or poll until it renders — a cold dev server can take 10-30s
484
+ regardless of who's watching, and that wait adds nothing the response didn't
485
+ already confirm. Reach for browser automation only if the user later reports
486
+ the canvas is broken.
487
+
488
+ ## Applying Visual Edits Back To Source
489
+
490
+ With Design closed, call hosted Design MCP's highlighted
491
+ `get-visual-edit-pending` for the design ID; it returns the handoff and
492
+ revision. Verify the applied source, acknowledge that revision, then pull again.
493
+ If MCP is unavailable, read the local bridge:
494
+
495
+ ```bash
496
+ npx @agent-native/core@latest design pending --root . --design-id <design-id-from-visual-edit-url>
497
+ ```
498
+
499
+ Pass the ID after `visual-edit` in the Design URL; the CLI prints that
500
+ design's prompt (`null` when empty).
501
+
502
+ Canvas edits on a localhost screen never write source directly. They stay
503
+ pending until the canvas shows **Apply design updates** (local) or **Apply edits**
504
+ (shared). An MCP App sends its prompt through the host or local Design agent;
505
+ otherwise use **Copy prompt to your agent**.
506
+
507
+ ChatGPT and Claude Code should pull, apply, acknowledge, and pull again.
508
+ Browser WebMCP hosts can call `get-visual-edit-prompt`. Never acknowledge
509
+ before applying the source change.
510
+
511
+ - Style, text, and drag/drop edits collect into one pending batch for a single
512
+ apply.
513
+ - After the write lands, the target app's own dev-server HMR refreshes the
514
+ frames — no manual reload. If frames do not refresh, the write did not land;
515
+ say so rather than assuming.
516
+ - The separate disk-icon "Apply to source" button is the deterministic
517
+ whole-file HTML/CSS writer. It is intentionally disabled for compiled
518
+ `.jsx`/`.tsx` routes — those must go through the agent path above.
519
+
520
+ ## Editing URLs
521
+
522
+ Keep localhost screens as URL files plus `screenMetadata[fileId]`. Do not
523
+ replace them with copied `srcdoc` HTML unless the user explicitly asks for a
524
+ frozen snapshot. To change a state, rerun `open-visual-edit` with the new
525
+ path/query, use the Screen settings section, call `update-screen-source`, or
526
+ duplicate the screen and update the copy's URL metadata.
527
+
528
+ ## Local Files in the Code Tab
529
+
530
+ Once a connection is registered, the design editor's Code panel (left rail →
531
+ Code, or `navigate --view editor --designId <id> --leftPanel code`) shows a
532
+ local-files workspace root for that connection next to the design's own files.
533
+ Treat that root like VS Code opened at the connected project directory: file
534
+ tree, search, open/edit, and save are backed by the real local files. It lists
535
+ the connected app's text/code files through the bridge
536
+ (`list-local-files` / `read-local-file`); build output, `node_modules`,
537
+ `.git`, and secret-looking paths (`.env*`, key files) are always excluded.
538
+
539
+ - Browsing and reading need only editor access on the design plus the running
540
+ bridge.
541
+ - Saving goes through `write-local-file`: the first save opens the
542
+ write-consent dialog (an 8-hour, folder-scoped grant) and retries
543
+ automatically once granted. Only text/code files are writable; secret paths
544
+ are always blocked.
545
+ - If the agent calls `write-local-file` directly (not through a UI save) and it
546
+ fails with "no write-consent grant", call `request-localhost-write-consent`.
547
+ It opens the write-consent dialog in the editor, or reports `alreadyGranted`
548
+ if one already exists. Granting is human-only —
549
+ `grant-localhost-write-consent` is hidden from agents, so you cannot approve
550
+ it yourself. Tell the user to click "Allow writes", then retry
551
+ `write-local-file` once. Do not keep retrying blindly: the write stays
552
+ blocked until the user approves.
553
+ - Saves are conflict-checked against the file's on-disk version — a file that
554
+ changed since it was read fails with a version conflict instead of being
555
+ overwritten.
556
+
557
+ ## React Source Writeback
558
+
559
+ - Use compiler/debug provenance (project-relative file, line, column,
560
+ component, and runtime multiplicity) to locate React/TSX source. Treat it as
561
+ evidence, not as permission for a generic AST structural transform.
562
+ - Read `positionPrecision` on every anchor before you trust `line`/`column`.
563
+ `authored` means those are the real JSX coordinates. `transformed` means they
564
+ are the dev server's own output coordinates — React 19 removed `_debugSource`
565
+ and exposes only an owner stack, so this is the normal case on a Vite/Next
566
+ dev server, and the line will not match the file. `unknown` means no tier was
567
+ reported. On anything but `authored`, use the file and component to find the
568
+ element by its JSX shape and re-derive the line from the file you read; never
569
+ edit at the reported line.
570
+ - A single-instance leaf text edit, literal `className`/`class` edit, or flat
571
+ literal `style={{ ... }}` property may use `apply-visual-edit` with a
572
+ `local-file` source and a complete `target.sourceAnchor`. Forward the
573
+ anchor's `positionPrecision` with it — the action refuses a `transformed`
574
+ anchor with `status: "needsAgent"` instead of seeking to a line that means
575
+ something else in the authored file. Preview first (omit `persist`), inspect
576
+ `proposedDiff`, then call with `persist: true`.
577
+ - Reparenting, grouping/ungrouping, wrappers, dynamic expressions, repeated
578
+ `.map()` instances, shared components, breakpoint-scoped edits, and
579
+ cross-file changes go through the coding agent with complete subject/target
580
+ anchors and their runtime relationship. `apply-visual-edit` refuses these
581
+ with `status: "needsAgent"` rather than guessing.
582
+ - Before each write, read the file and pass its exact `versionHash` to
583
+ `write-local-file` with `requireExpectedVersionHash: true`; on conflict,
584
+ re-read and re-plan. Keep the optimistic preview until HMR/runtime confirms
585
+ the result. Human write consent remains mandatory and agents cannot grant it.
586
+
587
+ ## Verification
588
+
589
+ For a plain "open this app" request, `open-visual-edit`'s own response is
590
+ the verification — see Open The Design Surface. Reach for the checks below
591
+ only to diagnose an actual report, or to confirm an applied edit landed:
592
+
593
+ - `list-localhost-connections` returns the expected connection and routes.
594
+ - The Design editor opens in overview mode.
595
+ - Every requested screen renders the intended localhost URL, showing real app
596
+ content rather than an endless loading spinner.
597
+ - The screen iframe carries a `src`, not a `srcdoc`. A localhost screen with a
598
+ `srcdoc` is a bug, not a slow load — check it in the browser devtools before
599
+ reporting the canvas as working.
600
+ - Alt-dragging a screen copies the URL-backed frame, not an inline HTML clone.
601
+ - A query/path edit changes only the target screen's URL metadata and iframe.
602
+ - `get-visual-edit-pending` is the tab-free handoff; acknowledge its revision
603
+ after applying. `get-visual-edit-prompt` is the browser equivalent.
604
+ - The Code tab shows a local-files root for the connection and opens its files.
605
+
606
+ ## AOS notes
607
+
608
+ This skill is optional and drives the Agent-Native Design service through an MCP
609
+ connector named `design` that AOS does NOT register or install — you connect it
610
+ yourself. It may point at a self-hosted or local Design app URL. Do not run any
611
+ `npx @agent-native/...@latest` command from this skill unless you explicitly
612
+ approved the network access in this conversation. Hosted publishing, posting to
613
+ GitHub, merging, and any other external write need your literal GO (AOS go-gate).
614
+ When the optional local BDB Plan Builder is installed, it can serve the same tool
615
+ names locally (planned, not yet built; say so).