@agimon-ai/po-grep 0.0.0-alpha.21 → 0.0.0-alpha.211

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,139 @@
1
+ import { defineNativePlugin, defineToolRenderer, useT } from "@agimon-ai/po-core/native";
2
+ import { View } from "react-native-unistyles/components/native/View";
3
+ import { Text } from "react-native-unistyles/components/native/Text";
4
+ import { HashlineLines, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, fontOf, hashlineBody, resultTextLines, toolTone } from "@agimon-ai/po-native-components";
5
+ import { StyleSheet } from "react-native-unistyles";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_lib/grepToolView.ts
8
+ /** What the grep call heading shows: the pattern, then where and how it searched. */
9
+ function grepCallView(args, t) {
10
+ const limit = typeof args.limit === "number" && Number.isFinite(args.limit) ? args.limit : void 0;
11
+ return {
12
+ pattern: typeof args.pattern === "string" ? args.pattern : "",
13
+ details: [
14
+ typeof args.path === "string" && args.path.length > 0 ? args.path : ".",
15
+ typeof args.glob === "string" ? args.glob : void 0,
16
+ args.ignoreCase === true ? t?.("grep.ui.ignoreCase", "ignore case") ?? "ignore case" : void 0,
17
+ limit === void 0 ? void 0 : t?.("grep.ui.matches", "{count} matches", { count: limit }) ?? `${limit} matches`
18
+ ].filter((value) => value !== void 0 && value.length > 0)
19
+ };
20
+ }
21
+ //#endregion
22
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/GrepToolMessage.native.tsx
23
+ /**
24
+ * The grep tool's timeline item on native, as the web's GrepToolMessage: the
25
+ * call summary in the header and, once expanded, the anchored matches with a
26
+ * line-number gutter, or the tool's message in red when the search failed.
27
+ */
28
+ function GrepToolMessage({ args, result, output, running, isError }) {
29
+ const t = useT();
30
+ const view = grepCallView(args, t);
31
+ const body = result === null || isError ? null : hashlineBody(result, output, "grep", true);
32
+ return /* @__PURE__ */ jsx(MessageItem, {
33
+ tone: toolTone({
34
+ running,
35
+ isError
36
+ }),
37
+ expandable: true,
38
+ defaultExpanded: false,
39
+ children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
40
+ title: "grep",
41
+ children: /* @__PURE__ */ jsxs(View, {
42
+ testID: "tool-call-grep",
43
+ style: styles.summary,
44
+ children: [/* @__PURE__ */ jsx(Text, {
45
+ numberOfLines: 1,
46
+ style: [styles.sans, styles.pattern],
47
+ children: view.pattern
48
+ }), view.details.length > 0 ? /* @__PURE__ */ jsxs(Text, {
49
+ numberOfLines: 1,
50
+ style: [styles.sans, styles.detail],
51
+ children: ["· ", view.details.join(" · ")]
52
+ }) : null]
53
+ })
54
+ }), expanded ? isError ? /* @__PURE__ */ jsxs(MessageItemBody, {
55
+ testID: "tool-result-grep",
56
+ children: [/* @__PURE__ */ jsx(MessageItemStatus, {
57
+ tone: "error",
58
+ children: t("grep.ui.failed", "failed")
59
+ }), resultTextLines(result, output).map((line, index) => /* @__PURE__ */ jsx(Text, {
60
+ selectable: true,
61
+ style: [styles.sans, styles.error],
62
+ children: line
63
+ }, `${String(index)}-${line}`))]
64
+ }) : body === null ? running ? /* @__PURE__ */ jsx(MessageItemBody, {
65
+ testID: "tool-result-grep",
66
+ children: /* @__PURE__ */ jsx(MessageItemStatus, {
67
+ tone: "running",
68
+ children: t("grep.ui.running", "running")
69
+ })
70
+ }) : null : body.shown.length === 0 && body.notice === void 0 ? null : /* @__PURE__ */ jsxs(MessageItemBody, {
71
+ testID: "tool-result-grep",
72
+ children: [/* @__PURE__ */ jsx(HashlineLines, {
73
+ lines: body.shown,
74
+ gutter: body.gutter
75
+ }), body.notice !== void 0 ? /* @__PURE__ */ jsx(Text, {
76
+ style: [styles.sans, styles.detail],
77
+ children: body.notice
78
+ }) : null]
79
+ }) : null] })
80
+ });
81
+ }
82
+ const styles = StyleSheet.create((theme) => ({
83
+ summary: {
84
+ flex: 1,
85
+ flexDirection: "row",
86
+ alignItems: "center",
87
+ gap: theme.spacing(2),
88
+ minWidth: 0,
89
+ uni__dependencies: [0]
90
+ },
91
+ sans: {
92
+ fontFamily: fontOf(theme.fontFamily.sans),
93
+ fontSize: theme.fontSize.base,
94
+ lineHeight: theme.lineHeight.base,
95
+ uni__dependencies: [0]
96
+ },
97
+ pattern: {
98
+ flexShrink: 1,
99
+ color: theme.colors.text,
100
+ uni__dependencies: [0]
101
+ },
102
+ detail: {
103
+ flexShrink: 1,
104
+ color: theme.colors.faint,
105
+ uni__dependencies: [0]
106
+ },
107
+ error: {
108
+ color: theme.colors.red,
109
+ uni__dependencies: [0]
110
+ }
111
+ }));
112
+ //#endregion
113
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/grep.native.tsx
114
+ var grep_native_default = defineToolRenderer({ message: GrepToolMessage });
115
+ //#endregion
116
+ //#region generated/native.ts
117
+ const via = (identity, value) => {
118
+ if (value === void 0) return void 0;
119
+ const declaration = value;
120
+ return {
121
+ ...identity,
122
+ ...declaration,
123
+ ...declaration.relations === void 0 ? {} : { relations: declaration.relations.map((relation) => ({
124
+ evidence: "declared",
125
+ ...relation
126
+ })) }
127
+ };
128
+ };
129
+ const nativePlugin = defineNativePlugin({
130
+ id: "grep",
131
+ packageName: "@agimon-ai/po-grep",
132
+ session: { get toolRenderers() {
133
+ return [via({ tools: ["grep"] }, grep_native_default)];
134
+ } }
135
+ });
136
+ //#endregion
137
+ export { nativePlugin };
138
+
139
+ //# sourceMappingURL=native.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.mjs","names":["useT","ToolMessageRenderProps","fontOf","HashlineLines","hashlineBody","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","resultTextLines","toolTone","PoNativeTheme","StyleSheet","grepCallView","GrepToolMessage","args","result","output","running","isError","t","view","body","expanded","styles","summary","sans","pattern","details","length","detail","join","map","line","index","String","error","shown","notice","undefined","gutter","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","fontFamily","fontSize","base","lineHeight","flexShrink","color","colors","text","faint","red","toolGrep"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/grepToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/GrepToolMessage.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/grep.native.tsx","../../generated/native.ts"],"sourcesContent":["// Imports nothing at runtime: the web and native cards share it, and the native\n// bundle may not load the web component library.\n\ntype Translate = (key: string, fallback: string, vars?: Readonly<Record<string, string | number>>) => string;\n\nexport interface GrepCallView {\n readonly pattern: string;\n /** Search path, glob, case flag, and limit, as the TUI's call heading lists them. */\n readonly details: readonly string[];\n}\n\n/** What the grep call heading shows: the pattern, then where and how it searched. */\nexport function grepCallView(args: Readonly<Record<string, unknown>>, t?: Translate): GrepCallView {\n const limit = typeof args.limit === 'number' && Number.isFinite(args.limit) ? args.limit : undefined;\n return {\n pattern: typeof args.pattern === 'string' ? args.pattern : '',\n details: [\n typeof args.path === 'string' && args.path.length > 0 ? args.path : '.',\n typeof args.glob === 'string' ? args.glob : undefined,\n args.ignoreCase === true ? (t?.('grep.ui.ignoreCase', 'ignore case') ?? 'ignore case') : undefined,\n limit === undefined\n ? undefined\n : (t?.('grep.ui.matches', '{count} matches', { count: limit }) ?? `${limit} matches`),\n ].filter((value): value is string => value !== undefined && value.length > 0),\n };\n}\n","import { useT } from '@agimon-ai/po-core/native';\nimport type { ToolMessageRenderProps } from '@agimon-ai/po-core/native';\nimport {\n fontOf,\n HashlineLines,\n hashlineBody,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n resultTextLines,\n toolTone,\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 { grepCallView } from '../_lib/grepToolView';\n\n/**\n * The grep tool's timeline item on native, as the web's GrepToolMessage: the\n * call summary in the header and, once expanded, the anchored matches with a\n * line-number gutter, or the tool's message in red when the search failed.\n */\nexport function GrepToolMessage({ args, result, output, running, isError }: ToolMessageRenderProps) {\n const t = useT();\n const view = grepCallView(args, t);\n const body = result === null || isError ? null : hashlineBody(result, output, 'grep', true);\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable defaultExpanded={false}>\n {({ expanded }) => (\n <>\n {/* no-untranslated-jsx: ignore - Tool identifier matches the invocation. */}\n <MessageItemHeader title=\"grep\">\n <View testID=\"tool-call-grep\" style={styles.summary}>\n <Text numberOfLines={1} style={[styles.sans, styles.pattern]}>\n {view.pattern}\n </Text>\n {view.details.length > 0 ? (\n <Text numberOfLines={1} style={[styles.sans, styles.detail]}>\n · {view.details.join(' · ')}\n </Text>\n ) : null}\n </View>\n </MessageItemHeader>\n {expanded ? (\n isError ? (\n <MessageItemBody testID=\"tool-result-grep\">\n <MessageItemStatus tone=\"error\">{t('grep.ui.failed', 'failed')}</MessageItemStatus>\n {resultTextLines(result, output).map((line, index) => (\n <Text key={`${String(index)}-${line}`} selectable style={[styles.sans, styles.error]}>\n {line}\n </Text>\n ))}\n </MessageItemBody>\n ) : body === null ? (\n running ? (\n <MessageItemBody testID=\"tool-result-grep\">\n <MessageItemStatus tone=\"running\">{t('grep.ui.running', 'running')}</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : body.shown.length === 0 && body.notice === undefined ? null : (\n <MessageItemBody testID=\"tool-result-grep\">\n <HashlineLines lines={body.shown} gutter={body.gutter} />\n {body.notice !== undefined ? <Text style={[styles.sans, styles.detail]}>{body.notice}</Text> : null}\n </MessageItemBody>\n )\n ) : null}\n </>\n )}\n </MessageItem>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n // Both shrink: a phone is narrower than the web card, and a pattern cut to\n // nothing by a long path reads worse than both cut short.\n pattern: { flexShrink: 1, color: theme.colors.text },\n detail: { flexShrink: 1, color: theme.colors.faint },\n error: { color: theme.colors.red },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { GrepToolMessage } from './_components/GrepToolMessage.native';\n\nexport default defineToolRenderer({ message: GrepToolMessage });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolGrep from '../src/extensions/workspaces/sessions/(frontend)/tool/grep.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => {\n if (value === undefined) return undefined as T;\n const declaration = value as { relations?: readonly Record<string, unknown>[] };\n return { ...identity, ...declaration, ...(declaration.relations === undefined ? {} : {\n relations: declaration.relations.map((relation) => ({ evidence: 'declared', ...relation })),\n }) } as T;\n};\n\nexport const nativePlugin = defineNativePlugin({\n id: 'grep',\n packageName: '@agimon-ai/po-grep',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['grep'] }, toolGrep)]; },\n },\n});\n"],"mappings":";;;;;;;;AAYA,SAAgB,aAAa,MAAyC,GAA6B;CACjG,MAAM,QAAQ,OAAO,KAAK,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,IAAI,KAAK,QAAQ,KAAA;CAC3F,OAAO;EACL,SAAS,OAAO,KAAK,YAAY,WAAW,KAAK,UAAU;EAC3D,SAAS;GACP,OAAO,KAAK,SAAS,YAAY,KAAK,KAAK,SAAS,IAAI,KAAK,OAAO;GACpE,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO,KAAA;GAC5C,KAAK,eAAe,OAAQ,IAAI,sBAAsB,aAAa,KAAK,gBAAiB,KAAA;GACzF,UAAU,KAAA,IACN,KAAA,IACC,IAAI,mBAAmB,mBAAmB,EAAE,OAAO,MAAM,CAAC,KAAK,GAAG,MAAM;EAC/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AAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,MAAM,cAAc;CACpB,OAAO;EAAE,GAAG;EAAU,GAAG;EAAa,GAAI,YAAY,cAAc,KAAA,IAAY,CAAC,IAAI,EACnF,WAAW,YAAY,UAAU,KAAK,cAAc;GAAE,UAAU;GAAY,GAAG;EAAS,EAAE,EAC5F;CAAG;AACL;AAEA,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,aAAa;CACb,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,GAAGW,mBAAQ,CAAC;CAAG,EAC9G;AACF,CAAC"}
@@ -5,25 +5,54 @@ Object.defineProperties(exports, {
5
5
  const require_grepTool = require("../grepTool-C2GQiJl4.cjs");
6
6
  let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
7
7
  let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
8
- let node_fs_promises = require("node:fs/promises");
8
+ let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
9
9
  let node_path = require("node:path");
10
10
  let _agimon_ai_po_hashline = require("@agimon-ai/po-hashline");
11
11
  let _agimon_ai_po_hashline_files = require("@agimon-ai/po-hashline/files");
12
12
  let _earendil_works_pi_coding_agent = require("@earendil-works/pi-coding-agent");
13
13
  let node_child_process = require("node:child_process");
14
+ //#region src/services/grepHost/index.ts
15
+ const defaultGrepOutput = {
16
+ maxBytes: _earendil_works_pi_coding_agent.DEFAULT_MAX_BYTES,
17
+ formatSize: _earendil_works_pi_coding_agent.formatSize,
18
+ truncateHead: _earendil_works_pi_coding_agent.truncateHead,
19
+ truncateLine: _earendil_works_pi_coding_agent.truncateLine
20
+ };
21
+ //#endregion
22
+ //#region src/services/matchLimit/index.ts
23
+ /**
24
+ * Keeps at most `limit` matching lines, and every context line around them.
25
+ *
26
+ * A context line carries no `:<line>:` marker, which is what separates it from
27
+ * a match, so trimming by line count alone would drop the context ripgrep was
28
+ * asked for.
29
+ */
30
+ function limitMatches(output, limit) {
31
+ if (limit === void 0) return output.trimEnd();
32
+ let matches = 0;
33
+ const selected = [];
34
+ for (const line of output.trimEnd().split("\n")) {
35
+ if (/:(\d+):/u.test(line)) {
36
+ matches++;
37
+ if (matches > limit) continue;
38
+ }
39
+ selected.push(line);
40
+ }
41
+ return selected.join("\n");
42
+ }
43
+ //#endregion
14
44
  //#region src/services/ripgrep/index.ts
15
45
  /** Search with ripgrep independently of the host. */
16
46
  async function runRipgrep(request) {
17
47
  const { params, cwd, signal } = request;
18
- const output = await spawnRipgrep(argumentsFor(params, cwd), cwd, signal);
19
- if (output.trim() === "") return { content: [{
20
- type: "text",
21
- text: "No matches found"
22
- }] };
23
- return { content: [{
24
- type: "text",
25
- text: limitMatches(output, params.limit)
26
- }] };
48
+ const { stdout, truncated } = await spawnRipgrep(argumentsFor(params, cwd), cwd, signal);
49
+ return {
50
+ content: [{
51
+ type: "text",
52
+ text: stdout.trim() === "" ? "No matches found" : limitMatches(stdout, params.limit)
53
+ }],
54
+ ...truncated ? { details: { truncated: true } } : {}
55
+ };
27
56
  }
28
57
  /** The ripgrep argv one search needs, exposed so a test can assert it without spawning. */
29
58
  function argumentsFor(params, cwd) {
@@ -42,26 +71,6 @@ function argumentsFor(params, cwd) {
42
71
  args.push("--", params.pattern, target);
43
72
  return args;
44
73
  }
45
- /**
46
- * Keeps at most `limit` matching lines, and every context line around them.
47
- *
48
- * A context line carries no `:<line>:` marker, which is what separates it from
49
- * a match, so trimming by line count alone would drop the context ripgrep was
50
- * asked for.
51
- */
52
- function limitMatches(output, limit) {
53
- if (limit === void 0) return output.trimEnd();
54
- let matches = 0;
55
- const selected = [];
56
- for (const line of output.trimEnd().split("\n")) {
57
- if (/:(\d+):/u.test(line)) {
58
- matches++;
59
- if (matches > limit) continue;
60
- }
61
- selected.push(line);
62
- }
63
- return selected.join("\n");
64
- }
65
74
  function spawnRipgrep(args, cwd, signal) {
66
75
  return new Promise((resolveOutput, reject) => {
67
76
  const child = (0, node_child_process.spawn)("rg", args, {
@@ -72,13 +81,28 @@ function spawnRipgrep(args, cwd, signal) {
72
81
  "pipe"
73
82
  ]
74
83
  });
75
- let stdout = "";
76
- let stderr = "";
84
+ const stdout = [];
85
+ const stderr = [];
86
+ let stdoutBytes = 0;
87
+ let stderrBytes = 0;
88
+ let truncated = false;
89
+ const collect = (chunks, chunk, bytes, cap) => {
90
+ if (truncated) return bytes;
91
+ const retained = Math.min(chunk.length, cap - bytes);
92
+ if (retained > 0) chunks.push(Buffer.from(chunk.subarray(0, retained)));
93
+ (0, _agimon_ai_po_core_platform.recordRipgrepOutput)(retained, bytes + retained >= cap);
94
+ bytes += retained;
95
+ if (bytes >= cap) {
96
+ truncated = true;
97
+ child.kill("SIGTERM");
98
+ }
99
+ return bytes;
100
+ };
77
101
  child.stdout.on("data", (chunk) => {
78
- stdout += chunk.toString();
102
+ stdoutBytes = collect(stdout, chunk, stdoutBytes, 8388608);
79
103
  });
80
104
  child.stderr.on("data", (chunk) => {
81
- stderr += chunk.toString();
105
+ stderrBytes = collect(stderr, chunk, stderrBytes, 65536);
82
106
  });
83
107
  const abort = () => {
84
108
  child.kill("SIGTERM");
@@ -95,11 +119,14 @@ function spawnRipgrep(args, cwd, signal) {
95
119
  });
96
120
  child.once("close", (code) => {
97
121
  signal?.removeEventListener("abort", abort);
98
- if (code === 0 || code === 1) {
99
- resolveOutput(stdout);
122
+ if (truncated || code === 0 || code === 1) {
123
+ resolveOutput({
124
+ stdout: Buffer.concat(stdout, stdoutBytes).toString("utf8"),
125
+ truncated
126
+ });
100
127
  return;
101
128
  }
102
- reject(new Error(stderr.trim() || `ripgrep exited with code ${code ?? "unknown"}`));
129
+ reject(new Error(Buffer.concat(stderr, stderrBytes).toString("utf8").trim() || `ripgrep exited with code ${code ?? "unknown"}`));
103
130
  });
104
131
  });
105
132
  }
@@ -108,7 +135,7 @@ function spawnRipgrep(args, cwd, signal) {
108
135
  const MATCH_DELIMITER = /:(\d+):/gu;
109
136
  const CONTEXT_DELIMITER = /-(\d+)-/gu;
110
137
  const NO_MATCHES = "No matches found";
111
- function createHeadlessGrepTool() {
138
+ function createHeadlessGrepTool(filesystem) {
112
139
  return {
113
140
  name: "grep",
114
141
  label: "grep",
@@ -117,39 +144,32 @@ function createHeadlessGrepTool() {
117
144
  parameters: require_grepTool.GrepParamsSchema,
118
145
  executionMode: "parallel",
119
146
  execute: async (_toolCallId, params, signal, _onUpdate, context) => {
147
+ const session = typeof filesystem === "function" ? filesystem() : filesystem;
120
148
  return tagGrepResult(await runRipgrep({
121
149
  params,
122
150
  cwd: context.cwd,
123
- signal
124
- }), params, context.cwd, signal);
151
+ signal,
152
+ filesystem: session
153
+ }), params, context.cwd, signal, session);
125
154
  }
126
155
  };
127
156
  }
128
- /** Node adapters for hashline post-processing. */
129
- const nodeGrepFileSystem = {
130
- stat: (path) => (0, node_fs_promises.stat)(path),
131
- readFile: (path) => (0, node_fs_promises.readFile)(path)
132
- };
133
- const defaultGrepOutput = {
134
- maxBytes: _earendil_works_pi_coding_agent.DEFAULT_MAX_BYTES,
135
- formatSize: _earendil_works_pi_coding_agent.formatSize,
136
- truncateHead: _earendil_works_pi_coding_agent.truncateHead,
137
- truncateLine: _earendil_works_pi_coding_agent.truncateLine
138
- };
139
- async function tagGrepResult(nativeResult, params, cwd, signal, writable = _agimon_ai_po_hashline_files.isWritableFile, filesystem = nodeGrepFileSystem, outputOperations = defaultGrepOutput) {
157
+ async function tagGrepResult(nativeResult, params, cwd, signal, filesystem, writable = _agimon_ai_po_hashline_files.isWritableFile, outputOperations = defaultGrepOutput) {
140
158
  const textPart = nativeResult.content.find((part) => part.type === "text");
141
159
  if (!textPart || textPart.text === NO_MATCHES) return nativeResult;
142
160
  const noticeIndex = textPart.text.lastIndexOf("\n\n[");
143
161
  const rowsText = noticeIndex === -1 ? textPart.text : textPart.text.slice(0, noticeIndex);
144
162
  const notice = noticeIndex === -1 ? "" : textPart.text.slice(noticeIndex);
145
163
  const searchPath = (0, _agimon_ai_po_hashline_files.resolveInputPath)(params.path ?? ".", cwd);
146
- const searchStats = await filesystem.stat(searchPath);
147
164
  assertNotAborted(signal);
148
- const rows = await parseValidatedGrepRows(rowsText, searchPath, searchStats.isDirectory(), signal, filesystem);
165
+ const context = signal ? (0, _agimon_ai_po_core_platform.withAbortSignal)(signal, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT) : _agimon_ai_po_core_platform.BACKGROUND_CONTEXT;
166
+ const searchStats = await grepFileInfo(filesystem, searchPath, signal);
167
+ assertNotAborted(signal);
168
+ const rows = await parseValidatedGrepRows(rowsText, searchPath, searchStats.kind === "directory", signal, filesystem);
149
169
  if (rows.length === 0) return nativeResult;
150
- const groups = groupGrepRows(rows, searchPath, searchStats.isDirectory(), cwd);
170
+ const groups = groupGrepRows(rows, searchPath, searchStats.kind === "directory", cwd);
151
171
  const blocks = [];
152
- let taggedFiles = 0;
172
+ let changedFiles = 0;
153
173
  let linesTruncated = nativeResult.details?.linesTruncated ?? false;
154
174
  for (const group of groups.values()) {
155
175
  assertNotAborted(signal);
@@ -161,8 +181,14 @@ async function tagGrepResult(nativeResult, params, cwd, signal, writable = _agim
161
181
  }
162
182
  let bytes;
163
183
  try {
164
- bytes = await filesystem.readFile(group.absolutePath);
165
- } catch {
184
+ bytes = await (0, _agimon_ai_po_core_platform.readBoundedFile)(filesystem, group.absolutePath, 8388608, context);
185
+ } catch (error) {
186
+ assertNotAborted(signal);
187
+ if (error instanceof _agimon_ai_po_core_platform.FileTooLargeError) {
188
+ blocks.push(`${group.nativeRows.join("\n")}\n[${group.path}: anchors omitted (file over 8 MiB)]`);
189
+ changedFiles++;
190
+ continue;
191
+ }
166
192
  blocks.push(group.nativeRows.join("\n"));
167
193
  continue;
168
194
  }
@@ -178,10 +204,10 @@ async function tagGrepResult(nativeResult, params, cwd, signal, writable = _agim
178
204
  }
179
205
  if (output.length > 1) {
180
206
  blocks.push(output.join("\n"));
181
- taggedFiles++;
207
+ changedFiles++;
182
208
  } else blocks.push(group.nativeRows.join("\n"));
183
209
  }
184
- if (blocks.length === 0 || taggedFiles === 0) return nativeResult;
210
+ if (blocks.length === 0 || changedFiles === 0) return nativeResult;
185
211
  const truncation = outputOperations.truncateHead(blocks.join("\n"), { maxLines: Number.MAX_SAFE_INTEGER });
186
212
  const extraNotice = truncation.truncated ? `\n\n[${outputOperations.formatSize(outputOperations.maxBytes)} tagged output limit reached]` : "";
187
213
  const details = {
@@ -218,6 +244,13 @@ function groupGrepRows(rows, searchPath, directory, cwd) {
218
244
  }
219
245
  return groups;
220
246
  }
247
+ async function grepFileInfo(filesystem, path, signal) {
248
+ const context = signal ? (0, _agimon_ai_po_core_platform.withAbortSignal)(signal, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT) : _agimon_ai_po_core_platform.BACKGROUND_CONTEXT;
249
+ const info = (0, _agimon_ai_po_core_platform.getOrThrow)(await filesystem.fileInfo(path, context));
250
+ if (info.kind !== "symlink") return info;
251
+ const target = (0, _agimon_ai_po_core_platform.getOrThrow)(await filesystem.canonicalPath(path, context));
252
+ return (0, _agimon_ai_po_core_platform.getOrThrow)(await filesystem.fileInfo(target, context));
253
+ }
221
254
  async function parseValidatedGrepRows(rowsText, searchPath, directory, signal, filesystem) {
222
255
  const pathCache = /* @__PURE__ */ new Map();
223
256
  const rows = [];
@@ -238,7 +271,7 @@ async function parseValidatedGrepRows(rowsText, searchPath, directory, signal, f
238
271
  const absolutePath = (0, node_path.resolve)(searchPath, candidate.path);
239
272
  let exists = pathCache.get(absolutePath);
240
273
  if (exists === void 0) {
241
- exists = await filesystem.stat(absolutePath).then((value) => value.isFile()).catch(() => false);
274
+ exists = await grepFileInfo(filesystem, absolutePath, signal).then((value) => value.kind === "file").catch(() => false);
242
275
  assertNotAborted(signal);
243
276
  pathCache.set(absolutePath, exists);
244
277
  }
@@ -276,13 +309,34 @@ function assertNotAborted(signal) {
276
309
  }
277
310
  //#endregion
278
311
  //#region src/extensions/workspaces/sessions/(backend)/tool/grep.server.ts
279
- var grep_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerTool)(createHeadlessGrepTool);
312
+ var grep_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerTool)(({ context }) => {
313
+ let filesystem;
314
+ context.inject([_agimon_ai_po_core_platform.PO_FS_SERVICE], (scoped) => {
315
+ const bound = (0, _agimon_ai_po_core_platform.requirePoFs)(scoped);
316
+ filesystem = bound;
317
+ return () => {
318
+ if (filesystem === bound) filesystem = void 0;
319
+ };
320
+ });
321
+ return createHeadlessGrepTool(() => {
322
+ if (!filesystem) throw new Error("Grep filesystem service is unavailable.");
323
+ return filesystem;
324
+ });
325
+ });
280
326
  //#endregion
281
327
  //#region generated/server.ts
282
328
  const at = (value, context) => typeof value === "function" ? value(context) : value;
283
- const via = (identity, value) => value === void 0 ? void 0 : {
284
- ...identity,
285
- ...value
329
+ const via = (identity, value) => {
330
+ if (value === void 0) return void 0;
331
+ const declaration = value;
332
+ return {
333
+ ...identity,
334
+ ...declaration,
335
+ ...declaration.relations === void 0 ? {} : { relations: declaration.relations.map((relation) => ({
336
+ evidence: "declared",
337
+ ...relation
338
+ })) }
339
+ };
286
340
  };
287
341
  const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
288
342
  name: "@agimon-ai/po-grep",
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs","names":["resolveInputPath","spawn","GrepParamsSchema","stat","readFile","DEFAULT_MAX_BYTES","isWritableFile","resolveInputPath","splitLines","decodeUtf8","formatFileHeader","computeFileTag","formatTaggedLine","resolve","displayPath","basename","defineServerTool","defineServerPlugin","toolGrep"],"sources":["../../src/services/ripgrep/index.ts","../../src/services/grepTool/index.ts","../../src/extensions/workspaces/sessions/(backend)/tool/grep.server.ts","../../generated/server.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\n\nimport { resolveInputPath } from '@agimon-ai/po-hashline/files';\n\nimport type { GrepParams } from '../../schemas/grepTool';\nimport type { RipgrepRequest, RipgrepResult } from './type';\n\n/** Search with ripgrep independently of the host. */\nexport async function runRipgrep(request: RipgrepRequest): Promise<RipgrepResult> {\n const { params, cwd, signal } = request;\n const output = await spawnRipgrep(argumentsFor(params, cwd), cwd, signal);\n if (output.trim() === '') return { content: [{ type: 'text', text: 'No matches found' }] };\n return { content: [{ type: 'text', text: limitMatches(output, params.limit) }] };\n}\n\n/** The ripgrep argv one search needs, exposed so a test can assert it without spawning. */\nexport function argumentsFor(params: GrepParams, cwd: string): string[] {\n const target = resolveInputPath(params.path ?? '.', cwd);\n const args = ['--color', 'never', '--no-heading', '--with-filename', '--line-number'];\n if (params.ignoreCase === true) args.push('--ignore-case');\n if (params.literal === true) args.push('--fixed-strings');\n if (params.context !== undefined) args.push('--context', String(params.context));\n if (params.glob !== undefined) args.push('--glob', params.glob);\n args.push('--', params.pattern, target);\n return args;\n}\n\n/**\n * Keeps at most `limit` matching lines, and every context line around them.\n *\n * A context line carries no `:<line>:` marker, which is what separates it from\n * a match, so trimming by line count alone would drop the context ripgrep was\n * asked for.\n */\nexport function limitMatches(output: string, limit: number | undefined): string {\n if (limit === undefined) return output.trimEnd();\n let matches = 0;\n const selected: string[] = [];\n for (const line of output.trimEnd().split('\\n')) {\n if (/:(\\d+):/u.test(line)) {\n matches++;\n if (matches > limit) continue;\n }\n selected.push(line);\n }\n return selected.join('\\n');\n}\n\nfunction spawnRipgrep(args: readonly string[], cwd: string, signal: AbortSignal | undefined): Promise<string> {\n return new Promise((resolveOutput, reject) => {\n const child = spawn('rg', args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });\n let stdout = '';\n let stderr = '';\n child.stdout.on('data', (chunk: Buffer) => {\n stdout += chunk.toString();\n });\n child.stderr.on('data', (chunk: Buffer) => {\n stderr += chunk.toString();\n });\n const abort = (): void => {\n child.kill('SIGTERM');\n reject(new Error('Operation aborted'));\n };\n if (signal?.aborted) {\n abort();\n return;\n }\n signal?.addEventListener('abort', abort, { once: true });\n child.once('error', (error) => {\n signal?.removeEventListener('abort', abort);\n reject(new Error(`Could not start ripgrep: ${error.message}`, { cause: error }));\n });\n child.once('close', (code) => {\n signal?.removeEventListener('abort', abort);\n // 1 is ripgrep's \"no matches\", which is a result rather than a failure.\n if (code === 0 || code === 1) {\n resolveOutput(stdout);\n return;\n }\n reject(new Error(stderr.trim() || `ripgrep exited with code ${code ?? 'unknown'}`));\n });\n });\n}\n","import { readFile, stat } from 'node:fs/promises';\nimport { basename, resolve } from 'node:path';\n\nimport type { PoHeadlessExecutionContext, PoHeadlessTool, PoHeadlessToolResult } from '@agimon-ai/po-core/headless';\nimport { formatFileHeader, formatTaggedLine, splitLines } from '@agimon-ai/po-hashline';\nimport {\n computeFileTag,\n decodeUtf8,\n displayPath,\n isWritableFile,\n resolveInputPath,\n} from '@agimon-ai/po-hashline/files';\nimport { DEFAULT_MAX_BYTES, formatSize, truncateHead, truncateLine } from '@earendil-works/pi-coding-agent';\n\nimport { GrepParamsSchema, type GrepParams } from '../../schemas/grepTool';\nimport { runRipgrep } from '../ripgrep';\n\nconst MATCH_DELIMITER = /:(\\d+):/gu;\nconst CONTEXT_DELIMITER = /-(\\d+)-/gu;\nconst NO_MATCHES = 'No matches found';\n\nexport interface GrepRow {\n readonly path: string;\n readonly line: number;\n readonly match: boolean;\n readonly native?: string;\n}\n\nexport interface GrepGroup {\n readonly path: string;\n readonly absolutePath: string;\n readonly nativeRows: string[];\n readonly rows: Map<number, boolean>;\n}\n\nexport interface GrepResult {\n content: Array<{ type: 'text'; text: string }>;\n details?: {\n readonly linesTruncated?: boolean;\n readonly truncation?: GrepTruncation;\n readonly [key: string]: unknown;\n };\n}\n\nexport interface GrepFileStats {\n isDirectory(): boolean;\n isFile(): boolean;\n}\n\nexport interface GrepFileSystem {\n stat(path: string): Promise<GrepFileStats>;\n readFile(path: string): Promise<Uint8Array>;\n}\n\nexport interface GrepTruncation {\n readonly content: string;\n readonly truncated: boolean;\n readonly truncatedBy: 'lines' | 'bytes' | null;\n readonly outputLines: number;\n}\n\nexport interface GrepOutputOperations {\n readonly maxBytes: number;\n formatSize(bytes: number): string;\n truncateHead(content: string, options: { readonly maxLines?: number }): GrepTruncation;\n truncateLine(line: string): { readonly text: string; readonly wasTruncated: boolean };\n}\nexport function createHeadlessGrepTool(): PoHeadlessTool<typeof GrepParamsSchema> {\n return {\n name: 'grep',\n label: 'grep',\n description:\n 'Search file contents using ripgrep semantics, then add exact-byte file tags and stable line anchors for writable matches. Respects .gitignore.',\n promptSnippet: 'Search file contents and return editable hashline anchors',\n parameters: GrepParamsSchema,\n executionMode: 'parallel',\n execute: async (\n _toolCallId: string,\n params: GrepParams,\n signal: AbortSignal | undefined,\n _onUpdate: ((result: PoHeadlessToolResult) => void) | undefined,\n context: PoHeadlessExecutionContext,\n ) => {\n const result = await runRipgrep({ params, cwd: context.cwd, signal });\n return tagGrepResult(result, params, context.cwd, signal);\n },\n };\n}\n\nexport function parseGrepRow(value: string): GrepRow[] {\n return grepRowCandidates(value)\n .slice(0, 1)\n .map(({ line, match, path }) => ({ line, match, path }));\n}\n\n/** Node adapters for hashline post-processing. */\nexport const nodeGrepFileSystem: GrepFileSystem = {\n stat: (path) => stat(path),\n readFile: (path) => readFile(path),\n};\n\nexport const defaultGrepOutput: GrepOutputOperations = {\n maxBytes: DEFAULT_MAX_BYTES,\n formatSize,\n truncateHead,\n truncateLine,\n};\n\nexport async function tagGrepResult(\n nativeResult: GrepResult,\n params: GrepParams,\n cwd: string,\n signal: AbortSignal | undefined,\n writable: (path: string) => Promise<boolean> = isWritableFile,\n filesystem: GrepFileSystem = nodeGrepFileSystem,\n outputOperations: GrepOutputOperations = defaultGrepOutput,\n): Promise<GrepResult> {\n const textPart = nativeResult.content.find((part) => part.type === 'text');\n if (!textPart || textPart.text === NO_MATCHES) return nativeResult;\n\n const noticeIndex = textPart.text.lastIndexOf('\\n\\n[');\n const rowsText = noticeIndex === -1 ? textPart.text : textPart.text.slice(0, noticeIndex);\n const notice = noticeIndex === -1 ? '' : textPart.text.slice(noticeIndex);\n const searchPath = resolveInputPath(params.path ?? '.', cwd);\n const searchStats = await filesystem.stat(searchPath);\n assertNotAborted(signal);\n const rows = await parseValidatedGrepRows(rowsText, searchPath, searchStats.isDirectory(), signal, filesystem);\n if (rows.length === 0) return nativeResult;\n\n const groups = groupGrepRows(rows, searchPath, searchStats.isDirectory(), cwd);\n const blocks: string[] = [];\n let taggedFiles = 0;\n let linesTruncated = nativeResult.details?.linesTruncated ?? false;\n\n for (const group of groups.values()) {\n assertNotAborted(signal);\n const canEdit = await writable(group.absolutePath);\n assertNotAborted(signal);\n if (!canEdit) {\n blocks.push(group.nativeRows.join('\\n'));\n continue;\n }\n let bytes: Uint8Array;\n try {\n bytes = await filesystem.readFile(group.absolutePath);\n } catch {\n blocks.push(group.nativeRows.join('\\n'));\n continue;\n }\n assertNotAborted(signal);\n const lines = splitLines(decodeUtf8(bytes, group.path));\n const output = [formatFileHeader(group.path, computeFileTag(bytes))];\n for (const [lineNumber, isMatch] of [...group.rows].sort(([left], [right]) => left - right)) {\n const line = lines[lineNumber - 1];\n if (line === undefined) continue;\n const compact = outputOperations.truncateLine(line);\n if (compact.wasTruncated) linesTruncated = true;\n output.push(formatTaggedLine(compact.text, lineNumber, isMatch ? '>> ' : ' ', line));\n }\n if (output.length > 1) {\n blocks.push(output.join('\\n'));\n taggedFiles++;\n } else {\n blocks.push(group.nativeRows.join('\\n'));\n }\n }\n\n if (blocks.length === 0 || taggedFiles === 0) return nativeResult;\n const truncation = outputOperations.truncateHead(blocks.join('\\n'), { maxLines: Number.MAX_SAFE_INTEGER });\n const extraNotice = truncation.truncated\n ? `\\n\\n[${outputOperations.formatSize(outputOperations.maxBytes)} tagged output limit reached]`\n : '';\n const details = {\n ...nativeResult.details,\n ...(truncation.truncated ? { truncation } : {}),\n ...(linesTruncated ? { linesTruncated: true } : {}),\n };\n assertNotAborted(signal);\n return {\n ...nativeResult,\n content: [{ type: 'text', text: `${truncation.content}${notice}${extraNotice}` }],\n details: Object.keys(details).length > 0 ? details : undefined,\n };\n}\n\nexport function groupGrepRows(\n rows: readonly GrepRow[],\n searchPath: string,\n directory: boolean,\n cwd: string,\n): Map<string, GrepGroup> {\n const groups = new Map<string, GrepGroup>();\n for (const row of rows) {\n const absolutePath = directory ? resolve(searchPath, row.path) : searchPath;\n let group = groups.get(absolutePath);\n if (!group) {\n group = { path: displayPath(absolutePath, cwd), absolutePath, nativeRows: [], rows: new Map() };\n groups.set(absolutePath, group);\n }\n if (row.native !== undefined) group.nativeRows.push(row.native);\n group.rows.set(row.line, row.match || group.rows.get(row.line) === true);\n }\n return groups;\n}\n\nasync function parseValidatedGrepRows(\n rowsText: string,\n searchPath: string,\n directory: boolean,\n signal: AbortSignal | undefined,\n filesystem: GrepFileSystem,\n): Promise<GrepRow[]> {\n const pathCache = new Map<string, boolean>();\n const rows: GrepRow[] = [];\n for (const value of rowsText.split('\\n')) {\n assertNotAborted(signal);\n let resolvedCandidate: GrepRow | undefined;\n for (const candidate of grepRowCandidates(value)) {\n if (!directory) {\n if (candidate.path === basename(searchPath) || candidate.path === searchPath) {\n rows.push({ ...candidate, native: value });\n break;\n }\n continue;\n }\n const absolutePath = resolve(searchPath, candidate.path);\n let exists = pathCache.get(absolutePath);\n if (exists === undefined) {\n exists = await filesystem\n .stat(absolutePath)\n .then((value) => value.isFile())\n .catch(() => false);\n assertNotAborted(signal);\n pathCache.set(absolutePath, exists);\n }\n if (exists) resolvedCandidate = { ...candidate, native: value };\n }\n if (resolvedCandidate) rows.push(resolvedCandidate);\n }\n return rows;\n}\n\nfunction grepRowCandidates(value: string): GrepRow[] {\n const candidates: Array<{ readonly index: number; readonly row: GrepRow }> = [];\n for (const match of value.matchAll(MATCH_DELIMITER)) {\n candidates.push({\n index: match.index,\n row: { path: value.slice(0, match.index), line: Number.parseInt(match[1] ?? '', 10), match: true },\n });\n }\n for (const match of value.matchAll(CONTEXT_DELIMITER)) {\n candidates.push({\n index: match.index,\n row: { path: value.slice(0, match.index), line: Number.parseInt(match[1] ?? '', 10), match: false },\n });\n }\n return candidates.sort((left, right) => left.index - right.index).map(({ row }) => row);\n}\n\nexport function assertNotAborted(signal: AbortSignal | undefined): void {\n if (signal?.aborted) throw new Error('Operation aborted');\n}\n","import { defineServerTool } from '@agimon-ai/po-core/extensionFile';\n\nimport { createHeadlessGrepTool } from '../../../../../services/grepTool';\n\nexport default defineServerTool(createHeadlessGrepTool);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nimport toolGrep from '../src/extensions/workspaces/sessions/(backend)/tool/grep.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-grep',\n session: (context) => ({\n get tools(): PoServerSessionPlugin['tools'] { return [via({ name: 'grep' }, at(toolGrep, context))]; },\n }),\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;;;;AAQA,eAAsB,WAAW,SAAiD;CAChF,MAAM,EAAE,QAAQ,KAAK,WAAW;CAChC,MAAM,SAAS,MAAM,aAAa,aAAa,QAAQ,GAAG,GAAG,KAAK,MAAM;CACxE,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,EAAE,SAAS,CAAC;EAAE,MAAM;EAAQ,MAAM;CAAmB,CAAC,EAAE;CACzF,OAAO,EAAE,SAAS,CAAC;EAAE,MAAM;EAAQ,MAAM,aAAa,QAAQ,OAAO,KAAK;CAAE,CAAC,EAAE;AACjF;;AAGA,SAAgB,aAAa,QAAoB,KAAuB;CACtE,MAAM,UAAA,GAASA,6BAAAA,iBAAAA,CAAiB,OAAO,QAAQ,KAAK,GAAG;CACvD,MAAM,OA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,KAAK;GAAE,MAAM,MAAM,MAAM,GAAG,MAAM,KAAK;GAAG,MAAM,OAAO,SAAS,MAAM,MAAM,IAAI,EAAE;GAAG,OAAO;EAAK;CACnG,CAAC;CAEH,KAAK,MAAM,SAAS,MAAM,SAAS,iBAAiB,GAClD,WAAW,KAAK;EACd,OAAO,MAAM;EACb,KAAK;GAAE,MAAM,MAAM,MAAM,GAAG,MAAM,KAAK;GAAG,MAAM,OAAO,SAAS,MAAM,MAAM,IAAI,EAAE;GAAG,OAAO;EAAM;CACpG,CAAC;CAEH,OAAO,WAAW,MAAM,MAAM,UAAU,KAAK,QAAQ,MAAM,KAAK,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG;AACxF;AAEA,SAAgB,iBAAiB,QAAuC;CACtE,IAAI,QAAQ,SAAS,MAAM,IAAI,MAAM,mBAAmB;AAC1D;;;ACjQA,IAAA,uBAAA,GAAeG,iCAAAA,iBAAAA,CAAiB,sBAAsB;;;ACEtD,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AACpE,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,gBAAA,GAAeC,gCAAAA,mBAAAA,CAAmB;CAC7C,MAAM;CACN,UAAU,aAAa,EACrB,IAAI,QAAwC;EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,OAAO,GAAG,GAAGC,qBAAU,OAAO,CAAC,CAAC;CAAG,EACvG;AACF,CAAC"}
1
+ {"version":3,"file":"server.cjs","names":["DEFAULT_MAX_BYTES","resolveInputPath","spawn","GrepParamsSchema","isWritableFile","resolveInputPath","withAbortSignal","BACKGROUND_CONTEXT","readBoundedFile","FileTooLargeError","splitLines","decodeUtf8","formatFileHeader","computeFileTag","formatTaggedLine","resolve","displayPath","getOrThrow","basename","defineServerTool","PO_FS_SERVICE","requirePoFs","defineServerPlugin","toolGrep"],"sources":["../../src/services/grepHost/index.ts","../../src/services/matchLimit/index.ts","../../src/services/ripgrep/index.ts","../../src/services/grepTool/index.ts","../../src/extensions/workspaces/sessions/(backend)/tool/grep.server.ts","../../generated/server.ts"],"sourcesContent":["import { DEFAULT_MAX_BYTES, formatSize, truncateHead, truncateLine } from '@earendil-works/pi-coding-agent';\n\n// The edge build replaces this host composition with portable output operations.\nexport const defaultGrepOutput = {\n maxBytes: DEFAULT_MAX_BYTES,\n formatSize,\n truncateHead,\n truncateLine,\n};\n","/**\n * Keeps at most `limit` matching lines, and every context line around them.\n *\n * A context line carries no `:<line>:` marker, which is what separates it from\n * a match, so trimming by line count alone would drop the context ripgrep was\n * asked for.\n */\nexport function limitMatches(output: string, limit: number | undefined): string {\n if (limit === undefined) return output.trimEnd();\n let matches = 0;\n const selected: string[] = [];\n for (const line of output.trimEnd().split('\\n')) {\n if (/:(\\d+):/u.test(line)) {\n matches++;\n if (matches > limit) continue;\n }\n selected.push(line);\n }\n return selected.join('\\n');\n}\n","import { spawn } from 'node:child_process';\n\nimport { recordRipgrepOutput } from '@agimon-ai/po-core/platform';\nimport { resolveInputPath } from '@agimon-ai/po-hashline/files';\n\nimport type { GrepParams } from '../../schemas/grepTool';\nimport { limitMatches } from '../matchLimit';\nimport type { RipgrepRequest, RipgrepResult } from './type';\n\n/** Search with ripgrep independently of the host. */\nexport async function runRipgrep(request: RipgrepRequest): Promise<RipgrepResult> {\n const { params, cwd, signal } = request;\n const { stdout, truncated } = await spawnRipgrep(argumentsFor(params, cwd), cwd, signal);\n return {\n content: [{ type: 'text', text: stdout.trim() === '' ? 'No matches found' : limitMatches(stdout, params.limit) }],\n ...(truncated ? { details: { truncated: true } } : {}),\n };\n}\n\n/** The ripgrep argv one search needs, exposed so a test can assert it without spawning. */\nexport function argumentsFor(params: GrepParams, cwd: string): string[] {\n const target = resolveInputPath(params.path ?? '.', cwd);\n const args = ['--color', 'never', '--no-heading', '--with-filename', '--line-number'];\n if (params.ignoreCase === true) args.push('--ignore-case');\n if (params.literal === true) args.push('--fixed-strings');\n if (params.context !== undefined) args.push('--context', String(params.context));\n if (params.glob !== undefined) args.push('--glob', params.glob);\n args.push('--', params.pattern, target);\n return args;\n}\n\nexport { limitMatches };\n\nfunction spawnRipgrep(\n args: readonly string[],\n cwd: string,\n signal: AbortSignal | undefined,\n): Promise<{ stdout: string; truncated: boolean }> {\n return new Promise((resolveOutput, reject) => {\n const child = spawn('rg', args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });\n const stdout: Buffer[] = [];\n const stderr: Buffer[] = [];\n let stdoutBytes = 0;\n let stderrBytes = 0;\n let truncated = false;\n const collect = (chunks: Buffer[], chunk: Buffer, bytes: number, cap: number): number => {\n if (truncated) return bytes;\n const retained = Math.min(chunk.length, cap - bytes);\n if (retained > 0) chunks.push(Buffer.from(chunk.subarray(0, retained)));\n recordRipgrepOutput(retained, bytes + retained >= cap);\n bytes += retained;\n if (bytes >= cap) {\n truncated = true;\n child.kill('SIGTERM');\n }\n return bytes;\n };\n child.stdout.on('data', (chunk: Buffer) => {\n stdoutBytes = collect(stdout, chunk, stdoutBytes, 8 * 1024 * 1024);\n });\n child.stderr.on('data', (chunk: Buffer) => {\n stderrBytes = collect(stderr, chunk, stderrBytes, 64 * 1024);\n });\n const abort = (): void => {\n child.kill('SIGTERM');\n reject(new Error('Operation aborted'));\n };\n if (signal?.aborted) {\n abort();\n return;\n }\n signal?.addEventListener('abort', abort, { once: true });\n child.once('error', (error) => {\n signal?.removeEventListener('abort', abort);\n reject(new Error(`Could not start ripgrep: ${error.message}`, { cause: error }));\n });\n child.once('close', (code) => {\n signal?.removeEventListener('abort', abort);\n // 1 is ripgrep's \"no matches\", which is a result rather than a failure.\n if (truncated || code === 0 || code === 1) {\n resolveOutput({ stdout: Buffer.concat(stdout, stdoutBytes).toString('utf8'), truncated });\n return;\n }\n reject(\n new Error(\n Buffer.concat(stderr, stderrBytes).toString('utf8').trim() || `ripgrep exited with code ${code ?? 'unknown'}`,\n ),\n );\n });\n });\n}\n","import { basename, resolve } from 'node:path';\n\nimport type { PoHeadlessExecutionContext, PoHeadlessTool, PoHeadlessToolResult } from '@agimon-ai/po-core/headless';\nimport {\n BACKGROUND_CONTEXT,\n FileTooLargeError,\n getOrThrow,\n readBoundedFile,\n withAbortSignal,\n type FileSystem,\n} from '@agimon-ai/po-core/platform';\nimport { formatFileHeader, formatTaggedLine, splitLines } from '@agimon-ai/po-hashline';\nimport {\n computeFileTag,\n decodeUtf8,\n displayPath,\n isWritableFile,\n resolveInputPath,\n} from '@agimon-ai/po-hashline/files';\n\nimport { GrepParamsSchema, type GrepParams } from '../../schemas/grepTool';\nimport { defaultGrepOutput } from '../grepHost';\nimport { runRipgrep } from '../ripgrep';\n\nconst MATCH_DELIMITER = /:(\\d+):/gu;\nconst CONTEXT_DELIMITER = /-(\\d+)-/gu;\nconst NO_MATCHES = 'No matches found';\n\nexport interface GrepRow {\n readonly path: string;\n readonly line: number;\n readonly match: boolean;\n readonly native?: string;\n}\n\nexport interface GrepGroup {\n readonly path: string;\n readonly absolutePath: string;\n readonly nativeRows: string[];\n readonly rows: Map<number, boolean>;\n}\n\nexport interface GrepResult {\n content: Array<{ type: 'text'; text: string }>;\n details?: {\n readonly linesTruncated?: boolean;\n readonly truncation?: GrepTruncation;\n readonly [key: string]: unknown;\n };\n}\n\nexport interface GrepTruncation {\n readonly content: string;\n readonly truncated: boolean;\n readonly truncatedBy: 'lines' | 'bytes' | null;\n readonly outputLines: number;\n}\n\nexport interface GrepOutputOperations {\n readonly maxBytes: number;\n formatSize(bytes: number): string;\n truncateHead(content: string, options: { readonly maxLines?: number }): GrepTruncation;\n truncateLine(line: string): { readonly text: string; readonly wasTruncated: boolean };\n}\nexport function createHeadlessGrepTool(\n filesystem: FileSystem | (() => FileSystem),\n): PoHeadlessTool<typeof GrepParamsSchema> {\n return {\n name: 'grep',\n label: 'grep',\n description:\n 'Search file contents using ripgrep semantics, then add exact-byte file tags and stable line anchors for writable matches. Respects .gitignore.',\n promptSnippet: 'Search file contents and return editable hashline anchors',\n parameters: GrepParamsSchema,\n executionMode: 'parallel',\n execute: async (\n _toolCallId: string,\n params: GrepParams,\n signal: AbortSignal | undefined,\n _onUpdate: ((result: PoHeadlessToolResult) => void) | undefined,\n context: PoHeadlessExecutionContext,\n ) => {\n const session = typeof filesystem === 'function' ? filesystem() : filesystem;\n const result = await runRipgrep({ params, cwd: context.cwd, signal, filesystem: session });\n return tagGrepResult(result, params, context.cwd, signal, session);\n },\n };\n}\n\nexport function parseGrepRow(value: string): GrepRow[] {\n return grepRowCandidates(value)\n .slice(0, 1)\n .map(({ line, match, path }) => ({ line, match, path }));\n}\n\nexport async function tagGrepResult(\n nativeResult: GrepResult,\n params: GrepParams,\n cwd: string,\n signal: AbortSignal | undefined,\n filesystem: FileSystem,\n writable: (path: string) => Promise<boolean> = isWritableFile,\n outputOperations: GrepOutputOperations = defaultGrepOutput,\n): Promise<GrepResult> {\n const textPart = nativeResult.content.find((part) => part.type === 'text');\n if (!textPart || textPart.text === NO_MATCHES) return nativeResult;\n\n const noticeIndex = textPart.text.lastIndexOf('\\n\\n[');\n const rowsText = noticeIndex === -1 ? textPart.text : textPart.text.slice(0, noticeIndex);\n const notice = noticeIndex === -1 ? '' : textPart.text.slice(noticeIndex);\n const searchPath = resolveInputPath(params.path ?? '.', cwd);\n assertNotAborted(signal);\n const context = signal ? withAbortSignal(signal, BACKGROUND_CONTEXT) : BACKGROUND_CONTEXT;\n const searchStats = await grepFileInfo(filesystem, searchPath, signal);\n assertNotAborted(signal);\n const rows = await parseValidatedGrepRows(rowsText, searchPath, searchStats.kind === 'directory', signal, filesystem);\n if (rows.length === 0) return nativeResult;\n\n const groups = groupGrepRows(rows, searchPath, searchStats.kind === 'directory', cwd);\n const blocks: string[] = [];\n let changedFiles = 0;\n let linesTruncated = nativeResult.details?.linesTruncated ?? false;\n\n for (const group of groups.values()) {\n assertNotAborted(signal);\n const canEdit = await writable(group.absolutePath);\n assertNotAborted(signal);\n if (!canEdit) {\n blocks.push(group.nativeRows.join('\\n'));\n continue;\n }\n let bytes: Uint8Array;\n try {\n bytes = await readBoundedFile(filesystem, group.absolutePath, 8 * 1024 * 1024, context);\n } catch (error) {\n assertNotAborted(signal);\n if (error instanceof FileTooLargeError) {\n blocks.push(`${group.nativeRows.join('\\n')}\\n[${group.path}: anchors omitted (file over 8 MiB)]`);\n changedFiles++;\n continue;\n }\n blocks.push(group.nativeRows.join('\\n'));\n continue;\n }\n assertNotAborted(signal);\n const lines = splitLines(decodeUtf8(bytes, group.path));\n const output = [formatFileHeader(group.path, computeFileTag(bytes))];\n for (const [lineNumber, isMatch] of [...group.rows].sort(([left], [right]) => left - right)) {\n const line = lines[lineNumber - 1];\n if (line === undefined) continue;\n const compact = outputOperations.truncateLine(line);\n if (compact.wasTruncated) linesTruncated = true;\n output.push(formatTaggedLine(compact.text, lineNumber, isMatch ? '>> ' : ' ', line));\n }\n if (output.length > 1) {\n blocks.push(output.join('\\n'));\n changedFiles++;\n } else {\n blocks.push(group.nativeRows.join('\\n'));\n }\n }\n\n if (blocks.length === 0 || changedFiles === 0) return nativeResult;\n const truncation = outputOperations.truncateHead(blocks.join('\\n'), { maxLines: Number.MAX_SAFE_INTEGER });\n const extraNotice = truncation.truncated\n ? `\\n\\n[${outputOperations.formatSize(outputOperations.maxBytes)} tagged output limit reached]`\n : '';\n const details = {\n ...nativeResult.details,\n ...(truncation.truncated ? { truncation } : {}),\n ...(linesTruncated ? { linesTruncated: true } : {}),\n };\n assertNotAborted(signal);\n return {\n ...nativeResult,\n content: [{ type: 'text', text: `${truncation.content}${notice}${extraNotice}` }],\n details: Object.keys(details).length > 0 ? details : undefined,\n };\n}\n\nexport function groupGrepRows(\n rows: readonly GrepRow[],\n searchPath: string,\n directory: boolean,\n cwd: string,\n): Map<string, GrepGroup> {\n const groups = new Map<string, GrepGroup>();\n for (const row of rows) {\n const absolutePath = directory ? resolve(searchPath, row.path) : searchPath;\n let group = groups.get(absolutePath);\n if (!group) {\n group = { path: displayPath(absolutePath, cwd), absolutePath, nativeRows: [], rows: new Map() };\n groups.set(absolutePath, group);\n }\n if (row.native !== undefined) group.nativeRows.push(row.native);\n group.rows.set(row.line, row.match || group.rows.get(row.line) === true);\n }\n return groups;\n}\n\n// fileInfo reports links themselves; grep validation historically follows their targets.\nasync function grepFileInfo(filesystem: FileSystem, path: string, signal: AbortSignal | undefined) {\n const context = signal ? withAbortSignal(signal, BACKGROUND_CONTEXT) : BACKGROUND_CONTEXT;\n const info = getOrThrow(await filesystem.fileInfo(path, context));\n if (info.kind !== 'symlink') return info;\n const target = getOrThrow(await filesystem.canonicalPath(path, context));\n return getOrThrow(await filesystem.fileInfo(target, context));\n}\n\nasync function parseValidatedGrepRows(\n rowsText: string,\n searchPath: string,\n directory: boolean,\n signal: AbortSignal | undefined,\n filesystem: FileSystem,\n): Promise<GrepRow[]> {\n const pathCache = new Map<string, boolean>();\n const rows: GrepRow[] = [];\n for (const value of rowsText.split('\\n')) {\n assertNotAborted(signal);\n let resolvedCandidate: GrepRow | undefined;\n for (const candidate of grepRowCandidates(value)) {\n if (!directory) {\n if (candidate.path === basename(searchPath) || candidate.path === searchPath) {\n rows.push({ ...candidate, native: value });\n break;\n }\n continue;\n }\n const absolutePath = resolve(searchPath, candidate.path);\n let exists = pathCache.get(absolutePath);\n if (exists === undefined) {\n exists = await grepFileInfo(filesystem, absolutePath, signal)\n .then((value) => value.kind === 'file')\n .catch(() => false);\n assertNotAborted(signal);\n pathCache.set(absolutePath, exists);\n }\n if (exists) resolvedCandidate = { ...candidate, native: value };\n }\n if (resolvedCandidate) rows.push(resolvedCandidate);\n }\n return rows;\n}\n\nfunction grepRowCandidates(value: string): GrepRow[] {\n const candidates: Array<{ readonly index: number; readonly row: GrepRow }> = [];\n for (const match of value.matchAll(MATCH_DELIMITER)) {\n candidates.push({\n index: match.index,\n row: { path: value.slice(0, match.index), line: Number.parseInt(match[1] ?? '', 10), match: true },\n });\n }\n for (const match of value.matchAll(CONTEXT_DELIMITER)) {\n candidates.push({\n index: match.index,\n row: { path: value.slice(0, match.index), line: Number.parseInt(match[1] ?? '', 10), match: false },\n });\n }\n return candidates.sort((left, right) => left.index - right.index).map(({ row }) => row);\n}\n\nexport function assertNotAborted(signal: AbortSignal | undefined): void {\n if (signal?.aborted) throw new Error('Operation aborted');\n}\n","import { defineServerTool } from '@agimon-ai/po-core/extensionFile';\nimport { PO_FS_SERVICE, requirePoFs, type FileSystem } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createHeadlessGrepTool } from '../../../../../services/grepTool';\n\nexport default defineServerTool(({ context }: PoServerPluginContext) => {\n let filesystem: FileSystem | undefined;\n context.inject([PO_FS_SERVICE], (scoped) => {\n const bound = requirePoFs(scoped);\n filesystem = bound;\n return () => {\n if (filesystem === bound) filesystem = undefined;\n };\n });\n return createHeadlessGrepTool(() => {\n if (!filesystem) throw new Error('Grep filesystem service is unavailable.');\n return filesystem;\n });\n});\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nimport toolGrep from '../src/extensions/workspaces/sessions/(backend)/tool/grep.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => {\n if (value === undefined) return undefined as T;\n const declaration = value as { relations?: readonly Record<string, unknown>[] };\n return { ...identity, ...declaration, ...(declaration.relations === undefined ? {} : {\n relations: declaration.relations.map((relation) => ({ evidence: 'declared', ...relation })),\n }) } as T;\n};\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-grep',\n session: (context) => ({\n get tools(): PoServerSessionPlugin['tools'] { return [via({ name: 'grep' }, at(toolGrep, context))]; },\n }),\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;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Y,MAAM;EAChC,aAAa;EACb,aAAa;GACX,IAAI,eAAe,OAAO,aAAa,KAAA;EACzC;CACF,CAAC;CACD,OAAO,6BAA6B;EAClC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,yCAAyC;EAC1E,OAAO;CACT,CAAC;AACH,CAAC;;;ACbD,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AACpE,MAAM,OAAU,UAAmC,UAAsB;CACvE,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,MAAM,cAAc;CACpB,OAAO;EAAE,GAAG;EAAU,GAAG;EAAa,GAAI,YAAY,cAAc,KAAA,IAAY,CAAC,IAAI,EACnF,WAAW,YAAY,UAAU,KAAK,cAAc;GAAE,UAAU;GAAY,GAAG;EAAS,EAAE,EAC5F;CAAG;AACL;AAEA,MAAa,gBAAA,GAAeC,gCAAAA,mBAAAA,CAAmB;CAC7C,MAAM;CACN,UAAU,aAAa,EACrB,IAAI,QAAwC;EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,OAAO,GAAG,GAAGC,qBAAU,OAAO,CAAC,CAAC;CAAG,EACvG;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAWa,wDAAY"}
1
+ {"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAgBa,wDAAY"}