Skip to content

feat(cli): add Claude Code and Codex session parsing and --discover to ingest-transcript - #2099

Open
suryanshxharma wants to merge 7 commits into
ClickHouse:mainfrom
suryanshxharma:feat/ingest-transcript-discover
Open

suryanshxharma wants to merge 7 commits into
ClickHouse:mainfrom
suryanshxharma:feat/ingest-transcript-discover

Conversation

@suryanshxharma

@suryanshxharma suryanshxharma commented Dec 3, 2026 •

Copy link
Copy Markdown

Part 1 of #2078 (formats and read-only discovery).

  • Added server/cli/_transcripts.py to parse Claude Code (~/.claude/projects/*/*.jsonl) and Codex (~/.codex/sessions/**/*.jsonl) session transcripts without modifying the source files.
  • Added --discover to loom ingest-transcript to list local sessions grouped by project (sources, session count, date range, total size) without writing anything.
  • Extended loom ingest-transcript --file to accept .jsonl session files in addition to .json and .md.
  • Added unit tests for Claude Code parsing, Codex parsing, and --discover, and updated CLI snapshots and docs/reference/cli.md.

Follow-up PR 2 will add project-level batch import (--newest N), client-side secret redaction, retention/recording checks, source_class="imported" with session timestamps, and the SessionStart primer offer.


Note

Medium Risk
CLI-only changes that read local chat logs and redact secrets before upload, but mis-redaction or over-stripping injected tags could still leak or lose conversation content sent to Loom.

Overview
Extends loom ingest-transcript so local Claude Code and Codex session .jsonl files can be parsed and ingested, and adds read-only --discover to list sessions grouped by project without contacting the server.

A new server/cli/_transcripts.py module scans default ~/.claude/projects and ~/.codex/sessions paths, auto-detects JSONL format, walks Claude’s active message branch (rewinds/sidechains/compaction), strips IDE-injected XML wrappers from user turns, and skips tool-result/meta noise. --discover prints per-project source mix, session count, date span, and size; --file on .jsonl** turns are redacted client-side (tokens, keys, JWTs, caller token) before conversation.append. --namespace / --file are optional when using --discover.

CLI reference, help snapshots, and unit tests cover parsing, discovery, branch logic, and redaction.

Reviewed by Cursor Bugbot for commit 95304b3. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 4, 2026 5:34pm UTC
loom-telemetry Ready Ready Preview Dec 4, 2026 5:34pm UTC

Request Review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread server/cli/_transcripts.py Resolved
Comment thread server/cli/shell.py Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread server/cli/_transcripts.py Resolved
@zlareb1 zlareb1 self-assigned this Dec 3, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

JSONL upload needs client-side redaction. The three commits on this head also need the required DCO sign-offs.

Comment thread server/cli/shell.py Resolved
Comment thread server/cli/_transcripts.py Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The transcript command breaks the unit test for agent token refusal. The failure reproduces on the exact CI merge. Failed job

Comment thread server/cli/shell.py Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The prepared-bot integration failure reproduces on clean main. General health can report ready while the web process still reads recording mode, so the bot identity endpoint refuses provisioning. The same test passes when the fixture waits for that process’s enforced heartbeat. Failed job · Repair #2106

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The streaming retirement test hits the same entry timeout on clean main when an event-loop turn pauses. The repair puts that test on the existing private clock. Failed job · Repair #2112

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread server/cli/_transcripts.py Resolved
…o ingest-transcript

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
…SONL error

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
…k token before args

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>
@suryanshxharma
suryanshxharma force-pushed the feat/ingest-transcript-discover branch from a620e69 to db04f2d Compare December 4, 2026 16:15

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The new head redacts JSONL uploads, streams discovery by file, and checks the agent token before reading the file arguments. The Unicode redaction finding still applies on this head. Reuse the Python SDK redactor’s word-boundary behavior and cover it in the outgoing-request test.

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread server/cli/_transcripts.py Resolved
Comment thread server/cli/_transcripts.py Resolved
s = _JWT_RE.sub("[redacted]", s)
s = _BEARER_RE.sub(r"\1 [redacted]", s)
s = _BASIC_AUTH_RE.sub(r"\1 [redacted]", s)
return _URL_CREDENTIALS_RE.sub(r"\1[redacted]@", s)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

URL redaction eats ordinary paths

Medium Severity

_URL_CREDENTIALS_RE is documented as matching the client redactor, but its userinfo class is [^\s/@\"'] and therefore allows /. A normal URL whose path contains : and a later @ is treated as credentials and rewritten to scheme://[redacted]@... before the turn is stored.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7084797. Configure here.

Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 0e67ef9. Configure here.

Comment thread server/cli/_transcripts.py Resolved
Signed-off-by: suryanshxharma <suryanshxharma@gmail.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The ASCII word boundary fixes the previous Unicode-adjacency case. The same flag also disables Unicode whitespace matching and lets formatted credentials reach the outgoing import.

re.IGNORECASE | re.ASCII,
)
_JWT_RE = re.compile(r"\beyJ[\w-]{0,512}\.[\w-]{1,8192}\.[\w-]{0,1024}", re.ASCII)
_BEARER_RE = re.compile(r"\b(Bearer)\s+[^\s\"'\\]+", re.IGNORECASE | re.ASCII)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

P1 — With re.ASCII on the whole expression, Bearer followed by a non-breaking space and a credential no longer matches. The assignment and Basic auth patterns have the same regression. Scope ASCII to the boundary with (?a:\b), keep Unicode whitespace matching, and exercise the outgoing request with a non-breaking space.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The Python SDK adapter job fails during test collection with agent-framework-core 1.26.0 and opentelemetry-api 1.46.0. Clean main fails with the same versions and traceback. A separate PR constrains the incompatible dependency. PR job · Main job · Fix #2164

This branch has not been deployed

No deployments
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.

2 participants