Skip to content

Add LLM synthesis and session transcript support to ask feature#17

Merged
hellno merged 8 commits intomainfrom
claude/review-queue-worker-LVStG
Feb 18, 2026
Merged

Add LLM synthesis and session transcript support to ask feature#17
hellno merged 8 commits intomainfrom
claude/review-queue-worker-LVStG

Conversation

@hellno
Copy link
Contributor

@hellno hellno commented Feb 18, 2026

Summary

Enhance the ask feature with Claude-powered answer synthesis and automatic capture of Claude Code session context at deploy time. This PR implements two of four planned improvements to post-deployment debugging.

Key Changes

1. LLM Synthesis for Ask Answers

  • Add synthesizeAnswer() function in ask-project.ts that calls Claude Haiku to generate structured answers with root cause and confidence levels
  • Falls back gracefully to existing pickAnswer() heuristic when ANTHROPIC_API_KEY is not configured or API calls fail
  • Extends AskProjectResponse to include optional root_cause, suggested_fix, and confidence fields
  • Add @anthropic-ai/sdk dependency to control-plane

2. Session Transcript Capture & Upload

  • CLI side: Add uploadSessionTranscript() in new session-transcript.ts module that reads Claude Code JSONL transcripts, truncates to last 200 messages / 800KB, and uploads to control-plane
  • Hook integration: Extend installClaudeCodeHooks() to install two hooks:
    • SessionStart: exports CLAUDE_TRANSCRIPT_PATH via CLAUDE_ENV_FILE for CLI access
    • PostToolUse (deploy_project): automatically uploads transcript after MCP-triggered deploys
  • CLI deploy: After successful deploy, check for CLAUDE_TRANSCRIPT_PATH env var and upload transcript asynchronously (fire-and-forget, silent on failure)
  • Control-plane endpoint: New PUT /v1/projects/:projectId/deployments/:deploymentId/session-transcript that stores transcript to R2 and sets has_session_transcript flag
  • Ask integration: Load and include session transcript as evidence when available; pass last 30 turns to LLM for context

3. Internal Commands

  • Add jack _internal session-start and jack _internal post-deploy subcommands to handle Claude Code hook callbacks
  • These commands are silent on failure to prevent hook errors from blocking user workflows

4. Database Schema

  • New migration 0031_add_session_transcript.sql adds has_session_transcript column to deployments table

Implementation Details

  • Session transcript upload is best-effort: failures are silently caught and never block deployments
  • LLM synthesis gracefully degrades to heuristic fallback if API key is missing or calls fail
  • Transcript truncation keeps conversation turns under 1MB server limit while preserving recent context
  • Evidence collection now includes session_transcript type with redacted turn summaries
  • All hook commands exit silently (exit 0) even on error to maintain user experience

Testing

Added scripts/test-ask-e2e.sh for manual E2E testing of transcript upload and ask endpoints, and scripts/curl-ask-examples.sh for quick API examples.

https://claude.ai/code/session_01Naw4TaqKjHM1m2HFpxs23y

claude and others added 8 commits February 18, 2026 10:48
…at deploy time

After each managed deploy, the Claude Code session transcript is automatically
uploaded to R2 as a deployment artifact. This gives the ask feature rich context
about what was being worked on when the code shipped.

Two paths capture the transcript:
- CLI deploy (jack deploy/ship): reads CLAUDE_TRANSCRIPT_PATH from env, which is
  exported by a new SessionStart hook via CLAUDE_ENV_FILE
- MCP deploy (deploy_project tool): a new PostToolUse hook fires after the tool
  call and uploads the transcript directly

New pieces:
- PUT /v1/projects/:projectId/deployments/:deploymentId/session-transcript endpoint
- jack _internal session-start: SessionStart hook handler (exports transcript path)
- jack _internal post-deploy: PostToolUse hook handler (uploads after MCP deploy)
- installClaudeCodeHooks() now also installs the two new hooks
- DB migration 0031: has_session_transcript column on deployments

https://claude.ai/code/session_01Naw4TaqKjHM1m2HFpxs23y
Replaces heuristic pickAnswer() with Claude (haiku) synthesis. Evidence
is passed as structured context; session transcript excerpt from the deploy
is included when available. Falls back to pickAnswer() if ANTHROPIC_API_KEY
is not set or the API call fails.

New pieces:
- synthesizeAnswer(): calls claude-haiku-4-5-20251001, returns answer +
  root_cause + suggested_fix + confidence; returns null when key absent
- fetchSessionTranscript(): reads session-transcript.jsonl from R2, parses
  Claude Code JSONL format (type/message/content), returns last 30 turns
- AskProjectResponse extended with root_cause?, suggested_fix?, confidence?
- AskProjectEvidence.type union gains "session_transcript"
- ANTHROPIC_API_KEY? added to Bindings; @anthropic-ai/sdk added to deps
- scripts/test-ask-e2e.sh: 7-step E2E test suite for transcript + ask endpoints
- scripts/curl-ask-examples.sh: quick curl reference

Run `wrangler secret put ANTHROPIC_API_KEY --cwd apps/control-plane` to
enable LLM synthesis; feature degrades gracefully without it.

https://claude.ai/code/session_01Naw4TaqKjHM1m2HFpxs23y
…gest

- Replace Anthropic SDK with Cloudflare Workers AI binding for LLM calls
- Use @cf/glm4/glm-4.7-flash for both digest generation and ask synthesis
- Generate prose session digest at transcript upload time via waitUntil
- Store digest in session_digest column on deployments (migration 0032)
- Remove @anthropic-ai/sdk dependency and ANTHROPIC_API_KEY references
- Update @cloudflare/workers-types to 4.20260218.0
MCP deploys failed with "Build failed" across projects because:
1. Claude Code/Desktop replaces the entire process env with only what's
   in the MCP config — missing HOME/TMPDIR broke wrangler subprocess
   resolution
2. The actual build error (stderr) was dropped by formatErrorResponse(),
   making failures undiagnosable

Add HOME, TMPDIR, USER to MCP env config. Surface JackError.meta.stderr
as error.details in MCP responses.

Users need `jack mcp install` to pick up the new env config.
Map oklch color tokens, JetBrains Mono, forced dark mode, and
transparent shadows to match the landing page design system.
Three hardening fixes for wrong project name/URL in MCP responses:

- Fix E: sync wrangler config name with cloud slug after project creation
  (4 call sites in project-operations.ts). Adds updateWranglerConfigName()
  utility that preserves comments/formatting for JSONC and TOML.
- Fix C: getProjectStatus() uses overview response (slug, url) instead of
  reading wrangler config name for managed projects. Falls back to local
  data if cloud is unreachable.
- Fix D: reject deploy if wrangler name is literally "jack-template" —
  this is always a bug from un-rendered template files.
…orker-LVStG

# Conflicts:
#	apps/control-plane/src/ask-project.ts
@hellno hellno merged commit 0d08514 into main Feb 18, 2026
1 check passed
@hellno hellno deleted the claude/review-queue-worker-LVStG branch February 18, 2026 13:24
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