Add LLM synthesis and session transcript support to ask feature#17
Merged
Add LLM synthesis and session transcript support to ask feature#17
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enhance the
askfeature 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
synthesizeAnswer()function inask-project.tsthat calls Claude Haiku to generate structured answers with root cause and confidence levelspickAnswer()heuristic whenANTHROPIC_API_KEYis not configured or API calls failAskProjectResponseto include optionalroot_cause,suggested_fix, andconfidencefields@anthropic-ai/sdkdependency to control-plane2. Session Transcript Capture & Upload
uploadSessionTranscript()in newsession-transcript.tsmodule that reads Claude Code JSONL transcripts, truncates to last 200 messages / 800KB, and uploads to control-planeinstallClaudeCodeHooks()to install two hooks:SessionStart: exportsCLAUDE_TRANSCRIPT_PATHviaCLAUDE_ENV_FILEfor CLI accessPostToolUse(deploy_project): automatically uploads transcript after MCP-triggered deploysCLAUDE_TRANSCRIPT_PATHenv var and upload transcript asynchronously (fire-and-forget, silent on failure)PUT /v1/projects/:projectId/deployments/:deploymentId/session-transcriptthat stores transcript to R2 and setshas_session_transcriptflag3. Internal Commands
jack _internal session-startandjack _internal post-deploysubcommands to handle Claude Code hook callbacks4. Database Schema
0031_add_session_transcript.sqladdshas_session_transcriptcolumn to deployments tableImplementation Details
session_transcripttype with redacted turn summariesTesting
Added
scripts/test-ask-e2e.shfor manual E2E testing of transcript upload and ask endpoints, andscripts/curl-ask-examples.shfor quick API examples.https://claude.ai/code/session_01Naw4TaqKjHM1m2HFpxs23y