moi-computer 0.12.1-next.0 → 0.12.1-next.2
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/README.md +26 -26
- package/bin/moi.mjs +2 -2
- package/client/AGENTS.md +7 -3
- package/client/api/app-config.ts +5 -10
- package/client/api/workspace-keys.ts +3 -2
- package/client/app/app-provider.tsx +25 -0
- package/client/app/{AppRouter.tsx → app-router.tsx} +4 -4
- package/client/app/routes/{HomeRoute.tsx → home-route.tsx} +2 -2
- package/client/app/routes/{WorkspaceRoute.tsx → workspace-route.tsx} +22 -23
- package/client/app/shell/{SidebarLayout.tsx → sidebar-layout.tsx} +29 -23
- package/client/dev/index.html +43 -0
- package/client/dev/index.ts +15 -0
- package/client/features/applets/api.ts +1 -1
- package/client/features/applets/{AppletContainer.tsx → applet-container.tsx} +1 -1
- package/client/features/applets/applet-thumbnail.ts +1 -1
- package/client/features/applets/{useApplet.ts → use-applet.ts} +2 -2
- package/client/features/applets/{WidgetShell.tsx → widget-shell.tsx} +4 -4
- package/client/features/chat/applet-chat-intents.ts +4 -4
- package/client/features/chat/{ChatPanel.tsx → chat-panel.tsx} +11 -11
- package/client/features/chat/{ChatPopup.tsx → chat-popup.tsx} +1 -1
- package/client/features/chat/composer/attachments/{DrawingAttachmentChip.tsx → drawing-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/attachments/{FileAttachmentChip.tsx → file-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/attachments/{TextAttachmentChip.tsx → text-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/banners/{ComposerBanner.tsx → composer-banner.tsx} +0 -14
- package/client/features/chat/composer/banners/{ErrorBanner.tsx → error-banner.tsx} +1 -1
- package/client/features/chat/composer/banners/{SkillUpdateBanner.tsx → skill-update-banner.tsx} +3 -3
- package/client/features/chat/composer/{ChatComposer.tsx → chat-composer.tsx} +8 -7
- package/client/features/chat/composer/{ModelPicker.tsx → model-picker.tsx} +1 -1
- package/client/features/chat/composer/{useWorkspaceComposerState.tsx → use-workspace-composer-state.tsx} +12 -28
- package/client/features/chat/composer/{useWorkspaceSkillUpdates.ts → use-workspace-skill-updates.ts} +1 -1
- package/client/features/chat/connection/chat-frames.ts +3 -3
- package/client/features/chat/messages/{ChatEmptyState.tsx → chat-empty-state.tsx} +4 -4
- package/client/features/chat/messages/{MarkdownContent.tsx → markdown-content.tsx} +1 -1
- package/client/features/chat/messages/tool-group/index.ts +1 -1
- package/client/features/chat/messages/tool-group/{ReadImagePreview.tsx → read-image-preview.tsx} +2 -2
- package/client/features/chat/messages/tool-group/{SubagentCard.tsx → subagent-card.tsx} +3 -3
- package/client/features/chat/messages/tool-group/{TimelineRow.tsx → timeline-row.tsx} +1 -1
- package/client/features/chat/messages/tool-group/{ToolCallGroup.tsx → tool-call-group.tsx} +8 -8
- package/client/features/chat/messages/tool-group/{ToolOutput.tsx → tool-output.tsx} +1 -1
- package/client/features/chat/messages/{TurnView.tsx → turn-view.tsx} +4 -4
- package/client/features/chat/sessions/api.ts +3 -3
- package/client/features/chat/sessions/{ChatSelector.tsx → chat-selector.tsx} +2 -2
- package/client/features/chat/sessions/{useSelectedSession.ts → use-selected-session.ts} +2 -2
- package/client/features/chat/{useChat.ts → use-chat.ts} +4 -4
- package/client/features/collab/host-state.ts +24 -7
- package/client/features/collab/local-user.ts +1 -1
- package/client/features/collab/proxy-user.ts +4 -9
- package/client/features/connectors/mcp-icons.ts +1 -1
- package/client/features/connectors/{McpServerCards.tsx → mcp-server-cards.tsx} +1 -1
- package/client/features/{home/workspace-setup/DemoDialog.tsx → demo/demo-dialog.tsx} +26 -80
- package/client/features/dev/chat-states-fixtures.ts +4 -4
- package/client/features/dev/{ChatStatesPage.tsx → chat-states-page.tsx} +6 -6
- package/client/features/dev/collab/local-user-settings.tsx +4 -4
- package/client/features/dev/{DevIndexPage.tsx → dev-index-page.tsx} +7 -1
- package/client/features/dev/{DevRoutes.tsx → dev-routes.tsx} +8 -6
- package/client/features/dev/workspace-setup-mocks.ts +102 -0
- package/client/features/dev/workspace-setup-page.tsx +11 -0
- package/client/features/dev/workspace-setup-preview.tsx +253 -0
- package/client/features/drawings/{DrawingToolbar.tsx → drawing-toolbar.tsx} +1 -1
- package/client/features/drawings/{useChatAnnotation.ts → use-chat-annotation.ts} +29 -23
- package/client/features/drawings/{useDrawingLayer.ts → use-drawing-layer.ts} +1 -1
- package/client/features/drawings/{useViewSketch.ts → use-view-sketch.ts} +1 -1
- package/client/features/harness/api.ts +36 -0
- package/client/features/harness/device-login-steps.tsx +97 -0
- package/client/features/home/api.ts +29 -89
- package/client/features/home/{HomeLogo.tsx → home-logo.tsx} +1 -1
- package/client/features/home/{HomePage.tsx → home-page.tsx} +13 -14
- package/client/features/overview/api.ts +2 -2
- package/client/features/overview/default/registry.tsx +1 -1
- package/client/features/overview/default/{ViewsWidget.tsx → views-widget.tsx} +1 -1
- package/client/features/overview/{HiddenPanel.tsx → hidden-panel.tsx} +2 -2
- package/client/features/overview/{Overview.tsx → overview.tsx} +6 -6
- package/client/features/overview/{WidgetCanvas.tsx → widget-canvas.tsx} +1 -1
- package/client/features/overview/{WidgetFrame.tsx → widget-frame.tsx} +1 -1
- package/client/features/overview/workspace-name.tsx +55 -0
- package/client/features/scratchpad/{Scratchpad.tsx → scratchpad.tsx} +10 -13
- package/client/features/scratchpad/{useScratchpadSnapshot.tsx → use-scratchpad-snapshot.tsx} +3 -3
- package/client/features/settings/api.ts +15 -9
- package/client/features/settings/{ConnectorsSettings.tsx → connectors-settings.tsx} +3 -3
- package/client/features/settings/{EnvironmentSettings.tsx → environment-settings.tsx} +3 -3
- package/client/features/settings/{GeneralSettings.tsx → general-settings.tsx} +5 -5
- package/client/features/settings/{useEnvVars.ts → use-env-vars.ts} +1 -1
- package/client/features/settings/{WorkspaceIconPicker.tsx → workspace-icon-picker.tsx} +1 -1
- package/client/features/settings/{WorkspaceSettingsDialog.tsx → workspace-settings-dialog.tsx} +3 -3
- package/client/features/update/api.ts +1 -1
- package/client/features/views/api.ts +1 -1
- package/client/features/views/{PendingViewScreen.tsx → pending-view-screen.tsx} +7 -4
- package/client/features/views/{useViewActions.ts → use-view-actions.ts} +2 -2
- package/client/features/views/{useViewDrafts.ts → use-view-drafts.ts} +15 -6
- package/client/features/views/{ViewManager.tsx → view-manager.tsx} +3 -3
- package/client/features/views/view-submission.ts +1 -1
- package/client/features/workspace/add/api.ts +80 -0
- package/client/features/{home/workspace-setup/CreateWorkspaceDialog.tsx → workspace/add/create-workspace-dialog.tsx} +56 -42
- package/client/features/workspace/add/import-workspace-dialog.tsx +81 -0
- package/client/features/{home/workspace-setup/useWorkspaceImport.ts → workspace/add/use-workspace-import.ts} +1 -1
- package/client/features/workspace/add/workspace-agent-options.ts +53 -0
- package/client/features/{home/workspace-setup/WorkspaceAgentStep.tsx → workspace/add/workspace-agent-selector.tsx} +59 -98
- package/client/features/{home/workspace-setup/WorkspaceDialogContent.tsx → workspace/add/workspace-dialog-content.tsx} +1 -1
- package/client/features/workspace/api.ts +31 -26
- package/client/features/workspace/browser-tab-state.ts +1 -1
- package/client/features/workspace/moi-context.ts +1 -1
- package/client/features/workspace/setup/workspace-login-state.tsx +175 -0
- package/client/features/workspace/setup/workspace-recovery-states.tsx +125 -0
- package/client/features/workspace/setup/workspace-setup-panel.tsx +18 -0
- package/client/features/workspace/setup/workspace-setup.tsx +78 -0
- package/client/features/workspace/setup/workspace-welcome-state.tsx +81 -0
- package/client/features/workspace/{ThemePanel.tsx → theme-panel.tsx} +3 -3
- package/client/features/workspace/{useWorkspaceNavigation.ts → use-workspace-navigation.ts} +2 -2
- package/client/features/workspace/{WorkspaceScreen.tsx → workspace-content.tsx} +37 -80
- package/client/features/workspace/workspace-frame.tsx +76 -0
- package/client/features/workspace/workspace-identity.tsx +40 -0
- package/client/features/workspace/{WorkspaceLayoutContext.tsx → workspace-layout-context.tsx} +2 -0
- package/client/features/workspace/{WorkspaceMenu.tsx → workspace-menu.tsx} +3 -3
- package/client/features/workspace/workspace-pending-screen.tsx +26 -0
- package/client/features/{home → workspace}/workspace-presentation.tsx +10 -3
- package/client/features/workspace/workspace-screen.tsx +28 -0
- package/client/features/workspace/{WorkspaceSplitLayout.tsx → workspace-split-layout.tsx} +1 -1
- package/client/features/workspace/{WorkspaceTabs.tsx → workspace-tabs.tsx} +2 -2
- package/client/index.css +2 -2
- package/client/index.html +29 -10
- package/client/index.tsx +7 -2
- package/client/lib/agent-availability.ts +0 -5
- package/client/lib/browser-tab-id.ts +4 -0
- package/client/main.tsx +10 -7
- package/client/runtime/app-context.ts +20 -0
- package/client/runtime/use-workspace-events.ts +56 -0
- package/client/runtime/workspace-events.ts +151 -0
- package/dist/chunk-00rh9df4.js +2 -0
- package/dist/chunk-4nh7y1hq.css +1 -0
- package/dist/{chunk-vqpkqtdr.js → chunk-am4agx6v.js} +1 -1
- package/dist/{chunk-gps4qc38.js → chunk-d7cbm65e.js} +1 -1
- package/dist/chunk-hbpdv7vd.js +1 -0
- package/dist/chunk-hmka9rt5.js +2 -0
- package/dist/{chunk-j905va8r.js → chunk-hvh9f5h0.js} +1 -1
- package/dist/chunk-mjjregkn.js +10 -0
- package/dist/chunk-rt30jbcm.js +1 -0
- package/dist/chunk-vt6zybej.js +2 -0
- package/dist/chunk-wbkwf6cc.js +68 -0
- package/dist/chunk-xjyfyz64.js +1 -0
- package/dist/{chunk-hzwr8dp8.js → chunk-y8nbwp21.js} +71 -71
- package/dist/chunk-ysfdcew7.js +1 -0
- package/dist/index.html +30 -11
- package/lib/format.ts +1 -1
- package/lib/harness-instructions.ts +30 -0
- package/lib/ids.ts +3 -3
- package/lib/moi-context.ts +2 -2
- package/lib/scratchpad-skew.ts +3 -3
- package/lib/types.ts +28 -20
- package/lib/update.ts +1 -1
- package/package.json +5 -2
- package/server/AGENTS.md +10 -4
- package/server/README.md +102 -0
- package/server/api/harnesses.ts +56 -0
- package/server/{api.ts → api/index.ts} +125 -118
- package/server/app-config.ts +24 -12
- package/server/app-settings.ts +1 -1
- package/server/applets/applet-css.ts +1 -1
- package/server/applets/build-applet.ts +4 -4
- package/server/applets/build-worker.ts +1 -1
- package/server/applets/config.ts +1 -1
- package/server/{functions-worker.ts → applets/functions-worker.ts} +1 -1
- package/server/{functions.ts → applets/functions.ts} +2 -2
- package/server/applets/index.ts +2 -2
- package/server/{thumbnails.ts → applets/thumbnails.ts} +9 -6
- package/server/{applet-typecheck.ts → applets/typecheck.ts} +4 -4
- package/server/{ui-components.ts → applets/ui-components.ts} +2 -2
- package/server/{views.ts → applets/views.ts} +7 -7
- package/server/{widgets.ts → applets/widgets.ts} +2 -2
- package/server/cli/applet-selector.ts +19 -0
- package/server/cli/args.ts +5 -0
- package/server/{cli-colors.ts → cli/colors.ts} +1 -1
- package/server/cli/commands/bundle.ts +119 -0
- package/server/cli/commands/call-server-fn.ts +42 -0
- package/server/cli/commands/check.ts +53 -0
- package/server/cli/commands/config.ts +132 -0
- package/server/cli/commands/debug.ts +119 -0
- package/server/cli/commands/env.ts +162 -0
- package/server/cli/commands/hermes.ts +149 -0
- package/server/cli/commands/init.ts +286 -0
- package/server/cli/commands/navigate.ts +35 -0
- package/server/cli/commands/openclaw.ts +168 -0
- package/server/cli/commands/refresh.ts +39 -0
- package/server/cli/commands/scratch.ts +496 -0
- package/server/cli/commands/service.ts +298 -0
- package/server/cli/commands/skill.ts +122 -0
- package/server/cli/commands/start.ts +138 -0
- package/server/cli/commands/status.ts +80 -0
- package/server/cli/commands/tabs.ts +43 -0
- package/server/cli/commands/theme.ts +192 -0
- package/server/cli/commands/ui-components.ts +15 -0
- package/server/cli/commands/update.ts +192 -0
- package/server/cli/commands/version.ts +9 -0
- package/server/cli/commands/views.ts +87 -0
- package/server/cli/control.ts +89 -0
- package/server/{cli-env.ts → cli/env.ts} +9 -9
- package/server/cli/index.ts +171 -0
- package/server/{cli-pc.ts → cli/pc.ts} +1 -1
- package/server/cli/provider.ts +25 -0
- package/server/cli/server-version.ts +16 -0
- package/server/cli/server.ts +81 -0
- package/server/{cli-ui-components.ts → cli/ui-components.ts} +5 -5
- package/server/cli.ts +2 -3252
- package/server/collab/manager.ts +3 -3
- package/server/collab/skill/index.ts +2 -2
- package/server/control.ts +20 -20
- package/server/harness/README.md +47 -25
- package/server/harness/acp/NOTES.md +11 -11
- package/server/harness/acp/archived.ts +3 -3
- package/server/harness/acp/client.ts +2 -2
- package/server/harness/acp/run-durations.ts +1 -1
- package/server/harness/acp/session.ts +5 -5
- package/server/harness/auth.ts +303 -0
- package/server/harness/claude-code/NOTES.md +9 -7
- package/server/harness/claude-code/auth.ts +125 -17
- package/server/harness/claude-code/index.ts +2 -1
- package/server/harness/claude-code/mcp.ts +1 -1
- package/server/harness/claude-code/session.ts +10 -7
- package/server/harness/codex/NOTES.md +12 -12
- package/server/harness/codex/auth.ts +86 -19
- package/server/harness/codex/client.ts +17 -13
- package/server/harness/codex/index.ts +2 -1
- package/server/harness/codex/permissions.ts +3 -3
- package/server/harness/codex/probe.ts +3 -5
- package/server/harness/codex/session.ts +16 -13
- package/server/harness/codex/thread-list.ts +4 -0
- package/server/harness/codex/transport.ts +5 -5
- package/server/harness/executable.ts +42 -18
- package/server/harness/hermes/NOTES.md +70 -70
- package/server/harness/hermes/discovery.ts +1 -1
- package/server/harness/openclaw/NOTES.md +24 -24
- package/server/harness/openclaw/adapter.ts +1 -1
- package/server/harness/openclaw/compat.ts +1 -1
- package/server/harness/openclaw/session.ts +5 -2
- package/server/harness/registry.ts +1 -1
- package/server/harness/shell-path.ts +31 -21
- package/server/harness/types.ts +9 -2
- package/server/navigation-relay.ts +1 -1
- package/server/open-browser.ts +7 -0
- package/server/{scratchpad-assets.ts → scratchpad/assets.ts} +4 -4
- package/server/{scratchpad.ts → scratchpad/document.ts} +8 -8
- package/server/{scratchpad-executor.ts → scratchpad/executor.ts} +7 -7
- package/server/{scratchpad-relay.ts → scratchpad/relay.ts} +4 -5
- package/server/{scratchpad-shape-defaults.ts → scratchpad/shape-defaults.ts} +2 -2
- package/server/server-cwd.ts +1 -1
- package/server/service.ts +2 -2
- package/server/{session-archive.ts → sessions/archive.ts} +5 -5
- package/server/{attachment-message.ts → sessions/attachment-message.ts} +1 -1
- package/server/{session-config.ts → sessions/config.ts} +1 -1
- package/server/{session-lifecycle.ts → sessions/lifecycle.ts} +3 -3
- package/server/{pending-views.ts → sessions/pending-views.ts} +3 -3
- package/server/{selected-session.ts → sessions/selected.ts} +1 -1
- package/server/{session-store.ts → sessions/store.ts} +1 -1
- package/server/{view-sessions.ts → sessions/view-sessions.ts} +9 -9
- package/server/{skills-template.ts → skills/template.ts} +1 -1
- package/server/{skill-update.ts → skills/update.ts} +5 -5
- package/server/{skill-version.ts → skills/version.ts} +4 -4
- package/server/static.ts +5 -3
- package/server/status.ts +3 -3
- package/server/vendor.ts +23 -30
- package/server/web.ts +17 -9
- package/server/{env-apply.ts → workspaces/env-apply.ts} +5 -5
- package/server/{workspace-env.ts → workspaces/env.ts} +3 -3
- package/server/{workspace-import.ts → workspaces/import.ts} +4 -4
- package/server/{workspace-init.ts → workspaces/init.ts} +5 -5
- package/server/{layout.ts → workspaces/layout.ts} +13 -8
- package/server/{preview.ts → workspaces/preview.ts} +1 -1
- package/server/{registry.ts → workspaces/registry.ts} +3 -3
- package/server/{required-env.ts → workspaces/required-env.ts} +3 -3
- package/server/{moi-scaffold.ts → workspaces/scaffold.ts} +3 -3
- package/ui-components/button.tsx +1 -1
- package/ui-components/docs/attachment.md +2 -2
- package/ui-components/docs/button.md +1 -1
- package/ui-components/docs/calendar.md +1 -1
- package/ui-components/docs/chart.md +4 -4
- package/ui-components/docs/data-table.md +1 -1
- package/ui-components/docs/drawer.md +1 -1
- package/ui-components/docs/field.md +1 -1
- package/ui-components/docs/input.md +2 -2
- package/ui-components/docs/label.md +2 -2
- package/ui-components/docs/table.md +2 -2
- package/workspace/.claude/skills/moi-workspace/SKILL.md +12 -12
- package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +2 -2
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +2 -2
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +2 -2
- package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +0 -101
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +0 -92
- package/client/features/overview/WorkspaceName.tsx +0 -60
- package/client/runtime/useWorkspaceEvents.ts +0 -189
- package/dist/chunk-1zhnhy00.js +0 -1
- package/dist/chunk-27501vke.js +0 -1
- package/dist/chunk-9xtv6djt.js +0 -2
- package/dist/chunk-am1x230f.js +0 -2
- package/dist/chunk-darpsw65.js +0 -1
- package/dist/chunk-n33w9y38.js +0 -10
- package/dist/chunk-r63ks44z.js +0 -68
- package/dist/chunk-wd46nk26.css +0 -1
- package/dist/chunk-xgt7vxt9.js +0 -1
- package/dist/chunk-yvzhwtfa.js +0 -2
- package/server/agent.ts +0 -223
- /package/client/components/shared/{AgentBlobatar.tsx → agent-blobatar.tsx} +0 -0
- /package/client/components/shared/{BottomPanel.tsx → bottom-panel.tsx} +0 -0
- /package/client/components/shared/{Composer.tsx → composer.tsx} +0 -0
- /package/client/components/shared/{LedLogo.tsx → led-logo.tsx} +0 -0
- /package/client/components/shared/{PanelHeader.tsx → panel-header.tsx} +0 -0
- /package/client/components/shared/{ReorderableList.tsx → reorderable-list.tsx} +0 -0
- /package/client/components/shared/{WorkspaceIcon.tsx → workspace-icon.tsx} +0 -0
- /package/client/features/applets/{WidgetErrorBoundary.tsx → widget-error-boundary.tsx} +0 -0
- /package/client/features/chat/composer/attachments/{AttachmentChip.tsx → attachment-chip.tsx} +0 -0
- /package/client/features/chat/messages/{ChatPromptBubbles.tsx → chat-prompt-bubbles.tsx} +0 -0
- /package/client/features/chat/messages/{ShimmerText.tsx → shimmer-text.tsx} +0 -0
- /package/client/features/chat/messages/tool-group/{CodeBlock.tsx → code-block.tsx} +0 -0
- /package/client/features/chat/messages/tool-group/{Collapse.tsx → collapse.tsx} +0 -0
- /package/client/features/chat/messages/{useStickToBottom.ts → use-stick-to-bottom.ts} +0 -0
- /package/client/features/connectors/{IconMcp.tsx → icon-mcp.tsx} +0 -0
- /package/client/features/dev/{BlobatarShapesPage.tsx → blobatar-shapes-page.tsx} +0 -0
- /package/client/features/dev/{HarnessDebugPage.tsx → harness-debug-page.tsx} +0 -0
- /package/client/features/dev/{TextureLabPage.tsx → texture-lab-page.tsx} +0 -0
- /package/client/features/dev/{ToolCallsPage.tsx → tool-calls-page.tsx} +0 -0
- /package/client/features/drawings/{DrawingLayer.tsx → drawing-layer.tsx} +0 -0
- /package/client/features/home/{WorkspacePreview.tsx → workspace-preview.tsx} +0 -0
- /package/client/features/overview/{useGridReconcile.ts → use-grid-reconcile.ts} +0 -0
- /package/client/features/scratchpad/{ScratchpadControls.tsx → scratchpad-controls.tsx} +0 -0
- /package/client/features/settings/{SettingsLayout.tsx → settings-layout.tsx} +0 -0
- /package/client/features/update/{UpdateControl.tsx → update-control.tsx} +0 -0
- /package/client/features/workspace/{UnavailablePage.tsx → unavailable-page.tsx} +0 -0
- /package/client/features/workspace/{useFitsSplitLayout.ts → use-fits-split-layout.ts} +0 -0
- /package/client/features/workspace/{WorkspaceContext.tsx → workspace-context.tsx} +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom-client.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-dom-client.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-dom.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom-client.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-dom-client.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-dom.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react.js +0 -0
- /package/server/{bundle-queue.ts → applets/bundle-queue.ts} +0 -0
- /package/server/{applet-log.ts → applets/log.ts} +0 -0
- /package/server/{cli-ui.ts → cli/ui.ts} +0 -0
- /package/server/{workspace-config.ts → workspaces/config.ts} +0 -0
- /package/server/{icon.ts → workspaces/icon.ts} +0 -0
- /package/server/{tabs.ts → workspaces/tabs.ts} +0 -0
- /package/server/{theme.ts → workspaces/theme.ts} +0 -0
package/server/applets/index.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { analyzeDependencies, resolveSource, scanSources } from './dependencies'
|
|
|
21
21
|
import type { AppletKind } from './build-applet'
|
|
22
22
|
import { buildAppletsInChild } from './build-worker'
|
|
23
23
|
import { APPLET_API_BASE_SENTINEL } from './api-base'
|
|
24
|
-
import { pruneAppletThumbnails } from '
|
|
24
|
+
import { pruneAppletThumbnails } from './thumbnails'
|
|
25
25
|
|
|
26
26
|
export { scanSources } from './dependencies'
|
|
27
27
|
|
|
@@ -263,7 +263,7 @@ const FS_MEDIA_RE =
|
|
|
263
263
|
// extension. The workspace holds secrets (`.env`, `.moi/`) and the routes built
|
|
264
264
|
// on this are unauthenticated — these guards are the protection, not the
|
|
265
265
|
// localhost bind. Shared by the raw stream (`serveWorkspaceFile`) and the image
|
|
266
|
-
// preview route (server/preview.ts).
|
|
266
|
+
// preview route (server/workspaces/preview.ts).
|
|
267
267
|
export function resolveWorkspaceMediaFile(workspaceRoot: string, tail: string): string | Response {
|
|
268
268
|
let rel: string
|
|
269
269
|
try {
|
|
@@ -9,7 +9,7 @@ import { join } from 'node:path'
|
|
|
9
9
|
|
|
10
10
|
import type { AppletKind, AppletThumbnail, AppletThumbnailBatch } from '@/lib/types'
|
|
11
11
|
|
|
12
|
-
import { ensureMoiGitignore } from '
|
|
12
|
+
import { ensureMoiGitignore } from '../workspaces/scaffold'
|
|
13
13
|
|
|
14
14
|
// Index records carry the image file name (`widget-clock.webp`) so existence
|
|
15
15
|
// and content type never need an fs probe. Server-internal — the API strips it.
|
|
@@ -162,21 +162,24 @@ export function pruneAppletThumbnails(
|
|
|
162
162
|
// Records that actually have an image on disk, for the home-card preview.
|
|
163
163
|
export async function getCapturedThumbnails(
|
|
164
164
|
workspacePath: string
|
|
165
|
-
): Promise<{ kind: AppletKind; id: string; viewedAt: string }[]> {
|
|
165
|
+
): Promise<{ kind: AppletKind; id: string; capturedAt: string; viewedAt: string }[]> {
|
|
166
166
|
const records = await loadIndex(getThumbnailsDir(workspacePath))
|
|
167
167
|
return records
|
|
168
168
|
.filter(record => record.file !== undefined)
|
|
169
|
-
.map(({ kind, id, viewedAt }) => ({ kind, id, viewedAt }))
|
|
169
|
+
.map(({ kind, id, capturedAt, viewedAt }) => ({ kind, id, capturedAt, viewedAt }))
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// One thumbnail image. Same caching story as applet bundles: strong ETag from
|
|
173
173
|
// size+mtime with `private, no-cache`, so an unchanged file costs a bodyless
|
|
174
|
-
// 304 and a re-capture busts every consumer on the next revalidation.
|
|
174
|
+
// 304 and a re-capture busts every consumer on the next revalidation. A
|
|
175
|
+
// `versioned` URL (the home preview's `<id>:<version>`) changes with every
|
|
176
|
+
// capture instead, so the browser keeps it without revalidating.
|
|
175
177
|
export async function serveAppletThumbnail(
|
|
176
178
|
workspacePath: string,
|
|
177
179
|
kind: AppletKind,
|
|
178
180
|
id: string,
|
|
179
|
-
ifNoneMatch?: string | null
|
|
181
|
+
ifNoneMatch?: string | null,
|
|
182
|
+
versioned = false
|
|
180
183
|
): Promise<Response> {
|
|
181
184
|
if (!isValidAppletId(id)) return new Response('Invalid id', { status: 400 })
|
|
182
185
|
const dir = getThumbnailsDir(workspacePath)
|
|
@@ -189,7 +192,7 @@ export async function serveAppletThumbnail(
|
|
|
189
192
|
const etag = `"${file.size}-${Math.trunc(file.lastModified)}"`
|
|
190
193
|
const headers = {
|
|
191
194
|
ETag: etag,
|
|
192
|
-
'Cache-Control': 'private, no-cache',
|
|
195
|
+
'Cache-Control': versioned ? 'private, max-age=604800, immutable' : 'private, no-cache',
|
|
193
196
|
'Content-Type': MIME_BY_EXT[record.file.split('.').pop() ?? ''] ?? 'application/octet-stream'
|
|
194
197
|
}
|
|
195
198
|
if (ifNoneMatch === etag) return new Response(null, { status: 304, headers })
|
|
@@ -4,7 +4,7 @@ import ts from 'typescript'
|
|
|
4
4
|
|
|
5
5
|
import type { AppletSelector } from '@/lib/applet-selector'
|
|
6
6
|
|
|
7
|
-
import { appletDeclarationPath, syncAppletDeclarations } from './
|
|
7
|
+
import { appletDeclarationPath, syncAppletDeclarations } from './declarations'
|
|
8
8
|
|
|
9
9
|
export type AppletTypecheckResult = {
|
|
10
10
|
files: string[]
|
|
@@ -13,18 +13,18 @@ export type AppletTypecheckResult = {
|
|
|
13
13
|
|
|
14
14
|
// Bun's ambient types come from the `@types/bun` moi itself depends on — the
|
|
15
15
|
// version moi was tested with, present wherever moi runs. It is found through
|
|
16
|
-
// Bun's resolver from
|
|
16
|
+
// Bun's resolver from Moi's own location rather than a fixed path: `bun
|
|
17
17
|
// install -g` hoists moi's dependencies beside the package, so
|
|
18
18
|
// `../node_modules/@types` only exists in a dev checkout, and TypeScript never
|
|
19
19
|
// falls back to node_modules for `types` entries once `typeRoots` is set. The
|
|
20
20
|
// same root serves the `bun-types` and `@types/node` references inside, so
|
|
21
21
|
// the workspace's own `node_modules` never takes part. `from` is injectable
|
|
22
22
|
// for tests.
|
|
23
|
-
export function resolvePackageTypeRoot(from: string = import.meta.dir): string {
|
|
23
|
+
export function resolvePackageTypeRoot(from: string = join(import.meta.dir, '..')): string {
|
|
24
24
|
try {
|
|
25
25
|
return dirname(dirname(Bun.resolveSync('@types/bun/package.json', from)))
|
|
26
26
|
} catch {
|
|
27
|
-
throw new Error("
|
|
27
|
+
throw new Error("Moi's bundled @types/bun is missing — reinstall moi-computer")
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// and docs are bundled, so installs do not depend on a remote registry.
|
|
3
3
|
import { join } from 'path'
|
|
4
4
|
|
|
5
|
-
import registry from '
|
|
6
|
-
import { PACKAGE_ROOT } from '
|
|
5
|
+
import registry from '../../registry.json'
|
|
6
|
+
import { PACKAGE_ROOT } from '../version'
|
|
7
7
|
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
9
|
// The curated catalog
|
|
@@ -3,7 +3,7 @@ import { existsSync } from 'node:fs'
|
|
|
3
3
|
import { viewTabId } from '@/lib/workspace-tabs'
|
|
4
4
|
import type { CompiledView, ViewConfig, ViewInfo, WorkspaceEntry } from '@/lib/types'
|
|
5
5
|
|
|
6
|
-
import { syncAppletLogAfterBuild } from './
|
|
6
|
+
import { syncAppletLogAfterBuild } from './log'
|
|
7
7
|
import {
|
|
8
8
|
buildApplets,
|
|
9
9
|
getAppletPaths,
|
|
@@ -11,14 +11,14 @@ import {
|
|
|
11
11
|
listBuilt,
|
|
12
12
|
scanSources,
|
|
13
13
|
serveApplet
|
|
14
|
-
} from './
|
|
14
|
+
} from './'
|
|
15
15
|
import { serializeWorkspaceBundle } from './bundle-queue'
|
|
16
16
|
import { reloadModules } from './functions'
|
|
17
|
-
import { loadLayout, saveLayout } from '
|
|
18
|
-
import { completeViewBuild, listPendingViews } from '
|
|
19
|
-
import { archiveViewSessions } from '
|
|
20
|
-
import { setViewSourceTitle } from './
|
|
21
|
-
import { deleteViewSourceFiles, readViewSource, ViewSourceInUseError } from './
|
|
17
|
+
import { loadLayout, saveLayout } from '../workspaces/layout'
|
|
18
|
+
import { completeViewBuild, listPendingViews } from '../sessions/pending-views'
|
|
19
|
+
import { archiveViewSessions } from '../sessions/archive'
|
|
20
|
+
import { setViewSourceTitle } from './config'
|
|
21
|
+
import { deleteViewSourceFiles, readViewSource, ViewSourceInUseError } from './view-source'
|
|
22
22
|
|
|
23
23
|
// The view applet kind. Sources in `.moi/views/`, compiled output + manifest in
|
|
24
24
|
// `.moi/.build/views/`; the shared mechanics live in `applets/index.ts`. Manifest
|
|
@@ -2,8 +2,8 @@ import { existsSync } from 'node:fs'
|
|
|
2
2
|
|
|
3
3
|
import type { WidgetConfig, WidgetInfo } from '@/lib/types'
|
|
4
4
|
|
|
5
|
-
import { syncAppletLogAfterBuild } from './
|
|
6
|
-
import { buildApplets, getAppletPaths, getAppletRevision, listBuilt, serveApplet } from './
|
|
5
|
+
import { syncAppletLogAfterBuild } from './log'
|
|
6
|
+
import { buildApplets, getAppletPaths, getAppletRevision, listBuilt, serveApplet } from './'
|
|
7
7
|
import { reloadModules } from './functions'
|
|
8
8
|
|
|
9
9
|
const DEFAULT_CONFIG: WidgetConfig = { rowSpan: 1, colSpan: 2 }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AppletSelector } from '@/lib/applet-selector'
|
|
2
|
+
import { parseAppletSelector } from '@/lib/applet-selector'
|
|
3
|
+
import pc from './pc'
|
|
4
|
+
|
|
5
|
+
export const appletOnlyArg = {
|
|
6
|
+
type: 'string' as const,
|
|
7
|
+
description: 'Limit to "widgets", "views", "widgets/<id>", or "views/<id>"'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function readAppletSelector(value: string | undefined): AppletSelector | undefined {
|
|
11
|
+
if (value === undefined) return undefined
|
|
12
|
+
if (parseAppletSelector(value)) return value as AppletSelector
|
|
13
|
+
console.error(
|
|
14
|
+
'\n' +
|
|
15
|
+
pc.red('✗') +
|
|
16
|
+
` Invalid --only value "${value}" — use "widgets", "views", "widgets/<id>", or "views/<id>".\n`
|
|
17
|
+
)
|
|
18
|
+
process.exit(1)
|
|
19
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// module is imported *first* in `cli.ts` so it runs before citty's module is
|
|
9
9
|
// evaluated (citty computes its `noColor` flag once, at import time).
|
|
10
10
|
//
|
|
11
|
-
// This only closes citty's gap. Our own coloring goes through `
|
|
11
|
+
// This only closes citty's gap. Our own coloring goes through `pc.ts`,
|
|
12
12
|
// which computes enablement directly (picocolors' auto-detection enables color
|
|
13
13
|
// on `CI` even through a pipe, and Bun evaluates picocolors too early for this
|
|
14
14
|
// `NO_COLOR` mutation to reach it). `FORCE_COLOR` and an explicit `NO_COLOR`
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { defineCommand } from 'citty'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
import { CONTROL_URL } from '../../constants'
|
|
4
|
+
import { staleSkillNotice } from '../../skills/version'
|
|
5
|
+
import { appletOnlyArg, readAppletSelector } from '../applet-selector'
|
|
6
|
+
import { exitControlUnreachable } from '../control'
|
|
7
|
+
import pc from '../pc'
|
|
8
|
+
import { columns } from '../ui'
|
|
9
|
+
|
|
10
|
+
function colorStatus(status: string) {
|
|
11
|
+
if (status === 'built') return pc.green(status)
|
|
12
|
+
if (status === 'failed') return pc.red(status)
|
|
13
|
+
return pc.dim(status)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const bundle = defineCommand({
|
|
17
|
+
meta: { name: 'bundle', description: 'Rebuild changed widgets and views' },
|
|
18
|
+
args: {
|
|
19
|
+
dir: {
|
|
20
|
+
type: 'positional',
|
|
21
|
+
default: '.',
|
|
22
|
+
description: 'Workspace directory (default: current)'
|
|
23
|
+
},
|
|
24
|
+
force: {
|
|
25
|
+
type: 'boolean',
|
|
26
|
+
description: 'Rebuild the selected applets, ignoring file modification times',
|
|
27
|
+
default: false
|
|
28
|
+
},
|
|
29
|
+
only: appletOnlyArg
|
|
30
|
+
},
|
|
31
|
+
async run({ args }) {
|
|
32
|
+
const only = readAppletSelector(args.only)
|
|
33
|
+
const path = resolve(args.dir)
|
|
34
|
+
// Computed locally up front so it can ride along in the success output; the
|
|
35
|
+
// agent reads this and knows to run `moi skill update`.
|
|
36
|
+
const notice = await staleSkillNotice(path)
|
|
37
|
+
const ws = new WebSocket(CONTROL_URL)
|
|
38
|
+
|
|
39
|
+
ws.onopen = () =>
|
|
40
|
+
ws.send(
|
|
41
|
+
JSON.stringify({
|
|
42
|
+
type: 'bundle',
|
|
43
|
+
path,
|
|
44
|
+
force: args.force,
|
|
45
|
+
only
|
|
46
|
+
})
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
ws.onmessage = event => {
|
|
50
|
+
const res = JSON.parse(String(event.data))
|
|
51
|
+
|
|
52
|
+
// The server fails loudly when the path isn't inside a registered
|
|
53
|
+
// workspace (e.g. run from an unrelated dir) instead of silently no-op'ing.
|
|
54
|
+
if (res.error) {
|
|
55
|
+
console.error('\n' + pc.red(pc.bold('Error:')) + ' ' + res.error + '\n')
|
|
56
|
+
ws.close()
|
|
57
|
+
process.exit(1)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type Row = { kind?: string; name: string; status: string; error?: string }
|
|
61
|
+
const results: Row[] = Array.isArray(res.results) ? res.results : []
|
|
62
|
+
const where = typeof res.workspacePath === 'string' ? res.workspacePath : path
|
|
63
|
+
|
|
64
|
+
// Empty here means a *real* workspace with no widgets/views — not the old
|
|
65
|
+
// "wrong dir" footgun (that's an error above now). Say so plainly.
|
|
66
|
+
if (results.length === 0) {
|
|
67
|
+
console.log(
|
|
68
|
+
'\n' +
|
|
69
|
+
pc.bold('moi bundle') +
|
|
70
|
+
pc.dim(' — nothing to build') +
|
|
71
|
+
'\n\n' +
|
|
72
|
+
pc.dim(` No widgets or views found in ${where}/.moi/`) +
|
|
73
|
+
'\n'
|
|
74
|
+
)
|
|
75
|
+
if (notice) console.log(pc.yellow(notice) + '\n')
|
|
76
|
+
ws.close()
|
|
77
|
+
process.exit(0)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const counts: Record<string, number> = {}
|
|
81
|
+
for (const r of results) counts[r.status] = (counts[r.status] ?? 0) + 1
|
|
82
|
+
const summary = ['built', 'skipped', 'failed']
|
|
83
|
+
.filter(s => counts[s])
|
|
84
|
+
.map(s => `${counts[s]} ${s}`)
|
|
85
|
+
.join(' · ')
|
|
86
|
+
|
|
87
|
+
console.log('\n' + pc.bold('moi bundle') + pc.dim(` — ${summary}`) + '\n')
|
|
88
|
+
console.log(
|
|
89
|
+
columns(
|
|
90
|
+
['kind', 'name', 'status'].map(h => pc.dim(h)),
|
|
91
|
+
results.map(r => [pc.dim(r.kind ?? ''), r.name, colorStatus(r.status)])
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
const failed = results.filter(r => r.status === 'failed')
|
|
96
|
+
console.log()
|
|
97
|
+
for (const f of failed) {
|
|
98
|
+
console.log(pc.red(pc.bold(f.name + ':')))
|
|
99
|
+
console.log(' ' + f.error + '\n')
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Runtime errors still standing after the rebuild's clear-on-success
|
|
103
|
+
// sweep — point the agent at the journal while it's paying attention.
|
|
104
|
+
const logCount = typeof res.logCount === 'number' ? res.logCount : 0
|
|
105
|
+
if (logCount > 0) {
|
|
106
|
+
console.log(
|
|
107
|
+
pc.yellow(`ℹ ${logCount} applet runtime error(s) on record — run \`moi debug logs\`.`) +
|
|
108
|
+
'\n'
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (notice) console.log(pc.yellow(notice) + '\n')
|
|
113
|
+
ws.close()
|
|
114
|
+
process.exit(failed.length > 0 ? 1 : 0)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
ws.onerror = () => void exitControlUnreachable()
|
|
118
|
+
}
|
|
119
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineCommand } from 'citty'
|
|
2
|
+
import { parse as devalueParse } from 'devalue'
|
|
3
|
+
import { resolve } from 'path'
|
|
4
|
+
import { dirArg } from '../args'
|
|
5
|
+
import { sendControl } from '../control'
|
|
6
|
+
import pc from '../pc'
|
|
7
|
+
|
|
8
|
+
export const callServerFn = defineCommand({
|
|
9
|
+
meta: {
|
|
10
|
+
name: 'call-server-fn',
|
|
11
|
+
description: 'Invoke an applet .server.ts function in an isolated one-shot worker (smoke test)'
|
|
12
|
+
},
|
|
13
|
+
args: {
|
|
14
|
+
fn: {
|
|
15
|
+
type: 'positional',
|
|
16
|
+
required: true,
|
|
17
|
+
description: 'Function path: <module>/<fn>, e.g. widgets/hello/getGreeting'
|
|
18
|
+
},
|
|
19
|
+
args: {
|
|
20
|
+
type: 'positional',
|
|
21
|
+
required: false,
|
|
22
|
+
description: 'Arguments as one JSON array, e.g. \'["ann", 10]\' (default [])'
|
|
23
|
+
},
|
|
24
|
+
dir: dirArg
|
|
25
|
+
},
|
|
26
|
+
run({ args }) {
|
|
27
|
+
const path = resolve(args.dir)
|
|
28
|
+
sendControl(
|
|
29
|
+
path,
|
|
30
|
+
{ type: 'call-server-fn', path, fn: args.fn, args: args.args ?? '[]' },
|
|
31
|
+
res => {
|
|
32
|
+
// The worker replies devalue-encoded (same wire format the browser RPC
|
|
33
|
+
// parses), so Map/Set/Date render readably through Bun.inspect.
|
|
34
|
+
const value = devalueParse(String(res.result))
|
|
35
|
+
console.log(Bun.inspect(value, { depth: 8, colors: process.stdout.isTTY }))
|
|
36
|
+
// Duration on stderr: stdout stays clean data, and a slow call is a
|
|
37
|
+
// warning sign worth surfacing (browser RPC times out at 30s).
|
|
38
|
+
console.error(pc.dim(`↩ ${res.ms}ms`))
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
})
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineCommand } from 'citty'
|
|
2
|
+
import { existsSync } from 'node:fs'
|
|
3
|
+
import { join, resolve } from 'path'
|
|
4
|
+
import { resolveWorkspace } from '../../skills/version'
|
|
5
|
+
import { appletOnlyArg, readAppletSelector } from '../applet-selector'
|
|
6
|
+
import pc from '../pc'
|
|
7
|
+
|
|
8
|
+
export const check = defineCommand({
|
|
9
|
+
meta: { name: 'check', description: 'Run applet checks' },
|
|
10
|
+
args: {
|
|
11
|
+
dir: {
|
|
12
|
+
type: 'positional',
|
|
13
|
+
default: '.',
|
|
14
|
+
description: 'Workspace directory (default: current)'
|
|
15
|
+
},
|
|
16
|
+
only: appletOnlyArg
|
|
17
|
+
},
|
|
18
|
+
async run({ args }) {
|
|
19
|
+
const only = readAppletSelector(args.only)
|
|
20
|
+
const { root } = await resolveWorkspace(resolve(args.dir))
|
|
21
|
+
if (!existsSync(join(root, '.moi'))) {
|
|
22
|
+
console.error('\n' + pc.red('✗') + ` No Moi workspace found at ${root}\n`)
|
|
23
|
+
process.exit(1)
|
|
24
|
+
}
|
|
25
|
+
const { formatAppletTypecheckDiagnostics, typecheckApplets } =
|
|
26
|
+
await import('../../applets/typecheck')
|
|
27
|
+
const result = await typecheckApplets(root, only)
|
|
28
|
+
|
|
29
|
+
if (only?.includes('/') && result.files.length === 0) {
|
|
30
|
+
console.error('\n' + pc.red('✗') + ` Applet "${only}" not found.\n`)
|
|
31
|
+
process.exit(1)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (result.diagnostics.length > 0) {
|
|
35
|
+
console.error('\n' + pc.red('✗') + ' Applet check failed: TypeScript\n')
|
|
36
|
+
console.error(formatAppletTypecheckDiagnostics(result.diagnostics))
|
|
37
|
+
process.exit(1)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (result.files.length === 0) {
|
|
41
|
+
const scope = args.only ? `.moi/${args.only}` : '.moi/widgets or .moi/views'
|
|
42
|
+
console.log('\n' + pc.green('✓') + ` No applet source files found in ${scope}\n`)
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const suffix = only ? ` (${only})` : ''
|
|
47
|
+
console.log(
|
|
48
|
+
'\n' +
|
|
49
|
+
pc.green('✓') +
|
|
50
|
+
` Applet checks passed: TypeScript · ${result.files.length} file${result.files.length === 1 ? '' : 's'}${suffix}\n`
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { defineCommand } from 'citty'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
import { CONTROL_URL } from '../../constants'
|
|
4
|
+
import { staleSkillNotice } from '../../skills/version'
|
|
5
|
+
import { exitControlUnreachable } from '../control'
|
|
6
|
+
import pc from '../pc'
|
|
7
|
+
|
|
8
|
+
async function sendConfig(payload: {
|
|
9
|
+
path: string
|
|
10
|
+
name?: string
|
|
11
|
+
iconPath?: string
|
|
12
|
+
clearName?: boolean
|
|
13
|
+
clearIcon?: boolean
|
|
14
|
+
}) {
|
|
15
|
+
const notice = await staleSkillNotice(payload.path)
|
|
16
|
+
const ws = new WebSocket(CONTROL_URL)
|
|
17
|
+
ws.onopen = () => ws.send(JSON.stringify({ type: 'config', ...payload }))
|
|
18
|
+
ws.onmessage = event => {
|
|
19
|
+
const res = JSON.parse(String(event.data))
|
|
20
|
+
if (res.error) {
|
|
21
|
+
console.error('\n' + pc.red(pc.bold('Error:')) + ' ' + res.error + '\n')
|
|
22
|
+
ws.close()
|
|
23
|
+
process.exit(1)
|
|
24
|
+
}
|
|
25
|
+
console.log()
|
|
26
|
+
if (res.ok) {
|
|
27
|
+
if (res.clearedName) console.log(pc.green('✓') + ' Name reset to ' + pc.dim('(folder name)'))
|
|
28
|
+
else if (res.name) console.log(pc.green('✓') + ' Name set to ' + pc.bold(res.name))
|
|
29
|
+
if (res.clearedIcon)
|
|
30
|
+
console.log(pc.green('✓') + ' Icon reset to ' + pc.dim('default (provider)'))
|
|
31
|
+
else if (res.icon) console.log(pc.green('✓') + ' Icon updated ' + pc.dim('(128×128 webp)'))
|
|
32
|
+
} else {
|
|
33
|
+
console.log(pc.bold('moi config') + ' — workspace identity\n')
|
|
34
|
+
console.log(
|
|
35
|
+
' ' + pc.dim('name') + ' ' + (res.name ? pc.bold(res.name) : pc.dim('(folder name)'))
|
|
36
|
+
)
|
|
37
|
+
console.log(
|
|
38
|
+
' ' +
|
|
39
|
+
pc.dim('icon') +
|
|
40
|
+
' ' +
|
|
41
|
+
(res.hasIcon ? pc.green('custom') : pc.dim('default (provider)'))
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
console.log()
|
|
45
|
+
if (notice) console.log(pc.yellow(notice) + '\n')
|
|
46
|
+
ws.close()
|
|
47
|
+
process.exit(0)
|
|
48
|
+
}
|
|
49
|
+
ws.onerror = () => void exitControlUnreachable()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// A terse cheat sheet — one line per command — so an agent can grasp the
|
|
53
|
+
// surface at a glance instead of parsing citty's full ARGUMENTS/OPTIONS dump.
|
|
54
|
+
export function printConfigHelp() {
|
|
55
|
+
const row = (cmd: string, desc: string) => ' ' + pc.cyan(cmd.padEnd(34)) + pc.dim(desc)
|
|
56
|
+
console.log()
|
|
57
|
+
console.log(pc.bold('moi config') + pc.dim(' — workspace name & icon'))
|
|
58
|
+
console.log()
|
|
59
|
+
console.log(row('moi config', 'Show current name & icon'))
|
|
60
|
+
console.log(row('moi config name "My WS"', 'Set the display name'))
|
|
61
|
+
console.log(row('moi config name --clear', 'Reset name to folder default'))
|
|
62
|
+
console.log(row('moi config icon ./logo.png', 'Set icon (png/jpg/gif/webp → 128×128 webp)'))
|
|
63
|
+
console.log(row('moi config icon --clear', 'Reset icon to provider default'))
|
|
64
|
+
console.log(row(' --dir <path>', 'Target workspace (default: current dir)'))
|
|
65
|
+
console.log()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const config = defineCommand({
|
|
69
|
+
meta: {
|
|
70
|
+
name: 'config',
|
|
71
|
+
description: 'Show or set the workspace name and icon (moi config [name|icon] <value>)'
|
|
72
|
+
},
|
|
73
|
+
args: {
|
|
74
|
+
field: {
|
|
75
|
+
type: 'positional',
|
|
76
|
+
required: false,
|
|
77
|
+
description: '"name" or "icon" — omit to show the current config'
|
|
78
|
+
},
|
|
79
|
+
value: {
|
|
80
|
+
type: 'positional',
|
|
81
|
+
required: false,
|
|
82
|
+
description: 'The new name, or a path to an image file (png/jpg/gif/webp)'
|
|
83
|
+
},
|
|
84
|
+
clear: {
|
|
85
|
+
type: 'boolean',
|
|
86
|
+
description: 'Reset the field to its default (folder name / provider icon)'
|
|
87
|
+
},
|
|
88
|
+
dir: { type: 'string', default: '.', description: 'Workspace directory (default: current)' }
|
|
89
|
+
},
|
|
90
|
+
run({ args }) {
|
|
91
|
+
const path = resolve(args.dir)
|
|
92
|
+
if (args.field === 'help') {
|
|
93
|
+
printConfigHelp()
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
if (!args.field) {
|
|
97
|
+
sendConfig({ path })
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
if (args.field === 'name') {
|
|
101
|
+
if (args.clear) {
|
|
102
|
+
sendConfig({ path, clearName: true })
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
if (!args.value) {
|
|
106
|
+
console.error(pc.red('Usage:') + ' moi config name "<workspace name>"')
|
|
107
|
+
process.exit(1)
|
|
108
|
+
}
|
|
109
|
+
sendConfig({ path, name: args.value })
|
|
110
|
+
} else if (args.field === 'icon') {
|
|
111
|
+
if (args.clear) {
|
|
112
|
+
sendConfig({ path, clearIcon: true })
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
if (!args.value) {
|
|
116
|
+
console.error(pc.red('Usage:') + ' moi config icon <path-to-image>')
|
|
117
|
+
process.exit(1)
|
|
118
|
+
}
|
|
119
|
+
sendConfig({ path, iconPath: resolve(args.value) })
|
|
120
|
+
} else {
|
|
121
|
+
console.error(
|
|
122
|
+
pc.red(`Unknown field "${args.field}".`) +
|
|
123
|
+
' Use ' +
|
|
124
|
+
pc.bold('name') +
|
|
125
|
+
' or ' +
|
|
126
|
+
pc.bold('icon') +
|
|
127
|
+
'.'
|
|
128
|
+
)
|
|
129
|
+
process.exit(1)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
})
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { appletSelectorMatches } from '@/lib/applet-selector'
|
|
2
|
+
import type { AppletLogEntry } from '@/lib/types'
|
|
3
|
+
import { defineCommand } from 'citty'
|
|
4
|
+
import { resolve } from 'path'
|
|
5
|
+
import { appletOnlyArg, readAppletSelector } from '../applet-selector'
|
|
6
|
+
import { dirArg } from '../args'
|
|
7
|
+
import { sendControl } from '../control'
|
|
8
|
+
import pc from '../pc'
|
|
9
|
+
|
|
10
|
+
// Compact relative age for a journal row: "just now", "4m ago", "2h ago", …
|
|
11
|
+
function agoLabel(ts: number): string {
|
|
12
|
+
const s = Math.max(0, Math.round((Date.now() - ts) / 1000))
|
|
13
|
+
if (s < 60) return 'just now'
|
|
14
|
+
if (s < 3600) return `${Math.round(s / 60)}m ago`
|
|
15
|
+
if (s < 86400) return `${Math.round(s / 3600)}h ago`
|
|
16
|
+
return `${Math.round(s / 86400)}d ago`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Where a journal entry points: the server function for rpc rows, else the applet.
|
|
20
|
+
function logSubject(e: {
|
|
21
|
+
source: string
|
|
22
|
+
kind?: string
|
|
23
|
+
name?: string
|
|
24
|
+
module?: string
|
|
25
|
+
fn?: string
|
|
26
|
+
}): string {
|
|
27
|
+
if (e.module) return `${e.module}/${e.fn ?? '?'}`
|
|
28
|
+
if (e.name) return `${e.kind ?? 'applet'} ${e.name}`
|
|
29
|
+
return 'unattributed'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const MAX_LOG_MESSAGE_LINES = 12
|
|
33
|
+
|
|
34
|
+
const debugLogs = defineCommand({
|
|
35
|
+
meta: {
|
|
36
|
+
name: 'logs',
|
|
37
|
+
description: 'Applet runtime errors on record (load / render / rpc / build failures)'
|
|
38
|
+
},
|
|
39
|
+
args: {
|
|
40
|
+
dir: dirArg,
|
|
41
|
+
only: appletOnlyArg,
|
|
42
|
+
json: {
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
default: false,
|
|
45
|
+
description: 'Machine-readable output, includes stacks and epoch timestamps'
|
|
46
|
+
},
|
|
47
|
+
clear: { type: 'boolean', default: false, description: 'Wipe the journal' }
|
|
48
|
+
},
|
|
49
|
+
run({ args }) {
|
|
50
|
+
const only = readAppletSelector(args.only)
|
|
51
|
+
const path = resolve(args.dir)
|
|
52
|
+
if (args.clear) {
|
|
53
|
+
if (only) {
|
|
54
|
+
console.error('\n' + pc.red('✗') + ' Cannot combine --only with --clear.\n')
|
|
55
|
+
process.exit(1)
|
|
56
|
+
}
|
|
57
|
+
sendControl(path, { type: 'debug:logs', path, clear: true }, res => {
|
|
58
|
+
console.log('\n' + pc.green('✓') + ` cleared ${res.cleared ?? 0} entries\n`)
|
|
59
|
+
})
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
sendControl(path, { type: 'debug:logs', path }, res => {
|
|
63
|
+
let entries = (Array.isArray(res.entries) ? res.entries : []) as AppletLogEntry[]
|
|
64
|
+
if (only) {
|
|
65
|
+
entries = entries.filter(
|
|
66
|
+
entry =>
|
|
67
|
+
entry.kind &&
|
|
68
|
+
entry.name &&
|
|
69
|
+
appletSelectorMatches(only, entry.kind === 'widget' ? 'widgets' : 'views', entry.name)
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
if (args.json) {
|
|
73
|
+
console.log(JSON.stringify(entries, null, 2))
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
if (entries.length === 0) {
|
|
77
|
+
const suffix = only ? ` for ${only}` : ''
|
|
78
|
+
console.log(
|
|
79
|
+
'\n' + pc.bold('moi debug logs') + pc.dim(` — no applet errors on record${suffix}`) + '\n'
|
|
80
|
+
)
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
const suffix = only ? ` for ${only}` : ''
|
|
84
|
+
console.log(
|
|
85
|
+
'\n' +
|
|
86
|
+
pc.bold('moi debug logs') +
|
|
87
|
+
pc.dim(` — ${entries.length} error(s) on record${suffix}`) +
|
|
88
|
+
'\n'
|
|
89
|
+
)
|
|
90
|
+
for (const e of entries) {
|
|
91
|
+
const count = e.count > 1 ? pc.dim(` ×${e.count}`) : ''
|
|
92
|
+
console.log(
|
|
93
|
+
` ${pc.dim(agoLabel(e.ts).padEnd(10))} ${e.source.padEnd(7)} ${pc.bold(logSubject(e))}${count}`
|
|
94
|
+
)
|
|
95
|
+
const lines = e.message.split('\n')
|
|
96
|
+
for (const line of lines.slice(0, MAX_LOG_MESSAGE_LINES)) {
|
|
97
|
+
console.log(' ' + line)
|
|
98
|
+
}
|
|
99
|
+
if (lines.length > MAX_LOG_MESSAGE_LINES) {
|
|
100
|
+
console.log(pc.dim(` … ${lines.length - MAX_LOG_MESSAGE_LINES} more lines (--json)`))
|
|
101
|
+
}
|
|
102
|
+
console.log()
|
|
103
|
+
}
|
|
104
|
+
console.log(
|
|
105
|
+
pc.dim(' Entries clear when their applet next builds successfully, or via --clear.') + '\n'
|
|
106
|
+
)
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
// Experimental workspace-debugging toolbox. One subcommand for now (`logs`);
|
|
112
|
+
// more introspection (worker state, RPC traces, …) may hang off it later.
|
|
113
|
+
export const debug = defineCommand({
|
|
114
|
+
meta: {
|
|
115
|
+
name: 'debug',
|
|
116
|
+
description: 'Debug the workspace (experimental) — `moi debug logs` for applet errors'
|
|
117
|
+
},
|
|
118
|
+
subCommands: { logs: debugLogs }
|
|
119
|
+
})
|