rrce-workflow 0.2.32 → 0.2.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +166 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25,6 +25,29 @@ var init_git = __esm({
25
25
  });
26
26
 
27
27
  // src/lib/paths.ts
28
+ var paths_exports = {};
29
+ __export(paths_exports, {
30
+ checkWriteAccess: () => checkWriteAccess,
31
+ copyDirToAllStoragePaths: () => copyDirToAllStoragePaths,
32
+ copyToAllStoragePaths: () => copyToAllStoragePaths,
33
+ detectWorkspaceRoot: () => detectWorkspaceRoot,
34
+ ensureDir: () => ensureDir,
35
+ getAgentPromptPath: () => getAgentPromptPath,
36
+ getConfigPath: () => getConfigPath,
37
+ getDefaultRRCEHome: () => getDefaultRRCEHome,
38
+ getEffectiveRRCEHome: () => getEffectiveRRCEHome,
39
+ getGlobalProjectKnowledgePath: () => getGlobalProjectKnowledgePath,
40
+ getGlobalWorkspacePath: () => getGlobalWorkspacePath,
41
+ getLocalWorkspacePath: () => getLocalWorkspacePath,
42
+ getRRCEHome: () => getRRCEHome,
43
+ getSuggestedGlobalPaths: () => getSuggestedGlobalPaths,
44
+ getWorkspaceName: () => getWorkspaceName,
45
+ listGlobalProjects: () => listGlobalProjects,
46
+ resolveAllDataPaths: () => resolveAllDataPaths,
47
+ resolveDataPath: () => resolveDataPath,
48
+ syncMetadataToAll: () => syncMetadataToAll,
49
+ writeToAllStoragePaths: () => writeToAllStoragePaths
50
+ });
28
51
  import * as fs from "fs";
29
52
  import * as path from "path";
30
53
  function detectWorkspaceRoot() {
@@ -54,9 +77,49 @@ function getConfigPath(workspaceRoot) {
54
77
  function getWorkspaceName(workspaceRoot) {
55
78
  return path.basename(workspaceRoot);
56
79
  }
80
+ function resolveDataPath(mode, workspaceName, workspaceRoot) {
81
+ switch (mode) {
82
+ case "global":
83
+ return path.join(RRCE_HOME, "workspaces", workspaceName);
84
+ case "workspace":
85
+ return path.join(workspaceRoot, ".rrce-workflow");
86
+ default:
87
+ return path.join(RRCE_HOME, "workspaces", workspaceName);
88
+ }
89
+ }
90
+ function resolveAllDataPaths(mode, workspaceName, workspaceRoot) {
91
+ const globalPath = path.join(RRCE_HOME, "workspaces", workspaceName);
92
+ const workspacePath = path.join(workspaceRoot, ".rrce-workflow");
93
+ switch (mode) {
94
+ case "global":
95
+ return [globalPath];
96
+ case "workspace":
97
+ return [workspacePath];
98
+ default:
99
+ return [globalPath];
100
+ }
101
+ }
57
102
  function getRRCEHome() {
58
103
  return RRCE_HOME;
59
104
  }
105
+ function listGlobalProjects(excludeWorkspace) {
106
+ const workspacesDir = path.join(RRCE_HOME, "workspaces");
107
+ if (!fs.existsSync(workspacesDir)) {
108
+ return [];
109
+ }
110
+ try {
111
+ const entries = fs.readdirSync(workspacesDir, { withFileTypes: true });
112
+ return entries.filter((entry) => entry.isDirectory() && entry.name !== excludeWorkspace).map((entry) => entry.name);
113
+ } catch {
114
+ return [];
115
+ }
116
+ }
117
+ function getGlobalProjectKnowledgePath(projectName) {
118
+ return path.join(RRCE_HOME, "workspaces", projectName, "knowledge");
119
+ }
120
+ function getGlobalWorkspacePath(workspaceName) {
121
+ return path.join(RRCE_HOME, "workspaces", workspaceName);
122
+ }
60
123
  function getLocalWorkspacePath(workspaceRoot) {
61
124
  return path.join(workspaceRoot, ".rrce-workflow");
62
125
  }
@@ -80,6 +143,13 @@ function copyToAllStoragePaths(sourceFile, relativePath, dataPaths) {
80
143
  fs.writeFileSync(targetPath, content);
81
144
  }
82
145
  }
146
+ function writeToAllStoragePaths(content, relativePath, dataPaths) {
147
+ for (const dataPath of dataPaths) {
148
+ const targetPath = path.join(dataPath, relativePath);
149
+ ensureDir(path.dirname(targetPath));
150
+ fs.writeFileSync(targetPath, content);
151
+ }
152
+ }
83
153
  function copyDirToAllStoragePaths(sourceDir, relativeDir, dataPaths) {
84
154
  if (!fs.existsSync(sourceDir)) {
85
155
  return;
@@ -124,6 +194,25 @@ function checkWriteAccess(dirPath) {
124
194
  function getDefaultRRCEHome() {
125
195
  return process.env.RRCE_HOME || path.join(process.env.HOME || "~", ".rrce-workflow");
126
196
  }
197
+ function getSuggestedGlobalPaths() {
198
+ const suggestions = [];
199
+ if (process.env.RRCE_HOME) {
200
+ suggestions.push({
201
+ path: process.env.RRCE_HOME,
202
+ label: "RRCE_HOME (environment)",
203
+ isWritable: checkWriteAccess(process.env.RRCE_HOME)
204
+ });
205
+ }
206
+ const homeDefault = path.join(process.env.HOME || "~", ".rrce-workflow");
207
+ if (!process.env.RRCE_HOME || process.env.RRCE_HOME !== homeDefault) {
208
+ suggestions.push({
209
+ path: homeDefault,
210
+ label: "~/.rrce-workflow (default)",
211
+ isWritable: checkWriteAccess(homeDefault)
212
+ });
213
+ }
214
+ return suggestions;
215
+ }
127
216
  function getEffectiveRRCEHome(workspaceRoot) {
128
217
  if (workspaceRoot) {
129
218
  const configPath = getConfigPath(workspaceRoot);
@@ -1283,8 +1372,8 @@ function registerResourceHandlers(server) {
1283
1372
  });
1284
1373
  }
1285
1374
  function registerToolHandlers(server) {
1286
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
1287
- tools: [
1375
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
1376
+ const tools = [
1288
1377
  {
1289
1378
  name: "search_knowledge",
1290
1379
  description: "Search across all exposed project knowledge bases",
@@ -1325,8 +1414,17 @@ function registerToolHandlers(server) {
1325
1414
  required: ["agent"]
1326
1415
  }
1327
1416
  }
1328
- ]
1329
- }));
1417
+ ];
1418
+ const projects = getExposedProjects();
1419
+ if (projects.length === 0) {
1420
+ tools.push({
1421
+ name: "help_setup",
1422
+ description: "Get help on how to configure projects for the RRCE MCP Server",
1423
+ inputSchema: { type: "object", properties: {} }
1424
+ });
1425
+ }
1426
+ return { tools };
1427
+ });
1330
1428
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
1331
1429
  const { name, arguments: args } = request.params;
