svharness 0.14.13 → 0.14.16
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.
|
Binary file
|
|
@@ -3,6 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveShellMenuIconSourcePath = resolveShellMenuIconSourcePath;
|
|
7
|
+
exports.installShellMenuIcon = installShellMenuIcon;
|
|
6
8
|
exports.resolveLaunchScriptPath = resolveLaunchScriptPath;
|
|
7
9
|
exports.resolveWindowsTerminalPath = resolveWindowsTerminalPath;
|
|
8
10
|
exports.runShellInstall = runShellInstall;
|
|
@@ -19,6 +21,8 @@ const win_registry_1 = require("../lib/win-registry");
|
|
|
19
21
|
const STUB_DIR = path_1.default.join(process.env.LOCALAPPDATA ?? path_1.default.join(os_1.default.homedir(), 'AppData', 'Local'), 'svharness', 'bin');
|
|
20
22
|
const STUB_PATH = path_1.default.join(STUB_DIR, 'launch_codechat_cli.ps1');
|
|
21
23
|
const LEGACY_STUB_PATH = path_1.default.join(STUB_DIR, 'launch_codechat_cli.cmd');
|
|
24
|
+
const ICON_FILENAME = 'codechat-agent.ico';
|
|
25
|
+
const ICON_STUB_PATH = path_1.default.join(STUB_DIR, ICON_FILENAME);
|
|
22
26
|
function logInfo(msg, silent) {
|
|
23
27
|
if (!silent)
|
|
24
28
|
logger_1.logger.info(msg);
|
|
@@ -36,6 +40,28 @@ function assertWin32() {
|
|
|
36
40
|
'Linux/macOS 请使用:launch_codechat_cli 或 svharness start-agent --work-dir <path>');
|
|
37
41
|
}
|
|
38
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolve bundled context-menu icon from the installed package.
|
|
45
|
+
*/
|
|
46
|
+
function resolveShellMenuIconSourcePath() {
|
|
47
|
+
const fromDist = path_1.default.resolve(__dirname, '..', '..', 'assets', ICON_FILENAME);
|
|
48
|
+
if (fs_extra_1.default.existsSync(fromDist)) {
|
|
49
|
+
return fromDist;
|
|
50
|
+
}
|
|
51
|
+
const fromCwd = path_1.default.resolve(__dirname, '..', '..', '..', 'assets', ICON_FILENAME);
|
|
52
|
+
if (fs_extra_1.default.existsSync(fromCwd)) {
|
|
53
|
+
return fromCwd;
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`未找到 ${ICON_FILENAME}(预期:${fromDist})`);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Copy icon to LOCALAPPDATA stub dir; return registry Icon value (`path,0`).
|
|
59
|
+
*/
|
|
60
|
+
async function installShellMenuIcon() {
|
|
61
|
+
const source = resolveShellMenuIconSourcePath();
|
|
62
|
+
await fs_extra_1.default.copy(source, ICON_STUB_PATH, { overwrite: true });
|
|
63
|
+
return `${ICON_STUB_PATH},0`;
|
|
64
|
+
}
|
|
39
65
|
/**
|
|
40
66
|
* Resolve absolute path to bin/launch-codechat-cli.js in the installed package.
|
|
41
67
|
*/
|
|
@@ -121,8 +147,9 @@ function buildMenuCommand(ps1Path, dirPlaceholder, wtPath) {
|
|
|
121
147
|
}
|
|
122
148
|
return `powershell.exe ${psArgs}`;
|
|
123
149
|
}
|
|
124
|
-
function registerMenuKey(menuKey, command) {
|
|
150
|
+
function registerMenuKey(menuKey, command, iconValue) {
|
|
125
151
|
(0, win_registry_1.regSetDefault)(menuKey, win_registry_1.SHELL_MENU_LABEL);
|
|
152
|
+
(0, win_registry_1.regSetString)(menuKey, 'Icon', iconValue);
|
|
126
153
|
(0, win_registry_1.regSetDefault)(`${menuKey}\\command`, command);
|
|
127
154
|
}
|
|
128
155
|
/**
|
|
@@ -136,14 +163,16 @@ async function runShellInstall(opts = {}) {
|
|
|
136
163
|
if (await fs_extra_1.default.pathExists(LEGACY_STUB_PATH)) {
|
|
137
164
|
await fs_extra_1.default.remove(LEGACY_STUB_PATH);
|
|
138
165
|
}
|
|
166
|
+
const iconValue = await installShellMenuIcon();
|
|
139
167
|
const wtPath = resolveWindowsTerminalPath();
|
|
140
168
|
const bgCommand = buildMenuCommand(STUB_PATH, '"%V"', wtPath);
|
|
141
169
|
const dirCommand = buildMenuCommand(STUB_PATH, '"%1"', wtPath);
|
|
142
|
-
registerMenuKey(win_registry_1.SHELL_MENU_KEY_BG, bgCommand);
|
|
143
|
-
registerMenuKey(win_registry_1.SHELL_MENU_KEY_DIR, dirCommand);
|
|
170
|
+
registerMenuKey(win_registry_1.SHELL_MENU_KEY_BG, bgCommand, iconValue);
|
|
171
|
+
registerMenuKey(win_registry_1.SHELL_MENU_KEY_DIR, dirCommand, iconValue);
|
|
144
172
|
const via = wtPath ? 'Windows Terminal' : 'PowerShell(UTF-8)';
|
|
145
173
|
logSuccess(`Windows 右键菜单已注册:「在此启动 CodeChat Agent」(${via})`, opts.silent);
|
|
146
174
|
logInfo(` stub: ${STUB_PATH}`, opts.silent);
|
|
175
|
+
logInfo(` icon: ${ICON_STUB_PATH}`, opts.silent);
|
|
147
176
|
logInfo(` 脚本: ${launchScriptPath}`, opts.silent);
|
|
148
177
|
if (wtPath) {
|
|
149
178
|
logInfo(` wt: ${wtPath}`, opts.silent);
|
|
@@ -159,6 +188,9 @@ async function runShellUninstall(opts = {}) {
|
|
|
159
188
|
if (await fs_extra_1.default.pathExists(STUB_PATH)) {
|
|
160
189
|
await fs_extra_1.default.remove(STUB_PATH);
|
|
161
190
|
}
|
|
191
|
+
if (await fs_extra_1.default.pathExists(ICON_STUB_PATH)) {
|
|
192
|
+
await fs_extra_1.default.remove(ICON_STUB_PATH);
|
|
193
|
+
}
|
|
162
194
|
if (await fs_extra_1.default.pathExists(LEGACY_STUB_PATH)) {
|
|
163
195
|
await fs_extra_1.default.remove(LEGACY_STUB_PATH);
|
|
164
196
|
}
|
package/dist/lib/win-registry.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SHELL_MENU_LABEL = exports.SHELL_MENU_KEY_DIR = exports.SHELL_MENU_KEY_BG = void 0;
|
|
4
4
|
exports.regSetDefault = regSetDefault;
|
|
5
|
+
exports.regSetString = regSetString;
|
|
5
6
|
exports.regDeleteKey = regDeleteKey;
|
|
6
7
|
exports.regKeyExists = regKeyExists;
|
|
7
8
|
const child_process_1 = require("child_process");
|
|
@@ -18,6 +19,15 @@ function regSetDefault(key, value) {
|
|
|
18
19
|
windowsHide: true,
|
|
19
20
|
});
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Set a named REG_SZ value on a registry key.
|
|
24
|
+
*/
|
|
25
|
+
function regSetString(key, name, value) {
|
|
26
|
+
(0, child_process_1.execSync)(`"${REG}" add "${key}" /v "${name}" /t REG_SZ /d "${quoteRegData(value)}" /f`, {
|
|
27
|
+
stdio: 'pipe',
|
|
28
|
+
windowsHide: true,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
21
31
|
/**
|
|
22
32
|
* Delete a registry key and subkeys.
|
|
23
33
|
*/
|
|
@@ -200,6 +200,14 @@ stub 接收 Explorer 传入的目录参数,`cd` 后调用 **绝对路径** 的
|
|
|
200
200
|
|
|
201
201
|
菜单标题:`在此启动 CodeChat CLI`
|
|
202
202
|
|
|
203
|
+
Icon(两处菜单键均设置):
|
|
204
|
+
|
|
205
|
+
```text
|
|
206
|
+
C:\Users\<user>\AppData\Local\svharness\bin\codechat-agent.ico,0
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
源文件:`assets/codechat-agent.ico`(圆角边框 + `>_` 终端提示符;可用 `scripts/generate-shell-icon.ps1` 重新生成)。
|
|
210
|
+
|
|
203
211
|
Command(Background,已安装 WT 时):
|
|
204
212
|
|
|
205
213
|
```text
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svharness",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.16",
|
|
4
4
|
"description": "CLI scaffolder for SDD-Driven Agent-Agnostic Coding Framework (harness)",
|
|
5
5
|
"bin": {
|
|
6
6
|
"svharness": "./bin/cli.js",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"dist/",
|
|
12
12
|
"bin/",
|
|
13
13
|
"docs/",
|
|
14
|
+
"assets/",
|
|
14
15
|
"scripts/postinstall.js",
|
|
15
16
|
"scripts/preuninstall.js",
|
|
16
17
|
"templates/",
|