@evandu/super-pi 0.1.250 → 0.1.251
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/agents/super-pi-task/core.ts +1 -0
- package/agents/super-pi-task/index.ts +2 -2
- package/dist/client/.super-pi-client-sources.json +8 -8
- package/dist/client/assets/{CodeMirrorEditor-BAARAbkf.js → CodeMirrorEditor-BoCTcc3p.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-D6rq77Wh.js → GitDiffEditor-o_sxTLid.js} +1 -1
- package/dist/client/assets/index-Dmv5LIfM.css +1 -0
- package/dist/client/assets/{index-B1oejSFf.js → index-Oui62h72.js} +58 -58
- package/dist/client/index.html +2 -2
- package/dist/server/http-server.js +1 -1
- package/dist/server/pi-session.js +12 -3
- package/dist/server/skills.js +19 -0
- package/dist/server/tool-registry.d.ts +8 -0
- package/dist/server/tool-registry.js +11 -1
- package/package.json +1 -1
- package/skills/super-pi-agent-development/SKILL.md +25 -0
- package/skills/super-pi-development/SKILL.md +31 -0
- package/skills/super-pi-tool-development/SKILL.md +27 -0
- package/dist/client/assets/index-CwOjMymH.css +0 -1
package/dist/client/index.html
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
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-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-Oui62h72.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
|
|
13
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Dmv5LIfM.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
16
16
|
<div id="root"></div>
|
|
@@ -563,7 +563,7 @@ export function createHttpServer(options) {
|
|
|
563
563
|
if (local)
|
|
564
564
|
environment = { ...environment, fingerprint: { python: local.python, platform: local.platform, packages: environment.requires } };
|
|
565
565
|
}
|
|
566
|
-
const tool = await toolRegistry.register({ slug: body.slug, name: body.name, glyph: body.glyph, description: body.description, entrypoint: body.entrypoint, script: body.script, environment, permissions: body.permissions, files: body.files });
|
|
566
|
+
const tool = await toolRegistry.register({ slug: body.slug, name: body.name, glyph: body.glyph, description: body.description, dialogSize: body.dialogSize, entrypoint: body.entrypoint, script: body.script, environment, permissions: body.permissions, files: body.files });
|
|
567
567
|
broadcaster.broadcast({ type: "tools.updated", tools: await toolRegistry.list() });
|
|
568
568
|
json(201, tool);
|
|
569
569
|
return;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* the transcript on disk while the live session still holds the old context in memory, and nothing in Pi
|
|
24
24
|
* would notice the difference.
|
|
25
25
|
*/
|
|
26
|
-
import { existsSync, statSync } from "node:fs";
|
|
26
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
27
27
|
import { open, readdir } from "node:fs/promises";
|
|
28
28
|
import { StringDecoder } from "node:string_decoder";
|
|
29
29
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -641,6 +641,15 @@ export function superPiExtensionPaths(repositoryRoot) {
|
|
|
641
641
|
}
|
|
642
642
|
/** Skills shipped by Super Pi itself. Paths are explicit so installed and development layouts agree. */
|
|
643
643
|
export function superPiSkillPaths(repositoryRoot) {
|
|
644
|
-
const
|
|
645
|
-
|
|
644
|
+
const root = join(repositoryRoot, "skills");
|
|
645
|
+
if (!existsSync(root))
|
|
646
|
+
return [];
|
|
647
|
+
try {
|
|
648
|
+
return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory())
|
|
649
|
+
.map((entry) => join(root, entry.name)).filter((path) => existsSync(join(path, "SKILL.md")))
|
|
650
|
+
.sort((a, b) => (a.endsWith("presentation") ? -1 : b.endsWith("presentation") ? 1 : a.localeCompare(b)));
|
|
651
|
+
}
|
|
652
|
+
catch {
|
|
653
|
+
return [];
|
|
654
|
+
}
|
|
646
655
|
}
|
package/dist/server/skills.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { readdir, readFile } from "node:fs/promises";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
5
6
|
/**
|
|
6
7
|
* Loads and returns all available skills for a given workspace and global environment.
|
|
7
8
|
* Priority is given to Pi SDK's DefaultResourceLoader which scans project and user skills.
|
|
@@ -99,6 +100,24 @@ export async function getAvailableSkills(workspacePath, options) {
|
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
}
|
|
103
|
+
// Built-in skills must be visible even when the SDK found user/project skills.
|
|
104
|
+
const bundledRoot = fileURLToPath(new URL("../../skills/", import.meta.url));
|
|
105
|
+
try {
|
|
106
|
+
for (const entry of await readdir(bundledRoot, { withFileTypes: true })) {
|
|
107
|
+
if (!entry.isDirectory())
|
|
108
|
+
continue;
|
|
109
|
+
const skillFile = join(bundledRoot, entry.name, "SKILL.md");
|
|
110
|
+
if (!existsSync(skillFile))
|
|
111
|
+
continue;
|
|
112
|
+
const text = await readFile(skillFile, "utf-8");
|
|
113
|
+
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1] ?? "";
|
|
114
|
+
const name = /^name:\s*(.+)$/m.exec(frontmatter)?.[1]?.trim() ?? entry.name;
|
|
115
|
+
const description = /^description:\s*(.+)$/m.exec(frontmatter)?.[1]?.trim() ?? "";
|
|
116
|
+
if (!skillsMap.has(name))
|
|
117
|
+
skillsMap.set(name, { id: `skill:${name}`, name, description, scope: "global", filePath: skillFile });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch { /* The package may be running from a partial development checkout. */ }
|
|
102
121
|
// 3. Optional: merge active memory notes skills if available and not colliding
|
|
103
122
|
if (options?.memory && options?.workspaceId) {
|
|
104
123
|
try {
|
|
@@ -39,6 +39,10 @@ export type MountedTool = {
|
|
|
39
39
|
name: string;
|
|
40
40
|
glyph?: string;
|
|
41
41
|
description?: string;
|
|
42
|
+
dialogSize?: {
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
};
|
|
42
46
|
entrypoint: string;
|
|
43
47
|
script?: ToolScript;
|
|
44
48
|
environment?: ToolEnvironment;
|
|
@@ -77,6 +81,10 @@ export declare class ToolRegistry {
|
|
|
77
81
|
name: string;
|
|
78
82
|
glyph?: string;
|
|
79
83
|
description?: string;
|
|
84
|
+
dialogSize?: {
|
|
85
|
+
width: number;
|
|
86
|
+
height: number;
|
|
87
|
+
};
|
|
80
88
|
entrypoint?: string;
|
|
81
89
|
script?: ToolScript;
|
|
82
90
|
environment?: ToolEnvironment;
|
|
@@ -57,6 +57,7 @@ export class ToolRegistry {
|
|
|
57
57
|
const script = input.script ? normalizeScript(input.script, files) : undefined;
|
|
58
58
|
const environment = input.environment ? normalizeEnvironment(input.environment) : undefined;
|
|
59
59
|
const permissions = normalizePermissions(input.permissions);
|
|
60
|
+
const dialogSize = normalizeDialogSize(input.dialogSize);
|
|
60
61
|
const glyph = validateToolGlyph(input.glyph);
|
|
61
62
|
const finalDir = join(this.toolsDir, slug), stagingDir = `${finalDir}.${crypto.randomUUID()}.staging`;
|
|
62
63
|
if (await stat(finalDir).catch(() => undefined))
|
|
@@ -69,7 +70,7 @@ export class ToolRegistry {
|
|
|
69
70
|
await rm(stagingDir, { recursive: true, force: true });
|
|
70
71
|
throw error;
|
|
71
72
|
}
|
|
72
|
-
const now = new Date().toISOString(), tool = { id: `tool_${crypto.randomUUID()}`, slug, name: input.name.trim(), ...(glyph ? { glyph } : {}), description: input.description?.trim().slice(0, 500), entrypoint, script, environment, permissions, source: "user", enabled: true, createdAt: now, updatedAt: now };
|
|
73
|
+
const now = new Date().toISOString(), tool = { id: `tool_${crypto.randomUUID()}`, slug, name: input.name.trim(), ...(glyph ? { glyph } : {}), description: input.description?.trim().slice(0, 500), ...(dialogSize ? { dialogSize } : {}), entrypoint, script, environment, permissions, source: "user", enabled: true, createdAt: now, updatedAt: now };
|
|
73
74
|
this.items.push(tool);
|
|
74
75
|
try {
|
|
75
76
|
await this.save();
|
|
@@ -118,6 +119,7 @@ export class ToolRegistry {
|
|
|
118
119
|
name: tool.name,
|
|
119
120
|
...(tool.glyph ? { glyph: tool.glyph } : {}),
|
|
120
121
|
...(tool.description ? { description: tool.description } : {}),
|
|
122
|
+
...(tool.dialogSize ? { dialogSize: tool.dialogSize } : {}),
|
|
121
123
|
entrypoint: tool.entrypoint,
|
|
122
124
|
files,
|
|
123
125
|
...(tool.script ? { script: tool.script } : {}),
|
|
@@ -132,6 +134,13 @@ function normalizeAssets(files) { const paths = new Set(); let bytes = 0; return
|
|
|
132
134
|
throw new Error("工具文件的内容必须是文本"); const path = safeRelative(item.path); if (paths.has(path))
|
|
133
135
|
throw new Error(`工具里有重复的文件:${path}`); paths.add(path); bytes += Buffer.byteLength(item.content); if (bytes > MAX_ASSET_BYTES)
|
|
134
136
|
throw new Error("工具文件总大小超过 512KB"); return { path, content: item.content }; }); }
|
|
137
|
+
function normalizeDialogSize(size) {
|
|
138
|
+
if (size === undefined)
|
|
139
|
+
return undefined;
|
|
140
|
+
if (!size || typeof size !== "object" || !Number.isFinite(size.width) || !Number.isFinite(size.height))
|
|
141
|
+
throw new Error("工具弹窗尺寸必须是有效数字");
|
|
142
|
+
return { width: Math.round(Math.max(480, Math.min(1800, size.width))), height: Math.round(Math.max(360, Math.min(1400, size.height))) };
|
|
143
|
+
}
|
|
135
144
|
function normalizeScript(script, files) { const path = safeRelative(script.path); if (!path.endsWith(".py") || !files.some((x) => x.path === path))
|
|
136
145
|
throw new Error("脚本必须指向文件列表里的一个 .py 文件"); if (script.parameters && Object.values(script.parameters).some((x) => !isParam(x)))
|
|
137
146
|
throw new Error("脚本的参数定义不合法"); return { path, timeoutMs: script.timeoutMs, parameters: script.parameters }; }
|
|
@@ -211,6 +220,7 @@ function safeRelative(value) { const p = value.replace(/\\/g, "/").trim(); if (!
|
|
|
211
220
|
function inside(root, target) { const r = relative(resolve(root), resolve(target)); return r === "" || (!r.startsWith(`..${sep}`) && r !== ".." && !r.includes(":")); }
|
|
212
221
|
function isParam(value) { const x = value; return !!x && typeof x === "object" && ["string", "number", "boolean", "object", "array"].includes(x.type ?? "") && (x.required === undefined || typeof x.required === "boolean") && (x.enum === undefined || Array.isArray(x.enum)); }
|
|
213
222
|
function isTool(value) { const x = value; if (!x || typeof x !== "object" || typeof x.id !== "string" || typeof x.slug !== "string" || typeof x.name !== "string" || typeof x.entrypoint !== "string" || (x.source !== "user" && x.source !== "builtin"))
|
|
223
|
+
return false; if (x.dialogSize !== undefined && (!x.dialogSize || !Number.isFinite(x.dialogSize.width) || !Number.isFinite(x.dialogSize.height)))
|
|
214
224
|
return false; if (x.environment !== undefined && (typeof x.environment !== "object" || x.environment === null))
|
|
215
225
|
return false; return x.permissions === undefined || (typeof x.permissions === "object" && x.permissions !== null); }
|
|
216
226
|
function copy(value) { return { ...value, script: value.script ? { ...value.script, parameters: value.script.parameters ? { ...value.script.parameters } : undefined } : undefined, environment: value.environment ? { ...value.environment, requires: value.environment.requires ? [...value.environment.requires] : undefined } : undefined, permissions: value.permissions ? { ...value.permissions } : undefined }; }
|
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: super-pi-agent-development
|
|
3
|
+
description: Create or improve Super Pi agents and roles using the installed agent format and capability model.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Super Pi Agent Development
|
|
7
|
+
|
|
8
|
+
Use this skill when asked to create, modify, review, or package an agent/role for Super Pi. Identify whether the request is for a personal role, a built-in role, or a multi-agent workflow.
|
|
9
|
+
|
|
10
|
+
## Personal role agents
|
|
11
|
+
|
|
12
|
+
- Personal role definitions live in `~/.super-pi/agents/<id>.md` and are loaded by Super Pi; do not ask the user to copy an internal prompt.
|
|
13
|
+
- Inspect the existing role loader and examples before writing. Preserve the frontmatter and schema that the installed version expects.
|
|
14
|
+
- Write a concise role prompt with its purpose, decision boundaries, tool access, expected output, and collaboration rules. Avoid duplicating system instructions or restricting a role to read-only access when it must deliver work.
|
|
15
|
+
- Use available filesystem tools to create the role file, then verify that the role appears in the role picker or is otherwise discoverable.
|
|
16
|
+
|
|
17
|
+
## Built-in roles and capabilities
|
|
18
|
+
|
|
19
|
+
- Built-in role definitions are packaged under `agents/`; changes require updating the relevant registration/ordering path and documentation.
|
|
20
|
+
- Prefer existing Super Pi tools and services for file edits, memory, skills, Git, sessions, and tool registration. Do not create a second mechanism for a capability that already exists.
|
|
21
|
+
- Keep built-in roles discoverable and consistently ordered. Explain any required restart or reload behavior.
|
|
22
|
+
|
|
23
|
+
## Delivery
|
|
24
|
+
|
|
25
|
+
Inspect the role loader, built-in role inventory, relevant schemas, and current design principles before editing. Implement the role and any registration/docs changes, then summarize file locations, capabilities, and how the user can invoke the role. Follow repository-specific validation and worktree rules when operating in a checkout.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: super-pi-development
|
|
3
|
+
description: Choose the existing Super Pi mechanism for a requested capability and implement it without asking the user to copy internal prompts.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Super Pi capability development
|
|
7
|
+
|
|
8
|
+
Use the smallest existing mechanism that fits the user's request. Do not ask the user to copy a prompt from settings before starting work. Super Pi already provides a registered `tool_register` capability for global sidebar tools, and the tool's own description explains the submission contract.
|
|
9
|
+
|
|
10
|
+
## Choose the right mechanism
|
|
11
|
+
|
|
12
|
+
| Need | Use |
|
|
13
|
+
|---|---|
|
|
14
|
+
| A user-facing interactive panel that should appear in every workspace | `tool_register`; see `super-pi-tool-development` |
|
|
15
|
+
| A reusable role with its own system prompt, model, or tool permissions | An Agent definition; see `super-pi-agent-development` |
|
|
16
|
+
| Reusable procedural instructions loaded on demand | A packaged skill at `skills/<name>/SKILL.md`, or user skill storage for personal procedures |
|
|
17
|
+
| A new first-party tool or lifecycle hook available to Super Pi agents | Extend the relevant Pi extension under `agents/super-pi-*/` and update its server capability surface |
|
|
18
|
+
| A connection to an external service that already offers MCP | Configure the native MCP integration; do not build a custom client or duplicate credentials |
|
|
19
|
+
| Reusable user-authored text with no new executable capability | Use a prompt template |
|
|
20
|
+
| Read/write office documents, knowledge, memory, or web pages | Use the existing built-in capability before proposing a new tool |
|
|
21
|
+
|
|
22
|
+
For bundled capabilities, keep the user-facing skill selector and Pi's `additionalSkillPaths` in sync. A skill that exists only in source but is not discovered by the installed application is not shipped.
|
|
23
|
+
|
|
24
|
+
## Development workflow
|
|
25
|
+
|
|
26
|
+
1. Inspect the relevant implementation and `docs/DESIGN-PRINCIPLES.md`; identify the current supported path before adding another one.
|
|
27
|
+
2. Make source changes in the task's feature worktree. Keep API schemas, runtime validation, client types, UI and import/export behavior in parity.
|
|
28
|
+
3. Prefer the existing registration/runtime path. Preserve service-side authorization and validation; never put credentials in a tool page, prompt, skill, or report.
|
|
29
|
+
4. Build the package and leave a concise summary of the changed capability, implementation path, and validation evidence.
|
|
30
|
+
|
|
31
|
+
When the user directly requests a tool or Agent, proceed with that request. The settings-page copy prompt is a fallback for models or environments that cannot load the built-in skill context.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: super-pi-tool-development
|
|
3
|
+
description: Build a global Super Pi sidebar tool and register it through the built-in tool_register capability.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build a Super Pi sidebar tool
|
|
7
|
+
|
|
8
|
+
When the user asks for a Super Pi tool, implement it and call the built-in `tool_register` directly. Do not ask them to copy the settings prompt. A tool is global to the Super Pi server and appears in each workspace's Tools tab.
|
|
9
|
+
|
|
10
|
+
## Tool shape
|
|
11
|
+
|
|
12
|
+
- Submit complete UTF-8 files, normally `index.html` plus local JavaScript and CSS. Keep the page self-contained and responsive.
|
|
13
|
+
- If local computation is needed, declare one Python script and its JSON parameter schema. It receives JSON on stdin and must print one JSON object on stdout. Pin dependencies as `package==version` in `environment.requires`.
|
|
14
|
+
- Load `./super-pi-tool.js` for tool-scoped Python jobs with `SuperPiTool.run`, `get`, `wait`, and `cancel`.
|
|
15
|
+
- For model calls, use `SuperPiTool.llm` or `llmText`; declare `permissions: { llm: true }`. Never create a model client or store a credential in the tool.
|
|
16
|
+
- Do not start an HTTP server, call `/api/exec`, guess a tool id, or pass shell commands and arbitrary paths.
|
|
17
|
+
- Use a distinctive 1–4 character `glyph`.
|
|
18
|
+
|
|
19
|
+
## Popup size
|
|
20
|
+
|
|
21
|
+
If the tool needs more reading space, include `dialogSize: { width, height }` in `tool_register`, in CSS pixels. The width and height are requested desktop dimensions; the host clamps them to the viewport and uses a smaller responsive layout on narrow screens. Choose the smallest size that fits the actual content. A document or data workbench commonly needs around `1100 × 780`; a compact calculator can use the default.
|
|
22
|
+
|
|
23
|
+
Keep the iframe content usable when the popup is narrow: use flexible layouts, allow long tables or code to scroll inside the panel, and do not assume the requested size will fit every viewport.
|
|
24
|
+
|
|
25
|
+
## Finish
|
|
26
|
+
|
|
27
|
+
Register only after the HTML and any script files are complete. Return the tool name, registration result, and the main interaction or calculation verified. If registration is unavailable in the current environment, report that constraint and provide the retained copy-prompt fallback only then.
|