@omercnet/paseo-omp 5.4.0-next.407.1 → 5.4.0-next.409.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/OVERVIEW.md CHANGED
@@ -18,6 +18,7 @@ OMP adds an agent provider for the OMP coding agent, plus an OMP sidebar and wor
18
18
  - When an OMP rule fires during a turn of an agent on Paseo's bundled `omp` provider, a notice under that turn names the rule and the text it matched. The plugin reads this, best effort, from the end of the agent's OMP session file, which that provider does not report.
19
19
  - When an agent on Paseo's bundled `omp` provider calls OMP's `lsp` tool for diagnostics, the call shows as a card grouped by file with an icon per severity. Output the plugin does not recognize keeps the original row.
20
20
  - When an agent on Paseo's bundled `omp` provider generates an image with OMP's `generate_image` tool, the row shows the image with a Download button on web and desktop. The plugin reads the saved `omp-image-*` file from the daemon host's temp directory, so the image is gone once the host cleans that directory.
21
+ - When an agent on Paseo's bundled `omp` provider previews an OMP `ast_edit` rewrite, the call shows as a read-only diff card per file. It is built from the preview text and does not apply or discard anything; OMP's follow-up `xd://resolve` or `xd://reject` write stays a separate row. A preview the plugin cannot parse keeps the original row.
21
22
  - OMP agents can call Paseo's orchestration tools with the optional `serverId` argument and `list_hosts` to delegate work to other connected Paseo hosts.
22
23
 
23
24
  ## Reads and sends
@@ -0,0 +1,53 @@
1
+ import type { PluginTimelineItemProps } from "@getpaseo/plugin/client";
2
+ import { Text, View } from "react-native";
3
+ import type { OmpAstEdit } from "../shared/ast-edit";
4
+
5
+ function countLabel(data: OmpAstEdit): string {
6
+ const total = data.files.reduce((sum, file) => sum + file.changes.length, 0);
7
+ const changes = total === 1 ? "1 change" : `${total} changes`;
8
+ const files = data.files.length === 1 ? "1 file" : `${data.files.length} files`;
9
+ return `AST edit preview: ${changes} in ${files}`;
10
+ }
11
+
12
+ export function OmpAstEditCard({ item, theme }: PluginTimelineItemProps<OmpAstEdit>) {
13
+ const { foreground, foregroundMuted, border, surface1, statusDanger, statusSuccess } =
14
+ theme.colors;
15
+ const code = { fontFamily: "monospace", fontSize: 12, flexShrink: 1 } as const;
16
+ return (
17
+ <View
18
+ style={{
19
+ gap: 8,
20
+ padding: 10,
21
+ borderRadius: 8,
22
+ borderWidth: 1,
23
+ borderColor: border,
24
+ backgroundColor: surface1,
25
+ }}
26
+ >
27
+ <Text style={{ color: foregroundMuted, fontSize: 13 }}>{countLabel(item.data)}</Text>
28
+ {item.data.files.map((file) => (
29
+ <View key={file.path} style={{ gap: 2 }}>
30
+ <Text style={{ color: foreground, fontSize: 13, fontWeight: "500" }} selectable>
31
+ {file.path}
32
+ </Text>
33
+ {file.changes.map((change, index) => (
34
+ <View key={`${index}:${change.line}`} style={{ gap: 1 }}>
35
+ <View style={{ flexDirection: "row", gap: 8 }}>
36
+ <Text style={{ ...code, color: foregroundMuted, minWidth: 28 }}>{change.line}</Text>
37
+ <Text style={{ ...code, color: statusDanger }} selectable>
38
+ {`- ${change.before}`}
39
+ </Text>
40
+ </View>
41
+ <View style={{ flexDirection: "row", gap: 8 }}>
42
+ <Text style={{ ...code, minWidth: 28 }}> </Text>
43
+ <Text style={{ ...code, color: statusSuccess }} selectable>
44
+ {`+ ${change.after}`}
45
+ </Text>
46
+ </View>
47
+ </View>
48
+ ))}
49
+ </View>
50
+ ))}
51
+ </View>
52
+ );
53
+ }
package/index.client.tsx CHANGED
@@ -4,6 +4,7 @@ import type {
4
4
  PluginClientContext,
5
5
  PluginSurfaceProps,
6
6
  } from "@getpaseo/plugin/client";
