一键导入
stack-l3-bun-pty
bun-pty pseudo-terminal integration: lazy-loading patterns, signal handling, and cross-platform PTY management for Bun runtime
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
bun-pty pseudo-terminal integration: lazy-loading patterns, signal handling, and cross-platform PTY management for Bun runtime
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when detecting and guardrailing against premature completion claims — verifying that subagent "done" assertions are backed by fresh runtime evidence, enforcing dual-signal completion protocol (doer + verifier must agree), and catching hollow "it works" claims that skip verification. Triggers on: "verify completion", "completion detection", "dual-signal", "premature completion", "evidence before claims", "hollow done", "fake done", "completion guardrail", "verify before complete", "block completion until verified", "done but not verified", "did it actually work", "completion verification", "dual-signal completion", "two-agent completion", "fresh evidence requirement". NOT for loop mechanics (iterative-loop), delegation patterns (subagent-delegation-patterns), or quality gate triad orchestration (quality-gate-orchestration).
Use when making cross-cutting changes, cross-pane modifications, framework migrations, or breaking changes that span multiple layers or frameworks (GSD, BMAD, Hivemind, or other). Triggers on: "cross-cutting change", "cross-pane change", "multi-layer change", "framework migration", "breaking change across frameworks", "change impact analysis", "cross-framework change", "multi-pane impact", "test-first change ordering", "dependency ordering across layers", "consumer impact tracing", "interface-first change", "ordered change management". NOT for single-layer changes, single-framework refactors, or cosmetic edits. Framework-agnostic — works across GSD, BMAD, Hivemind, or any project governance framework.
Evaluates whether implementation evidence is sufficient to pass quality gates. Enforces an evidence hierarchy from live runtime proof (L1) down to documentation summaries (L5), and refuses gate passage when evidence is missing, mocked where integration is claimed, or insufficient for the gate type. Use during code review gates, phase audits, milestone verification, integration checks, and deployment readiness. Activates after gate-spec-compliance clears spec alignment — this is the terminal gate in the triad (lifecycle → spec → evidence). Triggers: "evidence check", "gate evidence", "verify runtime proof", "evidence truth", "is there proof this works", "evidence hierarchy", "gate truth", "runtime evidence", "integration evidence", "mock-only detection", "completion honesty", "gate passed", "gate failed". Terminal skill in the quality gate triad — if evidence PASSES, all 3 gates clear.
Internal quality gate that evaluates whether Hivemind harness implementations correctly participate in the runtime lifecycle — covering 9-surface mutation authority, CQRS boundaries, actor hierarchy, event-driven wiring, classification fit (src/ vs .opencode/ vs .hivemind/), and OpenCode SDK surface compliance. Synthesized from .planning/codebase/ARCHITECTURE.md (9-surface authority table) and ingested @opencode-ai/plugin SDK v1.14.44 from anomalyco/opencode (tool(), hook() signatures). Use when performing a lifecycle gate check, auditing harness module integration, verifying CQRS boundary compliance, checking delegation hierarchy constraints, evaluating tool/hook registration correctness, running a harness quality gate, validating plugin composition integrity, or running phase audit on src/ modules. Activates during code review of src/ files, phase audit, milestone verification, integration check, and deployment readiness workflows.
Spec compliance gate performing bidirectional traceability, gap detection (4 types), EARS acceptance criteria validation, and anti-pattern scanning. Use during code review gates, phase audits, milestone verification, and deployment readiness. Middle gate in the quality triad (lifecycle → spec → evidence). Routes to gate-evidence-truth on PASS; STOPS with gap report on FAIL. Includes remediation routing to hm-spec-driven-authoring, hm-test-driven-execution, and hm-debug for fix workflows. Triggers on: "spec compliance", "verify against spec", "gap analysis", "compliance gate", "phase audit gate", "acceptance criteria check", "spec-to-code", "deployment readiness", "triad gate", "spec gate middle", "quality triad".
Detects and fixes drift between AGENTS.md documentation and actual codebase state. Scans source files and .opencode/ directories, compares claims against reality, produces a structured drift report, then applies targeted edits. Triggers on: 'sync agents md', 'update AGENTS.md', 'fix agents md drift', 'AGENTS.md out of date', 'check agent instruction drift'. NOT for generic documentation writing or README refreshes.
| name | stack-l3-bun-pty |
| version | 0.4.8 |
| description | bun-pty pseudo-terminal integration: lazy-loading patterns, signal handling, and cross-platform PTY management for Bun runtime |
| category | stack |
| triggers | ["bun-pty","pty integration","pseudo terminal","terminal integration","background command","pty spawn","IPty","IPtyForkOptions","IExitEvent","IDisposable","pty session","terminal session","lazy load pty","pty zombie process"] |
| metadata | {"layer":"3","role":"reference","lineage":"stack"} |
bun-pty 0.4.x — Cross-platform pseudo-terminal (PTY) for Bun, powered by Rust's portable-pty via Bun FFI.
bun:ffi + Rust native libs; crashes if imported in Node.jsimport at module top-level; use dynamic import() with try/catchkill() does NOT wait — process may linger; check onExit for confirmationIExitEvent.signal property names vary across bun-pty versionsonData/onExit return IDisposable — MUST call .dispose() to prevent memory leaks| Topic | File | What You'll Find |
|---|---|---|
| Core API | references/api/pty-api.md | spawn(), IPty, IPtyForkOptions, events |
| Lazy Loading | references/patterns/lazy-loading.md | Lazy import + graceful fallback pattern |
| TOC | TOC.md | Full table of contents |
import { spawn } from "bun-pty"
import type { IPty, IPtyForkOptions, IExitEvent, IDisposable } from "bun-pty"
Need interactive terminal (user sees output)? → PTY via spawn()
Need fire-and-forget command? → Bun.spawn() or child_process
Need streaming output capture? → PTY with onData ring buffer
Running in non-Bun environment? → Fallback to child_process.exec
Bun 1.3.5+ with simple terminal needs? → Bun.spawn({ terminal }) instead
| Anti-Pattern | Why It Breaks | Correct Pattern |
|---|---|---|
Top-level import { spawn } from "bun-pty" | Crashes in non-Bun environments | Dynamic const pty = await import("bun-pty") in try/catch |
Forgetting to .dispose() event subscriptions | Memory leak — onData/onExit hold references | Always dispose in finally block |
Calling kill() without waiting for onExit | Zombie process — kill() sends signal but doesn't wait | Use onExit promise to confirm termination |
| Ignoring exit signal normalization | IExitEvent has divergent property names across versions | Use extractExitSignal() helper to normalize |
| Creating PTY without size limits | Ring buffer grows unbounded under high throughput | Cap buffer size; implement overflow strategy |
| When working on... | Also load... | Because... |
|---|---|---|
| OpenCode run-background-command tool | stack-opencode | PTY integration via plugin hooks |
| Testing PTY code | stack-vitest | Mock bun-pty with null fallback pattern |
| Lifecycle gate for PTY modules | gate-lifecycle-integration | CQRS boundary: write-side (spawn) vs read-side (onData) |
Bun 1.3.5+ has built-in Bun.Terminal via Bun.spawn({ terminal }) — this may replace bun-pty for simple use cases. Keep bun-pty for advanced features (resize, bidirectional write, exit signal detail).
ABSOLUTE RULE: No bundled reference, cached asset, or stale pattern from this skill shall be consumed for tech-stack API interface decisions without MCP-verified validation against the project's ACTUAL versions (package.json + lockfile), canonical source mappings (
.hivemind/STACKS-REFERENCES.md), AND a raw codebase context scan of the current implementation state.
Skills bundle references and assets as ORIENTATION tools — they help you understand WHAT exists and WHERE to look. But every bundled reference is a SNAPSHOT, frozen at the moment of ingestion. Stacks evolve: packages release breaking changes, APIs shift, SDKs deprecate surfaces. Using stale bundled signatures as implementation authority produces silent runtime errors.
Before ANY tech-stack API interface from this skill's references/assets is used for implementation, code generation, or quality gate decisions:
STEP 1 — CONSUME .hivemind/STACKS-REFERENCES.md
├─ Read the canonical stack→repo→version mapping table
├─ Identify the correct GitHub repo for each dependency
└─ Confirm the repo is active (not archived), version is current
STEP 2 — READ package.json + lockfile
├─ Extract the ACTUAL installed version (npm ls / grep lockfile)
├─ Cross-reference repo URL from STACKS-REFERENCES.md against npm registry
└─ Flag any discrepancy between bundled version and installed version
STEP 3 — RAW CODEBASE CONTEXT SCAN
├─ grep/glob the actual src/ directory structure for current implementation
├─ Read current implementation files — not stale docs or bundled references
├─ Verify the claimed API signatures match current codebase reality
└─ Check import paths, type definitions, and function signatures exist in actual code
STEP 4 — MCP LIVE VALIDATION (minimum 2 tools)
├─ Context7: resolve-library-id → query-docs (API signatures at installed version)
├─ DeepWiki: ask-question (architecture patterns, behavioral semantics)
├─ Repomix: pack-remote-repository (full repo analysis at correct version tag)
├─ Exa: web-search (latest docs, tutorials, migration guides)
├─ Tavily: search + extract (version-specific migration info)
├─ GitHub: get-file-contents (exact source verification at correct version)
└─ GitMCP: search-code (source-level pattern matching)
STEP 5 — VERIFICATION RECORD
├─ Source URL + version confirmed to match package.json
├─ MCP tool(s) used + fetch timestamp
├─ Codebase scan paths + findings
├─ Version match status (MATCHED / MISMATCHED / UNVERIFIED)
└─ Flag as BLOCKING if version mismatch or critical staleness detected
| Action | Rule |
|---|---|
| Orientation (understanding WHAT exists, WHERE to look) | ✅ Reference-tier allowed from bundled assets without live validation |
| API signature lookup for implementation | 🚫 BLOCKED without live MCP validation (Step 4) + codebase scan (Step 3) |
| Interface verification for quality gates | 🚫 BLOCKED without live MCP validation (Step 4) + version match (Step 2) |
| Version-sensitive behavioral claims | 🚫 BLOCKED without live MCP validation (Step 4) |
| Architecture pattern understanding | ✅ Reference-tier allowed, but recommend live verification for production decisions |
| Generating code from bundled patterns | 🚫 BLOCKED — route to live MCP tools for current API surface |
| Workflow Phase | IRON CLAW Trigger | Required Validation |
|---|---|---|
| Implementation | Before using any API from bundled refs | Steps 2-4 minimum |
| Code review | When verifying API usage against docs | Steps 2-4 minimum |
| Quality gate | Before PASS verdict on interface claims | Steps 1-5 full |
| Research | When synthesizing findings from cached assets | Steps 4-5 minimum |
| Audit | When reporting version-based findings | Steps 1-5 full |
Reference documents provide facts, not workflows. When facts conflict with reality, this section guides resolution.
scripts/update.sh to re-fetch source when bun-pty version changes.npx --yes ctx7 library bun-pty "spawn API" or search npm for bun-pty changelog.Bun.Terminal availability as an alternative — the migration path may be complete before this reference is updated.node_modules/bun-pty/dist/index.d.ts for exact TypeScript signatures.references/api/pty-api.md) — these were extracted from source at a specific version.IExitEvent shape differs: The signal property divergence documented here is version-specific. Normalize via the extractExitSignal() helper pattern.npx --yes bun-pty --version to check installed version, then consult the corresponding docs.references/) for coverage — some edge cases may be documented at deeper levels.Bun.spawn() as a fallback for simple cases where bun-pty edge cases are unresolved.