adhdev 0.7.1 → 0.7.5
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/cli/index.js +128 -24
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +126 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -3169,7 +3169,7 @@ var init_scanner = __esm({
|
|
|
3169
3169
|
if (!manager) return;
|
|
3170
3170
|
registerExtensionProviders(this.ctx.providerLoader, manager, ide);
|
|
3171
3171
|
this.ctx.cdpManagers.set(ide, manager);
|
|
3172
|
-
LOG.info("
|
|
3172
|
+
LOG.info("IDE", `Attached: ${ide} (port ${port})`);
|
|
3173
3173
|
await setupIdeInstance(this.ctx, { ideType: ide, manager });
|
|
3174
3174
|
this.opts.onConnected?.(ide, ide, manager);
|
|
3175
3175
|
}
|
|
@@ -3202,7 +3202,7 @@ var init_scanner = __esm({
|
|
|
3202
3202
|
);
|
|
3203
3203
|
if (!manager) continue;
|
|
3204
3204
|
this.ctx.cdpManagers.set(managerKey, manager);
|
|
3205
|
-
LOG.info("
|
|
3205
|
+
LOG.info("IDE", `Attached window: ${managerKey} (port ${port}, page "${target.title}")`);
|
|
3206
3206
|
await setupIdeInstance(this.ctx, {
|
|
3207
3207
|
ideType: ide,
|
|
3208
3208
|
manager,
|
|
@@ -3256,9 +3256,9 @@ var init_initializer = __esm({
|
|
|
3256
3256
|
await this.connectIdePort(port, ide);
|
|
3257
3257
|
}
|
|
3258
3258
|
if (cdpManagers.size > 0) {
|
|
3259
|
-
LOG.info("
|
|
3259
|
+
LOG.info("IDE", `${cdpManagers.size} IDE window(s) attached: ${[...cdpManagers.entries()].map(([k, m]) => `${k}:${m.getPort()}`).join(", ")}`);
|
|
3260
3260
|
} else {
|
|
3261
|
-
LOG.warn("
|
|
3261
|
+
LOG.warn("IDE", `No IDE windows attached \u2014 tried: ${filtered.map((p) => `${p.ide}:${p.port}`).join(", ")}`);
|
|
3262
3262
|
}
|
|
3263
3263
|
}
|
|
3264
3264
|
// ─── Per-port connection (multi-window aware) ───
|
|
@@ -3284,7 +3284,7 @@ var init_initializer = __esm({
|
|
|
3284
3284
|
if (connected) {
|
|
3285
3285
|
registerExtensionProviders(providerLoader, manager, ide);
|
|
3286
3286
|
cdpManagers.set(ide, manager);
|
|
3287
|
-
LOG.info("
|
|
3287
|
+
LOG.info("IDE", `Attached: ${ide} (port ${port})`);
|
|
3288
3288
|
await this.config.onConnected?.(ide, manager, ide);
|
|
3289
3289
|
}
|
|
3290
3290
|
return;
|
|
@@ -3317,7 +3317,7 @@ var init_initializer = __esm({
|
|
|
3317
3317
|
if (connected) {
|
|
3318
3318
|
registerExtensionProviders(providerLoader, manager, ide);
|
|
3319
3319
|
cdpManagers.set(managerKey, manager);
|
|
3320
|
-
LOG.info("
|
|
3320
|
+
LOG.info("IDE", `Attached window: ${managerKey} (port ${port}${targets.length > 1 ? `, page "${target.title}"` : ""})`);
|
|
3321
3321
|
await this.config.onConnected?.(ide, manager, managerKey);
|
|
3322
3322
|
}
|
|
3323
3323
|
}
|
|
@@ -3346,7 +3346,7 @@ var init_initializer = __esm({
|
|
|
3346
3346
|
} catch {
|
|
3347
3347
|
}
|
|
3348
3348
|
this.config.cdpManagers.delete(key);
|
|
3349
|
-
LOG.info("
|
|
3349
|
+
LOG.info("IDE", `Detached window: ${key} (${reason})`);
|
|
3350
3350
|
await this.config.onDisconnected?.(ide, manager, key, reason);
|
|
3351
3351
|
}
|
|
3352
3352
|
}
|
|
@@ -4764,7 +4764,6 @@ function handleSetProviderSetting(h, args) {
|
|
|
4764
4764
|
}
|
|
4765
4765
|
async function handleExtensionScript(h, args, scriptName) {
|
|
4766
4766
|
const { agentType, ideType } = args || {};
|
|
4767
|
-
LOG.info("Command", `[ExtScript] ${scriptName} agentType=${agentType} ideType=${ideType} session=${h.currentSession?.sessionId || ""}`);
|
|
4768
4767
|
if (!agentType) return { success: false, error: "agentType is required" };
|
|
4769
4768
|
const loader = h.ctx.providerLoader;
|
|
4770
4769
|
if (!loader) return { success: false, error: "ProviderLoader not initialized" };
|
|
@@ -4990,7 +4989,75 @@ var init_workspace_commands = __esm({
|
|
|
4990
4989
|
});
|
|
4991
4990
|
|
|
4992
4991
|
// ../../oss/packages/daemon-core/src/commands/handler.ts
|
|
4993
|
-
|
|
4992
|
+
function logAtLevel(level, category, message) {
|
|
4993
|
+
switch (level) {
|
|
4994
|
+
case "debug":
|
|
4995
|
+
LOG.debug(category, message);
|
|
4996
|
+
return;
|
|
4997
|
+
case "warn":
|
|
4998
|
+
LOG.warn(category, message);
|
|
4999
|
+
return;
|
|
5000
|
+
case "error":
|
|
5001
|
+
LOG.error(category, message);
|
|
5002
|
+
return;
|
|
5003
|
+
default:
|
|
5004
|
+
LOG.info(category, message);
|
|
5005
|
+
}
|
|
5006
|
+
}
|
|
5007
|
+
function getCommandLogLevel(cmd) {
|
|
5008
|
+
return COMMAND_DEBUG_LEVELS.has(cmd) ? "debug" : "info";
|
|
5009
|
+
}
|
|
5010
|
+
function summarizeLogValue(value) {
|
|
5011
|
+
if (value === null) return "null";
|
|
5012
|
+
if (value === void 0) return "undefined";
|
|
5013
|
+
if (typeof value === "string") {
|
|
5014
|
+
const normalized = value.replace(/\s+/g, " ").trim();
|
|
5015
|
+
if (!normalized) return '""';
|
|
5016
|
+
if (normalized.length <= 80) return JSON.stringify(normalized);
|
|
5017
|
+
return `${JSON.stringify(normalized.slice(0, 80))}\u2026(${normalized.length} chars)`;
|
|
5018
|
+
}
|
|
5019
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
5020
|
+
if (Array.isArray(value)) return `[${value.length} items]`;
|
|
5021
|
+
if (typeof value === "object") return "{...}";
|
|
5022
|
+
return String(value);
|
|
5023
|
+
}
|
|
5024
|
+
function summarizeCommandArgs(args) {
|
|
5025
|
+
if (!args || typeof args !== "object") return "-";
|
|
5026
|
+
const preferredKeys = [
|
|
5027
|
+
"targetSessionId",
|
|
5028
|
+
"providerType",
|
|
5029
|
+
"agentType",
|
|
5030
|
+
"ideType",
|
|
5031
|
+
"model",
|
|
5032
|
+
"mode",
|
|
5033
|
+
"action",
|
|
5034
|
+
"button",
|
|
5035
|
+
"key",
|
|
5036
|
+
"force",
|
|
5037
|
+
"offset",
|
|
5038
|
+
"limit",
|
|
5039
|
+
"cols",
|
|
5040
|
+
"rows",
|
|
5041
|
+
"path",
|
|
5042
|
+
"command",
|
|
5043
|
+
"commandId",
|
|
5044
|
+
"workspace",
|
|
5045
|
+
"dir",
|
|
5046
|
+
"url",
|
|
5047
|
+
"text",
|
|
5048
|
+
"message",
|
|
5049
|
+
"data",
|
|
5050
|
+
"value"
|
|
5051
|
+
];
|
|
5052
|
+
const entries = [];
|
|
5053
|
+
for (const key of preferredKeys) {
|
|
5054
|
+
if (!(key in args) || args[key] === void 0) continue;
|
|
5055
|
+
const value = key === "text" || key === "message" ? `${String(args[key] || "").length} chars` : key === "data" ? `${String(args[key] || "").length} chars` : summarizeLogValue(args[key]);
|
|
5056
|
+
entries.push(`${key}=${value}`);
|
|
5057
|
+
}
|
|
5058
|
+
return entries.length ? entries.join(" ") : "{...}";
|
|
5059
|
+
}
|
|
5060
|
+
var COMMAND_DEBUG_LEVELS, DaemonCommandHandler;
|
|
4994
5061
|
var init_handler = __esm({
|
|
4995
5062
|
"../../oss/packages/daemon-core/src/commands/handler.ts"() {
|
|
4996
5063
|
"use strict";
|
|
@@ -5005,6 +5072,15 @@ var init_handler = __esm({
|
|
|
5005
5072
|
init_workspace_commands();
|
|
5006
5073
|
init_workspaces();
|
|
5007
5074
|
init_workspace_activity();
|
|
5075
|
+
COMMAND_DEBUG_LEVELS = /* @__PURE__ */ new Set([
|
|
5076
|
+
"pty_input",
|
|
5077
|
+
"pty_resize",
|
|
5078
|
+
"cdp_eval",
|
|
5079
|
+
"cdp_batch",
|
|
5080
|
+
"cdp_dom_query",
|
|
5081
|
+
"cdp_dom_dump",
|
|
5082
|
+
"cdp_dom_debug"
|
|
5083
|
+
]);
|
|
5008
5084
|
DaemonCommandHandler = class {
|
|
5009
5085
|
_ctx;
|
|
5010
5086
|
_agentStream = null;
|
|
@@ -5152,23 +5228,54 @@ var init_handler = __esm({
|
|
|
5152
5228
|
}
|
|
5153
5229
|
return void 0;
|
|
5154
5230
|
}
|
|
5231
|
+
logCommandStart(cmd, args) {
|
|
5232
|
+
const routeBits = [
|
|
5233
|
+
this._currentRoute.session?.sessionId ? `session=${this._currentRoute.session.sessionId}` : "",
|
|
5234
|
+
this._currentRoute.managerKey ? `manager=${this._currentRoute.managerKey}` : "",
|
|
5235
|
+
this._currentRoute.providerType ? `provider=${this._currentRoute.providerType}` : ""
|
|
5236
|
+
].filter(Boolean).join(" ");
|
|
5237
|
+
const summary = summarizeCommandArgs(args);
|
|
5238
|
+
logAtLevel(
|
|
5239
|
+
getCommandLogLevel(cmd),
|
|
5240
|
+
"Command",
|
|
5241
|
+
`[${cmd}] start${routeBits ? ` ${routeBits}` : ""} args=${summary}`
|
|
5242
|
+
);
|
|
5243
|
+
}
|
|
5244
|
+
logCommandEnd(cmd, result, startedAt) {
|
|
5245
|
+
const durationMs = Date.now() - startedAt;
|
|
5246
|
+
const parts = [`[${cmd}] end`, `success=${result.success}`, `duration=${durationMs}ms`];
|
|
5247
|
+
if (typeof result.error === "string" && result.error) {
|
|
5248
|
+
parts.push(`error=${JSON.stringify(result.error)}`);
|
|
5249
|
+
}
|
|
5250
|
+
const level = result.success ? getCommandLogLevel(cmd) : "warn";
|
|
5251
|
+
logAtLevel(level, "Command", parts.join(" "));
|
|
5252
|
+
}
|
|
5155
5253
|
setAgentStreamManager(manager) {
|
|
5156
5254
|
this._agentStream = manager;
|
|
5157
5255
|
}
|
|
5158
5256
|
// ─── Command Dispatcher ──────────────────────────
|
|
5159
5257
|
async handle(cmd, args) {
|
|
5160
5258
|
this._currentRoute = this.resolveRoute(args);
|
|
5259
|
+
const startedAt = Date.now();
|
|
5260
|
+
this.logCommandStart(cmd, args);
|
|
5261
|
+
let result;
|
|
5161
5262
|
if (!this._currentRoute.session && !this._currentRoute.managerKey && !this._currentRoute.providerType) {
|
|
5162
5263
|
const cdpCommands = ["send_chat", "read_chat", "list_chats", "new_chat", "switch_chat", "set_mode", "change_model", "set_thought_level", "resolve_action"];
|
|
5163
5264
|
if (cdpCommands.includes(cmd)) {
|
|
5164
|
-
|
|
5265
|
+
result = { success: false, error: "No targetSessionId specified \u2014 cannot route command" };
|
|
5266
|
+
this.logCommandEnd(cmd, result, startedAt);
|
|
5267
|
+
return result;
|
|
5165
5268
|
}
|
|
5166
5269
|
}
|
|
5167
5270
|
try {
|
|
5168
|
-
|
|
5271
|
+
result = await this.dispatch(cmd, args);
|
|
5272
|
+
this.logCommandEnd(cmd, result, startedAt);
|
|
5273
|
+
return result;
|
|
5169
5274
|
} catch (e) {
|
|
5170
5275
|
LOG.error("Command", `[${cmd}] Unhandled error: ${e?.message || e}`);
|
|
5171
|
-
|
|
5276
|
+
result = { success: false, error: `Internal error: ${e?.message || "unknown"}` };
|
|
5277
|
+
this.logCommandEnd(cmd, result, startedAt);
|
|
5278
|
+
return result;
|
|
5172
5279
|
}
|
|
5173
5280
|
}
|
|
5174
5281
|
async dispatch(cmd, args) {
|
|
@@ -41943,7 +42050,7 @@ async function initDaemonComponents(config2) {
|
|
|
41943
42050
|
const ideInstance = instanceManager.getInstance(instanceKey);
|
|
41944
42051
|
if (ideInstance) {
|
|
41945
42052
|
instanceManager.removeInstance(instanceKey);
|
|
41946
|
-
LOG.info("
|
|
42053
|
+
LOG.info("IDE", `Instance removed after detach: ${instanceKey}`);
|
|
41947
42054
|
}
|
|
41948
42055
|
if (ideInstance?.getInstanceId) {
|
|
41949
42056
|
agentStreamManager?.resetParentSession(ideInstance.getInstanceId());
|
|
@@ -42860,7 +42967,7 @@ ${e?.stack || ""}`);
|
|
|
42860
42967
|
this.notifyStateChange();
|
|
42861
42968
|
}
|
|
42862
42969
|
}
|
|
42863
|
-
/** Process
|
|
42970
|
+
/** Process unified data channel message */
|
|
42864
42971
|
handleCommandMessage(peerId, msg) {
|
|
42865
42972
|
const text = typeof msg === "string" ? msg : msg.toString("utf-8");
|
|
42866
42973
|
try {
|
|
@@ -42928,12 +43035,6 @@ ${e?.stack || ""}`);
|
|
|
42928
43035
|
}
|
|
42929
43036
|
return;
|
|
42930
43037
|
}
|
|
42931
|
-
if (parsed.type === "chat_history") {
|
|
42932
|
-
const { agent, offset, limit, id, instanceId } = parsed;
|
|
42933
|
-
const result = readChatHistory(agent || "", offset || 0, limit || 30, instanceId);
|
|
42934
|
-
this.sendToPeer(peerId, { type: "chat_history_result", id, ...result, agent });
|
|
42935
|
-
return;
|
|
42936
|
-
}
|
|
42937
43038
|
this.handleFileRequest(peerId, parsed);
|
|
42938
43039
|
} catch (e) {
|
|
42939
43040
|
log(`Parse error from peer ${peerId}: ${e?.message}`);
|
|
@@ -43495,7 +43596,7 @@ var init_adhdev_daemon = __esm({
|
|
|
43495
43596
|
fs12 = __toESM(require("fs"));
|
|
43496
43597
|
path14 = __toESM(require("path"));
|
|
43497
43598
|
import_chalk2 = __toESM(require("chalk"));
|
|
43498
|
-
pkgVersion = "0.7.
|
|
43599
|
+
pkgVersion = "0.7.5";
|
|
43499
43600
|
if (pkgVersion === "unknown") {
|
|
43500
43601
|
try {
|
|
43501
43602
|
const possiblePaths = [
|
|
@@ -43889,13 +43990,16 @@ ${err?.stack || ""}`);
|
|
|
43889
43990
|
// ─── CDP helpers ─────────────────────────────
|
|
43890
43991
|
/** Return CDP manager for specific IDE.
|
|
43891
43992
|
* Lookup order:
|
|
43892
|
-
* 1.
|
|
43893
|
-
* 2.
|
|
43993
|
+
* 1. If passed a runtime session UUID, resolve via sessionRegistry → cdpManagerKey
|
|
43994
|
+
* 2. Exact match on cdpManagers (full manager key)
|
|
43995
|
+
* 3. Prefix match on cdpManagers (ideType_workspace)
|
|
43894
43996
|
*/
|
|
43895
43997
|
getCdpFor(ideType) {
|
|
43896
43998
|
if (!this.components) return null;
|
|
43897
43999
|
const key = ideType.toLowerCase();
|
|
43898
|
-
|
|
44000
|
+
const sessionTarget = this.components.sessionRegistry.get(key);
|
|
44001
|
+
const resolvedKey = sessionTarget?.cdpManagerKey || key;
|
|
44002
|
+
return findCdpManager(this.components.cdpManagers, resolvedKey);
|
|
43899
44003
|
}
|
|
43900
44004
|
};
|
|
43901
44005
|
}
|