@estebanforge/pi-ask-shared

中文文档
0.1.6发布于 2026/11/13MITES Module零依赖近 30 天下载 1961

Shared runtime for the @estebanforge ask extensions: background-run registry, wake sender, stop handler, one-shot spawn lifecycle, layered config primitives, per-CLI peer adapters (claude/codex/agy), and the cross-peer consult core. Plain library, no Pi e

原始使用文档

@estebanforge/pi-ask-shared

Shared runtime for the @estebanforge ask extensions (pi-ask-claude, pi-ask-codex, pi-ask-antigravity). Plain library, no Pi entrypoint: each ask package lists it in dependencies, and Pi installs it transitively when a package is installed standalone.

What it provides

  • BackgroundRunRegistry: per-tool registry of background runs. RunId generation, concurrency cap, settle-exactly-once latch, TTL sweep for settled runs, dispose latch for session shutdown.
  • createWakeSender / buildWakeContent: pushes a finished run back into the conversation via ExtensionAPI.sendMessage with triggerTurn: true and deliverAs: "followUp". Guards a stale host with a latch plus catch-all, wraps peer output in an UNTRUSTED banner, optional redaction hook.
  • createStopHandler: pure logic for the /<tool>-stop command (unique-prefix match, ambiguity listing, settle on stop).
  • backgroundFlagText: the model-facing description for the background flag. Byte-identical across tools except the resume-handle name.
  • runProcess: the shared one-shot spawn lifecycle (detached process group, SIGTERM→SIGKILL with grace, watchdog timeout, abort wiring, settle-on-close with trailing flush, buffer valves; rejects impossible timeouts. MAX_TIMEOUT_MS / MAX_TIMEOUT_MINUTES cap every caller: setTimeout clamps anything above 2^31-1 ms to 1ms, which kills the peer instantly). Line mode for JSONL peers via onLine, raw mode via stdoutRaw plus onChunk. Windows: resolveSpawnTarget probes PATH for the native .com/.exe and refuses npm .cmd/.bat shims (a shell would corrupt prompt text), and createKillTree kills via taskkill /pid /T /F since POSIX group signals never fire there.
  • runConsult: one-shot peer consult over claude / codex / agy — per-CLI prompt transport (stdin, ---terminated positional, trailing -p), ANSI/OSC-stripped answers, classed ConsultError reasons, session-handle capture. sanitizeReviewerOutput is the standalone strip pass. Rejects non-positive, non-finite, or over-ceiling timeoutMs as ConsultError reason invalid-options.
  • Layered config primitives (configPaths, tryReadJson, loadLayeredRaw, saveLayeredConfig): global-merge-project with project-shadow routing and atomic writes. Callers keep their own path resolution (getAgentDir() vs homedir).
  • Peer adapters (peers/claude, peers/codex, peers/antigravity): argv builders, stream-event grammars, model-catalog parsing and alias resolution, stderr noise filters, and conversation-id discovery for agy. Consumed by the ask extensions, the antigravity bridge, and runConsult.
  • compareVersionsDesc: descending dotted-version compare shared by the codex and antigravity catalogs.
  • buildTimeBudgetNotice(timeoutMs): the wall-clock budget line appended to peer prompts, so spawned agents pace toward a complete answer before the watchdog terminates them. Seconds form with direct-answer framing under two minutes, minutes form with complete-answer-or-subset framing above; empty for anything under one second (the watchdog would kill before the model could read it).

Design constraints

  • Each tool owns its own registry instance. Pi loads packages with separate module roots, so nothing here may rely on cross-package shared state.
  • The registry is process state only. Process handles stay with the owning tool; it passes a kill callback to the stop handler.
  • Running runs are never swept by TTL: the tool's own timeout owns the running lifecycle.

版本与发布记录

@estebanforge/pi-ask-shared 共发布 7 个版本,首次发布于 2026/10/07;过去 12 个月发布了 7 个版本。

版本发布日期距今
0.1.6latest2026/11/132 天前
0.1.52026/11/105 天前
0.1.42026/11/096 天前
0.1.32026/10/2819 天前
0.1.22026/10/121 个月前
0.1.12026/10/071 个月前

关于 @estebanforge/pi-ask-shared 的常见问题

@estebanforge/pi-ask-shared 是什么?

Shared runtime for the @estebanforge ask extensions: background-run registry, wake sender, stop handler, one-shot spawn lifecycle, layered config primitives, per-CLI peer adapters (claude/codex/agy), and the cross-peer consult core. Plain library, no Pi e

如何安装 @estebanforge/pi-ask-shared?

在项目目录运行 npm install @estebanforge/pi-ask-shared,或使用 pnpm add / yarn add / bun add。

@estebanforge/pi-ask-shared 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/estebanforge__pi-ask-shared 是否存在。

@estebanforge/pi-ask-shared 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@estebanforge/pi-ask-shared 可以商用吗?

@estebanforge/pi-ask-shared 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@estebanforge/pi-ask-shared 的下载量有多少?

根据 npm 官方下载统计,@estebanforge/pi-ask-shared 在 2026/10/14 – 2026/11/12 这 30 天内被下载 1,961 次,日均约 65 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@estebanforge/pi-ask-shared 还在维护吗?

最新版本 0.1.6 发布于 2026/11/13(2 天前);至今共发布 7 个版本,其中过去 12 个月发布了 7 个;首次发布于 2026/10/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。