@evandu/super-pi 0.1.126 → 0.1.127
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/dist/.super-pi-check-inputs.json +2 -2
- package/dist/client/.super-pi-client-sources.json +7 -7
- package/dist/client/assets/{CodeMirrorEditor-B0lBmhx0.js → CodeMirrorEditor-DpbDVB1W.js} +2 -2
- package/dist/client/assets/{dist-pUnfiqui.js → dist-3JbohZwT.js} +1 -1
- package/dist/client/assets/{dist-BzqfS4cF.js → dist-BTxdkV1I.js} +1 -1
- package/dist/client/assets/{dist-CoiRxusA.js → dist-C30Mvvko.js} +1 -1
- package/dist/client/assets/{dist-BYtrk8af.js → dist-CBqTq6Rd.js} +1 -1
- package/dist/client/assets/{dist-BZ7PyaBp.js → dist-CKY9oRoB.js} +1 -1
- package/dist/client/assets/{dist-GF4SWnU-.js → dist-CZ_MzICk.js} +1 -1
- package/dist/client/assets/{dist-rONoVhdP.js → dist-CbkhMDE7.js} +1 -1
- package/dist/client/assets/{dist-Bi1EIIwj.js → dist-Cv9yhljh.js} +1 -1
- package/dist/client/assets/{dist-CL6353ch.js → dist-DL2rVK6z.js} +1 -1
- package/dist/client/assets/{dist-CuTxPpgb.js → dist-DhVx85Hi.js} +1 -1
- package/dist/client/assets/{dist-XPppcWa2.js → dist-DkWOTrCe.js} +1 -1
- package/dist/client/assets/{dist-BSZCQuEt.js → dist-Dx5uAXkp.js} +1 -1
- package/dist/client/assets/{dist-x58QSOcp.js → dist-H1xOj1sR.js} +1 -1
- package/dist/client/assets/{dist-DAujCIzu.js → dist-NOyudbxD.js} +1 -1
- package/dist/client/assets/{dist-BCUV3ivx.js → dist-NukDmwGc.js} +1 -1
- package/dist/client/assets/{dist-CjS579f2.js → dist-Uvt7BHub.js} +1 -1
- package/dist/client/assets/{dist-BNQkX4KY.js → dist-XSLGDk_-.js} +1 -1
- package/dist/client/assets/{dist-BW_rg1Bj.js → dist-ik9WKwIy.js} +1 -1
- package/dist/client/assets/{dist-SzL6z89P.js → dist-j9nf5NbD.js} +1 -1
- package/dist/client/assets/{dist-eerDlQWM.js → dist-kPkvm0f9.js} +1 -1
- package/dist/client/assets/{dist-BFm82vnX.js → dist-qTKaDyIl.js} +1 -1
- package/dist/client/assets/{dist-DawI143o.js → dist-zedNmYPO.js} +1 -1
- package/dist/client/assets/{index-09I_ABgJ.css → index-BAaymrG2.css} +1 -1
- package/dist/client/assets/{index-Dp0610g1.js → index-DvxaTOG8.js} +9 -9
- package/dist/client/index.html +2 -2
- package/dist/server/application/catalog-service.d.ts +4 -1
- package/dist/server/application/catalog-service.js +21 -0
- package/dist/server/command-handler.js +6 -0
- package/dist/server/pi-session.d.ts +22 -0
- package/dist/server/pi-session.js +20 -10
- package/dist/server/types.d.ts +21 -0
- package/package.json +5 -3
package/dist/client/index.html
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
<link rel="alternate icon" href="/favicon.ico" />
|
|
9
9
|
<link rel="apple-touch-icon" href="/favicon.svg" />
|
|
10
10
|
<title>Super Pi</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-DvxaTOG8.js"></script>
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BAaymrG2.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="root"></div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentRuntime } from "../runtime.js";
|
|
2
|
-
import type { AgentCatalog, ModelCatalog, ModelSelection } from "../types.js";
|
|
2
|
+
import type { AgentCatalog, ModelCatalog, ModelSelection, PromptCatalog } from "../types.js";
|
|
3
3
|
import type { EventBroadcaster } from "../server-context.js";
|
|
4
4
|
import type { Store } from "../store.js";
|
|
5
5
|
/**
|
|
@@ -12,6 +12,7 @@ export declare class CatalogService {
|
|
|
12
12
|
private readonly rootDir?;
|
|
13
13
|
private readonly onDirsChanged?;
|
|
14
14
|
private agentDirs;
|
|
15
|
+
private readonly promptCatalogs;
|
|
15
16
|
constructor(runtime: AgentRuntime, broadcaster: EventBroadcaster, agentsDir: string | readonly string[], store?: Store | undefined, rootDir?: string | undefined, onDirsChanged?: ((dirs: string[]) => void) | undefined);
|
|
16
17
|
/**
|
|
17
18
|
* Returns current active agent discovery directories.
|
|
@@ -67,6 +68,8 @@ export declare class CatalogService {
|
|
|
67
68
|
* Broadcasts subagents to connected clients.
|
|
68
69
|
*/
|
|
69
70
|
broadcastSubagents(): Promise<void>;
|
|
71
|
+
promptCatalog(workspaceId: string): Promise<PromptCatalog>;
|
|
72
|
+
broadcastPromptCatalog(workspaceId: string): Promise<void>;
|
|
70
73
|
/**
|
|
71
74
|
* Sets the app-wide default model, or clears it back to "Pi's own default".
|
|
72
75
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertModelAllowed, conversationWorkspace } from "../model-filter.js";
|
|
2
2
|
import { readAgents, resolveAgentDirectories } from "../agents.js";
|
|
3
|
+
import { loadPromptTemplateSummaries } from "../pi-session.js";
|
|
3
4
|
function summarize(agent) {
|
|
4
5
|
const { prompt, toolFlags, ...summary } = agent;
|
|
5
6
|
const toolSummary = toolFlags.includes("--no-tools")
|
|
@@ -21,6 +22,7 @@ export class CatalogService {
|
|
|
21
22
|
rootDir;
|
|
22
23
|
onDirsChanged;
|
|
23
24
|
agentDirs;
|
|
25
|
+
promptCatalogs = new Map();
|
|
24
26
|
constructor(runtime, broadcaster, agentsDir, store, rootDir, onDirsChanged) {
|
|
25
27
|
this.runtime = runtime;
|
|
26
28
|
this.broadcaster = broadcaster;
|
|
@@ -176,6 +178,25 @@ export class CatalogService {
|
|
|
176
178
|
async broadcastSubagents() {
|
|
177
179
|
this.broadcaster.broadcast({ type: "subagent.catalog", catalog: await this.subagentCatalog() });
|
|
178
180
|
}
|
|
181
|
+
async promptCatalog(workspaceId) {
|
|
182
|
+
const cached = this.promptCatalogs.get(workspaceId);
|
|
183
|
+
if (cached && cached.expiresAt > Date.now())
|
|
184
|
+
return cached.catalog;
|
|
185
|
+
const workspace = this.store?.snapshot().workspaces.find((item) => item.id === workspaceId);
|
|
186
|
+
if (!workspace)
|
|
187
|
+
return { source: "unavailable", prompts: [], workspaceId, fetchedAt: new Date().toISOString(), error: "workspace not found" };
|
|
188
|
+
try {
|
|
189
|
+
const catalog = { source: "sdk", prompts: await loadPromptTemplateSummaries(workspace.path), workspaceId, fetchedAt: new Date().toISOString() };
|
|
190
|
+
this.promptCatalogs.set(workspaceId, { expiresAt: Date.now() + 1_000, catalog });
|
|
191
|
+
return catalog;
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
return { source: "unavailable", prompts: [], workspaceId, fetchedAt: new Date().toISOString(), error: error instanceof Error ? error.message : String(error) };
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async broadcastPromptCatalog(workspaceId) {
|
|
198
|
+
this.broadcaster.broadcast({ type: "prompt.catalog", catalog: await this.promptCatalog(workspaceId) });
|
|
199
|
+
}
|
|
179
200
|
/**
|
|
180
201
|
* Sets the app-wide default model, or clears it back to "Pi's own default".
|
|
181
202
|
*
|
|
@@ -332,6 +332,12 @@ export class CommandHandler {
|
|
|
332
332
|
sendToSocket({ type: "model.catalog.all", catalog: await this.catalogService.getAllCatalog() });
|
|
333
333
|
return;
|
|
334
334
|
}
|
|
335
|
+
if (command.type === "prompt.catalog.fetch") {
|
|
336
|
+
const catalog = await this.catalogService.promptCatalog(command.workspaceId);
|
|
337
|
+
if (sendToSocket)
|
|
338
|
+
sendToSocket({ type: "prompt.catalog", catalog });
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
335
341
|
if (command.type === "agent.catalog.fetch") {
|
|
336
342
|
await this.catalogService.broadcastAgents();
|
|
337
343
|
return;
|
|
@@ -370,6 +370,21 @@ export interface SessionCreation {
|
|
|
370
370
|
*/
|
|
371
371
|
export type PiSessionFactory = (creation: SessionCreation) => Promise<PiSessionLike>;
|
|
372
372
|
export declare function createPiSession(creation: SessionCreation): Promise<PiSessionLike>;
|
|
373
|
+
/**
|
|
374
|
+
* Pi's own global configuration directory, when it can be worked out without importing the SDK.
|
|
375
|
+
*
|
|
376
|
+
* The SDK's `getAgentDir()` is the authority, but asking it would mean importing the SDK - which this
|
|
377
|
+
* file goes out of its way not to do for a path it can derive. The derivation is Pi's own default:
|
|
378
|
+
* `~/.pi/agent`, with the home directory taken from the environment rather than from `os.homedir()`,
|
|
379
|
+
* because on Windows the two disagree often enough to matter.
|
|
380
|
+
*
|
|
381
|
+
* `PI_CODING_AGENT_DIR` WINS, exactly as it wins in Pi (`core/config.ts:getAgentDir`). A person who
|
|
382
|
+
* set it expects Pi to read its whole configuration from there, and this function used to disagree
|
|
383
|
+
* with Pi about it: Pi's model runtime read `models.json` from that directory while the session's
|
|
384
|
+
* resource loader read the skills from `~/.pi/agent`. Two halves of one Pi pointed at two
|
|
385
|
+
* directories, and only one of them was the one the person had configured.
|
|
386
|
+
*/
|
|
387
|
+
export declare function defaultAgentDir(): string;
|
|
373
388
|
/**
|
|
374
389
|
* The Super Pi extension files, as absolute paths.
|
|
375
390
|
*
|
|
@@ -378,4 +393,11 @@ export declare function createPiSession(creation: SessionCreation): Promise<PiSe
|
|
|
378
393
|
* rather than against the server's directory, so a relative path would find a different file for every
|
|
379
394
|
* workspace. The SDK takes an absolute path, and this keeps the two paths of the same file.
|
|
380
395
|
*/
|
|
396
|
+
export interface PromptTemplateSummary {
|
|
397
|
+
name: string;
|
|
398
|
+
description: string;
|
|
399
|
+
argumentHint?: string;
|
|
400
|
+
scope: "user" | "project";
|
|
401
|
+
}
|
|
402
|
+
export declare function loadPromptTemplateSummaries(cwd: string): Promise<PromptTemplateSummary[]>;
|
|
381
403
|
export declare function superPiExtensionPaths(repositoryRoot: string): string[];
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
* would notice the difference.
|
|
25
25
|
*/
|
|
26
26
|
import { existsSync, statSync } from "node:fs";
|
|
27
|
-
import { join } from "node:path";
|
|
27
|
+
import { dirname, join } from "node:path";
|
|
28
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
28
29
|
const traceSession = (conversationId, phase, startedAt, extra = "") => {
|
|
29
30
|
if (process.env.SUPER_PI_TRACE_LATENCY !== "1")
|
|
30
31
|
return;
|
|
@@ -353,21 +354,30 @@ async function resolveSessionManager(sdk, creation) {
|
|
|
353
354
|
* resource loader read the skills from `~/.pi/agent`. Two halves of one Pi pointed at two
|
|
354
355
|
* directories, and only one of them was the one the person had configured.
|
|
355
356
|
*/
|
|
356
|
-
function defaultAgentDir() {
|
|
357
|
+
export function defaultAgentDir() {
|
|
357
358
|
const configured = process.env.PI_CODING_AGENT_DIR?.trim();
|
|
358
359
|
if (configured)
|
|
359
360
|
return configured;
|
|
360
361
|
const home = process.env.HOME ?? process.env.USERPROFILE ?? "";
|
|
361
362
|
return home ? join(home, ".pi", "agent") : join(".pi", "agent");
|
|
362
363
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
364
|
+
let promptTemplateLoader;
|
|
365
|
+
/** Reads Pi's own prompt-template loader rather than duplicating its discovery rules. */
|
|
366
|
+
async function loadPromptTemplateLoader() {
|
|
367
|
+
if (!promptTemplateLoader) {
|
|
368
|
+
const packageRoot = dirname(fileURLToPath(await import.meta.resolve("@earendil-works/pi-coding-agent")));
|
|
369
|
+
promptTemplateLoader = import(pathToFileURL(join(packageRoot, "core", "prompt-templates.js")).href)
|
|
370
|
+
.then((module) => module.loadPromptTemplates);
|
|
371
|
+
}
|
|
372
|
+
return promptTemplateLoader;
|
|
373
|
+
}
|
|
374
|
+
export async function loadPromptTemplateSummaries(cwd) {
|
|
375
|
+
const loadPromptTemplates = await loadPromptTemplateLoader();
|
|
376
|
+
const templates = loadPromptTemplates({ cwd, agentDir: defaultAgentDir(), promptPaths: [], includeDefaults: true });
|
|
377
|
+
return templates
|
|
378
|
+
.filter((template) => template.sourceInfo.scope === "user" || template.sourceInfo.scope === "project")
|
|
379
|
+
.map((template) => ({ name: template.name, description: template.description, ...(template.argumentHint ? { argumentHint: template.argumentHint } : {}), scope: template.sourceInfo.scope }));
|
|
380
|
+
}
|
|
371
381
|
export function superPiExtensionPaths(repositoryRoot) {
|
|
372
382
|
const paths = [
|
|
373
383
|
join(repositoryRoot, "agents", "super-pi-task", "index.ts"),
|
package/dist/server/types.d.ts
CHANGED
|
@@ -548,6 +548,19 @@ export type AgentSummary = Omit<AgentDefinition, "prompt" | "toolFlags" | "tools
|
|
|
548
548
|
toolSummary: string;
|
|
549
549
|
sourceDir?: string;
|
|
550
550
|
};
|
|
551
|
+
export type PromptTemplateSummary = {
|
|
552
|
+
name: string;
|
|
553
|
+
description: string;
|
|
554
|
+
argumentHint?: string;
|
|
555
|
+
scope: "user" | "project";
|
|
556
|
+
};
|
|
557
|
+
export type PromptCatalog = {
|
|
558
|
+
source: "sdk" | "unavailable";
|
|
559
|
+
prompts: PromptTemplateSummary[];
|
|
560
|
+
workspaceId: string;
|
|
561
|
+
fetchedAt: string;
|
|
562
|
+
error?: string;
|
|
563
|
+
};
|
|
551
564
|
export type AgentCatalog = {
|
|
552
565
|
source: "directory" | "unavailable";
|
|
553
566
|
agents: AgentSummary[];
|
|
@@ -1176,6 +1189,11 @@ export type ClientCommandBody =
|
|
|
1176
1189
|
| {
|
|
1177
1190
|
type: "agent.catalog.fetch";
|
|
1178
1191
|
}
|
|
1192
|
+
/** Asks for prompt templates loaded by Pi for a workspace. */
|
|
1193
|
+
| {
|
|
1194
|
+
type: "prompt.catalog.fetch";
|
|
1195
|
+
workspaceId: string;
|
|
1196
|
+
}
|
|
1179
1197
|
/**
|
|
1180
1198
|
* Sends a message to a conversation, and THAT IS ALL IT CLAIMS.
|
|
1181
1199
|
*
|
|
@@ -1581,6 +1599,9 @@ export type ServerEvent = {
|
|
|
1581
1599
|
} | {
|
|
1582
1600
|
type: "agent.catalog";
|
|
1583
1601
|
catalog: AgentCatalog;
|
|
1602
|
+
} | {
|
|
1603
|
+
type: "prompt.catalog";
|
|
1604
|
+
catalog: PromptCatalog;
|
|
1584
1605
|
}
|
|
1585
1606
|
/**
|
|
1586
1607
|
* The `mode: subagent` half of the same directory, as its OWN event rather than an extra key on
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evandu/super-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.127",
|
|
4
4
|
"description": "Web control plane and companion for Pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -123,7 +123,8 @@
|
|
|
123
123
|
"scripts/skills-discovery.test.mjs",
|
|
124
124
|
"scripts/session-state-icon.test.mjs",
|
|
125
125
|
"scripts/provider-fetch-models.test.mjs",
|
|
126
|
-
"scripts/shared-chrome.test.mjs"
|
|
126
|
+
"scripts/shared-chrome.test.mjs",
|
|
127
|
+
"scripts/prompt-templates.test.mjs"
|
|
127
128
|
],
|
|
128
129
|
"check:browser": [
|
|
129
130
|
"scripts/interrupt-browser.test.mjs",
|
|
@@ -172,7 +173,8 @@
|
|
|
172
173
|
"scripts/active-memory-browser.test.mjs",
|
|
173
174
|
"scripts/knowledge-base-browser.test.mjs",
|
|
174
175
|
"scripts/terminal-browser.test.mjs",
|
|
175
|
-
"scripts/ux-polish-browser.test.mjs"
|
|
176
|
+
"scripts/ux-polish-browser.test.mjs",
|
|
177
|
+
"scripts/prompt-templates-browser.test.mjs"
|
|
176
178
|
],
|
|
177
179
|
"dependencies": {
|
|
178
180
|
"@codemirror/commands": "^6.11.1",
|