@astrosheep/square 0.3.90 → 0.3.92

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.
Files changed (45) hide show
  1. package/dist/cli/context.js +2 -1
  2. package/dist/cli/maintenance-commands.js +5 -2
  3. package/dist/codex-address.d.ts +3 -0
  4. package/dist/codex-address.js +8 -0
  5. package/dist/codex-boundary-state.d.ts +6 -8
  6. package/dist/codex-boundary-state.js +8 -85
  7. package/dist/codex-hook.d.ts +1 -3
  8. package/dist/codex-hook.js +20 -76
  9. package/dist/codex-queue.d.ts +5 -17
  10. package/dist/codex-queue.js +21 -64
  11. package/dist/file-lock.d.ts +1 -17
  12. package/dist/file-lock.js +1 -64
  13. package/dist/help.js +2 -2
  14. package/dist/mcp.js +2 -1
  15. package/dist/packages/agent-delivery/src/codex-boundary.d.ts +13 -0
  16. package/dist/packages/agent-delivery/src/codex-boundary.js +75 -0
  17. package/dist/packages/agent-delivery/src/codex-cli.d.ts +10 -0
  18. package/dist/packages/agent-delivery/src/codex-cli.js +69 -0
  19. package/dist/packages/agent-delivery/src/codex-endpoint.d.ts +3 -0
  20. package/dist/packages/agent-delivery/src/codex-endpoint.js +14 -0
  21. package/dist/packages/agent-delivery/src/codex-hook.d.ts +26 -0
  22. package/dist/packages/agent-delivery/src/codex-hook.js +58 -0
  23. package/dist/packages/agent-delivery/src/codex-queue.d.ts +24 -0
  24. package/dist/packages/agent-delivery/src/codex-queue.js +58 -0
  25. package/dist/packages/agent-delivery/src/codex.d.ts +7 -0
  26. package/dist/packages/agent-delivery/src/codex.js +332 -0
  27. package/dist/packages/agent-delivery/src/errors.d.ts +1 -1
  28. package/dist/packages/agent-delivery/src/errors.js +1 -0
  29. package/dist/packages/agent-delivery/src/file-lock.d.ts +17 -0
  30. package/dist/packages/agent-delivery/src/file-lock.js +64 -0
  31. package/dist/packages/agent-delivery/src/index.d.ts +17 -3
  32. package/dist/packages/agent-delivery/src/index.js +29 -4
  33. package/dist/packages/agent-delivery/src/types.d.ts +58 -3
  34. package/dist/square-migration.d.ts +4 -0
  35. package/dist/square-migration.js +62 -51
  36. package/guides/codex-delivery.md +79 -0
  37. package/guides/migration.md +53 -27
  38. package/package.json +1 -1
  39. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  40. package/plugins/codex/.codex-plugin/plugin.json +1 -1
  41. package/plugins/codex/hooks/hooks.json +3 -0
  42. package/plugins/paseo/client/markdown.tsx +16 -38
  43. package/plugins/paseo/client/palette.ts +62 -0
  44. package/plugins/paseo/client/square-message.tsx +75 -45
  45. package/plugins/paseo/shared/message.ts +16 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "square",
3
- "version": "0.3.90",
3
+ "version": "0.3.92",
4
4
  "description": "Native Claude Code inbox delivery for Square participants",
5
5
  "types": "./types.d.ts",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "square",
3
- "version": "0.3.90",
3
+ "version": "0.3.92",
4
4
  "description": "Shared Square activity with reliable participant attention at Codex boundaries.",
