@agimon-ai/po-grep 0.0.0-alpha.0 → 0.0.0-stage
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/README.md +2 -65
- package/package.json +3 -131
- package/LICENSE +0 -22
- package/dist/apiContracts.cjs +0 -17
- package/dist/apiContracts.cjs.map +0 -1
- package/dist/apiContracts.d.mts +0 -53
- package/dist/apiContracts.d.mts.map +0 -1
- package/dist/apiContracts.mjs +0 -13
- package/dist/apiContracts.mjs.map +0 -1
- package/dist/extensions/mcp-ui.mjs +0 -24
- package/dist/extensions/mcp-ui.mjs.map +0 -1
- package/dist/extensions/mcp.cjs +0 -323
- package/dist/extensions/mcp.cjs.map +0 -1
- package/dist/extensions/mcp.d.mts +0 -5
- package/dist/extensions/mcp.d.mts.map +0 -1
- package/dist/extensions/mcp.mjs +0 -318
- package/dist/extensions/mcp.mjs.map +0 -1
- package/dist/extensions/server.cjs +0 -297
- package/dist/extensions/server.cjs.map +0 -1
- package/dist/extensions/server.d.mts +0 -5
- package/dist/extensions/server.d.mts.map +0 -1
- package/dist/extensions/server.mjs +0 -292
- package/dist/extensions/server.mjs.map +0 -1
- package/dist/extensions/web.mjs +0 -102
- package/dist/extensions/web.mjs.map +0 -1
- package/dist/grepTool-C2GQiJl4.cjs +0 -26
- package/dist/grepTool-C2GQiJl4.cjs.map +0 -1
- package/dist/grepTool-D1RuNGXK.mjs +0 -21
- package/dist/grepTool-D1RuNGXK.mjs.map +0 -1
- package/dist/index.cjs +0 -3
- package/dist/index.d.mts +0 -15
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -2
package/README.md
CHANGED
|
@@ -1,66 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Temporary Holding Version
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Part of the [Po distribution](https://www.npmjs.com/package/@agimon-ai/po).
|
|
6
|
-
|
|
7
|
-
The native server facet owns `grep`. Its private ripgrep service searches files, then attaches exact-byte file tags and stable three-letter anchors to writable matching or context lines. Non-writable files retain plain output. `@agimon-ai/po-read` and `@agimon-ai/po-edit` use the same hashline protocol.
|
|
8
|
-
|
|
9
|
-
> **Alpha:** tool and protocol contracts may change between releases.
|
|
10
|
-
|
|
11
|
-
## Requirements
|
|
12
|
-
|
|
13
|
-
- Node.js 24 or newer
|
|
14
|
-
- A Po native server host
|
|
15
|
-
|
|
16
|
-
## Install
|
|
17
|
-
|
|
18
|
-
Select `@agimon-ai/po-grep` in `.po/modes.yaml` and run `po sync`. The package's `poServer` metadata names its built server facet. There is no standalone Pi entry or tool-registration ordering requirement against `po-ui`.
|
|
19
|
-
|
|
20
|
-
Install `@agimon-ai/po-edit` when the model should apply the emitted anchors.
|
|
21
|
-
|
|
22
|
-
## Tool protocol
|
|
23
|
-
|
|
24
|
-
Writable search results group matching and context lines beneath an exact-byte
|
|
25
|
-
file header:
|
|
26
|
-
|
|
27
|
-
```text
|
|
28
|
-
@file src/example.ts#A1b2C3d4
|
|
29
|
-
4#def|const previous = true;
|
|
30
|
-
>> 5#abc|const match = true;
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
The eight-character file tag and three-letter line anchors are model-facing protocol data. Po's
|
|
34
|
-
human renderer hides the protocol tags and anchors while retaining file paths, line numbers, match
|
|
35
|
-
markers, and syntax highlighting.
|
|
36
|
-
|
|
37
|
-
## Attribution
|
|
38
|
-
|
|
39
|
-
The hashline protocol and FNV anchor approach are adapted from
|
|
40
|
-
[Phi's writetool](https://github.com/pulseaiclub/phi/tree/main/internal/tools/writetool), licensed
|
|
41
|
-
under MIT by pulseaiclub. Po uses an exact-byte SHA-256 file tag as an intentional compatibility
|
|
42
|
-
boundary.
|
|
43
|
-
|
|
44
|
-
## Public API
|
|
45
|
-
|
|
46
|
-
```ts
|
|
47
|
-
import { GrepParamsSchema } from '@agimon-ai/po-grep';
|
|
48
|
-
import type { GrepParams } from '@agimon-ai/po-grep';
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Development
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
pnpm build
|
|
55
|
-
pnpm typecheck
|
|
56
|
-
pnpm test
|
|
57
|
-
pnpm lint
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Maintained by [Agimon](https://agimon.ai/about).
|
|
61
|
-
|
|
62
|
-
## License
|
|
63
|
-
|
|
64
|
-
MIT
|
|
65
|
-
|
|
66
|
-
The server tool route lives in `src/extensions/workspaces/sessions/(backend)/tool/grep.server.ts` and delegates to the private grep service. Flat `src/exports` files only forward the public schema and parameter type; the tool factory is not public.
|
|
3
|
+
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|
package/package.json
CHANGED
|
@@ -1,134 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-grep",
|
|
3
|
-
"version": "0.0.0-
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"ai",
|
|
7
|
-
"coding-agent",
|
|
8
|
-
"developer-tools",
|
|
9
|
-
"grep",
|
|
10
|
-
"hashline",
|
|
11
|
-
"pi-coding-agent",
|
|
12
|
-
"pi-extension",
|
|
13
|
-
"pi-package",
|
|
14
|
-
"po"
|
|
15
|
-
],
|
|
16
|
-
"homepage": "https://agimon.ai",
|
|
17
|
-
"bugs": {
|
|
18
|
-
"url": "https://github.com/AgiFlow/po/issues"
|
|
19
|
-
},
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"author": "Vuong Ngo",
|
|
22
|
-
"repository": {
|
|
23
|
-
"type": "git",
|
|
24
|
-
"url": "git+https://github.com/AgiFlow/po.git",
|
|
25
|
-
"directory": "packages/default/po-grep"
|
|
26
|
-
},
|
|
27
|
-
"files": [
|
|
28
|
-
"dist"
|
|
29
|
-
],
|
|
30
|
-
"type": "module",
|
|
31
|
-
"main": "./dist/index.cjs",
|
|
32
|
-
"module": "./dist/index.mjs",
|
|
33
|
-
"types": "./dist/index.d.mts",
|
|
34
|
-
"jsnext:main": "./dist/index.mjs",
|
|
35
|
-
"exports": {
|
|
36
|
-
".": {
|
|
37
|
-
"types": "./dist/index.d.mts",
|
|
38
|
-
"import": "./dist/index.mjs",
|
|
39
|
-
"require": "./dist/index.cjs"
|
|
40
|
-
},
|
|
41
|
-
"./apiContracts": {
|
|
42
|
-
"types": "./dist/apiContracts.d.mts",
|
|
43
|
-
"import": "./dist/apiContracts.mjs",
|
|
44
|
-
"require": "./dist/apiContracts.cjs"
|
|
45
|
-
},
|
|
46
|
-
"./extensions/server": {
|
|
47
|
-
"types": "./dist/extensions/server.d.mts",
|
|
48
|
-
"import": "./dist/extensions/server.mjs",
|
|
49
|
-
"require": "./dist/extensions/server.cjs"
|
|
50
|
-
},
|
|
51
|
-
"./extensions/web": {
|
|
52
|
-
"import": "./dist/extensions/web.mjs"
|
|
53
|
-
},
|
|
54
|
-
"./package.json": "./package.json"
|
|
55
|
-
},
|
|
56
|
-
"publishConfig": {
|
|
57
|
-
"access": "public"
|
|
58
|
-
},
|
|
59
|
-
"dependencies": {
|
|
60
|
-
"@agimon-ai/po-core": "0.0.0-alpha.0",
|
|
61
|
-
"@agimon-ai/po-hashline": "0.0.0-alpha.0",
|
|
62
|
-
"@agimon-ai/po-ui": "0.0.0-alpha.0",
|
|
63
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.0",
|
|
64
|
-
"@deepseek-ai/cordis": "4.0.4",
|
|
65
|
-
"typebox": "1.3.34"
|
|
66
|
-
},
|
|
67
|
-
"devDependencies": {
|
|
68
|
-
"@agimon-ai/po-build": "0.0.0-alpha.0",
|
|
69
|
-
"@earendil-works/pi-coding-agent": "1.0.2",
|
|
70
|
-
"@tanstack/react-store": "0.11.2",
|
|
71
|
-
"@tanstack/store": "0.11.2",
|
|
72
|
-
"@types/node": "26.6.4",
|
|
73
|
-
"@types/react": "19.3.0",
|
|
74
|
-
"@vitest/coverage-v8": "5.0.3",
|
|
75
|
-
"@vscode/ripgrep": "1.18.0",
|
|
76
|
-
"react": "19.3.0",
|
|
77
|
-
"react-dom": "19.3.0",
|
|
78
|
-
"tsdown": "0.23.0",
|
|
79
|
-
"typescript": "7.0.2",
|
|
80
|
-
"vitest": "5.0.3"
|
|
81
|
-
},
|
|
82
|
-
"peerDependencies": {
|
|
83
|
-
"@earendil-works/pi-coding-agent": "1.0.2"
|
|
84
|
-
},
|
|
85
|
-
"peerDependenciesMeta": {
|
|
86
|
-
"@earendil-works/pi-coding-agent": {
|
|
87
|
-
"optional": true
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
"engines": {
|
|
91
|
-
"node": ">=24"
|
|
92
|
-
},
|
|
93
|
-
"poMcp": {
|
|
94
|
-
"entry": "./generated/mcp.ts",
|
|
95
|
-
"dist": "./dist/extensions/mcp.mjs",
|
|
96
|
-
"scopes": [
|
|
97
|
-
"session"
|
|
98
|
-
],
|
|
99
|
-
"ui": {
|
|
100
|
-
"entry": "./generated/mcp-ui.ts",
|
|
101
|
-
"dist": "./dist/extensions/mcp-ui.mjs",
|
|
102
|
-
"widgets": [
|
|
103
|
-
"@agimon-ai/po-grep/grep"
|
|
104
|
-
]
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"poServer": {
|
|
108
|
-
"entry": "./generated/server.ts",
|
|
109
|
-
"dist": "./dist/extensions/server.mjs",
|
|
110
|
-
"scopes": [
|
|
111
|
-
"session"
|
|
112
|
-
],
|
|
113
|
-
"contracts": {
|
|
114
|
-
"entry": "./src/exports/apiContracts.ts",
|
|
115
|
-
"dist": "./dist/apiContracts.mjs"
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
"poWeb": {
|
|
119
|
-
"pluginId": "grep",
|
|
120
|
-
"channels": [],
|
|
121
|
-
"client": "./dist/extensions/web.mjs",
|
|
122
|
-
"scopes": [
|
|
123
|
-
"session"
|
|
124
|
-
]
|
|
125
|
-
},
|
|
126
|
-
"scripts": {
|
|
127
|
-
"build": "tsdown && tsdown --config tsdown.mcp.config.ts",
|
|
128
|
-
"build:mcp": "tsdown --config tsdown.mcp.config.ts",
|
|
129
|
-
"test": "vitest --run",
|
|
130
|
-
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.web.json && tsc --noEmit -p tsconfig.mcp.json",
|
|
131
|
-
"lint": "oxlint . && oxfmt . --check",
|
|
132
|
-
"fixcode": "oxlint . --fix && oxfmt ."
|
|
133
|
-
}
|
|
3
|
+
"version": "0.0.0-stage",
|
|
4
|
+
"stub": true,
|
|
5
|
+
"description": "Temporary package placeholder for staged publishing"
|
|
134
6
|
}
|
package/LICENSE
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Vuong Ngo
|
|
4
|
-
Copyright (c) 2026 pulseaiclub
|
|
5
|
-
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
in the Software without restriction, including without limitation the rights
|
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
furnished to do so, subject to the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
SOFTWARE.
|
package/dist/apiContracts.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
//#region src/schemas/apiContracts.ts
|
|
6
|
-
/** This facet contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */
|
|
7
|
-
const apiContracts = (0, require("@agimon-ai/po-core/apiContracts").defineApiContract)({
|
|
8
|
-
version: 1,
|
|
9
|
-
http: [],
|
|
10
|
-
sockets: [],
|
|
11
|
-
dynamic: []
|
|
12
|
-
});
|
|
13
|
-
//#endregion
|
|
14
|
-
exports.apiContracts = apiContracts;
|
|
15
|
-
exports.default = apiContracts;
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=apiContracts.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.cjs","names":["defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract } from '@agimon-ai/po-core/apiContracts';\n\n/** This facet contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */\nexport const apiContracts = defineApiContract({ version: 1, http: [], sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;;;;AAGA,MAAa,gBAAA,4CAAeA,CAAAA,CAAAA,kBAAAA,CAAkB;CAAE,SAAS;CAAG,MAAM,CAAC;CAAG,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
|
package/dist/apiContracts.d.mts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
//#region src/schemas/apiContracts.d.ts
|
|
2
|
-
/** This facet contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */
|
|
3
|
-
export declare const apiContracts: {
|
|
4
|
-
version: 1;
|
|
5
|
-
protocols?: Record<string, string> | undefined;
|
|
6
|
-
schemas?: Record<string, boolean | object> | undefined;
|
|
7
|
-
http: {
|
|
8
|
-
id: string;
|
|
9
|
-
scope: "global" | "session" | "workspace";
|
|
10
|
-
basePath?: string | undefined;
|
|
11
|
-
path: string;
|
|
12
|
-
method: "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT";
|
|
13
|
-
description: string;
|
|
14
|
-
availability?: string | undefined;
|
|
15
|
-
authentication: "device" | "none" | "owner";
|
|
16
|
-
parameters?: {
|
|
17
|
-
name: string;
|
|
18
|
-
in: "header" | "path" | "query";
|
|
19
|
-
required: boolean;
|
|
20
|
-
schema: boolean | object;
|
|
21
|
-
}[] | undefined;
|
|
22
|
-
body?: {
|
|
23
|
-
contentType: string;
|
|
24
|
-
contentTypes?: string[] | undefined;
|
|
25
|
-
required: boolean;
|
|
26
|
-
schema: boolean | object;
|
|
27
|
-
} | undefined;
|
|
28
|
-
responses: Record<string, {
|
|
29
|
-
description: string;
|
|
30
|
-
contentType?: string | undefined;
|
|
31
|
-
schema?: boolean | object | undefined;
|
|
32
|
-
events?: Record<string, boolean | object> | undefined;
|
|
33
|
-
}>;
|
|
34
|
-
}[];
|
|
35
|
-
sockets: {
|
|
36
|
-
id: string;
|
|
37
|
-
scope: "global" | "session" | "workspace";
|
|
38
|
-
description: string;
|
|
39
|
-
availability?: string | undefined;
|
|
40
|
-
service: string;
|
|
41
|
-
member: string;
|
|
42
|
-
direction: "client-to-server" | "server-to-client";
|
|
43
|
-
kind: "channel" | "method" | "state";
|
|
44
|
-
input: boolean | object;
|
|
45
|
-
output?: boolean | object | undefined;
|
|
46
|
-
errors?: boolean | object | undefined;
|
|
47
|
-
}[];
|
|
48
|
-
dynamic: string[];
|
|
49
|
-
gaps?: string[] | undefined;
|
|
50
|
-
};
|
|
51
|
-
//#endregion
|
|
52
|
-
export { apiContracts as default };
|
|
53
|
-
//# sourceMappingURL=apiContracts.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBAGa"}
|
package/dist/apiContracts.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { defineApiContract } from "@agimon-ai/po-core/apiContracts";
|
|
2
|
-
//#region src/schemas/apiContracts.ts
|
|
3
|
-
/** This facet contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */
|
|
4
|
-
const apiContracts = defineApiContract({
|
|
5
|
-
version: 1,
|
|
6
|
-
http: [],
|
|
7
|
-
sockets: [],
|
|
8
|
-
dynamic: []
|
|
9
|
-
});
|
|
10
|
-
//#endregion
|
|
11
|
-
export { apiContracts, apiContracts as default };
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=apiContracts.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract } from '@agimon-ai/po-core/apiContracts';\n\n/** This facet contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */\nexport const apiContracts = defineApiContract({ version: 1, http: [], sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAa,eAAe,kBAAkB;CAAE,SAAS;CAAG,MAAM,CAAC;CAAG,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defineMcpWidget } from "@agimon-ai/po-core/web";
|
|
2
|
-
import { McpToolFields, McpToolFrame, McpToolOutput } from "@agimon-ai/po-web-components";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
//#region src/extensions/workspaces/sessions/(frontend)/tool/grep.mcp.tsx
|
|
5
|
-
function GrepMcpWidget(props) {
|
|
6
|
-
return /* @__PURE__ */ jsxs(McpToolFrame, {
|
|
7
|
-
...props,
|
|
8
|
-
title: "Search file contents",
|
|
9
|
-
children: [/* @__PURE__ */ jsx(McpToolFields, { fields: [
|
|
10
|
-
["Pattern", props.args.pattern],
|
|
11
|
-
["Path", props.args.path],
|
|
12
|
-
["Glob", props.args.glob],
|
|
13
|
-
["Ignore case", props.args.ignoreCase],
|
|
14
|
-
["Limit", props.args.limit]
|
|
15
|
-
] }), /* @__PURE__ */ jsx(McpToolOutput, { result: props.result })]
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region generated/mcp-ui.ts
|
|
20
|
-
const widgets = { "@agimon-ai/po-grep/grep": defineMcpWidget(GrepMcpWidget) };
|
|
21
|
-
//#endregion
|
|
22
|
-
export { widgets };
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=mcp-ui.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-ui.mjs","names":["Widget0"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/grep.mcp.tsx","../../generated/mcp-ui.ts"],"sourcesContent":["import { defineMcpWidget, type DoomMcpWidgetProps } from '@agimon-ai/po-core/web';\nimport { McpToolFrame, McpToolFields, McpToolOutput } from '@agimon-ai/po-web-components';\n\nfunction GrepMcpWidget(props: DoomMcpWidgetProps) {\n return (\n <McpToolFrame {...props} title=\"Search file contents\">\n <McpToolFields\n fields={[\n ['Pattern', props.args.pattern],\n ['Path', props.args.path],\n ['Glob', props.args.glob],\n ['Ignore case', props.args.ignoreCase],\n ['Limit', props.args.limit],\n ]}\n />\n <McpToolOutput result={props.result} />\n </McpToolFrame>\n );\n}\n\nexport default defineMcpWidget(GrepMcpWidget);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport type { ComponentType } from 'react';\nimport type { DoomMcpWidgetProps } from '@agimon-ai/po-core/mcpWidget';\nimport Widget0 from \"../src/extensions/workspaces/sessions/(frontend)/tool/grep.mcp\";\n\nexport const widgets: Readonly<Record<string, ComponentType<DoomMcpWidgetProps>>> = {\n \"@agimon-ai/po-grep/grep\": Widget0,\n};\n"],"mappings":";;;;AAGA,SAAS,cAAc,OAA2B;CAChD,OACE,qBAAC,cAAD;EAAc,GAAI;EAAO,OAAM;EAA/B,UAAA,CACE,oBAAC,eAAD,EACE,QAAQ;GACN,CAAC,WAAW,MAAM,KAAK,OAAO;GAC9B,CAAC,QAAQ,MAAM,KAAK,IAAI;GACxB,CAAC,QAAQ,MAAM,KAAK,IAAI;GACxB,CAAC,eAAe,MAAM,KAAK,UAAU;GACrC,CAAC,SAAS,MAAM,KAAK,KAAK;EAC5B,EACD,CAAA,GACD,oBAAC,eAAD,EAAe,QAAQ,MAAM,OAAS,CAAA,CAC1B;;AAElB;;;ACbA,MAAa,UAAuE,EAClF,2BDca,gBAAgB,aCdFA,EAC7B"}
|
package/dist/extensions/mcp.cjs
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
let _agimon_ai_po_core_mcpFacet = require("@agimon-ai/po-core/mcpFacet");
|
|
6
|
-
let node_fs_promises = require("node:fs/promises");
|
|
7
|
-
let node_path = require("node:path");
|
|
8
|
-
let _agimon_ai_po_hashline = require("@agimon-ai/po-hashline");
|
|
9
|
-
let _agimon_ai_po_hashline_files = require("@agimon-ai/po-hashline/files");
|
|
10
|
-
let _earendil_works_pi_coding_agent = require("@earendil-works/pi-coding-agent");
|
|
11
|
-
let typebox = require("typebox");
|
|
12
|
-
let node_child_process = require("node:child_process");
|
|
13
|
-
//#region src/schemas/grepTool.ts
|
|
14
|
-
const GrepParamsSchema = typebox.Type.Object({
|
|
15
|
-
pattern: typebox.Type.String({ description: "Regular expression or literal text to find." }),
|
|
16
|
-
path: typebox.Type.Optional(typebox.Type.String({ description: "File or directory to search. Defaults to the working directory." })),
|
|
17
|
-
glob: typebox.Type.Optional(typebox.Type.String({ description: "Glob filter for files to search." })),
|
|
18
|
-
ignoreCase: typebox.Type.Optional(typebox.Type.Boolean({ description: "Match without case sensitivity." })),
|
|
19
|
-
literal: typebox.Type.Optional(typebox.Type.Boolean({ description: "Treat pattern as literal text." })),
|
|
20
|
-
context: typebox.Type.Optional(typebox.Type.Integer({
|
|
21
|
-
minimum: 0,
|
|
22
|
-
description: "Context lines around every match."
|
|
23
|
-
})),
|
|
24
|
-
limit: typebox.Type.Optional(typebox.Type.Integer({
|
|
25
|
-
minimum: 1,
|
|
26
|
-
description: "Maximum number of matches."
|
|
27
|
-
}))
|
|
28
|
-
});
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/services/ripgrep/index.ts
|
|
31
|
-
/** Search with ripgrep independently of the host. */
|
|
32
|
-
async function runRipgrep(request) {
|
|
33
|
-
const { params, cwd, signal } = request;
|
|
34
|
-
const output = await spawnRipgrep(argumentsFor(params, cwd), cwd, signal);
|
|
35
|
-
if (output.trim() === "") return { content: [{
|
|
36
|
-
type: "text",
|
|
37
|
-
text: "No matches found"
|
|
38
|
-
}] };
|
|
39
|
-
return { content: [{
|
|
40
|
-
type: "text",
|
|
41
|
-
text: limitMatches(output, params.limit)
|
|
42
|
-
}] };
|
|
43
|
-
}
|
|
44
|
-
/** The ripgrep argv one search needs, exposed so a test can assert it without spawning. */
|
|
45
|
-
function argumentsFor(params, cwd) {
|
|
46
|
-
const target = (0, _agimon_ai_po_hashline_files.resolveInputPath)(params.path ?? ".", cwd);
|
|
47
|
-
const args = [
|
|
48
|
-
"--color",
|
|
49
|
-
"never",
|
|
50
|
-
"--no-heading",
|
|
51
|
-
"--with-filename",
|
|
52
|
-
"--line-number"
|
|
53
|
-
];
|
|
54
|
-
if (params.ignoreCase === true) args.push("--ignore-case");
|
|
55
|
-
if (params.literal === true) args.push("--fixed-strings");
|
|
56
|
-
if (params.context !== void 0) args.push("--context", String(params.context));
|
|
57
|
-
if (params.glob !== void 0) args.push("--glob", params.glob);
|
|
58
|
-
args.push("--", params.pattern, target);
|
|
59
|
-
return args;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Keeps at most `limit` matching lines, and every context line around them.
|
|
63
|
-
*
|
|
64
|
-
* A context line carries no `:<line>:` marker, which is what separates it from
|
|
65
|
-
* a match, so trimming by line count alone would drop the context ripgrep was
|
|
66
|
-
* asked for.
|
|
67
|
-
*/
|
|
68
|
-
function limitMatches(output, limit) {
|
|
69
|
-
if (limit === void 0) return output.trimEnd();
|
|
70
|
-
let matches = 0;
|
|
71
|
-
const selected = [];
|
|
72
|
-
for (const line of output.trimEnd().split("\n")) {
|
|
73
|
-
if (/:(\d+):/u.test(line)) {
|
|
74
|
-
matches++;
|
|
75
|
-
if (matches > limit) continue;
|
|
76
|
-
}
|
|
77
|
-
selected.push(line);
|
|
78
|
-
}
|
|
79
|
-
return selected.join("\n");
|
|
80
|
-
}
|
|
81
|
-
function spawnRipgrep(args, cwd, signal) {
|
|
82
|
-
return new Promise((resolveOutput, reject) => {
|
|
83
|
-
const child = (0, node_child_process.spawn)("rg", args, {
|
|
84
|
-
cwd,
|
|
85
|
-
stdio: [
|
|
86
|
-
"ignore",
|
|
87
|
-
"pipe",
|
|
88
|
-
"pipe"
|
|
89
|
-
]
|
|
90
|
-
});
|
|
91
|
-
let stdout = "";
|
|
92
|
-
let stderr = "";
|
|
93
|
-
child.stdout.on("data", (chunk) => {
|
|
94
|
-
stdout += chunk.toString();
|
|
95
|
-
});
|
|
96
|
-
child.stderr.on("data", (chunk) => {
|
|
97
|
-
stderr += chunk.toString();
|
|
98
|
-
});
|
|
99
|
-
const abort = () => {
|
|
100
|
-
child.kill("SIGTERM");
|
|
101
|
-
reject(/* @__PURE__ */ new Error("Operation aborted"));
|
|
102
|
-
};
|
|
103
|
-
if (signal?.aborted) {
|
|
104
|
-
abort();
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
signal?.addEventListener("abort", abort, { once: true });
|
|
108
|
-
child.once("error", (error) => {
|
|
109
|
-
signal?.removeEventListener("abort", abort);
|
|
110
|
-
reject(new Error(`Could not start ripgrep: ${error.message}`, { cause: error }));
|
|
111
|
-
});
|
|
112
|
-
child.once("close", (code) => {
|
|
113
|
-
signal?.removeEventListener("abort", abort);
|
|
114
|
-
if (code === 0 || code === 1) {
|
|
115
|
-
resolveOutput(stdout);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
reject(new Error(stderr.trim() || `ripgrep exited with code ${code ?? "unknown"}`));
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/services/grepTool/index.ts
|
|
124
|
-
const MATCH_DELIMITER = /:(\d+):/gu;
|
|
125
|
-
const CONTEXT_DELIMITER = /-(\d+)-/gu;
|
|
126
|
-
const NO_MATCHES = "No matches found";
|
|
127
|
-
function createHeadlessGrepTool() {
|
|
128
|
-
return {
|
|
129
|
-
name: "grep",
|
|
130
|
-
label: "grep",
|
|
131
|
-
description: "Search file contents using ripgrep semantics, then add exact-byte file tags and stable line anchors for writable matches. Respects .gitignore.",
|
|
132
|
-
promptSnippet: "Search file contents and return editable hashline anchors",
|
|
133
|
-
parameters: GrepParamsSchema,
|
|
134
|
-
executionMode: "parallel",
|
|
135
|
-
execute: async (_toolCallId, params, signal, _onUpdate, context) => {
|
|
136
|
-
return tagGrepResult(await runRipgrep({
|
|
137
|
-
params,
|
|
138
|
-
cwd: context.cwd,
|
|
139
|
-
signal
|
|
140
|
-
}), params, context.cwd, signal);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
/** Node adapters for hashline post-processing. */
|
|
145
|
-
const nodeGrepFileSystem = {
|
|
146
|
-
stat: (path) => (0, node_fs_promises.stat)(path),
|
|
147
|
-
readFile: (path) => (0, node_fs_promises.readFile)(path)
|
|
148
|
-
};
|
|
149
|
-
const defaultGrepOutput = {
|
|
150
|
-
maxBytes: _earendil_works_pi_coding_agent.DEFAULT_MAX_BYTES,
|
|
151
|
-
formatSize: _earendil_works_pi_coding_agent.formatSize,
|
|
152
|
-
truncateHead: _earendil_works_pi_coding_agent.truncateHead,
|
|
153
|
-
truncateLine: _earendil_works_pi_coding_agent.truncateLine
|
|
154
|
-
};
|
|
155
|
-
async function tagGrepResult(nativeResult, params, cwd, signal, writable = _agimon_ai_po_hashline_files.isWritableFile, filesystem = nodeGrepFileSystem, outputOperations = defaultGrepOutput) {
|
|
156
|
-
const textPart = nativeResult.content.find((part) => part.type === "text");
|
|
157
|
-
if (!textPart || textPart.text === NO_MATCHES) return nativeResult;
|
|
158
|
-
const noticeIndex = textPart.text.lastIndexOf("\n\n[");
|
|
159
|
-
const rowsText = noticeIndex === -1 ? textPart.text : textPart.text.slice(0, noticeIndex);
|
|
160
|
-
const notice = noticeIndex === -1 ? "" : textPart.text.slice(noticeIndex);
|
|
161
|
-
const searchPath = (0, _agimon_ai_po_hashline_files.resolveInputPath)(params.path ?? ".", cwd);
|
|
162
|
-
const searchStats = await filesystem.stat(searchPath);
|
|
163
|
-
assertNotAborted(signal);
|
|
164
|
-
const rows = await parseValidatedGrepRows(rowsText, searchPath, searchStats.isDirectory(), signal, filesystem);
|
|
165
|
-
if (rows.length === 0) return nativeResult;
|
|
166
|
-
const groups = groupGrepRows(rows, searchPath, searchStats.isDirectory(), cwd);
|
|
167
|
-
const blocks = [];
|
|
168
|
-
let taggedFiles = 0;
|
|
169
|
-
let linesTruncated = nativeResult.details?.linesTruncated ?? false;
|
|
170
|
-
for (const group of groups.values()) {
|
|
171
|
-
assertNotAborted(signal);
|
|
172
|
-
const canEdit = await writable(group.absolutePath);
|
|
173
|
-
assertNotAborted(signal);
|
|
174
|
-
if (!canEdit) {
|
|
175
|
-
blocks.push(group.nativeRows.join("\n"));
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
let bytes;
|
|
179
|
-
try {
|
|
180
|
-
bytes = await filesystem.readFile(group.absolutePath);
|
|
181
|
-
} catch {
|
|
182
|
-
blocks.push(group.nativeRows.join("\n"));
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
assertNotAborted(signal);
|
|
186
|
-
const lines = (0, _agimon_ai_po_hashline.splitLines)((0, _agimon_ai_po_hashline_files.decodeUtf8)(bytes, group.path));
|
|
187
|
-
const output = [(0, _agimon_ai_po_hashline.formatFileHeader)(group.path, (0, _agimon_ai_po_hashline_files.computeFileTag)(bytes))];
|
|
188
|
-
for (const [lineNumber, isMatch] of [...group.rows].sort(([left], [right]) => left - right)) {
|
|
189
|
-
const line = lines[lineNumber - 1];
|
|
190
|
-
if (line === void 0) continue;
|
|
191
|
-
const compact = outputOperations.truncateLine(line);
|
|
192
|
-
if (compact.wasTruncated) linesTruncated = true;
|
|
193
|
-
output.push((0, _agimon_ai_po_hashline.formatTaggedLine)(compact.text, lineNumber, isMatch ? ">> " : " ", line));
|
|
194
|
-
}
|
|
195
|
-
if (output.length > 1) {
|
|
196
|
-
blocks.push(output.join("\n"));
|
|
197
|
-
taggedFiles++;
|
|
198
|
-
} else blocks.push(group.nativeRows.join("\n"));
|
|
199
|
-
}
|
|
200
|
-
if (blocks.length === 0 || taggedFiles === 0) return nativeResult;
|
|
201
|
-
const truncation = outputOperations.truncateHead(blocks.join("\n"), { maxLines: Number.MAX_SAFE_INTEGER });
|
|
202
|
-
const extraNotice = truncation.truncated ? `\n\n[${outputOperations.formatSize(outputOperations.maxBytes)} tagged output limit reached]` : "";
|
|
203
|
-
const details = {
|
|
204
|
-
...nativeResult.details,
|
|
205
|
-
...truncation.truncated ? { truncation } : {},
|
|
206
|
-
...linesTruncated ? { linesTruncated: true } : {}
|
|
207
|
-
};
|
|
208
|
-
assertNotAborted(signal);
|
|
209
|
-
return {
|
|
210
|
-
...nativeResult,
|
|
211
|
-
content: [{
|
|
212
|
-
type: "text",
|
|
213
|
-
text: `${truncation.content}${notice}${extraNotice}`
|
|
214
|
-
}],
|
|
215
|
-
details: Object.keys(details).length > 0 ? details : void 0
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
function groupGrepRows(rows, searchPath, directory, cwd) {
|
|
219
|
-
const groups = /* @__PURE__ */ new Map();
|
|
220
|
-
for (const row of rows) {
|
|
221
|
-
const absolutePath = directory ? (0, node_path.resolve)(searchPath, row.path) : searchPath;
|
|
222
|
-
let group = groups.get(absolutePath);
|
|
223
|
-
if (!group) {
|
|
224
|
-
group = {
|
|
225
|
-
path: (0, _agimon_ai_po_hashline_files.displayPath)(absolutePath, cwd),
|
|
226
|
-
absolutePath,
|
|
227
|
-
nativeRows: [],
|
|
228
|
-
rows: /* @__PURE__ */ new Map()
|
|
229
|
-
};
|
|
230
|
-
groups.set(absolutePath, group);
|
|
231
|
-
}
|
|
232
|
-
if (row.native !== void 0) group.nativeRows.push(row.native);
|
|
233
|
-
group.rows.set(row.line, row.match || group.rows.get(row.line) === true);
|
|
234
|
-
}
|
|
235
|
-
return groups;
|
|
236
|
-
}
|
|
237
|
-
async function parseValidatedGrepRows(rowsText, searchPath, directory, signal, filesystem) {
|
|
238
|
-
const pathCache = /* @__PURE__ */ new Map();
|
|
239
|
-
const rows = [];
|
|
240
|
-
for (const value of rowsText.split("\n")) {
|
|
241
|
-
assertNotAborted(signal);
|
|
242
|
-
let resolvedCandidate;
|
|
243
|
-
for (const candidate of grepRowCandidates(value)) {
|
|
244
|
-
if (!directory) {
|
|
245
|
-
if (candidate.path === (0, node_path.basename)(searchPath) || candidate.path === searchPath) {
|
|
246
|
-
rows.push({
|
|
247
|
-
...candidate,
|
|
248
|
-
native: value
|
|
249
|
-
});
|
|
250
|
-
break;
|
|
251
|
-
}
|
|
252
|
-
continue;
|
|
253
|
-
}
|
|
254
|
-
const absolutePath = (0, node_path.resolve)(searchPath, candidate.path);
|
|
255
|
-
let exists = pathCache.get(absolutePath);
|
|
256
|
-
if (exists === void 0) {
|
|
257
|
-
exists = await filesystem.stat(absolutePath).then((value) => value.isFile()).catch(() => false);
|
|
258
|
-
assertNotAborted(signal);
|
|
259
|
-
pathCache.set(absolutePath, exists);
|
|
260
|
-
}
|
|
261
|
-
if (exists) resolvedCandidate = {
|
|
262
|
-
...candidate,
|
|
263
|
-
native: value
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
if (resolvedCandidate) rows.push(resolvedCandidate);
|
|
267
|
-
}
|
|
268
|
-
return rows;
|
|
269
|
-
}
|
|
270
|
-
function grepRowCandidates(value) {
|
|
271
|
-
const candidates = [];
|
|
272
|
-
for (const match of value.matchAll(MATCH_DELIMITER)) candidates.push({
|
|
273
|
-
index: match.index,
|
|
274
|
-
row: {
|
|
275
|
-
path: value.slice(0, match.index),
|
|
276
|
-
line: Number.parseInt(match[1] ?? "", 10),
|
|
277
|
-
match: true
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
for (const match of value.matchAll(CONTEXT_DELIMITER)) candidates.push({
|
|
281
|
-
index: match.index,
|
|
282
|
-
row: {
|
|
283
|
-
path: value.slice(0, match.index),
|
|
284
|
-
line: Number.parseInt(match[1] ?? "", 10),
|
|
285
|
-
match: false
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
return candidates.sort((left, right) => left.index - right.index).map(({ row }) => row);
|
|
289
|
-
}
|
|
290
|
-
function assertNotAborted(signal) {
|
|
291
|
-
if (signal?.aborted) throw new Error("Operation aborted");
|
|
292
|
-
}
|
|
293
|
-
//#endregion
|
|
294
|
-
//#region src/extensions/workspaces/sessions/(backend)/tool/grep.mcp.ts
|
|
295
|
-
var grep_mcp_default = (0, _agimon_ai_po_core_mcpFacet.defineMcpTool)(() => ({
|
|
296
|
-
...createHeadlessGrepTool(),
|
|
297
|
-
description: "Search file contents in the Po session's repository on the host machine (ripgrep, regex or literal, code search). Respects .gitignore. Matches include file hashes and line anchors for this server's edit tool."
|
|
298
|
-
}));
|
|
299
|
-
//#endregion
|
|
300
|
-
//#region generated/mcp.ts
|
|
301
|
-
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
302
|
-
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
303
|
-
...identity,
|
|
304
|
-
...value
|
|
305
|
-
};
|
|
306
|
-
const withWidget = (key, value) => value === void 0 ? value : {
|
|
307
|
-
...value,
|
|
308
|
-
_meta: {
|
|
309
|
-
...value._meta,
|
|
310
|
-
["po/widget"]: key
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
const mcp = (0, _agimon_ai_po_core_mcpFacet.defineMcpPlugin)({
|
|
314
|
-
name: "@agimon-ai/po-grep",
|
|
315
|
-
session: (context) => ({ get tools() {
|
|
316
|
-
return [withWidget("@agimon-ai/po-grep/grep", via({ name: "grep" }, at(grep_mcp_default, context)))];
|
|
317
|
-
} })
|
|
318
|
-
});
|
|
319
|
-
//#endregion
|
|
320
|
-
exports.default = mcp;
|
|
321
|
-
exports.mcp = mcp;
|
|
322
|
-
|
|
323
|
-
//# sourceMappingURL=mcp.cjs.map
|