@ian2018cs/agenthub 0.1.49 → 0.1.51

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.
@@ -2,7 +2,7 @@ import express from 'express';
2
2
  import { promises as fs } from 'fs';
3
3
  import path from 'path';
4
4
  import { spawn } from 'child_process';
5
- import { addProjectManually } from '../projects.js';
5
+ import { addProjectManually, loadProjectConfig } from '../projects.js';
6
6
  import { getUserPaths } from '../services/user-directories.js';
7
7
 
8
8
  const router = express.Router();
@@ -101,8 +101,42 @@ router.post('/create-workspace', async (req, res) => {
101
101
  // Check if directory already exists
102
102
  try {
103
103
  await fs.access(absolutePath);
104
- return res.status(400).json({
105
- error: 'A project with this name already exists. Please choose a different name.'
104
+ // Folder exists - check if it's registered in project config
105
+ const config = await loadProjectConfig(userUuid);
106
+ const projectKey = absolutePath.replace(/\//g, '-');
107
+ if (config[projectKey]?.manuallyAdded) {
108
+ // Project already fully registered - return existing project so frontend can navigate to it
109
+ const entry = config[projectKey];
110
+ const project = {
111
+ name: projectKey,
112
+ path: absolutePath,
113
+ fullPath: absolutePath,
114
+ displayName: entry.displayName || absolutePath.split('/').pop(),
115
+ isManuallyAdded: true,
116
+ createdAt: entry.createdAt || null,
117
+ lastActivity: entry.lastActivity || entry.createdAt || null,
118
+ sessions: []
119
+ };
120
+ return res.json({ success: true, project, existed: true });
121
+ }
122
+ // Orphan folder (folder exists but not in config as manuallyAdded) - re-register it
123
+ const project = await addProjectManually(absolutePath, null, userUuid).catch(async () => {
124
+ const existingConfig = await loadProjectConfig(userUuid);
125
+ const existingEntry = existingConfig[projectKey];
126
+ return {
127
+ name: projectKey,
128
+ path: absolutePath,
129
+ fullPath: absolutePath,
130
+ displayName: existingEntry?.displayName || absolutePath.split('/').pop(),
131
+ isManuallyAdded: true,
132
+ sessions: []
133
+ };
134
+ });
135
+ return res.json({
136
+ success: true,
137
+ project,
138
+ recovered: true,
139
+ message: 'Project folder already exists and has been re-registered successfully'
106
140
  });
107
141
  } catch (error) {
108
142
  if (error.code !== 'ENOENT') {