feat: add install hints for npm packages in SettingsTab and update shell command arguments

This commit is contained in:
Jarvis Luk 2026-04-10 00:44:47 +08:00
parent 76cedaca64
commit fd762f65c1
4 changed files with 29 additions and 74 deletions

72
package-lock.json generated
View file

@ -425,54 +425,6 @@
}
}
},
"node_modules/@docsearch/js/node_modules/@types/react": {
"version": "18.3.28",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.28.tgz",
"integrity": "sha512-z9VXpC7MWrhfWipitjNdgCauoMLRdIILQsAEV+ZesIzBq/oUlxk0m3ApZuMFCXdnS4U7KrI+l3WRUEGQ8K1QKw==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"@types/prop-types": "*",
"csstype": "^3.2.2"
}
},
"node_modules/@docsearch/js/node_modules/react": {
"version": "18.3.1",
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
"integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"loose-envify": "^1.1.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/@docsearch/js/node_modules/react-dom": {
"version": "18.3.1",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
"integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"loose-envify": "^1.1.0",
"scheduler": "^0.23.2"
},
"peerDependencies": {
"react": "^18.3.1"
}
},
"node_modules/@docsearch/js/node_modules/scheduler": {
"version": "0.23.2",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz",
"integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"loose-envify": "^1.1.0"
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.21.5",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz",
@ -1783,13 +1735,6 @@
"dev": true,
"license": "MIT"
},
"node_modules/@types/prop-types": {
"version": "15.7.15",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz",
"integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==",
"extraneous": true,
"license": "MIT"
},
"node_modules/@types/react": {
"version": "19.2.14",
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz",
@ -7373,16 +7318,6 @@
"node": ">=12"
}
},
"node_modules/vitepress/node_modules/@types/node": {
"version": "25.5.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.5.2.tgz",
"integrity": "sha512-tO4ZIRKNC+MDWV4qKVZe3Ql/woTnmHDr5JD8UI5hn2pwBrHEwOEMZK7WlNb5RKB6EoJ02gwmQS9OrjuFnZYdpg==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"undici-types": "~7.18.0"
}
},
"node_modules/vitepress/node_modules/@vitejs/plugin-vue": {
"version": "5.2.4",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.2.4.tgz",
@ -7436,13 +7371,6 @@
"@esbuild/win32-x64": "0.21.5"
}
},
"node_modules/vitepress/node_modules/undici-types": {
"version": "7.18.2",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz",
"integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==",
"extraneous": true,
"license": "MIT"
},
"node_modules/vitepress/node_modules/vite": {
"version": "5.4.21",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz",

View file

@ -842,6 +842,7 @@ export class AgentClientSettingTab extends PluginSettingTab {
this.plugin.settings.gemini.command = path;
await this.plugin.saveSettings();
});
this.addInstallHint(sectionEl, "@google/gemini-cli");
new Setting(sectionEl)
.setName("Arguments")
@ -918,6 +919,10 @@ export class AgentClientSettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
},
);
this.addInstallHint(
sectionEl,
"@agentclientprotocol/claude-agent-acp",
);
new Setting(sectionEl)
.setName("Arguments")
@ -994,6 +999,7 @@ export class AgentClientSettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
},
);
this.addInstallHint(sectionEl, "@zed-industries/codex-acp");
new Setting(sectionEl)
.setName("Arguments")
@ -1220,6 +1226,27 @@ export class AgentClientSettingTab extends PluginSettingTab {
return candidate;
}
/**
* Renders a copyable npm install command hint below a Path setting.
*/
private addInstallHint(
containerEl: HTMLElement,
npmPackage: string,
): void {
const command = `npm install -g ${npmPackage}@latest`;
const frag = document.createDocumentFragment();
frag.append("Not installed? Run in terminal: ");
frag.appendChild(document.createElement("code")).textContent = command;
new Setting(containerEl).setDesc(frag).addButton((btn) => {
btn.setButtonText("Copy").onClick(() => {
navigator.clipboard.writeText(command).then(() => {
btn.setButtonText("Copied!");
setTimeout(() => btn.setButtonText("Copy"), 1500);
});
});
});
}
/**
* Shared helper: adds an "Auto-detect" button to a Path setting.
* Calls `resolveCommandPath(commandName)` and, on success, writes the

View file

@ -46,7 +46,7 @@ export function resolveCommandPath(command: string): Promise<string | null> {
const escaped = trimmed.replace(/'/g, "'\\''");
execFile(
shell,
["-l", "-c", `which '${escaped}'`],
["-i", "-l", "-c", `which '${escaped}'`],
{ timeout: 5000 },
(err, stdout) => {
if (err) {

View file

@ -391,7 +391,7 @@ export function prepareShellCommand(
return {
command: shell,
args: ["-l", "-c", commandString],
args: ["-i", "-l", "-c", commandString],
needsShell: false,
};
}