@agimon-ai/po-edit 0.0.0-alpha.33 → 0.0.0-alpha.35

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.
@@ -97,7 +97,6 @@ function DiffRows({ rows, gutter, path }) {
97
97
  */
98
98
  function EditToolMessage({ args, result, output, running, isError, fileTabFor, openTransientTab }) {
99
99
  const call = editCallView(args);
100
- const view = result === null || isError ? void 0 : editResultView(result);
101
100
  const tab = fileTabFor(call.path);
102
101
  return /* @__PURE__ */ jsx(MessageItem, {
103
102
  tone: toolTone({
@@ -105,44 +104,47 @@ function EditToolMessage({ args, result, output, running, isError, fileTabFor, o
105
104
  isError
106
105
  }),
107
106
  expandable: true,
108
- children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
109
- title: "edit",
110
- children: /* @__PURE__ */ jsxs(View, {
111
- testID: "tool-call-edit",
112
- style: styles.summary,
113
- children: [/* @__PURE__ */ jsx(ToolPathLink, {
114
- path: call.path,
115
- ...tab === void 0 ? {} : { onOpen: () => openTransientTab(tab) }
116
- }), /* @__PURE__ */ jsxs(Text, {
117
- numberOfLines: 1,
118
- style: styles.detail,
119
- children: ["· ", call.ranges]
120
- })]
121
- })
122
- }), !expanded ? null : isError ? /* @__PURE__ */ jsxs(MessageItemBody, {
123
- testID: "tool-result-edit",
124
- children: [/* @__PURE__ */ jsx(MessageItemStatus, {
125
- tone: "error",
126
- children: "failed"
127
- }), resultTextLines(result, output).map((line, index) => /* @__PURE__ */ jsx(Text, {
128
- selectable: true,
129
- style: styles.error,
130
- children: line
131
- }, `${String(index)}-${line}`))]
132
- }) : view === void 0 ? running ? /* @__PURE__ */ jsx(MessageItemBody, {
133
- testID: "tool-result-edit",
134
- children: /* @__PURE__ */ jsx(MessageItemStatus, {
135
- tone: "running",
136
- children: "running"
137
- })
138
- }) : null : /* @__PURE__ */ jsx(MessageItemBody, {
139
- testID: "tool-result-edit",
140
- children: /* @__PURE__ */ jsx(DiffRows, {
141
- rows: view.rows,
142
- gutter: view.gutter,
143
- path: call.path
144
- })
145
- })] })
107
+ children: ({ expanded }) => {
108
+ const view = !expanded || result === null || isError ? void 0 : editResultView(result);
109
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
110
+ title: "edit",
111
+ children: /* @__PURE__ */ jsxs(View, {
112
+ testID: "tool-call-edit",
113
+ style: styles.summary,
114
+ children: [/* @__PURE__ */ jsx(ToolPathLink, {
115
+ path: call.path,
116
+ ...tab === void 0 ? {} : { onOpen: () => openTransientTab(tab) }
117
+ }), /* @__PURE__ */ jsxs(Text, {
118
+ numberOfLines: 1,
119
+ style: styles.detail,
120
+ children: ["· ", call.ranges]
121
+ })]
122
+ })
123
+ }), !expanded ? null : isError ? /* @__PURE__ */ jsxs(MessageItemBody, {
124
+ testID: "tool-result-edit",
125
+ children: [/* @__PURE__ */ jsx(MessageItemStatus, {
126
+ tone: "error",
127
+ children: "failed"
128
+ }), resultTextLines(result, output).map((line, index) => /* @__PURE__ */ jsx(Text, {
129
+ selectable: true,
130
+ style: styles.error,
131
+ children: line
132
+ }, `${String(index)}-${line}`))]
133
+ }) : view === void 0 ? running ? /* @__PURE__ */ jsx(MessageItemBody, {
134
+ testID: "tool-result-edit",
135
+ children: /* @__PURE__ */ jsx(MessageItemStatus, {
136
+ tone: "running",
137
+ children: "running"
138
+ })
139
+ }) : null : /* @__PURE__ */ jsx(MessageItemBody, {
140
+ testID: "tool-result-edit",
141
+ children: /* @__PURE__ */ jsx(DiffRows, {
142
+ rows: view.rows,
143
+ gutter: view.gutter,
144
+ path: call.path
145
+ })
146
+ })] });
147
+ }
146
148
  });
