@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.
Files changed (66) hide show
  1. package/README.md +25 -0
  2. package/agent-loader.js +3 -2
  3. package/agent-loader.js.map +2 -2
  4. package/main.js +82162 -46093
  5. package/main.js.map +4 -4
  6. package/package.json +12 -3
  7. package/resources/chrome-tools/browser-content.js +46 -46
  8. package/resources/chrome-tools/browser-cookies.js +16 -16
  9. package/resources/chrome-tools/browser-eval.js +27 -27
  10. package/resources/chrome-tools/browser-hn-scraper.js +1 -1
  11. package/resources/chrome-tools/browser-nav.js +23 -23
  12. package/resources/chrome-tools/browser-pick.js +127 -127
  13. package/resources/chrome-tools/browser-screenshot.js +10 -10
  14. package/resources/chrome-tools/browser-start.js +38 -38
  15. package/resources/pi-agent/extensions/answer.ts +392 -384
  16. package/resources/pi-agent/extensions/context.ts +415 -415
  17. package/resources/pi-agent/extensions/control.ts +1287 -1287
  18. package/resources/pi-agent/extensions/diff.ts +171 -171
  19. package/resources/pi-agent/extensions/files.ts +155 -155
  20. package/resources/pi-agent/extensions/knowledge.ts +664 -0
  21. package/resources/pi-agent/extensions/loop.ts +375 -375
  22. package/resources/pi-agent/extensions/pi-bash-live-view/index.ts +1 -1
  23. package/resources/pi-agent/extensions/pi-bash-live-view/package.json +22 -22
  24. package/resources/pi-agent/extensions/pi-bash-live-view/pty-execute.ts +2 -2
  25. package/resources/pi-agent/extensions/pi-bash-live-view/pty-session.ts +2 -2
  26. package/resources/pi-agent/extensions/pi-bash-live-view/spawn-helper.ts +2 -2
  27. package/resources/pi-agent/extensions/pi-bash-live-view/terminal-emulator.ts +18 -18
  28. package/resources/pi-agent/extensions/pi-bash-live-view/truncate.ts +1 -1
  29. package/resources/pi-agent/extensions/pi-bash-live-view/widget.ts +4 -4
  30. package/resources/pi-agent/extensions/pi-custom-compaction/package.json +4 -4
  31. package/resources/pi-agent/extensions/pi-mcp-adapter/app-bridge.bundle.js +14 -14
  32. package/resources/pi-agent/extensions/pi-mcp-adapter/commands.ts +6 -6
  33. package/resources/pi-agent/extensions/pi-mcp-adapter/config.ts +9 -9
  34. package/resources/pi-agent/extensions/pi-mcp-adapter/consent-manager.ts +4 -4
  35. package/resources/pi-agent/extensions/pi-mcp-adapter/direct-tools.ts +13 -13
  36. package/resources/pi-agent/extensions/pi-mcp-adapter/glimpse-ui.ts +5 -5
  37. package/resources/pi-agent/extensions/pi-mcp-adapter/host-html-template.ts +13 -13
  38. package/resources/pi-agent/extensions/pi-mcp-adapter/index.ts +14 -14
  39. package/resources/pi-agent/extensions/pi-mcp-adapter/init.ts +17 -17
  40. package/resources/pi-agent/extensions/pi-mcp-adapter/lifecycle.ts +2 -2
  41. package/resources/pi-agent/extensions/pi-mcp-adapter/logger.ts +2 -2
  42. package/resources/pi-agent/extensions/pi-mcp-adapter/mcp-panel.ts +17 -17
  43. package/resources/pi-agent/extensions/pi-mcp-adapter/metadata-cache.ts +9 -9
  44. package/resources/pi-agent/extensions/pi-mcp-adapter/npx-resolver.ts +35 -35
  45. package/resources/pi-agent/extensions/pi-mcp-adapter/oauth-handler.ts +1 -1
  46. package/resources/pi-agent/extensions/pi-mcp-adapter/proxy-modes.ts +12 -12
  47. package/resources/pi-agent/extensions/pi-mcp-adapter/server-manager.ts +6 -6
  48. package/resources/pi-agent/extensions/pi-mcp-adapter/tool-metadata.ts +4 -4
  49. package/resources/pi-agent/extensions/pi-mcp-adapter/types.ts +2 -2
  50. package/resources/pi-agent/extensions/pi-mcp-adapter/ui-resource-handler.ts +6 -6
  51. package/resources/pi-agent/extensions/pi-mcp-adapter/ui-server.ts +17 -17
  52. package/resources/pi-agent/extensions/pi-mcp-adapter/ui-session.ts +22 -22
  53. package/resources/pi-agent/extensions/pi-mcp-adapter/utils.ts +2 -2
  54. package/resources/pi-agent/extensions/prompt-editor.ts +900 -900
  55. package/resources/pi-agent/extensions/prompt-url-widget.ts +122 -122
  56. package/resources/pi-agent/extensions/redraws.ts +14 -14
  57. package/resources/pi-agent/extensions/review.ts +1533 -1533
  58. package/resources/pi-agent/extensions/todos.ts +1735 -1735
  59. package/resources/pi-agent/extensions/tps.ts +40 -40
  60. package/resources/pi-agent/extensions/whimsical.ts +3 -3
  61. package/resources/pi-agent/prompts/agent-system.md +2 -0
  62. package/resources/pi-agent/prompts/coder-system.md +2 -0
  63. package/server-loader.js +82 -1
  64. package/server-loader.js.map +3 -3
  65. package/tui.mjs +2 -0
  66. 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
- const prMatch = prompt.match(PR_PROMPT_PATTERN);
22
- if (prMatch?.[1]) {
23
- return { kind: "pr", url: prMatch[1].trim() };
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
- const issueMatch = prompt.match(ISSUE_PROMPT_PATTERN);
27
- if (issueMatch?.[1]) {
28
- return { kind: "issue", url: issueMatch[1].trim() };
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
- return undefined;
31
+ return undefined;
32
32
  }
33
33
 
34
34
  async function fetchGhMetadata(
35
- pi: ExtensionAPI,
36
- kind: PromptMatch["kind"],
37
- url: string,
35
+ pi: ExtensionAPI,
36
+ kind: PromptMatch["kind"],
37
+ url: string,
38
38
  ): Promise<GhMetadata | undefined> {
39
- const args =
39
+ const args =
40
40
  kind === "pr" ? ["pr", "view", url, "--json", "title,author"] : ["issue", "view", url, "--json", "title,author"];
41
41
 
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
- }
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
- 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;
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
- 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 =
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
- 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
- });
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 (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
- });
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
  }