5
5
  "author": {
6
6
  "name": "Square"
@@ -9,6 +9,9 @@
9
9
  "SessionEnd": [
10
10
  { "hooks": [{ "type": "command", "command": "square codex-hook", "timeout": 3 }] }
11
11
  ],
12
+ "UserPromptSubmit": [
13
+ { "hooks": [{ "type": "command", "command": "square codex-hook", "timeout": 5 }] }
14
+ ],
12
15
  "PostToolUse": [
13
16
  {
14
17
  "hooks": [
@@ -1,10 +1,7 @@
1
1
  import { useMemo, type ReactNode } from "react";
2
- import { Platform, Text, View, type TextStyle } from "react-native";
2
+ import { Platform, Text, View, type TextStyle, type ViewStyle } from "react-native";
3
3
  import type { PluginTheme } from "@getpaseo/plugin";
4
4
  import { Lexer, lexer, type Token, type Tokens } from "marked";
5
- import { parseSquareBlocks } from "../shared/message.ts";
6
-
7
- export { parseSquareBlocks };
8
5
 
9
6
  export const MONO = Platform.select({ ios: "Menlo", android: "monospace", default: "ui-monospace, Menlo, monospace" });
10
7
 
@@ -12,30 +9,21 @@ function makeStyles(colors: PluginTheme["colors"]) {
12
9
  return {
13
10
  block: { gap: 6 },
14
11
  text: { color: colors.foreground, fontSize: 13, lineHeight: 19 },
15
- strong: { fontWeight: "700" as const },
16
- em: { fontStyle: "italic" as const },
17
- del: { textDecorationLine: "line-through" as const },
12
+ strong: { fontWeight: "500" as const, color: colors.foreground },
13
+ em: { color: colors.foregroundMuted, fontStyle: "italic" as const },
14
+ del: { color: colors.foregroundMuted, textDecorationLine: "line-through" as const },
18
15
  link: { color: colors.accent, textDecorationLine: "underline" as const },
19
- inlineCode: { fontFamily: MONO, fontSize: 12, backgroundColor: colors.surface2, color: colors.foreground },
20
- codeBlock: {
21
- backgroundColor: colors.surface0,
22
- borderRadius: 8,
23
- borderWidth: 1,
24
- borderColor: colors.border,
25
- paddingHorizontal: 9,
26
- paddingVertical: 7,
27
- },
28
- codeText: { fontFamily: MONO, fontSize: 11.5, lineHeight: 17, color: colors.foreground },
16
+ inlineCode: { fontFamily: MONO },
17
+ codeBlock: { backgroundColor: colors.surface0, borderRadius: 4, paddingHorizontal: 8, paddingVertical: 6 },
18
+ codeText: { fontFamily: MONO, fontSize: 13, lineHeight: 19, color: colors.foreground },
29
19
  quote: { borderLeftWidth: 2, borderLeftColor: colors.border, paddingLeft: 8, gap: 2 },
30
20
  quoteText: { color: colors.foregroundMuted, fontStyle: "italic" as const },
31
- meta: { color: colors.foregroundMuted, fontSize: 11, lineHeight: 15, fontFamily: MONO },
32
- actor: { color: colors.accent, fontSize: 12, lineHeight: 17 },
33
21
  separator: { height: 1, backgroundColor: colors.border, marginVertical: 4 },
34
22
  listRow: { flexDirection: "row" as const, gap: 6 },
35
23
  listItem: { flexShrink: 1, gap: 2 },
36
- bullet: { color: colors.accent, fontSize: 13, lineHeight: 19 },
24
+ bullet: { color: colors.foregroundMuted, fontSize: 13, lineHeight: 19 },
37
25
  tableRow: { flexDirection: "row" as const, gap: 8 },
38
- tableCell: { flex: 1, fontSize: 12 },
26
+ tableCell: { flex: 1 },
39
27
  };
40
28
  }
41
29
 
@@ -55,7 +43,7 @@ function renderInlines(tokens: Token[], styles: Styles, prefix: string, extra?:
55
43
  case "em": return nested(styles.em);
56
44
  case "del": return nested(styles.del);
57
45
  case "link": return nested(styles.link);
58
- case "codespan": return <Text key={key} style={[styles.text, extra, styles.inlineCode]}>{` ${token.text} `}</Text>;
46
+ case "codespan": return <Text key={key} style={[styles.text, extra, styles.inlineCode]}>{token.text}</Text>;
59
47
  case "br": return "\n";
60
48
  case "image": return token.text;
61
49
  default: {
@@ -86,7 +74,7 @@ function renderBlocks(tokens: Token[], styles: Styles, prefix: string, textStyle
86
74
  );
87
75
  case "heading":
88
76
  return (
89
- <Text key={key} style={[styles.text, textStyle, styles.strong, { fontSize: Math.max(13, 18 - token.depth) }]}>
77
+ <Text key={key} style={[styles.text, textStyle, styles.strong]}>
90
78
  {renderInlines(children(token), styles, key)}
91
79
  </Text>
92
80
  );
@@ -100,7 +88,7 @@ function renderBlocks(tokens: Token[], styles: Styles, prefix: string, textStyle
100
88
  {list.items.map((item, itemIndex) => (
101
89
  <View key={`${key}-${itemIndex}`} style={styles.listRow}>
102
90
  <Text style={styles.bullet}>
103
- {item.task ? (item.checked === true ? "☑" : "☐") : list.ordered ? `${start + itemIndex}.` : "•"}
91
+ {item.task ? (item.checked === true ? "☑" : "☐") : list.ordered ? `${start + itemIndex}.` : "·"}
104
92
  </Text>
105
93
  <View style={styles.listItem}>{renderBlocks(children(item), styles, `${key}-${itemIndex}`, textStyle)}</View>
106
94
  </View>
@@ -153,19 +141,9 @@ export function SquareInline({ text, theme, numberOfLines, style }: {
153
141
  );
154
142
  }
155
143
 
156
- export function SquareMarkdown({ text, theme }: { text: string; theme: PluginTheme }) {
144
+ /** A body of Markdown: no envelope, no route line — the words only, indented by the card. */
145
+ export function SquareMarkdownBody({ text, theme, style }: { text: string; theme: PluginTheme; style?: ViewStyle }) {
157
146
  const styles = useMemo(() => makeStyles(theme.colors), [theme.colors]);
158
- const blocks = useMemo(() => parseSquareBlocks(text), [text]);
159
- return (
160
- <View style={styles.block}>
161
- {blocks.map((block, index) => (
162
- <View key={index} style={styles.block}>
163
- {index > 0 && <View style={styles.separator} />}
164
- {block.meta !== undefined && <Text style={styles.meta}>{block.meta}</Text>}
165
- {block.actor !== undefined && <Text style={styles.actor}>{block.actor}</Text>}
166
- {renderBlocks(lexer(block.body), styles, `${index}`)}
167
- </View>
168
- ))}
169
- </View>
170
- );
147
+ const tokens = useMemo(() => lexer(text), [text]);
148
+ return <View style={[styles.block, style]}>{renderBlocks(tokens, styles, "body")}</View>;
171
149
  }
@@ -0,0 +1,62 @@
1
+ import type { PluginTheme } from "@getpaseo/plugin";
2
+
3
+ /**
4
+ * Square's own courtyard palette: cool pewter slate and a cold blue voice,
5
+ * deliberately no relative of notesoup's warm parchment or pi-meantime's
6
+ * neutral carbon. Every token here is opaque and self-contained — the card and
7
+ * Markdown never borrow the host's surface ramp or accent, only its appearance
8
+ * (read from the host ink) and its accentForeground, which paints text on top
9
+ * of an accent fill.
10
+ */
11
+ const DARK = {
12
+ surface0: "#121519", // inset / code
13
+ surface1: "#171b20", // card
14
+ surface2: "#121519", // inset / code
15
+ border: "#262d36",
16
+ foreground: "#e6ebf2",
17
+ foregroundMuted: "#7d8999",
18
+ accent: "#60a5fa", // plaza ■ / links
19
+ } as const;
20
+
21
+ const LIGHT = {
22
+ surface0: "#e8edf3",
23
+ surface1: "#f3f6fa", // pewter slate, not notesoup's warm parchment
24
+ surface2: "#e8edf3",
25
+ border: "#d5dee8",
26
+ foreground: "#141b24",
27
+ foregroundMuted: "#64748b",
28
+ accent: "#2563eb",
29
+ } as const;
30
+
31
+ const VOICE = { dark: "#93c5fd", light: "#3b82f6" } as const;
32
+
33
+ export interface SquarePalette {
34
+ /** Complete theme for the card and its Markdown surfaces. */
35
+ theme: PluginTheme;
36
+ /** The filled ● speaker dot; the hollow ○ keeps the muted ink instead. */
37
+ voice: string;
38
+ }
39
+
40
+ /** Paseo theme colors are hex (#RGB or #RRGGBB). */
41
+ function brightness(hex: string): number {
42
+ const rgb = hex.length === 4 ? hex.slice(1).replace(/./g, digit => digit + digit) : hex.slice(1, 7);
43
+ return 0.299 * parseInt(rgb.slice(0, 2), 16)
44
+ + 0.587 * parseInt(rgb.slice(2, 4), 16)
45
+ + 0.114 * parseInt(rgb.slice(4, 6), 16);
46
+ }
47
+
48
+ export function squarePalette(theme: PluginTheme): SquarePalette {
49
+ // The SDK exposes colors, not appearance. Use the host theme, never the OS color scheme.
50
+ const dark = brightness(theme.colors.foreground) > brightness(theme.colors.surface0);
51
+ const palette = dark ? DARK : LIGHT;
52
+ return {
53
+ theme: { colors: {
54
+ ...palette,
55
+ accentForeground: theme.colors.accentForeground,
56
+ statusSuccess: theme.colors.statusSuccess,
57
+ statusWarning: theme.colors.statusWarning,
58
+ statusDanger: theme.colors.statusDanger,
59
+ } },
60
+ voice: dark ? VOICE.dark : VOICE.light,
61
+ };
62
+ }
@@ -1,69 +1,99 @@
1
1
  import type { PluginTimelineItemProps } from "@getpaseo/plugin/client";
2
2
  import { Icon } from "@getpaseo/plugin/client/react-native";
3
3
  import { useMemo, useState } from "react";
4
- import { Pressable, ScrollView, Text, View } from "react-native";
5
- import { outputPreview, squareHeadline, type SquareMessageData } from "../shared/message";
6
- import { SquareInline, SquareMarkdown } from "./markdown";
4
+ import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
5
+ import { parseSquareBlocks, parseSquareVoice, type SquareMessageData } from "../shared/message";
6
+ import { MONO, SquareInline, SquareMarkdownBody } from "./markdown";
7
+ import { squarePalette } from "./palette";
7
8
 
8
- /** A plain card: who, what they did, where, then what they said. No badge, no chrome — the words carry the place. */
9
+ /**
10
+ * The accent ■ marks the square itself, not a route.
11
+ * Collapsed: ■ who spoke · where · how many, then two preview lines.
12
+ * Expanded: the same header, then the bodies indented under it. Several voices
13
+ * become a stage script: each speaker holds a fixed left column, their words
14
+ * run down a single ruled dialogue column. No narration.
15
+ */
9
16
  export function SquareMessage({ item, theme, layout }: PluginTimelineItemProps<SquareMessageData>) {
10
17
  const [expanded, setExpanded] = useState(false);
18
+ const palette = useMemo(() => squarePalette(theme), [theme]);
11
19
  const { text, items } = item.data;
12
20
  const latest = items?.[items.length - 1];
13
- // Transform already bounded the collapsed preview; only normalise whitespace for the single line.
14
21
  const preview = latest?.preview?.replace(/\s+/g, " ").trim();
15
- const muted = theme.colors.foregroundMuted;
16
- const foreground = theme.colors.foreground;
17
-
18
- const styles = useMemo(() => ({
19
- card: {
20
- marginVertical: 3,
21
- marginRight: layout.compact ? 0 : 8,
22
- backgroundColor: theme.colors.surface1,
23
- borderWidth: 1,
24
- borderColor: theme.colors.border,
25
- borderRadius: 6,
26
- paddingHorizontal: 12,
27
- paddingVertical: 8,
28
- gap: 4,
29
- },
30
- whoRow: { flexDirection: "row" as const, alignItems: "center" as const, gap: 6 },
31
- glyph: { color: theme.colors.accent, fontSize: 9 },
32
- actor: { color: foreground, fontSize: 12.5, fontWeight: "600" as const },
33
- route: { color: muted, fontSize: 12.5, flex: 1 },
34
- count: { color: muted, fontSize: 11 },
35
- }), [foreground, layout.compact, muted, theme.colors.accent, theme.colors.border, theme.colors.surface1]);
36
-
37
- const headline = latest !== undefined ? squareHeadline(latest) : "Square context";
38
- const routeText = latest?.actor !== undefined && headline.startsWith(latest.actor)
39
- ? headline.slice(latest.actor.length).trim()
40
- : headline;
22
+ const blocks = useMemo(() => parseSquareBlocks(text), [text]);
23
+ const multi = blocks.length > 1;
24
+ const single = multi ? undefined : parseSquareVoice(blocks[0].actor, blocks[0].meta);
25
+ const names = items !== undefined
26
+ ? items.map(entry => entry.actor)
27
+ : blocks.map(block => parseSquareVoice(block.actor, block.meta).speaker);
28
+ const speakers = [...new Set(names.filter((name): name is string => name !== undefined))];
29
+ const squareName = latest?.square ?? blocks[0].meta?.split("·")[1]?.trim() ?? "Square";
30
+ const bell = latest?.route === "bell" || single?.bell === true;
31
+ const trailing = `· ${squareName}${expanded && single?.actId ? ` · ${single.actId}` : !expanded && items && items.length > 1 ? ` · ${items.length}` : ""}`;
32
+ const { accent, border, foreground, foregroundMuted: muted, surface1 } = palette.theme.colors;
33
+ const row = { flexDirection: "row" as const, alignItems: "center" as const, gap: 6 };
34
+ const indent = { paddingLeft: 15 };
41
35
 
42
36
  return (
43
- <View style={styles.card}>
37
+ <View style={{ backgroundColor: surface1, borderWidth: StyleSheet.hairlineWidth, borderColor: border, borderRadius: 8, paddingHorizontal: 12, paddingVertical: 9, gap: expanded ? 8 : 3 }}>
44
38
  <Pressable
45
39
  accessibilityRole="button"
46
- accessibilityLabel={`${expanded ? "收起" : "展开"} ${latest?.square ?? "square"}: ${headline}`}
40
+ accessibilityLabel={`${expanded ? "收起" : "展开"} ${squareName}: ${speakers.join(", ") || "Square"}`}
47
41
  aria-expanded={expanded}
48
42
  onPress={() => setExpanded(value => !value)}
49
- style={({ pressed }) => ({ gap: 4, opacity: pressed ? 0.7 : 1 })}
43
+ style={({ pressed }) => ({ gap: 3, opacity: pressed ? 0.7 : 1 })}
50
44
  >
51
- <View style={styles.whoRow}>
52
- <Text style={styles.glyph}>■</Text>
53
- {latest?.actor !== undefined && <Text style={styles.actor}>{latest.actor}</Text>}
54
- <Text numberOfLines={1} style={styles.route}>
55
- {routeText}{latest?.square !== undefined && ` · ${latest.square}`}
56
- </Text>
57
- {items !== undefined && items.length > 1 && <Text style={styles.count}>{items.length}</Text>}
58
- <Icon name={expanded ? "ChevronUp" : "ChevronDown"} size={16} color={muted} />
45
+ <View style={expanded && multi
46
+ ? { ...row, paddingBottom: 7, borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: border }
47
+ : row}>
48
+ <Text style={{ color: accent, fontSize: 9 }}>■</Text>
49
+ {expanded && multi ? (
50
+ <>
51
+ <Text numberOfLines={1} style={{ color: foreground, fontSize: 12.5, fontWeight: "500", flex: 1 }}>{squareName}</Text>
52
+ <Icon name="ChevronUp" size={15} color={muted} />
53
+ </>
54
+ ) : (
55
+ <>
56
+ <Text numberOfLines={1} style={{ color: foreground, fontSize: 13, fontWeight: "500", flex: 1 }}>
57
+ {speakers.join(", ") || "Square"}
58
+ {bell && <Text style={{ color: muted, fontWeight: "400" }}> · rang the bell</Text>}
59
+ </Text>
60
+ <Text style={{ color: muted, fontSize: 12 }}>{trailing}</Text>
61
+ <Icon name={expanded ? "ChevronUp" : "ChevronDown"} size={15} color={muted} />
62
+ </>
63
+ )}
59
64
  </View>
60
65
  {!expanded && preview !== undefined && preview !== "" && (
61
- <SquareInline text={preview} theme={theme} numberOfLines={2} />
66
+ <View style={indent}>
67
+ <SquareInline text={preview} theme={palette.theme} numberOfLines={2} />
68
+ </View>
62
69
  )}
63
70
  </Pressable>
64
71
  {expanded && (
65
- <ScrollView style={{ maxHeight: layout.compact ? 280 : 400, marginTop: 2, borderTopWidth: 1, borderTopColor: theme.colors.border }} contentContainerStyle={{ paddingTop: 8 }} nestedScrollEnabled>
66
- <SquareMarkdown text={outputPreview(text)} theme={theme} />
72
+ <ScrollView style={{ maxHeight: layout.compact ? 280 : 400 }} nestedScrollEnabled>
73
+ {multi ? (
74
+ <View style={{ gap: 10 }}>
75
+ {blocks.map((block, index) => {
76
+ const voice = parseSquareVoice(block.actor, block.meta);
77
+ const detail = [voice.bell ? "bell" : undefined, voice.actId].filter(Boolean).join(" · ");
78
+ return (
79
+ <View key={voice.actId ?? index} style={{ flexDirection: "row", alignItems: "flex-start", gap: 10 }}>
80
+ <View style={{ width: 62, paddingTop: 1, gap: 1 }}>
81
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 5 }}>
82
+ <Text style={{ fontSize: 8.5, color: voice.glyph === "○" ? muted : palette.voice }}>{voice.glyph}</Text>
83
+ {voice.speaker && <Text numberOfLines={1} style={{ color: foreground, fontSize: 12.5, fontWeight: "500", flexShrink: 1 }}>{voice.speaker}</Text>}
84
+ </View>
85
+ {(voice.bell || voice.actId) && <Text numberOfLines={1} style={{ color: muted, fontSize: 10.5, fontFamily: MONO, paddingLeft: 13 }}>{detail}</Text>}
86
+ </View>
87
+ <View style={{ flex: 1, borderLeftWidth: StyleSheet.hairlineWidth, borderLeftColor: border, paddingLeft: 10 }}>
88
+ <SquareMarkdownBody text={block.body} theme={palette.theme} />
89
+ </View>
90
+ </View>
91
+ );
92
+ })}
93
+ </View>
94
+ ) : (
95
+ <SquareMarkdownBody text={blocks[0].body} theme={palette.theme} style={indent} />
96
+ )}
67
97
  </ScrollView>
68
98
  )}
69
99
  </View>
@@ -50,6 +50,21 @@ export function parseSquareBlocks(text: string): SquareBlock[] {
50
50
  return blocks;
51
51
  }
52
52
 
53
+ export interface SquareVoice { glyph: string; speaker?: string; bell: boolean; actId?: string }
54
+
55
+ // A voice line is chrome for the card: `● rei rang the bell` names who, how, and which
56
+ // activity. Route prose is parsed into those marks, never rendered as narration.
57
+ export function parseSquareVoice(actorLine?: string, metaLine?: string): SquareVoice {
58
+ const line = actorLine?.trim() ?? "";
59
+ const cleaned = line.replace(/^[●○◎◆■·]\s*/, "").trim();
60
+ return {
61
+ glyph: /^[●○◎·]/.exec(line)?.[0] ?? "●",
62
+ speaker: /\S+/.exec(cleaned)?.[0],
63
+ bell: /rang the bell/i.test(cleaned),
64
+ actId: /act\/\d+/.exec(metaLine ?? "")?.[0],
65
+ };
66
+ }
67
+
53
68
  export const squareCardDetailsSchema = z.object({
54
69
  fullText: z.string().optional(),
55
70
  items: z.array(z.object({
@@ -62,7 +77,7 @@ export const squareCardDetailsSchema = z.object({
62
77
  })).min(1),
63
78
  });
64
79
 
65
- /** Human-facing summary; the stored description is Square's agent voice, and the human is not the recipient. */
80
+ /** Human-facing summary of a route; the card itself leads with people, not this prose. */
66
81
  export function squareHeadline(item: z.output<typeof squareCardDetailsSchema>["items"][number]): string {
67
82
  if (item.actor === undefined || item.route === undefined) return item.description;
68
83
  const to = item.recipient;