M2 — pi SDK session harness + prompt/skill composer #12
Loading…
Reference in a new issue
No description provided.
Delete branch "issue-3/pi-session-harness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements M2 — pi SDK session harness + prompt/skill composer (#3): reusable, deterministic helpers to (a) compose a stage system prompt from a thin pipeline wrapper plus an external skill body, and (b) run one pipeline stage as a fresh pi agent session. Adds a new self-contained
src/stage/module.Changes
composeStagePrompt(src/stage/helpers/): concatenateswrapper + skill body(YAML frontmatter stripped via the SDK'sstripFrontmatter). Degrades to a built-in default body withdegraded = truewhen the skill path is unset, unreadable, or blank (realizes DESIGN D15/D16). Skill reader is injectable for testing.runStage(src/stage/services/): builds a session via an injectable factory, subscribes to streaming events, aggregates assistant text and the ordered list of tool-call names, sends the user prompt, and always disposes the session infinally(on success and on throw).createPiStageSession(src/stage/services/): the real pi wiring — injects the composed system prompt viaDefaultResourceLoaderwithsystemPromptOverride(NOTadditionalSkillPaths), usesModelRuntime.create(),SessionManager.inMemory(),cwd = process.cwd(),resolveCliModel, and a least-privilege tool allowlist.parseThinkingLevel(src/stage/helpers/): coerces a config string into a valid piThinkingLevel(orundefined).src/stage/types/stage.ts) + barrel (src/stage/index.ts).Testing
npm test: 132 passed (20 files)tsc --noEmitclean,eslint .clean,prettier --checkcleanrunStageorchestration (dispose-on-success, dispose-on-throw, event aggregation, options forwarding),parseThinkingLevelPILOOP_E2E=1,runStage.e2e.test.ts): read-onlylsstage streams output, invokes a tool, disposes — asserts exit conditions, never exact LLM textChecklist
Closes #3