Skip to content

feat: add cortex-code transcript provider#20

Open
jamescha-earley wants to merge 1 commit into
vtemian:mainfrom
jamescha-earley:feat/cortex-code-provider
Open

feat: add cortex-code transcript provider#20
jamescha-earley wants to merge 1 commit into
vtemian:mainfrom
jamescha-earley:feat/cortex-code-provider

Conversation

@jamescha-earley
Copy link
Copy Markdown

@jamescha-earley jamescha-earley commented Mar 20, 2026

Summary

  • Adds a new cortexCode transcript provider that discovers and parses Snowflake Cortex Code conversation transcripts from ~/.snowflake/cortex/conversations/*.json
  • Scopes discovery to workspace via working_directory matching, detects running/idle/completed status from last_updated recency and active tool calls
  • Extracts connection name, message count, tool call count, and session type as metadata; registers as a default provider alongside cursor, claude-code, codex, and opencode

Test plan

  • 41 new tests across 4 test files (schemas, discovery, transcripts, provider integration)
  • npm run check passes (biome + typecheck + 262 tests across 36 files)
  • Build succeeds with ESM, CJS, and DTS outputs including new providers/cortex-code entry point
  • Tested locally against 297 real Cortex Code conversation files — correct discovery, parsing, metadata extraction, and status detection

Checklist

  • Tests added
  • npm run check passes
  • Docs updated (README.md — providers list, entry points, provider count)
  • CHANGELOG updated (Unreleased section)

.... Generated with Cortex Code


Summary by cubic

Adds a new cortexCode transcript provider that discovers and parses Snowflake Cortex Code session JSONs and normalizes them into agent snapshots. It’s included in the default provider set for observers.

  • New Features

    • Discovers sessions from ~/.snowflake/cortex/conversations/*.json, scoped by working_directory.
    • Detects running/idle/completed using last_updated recency and active tool calls.
    • Extracts metadata: connection name, message count, tool call count, session type; builds task summary from first user prompt.
    • Caches file headers by mtime to skip unchanged files; JSON file watch with 150ms debounce.
    • Public entry: @agentprobe/core/providers/cortex-code; registered as a default provider; 41 tests added.
  • Migration

    • No changes required—createObserver() now includes cortexCode() by default.
    • To customize, import cortexCode from @agentprobe/core/providers/cortex-code and pass options like cortexHomePath, maxFiles, or disable watch.

Written for commit c645adf. Summary will update on new commits.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 18 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/providers/cortex-code/transcripts.ts">

<violation number="1" location="src/providers/cortex-code/transcripts.ts:237">
P2: Hardcoded source string diverges from the canonical CORTEX_CODE_SOURCE_KIND, risking identifier drift and downstream mismatches.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/providers/cortex-code/transcripts.ts Outdated
Add a new provider that discovers and parses Snowflake Cortex Code
conversation transcripts from ~/.snowflake/cortex/conversations/*.json.

- Scopes discovery to workspace via working_directory matching
- Detects running/idle/completed status from last_updated recency
- Extracts connection name, message count, tool call count, session type
- Caches file headers by mtime to skip unchanged files
- Registers as default provider alongside cursor, claude-code, codex, opencode
- 41 new tests across schemas, discovery, transcripts, and provider integration

.... Generated with [Cortex Code](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code)

Co-Authored-By: Cortex Code <noreply@snowflake.com>
@jamescha-earley jamescha-earley force-pushed the feat/cortex-code-provider branch from 12add4c to c645adf Compare March 20, 2026 22:33
Copy link
Copy Markdown
Owner

@vtemian vtemian left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution, James! The provider is architecturally sound: it follows the discover -> read -> normalize pipeline correctly, uses factory functions, accumulates warnings non-fatally, and mirrors the existing claude-code provider patterns well. The test suite is solid (41 tests, real filesystem, proper cleanup). Clearly you studied the codebase before writing this.

A few things need fixing before we can merge:

  1. Module-level mutable stateheaderCache in discovery.ts is a module-level Map singleton. This leaks across provider instances and test runs. The claude-code provider keeps its cache in closed-over state inside the factory function. Please move headerCache into the factory's closure or pass it through options.

  2. Unused export isToolResultError — exported from schemas.ts and re-exported through index.ts, but never called anywhere. YAGNI: please remove it.

  3. Magic strings"Chat for session:" in transcripts.ts and "cortex-code://sessions" in provider.ts should be named constants (per project rules, no magic strings).

  4. Unused parameter _fileUpdatedAt — in recalculateStatus in transcripts.ts. If it's not needed, remove it from the signature rather than underscore-prefixing.

  5. Version bump — the PR bumps package.json to 0.2.0. Please revert this: version bumps are the maintainer's call.

None of these require structural changes, just a cleanup pass. Looking forward to v2!

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