@agimon-ai/doompi-read 0.0.1-alpha.2 → 0.0.1-alpha.20
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 +1 -1
- package/package.json +33 -12
- package/src/exports/webClient.ts +1 -0
- package/src/web/ReadToolMessage.tsx +99 -0
- package/src/web/index.ts +11 -0
- package/src/web/readToolView.ts +24 -0
- package/src/web/tsconfig.json +23 -0
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/doompi-read",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.20",
|
|
4
4
|
"description": "Snapshot-bound hashline read tool for Pi and DoomPi.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -14,10 +14,20 @@
|
|
|
14
14
|
"read"
|
|
15
15
|
],
|
|
16
16
|
"homepage": "https://agimon.ai",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/AgiFlow/doompi/issues"
|
|
19
|
+
},
|
|
17
20
|
"license": "MIT",
|
|
18
21
|
"author": "Vuong Ngo",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/AgiFlow/doompi.git",
|
|
25
|
+
"directory": "packages/default/doompi-read"
|
|
26
|
+
},
|
|
19
27
|
"files": [
|
|
20
|
-
"dist"
|
|
28
|
+
"dist",
|
|
29
|
+
"src/web",
|
|
30
|
+
"src/exports/webClient.ts"
|
|
21
31
|
],
|
|
22
32
|
"type": "module",
|
|
23
33
|
"main": "./dist/index.cjs",
|
|
@@ -41,23 +51,29 @@
|
|
|
41
51
|
},
|
|
42
52
|
"dependencies": {
|
|
43
53
|
"@deepseek-ai/cordis": "4.0.1",
|
|
44
|
-
"typebox": "1.3.
|
|
45
|
-
"@agimon-ai/doompi-
|
|
46
|
-
"@agimon-ai/doompi-
|
|
47
|
-
"@agimon-ai/doompi-
|
|
54
|
+
"typebox": "1.3.19",
|
|
55
|
+
"@agimon-ai/doompi-extension-contracts": "0.0.1-alpha.47",
|
|
56
|
+
"@agimon-ai/doompi-web-contracts": "0.0.1-alpha.11",
|
|
57
|
+
"@agimon-ai/doompi-hashline": "0.0.1-alpha.19",
|
|
58
|
+
"@agimon-ai/doompi-ui": "0.0.1-alpha.48",
|
|
59
|
+
"@agimon-ai/doompi-web-components": "0.0.1-alpha.8"
|
|
48
60
|
},
|
|
49
61
|
"devDependencies": {
|
|
50
|
-
"@earendil-works/pi-coding-agent": "0.84.
|
|
51
|
-
"@earendil-works/pi-tui": "0.84.
|
|
52
|
-
"@
|
|
62
|
+
"@earendil-works/pi-coding-agent": "0.84.4",
|
|
63
|
+
"@earendil-works/pi-tui": "0.84.4",
|
|
64
|
+
"@tanstack/react-store": "0.11.1",
|
|
65
|
+
"@tanstack/store": "0.11.1",
|
|
66
|
+
"@types/node": "26.4.0",
|
|
67
|
+
"@types/react": "19.2.18",
|
|
53
68
|
"@vitest/coverage-v8": "4.1.11",
|
|
69
|
+
"react": "19.2.8",
|
|
54
70
|
"tsdown": "0.22.14",
|
|
55
71
|
"typescript": "7.0.2",
|
|
56
72
|
"vitest": "4.1.11"
|
|
57
73
|
},
|
|
58
74
|
"peerDependencies": {
|
|
59
|
-
"@earendil-works/pi-coding-agent": "0.84.
|
|
60
|
-
"@earendil-works/pi-tui": "0.84.
|
|
75
|
+
"@earendil-works/pi-coding-agent": "0.84.4",
|
|
76
|
+
"@earendil-works/pi-tui": "0.84.4"
|
|
61
77
|
},
|
|
62
78
|
"peerDependenciesMeta": {
|
|
63
79
|
"@earendil-works/pi-coding-agent": {
|
|
@@ -70,6 +86,11 @@
|
|
|
70
86
|
"engines": {
|
|
71
87
|
"node": ">=22.19.0"
|
|
72
88
|
},
|
|
89
|
+
"doompiWeb": {
|
|
90
|
+
"pluginId": "read",
|
|
91
|
+
"channels": [],
|
|
92
|
+
"client": "./src/exports/webClient.ts"
|
|
93
|
+
},
|
|
73
94
|
"pi": {
|
|
74
95
|
"extensions": [
|
|
75
96
|
"./dist/extensions/pi.mjs"
|
|
@@ -78,7 +99,7 @@
|
|
|
78
99
|
"scripts": {
|
|
79
100
|
"build": "tsdown",
|
|
80
101
|
"test": "vitest --run",
|
|
81
|
-
"typecheck": "tsc --noEmit",
|
|
102
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p src/web/tsconfig.json",
|
|
82
103
|
"lint": "oxlint . && oxfmt . --check",
|
|
83
104
|
"fixcode": "oxlint . --fix && oxfmt ."
|
|
84
105
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { webPlugin } from '../web/index.ts';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HashlineLines,
|
|
3
|
+
hashlineBody,
|
|
4
|
+
MessageItem,
|
|
5
|
+
MessageItemBody,
|
|
6
|
+
MessageItemHeader,
|
|
7
|
+
MessageItemStatus,
|
|
8
|
+
resultTextLines,
|
|
9
|
+
toolTone,
|
|
10
|
+
} from '@agimon-ai/doompi-web-components';
|
|
11
|
+
import type { ToolMessageRenderProps } from '@agimon-ai/doompi-web-contracts';
|
|
12
|
+
import { readCallView } from './readToolView.ts';
|
|
13
|
+
|
|
14
|
+
const IMAGE_MIME_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);
|
|
15
|
+
|
|
16
|
+
function resultImages(content: readonly unknown[]): Array<{ data: string; mimeType: string }> {
|
|
17
|
+
return content.flatMap((block) => {
|
|
18
|
+
if (typeof block !== 'object' || block === null || Array.isArray(block)) return [];
|
|
19
|
+
const value = block as Record<string, unknown>;
|
|
20
|
+
return value.type === 'image' &&
|
|
21
|
+
typeof value.data === 'string' &&
|
|
22
|
+
typeof value.mimeType === 'string' &&
|
|
23
|
+
IMAGE_MIME_TYPES.has(value.mimeType)
|
|
24
|
+
? [{ data: value.data, mimeType: value.mimeType }]
|
|
25
|
+
: [];
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The read tool's timeline item, the web half of its renderCall and
|
|
30
|
+
* renderResult: the call summary in the header and the anchored lines with
|
|
31
|
+
* a line-number gutter in the body, collapsed to the TUI's budget until the
|
|
32
|
+
* item expands. A failure shows the tool's message in red instead.
|
|
33
|
+
*/
|
|
34
|
+
export function ReadToolMessage({ args, result, output, running, isError }: ToolMessageRenderProps) {
|
|
35
|
+
const view = readCallView(args);
|
|
36
|
+
const images = resultImages(result?.content ?? []);
|
|
37
|
+
const collapsed = result === null || isError ? null : hashlineBody(result, output, 'read', false);
|
|
38
|
+
return (
|
|
39
|
+
<MessageItem tone={toolTone({ running, isError })} expandable={collapsed !== null && collapsed.hidden > 0}>
|
|
40
|
+
{({ expanded }) => {
|
|
41
|
+
const body =
|
|
42
|
+
result === null || isError ? null : expanded ? hashlineBody(result, output, 'read', true) : collapsed;
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<MessageItemHeader title="read">
|
|
46
|
+
<span data-testid="tool-call-read" className="flex min-w-0 flex-1 items-center gap-2">
|
|
47
|
+
<span className="truncate text-doom-text">{view.path}</span>
|
|
48
|
+
{view.details.length > 0 ? (
|
|
49
|
+
<span className="shrink-0 text-doom-faint">· {view.details.join(' · ')}</span>
|
|
50
|
+
) : null}
|
|
51
|
+
</span>
|
|
52
|
+
</MessageItemHeader>
|
|
53
|
+
{isError ? (
|
|
54
|
+
<MessageItemBody data-testid="tool-result-read" className="flex flex-col">
|
|
55
|
+
<MessageItemStatus tone="error">failed</MessageItemStatus>
|
|
56
|
+
{resultTextLines(result, output).map((line, index) => (
|
|
57
|
+
<span key={`${String(index)}-${line}`} className="whitespace-pre-wrap break-words text-doom-red">
|
|
58
|
+
{line}
|
|
59
|
+
</span>
|
|
60
|
+
))}
|
|
61
|
+
</MessageItemBody>
|
|
62
|
+
) : body === null ? (
|
|
63
|
+
running ? (
|
|
64
|
+
<MessageItemBody data-testid="tool-result-read">
|
|
65
|
+
<MessageItemStatus tone="running">running</MessageItemStatus>
|
|
66
|
+
</MessageItemBody>
|
|
67
|
+
) : null
|
|
68
|
+
) : body.shown.length === 0 && body.notice === undefined && images.length === 0 ? null : (
|
|
69
|
+
<MessageItemBody data-testid="tool-result-read" className="flex flex-col gap-1">
|
|
70
|
+
<HashlineLines lines={body.shown} gutter={body.gutter} />
|
|
71
|
+
{images.map((image, index) => {
|
|
72
|
+
const url = `data:${image.mimeType};base64,${image.data}`;
|
|
73
|
+
return (
|
|
74
|
+
<a
|
|
75
|
+
key={`${image.mimeType}:${String(index)}`}
|
|
76
|
+
href={url}
|
|
77
|
+
target="_blank"
|
|
78
|
+
rel="noreferrer"
|
|
79
|
+
className="self-start"
|
|
80
|
+
>
|
|
81
|
+
<img
|
|
82
|
+
src={url}
|
|
83
|
+
alt={`Read result ${String(index + 1)}`}
|
|
84
|
+
data-testid="tool-result-read-image"
|
|
85
|
+
className="h-auto max-h-96 max-w-full rounded-md border border-doom-border-soft object-contain"
|
|
86
|
+
/>
|
|
87
|
+
</a>
|
|
88
|
+
);
|
|
89
|
+
})}
|
|
90
|
+
{body.hidden > 0 ? <MessageItemStatus expands>{body.hidden} more lines</MessageItemStatus> : null}
|
|
91
|
+
{body.notice !== undefined ? <span className="text-doom-faint">{body.notice}</span> : null}
|
|
92
|
+
</MessageItemBody>
|
|
93
|
+
)}
|
|
94
|
+
</>
|
|
95
|
+
);
|
|
96
|
+
}}
|
|
97
|
+
</MessageItem>
|
|
98
|
+
);
|
|
99
|
+
}
|
package/src/web/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineWebPlugin } from '@agimon-ai/doompi-web-contracts';
|
|
2
|
+
import { ReadToolMessage } from './ReadToolMessage.tsx';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This package's cockpit presence: the read tool's timeline card, the web
|
|
6
|
+
* half of the TUI's renderCall and renderResult for hashline reads.
|
|
7
|
+
*/
|
|
8
|
+
export const webPlugin = defineWebPlugin({
|
|
9
|
+
id: 'read',
|
|
10
|
+
toolRenderers: [{ tools: ['read'], message: ReadToolMessage }],
|
|
11
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { compactDetails } from '@agimon-ai/doompi-web-components';
|
|
2
|
+
|
|
3
|
+
export interface ReadCallView {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
/** `from N` and `N lines`, as the TUI's call heading lists them. */
|
|
6
|
+
readonly details: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function optionalNumber(value: unknown): number | undefined {
|
|
10
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** What the read call heading shows: the path, then the offset and limit when given. */
|
|
14
|
+
export function readCallView(args: Readonly<Record<string, unknown>>): ReadCallView {
|
|
15
|
+
const offset = optionalNumber(args.offset);
|
|
16
|
+
const limit = optionalNumber(args.limit);
|
|
17
|
+
return {
|
|
18
|
+
path: typeof args.path === 'string' ? args.path : '',
|
|
19
|
+
details: compactDetails([
|
|
20
|
+
offset === undefined ? undefined : `from ${offset}`,
|
|
21
|
+
limit === undefined ? undefined : `${limit} lines`,
|
|
22
|
+
]),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noImplicitAny": true,
|
|
10
|
+
"noUnusedLocals": true,
|
|
11
|
+
"noUnusedParameters": true,
|
|
12
|
+
"noImplicitReturns": true,
|
|
13
|
+
"noFallthroughCasesInSwitch": true,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"allowImportingTsExtensions": true,
|
|
19
|
+
"forceConsistentCasingInFileNames": true,
|
|
20
|
+
"types": ["node"]
|
|
21
|
+
},
|
|
22
|
+
"include": [".", "../types", "../exports/webClient.ts"]
|
|
23
|
+
}
|