@cydm/pie 2.7.15 → 2.7.17
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 +3 -1
- package/dist/builtin/extensions/ask-user/index.js +3 -3
- package/dist/builtin/extensions/cron/index.js +30 -2
- package/dist/builtin/extensions/im-forward/index.js +21 -10
- package/dist/builtin/extensions/pie-ipc/index.js +272 -20
- package/dist/builtin/extensions/plan-mode/index.js +3 -3
- package/dist/builtin/extensions/subagent/index.js +4 -4
- package/dist/builtin/extensions/todo/index.js +3 -3
- package/dist/chunks/{chunk-TDHVB2FH.js → chunk-2H2DD22Z.js} +2 -1
- package/dist/chunks/{chunk-CLEPSTWH.js → chunk-TGCI5M6R.js} +2 -2
- package/dist/chunks/{chunk-C5UTDL3S.js → chunk-UDCGB3LZ.js} +9 -2
- package/dist/chunks/{chunk-NM2JLPJ6.js → chunk-X7UO6BA6.js} +1 -1
- package/dist/chunks/{src-IY6TEIL7.js → src-GX4UBAYF.js} +2 -2
- package/dist/chunks/{test-stream-EXSL5TIO.js → test-stream-AKIZNFCM.js} +1 -1
- package/dist/cli.js +131 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -215,6 +215,8 @@ Main key bindings:
|
|
|
215
215
|
- `Ctrl+D` exit when the editor is empty; forward-delete otherwise
|
|
216
216
|
- `Ctrl+V` / `Alt+V` / `Cmd+V` paste an image from the clipboard when the main chat editor owns focus (terminal clipboard first, OS helper fallback). Plan refinement, extension input/editor/custom UI, visible overlays, and the mention picker retain their own paste keys.
|
|
217
217
|
- `Ctrl+O` expand or collapse tool output
|
|
218
|
+
- `Alt+O` toggle YOLO mode
|
|
219
|
+
- `Alt+I` set up or toggle IM forwarding
|
|
218
220
|
- `/` open the slash command menu
|
|
219
221
|
|
|
220
222
|
OS clipboard images are staged in per-read private temporary directories (0700 directories and exclusively reserved 0600 files on POSIX), including subprocess output, and removed after staging or on failure. Windows uses the user's temporary directory and inherited OS access controls. Terminal OSC 5522 frames and CSI 5522 support replies are incrementally framed, size-bounded, and never flushed as keyboard input while recognized: the default inter-chunk deadline is 1s, with a 10s absolute frame deadline. Failed frames discard their tails through the terminator or until 1s of idle recovery. An ambiguous lone Escape keeps its normal keyboard timeout unless a clipboard request is active; even then it is eventually delivered as Escape. After idle recovery, arbitrarily late bare payload bytes cannot be distinguished from new typing.
|
|
@@ -378,7 +380,7 @@ Pie exposes one default model-visible web tool: `web_research`. Use it for publi
|
|
|
378
380
|
|
|
379
381
|
## Permissions
|
|
380
382
|
|
|
381
|
-
Pie
|
|
383
|
+
Interactive Pie starts with YOLO mode on: filesystem sandbox directory restrictions are disabled and high-risk shell commands are auto-approved. Use `/settings/yolo off` in trusted workflows that need workspace-scoped file tools and confirmations; `~/.pie` remains allowlisted for Pie configuration/session support in that mode. Headless print/json-events hosts retain their non-YOLO composition. Shell commands return structured timeout/truncation/error details. The canonical executable tool is named `shell`; `bash` remains only a historical replay/rendering and policy identifier, not a second executable alias. On Windows `shell:auto` uses PowerShell, and callers can explicitly request the `bash`, `powershell`, or `cmd` dialect. High-risk shell commands require confirmation outside YOLO mode; the confirmation dialog also offers a time-boxed `Yolo (5 min)` option that suppresses further high-risk prompts for five minutes without enabling full YOLO mode. Explicitly turning `/settings/yolo off` revokes both persistent YOLO and any live temporary grant; status reports a remaining grant separately. `pie permissions` prints the current policy-derived safety summary.
|
|
382
384
|
|
|
383
385
|
In interactive Plan mode (`/tools/plan`), workspace editing tools are unavailable. The Plan-mode `shell` guard accepts simple read commands and read-only pipelines such as `rg 'TODO' . | head -20`; it blocks redirects, command substitution, and write-capable subcommands. Use `plan_scratch` to write, read, or list temporary text drafts in a directory dedicated to the current session. Shell redirection to `/tmp` remains blocked in Plan mode. When the plan is ready, the agent submits the ordered steps with `plan_submit` and you choose to execute immediately (progress is tracked through `[DONE:n]` markers in responses), keep planning, or refine the plan in a prefilled editor; a plan written as plain text under a `Plan:`/`计划:` heading is still detected as a fallback. Leave Plan mode before changing workspace files.
|
|
384
386
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
createAskUserCapability
|
|
4
|
-
} from "../../../chunks/chunk-
|
|
5
|
-
import "../../../chunks/chunk-
|
|
6
|
-
import "../../../chunks/chunk-
|
|
4
|
+
} from "../../../chunks/chunk-UDCGB3LZ.js";
|
|
5
|
+
import "../../../chunks/chunk-2H2DD22Z.js";
|
|
6
|
+
import "../../../chunks/chunk-X7UO6BA6.js";
|
|
7
7
|
import "../../../chunks/chunk-XXGYUYXI.js";
|
|
8
8
|
import "../../../chunks/chunk-LZQXQOPJ.js";
|
|
9
9
|
|
|
@@ -69,10 +69,20 @@ var Store = class {
|
|
|
69
69
|
fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
70
70
|
}
|
|
71
71
|
dir;
|
|
72
|
+
/** Serialized bytes of the state currently on disk; undefined until the
|
|
73
|
+
* first save. A poll transaction that leaves the state byte-identical
|
|
74
|
+
* (the common idle case: owners unchanged, no job transitions) skips the
|
|
75
|
+
* write+fsync+rename entirely — the leader polls every second, so an
|
|
76
|
+
* unconditional save burned a needless fsync per second forever.
|
|
77
|
+
* Calibrated against the raw file inside every transaction: another
|
|
78
|
+
* process's write invalidates it, so a no-op skip can never resurrect
|
|
79
|
+
* stale bytes over a newer foreign save. */
|
|
80
|
+
lastSavedContent;
|
|
72
81
|
transaction(fn) {
|
|
73
82
|
const lock = path.join(this.dir, "write.lock");
|
|
74
83
|
fs.mkdirSync(lock, { mode: 448 });
|
|
75
84
|
try {
|
|
85
|
+
this.calibrateCache();
|
|
76
86
|
const state = this.read();
|
|
77
87
|
const result = fn(state);
|
|
78
88
|
this.save(state);
|
|
@@ -81,6 +91,21 @@ var Store = class {
|
|
|
81
91
|
fs.rmdirSync(lock);
|
|
82
92
|
}
|
|
83
93
|
}
|
|
94
|
+
/** Invalidate the write-skip cache when the on-disk file is not the exact
|
|
95
|
+
* bytes we last wrote (another process saved, or a manual edit). Held
|
|
96
|
+
* under the transaction lock, so no writer can race this check. */
|
|
97
|
+
calibrateCache() {
|
|
98
|
+
if (this.lastSavedContent === void 0) return;
|
|
99
|
+
const file = path.join(this.dir, "state.json");
|
|
100
|
+
let raw;
|
|
101
|
+
try {
|
|
102
|
+
raw = fs.readFileSync(file, "utf8");
|
|
103
|
+
} catch {
|
|
104
|
+
this.lastSavedContent = void 0;
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (raw !== this.lastSavedContent) this.lastSavedContent = void 0;
|
|
108
|
+
}
|
|
84
109
|
read() {
|
|
85
110
|
const file = path.join(this.dir, "state.json");
|
|
86
111
|
if (!fs.existsSync(file)) return { version: 1, jobs: [], owners: {} };
|
|
@@ -101,6 +126,7 @@ var Store = class {
|
|
|
101
126
|
}
|
|
102
127
|
save(state) {
|
|
103
128
|
const content = JSON.stringify(state, null, 2);
|
|
129
|
+
if (this.lastSavedContent === content) return;
|
|
104
130
|
const projected = {
|
|
105
131
|
...state,
|
|
106
132
|
owners: Object.fromEntries(Object.entries(state.owners).map(([id, owner]) => [id, { ...owner, busy: false }])),
|
|
@@ -133,6 +159,7 @@ var Store = class {
|
|
|
133
159
|
fs.closeSync(dir);
|
|
134
160
|
}
|
|
135
161
|
}
|
|
162
|
+
this.lastSavedContent = content;
|
|
136
163
|
}
|
|
137
164
|
add(sessionId, cwd, prompt, schedule, now = Date.now()) {
|
|
138
165
|
if (!sessionId || sessionId.length > 256) throw new Error("an existing session is required");
|
|
@@ -581,6 +608,7 @@ function cron(ctx) {
|
|
|
581
608
|
ctx.on("session:changed", async (e) => {
|
|
582
609
|
try {
|
|
583
610
|
await runtime.bind(e.sessionId);
|
|
611
|
+
startupError = void 0;
|
|
584
612
|
} catch (e2) {
|
|
585
613
|
startupError = String(e2);
|
|
586
614
|
}
|
|
@@ -596,7 +624,7 @@ function cron(ctx) {
|
|
|
596
624
|
} catch {
|
|
597
625
|
}
|
|
598
626
|
ctx.ui.notify("cron: session ownership is uncertain or duplicated; input blocked. Close the duplicate/worker and inspect /cron.", "warning");
|
|
599
|
-
return { action: "
|
|
627
|
+
return { action: "reject" };
|
|
600
628
|
});
|
|
601
629
|
ctx.on("session:before_switch", (e) => {
|
|
602
630
|
if (!e.targetSessionId) return;
|
|
@@ -612,7 +640,7 @@ function cron(ctx) {
|
|
|
612
640
|
}
|
|
613
641
|
});
|
|
614
642
|
const run = (action, id, prompt, schedule) => {
|
|
615
|
-
if (startupError) throw new Error(`cron unavailable: ${startupError}; see docs/cron.md recovery`);
|
|
643
|
+
if (startupError && action !== "list") throw new Error(`cron unavailable: ${startupError}; see docs/cron.md recovery`);
|
|
616
644
|
if (action === "list") return JSON.stringify({ ...store.read(), recoveryRequired: fs3.existsSync(path4.join(store.dir, "unsafe.lock")), coordinatorPresent: fs3.existsSync(path4.join(store.dir, "scheduler.lock")) }, null, 2);
|
|
617
645
|
if (action === "add") {
|
|
618
646
|
if (!runtime.ready || !runtime.sessionId) throw new Error("wait for an existing session to load and register");
|
|
@@ -365,7 +365,7 @@ function createRuntime(ctx, cfg, connection, liveEnabled, persistEnabled) {
|
|
|
365
365
|
ctx.ui.notify("IM forwarding disabled", "info");
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
ctx.registerShortcut("
|
|
368
|
+
ctx.registerShortcut("alt+i", {
|
|
369
369
|
description: "Toggle IM forwarding",
|
|
370
370
|
handler: toggleForwarding
|
|
371
371
|
});
|
|
@@ -581,6 +581,9 @@ ${pending.caption || IM_INPUT_FALLBACK_CAPTION}` : pending.caption).trim();
|
|
|
581
581
|
if (cfg.allowUsers && (!event.sender_id || !cfg.allowUsers.includes(event.sender_id))) return;
|
|
582
582
|
const messageId = event.message_id;
|
|
583
583
|
if (!messageId) return;
|
|
584
|
+
const releaseInvalidatedEvent = () => {
|
|
585
|
+
if (event.event_id) seenEventIds.delete(key(event.event_id));
|
|
586
|
+
};
|
|
584
587
|
const sessionId = currentSessionId;
|
|
585
588
|
const epoch = inputEpoch;
|
|
586
589
|
const scope = ctx.beginUserInput?.(() => !terminated && inputEpoch === epoch && currentSessionId === sessionId && isForwardingEnabled());
|
|
@@ -595,7 +598,10 @@ ${pending.caption || IM_INPUT_FALLBACK_CAPTION}` : pending.caption).trim();
|
|
|
595
598
|
retry();
|
|
596
599
|
return;
|
|
597
600
|
}
|
|
598
|
-
if (!scope.isCurrent())
|
|
601
|
+
if (!scope.isCurrent()) {
|
|
602
|
+
releaseInvalidatedEvent();
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
599
605
|
const resolution = await resolveRouteForInbound(messageId, meta);
|
|
600
606
|
if (!("found" in resolution)) {
|
|
601
607
|
if (isTransient(resolution)) retry();
|
|
@@ -603,15 +609,20 @@ ${pending.caption || IM_INPUT_FALLBACK_CAPTION}` : pending.caption).trim();
|
|
|
603
609
|
return;
|
|
604
610
|
}
|
|
605
611
|
const route = resolution.found;
|
|
606
|
-
if (route.sessionId !== sessionId || !scope.isCurrent())
|
|
612
|
+
if (route.sessionId !== sessionId || !scope.isCurrent()) {
|
|
613
|
+
releaseInvalidatedEvent();
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
607
616
|
const imageKeys = event.images;
|
|
608
617
|
const caption = event.text;
|
|
609
618
|
if (!caption && !imageKeys.length) return;
|
|
610
619
|
const submitText = `${IM_INPUT_PREFIX}
|
|
611
620
|
${caption || IM_INPUT_FALLBACK_CAPTION}`;
|
|
612
621
|
const accepted = imageKeys.length ? await injectImageMessage(messageId, imageKeys, submitText, scope) : await scope.submit(submitText);
|
|
613
|
-
|
|
614
|
-
|
|
622
|
+
const currentAfterSubmit = scope.isCurrent();
|
|
623
|
+
if (!accepted || !currentAfterSubmit) {
|
|
624
|
+
if (!accepted && !currentAfterSubmit) releaseInvalidatedEvent();
|
|
625
|
+
if (currentAfterSubmit) {
|
|
615
626
|
ctx.ui.notify("im-forward: message was not accepted; no input submitted.", "warning");
|
|
616
627
|
await forwardMessage(`\u26A0\uFE0F \u6D88\u606F\u63A5\u6536\u5931\u8D25\uFF0C\u672A\u63D0\u4EA4\u4EFB\u52A1\u3002${imageKeys.length ? "\u8BF7\u68C0\u67E5\u9644\u4EF6\u540E\u91CD\u8BD5\u3002" : "\u8BF7\u91CD\u8BD5\u3002"}`, route.sessionId, ++forwardCounter, caption, messageId);
|
|
617
628
|
}
|
|
@@ -2068,13 +2079,13 @@ function initializeImForward(ctx, providers = implementedProviders) {
|
|
|
2068
2079
|
try {
|
|
2069
2080
|
const settings = provider.resolve(config.settings);
|
|
2070
2081
|
if (!settings) {
|
|
2071
|
-
ctx.ui.notify(`IM forwarding: ${provider.label} target/settings are incomplete. Use
|
|
2082
|
+
ctx.ui.notify(`IM forwarding: ${provider.label} target/settings are incomplete. Use Alt+I or /im-forward setup.`, "warning");
|
|
2072
2083
|
ctx.ui.setStatus?.("im-forward", "[IM!]");
|
|
2073
2084
|
return;
|
|
2074
2085
|
}
|
|
2075
2086
|
const connection = provider.connect(settings, ctx.cwd);
|
|
2076
2087
|
if (!connection) {
|
|
2077
|
-
ctx.ui.notify(`IM forwarding: ${provider.label} connection could not be prepared. Use
|
|
2088
|
+
ctx.ui.notify(`IM forwarding: ${provider.label} connection could not be prepared. Use Alt+I or /im-forward setup to check provider dependencies and configuration.`, "warning");
|
|
2078
2089
|
ctx.ui.setStatus?.("im-forward", "[IM!]");
|
|
2079
2090
|
return;
|
|
2080
2091
|
}
|
|
@@ -2173,7 +2184,7 @@ function initializeImForward(ctx, providers = implementedProviders) {
|
|
|
2173
2184
|
}
|
|
2174
2185
|
function showStatus(commandCtx) {
|
|
2175
2186
|
if (status) status(commandCtx);
|
|
2176
|
-
else commandCtx.ui.notify("IM forwarding is not configured or unavailable. Use
|
|
2187
|
+
else commandCtx.ui.notify("IM forwarding is not configured or unavailable. Use Alt+I or /im-forward setup.", "info");
|
|
2177
2188
|
}
|
|
2178
2189
|
async function clearConfiguration(commandCtx) {
|
|
2179
2190
|
setupAbort?.abort();
|
|
@@ -2193,7 +2204,7 @@ This does not remove the app credentials lark-cli itself stores; re-running setu
|
|
|
2193
2204
|
commandCtx.ui.notify(error.message || "IM forwarding configuration could not be cleared.", "error");
|
|
2194
2205
|
}
|
|
2195
2206
|
}
|
|
2196
|
-
ctx.registerShortcut("
|
|
2207
|
+
ctx.registerShortcut("alt+i", { description: "Set up or toggle IM forwarding", handler: () => toggleNow(ctx) });
|
|
2197
2208
|
ctx.registerCommand({ path: ["im-forward", "status"], description: "Show IM forwarding status", handler: async (commandCtx) => {
|
|
2198
2209
|
if (!disposed) showStatus(commandCtx);
|
|
2199
2210
|
} });
|
|
@@ -2203,7 +2214,7 @@ This does not remove the app credentials lark-cli itself stores; re-running setu
|
|
|
2203
2214
|
ctx.registerCommand({ path: ["im-forward", "setup"], description: "Run the IM forwarding setup wizard", handler: async () => {
|
|
2204
2215
|
if (!disposed) await setup();
|
|
2205
2216
|
} });
|
|
2206
|
-
ctx.registerCommand({ path: ["im-forward", "toggle"], description: "Toggle IM forwarding on/off (same as
|
|
2217
|
+
ctx.registerCommand({ path: ["im-forward", "toggle"], description: "Toggle IM forwarding on/off (same as Alt+I)", handler: async (commandCtx) => {
|
|
2207
2218
|
if (!disposed) await toggleNow(commandCtx);
|
|
2208
2219
|
} });
|
|
2209
2220
|
ctx.registerCommand({ path: ["im-forward", "clear"], description: "Remove IM forwarding configuration (with confirmation)", handler: async (commandCtx) => {
|