@openma/deepseek-harness-acp 0.4.6 → 0.4.8

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
@@ -144,7 +144,7 @@ function resolveHost(explicit) {
144
144
  // src/profile-boot.ts
145
145
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
146
146
  import { createRequire } from "node:module";
147
- import { dirname as dirname2, join as join2, sep as sep2 } from "node:path";
147
+ import { dirname as dirname2, isAbsolute as isAbsolute2, join as join2, resolve as resolve2, sep as sep2 } from "node:path";
148
148
  import { pathToFileURL as pathToFileURL2 } from "node:url";
149
149
  var BIN = "dsh-acp";
150
150
  function ownRoot() {
@@ -170,6 +170,53 @@ function bundlePatchPath(packageJsonPath) {
170
170
  }
171
171
  return join2(dirname2(packageJsonPath), declared);
172
172
  }
173
+ function resolveBundlePackageJson(specifier) {
174
+ const candidate = resolve2(specifier);
175
+ if (existsSync2(candidate)) {
176
+ return candidate.endsWith("package.json") ? candidate : join2(candidate, "package.json");
177
+ }
178
+ const req = createRequire(join2(process.cwd(), "noop.js"));
179
+ try {
180
+ return req.resolve(`${specifier}/package.json`);
181
+ } catch (cause) {
182
+ throw new Error(`${BIN}: cannot resolve bundle ${JSON.stringify(specifier)}`, { cause });
183
+ }
184
+ }
185
+ function rewriteBundleRows(row, packageJsonPath, manifest) {
186
+ const name = row["name"];
187
+ if (typeof name === "string" && !name.startsWith("cordis:") && !isAbsolute2(name)) {
188
+ const req = createRequire(packageJsonPath);
189
+ try {
190
+ row["name"] = req.resolve(name);
191
+ } catch (cause) {
192
+ if (name === manifest.name && manifest.main !== void 0) {
193
+ const entry = resolve2(dirname2(packageJsonPath), manifest.main);
194
+ if (existsSync2(entry)) row["name"] = entry;
195
+ else throw new Error(`${BIN}: bundle entry does not exist: ${entry}`, { cause });
196
+ } else {
197
+ throw new Error(
198
+ `${BIN}: bundle ${manifest.name ?? packageJsonPath} cannot resolve plugin ${JSON.stringify(name)}`,
199
+ { cause }
200
+ );
201
+ }
202
+ }
203
+ }
204
+ const insert = row["insert"];
205
+ if (Array.isArray(insert)) {
206
+ for (const nested of insert) {
207
+ if (nested !== null && typeof nested === "object") {
208
+ rewriteBundleRows(nested, packageJsonPath, manifest);
209
+ }
210
+ }
211
+ }
212
+ }
213
+ function loadBundleLayer(appBoot, specifier) {
214
+ const packageJsonPath = resolveBundlePackageJson(specifier);
215
+ const manifest = JSON.parse(readFileSync2(packageJsonPath, "utf8"));
216
+ const patches = appBoot.loadOverlayPatches(BIN, bundlePatchPath(packageJsonPath));
217
+ for (const row of patches) rewriteBundleRows(row, packageJsonPath, manifest);
218
+ return patches;
219
+ }
173
220
  async function bootAcpProfile(host, overrides) {
174
221
  const req = createRequire(join2(host.base, "noop.js"));
175
222
  const dshPkgPath = req.resolve("@deepseek-ai/dsh/package.json");
@@ -204,6 +251,10 @@ async function bootAcpProfile(host, overrides) {
204
251
  ];
205
252
  logDebug(`profile: virtual (dsh-base + ${ownRoot()})`);
206
253
  }
254
+ for (const bundle of overrides?.bundles ?? []) {
255
+ bundlePatches.push(...loadBundleLayer(appBoot, bundle));
256
+ logDebug(`profile: added bundle ${bundle}`);
257
+ }
207
258
  for (const row of bundlePatches) rewriteBridgeRows(row, bridgeEntry);
208
259
  const homePatchPath = join2(home, "cordis.patch.yml");
209
260
  const homePatches = appBoot.loadOptionalPatches(BIN, homePatchPath) ?? [];
@@ -317,7 +368,7 @@ async function readSecret(promptText) {
317
368
  return Buffer.concat(chunks).toString("utf8").trim();
318
369
  }
319
370
  process.stderr.write(promptText);
320
- return await new Promise((resolve2) => {
371
+ return await new Promise((resolve3) => {
321
372
  stdin.setRawMode(true);
322
373
  stdin.resume();
323
374
  stdin.setEncoding("utf8");
@@ -329,7 +380,7 @@ async function readSecret(promptText) {
329
380
  stdin.pause();
330
381
  stdin.off("data", onData);
331
382
  process.stderr.write("\n");
332
- resolve2(buffer.trim());
383
+ resolve3(buffer.trim());
333
384
  return;
334
385
  }
335
386
  if (char === "") {
@@ -387,6 +438,7 @@ function envString(name) {
387
438
  }
388
439
  function parseFlags(argv) {
389
440
  const flags = /* @__PURE__ */ new Map();
441
+ const bundles = [];
390
442
  for (let i = 0; i < argv.length; i += 1) {
391
443
  const arg = argv[i];
392
444
  if (arg === void 0 || !arg.startsWith("--")) {
@@ -394,19 +446,23 @@ function parseFlags(argv) {
394
446
  }
395
447
  const eq = arg.indexOf("=");
396
448
  if (eq >= 0) {
397
- flags.set(arg.slice(2, eq), arg.slice(eq + 1));
449
+ const name2 = arg.slice(2, eq);
450
+ const value = arg.slice(eq + 1);
451
+ if (name2 === "bundle") bundles.push(value);
452
+ else flags.set(name2, value);
398
453
  continue;
399
454
  }
400
455
  const name = arg.slice(2);
401
456
  const next = argv[i + 1];
402
457
  if (next !== void 0 && !next.startsWith("--") && FLAGS_WITH_VALUES.has(name)) {
403
- flags.set(name, next);
458
+ if (name === "bundle") bundles.push(next);
459
+ else flags.set(name, next);
404
460
  i += 1;
405
461
  } else {
406
462
  flags.set(name, true);
407
463
  }
408
464
  }
409
- return { flags };
465
+ return { flags, bundles };
410
466
  }
411
467
  var FLAGS_WITH_VALUES = /* @__PURE__ */ new Set([
412
468
  "dsh-path",
@@ -418,7 +474,8 @@ var FLAGS_WITH_VALUES = /* @__PURE__ */ new Set([
418
474
  "session-root",
419
475
  "persona",
420
476
  "reasoning-effort",
421
- "bash-timeout"
477
+ "bash-timeout",
478
+ "bundle"
422
479
  ]);
423
480
  function stringFlag(parsed, name) {
424
481
  const value = parsed.flags.get(name);
@@ -428,6 +485,10 @@ function stringFlag(parsed, name) {
428
485
  }
429
486
  function resolveSettings(argv) {
430
487
  const parsed = parseFlags(argv);
488
+ if (parsed.flags.has("bundle")) stringFlag(parsed, "bundle");
489
+ if (parsed.bundles.some((bundle) => bundle.length === 0)) {
490
+ throw new SettingsError("--bundle requires a value");
491
+ }
431
492
  for (const name of parsed.flags.keys()) {
432
493
  if (!FLAGS_WITH_VALUES.has(name) && name !== "no-thinking") {
433
494
  throw new SettingsError(`unknown flag: --${name}`);
@@ -462,6 +523,7 @@ function resolveSettings(argv) {
462
523
  }
463
524
  return {
464
525
  dshPath: stringFlag(parsed, "dsh-path") ?? envString("DSH_PATH"),
526
+ bundles: parsed.bundles,
465
527
  provider: stringFlag(parsed, "provider") ?? envString("DSH_PROVIDER"),
466
528
  model,
467
529
  models,
@@ -487,6 +549,7 @@ Options:
487
549
  package dir, or any dir carrying node_modules/@deepseek-ai
488
550
  (DSH_PATH; auto-detected when unset \u2014 own tree, ./node_modules,
489
551
  dsh on PATH, npm root -g)
552
+ --bundle <package-dir> Add a dsh bundle layer to the agent tree (repeatable)
490
553
  --provider <route> Provider route (DSH_PROVIDER, default deepseek-official)
491
554
  --model <id> Default model (DSH_MODEL, default deepseek-v4-flash)
492
555
  --models <a,b,...> Selectable models for the session "Model" option
@@ -585,6 +648,7 @@ ${HELP_TEXT}`);
585
648
  return;
586
649
  }
587
650
  const booted = await bootAcpProfile(host, {
651
+ bundles: settings.bundles,
588
652
  ...settings.provider !== void 0 ? { provider: settings.provider } : {},
589
653
  ...settings.model !== void 0 ? { model: settings.model } : {},
590
654
  ...settings.permissionMode !== void 0 ? { permissionMode: settings.permissionMode } : {},
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.4.6",
6
+ "version": "0.4.8",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/openma-ai/deepseek-harness-acp.git"
@@ -113,6 +113,7 @@
113
113
  "@deepseek-ai/dsh-sandbox-policy": "^0.1.0-rc.6",
114
114
  "@deepseek-ai/dsh-session": "^0.1.0-rc.6",
115
115
  "@deepseek-ai/dsh-session-title": "^0.1.0-rc.6",
116
+ "@deepseek-ai/dsh-user-questions": "^0.1.0-rc.6",
116
117
  "@deepseek-ai/dsh": "^0.1.0-rc.6"
117
118
  },
118
119
  "exports": {