@orbit-build/cli 1.8.0 → 1.9.1

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
@@ -29351,11 +29351,11 @@ ${lanes.join("\n")}
29351
29351
  return toComponents;
29352
29352
  }
29353
29353
  const components = toComponents.slice(start);
29354
- const relative15 = [];
29354
+ const relative16 = [];
29355
29355
  for (; start < fromComponents.length; start++) {
29356
- relative15.push("..");
29356
+ relative16.push("..");
29357
29357
  }
29358
- return ["", ...relative15, ...components];
29358
+ return ["", ...relative16, ...components];
29359
29359
  }
29360
29360
  function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
29361
29361
  Debug.assert(getRootLength(fromDirectory) > 0 === getRootLength(to) > 0, "Paths must either both be absolute or both be relative");
@@ -73900,9 +73900,9 @@ ${lanes.join("\n")}
73900
73900
  if (!startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
73901
73901
  return;
73902
73902
  }
73903
- const relative15 = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
73903
+ const relative16 = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
73904
73904
  for (const symlinkDirectory of symlinkDirectories) {
73905
- const option = resolvePath(symlinkDirectory, relative15);
73905
+ const option = resolvePath(symlinkDirectory, relative16);
73906
73906
  const result2 = cb(option, target === referenceRedirect);
73907
73907
  shouldFilterIgnoredPaths = true;
73908
73908
  if (result2) return result2;
@@ -235100,49 +235100,49 @@ var require_fast_uri = __commonJS({
235100
235100
  schemelessOptions.skipEscape = true;
235101
235101
  return serialize(resolved, schemelessOptions);
235102
235102
  }
235103
- function resolveComponent(base, relative15, options, skipNormalization) {
235103
+ function resolveComponent(base, relative16, options, skipNormalization) {
235104
235104
  const target = {};
235105
235105
  if (!skipNormalization) {
235106
235106
  base = parse7(serialize(base, options), options);
235107
- relative15 = parse7(serialize(relative15, options), options);
235107
+ relative16 = parse7(serialize(relative16, options), options);
235108
235108
  }
235109
235109
  options = options || {};
235110
- if (!options.tolerant && relative15.scheme) {
235111
- target.scheme = relative15.scheme;
235112
- target.userinfo = relative15.userinfo;
235113
- target.host = relative15.host;
235114
- target.port = relative15.port;
235115
- target.path = removeDotSegments(relative15.path || "");
235116
- target.query = relative15.query;
235110
+ if (!options.tolerant && relative16.scheme) {
235111
+ target.scheme = relative16.scheme;
235112
+ target.userinfo = relative16.userinfo;
235113
+ target.host = relative16.host;
235114
+ target.port = relative16.port;
235115
+ target.path = removeDotSegments(relative16.path || "");
235116
+ target.query = relative16.query;
235117
235117
  } else {
235118
- if (relative15.userinfo !== void 0 || relative15.host !== void 0 || relative15.port !== void 0) {
235119
- target.userinfo = relative15.userinfo;
235120
- target.host = relative15.host;
235121
- target.port = relative15.port;
235122
- target.path = removeDotSegments(relative15.path || "");
235123
- target.query = relative15.query;
235118
+ if (relative16.userinfo !== void 0 || relative16.host !== void 0 || relative16.port !== void 0) {
235119
+ target.userinfo = relative16.userinfo;
235120
+ target.host = relative16.host;
235121
+ target.port = relative16.port;
235122
+ target.path = removeDotSegments(relative16.path || "");
235123
+ target.query = relative16.query;
235124
235124
  } else {
235125
- if (!relative15.path) {
235125
+ if (!relative16.path) {
235126
235126
  target.path = base.path;
235127
- if (relative15.query !== void 0) {
235128
- target.query = relative15.query;
235127
+ if (relative16.query !== void 0) {
235128
+ target.query = relative16.query;
235129
235129
  } else {
235130
235130
  target.query = base.query;
235131
235131
  }
235132
235132
  } else {
235133
- if (relative15.path[0] === "/") {
235134
- target.path = removeDotSegments(relative15.path);
235133
+ if (relative16.path[0] === "/") {
235134
+ target.path = removeDotSegments(relative16.path);
235135
235135
  } else {
235136
235136
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
235137
- target.path = "/" + relative15.path;
235137
+ target.path = "/" + relative16.path;
235138
235138
  } else if (!base.path) {
235139
- target.path = relative15.path;
235139
+ target.path = relative16.path;
235140
235140
  } else {
235141
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative15.path;
235141
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative16.path;
235142
235142
  }
235143
235143
  target.path = removeDotSegments(target.path);
235144
235144
  }
235145
- target.query = relative15.query;
235145
+ target.query = relative16.query;
235146
235146
  }
235147
235147
  target.userinfo = base.userinfo;
235148
235148
  target.host = base.host;
@@ -235150,7 +235150,7 @@ var require_fast_uri = __commonJS({
235150
235150
  }
235151
235151
  target.scheme = base.scheme;
235152
235152
  }
235153
- target.fragment = relative15.fragment;
235153
+ target.fragment = relative16.fragment;
235154
235154
  return target;
235155
235155
  }
235156
235156
  function equal(uriA, uriB, options) {
@@ -256022,7 +256022,6 @@ function createDefaultToolRegistry() {
256022
256022
  var defaultToolRegistry = registerDefaultTools(toolRegistry);
256023
256023
 
256024
256024
  // ../context-engine/dist/index.js
256025
- import { join as join63 } from "path";
256026
256025
  import { existsSync as existsSync10 } from "fs";
256027
256026
  import { pathToFileURL } from "url";
256028
256027
  import { z as z29 } from "zod";
@@ -256059,6 +256058,7 @@ import { z as z63 } from "zod";
256059
256058
  import { existsSync as existsSync63, lstatSync as lstatSync5, promises as fs22 } from "fs";
256060
256059
  import { dirname as dirname62, isAbsolute as isAbsolute33, join as join53, win32 as win323 } from "path";
256061
256060
  import { parse as parseYaml32 } from "yaml";
256061
+ import { dirname as dirname7, join as join63, relative as relative5, resolve as resolve62 } from "path";
256062
256062
  var ProjectIndexer = class {
256063
256063
  constructor(cwd) {
256064
256064
  this.cwd = cwd;
@@ -259017,8 +259017,113 @@ function diagnostic(path9, code, message2) {
259017
259017
  function describe2(error) {
259018
259018
  return error instanceof Error ? error.message : String(error);
259019
259019
  }
259020
- var SKILLS_CACHE_TTL_MS = 3e4;
259021
259020
  var PROJECT_INSTRUCTIONS_MAX_BYTES = 1024 * 1024;
259021
+ var PROJECT_INSTRUCTION_CANDIDATES = [
259022
+ "ORBIT.md",
259023
+ ".agents/AGENTS.md",
259024
+ "AGENTS.md",
259025
+ "CLAUDE.md",
259026
+ ".helix/instructions.md",
259027
+ "RUNE.md",
259028
+ ".cursorrules",
259029
+ ".copilotrules"
259030
+ ];
259031
+ var SCOPED_INSTRUCTION_CANDIDATES = [
259032
+ "ORBIT.md",
259033
+ ".agents/AGENTS.md",
259034
+ "AGENTS.md",
259035
+ "CLAUDE.md",
259036
+ ".helix/instructions.md",
259037
+ "RUNE.md",
259038
+ ".cursorrules",
259039
+ ".copilotrules"
259040
+ ];
259041
+ var INSTRUCTION_FILE_MAX_BYTES = PROJECT_INSTRUCTIONS_MAX_BYTES;
259042
+ function loadProjectInstructions(cwd, relevantFiles = []) {
259043
+ const specialized = readInstructionSources(cwd, [
259044
+ ...PROJECT_INSTRUCTION_CANDIDATES,
259045
+ ...discoverScopedInstructionPaths(cwd, relevantFiles)
259046
+ ]);
259047
+ if (specialized.length > 0) return renderInstructionSources(specialized);
259048
+ const readme = readInstructionSources(cwd, ["README.md"]);
259049
+ return renderInstructionSources(readme);
259050
+ }
259051
+ function discoverScopedInstructionPaths(cwd, relevantFiles) {
259052
+ const root = resolve62(cwd);
259053
+ const discovered = /* @__PURE__ */ new Set();
259054
+ for (const file of relevantFiles) {
259055
+ let target;
259056
+ try {
259057
+ target = resolveSafePath(cwd, file);
259058
+ } catch {
259059
+ continue;
259060
+ }
259061
+ let directory = dirname7(target);
259062
+ const ancestors = [];
259063
+ while (true) {
259064
+ ancestors.push(directory);
259065
+ if (directory === root) break;
259066
+ const parent = dirname7(directory);
259067
+ if (parent === directory || !isWithin(root, parent)) break;
259068
+ directory = parent;
259069
+ }
259070
+ for (const ancestor of ancestors.reverse()) {
259071
+ const relativeDirectory = relative5(root, ancestor).replace(/\\/g, "/");
259072
+ for (const candidate of SCOPED_INSTRUCTION_CANDIDATES) {
259073
+ discovered.add(
259074
+ relativeDirectory ? `${relativeDirectory}/${candidate}` : candidate
259075
+ );
259076
+ }
259077
+ }
259078
+ }
259079
+ return [...discovered].sort((left, right) => {
259080
+ const leftDepth = left.split("/").length;
259081
+ const rightDepth = right.split("/").length;
259082
+ return leftDepth - rightDepth || left.localeCompare(right);
259083
+ });
259084
+ }
259085
+ function isWithin(root, target) {
259086
+ const relativePath = relative5(resolve62(root), resolve62(target));
259087
+ return relativePath === "" || !relativePath.startsWith("..") && !relativePath.includes("/..");
259088
+ }
259089
+ function readInstructionSources(cwd, candidates) {
259090
+ const sources = [];
259091
+ const seen = /* @__PURE__ */ new Set();
259092
+ let remainingBytes = PROJECT_INSTRUCTIONS_MAX_BYTES;
259093
+ for (const relativePath of candidates) {
259094
+ if (remainingBytes <= 0) break;
259095
+ const normalized = relativePath.replace(/\\/g, "/").toLowerCase();
259096
+ if (seen.has(normalized)) continue;
259097
+ seen.add(normalized);
259098
+ const path9 = join63(cwd, ...relativePath.split("/"));
259099
+ try {
259100
+ const content = readBoundedRegularFile(
259101
+ path9,
259102
+ Math.min(INSTRUCTION_FILE_MAX_BYTES, remainingBytes)
259103
+ );
259104
+ if (content === void 0 || content.trim().length === 0) continue;
259105
+ const bytes = Buffer.byteLength(content, "utf8");
259106
+ if (bytes > remainingBytes) continue;
259107
+ sources.push({ path: relativePath, content });
259108
+ remainingBytes -= bytes;
259109
+ } catch {
259110
+ }
259111
+ }
259112
+ return sources;
259113
+ }
259114
+ function renderInstructionSources(sources) {
259115
+ if (sources.length === 0) return "";
259116
+ const rendered = sources.map(({ path: path9, content }) => {
259117
+ const normalized = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
259118
+ return `## Orbit instruction source: ${path9}
259119
+ ${normalized.trim()}`;
259120
+ }).join("\n\n");
259121
+ return truncateTextToTokenBudget(
259122
+ rendered,
259123
+ Math.ceil(PROJECT_INSTRUCTIONS_MAX_BYTES / 4)
259124
+ );
259125
+ }
259126
+ var SKILLS_CACHE_TTL_MS = 3e4;
259022
259127
  var MAX_RELEVANT_FILES = 64;
259023
259128
  var FILE_SUMMARY_CONCURRENCY = 8;
259024
259129
  var ContextPackBuilder = class {
@@ -259039,7 +259144,12 @@ var ContextPackBuilder = class {
259039
259144
  }
259040
259145
  async build(relevantFiles, userQuery, options = {}) {
259041
259146
  const projectIndexPromise = this.indexer.index();
259042
- const projectInstructionsPromise = this.loadInstructions();
259147
+ const projectInstructionsPromise = Promise.resolve(
259148
+ loadProjectInstructions(
259149
+ this.cwd,
259150
+ relevantFiles.map((file) => file.path)
259151
+ )
259152
+ );
259043
259153
  const config = ConfigLoader.loadSync(this.cwd);
259044
259154
  const skillsPromise = this.loadSkills(
259045
259155
  config,
@@ -259212,30 +259322,6 @@ var ContextPackBuilder = class {
259212
259322
  }
259213
259323
  return { ...fitted, usedEstimate };
259214
259324
  }
259215
- async loadInstructions() {
259216
- const candidates = [
259217
- "ORBIT.md",
259218
- ".agents/AGENTS.md",
259219
- "AGENTS.md",
259220
- "CLAUDE.md",
259221
- "RUNE.md",
259222
- ".cursorrules",
259223
- ".copilotrules",
259224
- "README.md"
259225
- ];
259226
- for (const name of candidates) {
259227
- const p = join63(this.cwd, ...name.split("/"));
259228
- try {
259229
- const content = readBoundedRegularFile(
259230
- p,
259231
- PROJECT_INSTRUCTIONS_MAX_BYTES
259232
- );
259233
- if (content !== void 0) return content;
259234
- } catch {
259235
- }
259236
- }
259237
- return "";
259238
- }
259239
259325
  async loadSkills(config, userQuery, forcedSkills = []) {
259240
259326
  const skillsConfig = config.skills;
259241
259327
  if (skillsConfig.enabled === false) {
@@ -262704,7 +262790,7 @@ function firstString(...values) {
262704
262790
  // ../session/dist/index.js
262705
262791
  import { z as z31 } from "zod";
262706
262792
  import { createHash as createHash9, randomUUID as randomUUID6 } from "crypto";
262707
- import { dirname as dirname7, isAbsolute as isAbsolute5, join as join9, relative as relative5, resolve as resolve7, sep } from "path";
262793
+ import { dirname as dirname8, isAbsolute as isAbsolute5, join as join9, relative as relative6, resolve as resolve7, sep } from "path";
262708
262794
  import {
262709
262795
  closeSync as closeSync5,
262710
262796
  existsSync as existsSync11,
@@ -263134,7 +263220,7 @@ function syncParentDirectory(filePath) {
263134
263220
  if (process.platform === "win32") return;
263135
263221
  let directoryFd;
263136
263222
  try {
263137
- directoryFd = openSync5(dirname7(filePath), "r");
263223
+ directoryFd = openSync5(dirname8(filePath), "r");
263138
263224
  fsyncSync4(directoryFd);
263139
263225
  } catch {
263140
263226
  } finally {
@@ -263253,7 +263339,7 @@ function sanitizeTraceJsonText(text2, cwd) {
263253
263339
  }
263254
263340
  function normalizeTracePath(filePath, cwd) {
263255
263341
  const absolute = resolve7(cwd, filePath);
263256
- const relativePath = relative5(cwd, absolute);
263342
+ const relativePath = relative6(cwd, absolute);
263257
263343
  if (relativePath && !relativePath.startsWith("..") && !isAbsolute5(relativePath)) {
263258
263344
  return relativePath.split(sep).join("/");
263259
263345
  }
@@ -263703,7 +263789,7 @@ var SessionStore = class {
263703
263789
  } catch {
263704
263790
  return [];
263705
263791
  }
263706
- return this.readHistoryFiles(file, join9(dirname7(file), "history.jsonl"));
263792
+ return this.readHistoryFiles(file, join9(dirname8(file), "history.jsonl"));
263707
263793
  }
263708
263794
  readHistoryFiles(snapshotPath, journalPath) {
263709
263795
  let history = [];
@@ -263774,7 +263860,7 @@ var SessionStore = class {
263774
263860
  const validId = SessionIdSchema.parse(id);
263775
263861
  const sessionRoot = this.resolveSessionRoot();
263776
263862
  const resolved = resolveSafePath(this.cwd, join9(sessionRoot, validId));
263777
- const relativePath = relative5(sessionRoot, resolved);
263863
+ const relativePath = relative6(sessionRoot, resolved);
263778
263864
  if (relativePath !== validId || relativePath.includes(sep) || isAbsolute5(relativePath)) {
263779
263865
  throw new Error(`Invalid session directory: ${id}`);
263780
263866
  }
@@ -277796,7 +277882,7 @@ import { styleText as styleText2, stripVTControlCharacters } from "util";
277796
277882
  import process$1 from "process";
277797
277883
  var import_sisteransi2 = __toESM(require_src(), 1);
277798
277884
  import { existsSync as existsSync15, lstatSync as lstatSync7, readdirSync as readdirSync8 } from "fs";
277799
- import { dirname as dirname8, join as join13 } from "path";
277885
+ import { dirname as dirname9, join as join13 } from "path";
277800
277886
  function isUnicodeSupported() {
277801
277887
  if (process$1.platform !== "win32") {
277802
277888
  return process$1.env.TERM !== "linux";
@@ -281187,6 +281273,22 @@ var TuiEnvironmentStatus = class {
281187
281273
  }
281188
281274
  };
281189
281275
 
281276
+ // src/tui/TuiTerminalLifecycle.ts
281277
+ var ENABLE_ALT_SCREEN = "\x1B[?1049h";
281278
+ var DISABLE_ALT_SCREEN = "\x1B[?1049l";
281279
+ var ENABLE_MOUSE = "\x1B[?1000h\x1B[?1006h";
281280
+ var DISABLE_MOUSE = "\x1B[?1006l\x1B[?1000l";
281281
+ var HIDE_CURSOR = "\x1B[?25l";
281282
+ var RESET_AND_SHOW_CURSOR = "\x1B[0m\x1B[?25h";
281283
+ function enterFullscreenTerminal(mouseEnabled, stdout2 = process.stdout) {
281284
+ const mouseMode = mouseEnabled ? ENABLE_MOUSE : "";
281285
+ stdout2.write(`${ENABLE_ALT_SCREEN}${mouseMode}${HIDE_CURSOR}`);
281286
+ }
281287
+ function leaveFullscreenTerminal(stdin2 = process.stdin, stdout2 = process.stdout) {
281288
+ stdout2.write(`${DISABLE_MOUSE}${DISABLE_ALT_SCREEN}${RESET_AND_SHOW_CURSOR}`);
281289
+ if (stdin2.setRawMode) stdin2.setRawMode(false);
281290
+ }
281291
+
281190
281292
  // src/tui/TextPager.ts
281191
281293
  import readline2 from "readline";
281192
281294
  async function pageText(text2) {
@@ -281788,8 +281890,7 @@ var FullscreenTui = class {
281788
281890
  process.stdin.emit = this.originalStdinEmit;
281789
281891
  this.originalStdinEmit = null;
281790
281892
  }
281791
- const mouseMode = this.config?.tui?.mouse !== false ? "\x1B[?1000h\x1B[?1006h" : "";
281792
- process.stdout.write(`\x1B7\x1B[?1049h${mouseMode}\x1B[?25l`);
281893
+ enterFullscreenTerminal(this.config?.tui?.mouse !== false);
281793
281894
  process.stdout.on("resize", this.onResize);
281794
281895
  if (this.config?.tui?.mouse !== false) {
281795
281896
  this.originalStdinEmit = process.stdin.emit.bind(process.stdin);
@@ -281834,9 +281935,7 @@ var FullscreenTui = class {
281834
281935
  if (!this.isActive) return;
281835
281936
  this.isActive = false;
281836
281937
  process.stdout.off("resize", this.onResize);
281837
- process.stdout.write(
281838
- "\x1B[?1006l\x1B[?1000l\x1B[?1049l\x1B8\x1B[0J\x1B[?25h"
281839
- );
281938
+ leaveFullscreenTerminal();
281840
281939
  this.hasWrittenStdoutSinceStop = false;
281841
281940
  if (this.renderTimeout) {
281842
281941
  clearTimeout(this.renderTimeout);
@@ -282505,7 +282604,7 @@ var FullscreenTui = class {
282505
282604
  if (this.ctrlCTimeout) clearTimeout(this.ctrlCTimeout);
282506
282605
  this.ctrlCTimeout = null;
282507
282606
  this.ctrlCPressedOnce = false;
282508
- cleanup();
282607
+ cleanup(false);
282509
282608
  process.stdout.write("\x1B[?25l");
282510
282609
  this.resolveInput = null;
282511
282610
  resolve38(null);
@@ -282521,6 +282620,11 @@ var FullscreenTui = class {
282521
282620
  }
282522
282621
  return;
282523
282622
  }
282623
+ if (this.ctrlCPressedOnce) {
282624
+ if (this.ctrlCTimeout) clearTimeout(this.ctrlCTimeout);
282625
+ this.ctrlCTimeout = null;
282626
+ this.ctrlCPressedOnce = false;
282627
+ }
282524
282628
  const vimEffect = this.handleVimKeypress(str, key);
282525
282629
  if (vimEffect === "handled") return;
282526
282630
  if (key && key.ctrl && key.name === "r") {
@@ -282543,22 +282647,30 @@ var FullscreenTui = class {
282543
282647
  return;
282544
282648
  }
282545
282649
  if (key && (key.name === "return" || key.name === "enter")) {
282546
- cleanup();
282547
- process.stdout.write("\x1B[?25l");
282548
282650
  const submitted = this.acceptActiveSlashSuggestion() || this.inputBuffer;
282549
282651
  this.historySearchQuery = null;
282652
+ if (!submitted.trim()) {
282653
+ this.activeCommandIndex = 0;
282654
+ this.hideAutocomplete = false;
282655
+ this.historyIndex = -1;
282656
+ this.tempBuffer = "";
282657
+ this.inputBuffer = "";
282658
+ this.cursorPosition = 0;
282659
+ this.render();
282660
+ return;
282661
+ }
282662
+ cleanup();
282663
+ process.stdout.write("\x1B[?25l");
282550
282664
  this.resolveInput = null;
282551
282665
  this.historyScrollOffset = 0;
282552
282666
  this.hasNewOutputWhileScrolled = false;
282553
- if (submitted.trim()) {
282554
- const echoSubmitted = typeof options.echoSubmitted === "function" ? options.echoSubmitted(submitted) : options.echoSubmitted !== false;
282555
- if (echoSubmitted) {
282556
- this.history.push({ role: "user", text: submitted });
282557
- }
282558
- if (this.inputHistory[this.inputHistory.length - 1] !== submitted) {
282559
- this.inputHistory.push(submitted);
282560
- this.saveInputHistory();
282561
- }
282667
+ const echoSubmitted = typeof options.echoSubmitted === "function" ? options.echoSubmitted(submitted) : options.echoSubmitted !== false;
282668
+ if (echoSubmitted) {
282669
+ this.history.push({ role: "user", text: submitted });
282670
+ }
282671
+ if (this.inputHistory[this.inputHistory.length - 1] !== submitted) {
282672
+ this.inputHistory.push(submitted);
282673
+ this.saveInputHistory();
282562
282674
  }
282563
282675
  this.historyIndex = -1;
282564
282676
  this.inputBuffer = "";
@@ -282805,9 +282917,9 @@ var FullscreenTui = class {
282805
282917
  }
282806
282918
  }
282807
282919
  };
282808
- const cleanup = () => {
282920
+ const cleanup = (restoreRawMode = true) => {
282809
282921
  process.stdin.removeListener("keypress", onKeypress);
282810
- if (process.stdin.setRawMode) {
282922
+ if (restoreRawMode && process.stdin.setRawMode) {
282811
282923
  process.stdin.setRawMode(wasRaw);
282812
282924
  }
282813
282925
  process.stdin.pause();
@@ -282921,6 +283033,7 @@ var FullscreenTui = class {
282921
283033
  }
282922
283034
  }
282923
283035
  render(forceFull = false) {
283036
+ if (!this.isActive) return;
282924
283037
  const columns = Math.max(40, process.stdout.columns || 80);
282925
283038
  const rows = Math.max(10, process.stdout.rows || 24);
282926
283039
  const morandi2 = this.theme;
@@ -283540,7 +283653,7 @@ var FullscreenTui = class {
283540
283653
  // src/runtime/ReplController.ts
283541
283654
  import picocolors19 from "picocolors";
283542
283655
  import { rmSync as rmSync8, watch } from "fs";
283543
- import { dirname as dirname13, resolve as resolve14 } from "path";
283656
+ import { dirname as dirname14, resolve as resolve14 } from "path";
283544
283657
  import { homedir as homedir11 } from "os";
283545
283658
  import http3 from "http";
283546
283659
  import { randomBytes as randomBytes5, randomUUID as randomUUID13, timingSafeEqual as timingSafeEqual2 } from "crypto";
@@ -283759,14 +283872,14 @@ function stripQuotes(value) {
283759
283872
  // src/runtime/webui/WebUiRuntime.ts
283760
283873
  import http2 from "http";
283761
283874
  import { randomBytes as randomBytes4, randomUUID as randomUUID10 } from "crypto";
283762
- import { isAbsolute as isAbsolute6, relative as relative8, resolve as resolve11 } from "path";
283875
+ import { isAbsolute as isAbsolute6, relative as relative9, resolve as resolve11 } from "path";
283763
283876
  import { z as z61 } from "zod";
283764
283877
 
283765
283878
  // src/runtime/AutocompleteCandidates.ts
283766
283879
  import glob4 from "fast-glob";
283767
283880
  import { existsSync as existsSync18, readdirSync as readdirSync10 } from "fs";
283768
283881
  import { homedir as homedir10 } from "os";
283769
- import { dirname as dirname9, join as join17, resolve as resolve9 } from "path";
283882
+ import { dirname as dirname10, join as join17, resolve as resolve9 } from "path";
283770
283883
  import { z as z58 } from "zod";
283771
283884
  var AUTOCOMPLETE_SYMBOL_INDEX_MAX_BYTES = 256 * 1024 * 1024;
283772
283885
  var symbolIndexSchema = z58.object({
@@ -283809,7 +283922,7 @@ async function getAutocompleteCandidates(cwd, config, mcpPromptCommands = []) {
283809
283922
  const sessions = [];
283810
283923
  const normCwd = resolve9(cwd).toLowerCase().replace(/\\/g, "/");
283811
283924
  const normHome = resolve9(homedir10()).toLowerCase().replace(/\\/g, "/");
283812
- const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname9(normCwd) === normCwd;
283925
+ const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname10(normCwd) === normCwd;
283813
283926
  if (isHomeOrRoot) {
283814
283927
  return { commands, commandDetails, files, symbols, sessions };
283815
283928
  }
@@ -290333,7 +290446,7 @@ var WEB_UI_FAVICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4
290333
290446
  </svg>`;
290334
290447
 
290335
290448
  // src/runtime/webui/WebUiData.ts
290336
- import { relative as relative6 } from "path";
290449
+ import { relative as relative7 } from "path";
290337
290450
 
290338
290451
  // src/runtime/webui/WebUiSecurity.ts
290339
290452
  import { timingSafeEqual } from "crypto";
@@ -291309,7 +291422,7 @@ async function collectWebUiSkills(options) {
291309
291422
  BUILTIN_SLASH_COMMANDS
291310
291423
  ).filter((command) => command.source === "project");
291311
291424
  const displayPath = (path9) => {
291312
- const projectRelative = relative6(options.cwd, path9).replace(/\\/g, "/");
291425
+ const projectRelative = relative7(options.cwd, path9).replace(/\\/g, "/");
291313
291426
  if (projectRelative && !projectRelative.startsWith("..")) {
291314
291427
  return projectRelative;
291315
291428
  }
@@ -299778,7 +299891,7 @@ var WEB_UI_STYLES = WEB_UI_STYLE_SECTIONS.join("");
299778
299891
 
299779
299892
  // src/runtime/CapabilityScaffolder.ts
299780
299893
  import { promises as fs6 } from "fs";
299781
- import { dirname as dirname10, join as join18, relative as relative7, resolve as resolve10 } from "path";
299894
+ import { dirname as dirname11, join as join18, relative as relative8, resolve as resolve10 } from "path";
299782
299895
  import { randomUUID as randomUUID9 } from "crypto";
299783
299896
  import { stringify as stringifyYaml } from "yaml";
299784
299897
  import { z as z60 } from "zod";
@@ -299828,7 +299941,7 @@ async function createProjectCapability(cwd, request) {
299828
299941
  const stageDirectory = resolveSafePath(
299829
299942
  workspace,
299830
299943
  resolve10(
299831
- dirname10(skillsDirectory),
299944
+ dirname11(skillsDirectory),
299832
299945
  `.orbit-stage-${validated.name}-${randomUUID9()}`
299833
299946
  )
299834
299947
  );
@@ -299861,7 +299974,7 @@ async function createProjectCapability(cwd, request) {
299861
299974
  return {
299862
299975
  kind: validated.kind,
299863
299976
  name: validated.name,
299864
- path: normalizePath5(relative7(workspace, skillPath))
299977
+ path: normalizePath5(relative8(workspace, skillPath))
299865
299978
  };
299866
299979
  }
299867
299980
  const commandsDirectory = await ensureSafeDirectory(
@@ -299894,7 +300007,7 @@ async function createProjectCapability(cwd, request) {
299894
300007
  return {
299895
300008
  kind: validated.kind,
299896
300009
  name: validated.name,
299897
- path: normalizePath5(relative7(workspace, workflowPath))
300010
+ path: normalizePath5(relative8(workspace, workflowPath))
299898
300011
  };
299899
300012
  }
299900
300013
  async function assertMissing(path9) {
@@ -300949,7 +301062,7 @@ function isSkillScopeDiscoverable(cwd, configuredDirectories, scope) {
300949
301062
  scope === "versioned" ? ".agents/skills" : ".orbit/skills"
300950
301063
  );
300951
301064
  return resolveSkillDirectories(cwd, configuredDirectories).some((root) => {
300952
- const pathFromRoot = relative8(root, target);
301065
+ const pathFromRoot = relative9(root, target);
300953
301066
  return pathFromRoot === "" || !pathFromRoot.startsWith("..") && !isAbsolute6(pathFromRoot);
300954
301067
  });
300955
301068
  }
@@ -301517,14 +301630,14 @@ async function handleWorkspaceConfigCommand(configArgument, dependencies) {
301517
301630
  // src/runtime/commands/ContextCommandHandler.ts
301518
301631
  import glob5 from "fast-glob";
301519
301632
  import { existsSync as existsSync19, statSync as statSync6 } from "fs";
301520
- import { isAbsolute as isAbsolute7, relative as relative9, resolve as resolve12 } from "path";
301633
+ import { isAbsolute as isAbsolute7, relative as relative10, resolve as resolve12 } from "path";
301521
301634
  import picocolors12 from "picocolors";
301522
301635
  function parseAddArgument(argument) {
301523
301636
  const match = argument.match(/^(--read-only|--readonly|-r)(?:\s+|$)/);
301524
301637
  return match ? { fileArgument: argument.slice(match[0].length).trim(), readOnly: true } : { fileArgument: argument, readOnly: false };
301525
301638
  }
301526
301639
  function toWorkspaceRelative(cwd, absolutePath) {
301527
- return relative9(cwd, absolutePath).replace(/\\/g, "/");
301640
+ return relative10(cwd, absolutePath).replace(/\\/g, "/");
301528
301641
  }
301529
301642
  function safeCandidateFiles(cwd, candidates) {
301530
301643
  return candidates.filter((candidate) => {
@@ -301870,7 +301983,7 @@ async function handleContextCommand(command, argument, dependencies) {
301870
301983
  // src/runtime/commands/RollbackCommandHandler.ts
301871
301984
  import { execFileSync as execFileSync7 } from "child_process";
301872
301985
  import { existsSync as existsSync20, lstatSync as lstatSync8, mkdirSync as mkdirSync6, rmSync as rmSync7, writeFileSync as writeFileSync7 } from "fs";
301873
- import { dirname as dirname11 } from "path";
301986
+ import { dirname as dirname12 } from "path";
301874
301987
  import picocolors13 from "picocolors";
301875
301988
  import { z as z66 } from "zod";
301876
301989
  var GitStatusCodeSchema = z66.string().length(2).regex(/^[ MADRCU?!]{2}$/);
@@ -302231,7 +302344,7 @@ function restoreWorkspaceSnapshot(cwd, snapshots) {
302231
302344
  );
302232
302345
  }
302233
302346
  }
302234
- mkdirSync6(dirname11(absolutePath), { recursive: true });
302347
+ mkdirSync6(dirname12(absolutePath), { recursive: true });
302235
302348
  writeFileSync7(resolveSafePath(cwd, snapshot.path), snapshot.content);
302236
302349
  } catch (error) {
302237
302350
  failures.push(`${snapshot.path}: ${toErrorMessage3(error)}`);
@@ -302977,7 +303090,7 @@ function copyBooleanCapability(source, sourceKey, target, targetKey) {
302977
303090
  // src/runtime/ProjectLauncher.ts
302978
303091
  import { spawn as spawn5 } from "child_process";
302979
303092
  import { existsSync as existsSync21, mkdirSync as mkdirSync7, realpathSync as realpathSync3, statSync as statSync7 } from "fs";
302980
- import { dirname as dirname12, isAbsolute as isAbsolute8, parse as parse5, resolve as resolve13 } from "path";
303093
+ import { dirname as dirname13, isAbsolute as isAbsolute8, parse as parse5, resolve as resolve13 } from "path";
302981
303094
  var PROJECT_WEB_UI_READY_MESSAGE = "orbit-webui-ready";
302982
303095
  var ProjectLaunchError = class extends Error {
302983
303096
  constructor(code, message2, options) {
@@ -303103,7 +303216,7 @@ function ensureProjectDirectory(projectPath) {
303103
303216
  requireProjectDirectory(projectPath);
303104
303217
  return;
303105
303218
  }
303106
- const parentPath = dirname12(projectPath);
303219
+ const parentPath = dirname13(projectPath);
303107
303220
  if (!existsSync21(parentPath)) {
303108
303221
  throw new ProjectLaunchError(
303109
303222
  "parent_missing",
@@ -306219,11 +306332,11 @@ var IMAGE_TYPES = {
306219
306332
  ".webp": "image/webp"
306220
306333
  };
306221
306334
  function loadTerminalImage(requestedPath, options) {
306222
- const relative15 = requestedPath.trim().replace(/^(["'])(.*)\1$/, "$2");
306223
- if (!relative15 || /[\u0000-\u001f\u007f]/.test(relative15)) {
306335
+ const relative16 = requestedPath.trim().replace(/^(["'])(.*)\1$/, "$2");
306336
+ if (!relative16 || /[\u0000-\u001f\u007f]/.test(relative16)) {
306224
306337
  throw new Error("Image path must be a non-empty workspace-relative path.");
306225
306338
  }
306226
- const path9 = resolveSafePath(options.cwd, relative15);
306339
+ const path9 = resolveSafePath(options.cwd, relative16);
306227
306340
  const leaf = lstatSync9(path9);
306228
306341
  if (leaf.isSymbolicLink() && !options.allowSymbolicLink) {
306229
306342
  throw new Error(
@@ -306231,7 +306344,7 @@ function loadTerminalImage(requestedPath, options) {
306231
306344
  );
306232
306345
  }
306233
306346
  if (!leaf.isFile())
306234
- throw new Error(`Image is not a regular file: ${relative15}`);
306347
+ throw new Error(`Image is not a regular file: ${relative16}`);
306235
306348
  const stats = statSync8(path9);
306236
306349
  if (stats.size <= 0 || stats.size > MAX_TERMINAL_IMAGE_BYTES) {
306237
306350
  throw new Error(
@@ -306825,7 +306938,7 @@ Risk Warning: ${reason}`);
306825
306938
  });
306826
306939
  const normCwd = resolve14(this.cwd).toLowerCase().replace(/\\/g, "/");
306827
306940
  const normHome = resolve14(homedir11()).toLowerCase().replace(/\\/g, "/");
306828
- const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname13(normCwd) === normCwd;
306941
+ const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname14(normCwd) === normCwd;
306829
306942
  if (!isHomeOrRoot) {
306830
306943
  const indexer = new SymbolIndexer(this.cwd);
306831
306944
  this.watcher = watch(
@@ -308679,7 +308792,7 @@ function errorMessage4(error) {
308679
308792
  // src/commands/acp.ts
308680
308793
  import picocolors27 from "picocolors";
308681
308794
  import { createHash as createHash14 } from "crypto";
308682
- import { dirname as dirname14 } from "path";
308795
+ import { dirname as dirname15 } from "path";
308683
308796
  import { existsSync as existsSync29, mkdirSync as mkdirSync8 } from "fs";
308684
308797
 
308685
308798
  // ../acp/dist/index.js
@@ -313491,7 +313604,7 @@ async function runAcpRegistryFetchCommand(options = {}) {
313491
313604
  );
313492
313605
  }
313493
313606
  }
313494
- mkdirSync8(dirname14(outputPath), { recursive: true });
313607
+ mkdirSync8(dirname15(outputPath), { recursive: true });
313495
313608
  replacePrivateFileAtomically(
313496
313609
  outputPath,
313497
313610
  `${JSON.stringify(fetched.file, null, 2)}
@@ -313971,7 +314084,7 @@ function isRecord13(value) {
313971
314084
 
313972
314085
  // src/commands/review.ts
313973
314086
  import { existsSync as existsSync30, lstatSync as lstatSync11, readdirSync as readdirSync11 } from "fs";
313974
- import { isAbsolute as isAbsolute9, join as join20, relative as relative10, sep as sep3 } from "path";
314087
+ import { isAbsolute as isAbsolute9, join as join20, relative as relative11, sep as sep3 } from "path";
313975
314088
  import { z as z85 } from "zod";
313976
314089
  import picocolors28 from "picocolors";
313977
314090
  var FindingSchema = z85.object({
@@ -314058,7 +314171,7 @@ function runReviewCommand(action, artifactName, findingId, options = {}) {
314058
314171
  {
314059
314172
  format,
314060
314173
  artifactCount: selected.length,
314061
- out: relative10(cwd, outputPath).split(sep3).join("/")
314174
+ out: relative11(cwd, outputPath).split(sep3).join("/")
314062
314175
  },
314063
314176
  options.json === true
314064
314177
  );
@@ -314212,7 +314325,7 @@ function normalizeReviewPath(file, cwd) {
314212
314325
  const candidate = file.trim();
314213
314326
  if (!candidate) return "<unknown>";
314214
314327
  const absolute = isAbsolute9(candidate) ? candidate : resolveSafePath(cwd, candidate);
314215
- const relativePath = relative10(cwd, absolute);
314328
+ const relativePath = relative11(cwd, absolute);
314216
314329
  if (relativePath && !relativePath.startsWith("..") && !isAbsolute9(relativePath)) {
314217
314330
  return relativePath.split(sep3).join("/");
314218
314331
  }
@@ -314315,7 +314428,7 @@ import {
314315
314428
  rmSync as rmSync9,
314316
314429
  writeFileSync as writeFileSync8
314317
314430
  } from "fs";
314318
- import { dirname as dirname15, resolve as resolve16 } from "path";
314431
+ import { dirname as dirname16, resolve as resolve16 } from "path";
314319
314432
  import { randomUUID as randomUUID14 } from "crypto";
314320
314433
  import { z as z86 } from "zod";
314321
314434
  var TraceOptionsSchema = z86.object({
@@ -314335,7 +314448,7 @@ function runTraceExport(cwd, sessionId, options = {}) {
314335
314448
  return void 0;
314336
314449
  }
314337
314450
  const outputPath = resolveSafePath(cwd, value.out);
314338
- const directory = dirname15(outputPath);
314451
+ const directory = dirname16(outputPath);
314339
314452
  if (existsSync31(directory)) {
314340
314453
  const stats = lstatSync12(directory);
314341
314454
  if (stats.isSymbolicLink() || !stats.isDirectory()) {
@@ -315189,7 +315302,7 @@ import {
315189
315302
  rmSync as rmSync10,
315190
315303
  writeFileSync as writeFileSync9
315191
315304
  } from "fs";
315192
- import { basename as basename8, dirname as dirname16, join as join27, relative as relative11, resolve as resolve17 } from "path";
315305
+ import { basename as basename8, dirname as dirname17, join as join27, relative as relative12, resolve as resolve17 } from "path";
315193
315306
  import { createHash as createHash15, randomUUID as randomUUID15 } from "crypto";
315194
315307
  import { promisify as promisify5 } from "util";
315195
315308
  import picocolors30 from "picocolors";
@@ -315533,7 +315646,7 @@ function computeAcceptanceFixtureHash(cwd, fixturePaths) {
315533
315646
  };
315534
315647
  for (const requestedPath of Array.from(new Set(fixturePaths)).sort()) {
315535
315648
  const absolutePath = resolveSafePath(cwd, requestedPath);
315536
- const normalized = relative11(resolve17(cwd), absolutePath).replace(/\\/g, "/");
315649
+ const normalized = relative12(resolve17(cwd), absolutePath).replace(/\\/g, "/");
315537
315650
  visit(normalized, absolutePath);
315538
315651
  }
315539
315652
  const digest = createHash15("sha256");
@@ -315678,7 +315791,7 @@ function snapshotWorkspaceIntoWorktree(sourceCwd, worktreeCwd) {
315678
315791
  const targetPath = resolveSafePath(worktreeCwd, relativePath);
315679
315792
  const stats = lstatSync13(sourcePath);
315680
315793
  if (stats.isSymbolicLink() || !stats.isFile()) continue;
315681
- mkdirSync10(dirname16(targetPath), { recursive: true });
315794
+ mkdirSync10(dirname17(targetPath), { recursive: true });
315682
315795
  copyFileSync(sourcePath, targetPath);
315683
315796
  }
315684
315797
  execFileSync9("git", ["add", "-A"], {
@@ -315737,7 +315850,7 @@ function writeEvaluationReport(cwd, runId, report) {
315737
315850
  return filePath;
315738
315851
  }
315739
315852
  function writeJsonAtomically2(filePath, value) {
315740
- const directory = dirname16(filePath);
315853
+ const directory = dirname17(filePath);
315741
315854
  if (existsSync38(directory)) {
315742
315855
  const stats = lstatSync13(directory);
315743
315856
  if (stats.isSymbolicLink() || !stats.isDirectory()) {
@@ -316082,7 +316195,7 @@ import {
316082
316195
  openSync as openSync6,
316083
316196
  statSync as statSync9
316084
316197
  } from "fs";
316085
- import { dirname as dirname17, resolve as resolve20 } from "path";
316198
+ import { dirname as dirname18, resolve as resolve20 } from "path";
316086
316199
  import { z as z215 } from "zod";
316087
316200
  import { randomBytes as randomBytes6, timingSafeEqual as timingSafeEqual3 } from "crypto";
316088
316201
  import {
@@ -316118,7 +316231,7 @@ import {
316118
316231
  } from "https";
316119
316232
  import { timingSafeEqual as timingSafeEqual22 } from "crypto";
316120
316233
  import { existsSync as existsSync310, readFileSync as readFileSync22, realpathSync as realpathSync5, statSync as statSync24 } from "fs";
316121
- import { isAbsolute as isAbsolute10, relative as relative12, resolve as resolve36 } from "path";
316234
+ import { isAbsolute as isAbsolute10, relative as relative13, resolve as resolve36 } from "path";
316122
316235
  import { URL as URL2 } from "url";
316123
316236
  import { z as z410 } from "zod";
316124
316237
  import { createPublicKey as createPublicKey5, verify as verifySignature5 } from "crypto";
@@ -316184,6 +316297,59 @@ var DaemonTaskStateSchema = z96.enum([
316184
316297
  "canceled",
316185
316298
  "orphaned"
316186
316299
  ]);
316300
+ var DaemonFailureCodeSchema = z96.enum([
316301
+ "canceled",
316302
+ "aborted",
316303
+ "lease_expired",
316304
+ "nonzero_exit",
316305
+ "runner_error",
316306
+ "unknown"
316307
+ ]);
316308
+ function deriveDaemonFailureMetadata(state, options = {}) {
316309
+ if (state === "completed" || state === "queued" || state === "running") {
316310
+ return void 0;
316311
+ }
316312
+ if (state === "canceled") {
316313
+ return {
316314
+ failureCode: "canceled",
316315
+ retryable: false,
316316
+ recoveryHint: "Canceled explicitly. Resume the task only when you are ready to retry it."
316317
+ };
316318
+ }
316319
+ if (state === "orphaned") {
316320
+ return {
316321
+ failureCode: "lease_expired",
316322
+ retryable: true,
316323
+ recoveryHint: "The previous daemon stopped renewing its lease. Inspect the workspace, then resume explicitly."
316324
+ };
316325
+ }
316326
+ if (state === "aborted") {
316327
+ return {
316328
+ failureCode: "aborted",
316329
+ retryable: true,
316330
+ recoveryHint: "The daemon stopped before completion. Inspect partial changes, then resume explicitly."
316331
+ };
316332
+ }
316333
+ if (options.exitCode !== void 0 && options.exitCode !== 0) {
316334
+ return {
316335
+ failureCode: "nonzero_exit",
316336
+ retryable: true,
316337
+ recoveryHint: "The runner exited with a non-zero code. Review the recorded error and verification output before resuming."
316338
+ };
316339
+ }
316340
+ if (options.error) {
316341
+ return {
316342
+ failureCode: "runner_error",
316343
+ retryable: true,
316344
+ recoveryHint: "The runner failed unexpectedly. Review the error and workspace state before resuming."
316345
+ };
316346
+ }
316347
+ return {
316348
+ failureCode: "unknown",
316349
+ retryable: true,
316350
+ recoveryHint: "The task ended without a detailed failure receipt. Inspect the workspace before resuming."
316351
+ };
316352
+ }
316187
316353
  var DaemonRunOptionsSchema = z96.object({
316188
316354
  provider: z96.string().trim().min(1).max(256).optional(),
316189
316355
  model: z96.string().trim().min(1).max(256).optional(),
@@ -316222,6 +316388,9 @@ var DaemonTaskRecordSchema = z96.object({
316222
316388
  endedAt: z96.string().datetime().optional(),
316223
316389
  exitCode: z96.number().int().min(0).max(255).optional(),
316224
316390
  error: z96.string().max(4e3).optional(),
316391
+ failureCode: DaemonFailureCodeSchema.optional(),
316392
+ retryable: z96.boolean().optional(),
316393
+ recoveryHint: z96.string().max(500).optional(),
316225
316394
  owner: z96.object({
316226
316395
  instanceId: z96.string().regex(/^daemon_[a-f0-9]{24,64}$/),
316227
316396
  /** Optional for backward-compatible reads of pre-lease v1 records. */
@@ -316296,7 +316465,7 @@ var DaemonAuditLog = class {
316296
316465
  initialize() {
316297
316466
  if (this.initialized) return this.verify();
316298
316467
  const path9 = this.resolveFilePath();
316299
- ensurePrivateDirectory(dirname17(path9));
316468
+ ensurePrivateDirectory(dirname18(path9));
316300
316469
  this.assertRegularPath(path9);
316301
316470
  if (!existsSync39(path9)) {
316302
316471
  this.initialized = true;
@@ -316435,7 +316604,7 @@ var DaemonAuditLog = class {
316435
316604
  return path9;
316436
316605
  }
316437
316606
  assertRegularPath(path9) {
316438
- const parent = dirname17(path9);
316607
+ const parent = dirname18(path9);
316439
316608
  mkdirSync11(parent, { recursive: true });
316440
316609
  if (existsSync39(path9) && (lstatSync15(path9).isSymbolicLink() || !statSync9(path9).isFile())) {
316441
316610
  throw new Error("Daemon audit log must be a regular file.");
@@ -316921,6 +317090,7 @@ var DaemonStore = class {
316921
317090
  endedAt: (/* @__PURE__ */ new Date()).toISOString(),
316922
317091
  ...options.exitCode === void 0 ? {} : { exitCode: options.exitCode },
316923
317092
  ...options.error ? { error: redactSecrets(options.error).slice(0, 4e3) } : {},
317093
+ ...deriveDaemonFailureMetadata(state, options),
316924
317094
  ...options.sessionId ? { sessionId: options.sessionId } : {},
316925
317095
  owner: void 0
316926
317096
  });
@@ -316936,6 +317106,9 @@ var DaemonStore = class {
316936
317106
  state: "canceled",
316937
317107
  endedAt: (/* @__PURE__ */ new Date()).toISOString(),
316938
317108
  error: "Canceled by an authenticated daemon client.",
317109
+ failureCode: "canceled",
317110
+ retryable: false,
317111
+ recoveryHint: "Canceled explicitly. Resume the task only when you are ready to retry it.",
316939
317112
  owner: void 0
316940
317113
  });
316941
317114
  });
@@ -316956,6 +317129,9 @@ var DaemonStore = class {
316956
317129
  endedAt: void 0,
316957
317130
  exitCode: void 0,
316958
317131
  error: void 0,
317132
+ failureCode: void 0,
317133
+ retryable: void 0,
317134
+ recoveryHint: void 0,
316959
317135
  owner: void 0
316960
317136
  });
316961
317137
  });
@@ -317035,6 +317211,9 @@ var DaemonStore = class {
317035
317211
  state: "orphaned",
317036
317212
  endedAt: (/* @__PURE__ */ new Date()).toISOString(),
317037
317213
  error: "The owning Orbit daemon stopped renewing its lease; resume explicitly to retry this task.",
317214
+ failureCode: "lease_expired",
317215
+ retryable: true,
317216
+ recoveryHint: "The previous daemon stopped renewing its lease. Inspect the workspace, then resume explicitly.",
317038
317217
  owner: void 0
317039
317218
  });
317040
317219
  });
@@ -317912,7 +318091,7 @@ function canonicalAllowedWorkspace(input, roots) {
317912
318091
  continue;
317913
318092
  }
317914
318093
  const allowed = realpathSync5.native(allowedPath);
317915
- const relation = relative12(allowed, canonical);
318094
+ const relation = relative13(allowed, canonical);
317916
318095
  if (relation === "" || !relation.startsWith("..") && !isAbsolute10(relation)) {
317917
318096
  return canonical;
317918
318097
  }
@@ -318781,14 +318960,52 @@ function printDaemonResult(json, value) {
318781
318960
  );
318782
318961
  return;
318783
318962
  }
318963
+ if (isRecord17(value) && value.ok === true) {
318964
+ const tasks = Array.isArray(value.tasks) ? value.tasks.filter(isDaemonTaskRecord) : [];
318965
+ if (tasks.length > 0) {
318966
+ console.log(picocolors33.green(`\u2714 ${tasks.length} daemon task(s)`));
318967
+ for (const task2 of tasks) printHumanDaemonTask(task2);
318968
+ return;
318969
+ }
318970
+ const task = isDaemonTaskRecord(value.task) ? value.task : void 0;
318971
+ if (task) {
318972
+ printHumanDaemonTask(task);
318973
+ return;
318974
+ }
318975
+ if (typeof value.activeTasks === "number") {
318976
+ console.log(
318977
+ picocolors33.green(
318978
+ `\u2714 Daemon healthy \xB7 ${value.activeTasks} active task(s)`
318979
+ )
318980
+ );
318981
+ return;
318982
+ }
318983
+ }
318784
318984
  console.log(picocolors33.green(`\u2714 ${JSON.stringify(value)}`));
318785
318985
  }
318986
+ function printHumanDaemonTask(task) {
318987
+ const icon = task.state === "completed" ? "\u2714" : ["failed", "aborted"].includes(task.state) ? "\u2716" : task.state === "canceled" || task.state === "orphaned" ? "\u26A0" : "\u25CF";
318988
+ const summary = `${icon} ${task.id} \xB7 ${task.state} \xB7 attempt ${task.attempt}`;
318989
+ console.log(
318990
+ task.state === "completed" ? picocolors33.green(summary) : task.state === "failed" || task.state === "aborted" ? picocolors33.red(summary) : picocolors33.yellow(summary)
318991
+ );
318992
+ if (task.failureCode) {
318993
+ const retry = task.retryable ? "\u53EF\u6062\u590D" : "\u4E0D\u53EF\u81EA\u52A8\u6062\u590D";
318994
+ console.log(picocolors33.gray(` failure: ${task.failureCode} \xB7 ${retry}`));
318995
+ }
318996
+ if (task.error) console.log(picocolors33.gray(` error: ${task.error}`));
318997
+ if (task.recoveryHint)
318998
+ console.log(picocolors33.cyan(` next: ${task.recoveryHint}`));
318999
+ }
318786
319000
  function formatHost(host) {
318787
319001
  return host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
318788
319002
  }
318789
319003
  function isRecord17(value) {
318790
319004
  return typeof value === "object" && value !== null && !Array.isArray(value);
318791
319005
  }
319006
+ function isDaemonTaskRecord(value) {
319007
+ return isRecord17(value) && typeof value.id === "string" && typeof value.state === "string" && typeof value.attempt === "number";
319008
+ }
318792
319009
  function normalizeRootList(value) {
318793
319010
  if (!Array.isArray(value)) return [];
318794
319011
  return value.flatMap(
@@ -318812,7 +319029,7 @@ import {
318812
319029
  writeFileSync as writeFileSync11
318813
319030
  } from "fs";
318814
319031
  import { createHash as createHash17, randomUUID as randomUUID16 } from "crypto";
318815
- import { dirname as dirname18, isAbsolute as isAbsolute11, join as join31, relative as relative13, resolve as resolve29, sep as sep4 } from "path";
319032
+ import { dirname as dirname19, isAbsolute as isAbsolute11, join as join31, relative as relative14, resolve as resolve29, sep as sep4 } from "path";
318816
319033
  import { z as z99 } from "zod";
318817
319034
  var MAX_BACKUP_BYTES = 64 * 1024 * 1024;
318818
319035
  var MAX_SERIALIZED_BACKUP_BYTES = 96 * 1024 * 1024;
@@ -318901,7 +319118,7 @@ function createProjectBackup(projectDirectory) {
318901
319118
  `Project backup exceeds ${formatBytes3(MAX_BACKUP_BYTES)}. Remove large generated data and retry.`
318902
319119
  );
318903
319120
  }
318904
- const bundlePath = normalizeBundlePath(relative13(orbitRoot, absolutePath));
319121
+ const bundlePath = normalizeBundlePath(relative14(orbitRoot, absolutePath));
318905
319122
  if (!bundlePath) throw new Error("Unable to create a safe backup path.");
318906
319123
  files.push({
318907
319124
  path: bundlePath,
@@ -318921,7 +319138,7 @@ function createProjectBackup(projectDirectory) {
318921
319138
  }
318922
319139
  function writeProjectBackup(outputPath, bundle) {
318923
319140
  const destination = resolve29(outputPath);
318924
- mkdirSync12(dirname18(destination), { recursive: true });
319141
+ mkdirSync12(dirname19(destination), { recursive: true });
318925
319142
  const temporaryPath = `${destination}.${process.pid}.${randomUUID16()}.tmp`;
318926
319143
  try {
318927
319144
  writeFileSync11(
@@ -318981,7 +319198,7 @@ function restoreProjectBackup(projectDirectory, bundle, options = {}) {
318981
319198
  try {
318982
319199
  for (const { file, destination } of planned) {
318983
319200
  const stagedPath = resolveBackupDestination(stagedRoot, file.path);
318984
- mkdirSync12(dirname18(stagedPath), { recursive: true, mode: 448 });
319201
+ mkdirSync12(dirname19(stagedPath), { recursive: true, mode: 448 });
318985
319202
  writeFileSync11(stagedPath, Buffer.from(file.content, "base64"), {
318986
319203
  mode: 384,
318987
319204
  flag: "wx"
@@ -318990,11 +319207,11 @@ function restoreProjectBackup(projectDirectory, bundle, options = {}) {
318990
319207
  }
318991
319208
  for (const { file, destination, stagedPath } of staged) {
318992
319209
  assertRestoreDestinationSafe(orbitRoot, destination, file.path);
318993
- mkdirSync12(dirname18(destination), { recursive: true, mode: 448 });
319210
+ mkdirSync12(dirname19(destination), { recursive: true, mode: 448 });
318994
319211
  let previousPath;
318995
319212
  if (existsSync41(destination)) {
318996
319213
  previousPath = resolveBackupDestination(previousRoot, file.path);
318997
- mkdirSync12(dirname18(previousPath), { recursive: true, mode: 448 });
319214
+ mkdirSync12(dirname19(previousPath), { recursive: true, mode: 448 });
318998
319215
  renameSync8(destination, previousPath);
318999
319216
  }
319000
319217
  const record2 = { destination, previousPath };
@@ -319011,7 +319228,7 @@ function restoreProjectBackup(projectDirectory, bundle, options = {}) {
319011
319228
  try {
319012
319229
  rmSync13(record2.destination, { force: true });
319013
319230
  if (record2.previousPath && existsSync41(record2.previousPath)) {
319014
- mkdirSync12(dirname18(record2.destination), { recursive: true });
319231
+ mkdirSync12(dirname19(record2.destination), { recursive: true });
319015
319232
  renameSync8(record2.previousPath, record2.destination);
319016
319233
  }
319017
319234
  } catch (rollbackError) {
@@ -319034,10 +319251,10 @@ function restoreProjectBackup(projectDirectory, bundle, options = {}) {
319034
319251
  }
319035
319252
  }
319036
319253
  function assertRestoreDestinationSafe(orbitRoot, destination, bundlePath) {
319037
- assertDirectoryChainHasNoSymlink(orbitRoot, dirname18(destination));
319254
+ assertDirectoryChainHasNoSymlink(orbitRoot, dirname19(destination));
319038
319255
  let current = resolve29(orbitRoot);
319039
- const parent = dirname18(destination);
319040
- for (const part of relative13(current, parent).split(sep4).filter(Boolean)) {
319256
+ const parent = dirname19(destination);
319257
+ for (const part of relative14(current, parent).split(sep4).filter(Boolean)) {
319041
319258
  current = join31(current, part);
319042
319259
  if (existsSync41(current) && !lstatSync16(current).isDirectory()) {
319043
319260
  throw new Error(
@@ -319071,7 +319288,7 @@ function listBackupFiles(root) {
319071
319288
  );
319072
319289
  }
319073
319290
  const absolutePath = join31(directory, name);
319074
- const relativePath = relative13(root, absolutePath).split(sep4).join("/");
319291
+ const relativePath = relative14(root, absolutePath).split(sep4).join("/");
319075
319292
  const topLevel = relativePath.split("/")[0]?.toLowerCase() ?? "";
319076
319293
  if (EXCLUDED_TOP_LEVEL.has(topLevel) || topLevel.startsWith(".restore-")) {
319077
319294
  continue;
@@ -319115,7 +319332,7 @@ function resolveBackupDestination(root, filePath) {
319115
319332
  function assertDirectoryChainHasNoSymlink(root, target) {
319116
319333
  const absoluteRoot = resolve29(root);
319117
319334
  const absoluteTarget = resolve29(target);
319118
- const relativeTarget = relative13(absoluteRoot, absoluteTarget);
319335
+ const relativeTarget = relative14(absoluteRoot, absoluteTarget);
319119
319336
  if (relativeTarget.startsWith("..") || isAbsolute11(relativeTarget)) {
319120
319337
  throw new Error("Backup restore directory escapes the project.");
319121
319338
  }
@@ -319246,11 +319463,11 @@ import {
319246
319463
  } from "fs";
319247
319464
  import { randomUUID as randomUUID17 } from "crypto";
319248
319465
  import {
319249
- dirname as dirname19,
319466
+ dirname as dirname20,
319250
319467
  extname as extname7,
319251
319468
  isAbsolute as isAbsolute12,
319252
319469
  join as join35,
319253
- relative as relative14,
319470
+ relative as relative15,
319254
319471
  resolve as resolve31,
319255
319472
  sep as sep5
319256
319473
  } from "path";
@@ -319293,7 +319510,7 @@ var ExtensionManager = class {
319293
319510
  install(cwd, manifestPath, options = {}) {
319294
319511
  const manifest = loadOrbitExtensionManifest(cwd, manifestPath);
319295
319512
  verifyOrbitCompatibility(manifest, readCliVersion());
319296
- const sourceRoot = dirname19(resolve31(cwd, manifestPath));
319513
+ const sourceRoot = dirname20(resolve31(cwd, manifestPath));
319297
319514
  validateContributionFiles(sourceRoot, manifest);
319298
319515
  validateContributionPermissions(manifest);
319299
319516
  const requiresTrust = extensionRequiresTrust(manifest, sourceRoot);
@@ -319347,7 +319564,7 @@ var ExtensionManager = class {
319347
319564
  }
319348
319565
  for (const target2 of declarativeTargets) {
319349
319566
  if (!existsSync45(target2.target)) continue;
319350
- mkdirSync13(dirname19(target2.backup), { recursive: true });
319567
+ mkdirSync13(dirname20(target2.backup), { recursive: true });
319351
319568
  renameSync9(target2.target, target2.backup);
319352
319569
  target2.backedUp = true;
319353
319570
  }
@@ -319364,7 +319581,7 @@ var ExtensionManager = class {
319364
319581
  installedAt: (/* @__PURE__ */ new Date()).toISOString(),
319365
319582
  trusted: options.trust === true || !requiresTrust,
319366
319583
  path: target,
319367
- manifestFile: relative14(sourceRoot, resolve31(cwd, manifestPath)).replace(
319584
+ manifestFile: relative15(sourceRoot, resolve31(cwd, manifestPath)).replace(
319368
319585
  /\\/g,
319369
319586
  "/"
319370
319587
  )
@@ -319390,7 +319607,7 @@ var ExtensionManager = class {
319390
319607
  rmSync14(target2.target, { recursive: true, force: true });
319391
319608
  }
319392
319609
  if (target2.backedUp && existsSync45(target2.backup)) {
319393
- mkdirSync13(dirname19(target2.target), { recursive: true });
319610
+ mkdirSync13(dirname20(target2.target), { recursive: true });
319394
319611
  renameSync9(target2.backup, target2.target);
319395
319612
  }
319396
319613
  }
@@ -319445,7 +319662,7 @@ var ExtensionManager = class {
319445
319662
  try {
319446
319663
  for (const entry of targets) {
319447
319664
  if (!existsSync45(entry.target)) continue;
319448
- mkdirSync13(dirname19(entry.backup), { recursive: true });
319665
+ mkdirSync13(dirname20(entry.backup), { recursive: true });
319449
319666
  renameSync9(entry.target, entry.backup);
319450
319667
  entry.backedUp = true;
319451
319668
  }
@@ -319456,7 +319673,7 @@ var ExtensionManager = class {
319456
319673
  try {
319457
319674
  for (const entry of targets) {
319458
319675
  if (!entry.backedUp || !existsSync45(entry.backup)) continue;
319459
- mkdirSync13(dirname19(entry.target), { recursive: true });
319676
+ mkdirSync13(dirname20(entry.target), { recursive: true });
319460
319677
  renameSync9(entry.backup, entry.target);
319461
319678
  }
319462
319679
  rmSync14(rollbackRoot, { recursive: true, force: true });
@@ -319482,7 +319699,7 @@ var ExtensionManager = class {
319482
319699
  }
319483
319700
  isManagedExtensionPath(extension) {
319484
319701
  const expected = resolve31(this.extensionsDir, extension.id);
319485
- const slot = relative14(this.extensionsDir, expected);
319702
+ const slot = relative15(this.extensionsDir, expected);
319486
319703
  const remainsInsideManagedRoot = slot.length > 0 && slot !== ".." && !slot.startsWith(`..${sep5}`) && !isAbsolute12(slot);
319487
319704
  return remainsInsideManagedRoot && resolve31(extension.path) === expected;
319488
319705
  }
@@ -319606,7 +319823,7 @@ function validateContributionFiles(root, manifest) {
319606
319823
  ];
319607
319824
  for (const contribution of contributions) {
319608
319825
  const target = resolve31(root, contribution.path);
319609
- const relation = relative14(root, target);
319826
+ const relation = relative15(root, target);
319610
319827
  if (relation.startsWith("..") || relation === "") {
319611
319828
  throw new Error(
319612
319829
  `Invalid extension contribution path: ${contribution.path}`
@@ -319663,7 +319880,7 @@ function validateContributionFiles(root, manifest) {
319663
319880
  }
319664
319881
  const definition = loadExtensionToolDefinition(root, tool.path);
319665
319882
  const entrypoint = resolve31(root, definition.entrypoint);
319666
- const relation = relative14(root, entrypoint);
319883
+ const relation = relative15(root, entrypoint);
319667
319884
  if (relation.startsWith("..") || relation === "" || !existsSync45(entrypoint) || lstatSync17(entrypoint).isSymbolicLink() || !lstatSync17(entrypoint).isFile()) {
319668
319885
  throw new Error(
319669
319886
  `Extension tool entrypoint is missing or unsafe: ${definition.entrypoint}`
@@ -319706,7 +319923,7 @@ function copyDirectoryEntry(source, target, budget, depth) {
319706
319923
  if (budget.bytes > MAX_EXTENSION_TREE_BYTES) {
319707
319924
  throw new Error("Extension tree exceeds the 256 MiB limit.");
319708
319925
  }
319709
- mkdirSync13(dirname19(target), { recursive: true });
319926
+ mkdirSync13(dirname20(target), { recursive: true });
319710
319927
  writeFileSync12(target, data, { mode: 384 });
319711
319928
  }
319712
319929
  function materializeDeclarativeContributions(extensionRoot, manifest, orbitDir) {
@@ -319736,7 +319953,7 @@ function removeTransactionArtifact(path9) {
319736
319953
  function assertSafeManagedPath(target, managedRoot) {
319737
319954
  const root = resolve31(managedRoot);
319738
319955
  const absoluteTarget = resolve31(target);
319739
- const relation = relative14(root, absoluteTarget);
319956
+ const relation = relative15(root, absoluteTarget);
319740
319957
  if (relation === ".." || relation.startsWith(`..${sep5}`) || isAbsolute12(relation)) {
319741
319958
  throw new Error(`Managed extension path escapes ${root}.`);
319742
319959
  }
@@ -319766,7 +319983,7 @@ function assertSafeManagedPath(target, managedRoot) {
319766
319983
  }
319767
319984
  }
319768
319985
  if (current === root) return;
319769
- const parent = dirname19(current);
319986
+ const parent = dirname20(current);
319770
319987
  if (parent === current) {
319771
319988
  throw new Error(`Managed extension path could not reach ${root}.`);
319772
319989
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbit-build/cli",
3
- "version": "1.8.0",
3
+ "version": "1.9.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Local-first AI coding agent CLI, TUI, Web UI, diagnostics, and LSP runtime",
6
6
  "keywords": [
@@ -9,6 +9,7 @@ from pathlib import Path
9
9
  from typing import Any
10
10
 
11
11
  from project_utils import build_directory, delivery_directory, generated_directory
12
+ from script_runtime import configure_utf8_output
12
13
 
13
14
 
14
15
  FIGURE_SUFFIXES = {".png"}
@@ -307,4 +308,5 @@ def main() -> None:
307
308
 
308
309
 
309
310
  if __name__ == "__main__":
311
+ configure_utf8_output()
310
312
  main()
@@ -12,6 +12,7 @@ from project_utils import (
12
12
  delivery_directory,
13
13
  question_numbers,
14
14
  )
15
+ from script_runtime import configure_utf8_output
15
16
 
16
17
 
17
18
  SKILL_ROOT = Path(__file__).resolve().parents[1]
@@ -484,4 +485,5 @@ if __name__ == "__main__":
484
485
 
485
486
 
486
487
  if __name__ == "__main__":
488
+ configure_utf8_output()
487
489
  main()
@@ -17,6 +17,7 @@ from project_utils import (
17
17
  load_profile,
18
18
  numeric_limit,
19
19
  )
20
+ from script_runtime import configure_utf8_output
20
21
 
21
22
 
22
23
  EXCLUDED_PARTS = {
@@ -310,4 +311,5 @@ def main() -> None:
310
311
 
311
312
 
312
313
  if __name__ == "__main__":
314
+ configure_utf8_output()
313
315
  main()
@@ -7,6 +7,7 @@ import sys
7
7
  from pathlib import Path
8
8
 
9
9
  from project_utils import control_directory
10
+ from script_runtime import configure_utf8_output
10
11
 
11
12
 
12
13
  def main() -> None:
@@ -55,4 +56,5 @@ def main() -> None:
55
56
 
56
57
 
57
58
  if __name__ == "__main__":
59
+ configure_utf8_output()
58
60
  main()
@@ -5,6 +5,7 @@ import shutil
5
5
  from pathlib import Path
6
6
 
7
7
  from project_utils import build_directory
8
+ from script_runtime import configure_utf8_output
8
9
 
9
10
 
10
11
  CACHE_DIR_NAMES = {
@@ -143,4 +144,5 @@ def main() -> None:
143
144
 
144
145
 
145
146
  if __name__ == "__main__":
147
+ configure_utf8_output()
146
148
  main()
@@ -8,6 +8,7 @@ from pathlib import Path
8
8
  from typing import Any
9
9
 
10
10
  from project_utils import control_path, delivery_directory, iter_regular_files
11
+ from script_runtime import configure_utf8_output
11
12
 
12
13
 
13
14
  EXCLUDED_PARTS = {"__pycache__", ".pytest_cache", ".mypy_cache", ".ruff_cache", "build"}
@@ -119,4 +120,5 @@ def main() -> None:
119
120
 
120
121
 
121
122
  if __name__ == "__main__":
123
+ configure_utf8_output()
122
124
  main()
@@ -12,6 +12,7 @@ sys.dont_write_bytecode = True
12
12
 
13
13
  from evidence_freeze import require_refresh_authorization, write_freeze
14
14
  from project_utils import question_numbers
15
+ from script_runtime import configure_utf8_output
15
16
  from validate_project import code_architecture_errors
16
17
 
17
18
 
@@ -96,4 +97,5 @@ def main() -> None:
96
97
 
97
98
 
98
99
  if __name__ == "__main__":
100
+ configure_utf8_output()
99
101
  main()
@@ -11,6 +11,7 @@ import zipfile
11
11
  from pathlib import Path
12
12
 
13
13
  from project_utils import control_directory
14
+ from script_runtime import configure_utf8_output
14
15
  from typing import Any
15
16
  from xml.etree import ElementTree
16
17
 
@@ -245,4 +246,5 @@ def main() -> None:
245
246
 
246
247
 
247
248
  if __name__ == "__main__":
249
+ configure_utf8_output()
248
250
  main()
@@ -13,6 +13,7 @@ from project_utils import (
13
13
  numeric_limit,
14
14
  question_numbers,
15
15
  )
16
+ from script_runtime import configure_utf8_output
16
17
 
17
18
 
18
19
  EXCLUDED_PARTS = {
@@ -127,4 +128,5 @@ def main() -> None:
127
128
 
128
129
 
129
130
  if __name__ == "__main__":
131
+ configure_utf8_output()
130
132
  main()
@@ -0,0 +1,17 @@
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ from typing import TextIO
5
+
6
+
7
+ def _configure_stream(stream: TextIO) -> None:
8
+ reconfigure = getattr(stream, "reconfigure", None)
9
+ if callable(reconfigure):
10
+ reconfigure(encoding="utf-8", errors="backslashreplace")
11
+
12
+
13
+ def configure_utf8_output() -> None:
14
+ """Keep Chinese paths printable in terminals and redirected subprocess output."""
15
+
16
+ _configure_stream(sys.stdout)
17
+ _configure_stream(sys.stderr)
@@ -27,6 +27,7 @@ from project_utils import (
27
27
  numeric_limit,
28
28
  question_numbers,
29
29
  )
30
+ from script_runtime import configure_utf8_output
30
31
  from evidence_freeze import evidence_differences
31
32
 
32
33
 
@@ -1410,4 +1411,5 @@ def main() -> None:
1410
1411
 
1411
1412
 
1412
1413
  if __name__ == "__main__":
1414
+ configure_utf8_output()
1413
1415
  main()