adhdev 0.1.23 → 0.1.24
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/dist/index.js +109 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -74,10 +74,10 @@ function getIdeVersion(cliCommand) {
|
|
|
74
74
|
function checkPathExists(paths) {
|
|
75
75
|
for (const p of paths) {
|
|
76
76
|
if (p.includes("*")) {
|
|
77
|
-
const
|
|
77
|
+
const home = (0, import_os.homedir)();
|
|
78
78
|
const starIdx = p.indexOf("*");
|
|
79
79
|
const suffix = p.substring(starIdx + 1);
|
|
80
|
-
const homeNormalized =
|
|
80
|
+
const homeNormalized = home.replace(/\//g, "\\\\");
|
|
81
81
|
const resolved = homeNormalized + suffix;
|
|
82
82
|
if ((0, import_fs.existsSync)(resolved)) return resolved;
|
|
83
83
|
} else {
|
|
@@ -326,7 +326,8 @@ var init_config = __esm({
|
|
|
326
326
|
setupCompleted: false,
|
|
327
327
|
setupDate: null,
|
|
328
328
|
configuredCLIs: [],
|
|
329
|
-
enabledIdes: []
|
|
329
|
+
enabledIdes: [],
|
|
330
|
+
recentCliWorkspaces: []
|
|
330
331
|
};
|
|
331
332
|
}
|
|
332
333
|
});
|
|
@@ -1766,6 +1767,14 @@ var init_local_server = __esm({
|
|
|
1766
1767
|
}
|
|
1767
1768
|
break;
|
|
1768
1769
|
}
|
|
1770
|
+
case "ext:command": {
|
|
1771
|
+
const ext = this.extensions.get(ws);
|
|
1772
|
+
if (ext) {
|
|
1773
|
+
ext.lastSeen = Date.now();
|
|
1774
|
+
this.options.onCommand?.(ext, msg.payload.command, msg.payload.args, msg.id);
|
|
1775
|
+
}
|
|
1776
|
+
break;
|
|
1777
|
+
}
|
|
1769
1778
|
}
|
|
1770
1779
|
}
|
|
1771
1780
|
/**
|
|
@@ -3330,9 +3339,6 @@ var init_daemon_script_loader = __esm({
|
|
|
3330
3339
|
});
|
|
3331
3340
|
|
|
3332
3341
|
// src/daemon-commands.ts
|
|
3333
|
-
function home() {
|
|
3334
|
-
return os7.homedir();
|
|
3335
|
-
}
|
|
3336
3342
|
var fs4, path3, os7, DaemonCommandHandler;
|
|
3337
3343
|
var init_daemon_commands = __esm({
|
|
3338
3344
|
"src/daemon-commands.ts"() {
|
|
@@ -3340,6 +3346,7 @@ var init_daemon_commands = __esm({
|
|
|
3340
3346
|
fs4 = __toESM(require("fs"));
|
|
3341
3347
|
path3 = __toESM(require("path"));
|
|
3342
3348
|
os7 = __toESM(require("os"));
|
|
3349
|
+
init_config();
|
|
3343
3350
|
DaemonCommandHandler = class {
|
|
3344
3351
|
ctx;
|
|
3345
3352
|
agentStream = null;
|
|
@@ -3487,6 +3494,21 @@ var init_daemon_commands = __esm({
|
|
|
3487
3494
|
async handleSendChat(args) {
|
|
3488
3495
|
const text = args?.text || args?.message;
|
|
3489
3496
|
if (!text) return { success: false, error: "text required" };
|
|
3497
|
+
const targetAgent = args?.agentType || args?.cliType || this._currentIdeType;
|
|
3498
|
+
if (targetAgent) {
|
|
3499
|
+
for (const [key, adapter] of this.ctx.adapters.entries()) {
|
|
3500
|
+
if (adapter.cliType === targetAgent || key.startsWith(targetAgent)) {
|
|
3501
|
+
console.log(`[send_chat] Routing to CLI adapter: ${adapter.cliType} (${key})`);
|
|
3502
|
+
try {
|
|
3503
|
+
await adapter.sendMessage(text);
|
|
3504
|
+
return { success: true, sent: true, targetAgent: adapter.cliType };
|
|
3505
|
+
} catch (e) {
|
|
3506
|
+
console.log(`[send_chat] CLI adapter failed: ${e.message}`);
|
|
3507
|
+
return { success: false, error: `CLI send failed: ${e.message}` };
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
}
|
|
3490
3512
|
const targetCdp = this.getCdp();
|
|
3491
3513
|
const targetLoader = this.getScriptLoader();
|
|
3492
3514
|
if (targetCdp?.isConnected && targetLoader) {
|
|
@@ -3516,7 +3538,7 @@ var init_daemon_commands = __esm({
|
|
|
3516
3538
|
console.log(`[send_chat] Failed on ${ideType}: ${e.message}`);
|
|
3517
3539
|
}
|
|
3518
3540
|
}
|
|
3519
|
-
return { success: false, error: "No CDP could send the message" };
|
|
3541
|
+
return { success: false, error: "No CDP or CLI adapter could send the message" };
|
|
3520
3542
|
}
|
|
3521
3543
|
async handleListChats(args) {
|
|
3522
3544
|
const cdp = this.getCdp();
|
|
@@ -3792,10 +3814,10 @@ var init_daemon_commands = __esm({
|
|
|
3792
3814
|
return this.handleFileList(args);
|
|
3793
3815
|
}
|
|
3794
3816
|
resolveSafePath(requestedPath) {
|
|
3795
|
-
const
|
|
3817
|
+
const home = os7.homedir();
|
|
3796
3818
|
let resolved;
|
|
3797
3819
|
if (requestedPath.startsWith("~")) {
|
|
3798
|
-
resolved = path3.join(
|
|
3820
|
+
resolved = path3.join(home, requestedPath.slice(1));
|
|
3799
3821
|
} else if (path3.isAbsolute(requestedPath)) {
|
|
3800
3822
|
resolved = requestedPath;
|
|
3801
3823
|
} else {
|
|
@@ -3812,18 +3834,24 @@ var init_daemon_commands = __esm({
|
|
|
3812
3834
|
}
|
|
3813
3835
|
// ─── 기타 ───────────────────────────────────
|
|
3814
3836
|
async handleGetRecentWorkspaces(args) {
|
|
3837
|
+
const config = loadConfig();
|
|
3838
|
+
const cliRecent = config.recentCliWorkspaces || [];
|
|
3815
3839
|
try {
|
|
3816
|
-
const storageDir = path3.join(
|
|
3840
|
+
const storageDir = path3.join(os7.homedir(), "Library", "Application Support");
|
|
3817
3841
|
const candidates = ["Cursor", "Code", "VSCodium"];
|
|
3818
3842
|
for (const app of candidates) {
|
|
3819
3843
|
const stateFile = path3.join(storageDir, app, "User", "globalStorage", "state.vscdb");
|
|
3820
3844
|
if (fs4.existsSync(stateFile)) {
|
|
3821
|
-
|
|
3845
|
+
const result = await this.delegateToExtension("adhdev.getRecentWorkspaces", []);
|
|
3846
|
+
if (result.success && Array.isArray(result.result)) {
|
|
3847
|
+
const merged = Array.from(/* @__PURE__ */ new Set([...cliRecent, ...result.result])).slice(0, 20);
|
|
3848
|
+
return { success: true, result: merged };
|
|
3849
|
+
}
|
|
3822
3850
|
}
|
|
3823
3851
|
}
|
|
3824
|
-
return
|
|
3852
|
+
return { success: true, result: cliRecent };
|
|
3825
3853
|
} catch {
|
|
3826
|
-
return
|
|
3854
|
+
return { success: true, result: cliRecent };
|
|
3827
3855
|
}
|
|
3828
3856
|
}
|
|
3829
3857
|
async handleRefreshScripts(args) {
|
|
@@ -4560,6 +4588,17 @@ var init_adhdev_daemon = __esm({
|
|
|
4560
4588
|
});
|
|
4561
4589
|
}
|
|
4562
4590
|
}
|
|
4591
|
+
},
|
|
4592
|
+
onCommand: async (ext, command, args, messageId) => {
|
|
4593
|
+
const mockMsg = {
|
|
4594
|
+
id: messageId || `ext_${Date.now()}`,
|
|
4595
|
+
type: "ext:command",
|
|
4596
|
+
payload: args,
|
|
4597
|
+
metadata: { ideType: ext.ideType, instanceId: ext.instanceId },
|
|
4598
|
+
ipcWs: ext.ws
|
|
4599
|
+
// 응답을 위해 저장
|
|
4600
|
+
};
|
|
4601
|
+
await this.handleCommand(mockMsg, command, args);
|
|
4563
4602
|
}
|
|
4564
4603
|
});
|
|
4565
4604
|
try {
|
|
@@ -4594,7 +4633,8 @@ var init_adhdev_daemon = __esm({
|
|
|
4594
4633
|
cdpManagers: this.cdpManagers,
|
|
4595
4634
|
scriptLoaders: this.scriptLoaders,
|
|
4596
4635
|
localServer: this.localServer,
|
|
4597
|
-
ideType: this.ideType
|
|
4636
|
+
ideType: this.ideType,
|
|
4637
|
+
adapters: this.adapters
|
|
4598
4638
|
});
|
|
4599
4639
|
this.agentStreamManager = new DaemonAgentStreamManager(
|
|
4600
4640
|
console.log,
|
|
@@ -4757,6 +4797,8 @@ var init_adhdev_daemon = __esm({
|
|
|
4757
4797
|
"exec_command",
|
|
4758
4798
|
"launch_cli",
|
|
4759
4799
|
"stop_cli",
|
|
4800
|
+
"agent_command",
|
|
4801
|
+
// Added agent_command here
|
|
4760
4802
|
// Extension-delegated commands (must be registered to receive WS messages)
|
|
4761
4803
|
"vscode_command_exec",
|
|
4762
4804
|
"execute_vscode_command",
|
|
@@ -4799,10 +4841,48 @@ var init_adhdev_daemon = __esm({
|
|
|
4799
4841
|
const key = this.getCliKey(cliType, dir);
|
|
4800
4842
|
if (!this.adapters.has(key)) {
|
|
4801
4843
|
await this.startCliSession(cliType, dir);
|
|
4844
|
+
try {
|
|
4845
|
+
const config = loadConfig();
|
|
4846
|
+
console.log(import_chalk2.default.cyan(` \u{1F4C2} Saving recent workspace: ${dir}`));
|
|
4847
|
+
const recent = config.recentCliWorkspaces || [];
|
|
4848
|
+
if (!recent.includes(dir)) {
|
|
4849
|
+
const updated = [dir, ...recent].slice(0, 10);
|
|
4850
|
+
saveConfig({ ...config, recentCliWorkspaces: updated });
|
|
4851
|
+
console.log(import_chalk2.default.green(` \u2713 Recent workspace saved: ${dir}`));
|
|
4852
|
+
}
|
|
4853
|
+
} catch (e) {
|
|
4854
|
+
console.error(import_chalk2.default.red(` \u2717 Failed to save recent workspace: ${e}`));
|
|
4855
|
+
}
|
|
4802
4856
|
}
|
|
4803
4857
|
this.sendResult(msg, true, { cliType, dir, id: key });
|
|
4804
4858
|
return;
|
|
4805
4859
|
}
|
|
4860
|
+
case "agent_command": {
|
|
4861
|
+
const agentType = args?.agentType || args?.cliType;
|
|
4862
|
+
const dir = args?.dir || process.cwd();
|
|
4863
|
+
const action = args?.action;
|
|
4864
|
+
if (!agentType || !action) throw new Error("agentType and action required");
|
|
4865
|
+
const key = this.getCliKey(agentType, dir);
|
|
4866
|
+
const adapter = this.adapters.get(key);
|
|
4867
|
+
if (!adapter) throw new Error(`CLI agent not running for ${key}`);
|
|
4868
|
+
if (action === "send_chat") {
|
|
4869
|
+
const message = args.message || args.text;
|
|
4870
|
+
if (!message) throw new Error("message required for send_chat");
|
|
4871
|
+
await adapter.sendMessage(message);
|
|
4872
|
+
this.sendResult(msg, true, { status: "generating" });
|
|
4873
|
+
} else if (action === "clear_history") {
|
|
4874
|
+
if (typeof adapter.clearHistory === "function") {
|
|
4875
|
+
adapter.clearHistory();
|
|
4876
|
+
}
|
|
4877
|
+
this.sendResult(msg, true, { cleared: true });
|
|
4878
|
+
} else if (action === "stop") {
|
|
4879
|
+
await this.stopCliSession(key);
|
|
4880
|
+
this.sendResult(msg, true, { stopped: true });
|
|
4881
|
+
} else {
|
|
4882
|
+
throw new Error(`Unknown action: ${action}`);
|
|
4883
|
+
}
|
|
4884
|
+
return;
|
|
4885
|
+
}
|
|
4806
4886
|
case "stop_cli": {
|
|
4807
4887
|
const cliType = args?.cliType;
|
|
4808
4888
|
const dir = args?.dir || process.cwd();
|
|
@@ -5163,6 +5243,17 @@ var init_adhdev_daemon = __esm({
|
|
|
5163
5243
|
}
|
|
5164
5244
|
sendResult(msg, success, extra) {
|
|
5165
5245
|
if (!msg.id) return;
|
|
5246
|
+
if (msg.ipcWs && this.localServer) {
|
|
5247
|
+
msg.ipcWs.send(JSON.stringify({
|
|
5248
|
+
type: "daemon:command_result",
|
|
5249
|
+
// 프로토콜은 아니지만 테스트용/확장용으로 추가
|
|
5250
|
+
payload: {
|
|
5251
|
+
requestId: msg.id,
|
|
5252
|
+
success,
|
|
5253
|
+
...extra
|
|
5254
|
+
}
|
|
5255
|
+
}));
|
|
5256
|
+
}
|
|
5166
5257
|
this.bridge?.sendMessage("command_result", {
|
|
5167
5258
|
requestId: msg.id,
|
|
5168
5259
|
success,
|
|
@@ -6528,14 +6619,14 @@ async function injectTokenToIDE(ide, connectionToken) {
|
|
|
6528
6619
|
const fs7 = await import("fs");
|
|
6529
6620
|
const path6 = await import("path");
|
|
6530
6621
|
const platform9 = os10.platform();
|
|
6531
|
-
const
|
|
6622
|
+
const home = os10.homedir();
|
|
6532
6623
|
const getSettingsPath = (appName2) => {
|
|
6533
6624
|
if (platform9 === "darwin") {
|
|
6534
|
-
return path6.join(
|
|
6625
|
+
return path6.join(home, "Library", "Application Support", appName2, "User", "settings.json");
|
|
6535
6626
|
} else if (platform9 === "win32") {
|
|
6536
|
-
return path6.join(process.env.APPDATA || path6.join(
|
|
6627
|
+
return path6.join(process.env.APPDATA || path6.join(home, "AppData", "Roaming"), appName2, "User", "settings.json");
|
|
6537
6628
|
} else {
|
|
6538
|
-
return path6.join(
|
|
6629
|
+
return path6.join(home, ".config", appName2, "User", "settings.json");
|
|
6539
6630
|
}
|
|
6540
6631
|
};
|
|
6541
6632
|
const appNameMap = {
|