moi-computer 0.12.0 → 0.12.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -27
- package/bin/moi.mjs +2 -2
- package/client/AGENTS.md +7 -4
- package/client/api/app-config.ts +3 -2
- package/client/api/app-ui-keys.ts +1 -1
- package/client/api/workspace-keys.ts +2 -4
- 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} +20 -31
- package/client/app/shell/{SidebarLayout.tsx → sidebar-layout.tsx} +10 -10
- package/client/dev/index.html +43 -0
- package/client/dev/index.ts +15 -0
- package/client/features/applets/{AppletContainer.tsx → applet-container.tsx} +1 -1
- package/client/features/applets/applet-runtime.ts +11 -13
- 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 +33 -14
- package/client/features/chat/{ChatPanel.tsx → chat-panel.tsx} +80 -59
- package/client/features/chat/chat-popup.tsx +171 -0
- package/client/features/chat/chat-send.ts +33 -1
- package/client/features/chat/chat-store.ts +10 -0
- 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} +31 -33
- package/client/features/chat/composer/{ModelPicker.tsx → model-picker.tsx} +4 -4
- package/client/features/chat/composer/{useWorkspaceComposerState.tsx → use-workspace-composer-state.tsx} +14 -30
- package/client/features/chat/composer/{useWorkspaceSkillUpdates.ts → use-workspace-skill-updates.ts} +1 -1
- package/client/features/chat/connection/chat-frames.ts +15 -8
- package/client/features/chat/messages/{ChatEmptyState.tsx → chat-empty-state.tsx} +37 -23
- package/client/features/chat/messages/fork-history.ts +14 -0
- package/client/features/chat/messages/{MarkdownContent.tsx → markdown-content.tsx} +4 -4
- 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 +109 -19
- package/client/features/chat/sessions/browser-tab-state.ts +30 -7
- package/client/features/chat/sessions/{ChatSelector.tsx → chat-selector.tsx} +139 -80
- package/client/features/chat/sessions/use-selected-session.ts +351 -0
- package/client/features/chat/{useChat.ts → use-chat.ts} +46 -48
- package/client/features/collab/client.ts +10 -11
- package/client/features/collab/hooks.tsx +6 -11
- package/client/features/collab/host-state.ts +57 -128
- package/client/features/collab/provider.tsx +3 -3
- package/client/features/collab/proxy-user.ts +1 -1
- package/client/features/collab/testing/fake-engine.ts +6 -27
- package/client/features/collab/workspace-users-menu.tsx +3 -7
- 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} +6 -6
- 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 +226 -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/{useViewBuilderSketch.ts → use-view-sketch.ts} +8 -8
- package/client/features/harness/api.ts +36 -0
- package/client/features/harness/device-login-steps.tsx +97 -0
- package/client/features/home/api.ts +1 -81
- package/client/features/home/{HomeLogo.tsx → home-logo.tsx} +1 -1
- package/client/features/home/{HomePage.tsx → home-page.tsx} +16 -20
- package/client/features/overview/api.ts +2 -2
- package/client/features/overview/default/registry.tsx +3 -5
- package/client/features/overview/default/{ViewsWidget.tsx → views-widget.tsx} +6 -13
- package/client/features/overview/{HiddenPanel.tsx → hidden-panel.tsx} +2 -2
- package/client/features/overview/{Overview.tsx → overview.tsx} +9 -12
- 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} +7 -7
- package/client/features/scratchpad/{useScratchpadSnapshot.tsx → use-scratchpad-snapshot.tsx} +3 -3
- package/client/features/settings/api.ts +1 -1
- 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 +64 -131
- package/client/features/views/pending-view-screen.tsx +282 -0
- package/client/features/views/use-view-actions.ts +151 -0
- package/client/features/views/use-view-drafts.ts +88 -0
- package/client/features/views/{ViewManager.tsx → view-manager.tsx} +13 -13
- package/client/features/views/view-presentation.ts +4 -5
- package/client/features/views/view-submission.ts +88 -0
- 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 +24 -15
- package/client/features/workspace/browser-tab-state.ts +16 -9
- package/client/features/workspace/moi-context.ts +14 -16
- 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 +77 -0
- package/client/features/workspace/setup/workspace-welcome-state.tsx +81 -0
- package/client/features/workspace/tab-resolution.ts +16 -29
- package/client/features/workspace/{ThemePanel.tsx → theme-panel.tsx} +3 -3
- package/client/features/workspace/use-workspace-navigation.ts +245 -0
- package/client/features/workspace/workspace-content.tsx +641 -0
- package/client/features/workspace/workspace-identity.tsx +40 -0
- package/client/features/workspace/workspace-menu.tsx +63 -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 +1 -1
- package/client/index.tsx +5 -1
- package/client/lib/agent-availability.ts +0 -5
- package/client/main.tsx +1 -1
- package/client/runtime/{useWorkspaceEvents.ts → use-workspace-events.ts} +10 -18
- package/client/store/ui.ts +25 -29
- package/dist/chunk-08ndj2rg.js +2 -0
- package/dist/chunk-2x040tmg.js +68 -0
- package/dist/chunk-3smxq0ts.js +1 -0
- package/dist/chunk-68ch5hs8.js +2 -0
- package/dist/{chunk-z3byfve5.js → chunk-9vg3xa81.js} +2 -2
- package/dist/chunk-c2p00p9j.css +1 -0
- package/dist/chunk-cs833y9j.js +1 -0
- package/dist/{chunk-97eg9mjn.js → chunk-d7cbm65e.js} +1 -1
- package/dist/{chunk-efdyz6xp.js → chunk-hvh9f5h0.js} +1 -1
- package/dist/{chunk-vfpsc75k.js → chunk-jvyvwwv3.js} +1 -1
- package/dist/chunk-nwevqe86.js +10 -0
- package/dist/{chunk-3a48fyf7.js → chunk-q0gbdts4.js} +4 -4
- package/dist/chunk-rt30jbcm.js +1 -0
- package/dist/chunk-y5y3kj67.js +1 -0
- package/dist/index.html +2 -2
- package/lib/format.ts +1 -1
- package/lib/harness-instructions.ts +30 -0
- package/lib/ids.ts +3 -6
- package/lib/moi-context.ts +102 -75
- package/lib/navigation.ts +48 -87
- package/lib/scratchpad-skew.ts +3 -3
- package/lib/session-drafts.ts +10 -0
- package/lib/types.ts +92 -51
- package/lib/update.ts +1 -1
- package/lib/view-build-directives.ts +12 -0
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-tabs.ts +12 -7
- package/package.json +7 -2
- package/server/AGENTS.md +10 -4
- package/server/README.md +102 -0
- package/server/agent-launcher.ts +27 -0
- package/server/api/harnesses.ts +56 -0
- package/server/{api.ts → api/index.ts} +197 -299
- package/server/app-config.ts +45 -14
- 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 +3 -2
- 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} +3 -2
- package/server/applets/index.ts +2 -2
- package/server/{thumbnails.ts → applets/thumbnails.ts} +1 -1
- package/server/{applet-typecheck.ts → applets/typecheck.ts} +4 -4
- package/server/{ui-components.ts → applets/ui-components.ts} +2 -2
- package/server/applets/view-source.ts +7 -1
- package/server/{views.ts → applets/views.ts} +35 -46
- 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} +78 -56
- 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 -3215
- package/server/collab/manager.ts +3 -3
- package/server/collab/skill/index.ts +2 -2
- package/server/control.ts +97 -78
- package/server/data-dir.ts +13 -0
- package/server/harness/README.md +55 -25
- package/server/harness/acp/NOTES.md +11 -11
- package/server/harness/acp/adapter.ts +2 -2
- package/server/harness/acp/archived.ts +3 -3
- package/server/harness/acp/client.ts +4 -3
- package/server/harness/acp/discovery.ts +3 -3
- package/server/harness/acp/run-durations.ts +1 -1
- package/server/harness/acp/session.ts +9 -12
- package/server/harness/auth.ts +303 -0
- package/server/harness/claude-code/NOTES.md +9 -7
- package/server/harness/claude-code/adapter.ts +13 -8
- package/server/harness/claude-code/auth.ts +127 -18
- package/server/harness/claude-code/cli.ts +3 -1
- package/server/harness/claude-code/git-worktree.ts +5 -2
- package/server/harness/claude-code/index.ts +7 -1
- package/server/harness/claude-code/mcp.ts +3 -1
- package/server/harness/claude-code/models.ts +2 -0
- package/server/harness/claude-code/session.ts +13 -39
- package/server/harness/claude-code/sessions.ts +8 -12
- package/server/harness/codex/NOTES.md +35 -16
- package/server/harness/codex/adapter.ts +5 -3
- package/server/harness/codex/auth.ts +86 -19
- package/server/harness/codex/client.ts +30 -34
- package/server/harness/codex/index.ts +20 -1
- package/server/harness/codex/permissions.ts +3 -3
- package/server/harness/codex/probe.ts +3 -5
- package/server/harness/codex/session.ts +20 -25
- package/server/harness/codex/thread-list.ts +74 -0
- package/server/harness/codex/transport.ts +5 -5
- package/server/harness/executable.ts +42 -18
- package/server/harness/fork.ts +12 -0
- 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 +4 -4
- package/server/harness/openclaw/compat.ts +1 -1
- package/server/harness/openclaw/session.ts +6 -31
- package/server/harness/registry.ts +1 -1
- package/server/harness/session-title.ts +12 -3
- package/server/harness/shell-path.ts +31 -21
- package/server/harness/types.ts +17 -5
- 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 +18 -4
- package/server/sessions/archive.ts +32 -0
- package/server/{attachment-message.ts → sessions/attachment-message.ts} +1 -1
- package/server/sessions/config.ts +41 -0
- package/server/sessions/lifecycle.ts +17 -0
- package/server/sessions/pending-views.ts +164 -0
- package/server/sessions/selected.ts +199 -0
- package/server/sessions/store.ts +127 -0
- package/server/sessions/view-sessions.ts +267 -0
- 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 +1 -1
- package/server/status.ts +6 -4
- package/server/web.ts +58 -49
- package/server/{env-apply.ts → workspaces/env-apply.ts} +5 -5
- package/server/{workspace-env.ts → workspaces/env.ts} +30 -3
- package/server/{workspace-import.ts → workspaces/import.ts} +4 -4
- package/server/{workspace-init.ts → workspaces/init.ts} +10 -6
- package/server/{layout.ts → workspaces/layout.ts} +2 -2
- package/server/{preview.ts → workspaces/preview.ts} +1 -1
- package/server/{registry.ts → workspaces/registry.ts} +17 -7
- package/server/{required-env.ts → workspaces/required-env.ts} +3 -3
- package/server/{moi-scaffold.ts → workspaces/scaffold.ts} +4 -3
- package/server/{tabs.ts → workspaces/tabs.ts} +7 -10
- 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 +61 -32
- package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +4 -7
- 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/ChatPopup.tsx +0 -98
- package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +0 -101
- package/client/features/chat/sessions/useSelectedSession.ts +0 -185
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +0 -92
- package/client/features/overview/WorkspaceName.tsx +0 -60
- package/client/features/views/ViewBuilder.tsx +0 -239
- package/client/features/views/useViewBuilderActions.ts +0 -103
- package/client/features/views/useViewBuilderDrafts.ts +0 -68
- package/client/features/workspace/WorkspaceScreen.tsx +0 -839
- package/client/features/workspace/useWorkspaceNavigation.ts +0 -203
- package/dist/chunk-2jncyq65.js +0 -1
- package/dist/chunk-e2q5ken7.js +0 -68
- package/dist/chunk-h2kj1ysj.js +0 -1
- package/dist/chunk-jf6czgrz.js +0 -2
- package/dist/chunk-nez8sdta.js +0 -1
- package/dist/chunk-nzwgm8vc.css +0 -1
- package/dist/chunk-ph0h6h86.js +0 -1
- package/dist/chunk-ryg9z3kn.js +0 -10
- package/dist/chunk-tpn177bt.js +0 -2
- package/lib/view-builder-directives.ts +0 -16
- package/server/agent.ts +0 -223
- package/server/chat-selection.ts +0 -22
- package/server/selected-session.ts +0 -152
- package/server/session-config.ts +0 -136
- package/server/view-builders.ts +0 -453
- /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/features/workspace/{WorkspaceLayoutContext.tsx → workspace-layout-context.tsx} +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/{theme.ts → workspaces/theme.ts} +0 -0
|
@@ -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
|
+
})
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { defineCommand } from 'citty'
|
|
2
|
+
import { isValidEnvKey } from '../../workspaces/env'
|
|
3
|
+
import {
|
|
4
|
+
execWithEnv,
|
|
5
|
+
readEnvView,
|
|
6
|
+
readSecretValue,
|
|
7
|
+
renderEnvView,
|
|
8
|
+
resolveCwdWorkspace,
|
|
9
|
+
writeEnv
|
|
10
|
+
} from '../env'
|
|
11
|
+
import pc from '../pc'
|
|
12
|
+
|
|
13
|
+
function envFail(message: string): never {
|
|
14
|
+
console.error('\n' + pc.red('✗') + ' ' + message + '\n')
|
|
15
|
+
process.exit(1)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const envSet = defineCommand({
|
|
19
|
+
meta: {
|
|
20
|
+
name: 'set',
|
|
21
|
+
description:
|
|
22
|
+
'Set custom secrets: `moi env set KEY=value [KEY=value...]`, or `moi env set KEY` to read one value from stdin'
|
|
23
|
+
},
|
|
24
|
+
args: {
|
|
25
|
+
key: {
|
|
26
|
+
type: 'positional',
|
|
27
|
+
required: true,
|
|
28
|
+
description: 'KEY=value pair(s), or a single bare KEY to read the value from stdin'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
async run({ args }) {
|
|
32
|
+
const entry = await resolveCwdWorkspace()
|
|
33
|
+
const pairs = args._
|
|
34
|
+
const set: Record<string, string> = {}
|
|
35
|
+
|
|
36
|
+
if (pairs.length === 1 && !pairs[0].includes('=')) {
|
|
37
|
+
// Bare-KEY form: one key, value from stdin (hidden prompt on a TTY).
|
|
38
|
+
const key = pairs[0]
|
|
39
|
+
if (!isValidEnvKey(key)) envFail(`Invalid env key: ${key}`)
|
|
40
|
+
let value: string
|
|
41
|
+
try {
|
|
42
|
+
value = await readSecretValue(key)
|
|
43
|
+
} catch {
|
|
44
|
+
// Ctrl-C at the hidden prompt.
|
|
45
|
+
process.exit(1)
|
|
46
|
+
}
|
|
47
|
+
// An empty value is almost always an unset variable on the piping side —
|
|
48
|
+
// storing '' would silently shadow a real .env value with nothing.
|
|
49
|
+
if (value === '')
|
|
50
|
+
envFail(`Empty value for ${key} — pipe a non-empty value or pass ${key}=value`)
|
|
51
|
+
set[key] = value
|
|
52
|
+
} else {
|
|
53
|
+
for (const pair of pairs) {
|
|
54
|
+
const eq = pair.indexOf('=')
|
|
55
|
+
if (eq === -1) {
|
|
56
|
+
envFail(
|
|
57
|
+
`Missing value for ${pair} — use KEY=value (bare KEY reads stdin only when set alone)`
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
const key = pair.slice(0, eq)
|
|
61
|
+
const value = pair.slice(eq + 1)
|
|
62
|
+
if (!isValidEnvKey(key)) envFail(`Invalid env key: ${key}`)
|
|
63
|
+
if (value === '')
|
|
64
|
+
envFail(`Empty value for ${key} — use \`moi env unset ${key}\` to remove a key`)
|
|
65
|
+
set[key] = value
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const backend = await writeEnv(entry.path, { set })
|
|
70
|
+
for (const key of Object.keys(set)) {
|
|
71
|
+
console.log(pc.green('✓') + ` Set ${pc.bold(key)} ${pc.dim('(custom)')}`)
|
|
72
|
+
}
|
|
73
|
+
// A plaintext fallback should never go unnoticed at write time.
|
|
74
|
+
if (backend === 'file') {
|
|
75
|
+
console.log(pc.dim(' Stored in a 0600 file — OS keychain unavailable.'))
|
|
76
|
+
}
|
|
77
|
+
process.exit(0)
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const envUnset = defineCommand({
|
|
82
|
+
meta: { name: 'unset', description: 'Remove custom secrets: `moi env unset KEY [KEY...]`' },
|
|
83
|
+
args: {
|
|
84
|
+
key: { type: 'positional', required: true, description: 'Key(s) to remove' }
|
|
85
|
+
},
|
|
86
|
+
async run({ args }) {
|
|
87
|
+
const entry = await resolveCwdWorkspace()
|
|
88
|
+
const view = await readEnvView(entry.path)
|
|
89
|
+
const byKey = new Map(view.vars.map(v => [v.key, v]))
|
|
90
|
+
|
|
91
|
+
// Only custom secrets are removable; a dotenv-sourced key lives in its file.
|
|
92
|
+
const removable: string[] = []
|
|
93
|
+
let hadError = false
|
|
94
|
+
for (const key of args._) {
|
|
95
|
+
const v = byKey.get(key)
|
|
96
|
+
if (!v) {
|
|
97
|
+
console.warn(pc.yellow('!') + ` ${key} is not set — skipping`)
|
|
98
|
+
continue
|
|
99
|
+
}
|
|
100
|
+
if (v.source === 'dotenv') {
|
|
101
|
+
console.error(
|
|
102
|
+
pc.red('✗') +
|
|
103
|
+
` ${key} comes from ${(v.files ?? []).join(', ')} — edit that file instead` +
|
|
104
|
+
pc.dim(' (moi env unset only removes custom secrets)')
|
|
105
|
+
)
|
|
106
|
+
hadError = true
|
|
107
|
+
continue
|
|
108
|
+
}
|
|
109
|
+
removable.push(key)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (removable.length > 0) {
|
|
113
|
+
await writeEnv(entry.path, { remove: removable })
|
|
114
|
+
for (const key of removable) {
|
|
115
|
+
const v = byKey.get(key)
|
|
116
|
+
const unshadow =
|
|
117
|
+
v?.source === 'both' ? pc.dim(` (falls back to ${(v.files ?? []).join(', ')})`) : ''
|
|
118
|
+
console.log(pc.green('✓') + ` Removed ${pc.bold(key)}${unshadow}`)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
process.exit(hadError ? 1 : 0)
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
const envExec = defineCommand({
|
|
126
|
+
meta: {
|
|
127
|
+
name: 'exec',
|
|
128
|
+
description: 'Run a command with the workspace env: `moi env exec -- <cmd> [args...]`'
|
|
129
|
+
},
|
|
130
|
+
async run({ rawArgs }) {
|
|
131
|
+
// Everything after `--` is the child command, untouched by flag parsing.
|
|
132
|
+
const sep = rawArgs.indexOf('--')
|
|
133
|
+
const cmd = sep === -1 ? [] : rawArgs.slice(sep + 1)
|
|
134
|
+
if (cmd.length === 0) {
|
|
135
|
+
console.error('\n' + pc.red('✗') + ' Usage: moi env exec -- <cmd> [args...]\n')
|
|
136
|
+
process.exit(1)
|
|
137
|
+
}
|
|
138
|
+
const entry = await resolveCwdWorkspace()
|
|
139
|
+
process.exit(await execWithEnv(entry.path, cmd))
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
const envSubCommands = { set: envSet, unset: envUnset, exec: envExec }
|
|
144
|
+
|
|
145
|
+
export const env = defineCommand({
|
|
146
|
+
meta: {
|
|
147
|
+
name: 'env',
|
|
148
|
+
description: 'Show the workspace env (key names only — never values)'
|
|
149
|
+
},
|
|
150
|
+
subCommands: envSubCommands,
|
|
151
|
+
async run({ rawArgs }) {
|
|
152
|
+
// citty invokes the parent run even after dispatching a subcommand — only
|
|
153
|
+
// render the table when no subcommand ran. Object.hasOwn so prototype
|
|
154
|
+
// names ('constructor', 'toString') never count as a dispatched command.
|
|
155
|
+
const first = rawArgs.find(a => !a.startsWith('-'))
|
|
156
|
+
if (first && Object.hasOwn(envSubCommands, first)) return
|
|
157
|
+
const entry = await resolveCwdWorkspace()
|
|
158
|
+
const view = await readEnvView(entry.path)
|
|
159
|
+
console.log('\n' + renderEnvView(entry, view) + '\n')
|
|
160
|
+
process.exit(0)
|
|
161
|
+
}
|
|
162
|
+
})
|