feat: setup shell and files routes

- previously the nproject name to the backend was passed like 'C--USERS-...' and it used the legacy project-config.json file in .claude to get the original workspace paths,
However, now we are directly passing the workspace and no parsing is necessary for the routes.
So I modified the extractProjectDirectory to just return the project name.
This commit is contained in:
Haileyesus
2026-04-08 15:30:28 +03:00
parent 7c8819cf34
commit 4a4a1e1803
18 changed files with 378 additions and 50 deletions

View File

@@ -5,11 +5,17 @@ import os from 'os';
import mime from 'mime-types';
import fetch from 'node-fetch';
import { promises as fsPromises } from 'fs';
import { extractProjectDirectory } from '../../../projects.js';
import { authenticateToken } from '../auth/auth.middleware.js';
const router = express.Router();
const extractProjectDirectory = (projectName) => {
return new Promise((resolve, reject) => {
// just return the original project name for now, since we are no longer encoding the path in the project name
resolve(projectName);
});
}
/**
* Validate that a path is within the project root
* @param {string} projectRoot - The project root path
@@ -149,7 +155,9 @@ router.get('/api/projects/:projectName/file', authenticateToken, async (req, res
return res.status(400).json({ error: 'Invalid file path' });
}
console.log("PROJECT NAME IS: ", projectName);
const projectRoot = await extractProjectDirectory(projectName).catch(() => null);
console.log("PROJECT ROOT IS: ", projectRoot);
if (!projectRoot) {
return res.status(404).json({ error: 'Project not found' });
}
@@ -288,7 +296,9 @@ router.get('/api/projects/:projectName/files', authenticateToken, async (req, re
// Use extractProjectDirectory to get the actual project path
let actualPath;
try {
console.log("Extracting project directory for:", req.params.projectName);
actualPath = await extractProjectDirectory(req.params.projectName);
console.log("Extracted project directory:", actualPath);
} catch (error) {
console.error('Error extracting project directory:', error);
// Fallback to simple dash replacement

View File

@@ -2,10 +2,17 @@ import express from 'express';
import spawn from 'cross-spawn';
import path from 'path';
import { promises as fs } from 'fs';
import { extractProjectDirectory } from '../../../projects.js';
import { queryClaudeSDK } from '../../../claude-sdk.js';
import { spawnCursor } from '../../../cursor-cli.js';
const extractProjectDirectory = (projectName) => {
return new Promise((resolve, reject) => {
// just return the original project name for now, since we are no longer encoding the path in the project name
resolve(projectName);
});
}
const router = express.Router();
const COMMIT_DIFF_CHARACTER_LIMIT = 500_000;

View File

@@ -13,15 +13,17 @@ import fs from 'fs';
import path from 'path';
import { promises as fsPromises } from 'fs';
import spawn from 'cross-spawn';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import os from 'os';
import { extractProjectDirectory } from '../../../projects.js';
import { detectTaskMasterMCPServer } from '../../../utils/mcp-detector.js';
import { broadcastTaskMasterProjectUpdate, broadcastTaskMasterTasksUpdate } from '../../../utils/taskmaster-websocket.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const extractProjectDirectory = (projectName) => {
return new Promise((resolve, reject) => {
// just return the original project name for now, since we are no longer encoding the path in the project name
resolve(projectName);
});
}
const router = express.Router();