@dexhq/canvas 0.14.0 → 0.16.0
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.
- package/CHANGELOG.md +70 -0
- package/README.md +5 -3
- package/app/canvas/activity-parts.tsx +50 -6
- package/app/canvas/activity.tsx +10 -18
- package/app/canvas/agent-changes.ts +18 -8
- package/app/canvas/anchoring.ts +15 -7
- package/app/canvas/canvas-context.tsx +6 -2
- package/app/canvas/canvas-input.ts +186 -14
- package/app/canvas/canvas-keys.ts +9 -0
- package/app/canvas/canvas-model.ts +7 -44
- package/app/canvas/canvas-panels.ts +1 -17
- package/app/canvas/canvas-scene.ts +250 -27
- package/app/canvas/canvas-ui.ts +13 -3
- package/app/canvas/canvas.css +147 -29
- package/app/canvas/change-notice.tsx +10 -1
- package/app/canvas/comment-layer.tsx +2 -1
- package/app/canvas/comments.tsx +270 -111
- package/app/canvas/element-link.ts +135 -0
- package/app/canvas/element-picker.ts +223 -27
- package/app/canvas/engine/canvas-gestures.ts +72 -17
- package/app/canvas/engine/canvas-store.ts +17 -1
- package/app/canvas/engine/engine.css +6 -3
- package/app/canvas/export-dialog.tsx +265 -0
- package/app/canvas/find-bar.tsx +817 -0
- package/app/canvas/find-model.ts +135 -0
- package/app/canvas/flow-canvas.tsx +83 -16
- package/app/canvas/follow-pin.ts +26 -6
- package/app/canvas/frame-context-menu.tsx +61 -7
- package/app/canvas/frame-node.tsx +19 -20
- package/app/canvas/imported-reviews.tsx +12 -22
- package/app/canvas/layout.ts +68 -22
- package/app/canvas/linked-element.tsx +196 -0
- package/app/canvas/live-page.ts +156 -19
- package/app/canvas/mentions.tsx +209 -0
- package/app/canvas/page-find.ts +220 -0
- package/app/canvas/page-style.ts +23 -0
- package/app/canvas/picked-box.tsx +21 -0
- package/app/canvas/removed-views-panel.tsx +4 -4
- package/app/canvas/request-node.tsx +151 -0
- package/app/canvas/review-panel.tsx +8 -3
- package/app/canvas/section-node.tsx +6 -133
- package/app/canvas/spec-margin.tsx +4 -1
- package/app/canvas/spec-threads.ts +24 -23
- package/app/canvas/teammates-layer.tsx +205 -0
- package/app/canvas/text-layer.tsx +103 -17
- package/app/canvas/thread-focus.tsx +14 -12
- package/app/canvas/tool-cursors.ts +7 -6
- package/app/canvas/tool-icons.tsx +24 -56
- package/app/canvas/typing.ts +12 -0
- package/app/canvas/use-activity.ts +0 -8
- package/app/canvas/use-agent-changes.tsx +40 -42
- package/app/canvas/use-canvas-clipboard.tsx +11 -14
- package/app/canvas/use-canvas-editor.ts +4 -2
- package/app/canvas/xray.ts +3 -12
- package/app/export/player-model.ts +159 -0
- package/app/export/player.tsx +198 -0
- package/app/export.html +31 -0
- package/app/export.tsx +9 -0
- package/app/frame/announce-refreshes.ts +21 -0
- package/app/frame/start-frame.tsx +50 -0
- package/app/frame/view-loads.ts +161 -0
- package/app/frame/views.ts +13 -49
- package/app/frame.tsx +2 -33
- package/app/i18n/locales/en/messages.po +233 -14
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +232 -13
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/dex-glyphs.tsx +219 -0
- package/app/icons/glyphs.tsx +80 -80
- package/app/kit/use-flow.ts +2 -1
- package/app/live/canvas-teammates.ts +90 -0
- package/app/live/studio-api.ts +30 -20
- package/app/main.tsx +3 -0
- package/app/pages/canvas.tsx +45 -14
- package/app/pages/commands-settings.tsx +17 -3
- package/app/pages/render.tsx +39 -11
- package/app/shell/bell.tsx +15 -5
- package/app/shell/feedback-form.tsx +10 -21
- package/app/shell/feedback-link.tsx +2 -1
- package/app/shell/presence.tsx +123 -26
- package/app/shell/scaled-frame.tsx +21 -9
- package/app/shell/thread-list.tsx +25 -8
- package/app/shell/working-on.tsx +35 -3
- package/app/types.ts +21 -205
- package/app/ui/file-drop.ts +128 -0
- package/app/ui/prompt-editor.tsx +39 -11
- package/app/ui/reference.tsx +21 -8
- package/app/ui/shadcn/input-group.tsx +2 -2
- package/bin/sudio.mjs +1 -1
- package/dist/cli/banner.d.mts +4 -2
- package/dist/cli/banner.mjs +34 -11
- package/dist/cli/commands/app.mjs +19 -11
- package/dist/cli/commands/create.d.mts +5 -5
- package/dist/cli/commands/create.mjs +4 -4
- package/dist/cli/commands/export.d.mts +40 -0
- package/dist/cli/commands/export.mjs +66 -0
- package/dist/cli/commands/hook.mjs +2 -1
- package/dist/cli/commands/init.d.mts +2 -2
- package/dist/cli/commands/upgrade.mjs +1 -1
- package/dist/cli/help.d.mts +1 -1
- package/dist/cli/help.mjs +13 -7
- package/dist/cli/main.d.mts +42 -5
- package/dist/cli/main.mjs +1 -0
- package/dist/config/load.mjs +14 -2
- package/dist/config/project-files.d.mts +11 -0
- package/dist/config/project-files.mjs +23 -2
- package/dist/config/renamed.d.mts +7 -2
- package/dist/config/renamed.mjs +13 -3
- package/dist/content/capture.d.mts +2 -2
- package/dist/content/capture.mjs +2 -2
- package/dist/content/commands.d.mts +11 -9
- package/dist/content/commands.mjs +22 -16
- package/dist/content/comments-log.mjs +2 -1
- package/dist/content/content.d.mts +13 -143
- package/dist/content/content.mjs +55 -76
- package/dist/content/element-words.d.mts +42 -0
- package/dist/content/element-words.mjs +112 -0
- package/dist/content/flow-specs.mjs +1 -1
- package/dist/content/hosted-person.d.mts +31 -0
- package/dist/content/hosted-person.mjs +68 -0
- package/dist/content/merge-rules.d.mts +5 -0
- package/dist/content/merge-rules.mjs +17 -1
- package/dist/content/prototype-summary.d.mts +3 -39
- package/dist/content/prototype-summary.mjs +2 -3
- package/dist/content/prototypes.mjs +1 -1
- package/dist/content/screenshot.mjs +9 -0
- package/dist/content/text-edit.d.mts +24 -14
- package/dist/content/text-edit.mjs +92 -81
- package/dist/content/text-replace.d.mts +30 -0
- package/dist/content/text-replace.mjs +285 -0
- package/dist/content/thread-module.d.mts +2 -4
- package/dist/content/thread-module.mjs +4 -5
- package/dist/content/threads.mjs +1 -1
- package/dist/paste/paste.mjs +1 -1
- package/dist/paths.d.mts +0 -2
- package/dist/paths.mjs +1 -3
- package/dist/server/agent-env.d.mts +5 -1
- package/dist/server/agent-env.mjs +7 -2
- package/dist/server/agent-session.d.mts +14 -1
- package/dist/server/agent-session.mjs +84 -19
- package/dist/server/agents.d.mts +10 -0
- package/dist/server/agents.mjs +21 -6
- package/dist/server/build-pictures.mjs +1 -1
- package/dist/server/canvas-presence.d.mts +22 -0
- package/dist/server/canvas-presence.mjs +160 -0
- package/dist/server/channel.d.mts +13 -24
- package/dist/server/channel.mjs +55 -37
- package/dist/server/claimed-presence.d.mts +3 -2
- package/dist/server/claimed-presence.mjs +15 -7
- package/dist/server/close-check.mjs +2 -2
- package/dist/server/command-settings.mjs +1 -1
- package/dist/server/comments/actions.d.mts +145 -0
- package/dist/server/comments/actions.mjs +146 -0
- package/dist/server/comments/routes.d.mts +25 -0
- package/dist/server/comments/routes.mjs +67 -0
- package/dist/server/comments/tools.d.mts +6 -0
- package/dist/server/comments/tools.mjs +154 -0
- package/dist/server/dev-server.mjs +59 -23
- package/dist/server/export/build.d.mts +15 -0
- package/dist/server/export/build.mjs +220 -0
- package/dist/server/export/page.d.mts +25 -0
- package/dist/server/export/page.mjs +40 -0
- package/dist/server/export/plugin.d.mts +31 -0
- package/dist/server/export/plugin.mjs +69 -0
- package/dist/server/export/run.d.mts +9 -0
- package/dist/server/export/run.mjs +61 -0
- package/dist/server/export/save.d.mts +7 -0
- package/dist/server/export/save.mjs +29 -0
- package/dist/server/file-lock.d.mts +2 -2
- package/dist/server/file-lock.mjs +130 -36
- package/dist/server/hosted.d.mts +8 -0
- package/dist/server/hosted.mjs +78 -0
- package/dist/server/live-mirror.mjs +66 -10
- package/dist/server/live.mjs +28 -1
- package/dist/server/mcp.d.mts +0 -2
- package/dist/server/mcp.mjs +9 -8
- package/dist/server/me.d.mts +3 -1
- package/dist/server/me.mjs +8 -2
- package/dist/server/notices.d.mts +1 -1
- package/dist/server/notices.mjs +1 -1
- package/dist/server/open-page.d.mts +22 -0
- package/dist/server/open-page.mjs +20 -2
- package/dist/server/outcome.d.mts +22 -0
- package/dist/server/outcome.mjs +8 -0
- package/dist/server/own-copies.mjs +1 -1
- package/dist/server/people.d.mts +8 -3
- package/dist/server/people.mjs +6 -2
- package/dist/server/pictures.d.mts +1 -1
- package/dist/server/pictures.mjs +2 -2
- package/dist/server/port.d.mts +12 -0
- package/dist/server/port.mjs +66 -14
- package/dist/server/prebundle.d.mts +32 -0
- package/dist/server/prebundle.mjs +115 -0
- package/dist/server/presence.d.mts +4 -1
- package/dist/server/presence.mjs +2 -2
- package/dist/server/problems.d.mts +8 -0
- package/dist/server/problems.mjs +13 -0
- package/dist/server/requests.d.mts +5 -1
- package/dist/server/requests.mjs +76 -78
- package/dist/server/source-stamp.d.mts +4 -3
- package/dist/server/source-stamp.mjs +60 -31
- package/dist/server/state.d.mts +19 -10
- package/dist/server/state.mjs +27 -18
- package/dist/server/studio-for.d.mts +5 -0
- package/dist/server/studio-for.mjs +17 -3
- package/dist/server/sync-install.d.mts +8 -12
- package/dist/server/sync-install.mjs +12 -30
- package/dist/server/thread-source.d.mts +8 -0
- package/dist/server/thread-source.mjs +25 -6
- package/dist/server/tools/describe.d.mts +1 -1
- package/dist/server/tools/describe.mjs +1 -1
- package/dist/server/tools/export.d.mts +5 -0
- package/dist/server/tools/export.mjs +35 -0
- package/dist/server/tools/feedback.d.mts +1 -1
- package/dist/server/tools/place-frame.mjs +16 -16
- package/dist/server/tools/reading.mjs +13 -4
- package/dist/server/tools/show.d.mts +1 -1
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/thread-list.mjs +2 -2
- package/dist/server/tools/watch.mjs +5 -3
- package/dist/server/vite.d.mts +9 -4
- package/dist/server/vite.mjs +65 -63
- package/dist/server/web-app.mjs +4 -7
- package/dist/server/welcome.mjs +2 -1
- package/dist/server/work-groups.mjs +1 -1
- package/dist/setup/apply.d.mts +4 -0
- package/dist/setup/apply.mjs +5 -4
- package/dist/setup/create.d.mts +4 -2
- package/dist/setup/create.mjs +72 -22
- package/dist/setup/design-system-checks.mjs +3 -17
- package/dist/setup/desktop-app-script.mjs +4 -3
- package/dist/setup/desktop-app-start.d.mts +8 -2
- package/dist/setup/desktop-app-start.mjs +64 -29
- package/dist/setup/desktop-app.d.mts +8 -0
- package/dist/setup/desktop-app.mjs +19 -3
- package/dist/setup/detect/workspace.d.mts +10 -10
- package/dist/setup/detect/workspace.mjs +10 -12
- package/dist/setup/detect.d.mts +0 -2
- package/dist/setup/detect.mjs +1 -3
- package/dist/setup/doctor.d.mts +4 -1
- package/dist/setup/doctor.mjs +8 -6
- package/dist/setup/migrate/dex-folder.d.mts +61 -0
- package/dist/setup/migrate/dex-folder.mjs +544 -0
- package/dist/setup/migrate/files-folder.mjs +1 -1
- package/dist/setup/migrate/guides.mjs +1 -1
- package/dist/setup/migrate/migrations.mjs +4 -0
- package/dist/setup/migrate/row-titles.mjs +1 -1
- package/dist/setup/migrate/setup-files.d.mts +5 -0
- package/dist/setup/migrate/setup-files.mjs +115 -0
- package/dist/setup/migrate/studio-state.d.mts +2 -2
- package/dist/setup/migrate/studio-state.mjs +4 -4
- package/dist/setup/placement.d.mts +1 -1
- package/dist/setup/placement.mjs +5 -4
- package/dist/setup/plan.d.mts +5 -5
- package/dist/setup/plan.mjs +8 -12
- package/dist/setup/project.d.mts +6 -1
- package/dist/setup/project.mjs +10 -10
- package/dist/setup/prompts.d.mts +2 -1
- package/dist/setup/prompts.mjs +4 -3
- package/dist/setup/questions.mjs +3 -2
- package/dist/setup/starters.d.mts +3 -1
- package/dist/setup/starters.mjs +9 -3
- package/dist/setup/write.d.mts +15 -3
- package/dist/setup/write.mjs +23 -3
- package/dist/shared/annotations-core.mjs +1 -1
- package/dist/shared/canvas-core.d.mts +22 -7
- package/dist/shared/canvas-core.mjs +39 -11
- package/dist/shared/canvas-file.d.mts +201 -0
- package/dist/shared/canvas-file.mjs +1 -0
- package/dist/shared/comments/routes.d.mts +55 -0
- package/dist/shared/comments/routes.mjs +39 -0
- package/dist/shared/export-core.d.mts +62 -0
- package/dist/shared/export-core.mjs +101 -0
- package/dist/shared/feedback.d.mts +8 -0
- package/dist/shared/feedback.mjs +10 -2
- package/dist/shared/live-core.d.mts +2 -0
- package/dist/shared/live-core.mjs +6 -1
- package/dist/shared/live-presence.d.mts +57 -2
- package/dist/shared/live-presence.mjs +90 -4
- package/dist/shared/page-messages.d.mts +14 -1
- package/dist/shared/page-messages.mjs +30 -3
- package/dist/shared/page-review.d.mts +2 -11
- package/dist/shared/page-review.mjs +4 -13
- package/dist/shared/people-core.d.mts +28 -0
- package/dist/shared/people-core.mjs +27 -1
- package/dist/shared/presence-core.d.mts +13 -0
- package/dist/shared/presence-core.mjs +11 -2
- package/dist/shared/references-core.d.mts +4 -0
- package/dist/shared/references-core.mjs +12 -4
- package/dist/shared/review-file.d.mts +5 -0
- package/dist/shared/review-file.mjs +23 -13
- package/dist/shared/server-page.mjs +1 -1
- package/dist/shared/signup.d.mts +2 -5
- package/dist/shared/signup.mjs +2 -35
- package/dist/shared/studio-events.d.mts +0 -6
- package/dist/shared/studio-events.mjs +1 -5
- package/dist/shared/studio-files.d.mts +21 -0
- package/dist/shared/studio-files.mjs +16 -2
- package/dist/shared/studio-routes.d.mts +29 -63
- package/dist/shared/studio-routes.mjs +1 -69
- package/dist/shared/threads-core.d.mts +29 -6
- package/dist/shared/threads-core.mjs +68 -13
- package/extension/dist/feedback.js +104 -284
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +104 -284
- package/package.json +2 -2
- package/src/cli/banner.ts +45 -11
- package/src/cli/commands/app.ts +23 -8
- package/src/cli/commands/create.ts +4 -4
- package/src/cli/commands/export.ts +78 -0
- package/src/cli/commands/hook.ts +4 -1
- package/src/cli/commands/upgrade.ts +1 -1
- package/src/cli/help.ts +13 -7
- package/src/cli/main.ts +1 -0
- package/src/config/load.ts +26 -2
- package/src/config/project-files.ts +36 -6
- package/src/config/renamed.ts +19 -4
- package/src/content/capture.ts +6 -12
- package/src/content/commands.ts +30 -18
- package/src/content/comments-log.ts +4 -1
- package/src/content/content.ts +71 -257
- package/src/content/element-words.ts +175 -0
- package/src/content/flow-specs.ts +2 -1
- package/src/content/hosted-person.ts +107 -0
- package/src/content/merge-rules.ts +29 -0
- package/src/content/prototype-summary.ts +4 -44
- package/src/content/review-pages.ts +2 -1
- package/src/content/screenshot.ts +14 -0
- package/src/content/text-edit.ts +172 -105
- package/src/content/text-replace.ts +420 -0
- package/src/content/thread-module.ts +2 -4
- package/src/content/trash.ts +1 -1
- package/src/paths.ts +0 -8
- package/src/server/agent-env.ts +12 -2
- package/src/server/agent-session.ts +124 -34
- package/src/server/agents.ts +48 -17
- package/src/server/canvas-presence.ts +237 -0
- package/src/server/channel.ts +95 -53
- package/src/server/claimed-presence.ts +26 -10
- package/src/server/command-settings.ts +1 -1
- package/src/server/comments/actions.ts +333 -0
- package/src/server/comments/routes.ts +131 -0
- package/src/server/comments/tools.ts +317 -0
- package/src/server/dev-server.ts +94 -33
- package/src/server/export/build.ts +310 -0
- package/src/server/export/page.ts +85 -0
- package/src/server/export/plugin.ts +138 -0
- package/src/server/export/run.ts +79 -0
- package/src/server/export/save.ts +38 -0
- package/src/server/file-lock.ts +205 -54
- package/src/server/hosted.ts +113 -0
- package/src/server/live-mirror.ts +93 -8
- package/src/server/live.ts +46 -1
- package/src/server/machine-update.ts +3 -3
- package/src/server/mcp.ts +15 -14
- package/src/server/me.ts +12 -6
- package/src/server/notices.ts +2 -2
- package/src/server/open-page.ts +54 -4
- package/src/server/outcome.ts +26 -0
- package/src/server/people.ts +13 -3
- package/src/server/pictures.ts +2 -2
- package/src/server/port.ts +94 -20
- package/src/server/prebundle.ts +230 -0
- package/src/server/presence.ts +12 -4
- package/src/server/problems.ts +11 -0
- package/src/server/requests.ts +115 -110
- package/src/server/roster.ts +1 -1
- package/src/server/saved.ts +1 -1
- package/src/server/source-stamp.ts +118 -37
- package/src/server/state.ts +53 -31
- package/src/server/studio-for.ts +26 -2
- package/src/server/sync-install.ts +35 -26
- package/src/server/thread-place.ts +2 -4
- package/src/server/thread-source.ts +35 -3
- package/src/server/tools/export.ts +56 -0
- package/src/server/tools/place-frame.ts +23 -15
- package/src/server/tools/reading.ts +16 -3
- package/src/server/tools/thread-list.ts +1 -1
- package/src/server/tools/watch.ts +7 -7
- package/src/server/updates.ts +2 -2
- package/src/server/vite.ts +106 -110
- package/src/server/web-app.ts +11 -9
- package/src/server/welcome.ts +3 -1
- package/src/setup/apply.ts +8 -5
- package/src/setup/create.ts +101 -27
- package/src/setup/design-system-checks.ts +8 -21
- package/src/setup/desktop-app-script.ts +4 -3
- package/src/setup/desktop-app-start.ts +94 -26
- package/src/setup/desktop-app.ts +23 -2
- package/src/setup/detect/workspace.ts +20 -21
- package/src/setup/detect.ts +0 -4
- package/src/setup/doctor.ts +13 -6
- package/src/setup/migrate/dex-folder.ts +842 -0
- package/src/setup/migrate/files-folder.ts +1 -1
- package/src/setup/migrate/guides.ts +3 -1
- package/src/setup/migrate/migrations.ts +8 -2
- package/src/setup/migrate/setup-files.ts +198 -0
- package/src/setup/migrate/studio-state.ts +12 -10
- package/src/setup/own-app.ts +1 -1
- package/src/setup/placement.ts +7 -6
- package/src/setup/plan.ts +13 -18
- package/src/setup/project.ts +11 -10
- package/src/setup/prompts.ts +5 -4
- package/src/setup/questions.ts +6 -3
- package/src/setup/starters.ts +11 -4
- package/src/setup/write.ts +34 -3
- package/src/shared/canvas-core.ts +48 -9
- package/src/shared/canvas-file.ts +205 -0
- package/src/shared/comments/routes.ts +81 -0
- package/src/shared/export-core.ts +198 -0
- package/src/shared/feedback.ts +14 -4
- package/src/shared/live-core.ts +8 -0
- package/src/shared/live-presence.ts +171 -2
- package/src/shared/page-messages.ts +38 -2
- package/src/shared/page-review.ts +11 -16
- package/src/shared/people-core.ts +44 -0
- package/src/shared/presence-core.ts +18 -2
- package/src/shared/references-core.ts +22 -3
- package/src/shared/review-file.ts +28 -12
- package/src/shared/server-page.ts +2 -1
- package/src/shared/signup.ts +4 -28
- package/src/shared/studio-events.ts +0 -13
- package/src/shared/studio-files.ts +29 -1
- package/src/shared/studio-routes.ts +32 -65
- package/src/shared/threads-core.ts +134 -12
- package/templates/methods/explore.md +1 -1
- package/templates/methods/handoff.md +1 -1
- package/templates/methods/review.md +2 -1
- package/templates/rules/canvas-frames.md +6 -3
- package/templates/rules/commands.md +1 -0
- package/templates/rules/prototypes.md +1 -1
- package/templates/rules/studio.md +17 -11
- package/templates/skills/comprehend/SKILL.md +56 -0
- package/templates/skills/distill/SKILL.md +172 -0
- package/templates/skills/export-prototype/SKILL.md +35 -0
- package/templates/skills/riff/SKILL.md +21 -0
- package/templates/skills/riff-deep/SKILL.md +40 -0
- package/templates/skills/riff-max/SKILL.md +46 -0
- package/templates/skills/riff-state/SKILL.md +45 -0
- package/templates/skills/riff-up/SKILL.md +38 -0
- package/templates/skills/riff-wide/SKILL.md +40 -0
- package/templates/starters/standalone/README.md +1 -1
- package/templates/starters/turborepo/README.md +2 -2
- package/templates/starters/turborepo/apps/web/src/app.tsx +2 -2
- package/templates/starters/vite/README.md +1 -1
- package/dist/server/tools/close-reply.d.mts +0 -6
- package/dist/server/tools/close-reply.mjs +0 -138
- package/dist/server/tools/comment.d.mts +0 -6
- package/dist/server/tools/comment.mjs +0 -49
- package/src/server/tools/close-reply.ts +0 -271
- package/src/server/tools/comment.ts +0 -96
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { parseJsx } from "./jsx-source.mjs";
|
|
2
|
+
import { CODE_PROPS, isCodeProp, words } from "./element-words.mjs";
|
|
3
|
+
import { join, relative } from "node:path";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { readFile, readdir, writeFile } from "node:fs/promises";
|
|
6
|
+
//#region src/content/text-replace.ts
|
|
7
|
+
const SOURCE_RE = /\.(?:tsx|ts|jsx|js)$/;
|
|
8
|
+
const SKIPPED = /* @__PURE__ */ new Set([
|
|
9
|
+
"comments",
|
|
10
|
+
"docs",
|
|
11
|
+
"node_modules"
|
|
12
|
+
]);
|
|
13
|
+
const JSX_UNSAFE_RE = /[{}<>]/;
|
|
14
|
+
const REGEX_CHARS_RE = /[.*+?^${}()|[\]\\]/g;
|
|
15
|
+
const MAX_LENGTH = 2e3;
|
|
16
|
+
/** How many replacements can still be put back, newest kept. */
|
|
17
|
+
const UNDO_KEPT = 20;
|
|
18
|
+
/** Calls whose strings are class names, or a module's path. */
|
|
19
|
+
const CODE_CALLS = /* @__PURE__ */ new Set([
|
|
20
|
+
"classNames",
|
|
21
|
+
"clsx",
|
|
22
|
+
"cn",
|
|
23
|
+
"cva",
|
|
24
|
+
"cx",
|
|
25
|
+
"require",
|
|
26
|
+
"tv",
|
|
27
|
+
"twMerge"
|
|
28
|
+
]);
|
|
29
|
+
const COMPARISONS = /* @__PURE__ */ new Set([
|
|
30
|
+
"==",
|
|
31
|
+
"===",
|
|
32
|
+
"!=",
|
|
33
|
+
"!=="
|
|
34
|
+
]);
|
|
35
|
+
const undos = /* @__PURE__ */ new Map();
|
|
36
|
+
async function sourceFiles(dir) {
|
|
37
|
+
let entries;
|
|
38
|
+
try {
|
|
39
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
40
|
+
} catch {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
const files = [];
|
|
44
|
+
for (const entry of entries) {
|
|
45
|
+
if (SKIPPED.has(entry.name) || entry.isSymbolicLink()) continue;
|
|
46
|
+
const path = join(dir, entry.name);
|
|
47
|
+
if (entry.isDirectory()) files.push(...await sourceFiles(path));
|
|
48
|
+
else if (SOURCE_RE.test(entry.name)) files.push(path);
|
|
49
|
+
}
|
|
50
|
+
return files;
|
|
51
|
+
}
|
|
52
|
+
const isNode = (value) => typeof value === "object" && value !== null && typeof value.type === "string";
|
|
53
|
+
const calleeName = (node) => {
|
|
54
|
+
const callee = node.callee;
|
|
55
|
+
if (callee?.type === "Identifier") return callee.name;
|
|
56
|
+
};
|
|
57
|
+
/** An object property's name, when it is written as a name or a string. */
|
|
58
|
+
const keyName = (node) => {
|
|
59
|
+
const named = node.key;
|
|
60
|
+
if (named?.type === "Identifier") return named.name;
|
|
61
|
+
return named?.type === "StringLiteral" ? named.value : void 0;
|
|
62
|
+
};
|
|
63
|
+
const propName = (node) => {
|
|
64
|
+
const name = node.name;
|
|
65
|
+
return name?.type === "JSXIdentifier" ? name.name : void 0;
|
|
66
|
+
};
|
|
67
|
+
const CALLS = /* @__PURE__ */ new Set(["CallExpression", "NewExpression"]);
|
|
68
|
+
const FUNCTIONS = /* @__PURE__ */ new Set([
|
|
69
|
+
"ArrowFunctionExpression",
|
|
70
|
+
"FunctionDeclaration",
|
|
71
|
+
"FunctionExpression"
|
|
72
|
+
]);
|
|
73
|
+
/**
|
|
74
|
+
* What a call is given is the call's to read, not the page's words:
|
|
75
|
+
* useState("Save"), getItem(draft ? "Save" : "Old"), import("./save").
|
|
76
|
+
* A callback it is given is words again: what it renders shows.
|
|
77
|
+
*/
|
|
78
|
+
const givenToCall = (parent, key) => CALLS.has(parent.type) && key === "arguments";
|
|
79
|
+
/** Whether a string at this place in the tree is code, not words. */
|
|
80
|
+
const isCode = (parent, key) => {
|
|
81
|
+
if (parent.type.startsWith("TS")) return key !== "expression";
|
|
82
|
+
switch (parent.type) {
|
|
83
|
+
case "ImportDeclaration":
|
|
84
|
+
case "ImportExpression":
|
|
85
|
+
case "SwitchCase": return true;
|
|
86
|
+
case "ExportAllDeclaration":
|
|
87
|
+
case "ExportNamedDeclaration": return key === "source";
|
|
88
|
+
case "ObjectProperty": return key === "key" || CODE_PROPS.has(keyName(parent) ?? "");
|
|
89
|
+
case "ObjectMethod":
|
|
90
|
+
case "ClassProperty":
|
|
91
|
+
case "MemberExpression":
|
|
92
|
+
case "OptionalMemberExpression": return key === "key" || key === "property";
|
|
93
|
+
case "BinaryExpression": return COMPARISONS.has(parent.operator);
|
|
94
|
+
case "CallExpression": return CODE_CALLS.has(calleeName(parent) ?? "");
|
|
95
|
+
case "JSXAttribute": return isCodeProp(propName(parent) ?? "");
|
|
96
|
+
default: return false;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
/** Every run of words in a module that is not code. */
|
|
100
|
+
function textRuns(code, filename) {
|
|
101
|
+
const program = parseJsx(code, filename);
|
|
102
|
+
if (!program) return [];
|
|
103
|
+
const runs = [];
|
|
104
|
+
const walk = (node, inCode) => {
|
|
105
|
+
for (const [key, value] of Object.entries(node)) {
|
|
106
|
+
if (key === "loc" || key === "extra" || key.endsWith("Comments")) continue;
|
|
107
|
+
for (const child of Array.isArray(value) ? value : [value]) if (isNode(child)) visit(child, node, key, inCode);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const visit = (node, parent, key, inCode) => {
|
|
111
|
+
let asCode = inCode || isCode(parent, key);
|
|
112
|
+
if (!asCode && givenToCall(parent, key)) asCode = "given";
|
|
113
|
+
if (asCode === "given" && FUNCTIONS.has(node.type)) asCode = false;
|
|
114
|
+
const { start, end } = node;
|
|
115
|
+
if (typeof start !== "number" || typeof end !== "number") {
|
|
116
|
+
walk(node, asCode);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (node.type === "JSXText") {
|
|
120
|
+
runs.push({
|
|
121
|
+
kind: "jsx",
|
|
122
|
+
part: false,
|
|
123
|
+
start,
|
|
124
|
+
end,
|
|
125
|
+
value: node.value
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (asCode) {
|
|
130
|
+
walk(node, asCode);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (node.type === "StringLiteral") {
|
|
134
|
+
const quote = code[start];
|
|
135
|
+
runs.push({
|
|
136
|
+
attribute: parent.type === "JSXAttribute",
|
|
137
|
+
kind: quote,
|
|
138
|
+
part: parent.type === "BinaryExpression",
|
|
139
|
+
start: start + 1,
|
|
140
|
+
end: end - 1,
|
|
141
|
+
value: node.value
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (node.type === "TemplateElement") {
|
|
146
|
+
const cooked = node.value?.cooked;
|
|
147
|
+
runs.push({
|
|
148
|
+
kind: "`",
|
|
149
|
+
part: true,
|
|
150
|
+
start,
|
|
151
|
+
end,
|
|
152
|
+
value: cooked ?? ""
|
|
153
|
+
});
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
walk(node, asCode);
|
|
157
|
+
};
|
|
158
|
+
walk(program, false);
|
|
159
|
+
return runs;
|
|
160
|
+
}
|
|
161
|
+
/** The new words as they must be written in a run, or undefined if they cannot. */
|
|
162
|
+
const written = ({ attribute, kind }, value) => {
|
|
163
|
+
if (kind === "jsx") return JSX_UNSAFE_RE.test(value) ? void 0 : value;
|
|
164
|
+
if (attribute) return value.includes(kind) ? void 0 : value;
|
|
165
|
+
const escaped = value.replaceAll("\\", "\\\\").replaceAll(kind, `\\${kind}`);
|
|
166
|
+
return kind === "`" ? escaped.replaceAll("${", "\\${") : escaped;
|
|
167
|
+
};
|
|
168
|
+
const finder = (find) => new RegExp(find.replace(REGEX_CHARS_RE, "\\$&"), "gi");
|
|
169
|
+
/** One module with `find` changed to `to` in its runs the pages showed. */
|
|
170
|
+
function replaceIn(code, filename, find, to, seen) {
|
|
171
|
+
const matches = finder(find);
|
|
172
|
+
let replaced = 0;
|
|
173
|
+
let skipped = 0;
|
|
174
|
+
let next = code;
|
|
175
|
+
const runs = textRuns(code, filename).filter(({ part, value }) => {
|
|
176
|
+
const said = words(value);
|
|
177
|
+
return said.search(matches) !== -1 && (part ? seen.some((text) => text.includes(said)) : seen.includes(said));
|
|
178
|
+
}).sort((a, b) => b.start - a.start);
|
|
179
|
+
for (const run of runs) {
|
|
180
|
+
const raw = code.slice(run.start, run.end);
|
|
181
|
+
const value = written(run, to);
|
|
182
|
+
const count = raw.match(finder(find))?.length ?? 0;
|
|
183
|
+
if (value === void 0) {
|
|
184
|
+
skipped += count;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (count === 0) {
|
|
188
|
+
skipped += 1;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
next = next.slice(0, run.start) + raw.replace(finder(find), () => value) + next.slice(run.end);
|
|
192
|
+
replaced += count;
|
|
193
|
+
}
|
|
194
|
+
if (next !== code && !parseJsx(next, filename)) return {
|
|
195
|
+
next: code,
|
|
196
|
+
replaced: 0,
|
|
197
|
+
skipped: skipped + replaced
|
|
198
|
+
};
|
|
199
|
+
return {
|
|
200
|
+
next,
|
|
201
|
+
replaced,
|
|
202
|
+
skipped
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Change `find` to `to`, ignoring case, wherever the modules in `folder`
|
|
207
|
+
* write it as text that one of the `seen` texts (what the frames showed)
|
|
208
|
+
* holds. Each changed file can be put back with the `undo` it answers with.
|
|
209
|
+
*/
|
|
210
|
+
async function replaceText(folder, find, to, seen) {
|
|
211
|
+
const nothing = {
|
|
212
|
+
files: [],
|
|
213
|
+
replaced: 0,
|
|
214
|
+
skipped: 0
|
|
215
|
+
};
|
|
216
|
+
if (!find.trim() || find.length > MAX_LENGTH || to.length > MAX_LENGTH) return nothing;
|
|
217
|
+
const shown = seen.map(words);
|
|
218
|
+
const changed = [];
|
|
219
|
+
let skipped = 0;
|
|
220
|
+
for (const path of await sourceFiles(folder)) {
|
|
221
|
+
const before = await readFile(path, "utf8");
|
|
222
|
+
if (before.search(finder(find)) === -1) continue;
|
|
223
|
+
const result = replaceIn(before, path, find, to, shown);
|
|
224
|
+
skipped += result.skipped;
|
|
225
|
+
if (result.next !== before) changed.push({
|
|
226
|
+
path,
|
|
227
|
+
before,
|
|
228
|
+
after: result.next,
|
|
229
|
+
replaced: result.replaced
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
const saved = [];
|
|
233
|
+
let replaced = 0;
|
|
234
|
+
for (const change of changed) try {
|
|
235
|
+
if (await readFile(change.path, "utf8") === change.before) {
|
|
236
|
+
await writeFile(change.path, change.after);
|
|
237
|
+
saved.push(change);
|
|
238
|
+
replaced += change.replaced ?? 0;
|
|
239
|
+
}
|
|
240
|
+
} catch {}
|
|
241
|
+
const left = changed.length - saved.length;
|
|
242
|
+
if (saved.length === 0) return {
|
|
243
|
+
...nothing,
|
|
244
|
+
skipped,
|
|
245
|
+
...left > 0 ? { left } : {}
|
|
246
|
+
};
|
|
247
|
+
const undo = randomUUID();
|
|
248
|
+
undos.set(undo, saved);
|
|
249
|
+
for (const old of undos.keys()) {
|
|
250
|
+
if (undos.size <= UNDO_KEPT) break;
|
|
251
|
+
undos.delete(old);
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
files: saved.map(({ path }) => relative(folder, path)),
|
|
255
|
+
...left > 0 ? { left } : {},
|
|
256
|
+
replaced,
|
|
257
|
+
skipped,
|
|
258
|
+
undo
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Put back a replacement: each file it changed, unless it has changed again
|
|
263
|
+
* since, which keeps the newer change. Answers with the files put back and
|
|
264
|
+
* the ones left, relative to `folder`.
|
|
265
|
+
*/
|
|
266
|
+
async function undoReplace(folder, undo) {
|
|
267
|
+
const changed = undos.get(undo) ?? [];
|
|
268
|
+
undos.delete(undo);
|
|
269
|
+
const restored = [];
|
|
270
|
+
const kept = [];
|
|
271
|
+
for (const { path, before, after } of changed) {
|
|
272
|
+
const now = await readFile(path, "utf8").catch(() => void 0);
|
|
273
|
+
const name = relative(folder, path);
|
|
274
|
+
if (now === after) {
|
|
275
|
+
await writeFile(path, before);
|
|
276
|
+
restored.push(name);
|
|
277
|
+
} else kept.push(name);
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
kept,
|
|
281
|
+
restored
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//#endregion
|
|
285
|
+
export { replaceText, undoReplace };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentAction, ListStatus, NewThread, PersonChange, ThreadAnswerOf, ThreadChange, ThreadWithPrototype
|
|
1
|
+
import { AgentAction, ListStatus, NewThread, PersonChange, ThreadAnswerOf, ThreadChange, ThreadWithPrototype } from "../shared/threads-core.mjs";
|
|
2
2
|
import { ReviewFile, ReviewImport } from "../shared/review-file.mjs";
|
|
3
3
|
//#region src/content/thread-module.d.ts
|
|
4
4
|
/** Runs `run` on each tick until the function it returns is called. */
|
|
@@ -69,11 +69,9 @@ export declare function openThreads(root: string, { store: kind, tick }?: {
|
|
|
69
69
|
* agent, or set its status to resolve, dismiss or reopen it. Only those,
|
|
70
70
|
* and never as an agent. Answers as change does.
|
|
71
71
|
*/
|
|
72
|
-
respond: (id: string, { author, authorId, body, edit, on, react, remove, for: audience, hidden, status }: PersonChange & {
|
|
72
|
+
respond: (id: string, { author, authorId, body, edit, on, react, remove, for: audience, hidden, status, target }: PersonChange & {
|
|
73
73
|
author: string;
|
|
74
74
|
}) => Promise<ThreadAnswer | undefined>;
|
|
75
|
-
/** A thread as an agent should read it: what, where, and which file. */
|
|
76
|
-
describe: typeof describeThread;
|
|
77
75
|
subscribe: (listener: ThreadListener, filter?: ThreadFilter) => Promise<() => void>;
|
|
78
76
|
};
|
|
79
77
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { splitPrototypeName } from "../shared/prototypes-core.mjs";
|
|
2
|
+
import { AGENT_ACTIONS, agentChange, changeProblems, statusFilter, threadProblems } from "../shared/threads-core.mjs";
|
|
2
3
|
import { legacyFile, legacyNameOf } from "./prototypes.mjs";
|
|
3
|
-
import { AGENT_ACTIONS, agentChange, changeProblems, describeThread, statusFilter, threadProblems } from "../shared/threads-core.mjs";
|
|
4
4
|
import { reviewFor } from "../shared/review-file.mjs";
|
|
5
5
|
import { fileStore, openStore } from "./store.mjs";
|
|
6
6
|
//#region src/content/thread-module.ts
|
|
@@ -180,7 +180,7 @@ function openThreads(root, { store: kind, tick = every(TICK_MS) } = {}) {
|
|
|
180
180
|
* agent, or set its status to resolve, dismiss or reopen it. Only those,
|
|
181
181
|
* and never as an agent. Answers as change does.
|
|
182
182
|
*/
|
|
183
|
-
respond: (id, { author, authorId, body, edit, on, react, remove, for: audience, hidden, status }) => change(id, {
|
|
183
|
+
respond: (id, { author, authorId, body, edit, on, react, remove, for: audience, hidden, status, target }) => change(id, {
|
|
184
184
|
author,
|
|
185
185
|
authorId,
|
|
186
186
|
body,
|
|
@@ -190,10 +190,9 @@ function openThreads(root, { store: kind, tick = every(TICK_MS) } = {}) {
|
|
|
190
190
|
remove,
|
|
191
191
|
for: audience,
|
|
192
192
|
hidden,
|
|
193
|
-
status
|
|
193
|
+
status,
|
|
194
|
+
target
|
|
194
195
|
}),
|
|
195
|
-
/** A thread as an agent should read it: what, where, and which file. */
|
|
196
|
-
describe: describeThread,
|
|
197
196
|
subscribe: feed.subscribe
|
|
198
197
|
};
|
|
199
198
|
}
|
package/dist/content/threads.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { THREAD_ID_RE, changeConflicts, changeThread, newThread } from "../shared/threads-core.mjs";
|
|
1
2
|
import { withLock } from "../server/file-lock.mjs";
|
|
2
3
|
import { prepareState, studioState } from "../server/state.mjs";
|
|
3
4
|
import { askForMerges } from "./merge-rules.mjs";
|
|
4
5
|
import { listPrototypes, prototypePaths } from "./prototypes.mjs";
|
|
5
|
-
import { THREAD_ID_RE, changeConflicts, changeThread, newThread } from "../shared/threads-core.mjs";
|
|
6
6
|
import { changeEvent, eventLine, foldEvents, parseEvents, snapshotEvent, startEvent } from "./comments-log.mjs";
|
|
7
7
|
import { reviewEvents } from "./review-import.mjs";
|
|
8
8
|
import { existsSync } from "node:fs";
|
package/dist/paste/paste.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { MAX_SIDE } from "../content/capture.mjs";
|
|
1
2
|
import { isSnapshotClipboard, snapshotFrom } from "../shared/snapshot-clipboard.mjs";
|
|
2
3
|
import { fontBringer } from "./fonts.mjs";
|
|
3
|
-
import { MAX_SIDE } from "../content/capture.mjs";
|
|
4
4
|
import { PASTED_IMAGE_TYPES } from "../shared/pasted-image.mjs";
|
|
5
5
|
import { imageDataUrl, withImages } from "../shared/snapshot-images.mjs";
|
|
6
6
|
import { isFigmaClipboard } from "./figma/decode.mjs";
|
package/dist/paths.d.mts
CHANGED
|
@@ -23,8 +23,6 @@ export declare const STUDIO_REACT: {
|
|
|
23
23
|
range: string;
|
|
24
24
|
major: number;
|
|
25
25
|
};
|
|
26
|
-
/** The range the studio asks of a peer dependency: "^2.1.10". */
|
|
27
|
-
export declare const studioPeer: (name: string) => string | undefined;
|
|
28
26
|
/**
|
|
29
27
|
* The highest major a version or range allows ("^18 || ^19" → 19), or
|
|
30
28
|
* undefined when it names none ("catalog:", "latest").
|
package/dist/paths.mjs
CHANGED
|
@@ -36,8 +36,6 @@ const STUDIO_REACT = (() => {
|
|
|
36
36
|
major: Number(range.match(MAJOR_RE)?.[0])
|
|
37
37
|
};
|
|
38
38
|
})();
|
|
39
|
-
/** The range the studio asks of a peer dependency: "^2.1.10". */
|
|
40
|
-
const studioPeer = (name) => JSON.parse(readFileSync(join(PACKAGE_ROOT, "package.json"), "utf8")).peerDependencies?.[name];
|
|
41
39
|
/**
|
|
42
40
|
* The highest major a version or range allows ("^18 || ^19" → 19), or
|
|
43
41
|
* undefined when it names none ("catalog:", "latest").
|
|
@@ -135,4 +133,4 @@ function installedDex(from, fallback) {
|
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
135
|
//#endregion
|
|
138
|
-
export { APP_DIR, EXTENSION_DIR, PACKAGE_NAME, PACKAGE_ROOT, STUDIO_REACT, TEMPLATES_DIR, compareVersions, highestMajor, installedBin, installedDex, isDirectory, isFile, isOlder, posix, readTemplate, runningVersion, shownFrom,
|
|
136
|
+
export { APP_DIR, EXTENSION_DIR, PACKAGE_NAME, PACKAGE_ROOT, STUDIO_REACT, TEMPLATES_DIR, compareVersions, highestMajor, installedBin, installedDex, isDirectory, isFile, isOlder, posix, readTemplate, runningVersion, shownFrom, studioVersion };
|
|
@@ -7,6 +7,10 @@ export declare const withoutAgentSession: (env: NodeJS.ProcessEnv) => NodeJS.Pro
|
|
|
7
7
|
* profile sets the rest, as in any new window. However the terminal app was
|
|
8
8
|
* started, even by an agent's session, nothing of that session reaches what
|
|
9
9
|
* runs. A shell of the same kind stays open once `command` ends.
|
|
10
|
+
*
|
|
11
|
+
* `runtime`, the Node running Dex, goes first on that shell's PATH: a
|
|
12
|
+
* profile may not put Node there at all (nvm loaded only in some shells),
|
|
13
|
+
* and `dex`, its hooks and its MCP server all run on it.
|
|
10
14
|
*/
|
|
11
|
-
export declare const inFreshShell: (command: string) => string;
|
|
15
|
+
export declare const inFreshShell: (command: string, runtime?: string) => string;
|
|
12
16
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
1
2
|
//#region src/server/agent-env.ts
|
|
2
3
|
const SESSION_MARKERS = [
|
|
3
4
|
"CLAUDECODE",
|
|
@@ -37,10 +38,14 @@ const quoted = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
|
37
38
|
* profile sets the rest, as in any new window. However the terminal app was
|
|
38
39
|
* started, even by an agent's session, nothing of that session reaches what
|
|
39
40
|
* runs. A shell of the same kind stays open once `command` ends.
|
|
41
|
+
*
|
|
42
|
+
* `runtime`, the Node running Dex, goes first on that shell's PATH: a
|
|
43
|
+
* profile may not put Node there at all (nvm loaded only in some shells),
|
|
44
|
+
* and `dex`, its hooks and its MCP server all run on it.
|
|
40
45
|
*/
|
|
41
|
-
const inFreshShell = (command) => {
|
|
46
|
+
const inFreshShell = (command, runtime = process.execPath) => {
|
|
42
47
|
const kept = KEPT_FOR_LOGIN.map((name) => `${name}="$${name}"`).join(" ");
|
|
43
|
-
const then = `${command}; exec "$SHELL" -l`;
|
|
48
|
+
const then = `${`export PATH=${quoted(dirname(runtime))}:"$PATH"`}; ${command}; exec "$SHELL" -l`;
|
|
44
49
|
return `exec /usr/bin/env -i ${kept} "$SHELL" -lic ${quoted(then)}`;
|
|
45
50
|
};
|
|
46
51
|
//#endregion
|
|
@@ -24,12 +24,18 @@ export declare const presenceTargetOf: (thread: ThreadWithPrototype) => Presence
|
|
|
24
24
|
* acting on `threads`. Presence is best effort: a mark that fails never
|
|
25
25
|
* fails the action.
|
|
26
26
|
*/
|
|
27
|
-
export declare function openAgentSession(root: string, threads: ThreadModule, { agent, id, presence }: {
|
|
27
|
+
export declare function openAgentSession(root: string, threads: ThreadModule, { agent, claudeSession, id, presence }: {
|
|
28
28
|
agent: () => string;
|
|
29
|
+
/**
|
|
30
|
+
* The Claude Code session it serves, when it does: Claude's hook marks
|
|
31
|
+
* that agent's edits under its id.
|
|
32
|
+
*/
|
|
33
|
+
claudeSession?: string;
|
|
29
34
|
id?: string;
|
|
30
35
|
presence?: SessionPresence;
|
|
31
36
|
}): {
|
|
32
37
|
id: string;
|
|
38
|
+
marksUnder: string[];
|
|
33
39
|
act: (threadId: string, action: UnsignedAction) => Promise<ThreadAnswer | undefined>;
|
|
34
40
|
/**
|
|
35
41
|
* Claim a thread for this session: it is acknowledged (👀), and the
|
|
@@ -44,6 +50,13 @@ export declare function openAgentSession(root: string, threads: ThreadModule, {
|
|
|
44
50
|
adopt: (threadIds: string[]) => void;
|
|
45
51
|
/** The threads the session holds now, for the server after this one. */
|
|
46
52
|
holding: () => string[];
|
|
53
|
+
/**
|
|
54
|
+
* The agent waits for work (`watch`): holding none, it is at work
|
|
55
|
+
* nowhere, as when its turn ends, so nothing it marked shows. Holding
|
|
56
|
+
* some, its marks stay with them. A comment a person closed or answered
|
|
57
|
+
* while it held it is no longer its own, and counts for none.
|
|
58
|
+
*/
|
|
59
|
+
waits: () => Promise<void>;
|
|
47
60
|
/** Hear how many threads the session holds, each time that changes. */
|
|
48
61
|
onHoldingChange: (listener: (count: number) => void) => void;
|
|
49
62
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { claimOf } from "../shared/threads-core.mjs";
|
|
1
2
|
import { openPresence } from "./presence.mjs";
|
|
2
3
|
import { randomUUID } from "node:crypto";
|
|
3
4
|
//#region src/server/agent-session.ts
|
|
@@ -34,17 +35,19 @@ const presenceTargetOf = (thread) => {
|
|
|
34
35
|
* acting on `threads`. Presence is best effort: a mark that fails never
|
|
35
36
|
* fails the action.
|
|
36
37
|
*/
|
|
37
|
-
function openAgentSession(root, threads, { agent, id = newSessionId(), presence = openPresence(root) }) {
|
|
38
|
-
/**
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
function openAgentSession(root, threads, { agent, claudeSession, id = newSessionId(), presence = openPresence(root) }) {
|
|
39
|
+
/** Whom its marks are under: itself, and the Claude Code session it serves. */
|
|
40
|
+
const marksUnder = claudeSession && claudeSession !== id ? [id, claudeSession] : [id];
|
|
41
|
+
/**
|
|
42
|
+
* Clear its marks, its sub-agents' too, on one view or doc or everywhere.
|
|
43
|
+
* Presence only shows the work: a clear that fails changes nothing, and
|
|
44
|
+
* marks expire.
|
|
45
|
+
*/
|
|
46
|
+
const clearMarks = async (where) => {
|
|
47
|
+
await Promise.allSettled(marksUnder.map((within) => presence.clear({
|
|
48
|
+
...where,
|
|
49
|
+
within
|
|
50
|
+
})));
|
|
48
51
|
};
|
|
49
52
|
/** Threads this session claimed and has not yet closed or answered. */
|
|
50
53
|
const held = /* @__PURE__ */ new Set();
|
|
@@ -58,6 +61,53 @@ function openAgentSession(root, threads, { agent, id = newSessionId(), presence
|
|
|
58
61
|
};
|
|
59
62
|
/** Given to another server (mcp-handover.ts): this one lets go of nothing. */
|
|
60
63
|
let handedOver = false;
|
|
64
|
+
/** Where each thread it holds is on the canvas, once it has looked. */
|
|
65
|
+
const places = /* @__PURE__ */ new Map();
|
|
66
|
+
const placeOf = async (threadId) => {
|
|
67
|
+
if (!places.has(threadId)) {
|
|
68
|
+
const thread = await threads.find(threadId);
|
|
69
|
+
places.set(threadId, thread && presenceTargetOf(thread));
|
|
70
|
+
}
|
|
71
|
+
return places.get(threadId);
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Let go of the threads it holds that a person closed or answered since
|
|
75
|
+
* it claimed them, which are no longer its own. One claimed meanwhile
|
|
76
|
+
* stays held.
|
|
77
|
+
*/
|
|
78
|
+
const letGoOfClosed = async () => {
|
|
79
|
+
const ids = [...held];
|
|
80
|
+
if (ids.length === 0) return;
|
|
81
|
+
const own = new Set((await threads.list({ status: "acknowledged" })).filter((thread) => claimOf(thread)?.session === id).map((thread) => thread.id));
|
|
82
|
+
const closed = ids.filter((each) => !own.has(each));
|
|
83
|
+
if (closed.length > 0) holdingChange(() => {
|
|
84
|
+
for (const each of closed) {
|
|
85
|
+
held.delete(each);
|
|
86
|
+
places.delete(each);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
/** Whether it holds a thread on `where`, as far as it knows. */
|
|
91
|
+
const holdsOn = async (where) => (await Promise.all([...held].map(placeOf))).some((on) => on?.slug === where.slug && on.target === where.target);
|
|
92
|
+
/**
|
|
93
|
+
* Its work on `thread` (or on nothing, waiting) is over: the thread's view
|
|
94
|
+
* shows nobody at work for it, unless it holds another there, and once
|
|
95
|
+
* it holds nothing, nothing it marked does (the file's shared code, other
|
|
96
|
+
* views it changed on the way). What it holds is looked at again first
|
|
97
|
+
* with `recheck`, or when another it holds would keep the view's marks,
|
|
98
|
+
* as a person may have closed it meanwhile. Handed over, its marks are
|
|
99
|
+
* the next server's.
|
|
100
|
+
*/
|
|
101
|
+
const workEnded = async (thread, recheck) => {
|
|
102
|
+
if (handedOver) return;
|
|
103
|
+
const where = thread && presenceTargetOf(thread);
|
|
104
|
+
if (recheck || where && await holdsOn(where)) await letGoOfClosed().catch(() => void 0);
|
|
105
|
+
if (held.size === 0) {
|
|
106
|
+
await clearMarks();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (where && !await holdsOn(where)) await clearMarks(where);
|
|
110
|
+
};
|
|
61
111
|
/**
|
|
62
112
|
* An action on a thread, signed by this session: the thread after it, the
|
|
63
113
|
* problems that stopped it, or undefined when there is no such thread.
|
|
@@ -68,12 +118,17 @@ function openAgentSession(root, threads, { agent, id = newSessionId(), presence
|
|
|
68
118
|
author: agent(),
|
|
69
119
|
session: id
|
|
70
120
|
});
|
|
71
|
-
if (answer?.thread
|
|
72
|
-
|
|
121
|
+
if (action.action === "release" || Boolean(answer?.thread && LETS_GO.has(action.action))) {
|
|
122
|
+
const finished = held.has(threadId);
|
|
123
|
+
holdingChange(() => held.delete(threadId));
|
|
124
|
+
places.delete(threadId);
|
|
125
|
+
await workEnded(answer?.thread, finished).catch(() => void 0);
|
|
126
|
+
}
|
|
73
127
|
return answer;
|
|
74
128
|
};
|
|
75
129
|
return {
|
|
76
130
|
id,
|
|
131
|
+
marksUnder,
|
|
77
132
|
act,
|
|
78
133
|
/**
|
|
79
134
|
* Claim a thread for this session: it is acknowledged (👀), and the
|
|
@@ -82,7 +137,10 @@ function openAgentSession(root, threads, { agent, id = newSessionId(), presence
|
|
|
82
137
|
*/
|
|
83
138
|
claim: async (threadId) => {
|
|
84
139
|
const answer = await act(threadId, { action: "acknowledge" });
|
|
85
|
-
if (answer?.thread)
|
|
140
|
+
if (answer?.thread) {
|
|
141
|
+
places.set(threadId, presenceTargetOf(answer.thread));
|
|
142
|
+
holdingChange(() => held.add(threadId));
|
|
143
|
+
}
|
|
86
144
|
return answer;
|
|
87
145
|
},
|
|
88
146
|
/**
|
|
@@ -96,6 +154,13 @@ function openAgentSession(root, threads, { agent, id = newSessionId(), presence
|
|
|
96
154
|
},
|
|
97
155
|
/** The threads the session holds now, for the server after this one. */
|
|
98
156
|
holding: () => [...held],
|
|
157
|
+
/**
|
|
158
|
+
* The agent waits for work (`watch`): holding none, it is at work
|
|
159
|
+
* nowhere, as when its turn ends, so nothing it marked shows. Holding
|
|
160
|
+
* some, its marks stay with them. A comment a person closed or answered
|
|
161
|
+
* while it held it is no longer its own, and counts for none.
|
|
162
|
+
*/
|
|
163
|
+
waits: () => workEnded(void 0, true).catch(() => void 0),
|
|
99
164
|
/** Hear how many threads the session holds, each time that changes. */
|
|
100
165
|
onHoldingChange: (listener) => {
|
|
101
166
|
holdingListeners.add(listener);
|
|
@@ -108,7 +173,10 @@ function openAgentSession(root, threads, { agent, id = newSessionId(), presence
|
|
|
108
173
|
handOver: (given) => {
|
|
109
174
|
handedOver = true;
|
|
110
175
|
holdingChange(() => {
|
|
111
|
-
for (const threadId of given)
|
|
176
|
+
for (const threadId of given) {
|
|
177
|
+
held.delete(threadId);
|
|
178
|
+
places.delete(threadId);
|
|
179
|
+
}
|
|
112
180
|
});
|
|
113
181
|
},
|
|
114
182
|
/**
|
|
@@ -120,10 +188,7 @@ function openAgentSession(root, threads, { agent, id = newSessionId(), presence
|
|
|
120
188
|
const unfinished = [...held];
|
|
121
189
|
holdingChange(() => held.clear());
|
|
122
190
|
await Promise.allSettled(unfinished.map((threadId) => act(threadId, { action: "release" })));
|
|
123
|
-
if (handedOver)
|
|
124
|
-
try {
|
|
125
|
-
await presence.clear({ session: id });
|
|
126
|
-
} catch {}
|
|
191
|
+
if (!handedOver) await clearMarks();
|
|
127
192
|
}
|
|
128
193
|
};
|
|
129
194
|
}
|
package/dist/server/agents.d.mts
CHANGED
|
@@ -10,6 +10,11 @@ export type Piece = "mcp" | "presence" | "instructions";
|
|
|
10
10
|
interface PieceStatus {
|
|
11
11
|
/** Whether anything of it is there, so nothing at all is "not set up". */
|
|
12
12
|
found: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether it lacks only Dex's names: the studio wrote it under a name or
|
|
15
|
+
* command from before a rename, which adding renames and nothing else.
|
|
16
|
+
*/
|
|
17
|
+
old?: boolean;
|
|
13
18
|
piece: Piece;
|
|
14
19
|
why?: string;
|
|
15
20
|
}
|
|
@@ -30,6 +35,11 @@ export interface AgentSetup {
|
|
|
30
35
|
piece: Piece;
|
|
31
36
|
why: string;
|
|
32
37
|
}[];
|
|
38
|
+
/**
|
|
39
|
+
* Whether all it lacks is Dex's names (a server or hook the studio wrote
|
|
40
|
+
* before a rename): `dex upgrade` adds it again, as the dialog does.
|
|
41
|
+
*/
|
|
42
|
+
old: boolean;
|
|
33
43
|
oneClick: boolean;
|
|
34
44
|
status: SetupStatus;
|
|
35
45
|
}
|