Skip to content

fix(pi): support Oh My Pi (OMP) session format and directory naming - #143

Merged
phodal merged 5 commits into
QoderAI:mainfrom
comicchang:fix/pi-omp-session-compat
Sep 4, 2026
Merged

fix(pi): support Oh My Pi (OMP) session format and directory naming#143
phodal merged 5 commits into
QoderAI:mainfrom
comicchang:fix/pi-omp-session-compat

Conversation

@comicchang

Copy link
Copy Markdown
Contributor

Why

Oh My Pi (OMP) is a popular open-source coding agent CLI that shares Pi's session infrastructure but has diverged in two ways:

  1. Directory naming: OMP v17.2.9+ uses home-relative directory names for sessions under ~/.omp/agent/sessions/ (e.g. -src-dotai for ~/src/dotai), while the Pi adapter only recognizes the legacy absolute format (--Users-ooxx-src-dotai--).

  2. JSONL preamble: OMP emits a title record as the first line of session JSONL files, before the session header. The Pi adapter's probeTranscript rejects any file whose first record is not a session header.

  3. macOS bug: path.win32.isAbsolute("/Users/...") returns true on macOS, causing path.win32.normalize to convert forward slashes to backslashes. This silently corrupted the slug generation.

What changed

scripts/session-analysis/platforms/pi.mjs (core fix)

  • workspaceToPiSessionDirVariants: Added homeExact and homePrefix fields for OMP's home-relative directory naming. Also fixed path.win32.isAbsolutepath.isAbsolute and path.win32.normalizepath.normalize to avoid backslash corruption on macOS.

  • listSessionDirectories: Extended the filter to match against homeExact/homePrefix variants in addition to the existing exact/prefix fields.

  • probeTranscript: Skip leading title records before the session header. Other non-session record types before the header still cause fail-closed rejection.

Documentation

  • Added OMP to README.md and README.zh-CN.md more-adapters sections
  • Added OMP row to adapter matrix tables (overview and canonical)
  • Added OMP discovery and lifecycle sections
  • Added OMP to output modes list

How to use

PI_CODING_AGENT_DIR=~/.omp/agent better-harness harness evidence-bundle \
  --platform pi --workspace <project> --cwd <project> --language en --format json

Testing

  • All 435 existing session tests pass (0 regressions)
  • Verified end-to-end: 206 eligible sessions, 300 episodes, 3 candidates discovered from OMP session directory
  • The exact/prefix fields are unchanged, so all existing Pi users are unaffected

OMP (Oh My Pi) stores sessions under ~/.omp/agent/sessions/ using:
- Home-relative directory names (e.g. -src-dotai for ~/src/dotai)
  instead of Pi's legacy absolute format (--Users-ooxx-src-dotai--)
- A 'title' preamble record before the session header in JSONL files

Changes:
- workspaceToPiSessionDirVariants: add homeExact/homePrefix fields for
  OMP's home-relative directory naming convention
- listSessionDirectories: match against homeExact/homePrefix variants
- probeTranscript: skip 'title' preamble records before session header
- Fix path.win32.isAbsolute/normalize bug on macOS (returns true for
  /Users/... paths, mangling forward slashes to backslashes)

Documentation:
- Add OMP to README.md and README.zh-CN.md more-adapters sections
- Add OMP row to adapter matrix tables (overview and canonical)
- Add OMP discovery and lifecycle sections
- Add OMP to output modes list

Usage: PI_CODING_AGENT_DIR=~/.omp/agent better-harness harness
evidence-bundle --platform pi --workspace <path>
OMP /fork creates a new session file with parentSession field in header,
duplicating all parent messages. 38/479 (7.9%) sessions are forked.

Follow-up design: detect parentSession, mark as derived, process only
incremental messages after fork point to avoid double-counting.
OMP /fork creates a new session file with all parent entries copied.
The parentSession field in the session header identifies the source.

Changes:
- probeTranscript: detect parentSession, store forkTimestamp
- addRef: propagate forkTimestamp/parentSessionId to session object
- readSession: skip events with timestamp < forkCutoff to avoid
  double-counting inherited parent messages

Verified: 1 forked session detected in dotai (103 sessions), properly
marked as derived with incremental-only processing.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new home-relative session directory matching can incorrectly include unrelated workspaces due to an overly broad prefix check and an imprecise “outside home” test.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR extends the existing Pi session analyzer to also recognize Oh My Pi (OMP) session evidence by supporting OMP’s home-relative session directory naming and its JSONL preamble format, and updates the documentation to list OMP as an adapter-supported host.

Changes:

  • Updated Pi session directory discovery to include OMP home-relative directory variants and fixed cross-platform path normalization behavior.
  • Updated Pi transcript probing/reading to tolerate OMP’s leading title record and to capture fork metadata for skipping inherited pre-fork entries.
  • Documented OMP support across the READMEs and host adapter matrix docs.
File summaries
File Description
scripts/session-analysis/platforms/pi.mjs Adds OMP directory variants, preamble handling, and fork-aware event filtering.
README.md Adds OMP to the “More adapters” list with a pointer to the matrix.
README.zh-CN.md Adds OMP to the Chinese “More adapters” list with a pointer to the matrix.
docs/docs/hosts/adapter-matrix.md Adds OMP to the public adapter matrix and documents OMP-specific session details.
docs/adapters/README.md Adds OMP to the canonical adapter matrix and discovery/lifecycle notes.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/session-analysis/platforms/pi.mjs Outdated
comicchang and others added 2 commits September 4, 2026 10:17
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…nce-safe

Follow-up on the OMP compatibility work. The home-relative prefix boundary was
already tightened in the preceding commit; this adds the regression tests that
lock it, including a home child whose name merely begins with "..", and fixes
the two remaining defects.

Moving the slug normalizer from `path.win32` to `path` broke Windows-shaped
workspace strings on POSIX hosts by resolving them against the host cwd, so
`C:\workspace\project` produced a cwd-prefixed slug. The existing substring
assertion passed straight through that regression, so it is now an equality
check. The genuine `path.win32` problem was elsewhere: normalizing a POSIX path
through `path.win32` backslashes it, which defeated the home-relative
derivation, so that derivation now reads the host-native path instead of the
slug form.

Fork handling dropped inherited entries even when the parent session was absent
from the discovery result, losing evidence with no coverage marker, while still
reporting a session range that covered entries the session no longer yielded.
Deduplication now runs after every transcript is probed, applies only when the
parent is discovered as well, stores the cutoff on the source ref rather than
the session so a second transcript cannot inherit a foreign cutoff, and shares
one predicate with the reader so the reported range always matches the events.

OMP is documented as a session layout of the `pi` platform rather than a new
host, per the bounded host-adapter policy: the duplicated adapter-matrix rows,
the unverified `pi` manifest install-shell claim, and the lifecycle row are
removed, both READMEs attach OMP to the Pi entry, and the zh-Hans mirror gains
the missing section. Acceptance scenarios and boundaries are recorded in
docs/specs/2026-09-04-omp-session-format-compat.md.

Validated with the provider suite and the full run. Each new assertion was
mutation-checked: reverting the prefix boundary, the `path.win32` slug handling,
or the parent-existence condition fails exactly the test that covers it.

Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
@phodal
phodal merged commit f25cb46 into QoderAI:main Sep 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants