[PR #4576] [CLOSED] fix(mcp): require an absolute input_path for JavaScript application analysis #6317

Closed
opened 2026-10-31 01:13:32 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4576
Author: @Ganesh2325
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: fix/js-app-absolute-input-path


📝 Commits (3)

  • 153c80a fix(mcp): require an absolute input_path for JavaScript application analysis
  • 44fe829 Merge remote-tracking branch 'upstream/main' into fix/js-app-absolute-input-path
  • 465813c test(mcp): use an absolute input_path in application export-shape parity

📊 Changes

4 files changed (+113 additions, -2 deletions)

View changed files

➕ src/contracts/javascript/electronToolContracts.test.ts (+36 -0)
📝 src/contracts/javascript/electronToolContracts.ts (+13 -0)
📝 tests/boundary/mcp/applicationExportShapeMcp.test.ts (+10 -2)
➕ tests/boundary/mcp/javascriptApplicationRelativeInput.test.ts (+54 -0)

📄 Description

Fixes #3924

Problem

analyze_javascript_application documents an absolute input_path (docs/javascript-artifact-reconstruction.md: "input_path must be absolute"). The MCP input schema used localPathStringSchema, which only rejects empty and NUL-containing strings. So input_path: "app" analyzed app under whatever directory the MCP server was launched from. A missing relative path got an existence-dependent ENOENT error instead of the path-shape correction.

Change

src/contracts/javascript/electronToolContracts.ts: the MCP request schema (analyzeJavaScriptApplicationRequestSchema) narrows input_path to an absolute path. This uses the same refine(isAbsolute) pattern and message style as snapshot_path/path in sessionLifecycleInputs.ts. Relative values now fail input validation with an error naming input_path and the absolute-path requirement, whether or not the path exists. The shared domain input schema and the CLI path handling are unchanged. The CLI already resolves its positional path before analysis.

Verification

  • npx vitest run src/contracts/javascript/electronToolContracts.test.ts (new): 6 passed. It covers relative app, missing-app, ./app, ../app/app.asar, an absolute control, and empty input. Against main the 4 relative cases fail.
  • npx vitest run tests/boundary/mcp/javascriptApplicationRelativeInput.test.ts (new, the reporter's repro): 1 passed. It starts the stdio MCP server with a temp cwd containing app/main.js. Both app and missing-app return isError with the absolute-path message, and the absolute path still parses 1 JavaScript file. Run after npm run build:cached.
  • npx vitest run tests/boundary/mcp/javascriptSourceSelection.test.ts tests/boundary/mcp/toolSchemaValidity.test.ts: passed after npm run test:prepare.
  • npx vitest run src/contracts src/application/javascript: 426 passed, 3 skipped.
  • npm run verify:test-discovery: all 1443 test files discovered exactly once.
  • npm run lint: exit 0. npm run typecheck: exit 0.

Not covered

  • Windows path forms were not run. isAbsolute is host-specific, the same as the existing session path schemas.
  • I didn't audit other MCP tools with path inputs. This PR is scoped to the tool in the issue.

This change was prepared with AI assistance.

Author readiness

Human owner: @Ganesh2325

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4576 **Author:** [@Ganesh2325](https://github.com/Ganesh2325) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/js-app-absolute-input-path` --- ### 📝 Commits (3) - [`153c80a`](https://github.com/morluto/rea/commit/153c80ade56144368f9863ba67fbcca09999b419) fix(mcp): require an absolute input_path for JavaScript application analysis - [`44fe829`](https://github.com/morluto/rea/commit/44fe829e45a08cb2ef4fbaa1fabbdb0d5e6642b7) Merge remote-tracking branch 'upstream/main' into fix/js-app-absolute-input-path - [`465813c`](https://github.com/morluto/rea/commit/465813c4f2117ce917f6ee04a48b4ab49c37007b) test(mcp): use an absolute input_path in application export-shape parity ### 📊 Changes **4 files changed** (+113 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `src/contracts/javascript/electronToolContracts.test.ts` (+36 -0) 📝 `src/contracts/javascript/electronToolContracts.ts` (+13 -0) 📝 `tests/boundary/mcp/applicationExportShapeMcp.test.ts` (+10 -2) ➕ `tests/boundary/mcp/javascriptApplicationRelativeInput.test.ts` (+54 -0) </details> ### 📄 Description Fixes #3924 ## Problem `analyze_javascript_application` documents an absolute `input_path` (`docs/javascript-artifact-reconstruction.md`: "`input_path` must be absolute"). The MCP input schema used `localPathStringSchema`, which only rejects empty and NUL-containing strings. So `input_path: "app"` analyzed `app` under whatever directory the MCP server was launched from. A missing relative path got an existence-dependent ENOENT error instead of the path-shape correction. ## Change `src/contracts/javascript/electronToolContracts.ts`: the MCP request schema (`analyzeJavaScriptApplicationRequestSchema`) narrows `input_path` to an absolute path. This uses the same `refine(isAbsolute)` pattern and message style as `snapshot_path`/`path` in `sessionLifecycleInputs.ts`. Relative values now fail input validation with an error naming `input_path` and the absolute-path requirement, whether or not the path exists. The shared domain input schema and the CLI path handling are unchanged. The CLI already resolves its positional path before analysis. ## Verification - `npx vitest run src/contracts/javascript/electronToolContracts.test.ts` (new): 6 passed. It covers relative `app`, `missing-app`, `./app`, `../app/app.asar`, an absolute control, and empty input. Against `main` the 4 relative cases fail. - `npx vitest run tests/boundary/mcp/javascriptApplicationRelativeInput.test.ts` (new, the reporter's repro): 1 passed. It starts the stdio MCP server with a temp cwd containing `app/main.js`. Both `app` and `missing-app` return `isError` with the absolute-path message, and the absolute path still parses 1 JavaScript file. Run after `npm run build:cached`. - `npx vitest run tests/boundary/mcp/javascriptSourceSelection.test.ts tests/boundary/mcp/toolSchemaValidity.test.ts`: passed after `npm run test:prepare`. - `npx vitest run src/contracts src/application/javascript`: 426 passed, 3 skipped. - `npm run verify:test-discovery`: all 1443 test files discovered exactly once. - `npm run lint`: exit 0. `npm run typecheck`: exit 0. ## Not covered - Windows path forms were not run. `isAbsolute` is host-specific, the same as the existing session path schemas. - I didn't audit other MCP tools with path inputs. This PR is scoped to the tool in the issue. This change was prepared with AI assistance. ## Author readiness Human owner: @Ganesh2325 - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:13:32 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6317
No description provided.