1332
1430
  logger.info(`Calling tool: ${name}`, args);
@@ -1404,6 +1502,18 @@ Note: If the user's request refers to a project not listed here, ask them to exp
1404
1502
  `;
1405
1503
  return { content: [{ type: "text", text: contextPreamble + content }] };
1406
1504
  }
1505
+ case "help_setup": {
1506
+ const msg = `
1507
+ RRCE MCP Server is running, but no projects are configured/exposed.
1508
+
1509
+ To fix this:
1510
+ 1. Open a terminal.
1511
+ 2. Run: npx rrce-workflow mcp configure
1512
+ 3. Select the projects you want to expose to the AI.
1513
+ 4. Restart the MCP server (or it may pick up changes automatically).
1514
+ `;
1515
+ return { content: [{ type: "text", text: msg }] };
1516
+ }
1407
1517
  default:
1408
1518
  throw new Error(`Unknown tool: ${name}`);
1409
1519
  }
@@ -1458,6 +1568,13 @@ function registerPromptHandlers(server) {
1458
1568
  Context - Available Projects (MCP Hub):
1459
1569
  ${projectList}
1460
1570
  `;
1571
+ if (projects.length === 0) {
1572
+ contextPreamble += `
1573
+ WARNING: No projects are currently exposed to the MCP server.
1574
+ The user needs to run 'npx rrce-workflow mcp configure' in their terminal to select projects to expose.
1575
+ Please advise the user to do this if they expect to see project context.
1576
+ `;
1577
+ }
1461
1578
  if (activeProject) {
1462
1579
  contextPreamble += `
1463
1580
  Current Active Workspace: ${activeProject.name} (${activeProject.path})
@@ -2134,6 +2251,7 @@ async function handleStartServer() {
2134
2251
  let keepRunning = true;
2135
2252
  while (keepRunning) {
2136
2253
  let nextAction = "exit";
2254
+ process.stdin.resume();
2137
2255
  const app = render(React7.createElement(App2, {
2138
2256
  initialPort,
2139
2257
  onExit: () => {
@@ -2145,7 +2263,10 @@ async function handleStartServer() {
2145
2263
  onInstall: () => {
2146
2264
  nextAction = "install";
2147
2265
  }
2148
- }));
2266
+ }), {
2267
+ exitOnCtrlC: false
2268
+ // We handle this in App
2269
+ });
2149
2270
  await app.waitUntilExit();
2150
2271
  if (nextAction === "exit") {
2151
2272
  keepRunning = false;
@@ -2403,6 +2524,10 @@ async function runSetupFlow(workspacePath, workspaceName, existingProjects) {
2403
2524
  confirm: () => confirm2({
2404
2525
  message: "Create configuration?",
2405
2526
  initialValue: true
2527
+ }),
2528
+ exposeToMCP: () => confirm2({
2529
+ message: "Expose this project to MCP (AI Agent) server?",
2530
+ initialValue: true
2406
2531
  })
2407
2532
  },
2408
2533
  {
@@ -2431,7 +2556,8 @@ async function runSetupFlow(workspacePath, workspaceName, existingProjects) {
2431
2556
  globalPath: customGlobalPath,
2432
2557
  tools: config.tools,
2433
2558
  linkedProjects: config.linkedProjects,
2434
- addToGitignore: config.addToGitignore
2559
+ addToGitignore: config.addToGitignore,
2560
+ exposeToMCP: config.exposeToMCP
2435
2561
  }, workspacePath, workspaceName, existingProjects);
2436
2562
  s.stop("Configuration generated");
2437
2563
  const dataPaths = getDataPaths(
@@ -2460,19 +2586,28 @@ async function runSetupFlow(workspacePath, workspaceName, existingProjects) {
2460
2586
  summary.push(`Workspace file: ${pc4.cyan(`${workspaceName}.code-workspace`)}`);
2461
2587
  }
2462
2588
  note3(summary.join("\n"), "Setup Summary");
2463
- const shouldConfigureMCP = await confirm2({
2464
- message: "Would you like to configure the MCP server now?",
2465
- initialValue: true
2466
- });
2467
- if (shouldConfigureMCP && !isCancel3(shouldConfigureMCP)) {
2468
- const { runMCP: runMCP2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
2469
- await runMCP2();
2470
- } else {
2589
+ if (config.exposeToMCP) {
2590
+ note3(`${pc4.green("\u2713")} Project exposed to MCP Hub`, "MCP Configuration");
2471
2591
  if (linkedProjects.length > 0) {
2472
2592
  outro2(pc4.green(`\u2713 Setup complete! Open ${pc4.bold(`${workspaceName}.code-workspace`)} in VSCode to access linked knowledge.`));
2473
2593
  } else {
2474
2594
  outro2(pc4.green(`\u2713 Setup complete! Your agents are ready to use.`));
2475
2595
  }
2596
+ } else {
2597
+ const shouldConfigureMCP = await confirm2({
2598
+ message: "Would you like to configure the MCP server now?",
2599
+ initialValue: true
2600
+ });
2601
+ if (shouldConfigureMCP && !isCancel3(shouldConfigureMCP)) {
2602
+ const { runMCP: runMCP2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
2603
+ await runMCP2();
2604
+ } else {
2605
+ if (linkedProjects.length > 0) {
2606
+ outro2(pc4.green(`\u2713 Setup complete! Open ${pc4.bold(`${workspaceName}.code-workspace`)} in VSCode to access linked knowledge.`));
2607
+ } else {
2608
+ outro2(pc4.green(`\u2713 Setup complete! Your agents are ready to use.`));
2609
+ }
2610
+ }
2476
2611
  }
2477
2612
  } catch (error) {
2478
2613
  s.stop("Error occurred");
@@ -2542,6 +2677,23 @@ linked_projects:
2542
2677
  );
2543
2678
  generateVSCodeWorkspace(workspacePath, workspaceName, selectedProjects, config.globalPath);
2544
2679
  }
2680
+ if (config.exposeToMCP) {
2681
+ try {
2682
+ const { loadMCPConfig: loadMCPConfig2, saveMCPConfig: saveMCPConfig2, setProjectConfig: setProjectConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
2683
+ const { getWorkspaceName: getWorkspaceName2 } = await Promise.resolve().then(() => (init_paths(), paths_exports));
2684
+ const mcpConfig = loadMCPConfig2();
2685
+ const currentProjectName = workspaceName;
2686
+ if (config.storageMode === "workspace") {
2687
+ setProjectConfig2(mcpConfig, currentProjectName, true);
2688
+ saveMCPConfig2(mcpConfig);
2689
+ } else {
2690
+ setProjectConfig2(mcpConfig, currentProjectName, true);
2691
+ saveMCPConfig2(mcpConfig);
2692
+ }
2693
+ } catch (e) {
2694
+ console.error("Failed to update MCP config:", e);
2695
+ }
2696
+ }
2545
2697
  }
2546
2698
  function getDataPaths(mode, workspaceName, workspaceRoot, customGlobalPath) {
2547
2699
  const globalPath = path12.join(customGlobalPath || getDefaultRRCEHome(), "workspaces", workspaceName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rrce-workflow",
3
- "version": "0.2.32",
3
+ "version": "0.2.34",
4
4
  "description": "RRCE-Workflow TUI - Agentic code workflow generator for AI-assisted development",
5
5
  "author": "RRCE Team",
6
6
  "license": "MIT",