@marimo-team/islands 0.23.15-dev20 → 0.23.15-dev21
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/dist/{code-visibility-DNwczZr1.js → code-visibility-Bqg6aos7.js} +1 -1
- package/dist/main.js +2 -2
- package/dist/{reveal-component-Cb5uzhCh.js → reveal-component-BzkgqXit.js} +1 -1
- package/package.json +1 -1
- package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +153 -0
- package/src/components/editor/actions/pair-with-agent-commands.ts +109 -0
- package/src/components/editor/actions/pair-with-agent-modal.tsx +20 -64
|
@@ -36291,7 +36291,7 @@ ${d}`,
|
|
|
36291
36291
|
return Logger.warn("Failed to get version from mount config"), null;
|
|
36292
36292
|
}
|
|
36293
36293
|
}
|
|
36294
|
-
marimoVersionAtom = atom(getVersionFromMountConfig() || "0.23.15-
|
|
36294
|
+
marimoVersionAtom = atom(getVersionFromMountConfig() || "0.23.15-dev21");
|
|
36295
36295
|
showCodeInRunModeAtom = atom(true);
|
|
36296
36296
|
atom(null);
|
|
36297
36297
|
var import_compiler_runtime = require_compiler_runtime();
|
package/dist/main.js
CHANGED
|
@@ -26,7 +26,7 @@ import { $ as reducer, $t as isUninstantiated, A as ChevronDownIcon, An as Item$
|
|
|
26
26
|
import { __tla as __tla_1 } from "./chunk-5FQGJX7Z-BbqSm5gU.js";
|
|
27
27
|
import { o as useSize, s as Root$1, u as createLucideIcon } from "./dist--2Bqjvs0.js";
|
|
28
28
|
import { A as SquareFunction, C as DEFAULT_COLOR_SCHEME, D as SCALE_TYPE_DESCRIPTIONS, E as EMPTY_VALUE$1, O as TIME_UNIT_DESCRIPTIONS, S as DEFAULT_AGGREGATION, T as DEFAULT_TIME_UNIT, _ as AGGREGATION_TYPE_DESCRIPTIONS, a as AGGREGATION_FNS$1, b as COLOR_SCHEMES, c as COLOR_BY_FIELDS, d as NONE_VALUE, f as SELECTABLE_DATA_TYPES, g as TIME_UNITS, h as STRING_AGGREGATION_FNS, i as convertDataTypeToSelectable, j as ChartColumn, k as escapeFieldName, l as COMBINED_TIME_UNITS, m as SORT_TYPES, n as createSpecWithoutData, o as BIN_AGGREGATION, p as SINGLE_TIME_UNITS, r as isFieldSet, s as CHART_TYPES, t as augmentSpecWithData, u as ChartType, v as AGGREGATION_TYPE_ICON, w as DEFAULT_MAX_BINS_FACET, x as COUNT_FIELD, y as CHART_TYPE_ICON } from "./spec-Cz-Bj1JI.js";
|
|
29
|
-
import { $ as ContextAwarePanelItem, $t as EmotionCacheProvider, A as prettifyRowColumnCount, At as loadTableData, B as useSelectList, Bt as dateToLocalISOTime, C as Filenames, Ct as ColumnChartContext, D as EmptyState, Dt as usePrevious$1, E as ColumnPreviewContainer, Et as useIntersectionObserver, F as ContextMenuContent, Ft as getMimeValues, G as ComboboxItem, Gt as ChartErrorState, H as DatePicker, Ht as TabsContent, I as ContextMenuItem, It as isNullishFilter, J as CommandInput, Jt as LazyVegaEmbed, K as Command, Kt as ChartInfoState, L as ContextMenuSeparator, Lt as Maps, M as getColumnCountForDisplay, Mt as SELECT_COLUMN_ID, N as getUserColumnVisibilityCounts, Nt as TOO_MANY_ROWS, O as ErrorState, Ot as getPageIndexForRow, P as ContextMenu, Pt as toFieldTypes, Q as smartMatch, Qt as HtmlOutput, R as ContextMenuTrigger, Rt as dateToLocalISODate, S as Progress, St as renderCellValue, T as ColumnName, Tt as DelayMount, U as DateRangePicker, Ut as TabsList, V as CompactChipRow, Vt as Tabs, W as Combobox, Wt as TabsTrigger, X as CommandList, Xt as RenderTextWithLinks, Y as CommandItem, Yt as useOverflowDetection, Z as CommandSeparator, Zt as Kbd, _ as InstallPackageButton, _n as ArrowDownWideNarrow, _t as TableHeader, an as GripHorizontal, at as SlotNames, b as downloadByURL, bt as generateColumns, d as RadioGroup, dn as Code, dt as Fill, en as hasFunctionProperty, et as PANEL_TYPES, f as RadioGroupItem, fn as ChevronsUpDown, ft as Provider$1, g as DataTable, gn as ChevronLeft, gt as TableHead, h as OutputRenderer, hn as ChevronsDownUp, ht as TableCell, in as TextWrap, it as isCellAwareAtom, j as prettifyRowCount, jt as INDEX_COLUMN_NAME, k as LoadingState, kt as loadTableAndRawData, l as Slide, ln as Ellipsis, m as OutputArea, mn as ChevronsLeft, mt as TableBody, n as marimoVersionAtom, nn as $fae977aafc393c5c$export$588937bcd60ade55, nt as contextAwarePanelOwner, on as Funnel, ot as slotsController, p as JsonOutput, pn as ChevronsRight, pt as Table, q as CommandEmpty, qt as ChartLoadingState, r as showCodeInRunModeAtom, rn as $fae977aafc393c5c$export$6b862160d295c8e, rt as contextAwarePanelType, s as SLIDE_TYPE_OPTIONS_BY_VALUE, sn as EyeOff, st as Toggle, t as useNotebookCodeAvailable, tn as isRecord, tt as contextAwarePanelOpen, u as Switch, un as Download, v as ADD_PRINTING_CLASS, vt as TableRow, w as downloadSizeLimitAtom, wt as ColumnChartSpecModel, x as downloadHTMLAsImage, xt as inferFieldTypes, y as downloadBlob, yt as NAMELESS_COLUMN_PREFIX, z as useInternalStateWithSync, zt as dateToLocalISODateTime, __tla as __tla_2 } from "./code-visibility-
|
|
29
|
+
import { $ as ContextAwarePanelItem, $t as EmotionCacheProvider, A as prettifyRowColumnCount, At as loadTableData, B as useSelectList, Bt as dateToLocalISOTime, C as Filenames, Ct as ColumnChartContext, D as EmptyState, Dt as usePrevious$1, E as ColumnPreviewContainer, Et as useIntersectionObserver, F as ContextMenuContent, Ft as getMimeValues, G as ComboboxItem, Gt as ChartErrorState, H as DatePicker, Ht as TabsContent, I as ContextMenuItem, It as isNullishFilter, J as CommandInput, Jt as LazyVegaEmbed, K as Command, Kt as ChartInfoState, L as ContextMenuSeparator, Lt as Maps, M as getColumnCountForDisplay, Mt as SELECT_COLUMN_ID, N as getUserColumnVisibilityCounts, Nt as TOO_MANY_ROWS, O as ErrorState, Ot as getPageIndexForRow, P as ContextMenu, Pt as toFieldTypes, Q as smartMatch, Qt as HtmlOutput, R as ContextMenuTrigger, Rt as dateToLocalISODate, S as Progress, St as renderCellValue, T as ColumnName, Tt as DelayMount, U as DateRangePicker, Ut as TabsList, V as CompactChipRow, Vt as Tabs, W as Combobox, Wt as TabsTrigger, X as CommandList, Xt as RenderTextWithLinks, Y as CommandItem, Yt as useOverflowDetection, Z as CommandSeparator, Zt as Kbd, _ as InstallPackageButton, _n as ArrowDownWideNarrow, _t as TableHeader, an as GripHorizontal, at as SlotNames, b as downloadByURL, bt as generateColumns, d as RadioGroup, dn as Code, dt as Fill, en as hasFunctionProperty, et as PANEL_TYPES, f as RadioGroupItem, fn as ChevronsUpDown, ft as Provider$1, g as DataTable, gn as ChevronLeft, gt as TableHead, h as OutputRenderer, hn as ChevronsDownUp, ht as TableCell, in as TextWrap, it as isCellAwareAtom, j as prettifyRowCount, jt as INDEX_COLUMN_NAME, k as LoadingState, kt as loadTableAndRawData, l as Slide, ln as Ellipsis, m as OutputArea, mn as ChevronsLeft, mt as TableBody, n as marimoVersionAtom, nn as $fae977aafc393c5c$export$588937bcd60ade55, nt as contextAwarePanelOwner, on as Funnel, ot as slotsController, p as JsonOutput, pn as ChevronsRight, pt as Table, q as CommandEmpty, qt as ChartLoadingState, r as showCodeInRunModeAtom, rn as $fae977aafc393c5c$export$6b862160d295c8e, rt as contextAwarePanelType, s as SLIDE_TYPE_OPTIONS_BY_VALUE, sn as EyeOff, st as Toggle, t as useNotebookCodeAvailable, tn as isRecord, tt as contextAwarePanelOpen, u as Switch, un as Download, v as ADD_PRINTING_CLASS, vt as TableRow, w as downloadSizeLimitAtom, wt as ColumnChartSpecModel, x as downloadHTMLAsImage, xt as inferFieldTypes, y as downloadBlob, yt as NAMELESS_COLUMN_PREFIX, z as useInternalStateWithSync, zt as dateToLocalISODateTime, __tla as __tla_2 } from "./code-visibility-Bqg6aos7.js";
|
|
30
30
|
import { c as Calendar, i as createReducerAndAtoms, n as useOnUnmount, o as ToggleLeft, t as useOnMount } from "./useLifecycle-DegSo0lV.js";
|
|
31
31
|
import { t as Check } from "./check-C9OoNtR4.js";
|
|
32
32
|
import { A as Icon, C as logNever, D as $18f2051aff69b9bf$export$a54013f0d02a8f82, E as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7, F as createCollection, I as X, M as clamp$2, N as usePrevious$2, P as useDirection, R as ChevronDown, S as assertNever, a as SelectGroup, c as SelectSeparator, d as NativeSelect, i as SelectContent, j as Trigger$1, l as SelectTrigger, n as capitalize, o as SelectItem, r as Select, s as SelectLabel, t as Strings, u as SelectValue, w as $a916eb452884faea$export$b7a616150fdb9f44 } from "./strings-Dq_j3Rxw.js";
|
|
@@ -38024,7 +38024,7 @@ ${c}
|
|
|
38024
38024
|
function _temp2$2(e) {
|
|
38025
38025
|
e.target === e.currentTarget && e.key === "Enter" && (e.preventDefault(), e.stopPropagation(), e.currentTarget.click());
|
|
38026
38026
|
}
|
|
38027
|
-
var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-
|
|
38027
|
+
var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-BzkgqXit.js"));
|
|
38028
38028
|
const SlidesLayoutRenderer = ({ layout: e, setLayout: r, cells: c, mode: l }) => {
|
|
38029
38029
|
var _a5;
|
|
38030
38030
|
let u = useAtomValue(kioskModeAtom), d = l === "read" || u, f = useAtomValue(numColumnsAtom) > 1, [p, m] = (0, import_react.useState)(null), { slideCells: h, skippedIds: g, noOutputIds: _, slideTypes: v, startCellIndex: y } = (0, import_react.useMemo)(() => computeSlideCellsInfo(c, e), [
|
|
@@ -9,7 +9,7 @@ import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
|
9
9
|
import { lt as kioskModeAtom, pt as outputIsStale } from "./html-to-image-JXL8cvmt.js";
|
|
10
10
|
import "./chunk-5FQGJX7Z-BbqSm5gU.js";
|
|
11
11
|
import { u as createLucideIcon } from "./dist--2Bqjvs0.js";
|
|
12
|
-
import { a as DEFAULT_DECK_VERTICAL_ALIGN, c as SlideSidebar, cn as Expand, ct as Panel, dn as Code, i as DEFAULT_DECK_TRANSITION, l as Slide, lt as PanelGroup, o as DEFAULT_SLIDE_TYPE, sn as EyeOff, t as useNotebookCodeAvailable, ut as PanelResizeHandle } from "./code-visibility-
|
|
12
|
+
import { a as DEFAULT_DECK_VERTICAL_ALIGN, c as SlideSidebar, cn as Expand, ct as Panel, dn as Code, i as DEFAULT_DECK_TRANSITION, l as Slide, lt as PanelGroup, o as DEFAULT_SLIDE_TYPE, sn as EyeOff, t as useNotebookCodeAvailable, ut as PanelResizeHandle } from "./code-visibility-Bqg6aos7.js";
|
|
13
13
|
import { X as useDebouncedCallback } from "./input-DtsN7xm-.js";
|
|
14
14
|
import "./toDate-CWNNlFEX.js";
|
|
15
15
|
import "./react-dom-BTJzcVJ9.js";
|
package/package.json
CHANGED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import {
|
|
5
|
+
type ConnectionInfo,
|
|
6
|
+
getMarimoCommand,
|
|
7
|
+
getRawPrompt,
|
|
8
|
+
getTerminalCommand,
|
|
9
|
+
maskToken,
|
|
10
|
+
shellQuote,
|
|
11
|
+
} from "../pair-with-agent-commands";
|
|
12
|
+
|
|
13
|
+
const CONNECTION: ConnectionInfo = {
|
|
14
|
+
url: "http://localhost:8000",
|
|
15
|
+
sessionId: "s_ab12cd",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe("shellQuote", () => {
|
|
19
|
+
it("quotes an empty string", () => {
|
|
20
|
+
expect(shellQuote("")).toBe("''");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("leaves shell-safe values untouched", () => {
|
|
24
|
+
expect(shellQuote("http://localhost:8000")).toBe("http://localhost:8000");
|
|
25
|
+
expect(shellQuote("s_ab12cd")).toBe("s_ab12cd");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("quotes values with shell metacharacters", () => {
|
|
29
|
+
expect(shellQuote("http://host:8000?a=1&b=2")).toBe(
|
|
30
|
+
"'http://host:8000?a=1&b=2'",
|
|
31
|
+
);
|
|
32
|
+
expect(shellQuote("has space")).toBe("'has space'");
|
|
33
|
+
expect(shellQuote("$(rm -rf /)")).toBe("'$(rm -rf /)'");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("escapes embedded single quotes without breaking out", () => {
|
|
37
|
+
// Closes the quote, emits a literal ' via "'", then reopens: '"'"'
|
|
38
|
+
expect(shellQuote("a'b")).toBe(`'a'"'"'b'`);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("getMarimoCommand", () => {
|
|
43
|
+
afterEach(() => {
|
|
44
|
+
vi.unstubAllEnvs();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("uses the local checkout in dev", () => {
|
|
48
|
+
vi.stubEnv("DEV", true);
|
|
49
|
+
expect(getMarimoCommand()).toBe("uv run marimo");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("uses uvx outside of dev", () => {
|
|
53
|
+
vi.stubEnv("DEV", false);
|
|
54
|
+
expect(getMarimoCommand()).toBe("uvx marimo@latest");
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe("getTerminalCommand", () => {
|
|
59
|
+
it("includes the url and session for each agent", () => {
|
|
60
|
+
expect(getTerminalCommand("claude", CONNECTION, false)).toBe(
|
|
61
|
+
`claude "$(uv run marimo pair prompt --url http://localhost:8000 --session s_ab12cd --claude)"`,
|
|
62
|
+
);
|
|
63
|
+
expect(getTerminalCommand("codex", CONNECTION, false)).toBe(
|
|
64
|
+
`codex "$(uv run marimo pair prompt --url http://localhost:8000 --session s_ab12cd --codex)"`,
|
|
65
|
+
);
|
|
66
|
+
expect(getTerminalCommand("opencode", CONNECTION, false)).toBe(
|
|
67
|
+
`opencode --prompt "$(uv run marimo pair prompt --url http://localhost:8000 --session s_ab12cd --opencode)"`,
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("always targets the given session, not a random one", () => {
|
|
72
|
+
const command = getTerminalCommand("claude", CONNECTION, false);
|
|
73
|
+
expect(command).toContain("--session s_ab12cd");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("shell-escapes a url containing metacharacters", () => {
|
|
77
|
+
const command = getTerminalCommand(
|
|
78
|
+
"claude",
|
|
79
|
+
{ url: "http://host:8000?file=a&b", sessionId: "s_ab12cd" },
|
|
80
|
+
false,
|
|
81
|
+
);
|
|
82
|
+
expect(command).toContain("--url 'http://host:8000?file=a&b'");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("adds --with-token before the agent flag when requested", () => {
|
|
86
|
+
const command = getTerminalCommand("claude", CONNECTION, true);
|
|
87
|
+
expect(command).toContain("--with-token --claude");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("omits --with-token when not requested", () => {
|
|
91
|
+
expect(getTerminalCommand("claude", CONNECTION, false)).not.toContain(
|
|
92
|
+
"--with-token",
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe("getRawPrompt", () => {
|
|
98
|
+
it("references the session-scoped execute-code command", () => {
|
|
99
|
+
const prompt = getRawPrompt(CONNECTION, null);
|
|
100
|
+
expect(prompt).toContain(
|
|
101
|
+
"execute-code.sh --url http://localhost:8000 --session s_ab12cd",
|
|
102
|
+
);
|
|
103
|
+
expect(prompt).toContain(
|
|
104
|
+
"Connect to the notebook at: http://localhost:8000 (session s_ab12cd)",
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("omits the token hint when there is no token", () => {
|
|
109
|
+
const prompt = getRawPrompt(CONNECTION, null);
|
|
110
|
+
expect(prompt).not.toContain("--token");
|
|
111
|
+
expect(prompt).not.toContain("auth token");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("includes a session-scoped token hint when a token is present", () => {
|
|
115
|
+
const prompt = getRawPrompt(CONNECTION, "secret-token");
|
|
116
|
+
expect(prompt).toContain(
|
|
117
|
+
"execute-code.sh --url http://localhost:8000 --session s_ab12cd --token secret-token",
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("shell-escapes a token containing a single quote", () => {
|
|
122
|
+
const prompt = getRawPrompt(CONNECTION, "tok'en");
|
|
123
|
+
expect(prompt).toContain(`--token 'tok'"'"'en'`);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("matches the CLI prompt shape", () => {
|
|
127
|
+
const prompt = getRawPrompt(CONNECTION, null);
|
|
128
|
+
expect(prompt).toMatchInlineSnapshot(`
|
|
129
|
+
"Use the /marimo-pair skill to pair-program on a running marimo notebook.
|
|
130
|
+
|
|
131
|
+
Connect to the notebook at: http://localhost:8000 (session s_ab12cd)
|
|
132
|
+
|
|
133
|
+
Use \`execute-code.sh --url http://localhost:8000 --session s_ab12cd\` from the marimo-pair skill to execute code in the notebook.
|
|
134
|
+
|
|
135
|
+
Once you are connected, send a fun toast (mo.status.toast(...)) to the user inside marimo letting them know you're ready to pair."
|
|
136
|
+
`);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe("maskToken", () => {
|
|
141
|
+
it("masks short tokens entirely", () => {
|
|
142
|
+
expect(maskToken("ab")).toBe("****");
|
|
143
|
+
expect(maskToken("abcd")).toBe("****");
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("reveals only the last four characters", () => {
|
|
147
|
+
expect(maskToken("abcdefgh")).toBe("****efgh");
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("caps the number of mask characters at eight", () => {
|
|
151
|
+
expect(maskToken("0123456789abcdef")).toBe("********cdef");
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { assertNever } from "@/utils/assertNever";
|
|
4
|
+
|
|
5
|
+
export type AgentTab = "claude" | "codex" | "opencode" | "prompt";
|
|
6
|
+
|
|
7
|
+
export const TERMINAL_TABS = ["claude", "codex", "opencode"] as const;
|
|
8
|
+
|
|
9
|
+
export const AGENT_TABS = ["claude", "codex", "opencode", "prompt"] as const;
|
|
10
|
+
|
|
11
|
+
export const AGENT_LABELS: Record<AgentTab, string> = {
|
|
12
|
+
claude: "Claude",
|
|
13
|
+
codex: "Codex",
|
|
14
|
+
opencode: "OpenCode",
|
|
15
|
+
prompt: "Prompt",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const SKILL_INSTALL = "npx skills add marimo-team/marimo-pair";
|
|
19
|
+
|
|
20
|
+
/** How to invoke marimo: from the local checkout in dev, else via uvx. */
|
|
21
|
+
export function getMarimoCommand(): string {
|
|
22
|
+
return import.meta.env.DEV ? "uv run marimo" : "uvx marimo@latest";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* POSIX-quote a value for safe embedding in a shell command. These commands are
|
|
27
|
+
* meant to be copied into a terminal, so a url/token containing shell
|
|
28
|
+
* metacharacters (`'`, `&`, `$(...)`, ...) must not break out of its argument.
|
|
29
|
+
*
|
|
30
|
+
* Mirrors Python's `shlex.quote` (used on the CLI side in
|
|
31
|
+
* `marimo/_cli/pair/commands.py`) so both sides produce identical commands:
|
|
32
|
+
* values that are already shell-safe are left as-is for readability, and
|
|
33
|
+
* anything else is single-quoted with embedded quotes escaped as `'"'"'`.
|
|
34
|
+
*/
|
|
35
|
+
export function shellQuote(value: string): string {
|
|
36
|
+
if (value === "") {
|
|
37
|
+
return "''";
|
|
38
|
+
}
|
|
39
|
+
// Same "safe" character set as CPython's shlex.quote (ASCII \w plus a few).
|
|
40
|
+
if (/^[\w@%+=:,./-]+$/.test(value)) {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Identifies the specific running notebook to pair on. */
|
|
47
|
+
export interface ConnectionInfo {
|
|
48
|
+
url: string;
|
|
49
|
+
/**
|
|
50
|
+
* The current session id, so agents connect to *this* notebook rather than
|
|
51
|
+
* guessing when multiple sessions are open on the same server.
|
|
52
|
+
*/
|
|
53
|
+
sessionId: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The shell command that wraps an agent CLI, delegating prompt generation to
|
|
58
|
+
* `marimo pair prompt` so the terminal and CLI stay in sync.
|
|
59
|
+
*/
|
|
60
|
+
export function getTerminalCommand(
|
|
61
|
+
agent: Exclude<AgentTab, "prompt">,
|
|
62
|
+
{ url, sessionId }: ConnectionInfo,
|
|
63
|
+
withToken: boolean,
|
|
64
|
+
): string {
|
|
65
|
+
const tokenFlag = withToken ? " --with-token" : "";
|
|
66
|
+
const base = `${getMarimoCommand()} pair prompt --url ${shellQuote(url)} --session ${shellQuote(sessionId)}${tokenFlag}`;
|
|
67
|
+
switch (agent) {
|
|
68
|
+
case "claude":
|
|
69
|
+
return `claude "$(${base} --claude)"`;
|
|
70
|
+
case "codex":
|
|
71
|
+
return `codex "$(${base} --codex)"`;
|
|
72
|
+
case "opencode":
|
|
73
|
+
return `opencode --prompt "$(${base} --opencode)"`;
|
|
74
|
+
default:
|
|
75
|
+
assertNever(agent);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The raw prompt for the "Prompt" tab. Mirrors the output of
|
|
81
|
+
* `marimo pair prompt` (see `marimo/_cli/pair/commands.py`) so pasting it into
|
|
82
|
+
* an agent behaves the same as the terminal commands.
|
|
83
|
+
*/
|
|
84
|
+
export function getRawPrompt(
|
|
85
|
+
{ url, sessionId }: ConnectionInfo,
|
|
86
|
+
token: string | null,
|
|
87
|
+
): string {
|
|
88
|
+
const executeCmd = `execute-code.sh --url ${shellQuote(url)} --session ${shellQuote(sessionId)}`;
|
|
89
|
+
const tokenHint = token
|
|
90
|
+
? `\n\nUse this auth token when calling \`execute-code.sh\`: \`${executeCmd} --token ${shellQuote(token)}\`.`
|
|
91
|
+
: "";
|
|
92
|
+
return [
|
|
93
|
+
"Use the /marimo-pair skill to pair-program on a running marimo notebook.",
|
|
94
|
+
"",
|
|
95
|
+
`Connect to the notebook at: ${url} (session ${sessionId})`,
|
|
96
|
+
"",
|
|
97
|
+
`Use \`${executeCmd}\` from the marimo-pair skill to execute code in the notebook.${tokenHint}`,
|
|
98
|
+
"",
|
|
99
|
+
"Once you are connected, send a fun toast (mo.status.toast(...)) to the user inside marimo letting them know you're ready to pair.",
|
|
100
|
+
].join("\n");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Mask all but the last 4 chars of a token for display. */
|
|
104
|
+
export function maskToken(token: string): string {
|
|
105
|
+
if (token.length <= 4) {
|
|
106
|
+
return "****";
|
|
107
|
+
}
|
|
108
|
+
return `${"*".repeat(Math.min(token.length - 4, 8))}${token.slice(-4)}`;
|
|
109
|
+
}
|
|
@@ -14,67 +14,20 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
|
|
14
14
|
import { copyToClipboard } from "@/utils/copy";
|
|
15
15
|
import { Events } from "@/utils/events";
|
|
16
16
|
import { Tooltip } from "@/components/ui/tooltip";
|
|
17
|
-
import { assertNever } from "@/utils/assertNever";
|
|
18
17
|
import { asRemoteURL, useRuntimeManager } from "@/core/runtime/config";
|
|
19
18
|
import { API } from "@/core/network/api";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
withToken: boolean,
|
|
33
|
-
): string {
|
|
34
|
-
const tokenFlag = withToken ? " --with-token" : "";
|
|
35
|
-
const base = `${getMarimoCommand()} pair prompt --url '${url}'${tokenFlag}`;
|
|
36
|
-
switch (agent) {
|
|
37
|
-
case "claude":
|
|
38
|
-
return `claude "$(${base} --claude)"`;
|
|
39
|
-
case "codex":
|
|
40
|
-
return `codex "$(${base} --codex)"`;
|
|
41
|
-
case "opencode":
|
|
42
|
-
return `opencode --prompt "$(${base} --opencode)"`;
|
|
43
|
-
default:
|
|
44
|
-
assertNever(agent);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function getRawPrompt(url: string, token: string | null): string {
|
|
49
|
-
const tokenHint = token
|
|
50
|
-
? `\n\nUse this auth token when calling \`execute-code.sh\`: \`execute-code.sh --url '${url}' --token '${token}'\`.`
|
|
51
|
-
: "";
|
|
52
|
-
return [
|
|
53
|
-
"Use the /marimo-pair skill to pair-program on a running marimo notebook.",
|
|
54
|
-
"",
|
|
55
|
-
`Connect to the notebook at: ${url}`,
|
|
56
|
-
"",
|
|
57
|
-
`Use \`execute-code.sh --url ${url}\` from the marimo-pair skill to execute code in the notebook.${tokenHint}`,
|
|
58
|
-
"",
|
|
59
|
-
"Once you are connected, send a fun toast (mo.status.toast(...)) to the user inside marimo letting them know you're ready to pair.",
|
|
60
|
-
].join("\n");
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function maskToken(token: string): string {
|
|
64
|
-
if (token.length <= 4) {
|
|
65
|
-
return "****";
|
|
66
|
-
}
|
|
67
|
-
return `${"*".repeat(Math.min(token.length - 4, 8))}${token.slice(-4)}`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const SKILL_INSTALL = "npx skills add marimo-team/marimo-pair";
|
|
71
|
-
|
|
72
|
-
const AGENT_LABELS: Record<AgentTab, string> = {
|
|
73
|
-
claude: "Claude",
|
|
74
|
-
codex: "Codex",
|
|
75
|
-
opencode: "OpenCode",
|
|
76
|
-
prompt: "Prompt",
|
|
77
|
-
};
|
|
19
|
+
import { getSessionId } from "@/core/kernel/session";
|
|
20
|
+
import {
|
|
21
|
+
AGENT_LABELS,
|
|
22
|
+
AGENT_TABS,
|
|
23
|
+
type AgentTab,
|
|
24
|
+
type ConnectionInfo,
|
|
25
|
+
getRawPrompt,
|
|
26
|
+
getTerminalCommand,
|
|
27
|
+
maskToken,
|
|
28
|
+
SKILL_INSTALL,
|
|
29
|
+
TERMINAL_TABS,
|
|
30
|
+
} from "./pair-with-agent-commands";
|
|
78
31
|
|
|
79
32
|
function useAuthToken(): string | null {
|
|
80
33
|
const [token, setToken] = useState<string | null>(null);
|
|
@@ -98,7 +51,10 @@ export const PairWithAgentModal: React.FC<{
|
|
|
98
51
|
const runtimeManager = useRuntimeManager();
|
|
99
52
|
const authToken = useAuthToken();
|
|
100
53
|
const hasToken = Boolean(authToken);
|
|
101
|
-
const
|
|
54
|
+
const connection: ConnectionInfo = {
|
|
55
|
+
url: runtimeManager.httpURL.toString(),
|
|
56
|
+
sessionId: getSessionId(),
|
|
57
|
+
};
|
|
102
58
|
|
|
103
59
|
return (
|
|
104
60
|
<DialogContent className="sm:max-w-2xl">
|
|
@@ -125,7 +81,7 @@ export const PairWithAgentModal: React.FC<{
|
|
|
125
81
|
onValueChange={(v) => setActiveTab(v as AgentTab)}
|
|
126
82
|
>
|
|
127
83
|
<TabsList className="w-full">
|
|
128
|
-
{
|
|
84
|
+
{AGENT_TABS.map((tab) => (
|
|
129
85
|
<TabsTrigger key={tab} value={tab} className="flex-1">
|
|
130
86
|
{AGENT_LABELS[tab]}
|
|
131
87
|
</TabsTrigger>
|
|
@@ -147,7 +103,7 @@ export const PairWithAgentModal: React.FC<{
|
|
|
147
103
|
</Step>
|
|
148
104
|
<Step index={2} title="Run in your terminal">
|
|
149
105
|
<CommandBlock
|
|
150
|
-
command={getTerminalCommand(tab,
|
|
106
|
+
command={getTerminalCommand(tab, connection, hasToken)}
|
|
151
107
|
/>
|
|
152
108
|
</Step>
|
|
153
109
|
{hasToken && authToken && (
|
|
@@ -179,9 +135,9 @@ export const PairWithAgentModal: React.FC<{
|
|
|
179
135
|
}
|
|
180
136
|
>
|
|
181
137
|
<CommandBlock
|
|
182
|
-
command={getRawPrompt(
|
|
138
|
+
command={getRawPrompt(connection, authToken)}
|
|
183
139
|
display={getRawPrompt(
|
|
184
|
-
|
|
140
|
+
connection,
|
|
185
141
|
authToken ? maskToken(authToken) : null,
|
|
186
142
|
)}
|
|
187
143
|
multiline={true}
|