archicore 0.1.6 → 0.1.7

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.
@@ -367,7 +367,64 @@ async function handleIndexCommand() {
367
367
  });
368
368
  if (!response.ok) {
369
369
  const errorData = await response.json().catch(() => ({}));
370
- throw new Error(errorData.error || 'Upload failed');
370
+ // If access denied, re-register project with current user
371
+ if (response.status === 403 && errorData.error?.includes('Access denied')) {
372
+ indexSpinner.update('Re-registering project with current user...');
373
+ // Clear old project ID and re-register
374
+ const reRegisterResponse = await fetch(`${config.serverUrl}/api/projects`, {
375
+ method: 'POST',
376
+ headers: {
377
+ 'Content-Type': 'application/json',
378
+ 'Authorization': `Bearer ${config.accessToken}`,
379
+ },
380
+ body: JSON.stringify({ name: state.projectName, path: state.projectPath }),
381
+ });
382
+ if (reRegisterResponse.ok) {
383
+ const reData = await reRegisterResponse.json();
384
+ state.projectId = reData.id || reData.project?.id;
385
+ // Retry upload with new project ID
386
+ indexSpinner.update('Uploading to server...');
387
+ const retryResponse = await fetch(`${config.serverUrl}/api/projects/${state.projectId}/upload-index`, {
388
+ method: 'POST',
389
+ headers: {
390
+ 'Content-Type': 'application/json',
391
+ 'Authorization': `Bearer ${config.accessToken}`,
392
+ },
393
+ body: JSON.stringify({
394
+ asts: astsArray,
395
+ symbols: symbolsArray,
396
+ graph: graphData,
397
+ fileContents,
398
+ statistics: {
399
+ totalFiles: asts.size,
400
+ totalSymbols: symbols.size,
401
+ },
402
+ }),
403
+ });
404
+ if (!retryResponse.ok) {
405
+ throw new Error('Upload failed after re-registration');
406
+ }
407
+ // Use retry response for data
408
+ const retryData = await retryResponse.json();
409
+ indexSpinner.succeed('Project re-registered and indexed');
410
+ printKeyValue('Files', String(retryData.statistics?.filesCount || asts.size));
411
+ printKeyValue('Symbols', String(retryData.statistics?.symbolsCount || symbols.size));
412
+ // Update local config with new project ID
413
+ const localProjectRetry = await getLocalProject(state.projectPath);
414
+ if (localProjectRetry && state.projectId) {
415
+ localProjectRetry.id = state.projectId;
416
+ localProjectRetry.indexed = true;
417
+ await fs.writeFile(pathModule.default.join(state.projectPath, '.archicore', 'project.json'), JSON.stringify(localProjectRetry, null, 2));
418
+ }
419
+ return; // Exit early - already handled
420
+ }
421
+ else {
422
+ throw new Error('Failed to re-register project');
423
+ }
424
+ }
425
+ else {
426
+ throw new Error(errorData.error || 'Upload failed');
427
+ }
371
428
  }
372
429
  const data = await response.json();
373
430
  indexSpinner.succeed('Project indexed and uploaded');
@@ -78,12 +78,17 @@ apiRouter.get('/projects/:id', authMiddleware, async (req, res) => {
78
78
  async function checkProjectAccess(req, res, next) {
79
79
  const { id } = req.params;
80
80
  const userId = getUserId(req);
81
+ Logger.info(`checkProjectAccess: projectId=${id}, userId=${userId}`);
81
82
  if (!userId) {
82
83
  res.status(401).json({ error: 'Authentication required' });
83
84
  return;
84
85
  }
85
86
  const isOwner = await projectService.isProjectOwner(id, userId);
87
+ Logger.info(`checkProjectAccess: isOwner=${isOwner}`);
86
88
  if (!isOwner) {
89
+ // Log project details for debugging
90
+ const project = await projectService.getProject(id);
91
+ Logger.warn(`Access denied: userId=${userId}, project.ownerId=${project?.ownerId}`);
87
92
  res.status(403).json({ error: 'Access denied to this project' });
88
93
  return;
89
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archicore",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "AI Software Architect - code analysis, impact prediction, semantic search",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",