@drisp/cli 0.5.14 → 0.5.15

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.
@@ -8,7 +8,7 @@ import {
8
8
  installWorkflowPlugins,
9
9
  resolveWorkflow,
10
10
  writeGlobalConfig
11
- } from "./chunk-7E54JMXH.js";
11
+ } from "./chunk-SOW2QPXY.js";
12
12
 
13
13
  // src/setup/steps/WorkflowInstallWizard.tsx
14
14
  import { useState, useEffect, useCallback, useRef } from "react";
@@ -92,4 +92,4 @@ function WorkflowInstallWizard({ source, onDone }) {
92
92
  export {
93
93
  WorkflowInstallWizard as default
94
94
  };
95
- //# sourceMappingURL=WorkflowInstallWizard-7Y5PWAKW.js.map
95
+ //# sourceMappingURL=WorkflowInstallWizard-AY4CPQS2.js.map
@@ -3,7 +3,7 @@ import {
3
3
  loadOrCreateToken,
4
4
  requireTokenForBind,
5
5
  timingSafeTokenEqual
6
- } from "./chunk-MRAM6EYI.js";
6
+ } from "./chunk-D4W7RB25.js";
7
7
  import {
8
8
  CHANNEL_REQUEST_ID_REGEX,
9
9
  createUdsServerTransport,
@@ -19,7 +19,7 @@ import {
19
19
  trackGatewayTransportConnect,
20
20
  trackGatewayTransportDisconnect,
21
21
  writeGatewayTrace
22
- } from "./chunk-BTY7MYYT.js";
22
+ } from "./chunk-WRHKXH5M.js";
23
23
 
24
24
  // src/gateway/daemon.ts
25
25
  import fs4 from "fs";
