feat(project-root): enhance project root detection with boundary markers (#1545)

This commit is contained in:
Ralph Khreish
2025-12-24 13:26:48 +01:00
committed by GitHub
parent 3f489d8116
commit a0007a3575
7 changed files with 337 additions and 124 deletions

View File

@@ -24,7 +24,8 @@
"dependencies": {
"@tm/core": "*",
"fastmcp": "^3.23.0",
"zod": "^4.1.11"
"zod": "^4.1.11",
"dotenv": "^16.6.1"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",

View File

@@ -2,6 +2,7 @@
* Shared utilities for MCP tools
*/
import dotenv from 'dotenv';
import fs from 'node:fs';
import path from 'node:path';
import {
@@ -395,6 +396,13 @@ export function withToolContext<TArgs extends { projectRoot?: string }>(
args: TArgs & { projectRoot: string },
context: Context<undefined>
) => {
// Load project .env if it exists (won't overwrite MCP-provided env vars)
// This ensures project-specific env vars are available to tool execution
const envPath = path.join(args.projectRoot, '.env');
if (fs.existsSync(envPath)) {
dotenv.config({ path: envPath });
}
// Create tmCore instance
const tmCore = await createTmCore({
projectPath: args.projectRoot,