147
149
  }
148
150
  const styles = StyleSheet.create((theme) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"native.mjs","names":["ToolMessageRenderProps","fontOf","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","SyntaxLine","ToolPathLink","toolTone","useSyntaxLines","PoNativeTheme","StyleSheet","DiffMarker","DiffRow","editCallView","editResultView","resultTextLines","DiffRows","rows","gutter","path","spans","map","row","content","join","index","String","lineNumber","styles","marker","mono","padStart","ink","EditToolMessage","args","result","output","running","isError","fileTabFor","openTransientTab","call","view","undefined","tab","expanded","summary","onOpen","detail","ranges","line","error","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","flexShrink","color","colors","faint","fontFamily","sans","fontSize","base","lineHeight","red","backgroundColor","sm","lineHeightRelaxed","green","dim","toolEdit"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/editToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/EditToolMessage.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/edit.native.tsx","../../generated/native.ts"],"sourcesContent":["import type { ToolResultView } from '@agimon-ai/po-core/web';\n\n/** Pi emits `+12 text`, `-12 text`, ` 12 text`, and a blank-numbered ` ... ` elision between hunks. */\nconst DIFF_ROW_PATTERN = /^([+\\- ])( *\\d*) (.*)$/u;\nconst CONTEXT_MARKER = ' ';\n\nexport type DiffMarker = '+' | '-' | typeof CONTEXT_MARKER;\n\nexport interface DiffRow {\n readonly marker: DiffMarker;\n readonly lineNumber: string;\n readonly content: string;\n}\n\nexport interface EditCallView {\n readonly path: string;\n /** `N range` or `N ranges`, the count the TUI's call heading shows. */\n readonly ranges: string;\n}\n\nexport interface EditResultView {\n readonly rows: readonly DiffRow[];\n /** Widest line number among the rows, in characters, sizing the gutter. */\n readonly gutter: number;\n}\n\n/** What the edit call heading shows: the path and how many ranges the call touches. */\nexport function editCallView(args: Readonly<Record<string, unknown>>): EditCallView {\n const count = Array.isArray(args.edits) ? args.edits.length : 0;\n return {\n path: typeof args.path === 'string' ? args.path : '',\n ranges: `${count} ${count === 1 ? 'range' : 'ranges'}`,\n };\n}\n\nfunction toDiffMarker(value: string | undefined): DiffMarker {\n return value === '+' || value === '-' ? value : CONTEXT_MARKER;\n}\n\n/** Pi's display diff as rows; a line that is not a diff row reads as unnumbered context. */\nexport function parseDiffRows(diff: string): DiffRow[] {\n return diff.split('\\n').map((line) => {\n const expanded = line.replaceAll('\\t', ' ');\n const match = DIFF_ROW_PATTERN.exec(expanded);\n if (!match) return { marker: CONTEXT_MARKER, lineNumber: '', content: expanded };\n return { marker: toDiffMarker(match[1]), lineNumber: (match[2] ?? '').trim(), content: match[3] ?? '' };\n });\n}\n\n/** The diff a successful edit carries in its details; undefined when the details never arrived. */\nexport function editResultView(result: ToolResultView | null): EditResultView | undefined {\n const details = result?.details;\n if (typeof details !== 'object' || details === null) return undefined;\n const diff = (details as { diff?: unknown }).diff;\n if (typeof diff !== 'string' || diff.length === 0) return undefined;\n const rows = parseDiffRows(diff);\n return { rows, gutter: rows.reduce((widest, row) => Math.max(widest, row.lineNumber.length), 1) };\n}\n\n/** The result's text lines, for the error case where the diff never happened. */\nexport function resultTextLines(result: ToolResultView | null, output: string): string[] {\n const text =\n result === null\n ? output\n : result.content\n .flatMap((block) => {\n const record =\n typeof block === 'object' && block !== null ? (block as { type?: unknown; text?: unknown }) : {};\n return record.type === 'text' && typeof record.text === 'string' ? [record.text] : [];\n })\n .join('\\n');\n const lines = text.replaceAll('\\t', ' ').replaceAll('\\r\\n', '\\n').split('\\n');\n while (lines.at(-1) === '') lines.pop();\n return lines;\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/native';\nimport {\n fontOf,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n SyntaxLine,\n ToolPathLink,\n toolTone,\n useSyntaxLines,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { type DiffMarker, type DiffRow, editCallView, editResultView, resultTextLines } from '../_lib/editToolView';\n\n/**\n * The banded rows and the grammar over them, as the web's DiffRows: parsed as\n * one document, so a replaced line is seen twice and may colour oddly, and the\n * `+`/`-` wash stays underneath so what changed is still legible.\n */\nfunction DiffRows({ rows, gutter, path }: { rows: readonly DiffRow[]; gutter: number; path: string }) {\n const spans = useSyntaxLines(rows.map((row) => row.content).join('\\n'), { path });\n return (\n <View>\n {rows.map((row, index) => (\n <View key={`${String(index)}-${row.lineNumber}`} style={styles.row(row.marker)}>\n <Text style={[styles.mono, styles.gutter]}>{row.lineNumber.padStart(gutter)}</Text>\n <Text style={[styles.mono, styles.ink(row.marker)]}>{row.marker}</Text>\n <SyntaxLine\n selectable\n spans={spans?.[index]}\n text={row.content}\n style={[styles.mono, styles.content, styles.ink(row.marker)]}\n />\n </View>\n ))}\n </View>\n );\n}\n\n/**\n * The edit tool's timeline item on native, as the web's EditToolMessage:\n * `path · N ranges` in the header, the display diff banded by row in the body,\n * and the tool's message in red when the edit failed.\n */\nexport function EditToolMessage({\n args,\n result,\n output,\n running,\n isError,\n fileTabFor,\n openTransientTab,\n}: ToolMessageRenderProps) {\n const call = editCallView(args);\n const view = result === null || isError ? undefined : editResultView(result);\n const tab = fileTabFor(call.path);\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable>\n {({ expanded }) => (\n <>\n <MessageItemHeader title=\"edit\">\n <View testID=\"tool-call-edit\" style={styles.summary}>\n <ToolPathLink path={call.path} {...(tab === undefined ? {} : { onOpen: () => openTransientTab(tab) })} />\n <Text numberOfLines={1} style={styles.detail}>\n · {call.ranges}\n </Text>\n </View>\n </MessageItemHeader>\n {!expanded ? null : isError ? (\n <MessageItemBody testID=\"tool-result-edit\">\n <MessageItemStatus tone=\"error\">failed</MessageItemStatus>\n {resultTextLines(result, output).map((line, index) => (\n <Text key={`${String(index)}-${line}`} selectable style={styles.error}>\n {line}\n </Text>\n ))}\n </MessageItemBody>\n ) : view === undefined ? (\n running ? (\n <MessageItemBody testID=\"tool-result-edit\">\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : (\n <MessageItemBody testID=\"tool-result-edit\">\n <DiffRows rows={view.rows} gutter={view.gutter} path={call.path} />\n </MessageItemBody>\n )}\n </>\n )}\n </MessageItem>\n );\n}\n\n// Po carries a diff on the background the way Magit does: a green wash on\n// added rows, a red wash on removed ones, and the foreground left to the text.\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n detail: {\n flexShrink: 0,\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n error: {\n color: theme.colors.red,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n row: (marker: DiffMarker) => ({\n flexDirection: 'row',\n gap: theme.spacing(2),\n backgroundColor:\n marker === '+' ? theme.colors['tint-green'] : marker === '-' ? theme.colors['tint-red'] : undefined,\n }),\n mono: {\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n gutter: { color: theme.colors.faint },\n ink: (marker: DiffMarker) => ({\n color: marker === '+' ? theme.colors.green : marker === '-' ? theme.colors.red : theme.colors.dim,\n }),\n content: { flex: 1, minWidth: 0 },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { EditToolMessage } from './_components/EditToolMessage.native';\n\nexport default defineToolRenderer({ message: EditToolMessage });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolEdit from '../src/extensions/workspaces/sessions/(frontend)/tool/edit.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'edit',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools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C,EAAE;;;AC/HF,IAAA,sBAAe,mBAAmB,EAAE,SAAS,gBAAgB,CAAC;;;ACC9D,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,GAAGiB,mBAAQ,CAAC;CAAG,EAC9G;AACF,CAAC"}
1
+ {"version":3,"file":"native.mjs","names":["ToolMessageRenderProps","fontOf","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","SyntaxLine","ToolPathLink","toolTone","useSyntaxLines","PoNativeTheme","StyleSheet","DiffMarker","DiffRow","editCallView","editResultView","resultTextLines","DiffRows","rows","gutter","path","spans","map","row","content","join","index","String","lineNumber","styles","marker","mono","padStart","ink","EditToolMessage","args","result","output","running","isError","fileTabFor","openTransientTab","call","tab","expanded","view","undefined","summary","onOpen","detail","ranges","line","error","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","flexShrink","color","colors","faint","fontFamily","sans","fontSize","base","lineHeight","red","backgroundColor","sm","lineHeightRelaxed","green","dim","toolEdit"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/editToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/EditToolMessage.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/edit.native.tsx","../../generated/native.ts"],"sourcesContent":["import type { ToolResultView } from '@agimon-ai/po-core/web';\n\n/** Pi emits `+12 text`, `-12 text`, ` 12 text`, and a blank-numbered ` ... ` elision between hunks. */\nconst DIFF_ROW_PATTERN = /^([+\\- ])( *\\d*) (.*)$/u;\nconst CONTEXT_MARKER = ' ';\n\nexport type DiffMarker = '+' | '-' | typeof CONTEXT_MARKER;\n\nexport interface DiffRow {\n readonly marker: DiffMarker;\n readonly lineNumber: string;\n readonly content: string;\n}\n\nexport interface EditCallView {\n readonly path: string;\n /** `N range` or `N ranges`, the count the TUI's call heading shows. */\n readonly ranges: string;\n}\n\nexport interface EditResultView {\n readonly rows: readonly DiffRow[];\n /** Widest line number among the rows, in characters, sizing the gutter. */\n readonly gutter: number;\n}\n\n/** What the edit call heading shows: the path and how many ranges the call touches. */\nexport function editCallView(args: Readonly<Record<string, unknown>>): EditCallView {\n const count = Array.isArray(args.edits) ? args.edits.length : 0;\n return {\n path: typeof args.path === 'string' ? args.path : '',\n ranges: `${count} ${count === 1 ? 'range' : 'ranges'}`,\n };\n}\n\nfunction toDiffMarker(value: string | undefined): DiffMarker {\n return value === '+' || value === '-' ? value : CONTEXT_MARKER;\n}\n\n/** Pi's display diff as rows; a line that is not a diff row reads as unnumbered context. */\nexport function parseDiffRows(diff: string): DiffRow[] {\n return diff.split('\\n').map((line) => {\n const expanded = line.replaceAll('\\t', ' ');\n const match = DIFF_ROW_PATTERN.exec(expanded);\n if (!match) return { marker: CONTEXT_MARKER, lineNumber: '', content: expanded };\n return { marker: toDiffMarker(match[1]), lineNumber: (match[2] ?? '').trim(), content: match[3] ?? '' };\n });\n}\n\n/** The diff a successful edit carries in its details; undefined when the details never arrived. */\nexport function editResultView(result: ToolResultView | null): EditResultView | undefined {\n const details = result?.details;\n if (typeof details !== 'object' || details === null) return undefined;\n const diff = (details as { diff?: unknown }).diff;\n if (typeof diff !== 'string' || diff.length === 0) return undefined;\n const rows = parseDiffRows(diff);\n return { rows, gutter: rows.reduce((widest, row) => Math.max(widest, row.lineNumber.length), 1) };\n}\n\n/** The result's text lines, for the error case where the diff never happened. */\nexport function resultTextLines(result: ToolResultView | null, output: string): string[] {\n const text =\n result === null\n ? output\n : result.content\n .flatMap((block) => {\n const record =\n typeof block === 'object' && block !== null ? (block as { type?: unknown; text?: unknown }) : {};\n return record.type === 'text' && typeof record.text === 'string' ? [record.text] : [];\n })\n .join('\\n');\n const lines = text.replaceAll('\\t', ' ').replaceAll('\\r\\n', '\\n').split('\\n');\n while (lines.at(-1) === '') lines.pop();\n return lines;\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/native';\nimport {\n fontOf,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n SyntaxLine,\n ToolPathLink,\n toolTone,\n useSyntaxLines,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { type DiffMarker, type DiffRow, editCallView, editResultView, resultTextLines } from '../_lib/editToolView';\n\n/**\n * The banded rows and the grammar over them, as the web's DiffRows: parsed as\n * one document, so a replaced line is seen twice and may colour oddly, and the\n * `+`/`-` wash stays underneath so what changed is still legible.\n */\nfunction DiffRows({ rows, gutter, path }: { rows: readonly DiffRow[]; gutter: number; path: string }) {\n const spans = useSyntaxLines(rows.map((row) => row.content).join('\\n'), { path });\n return (\n <View>\n {rows.map((row, index) => (\n <View key={`${String(index)}-${row.lineNumber}`} style={styles.row(row.marker)}>\n <Text style={[styles.mono, styles.gutter]}>{row.lineNumber.padStart(gutter)}</Text>\n <Text style={[styles.mono, styles.ink(row.marker)]}>{row.marker}</Text>\n <SyntaxLine\n selectable\n spans={spans?.[index]}\n text={row.content}\n style={[styles.mono, styles.content, styles.ink(row.marker)]}\n />\n </View>\n ))}\n </View>\n );\n}\n\n/**\n * The edit tool's timeline item on native, as the web's EditToolMessage:\n * `path · N ranges` in the header, the display diff banded by row in the body,\n * and the tool's message in red when the edit failed.\n */\nexport function EditToolMessage({\n args,\n result,\n output,\n running,\n isError,\n fileTabFor,\n openTransientTab,\n}: ToolMessageRenderProps) {\n const call = editCallView(args);\n const tab = fileTabFor(call.path);\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable>\n {({ expanded }) => {\n const view = !expanded || result === null || isError ? undefined : editResultView(result);\n return (\n <>\n <MessageItemHeader title=\"edit\">\n <View testID=\"tool-call-edit\" style={styles.summary}>\n <ToolPathLink\n path={call.path}\n {...(tab === undefined ? {} : { onOpen: () => openTransientTab(tab) })}\n />\n <Text numberOfLines={1} style={styles.detail}>\n · {call.ranges}\n </Text>\n </View>\n </MessageItemHeader>\n {!expanded ? null : isError ? (\n <MessageItemBody testID=\"tool-result-edit\">\n <MessageItemStatus tone=\"error\">failed</MessageItemStatus>\n {resultTextLines(result, output).map((line, index) => (\n <Text key={`${String(index)}-${line}`} selectable style={styles.error}>\n {line}\n </Text>\n ))}\n </MessageItemBody>\n ) : view === undefined ? (\n running ? (\n <MessageItemBody testID=\"tool-result-edit\">\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : (\n <MessageItemBody testID=\"tool-result-edit\">\n <DiffRows rows={view.rows} gutter={view.gutter} path={call.path} />\n </MessageItemBody>\n )}\n </>\n );\n }}\n </MessageItem>\n );\n}\n\n// Po carries a diff on the background the way Magit does: a green wash on\n// added rows, a red wash on removed ones, and the foreground left to the text.\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n detail: {\n flexShrink: 0,\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n error: {\n color: theme.colors.red,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n row: (marker: DiffMarker) => ({\n flexDirection: 'row',\n gap: theme.spacing(2),\n backgroundColor:\n marker === '+' ? theme.colors['tint-green'] : marker === '-' ? theme.colors['tint-red'] : undefined,\n }),\n mono: {\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n gutter: { color: theme.colors.faint },\n ink: (marker: DiffMarker) => ({\n color: marker === '+' ? theme.colors.green : marker === '-' ? theme.colors.red : theme.colors.dim,\n }),\n content: { flex: 1, minWidth: 0 },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { EditToolMessage } from './_components/EditToolMessage.native';\n\nexport default defineToolRenderer({ message: EditToolMessage });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolEdit from '../src/extensions/workspaces/sessions/(frontend)/tool/edit.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'edit',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['edit'] }, toolEdit)]; },\n },\n});\n"],"mappings":";;;;;;;;AAGA,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;;AAuBvB,SAAgB,aAAa,MAAuD;CAClF,MAAM,QAAQ,MAAM,QAAQ,KAAK,KAAK,IAAI,KAAK,MAAM,SAAS;CAC9D,OAAO;EACL,MAAM,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;EAClD,QAAQ,GAAG,MAAM,GAAG,UAAU,IAAI,UAAU;CAC9C;AACF;AAEA,SAAS,aAAa,OAAuC;CAC3D,OAAO,UAAU,OAAO,UAAU,MAAM,QAAQ;AAClD;;AAGA,SAAgB,cAAc,MAAyB;CACrD,OAAO,KAAK,MAAM,IAAI,CAAC,CAAC,KAAK,SAAS;EACpC,MAAM,WAAW,KAAK,WAAW,KAAM,IAAI;EAC3C,MAAM,QAAQ,iBAAiB,KAAK,QAAQ;EAC5C,IAAI,CAAC,OAAO,OAAO;GAAE,QAAQ;GAAgB,YAAY;GAAI,SAAS;EAAS;EAC/E,OAAO;GAAE,QAAQ,aAAa,MAAM,EAAE;GAAG,aAAa,MAAM,MAAM,GAAA,CAAI,KAAK;GAAG,SAAS,MAAM,MAAM;EAAG;CACxG,CAAC;AACH;;AA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cAAclB,KAAAA;EAASe,mBAAA,CAAA,CAAA;CACvG;CACA9B,MAAM;EACJmC,YAAYjE,OAAOqD,MAAMY,WAAWnC,IAAI;EACxCqC,UAAUd,MAAMc,SAASK;EACzBH,YAAYhB,MAAMoB,kBAAkBD;EAAEZ,mBAAA,CAAA,CAAA;CACxC;CACA1C,QAAQ;EAAE4C,OAAOT,MAAMU,OAAOC;EAAKJ,mBAAA,CAAA,CAAA;CAAC;CACpC5B,MAAMH,YAAwB;EAC5BiC,OAAOjC,WAAW,MAAMwB,MAAMU,OAAOW,QAAQ7C,WAAW,MAAMwB,MAAMU,OAAOO,MAAMjB,MAAMU,OAAOY;EAAGf,mBAAA,CAAA,CAAA;CACnG;CACArC,SAAS;EAAE+B,MAAM;EAAGK,UAAU;CAAE;AAClC,EAAE;;;ACpIF,IAAA,sBAAe,mBAAmB,EAAE,SAAS,gBAAgB,CAAC;;;ACC9D,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,GAAGiB,mBAAQ,CAAC;CAAG,EAC9G;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-edit",
3
- "version": "0.0.0-alpha.33",
3
+ "version": "0.0.0-alpha.35",
4
4
  "description": "Snapshot-bound hashline edit tool for Pi and Po.",
5
5
  "keywords": [
6
6
  "ai",
@@ -59,16 +59,16 @@
59
59
  "access": "public"
60
60
  },
61
61
  "dependencies": {
62
- "@agimon-ai/po-core": "0.0.0-alpha.33",
63
- "@agimon-ai/po-hashline": "0.0.0-alpha.33",
64
- "@agimon-ai/po-ui": "0.0.0-alpha.33",
65
- "@agimon-ai/po-web-components": "0.0.0-alpha.33",
62
+ "@agimon-ai/po-core": "0.0.0-alpha.35",
63
+ "@agimon-ai/po-hashline": "0.0.0-alpha.35",
64
+ "@agimon-ai/po-ui": "0.0.0-alpha.35",
65
+ "@agimon-ai/po-web-components": "0.0.0-alpha.35",
66
66
  "@deepseek-ai/cordis": "4.0.5",
67
67
  "typebox": "1.3.37"
68
68
  },
69
69
  "devDependencies": {
70
- "@agimon-ai/po-build": "0.0.0-alpha.33",
71
- "@agimon-ai/po-native-components": "0.0.0-alpha.33",
70
+ "@agimon-ai/po-build": "0.0.0-alpha.35",
71
+ "@agimon-ai/po-native-components": "0.0.0-alpha.35",
72
72
  "@earendil-works/pi-coding-agent": "1.3.0",
73
73
  "@earendil-works/pi-durable": "1.3.0",
74
74
  "@tanstack/react-store": "0.11.2",
@@ -85,7 +85,7 @@
85
85
  "vitest": "5.0.4"
86
86
  },
87
87
  "peerDependencies": {
88
- "@agimon-ai/po-native-components": "0.0.0-alpha.33",
88
+ "@agimon-ai/po-native-components": "0.0.0-alpha.35",
89
89
  "@earendil-works/pi-coding-agent": "1.3.0",
90
90
  "react-native": "0.86.3",
91
91
  "react-native-unistyles": "^3.5.3"