singularity-forge/packages/pi-coding-agent/src/core
TÂCHES 789a6645da feat: TTSR + blob/artifact storage (ported from oh-my-pi)
* docs(M002): context, requirements, and roadmap

* feat: port TTSR and blob/artifact storage from oh-my-pi

Phase 1 — TTSR (Time Traveling Stream Rules):
- TtsrManager: regex-based stream monitoring with scope filtering,
  repeat gating, and buffer isolation (picomatch replaces Bun.Glob)
- Rule loader: scans ~/.gsd/agent/rules/*.md and .gsd/rules/*.md
  with YAML frontmatter parsing; project rules override global
- TTSR extension: wires into pi event lifecycle (session_start,
  turn_start, message_update, turn_end, agent_end) to abort on
  match and inject violation as system reminder via sendMessage
- Interrupt template for rule violation injection

Phase 2 — Blob/Artifact Storage:
- BlobStore: content-addressed storage at ~/.gsd/agent/blobs/ using
  Node crypto (sha256), sync I/O, automatic deduplication
- ArtifactManager: session-scoped sequential artifact files stored
  alongside session JSONL (lazy dir creation, resume-safe ID scan)
- Session manager integration: prepareForPersistence externalizes
  images ≥1KB to blob store before JSONL write; resolveBlobRefs
  rehydrates on session load; truncates strings >500KB
- Bash tool artifact spill: uses ArtifactManager instead of temp
  files when available, includes artifact:// references in output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: harden blob store, TTSR manager, and dep classification

- Validate SHA-256 hex format in BlobStore.get/has/parseBlobRef to
  prevent path traversal via crafted blob references
- Cap TTSR per-stream buffers at 512KB to prevent unbounded memory growth
- Move picomatch from devDependencies to dependencies (runtime import)
- Warn on invalid regex in TTSR rule conditions instead of silent skip
- Remove .gsd/ planning files that were force-added past .gitignore
- Add trailing newline to ttsr-interrupt.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add tests for blob store, artifact manager, TTSR manager, and rule loader

55 tests covering:
- BlobStore put/get/has, idempotency, path traversal rejection
- parseBlobRef/isBlobRef validation, externalize/resolve round-trips
- ArtifactManager sequential IDs, lazy dir creation, session resume
- TtsrManager rule matching, scope filtering, buffer isolation,
  repeat gating, buffer size cap, injection persistence
- Rule loader frontmatter parsing, directory scanning, merge logic

Also fixes BlobStore constructor to avoid TS parameter property syntax
(incompatible with Node's strip-only TypeScript mode).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 08:43:56 -06:00
..
compaction feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
export-html fix: add missing export-html vendor files 2026-03-13 10:38:13 +01:00
extensions fix: alias @mariozechner/* imports to @gsd/* for external PI ecosystem packages 2026-03-13 07:27:24 -06:00
tools feat: TTSR + blob/artifact storage (ported from oh-my-pi) 2026-03-13 08:43:56 -06:00
agent-session.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
artifact-manager.ts feat: TTSR + blob/artifact storage (ported from oh-my-pi) 2026-03-13 08:43:56 -06:00
auth-storage.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
bash-executor.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
blob-store.ts feat: TTSR + blob/artifact storage (ported from oh-my-pi) 2026-03-13 08:43:56 -06:00
defaults.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
diagnostics.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
event-bus.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
exec.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
footer-data-provider.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
index.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
keybindings.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
messages.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
model-registry.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
model-resolver.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
package-manager.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
prompt-templates.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
resolve-config-value.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
resource-loader.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
sdk.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
session-manager.ts feat: TTSR + blob/artifact storage (ported from oh-my-pi) 2026-03-13 08:43:56 -06:00
settings-manager.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
skills.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
slash-commands.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
system-prompt.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
timings.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00