adhdev 0.6.19 → 0.6.21

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 CHANGED
@@ -4990,6 +4990,15 @@ var init_handler = __esm({
4990
4990
  return handleExtensionScript(this, args, "listModes");
4991
4991
  case "set_extension_mode":
4992
4992
  return handleExtensionScript(this, args, "setMode");
4993
+ // ─── Provider Auto-Fix / Clone (DevServer proxy) ──────────
4994
+ case "provider_auto_fix":
4995
+ return this.proxyDevServerPost(args, "auto-implement");
4996
+ case "provider_auto_fix_cancel":
4997
+ return this.proxyDevServerPost(args, "auto-implement/cancel");
4998
+ case "provider_auto_fix_status":
4999
+ return this.proxyDevServerGet(args, "auto-implement/status");
5000
+ case "provider_clone":
5001
+ return this.proxyDevServerScaffold(args);
4993
5002
  default:
4994
5003
  return { success: false, error: `Unknown command: ${cmd}` };
4995
5004
  }
@@ -5017,6 +5026,95 @@ var init_handler = __esm({
5017
5026
  }
5018
5027
  return { success: false, error: "ProviderLoader not initialized" };
5019
5028
  }
5029
+ // ─── DevServer HTTP proxy helpers ─────────────────
5030
+ // These bridge WS commands to the DevServer REST API (localhost:19280)
5031
+ async proxyDevServerPost(args, endpoint) {
5032
+ const { providerType, ...body } = args || {};
5033
+ if (!providerType) return { success: false, error: "providerType required" };
5034
+ try {
5035
+ const http3 = await import("http");
5036
+ const postData = JSON.stringify(body);
5037
+ const result = await new Promise((resolve8, reject) => {
5038
+ const req = http3.request({
5039
+ hostname: "127.0.0.1",
5040
+ port: 19280,
5041
+ path: `/api/providers/${providerType}/${endpoint}`,
5042
+ method: "POST",
5043
+ headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(postData) }
5044
+ }, (res) => {
5045
+ let data = "";
5046
+ res.on("data", (chunk) => data += chunk);
5047
+ res.on("end", () => {
5048
+ try {
5049
+ resolve8(JSON.parse(data));
5050
+ } catch {
5051
+ resolve8({ raw: data });
5052
+ }
5053
+ });
5054
+ });
5055
+ req.on("error", reject);
5056
+ req.write(postData);
5057
+ req.end();
5058
+ });
5059
+ return { success: true, ...result };
5060
+ } catch (e) {
5061
+ return { success: false, error: `DevServer unreachable: ${e.message}. Start daemon with --dev flag.` };
5062
+ }
5063
+ }
5064
+ async proxyDevServerGet(args, endpoint) {
5065
+ const { providerType } = args || {};
5066
+ if (!providerType) return { success: false, error: "providerType required" };
5067
+ try {
5068
+ const http3 = await import("http");
5069
+ const result = await new Promise((resolve8, reject) => {
5070
+ http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
5071
+ let data = "";
5072
+ res.on("data", (chunk) => data += chunk);
5073
+ res.on("end", () => {
5074
+ try {
5075
+ resolve8(JSON.parse(data));
5076
+ } catch {
5077
+ resolve8({ raw: data });
5078
+ }
5079
+ });
5080
+ }).on("error", reject);
5081
+ });
5082
+ return { success: true, ...result };
5083
+ } catch (e) {
5084
+ return { success: false, error: `DevServer unreachable: ${e.message}. Start daemon with --dev flag.` };
5085
+ }
5086
+ }
5087
+ async proxyDevServerScaffold(args) {
5088
+ try {
5089
+ const http3 = await import("http");
5090
+ const postData = JSON.stringify(args || {});
5091
+ const result = await new Promise((resolve8, reject) => {
5092
+ const req = http3.request({
5093
+ hostname: "127.0.0.1",
5094
+ port: 19280,
5095
+ path: "/api/scaffold",
5096
+ method: "POST",
5097
+ headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(postData) }
5098
+ }, (res) => {
5099
+ let data = "";
5100
+ res.on("data", (chunk) => data += chunk);
5101
+ res.on("end", () => {
5102
+ try {
5103
+ resolve8(JSON.parse(data));
5104
+ } catch {
5105
+ resolve8({ raw: data });
5106
+ }
5107
+ });
5108
+ });
5109
+ req.on("error", reject);
5110
+ req.write(postData);
5111
+ req.end();
5112
+ });
5113
+ return { success: true, ...result };
5114
+ } catch (e) {
5115
+ return { success: false, error: `DevServer unreachable: ${e.message}. Start daemon with --dev flag.` };
5116
+ }
5117
+ }
5020
5118
  };
