@agimon-ai/po-edit 0.0.0-alpha.0

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.
@@ -0,0 +1,179 @@
1
+ import { defineToolRenderer, defineWebPlugin } from "@agimon-ai/po-core/web";
2
+ import { MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, SyntaxLine, ToolPathLink, collapseLines, toolTone, useSyntaxLines } from "@agimon-ai/po-web-components";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_lib/editToolView.ts
5
+ /** Pi emits `+12 text`, `-12 text`, ` 12 text`, and a blank-numbered ` ... ` elision between hunks. */
6
+ const DIFF_ROW_PATTERN = /^([+\- ])( *\d*) (.*)$/u;
7
+ const CONTEXT_MARKER = " ";
8
+ /** What the edit call heading shows: the path and how many ranges the call touches. */
9
+ function editCallView(args) {
10
+ const count = Array.isArray(args.edits) ? args.edits.length : 0;
11
+ return {
12
+ path: typeof args.path === "string" ? args.path : "",
13
+ ranges: `${count} ${count === 1 ? "range" : "ranges"}`
14
+ };
15
+ }
16
+ function toDiffMarker(value) {
17
+ return value === "+" || value === "-" ? value : CONTEXT_MARKER;
18
+ }
19
+ /** Pi's display diff as rows; a line that is not a diff row reads as unnumbered context. */
20
+ function parseDiffRows(diff) {
21
+ return diff.split("\n").map((line) => {
22
+ const expanded = line.replaceAll(" ", " ");
23
+ const match = DIFF_ROW_PATTERN.exec(expanded);
24
+ if (!match) return {
25
+ marker: CONTEXT_MARKER,
26
+ lineNumber: "",
27
+ content: expanded
28
+ };
29
+ return {
30
+ marker: toDiffMarker(match[1]),
31
+ lineNumber: (match[2] ?? "").trim(),
32
+ content: match[3] ?? ""
33
+ };
34
+ });
35
+ }
36
+ /** The diff a successful edit carries in its details; undefined when the details never arrived. */
37
+ function editResultView(result) {
38
+ const details = result?.details;
39
+ if (typeof details !== "object" || details === null) return void 0;
40
+ const diff = details.diff;
41
+ if (typeof diff !== "string" || diff.length === 0) return void 0;
42
+ const rows = parseDiffRows(diff);
43
+ return {
44
+ rows,
45
+ gutter: rows.reduce((widest, row) => Math.max(widest, row.lineNumber.length), 1)
46
+ };
47
+ }
48
+ /** The result's text lines, for the error case where the diff never happened. */
49
+ function resultTextLines(result, output) {
50
+ const lines = (result === null ? output : result.content.flatMap((block) => {
51
+ const record = typeof block === "object" && block !== null ? block : {};
52
+ return record.type === "text" && typeof record.text === "string" ? [record.text] : [];
53
+ }).join("\n")).replaceAll(" ", " ").replaceAll("\r\n", "\n").split("\n");
54
+ while (lines.at(-1) === "") lines.pop();
55
+ return lines;
56
+ }
57
+ //#endregion
58
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/EditToolMessage.tsx
59
+ /** Diff rows shown until the item expands; about what the old scroll box held. */
60
+ const COLLAPSED_ROWS = 24;
61
+ const ROW_TONE = {
62
+ "+": "bg-doom-tint-green text-doom-green",
63
+ "-": "bg-doom-tint-red text-doom-red",
64
+ " ": "text-doom-dim"
65
+ };
66
+ /**
67
+ * The banded rows, and the grammar over them.
68
+ *
69
+ * Its own component because the colours come from a hook, and the body that
70
+ * renders these rows is chosen inside a render prop. The rows are parsed as
71
+ * one document: a diff is not a file, so a replaced line is seen twice and a
72
+ * split string can colour oddly, which costs a token here and there and never
73
+ * costs the reader the text. The `+` and `-` wash stays underneath, so what
74
+ * changed is still legible when the grammar has coloured the foreground.
75
+ */
76
+ function DiffRows({ rows, gutter, path }) {
77
+ const spans = useSyntaxLines(rows.map((row) => row.content).join("\n"), { path });
78
+ return /* @__PURE__ */ jsx(Fragment, { children: rows.map((row, index) => /* @__PURE__ */ jsxs("span", {
79
+ className: `flex gap-2 ${ROW_TONE[row.marker]}`,
80
+ children: [
81
+ /* @__PURE__ */ jsx("span", {
82
+ className: "shrink-0 text-right text-doom-faint",
83
+ style: { width: `${String(gutter)}ch` },
84
+ children: row.lineNumber
85
+ }),
86
+ /* @__PURE__ */ jsx("span", {
87
+ className: "w-2 shrink-0",
88
+ children: row.marker === " " ? "" : row.marker
89
+ }),
90
+ /* @__PURE__ */ jsx(SyntaxLine, {
91
+ spans: spans?.[index],
92
+ text: row.content,
93
+ className: "min-w-0 whitespace-pre-wrap break-words"
94
+ })
95
+ ]
96
+ }, `${String(index)}-${row.lineNumber}`)) });
97
+ }
98
+ /**
99
+ * The edit tool's timeline item: `path · N ranges` in the header; the display
100
+ * diff from the result's details, banded by row, in the body. A successful
101
+ * edit whose details never arrived shows nothing, and a failed one shows the
102
+ * tool's message in red.
103
+ */
104
+ function EditToolMessage({ args, result, output, running, isError, fileTabFor, openTransientTab }) {
105
+ const call = editCallView(args);
106
+ const view = result === null || isError ? void 0 : editResultView(result);
107
+ const tab = fileTabFor(call.path);
108
+ return /* @__PURE__ */ jsx(MessageItem, {
109
+ tone: toolTone({
110
+ running,
111
+ isError
112
+ }),
113
+ expandable: view !== void 0 && view.rows.length > COLLAPSED_ROWS,
114
+ children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
115
+ title: "edit",
116
+ children: /* @__PURE__ */ jsxs("span", {
117
+ "data-testid": "tool-call-edit",
118
+ className: "flex min-w-0 flex-1 items-center gap-2",
119
+ children: [/* @__PURE__ */ jsx(ToolPathLink, {
120
+ path: call.path,
121
+ ...tab === void 0 ? {} : { onOpen: () => openTransientTab(tab) }
122
+ }), /* @__PURE__ */ jsxs("span", {
123
+ className: "shrink-0 text-doom-faint",
124
+ children: ["· ", call.ranges]
125
+ })]
126
+ })
127
+ }), isError ? /* @__PURE__ */ jsxs(MessageItemBody, {
128
+ "data-testid": "tool-result-edit",
129
+ className: "flex flex-col",
130
+ children: [/* @__PURE__ */ jsx(MessageItemStatus, {
131
+ tone: "error",
132
+ children: "failed"
133
+ }), resultTextLines(result, output).map((line, index) => /* @__PURE__ */ jsx("span", {
134
+ className: "whitespace-pre-wrap break-words text-doom-red",
135
+ children: line
136
+ }, `${String(index)}-${line}`))]
137
+ }) : view === void 0 ? running ? /* @__PURE__ */ jsx(MessageItemBody, {
138
+ "data-testid": "tool-result-edit",
139
+ children: /* @__PURE__ */ jsx(MessageItemStatus, {
140
+ tone: "running",
141
+ children: "running"
142
+ })
143
+ }) : null : (() => {
144
+ const { shown, hidden } = collapseLines(view.rows, COLLAPSED_ROWS, expanded);
145
+ return /* @__PURE__ */ jsxs(MessageItemBody, {
146
+ "data-testid": "tool-result-edit",
147
+ className: "flex flex-col font-mono",
148
+ children: [/* @__PURE__ */ jsx(DiffRows, {
149
+ rows: shown,
150
+ gutter: view.gutter,
151
+ path: call.path
152
+ }), hidden > 0 ? /* @__PURE__ */ jsxs(MessageItemStatus, {
153
+ expands: true,
154
+ className: "pt-1",
155
+ children: [hidden, " more rows"]
156
+ }) : null]
157
+ });
158
+ })()] })
159
+ });
160
+ }
161
+ //#endregion
162
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/edit.web.tsx
163
+ var edit_web_default = defineToolRenderer({ message: EditToolMessage });
164
+ //#endregion
165
+ //#region generated/web.ts
166
+ const via = (identity, value) => value === void 0 ? void 0 : {
167
+ ...identity,
168
+ ...value
169
+ };
170
+ const webPlugin = defineWebPlugin({
171
+ id: "edit",
172
+ session: { get toolRenderers() {
173
+ return [via({ tools: ["edit"] }, edit_web_default)];
174
+ } }
175
+ });
176
+ //#endregion
177
+ export { webPlugin };
178
+
179
+ //# sourceMappingURL=web.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.mjs","names":["toolEdit"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/editToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/EditToolMessage.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/edit.web.tsx","../../generated/web.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/web';\nimport {\n collapseLines,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n SyntaxLine,\n ToolPathLink,\n toolTone,\n useSyntaxLines,\n} from '@agimon-ai/po-web-components';\n\nimport { type DiffRow, editCallView, editResultView, resultTextLines } from '../_lib/editToolView';\n\n/** Diff rows shown until the item expands; about what the old scroll box held. */\nconst COLLAPSED_ROWS = 24;\n\n// Doom 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 ROW_TONE: Readonly<Record<DiffRow['marker'], string>> = {\n '+': 'bg-doom-tint-green text-doom-green',\n '-': 'bg-doom-tint-red text-doom-red',\n ' ': 'text-doom-dim',\n};\n\n/**\n * The banded rows, and the grammar over them.\n *\n * Its own component because the colours come from a hook, and the body that\n * renders these rows is chosen inside a render prop. The rows are parsed as\n * one document: a diff is not a file, so a replaced line is seen twice and a\n * split string can colour oddly, which costs a token here and there and never\n * costs the reader the text. The `+` and `-` wash stays underneath, so what\n * changed is still legible when the grammar has coloured the foreground.\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 <>\n {rows.map((row, index) => (\n <span key={`${String(index)}-${row.lineNumber}`} className={`flex gap-2 ${ROW_TONE[row.marker]}`}>\n <span className=\"shrink-0 text-right text-doom-faint\" style={{ width: `${String(gutter)}ch` }}>\n {row.lineNumber}\n </span>\n <span className=\"w-2 shrink-0\">{row.marker === ' ' ? '' : row.marker}</span>\n <SyntaxLine spans={spans?.[index]} text={row.content} className=\"min-w-0 whitespace-pre-wrap break-words\" />\n </span>\n ))}\n </>\n );\n}\n\n/**\n * The edit tool's timeline item: `path · N ranges` in the header; the display\n * diff from the result's details, banded by row, in the body. A successful\n * edit whose details never arrived shows nothing, and a failed one shows the\n * tool's message in red.\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 // The file this edit lands in, opened from the header rather than found\n // again in a file list; plain text when nothing installed can show it.\n const tab = fileTabFor(call.path);\n return (\n <MessageItem\n tone={toolTone({ running, isError })}\n expandable={view !== undefined && view.rows.length > COLLAPSED_ROWS}\n >\n {({ expanded }) => (\n <>\n <MessageItemHeader title=\"edit\">\n <span data-testid=\"tool-call-edit\" className=\"flex min-w-0 flex-1 items-center gap-2\">\n <ToolPathLink path={call.path} {...(tab === undefined ? {} : { onOpen: () => openTransientTab(tab) })} />\n <span className=\"shrink-0 text-doom-faint\">· {call.ranges}</span>\n </span>\n </MessageItemHeader>\n {isError ? (\n <MessageItemBody data-testid=\"tool-result-edit\" className=\"flex flex-col\">\n <MessageItemStatus tone=\"error\">failed</MessageItemStatus>\n {resultTextLines(result, output).map((line, index) => (\n <span key={`${String(index)}-${line}`} className=\"whitespace-pre-wrap break-words text-doom-red\">\n {line}\n </span>\n ))}\n </MessageItemBody>\n ) : view === undefined ? (\n running ? (\n <MessageItemBody data-testid=\"tool-result-edit\">\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : (\n (() => {\n const { shown, hidden } = collapseLines(view.rows, COLLAPSED_ROWS, expanded);\n return (\n <MessageItemBody data-testid=\"tool-result-edit\" className=\"flex flex-col font-mono\">\n <DiffRows rows={shown} gutter={view.gutter} path={call.path} />\n {hidden > 0 ? (\n <MessageItemStatus expands className=\"pt-1\">\n {hidden} more rows\n </MessageItemStatus>\n ) : null}\n </MessageItemBody>\n );\n })()\n )}\n </>\n )}\n </MessageItem>\n );\n}\n","import { defineToolRenderer } from '@agimon-ai/po-core/web';\n\nimport { EditToolMessage } from './_components/EditToolMessage';\n\nexport default defineToolRenderer({ message: EditToolMessage });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineWebPlugin, type WebPluginContributions } from '@agimon-ai/po-core/web';\n\nimport toolEdit from '../src/extensions/workspaces/sessions/(frontend)/tool/edit.web';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const webPlugin = defineWebPlugin({\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;;AAGA,S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,CACc;EACf,CAAA,IAAA,SAAS,KAAA,IACX,UACE,oBAAC,iBAAD;GAAiB,eAAY;GAC3B,UAAA,oBAAC,mBAAD;IAAmB,MAAK;IAAU,UAAA;GAA0B,CAAA;EAC7C,CAAA,IACf,cAEG;GACL,MAAM,EAAE,OAAO,WAAW,cAAc,KAAK,MAAM,gBAAgB,QAAQ;GAC3E,OACE,qBAAC,iBAAD;IAAiB,eAAY;IAAmB,WAAU;IAA1D,UAAA,CACE,oBAAC,UAAD;KAAU,MAAM;KAAO,QAAQ,KAAK;KAAQ,MAAM,KAAK;IAAO,CAAA,GAC7D,SAAS,IACR,qBAAC,mBAAD;KAAmB,SAAA;KAAQ,WAAU;KAArC,UAAA,CACG,QAAO,YACS;IACjB,CAAA,IAAA,IACW;;EAErB,EAAA,CAAG,CAEL,EAAA,CAAA;CAEO,CAAA;AAEjB;;;ACpHA,IAAA,mBAAe,mBAAmB,EAAE,SAAS,gBAAgB,CAAC;;;ACC9D,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,YAAY,gBAAgB;CACvC,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,GAAGA,gBAAQ,CAAC;CAAG,EAC9G;AACF,CAAC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,7 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_editTool = require("./editTool-BKaEjUdm.cjs");
3
+ exports.EditParamsSchema = require_editTool.EditParamsSchema;
4
+ exports.HashlineRangeSchema = require_editTool.HashlineRangeSchema;
5
+ exports.createHashlineEditTool = require_editTool.createHashlineEditTool;
6
+ exports.createHeadlessEditTool = require_editTool.createHeadlessEditTool;
7
+ exports.executeHashlineEdit = require_editTool.executeHashlineEdit;
@@ -0,0 +1,34 @@
1
+ import { EditToolDetails, ToolDefinition } from "@earendil-works/pi-coding-agent";
2
+ import { Static, Type } from "typebox";
3
+ import { DoomHeadlessTool } from "@agimon-ai/po-core/headless";
4
+ //#region src/schemas/editTool.d.ts
5
+ export declare const HashlineRangeSchema: Type.TObject<{
6
+ from: Type.TString;
7
+ to: Type.TString;
8
+ content: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
9
+ }>;
10
+ export declare const EditParamsSchema: Type.TObject<{
11
+ path: Type.TString;
12
+ hash: Type.TString;
13
+ edits: Type.TArray<Type.TObject<{
14
+ from: Type.TString;
15
+ to: Type.TString;
16
+ content: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
17
+ }>>;
18
+ }>;
19
+ type HashlineRange = Static<typeof HashlineRangeSchema>;
20
+ type EditParams = Static<typeof EditParamsSchema>;
21
+ //#endregion
22
+ //#region src/services/editTool/index.d.ts
23
+ export declare function createHashlineEditTool(): ToolDefinition<typeof EditParamsSchema>;
24
+ export declare function createHeadlessEditTool(): DoomHeadlessTool<typeof EditParamsSchema>;
25
+ export declare function executeHashlineEdit(params: EditParams, cwd: string, signal: AbortSignal | undefined): Promise<{
26
+ content: [{
27
+ type: 'text';
28
+ text: string;
29
+ }];
30
+ details: EditToolDetails;
31
+ }>;
32
+ //#endregion
33
+ export type { EditParams, HashlineRange };
34
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/schemas/editTool.ts","../src/services/editTool/index.ts"],"mappings":";;;;qBAEa,qBAAmB,KAAA;;;;;qBAWnB,kBAAgB,KAAA;;;;;;;;;KASjB,gBAAgB,cAAc;KAC9B,aAAa,cAAc;;;wBCGvB,0BAA0B,sBAAsB;wBAqBhD,0BAA0B,wBAAwB;wBA2B5C,oBACpB,QAAQ,YACR,aACA,QAAQ,0BACP;EAAU;IAAY;IAAc;;EAAiB,SAAS"}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { a as HashlineRangeSchema, i as EditParamsSchema, n as createHeadlessEditTool, r as executeHashlineEdit, t as createHashlineEditTool } from "./editTool--RaZ-yPH.mjs";
2
+ export { EditParamsSchema, HashlineRangeSchema, createHashlineEditTool, createHeadlessEditTool, executeHashlineEdit };
package/package.json ADDED
@@ -0,0 +1,132 @@
1
+ {
2
+ "name": "@agimon-ai/po-edit",
3
+ "version": "0.0.0-alpha.0",
4
+ "description": "Snapshot-bound hashline edit tool for Pi and Po.",
5
+ "keywords": [
6
+ "ai",
7
+ "coding-agent",
8
+ "developer-tools",
9
+ "hashline",
10
+ "pi-coding-agent",
11
+ "pi-extension",
12
+ "pi-package",
13
+ "po"
14
+ ],
15
+ "homepage": "https://agimon.ai",
16
+ "bugs": {
17
+ "url": "https://github.com/AgiFlow/po/issues"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Vuong Ngo",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/AgiFlow/po.git",
24
+ "directory": "packages/default/po-edit"
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "type": "module",
30
+ "main": "./dist/index.cjs",
31
+ "module": "./dist/index.mjs",
32
+ "types": "./dist/index.d.mts",
33
+ "jsnext:main": "./dist/index.mjs",
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.mts",
37
+ "import": "./dist/index.mjs",
38
+ "require": "./dist/index.cjs"
39
+ },
40
+ "./apiContracts": {
41
+ "types": "./dist/apiContracts.d.mts",
42
+ "import": "./dist/apiContracts.mjs",
43
+ "require": "./dist/apiContracts.cjs"
44
+ },
45
+ "./extensions/server": {
46
+ "types": "./dist/extensions/server.d.mts",
47
+ "import": "./dist/extensions/server.mjs",
48
+ "require": "./dist/extensions/server.cjs"
49
+ },
50
+ "./extensions/web": {
51
+ "import": "./dist/extensions/web.mjs"
52
+ },
53
+ "./package.json": "./package.json"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "dependencies": {
59
+ "@agimon-ai/po-core": "0.0.0-alpha.0",
60
+ "@agimon-ai/po-hashline": "0.0.0-alpha.0",
61
+ "@agimon-ai/po-ui": "0.0.0-alpha.0",
62
+ "@agimon-ai/po-web-components": "0.0.0-alpha.0",
63
+ "@deepseek-ai/cordis": "4.0.4",
64
+ "typebox": "1.3.34"
65
+ },
66
+ "devDependencies": {
67
+ "@agimon-ai/po-build": "0.0.0-alpha.0",
68
+ "@earendil-works/pi-coding-agent": "1.0.2",
69
+ "@tanstack/react-store": "0.11.2",
70
+ "@tanstack/store": "0.11.2",
71
+ "@types/node": "26.6.4",
72
+ "@types/react": "19.3.0",
73
+ "@vitest/coverage-v8": "5.0.3",
74
+ "react": "19.3.0",
75
+ "react-dom": "19.3.0",
76
+ "tsdown": "0.23.0",
77
+ "typescript": "7.0.2",
78
+ "vitest": "5.0.3"
79
+ },
80
+ "peerDependencies": {
81
+ "@earendil-works/pi-coding-agent": "1.0.2"
82
+ },
83
+ "peerDependenciesMeta": {
84
+ "@earendil-works/pi-coding-agent": {
85
+ "optional": true
86
+ }
87
+ },
88
+ "engines": {
89
+ "node": ">=24"
90
+ },
91
+ "poMcp": {
92
+ "entry": "./generated/mcp.ts",
93
+ "dist": "./dist/extensions/mcp.mjs",
94
+ "scopes": [
95
+ "session"
96
+ ],
97
+ "ui": {
98
+ "entry": "./generated/mcp-ui.ts",
99
+ "dist": "./dist/extensions/mcp-ui.mjs",
100
+ "widgets": [
101
+ "@agimon-ai/po-edit/edit"
102
+ ]
103
+ }
104
+ },
105
+ "poServer": {
106
+ "entry": "./generated/server.ts",
107
+ "dist": "./dist/extensions/server.mjs",
108
+ "scopes": [
109
+ "session"
110
+ ],
111
+ "contracts": {
112
+ "entry": "./src/exports/apiContracts.ts",
113
+ "dist": "./dist/apiContracts.mjs"
114
+ }
115
+ },
116
+ "poWeb": {
117
+ "pluginId": "edit",
118
+ "channels": [],
119
+ "client": "./dist/extensions/web.mjs",
120
+ "scopes": [
121
+ "session"
122
+ ]
123
+ },
124
+ "scripts": {
125
+ "build": "tsdown && tsdown --config tsdown.mcp.config.ts",
126
+ "build:mcp": "tsdown --config tsdown.mcp.config.ts",
127
+ "test": "vitest --run",
128
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.web.json && tsc --noEmit -p tsconfig.mcp.json",
129
+ "lint": "oxlint . && oxfmt . --check",
130
+ "fixcode": "oxlint . --fix && oxfmt ."
131
+ }
132
+ }