@@ -2440,7 +2440,7 @@ var cachedVersion = null;
2440
2440
  function readVersion() {
2441
2441
  if (cachedVersion !== null) return cachedVersion;
2442
2442
  try {
2443
- const injected = "0.5.14";
2443
+ const injected = "0.5.15";
2444
2444
  if (typeof injected === "string" && injected.length > 0) {
2445
2445
  cachedVersion = injected;
2446
2446
  return cachedVersion;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isLoopbackHost
3
- } from "./chunk-BTY7MYYT.js";
3
+ } from "./chunk-WRHKXH5M.js";
4
4
 
5
5
  // src/gateway/auth.ts
6
6
  import crypto from "crypto";
@@ -73,4 +73,4 @@ export {
73
73
  timingSafeTokenEqual,
74
74
  requireTokenForBind
75
75
  };
76
- //# sourceMappingURL=chunk-MRAM6EYI.js.map
76
+ //# sourceMappingURL=chunk-D4W7RB25.js.map
@@ -1,12 +1,150 @@
1
1
  // src/infra/plugins/workflowResolver.ts
2
- import fs2 from "fs";
2
+ import fs3 from "fs";
3
3
  import path2 from "path";
4
4
 
5
5
  // src/infra/plugins/marketplaceShared.ts
6
- import { execFileSync } from "child_process";
7
- import fs from "fs";
6
+ import { execFileSync as execFileSync2 } from "child_process";
7
+ import fs2 from "fs";
8
8
  import os from "os";
9
9
  import path from "path";
10
+
11
+ // src/infra/plugins/marketplaceRefresh.ts
12
+ import { execFileSync } from "child_process";
13
+ import fs from "fs";
14
+ var MarketplaceRefreshError = class extends Error {
15
+ kind;
16
+ marketplace;
17
+ constructor(outcome) {
18
+ super(outcome.message);
19
+ this.name = "MarketplaceRefreshError";
20
+ this.kind = outcome.kind;
21
+ this.marketplace = outcome.marketplace;
22
+ }
23
+ };
24
+ var NETWORK_OR_AUTH_SIGNATURES = [
25
+ "could not resolve host",
26
+ "could not resolve proxy",
27
+ "couldn\u2019t resolve host",
28
+ "name or service not known",
29
+ "temporary failure in name resolution",
30
+ "failed to connect",
31
+ "connection timed out",
32
+ "connection refused",
33
+ "connection reset",
34
+ "network is unreachable",
35
+ "network unavailable",
36
+ "unable to access",
37
+ "ssl certificate problem",
38
+ "gnutls_handshake",
39
+ "authentication failed",
40
+ "could not read username",
41
+ "could not read password",
42
+ "permission denied (publickey)",
43
+ "terminal prompts disabled",
44
+ "invalid username or password",
45
+ "403 forbidden",
46
+ "access denied",
47
+ "repository not found",
48
+ "remote: not found"
49
+ ];
50
+ function classifyGitFailure(message) {
51
+ const haystack = message.toLowerCase();
52
+ for (const signature of NETWORK_OR_AUTH_SIGNATURES) {
53
+ if (haystack.includes(signature)) {
54
+ return "network-or-auth";
55
+ }
56
+ }
57
+ return "unrecoverable-cache";
58
+ }
59
+ function repoUrlFor(owner, repo) {
60
+ return `https://github.com/${owner}/${repo}.git`;
61
+ }
62
+ var GIT_STDIO = ["ignore", "ignore", "pipe"];
63
+ function gitFailureText(error) {
64
+ const err = error;
65
+ const stderr = err.stderr == null ? "" : err.stderr.toString().trim();
66
+ const message = err.message ?? "";
67
+ return stderr ? `${message} ${stderr}`.trim() : message;
68
+ }
69
+ function cloneInto(repoUrl, repoDir) {
70
+ fs.mkdirSync(repoDir, { recursive: true });
71
+ try {
72
+ execFileSync("git", ["clone", "--depth", "1", repoUrl, repoDir], {
73
+ stdio: GIT_STDIO
74
+ });
75
+ } catch (error) {
76
+ fs.rmSync(repoDir, { recursive: true, force: true });
77
+ throw error;
78
+ }
79
+ }
80
+ function failureOutcome(kind, marketplace, cause, backupDir) {
81
+ const message = kind === "network-or-auth" ? `Could not refresh the "${marketplace}" marketplace: the remote could not be reached (connectivity or authentication problem). ${cause}` : `Could not refresh the "${marketplace}" marketplace: the cached copy is corrupt and could not be rebuilt.${backupDir ? ` Previous cache preserved at ${backupDir}.` : ""} ${cause}`;
82
+ return {
83
+ ok: false,
84
+ kind,
85
+ marketplace,
86
+ message,
87
+ cause,
88
+ ...backupDir ? { backupDir } : {}
89
+ };
90
+ }
91
+ function refreshMarketplaceRepo(owner, repo) {
92
+ const marketplace = `${owner}/${repo}`;
93
+ const repoDir = marketplaceRepoCacheDir(owner, repo);
94
+ const repoUrl = repoUrlFor(owner, repo);
95
+ if (!fs.existsSync(repoDir)) {
96
+ try {
97
+ cloneInto(repoUrl, repoDir);
98
+ return { ok: true, repoDir };
99
+ } catch (cloneError) {
100
+ const cause = gitFailureText(cloneError);
101
+ return failureOutcome(classifyGitFailure(cause), marketplace, cause);
102
+ }
103
+ }
104
+ try {
105
+ execFileSync("git", ["pull", "--ff-only"], {
106
+ cwd: repoDir,
107
+ stdio: GIT_STDIO
108
+ });
109
+ return { ok: true, repoDir };
110
+ } catch {
111
+ const backupDir = `${repoDir}.backup-${Date.now()}`;
112
+ try {
113
+ fs.renameSync(repoDir, backupDir);
114
+ cloneInto(repoUrl, repoDir);
115
+ return { ok: true, repoDir, selfHealed: true, backupDir };
116
+ } catch (recoveryError) {
117
+ const cause = gitFailureText(recoveryError);
118
+ return failureOutcome(
119
+ classifyGitFailure(cause),
120
+ marketplace,
121
+ cause,
122
+ backupDir
123
+ );
124
+ }
125
+ }
126
+ }
127
+ function ensureFailureOutcome(kind, marketplace, cause) {
128
+ const message = kind === "network-or-auth" ? `Could not reach the "${marketplace}" marketplace: the remote could not be reached (connectivity or authentication problem). ${cause}` : `Could not clone the "${marketplace}" marketplace: the local cache could not be created. ${cause}`;
129
+ return { ok: false, kind, marketplace, message, cause };
130
+ }
131
+ function ensureRepo(owner, repo) {
132
+ const repoDir = marketplaceRepoCacheDir(owner, repo);
133
+ if (!fs.existsSync(repoDir)) {
134
+ const marketplace = `${owner}/${repo}`;
135
+ try {
136
+ cloneInto(repoUrlFor(owner, repo), repoDir);
137
+ } catch (error) {
138
+ const cause = gitFailureText(error);
139
+ throw new MarketplaceRefreshError(
140
+ ensureFailureOutcome(classifyGitFailure(cause), marketplace, cause)
141
+ );
142
+ }
143
+ }
144
+ return repoDir;
145
+ }
146
+
147
+ // src/infra/plugins/marketplaceShared.ts
10
148
  var MARKETPLACE_REF_RE = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/;
11
149
  var MARKETPLACE_SLUG_RE = /^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/;
12
150
  function marketplacesCacheDir() {
@@ -23,17 +161,17 @@ function resolvePluginManifestPath(repoDir) {
23
161
  "marketplace.json"
24
162
  );
25
163
  const legacyManifestPath = resolveLegacyPluginManifestPath(repoDir);
26
- return fs.existsSync(preferredManifestPath) ? preferredManifestPath : legacyManifestPath;
164
+ return fs2.existsSync(preferredManifestPath) ? preferredManifestPath : legacyManifestPath;
27
165
  }
28
166
  function resolveLegacyPluginManifestPath(repoDir) {
29
167
  return path.join(repoDir, ".claude-plugin", "marketplace.json");
30
168
  }
31
169
  function readManifest(manifestPath) {
32
- if (!fs.existsSync(manifestPath)) {
170
+ if (!fs2.existsSync(manifestPath)) {
33
171
  throw new Error(`Marketplace manifest not found: ${manifestPath}`);
34
172
  }
35
173
  return JSON.parse(
36
- fs.readFileSync(manifestPath, "utf-8")
174
+ fs2.readFileSync(manifestPath, "utf-8")
37
175
  );
38
176
  }
39
177
  function entryRelativeSourcePath(entry, pluginName) {
@@ -91,7 +229,7 @@ function resolvePluginDirFromManifest(pluginName, repoDir, manifestPath) {
91
229
  repoDir,
92
230
  entryRelativeSourcePath(entry, pluginName)
93
231
  );
94
- if (!fs.existsSync(pluginDir)) {
232
+ if (!fs2.existsSync(pluginDir)) {
95
233
  throw new Error(`Plugin source directory not found: ${pluginDir}`);
96
234
  }
97
235
  return pluginDir;
@@ -140,9 +278,9 @@ function resolvePluginVersionFromDir(pluginDir) {
140
278
  path.join(pluginDir, ".claude-plugin", "plugin.json")
141
279
  ];
142
280
  for (const manifestPath of manifestPaths) {
143
- if (!fs.existsSync(manifestPath)) continue;
281
+ if (!fs2.existsSync(manifestPath)) continue;
144
282
  try {
145
- const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
283
+ const manifest = JSON.parse(fs2.readFileSync(manifestPath, "utf-8"));
146
284
  if (typeof manifest.version === "string" && manifest.version.length > 0) {
147
285
  return manifest.version;
148
286
  }
@@ -153,12 +291,12 @@ function resolvePluginVersionFromDir(pluginDir) {
153
291
  }
154
292
  function resolvePackagedArtifactLayout(pluginRoot, version) {
155
293
  const releasePath = path.join(pluginRoot, "dist", version, "release.json");
156
- if (!fs.existsSync(releasePath)) {
294
+ if (!fs2.existsSync(releasePath)) {
157
295
  return void 0;
158
296
  }
159
297
  try {
160
298
  const release = JSON.parse(
161
- fs.readFileSync(releasePath, "utf-8")
299
+ fs2.readFileSync(releasePath, "utf-8")
162
300
  );
163
301
  if (release.version !== version) {
164
302
  return void 0;
@@ -179,7 +317,7 @@ function resolvePackagedArtifactLayout(pluginRoot, version) {
179
317
  if (!isPathWithinRoot(releaseDir, claudeArtifactDir) || !isPathWithinRoot(releaseDir, resolvedCodexMarketplacePath) || !isPathWithinRoot(releaseDir, codexPluginDir)) {
180
318
  return void 0;
181
319
  }
182
- if (!fs.existsSync(claudeArtifactDir) || !fs.existsSync(resolvedCodexMarketplacePath) || !fs.existsSync(codexPluginDir)) {
320
+ if (!fs2.existsSync(claudeArtifactDir) || !fs2.existsSync(resolvedCodexMarketplacePath) || !fs2.existsSync(codexPluginDir)) {
183
321
  return void 0;
184
322
  }
185
323
  return {
@@ -191,27 +329,9 @@ function resolvePackagedArtifactLayout(pluginRoot, version) {
191
329
  return void 0;
192
330
  }
193
331
  }
194
- function ensureRepo(owner, repo) {
195
- const repoDir = marketplaceRepoCacheDir(owner, repo);
196
- if (!fs.existsSync(repoDir)) {
197
- const repoUrl = `https://github.com/${owner}/${repo}.git`;
198
- fs.mkdirSync(repoDir, { recursive: true });
199
- try {
200
- execFileSync("git", ["clone", "--depth", "1", repoUrl, repoDir], {
201
- stdio: "ignore"
202
- });
203
- } catch (error) {
204
- fs.rmSync(repoDir, { recursive: true, force: true });
205
- throw new Error(
206
- `Failed to clone marketplace repo ${owner}/${repo}: ${error.message}`
207
- );
208
- }
209
- }
210
- return repoDir;
211
- }
212
332
  function requireGitForMarketplace(kind) {
213
333
  try {
214
- execFileSync("git", ["--version"], { stdio: "ignore" });
334
+ execFileSync2("git", ["--version"], { stdio: "ignore" });
215
335
  } catch {
216
336
  throw new Error(
217
337
  `git is not installed. Install git to use marketplace ${kind}.`
@@ -270,14 +390,14 @@ var WorkflowVersionNotFoundError = class extends Error {
270
390
  function resolveWorkflowManifestPath(repoDir) {
271
391
  const preferred = path2.join(repoDir, ".athena-workflow", "marketplace.json");
272
392
  const legacy = path2.join(repoDir, ".claude-plugin", "marketplace.json");
273
- return fs2.existsSync(preferred) ? preferred : legacy;
393
+ return fs3.existsSync(preferred) ? preferred : legacy;
274
394
  }
275
395
  function preferCanonicalWorkflowPath(repoDir, workflowPath) {
276
396
  const relativePath = path2.relative(repoDir, workflowPath);
277
397
  const segments = relativePath.split(path2.sep);
278
398
  if (segments[0] !== ".workflows") return workflowPath;
279
399
  const canonical = path2.join(repoDir, "workflows", ...segments.slice(1));
280
- return fs2.existsSync(canonical) ? canonical : workflowPath;
400
+ return fs3.existsSync(canonical) ? canonical : workflowPath;
281
401
  }
282
402
  function resolveWorkflowEntryPath(entry, manifest, repoDir) {
283
403
  if (typeof entry.source !== "string") {
@@ -297,7 +417,7 @@ function resolveWorkflowEntryPath(entry, manifest, repoDir) {
297
417
  );
298
418
  }
299
419
  const resolved = preferCanonicalWorkflowPath(repoDir, workflowPath);
300
- if (!fs2.existsSync(resolved)) {
420
+ if (!fs3.existsSync(resolved)) {
301
421
  throw new Error(`Workflow source not found: ${resolved}`);
302
422
  }
303
423
  return resolved;
@@ -331,7 +451,7 @@ function listWorkflowEntriesFromManifest(repoDir, manifestPath, source) {
331
451
  function findMarketplaceRepoDir(startPath) {
332
452
  let currentDir = path2.resolve(startPath);
333
453
  for (; ; ) {
334
- if (fs2.existsSync(resolveWorkflowManifestPath(currentDir)) || fs2.existsSync(resolvePluginManifestPath(currentDir))) {
454
+ if (fs3.existsSync(resolveWorkflowManifestPath(currentDir)) || fs3.existsSync(resolvePluginManifestPath(currentDir))) {
335
455
  return currentDir;
336
456
  }
337
457
  const parentDir = path2.dirname(currentDir);
@@ -342,7 +462,7 @@ function findMarketplaceRepoDir(startPath) {
342
462
  function resolveWorkflowMarketplaceSource(source) {
343
463
  const trimmed = source.trim();
344
464
  const resolvedPath = path2.resolve(trimmed);
345
- if (!fs2.existsSync(resolvedPath) && isMarketplaceSlug(trimmed)) {
465
+ if (!fs3.existsSync(resolvedPath) && isMarketplaceSlug(trimmed)) {
346
466
  const slashIdx = trimmed.indexOf("/");
347
467
  return {
348
468
  kind: "remote",
@@ -388,10 +508,10 @@ function resolveMarketplaceWorkflow(ref) {
388
508
  function gatherMarketplaceWorkflowSources(source) {
389
509
  const trimmed = source.trim();
390
510
  const resolvedPath = path2.resolve(trimmed);
391
- if (fs2.existsSync(resolvedPath) && fs2.statSync(resolvedPath).isFile()) {
392
- return [{ kind: "filesystem", workflowPath: fs2.realpathSync(resolvedPath) }];
511
+ if (fs3.existsSync(resolvedPath) && fs3.statSync(resolvedPath).isFile()) {
512
+ return [{ kind: "filesystem", workflowPath: fs3.realpathSync(resolvedPath) }];
393
513
  }
394
- if (!fs2.existsSync(resolvedPath) && isMarketplaceSlug(trimmed)) {
514
+ if (!fs3.existsSync(resolvedPath) && isMarketplaceSlug(trimmed)) {
395
515
  const slashIdx = trimmed.indexOf("/");
396
516
  const owner = trimmed.slice(0, slashIdx);
397
517
  const repo = trimmed.slice(slashIdx + 1);
@@ -421,7 +541,7 @@ function gatherMarketplaceWorkflowSources(source) {
421
541
  `Marketplace source not found: ${trimmed}. Expected a marketplace repo root, a path inside one, or an owner/repo slug.`
422
542
  );
423
543
  }
424
- const canonicalRepoDir = fs2.realpathSync(repoDir);
544
+ const canonicalRepoDir = fs3.realpathSync(repoDir);
425
545
  const manifestPath = resolveWorkflowManifestPath(canonicalRepoDir);
426
546
  return listWorkflowEntriesFromManifest(canonicalRepoDir, manifestPath, {
427
547
  kind: "local",
@@ -485,8 +605,8 @@ function resolveWorkflowInstall(sourceOrName, configuredSources) {
485
605
  };
486
606
  }
487
607
  const resolvedPath = path2.resolve(sourceOrName);
488
- if (fs2.existsSync(resolvedPath) && fs2.statSync(resolvedPath).isFile()) {
489
- return { kind: "filesystem", workflowPath: fs2.realpathSync(resolvedPath) };
608
+ if (fs3.existsSync(resolvedPath) && fs3.statSync(resolvedPath).isFile()) {
609
+ return { kind: "filesystem", workflowPath: fs3.realpathSync(resolvedPath) };
490
610
  }
491
611
  const { bareName, pinnedVersion } = parseBareWorkflowName(sourceOrName);
492
612
  if (bareName.includes("/") || bareName.includes("\\")) {
@@ -530,13 +650,9 @@ function resolveWorkflowInstall(sourceOrName, configuredSources) {
530
650
  return allListings[0];
531
651
  }
532
652
 
533
- // src/infra/plugins/marketplace.ts
653
+ // src/infra/plugins/versionedPluginResolution.ts
534
654
  import { execFileSync as execFileSync3 } from "child_process";
535
655
  import fs4 from "fs";
536
-
537
- // src/infra/plugins/versionedPluginResolution.ts
538
- import { execFileSync as execFileSync2 } from "child_process";
539
- import fs3 from "fs";
540
656
  import os2 from "os";
541
657
  import path3 from "path";
542
658
  var PLUGIN_NPM_SCOPE = "@athenaflow";
@@ -554,7 +670,7 @@ function resolveVersionedPluginDir(owner, repo, pluginName, version) {
554
670
  pluginName,
555
671
  version
556
672
  );
557
- return fs3.existsSync(cacheDir) ? cacheDir : void 0;
673
+ return fs4.existsSync(cacheDir) ? cacheDir : void 0;
558
674
  }
559
675
  function fetchPluginPackage(owner, repo, pluginName, version) {
560
676
  const npmPkg = pluginNpmPackageName(pluginName);
@@ -565,46 +681,46 @@ function fetchPluginPackage(owner, repo, pluginName, version) {
565
681
  pluginName,
566
682
  version
567
683
  );
568
- if (fs3.existsSync(destDir)) {
684
+ if (fs4.existsSync(destDir)) {
569
685
  return destDir;
570
686
  }
571
687
  const cacheBase = versionedPluginCacheDir();
572
- fs3.mkdirSync(cacheBase, { recursive: true });
573
- const tmpDir = fs3.mkdtempSync(path3.join(cacheBase, ".tmp-"));
688
+ fs4.mkdirSync(cacheBase, { recursive: true });
689
+ const tmpDir = fs4.mkdtempSync(path3.join(cacheBase, ".tmp-"));
574
690
  try {
575
- const tarball = execFileSync2(
691
+ const tarball = execFileSync3(
576
692
  "npm",
577
693
  ["pack", `${npmPkg}@${version}`, "--pack-destination", tmpDir],
578
694
  { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
579
695
  ).trim();
580
696
  const tarballPath = path3.join(tmpDir, tarball);
581
- if (!fs3.existsSync(tarballPath)) {
697
+ if (!fs4.existsSync(tarballPath)) {
582
698
  throw new Error(`npm pack did not produce expected tarball: ${tarball}`);
583
699
  }
584
700
  const extractDir = path3.join(tmpDir, "extracted");
585
- fs3.mkdirSync(extractDir, { recursive: true });
586
- execFileSync2("tar", ["xzf", tarballPath, "-C", extractDir], {
701
+ fs4.mkdirSync(extractDir, { recursive: true });
702
+ execFileSync3("tar", ["xzf", tarballPath, "-C", extractDir], {
587
703
  stdio: "ignore"
588
704
  });
589
705
  const packageDir = path3.join(extractDir, "package");
590
- if (!fs3.existsSync(packageDir)) {
706
+ if (!fs4.existsSync(packageDir)) {
591
707
  throw new Error(
592
708
  "Extracted tarball does not contain a package/ directory"
593
709
  );
594
710
  }
595
- fs3.mkdirSync(path3.dirname(destDir), { recursive: true });
711
+ fs4.mkdirSync(path3.dirname(destDir), { recursive: true });
596
712
  try {
597
- fs3.renameSync(packageDir, destDir);
713
+ fs4.renameSync(packageDir, destDir);
598
714
  } catch (error) {
599
715
  const code = typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : void 0;
600
- if ((code === "EEXIST" || code === "ENOTEMPTY") && fs3.existsSync(destDir)) {
716
+ if ((code === "EEXIST" || code === "ENOTEMPTY") && fs4.existsSync(destDir)) {
601
717
  return destDir;
602
718
  }
603
719
  throw error;
604
720
  }
605
721
  return destDir;
606
722
  } finally {
607
- fs3.rmSync(tmpDir, { recursive: true, force: true });
723
+ fs4.rmSync(tmpDir, { recursive: true, force: true });
608
724
  }
609
725
  }
610
726
  function resolvePackagedArtifactsOrThrow(pluginName, version, pluginRoot, stage) {
@@ -648,7 +764,7 @@ function resolveMarketplaceSourceFallback(ref, pluginName, version, repoDir) {
648
764
  );
649
765
  }
650
766
  function describeSourceFallbackRejection(owner, repo, pluginName, version, repoDir) {
651
- if (!fs3.existsSync(repoDir)) {
767
+ if (!fs4.existsSync(repoDir)) {
652
768
  return `source fallback was unavailable because marketplace repo ${owner}/${repo} is not cached locally`;
653
769
  }
654
770
  let entry;
@@ -701,7 +817,7 @@ function resolveVersionedMarketplacePluginTarget(ref, version, sourceRepoDir, op
701
817
  npmError = error;
702
818
  }
703
819
  const repoDir = sourceRepoDir ?? ensureRepo(owner, repo);
704
- const fallbackTarget = fs3.existsSync(repoDir) ? resolveMarketplaceSourceFallback(ref, pluginName, version, repoDir) : void 0;
820
+ const fallbackTarget = fs4.existsSync(repoDir) ? resolveMarketplaceSourceFallback(ref, pluginName, version, repoDir) : void 0;
705
821
  if (fallbackTarget) {
706
822
  return fallbackTarget;
707
823
  }
@@ -724,44 +840,6 @@ function refreshVersionedMarketplacePluginTarget(ref, version, sourceRepoDir) {
724
840
  }
725
841
 
726
842
  // src/infra/plugins/marketplace.ts
727
- function pullMarketplaceRepo(owner, repo) {
728
- const repoDir = marketplaceRepoCacheDir(owner, repo);
729
- const repoUrl = `https://github.com/${owner}/${repo}.git`;
730
- if (!fs4.existsSync(repoDir)) {
731
- cloneMarketplaceRepo(owner, repo, repoUrl, repoDir);
732
- return;
733
- }
734
- try {
735
- execFileSync3("git", ["pull", "--ff-only"], {
736
- cwd: repoDir,
737
- stdio: "ignore"
738
- });
739
- return;
740
- } catch (pullError) {
741
- const backupDir = `${repoDir}.backup-${Date.now()}`;
742
- try {
743
- fs4.renameSync(repoDir, backupDir);
744
- cloneMarketplaceRepo(owner, repo, repoUrl, repoDir);
745
- } catch (recoveryError) {
746
- throw new Error(
747
- `Failed to refresh marketplace repo ${owner}/${repo}: ${pullError.message}. Recovery clone failed: ${recoveryError.message}. Preserved previous cache at ${backupDir}.`
748
- );
749
- }
750
- }
751
- }
752
- function cloneMarketplaceRepo(owner, repo, repoUrl, repoDir) {
753
- fs4.mkdirSync(repoDir, { recursive: true });
754
- try {
755
- execFileSync3("git", ["clone", "--depth", "1", repoUrl, repoDir], {
756
- stdio: "ignore"
757
- });
758
- } catch (error) {
759
- fs4.rmSync(repoDir, { recursive: true, force: true });
760
- throw new Error(
761
- `Failed to clone marketplace repo ${owner}/${repo}: ${error.message}`
762
- );
763
- }
764
- }
765
843
  function resolveMarketplacePlugin(ref) {
766
844
  requireGitForMarketplace("plugins");
767
845
  const { pluginName, owner, repo } = parseRef(ref);
@@ -1464,13 +1542,22 @@ function installWorkflowFromSource(source, name) {
1464
1542
  writeWorkflowSourceMetadata(destDir, metadata);
1465
1543
  return workflowName;
1466
1544
  }
1467
- function reResolveFromMetadata(metadata) {
1545
+ function reResolveFromMetadata(metadata, refresh = refreshMarketplaceRepo, onSelfHeal) {
1468
1546
  if (metadata.kind === "marketplace-remote") {
1469
1547
  const slug = metadata.ref.slice(metadata.ref.indexOf("@") + 1);
1470
1548
  const slashIdx = slug.indexOf("/");
1471
1549
  const owner = slug.slice(0, slashIdx);
1472
1550
  const repo = slug.slice(slashIdx + 1);
1473
- pullMarketplaceRepo(owner, repo);
1551
+ const refreshed = refresh(owner, repo);
1552
+ if (!refreshed.ok) {
1553
+ throw new MarketplaceRefreshError(refreshed);
1554
+ }
1555
+ if (refreshed.selfHealed) {
1556
+ onSelfHeal?.({
1557
+ marketplace: `${owner}/${repo}`,
1558
+ backupDir: refreshed.backupDir
1559
+ });
1560
+ }
1474
1561
  return resolveWorkflowInstall(metadata.ref, []);
1475
1562
  }
1476
1563
  if (metadata.kind === "marketplace-local") {
@@ -1493,7 +1580,7 @@ function reResolveFromMetadata(metadata) {
1493
1580
  }
1494
1581
  return { kind: "filesystem", workflowPath: metadata.path };
1495
1582
  }
1496
- function updateWorkflow(name) {
1583
+ function updateWorkflow(name, refresh = refreshMarketplaceRepo, onSelfHeal) {
1497
1584
  const workflowDir = path7.join(registryDir(), name);
1498
1585
  const metadata = readWorkflowSourceMetadata(workflowDir);
1499
1586
  if (!metadata) {
@@ -1501,11 +1588,52 @@ function updateWorkflow(name) {
1501
1588
  `Workflow "${name}" has no recorded source. Reinstall it with: athena-flow workflow install <source>`
1502
1589
  );
1503
1590
  }
1504
- const source = reResolveFromMetadata(metadata);
1591
+ const source = reResolveFromMetadata(metadata, refresh, onSelfHeal);
1505
1592
  const installedName = installWorkflowFromSource(source, name);
1506
1593
  refreshPinnedWorkflowPlugins(resolveWorkflow(installedName));
1507
1594
  return installedName;
1508
1595
  }
1596
+ function updateWorkflows(names) {
1597
+ const refreshCache = /* @__PURE__ */ new Map();
1598
+ const refresh = (owner, repo) => {
1599
+ const key = `${owner}/${repo}`;
1600
+ const cached = refreshCache.get(key);
1601
+ if (cached) return cached;
1602
+ const outcome = refreshMarketplaceRepo(owner, repo);
1603
+ refreshCache.set(key, outcome);
1604
+ return outcome;
1605
+ };
1606
+ const upgraded = [];
1607
+ const marketplaceFailures = [];
1608
+ const reportedMarketplaces = /* @__PURE__ */ new Set();
1609
+ const workflowFailures = [];
1610
+ const selfHealed = [];
1611
+ const selfHealedMarketplaces = /* @__PURE__ */ new Set();
1612
+ const onSelfHeal = (info) => {
1613
+ if (!selfHealedMarketplaces.has(info.marketplace)) {
1614
+ selfHealedMarketplaces.add(info.marketplace);
1615
+ selfHealed.push(info);
1616
+ }
1617
+ };
1618
+ for (const name of names) {
1619
+ try {
1620
+ upgraded.push(updateWorkflow(name, refresh, onSelfHeal));
1621
+ } catch (error) {
1622
+ if (error instanceof MarketplaceRefreshError) {
1623
+ if (!reportedMarketplaces.has(error.marketplace)) {
1624
+ reportedMarketplaces.add(error.marketplace);
1625
+ marketplaceFailures.push({ marketplace: error.marketplace, error });
1626
+ }
1627
+ } else {
1628
+ workflowFailures.push({
1629
+ name,
1630
+ error: error instanceof Error ? error : new Error(String(error))
1631
+ });
1632
+ }
1633
+ }
1634
+ }
1635
+ return { upgraded, marketplaceFailures, workflowFailures, selfHealed };
1636
+ }
1509
1637
  function listWorkflows() {
1510
1638
  const dir = registryDir();
1511
1639
  const installed = fs9.existsSync(dir) ? fs9.readdirSync(dir, { withFileTypes: true }).filter(
@@ -2103,9 +2231,10 @@ export {
2103
2231
  resolveWorkflow,
2104
2232
  installWorkflowFromSource,
2105
2233
  updateWorkflow,
2234
+ updateWorkflows,
2106
2235
  listWorkflows,
2107
2236
  removeWorkflow,
2108
2237
  compileWorkflowPlan,
2109
2238
  collectMcpServersWithOptions
2110
2239
  };
2111
- //# sourceMappingURL=chunk-7E54JMXH.js.map
2240
+ //# sourceMappingURL=chunk-SOW2QPXY.js.map
@@ -23,7 +23,7 @@ import {
23
23
  traceGatewayFrame,
24
24
  trackGatewayTransportReconnect,
25
25
  writeGatewayTrace
26
- } from "./chunk-BTY7MYYT.js";
26
+ } from "./chunk-WRHKXH5M.js";
27
27
  import {
28
28
  compileWorkflowPlan,
29
29
  createWorkflowRunner,
@@ -34,7 +34,7 @@ import {
34
34
  resolveWorkflow,
35
35
  resolveWorkflowInstall,
36
36
  resolveWorkflowPlugins
37
- } from "./chunk-7E54JMXH.js";
37
+ } from "./chunk-SOW2QPXY.js";
38
38
 
39
39
  // src/infra/daemon/stateDir.ts
40
40
  import fs from "fs";
@@ -3058,6 +3058,24 @@ function validateConflicts(config) {
3058
3058
  return warnings;
3059
3059
  }
3060
3060
 
3061
+ // src/core/compaction/handoffInstructions.ts
3062
+ var HANDOFF_COMPACT_INSTRUCTIONS = `When compacting this conversation, write the compacted summary as a handoff so a fresh agent can continue the work without re-reading the history. Preserve:
3063
+ - The current task and goal, and where it stands right now.
3064
+ - Decisions already made (and why) and any open questions still to resolve.
3065
+ - Files and locations touched, referenced by path \u2014 do not paste file contents.
3066
+ - A "Suggested next steps / skills" section naming what to do or invoke next.
3067
+
3068
+ Reference existing artifacts (PRDs, plans, ADRs, issues, commits, diffs) by path or URL instead of duplicating their content. Redact secrets \u2014 API keys, passwords, tokens, or personally identifiable information.`;
3069
+ var HANDOFF_COMPACT_PROMPT = `Summarize the conversation so far as a handoff document that lets a fresh agent continue the work without re-reading the history.
3070
+
3071
+ Include:
3072
+ - The current task and goal, and its present status.
3073
+ - Decisions already made (with rationale) and any open questions still to resolve.
3074
+ - Files and locations touched, referenced by path \u2014 do not reproduce file contents.
3075
+ - A "Suggested next steps / skills" section naming what to do or invoke next.
3076
+
3077
+ Reference existing artifacts (PRDs, plans, ADRs, issues, commits, diffs) by path or URL rather than duplicating them. Redact any sensitive information such as API keys, passwords, tokens, or personally identifiable information.`;
3078
+
3061
3079
  // src/harnesses/claude/process/spawn.ts
3062
3080
  function makePreflightError(failureCode, message) {
3063
3081
  const error = new Error(message);
@@ -3110,6 +3128,20 @@ function runSpawnPreflight(hookSocketPath) {
3110
3128
  }
3111
3129
  validateSocketPath(hookSocketPath);
3112
3130
  }
3131
+ var HANDOFF_COMPACT_SYSTEM_PROMPT = `## Compact Instructions
3132
+
3133
+ ${HANDOFF_COMPACT_INSTRUCTIONS}`;
3134
+ function appendHandoffCompactInstructions(config) {
3135
+ return {
3136
+ ...config,
3137
+ appendSystemPrompt: [
3138
+ config.appendSystemPrompt,
3139
+ HANDOFF_COMPACT_SYSTEM_PROMPT
3140
+ ].filter(
3141
+ (part) => typeof part === "string" && part.length > 0
3142
+ ).join("\n\n")
3143
+ };
3144
+ }
3113
3145
  function spawnClaude(options) {
3114
3146
  const {
3115
3147
  prompt,
@@ -3130,13 +3162,13 @@ function spawnClaude(options) {
3130
3162
  const hookSocketPath = explicitHookSocketPath ?? resolveHookSocketPath(instanceId);
3131
3163
  runSpawnPreflight(hookSocketPath);
3132
3164
  const isolationConfig = resolveIsolationConfig(isolation);
3133
- const streamingConfig = {
3165
+ const streamingConfig = appendHandoffCompactInstructions({
3134
3166
  ...isolationConfig,
3135
3167
  // Athena depends on the stream-json event feed for live token/context
3136
3168
  // updates, so opt in unless a caller explicitly disables it.
3137
3169
  verbose: isolationConfig.verbose ?? true,
3138
3170
  includePartialMessages: isolationConfig.includePartialMessages ?? true
3139
- };
3171
+ });
3140
3172
  const portableAuth = resolveRuntimeAuthOverlay({ cwd: projectDir });
3141
3173
  const { settingsPath, cleanup } = generateHookSettings(void 0, portableAuth);
3142
3174
  registerCleanupOnExit(cleanup);
@@ -6671,6 +6703,9 @@ function buildCodexPromptOptions(input) {
6671
6703
  plugins: resolveCodexWorkflowPlugins(input.workflowPlan),
6672
6704
  config: {
6673
6705
  model_auto_compact_token_limit: 175e3,
6706
+ // Steer Codex's history compaction toward a handoff-style summary.
6707
+ // `compact_prompt` replaces the default summarization prompt.
6708
+ compact_prompt: HANDOFF_COMPACT_PROMPT,
6674
6709
  ...resolveCodexMcpConfig(input.pluginMcpConfig, input.workflowPlan) ?? {}
6675
6710
  },
6676
6711
  ephemeral: input.ephemeral,
@@ -18202,4 +18237,4 @@ export {
18202
18237
  startUdsServer,
18203
18238
  sendUdsRequest
18204
18239
  };
18205
- //# sourceMappingURL=chunk-XZDDQJUX.js.map
18240
+ //# sourceMappingURL=chunk-UAZ2R7F3.js.map
@@ -170,7 +170,7 @@ function isLoopbackHost(host) {
170
170
 
171
171
  // src/infra/telemetry/client.ts
172
172
  import { PostHog } from "posthog-node";
173
- var POSTHOG_API_KEY = true ? "" : "";
173
+ var POSTHOG_API_KEY = true ? "phc_4UifMvZlZcJdgf3uDqzgEdIlQt98yAeUqVX5tobJcuD\n" : "";
174
174
  var POSTHOG_HOST = "https://us.i.posthog.com";
175
175
  var client = null;
176
176
  var deviceId = null;
@@ -772,4 +772,4 @@ export {
772
772
  trackSetupCompleted,
773
773
  refreshDashboardAccessToken
774
774
  };
775
- //# sourceMappingURL=chunk-BTY7MYYT.js.map
775
+ //# sourceMappingURL=chunk-WRHKXH5M.js.map
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import "./chunk-HXBCZAP7.js";
3
3
  import {
4
4
  rotateGatewayToken
5
- } from "./chunk-MRAM6EYI.js";
5
+ } from "./chunk-D4W7RB25.js";
6
6
  import {
7
7
  CREDENTIAL_SOURCES_TRIED,
8
8
  EXEC_EXIT_CODE,
@@ -97,7 +97,7 @@ import {
97
97
  writeAttachmentMirror,
98
98
  writeGatewayClientConfig,
99
99
  wsClientOptionsForEndpoint
100
- } from "./chunk-XZDDQJUX.js";
100
+ } from "./chunk-UAZ2R7F3.js";
101
101
  import {
102
102
  generateId as generateId2
103
103
  } from "./chunk-BTKQ67RE.js";
@@ -121,7 +121,7 @@ import {
121
121
  trackTelemetryOptedOut,
122
122
  writeDashboardClientConfig,
123
123
  writeGatewayTrace
124
- } from "./chunk-BTY7MYYT.js";
124
+ } from "./chunk-WRHKXH5M.js";
125
125
  import {
126
126
  McpOptionsStep,
127
127
  StepSelector,
@@ -153,10 +153,11 @@ import {
153
153
  resolveWorkflowInstall,
154
154
  resolveWorkflowMarketplaceSource,
155
155
  updateWorkflow,
156
+ updateWorkflows,
156
157
  useWorkflowSessionController,
157
158
  writeGlobalConfig,
158
159
  writeProjectConfig
159
- } from "./chunk-7E54JMXH.js";
160
+ } from "./chunk-SOW2QPXY.js";
160
161
 
161
162
  // src/app/entry/cli.tsx
162
163
  import { render } from "ink";
@@ -12127,6 +12128,7 @@ function runWorkflowCommand(input, deps = {}) {
12127
12128
  const remove = deps.removeWorkflow ?? removeWorkflow;
12128
12129
  const resolveInstalledWorkflow = deps.resolveWorkflow ?? resolveWorkflow;
12129
12130
  const upgrade = deps.updateWorkflow ?? updateWorkflow;
12131
+ const upgradeAll = deps.updateWorkflows ?? updateWorkflows;
12130
12132
  const gatherSources = deps.gatherMarketplaceWorkflowSources ?? gatherMarketplaceWorkflowSources;
12131
12133
  const readGlobal = deps.readGlobalConfig ?? readGlobalConfig;
12132
12134
  const readProject = deps.readProjectConfig ?? readConfig;
@@ -12134,6 +12136,12 @@ function runWorkflowCommand(input, deps = {}) {
12134
12136
  const writeProject = deps.writeProjectConfig ?? writeProjectConfig;
12135
12137
  const logError = deps.logError ?? console.error;
12136
12138
  const logOut = deps.logOut ?? console.log;
12139
+ const logWarn = deps.logWarn ?? console.warn;
12140
+ const warnSelfHeal = (info) => {
12141
+ logWarn(
12142
+ `Warning: rebuilt the cached copy of marketplace ${info.marketplace} because it was unusable.${info.backupDir ? ` Previous cache preserved at ${info.backupDir}.` : ""}`
12143
+ );
12144
+ };
12137
12145
  const fmtError = (error) => `Error: ${error instanceof Error ? error.message : String(error)}`;
12138
12146
  const formatWorkflowLabel = (name) => {
12139
12147
  try {
@@ -12229,7 +12237,7 @@ function runWorkflowCommand(input, deps = {}) {
12229
12237
  const name = input.subcommandArgs[0];
12230
12238
  if (name) {
12231
12239
  try {
12232
- const updatedName = upgrade(name);
12240
+ const updatedName = upgrade(name, void 0, warnSelfHeal);
12233
12241
  logOut(
12234
12242
  `Upgraded workflow: ${formatWorkflowLabel(updatedName)}${formatSourceSuffix(updatedName)}`
12235
12243
  );
@@ -12245,19 +12253,22 @@ function runWorkflowCommand(input, deps = {}) {
12245
12253
  logOut("No installed workflows to upgrade.");
12246
12254
  return 0;
12247
12255
  }
12248
- let failures = 0;
12249
- for (const wfName of all) {
12250
- try {
12251
- const updatedName = upgrade(wfName);
12252
- logOut(
12253
- `Upgraded workflow: ${formatWorkflowLabel(updatedName)}${formatSourceSuffix(updatedName)}`
12254
- );
12255
- } catch (error) {
12256
- logError(`Failed to upgrade "${wfName}": ${fmtError(error)}`);
12257
- failures++;
12258
- }
12256
+ const report = upgradeAll(all);
12257
+ for (const upgradedName of report.upgraded) {
12258
+ logOut(
12259
+ `Upgraded workflow: ${formatWorkflowLabel(upgradedName)}${formatSourceSuffix(upgradedName)}`
12260
+ );
12261
+ }
12262
+ for (const info of report.selfHealed) {
12263
+ warnSelfHeal(info);
12264
+ }
12265
+ for (const { error } of report.marketplaceFailures) {
12266
+ logError(fmtError(error));
12267
+ }
12268
+ for (const { name: failedName, error } of report.workflowFailures) {
12269
+ logError(`Failed to upgrade "${failedName}": ${fmtError(error)}`);
12259
12270
  }
12260
- return failures > 0 ? 1 : 0;
12271
+ return report.marketplaceFailures.length + report.workflowFailures.length > 0 ? 1 : 0;
12261
12272
  }
12262
12273
  case "remove": {
12263
12274
  const name = input.subcommandArgs[0];
@@ -12670,7 +12681,7 @@ var cachedVersion = null;
12670
12681
  function readPackageVersion() {
12671
12682
  if (cachedVersion !== null) return cachedVersion;
12672
12683
  try {
12673
- const injected = "0.5.14";
12684
+ const injected = "0.5.15";
12674
12685
  if (typeof injected === "string" && injected.length > 0) {
12675
12686
  cachedVersion = injected;
12676
12687
  return cachedVersion;
@@ -15417,7 +15428,7 @@ Available commands: ${[...KNOWN_COMMANDS].join(", ")}`
15417
15428
  await exitWith(1);
15418
15429
  return;
15419
15430
  }
15420
- const { default: WorkflowInstallWizard } = await import("./WorkflowInstallWizard-7Y5PWAKW.js");
15431
+ const { default: WorkflowInstallWizard } = await import("./WorkflowInstallWizard-AY4CPQS2.js");
15421
15432
  const { waitUntilExit } = render(
15422
15433
  /* @__PURE__ */ jsx25(
15423
15434
  WorkflowInstallWizard,
@@ -3,13 +3,13 @@ import {
3
3
  ensureDaemonStateDir,
4
4
  runDashboardRuntimeDaemon,
5
5
  startUdsServer
6
- } from "./chunk-XZDDQJUX.js";
6
+ } from "./chunk-UAZ2R7F3.js";
7
7
  import "./chunk-BTKQ67RE.js";
8
8
  import {
9
9
  readDashboardClientConfig,
10
10
  refreshDashboardAccessToken
11
- } from "./chunk-BTY7MYYT.js";
12
- import "./chunk-7E54JMXH.js";
11
+ } from "./chunk-WRHKXH5M.js";
12
+ import "./chunk-SOW2QPXY.js";
13
13
 
14
14
  // src/infra/daemon/logFile.ts
15
15
  import fs from "fs";
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "hooks",
18
18
  "dashboard"
19
19
  ],
20
- "version": "0.5.14",
20
+ "version": "0.5.15",
21
21
  "license": "MIT",
22
22
  "bin": {
23
23
  "athena": "dist/cli.js",