@docyrus/docyrus 0.0.34 → 0.0.36
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 +25 -0
- package/agent-loader.js +3 -2
- package/agent-loader.js.map +2 -2
- package/main.js +82162 -46093
- package/main.js.map +4 -4
- package/package.json +12 -3
- package/resources/chrome-tools/browser-content.js +46 -46
- package/resources/chrome-tools/browser-cookies.js +16 -16
- package/resources/chrome-tools/browser-eval.js +27 -27
- package/resources/chrome-tools/browser-hn-scraper.js +1 -1
- package/resources/chrome-tools/browser-nav.js +23 -23
- package/resources/chrome-tools/browser-pick.js +127 -127
- package/resources/chrome-tools/browser-screenshot.js +10 -10
- package/resources/chrome-tools/browser-start.js +38 -38
- package/resources/pi-agent/extensions/answer.ts +392 -384
- package/resources/pi-agent/extensions/context.ts +415 -415
- package/resources/pi-agent/extensions/control.ts +1287 -1287
- package/resources/pi-agent/extensions/diff.ts +171 -171
- package/resources/pi-agent/extensions/files.ts +155 -155
- package/resources/pi-agent/extensions/knowledge.ts +664 -0
- package/resources/pi-agent/extensions/loop.ts +375 -375
- package/resources/pi-agent/extensions/pi-bash-live-view/index.ts +1 -1
- package/resources/pi-agent/extensions/pi-bash-live-view/package.json +22 -22
- package/resources/pi-agent/extensions/pi-bash-live-view/pty-execute.ts +2 -2
- package/resources/pi-agent/extensions/pi-bash-live-view/pty-session.ts +2 -2
- package/resources/pi-agent/extensions/pi-bash-live-view/spawn-helper.ts +2 -2
- package/resources/pi-agent/extensions/pi-bash-live-view/terminal-emulator.ts +18 -18
- package/resources/pi-agent/extensions/pi-bash-live-view/truncate.ts +1 -1
- package/resources/pi-agent/extensions/pi-bash-live-view/widget.ts +4 -4
- package/resources/pi-agent/extensions/pi-custom-compaction/package.json +4 -4
- package/resources/pi-agent/extensions/pi-mcp-adapter/app-bridge.bundle.js +14 -14
- package/resources/pi-agent/extensions/pi-mcp-adapter/commands.ts +6 -6
- package/resources/pi-agent/extensions/pi-mcp-adapter/config.ts +9 -9
- package/resources/pi-agent/extensions/pi-mcp-adapter/consent-manager.ts +4 -4
- package/resources/pi-agent/extensions/pi-mcp-adapter/direct-tools.ts +13 -13
- package/resources/pi-agent/extensions/pi-mcp-adapter/glimpse-ui.ts +5 -5
- package/resources/pi-agent/extensions/pi-mcp-adapter/host-html-template.ts +13 -13
- package/resources/pi-agent/extensions/pi-mcp-adapter/index.ts +14 -14
- package/resources/pi-agent/extensions/pi-mcp-adapter/init.ts +17 -17
- package/resources/pi-agent/extensions/pi-mcp-adapter/lifecycle.ts +2 -2
- package/resources/pi-agent/extensions/pi-mcp-adapter/logger.ts +2 -2
- package/resources/pi-agent/extensions/pi-mcp-adapter/mcp-panel.ts +17 -17
- package/resources/pi-agent/extensions/pi-mcp-adapter/metadata-cache.ts +9 -9
- package/resources/pi-agent/extensions/pi-mcp-adapter/npx-resolver.ts +35 -35
- package/resources/pi-agent/extensions/pi-mcp-adapter/oauth-handler.ts +1 -1
- package/resources/pi-agent/extensions/pi-mcp-adapter/proxy-modes.ts +12 -12
- package/resources/pi-agent/extensions/pi-mcp-adapter/server-manager.ts +6 -6
- package/resources/pi-agent/extensions/pi-mcp-adapter/tool-metadata.ts +4 -4
- package/resources/pi-agent/extensions/pi-mcp-adapter/types.ts +2 -2
- package/resources/pi-agent/extensions/pi-mcp-adapter/ui-resource-handler.ts +6 -6
- package/resources/pi-agent/extensions/pi-mcp-adapter/ui-server.ts +17 -17
- package/resources/pi-agent/extensions/pi-mcp-adapter/ui-session.ts +22 -22
- package/resources/pi-agent/extensions/pi-mcp-adapter/utils.ts +2 -2
- package/resources/pi-agent/extensions/prompt-editor.ts +900 -900
- package/resources/pi-agent/extensions/prompt-url-widget.ts +122 -122
- package/resources/pi-agent/extensions/redraws.ts +14 -14
- package/resources/pi-agent/extensions/review.ts +1533 -1533
- package/resources/pi-agent/extensions/todos.ts +1735 -1735
- package/resources/pi-agent/extensions/tps.ts +40 -40
- package/resources/pi-agent/extensions/whimsical.ts +3 -3
- package/resources/pi-agent/prompts/agent-system.md +2 -0
- package/resources/pi-agent/prompts/coder-system.md +2 -0
- package/server-loader.js +82 -1
- package/server-loader.js.map +3 -3
- package/tui.mjs +2 -0
- package/tui.mjs.map +1 -1
|
@@ -18,141 +18,141 @@ type GhMetadata = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
function extractPromptMatch(prompt: string): PromptMatch | undefined {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const prMatch = prompt.match(PR_PROMPT_PATTERN);
|
|
22
|
+
if (prMatch?.[1]) {
|
|
23
|
+
return { kind: "pr", url: prMatch[1].trim() };
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const issueMatch = prompt.match(ISSUE_PROMPT_PATTERN);
|
|
27
|
+
if (issueMatch?.[1]) {
|
|
28
|
+
return { kind: "issue", url: issueMatch[1].trim() };
|
|
29
|
+
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
return undefined;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
async function fetchGhMetadata(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
pi: ExtensionAPI,
|
|
36
|
+
kind: PromptMatch["kind"],
|
|
37
|
+
url: string,
|
|
38
38
|
): Promise<GhMetadata | undefined> {
|
|
39
|
-
|
|
39
|
+
const args =
|
|
40
40
|
kind === "pr" ? ["pr", "view", url, "--json", "title,author"] : ["issue", "view", url, "--json", "title,author"];
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
try {
|
|
43
|
+
const result = await pi.exec("gh", args);
|
|
44
|
+
if (result.code !== 0 || !result.stdout) {return undefined;}
|
|
45
|
+
return JSON.parse(result.stdout) as GhMetadata;
|
|
46
|
+
} catch {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function formatAuthor(author?: GhMetadata["author"]): string | undefined {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
if (!author) {return undefined;}
|
|
53
|
+
const name = author.name?.trim();
|
|
54
|
+
const login = author.login?.trim();
|
|
55
|
+
if (name && login) {return `${name} (@${login})`;}
|
|
56
|
+
if (login) {return `@${login}`;}
|
|
57
|
+
if (name) {return name;}
|
|
58
|
+
return undefined;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export default function promptUrlWidgetExtension(pi: ExtensionAPI) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
62
|
+
const setWidget = (ctx: ExtensionContext, match: PromptMatch, title?: string, authorText?: string) => {
|
|
63
|
+
ctx.ui.setWidget("prompt-url", (_tui, thm) => {
|
|
64
|
+
const titleText = title ? thm.fg("accent", title) : thm.fg("accent", match.url);
|
|
65
|
+
const authorLine = authorText ? thm.fg("muted", authorText) : undefined;
|
|
66
|
+
const urlLine = thm.fg("dim", match.url);
|
|
67
|
+
|
|
68
|
+
const lines = [titleText];
|
|
69
|
+
if (authorLine) {lines.push(authorLine);}
|
|
70
|
+
lines.push(urlLine);
|
|
71
|
+
|
|
72
|
+
const container = new Container();
|
|
73
|
+
container.addChild(new DynamicBorder((s: string) => thm.fg("muted", s)));
|
|
74
|
+
container.addChild(new Text(lines.join("\n"), 1, 0));
|
|
75
|
+
return container;
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const applySessionName = (ctx: ExtensionContext, match: PromptMatch, title?: string) => {
|
|
80
|
+
const label = match.kind === "pr" ? "PR" : "Issue";
|
|
81
|
+
const trimmedTitle = title?.trim();
|
|
82
|
+
const fallbackName = `${label}: ${match.url}`;
|
|
83
|
+
const desiredName = trimmedTitle ? `${label}: ${trimmedTitle} (${match.url})` : fallbackName;
|
|
84
|
+
const currentName = pi.getSessionName()?.trim();
|
|
85
|
+
if (!currentName) {
|
|
86
|
+
pi.setSessionName(desiredName);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (currentName === match.url || currentName === fallbackName) {
|
|
90
|
+
pi.setSessionName(desiredName);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
pi.on("before_agent_start", async(event, ctx) => {
|
|
95
|
+
if (!ctx.hasUI) {return;}
|
|
96
|
+
const match = extractPromptMatch(event.prompt);
|
|
97
|
+
if (!match) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
setWidget(ctx, match);
|
|
102
|
+
applySessionName(ctx, match);
|
|
103
|
+
void fetchGhMetadata(pi, match.kind, match.url).then((meta) => {
|
|
104
|
+
const title = meta?.title?.trim();
|
|
105
|
+
const authorText = formatAuthor(meta?.author);
|
|
106
|
+
setWidget(ctx, match, title, authorText);
|
|
107
|
+
applySessionName(ctx, match, title);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
pi.on("session_switch", async(_event, ctx) => {
|
|
112
|
+
rebuildFromSession(ctx);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const getUserText = (content: string | { type: string; text?: string }[] | undefined): string => {
|
|
116
|
+
if (!content) {return "";}
|
|
117
|
+
if (typeof content === "string") {return content;}
|
|
118
|
+
return (
|
|
119
|
+
content
|
|
120
|
+
.filter((block): block is { type: "text"; text: string } => block.type === "text")
|
|
121
|
+
.map((block) => block.text)
|
|
122
|
+
.join("\n") ?? ""
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const rebuildFromSession = (ctx: ExtensionContext) => {
|
|
127
|
+
if (!ctx.hasUI) {return;}
|
|
128
|
+
|
|
129
|
+
const entries = ctx.sessionManager.getEntries();
|
|
130
|
+
const lastMatch = [...entries].reverse().find((entry) => {
|
|
131
|
+
if (entry.type !== "message" || entry.message.role !== "user") {return false;}
|
|
132
|
+
const text = getUserText(entry.message.content);
|
|
133
|
+
return !!extractPromptMatch(text);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const content =
|
|
137
137
|
lastMatch?.type === "message" && lastMatch.message.role === "user" ? lastMatch.message.content : undefined;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
138
|
+
const text = getUserText(content);
|
|
139
|
+
const match = text ? extractPromptMatch(text) : undefined;
|
|
140
|
+
if (!match) {
|
|
141
|
+
ctx.ui.setWidget("prompt-url", undefined);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
setWidget(ctx, match);
|
|
146
|
+
applySessionName(ctx, match);
|
|
147
|
+
void fetchGhMetadata(pi, match.kind, match.url).then((meta) => {
|
|
148
|
+
const title = meta?.title?.trim();
|
|
149
|
+
const authorText = formatAuthor(meta?.author);
|
|
150
|
+
setWidget(ctx, match, title, authorText);
|
|
151
|
+
applySessionName(ctx, match, title);
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
pi.on("session_start", async(_event, ctx) => {
|
|
156
|
+
rebuildFromSession(ctx);
|
|
157
|
+
});
|
|
158
158
|
}
|
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
8
8
|
import { Text } from "@mariozechner/pi-tui";
|
|
9
9
|
|
|
10
|
-
export default function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
export default function(pi: ExtensionAPI) {
|
|
11
|
+
pi.registerCommand("tui", {
|
|
12
|
+
description: "Show TUI stats",
|
|
13
|
+
handler: async(_args, ctx) => {
|
|
14
|
+
if (!ctx.hasUI) {return;}
|
|
15
|
+
let redraws = 0;
|
|
16
|
+
await ctx.ui.custom<void>((tui, _theme, _keybindings, done) => {
|
|
17
|
+
redraws = tui.fullRedraws;
|
|
18
|
+
done(undefined);
|
|
19
|
+
return new Text("", 0, 0);
|
|
20
|
+
});
|
|
21
|
+
ctx.ui.notify(`TUI full redraws: ${redraws}`, "info");
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
24
|
}
|