@zihanw/pi-forge 0.5.2 → 0.5.4
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/CHANGELOG.md +24 -0
- package/README.md +22 -21
- package/README.zh-CN.md +22 -21
- package/dist/agent-profile.js +5 -5
- package/dist/agent-profile.js.map +1 -1
- package/dist/codecs/agent-profile.js +4 -4
- package/dist/codecs/agent-profile.js.map +1 -1
- package/dist/codecs/prompt-stack.d.ts +2 -2
- package/dist/codecs/prompt-stack.js +20 -20
- package/dist/codecs/prompt-stack.js.map +1 -1
- package/dist/compile-cycle.d.ts +6 -1
- package/dist/compile-cycle.d.ts.map +1 -1
- package/dist/compile-cycle.js +2 -0
- package/dist/compile-cycle.js.map +1 -1
- package/dist/compiler.d.ts +7 -1
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +70 -2
- package/dist/compiler.js.map +1 -1
- package/dist/context-diff-history.d.ts +2 -0
- package/dist/context-diff-history.d.ts.map +1 -1
- package/dist/context-diff-history.js +9 -0
- package/dist/context-diff-history.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +12 -3
- package/dist/lifecycle.js.map +1 -1
- package/dist/preset-command.d.ts +2 -0
- package/dist/preset-command.d.ts.map +1 -1
- package/dist/preset-command.js +22 -14
- package/dist/preset-command.js.map +1 -1
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +3 -3
- package/dist/preview.js.map +1 -1
- package/dist/profile-command.d.ts +4 -1
- package/dist/profile-command.d.ts.map +1 -1
- package/dist/profile-command.js +15 -11
- package/dist/profile-command.js.map +1 -1
- package/dist/profile-service.js +4 -4
- package/dist/profile-service.js.map +1 -1
- package/dist/prompt-cache-warning.d.ts +23 -0
- package/dist/prompt-cache-warning.d.ts.map +1 -0
- package/dist/prompt-cache-warning.js +74 -0
- package/dist/prompt-cache-warning.js.map +1 -0
- package/dist/repositories/prompt-stack.js +8 -8
- package/dist/repositories/prompt-stack.js.map +1 -1
- package/dist/runtime/profile-runtime.js +3 -3
- package/dist/runtime/profile-runtime.js.map +1 -1
- package/dist/runtime/prompt-stack-runtime.js +1 -1
- package/dist/runtime/prompt-stack-runtime.js.map +1 -1
- package/dist/runtime/tool-policy-runtime.d.ts.map +1 -1
- package/dist/runtime/tool-policy-runtime.js +16 -4
- package/dist/runtime/tool-policy-runtime.js.map +1 -1
- package/dist/runtime/web-editor-runtime.js +7 -7
- package/dist/runtime/web-editor-runtime.js.map +1 -1
- package/dist/subagent-host.js +4 -4
- package/dist/subagent-host.js.map +1 -1
- package/dist/web-editor/client-script.generated.d.ts.map +1 -1
- package/dist/web-editor/client-script.generated.js +1 -1
- package/dist/web-editor/client-script.generated.js.map +1 -1
- package/dist/web-editor/client-styles.generated.d.ts.map +1 -1
- package/dist/web-editor/client-styles.generated.js +1 -1
- package/dist/web-editor/client-styles.generated.js.map +1 -1
- package/dist/web-editor/server.js +4 -4
- package/dist/web-editor/server.js.map +1 -1
- package/dist/web-editor/styles.d.ts.map +1 -1
- package/dist/web-editor/styles.js +105 -2
- package/dist/web-editor/styles.js.map +1 -1
- package/dist/web-editor/types.d.ts +11 -1
- package/dist/web-editor/types.d.ts.map +1 -1
- package/dist/web-host.d.ts.map +1 -1
- package/dist/web-host.js +30 -14
- package/dist/web-host.js.map +1 -1
- package/docs/README.md +5 -5
- package/docs/concepts/prompt-stacks.md +17 -17
- package/docs/design/pi-forge-system-update-design-notes.md +229 -0
- package/docs/development/roadmap.md +4 -2
- package/docs/guides/use-cases.md +1 -1
- package/docs/guides/web-editor.md +10 -9
- package/docs/zh-CN/README.md +4 -4
- package/docs/zh-CN/concepts/prompt-stacks.md +11 -11
- package/docs/zh-CN/guides/web-editor.md +8 -7
- package/examples/custom-system-status-extension/README.md +5 -6
- package/examples/custom-system-status-extension/index.ts +11 -6
- package/examples/fake-assistant-direct-output-prompt-stack.json +48 -0
- package/examples/minimal-prompt-stack.json +7 -3
- package/package.json +2 -2
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
`/preset ui restart` 会替换 server,`/preset ui stop` 会关闭它。
|
|
12
12
|
|
|
13
|
-
编辑器绑定在带 session token 的可用 `127.0.0.1` 端口;多个项目可以同时运行。读取、预览和 payload 检查在合适范围内可用;写入要求 Pi 信任项目,并且文件被限制在
|
|
13
|
+
编辑器绑定在带 session token 的可用 `127.0.0.1` 端口;多个项目可以同时运行。读取、预览和 payload 检查在合适范围内可用;写入要求 Pi 信任项目,并且文件被限制在 Pi Forge 的预设/Profile 存储内。可以在 `.pi/forge/config.json` 中设置偏好端口:
|
|
14
14
|
|
|
15
15
|
```json
|
|
16
16
|
{
|
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
|
|
23
23
|
## 界面语言
|
|
24
24
|
|
|
25
|
-
编辑器界面提供英文和中文。使用顶栏的语言选择器(Auto / English / 中文);选择会写入项目配置中的 `webEditor.locale`。默认为 `Auto`,跟随浏览器语言,首次页面渲染也会参考浏览器的 `Accept-Language`
|
|
25
|
+
编辑器界面提供英文和中文。使用顶栏的语言选择器(Auto / English / 中文);选择会写入项目配置中的 `webEditor.locale`。默认为 `Auto`,跟随浏览器语言,首次页面渲染也会参考浏览器的 `Accept-Language` 请求头。界面框架、内置预设/Profile 界面以及预览/差异停靠栏均已本地化;编译器诊断信息、插件提供的设置页面以及预设中自行编写的内容保持其原始语言。
|
|
26
26
|
|
|
27
|
-
##
|
|
27
|
+
## 预设工作区
|
|
28
28
|
|
|
29
29
|
支持:
|
|
30
30
|
|
|
31
|
-
- 从默认 Pi mirror
|
|
31
|
+
- 从默认 Pi mirror 新建预设;
|
|
32
|
+
- 在 **堆栈** tab 中编排有序的 Block/Slot;
|
|
32
33
|
- 结构化和原始 JSON 编辑;
|
|
33
34
|
- 拖拽排序、启用/禁用、校验和完整编译预览;
|
|
34
35
|
- 工具/skill 搜索、精确名称 chips 和通配符策略;
|
|
@@ -36,13 +37,13 @@
|
|
|
36
37
|
- 原生 pi-forge JSON 导入;
|
|
37
38
|
- 导出、fork、删除和 payload 捕获。
|
|
38
39
|
|
|
39
|
-
已有 ID 在编辑时不可修改;需要新 ID 时使用 **Fork**,避免破坏
|
|
40
|
+
已有 ID 在编辑时不可修改;需要新 ID 时使用 **Fork**,避免破坏 Profile 引用和当前选择。工具栏的 scope 下拉(默认 `project`)决定新建、导入和 fork 的写入位置:选择 `global` 写入用户全局 `~/.pi/forge/prompt-stacks`,选择 `project` 写入项目 `.pi/forge/prompt-stacks`;这些目录名在 0.5.3 中为兼容性暂时保留。列表会为全局预设显示 `global` badge;保存和删除通过 `global:<id>` 路由精确作用于全局文件。保存、导入、fork 和删除后会重新加载当前 Pi session。
|
|
40
41
|
|
|
41
42
|
## Agent profile 工作区
|
|
42
43
|
|
|
43
|
-
列表显示
|
|
44
|
+
列表显示 Profile ID、名称、模型、思考等级、预设、校验状态、auto-activation 和 last-applied provenance。每个 Profile 都带 `project` / `global` scope badge;同 ID 的 shadow 对会显示 `shadows global:<id>` 或 `shadowed by project:<id>`。
|
|
44
45
|
|
|
45
|
-
可信项目通过 **New profile** 旁的 scope 下拉(默认 `project`)选择目标 scope:选择 `global` 写入用户全局 `~/.pi/forge/agent-profiles`,选择 `project` 写入项目 `.pi/forge/agent-profiles`。全局
|
|
46
|
+
可信项目通过 **New profile** 旁的 scope 下拉(默认 `project`)选择目标 scope:选择 `global` 写入用户全局 `~/.pi/forge/agent-profiles`,选择 `project` 写入项目 `.pi/forge/agent-profiles`。全局 Profile 可通过显式 `global:<id>` 路由编辑、校验、保存、一次性应用和删除;未限定路由始终只作用于项目资源。编辑全局 Profile 时,预设下拉只显示全局预设。Model 选项来自 Pi registry,thinking 选项反映模型支持,预设选项来自同一个 repository。编辑器会拒绝同 scope 内第二个 auto-activation Profile。
|
|
46
47
|
|
|
47
48
|
## Delegation
|
|
48
49
|
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
This example shows how trusted pi-forge extension modules can register a custom macro and custom slot without importing `@zihanw/pi-forge` from a loose Pi extension file.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
It registers two renderers that sample the machine when the prompt is compiled:
|
|
6
6
|
|
|
7
|
-
- `{{ extensions.cpuLoad }}` macro: one-line CPU load summary.
|
|
8
|
-
- `machine-status` slot: CPU load, OS load average, memory, and uptime
|
|
7
|
+
- `{{ extensions.cpuLoad }}` macro: one-line CPU load summary sampled when that macro is rendered.
|
|
8
|
+
- `machine-status` slot: CPU load, OS load average, memory, and uptime sampled when that slot is rendered.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This is compile-time telemetry, not a continuous sampler: no background timer runs and nothing streams while the model is generating. pi-forge performs the full Stack compilation for the first provider request of each user turn (and for explicit Preview/Diff compilation); tool-result follow-up requests do not rerun the full Stack. The macro and slot render independently, so their snapshots may differ slightly.
|
|
11
11
|
|
|
12
12
|
## Try It
|
|
13
13
|
|
|
@@ -26,8 +26,7 @@ Start Pi, trust the project if prompted, then run:
|
|
|
26
26
|
/preset use custom-system-status
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
Use `/preset diagnostics` to confirm the extension file is listed under loaded pi-forge extensions.
|
|
30
|
-
Run `/preset reload` whenever you want to capture a fresh machine snapshot.
|
|
29
|
+
Use `/preset diagnostics` to confirm the extension file is listed under loaded pi-forge extensions. Start another user turn or recompile Preview to sample again. `/preset reload` is only needed after changing the extension or stack files.
|
|
31
30
|
|
|
32
31
|
## Where To Put The Extension
|
|
33
32
|
|
|
@@ -24,7 +24,7 @@ interface ForgeRegistrationApi {
|
|
|
24
24
|
}): () => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
interface SystemStatusSnapshot {
|
|
27
|
+
export interface SystemStatusSnapshot {
|
|
28
28
|
logicalCores: number;
|
|
29
29
|
cpuModel: string;
|
|
30
30
|
load1: number;
|
|
@@ -37,20 +37,23 @@ interface SystemStatusSnapshot {
|
|
|
37
37
|
uptimeSeconds: number;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export default function registerSystemStatus(
|
|
41
|
-
|
|
40
|
+
export default function registerSystemStatus(
|
|
41
|
+
api: ForgeRegistrationApi,
|
|
42
|
+
sampleSystemStatus: () => SystemStatusSnapshot = readSystemStatus,
|
|
43
|
+
): void {
|
|
42
44
|
api.registerMacro({
|
|
43
45
|
name: "cpuLoad",
|
|
44
46
|
source: "pi-forge-example-system-status",
|
|
45
|
-
description: "Machine CPU load
|
|
47
|
+
description: "Machine CPU load sampled when the prompt is compiled.",
|
|
46
48
|
dependencies: [],
|
|
47
|
-
|
|
49
|
+
// Renderers run during prompt compilation. Read a fresh snapshot for each render.
|
|
50
|
+
render: () => formatCpuLoad(Object.freeze(sampleSystemStatus())),
|
|
48
51
|
});
|
|
49
52
|
|
|
50
53
|
api.registerSlot({
|
|
51
54
|
name: "machine-status",
|
|
52
55
|
source: "pi-forge-example-system-status",
|
|
53
|
-
description: "Machine CPU, memory, and uptime
|
|
56
|
+
description: "Machine CPU, memory, and uptime sampled when the prompt is compiled.",
|
|
54
57
|
dependencies: [],
|
|
55
58
|
options: {
|
|
56
59
|
format: { type: "enum", values: ["plain", "xml"], default: "plain" },
|
|
@@ -59,6 +62,8 @@ export default function registerSystemStatus(api: ForgeRegistrationApi): void {
|
|
|
59
62
|
includeUptime: { type: "boolean", default: true },
|
|
60
63
|
},
|
|
61
64
|
render: (ctx) => {
|
|
65
|
+
// Do not capture this at registration time: sample when the slot is rendered.
|
|
66
|
+
const snapshot = Object.freeze(sampleSystemStatus());
|
|
62
67
|
const includeMemory = ctx.options.includeMemory !== false;
|
|
63
68
|
const includeUptime = ctx.options.includeUptime !== false;
|
|
64
69
|
const heading = typeof ctx.options.heading === "string" && ctx.options.heading.trim()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 2,
|
|
3
|
+
"type": "pi-forge.prompt-stack",
|
|
4
|
+
"id": "fake-assistant-direct-output",
|
|
5
|
+
"name": "Fake Assistant: Direct Output",
|
|
6
|
+
"description": "Model-specific experiment: append an ordinary assistant text message after chat history to suggest that tagged reasoning has already finished. Compatibility varies by model, provider, and endpoint; verify with an A/B run before use.",
|
|
7
|
+
"autoActivate": false,
|
|
8
|
+
"mode": "replace",
|
|
9
|
+
"defaults": {
|
|
10
|
+
"syntheticMessagesVisible": false,
|
|
11
|
+
"unresolvedMacroPolicy": "warn"
|
|
12
|
+
},
|
|
13
|
+
"context": {
|
|
14
|
+
"allowDuplicateChatHistory": false,
|
|
15
|
+
"mergeConsecutiveRoles": false
|
|
16
|
+
},
|
|
17
|
+
"tools": {
|
|
18
|
+
"deny": [
|
|
19
|
+
"*"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"items": [
|
|
23
|
+
{
|
|
24
|
+
"kind": "block",
|
|
25
|
+
"id": "direct-answer-role",
|
|
26
|
+
"name": "Direct Answer Role",
|
|
27
|
+
"enabled": true,
|
|
28
|
+
"role": "system",
|
|
29
|
+
"content": "You are a concise assistant. Answer the user's latest request directly and include only the requested result."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"kind": "slot",
|
|
33
|
+
"id": "chat-history",
|
|
34
|
+
"name": "Chat History",
|
|
35
|
+
"enabled": true,
|
|
36
|
+
"slot": "chat-history"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"kind": "block",
|
|
40
|
+
"id": "fake-completed-thinking",
|
|
41
|
+
"name": "Fake Completed Thinking",
|
|
42
|
+
"enabled": true,
|
|
43
|
+
"role": "assistant",
|
|
44
|
+
"content": "<think>思考已完成,直接输出结果。</think>"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"parameters": {}
|
|
48
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "pi-forge.prompt-stack",
|
|
4
4
|
"id": "minimal",
|
|
5
5
|
"name": "Minimal Worker",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "Minimal Pi approximation of the DeepSeek Harness Minimal shape: the exact one-line persona, chat history, and only Pi's stock bash plus edit. It does not replicate DSH's persistent shell, editor tool, PTY, sandbox, or deployment semantics.",
|
|
7
7
|
"autoActivate": false,
|
|
8
8
|
"mode": "replace",
|
|
9
9
|
"defaults": {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
},
|
|
13
13
|
"tools": {
|
|
14
14
|
"allow": [
|
|
15
|
-
"bash"
|
|
15
|
+
"bash",
|
|
16
|
+
"edit"
|
|
16
17
|
]
|
|
17
18
|
},
|
|
18
19
|
"items": [
|
|
@@ -29,7 +30,10 @@
|
|
|
29
30
|
"id": "chat-history",
|
|
30
31
|
"name": "Chat History",
|
|
31
32
|
"enabled": true,
|
|
32
|
-
"slot": "chat-history"
|
|
33
|
+
"slot": "chat-history",
|
|
34
|
+
"options": {
|
|
35
|
+
"includeSummaries": false
|
|
36
|
+
}
|
|
33
37
|
}
|
|
34
38
|
],
|
|
35
39
|
"parameters": {}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zihanw/pi-forge",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "Pi extension for
|
|
3
|
+
"version": "0.5.4",
|
|
4
|
+
"description": "Pi extension for editable context presets, one-shot agent profiles, tool policy, and request debugging.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/MacroSony/pi-forge.git"
|