@agimon-ai/po-grep 0.0.0-alpha.22 → 0.0.0-alpha.220
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/LICENSE +1 -166
- package/NOTICE +35 -0
- package/README.md +2 -4
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +2 -2
- package/dist/extensions/mcp-ui.mjs +8 -7
- package/dist/extensions/mcp-ui.mjs.map +1 -1
- package/dist/extensions/mcp.cjs +114 -69
- package/dist/extensions/mcp.cjs.map +1 -1
- package/dist/extensions/mcp.d.mts.map +1 -1
- package/dist/extensions/mcp.mjs +114 -69
- package/dist/extensions/mcp.mjs.map +1 -1
- package/dist/extensions/native.mjs +139 -0
- package/dist/extensions/native.mjs.map +1 -0
- package/dist/extensions/server.cjs +119 -65
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +119 -65
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +23 -13
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/po-runtime-identity.json +1 -0
- package/locales/vi.json +12 -0
- package/locales/zh-CN.json +12 -0
- package/package.json +61 -14
package/LICENSE
CHANGED
|
@@ -1,171 +1,6 @@
|
|
|
1
|
-
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
2
|
-
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
3
|
-
|
|
4
|
-
Parameters
|
|
5
|
-
|
|
6
|
-
Licensor: Agimon Pty Ltd
|
|
7
|
-
Licensed Work: Po, the software in the Po source repository and the
|
|
8
|
-
packages released from it, in each version released by
|
|
9
|
-
the Licensor.
|
|
10
|
-
The Licensed Work is (c) 2026 Agimon Pty Ltd.
|
|
11
|
-
Material identified as third-party in the "Third-party
|
|
12
|
-
components" section at the end of this file or in a
|
|
13
|
-
NOTICE file, and any package or directory whose own
|
|
14
|
-
license file grants a different license, is not part of
|
|
15
|
-
the Licensed Work and remains under its own license.
|
|
16
|
-
Additional Use Grant: You may make production use of the Licensed Work if
|
|
17
|
-
your use is Eligible Use. "Eligible Use" is production use that falls
|
|
18
|
-
within at least one of the following:
|
|
19
|
-
|
|
20
|
-
(a) Personal Use. Use by an individual for their own personal purposes,
|
|
21
|
-
and not on behalf of, or for the benefit of, an employer, client, or
|
|
22
|
-
other Organization. Use by an individual in the course of employment
|
|
23
|
-
or engagement by an Organization is use by that Organization.
|
|
24
|
-
|
|
25
|
-
(b) Small Organization Use. Use by or on behalf of an Organization whose
|
|
26
|
-
Annual Revenue is less than USD 1,000,000.
|
|
27
|
-
|
|
28
|
-
(c) Non-profit, Education and Research Use. Use, regardless of Annual
|
|
29
|
-
Revenue, by (i) an Organization registered or recognized as a
|
|
30
|
-
non-profit or charitable organization under the laws of its
|
|
31
|
-
jurisdiction, for its non-profit purposes; (ii) an accredited school,
|
|
32
|
-
college, or university, for teaching, learning, or academic research;
|
|
33
|
-
or (iii) a publicly funded research institution, for its research.
|
|
34
|
-
|
|
35
|
-
(d) Service Provider Use. Use by a consultant, contractor, agency, or other
|
|
36
|
-
service provider, regardless of its own Annual Revenue, solely to
|
|
37
|
-
build, deploy, host, operate, or support the Licensed Work for a client
|
|
38
|
-
whose own use would be Eligible Use under (a), (b), or (c). A service
|
|
39
|
-
provider's use for its own purposes is Eligible Use only if the service
|
|
40
|
-
provider itself qualifies under (b) or (c).
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Hosted services. Offering the Licensed Work to third parties as a hosted
|
|
44
|
-
or managed service whose primary value is the Licensed Work is Eligible
|
|
45
|
-
Use only if each such third party's own use would be Eligible Use.
|
|
46
|
-
|
|
47
|
-
Definitions. "Organization" means any company, partnership, sole
|
|
48
|
-
proprietorship, trust, association, government body, or other entity, and
|
|
49
|
-
includes an individual acting in a business or professional capacity.
|
|
50
|
-
"Affiliate" means any entity that directly or indirectly controls, is
|
|
51
|
-
controlled by, or is under common control with an Organization, where
|
|
52
|
-
"control" means ownership of more than 50% of the voting interests of an
|
|
53
|
-
entity or the power to direct its management and policies by contract or
|
|
54
|
-
otherwise. "Annual Revenue" means the total gross revenue of an
|
|
55
|
-
Organization and all of its Affiliates combined, from all sources and
|
|
56
|
-
whether or not related to the Licensed Work, for its most recently
|
|
57
|
-
completed fiscal year, or, if it has not completed a fiscal year, for the
|
|
58
|
-
twelve months before the use (or since its formation, if shorter),
|
|
59
|
-
converted into US dollars at the average exchange rate for that period.
|
|
60
|
-
Proceeds of equity or debt financing are not revenue.
|
|
61
|
-
|
|
62
|
-
Threshold. If an Organization stops qualifying under (b), its existing
|
|
63
|
-
production use remains Eligible Use for 90 days after it stops
|
|
64
|
-
qualifying, after which it must obtain a commercial license or stop
|
|
65
|
-
production use. Use that was Eligible Use when it occurred never requires
|
|
66
|
-
a commercial license after the fact.
|
|
67
|
-
Change Date: Four years from the date a version of the Licensed Work
|
|
68
|
-
is first publicly released by the Licensor.
|
|
69
|
-
Change License: Apache License, Version 2.0
|
|
70
|
-
|
|
71
|
-
For information about alternative licensing arrangements for the Licensed
|
|
72
|
-
Work, please visit: https://agimon.ai/licensing
|
|
73
|
-
|
|
74
|
-
Notice
|
|
75
|
-
|
|
76
|
-
The Business Source License (this document, or the "License") is not an Open
|
|
77
|
-
Source license. However, the Licensed Work will eventually be made available
|
|
78
|
-
under an Open Source License, as stated in this License.
|
|
79
|
-
|
|
80
|
-
-----------------------------------------------------------------------------
|
|
81
|
-
|
|
82
|
-
Business Source License 1.1
|
|
83
|
-
|
|
84
|
-
Terms
|
|
85
|
-
|
|
86
|
-
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
87
|
-
works, redistribute, and make non-production use of the Licensed Work. The
|
|
88
|
-
Licensor may make an Additional Use Grant, above, permitting limited
|
|
89
|
-
production use.
|
|
90
|
-
|
|
91
|
-
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
92
|
-
available distribution of a specific version of the Licensed Work under this
|
|
93
|
-
License, whichever comes first, the Licensor hereby grants you rights under
|
|
94
|
-
the terms of the Change License, and the rights granted in the paragraph
|
|
95
|
-
above terminate.
|
|
96
|
-
|
|
97
|
-
If your use of the Licensed Work does not comply with the requirements
|
|
98
|
-
currently in effect as described in this License, you must purchase a
|
|
99
|
-
commercial license from the Licensor, its affiliated entities, or authorized
|
|
100
|
-
resellers, or you must refrain from using the Licensed Work.
|
|
101
|
-
|
|
102
|
-
All copies of the original and modified Licensed Work, and derivative works
|
|
103
|
-
of the Licensed Work, are subject to this License. This License applies
|
|
104
|
-
separately for each version of the Licensed Work and the Change Date may vary
|
|
105
|
-
for each version of the Licensed Work released by Licensor.
|
|
106
|
-
|
|
107
|
-
You must conspicuously display this License on each original or modified copy
|
|
108
|
-
of the Licensed Work. If you receive the Licensed Work in original or
|
|
109
|
-
modified form from a third party, the terms and conditions set forth in this
|
|
110
|
-
License apply to your use of that work.
|
|
111
|
-
|
|
112
|
-
Any use of the Licensed Work in violation of this License will automatically
|
|
113
|
-
terminate your rights under this License for the current and all other
|
|
114
|
-
versions of the Licensed Work.
|
|
115
|
-
|
|
116
|
-
This License does not grant you any right in any trademark or logo of
|
|
117
|
-
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
118
|
-
Licensor as expressly required by this License).
|
|
119
|
-
|
|
120
|
-
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
121
|
-
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
122
|
-
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
123
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
124
|
-
TITLE.
|
|
125
|
-
|
|
126
|
-
MariaDB hereby grants you permission to use this License’s text to license
|
|
127
|
-
your works, and to refer to it using the trademark “Business Source License”,
|
|
128
|
-
as long as you comply with the Covenants of Licensor below.
|
|
129
|
-
|
|
130
|
-
Covenants of Licensor
|
|
131
|
-
|
|
132
|
-
In consideration of the right to use this License’s text and the “Business
|
|
133
|
-
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
|
134
|
-
other recipients of the licensed work to be provided by Licensor:
|
|
135
|
-
|
|
136
|
-
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
137
|
-
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
138
|
-
where “compatible” means that software provided under the Change License can
|
|
139
|
-
be included in a program with software provided under GPL Version 2.0 or a
|
|
140
|
-
later version. Licensor may specify additional Change Licenses without
|
|
141
|
-
limitation.
|
|
142
|
-
|
|
143
|
-
2. To either: (a) specify an additional grant of rights to use that does not
|
|
144
|
-
impose any additional restriction on the right granted in this License, as
|
|
145
|
-
the Additional Use Grant; or (b) insert the text “None”.
|
|
146
|
-
|
|
147
|
-
3. To specify a Change Date.
|
|
148
|
-
|
|
149
|
-
4. Not to modify this License in any other way.
|
|
150
|
-
|
|
151
|
-
-----------------------------------------------------------------------------
|
|
152
|
-
|
|
153
|
-
Third-party components
|
|
154
|
-
|
|
155
|
-
The following material in this package was written by third parties. It is
|
|
156
|
-
not part of the Licensed Work, is not licensed under the Business Source
|
|
157
|
-
License above, and remains under its own license, reproduced below. Where a
|
|
158
|
-
file combines third-party material with changes by Agimon Pty Ltd, the
|
|
159
|
-
third-party portions remain under their original license and the changes
|
|
160
|
-
are part of the Licensed Work.
|
|
161
|
-
|
|
162
|
-
1. Phi writetool (https://github.com/pulseaiclub/phi/tree/main/internal/tools/writetool)
|
|
163
|
-
Used in: hashline protocol and FNV anchor implementation
|
|
164
|
-
License: MIT
|
|
165
|
-
|
|
166
1
|
MIT License
|
|
167
2
|
|
|
168
|
-
Copyright (c) 2026
|
|
3
|
+
Copyright (c) 2026 Agimon Pty Ltd
|
|
169
4
|
|
|
170
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
171
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/NOTICE
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
This package is licensed under the MIT License, see LICENSE.
|
|
2
|
+
|
|
3
|
+
Third-party components
|
|
4
|
+
|
|
5
|
+
The following material in this package was written by third parties. It is
|
|
6
|
+
not covered by this package's LICENSE and remains under its own license,
|
|
7
|
+
reproduced below. Where a file combines third-party material with changes by
|
|
8
|
+
Agimon Pty Ltd, the third-party portions remain under their original license
|
|
9
|
+
and the changes are licensed under this package's LICENSE.
|
|
10
|
+
|
|
11
|
+
1. Phi writetool (https://github.com/pulseaiclub/phi/tree/main/internal/tools/writetool)
|
|
12
|
+
Used in: hashline protocol and FNV anchor implementation
|
|
13
|
+
License: MIT
|
|
14
|
+
|
|
15
|
+
MIT License
|
|
16
|
+
|
|
17
|
+
Copyright (c) 2026 pulseaiclub
|
|
18
|
+
|
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
20
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
21
|
+
in the Software without restriction, including without limitation the rights
|
|
22
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
24
|
+
furnished to do so, subject to the following conditions:
|
|
25
|
+
|
|
26
|
+
The above copyright notice and this permission notice shall be included in all
|
|
27
|
+
copies or substantial portions of the Software.
|
|
28
|
+
|
|
29
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
30
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
31
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
32
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
33
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
34
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ The native server plugin owns `grep`. Its private ripgrep service searches files
|
|
|
15
15
|
|
|
16
16
|
## Install
|
|
17
17
|
|
|
18
|
-
Select `@agimon-ai/po-grep` in `.po/
|
|
18
|
+
Select `@agimon-ai/po-grep` in `.po/presets.yaml` and run `po sync`. The package's `poServer` metadata names its built server plugin. There is no standalone Pi entry or tool-registration ordering requirement against `po-ui`.
|
|
19
19
|
|
|
20
20
|
Install `@agimon-ai/po-edit` when the model should apply the emitted anchors.
|
|
21
21
|
|
|
@@ -61,6 +61,4 @@ Maintained by [Agimon](https://agimon.ai/about).
|
|
|
61
61
|
|
|
62
62
|
## License
|
|
63
63
|
|
|
64
|
-
|
|
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.
|
|
64
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -1 +1 @@
|
|
|
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 server plugin 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,
|
|
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 server plugin 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,G,yCAAeA,CAAAA,CAAAA,kBAAAA,CAAkB;CAAE,SAAS;CAAG,MAAM,CAAC;CAAG,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
|
package/dist/apiContracts.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const apiContracts: {
|
|
|
6
6
|
schemas?: Record<string, boolean | object> | undefined;
|
|
7
7
|
http: {
|
|
8
8
|
id: string;
|
|
9
|
-
scope: "
|
|
9
|
+
scope: "host" | "session" | "workspace";
|
|
10
10
|
basePath?: string | undefined;
|
|
11
11
|
path: string;
|
|
12
12
|
method: "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT";
|
|
@@ -34,7 +34,7 @@ export declare const apiContracts: {
|
|
|
34
34
|
}[];
|
|
35
35
|
sockets: {
|
|
36
36
|
id: string;
|
|
37
|
-
scope: "
|
|
37
|
+
scope: "host" | "session" | "workspace";
|
|
38
38
|
description: string;
|
|
39
39
|
availability?: string | undefined;
|
|
40
40
|
service: string;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { defineMcpWidget } from "@agimon-ai/po-core/web";
|
|
1
|
+
import { defineMcpWidget, useT } from "@agimon-ai/po-core/web";
|
|
2
2
|
import { McpToolFields, McpToolFrame, McpToolOutput } from "@agimon-ai/po-web-components";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
//#region src/extensions/workspaces/sessions/(frontend)/tool/grep.mcp.tsx
|
|
5
5
|
function GrepMcpWidget(props) {
|
|
6
|
+
const t = useT();
|
|
6
7
|
return /* @__PURE__ */ jsxs(McpToolFrame, {
|
|
7
8
|
...props,
|
|
8
|
-
title: "Search file contents",
|
|
9
|
+
title: t("grep.ui.mcpTitle", "Search file contents"),
|
|
9
10
|
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]
|
|
11
|
+
[t("grep.ui.mcpPattern", "Pattern"), props.args.pattern],
|
|
12
|
+
[t("grep.ui.mcpPath", "Path"), props.args.path],
|
|
13
|
+
[t("grep.ui.mcpGlob", "Glob"), props.args.glob],
|
|
14
|
+
[t("grep.ui.mcpIgnorecase", "Ignore case"), props.args.ignoreCase],
|
|
15
|
+
[t("grep.ui.mcpLimit", "Limit"), props.args.limit]
|
|
15
16
|
] }), /* @__PURE__ */ jsx(McpToolOutput, { result: props.result })]
|
|
16
17
|
});
|
|
17
18
|
}
|
|
@@ -1 +1 @@
|
|
|
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 PoMcpWidgetProps } from '@agimon-ai/po-core/web';\nimport { McpToolFrame, McpToolFields, McpToolOutput } from '@agimon-ai/po-web-components';\n\nfunction GrepMcpWidget(props: PoMcpWidgetProps) {\n return (\n <McpToolFrame {...props} title
|
|
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, useT, type PoMcpWidgetProps } from '@agimon-ai/po-core/web';\nimport { McpToolFrame, McpToolFields, McpToolOutput } from '@agimon-ai/po-web-components';\n\nfunction GrepMcpWidget(props: PoMcpWidgetProps) {\n const t = useT();\n return (\n <McpToolFrame {...props} title={t('grep.ui.mcpTitle', 'Search file contents')}>\n <McpToolFields\n fields={[\n [t('grep.ui.mcpPattern', 'Pattern'), props.args.pattern],\n [t('grep.ui.mcpPath', 'Path'), props.args.path],\n [t('grep.ui.mcpGlob', 'Glob'), props.args.glob],\n [t('grep.ui.mcpIgnorecase', 'Ignore case'), props.args.ignoreCase],\n [t('grep.ui.mcpLimit', '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 { PoMcpWidgetProps } 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<PoMcpWidgetProps>>> = {\n \"@agimon-ai/po-grep/grep\": Widget0,\n};\n"],"mappings":";;;;AAGA,SAAS,cAAc,OAAyB;CAC9C,MAAM,IAAI,KAAK;CACf,OACE,qBAAC,cAAD;EAAc,GAAI;EAAO,OAAO,EAAE,oBAAoB,sBAAsB;EAA5E,UAAA,CACE,oBAAC,eAAD,EACE,QAAQ;GACN,CAAC,EAAE,sBAAsB,SAAS,GAAG,MAAM,KAAK,OAAO;GACvD,CAAC,EAAE,mBAAmB,MAAM,GAAG,MAAM,KAAK,IAAI;GAC9C,CAAC,EAAE,mBAAmB,MAAM,GAAG,MAAM,KAAK,IAAI;GAC9C,CAAC,EAAE,yBAAyB,aAAa,GAAG,MAAM,KAAK,UAAU;GACjE,CAAC,EAAE,oBAAoB,OAAO,GAAG,MAAM,KAAK,KAAK;EACnD,EACD,CAAA,GACD,oBAAC,eAAD,EAAe,QAAQ,MAAM,OAAS,CAAA,CAC1B;;AAElB;;;ACdA,MAAa,UAAqE,EAChF,2BDea,gBAAgB,aCfFA,EAC7B"}
|
package/dist/extensions/mcp.cjs
CHANGED
|
@@ -3,12 +3,12 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
let _agimon_ai_po_core_mcpFacet = require("@agimon-ai/po-core/mcpFacet");
|
|
6
|
-
let
|
|
6
|
+
let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
let _agimon_ai_po_hashline = require("@agimon-ai/po-hashline");
|
|
9
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
10
|
let typebox = require("typebox");
|
|
11
|
+
let _earendil_works_pi_coding_agent = require("@earendil-works/pi-coding-agent");
|
|
12
12
|
let node_child_process = require("node:child_process");
|
|
13
13
|
//#region src/schemas/grepTool.ts
|
|
14
14
|
const GrepParamsSchema = typebox.Type.Object({
|
|
@@ -27,19 +27,48 @@ const GrepParamsSchema = typebox.Type.Object({
|
|
|
27
27
|
}))
|
|
28
28
|
});
|
|
29
29
|
//#endregion
|
|
30
|
+
//#region src/services/grepHost/index.ts
|
|
31
|
+
const defaultGrepOutput = {
|
|
32
|
+
maxBytes: _earendil_works_pi_coding_agent.DEFAULT_MAX_BYTES,
|
|
33
|
+
formatSize: _earendil_works_pi_coding_agent.formatSize,
|
|
34
|
+
truncateHead: _earendil_works_pi_coding_agent.truncateHead,
|
|
35
|
+
truncateLine: _earendil_works_pi_coding_agent.truncateLine
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/services/matchLimit/index.ts
|
|
39
|
+
/**
|
|
40
|
+
* Keeps at most `limit` matching lines, and every context line around them.
|
|
41
|
+
*
|
|
42
|
+
* A context line carries no `:<line>:` marker, which is what separates it from
|
|
43
|
+
* a match, so trimming by line count alone would drop the context ripgrep was
|
|
44
|
+
* asked for.
|
|
45
|
+
*/
|
|
46
|
+
function limitMatches(output, limit) {
|
|
47
|
+
if (limit === void 0) return output.trimEnd();
|
|
48
|
+
let matches = 0;
|
|
49
|
+
const selected = [];
|
|
50
|
+
for (const line of output.trimEnd().split("\n")) {
|
|
51
|
+
if (/:(\d+):/u.test(line)) {
|
|
52
|
+
matches++;
|
|
53
|
+
if (matches > limit) continue;
|
|
54
|
+
}
|
|
55
|
+
selected.push(line);
|
|
56
|
+
}
|
|
57
|
+
return selected.join("\n");
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
30
60
|
//#region src/services/ripgrep/index.ts
|
|
31
61
|
/** Search with ripgrep independently of the host. */
|
|
32
62
|
async function runRipgrep(request) {
|
|
33
63
|
const { params, cwd, signal } = request;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}] };
|
|
64
|
+
const { stdout, truncated } = await spawnRipgrep(argumentsFor(params, cwd), cwd, signal);
|
|
65
|
+
return {
|
|
66
|
+
content: [{
|
|
67
|
+
type: "text",
|
|
68
|
+
text: stdout.trim() === "" ? "No matches found" : limitMatches(stdout, params.limit)
|
|
69
|
+
}],
|
|
70
|
+
...truncated ? { details: { truncated: true } } : {}
|
|
71
|
+
};
|
|
43
72
|
}
|
|
44
73
|
/** The ripgrep argv one search needs, exposed so a test can assert it without spawning. */
|
|
45
74
|
function argumentsFor(params, cwd) {
|
|
@@ -58,26 +87,6 @@ function argumentsFor(params, cwd) {
|
|
|
58
87
|
args.push("--", params.pattern, target);
|
|
59
88
|
return args;
|
|
60
89
|
}
|
|
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
90
|
function spawnRipgrep(args, cwd, signal) {
|
|
82
91
|
return new Promise((resolveOutput, reject) => {
|
|
83
92
|
const child = (0, node_child_process.spawn)("rg", args, {
|
|
@@ -88,13 +97,28 @@ function spawnRipgrep(args, cwd, signal) {
|
|
|
88
97
|
"pipe"
|
|
89
98
|
]
|
|
90
99
|
});
|
|
91
|
-
|
|
92
|
-
|
|
100
|
+
const stdout = [];
|
|
101
|
+
const stderr = [];
|
|
102
|
+
let stdoutBytes = 0;
|
|
103
|
+
let stderrBytes = 0;
|
|
104
|
+
let truncated = false;
|
|
105
|
+
const collect = (chunks, chunk, bytes, cap) => {
|
|
106
|
+
if (truncated) return bytes;
|
|
107
|
+
const retained = Math.min(chunk.length, cap - bytes);
|
|
108
|
+
if (retained > 0) chunks.push(Buffer.from(chunk.subarray(0, retained)));
|
|
109
|
+
(0, _agimon_ai_po_core_platform.recordRipgrepOutput)(retained, bytes + retained >= cap);
|
|
110
|
+
bytes += retained;
|
|
111
|
+
if (bytes >= cap) {
|
|
112
|
+
truncated = true;
|
|
113
|
+
child.kill("SIGTERM");
|
|
114
|
+
}
|
|
115
|
+
return bytes;
|
|
116
|
+
};
|
|
93
117
|
child.stdout.on("data", (chunk) => {
|
|
94
|
-
stdout
|
|
118
|
+
stdoutBytes = collect(stdout, chunk, stdoutBytes, 8388608);
|
|
95
119
|
});
|
|
96
120
|
child.stderr.on("data", (chunk) => {
|
|
97
|
-
stderr
|
|
121
|
+
stderrBytes = collect(stderr, chunk, stderrBytes, 65536);
|
|
98
122
|
});
|
|
99
123
|
const abort = () => {
|
|
100
124
|
child.kill("SIGTERM");
|
|
@@ -111,11 +135,14 @@ function spawnRipgrep(args, cwd, signal) {
|
|
|
111
135
|
});
|
|
112
136
|
child.once("close", (code) => {
|
|
113
137
|
signal?.removeEventListener("abort", abort);
|
|
114
|
-
if (code === 0 || code === 1) {
|
|
115
|
-
resolveOutput(
|
|
138
|
+
if (truncated || code === 0 || code === 1) {
|
|
139
|
+
resolveOutput({
|
|
140
|
+
stdout: Buffer.concat(stdout, stdoutBytes).toString("utf8"),
|
|
141
|
+
truncated
|
|
142
|
+
});
|
|
116
143
|
return;
|
|
117
144
|
}
|
|
118
|
-
reject(new Error(stderr.trim() || `ripgrep exited with code ${code ?? "unknown"}`));
|
|
145
|
+
reject(new Error(Buffer.concat(stderr, stderrBytes).toString("utf8").trim() || `ripgrep exited with code ${code ?? "unknown"}`));
|
|
119
146
|
});
|
|
120
147
|
});
|
|
121
148
|
}
|
|
@@ -124,7 +151,7 @@ function spawnRipgrep(args, cwd, signal) {
|
|
|
124
151
|
const MATCH_DELIMITER = /:(\d+):/gu;
|
|
125
152
|
const CONTEXT_DELIMITER = /-(\d+)-/gu;
|
|
126
153
|
const NO_MATCHES = "No matches found";
|
|
127
|
-
function createHeadlessGrepTool() {
|
|
154
|
+
function createHeadlessGrepTool(filesystem) {
|
|
128
155
|
return {
|
|
129
156
|
name: "grep",
|
|
130
157
|
label: "grep",
|
|
@@ -133,39 +160,32 @@ function createHeadlessGrepTool() {
|
|
|
133
160
|
parameters: GrepParamsSchema,
|
|
134
161
|
executionMode: "parallel",
|
|
135
162
|
execute: async (_toolCallId, params, signal, _onUpdate, context) => {
|
|
163
|
+
const session = typeof filesystem === "function" ? filesystem() : filesystem;
|
|
136
164
|
return tagGrepResult(await runRipgrep({
|
|
137
165
|
params,
|
|
138
166
|
cwd: context.cwd,
|
|
139
|
-
signal
|
|
140
|
-
|
|
167
|
+
signal,
|
|
168
|
+
filesystem: session
|
|
169
|
+
}), params, context.cwd, signal, session);
|
|
141
170
|
}
|
|
142
171
|
};
|
|
143
172
|
}
|
|
144
|
-
|
|
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) {
|
|
173
|
+
async function tagGrepResult(nativeResult, params, cwd, signal, filesystem, writable = _agimon_ai_po_hashline_files.isWritableFile, outputOperations = defaultGrepOutput) {
|
|
156
174
|
const textPart = nativeResult.content.find((part) => part.type === "text");
|
|
157
175
|
if (!textPart || textPart.text === NO_MATCHES) return nativeResult;
|
|
158
176
|
const noticeIndex = textPart.text.lastIndexOf("\n\n[");
|
|
159
177
|
const rowsText = noticeIndex === -1 ? textPart.text : textPart.text.slice(0, noticeIndex);
|
|
160
178
|
const notice = noticeIndex === -1 ? "" : textPart.text.slice(noticeIndex);
|
|
161
179
|
const searchPath = (0, _agimon_ai_po_hashline_files.resolveInputPath)(params.path ?? ".", cwd);
|
|
162
|
-
const searchStats = await filesystem.stat(searchPath);
|
|
163
180
|
assertNotAborted(signal);
|
|
164
|
-
const
|
|
181
|
+
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;
|
|
182
|
+
const searchStats = await grepFileInfo(filesystem, searchPath, signal);
|
|
183
|
+
assertNotAborted(signal);
|
|
184
|
+
const rows = await parseValidatedGrepRows(rowsText, searchPath, searchStats.kind === "directory", signal, filesystem);
|
|
165
185
|
if (rows.length === 0) return nativeResult;
|
|
166
|
-
const groups = groupGrepRows(rows, searchPath, searchStats.
|
|
186
|
+
const groups = groupGrepRows(rows, searchPath, searchStats.kind === "directory", cwd);
|
|
167
187
|
const blocks = [];
|
|
168
|
-
let
|
|
188
|
+
let changedFiles = 0;
|
|
169
189
|
let linesTruncated = nativeResult.details?.linesTruncated ?? false;
|
|
170
190
|
for (const group of groups.values()) {
|
|
171
191
|
assertNotAborted(signal);
|
|
@@ -177,8 +197,14 @@ async function tagGrepResult(nativeResult, params, cwd, signal, writable = _agim
|
|
|
177
197
|
}
|
|
178
198
|
let bytes;
|
|
179
199
|
try {
|
|
180
|
-
bytes = await
|
|
181
|
-
} catch {
|
|
200
|
+
bytes = await (0, _agimon_ai_po_core_platform.readBoundedFile)(filesystem, group.absolutePath, 8388608, context);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
assertNotAborted(signal);
|
|
203
|
+
if (error instanceof _agimon_ai_po_core_platform.FileTooLargeError) {
|
|
204
|
+
blocks.push(`${group.nativeRows.join("\n")}\n[${group.path}: anchors omitted (file over 8 MiB)]`);
|
|
205
|
+
changedFiles++;
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
182
208
|
blocks.push(group.nativeRows.join("\n"));
|
|
183
209
|
continue;
|
|
184
210
|
}
|
|
@@ -194,10 +220,10 @@ async function tagGrepResult(nativeResult, params, cwd, signal, writable = _agim
|
|
|
194
220
|
}
|
|
195
221
|
if (output.length > 1) {
|
|
196
222
|
blocks.push(output.join("\n"));
|
|
197
|
-
|
|
223
|
+
changedFiles++;
|
|
198
224
|
} else blocks.push(group.nativeRows.join("\n"));
|
|
199
225
|
}
|
|
200
|
-
if (blocks.length === 0 ||
|
|
226
|
+
if (blocks.length === 0 || changedFiles === 0) return nativeResult;
|
|
201
227
|
const truncation = outputOperations.truncateHead(blocks.join("\n"), { maxLines: Number.MAX_SAFE_INTEGER });
|
|
202
228
|
const extraNotice = truncation.truncated ? `\n\n[${outputOperations.formatSize(outputOperations.maxBytes)} tagged output limit reached]` : "";
|
|
203
229
|
const details = {
|
|
@@ -234,6 +260,13 @@ function groupGrepRows(rows, searchPath, directory, cwd) {
|
|
|
234
260
|
}
|
|
235
261
|
return groups;
|
|
236
262
|
}
|
|
263
|
+
async function grepFileInfo(filesystem, path, signal) {
|
|
264
|
+
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;
|
|
265
|
+
const info = (0, _agimon_ai_po_core_platform.getOrThrow)(await filesystem.fileInfo(path, context));
|
|
266
|
+
if (info.kind !== "symlink") return info;
|
|
267
|
+
const target = (0, _agimon_ai_po_core_platform.getOrThrow)(await filesystem.canonicalPath(path, context));
|
|
268
|
+
return (0, _agimon_ai_po_core_platform.getOrThrow)(await filesystem.fileInfo(target, context));
|
|
269
|
+
}
|
|
237
270
|
async function parseValidatedGrepRows(rowsText, searchPath, directory, signal, filesystem) {
|
|
238
271
|
const pathCache = /* @__PURE__ */ new Map();
|
|
239
272
|
const rows = [];
|
|
@@ -254,7 +287,7 @@ async function parseValidatedGrepRows(rowsText, searchPath, directory, signal, f
|
|
|
254
287
|
const absolutePath = (0, node_path.resolve)(searchPath, candidate.path);
|
|
255
288
|
let exists = pathCache.get(absolutePath);
|
|
256
289
|
if (exists === void 0) {
|
|
257
|
-
exists = await filesystem
|
|
290
|
+
exists = await grepFileInfo(filesystem, absolutePath, signal).then((value) => value.kind === "file").catch(() => false);
|
|
258
291
|
assertNotAborted(signal);
|
|
259
292
|
pathCache.set(absolutePath, exists);
|
|
260
293
|
}
|
|
@@ -292,16 +325,28 @@ function assertNotAborted(signal) {
|
|
|
292
325
|
}
|
|
293
326
|
//#endregion
|
|
294
327
|
//#region src/extensions/workspaces/sessions/(backend)/tool/grep.mcp.ts
|
|
295
|
-
var grep_mcp_default = (0, _agimon_ai_po_core_mcpFacet.defineMcpTool)(() =>
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
328
|
+
var grep_mcp_default = (0, _agimon_ai_po_core_mcpFacet.defineMcpTool)((context) => {
|
|
329
|
+
const filesystem = context.services.get(_agimon_ai_po_core_platform.PO_FS_SERVICE);
|
|
330
|
+
if (!filesystem) throw new Error("Grep filesystem service is unavailable.");
|
|
331
|
+
return {
|
|
332
|
+
...createHeadlessGrepTool(filesystem),
|
|
333
|
+
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."
|
|
334
|
+
};
|
|
335
|
+
});
|
|
299
336
|
//#endregion
|
|
300
337
|
//#region generated/mcp.ts
|
|
301
338
|
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
302
|
-
const via = (identity, value) =>
|
|
303
|
-
|
|
304
|
-
|
|
339
|
+
const via = (identity, value) => {
|
|
340
|
+
if (value === void 0) return void 0;
|
|
341
|
+
const declaration = value;
|
|
342
|
+
return {
|
|
343
|
+
...identity,
|
|
344
|
+
...declaration,
|
|
345
|
+
...declaration.relations === void 0 ? {} : { relations: declaration.relations.map((relation) => ({
|
|
346
|
+
evidence: "declared",
|
|
347
|
+
...relation
|
|
348
|
+
})) }
|
|
349
|
+
};
|
|
305
350
|
};
|
|
306
351
|
const withWidget = (key, value) => value === void 0 ? value : {
|
|
307
352
|
...value,
|