@zihanw/pi-forge 0.2.0 → 0.3.1
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 +233 -105
- package/README.zh-CN.md +215 -104
- package/dist/compiler.d.ts +10 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +490 -0
- package/dist/compiler.js.map +1 -0
- package/dist/extension-registry.d.ts +25 -0
- package/dist/extension-registry.d.ts.map +1 -0
- package/dist/extension-registry.js +6 -0
- package/dist/extension-registry.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +364 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +14 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +139 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/loader.d.ts +8 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +345 -0
- package/dist/loader.js.map +1 -0
- package/dist/macro-engine.d.ts +23 -0
- package/dist/macro-engine.d.ts.map +1 -0
- package/dist/macro-engine.js +262 -0
- package/dist/macro-engine.js.map +1 -0
- package/dist/payload-capture.d.ts +15 -0
- package/dist/payload-capture.d.ts.map +1 -0
- package/dist/payload-capture.js +86 -0
- package/dist/payload-capture.js.map +1 -0
- package/dist/payload-command.d.ts +10 -0
- package/dist/payload-command.d.ts.map +1 -0
- package/dist/payload-command.js +112 -0
- package/dist/payload-command.js.map +1 -0
- package/dist/policy.d.ts +6 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +38 -0
- package/dist/policy.js.map +1 -0
- package/dist/preset-command.d.ts +14 -0
- package/dist/preset-command.d.ts.map +1 -0
- package/dist/preset-command.js +223 -0
- package/dist/preset-command.js.map +1 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +179 -0
- package/dist/preview.js.map +1 -0
- package/dist/regex.d.ts +7 -0
- package/dist/regex.d.ts.map +1 -0
- package/dist/regex.js +432 -0
- package/dist/regex.js.map +1 -0
- package/dist/render-helpers.d.ts +44 -0
- package/dist/render-helpers.d.ts.map +1 -0
- package/dist/render-helpers.js +128 -0
- package/dist/render-helpers.js.map +1 -0
- package/dist/runtime-state.d.ts +24 -0
- package/dist/runtime-state.d.ts.map +1 -0
- package/dist/runtime-state.js +13 -0
- package/dist/runtime-state.js.map +1 -0
- package/dist/sillytavern-importer/items.d.ts +3 -0
- package/dist/sillytavern-importer/items.d.ts.map +1 -0
- package/dist/sillytavern-importer/items.js +88 -0
- package/dist/sillytavern-importer/items.js.map +1 -0
- package/dist/sillytavern-importer/macros.d.ts +15 -0
- package/dist/sillytavern-importer/macros.d.ts.map +1 -0
- package/dist/sillytavern-importer/macros.js +141 -0
- package/dist/sillytavern-importer/macros.js.map +1 -0
- package/dist/sillytavern-importer/prompt-order.d.ts +6 -0
- package/dist/sillytavern-importer/prompt-order.d.ts.map +1 -0
- package/dist/sillytavern-importer/prompt-order.js +38 -0
- package/dist/sillytavern-importer/prompt-order.js.map +1 -0
- package/dist/sillytavern-importer/regex.d.ts +3 -0
- package/dist/sillytavern-importer/regex.d.ts.map +1 -0
- package/dist/sillytavern-importer/regex.js +275 -0
- package/dist/sillytavern-importer/regex.js.map +1 -0
- package/dist/sillytavern-importer/report.d.ts +21 -0
- package/dist/sillytavern-importer/report.d.ts.map +1 -0
- package/dist/sillytavern-importer/report.js +166 -0
- package/dist/sillytavern-importer/report.js.map +1 -0
- package/dist/sillytavern-importer/types.d.ts +106 -0
- package/dist/sillytavern-importer/types.d.ts.map +1 -0
- package/dist/sillytavern-importer/types.js +2 -0
- package/dist/sillytavern-importer/types.js.map +1 -0
- package/dist/sillytavern-importer.d.ts +5 -0
- package/dist/sillytavern-importer.d.ts.map +1 -0
- package/dist/sillytavern-importer.js +117 -0
- package/dist/sillytavern-importer.js.map +1 -0
- package/dist/slot-renderers.d.ts +25 -0
- package/dist/slot-renderers.d.ts.map +1 -0
- package/dist/slot-renderers.js +334 -0
- package/dist/slot-renderers.js.map +1 -0
- package/dist/stack-migration.d.ts +29 -0
- package/dist/stack-migration.d.ts.map +1 -0
- package/dist/stack-migration.js +126 -0
- package/dist/stack-migration.js.map +1 -0
- package/dist/storage.d.ts +6 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +23 -0
- package/dist/storage.js.map +1 -0
- package/dist/types.d.ts +173 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/web-editor/index.d.ts +3 -0
- package/dist/web-editor/index.d.ts.map +1 -0
- package/dist/web-editor/index.js +2 -0
- package/dist/web-editor/index.js.map +1 -0
- package/dist/web-editor/page.d.ts +2 -0
- package/dist/web-editor/page.d.ts.map +1 -0
- package/dist/web-editor/page.js +3331 -0
- package/dist/web-editor/page.js.map +1 -0
- package/dist/web-editor/server.d.ts +4 -0
- package/dist/web-editor/server.d.ts.map +1 -0
- package/dist/web-editor/server.js +263 -0
- package/dist/web-editor/server.js.map +1 -0
- package/dist/web-editor/types.d.ts +125 -0
- package/dist/web-editor/types.d.ts.map +1 -0
- package/dist/web-editor/types.js +2 -0
- package/dist/web-editor/types.js.map +1 -0
- package/dist/web-host.d.ts +29 -0
- package/dist/web-host.d.ts.map +1 -0
- package/dist/web-host.js +174 -0
- package/dist/web-host.js.map +1 -0
- package/examples/custom-system-status-extension/README.md +78 -0
- package/examples/custom-system-status-extension/index.ts +176 -0
- package/examples/custom-system-status-extension/prompt-stack.json +39 -0
- package/examples/default-prompt-stack.json +52 -93
- package/examples/image-reader-prompt-stack.json +124 -0
- package/examples/reviewer-prompt-stack.json +115 -0
- package/examples/sillytavern-dm-writer-prompt-stack.json +190 -0
- package/package.json +30 -9
- package/src/compiler.ts +321 -420
- package/src/extension-registry.ts +33 -0
- package/src/index.ts +310 -1110
- package/src/lifecycle.ts +171 -0
- package/src/loader.ts +141 -56
- package/src/macro-engine.ts +358 -0
- package/src/payload-capture.ts +85 -0
- package/src/payload-command.ts +138 -0
- package/src/policy.ts +42 -0
- package/src/preset-command.ts +271 -0
- package/src/preview.ts +226 -0
- package/src/regex.ts +500 -0
- package/src/render-helpers.ts +169 -0
- package/src/runtime-state.ts +36 -0
- package/src/sillytavern-importer/items.ts +98 -0
- package/src/sillytavern-importer/macros.ts +159 -0
- package/src/sillytavern-importer/prompt-order.ts +54 -0
- package/src/sillytavern-importer/regex.ts +270 -0
- package/src/sillytavern-importer/report.ts +202 -0
- package/src/sillytavern-importer/types.ts +120 -0
- package/src/sillytavern-importer.ts +57 -482
- package/src/slot-renderers.ts +414 -0
- package/src/stack-migration.ts +159 -0
- package/src/storage.ts +28 -0
- package/src/types.ts +83 -52
- package/src/web-editor/index.ts +2 -0
- package/src/web-editor/page.ts +3330 -0
- package/src/web-editor/server.ts +294 -0
- package/src/web-editor/types.ts +98 -0
- package/src/web-host.ts +232 -0
- package/src/web-editor.ts +0 -1491
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-host.js","sourceRoot":"","sources":["../src/web-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACN,0BAA0B,EAC1B,eAAe,EACf,mBAAmB,GACnB,MAAM,aAAa,CAAC;AA8BrB,MAAM,UAAU,mBAAmB,CAAC,GAA4B,EAAE,OAAuB;IACxF,OAAO;QACN,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,UAAU,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;QAC1E,aAAa,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE;QACjD,QAAQ,EAAE,CAAC,EAAE,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AAG,EAAE,KAAK,EAAE,kDAAkD,EAAE,CAAC;IAC9F,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;IACvD,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5B,IAAI,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1B,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;AACxH,CAAC;AAED,SAAS,kBAAkB,CAAC,EAAU;IACrC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,OAAO,6BAA6B,CAAC;IACrD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAClC,OAAO,mEAAmE,CAAC;IAC5E,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACpC,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Custom System Status Extension
|
|
2
|
+
|
|
3
|
+
This example shows how trusted extension code can register a pi-forge custom macro and custom slot.
|
|
4
|
+
|
|
5
|
+
It registers:
|
|
6
|
+
|
|
7
|
+
- `{{cpuLoad}}` macro: one-line CPU load summary.
|
|
8
|
+
- `machine-status` slot: CPU load, OS load average, memory, and uptime snapshot.
|
|
9
|
+
|
|
10
|
+
The renderers are synchronous, so this example uses Node's OS load average and memory APIs. It is a rough machine-load signal, not an async sampled CPU-utilization profiler.
|
|
11
|
+
|
|
12
|
+
## Try It Quickly
|
|
13
|
+
|
|
14
|
+
From a project where `@zihanw/pi-forge` is installed:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pi -e ./examples/custom-system-status-extension/index.ts
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
When developing from a local pi-forge checkout without installing the package, run the example in place from this repository. The extension falls back to `../../src/index.ts`.
|
|
21
|
+
|
|
22
|
+
If you copy the extension into another project's `.pi/extensions/` folder while pi-forge itself is loaded from a local checkout, point the extension at that same checkout:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
PI_FORGE_MODULE=/path/to/pi-forge/src/index.ts pi
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Replace `/path/to/pi-forge` with the local checkout that matches the pi-forge extension you load from `settings.json`.
|
|
29
|
+
|
|
30
|
+
Then copy `prompt-stack.json` into your project's prompt-stack folder:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
mkdir -p .pi/forge/prompt-stacks
|
|
34
|
+
cp examples/custom-system-status-extension/prompt-stack.json .pi/forge/prompt-stacks/custom-system-status.json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Use `/preset reload`, then `/preset use custom-system-status`.
|
|
38
|
+
|
|
39
|
+
## Where To Put The Extension
|
|
40
|
+
|
|
41
|
+
Use one of Pi's trusted extension locations:
|
|
42
|
+
|
|
43
|
+
- Project-local: `.pi/extensions/system-status/index.ts`
|
|
44
|
+
- Global: `~/.pi/agent/extensions/system-status/index.ts`
|
|
45
|
+
- Package-managed: a Pi package with a `pi.extensions` entry in `package.json`
|
|
46
|
+
|
|
47
|
+
For project-local use:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
mkdir -p .pi/extensions/system-status
|
|
51
|
+
cp examples/custom-system-status-extension/index.ts .pi/extensions/system-status/index.ts
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Project-local extensions load only after the project is trusted. If the extension is not loaded, the stack can still be read, but `machine-status` will validate as an unsupported slot and `{{cpuLoad}}` will remain an unresolved macro.
|
|
55
|
+
|
|
56
|
+
If the extension fails with `Cannot find module '@zihanw/pi-forge'`, pi-forge is not installed as a package visible to this extension. Either install/load pi-forge as a package, run the example in place from the pi-forge checkout, or set `PI_FORGE_MODULE` to the local `src/index.ts` path of the checkout that Pi is loading.
|
|
57
|
+
|
|
58
|
+
## Stack Reference
|
|
59
|
+
|
|
60
|
+
The stack references the custom slot declaratively:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"kind": "slot",
|
|
65
|
+
"id": "machine-status",
|
|
66
|
+
"enabled": true,
|
|
67
|
+
"role": "system",
|
|
68
|
+
"slot": "machine-status",
|
|
69
|
+
"options": {
|
|
70
|
+
"format": "plain",
|
|
71
|
+
"heading": "Runtime machine snapshot",
|
|
72
|
+
"includeMemory": true,
|
|
73
|
+
"includeUptime": true
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Only the extension file contains executable code. The prompt stack just selects the registered slot and passes options.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { cpus, freemem, loadavg, totalmem, uptime } from "node:os";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import type { registerMacro, registerSlot } from "../../src/index.ts";
|
|
6
|
+
|
|
7
|
+
interface PiForgeRegistrationApi {
|
|
8
|
+
registerMacro: typeof registerMacro;
|
|
9
|
+
registerSlot: typeof registerSlot;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface SystemStatusSnapshot {
|
|
13
|
+
logicalCores: number;
|
|
14
|
+
cpuModel: string;
|
|
15
|
+
load1: number;
|
|
16
|
+
load5: number;
|
|
17
|
+
load15: number;
|
|
18
|
+
normalizedLoad1: number;
|
|
19
|
+
freeMemoryMb: number;
|
|
20
|
+
totalMemoryMb: number;
|
|
21
|
+
usedMemoryPercent: number;
|
|
22
|
+
uptimeSeconds: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ExampleRegistryState {
|
|
26
|
+
unregister: Array<() => void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type ExampleGlobal = typeof globalThis & {
|
|
30
|
+
__piForgeSystemStatusExample?: ExampleRegistryState;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function registryState(): ExampleRegistryState {
|
|
34
|
+
const globalScope = globalThis as ExampleGlobal;
|
|
35
|
+
globalScope.__piForgeSystemStatusExample ??= { unregister: [] };
|
|
36
|
+
return globalScope.__piForgeSystemStatusExample;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function resetRegistrations(): void {
|
|
40
|
+
const state = registryState();
|
|
41
|
+
for (const unregister of state.unregister.splice(0)) unregister();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default async function systemStatusExtension(_pi: ExtensionAPI): Promise<void> {
|
|
45
|
+
const { registerMacro, registerSlot } = await loadPiForgeRegistrationApi();
|
|
46
|
+
resetRegistrations();
|
|
47
|
+
const state = registryState();
|
|
48
|
+
|
|
49
|
+
state.unregister.push(
|
|
50
|
+
registerMacro({
|
|
51
|
+
name: "cpuLoad",
|
|
52
|
+
source: "pi-forge-example-system-status",
|
|
53
|
+
description: "Current machine CPU load as normalized 1-minute OS load average.",
|
|
54
|
+
render: () => formatCpuLoad(readSystemStatus()),
|
|
55
|
+
}),
|
|
56
|
+
registerSlot({
|
|
57
|
+
name: "machine-status",
|
|
58
|
+
source: "pi-forge-example-system-status",
|
|
59
|
+
description: "Current machine CPU, memory, and uptime snapshot.",
|
|
60
|
+
options: {
|
|
61
|
+
format: { type: "enum", values: ["plain", "xml"], default: "plain" },
|
|
62
|
+
heading: { type: "string", default: "Machine status" },
|
|
63
|
+
includeMemory: { type: "boolean", default: true },
|
|
64
|
+
includeUptime: { type: "boolean", default: true },
|
|
65
|
+
},
|
|
66
|
+
render: (ctx) => {
|
|
67
|
+
const snapshot = readSystemStatus();
|
|
68
|
+
const includeMemory = ctx.options.includeMemory !== false;
|
|
69
|
+
const includeUptime = ctx.options.includeUptime !== false;
|
|
70
|
+
const heading = typeof ctx.options.heading === "string" && ctx.options.heading.trim()
|
|
71
|
+
? ctx.options.heading.trim()
|
|
72
|
+
: "Machine status";
|
|
73
|
+
|
|
74
|
+
if (ctx.format() === "xml") {
|
|
75
|
+
const lines = [
|
|
76
|
+
"<machine_status>",
|
|
77
|
+
` <cpu logical_cores=\"${snapshot.logicalCores}\" normalized_load_1m=\"${snapshot.normalizedLoad1.toFixed(3)}\" model=\"${ctx.helpers.escapeXml(snapshot.cpuModel)}\">${ctx.helpers.escapeXml(formatCpuLoad(snapshot))}</cpu>`,
|
|
78
|
+
` <load_average one_minute=\"${snapshot.load1.toFixed(2)}\" five_minutes=\"${snapshot.load5.toFixed(2)}\" fifteen_minutes=\"${snapshot.load15.toFixed(2)}\" />`,
|
|
79
|
+
];
|
|
80
|
+
if (includeMemory) {
|
|
81
|
+
lines.push(` <memory used_percent=\"${snapshot.usedMemoryPercent.toFixed(1)}\" free_mb=\"${snapshot.freeMemoryMb}\" total_mb=\"${snapshot.totalMemoryMb}\" />`);
|
|
82
|
+
}
|
|
83
|
+
if (includeUptime) {
|
|
84
|
+
lines.push(` <uptime>${ctx.helpers.escapeXml(formatDuration(snapshot.uptimeSeconds))}</uptime>`);
|
|
85
|
+
}
|
|
86
|
+
lines.push("</machine_status>");
|
|
87
|
+
return lines.join("\n");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const lines = [
|
|
91
|
+
`${heading}:`,
|
|
92
|
+
ctx.helpers.plainBullet("CPU", `${snapshot.logicalCores} logical cores, ${snapshot.cpuModel}`),
|
|
93
|
+
ctx.helpers.plainBullet("CPU load", formatCpuLoad(snapshot)),
|
|
94
|
+
ctx.helpers.plainBullet("Load average", `${snapshot.load1.toFixed(2)} / ${snapshot.load5.toFixed(2)} / ${snapshot.load15.toFixed(2)} (1m/5m/15m)`),
|
|
95
|
+
];
|
|
96
|
+
if (includeMemory) {
|
|
97
|
+
lines.push(ctx.helpers.plainBullet("Memory", `${snapshot.usedMemoryPercent.toFixed(1)}% used (${snapshot.freeMemoryMb} MB free / ${snapshot.totalMemoryMb} MB total)`));
|
|
98
|
+
}
|
|
99
|
+
if (includeUptime) {
|
|
100
|
+
lines.push(ctx.helpers.plainBullet("Uptime", formatDuration(snapshot.uptimeSeconds)));
|
|
101
|
+
}
|
|
102
|
+
return lines.join("\n");
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function loadPiForgeRegistrationApi(): Promise<PiForgeRegistrationApi> {
|
|
109
|
+
const override = process.env.PI_FORGE_MODULE;
|
|
110
|
+
if (override) {
|
|
111
|
+
return importPiForgeApi(pathToFileURL(resolve(override)).href);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
try {
|
|
115
|
+
return await importPiForgeApi("@zihanw/pi-forge");
|
|
116
|
+
} catch {
|
|
117
|
+
try {
|
|
118
|
+
return await importPiForgeApi("../../src/index.ts");
|
|
119
|
+
} catch (error) {
|
|
120
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
121
|
+
throw new Error(
|
|
122
|
+
"Unable to load pi-forge registration API. Install @zihanw/pi-forge, " +
|
|
123
|
+
"set PI_FORGE_MODULE=/absolute/path/to/pi-forge/src/index.ts, or run this example in place from the pi-forge checkout. " +
|
|
124
|
+
`Last error: ${detail}`,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function importPiForgeApi(specifier: string): Promise<PiForgeRegistrationApi> {
|
|
131
|
+
const mod = await import(specifier) as Partial<PiForgeRegistrationApi>;
|
|
132
|
+
if (typeof mod.registerMacro !== "function" || typeof mod.registerSlot !== "function") {
|
|
133
|
+
throw new Error(`Module does not export registerMacro/registerSlot: ${specifier}`);
|
|
134
|
+
}
|
|
135
|
+
return { registerMacro: mod.registerMacro, registerSlot: mod.registerSlot };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function readSystemStatus(): SystemStatusSnapshot {
|
|
139
|
+
const cores = cpus();
|
|
140
|
+
const logicalCores = Math.max(cores.length, 1);
|
|
141
|
+
const [load1 = 0, load5 = 0, load15 = 0] = loadavg();
|
|
142
|
+
const free = freemem();
|
|
143
|
+
const total = totalmem();
|
|
144
|
+
const freeMemoryMb = Math.round(free / 1024 / 1024);
|
|
145
|
+
const totalMemoryMb = Math.round(total / 1024 / 1024);
|
|
146
|
+
const usedMemoryPercent = total > 0 ? ((total - free) / total) * 100 : 0;
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
logicalCores,
|
|
150
|
+
cpuModel: cores[0]?.model ?? "unknown",
|
|
151
|
+
load1,
|
|
152
|
+
load5,
|
|
153
|
+
load15,
|
|
154
|
+
normalizedLoad1: load1 / logicalCores,
|
|
155
|
+
freeMemoryMb,
|
|
156
|
+
totalMemoryMb,
|
|
157
|
+
usedMemoryPercent,
|
|
158
|
+
uptimeSeconds: uptime(),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function formatCpuLoad(snapshot: SystemStatusSnapshot): string {
|
|
163
|
+
const normalizedPercent = snapshot.normalizedLoad1 * 100;
|
|
164
|
+
return `${normalizedPercent.toFixed(1)}% normalized (${snapshot.load1.toFixed(2)} 1m load / ${snapshot.logicalCores} logical cores)`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function formatDuration(seconds: number): string {
|
|
168
|
+
const days = Math.floor(seconds / 86_400);
|
|
169
|
+
const hours = Math.floor((seconds % 86_400) / 3_600);
|
|
170
|
+
const minutes = Math.floor((seconds % 3_600) / 60);
|
|
171
|
+
const parts: string[] = [];
|
|
172
|
+
if (days > 0) parts.push(`${days}d`);
|
|
173
|
+
if (hours > 0 || parts.length > 0) parts.push(`${hours}h`);
|
|
174
|
+
parts.push(`${minutes}m`);
|
|
175
|
+
return parts.join(" ");
|
|
176
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"type": "pi-forge.prompt-stack",
|
|
4
|
+
"id": "custom-system-status",
|
|
5
|
+
"name": "Custom System Status",
|
|
6
|
+
"description": "Example stack that uses a trusted custom macro and custom slot registered by examples/custom-system-status-extension/index.ts.",
|
|
7
|
+
"mode": "append",
|
|
8
|
+
"items": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "block",
|
|
11
|
+
"id": "cpu-load-macro",
|
|
12
|
+
"name": "CPU Load Macro",
|
|
13
|
+
"enabled": true,
|
|
14
|
+
"role": "system",
|
|
15
|
+
"content": "Current rough CPU load: {{cpuLoad}}"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"kind": "slot",
|
|
19
|
+
"id": "machine-status",
|
|
20
|
+
"name": "Machine Status Slot",
|
|
21
|
+
"enabled": true,
|
|
22
|
+
"role": "system",
|
|
23
|
+
"slot": "machine-status",
|
|
24
|
+
"options": {
|
|
25
|
+
"format": "plain",
|
|
26
|
+
"heading": "Runtime machine snapshot",
|
|
27
|
+
"includeMemory": true,
|
|
28
|
+
"includeUptime": true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"kind": "slot",
|
|
33
|
+
"id": "chat-history",
|
|
34
|
+
"name": "Chat History",
|
|
35
|
+
"enabled": true,
|
|
36
|
+
"slot": "chat-history"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"type": "pi-forge.prompt-stack",
|
|
4
4
|
"id": "default",
|
|
5
|
-
"name": "Default
|
|
6
|
-
"description": "
|
|
5
|
+
"name": "Default Pi Prompt Mirror",
|
|
6
|
+
"description": "Recreates Pi's built-in prompt layout with pi-forge slots, exposing tools, guidelines, docs, append-system-prompt, project context, skills, date/cwd, and chat history as movable pieces.",
|
|
7
7
|
"autoActivate": true,
|
|
8
8
|
"mode": "replace",
|
|
9
9
|
"defaults": {
|
|
@@ -13,48 +13,24 @@
|
|
|
13
13
|
"context": {
|
|
14
14
|
"allowDuplicateChatHistory": false
|
|
15
15
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"char": "Assistant"
|
|
16
|
+
"tools": {
|
|
17
|
+
"allow": ["*"]
|
|
19
18
|
},
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"definitions": {
|
|
23
|
-
"agent.progress": {
|
|
24
|
-
"type": "string",
|
|
25
|
-
"scope": "session",
|
|
26
|
-
"description": "Concise summary of current task, story, or conversation progress.",
|
|
27
|
-
"agentWritable": true
|
|
28
|
-
},
|
|
29
|
-
"agent.openQuestions": {
|
|
30
|
-
"type": "string[]",
|
|
31
|
-
"scope": "session",
|
|
32
|
-
"description": "Short list of questions that may need user input.",
|
|
33
|
-
"agentWritable": true
|
|
34
|
-
},
|
|
35
|
-
"agent.notes": {
|
|
36
|
-
"type": "string[]",
|
|
37
|
-
"scope": "session",
|
|
38
|
-
"description": "Durable notes the user explicitly asked the agent to remember.",
|
|
39
|
-
"agentWritable": true
|
|
40
|
-
},
|
|
41
|
-
"user.preference": {
|
|
42
|
-
"type": "string",
|
|
43
|
-
"scope": "session",
|
|
44
|
-
"description": "User-provided preference or instruction for this session.",
|
|
45
|
-
"agentWritable": false,
|
|
46
|
-
"userWritable": true
|
|
47
|
-
}
|
|
48
|
-
}
|
|
19
|
+
"skills": {
|
|
20
|
+
"allow": ["*"]
|
|
49
21
|
},
|
|
50
22
|
"items": [
|
|
51
23
|
{
|
|
52
24
|
"kind": "block",
|
|
53
25
|
"id": "main-role",
|
|
54
|
-
"name": "
|
|
26
|
+
"name": "Pi Default Role",
|
|
55
27
|
"enabled": true,
|
|
56
28
|
"role": "system",
|
|
57
|
-
"
|
|
29
|
+
"source": {
|
|
30
|
+
"package": "@earendil-works/pi-coding-agent",
|
|
31
|
+
"file": "dist/core/system-prompt.js"
|
|
32
|
+
},
|
|
33
|
+
"content": "You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files."
|
|
58
34
|
},
|
|
59
35
|
{
|
|
60
36
|
"kind": "slot",
|
|
@@ -62,61 +38,76 @@
|
|
|
62
38
|
"name": "Available Tools",
|
|
63
39
|
"enabled": true,
|
|
64
40
|
"role": "system",
|
|
65
|
-
"slot": "tools"
|
|
41
|
+
"slot": "tools",
|
|
42
|
+
"options": {
|
|
43
|
+
"format": "plain",
|
|
44
|
+
"onlyWithSnippets": true
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"kind": "block",
|
|
49
|
+
"id": "custom-tools-note",
|
|
50
|
+
"name": "Custom Tools Note",
|
|
51
|
+
"enabled": true,
|
|
52
|
+
"role": "system",
|
|
53
|
+
"content": "In addition to the tools above, you may have access to other custom tools depending on the project."
|
|
66
54
|
},
|
|
67
55
|
{
|
|
68
56
|
"kind": "slot",
|
|
69
57
|
"id": "tool-guidelines",
|
|
70
|
-
"name": "
|
|
58
|
+
"name": "Guidelines",
|
|
71
59
|
"enabled": true,
|
|
72
60
|
"role": "system",
|
|
73
|
-
"slot": "tool-guidelines"
|
|
61
|
+
"slot": "tool-guidelines",
|
|
62
|
+
"options": {
|
|
63
|
+
"format": "plain",
|
|
64
|
+
"heading": "Guidelines:",
|
|
65
|
+
"includePiDefaultGuidelines": true,
|
|
66
|
+
"piStyle": true
|
|
67
|
+
}
|
|
74
68
|
},
|
|
75
69
|
{
|
|
76
70
|
"kind": "slot",
|
|
77
|
-
"id": "
|
|
78
|
-
"name": "
|
|
71
|
+
"id": "pi-docs",
|
|
72
|
+
"name": "Pi Documentation Guidance",
|
|
79
73
|
"enabled": true,
|
|
80
74
|
"role": "system",
|
|
81
|
-
"slot": "
|
|
75
|
+
"slot": "pi-docs"
|
|
82
76
|
},
|
|
83
77
|
{
|
|
84
78
|
"kind": "slot",
|
|
85
|
-
"id": "
|
|
86
|
-
"name": "
|
|
79
|
+
"id": "append-system-prompt",
|
|
80
|
+
"name": "User Append System Prompt",
|
|
87
81
|
"enabled": true,
|
|
88
82
|
"role": "system",
|
|
89
|
-
"slot": "
|
|
83
|
+
"slot": "append-system-prompt"
|
|
90
84
|
},
|
|
91
85
|
{
|
|
92
86
|
"kind": "slot",
|
|
93
|
-
"id": "
|
|
94
|
-
"name": "
|
|
87
|
+
"id": "project-context",
|
|
88
|
+
"name": "Project Context",
|
|
95
89
|
"enabled": true,
|
|
96
90
|
"role": "system",
|
|
97
|
-
"slot": "
|
|
91
|
+
"slot": "project-context"
|
|
98
92
|
},
|
|
99
93
|
{
|
|
100
94
|
"kind": "slot",
|
|
101
|
-
"id": "
|
|
102
|
-
"name": "
|
|
95
|
+
"id": "skills",
|
|
96
|
+
"name": "Available Skills",
|
|
103
97
|
"enabled": true,
|
|
104
|
-
"role": "
|
|
105
|
-
"slot": "
|
|
98
|
+
"role": "system",
|
|
99
|
+
"slot": "skills",
|
|
106
100
|
"options": {
|
|
107
|
-
"
|
|
108
|
-
"includeNamespaces": ["user.*", "agent.*"],
|
|
109
|
-
"includeMetadata": true,
|
|
110
|
-
"maxValueChars": 1200
|
|
101
|
+
"requireReadTool": true
|
|
111
102
|
}
|
|
112
103
|
},
|
|
113
104
|
{
|
|
114
|
-
"kind": "
|
|
115
|
-
"id": "
|
|
116
|
-
"name": "
|
|
105
|
+
"kind": "slot",
|
|
106
|
+
"id": "date-cwd",
|
|
107
|
+
"name": "Date and Working Directory",
|
|
117
108
|
"enabled": true,
|
|
118
|
-
"role": "
|
|
119
|
-
"
|
|
109
|
+
"role": "system",
|
|
110
|
+
"slot": "date-cwd"
|
|
120
111
|
},
|
|
121
112
|
{
|
|
122
113
|
"kind": "slot",
|
|
@@ -124,38 +115,6 @@
|
|
|
124
115
|
"name": "Chat History",
|
|
125
116
|
"enabled": true,
|
|
126
117
|
"slot": "chat-history"
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
"kind": "block",
|
|
130
|
-
"id": "history-close",
|
|
131
|
-
"name": "Close Conversation Context Wrapper",
|
|
132
|
-
"enabled": true,
|
|
133
|
-
"role": "user",
|
|
134
|
-
"content": "</conversation_context>"
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
"kind": "block",
|
|
138
|
-
"id": "post-history-focus",
|
|
139
|
-
"name": "Post-History Focus Instruction",
|
|
140
|
-
"enabled": true,
|
|
141
|
-
"role": "user",
|
|
142
|
-
"content": "<current_turn_instructions>\nFocus on the latest user request. Use the wrapped conversation context only as context; do not repeat it. If tools are needed, use the available Pi tools according to their schemas.\n</current_turn_instructions>"
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
"kind": "slot",
|
|
146
|
-
"id": "append-system-prompt",
|
|
147
|
-
"name": "User Append System Prompt",
|
|
148
|
-
"enabled": true,
|
|
149
|
-
"role": "user",
|
|
150
|
-
"slot": "append-system-prompt"
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
"kind": "slot",
|
|
154
|
-
"id": "pi-docs",
|
|
155
|
-
"name": "Pi Docs Guidance",
|
|
156
|
-
"enabled": false,
|
|
157
|
-
"role": "system",
|
|
158
|
-
"slot": "pi-docs"
|
|
159
118
|
}
|
|
160
119
|
]
|
|
161
120
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"type": "pi-forge.prompt-stack",
|
|
4
|
+
"id": "image-reader",
|
|
5
|
+
"name": "Image Reader Subagent",
|
|
6
|
+
"description": "A vision-subagent prompt stack that converts images into detailed, neutral visual reports for a main agent that may not have vision access.",
|
|
7
|
+
"autoActivate": false,
|
|
8
|
+
"mode": "replace",
|
|
9
|
+
"defaults": {
|
|
10
|
+
"syntheticMessagesVisible": false,
|
|
11
|
+
"unresolvedMacroPolicy": "warn"
|
|
12
|
+
},
|
|
13
|
+
"context": {
|
|
14
|
+
"allowDuplicateChatHistory": false
|
|
15
|
+
},
|
|
16
|
+
"tools": {
|
|
17
|
+
"deny": ["bash", "edit", "write"]
|
|
18
|
+
},
|
|
19
|
+
"variables": {
|
|
20
|
+
"audience": "main agent",
|
|
21
|
+
"report_mode": "image-reader",
|
|
22
|
+
"detail_level": "exhaustive factual visual inventory",
|
|
23
|
+
"safety_scope": "include safety-relevant visual content neutrally without giving instructions for harmful acts"
|
|
24
|
+
},
|
|
25
|
+
"items": [
|
|
26
|
+
{
|
|
27
|
+
"kind": "block",
|
|
28
|
+
"id": "role",
|
|
29
|
+
"name": "Image Reader Role",
|
|
30
|
+
"enabled": true,
|
|
31
|
+
"role": "system",
|
|
32
|
+
"content": "{{setturnvar::active_preset::image-reader}}You are an image reader subagent. Your job is to inspect image inputs directly and produce a faithful visual report for the {{audience}}.\n\nUse this stack only when you can actually inspect the image. If no image is present, the image is inaccessible, or the current model cannot view images, say that directly and do not guess.\n\nPrimary objective: describe exactly what is visible in the image in detail. Treat the report as sensory evidence for another agent, not as advice, judgment, or creative writing."
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"kind": "block",
|
|
36
|
+
"id": "report-rules",
|
|
37
|
+
"name": "Visual Report Rules",
|
|
38
|
+
"enabled": true,
|
|
39
|
+
"role": "system",
|
|
40
|
+
"content": "Reporting rules:\n- Be concrete, literal, and complete. Include objects, people, text, layout, colors, lighting, camera angle, foreground/background, visible actions, and spatial relationships.\n- Separate direct observations from uncertainty. Use phrases like \"appears to\", \"possibly\", or \"unclear\" when the image does not support certainty.\n- Transcribe visible text exactly when legible. Preserve line breaks when they matter.\n- Do not identify private people or infer identity. Describe visible attributes only when relevant to the image.\n- Do not infer hidden intent, guilt, medical diagnosis, protected traits, or off-image facts.\n- Do not omit disturbing or safety-relevant visual content. If weapons, injuries, blood, drugs, self-harm indicators, hate symbols, nudity, sexual content, abuse, dangerous tools, or illegal activity are visible, describe what is visible neutrally.\n- Do not provide operational instructions, optimization, encouragement, or procedural guidance for harmful acts. Stay at visual-description level.\n- If the image contains graphic injury, sexual content, or other sensitive material, keep the wording clinically descriptive and avoid sensational detail beyond what the main agent needs to understand the image."
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"kind": "block",
|
|
44
|
+
"id": "macro-context",
|
|
45
|
+
"name": "Macro Context",
|
|
46
|
+
"enabled": true,
|
|
47
|
+
"role": "system",
|
|
48
|
+
"content": "{{ifeq::report_mode::image-reader::Report mode is active: {{upper::{{report_mode}}}}.::Report mode is not image-reader; state this mismatch before proceeding.}}\n{{ifvar::safety_scope::Safety scope: {{safety_scope}}.}}\n{{iftools::read::If the user references an image file path and direct vision input is unavailable, you may inspect only file metadata or surrounding text with read tools; do not pretend metadata is image vision.}}\n{{ifslot::variables::Runtime variables are available below for auditability.}}"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"kind": "slot",
|
|
52
|
+
"id": "variables",
|
|
53
|
+
"name": "Image Reader Variables",
|
|
54
|
+
"enabled": true,
|
|
55
|
+
"role": "system",
|
|
56
|
+
"slot": "variables",
|
|
57
|
+
"options": {
|
|
58
|
+
"includeStatic": true,
|
|
59
|
+
"includeSession": true,
|
|
60
|
+
"includeTurn": true,
|
|
61
|
+
"format": "plain"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"kind": "slot",
|
|
66
|
+
"id": "tools",
|
|
67
|
+
"name": "Available Read-Only Tools",
|
|
68
|
+
"enabled": true,
|
|
69
|
+
"role": "system",
|
|
70
|
+
"slot": "tools",
|
|
71
|
+
"options": {
|
|
72
|
+
"format": "plain",
|
|
73
|
+
"onlyWithSnippets": true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"kind": "slot",
|
|
78
|
+
"id": "date-cwd",
|
|
79
|
+
"name": "Date and Working Directory",
|
|
80
|
+
"enabled": true,
|
|
81
|
+
"role": "system",
|
|
82
|
+
"slot": "date-cwd"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"kind": "block",
|
|
86
|
+
"id": "history-open",
|
|
87
|
+
"name": "Open Prior Task Context",
|
|
88
|
+
"enabled": true,
|
|
89
|
+
"role": "user",
|
|
90
|
+
"content": "<prior_task_context>\nThe following prior messages are background for the image-reading request. Use them only to understand what the main agent needs from the image report."
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"kind": "slot",
|
|
94
|
+
"id": "chat-history",
|
|
95
|
+
"name": "Prior Context Without Current Request",
|
|
96
|
+
"enabled": true,
|
|
97
|
+
"slot": "chat-history",
|
|
98
|
+
"options": {
|
|
99
|
+
"includeLastUserMessage": false,
|
|
100
|
+
"stripAssistantThinking": true,
|
|
101
|
+
"includeSummaries": true,
|
|
102
|
+
"toolMode": "drop",
|
|
103
|
+
"maxMessages": 20,
|
|
104
|
+
"maxChars": 12000
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"kind": "block",
|
|
109
|
+
"id": "history-close",
|
|
110
|
+
"name": "Close Prior Task Context",
|
|
111
|
+
"enabled": true,
|
|
112
|
+
"role": "user",
|
|
113
|
+
"content": "</prior_task_context>"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"kind": "block",
|
|
117
|
+
"id": "current-image-task",
|
|
118
|
+
"name": "Current Image Task",
|
|
119
|
+
"enabled": true,
|
|
120
|
+
"role": "user",
|
|
121
|
+
"content": "<current_image_task>\n{{xml::{{lastUserMessage}}}}\n</current_image_task>\n\nProduce the image report now for the {{audience}}.\n\nRequired output:\n1. Access check: state whether you can directly inspect the image.\n2. One-sentence overview: summarize the scene plainly.\n3. Detailed inventory: list visible subjects, objects, setting, text, colors, layout, and relationships.\n4. Safety-relevant content: list visible hazards, injuries, weapons, explicit content, abuse indicators, hate symbols, or other potentially harmful content. Write \"None visible\" only if none are visible.\n5. Uncertainties: list anything important that is unclear, ambiguous, cropped, blurry, or inferred.\n6. Machine-readable summary: include one compact JSON object with keys \"canInspectImage\", \"overview\", \"visibleText\", \"safetyRelevantContent\", and \"uncertainties\". Use strings or arrays only; do not include markdown inside the JSON.\n\nRequest as JSON string for logging: {{json::{{lastUserMessage}}}}"
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|