Skip to content

fix(persona): restore full ai-hist MCP via npx -p ai-hist (revert bundled WHY-only server) - #209

Merged
khaliqgant merged 1 commit into
mainfrom
fix/aihist-injection-p-flag
Jun 6, 2026
Merged

khaliqgant merged 1 commit into
mainfrom
fix/aihist-injection-p-flag

Conversation

@khaliqgant

Copy link
Copy Markdown
Member

Problem

An automated PR-reviewer commit (f6977ea, applied to #206) replaced the ai-hist MCP injection with a bundled, zero-dependency ai-hist-mcp-server.ts launched via node. That server exposes only list_trajectories + read_trajectory — it drops the HOW (AI_HIST_DB is unwired) and exposes none of the locked contract tools (search_history, why_for_task, search_trajectories, get_session, get_context, stats). As merged, personas got a minimal why-only reader instead of the unified why+how MCP the team built (and bypassed codex-1's published ai-hist@0.3.0 entirely).

Fix

Restore the unified MCP by launching codex-1's published package directly:
npx -y -p ai-hist ai-hist-mcp. The ai-hist-mcp bin ships inside ai-hist@0.3.0, so this needs no separately-published wrapper package (sidesteps the npm first-publish/OIDC blocker).

  • buildAiHistMcpServer: command: 'npx', args: ['-y','-p','ai-hist','ai-hist-mcp']
  • remove the bundled ai-hist-mcp-server.ts + AI_HIST_SERVER_SCRIPT
  • restore test assertions to the npx form; drop now-unused node:path imports

buildAiHistMcpServer is the single chokepoint for both the CLI spawn (C) and cloud-defaults (B), so this one revert restores both injection paths. B's contract-emit side (#207) is unaffected — it still writes the full contract files; this only fixes which MCP reads them.

Verification

  • persona-kit: 267 tests pass (ai-hist injection + plan assertions restored to npx form)
  • D smoke already validated this exact server: why_for_task (why) + search_history (how) over stdio against ai-hist@0.3.0.

Follow-up (optional, non-blocking): once the ai-hist-mcp wrapper package is bootstrapped on npm, the args can simplify to ['-y','ai-hist-mcp'].

🤖 Generated with Claude Code

…led WHY-only server)