7
+ import { OmpAstEditCard } from "./client/ast-edit";
7
8
  import { ConfigSidebarItem } from "./client/config-sidebar";
8
9
  import { OmpGeneratedImagesRow } from "./client/generated-image";
9
10
  import { OMP_ICON } from "./client/hub-icon";
@@ -39,6 +40,7 @@ import {
39
40
  configStoreFromParams,
40
41
  } from "./client/sidebar-compat";
41
42
  import { OmpSubagentStrip } from "./client/subagents-strip";
43
+ import { OMP_AST_EDIT_KIND, ompAstEditSchema, transformOmpAstEditItem } from "./shared/ast-edit";
42
44
  import {
43
45
  type ComposerPillSettings,
44
46
  composerPillSettings,
@@ -274,6 +276,19 @@ export default function contribute(client: PluginClientContext) {
274
276
  return transformOmpGeneratedImageItem(item);
275
277
  },
276
278
  });
279
+ const removeAstEditRenderer = client.addTimelineRenderer({
280
+ kind: OMP_AST_EDIT_KIND,
281
+ version: 1,
282
+ schema: ompAstEditSchema,
283
+ Component: OmpAstEditCard,
284
+ });
285
+ const removeAstEditTransformer = client.addTimelineTransformer({
286
+ id: "omp-ast-edit",
287
+ query: { itemType: "tool_call" },
288
+ transform({ item }) {
289
+ return transformOmpAstEditItem(item);
290
+ },
291
+ });
277
292
  const loadStoreQuotas = createStoreQuotaLoader(
278
293
  (input) => client.rpc(listOmpQuotas, input),
279
294
  QUOTA_POLL_MS,
@@ -564,6 +579,8 @@ export default function contribute(client: PluginClientContext) {
564
579
  removeImageTransformer();
565
580
  removeGeneratedImageRenderer();
566
581
  removeGeneratedImageTransformer();
582
+ removeAstEditRenderer();
583
+ removeAstEditTransformer();
567
584
  removeOpenConfig();
568
585
  removeConfigEntry();
569
586
  removeOpenWorkspace();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "5.4.0-next.407.1",
3
+ "version": "5.4.0-next.409.1",
4
4
  "type": "module",
5
5
  "description": "Paseo integration for OMP, including its direct provider and workspace tooling.",
6
6
  "license": "MIT",
@@ -1,2 +1,2 @@
1
1
  /** Release Please keeps this bundle-safe constant aligned with package.json. */
2
- export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.407.1"; // x-release-please-version
2
+ export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.409.1"; // x-release-please-version
@@ -0,0 +1,124 @@
1
+ import { z } from "zod";
2
+
3
+ export const OMP_AST_EDIT_KIND = "omp-ast-edit";
4
+
5
+ export const ompAstEditSchema = z.object({
6
+ files: z
7
+ .array(
8
+ z.object({
9
+ path: z.string().min(1),
10
+ changes: z
11
+ .array(
12
+ z.object({
13
+ line: z.number().int().positive(),
14
+ before: z.string(),
15
+ after: z.string(),
16
+ }),
17
+ )
18
+ .min(1),
19
+ }),
20
+ )
21
+ .min(1),
22
+ });
23
+ export type OmpAstEdit = z.infer<typeof ompAstEditSchema>;
24
+
25
+ const PROPOSAL = /^Staged as a proposal\b/u;
26
+ const TAG = "#[0-9A-Fa-f]{2,8}";
27
+ /** `[a.ts#387A]` heads a single-file preview. */
28
+ const SINGLE_FILE = new RegExp(`^\\[(.+)${TAG}\\]$`, "u");
29
+ /** `## b.ts#D8CE (1 replacement)` is a file in a directory preview; `# sub/` is a directory. */
30
+ const TREE_FILE = new RegExp(`^(#+) (.+)${TAG} \\(\\d+ replacements?\\)$`, "u");
31
+ const TREE_DIRECTORY = /^(#+) (.+\/)$/u;
32
+ const CHANGE = /^([-+])(\d+):(.*)$/u;
33
+
34
+ type FileChanges = OmpAstEdit["files"][number]["changes"];
35
+
36
+ /**
37
+ * Parses the preview text OMP's `ast_edit` returns in its default hashline mode: a header per file
38
+ * (`[path#TAG]`, or a `#` tree for several files) followed by `-LINE:before` / `+LINE:after`
39
+ * pairs. Returns `undefined` unless every line is recognized, so any other output (plain
40
+ * line/column mode, no matches, parse issues, a truncation notice) keeps its original row.
41
+ */
42
+ export function parseOmpAstEdit(text: string): OmpAstEdit | undefined {
43
+ const files = new Map<string, FileChanges>();
44
+ const directories: string[] = [];
45
+ let current: FileChanges | undefined;
46
+ let removed: { line: number; before: string } | undefined;
47
+ for (const line of text.split(/\r?\n/u)) {
48
+ if (line.trim() === "" || PROPOSAL.test(line)) continue;
49
+ const change = CHANGE.exec(line);
50
+ if (change) {
51
+ const number = Number(change[2]);
52
+ const content = change[3] ?? "";
53
+ if (!current) return undefined;
54
+ if (change[1] === "-") {
55
+ if (removed) return undefined;
56
+ removed = { line: number, before: content };
57
+ } else {
58
+ if (removed?.line !== number) return undefined;
59
+ current.push({ line: number, before: removed.before, after: content });
60
+ removed = undefined;
61
+ }
62
+ continue;
63
+ }
64
+ if (removed) return undefined;
65
+ const file = SINGLE_FILE.exec(line) ?? TREE_FILE.exec(line);
66
+ if (file) {
67
+ const depth = file.length === 3 ? (file[1] ?? "").length - 1 : 0;
68
+ directories.length = depth;
69
+ const path = directories.join("") + (file.at(-1) ?? "");
70
+ current = files.get(path) ?? [];
71
+ files.set(path, current);
72
+ continue;
73
+ }
74
+ const directory = TREE_DIRECTORY.exec(line);
75
+ if (!directory) return undefined;
76
+ const depth = (directory[1] ?? "").length - 1;
77
+ directories.length = depth;
78
+ directories[depth] = directory[2] ?? "";
79
+ current = undefined;
80
+ }
81
+ if (removed) return undefined;
82
+ const parsed = ompAstEditSchema.safeParse({
83
+ files: [...files].map(([path, changes]) => ({ path, changes })),
84
+ });
85
+ return parsed.success ? parsed.data : undefined;
86
+ }
87
+
88
+ const textBlockSchema = z.looseObject({ type: z.string(), text: z.string().optional() });
89
+ const astEditRowSchema = z.object({
90
+ name: z.literal("ast_edit"),
91
+ callId: z.string(),
92
+ status: z.literal("completed"),
93
+ detail: z.union([
94
+ z.object({ type: z.literal("plain_text"), text: z.string() }),
95
+ z.object({
96
+ type: z.literal("unknown"),
97
+ output: z.looseObject({ content: z.array(textBlockSchema) }),
98
+ }),
99
+ ]),
100
+ });
101
+
102
+ /**
103
+ * Replaces a completed built-in `ast_edit` row with a read-only diff card. The built-in provider
104
+ * passes only the result text (as a plain text row, or as the raw result for an unmapped tool), so
105
+ * a row whose text does not parse stays as is.
106
+ */
107
+ export function transformOmpAstEditItem(item: unknown) {
108
+ const row = astEditRowSchema.safeParse(item);
109
+ if (!row.success) return undefined;
110
+ const { detail } = row.data;
111
+ const text =
112
+ detail.type === "plain_text"
113
+ ? detail.text
114
+ : detail.output.content
115
+ .flatMap((block) => (block.text === undefined ? [] : [block.text]))
116
+ .join("\n");
117
+ const data = parseOmpAstEdit(text);
118
+ if (!data) return undefined;
119
+ return {
120
+ items: [
121
+ { type: "plugin" as const, kind: OMP_AST_EDIT_KIND, id: row.data.callId, version: 1, data },
122
+ ],
123
+ };
124
+ }