minovative-mind-cli 1.1.3 → 1.1.4

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.
@@ -6,6 +6,7 @@ import * as p from '@clack/prompts';
6
6
  import pc from 'picocolors';
7
7
  import { startAgentLoop } from '../services/agent.js';
8
8
  import { getAuthorizedIdToken, login } from '../services/auth.js';
9
+ import { updateWorkspaceStatus } from '../services/workspace.js';
9
10
  export default class DefaultCommand extends Command {
10
11
  static description = 'Start an interactive AI coding agent session powered by Vertex AI.';
11
12
  static examples = ['<%= config.bin %>', '<%= config.bin %> --help'];
@@ -30,6 +31,10 @@ export default class DefaultCommand extends Command {
30
31
  }
31
32
  p.log.info(`${pc.dim('Workspace:')} ${pc.cyan(workspaceRoot)}`);
32
33
  p.log.info(`${pc.dim('Commands:')} Type ${pc.yellow('/')} to open the command menu and "${pc.yellow('stop')}" to stop the ai generation. Type ${pc.yellow('exit')} to leave.`);
34
+ // Update workspace status in the background
35
+ if (idToken) {
36
+ updateWorkspaceStatus(idToken, workspaceRoot).catch(() => { });
37
+ }
33
38
  await startAgentLoop(workspaceRoot, this.config.version);
34
39
  }
35
40
  }
@@ -0,0 +1 @@
1
+ export declare function updateWorkspaceStatus(idToken: string, workspaceRoot: string): Promise<void>;
@@ -0,0 +1,51 @@
1
+ import * as path from 'path';
2
+ import { debugLog } from '../utils/logger.js';
3
+ export async function updateWorkspaceStatus(idToken, workspaceRoot) {
4
+ try {
5
+ // 1. Decode JWT to get user_id (uid)
6
+ const payloadBase64 = idToken.split('.')[1];
7
+ if (!payloadBase64)
8
+ return;
9
+ const payloadRaw = Buffer.from(payloadBase64, 'base64').toString('utf8');
10
+ const payload = JSON.parse(payloadRaw);
11
+ const uid = payload.user_id;
12
+ if (!uid)
13
+ return;
14
+ // 2. Generate a URL-safe ID for the workspace based on its path
15
+ const workspaceId = Buffer.from(workspaceRoot)
16
+ .toString('base64')
17
+ .replace(/\//g, '_')
18
+ .replace(/\+/g, '-')
19
+ .replace(/=/g, '');
20
+ // 3. Prepare the Firestore REST API payload
21
+ const url = `https://firestore.googleapis.com/v1/projects/minovative-mind-prod/databases/(default)/documents/users/${uid}/projects/${workspaceId}?updateMask.fieldPaths=name&updateMask.fieldPaths=path&updateMask.fieldPaths=workspacePath&updateMask.fieldPaths=lastUsed`;
22
+ const body = {
23
+ name: `projects/minovative-mind-prod/databases/(default)/documents/users/${uid}/projects/${workspaceId}`,
24
+ fields: {
25
+ name: { stringValue: path.basename(workspaceRoot) },
26
+ path: { stringValue: workspaceRoot },
27
+ workspacePath: { stringValue: workspaceRoot },
28
+ lastUsed: { timestampValue: new Date().toISOString() },
29
+ },
30
+ };
31
+ // 4. Send the PATCH request
32
+ const response = await fetch(url, {
33
+ method: 'PATCH',
34
+ headers: {
35
+ Authorization: `Bearer ${idToken}`,
36
+ 'Content-Type': 'application/json',
37
+ },
38
+ body: JSON.stringify(body),
39
+ });
40
+ if (!response.ok) {
41
+ const errorText = await response.text();
42
+ debugLog(`Failed to update workspace status: ${response.status} ${errorText}`);
43
+ }
44
+ else {
45
+ debugLog(`Workspace status updated successfully for ${workspaceRoot}`);
46
+ }
47
+ }
48
+ catch (error) {
49
+ debugLog(`Error updating workspace status: ${error.message}`);
50
+ }
51
+ }
@@ -65,5 +65,5 @@
65
65
  ]
66
66
  }
67
67
  },
68
- "version": "1.1.3"
68
+ "version": "1.1.4"
69
69
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minovative-mind-cli",
3
3
  "description": "An automated AI agent powered by Vertex AI that helps you write software",
4
- "version": "1.1.3",
4
+ "version": "1.1.4",
5
5
  "author": "Daniel Ward",
6
6
  "bin": {
7
7
  "minovative-mind-cli": "./bin/run.js"