adhdev 0.7.15 → 0.7.17

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 CHANGED
@@ -19001,31 +19001,14 @@ var init_provider_cli_adapter = __esm({
19001
19001
  this.accumulatedRawBuffer = (this.accumulatedRawBuffer + rawData).slice(-_ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
19002
19002
  if (this.startupParseGate) {
19003
19003
  this.startupBuffer += cleanData;
19004
- const dialogPatterns = [
19005
- /Do you want to connect/i,
19006
- /Do you trust the files/i,
19007
- /Quick safety check/i,
19008
- /Is this a project/i,
19009
- /Enter to confirm/i,
19010
- /be able to read, edit, and execute/i,
19011
- /Security guide/i
19012
- ];
19013
- if (dialogPatterns.some((p) => p.test(this.startupBuffer))) {
19014
- setTimeout(() => this.ptyProcess?.write("\r"), this.timeouts.dialogAccept);
19015
- this.startupBuffer = "";
19016
- return;
19017
- }
19018
19004
  const elapsed = Date.now() - this.spawnAt;
19019
- const bufCap = this.startupBuffer.length > 12e3;
19020
19005
  const scriptStatus = this.runDetectStatus(this.startupBuffer);
19021
- const isReady = scriptStatus === "idle" || elapsed > 8e3 || bufCap;
19006
+ const isReady = scriptStatus === "idle" || scriptStatus === "waiting_approval" || elapsed > 8e3 || this.startupBuffer.length > 12e3;
19022
19007
  if (isReady) {
19023
19008
  this.startupParseGate = false;
19024
19009
  this.ready = true;
19025
- LOG.info("CLI", `[${this.cliType}] Startup gate end (${elapsed}ms, scriptStatus=${scriptStatus})`);
19010
+ LOG.info("CLI", `[${this.cliType}] Startup ready (${elapsed}ms, scriptStatus=${scriptStatus})`);
19026
19011
  this.onStatusChange?.();
19027
- } else {
19028
- return;
19029
19012
  }
19030
19013
  }
19031
19014
  this.scheduleSettle();
@@ -19233,51 +19216,6 @@ var init_provider_cli_adapter = __esm({
19233
19216
  this.onStatusChange?.();
19234
19217
  }
19235
19218
  commitCurrentTranscript() {
19236
- const baseMessages = [...this.committedMessages];
19237
- const parsed = this.parseCurrentTranscript(baseMessages, "", this.currentTurnScope);
19238
- if (parsed && Array.isArray(parsed.messages) && parsed.messages.length > 0) {
19239
- const parsedMessages = parsed.messages.filter((m) => m && (m.role === "user" || m.role === "assistant")).map((m) => ({
19240
- role: m.role,
19241
- content: typeof m.content === "string" ? m.content : String(m.content || ""),
19242
- timestamp: m.timestamp
19243
- }));
19244
- const latestAssistant = [...parsedMessages].reverse().find((m) => m.role === "assistant" && m.content.trim());
19245
- if (latestAssistant) {
19246
- LOG.info("CLI", `[${this.cliType}] commitCurrentTranscript parsed assistant len=${latestAssistant.content.length} scopePrompt=${JSON.stringify(this.currentTurnScope?.prompt || "").slice(0, 120)}`);
19247
- const nextMessages = [...baseMessages];
19248
- const last2 = nextMessages[nextMessages.length - 1];
19249
- if (last2?.role === "assistant") {
19250
- last2.content = latestAssistant.content;
19251
- last2.timestamp = latestAssistant.timestamp || last2.timestamp;
19252
- } else if (last2?.role === "user") {
19253
- nextMessages.push({
19254
- role: "assistant",
19255
- content: latestAssistant.content,
19256
- timestamp: latestAssistant.timestamp || Date.now()
19257
- });
19258
- } else {
19259
- nextMessages.push({
19260
- role: "assistant",
19261
- content: latestAssistant.content,
19262
- timestamp: latestAssistant.timestamp || Date.now()
19263
- });
19264
- }
19265
- this.committedMessages = nextMessages;
19266
- this.syncMessageViews();
19267
- return;
19268
- }
19269
- }
19270
- const fallback = String(this.responseBuffer || "").trim();
19271
- LOG.info("CLI", `[${this.cliType}] commitCurrentTranscript fallback len=${fallback.length} scopePrompt=${JSON.stringify(this.currentTurnScope?.prompt || "").slice(0, 120)}`);
19272
- if (!fallback) return;
19273
- const last = baseMessages[baseMessages.length - 1];
19274
- if (last?.role === "assistant") {
19275
- last.content = fallback;
19276
- } else {
19277
- baseMessages.push({ role: "assistant", content: fallback, timestamp: Date.now() });
19278
- }
19279
- this.committedMessages = baseMessages;
19280
- this.syncMessageViews();
19281
19219
  }
19282
19220
  // ─── Script Execution ──────────────────────────
19283
19221
  runDetectStatus(text) {
@@ -37198,7 +37136,11 @@ var init_acp_provider_instance = __esm({
37198
37136
  });
37199
37137
 
37200
37138
  // ../../oss/packages/daemon-core/src/commands/cli-manager.ts
37201
- var os14, path10, crypto4, import_chalk, DaemonCliManager;
37139
+ function colorize(color, text) {
37140
+ const fn2 = chalkApi?.[color];
37141
+ return typeof fn2 === "function" ? fn2(text) : text;
37142
+ }
37143
+ var os14, path10, crypto4, import_chalk, chalkApi, DaemonCliManager;
37202
37144
  var init_cli_manager = __esm({
37203
37145
  "../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
37204
37146
  "use strict";
@@ -37214,6 +37156,7 @@ var init_cli_manager = __esm({
37214
37156
  init_cli_provider_instance();
37215
37157
  init_acp_provider_instance();
37216
37158
  init_logger();
37159
+ chalkApi = import_chalk.default?.yellow ? import_chalk.default : import_chalk.default?.default || null;
37217
37160
  DaemonCliManager = class {
37218
37161
  adapters = /* @__PURE__ */ new Map();
37219
37162
  deps;
@@ -37233,16 +37176,16 @@ var init_cli_manager = __esm({
37233
37176
  const provider = this.providerLoader.getByAlias(cliType);
37234
37177
  const actKind = provider?.category === "acp" ? "acp" : "cli";
37235
37178
  let next = loadConfig();
37236
- console.log(import_chalk.default.cyan(` \u{1F4C2} Saving recent workspace: ${dir}`));
37179
+ console.log(colorize("cyan", ` \u{1F4C2} Saving recent workspace: ${dir}`));
37237
37180
  const recent = next.recentCliWorkspaces || [];
37238
37181
  if (!recent.includes(dir)) {
37239
37182
  next = { ...next, recentCliWorkspaces: [dir, ...recent].slice(0, 10) };
37240
37183
  }
37241
37184
  next = appendWorkspaceActivity(next, dir, { kind: actKind, agentType: normalizedType });
37242
37185
  saveConfig(next);
37243
- console.log(import_chalk.default.green(` \u2713 Recent workspace saved: ${dir}`));
37186
+ console.log(colorize("green", ` \u2713 Recent workspace saved: ${dir}`));
37244
37187
  } catch (e) {
37245
- console.error(import_chalk.default.red(` \u2717 Failed to save recent workspace: ${e}`));
37188
+ console.error(colorize("red", ` \u2717 Failed to save recent workspace: ${e}`));
37246
37189
  }
37247
37190
  }
37248
37191
  getTransportFactory(runtimeId, providerType, workspace, cliArgs, attachExisting = false) {
@@ -37258,7 +37201,7 @@ var init_cli_manager = __esm({
37258
37201
  const normalizedType = this.providerLoader.resolveAlias(cliType);
37259
37202
  const provider = this.providerLoader.getMeta(normalizedType);
37260
37203
  if (provider && provider.category === "cli" && provider.patterns && provider.spawn) {
37261
- console.log(import_chalk.default.cyan(` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
37204
+ console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
37262
37205
  const resolvedProvider = this.providerLoader.resolve(normalizedType) || provider;
37263
37206
  const transportFactory = this.getTransportFactory(runtimeId, normalizedType, workingDir, cliArgs, attachExisting);
37264
37207
  return new ProviderCliAdapter(resolvedProvider, workingDir, cliArgs, transportFactory);
@@ -37351,7 +37294,7 @@ ${installInfo}`
37351
37294
  );
37352
37295
  }
37353
37296
  }
37354
- console.log(import_chalk.default.cyan(` \u{1F50C} Starting ACP agent: ${provider.name} (${provider.type}) in ${resolvedDir}`));
37297
+ console.log(colorize("cyan", ` \u{1F50C} Starting ACP agent: ${provider.name} (${provider.type}) in ${resolvedDir}`));
37355
37298
  const acpInstance = new AcpProviderInstance(provider, resolvedDir, cliArgs);
37356
37299
  await instanceManager2.addInstance(key, acpInstance, {
37357
37300
  settings: this.providerLoader.getSettings(normalizedType)
@@ -37391,11 +37334,11 @@ ${installInfo}`
37391
37334
  setOnPtyData: () => {
37392
37335
  }
37393
37336
  });
37394
- console.log(import_chalk.default.green(` \u2713 ACP agent started: ${provider.name} in ${resolvedDir}`));
37337
+ console.log(colorize("green", ` \u2713 ACP agent started: ${provider.name} in ${resolvedDir}`));
37395
37338
  if (initialModel) {
37396
37339
  try {
37397
37340
  await acpInstance.setConfigOption("model", initialModel);
37398
- console.log(import_chalk.default.green(` \u{1F916} Initial model set: ${initialModel}`));
37341
+ console.log(colorize("green", ` \u{1F916} Initial model set: ${initialModel}`));
37399
37342
  } catch (e) {
37400
37343
  LOG.warn("CLI", `[ACP] Initial model set failed: ${e?.message}`);
37401
37344
  }
@@ -37410,9 +37353,9 @@ ${installInfo}`
37410
37353
  }
37411
37354
  const cliInfo = await detectCLI(cliType, this.providerLoader);
37412
37355
  if (!cliInfo) throw new Error(`${cliType} not found`);
37413
- console.log(import_chalk.default.yellow(` \u26A1 Starting CLI ${cliType} in ${resolvedDir}...`));
37356
+ console.log(colorize("yellow", ` \u26A1 Starting CLI ${cliType} in ${resolvedDir}...`));
37414
37357
  if (provider) {
37415
- console.log(import_chalk.default.cyan(` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
37358
+ console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
37416
37359
  }
37417
37360
  const instanceManager = this.deps.getInstanceManager();
37418
37361
  if (provider && instanceManager) {
@@ -37427,7 +37370,7 @@ ${installInfo}`
37427
37370
  {},
37428
37371
  false
37429
37372
  );
37430
- console.log(import_chalk.default.green(` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
37373
+ console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
37431
37374
  } else {
37432
37375
  const adapter = this.createAdapter(cliType, resolvedDir, cliArgs, key, false);
37433
37376
  try {
@@ -37460,7 +37403,7 @@ ${installInfo}`
37460
37403
  });
37461
37404
  }
37462
37405
  this.adapters.set(key, adapter);
37463
- console.log(import_chalk.default.green(` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
37406
+ console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
37464
37407
  }
37465
37408
  try {
37466
37409
  addCliHistory({ category: "cli", cliType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
@@ -37622,7 +37565,7 @@ ${installInfo}`
37622
37565
  if (found) {
37623
37566
  await this.stopSessionWithMode(found.key, mode);
37624
37567
  } else {
37625
- console.log(import_chalk.default.yellow(` \u26A0 No adapter found for ${cliType}`));
37568
+ console.log(colorize("yellow", ` \u26A0 No adapter found for ${cliType}`));
37626
37569
  }
37627
37570
  return { success: true, cliType, dir, stopped: true, mode };
37628
37571
  }
@@ -44400,7 +44343,7 @@ var init_adhdev_daemon = __esm({
44400
44343
  fs14 = __toESM(require("fs"));
44401
44344
  path16 = __toESM(require("path"));
44402
44345
  import_chalk2 = __toESM(require("chalk"));
44403
- pkgVersion = "0.7.15";
44346
+ pkgVersion = "0.7.17";
44404
44347
  if (pkgVersion === "unknown") {
44405
44348
  try {
44406
44349
  const possiblePaths = [