moi-computer 0.13.1-next.0 → 0.13.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/client/api/app-config.ts +12 -2
- package/client/api/http.ts +11 -1
- package/client/app/app-router.tsx +3 -2
- package/client/app/routes/home-route.tsx +1 -1
- package/client/app/routes/workspace-registration.tsx +68 -0
- package/client/app/routes/workspace-route.tsx +37 -13
- package/client/app/shell/sidebar-layout.tsx +10 -5
- package/client/components/shared/workspace-icon.tsx +8 -17
- package/client/features/account/account-test-utils.tsx +18 -4
- package/client/features/account/api.ts +10 -8
- package/client/features/account/profile-actions.ts +5 -7
- package/client/features/app-settings/avatar-upload.tsx +62 -0
- package/client/features/app-settings/profile-settings.tsx +10 -0
- package/client/features/app-settings/settings-page.tsx +2 -1
- package/client/features/applets/api.ts +6 -6
- package/client/features/applets/applet-cache.ts +6 -5
- package/client/features/applets/applet-log.ts +2 -1
- package/client/features/applets/applet-runtime.ts +2 -1
- package/client/features/applets/use-applet.ts +73 -18
- package/client/features/applets/widget-shell.tsx +4 -2
- package/client/features/chat/applet-chat-intents.ts +5 -13
- package/client/features/chat/chat-popup.tsx +8 -4
- package/client/features/chat/chat-send.ts +2 -2
- package/client/features/chat/composer/model-order.ts +4 -4
- package/client/features/chat/composer/model-picker.tsx +12 -10
- package/client/features/chat/composer/use-workspace-composer-state.tsx +1 -1
- package/client/features/chat/sessions/api.ts +11 -28
- package/client/features/chat/sessions/use-selected-session.ts +18 -100
- package/client/features/chat/use-chat.ts +8 -12
- package/client/features/collab/applet-api.ts +1 -1
- package/client/features/collab/components/cursors.tsx +6 -1
- package/client/features/collab/components/presence-avatars.tsx +1 -1
- package/client/features/collab/components/presence-frame.tsx +1 -1
- package/client/features/collab/components/presence-group.tsx +1 -1
- package/client/features/collab/components/presence-helpers.ts +2 -2
- package/client/features/collab/components/user-avatar-group.tsx +1 -1
- package/client/features/collab/components/user-avatar.tsx +1 -1
- package/client/features/collab/components/user.tsx +1 -1
- package/client/features/collab/index.ts +3 -3
- package/client/features/collab/members/api.ts +17 -0
- package/client/features/collab/members/hooks.ts +97 -0
- package/client/features/collab/members/store.ts +148 -0
- package/client/features/{workspace-members → collab/members}/types.ts +7 -5
- package/client/features/collab/{client.ts → presence/client.ts} +4 -5
- package/client/features/collab/{hooks.tsx → presence/hooks.tsx} +1 -1
- package/client/features/collab/{provider.tsx → presence/provider.tsx} +1 -12
- package/client/features/collab/{users.ts → presence/users.ts} +19 -21
- package/client/features/collab/proxy-user.ts +1 -3
- package/client/features/collab/sharing/agent-invite.tsx +30 -0
- package/client/features/collab/sharing/workspace-members.tsx +269 -0
- package/client/features/collab/sharing/workspace-sharing-menu.tsx +179 -0
- package/client/features/collab/testing/component-fixtures.tsx +3 -3
- package/client/features/collab/testing/fake-engine.ts +2 -2
- package/client/features/dev/chat-states-page.tsx +3 -1
- package/client/features/dev/collab/collab-playground.tsx +2 -2
- package/client/features/dev/dev-index-page.tsx +0 -6
- package/client/features/dev/dev-routes.tsx +0 -2
- package/client/features/dev/harness-debug-page.tsx +7 -7
- package/client/features/dev/workspace-setup-mocks.ts +1 -2
- package/client/features/dev/workspace-setup-preview.tsx +6 -4
- package/client/features/harness/api.ts +13 -10
- package/client/features/harness/harness-login-panel.tsx +9 -5
- package/client/features/harness/harness-presentation.ts +4 -4
- package/client/features/harness/harness-selector.tsx +13 -13
- package/client/features/harness/use-harness-login.ts +5 -5
- package/client/features/home/api.ts +38 -2
- package/client/features/home/home-page.tsx +43 -13
- package/client/features/home/shared-workspaces.tsx +70 -0
- package/client/features/home/workspace-invitations.tsx +101 -0
- package/client/features/identity/host-api.ts +5 -4
- package/client/features/identity/store.ts +1 -7
- package/client/features/onboarding/agent-setup-step.tsx +8 -8
- package/client/features/onboarding/onboarding-page.tsx +3 -2
- package/client/features/onboarding/workspace-setup-step.tsx +1 -1
- package/client/features/overview/api.ts +3 -5
- package/client/features/overview/default/registry.tsx +1 -1
- package/client/features/overview/default/views-widget.tsx +2 -2
- package/client/features/overview/hidden-panel.tsx +7 -5
- package/client/features/overview/overview.tsx +18 -16
- package/client/features/overview/workspace-name.tsx +2 -2
- package/client/features/scratchpad/scratchpad.tsx +9 -7
- package/client/features/scratchpad/use-scratchpad-snapshot.tsx +13 -5
- package/client/features/views/api.ts +34 -16
- package/client/features/views/use-view-actions.ts +10 -20
- package/client/features/views/view-manager.tsx +1 -1
- package/client/features/views/view-submission.ts +2 -21
- package/client/features/workspace/add/api.ts +5 -4
- package/client/features/workspace/add/create-workspace-dialog.tsx +12 -9
- package/client/features/workspace/add/import-workspace-dialog.tsx +7 -7
- package/client/features/workspace/add/use-workspace-import.ts +10 -10
- package/client/features/workspace/add/workspace-agent-options.ts +21 -20
- package/client/features/workspace/add/workspace-agent-selector.tsx +11 -11
- package/client/features/workspace/api.ts +60 -13
- package/client/features/workspace/harness-transition.ts +7 -13
- package/client/features/workspace/remote.ts +25 -0
- package/client/features/workspace/settings/api.ts +7 -12
- package/client/features/workspace/settings/connectors-settings.tsx +3 -3
- package/client/features/workspace/settings/general-settings.tsx +8 -8
- package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
- package/client/features/workspace/setup/workspace-recovery-states.tsx +43 -14
- package/client/features/workspace/setup/workspace-setup.tsx +6 -6
- package/client/features/workspace/tab-resolution.ts +2 -2
- package/client/features/workspace/use-workspace-navigation.ts +7 -4
- package/client/features/workspace/workspace-content.tsx +32 -26
- package/client/features/workspace/workspace-frame.tsx +13 -26
- package/client/features/workspace/workspace-layout-context.tsx +45 -12
- package/client/features/workspace/workspace-menu.tsx +2 -2
- package/client/features/workspace/workspace-pane.tsx +22 -0
- package/client/features/workspace/workspace-pending-screen.tsx +1 -1
- package/client/features/workspace/workspace-preferences.ts +34 -0
- package/client/features/workspace/workspace-presentation.tsx +12 -16
- package/client/features/workspace/workspace-screen.tsx +2 -2
- package/client/features/workspace/workspace-state.ts +2 -1
- package/client/features/workspace/workspace-tabs.tsx +1 -1
- package/client/features/workspace/workspace-test-utils.ts +23 -0
- package/client/runtime/use-workspace-events.ts +14 -0
- package/client/runtime/workspace-events.ts +9 -9
- package/client/store/ui.ts +29 -9
- package/dist/chunk-44khk4sp.js +2 -0
- package/dist/chunk-ba6mz56s.js +72 -0
- package/dist/chunk-ec5ennpv.js +1 -0
- package/dist/chunk-ectsnw81.js +2 -0
- package/dist/chunk-en7w5ypg.js +1 -0
- package/dist/chunk-f695wcx5.js +5 -0
- package/dist/chunk-kffcah9w.css +1 -0
- package/dist/{chunk-kdgk4dac.js → chunk-n0fawy9x.js} +1 -1
- package/dist/chunk-pdt9hxfw.js +2 -0
- package/dist/chunk-rmd0ctfx.js +546 -0
- package/dist/chunk-zv22wv0g.js +1 -0
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +4 -4
- package/lib/harness-types.ts +13 -0
- package/lib/types.ts +34 -50
- package/lib/workspace-config.ts +48 -0
- package/lib/workspace-layout.ts +2 -4
- package/package.json +4 -2
- package/server/README.md +29 -27
- package/server/api/harnesses.ts +5 -5
- package/server/api/index.ts +170 -68
- package/server/app-config.ts +2 -7
- package/server/applets/declarations.ts +6 -7
- package/server/applets/index.ts +15 -9
- package/server/applets/views.ts +2 -17
- package/server/applets/widgets.ts +3 -2
- package/server/cli/commands/config.ts +8 -20
- package/server/cli/commands/hermes.ts +2 -2
- package/server/cli/commands/init.ts +96 -64
- package/server/cli/commands/openclaw.ts +2 -2
- package/server/cli/commands/refresh.ts +10 -1
- package/server/cli/commands/remote.ts +228 -0
- package/server/cli/commands/skill.ts +4 -4
- package/server/cli/commands/tabs.ts +5 -12
- package/server/cli/control.ts +35 -4
- package/server/cli/index.ts +10 -6
- package/server/cli/remote-command.ts +77 -0
- package/server/cli/remote-control.ts +70 -0
- package/server/cli/remote-operations.ts +244 -0
- package/server/collab/config.ts +4 -8
- package/server/collab/manager.ts +5 -2
- package/server/collab/skill/index.ts +4 -50
- package/server/control.ts +38 -11
- package/server/harness/acp/session.ts +4 -4
- package/server/harness/auth.ts +26 -31
- package/server/harness/claude-code/index.ts +1 -1
- package/server/harness/codex/discovery.ts +1 -1
- package/server/harness/codex/session.ts +1 -1
- package/server/harness/detect.ts +14 -19
- package/server/harness/executable.ts +10 -10
- package/server/harness/hermes/NOTES.md +2 -2
- package/server/harness/hermes/index.ts +1 -1
- package/server/harness/install.ts +11 -11
- package/server/harness/openclaw/index.ts +1 -1
- package/server/harness/registry.ts +7 -6
- package/server/harness/types.ts +4 -4
- package/server/onboarding/jobs.ts +1 -1
- package/server/operations/commands.ts +46 -0
- package/server/operations/files.ts +148 -0
- package/server/operations/server.ts +206 -0
- package/server/remote/agent.ts +103 -0
- package/server/remote/client.ts +665 -0
- package/server/remote/workspace.ts +34 -0
- package/server/scratchpad/document.ts +32 -12
- package/server/scratchpad/executor.ts +16 -7
- package/server/sessions/config.ts +8 -5
- package/server/sessions/pending-views.ts +16 -0
- package/server/sessions/view-sessions.ts +10 -12
- package/server/skills/locations.ts +4 -4
- package/server/skills/template.ts +3 -2
- package/server/skills/update.ts +12 -12
- package/server/skills/version.ts +7 -7
- package/server/skills/workspace.ts +13 -13
- package/server/web.ts +12 -10
- package/server/workspace-state/file.ts +2 -0
- package/server/workspace-state/index.ts +0 -4
- package/server/workspaces/api.ts +28 -0
- package/server/workspaces/change-harness.ts +15 -26
- package/server/workspaces/import.ts +4 -4
- package/server/workspaces/init.ts +15 -13
- package/server/workspaces/layout.ts +60 -66
- package/server/workspaces/registry.ts +43 -18
- package/server/workspaces/scaffold.ts +1 -0
- package/server/workspaces/shared.ts +74 -0
- package/server/workspaces/tabs.ts +6 -12
- package/skill/SKILL.md +24 -4
- package/client/api/app-ui-keys.ts +0 -6
- package/client/features/chat/sessions/browser-tab-state.ts +0 -43
- package/client/features/collab/workspace-users-menu.tsx +0 -190
- package/client/features/dev/cloud-avatar-upload.tsx +0 -58
- package/client/features/dev/cloud-page.tsx +0 -363
- package/client/features/workspace/browser-tab-state.ts +0 -51
- package/client/features/workspace/layout-save.ts +0 -13
- package/client/features/workspace-members/api.ts +0 -20
- package/client/features/workspace-members/hooks.ts +0 -127
- package/client/features/workspace-members/keys.ts +0 -6
- package/client/features/workspace-members/store.ts +0 -123
- package/dist/chunk-00s35r33.js +0 -546
- package/dist/chunk-7rz6g7g7.js +0 -1
- package/dist/chunk-af2jyddf.js +0 -2
- package/dist/chunk-cekekc3f.css +0 -1
- package/dist/chunk-ep5vh16c.js +0 -75
- package/dist/chunk-s5s1vzdw.js +0 -2
- package/dist/chunk-svxhxfeq.js +0 -2
- package/dist/chunk-t0r0bds1.js +0 -1
- package/dist/chunk-vp2qzc0d.js +0 -1
- package/dist/chunk-wz5qv1bn.js +0 -2
- package/lib/workspace-types.ts +0 -13
- package/server/workspace-state/legacy-migration.ts +0 -79
- /package/client/features/collab/{presence-publisher.ts → presence/presence-publisher.ts} +0 -0
- /package/client/features/collab/{presence-target.ts → presence/presence-target.ts} +0 -0
- /package/client/features/collab/{store.ts → presence/store.ts} +0 -0
|
@@ -14,8 +14,8 @@ import { columns } from '../ui'
|
|
|
14
14
|
// same way `moi bundle` does, so it works from `.moi/` or any subdirectory.
|
|
15
15
|
async function runSkillUpdate(cwd: string): Promise<void> {
|
|
16
16
|
// Include the primary harness destination and existing copies for other agents.
|
|
17
|
-
const { root,
|
|
18
|
-
const result = await updateWorkspaceSkills(root,
|
|
17
|
+
const { root, harness } = await resolveWorkspace(cwd)
|
|
18
|
+
const result = await updateWorkspaceSkills(root, harness)
|
|
19
19
|
const { changedSkills, updatedAppletTypes } = result
|
|
20
20
|
const heading = changedSkills.length > 0 ? 'Skills updated in ' : 'Skills unchanged in '
|
|
21
21
|
|
|
@@ -97,8 +97,8 @@ export const skill = defineCommand({
|
|
|
97
97
|
const sub = rawArgs.find(a => !a.startsWith('-'))
|
|
98
98
|
if (sub && sub in skillSubCommands) return
|
|
99
99
|
|
|
100
|
-
const { root,
|
|
101
|
-
const statuses = await skillStatuses(root,
|
|
100
|
+
const { root, harness } = await resolveWorkspace(resolve(args.dir))
|
|
101
|
+
const statuses = await skillStatuses(root, harness)
|
|
102
102
|
|
|
103
103
|
console.log('\n' + pc.bold('moi skill') + pc.dim(' — workspace skills') + '\n')
|
|
104
104
|
console.log(
|
|
@@ -5,25 +5,18 @@ import { sendControl } from '../control'
|
|
|
5
5
|
import pc from '../pc'
|
|
6
6
|
import { columns } from '../ui'
|
|
7
7
|
|
|
8
|
-
// The listing behind `moi tabs`: every tab (static + views), one per row
|
|
9
|
-
// saved default (`layout.tabs.active`) marked. The
|
|
8
|
+
// The listing behind `moi tabs`: every tab (static + views), one per row. The
|
|
10
9
|
// addresses are documented in docs/navigation.md.
|
|
11
10
|
function runTabsList(dir: string) {
|
|
12
11
|
const path = resolve(dir)
|
|
13
12
|
sendControl(path, { type: 'tabs', path }, res => {
|
|
14
|
-
type Row = { title: string;
|
|
13
|
+
type Row = { title: string; href: string }
|
|
15
14
|
const rows: Row[] = Array.isArray(res.tabs) ? (res.tabs as Row[]) : []
|
|
16
|
-
console.log(
|
|
17
|
-
'\n' + pc.bold('moi tabs') + pc.dim(' — workspace tabs, the default one marked') + '\n'
|
|
18
|
-
)
|
|
15
|
+
console.log('\n' + pc.bold('moi tabs') + pc.dim(' — workspace tabs') + '\n')
|
|
19
16
|
console.log(
|
|
20
17
|
columns(
|
|
21
|
-
['
|
|
22
|
-
rows.map(row => [
|
|
23
|
-
row.isDefault ? pc.green('●') : ' ',
|
|
24
|
-
row.isDefault ? pc.bold(row.title) : row.title,
|
|
25
|
-
row.href
|
|
26
|
-
])
|
|
18
|
+
['title', 'address'].map(h => pc.dim(h)),
|
|
19
|
+
rows.map(row => [row.title, row.href])
|
|
27
20
|
)
|
|
28
21
|
)
|
|
29
22
|
console.log('\n' + pc.dim(' Open one: moi navigate <address>') + '\n')
|
package/server/cli/control.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { remoteControl } from './remote-control'
|
|
1
2
|
import { accessSync, constants } from 'node:fs'
|
|
2
3
|
import { CONTROL_URL } from '../constants'
|
|
3
4
|
import { controlFailureMessage, probeControlServer } from '../control-client'
|
|
@@ -46,14 +47,44 @@ export async function registerViaControl(absPath: string): Promise<string> {
|
|
|
46
47
|
})
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
// Tell the local server something it may act on. Never fails the command: the
|
|
51
|
+
// server may be stopped, and the caller's own work is already done.
|
|
52
|
+
export function notifyLocalServer(payload: Record<string, unknown>, timeoutMs = 3000) {
|
|
53
|
+
return new Promise<void>(done => {
|
|
54
|
+
const ws = new WebSocket(CONTROL_URL)
|
|
55
|
+
const finish = () => {
|
|
56
|
+
clearTimeout(timer)
|
|
57
|
+
ws.close()
|
|
58
|
+
done()
|
|
59
|
+
}
|
|
60
|
+
const timer = setTimeout(finish, timeoutMs)
|
|
61
|
+
ws.onopen = () => ws.send(JSON.stringify(payload))
|
|
62
|
+
ws.onmessage = finish
|
|
63
|
+
ws.onerror = finish
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Shared data in a linked folder uses the owner API. Browser actions and local
|
|
68
|
+
// workspaces use visitor control. Both paths keep output/file IO on the caller.
|
|
69
|
+
export async function sendControl(
|
|
53
70
|
path: string,
|
|
54
71
|
payload: Record<string, unknown>,
|
|
55
72
|
onResult: (res: Record<string, unknown>) => void | Promise<void>
|
|
56
73
|
) {
|
|
74
|
+
try {
|
|
75
|
+
const result = await remoteControl(path, payload)
|
|
76
|
+
if (result) {
|
|
77
|
+
if (result.error) throw new Error(String(result.error))
|
|
78
|
+
await onResult(result)
|
|
79
|
+
const notice = await staleSkillNotice(path)
|
|
80
|
+
if (notice) console.error('\n' + pc.yellow(notice) + '\n')
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error(error instanceof Error ? error.message : 'Remote command failed')
|
|
85
|
+
process.exitCode = 1
|
|
86
|
+
return
|
|
87
|
+
}
|
|
57
88
|
const ws = new WebSocket(CONTROL_URL)
|
|
58
89
|
let connected = false
|
|
59
90
|
let responded = false
|
package/server/cli/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { init } from './commands/init'
|
|
|
14
14
|
import { navigate } from './commands/navigate'
|
|
15
15
|
import { openclaw } from './commands/openclaw'
|
|
16
16
|
import { refresh } from './commands/refresh'
|
|
17
|
+
import { remote } from './commands/remote'
|
|
17
18
|
import { scratch } from './commands/scratch'
|
|
18
19
|
import { service } from './commands/service'
|
|
19
20
|
import { skill } from './commands/skill'
|
|
@@ -26,25 +27,28 @@ import { update } from './commands/update'
|
|
|
26
27
|
import { version } from './commands/version'
|
|
27
28
|
import { views } from './commands/views'
|
|
28
29
|
import pc from './pc'
|
|
30
|
+
import { remoteWorkspaceCommand } from './remote-command'
|
|
29
31
|
|
|
30
32
|
// The root help splits the surface by audience: workspace commands are the
|
|
31
33
|
// agent's day-to-day toolkit (skills tell it to run them); system commands
|
|
32
34
|
// manage Moi itself and are for the human at the keyboard.
|
|
33
35
|
const workspaceCommands = {
|
|
34
|
-
bundle,
|
|
35
|
-
check,
|
|
36
|
+
bundle: remoteWorkspaceCommand('bundle', bundle),
|
|
37
|
+
check: remoteWorkspaceCommand('check', check),
|
|
36
38
|
refresh,
|
|
39
|
+
// A view under construction belongs to the caller's chat, so these stay on local control.
|
|
37
40
|
views,
|
|
38
|
-
'call-server-fn': callServerFn,
|
|
39
|
-
debug,
|
|
40
|
-
theme,
|
|
41
|
+
'call-server-fn': remoteWorkspaceCommand('call-server-fn', callServerFn),
|
|
42
|
+
debug: remoteWorkspaceCommand('debug', debug),
|
|
43
|
+
theme: remoteWorkspaceCommand('theme', theme),
|
|
41
44
|
config,
|
|
42
45
|
env,
|
|
43
46
|
scratch,
|
|
44
47
|
skill,
|
|
45
48
|
tabs,
|
|
46
49
|
navigate,
|
|
47
|
-
|
|
50
|
+
remote,
|
|
51
|
+
'ui-components': remoteWorkspaceCommand('ui-components', uiComponents)
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
const systemCommands = {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ArgsDef, CommandDef } from 'citty'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
import { notifyLocalServer } from './control'
|
|
4
|
+
import { runLinkedWorkspaceCommand } from './remote-operations'
|
|
5
|
+
|
|
6
|
+
// Wrap owner-executed commands only. Preserve their parser/help while running
|
|
7
|
+
// them on the linked host. Commands with caller file IO or browser actions use
|
|
8
|
+
// their ordinary handlers and remote-control instead.
|
|
9
|
+
export function remoteWorkspaceCommand<T extends ArgsDef>(
|
|
10
|
+
name: string,
|
|
11
|
+
command: CommandDef<T>,
|
|
12
|
+
prefix: string[] = []
|
|
13
|
+
): CommandDef<T> {
|
|
14
|
+
const original = command.run
|
|
15
|
+
return {
|
|
16
|
+
...command,
|
|
17
|
+
...(command.subCommands
|
|
18
|
+
? {
|
|
19
|
+
subCommands: async () => {
|
|
20
|
+
const source =
|
|
21
|
+
typeof command.subCommands === 'function'
|
|
22
|
+
? await command.subCommands()
|
|
23
|
+
: await command.subCommands
|
|
24
|
+
const children: NonNullable<typeof source> = {}
|
|
25
|
+
for (const [key, value] of Object.entries(source ?? {})) {
|
|
26
|
+
const child = typeof value === 'function' ? await value() : await value
|
|
27
|
+
children[key] = remoteWorkspaceCommand(name, child, [...prefix, key])
|
|
28
|
+
}
|
|
29
|
+
return children
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
: {}),
|
|
33
|
+
async run(context) {
|
|
34
|
+
if (command.subCommands && context.args._.length) return original?.(context)
|
|
35
|
+
const args = context.args as Record<string, unknown>
|
|
36
|
+
const folder = resolve(typeof args.dir === 'string' ? args.dir : process.cwd())
|
|
37
|
+
const definitions =
|
|
38
|
+
typeof command.args === 'function' ? await command.args() : await command.args
|
|
39
|
+
const positionalDir = Object.entries(definitions ?? {})
|
|
40
|
+
.filter(([, def]) => def.type === 'positional')
|
|
41
|
+
.findIndex(([key]) => key === 'dir')
|
|
42
|
+
let position = 0
|
|
43
|
+
const forwarded: string[] = []
|
|
44
|
+
for (let i = 0; i < context.rawArgs.length; i++) {
|
|
45
|
+
const arg = context.rawArgs[i]!
|
|
46
|
+
if (arg === '--dir') {
|
|
47
|
+
i++
|
|
48
|
+
continue
|
|
49
|
+
}
|
|
50
|
+
if (arg.startsWith('--dir=')) continue
|
|
51
|
+
if (arg.startsWith('-') && arg !== '-') {
|
|
52
|
+
forwarded.push(arg)
|
|
53
|
+
const option = arg.replace(/^--?/, '').split('=')[0]!
|
|
54
|
+
if (
|
|
55
|
+
!arg.includes('=') &&
|
|
56
|
+
definitions?.[option]?.type === 'string' &&
|
|
57
|
+
context.rawArgs[i + 1] !== undefined
|
|
58
|
+
)
|
|
59
|
+
forwarded.push(context.rawArgs[++i]!)
|
|
60
|
+
} else if (position++ !== positionalDir) forwarded.push(arg)
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
if (await runLinkedWorkspaceCommand(name, [...prefix, ...forwarded], folder)) {
|
|
64
|
+
// A view the owner just built is still marked as building in this Moi.
|
|
65
|
+
if (name === 'bundle' && !process.exitCode)
|
|
66
|
+
await notifyLocalServer({ type: 'views:reconcile', path: folder })
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error(error instanceof Error ? error.message : 'Remote command failed')
|
|
71
|
+
process.exitCode = 1
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
return original?.(context)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { basename } from 'node:path'
|
|
2
|
+
import type { ScratchOp, ViewInfo } from '@/lib/types'
|
|
3
|
+
import { currentRemoteWorkspace } from '../remote/workspace'
|
|
4
|
+
import { requestWorkspace } from '../workspaces/api'
|
|
5
|
+
import { assembleTabRows } from '../workspaces/tabs'
|
|
6
|
+
import { readScratchpadImage, readScratchpadShapes } from '../scratchpad/document'
|
|
7
|
+
import type { WorkspaceConfig } from '../workspaces/config'
|
|
8
|
+
|
|
9
|
+
type ScratchCliOp = ScratchOp | { kind: 'read' } | { kind: 'read-image'; name: string }
|
|
10
|
+
|
|
11
|
+
// These commands keep parsing, local file IO and output on the caller. Only
|
|
12
|
+
// shared data crosses the owner API. Browser rendering stays on visitor control.
|
|
13
|
+
export async function remoteControl(
|
|
14
|
+
path: string,
|
|
15
|
+
payload: Record<string, unknown>
|
|
16
|
+
): Promise<Record<string, unknown> | undefined> {
|
|
17
|
+
if (!['config', 'scratch', 'tabs'].includes(String(payload.type))) return
|
|
18
|
+
const op = payload.op as ScratchCliOp | undefined
|
|
19
|
+
if (payload.type === 'scratch' && op?.kind === 'view') return
|
|
20
|
+
const remote = await currentRemoteWorkspace(path)
|
|
21
|
+
if (!remote) return
|
|
22
|
+
const workspace = { remote }
|
|
23
|
+
const request = (suffix: string, init?: RequestInit) => requestWorkspace(workspace, suffix, init)
|
|
24
|
+
if (payload.type === 'tabs') {
|
|
25
|
+
const { views }: { views: ViewInfo[] } = await (
|
|
26
|
+
await request('/views?includePending=true')
|
|
27
|
+
).json()
|
|
28
|
+
return { tabs: assembleTabRows(views) }
|
|
29
|
+
}
|
|
30
|
+
if (payload.type === 'config') {
|
|
31
|
+
if (typeof payload.iconPath === 'string') {
|
|
32
|
+
const file = Bun.file(payload.iconPath)
|
|
33
|
+
if (!(await file.exists())) throw new Error('Local icon file not found')
|
|
34
|
+
return { ok: true, ...(await (await request('/icon', { method: 'PUT', body: file })).json()) }
|
|
35
|
+
}
|
|
36
|
+
if (payload.clearIcon) {
|
|
37
|
+
await request('/icon', { method: 'DELETE' })
|
|
38
|
+
return { ok: true, clearedIcon: true }
|
|
39
|
+
}
|
|
40
|
+
if (payload.name !== undefined || payload.clearName) {
|
|
41
|
+
const result = await (
|
|
42
|
+
await request('/config', {
|
|
43
|
+
method: 'PUT',
|
|
44
|
+
headers: { 'content-type': 'application/json' },
|
|
45
|
+
body: JSON.stringify({ name: payload.clearName ? null : payload.name })
|
|
46
|
+
})
|
|
47
|
+
).json()
|
|
48
|
+
return { ...result, ok: true, clearedName: payload.clearName === true }
|
|
49
|
+
}
|
|
50
|
+
const config: WorkspaceConfig = await (await request('/config')).json()
|
|
51
|
+
return { ...config, hasIcon: !!config.icon }
|
|
52
|
+
}
|
|
53
|
+
if (!op) throw new Error('Missing scratch operation')
|
|
54
|
+
if (op.kind === 'read') return { shapes: await readScratchpadShapes(workspace) }
|
|
55
|
+
if (op.kind === 'read-image') return readScratchpadImage(workspace, op.name)
|
|
56
|
+
const body = new FormData()
|
|
57
|
+
if (op.kind.startsWith('add-') && 'name' in op && !op.name)
|
|
58
|
+
op.name = `s_${crypto.randomUUID().slice(0, 8)}`
|
|
59
|
+
if (op.kind === 'add-image') {
|
|
60
|
+
const file = Bun.file(op.path)
|
|
61
|
+
if (!(await file.exists())) throw new Error('Local image file not found')
|
|
62
|
+
body.set('image', file)
|
|
63
|
+
// The owner receives bytes, never a caller's filesystem path.
|
|
64
|
+
body.set('op', JSON.stringify({ ...op, path: basename(op.path) }))
|
|
65
|
+
} else body.set('op', JSON.stringify(op))
|
|
66
|
+
return {
|
|
67
|
+
ok: true,
|
|
68
|
+
result: await (await request('/scratchpad/ops', { method: 'POST', body })).json()
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { defineCommand } from 'citty'
|
|
2
|
+
import { mkdir, rename, rm } from 'node:fs/promises'
|
|
3
|
+
import { dirname, resolve } from 'node:path'
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
import { operation } from '../remote/client'
|
|
6
|
+
import { currentRemoteWorkspace } from '../remote/workspace'
|
|
7
|
+
|
|
8
|
+
const path = { type: 'string' as const, description: 'Local linked workspace folder' }
|
|
9
|
+
const json = { type: 'boolean' as const, description: 'Print JSON result' }
|
|
10
|
+
const commandResult = z.object({
|
|
11
|
+
exitCode: z.number().int(),
|
|
12
|
+
stdout: z.string(),
|
|
13
|
+
stderr: z.string()
|
|
14
|
+
})
|
|
15
|
+
async function printCommandResult(response: Response, json = false) {
|
|
16
|
+
const result = commandResult.parse(await response.json())
|
|
17
|
+
if (json) console.log(JSON.stringify(result))
|
|
18
|
+
else {
|
|
19
|
+
process.stdout.write(result.stdout)
|
|
20
|
+
process.stderr.write(result.stderr)
|
|
21
|
+
}
|
|
22
|
+
process.exitCode = result.exitCode < 0 ? 1 : result.exitCode
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Ordinary workspace commands can use the folder's remote link automatically. */
|
|
26
|
+
export async function runLinkedWorkspaceCommand(command: string, args: string[], folder: string) {
|
|
27
|
+
const linked = await currentRemoteWorkspace(folder)
|
|
28
|
+
if (!linked) return false
|
|
29
|
+
const response = await operation(linked.user_id, linked.workspace_id, '/commands', {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
body: JSON.stringify({ command, args }),
|
|
32
|
+
contentType: 'application/json'
|
|
33
|
+
})
|
|
34
|
+
await printCommandResult(response)
|
|
35
|
+
return true
|
|
36
|
+
}
|
|
37
|
+
const execEvent = z.discriminatedUnion('type', [
|
|
38
|
+
z.object({ type: z.literal('stdout'), data: z.string() }),
|
|
39
|
+
z.object({ type: z.literal('stderr'), data: z.string() }),
|
|
40
|
+
z.object({ type: z.literal('exit'), code: z.number().int() })
|
|
41
|
+
])
|
|
42
|
+
const fileSuffix = (value: string) => {
|
|
43
|
+
if (
|
|
44
|
+
!value ||
|
|
45
|
+
value.startsWith('/') ||
|
|
46
|
+
value.includes('\\') ||
|
|
47
|
+
value.split('/').some(p => p === '.' || p === '..' || !p)
|
|
48
|
+
)
|
|
49
|
+
throw new Error('Use a file path relative to the remote workspace')
|
|
50
|
+
return '/files/' + value.split('/').map(encodeURIComponent).join('/')
|
|
51
|
+
}
|
|
52
|
+
async function target(folder?: string) {
|
|
53
|
+
const current = await currentRemoteWorkspace(folder)
|
|
54
|
+
if (!current)
|
|
55
|
+
throw new Error(
|
|
56
|
+
'This folder is not a remote workspace — run moi init --remote ownerId:workspaceId first'
|
|
57
|
+
)
|
|
58
|
+
return (suffix: string, options?: Parameters<typeof operation>[3]) =>
|
|
59
|
+
operation(current.user_id, current.workspace_id, suffix, options)
|
|
60
|
+
}
|
|
61
|
+
async function stdin() {
|
|
62
|
+
if (process.stdin.isTTY) throw new Error('Supply content or pipe it on stdin')
|
|
63
|
+
return Bun.stdin.text()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function remoteOperations(report: (action: () => Promise<void>) => Promise<void>) {
|
|
67
|
+
const read = defineCommand({
|
|
68
|
+
meta: { name: 'read', description: 'Read a remote workspace file to stdout' },
|
|
69
|
+
args: { file: { type: 'positional', required: true }, path },
|
|
70
|
+
run: ({ args }) =>
|
|
71
|
+
report(async () => {
|
|
72
|
+
const response = await (await target(args.path))(fileSuffix(args.file))
|
|
73
|
+
if (response.body)
|
|
74
|
+
for await (const chunk of response.body) await Bun.write(Bun.stdout, chunk)
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
const write = defineCommand({
|
|
78
|
+
meta: { name: 'write', description: 'Write a remote file; content argument or stdin' },
|
|
79
|
+
args: {
|
|
80
|
+
file: { type: 'positional', required: true },
|
|
81
|
+
content: { type: 'positional', required: false },
|
|
82
|
+
path,
|
|
83
|
+
json
|
|
84
|
+
},
|
|
85
|
+
run: ({ args }) =>
|
|
86
|
+
report(async () => {
|
|
87
|
+
const response = await (
|
|
88
|
+
await target(args.path)
|
|
89
|
+
)(fileSuffix(args.file), {
|
|
90
|
+
method: 'PUT',
|
|
91
|
+
body: args.content ?? (await stdin()),
|
|
92
|
+
contentType: 'application/octet-stream'
|
|
93
|
+
})
|
|
94
|
+
console.log(args.json ? JSON.stringify(await response.json()) : `Wrote ${args.file}`)
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
const patch = defineCommand({
|
|
98
|
+
meta: {
|
|
99
|
+
name: 'patch',
|
|
100
|
+
description: 'Apply a unified diff to a remote file (stdin or --patch-file)'
|
|
101
|
+
},
|
|
102
|
+
args: {
|
|
103
|
+
file: { type: 'positional', required: true },
|
|
104
|
+
'patch-file': { type: 'string' },
|
|
105
|
+
path,
|
|
106
|
+
json
|
|
107
|
+
},
|
|
108
|
+
run: ({ args }) =>
|
|
109
|
+
report(async () => {
|
|
110
|
+
const diff = args['patch-file']
|
|
111
|
+
? await Bun.file(resolve(args['patch-file'])).text()
|
|
112
|
+
: await stdin()
|
|
113
|
+
const response = await (
|
|
114
|
+
await target(args.path)
|
|
115
|
+
)(fileSuffix(args.file), {
|
|
116
|
+
method: 'PATCH',
|
|
117
|
+
body: JSON.stringify({ patch: diff }),
|
|
118
|
+
contentType: 'application/json'
|
|
119
|
+
})
|
|
120
|
+
console.log(args.json ? JSON.stringify(await response.json()) : `Patched ${args.file}`)
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
const upload = defineCommand({
|
|
124
|
+
meta: { name: 'file-upload', description: 'Upload a local file to a remote workspace path' },
|
|
125
|
+
args: {
|
|
126
|
+
source: { type: 'positional', required: true },
|
|
127
|
+
destination: { type: 'positional', required: true },
|
|
128
|
+
path,
|
|
129
|
+
json
|
|
130
|
+
},
|
|
131
|
+
run: ({ args }) =>
|
|
132
|
+
report(async () => {
|
|
133
|
+
const file = Bun.file(resolve(args.source))
|
|
134
|
+
if (!(await file.exists())) throw new Error('Local source file not found')
|
|
135
|
+
const response = await (
|
|
136
|
+
await target(args.path)
|
|
137
|
+
)(fileSuffix(args.destination), {
|
|
138
|
+
method: 'PUT',
|
|
139
|
+
body: file,
|
|
140
|
+
contentType: 'application/octet-stream'
|
|
141
|
+
})
|
|
142
|
+
console.log(
|
|
143
|
+
args.json ? JSON.stringify(await response.json()) : `Uploaded ${args.destination}`
|
|
144
|
+
)
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
const download = defineCommand({
|
|
148
|
+
meta: {
|
|
149
|
+
name: 'file-download',
|
|
150
|
+
description: 'Download a remote workspace file to a local path'
|
|
151
|
+
},
|
|
152
|
+
args: {
|
|
153
|
+
source: { type: 'positional', required: true },
|
|
154
|
+
destination: { type: 'positional', required: true },
|
|
155
|
+
path,
|
|
156
|
+
json
|
|
157
|
+
},
|
|
158
|
+
run: ({ args }) =>
|
|
159
|
+
report(async () => {
|
|
160
|
+
const response = await (await target(args.path))(fileSuffix(args.source))
|
|
161
|
+
const destination = resolve(args.destination),
|
|
162
|
+
temporary = `${destination}.${crypto.randomUUID()}.tmp`
|
|
163
|
+
await mkdir(dirname(destination), { recursive: true })
|
|
164
|
+
try {
|
|
165
|
+
await Bun.write(temporary, response)
|
|
166
|
+
await rename(temporary, destination)
|
|
167
|
+
} finally {
|
|
168
|
+
await rm(temporary, { force: true })
|
|
169
|
+
}
|
|
170
|
+
console.log(
|
|
171
|
+
args.json
|
|
172
|
+
? JSON.stringify({ ok: true, path: destination })
|
|
173
|
+
: `Downloaded ${args.destination}`
|
|
174
|
+
)
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
const exec = defineCommand({
|
|
178
|
+
meta: {
|
|
179
|
+
name: 'exec',
|
|
180
|
+
description: 'Run a shell command on the remote host, in this workspace'
|
|
181
|
+
},
|
|
182
|
+
args: { command: { type: 'positional', required: true }, path, json },
|
|
183
|
+
run: ({ args }) =>
|
|
184
|
+
report(async () => {
|
|
185
|
+
const controller = new AbortController()
|
|
186
|
+
const request = await target(args.path)
|
|
187
|
+
const id = crypto.randomUUID()
|
|
188
|
+
let cancellation: Promise<void> | undefined
|
|
189
|
+
const interrupt = () => {
|
|
190
|
+
cancellation ??= request('/exec', {
|
|
191
|
+
method: 'POST',
|
|
192
|
+
body: JSON.stringify({ cancel: id }),
|
|
193
|
+
contentType: 'application/json',
|
|
194
|
+
signal: AbortSignal.timeout(10_000)
|
|
195
|
+
})
|
|
196
|
+
.then(async response => {
|
|
197
|
+
await response.body?.cancel()
|
|
198
|
+
})
|
|
199
|
+
.catch(() => {
|
|
200
|
+
console.error('Could not confirm the remote command stopped')
|
|
201
|
+
})
|
|
202
|
+
.finally(() => controller.abort())
|
|
203
|
+
}
|
|
204
|
+
process.once('SIGINT', interrupt)
|
|
205
|
+
try {
|
|
206
|
+
const response = await request('/exec', {
|
|
207
|
+
method: 'POST',
|
|
208
|
+
body: JSON.stringify({ command: args.command, id }),
|
|
209
|
+
contentType: 'application/json',
|
|
210
|
+
signal: controller.signal
|
|
211
|
+
})
|
|
212
|
+
if (!response.body) throw new Error('Remote execution returned no stream')
|
|
213
|
+
let pending = '',
|
|
214
|
+
exit: number | undefined
|
|
215
|
+
const decoder = new TextDecoder()
|
|
216
|
+
for await (const chunk of response.body) {
|
|
217
|
+
pending += decoder.decode(chunk, { stream: true })
|
|
218
|
+
let end: number
|
|
219
|
+
while ((end = pending.indexOf('\n')) !== -1) {
|
|
220
|
+
const line = pending.slice(0, end)
|
|
221
|
+
pending = pending.slice(end + 1)
|
|
222
|
+
const event = execEvent.parse(JSON.parse(line))
|
|
223
|
+
if (args.json) console.log(JSON.stringify(event))
|
|
224
|
+
if (event.type === 'exit') exit = event.code
|
|
225
|
+
else if (!args.json)
|
|
226
|
+
(event.type === 'stdout' ? process.stdout : process.stderr).write(event.data)
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (exit === undefined || pending)
|
|
230
|
+
throw new Error(
|
|
231
|
+
'Remote execution disconnected before the exit code; command may still have run'
|
|
232
|
+
)
|
|
233
|
+
process.exitCode = exit < 0 ? 1 : exit
|
|
234
|
+
} catch (error) {
|
|
235
|
+
if (!cancellation) throw error
|
|
236
|
+
} finally {
|
|
237
|
+
process.removeListener('SIGINT', interrupt)
|
|
238
|
+
await cancellation
|
|
239
|
+
if (cancellation) process.exitCode = 130
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
})
|
|
243
|
+
return { read, write, patch, exec, 'file-upload': upload, 'file-download': download }
|
|
244
|
+
}
|
package/server/collab/config.ts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HarnessType } from '@/lib/types'
|
|
2
2
|
|
|
3
3
|
import { getAppConfig } from '../app-config'
|
|
4
4
|
import { collabSkillReferencePath } from './skill'
|
|
5
5
|
|
|
6
|
-
export function isCollabEnabled(): boolean {
|
|
7
|
-
return getAppConfig().collab
|
|
8
|
-
}
|
|
9
|
-
|
|
10
6
|
export async function getCollabReferencePath(
|
|
11
7
|
workspacePath: string,
|
|
12
|
-
|
|
8
|
+
harness?: HarnessType
|
|
13
9
|
): Promise<string | undefined> {
|
|
14
|
-
if (
|
|
15
|
-
const referencePath = collabSkillReferencePath(workspacePath,
|
|
10
|
+
if (getAppConfig().environment !== 'cloud') return undefined
|
|
11
|
+
const referencePath = collabSkillReferencePath(workspacePath, harness)
|
|
16
12
|
return (await Bun.file(referencePath).exists()) ? referencePath : undefined
|
|
17
13
|
}
|
package/server/collab/manager.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { join, resolve } from 'node:path'
|
|
|
5
5
|
import { COLLAB_MAX_MESSAGE_BYTES, isCollabClientMessage } from '@/lib/collab/protocol'
|
|
6
6
|
import type { CollabClientMessage, CollabServerMessage, UserProfile } from '@/lib/collab/types'
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { getAppConfig } from '../app-config'
|
|
9
9
|
import type { ParentMessage, WorkerMessage } from './worker-messages'
|
|
10
10
|
|
|
11
11
|
export type ClientSocket = {
|
|
@@ -107,7 +107,10 @@ export class CollabManager {
|
|
|
107
107
|
const canonicalPath = await realpath(workspacePath)
|
|
108
108
|
binding.workspacePaths.add(canonicalPath)
|
|
109
109
|
if (binding.closed) throw new CollabRuntimeError('unavailable', 'Collab connection closed')
|
|
110
|
-
|
|
110
|
+
const enabled = this.options.enabled
|
|
111
|
+
? await this.options.enabled(canonicalPath)
|
|
112
|
+
: getAppConfig().environment === 'cloud'
|
|
113
|
+
if (!enabled) {
|
|
111
114
|
throw new CollabRuntimeError(
|
|
112
115
|
'unavailable',
|
|
113
116
|
'Collaboration is only available in the cloud environment'
|
|
@@ -1,53 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import type { WorkspaceType } from '@/lib/types'
|
|
5
|
-
|
|
6
|
-
import { appletDeclarationPath, installCollabDeclaration } from '../../applets/declarations'
|
|
7
|
-
import { COLLAB_REFERENCE_SOURCE_PATH } from '../../skills/template'
|
|
1
|
+
import { join } from 'node:path'
|
|
2
|
+
import type { HarnessType } from '@/lib/types'
|
|
8
3
|
import { skillsDirFor } from '../../workspaces/init'
|
|
9
4
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
export function collabSkillReferencePath(workspacePath: string, type?: WorkspaceType): string {
|
|
13
|
-
return join(skillsDirFor(workspacePath, type), 'moi-workspace', 'references', 'COLLAB.md')
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function targetPaths(workspacePath: string, type?: WorkspaceType): SkillPaths {
|
|
17
|
-
return {
|
|
18
|
-
referencePath: collabSkillReferencePath(workspacePath, type),
|
|
19
|
-
typesPath: appletDeclarationPath(workspacePath, 'collab.d.ts')
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function writeChanged(path: string, contents: string): Promise<void> {
|
|
24
|
-
const file = Bun.file(path)
|
|
25
|
-
if ((await file.exists()) && (await file.text()) === contents) return
|
|
26
|
-
await mkdir(dirname(path), { recursive: true })
|
|
27
|
-
await Bun.write(path, contents)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Only an explicit `moi init --collab` installs the guide and types.
|
|
31
|
-
export async function installCollabSkill(
|
|
32
|
-
workspacePath: string,
|
|
33
|
-
type?: WorkspaceType
|
|
34
|
-
): Promise<SkillPaths> {
|
|
35
|
-
const source = Bun.file(COLLAB_REFERENCE_SOURCE_PATH)
|
|
36
|
-
if (!(await source.exists())) {
|
|
37
|
-
throw new Error('The collab guide is unavailable in this build: COLLAB.md is missing.')
|
|
38
|
-
}
|
|
39
|
-
const reference = await source.text()
|
|
40
|
-
const paths = targetPaths(workspacePath, type)
|
|
41
|
-
await writeChanged(paths.referencePath, reference)
|
|
42
|
-
await installCollabDeclaration(workspacePath)
|
|
43
|
-
return paths
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export async function removeCollabSkill(
|
|
47
|
-
workspacePath: string,
|
|
48
|
-
type?: WorkspaceType
|
|
49
|
-
): Promise<void> {
|
|
50
|
-
const paths = targetPaths(workspacePath, type)
|
|
51
|
-
await rm(paths.referencePath, { force: true })
|
|
52
|
-
await rm(paths.typesPath, { force: true })
|
|
5
|
+
export function collabSkillReferencePath(workspacePath: string, harness?: HarnessType): string {
|
|
6
|
+
return join(skillsDirFor(workspacePath, harness), 'moi-workspace', 'references', 'COLLAB.md')
|
|
53
7
|
}
|