The pr-reviewer rework (f6977ea, on #206) replaced the ai-hist injection with a
bundled zero-dep server exposing only list_trajectories/read_trajectory — which
drops the HOW (cross-tool history) and none of the locked contract tools
(search_history/why_for_task/search_trajectories/get_session/get_context/stats).
Restore the unified why+how MCP by launching codex-1's published ai-hist package
directly: `npx -y -p ai-hist ai-hist-mcp` — the ai-hist-mcp bin ships inside
ai-hist@0.3.0, so no separately-published wrapper package is required.

- buildAiHistMcpServer: command 'npx', args ['-y','-p','ai-hist','ai-hist-mcp']
- remove the bundled ai-hist-mcp-server.ts + AI_HIST_SERVER_SCRIPT const
- restore test assertions to the npx form; drop now-unused node:path imports

buildAiHistMcpServer is the single chokepoint for both the CLI spawn and
cloud-defaults (B), so this restores both injection paths at once. B's
contract-emit side is unaffected. persona-kit: 267 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codeant-ai

codeant-ai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dbb8a129-5cf7-4b70-bb6a-fb80b83d0ec4

📥 Commits

Reviewing files that changed from the base of the PR and between 621a679 and fb3760a.

📒 Files selected for processing (4)
  • packages/persona-kit/src/ai-hist-mcp-server.ts
  • packages/persona-kit/src/interactive-spec.test.ts
  • packages/persona-kit/src/interactive-spec.ts
  • packages/persona-kit/src/plan.test.ts
💤 Files with no reviewable changes (1)
  • packages/persona-kit/src/ai-hist-mcp-server.ts

📝 Walkthrough

Walkthrough

This PR removes the bundled Node.js MCP server implementation and migrates to launching the ai-hist server through the external ai-hist package via npx. Core implementation in interactive-spec.ts switches from running a local script via process.execPath to invoking npx -y -p ai-hist ai-hist-mcp. Test files are updated to align assertions with the new launch mechanism.

Changes

MCP Server Launch Migration to NPX

Layer / File(s) Summary
Core Implementation: NPX-Based Server Launch
packages/persona-kit/src/interactive-spec.ts
Removes the node:url import and AI_HIST_SERVER_SCRIPT constant, then updates buildAiHistMcpServer to launch the ai-hist MCP server via npx -y -p ai-hist ai-hist-mcp instead of via process.execPath with a local script, while preserving environment variable configuration.
Test Assertions: Updated Server Launch Expectations
packages/persona-kit/src/interactive-spec.test.ts, packages/persona-kit/src/plan.test.ts
Removes unused node:path imports and updates assertAiHistServer test helper expectations in both files to verify the server is launched via npx -y -p ai-hist ai-hist-mcp with type: 'stdio' instead of a dynamically resolved Node.js process.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

size:L

Poem

A script once lived, bundled with care,
Now the package dwells in the air,
Via npx it springs to life,
Tests all aligned, no CLI strife,
Simpler paths through the MCP air. 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: reverting a bundled WHY-only server and restoring the full ai-hist MCP via npx with the -p flag.
Description check ✅ Passed The description comprehensively explains the problem, fix, and verification, clearly relating to the changeset of removing the bundled server and restoring npx-based injection.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/aihist-injection-p-flag

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the launch mechanism of the ai-hist MCP server, replacing the execution of a local script via process.execPath with an npx invocation (npx -y -p ai-hist ai-hist-mcp). Consequently, the local script file is removed, and the relevant tests are updated. The reviewer recommends pinning the ai-hist package to a specific version (e.g., ai-hist@0.3.0) in both the implementation and the test assertions to mitigate supply chain security risks, prevent unexpected breaking changes, and avoid performance overhead from registry checks.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

command: process.execPath,
args: [AI_HIST_SERVER_SCRIPT],
command: 'npx',
args: ['-y', '-p', 'ai-hist', 'ai-hist-mcp'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-medium medium

Using npx -y -p ai-hist without a pinned version introduces supply chain security risks and reliability issues (e.g., unexpected breaking changes if a new version of ai-hist is published). Additionally, it can cause performance overhead due to registry update checks.\n\nConsider pinning the package to a specific version (like ai-hist@0.3.0) to ensure deterministic, secure, and reliable execution.

Suggested change
args: ['-y', '-p', 'ai-hist', 'ai-hist-mcp'],
args: ['-y', '-p', 'ai-hist@0.3.0', 'ai-hist-mcp'],

command: process.execPath,
args: [(server as { args: string[] }).args[0]],
command: 'npx',
args: ['-y', '-p', 'ai-hist', 'ai-hist-mcp'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update the test assertion to match the pinned version of the ai-hist package.

Suggested change
args: ['-y', '-p', 'ai-hist', 'ai-hist-mcp'],
args: ['-y', '-p', 'ai-hist@0.3.0', 'ai-hist-mcp'],

command: process.execPath,
args: [(server as { args: string[] }).args[0]],
command: 'npx',
args: ['-y', '-p', 'ai-hist', 'ai-hist-mcp'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update the test assertion to match the pinned version of the ai-hist package.

Suggested change
args: ['-y', '-p', 'ai-hist', 'ai-hist-mcp'],
args: ['-y', '-p', 'ai-hist@0.3.0', 'ai-hist-mcp'],

@khaliqgant
khaliqgant merged commit 06df9da into main Jun 6, 2026
2 of 3 checks passed
@khaliqgant
khaliqgant deleted the fix/aihist-injection-p-flag branch June 6, 2026 12:49
@agent-relay-code

Copy link
Copy Markdown
Contributor

Reviewed PR #209 against the current checkout. I did not find a demonstrated breakage requiring code changes.

Validated:

  • ai-hist@0.3.0 publishes bin ai-hist-mcp.
  • Generated command npx -y -p ai-hist ai-hist-mcp starts and responds to MCP initialize + tools/list over stdio.
  • corepack pnpm --filter @agentworkforce/persona-kit test passed.
  • corepack pnpm --filter @agentworkforce/runtime test passed.

I cleaned generated dist artifacts from the test runs. No source edits were left behind.

@agent-relay-code

Copy link
Copy Markdown
Contributor

✅ pr-reviewer applied fixes — committed and pushed cc7c664 to this PR. The notes below describe what changed.

Reviewed PR #209 against the current checkout. I did not find a demonstrated breakage requiring code changes.

Validated:

  • ai-hist@0.3.0 publishes bin ai-hist-mcp.
  • Generated command npx -y -p ai-hist ai-hist-mcp starts and responds to MCP initialize + tools/list over stdio.
  • corepack pnpm --filter @agentworkforce/persona-kit test passed.
  • corepack pnpm --filter @agentworkforce/runtime test passed.

I cleaned generated dist artifacts from the test runs. No source edits were left behind.

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.

1 participant