5021
5119
  }
5022
5120
  });
@@ -28411,7 +28509,7 @@ var init_dev_server = __esm({
28411
28509
  // ─── Phase 2: Auto-Implement Backend ───
28412
28510
  async handleAutoImplement(type, req, res) {
28413
28511
  const body = await this.readBody(req);
28414
- const { agent = "claude-cli", functions, reference = "antigravity", model } = body;
28512
+ const { agent = "claude-cli", functions, reference = "antigravity", model, comment } = body;
28415
28513
  if (!functions || !Array.isArray(functions) || functions.length === 0) {
28416
28514
  this.json(res, 400, { error: 'functions[] is required (e.g. ["readChat", "sendMessage"])' });
28417
28515
  return;
@@ -28460,7 +28558,7 @@ var init_dev_server = __esm({
28460
28558
  }
28461
28559
  }
28462
28560
  }
28463
- const prompt = this.buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts);
28561
+ const prompt = this.buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts, comment);
28464
28562
  const tmpDir = path12.join(os14.tmpdir(), "adhdev-autoimpl");
28465
28563
  if (!fs9.existsSync(tmpDir)) fs9.mkdirSync(tmpDir, { recursive: true });
28466
28564
  const promptFile = path12.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
@@ -28643,6 +28741,7 @@ var init_dev_server = __esm({
28643
28741
  }
28644
28742
  this.sendAutoImplSSE({ event: "progress", data: { function: "_init", status: "spawning", message: `\uC5D0\uC774\uC804\uD2B8 \uC2E4\uD589 \uC911: ${shellCmd.substring(0, 200)}... (prompt: ${prompt.length} chars)` } });
28645
28743
  this.autoImplStatus = { running: true, type, progress: [] };
28744
+ const spawnedAt = Date.now();
28646
28745
  let child;
28647
28746
  let isPty = false;
28648
28747
  const { spawn: spawnFn } = await import("child_process");
@@ -28695,8 +28794,9 @@ var init_dev_server = __esm({
28695
28794
  const checkAutoApproval = (chunk, writeFn) => {
28696
28795
  const cleanData = chunk.replace(/\x1B\[\d*[A-HJKSTfG]/g, " ").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "").replace(/\x1B\][^\x07]*\x07/g, "").replace(/\x1B\][^\x1B]*\x1B\\/g, "").replace(/ +/g, " ");
28697
28796
  approvalBuffer = (approvalBuffer + cleanData).slice(-1500);
28698
- if (approvalBuffer.includes("AUTO_IMPLEMENT_FINISHED")) {
28699
- this.log("Agent finished task. Terminating interactive CLI session to unblock pipeline.");
28797
+ const elapsed = Date.now() - spawnedAt;
28798
+ if (elapsed > 15e3 && approvalBuffer.includes("AUTO_IMPLEMENT_FINISHED")) {
28799
+ this.log(`Agent finished task after ${Math.round(elapsed / 1e3)}s. Terminating interactive CLI session to unblock pipeline.`);
28700
28800
  this.sendAutoImplSSE({ event: "output", data: { chunk: `
28701
28801
  [\u{1F916} ADHDev Pipeline] Completion token detected. Proceeding...
28702
28802
  `, stream: "stdout" } });
@@ -28798,7 +28898,7 @@ var init_dev_server = __esm({
28798
28898
  this.json(res, 500, { error: `Auto-implement failed: ${e.message}` });
28799
28899
  }
28800
28900
  }
28801
- buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts) {
28901
+ buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts, userComment) {
28802
28902
  const lines = [];
28803
28903
  lines.push("You are implementing browser automation scripts for an IDE provider.");
28804
28904
  lines.push("Be concise. Do NOT explain your reasoning. Just edit files directly.");
@@ -28952,6 +29052,13 @@ var init_dev_server = __esm({
28952
29052
  lines.push("3. Use CDP evaluate to deeply inspect the DOM structure of the newly generated tables, code blocks, thought blocks, and tool calls.");
28953
29053
  lines.push("4. Ensure `readChat` extracts `content` with precise markdown formatting (especially for tables/code) and assigns correct `kind` tags (`thought`, `tool`, `terminal`).");
28954
29054
  lines.push("");
29055
+ if (userComment) {
29056
+ lines.push("## \u26A0\uFE0F User Instructions (HIGH PRIORITY)");
29057
+ lines.push("The user has provided the following additional instructions. Follow them strictly:");
29058
+ lines.push("");
29059
+ lines.push(userComment);
29060
+ lines.push("");
29061
+ }
28955
29062
  lines.push("Start NOW. Do not ask for permission. Explore the DOM -> Code -> Test.");
28956
29063
  return lines.join("\n");
28957
29064
  }
@@ -31020,7 +31127,7 @@ var init_adhdev_daemon = __esm({
31020
31127
  fs11 = __toESM(require("fs"));
31021
31128
  path14 = __toESM(require("path"));
31022
31129
  import_chalk2 = __toESM(require("chalk"));
31023
- pkgVersion = "0.6.19";
31130
+ pkgVersion = "0.6.21";
31024
31131
  if (pkgVersion === "unknown") {
31025
31132
  try {
31026
31133
  const possiblePaths = [
@@ -32619,7 +32726,7 @@ function registerProviderCommands(program2) {
32619
32726
  process.exit(1);
32620
32727
  }
32621
32728
  });
32622
- provider.command("fix [type] [scripts...]").description("Auto-implement provider scripts using AI reading the target IDE DOM").option("-a, --agent <agent>", "AI agent to use (e.g. claude-cli, gemini-cli, codex-cli, or any ACP provider like cline-acp)", "codex-cli").option("-m, --model <model>", "Model override (e.g. claude-sonnet-3.5, gemini-2.0-pro)").option("-r, --reference <ref>", "Reference provider to learn from", "antigravity").action(async (typeArg, scripts, options) => {
32729
+ provider.command("fix [type] [scripts...]").description("Auto-implement provider scripts using AI reading the target IDE DOM").option("-a, --agent <agent>", "AI agent to use (e.g. claude-cli, gemini-cli, codex-cli, or any ACP provider like cline-acp)", "codex-cli").option("-m, --model <model>", "Model override (e.g. claude-sonnet-3.5, gemini-2.0-pro)").option("-r, --reference <ref>", "Reference provider to learn from", "antigravity").option("-c, --comment <text>", 'Additional instructions for the AI agent (e.g. "focus on shadow DOM handling")').action(async (typeArg, scripts, options) => {
32623
32730
  try {
32624
32731
  const http3 = await import("http");
32625
32732
  const inquirer2 = (await import("inquirer")).default;
@@ -32749,14 +32856,27 @@ function registerProviderCommands(program2) {
32749
32856
  process.exit(0);
32750
32857
  }
32751
32858
  }
32859
+ let userComment = options.comment || "";
32860
+ if (!typeArg && !userComment) {
32861
+ const commentAnswer = await inquirer2.prompt([{
32862
+ type: "input",
32863
+ name: "comment",
32864
+ message: "Additional instructions for the agent (press Enter to skip):"
32865
+ }]);
32866
+ userComment = commentAnswer.comment || "";
32867
+ }
32752
32868
  let consecutiveFailures = 0;
32753
32869
  console.log(import_chalk6.default.bold(`
32754
32870
  \u25B6\uFE0F Generating [${functionsToFix.length}] function(s) natively via autonomous agent for ${type}...`));
32871
+ if (userComment) {
32872
+ console.log(import_chalk6.default.gray(` \u{1F4AC} Comment: ${userComment}`));
32873
+ }
32755
32874
  try {
32756
32875
  const postData = JSON.stringify({
32757
32876
  functions: functionsToFix,
32758
32877
  agent: agentName,
32759
32878
  ...modelName ? { model: modelName } : {},
32879
+ ...userComment ? { comment: userComment } : {},
32760
32880
  reference
32761
32881
  });
32762
32882
  const startResult = await new Promise((resolve8, reject) => {