@ghl-ai/aw 0.1.36-beta.88 → 0.1.36-beta.90
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.
- package/commands/init.mjs +33 -14
- package/package.json +1 -1
package/commands/init.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { existsSync, mkdirSync, writeFileSync, symlinkSync, lstatSync, readdirSync, readFileSync, rmSync, realpathSync, appendFileSync } from 'node:fs';
|
|
8
8
|
import { execSync } from 'node:child_process';
|
|
9
|
-
import { join, dirname, sep } from 'node:path';
|
|
9
|
+
import { join, dirname, basename, sep } from 'node:path';
|
|
10
10
|
import { homedir } from 'node:os';
|
|
11
11
|
import { fileURLToPath } from 'node:url';
|
|
12
12
|
import * as config from '../config.mjs';
|
|
@@ -104,24 +104,43 @@ function installIdeTasks() {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
|
-
* Write .vscode/settings.json so Cursor/VS Code always treats
|
|
108
|
-
* repository
|
|
109
|
-
*
|
|
107
|
+
* Write .vscode/settings.json so Cursor/VS Code always treats ~/.aw as a git
|
|
108
|
+
* repository in the source-control panel.
|
|
109
|
+
*
|
|
110
|
+
* VS Code/Cursor does NOT follow symlinks when scanning for git repos, so
|
|
111
|
+
* `.aw/` → `~/.aw` is never auto-detected. `git.scanRepositories` is also
|
|
112
|
+
* documented as unreliable for this case.
|
|
113
|
+
*
|
|
114
|
+
* The only reliable fix: a `.code-workspace` file that adds `~/.aw` as an
|
|
115
|
+
* explicit second folder. VS Code/Cursor fully supports multi-root workspaces
|
|
116
|
+
* and will show the git panel for every folder listed there.
|
|
117
|
+
*
|
|
118
|
+
* We create/update `<project>.code-workspace` in the project root and merge
|
|
119
|
+
* `~/.aw` into its folders array without touching anything else.
|
|
110
120
|
*/
|
|
111
121
|
function installVscodeGitSettings(projectDir) {
|
|
112
122
|
if (!projectDir || projectDir === HOME) return;
|
|
113
123
|
try {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
let
|
|
118
|
-
if (existsSync(
|
|
119
|
-
try {
|
|
124
|
+
const projectName = basename(projectDir);
|
|
125
|
+
const workspacePath = join(projectDir, `${projectName}.code-workspace`);
|
|
126
|
+
|
|
127
|
+
let workspace = { folders: [], settings: {} };
|
|
128
|
+
if (existsSync(workspacePath)) {
|
|
129
|
+
try { workspace = JSON.parse(readFileSync(workspacePath, 'utf8')); } catch { /* corrupted — overwrite */ }
|
|
120
130
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
|
|
132
|
+
workspace.folders = workspace.folders || [];
|
|
133
|
+
workspace.settings = workspace.settings || {};
|
|
134
|
+
|
|
135
|
+
// Ensure project root is listed first
|
|
136
|
+
const hasRoot = workspace.folders.some(f => f.path === '.' || f.path === projectDir);
|
|
137
|
+
if (!hasRoot) workspace.folders.unshift({ path: '.' });
|
|
138
|
+
|
|
139
|
+
// Add ~/.aw as a second folder if not already present
|
|
140
|
+
const hasAw = workspace.folders.some(f => f.path === AW_HOME || f.name === 'aw registry');
|
|
141
|
+
if (!hasAw) {
|
|
142
|
+
workspace.folders.push({ path: AW_HOME, name: 'aw registry' });
|
|
143
|
+
writeFileSync(workspacePath, JSON.stringify(workspace, null, 2) + '\n');
|
|
125
144
|
}
|
|
126
145
|
} catch { /* best effort */ }
|
|
127
146
|
}
|