@vinihcrosa/lumem-os 0.3.0 → 0.4.0

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.
@@ -7262,7 +7262,7 @@ var require_public_api = __commonJS({
7262
7262
  }
7263
7263
  return doc;
7264
7264
  }
7265
- function parse5(src, reviver, options) {
7265
+ function parse6(src, reviver, options) {
7266
7266
  let _reviver = void 0;
7267
7267
  if (typeof reviver === "function") {
7268
7268
  _reviver = reviver;
@@ -7303,7 +7303,7 @@ var require_public_api = __commonJS({
7303
7303
  return value.toString(options);
7304
7304
  return new Document.Document(value, _replacer, options).toString(options);
7305
7305
  }
7306
- exports.parse = parse5;
7306
+ exports.parse = parse6;
7307
7307
  exports.parseAllDocuments = parseAllDocuments;
7308
7308
  exports.parseDocument = parseDocument;
7309
7309
  exports.stringify = stringify2;
@@ -15698,7 +15698,7 @@ var require_transport = __commonJS({
15698
15698
  "../../node_modules/.pnpm/pino@10.3.1/node_modules/pino/lib/transport.js"(exports, module) {
15699
15699
  "use strict";
15700
15700
  var { createRequire } = __require("module");
15701
- var { existsSync: existsSync10 } = __require("node:fs");
15701
+ var { existsSync: existsSync11 } = __require("node:fs");
15702
15702
  var getCallers = require_caller();
15703
15703
  var { join: join21, isAbsolute: isAbsolute8, sep: sep6 } = __require("node:path");
15704
15704
  var { fileURLToPath: fileURLToPath3 } = __require("node:url");
@@ -15772,7 +15772,7 @@ var require_transport = __commonJS({
15772
15772
  return false;
15773
15773
  }
15774
15774
  }
15775
- return isAbsolute8(path) && !existsSync10(path);
15775
+ return isAbsolute8(path) && !existsSync11(path);
15776
15776
  }
15777
15777
  function stripQuotes(value) {
15778
15778
  const first = value[0];
@@ -19370,10 +19370,10 @@ var require_forwarded = __commonJS({
19370
19370
  const remote = header.trim();
19371
19371
  return remote.length ? [socketAddr, remote] : [socketAddr];
19372
19372
  } else {
19373
- return parse5(header, socketAddr);
19373
+ return parse6(header, socketAddr);
19374
19374
  }
19375
19375
  }
19376
- function parse5(header, socketAddr) {
19376
+ function parse6(header, socketAddr) {
19377
19377
  const result = [socketAddr];
19378
19378
  let end = header.length;
19379
19379
  let start = end;
@@ -20875,7 +20875,7 @@ var require_secure_json_parse = __commonJS({
20875
20875
  }
20876
20876
  return obj;
20877
20877
  }
20878
- function parse5(text2, reviver, options) {
20878
+ function parse6(text2, reviver, options) {
20879
20879
  const { stackTraceLimit } = Error;
20880
20880
  Error.stackTraceLimit = 0;
20881
20881
  try {
@@ -20895,9 +20895,9 @@ var require_secure_json_parse = __commonJS({
20895
20895
  Error.stackTraceLimit = stackTraceLimit;
20896
20896
  }
20897
20897
  }
20898
- module.exports = parse5;
20899
- module.exports.default = parse5;
20900
- module.exports.parse = parse5;
20898
+ module.exports = parse6;
20899
+ module.exports.default = parse6;
20900
+ module.exports.parse = parse6;
20901
20901
  module.exports.safeParse = safeParse3;
20902
20902
  module.exports.scan = filter;
20903
20903
  }
@@ -24857,7 +24857,7 @@ var require_fast_uri = __commonJS({
24857
24857
  normalizeString(uri, options);
24858
24858
  } else if (typeof uri === "object") {
24859
24859
  uri = /** @type {T} */
24860
- parse5(serialize(uri, options), options);
24860
+ parse6(serialize(uri, options), options);
24861
24861
  }
24862
24862
  return uri;
24863
24863
  }
@@ -24875,8 +24875,8 @@ var require_fast_uri = __commonJS({
24875
24875
  function resolveComponent(base, relative5, options, skipNormalization) {
24876
24876
  const target = {};
24877
24877
  if (!skipNormalization) {
24878
- base = parse5(serialize(base, options), options);
24879
- relative5 = parse5(serialize(relative5, options), options);
24878
+ base = parse6(serialize(base, options), options);
24879
+ relative5 = parse6(serialize(relative5, options), options);
24880
24880
  }
24881
24881
  options = options || {};
24882
24882
  if (!options.tolerant && relative5.scheme) {
@@ -25120,7 +25120,7 @@ var require_fast_uri = __commonJS({
25120
25120
  }
25121
25121
  return { parsed, malformedAuthorityOrPort };
25122
25122
  }
25123
- function parse5(uri, opts) {
25123
+ function parse6(uri, opts) {
25124
25124
  return parseWithStatus(uri, opts).parsed;
25125
25125
  }
25126
25126
  function normalizeString(uri, opts) {
@@ -25149,7 +25149,7 @@ var require_fast_uri = __commonJS({
25149
25149
  resolveComponent,
25150
25150
  equal,
25151
25151
  serialize,
25152
- parse: parse5
25152
+ parse: parse6
25153
25153
  };
25154
25154
  module.exports = fastUri;
25155
25155
  module.exports.default = fastUri;
@@ -27877,14 +27877,14 @@ var require_ref2 = __commonJS({
27877
27877
  cxt.ok(valid);
27878
27878
  function validateJtdRef() {
27879
27879
  var _a;
27880
- const refSchema = (_a = root.schema.definitions) === null || _a === void 0 ? void 0 : _a[ref];
27881
- if (!refSchema) {
27880
+ const refSchema2 = (_a = root.schema.definitions) === null || _a === void 0 ? void 0 : _a[ref];
27881
+ if (!refSchema2) {
27882
27882
  throw new ref_error_1.default(it.opts.uriResolver, "", ref, `No definition ${ref}`);
27883
27883
  }
27884
- if (hasRef(refSchema) || !it.opts.inlineRefs)
27885
- callValidate(refSchema);
27884
+ if (hasRef(refSchema2) || !it.opts.inlineRefs)
27885
+ callValidate(refSchema2);
27886
27886
  else
27887
- inlineRefSchema(refSchema);
27887
+ inlineRefSchema(refSchema2);
27888
27888
  }
27889
27889
  function callValidate(schema2) {
27890
27890
  const sch = compile_1.compileSchema.call(it.self, new compile_1.SchemaEnv({ schema: schema2, root, schemaPath: `/definitions/${ref}` }));
@@ -28869,13 +28869,13 @@ var require_serialize = __commonJS({
28869
28869
  function serializeRef(cxt) {
28870
28870
  const { gen, self, data, definitions, schema: schema2, schemaEnv } = cxt;
28871
28871
  const { ref } = schema2;
28872
- const refSchema = definitions[ref];
28873
- if (!refSchema)
28872
+ const refSchema2 = definitions[ref];
28873
+ if (!refSchema2)
28874
28874
  throw new ref_error_1.default(self.opts.uriResolver, "", ref, `No definition ${ref}`);
28875
- if (!(0, ref_1.hasRef)(refSchema))
28876
- return serializeCode({ ...cxt, schema: refSchema });
28875
+ if (!(0, ref_1.hasRef)(refSchema2))
28876
+ return serializeCode({ ...cxt, schema: refSchema2 });
28877
28877
  const { root } = schemaEnv;
28878
- const sch = compileSerializer.call(self, new __1.SchemaEnv({ schema: refSchema, root }), definitions);
28878
+ const sch = compileSerializer.call(self, new __1.SchemaEnv({ schema: refSchema2, root }), definitions);
28879
28879
  gen.add(names_1.default.json, (0, codegen_1._)`${getSerialize(gen, sch)}(${data})`);
28880
28880
  }
28881
28881
  function getSerialize(gen, sch) {
@@ -29124,9 +29124,9 @@ var require_parse = __commonJS({
29124
29124
  const parseFuncCode = gen.toString();
29125
29125
  sourceCode = `${gen.scopeRefs(names_1.default.scope)}return ${parseFuncCode}`;
29126
29126
  const makeParse = new Function(`${names_1.default.scope}`, sourceCode);
29127
- const parse5 = makeParse(this.scope.get());
29128
- this.scope.value(parseName, { ref: parse5 });
29129
- sch.parse = parse5;
29127
+ const parse6 = makeParse(this.scope.get());
29128
+ this.scope.value(parseName, { ref: parse6 });
29129
+ sch.parse = parse6;
29130
29130
  } catch (e) {
29131
29131
  if (sourceCode)
29132
29132
  this.logger.error("Error compiling parser, function code:", sourceCode);
@@ -29367,13 +29367,13 @@ var require_parse = __commonJS({
29367
29367
  function parseRef(cxt) {
29368
29368
  const { gen, self, definitions, schema: schema2, schemaEnv } = cxt;
29369
29369
  const { ref } = schema2;
29370
- const refSchema = definitions[ref];
29371
- if (!refSchema)
29370
+ const refSchema2 = definitions[ref];
29371
+ if (!refSchema2)
29372
29372
  throw new ref_error_1.default(self.opts.uriResolver, "", ref, `No definition ${ref}`);
29373
- if (!(0, ref_1.hasRef)(refSchema))
29374
- return parseCode({ ...cxt, schema: refSchema });
29373
+ if (!(0, ref_1.hasRef)(refSchema2))
29374
+ return parseCode({ ...cxt, schema: refSchema2 });
29375
29375
  const { root } = schemaEnv;
29376
- const sch = compileParser.call(self, new __1.SchemaEnv({ schema: refSchema, root }), definitions);
29376
+ const sch = compileParser.call(self, new __1.SchemaEnv({ schema: refSchema2, root }), definitions);
29377
29377
  partialParse(cxt, getParser(gen, sch), true);
29378
29378
  }
29379
29379
  function getParser(gen, sch) {
@@ -30141,7 +30141,7 @@ var require_fast_uri2 = __commonJS({
30141
30141
  normalizeString(uri, options);
30142
30142
  } else if (typeof uri === "object") {
30143
30143
  uri = /** @type {T} */
30144
- parse5(serialize(uri, options), options);
30144
+ parse6(serialize(uri, options), options);
30145
30145
  }
30146
30146
  return uri;
30147
30147
  }
@@ -30159,8 +30159,8 @@ var require_fast_uri2 = __commonJS({
30159
30159
  function resolveComponent(base, relative5, options, skipNormalization) {
30160
30160
  const target = {};
30161
30161
  if (!skipNormalization) {
30162
- base = parse5(serialize(base, options), options);
30163
- relative5 = parse5(serialize(relative5, options), options);
30162
+ base = parse6(serialize(base, options), options);
30163
+ relative5 = parse6(serialize(relative5, options), options);
30164
30164
  }
30165
30165
  options = options || {};
30166
30166
  if (!options.tolerant && relative5.scheme) {
@@ -30403,7 +30403,7 @@ var require_fast_uri2 = __commonJS({
30403
30403
  }
30404
30404
  return { parsed, malformedAuthorityOrPort };
30405
30405
  }
30406
- function parse5(uri, opts) {
30406
+ function parse6(uri, opts) {
30407
30407
  return parseWithStatus(uri, opts).parsed;
30408
30408
  }
30409
30409
  function normalizeString(uri, opts) {
@@ -30432,7 +30432,7 @@ var require_fast_uri2 = __commonJS({
30432
30432
  resolveComponent,
30433
30433
  equal,
30434
30434
  serialize,
30435
- parse: parse5
30435
+ parse: parse6
30436
30436
  };
30437
30437
  module.exports = fastUri;
30438
30438
  module.exports.default = fastUri;
@@ -34762,7 +34762,7 @@ var require_parse2 = __commonJS({
34762
34762
  "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/parse.js"(exports, module) {
34763
34763
  "use strict";
34764
34764
  var SemVer = require_semver();
34765
- var parse5 = (version3, options, throwErrors = false) => {
34765
+ var parse6 = (version3, options, throwErrors = false) => {
34766
34766
  if (version3 instanceof SemVer) {
34767
34767
  return version3;
34768
34768
  }
@@ -34775,7 +34775,7 @@ var require_parse2 = __commonJS({
34775
34775
  throw er;
34776
34776
  }
34777
34777
  };
34778
- module.exports = parse5;
34778
+ module.exports = parse6;
34779
34779
  }
34780
34780
  });
34781
34781
 
@@ -34783,9 +34783,9 @@ var require_parse2 = __commonJS({
34783
34783
  var require_valid = __commonJS({
34784
34784
  "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/valid.js"(exports, module) {
34785
34785
  "use strict";
34786
- var parse5 = require_parse2();
34786
+ var parse6 = require_parse2();
34787
34787
  var valid = (version3, options) => {
34788
- const v = parse5(version3, options);
34788
+ const v = parse6(version3, options);
34789
34789
  return v ? v.version : null;
34790
34790
  };
34791
34791
  module.exports = valid;
@@ -34796,9 +34796,9 @@ var require_valid = __commonJS({
34796
34796
  var require_clean = __commonJS({
34797
34797
  "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/clean.js"(exports, module) {
34798
34798
  "use strict";
34799
- var parse5 = require_parse2();
34799
+ var parse6 = require_parse2();
34800
34800
  var clean2 = (version3, options) => {
34801
- const s = parse5(version3.trim().replace(/^[=v]+/, ""), options);
34801
+ const s = parse6(version3.trim().replace(/^[=v]+/, ""), options);
34802
34802
  return s ? s.version : null;
34803
34803
  };
34804
34804
  module.exports = clean2;
@@ -34833,10 +34833,10 @@ var require_inc = __commonJS({
34833
34833
  var require_diff = __commonJS({
34834
34834
  "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/diff.js"(exports, module) {
34835
34835
  "use strict";
34836
- var parse5 = require_parse2();
34836
+ var parse6 = require_parse2();
34837
34837
  var diff = (version1, version22) => {
34838
- const v1 = parse5(version1, null, true);
34839
- const v2 = parse5(version22, null, true);
34838
+ const v1 = parse6(version1, null, true);
34839
+ const v2 = parse6(version22, null, true);
34840
34840
  const comparison = v1.compare(v2);
34841
34841
  if (comparison === 0) {
34842
34842
  return null;
@@ -34907,9 +34907,9 @@ var require_patch = __commonJS({
34907
34907
  var require_prerelease = __commonJS({
34908
34908
  "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/prerelease.js"(exports, module) {
34909
34909
  "use strict";
34910
- var parse5 = require_parse2();
34910
+ var parse6 = require_parse2();
34911
34911
  var prerelease = (version3, options) => {
34912
- const parsed = parse5(version3, options);
34912
+ const parsed = parse6(version3, options);
34913
34913
  return parsed && parsed.prerelease.length ? parsed.prerelease : null;
34914
34914
  };
34915
34915
  module.exports = prerelease;
@@ -35095,7 +35095,7 @@ var require_coerce = __commonJS({
35095
35095
  "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/coerce.js"(exports, module) {
35096
35096
  "use strict";
35097
35097
  var SemVer = require_semver();
35098
- var parse5 = require_parse2();
35098
+ var parse6 = require_parse2();
35099
35099
  var { safeRe: re, t: t2 } = require_re();
35100
35100
  var coerce2 = (version3, options) => {
35101
35101
  if (version3 instanceof SemVer) {
@@ -35130,7 +35130,7 @@ var require_coerce = __commonJS({
35130
35130
  const patch = match[4] || "0";
35131
35131
  const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
35132
35132
  const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
35133
- return parse5(`${major}.${minor}.${patch}${prerelease}${build}`, options);
35133
+ return parse6(`${major}.${minor}.${patch}${prerelease}${build}`, options);
35134
35134
  };
35135
35135
  module.exports = coerce2;
35136
35136
  }
@@ -35140,7 +35140,7 @@ var require_coerce = __commonJS({
35140
35140
  var require_truncate = __commonJS({
35141
35141
  "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/truncate.js"(exports, module) {
35142
35142
  "use strict";
35143
- var parse5 = require_parse2();
35143
+ var parse6 = require_parse2();
35144
35144
  var constants4 = require_constants2();
35145
35145
  var SemVer = require_semver();
35146
35146
  var truncate = (version3, truncation, options) => {
@@ -35152,7 +35152,7 @@ var require_truncate = __commonJS({
35152
35152
  };
35153
35153
  var cloneInputVersion = (version3, options) => {
35154
35154
  const versionStringToParse = version3 instanceof SemVer ? version3.version : version3;
35155
- return parse5(versionStringToParse, options);
35155
+ return parse6(versionStringToParse, options);
35156
35156
  };
35157
35157
  var doTruncation = (version3, truncation) => {
35158
35158
  if (isPrerelease(truncation)) {
@@ -36196,7 +36196,7 @@ var require_semver2 = __commonJS({
36196
36196
  var constants4 = require_constants2();
36197
36197
  var SemVer = require_semver();
36198
36198
  var identifiers = require_identifiers();
36199
- var parse5 = require_parse2();
36199
+ var parse6 = require_parse2();
36200
36200
  var valid = require_valid();
36201
36201
  var clean2 = require_clean();
36202
36202
  var inc = require_inc();
@@ -36235,7 +36235,7 @@ var require_semver2 = __commonJS({
36235
36235
  var simplifyRange = require_simplify();
36236
36236
  var subset = require_subset();
36237
36237
  module.exports = {
36238
- parse: parse5,
36238
+ parse: parse6,
36239
36239
  valid,
36240
36240
  clean: clean2,
36241
36241
  inc,
@@ -36919,7 +36919,7 @@ var require_parse3 = __commonJS({
36919
36919
  var Empty = function() {
36920
36920
  };
36921
36921
  Empty.prototype = /* @__PURE__ */ Object.create(null);
36922
- function parse5(input) {
36922
+ function parse6(input) {
36923
36923
  const result = new Empty();
36924
36924
  if (typeof input !== "string") {
36925
36925
  return result;
@@ -36999,7 +36999,7 @@ var require_parse3 = __commonJS({
36999
36999
  }
37000
37000
  return result;
37001
37001
  }
37002
- module.exports = parse5;
37002
+ module.exports = parse6;
37003
37003
  }
37004
37004
  });
37005
37005
 
@@ -37251,15 +37251,15 @@ var require_stringify2 = __commonJS({
37251
37251
  var require_lib = __commonJS({
37252
37252
  "../../node_modules/.pnpm/fast-querystring@1.1.2/node_modules/fast-querystring/lib/index.js"(exports, module) {
37253
37253
  "use strict";
37254
- var parse5 = require_parse3();
37254
+ var parse6 = require_parse3();
37255
37255
  var stringify2 = require_stringify2();
37256
37256
  var fastQuerystring = {
37257
- parse: parse5,
37257
+ parse: parse6,
37258
37258
  stringify: stringify2
37259
37259
  };
37260
37260
  module.exports = fastQuerystring;
37261
37261
  module.exports.default = fastQuerystring;
37262
- module.exports.parse = parse5;
37262
+ module.exports.parse = parse6;
37263
37263
  module.exports.stringify = stringify2;
37264
37264
  }
37265
37265
  });
@@ -37988,7 +37988,7 @@ var require_dist4 = __commonJS({
37988
37988
  var require_safe_regex2 = __commonJS({
37989
37989
  "../../node_modules/.pnpm/safe-regex2@5.1.1/node_modules/safe-regex2/index.js"(exports, module) {
37990
37990
  "use strict";
37991
- var parse5 = require_dist4();
37991
+ var parse6 = require_dist4();
37992
37992
  var { types } = require_dist4();
37993
37993
  function walk(node, opts, starHeight) {
37994
37994
  let i;
@@ -38023,7 +38023,7 @@ var require_safe_regex2 = __commonJS({
38023
38023
  if (isRegExp(re)) re = re.source;
38024
38024
  else if (typeof re !== "string") re = String(re);
38025
38025
  try {
38026
- return walk(parse5(re), opts, 0);
38026
+ return walk(parse6(re), opts, 0);
38027
38027
  } catch {
38028
38028
  return false;
38029
38029
  }
@@ -41097,7 +41097,7 @@ var require_set_cookie = __commonJS({
41097
41097
  }
41098
41098
  return { name, value };
41099
41099
  }
41100
- function parse5(input, options) {
41100
+ function parse6(input, options) {
41101
41101
  options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
41102
41102
  if (!input) {
41103
41103
  if (!options.map) {
@@ -41196,8 +41196,8 @@ var require_set_cookie = __commonJS({
41196
41196
  }
41197
41197
  return cookiesStrings;
41198
41198
  }
41199
- module.exports = parse5;
41200
- module.exports.parse = parse5;
41199
+ module.exports = parse6;
41200
+ module.exports.parse = parse6;
41201
41201
  module.exports.parseString = parseString2;
41202
41202
  module.exports.splitCookiesString = splitCookiesString;
41203
41203
  }
@@ -45305,7 +45305,7 @@ var require_extension = __commonJS({
45305
45305
  if (dest[name] === void 0) dest[name] = [elem];
45306
45306
  else dest[name].push(elem);
45307
45307
  }
45308
- function parse5(header) {
45308
+ function parse6(header) {
45309
45309
  const offers = /* @__PURE__ */ Object.create(null);
45310
45310
  let params = /* @__PURE__ */ Object.create(null);
45311
45311
  let mustUnescape = false;
@@ -45445,7 +45445,7 @@ var require_extension = __commonJS({
45445
45445
  }).join(", ");
45446
45446
  }).join(", ");
45447
45447
  }
45448
- module.exports = { format, parse: parse5 };
45448
+ module.exports = { format, parse: parse6 };
45449
45449
  }
45450
45450
  });
45451
45451
 
@@ -45479,7 +45479,7 @@ var require_websocket = __commonJS({
45479
45479
  var {
45480
45480
  EventTarget: { addEventListener, removeEventListener }
45481
45481
  } = require_event_target();
45482
- var { format, parse: parse5 } = require_extension();
45482
+ var { format, parse: parse6 } = require_extension();
45483
45483
  var { toBuffer } = require_buffer_util();
45484
45484
  var kAborted = Symbol("kAborted");
45485
45485
  var protocolVersions = [8, 13];
@@ -46156,7 +46156,7 @@ var require_websocket = __commonJS({
46156
46156
  }
46157
46157
  let extensions;
46158
46158
  try {
46159
- extensions = parse5(secWebSocketExtensions);
46159
+ extensions = parse6(secWebSocketExtensions);
46160
46160
  } catch (err) {
46161
46161
  const message = "Invalid Sec-WebSocket-Extensions header";
46162
46162
  abortHandshake(websocket, socket, message);
@@ -46448,7 +46448,7 @@ var require_subprotocol = __commonJS({
46448
46448
  "../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/subprotocol.js"(exports, module) {
46449
46449
  "use strict";
46450
46450
  var { tokenChars } = require_validation3();
46451
- function parse5(header) {
46451
+ function parse6(header) {
46452
46452
  const protocols = /* @__PURE__ */ new Set();
46453
46453
  let start = -1;
46454
46454
  let end = -1;
@@ -46484,7 +46484,7 @@ var require_subprotocol = __commonJS({
46484
46484
  protocols.add(protocol);
46485
46485
  return protocols;
46486
46486
  }
46487
- module.exports = { parse: parse5 };
46487
+ module.exports = { parse: parse6 };
46488
46488
  }
46489
46489
  });
46490
46490
 
@@ -50375,7 +50375,7 @@ var require_commonjs5 = __commonJS({
50375
50375
  var node_url_1 = __require("node:url");
50376
50376
  var fs_1 = __require("fs");
50377
50377
  var actualFS = __importStar(__require("node:fs"));
50378
- var realpathSync = fs_1.realpathSync.native;
50378
+ var realpathSync3 = fs_1.realpathSync.native;
50379
50379
  var promises_1 = __require("node:fs/promises");
50380
50380
  var minipass_1 = require_commonjs4();
50381
50381
  var defaultFS = {
@@ -50383,7 +50383,7 @@ var require_commonjs5 = __commonJS({
50383
50383
  readdir: fs_1.readdir,
50384
50384
  readdirSync: fs_1.readdirSync,
50385
50385
  readlinkSync: fs_1.readlinkSync,
50386
- realpathSync,
50386
+ realpathSync: realpathSync3,
50387
50387
  promises: {
50388
50388
  lstat: promises_1.lstat,
50389
50389
  readdir: promises_1.readdir,
@@ -53510,7 +53510,7 @@ var require_dist6 = __commonJS({
53510
53510
  var HOUR = MIN * 60;
53511
53511
  var DAY2 = HOUR * 24;
53512
53512
  var YEAR = DAY2 * 365.25;
53513
- function parse5(val) {
53513
+ function parse6(val) {
53514
53514
  var num, arr = val.toLowerCase().match(RGX);
53515
53515
  if (arr != null && (num = parseFloat(arr[1]))) {
53516
53516
  if (arr[3] != null) return num * SEC;
@@ -53536,7 +53536,7 @@ var require_dist6 = __commonJS({
53536
53536
  return fmt(abs / YEAR, pfx, "year", long);
53537
53537
  }
53538
53538
  exports.format = format;
53539
- exports.parse = parse5;
53539
+ exports.parse = parse6;
53540
53540
  }
53541
53541
  });
53542
53542
 
@@ -54988,14 +54988,14 @@ var require_accept_negotiator = __commonJS({
54988
54988
  }
54989
54989
  return false;
54990
54990
  }
54991
- parse5(header, processMatch);
54991
+ parse6(header, processMatch);
54992
54992
  return preferredEncoding;
54993
54993
  }
54994
54994
  var BEGIN = 0;
54995
54995
  var TOKEN = 1;
54996
54996
  var QUALITY = 2;
54997
54997
  var END = 3;
54998
- function parse5(header, processMatch) {
54998
+ function parse6(header, processMatch) {
54999
54999
  let str = "";
55000
55000
  let quality;
55001
55001
  let state = BEGIN;
@@ -55131,7 +55131,7 @@ var require_content_disposition = __commonJS({
55131
55131
  "../../node_modules/.pnpm/content-disposition@0.5.4/node_modules/content-disposition/index.js"(exports, module) {
55132
55132
  "use strict";
55133
55133
  module.exports = contentDisposition;
55134
- module.exports.parse = parse5;
55134
+ module.exports.parse = parse6;
55135
55135
  var basename5 = __require("path").basename;
55136
55136
  var Buffer2 = require_safe_buffer().Buffer;
55137
55137
  var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;
@@ -55222,7 +55222,7 @@ var require_content_disposition = __commonJS({
55222
55222
  function getlatin1(val) {
55223
55223
  return String(val).replace(NON_LATIN1_REGEXP, "?");
55224
55224
  }
55225
- function parse5(string4) {
55225
+ function parse6(string4) {
55226
55226
  if (!string4 || typeof string4 !== "string") {
55227
55227
  throw new TypeError("argument string is required");
55228
55228
  }
@@ -55620,8 +55620,8 @@ var require_static = __commonJS({
55620
55620
  }
55621
55621
  }
55622
55622
  }
55623
- for (const [dirname12, rootPath] of indexDirs.entries()) {
55624
- const pathname = dirname12 + (dirname12.endsWith("/") ? "" : "/");
55623
+ for (const [dirname13, rootPath] of indexDirs.entries()) {
55624
+ const pathname = dirname13 + (dirname13.endsWith("/") ? "" : "/");
55625
55625
  const file2 = "/" + pathname.replace(prefix, "");
55626
55626
  setUpHeadAndGet(routeOpts, pathname, file2, rootPath);
55627
55627
  if (opts.redirect === true) {
@@ -55918,7 +55918,7 @@ var require_static = __commonJS({
55918
55918
 
55919
55919
  // src/boot/reconcile.ts
55920
55920
  import { existsSync as existsSync2 } from "node:fs";
55921
- import { mkdir as mkdir2, readdir as readdir2, rename, rm } from "node:fs/promises";
55921
+ import { mkdir as mkdir2, readdir as readdir2, rename as rename2, rm as rm2 } from "node:fs/promises";
55922
55922
  import { dirname as dirname2, join as join4 } from "node:path";
55923
55923
 
55924
55924
  // src/acp/transcript-maintenance.ts
@@ -60415,8 +60415,23 @@ var CLAUDE_ADAPTER = {
60415
60415
  // Duas strings porque não são a mesma string, e é exatamente essa a armadilha:
60416
60416
  // o pacote é escopado e o binário não.
60417
60417
  command: "claude-agent-acp",
60418
- pinnedVersion: "0.40.0",
60418
+ /*
60419
+ * Medido em 2026-09-08, e a medição é o motivo de não ser `0.40.0`.
60420
+ *
60421
+ * O adaptador **embute** o runtime: `0.40.0` depende de
60422
+ * `@anthropic-ai/claude-agent-sdk@0.3.160`, que é o Claude Code `2.1.160`, e a
60423
+ * API recusa o modelo default desta conta com *"version 2.1.251 or newer is
60424
+ * required"*. Quem responde `session/prompt` é o SDK de dentro, então o
60425
+ * `claude` do PATH — `2.1.263` na máquina que mediu — não salva.
60426
+ *
60427
+ * `0.75.1` traz o SDK `0.3.257`. O estudo, com as duas versões lado a lado,
60428
+ * está em `docs/project/claude-agent-acp-0.75.md`.
60429
+ */
60430
+ pinnedVersion: "0.75.1",
60419
60431
  cli: { command: "claude", install: null },
60432
+ // Medido: `0.40.0` embutia o `0.3.160` e `0.75.1` embute o `0.3.257`, e o
60433
+ // número depois do `0.3.` é o do Claude Code que a API cobra na recusa.
60434
+ runtime: "@anthropic-ai/claude-agent-sdk",
60420
60435
  apiKeyEnv: ["ANTHROPIC_API_KEY"]
60421
60436
  };
60422
60437
  var CODEX_ADAPTER = {
@@ -60429,6 +60444,10 @@ var CODEX_ADAPTER = {
60429
60444
  pinnedVersion: "1.10.0",
60430
60445
  // Null, e não `{ command: "codex" }` por simetria: ele traz o próprio.
60431
60446
  cli: null,
60447
+ // Ele **é** o CLI que o `cli: null` acima diz que vem de dentro — e vem por um
60448
+ // caret (`^0.153.3`), que é o risco da fase 0 e o motivo de a conferência
60449
+ // tratar runtime não-pinado como aviso em vez de reprovação.
60450
+ runtime: "@openai/codex",
60432
60451
  apiKeyEnv: ["CODEX_API_KEY", "OPENAI_API_KEY"]
60433
60452
  };
60434
60453
  var ADAPTERS = [CLAUDE_ADAPTER, CODEX_ADAPTER];
@@ -60441,7 +60460,7 @@ function adapterByCommand(command) {
60441
60460
  }
60442
60461
 
60443
60462
  // ../shared/src/constants.ts
60444
- var LUMEM_VERSION = "0.3.0";
60463
+ var LUMEM_VERSION = "0.4.0";
60445
60464
  var DEFAULT_SERVER_PORT = 4317;
60446
60465
  var MIN_GIT_VERSION = { major: 2, minor: 30 };
60447
60466
  var ADAPTERS_DIR_NAME = "adapters";
@@ -60743,12 +60762,16 @@ function remove(dir, sessionId) {
60743
60762
  // src/git/GitService.ts
60744
60763
  import { realpath, stat } from "node:fs/promises";
60745
60764
 
60765
+ // src/git/clone.ts
60766
+ import { spawn } from "node:child_process";
60767
+ import { rename, rm } from "node:fs/promises";
60768
+
60746
60769
  // src/git/exec.ts
60747
60770
  import { execFile } from "node:child_process";
60748
60771
  import { promisify } from "node:util";
60749
60772
  var run = promisify(execFile);
60750
60773
  var DEFAULT_GIT_TIMEOUT_MS = 3e4;
60751
- var execGit = async (args, { cwd, timeoutMs = DEFAULT_GIT_TIMEOUT_MS }) => {
60774
+ var execGit = async (args, { cwd, timeoutMs = DEFAULT_GIT_TIMEOUT_MS, env }) => {
60752
60775
  try {
60753
60776
  const { stdout, stderr } = await run("git", [...args], {
60754
60777
  cwd,
@@ -60757,7 +60780,7 @@ var execGit = async (args, { cwd, timeoutMs = DEFAULT_GIT_TIMEOUT_MS }) => {
60757
60780
  // Nothing reads them as paths yet; the day something does, this is the
60758
60781
  // bug nobody would think to look for.
60759
60782
  env: {
60760
- ...process.env,
60783
+ ...env ?? process.env,
60761
60784
  // Without this a repository needing credentials hangs the daemon until
60762
60785
  // the timeout instead of failing with something readable.
60763
60786
  GIT_TERMINAL_PROMPT: "0",
@@ -60790,7 +60813,249 @@ function asGitFailure(error40, args) {
60790
60813
  });
60791
60814
  }
60792
60815
 
60816
+ // src/git/clone.ts
60817
+ var CloneError = class extends DomainError {
60818
+ constructor(failure, message, options) {
60819
+ super(failure === "internal" ? "BLOCKED" : "GIT_FAILED", message, options);
60820
+ this.failure = failure;
60821
+ this.name = "CloneError";
60822
+ }
60823
+ };
60824
+ var DEFAULT_SILENCE_MS = 12e4;
60825
+ var SIGKILL_GRACE_MS = 5e3;
60826
+ var STDERR_RING_BYTES = 64 * 1024;
60827
+ var MAX_LINE = 500;
60828
+ async function cloneRepository(options) {
60829
+ const { targetPath: targetPath2, tempPath, resolveTarget } = options;
60830
+ try {
60831
+ await runClone(options);
60832
+ await rewriteOrigin(options);
60833
+ const finalTarget = resolveTarget ? await resolveTarget() : targetPath2;
60834
+ await rename(tempPath, finalTarget);
60835
+ return finalTarget;
60836
+ } catch (error40) {
60837
+ await rm(tempPath, { recursive: true, force: true }).catch(() => {
60838
+ });
60839
+ throw error40;
60840
+ }
60841
+ }
60842
+ function cloneArgs(rawUrl, tempPath) {
60843
+ return [
60844
+ "-c",
60845
+ "protocol.allow=never",
60846
+ "-c",
60847
+ "protocol.https.allow=always",
60848
+ "-c",
60849
+ "protocol.http.allow=always",
60850
+ "-c",
60851
+ "protocol.ssh.allow=always",
60852
+ "-c",
60853
+ "protocol.file.allow=always",
60854
+ "clone",
60855
+ "--progress",
60856
+ "--no-recurse-submodules",
60857
+ "--",
60858
+ rawUrl,
60859
+ tempPath
60860
+ ];
60861
+ }
60862
+ function cloneEnv(base = process.env) {
60863
+ const ssh = base["GIT_SSH_COMMAND"]?.trim();
60864
+ return {
60865
+ ...base,
60866
+ GIT_TERMINAL_PROMPT: "0",
60867
+ GIT_ASKPASS: "",
60868
+ SSH_ASKPASS: "",
60869
+ GIT_OPTIONAL_LOCKS: "0",
60870
+ GIT_SSH_COMMAND: `${ssh === void 0 || ssh === "" ? "ssh" : ssh} -o BatchMode=yes`
60871
+ };
60872
+ }
60873
+ function runClone({
60874
+ rawUrl,
60875
+ tempPath,
60876
+ onProgress,
60877
+ signal,
60878
+ silenceMs = DEFAULT_SILENCE_MS,
60879
+ env
60880
+ }) {
60881
+ return new Promise((resolve6, reject) => {
60882
+ const child = spawn("git", cloneArgs(rawUrl, tempPath), {
60883
+ env: cloneEnv(env),
60884
+ stdio: ["ignore", "ignore", "pipe"]
60885
+ });
60886
+ const errors = new Ring(STDERR_RING_BYTES);
60887
+ let settled = false;
60888
+ let killTimer;
60889
+ const silence = new SilenceTimer(silenceMs, () => {
60890
+ finish(new CloneError("network", `git ficou ${Math.round(silenceMs / 1e3)}s sem responder`));
60891
+ kill();
60892
+ });
60893
+ function kill() {
60894
+ child.kill("SIGTERM");
60895
+ killTimer = setTimeout(() => child.kill("SIGKILL"), SIGKILL_GRACE_MS);
60896
+ killTimer.unref?.();
60897
+ }
60898
+ function finish(error40) {
60899
+ if (settled) return;
60900
+ settled = true;
60901
+ silence.stop();
60902
+ signal?.removeEventListener("abort", onAbort);
60903
+ if (error40) reject(error40);
60904
+ else resolve6();
60905
+ }
60906
+ function onAbort() {
60907
+ finish(new CloneError("internal", "clone cancelado"));
60908
+ kill();
60909
+ }
60910
+ if (signal?.aborted) {
60911
+ child.kill("SIGKILL");
60912
+ finish(new CloneError("internal", "clone cancelado"));
60913
+ return;
60914
+ }
60915
+ signal?.addEventListener("abort", onAbort, { once: true });
60916
+ const reader = new ProgressReader((progress) => {
60917
+ silence.touch();
60918
+ onProgress?.(progress);
60919
+ });
60920
+ child.stderr.on("data", (chunk) => {
60921
+ errors.push(chunk);
60922
+ reader.push(chunk.toString("utf8"));
60923
+ });
60924
+ child.on("error", (error40) => {
60925
+ finish(
60926
+ error40.code === "ENOENT" ? new CloneError("internal", "git n\xE3o est\xE1 instalado ou n\xE3o est\xE1 no PATH", {
60927
+ cause: error40
60928
+ }) : new CloneError("internal", error40.message, { cause: error40 })
60929
+ );
60930
+ });
60931
+ child.on("close", (code) => {
60932
+ if (killTimer) clearTimeout(killTimer);
60933
+ if (code === 0) return finish();
60934
+ const stderr = errors.text();
60935
+ finish(new CloneError(classify(stderr), lastMeaningfulLine(stderr) || `git saiu com ${code}`));
60936
+ });
60937
+ });
60938
+ }
60939
+ async function rewriteOrigin({ rawUrl, url: url2, tempPath }) {
60940
+ if (rawUrl === url2) return;
60941
+ await execGit(["remote", "set-url", "origin", url2], { cwd: tempPath });
60942
+ }
60943
+ function classify(stderr) {
60944
+ if (/authentication failed|could not read username|could not read password|invalid username or password|permission denied \(publickey|terminal prompts disabled|host key verification failed/i.test(
60945
+ stderr
60946
+ )) {
60947
+ return "auth";
60948
+ }
60949
+ if (/connection refused/i.test(stderr)) return "refused";
60950
+ if (/could not resolve host|couldn't connect to server|connection timed out|operation timed out|network is unreachable|no route to host/i.test(
60951
+ stderr
60952
+ )) {
60953
+ return "network";
60954
+ }
60955
+ return "git";
60956
+ }
60957
+ function lastMeaningfulLine(stderr) {
60958
+ const lines = stderr.split(/[\r\n]+/).map((line) => clean(line)).filter((line) => line !== "");
60959
+ const fatal = lines.filter((line) => /^(fatal|error):/i.test(line)).at(-1);
60960
+ return fatal ?? lines.at(-1) ?? "";
60961
+ }
60962
+ function clean(line) {
60963
+ const stripped = line.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, "").trim();
60964
+ return stripped.length > MAX_LINE ? `${stripped.slice(0, MAX_LINE)}\u2026` : stripped;
60965
+ }
60966
+ var PHASES = [
60967
+ [/^cloning into/i, "connecting"],
60968
+ [/enumerating objects|counting objects/i, "counting"],
60969
+ [/compressing objects/i, "compressing"],
60970
+ [/receiving objects/i, "receiving"],
60971
+ [/resolving deltas/i, "resolving"],
60972
+ [/updating files|checking out files/i, "checkout"]
60973
+ ];
60974
+ function phaseOf(line) {
60975
+ for (const [pattern, phase] of PHASES) if (pattern.test(line)) return phase;
60976
+ return null;
60977
+ }
60978
+ function percentOf(line) {
60979
+ const match = /(\d{1,3})%/.exec(line);
60980
+ if (!match) return null;
60981
+ return Math.min(100, Number(match[1]));
60982
+ }
60983
+ var ProgressReader = class {
60984
+ constructor(emit) {
60985
+ this.emit = emit;
60986
+ }
60987
+ buffer = "";
60988
+ phase = null;
60989
+ push(chunk) {
60990
+ this.buffer += chunk;
60991
+ const parts = this.buffer.split(/[\r\n]/);
60992
+ this.buffer = parts.pop() ?? "";
60993
+ for (const part of parts) this.line(part);
60994
+ }
60995
+ line(raw) {
60996
+ const message = clean(raw);
60997
+ if (message === "") return;
60998
+ this.phase = phaseOf(message) ?? this.phase;
60999
+ this.emit({ phase: this.phase, percent: percentOf(message), message });
61000
+ }
61001
+ };
61002
+ var Ring = class {
61003
+ constructor(limit) {
61004
+ this.limit = limit;
61005
+ }
61006
+ chunks = [];
61007
+ size = 0;
61008
+ push(chunk) {
61009
+ this.chunks.push(chunk);
61010
+ this.size += chunk.length;
61011
+ while (this.size > this.limit && this.chunks.length > 1) {
61012
+ this.size -= this.chunks.shift().length;
61013
+ }
61014
+ }
61015
+ text() {
61016
+ return Buffer.concat(this.chunks).toString("utf8");
61017
+ }
61018
+ get bytes() {
61019
+ return this.size;
61020
+ }
61021
+ };
61022
+ var SilenceTimer = class {
61023
+ constructor(ms, onSilence) {
61024
+ this.ms = ms;
61025
+ this.onSilence = onSilence;
61026
+ this.touch();
61027
+ }
61028
+ timer;
61029
+ touch() {
61030
+ this.stop();
61031
+ this.timer = setTimeout(this.onSilence, this.ms);
61032
+ this.timer.unref?.();
61033
+ }
61034
+ stop() {
61035
+ if (this.timer) clearTimeout(this.timer);
61036
+ this.timer = void 0;
61037
+ }
61038
+ };
61039
+
60793
61040
  // src/git/GitService.ts
61041
+ var FETCH_TIMEOUT_MS = 12e4;
61042
+ function worktreeAddArgs(branch, targetPath2, source) {
61043
+ switch (source.kind) {
61044
+ case "new-branch":
61045
+ return ["worktree", "add", "-b", branch, targetPath2, source.base];
61046
+ // Sem `-b`: a branch existe, e o git só a coloca no checkout novo.
61047
+ case "existing-branch":
61048
+ return ["worktree", "add", targetPath2, branch];
61049
+ // `--track -b`, e nunca o ref remoto sozinho — medido: sozinho ele entrega
61050
+ // HEAD destacado com sucesso.
61051
+ case "remote-branch":
61052
+ return ["worktree", "add", "--track", "-b", branch, targetPath2, source.remoteRef];
61053
+ // `--no-track` dito por extenso: sem ele o git configura upstream sozinho
61054
+ // quando o ponto de partida é uma ref de `refs/remotes/`.
61055
+ case "branch-at":
61056
+ return ["worktree", "add", "--no-track", "-b", branch, targetPath2, source.ref];
61057
+ }
61058
+ }
60794
61059
  function createGitService({ exec = execGit } = {}) {
60795
61060
  async function branchExists(repoPath, branch) {
60796
61061
  try {
@@ -60800,6 +61065,17 @@ function createGitService({ exec = execGit } = {}) {
60800
61065
  return false;
60801
61066
  }
60802
61067
  }
61068
+ async function readWorktrees(repoPath) {
61069
+ const { stdout } = await exec(["worktree", "list", "--porcelain", "-z"], { cwd: repoPath });
61070
+ return parseWorktreeList(stdout);
61071
+ }
61072
+ async function readRefs(repoPath) {
61073
+ const { stdout } = await exec(
61074
+ ["for-each-ref", "--format=%(refname)", "refs/heads/", "refs/remotes/"],
61075
+ { cwd: repoPath }
61076
+ ).catch(() => ({ stdout: "", stderr: "" }));
61077
+ return stdout.split("\n").map((line) => line.trim()).filter((line) => line !== "");
61078
+ }
60803
61079
  const service = {
60804
61080
  hasCommits,
60805
61081
  async isGitRepo(path) {
@@ -60861,22 +61137,85 @@ function createGitService({ exec = execGit } = {}) {
60861
61137
  return current;
60862
61138
  },
60863
61139
  branchExists,
60864
- async addWorktree({ repoPath, branch, targetPath: targetPath2, baseBranch }) {
60865
- if (await branchExists(repoPath, branch)) {
61140
+ async addWorktree({ repoPath, branch, targetPath: targetPath2, source }) {
61141
+ const existedBefore = await branchExists(repoPath, branch);
61142
+ if (source.kind === "existing-branch") {
61143
+ if (!existedBefore) {
61144
+ throw new DomainError("BLOCKED", `a branch "${branch}" n\xE3o existe neste reposit\xF3rio`);
61145
+ }
61146
+ const holder = (await readWorktrees(repoPath)).find((entry) => entry.branch === branch);
61147
+ if (holder !== void 0) {
61148
+ throw new DomainError(
61149
+ "BLOCKED",
61150
+ `a branch "${branch}" j\xE1 est\xE1 no checkout em ${holder.path}`
61151
+ );
61152
+ }
61153
+ } else if (existedBefore) {
60866
61154
  throw new DomainError("BLOCKED", `a branch "${branch}" j\xE1 existe; escolha outro nome`);
60867
61155
  }
60868
61156
  try {
60869
- await exec(["worktree", "add", "-b", branch, targetPath2, baseBranch], { cwd: repoPath });
61157
+ await exec(worktreeAddArgs(branch, targetPath2, source), { cwd: repoPath });
60870
61158
  } catch (error40) {
60871
- await exec(["branch", "-D", branch], { cwd: repoPath }).catch(() => {
61159
+ if (!existedBefore) await exec(["branch", "-D", branch], { cwd: repoPath }).catch(() => {
60872
61160
  });
60873
61161
  throw error40;
60874
61162
  }
60875
61163
  },
60876
- async listWorktrees(repoPath) {
60877
- const { stdout } = await exec(["worktree", "list", "--porcelain", "-z"], { cwd: repoPath });
60878
- return parseWorktreeList(stdout);
61164
+ async listRemotes(repoPath) {
61165
+ const { stdout } = await exec(["remote"], { cwd: repoPath }).catch(() => ({
61166
+ stdout: "",
61167
+ stderr: ""
61168
+ }));
61169
+ return stdout.split("\n").map((line) => line.trim()).filter((line) => line !== "");
61170
+ },
61171
+ async fetchRef({ repoPath, remote, refspec, timeoutMs = FETCH_TIMEOUT_MS }) {
61172
+ await exec(["fetch", "--no-tags", "--", remote, refspec], {
61173
+ cwd: repoPath,
61174
+ timeoutMs,
61175
+ env: cloneEnv()
61176
+ });
61177
+ },
61178
+ async resolveShortSha(repoPath, ref) {
61179
+ const { stdout } = await exec(["rev-parse", "--short", "--verify", "--quiet", `${ref}^{commit}`], {
61180
+ cwd: repoPath
61181
+ }).catch(() => ({ stdout: "", stderr: "" }));
61182
+ const sha = stdout.trim();
61183
+ return sha === "" ? null : sha;
61184
+ },
61185
+ async listBranches(repoPath) {
61186
+ const [refs, worktrees] = await Promise.all([readRefs(repoPath), readWorktrees(repoPath)]);
61187
+ const holderOf = new Map(
61188
+ worktrees.filter((entry) => entry.branch !== null).map((entry) => [entry.branch, entry.path])
61189
+ );
61190
+ const byName2 = /* @__PURE__ */ new Map();
61191
+ const entryFor = (name) => {
61192
+ const existing = byName2.get(name);
61193
+ if (existing !== void 0) return existing;
61194
+ const created = {
61195
+ name,
61196
+ local: false,
61197
+ remotes: [],
61198
+ worktreePath: holderOf.get(name) ?? null
61199
+ };
61200
+ byName2.set(name, created);
61201
+ return created;
61202
+ };
61203
+ for (const ref of refs) {
61204
+ if (ref.startsWith("refs/heads/")) {
61205
+ entryFor(ref.slice("refs/heads/".length)).local = true;
61206
+ continue;
61207
+ }
61208
+ const rest = ref.slice("refs/remotes/".length);
61209
+ const slash = rest.indexOf("/");
61210
+ if (slash === -1) continue;
61211
+ const remote = rest.slice(0, slash);
61212
+ const name = rest.slice(slash + 1);
61213
+ if (name === "HEAD") continue;
61214
+ entryFor(name).remotes.push(remote);
61215
+ }
61216
+ return [...byName2.values()];
60879
61217
  },
61218
+ listWorktrees: readWorktrees,
60880
61219
  async removeWorktree({ repoPath, path, force = false }) {
60881
61220
  await exec(["worktree", "remove", ...force ? ["--force"] : [], path], { cwd: repoPath });
60882
61221
  },
@@ -60899,10 +61238,9 @@ function createGitService({ exec = execGit } = {}) {
60899
61238
  return { ahead: ahead ?? 0, behind: behind ?? 0 };
60900
61239
  },
60901
61240
  async getRemoteUrl(path) {
60902
- const { stdout } = await exec(["remote", "get-url", "origin"], { cwd: path }).catch(() => ({
60903
- stdout: "",
60904
- stderr: ""
60905
- }));
61241
+ const { stdout } = await exec(["config", "--get", "remote.origin.url"], {
61242
+ cwd: path
61243
+ }).catch(() => ({ stdout: "", stderr: "" }));
60906
61244
  const url2 = stdout.trim();
60907
61245
  return url2 === "" ? null : url2;
60908
61246
  },
@@ -60915,10 +61253,8 @@ function createGitService({ exec = execGit } = {}) {
60915
61253
  return subject === "" ? null : subject;
60916
61254
  },
60917
61255
  async hasRemoteBranch(path, branch) {
60918
- const { stdout } = await exec(["for-each-ref", "--format=%(refname)", "refs/remotes/"], {
60919
- cwd: path
60920
- }).catch(() => ({ stdout: "", stderr: "" }));
60921
- return stdout.split("\n").map((line) => line.trim()).filter((line) => line !== "").some((ref) => {
61256
+ return (await readRefs(path)).some((ref) => {
61257
+ if (!ref.startsWith("refs/remotes/")) return false;
60922
61258
  const rest = ref.slice("refs/remotes/".length);
60923
61259
  const slash = rest.indexOf("/");
60924
61260
  return slash !== -1 && rest.slice(slash + 1) === branch;
@@ -67516,11 +67852,11 @@ async function migrateWorktreeLayout({
67516
67852
  continue;
67517
67853
  }
67518
67854
  await mkdir2(dirname2(target), { recursive: true });
67519
- await rename(row.path, target);
67855
+ await rename2(row.path, target);
67520
67856
  try {
67521
67857
  await git.repairWorktree({ repoPath: project2.path, path: target });
67522
67858
  } catch (error40) {
67523
- await rename(target, row.path).catch(() => {
67859
+ await rename2(target, row.path).catch(() => {
67524
67860
  });
67525
67861
  throw error40;
67526
67862
  }
@@ -67541,7 +67877,7 @@ async function reconcileClones({ config: config2, log }) {
67541
67877
  for (const entry of await readdir2(project2, { withFileTypes: true }).catch(() => [])) {
67542
67878
  if (!entry.name.startsWith(CLONE_TEMP_PREFIX)) continue;
67543
67879
  try {
67544
- await rm(join4(project2, entry.name), { recursive: true, force: true });
67880
+ await rm2(join4(project2, entry.name), { recursive: true, force: true });
67545
67881
  removed += 1;
67546
67882
  } catch (error40) {
67547
67883
  log?.warn({ path: join4(project2, entry.name), err: error40 }, "n\xE3o deu para limpar clone");
@@ -77747,12 +78083,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
77747
78083
  seen.ref = null;
77748
78084
  if (ref) {
77749
78085
  flattenRef(ref, params2);
77750
- const refSchema = this.seen.get(ref).schema;
77751
- if (refSchema.$ref && params2.target === "draft-7") {
78086
+ const refSchema2 = this.seen.get(ref).schema;
78087
+ if (refSchema2.$ref && params2.target === "draft-7") {
77752
78088
  schema3.allOf = schema3.allOf ?? [];
77753
- schema3.allOf.push(refSchema);
78089
+ schema3.allOf.push(refSchema2);
77754
78090
  } else {
77755
- Object.assign(schema3, refSchema);
78091
+ Object.assign(schema3, refSchema2);
77756
78092
  Object.assign(schema3, _cached);
77757
78093
  }
77758
78094
  }
@@ -81465,13 +81801,13 @@ var ConnectionBuilder = class {
81465
81801
  /**
81466
81802
  * Adds a typed request handler for one method.
81467
81803
  */
81468
- onReceiveRequest(method, parse5, handler) {
81804
+ onReceiveRequest(method, parse6, handler) {
81469
81805
  return this.withHandler({
81470
81806
  handleMessage: async (message, cx) => {
81471
81807
  if (message.kind !== "request" || message.method !== method) {
81472
81808
  return Handled.no(message);
81473
81809
  }
81474
- const request = parse5(message.params);
81810
+ const request = parse6(message.params);
81475
81811
  return await handler(request, message.responder, cx) ?? Handled.yes();
81476
81812
  },
81477
81813
  describe: () => `${this.connectionName ?? "request"}:${method}`
@@ -81480,13 +81816,13 @@ var ConnectionBuilder = class {
81480
81816
  /**
81481
81817
  * Adds a typed notification handler for one method.
81482
81818
  */
81483
- onReceiveNotification(method, parse5, handler) {
81819
+ onReceiveNotification(method, parse6, handler) {
81484
81820
  return this.withHandler({
81485
81821
  handleMessage: async (message, cx) => {
81486
81822
  if (message.kind !== "notification" || message.method !== method) {
81487
81823
  return Handled.no(message);
81488
81824
  }
81489
- const notification = parse5(message.params);
81825
+ const notification = parse6(message.params);
81490
81826
  return await handler(notification, cx) ?? Handled.yes();
81491
81827
  },
81492
81828
  describe: () => `${this.connectionName ?? "notification"}:${method}`
@@ -82697,8 +83033,8 @@ import {
82697
83033
  mkdir as mkdir3,
82698
83034
  readdir as readdir4,
82699
83035
  readFile,
82700
- rename as rename2,
82701
- rm as rm2,
83036
+ rename as rename3,
83037
+ rm as rm3,
82702
83038
  rmdir,
82703
83039
  stat as stat2,
82704
83040
  unlink,
@@ -82892,9 +83228,9 @@ async function writeAtomically(target, content, mode) {
82892
83228
  try {
82893
83229
  await writeFile(temp, content, { mode: 384 });
82894
83230
  await chmod(temp, mode & 511);
82895
- await rename2(temp, target);
83231
+ await rename3(temp, target);
82896
83232
  } catch (error40) {
82897
- await rm2(temp, { force: true }).catch(() => {
83233
+ await rm3(temp, { force: true }).catch(() => {
82898
83234
  });
82899
83235
  throw error40;
82900
83236
  }
@@ -83186,7 +83522,7 @@ function createFileService({
83186
83522
  throw new DomainError("DUPLICATE", `j\xE1 existe alguma coisa em ${destination.relative}`);
83187
83523
  }
83188
83524
  try {
83189
- await rename2(source.entry, destination.entry);
83525
+ await rename3(source.entry, destination.entry);
83190
83526
  } catch (error40) {
83191
83527
  throw asRenameFailure(error40, source.relative, destination.relative);
83192
83528
  }
@@ -83207,7 +83543,7 @@ function createFileService({
83207
83543
  return;
83208
83544
  }
83209
83545
  if (recursive) {
83210
- await rm2(entry, { recursive: true }).catch((error40) => {
83546
+ await rm3(entry, { recursive: true }).catch((error40) => {
83211
83547
  throw asRemovalFailure(error40, relative5);
83212
83548
  });
83213
83549
  return;
@@ -83405,10 +83741,10 @@ function createTerminalBridge({
83405
83741
  }
83406
83742
 
83407
83743
  // src/acp/process.ts
83408
- import { spawn } from "node:child_process";
83744
+ import { spawn as spawn2 } from "node:child_process";
83409
83745
  import { Readable, Writable } from "node:stream";
83410
83746
  function spawnAcpProcess({ command, args, cwd, env }) {
83411
- const child = spawn(command, [...args], {
83747
+ const child = spawn2(command, [...args], {
83412
83748
  cwd,
83413
83749
  env: { ...process.env, ...env },
83414
83750
  stdio: ["pipe", "pipe", "inherit"]
@@ -85049,7 +85385,7 @@ async function commitGitignore(stateDir, exec) {
85049
85385
  }
85050
85386
 
85051
85387
  // src/memory/MemoryService.ts
85052
- import { mkdir as mkdir5, readFile as readFile4, rm as rm3 } from "node:fs/promises";
85388
+ import { mkdir as mkdir5, readFile as readFile4, rm as rm4 } from "node:fs/promises";
85053
85389
  import { dirname as dirname6, join as join11 } from "node:path";
85054
85390
 
85055
85391
  // src/memory/catalog.ts
@@ -86076,7 +86412,7 @@ var writeMemorySchema = external_exports.object({
86076
86412
  *
86077
86413
  * O default é `human` nas duas superfícies, de propósito — elas contam a mesma
86078
86414
  * história. Quem **impõe** o ator (transporte, ambiente ou token de sessão) é a
86079
- * [Q46](../../../../docs/prd/workspace-memory/open-questions.md), aberta: até
86415
+ * [Q46](../../../../docs/features/007-workspace-memory/open-questions.md), aberta: até
86080
86416
  * ela fechar, o desvio da Q27 protege contra engano, não contra quem quer
86081
86417
  * burlá-lo — e o WAL registra o ator declarado de toda escrita.
86082
86418
  */
@@ -86413,7 +86749,7 @@ var MemoryService = class {
86413
86749
  const absolute = entryPathFor(this.stateDir, this.targetFor(resolved, ids), type, slug);
86414
86750
  const path = repoRelative(this.stateDir, absolute);
86415
86751
  const record2 = await this.recordDeletion(path, "human");
86416
- await rm3(absolute, { force: true });
86752
+ await rm4(absolute, { force: true });
86417
86753
  removeEntry(this.db, path);
86418
86754
  removeFromIndex(this.db, path);
86419
86755
  clearSignal(this.db, path);
@@ -86449,7 +86785,7 @@ var MemoryService = class {
86449
86785
  const absolute = join11(this.stateDir, path);
86450
86786
  if (previousSha === void 0) {
86451
86787
  const record3 = await this.recordDeletion(path, "human");
86452
- await rm3(absolute, { force: true });
86788
+ await rm4(absolute, { force: true });
86453
86789
  removeEntry(this.db, path);
86454
86790
  removeFromIndex(this.db, path);
86455
86791
  clearSignal(this.db, path);
@@ -91554,12 +91890,12 @@ function createMiddlewareFactory() {
91554
91890
  }
91555
91891
  return createMiddleware;
91556
91892
  }
91557
- function createInputMiddleware(parse5) {
91893
+ function createInputMiddleware(parse6) {
91558
91894
  const inputMiddleware = async function inputValidatorMiddleware(opts) {
91559
91895
  let parsedInput;
91560
91896
  const rawInput = await opts.getRawInput();
91561
91897
  try {
91562
- parsedInput = await parse5(rawInput);
91898
+ parsedInput = await parse6(rawInput);
91563
91899
  } catch (cause) {
91564
91900
  throw new TRPCError({
91565
91901
  code: "BAD_REQUEST",
@@ -91572,12 +91908,12 @@ function createInputMiddleware(parse5) {
91572
91908
  inputMiddleware._type = "input";
91573
91909
  return inputMiddleware;
91574
91910
  }
91575
- function createOutputMiddleware(parse5) {
91911
+ function createOutputMiddleware(parse6) {
91576
91912
  const outputMiddleware = async function outputValidatorMiddleware({ next }) {
91577
91913
  const result = await next();
91578
91914
  if (!result.ok) return result;
91579
91915
  try {
91580
- const data = await parse5(result.data);
91916
+ const data = await parse6(result.data);
91581
91917
  return (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, result), {}, { data });
91582
91918
  } catch (cause) {
91583
91919
  throw new TRPCError({
@@ -92591,7 +92927,7 @@ async function* snapshots(id, current, listeners, signal) {
92591
92927
  }
92592
92928
 
92593
92929
  // src/pr/GhHost.ts
92594
- import { mkdtemp, rm as rm4, writeFile as writeFile4 } from "node:fs/promises";
92930
+ import { mkdtemp, rm as rm5, writeFile as writeFile4 } from "node:fs/promises";
92595
92931
  import { tmpdir } from "node:os";
92596
92932
  import { join as join15 } from "node:path";
92597
92933
 
@@ -92766,7 +93102,7 @@ var OFFLINE = [
92766
93102
  "proxyconnect",
92767
93103
  "eof"
92768
93104
  ];
92769
- function classify(result) {
93105
+ function classify2(result) {
92770
93106
  if (result.spawnError === "ENOENT") {
92771
93107
  return {
92772
93108
  kind: "no-binary",
@@ -92852,6 +93188,10 @@ var FIELDS = [
92852
93188
  "latestReviews",
92853
93189
  "headRefName",
92854
93190
  "baseRefName",
93191
+ // Se a head vive em outro repositório. Sem isto, `headRefName` é um nome
93192
+ // pelado e `patch-1` de um fork casa com o `origin/patch-1` do upstream —
93193
+ // outra branch, sem relação nenhuma com a PR.
93194
+ "isCrossRepository",
92855
93195
  "updatedAt",
92856
93196
  "mergedAt",
92857
93197
  "closedAt",
@@ -92861,6 +93201,7 @@ var FIELDS = [
92861
93201
  var PROJECTION = [
92862
93202
  "map({number, url, title, state, isDraft, mergeable, mergeStateStatus, reviewDecision,",
92863
93203
  "headRefName, baseRefName, updatedAt, mergedAt, closedAt,",
93204
+ "crossRepository: (.isCrossRepository // false),",
92864
93205
  'author: (.author.login // ""),',
92865
93206
  'reviews: [.latestReviews[]? | {author: (.author.login // ""), state: .state}],',
92866
93207
  "checks: [.statusCheckRollup[]? | {",
@@ -92869,6 +93210,12 @@ var PROJECTION = [
92869
93210
  'url: (.detailsUrl // .targetUrl // ""),',
92870
93211
  "startedAt: (.startedAt // null), completedAt: (.completedAt // null)}]})"
92871
93212
  ].join(" ");
93213
+ var ISSUE_FIELDS = ["number", "title", "state", "url", "updatedAt", "author", "labels"].join(",");
93214
+ var ISSUE_PROJECTION = [
93215
+ "map({number, title, state, url, updatedAt,",
93216
+ 'author: (.author.login // ""),',
93217
+ "labels: [.labels[]?.name]})"
93218
+ ].join(" ");
92872
93219
  var REPO_FIELDS = [
92873
93220
  "nameWithOwner",
92874
93221
  "mergeCommitAllowed",
@@ -92891,7 +93238,7 @@ function createGhHost({ exec = execGh, limit = DEFAULT_LIMIT } = {}) {
92891
93238
  }
92892
93239
  async function run3(args, cwd) {
92893
93240
  const result = await exec(args, { cwd });
92894
- const failure = classify(result);
93241
+ const failure = classify2(result);
92895
93242
  return failure === null ? { ok: true, stdout: result.stdout } : { ok: false, failure };
92896
93243
  }
92897
93244
  function unsupported(host) {
@@ -92953,6 +93300,34 @@ function createGhHost({ exec = execGh, limit = DEFAULT_LIMIT } = {}) {
92953
93300
  }
92954
93301
  };
92955
93302
  },
93303
+ async issues({ repoPath, remoteUrl }) {
93304
+ const host = hostOf(remoteUrl);
93305
+ if (!isGitHub(host)) return { ok: false, failure: unsupported(host) };
93306
+ const result = await run3(
93307
+ [
93308
+ "issue",
93309
+ "list",
93310
+ "--state",
93311
+ "open",
93312
+ "--limit",
93313
+ String(limit),
93314
+ "--json",
93315
+ ISSUE_FIELDS,
93316
+ "--jq",
93317
+ ISSUE_PROJECTION
93318
+ ],
93319
+ repoPath
93320
+ );
93321
+ if (!result.ok) return result;
93322
+ const parsed = parseJson(result.stdout, []);
93323
+ if (parsed === null) {
93324
+ return {
93325
+ ok: false,
93326
+ failure: { kind: "failed", message: "o gh respondeu algo que n\xE3o \xE9 JSON" }
93327
+ };
93328
+ }
93329
+ return { ok: true, issues: parsed };
93330
+ },
92956
93331
  async create(input) {
92957
93332
  const host = hostOf(input.remoteUrl);
92958
93333
  if (!isGitHub(host)) return { ok: false, failure: unsupported(host) };
@@ -92979,7 +93354,7 @@ function createGhHost({ exec = execGh, limit = DEFAULT_LIMIT } = {}) {
92979
93354
  const printed = result.stdout.trim().split("\n").at(-1)?.trim() ?? "";
92980
93355
  return { ok: true, url: safeUrl(printed, host) ?? "" };
92981
93356
  } finally {
92982
- await rm4(dir, { recursive: true, force: true });
93357
+ await rm5(dir, { recursive: true, force: true });
92983
93358
  }
92984
93359
  },
92985
93360
  async merge(input) {
@@ -93236,6 +93611,63 @@ function digestOf(snapshot) {
93236
93611
  return JSON.stringify(rest);
93237
93612
  }
93238
93613
 
93614
+ // src/pr/IssueCache.ts
93615
+ var ISSUE_TTL_MS = 6e4;
93616
+ var NO_HOST = {
93617
+ kind: "unsupported-host",
93618
+ message: "este reposit\xF3rio n\xE3o tem um remote conhecido"
93619
+ };
93620
+ function createIssueCache({ host, now = () => Date.now() }) {
93621
+ const slots = /* @__PURE__ */ new Map();
93622
+ let reads = 0;
93623
+ function slotOf(projectId) {
93624
+ const existing = slots.get(projectId);
93625
+ if (existing !== void 0) return existing;
93626
+ const created = { issues: null, failure: null, readAt: null, freshUntil: 0, inFlight: null };
93627
+ slots.set(projectId, created);
93628
+ return created;
93629
+ }
93630
+ function viewOf2(slot) {
93631
+ return { issues: slot.issues, failure: slot.failure, readAt: slot.readAt };
93632
+ }
93633
+ async function fetch(project2, slot) {
93634
+ reads += 1;
93635
+ const read = await host.issues({ repoPath: project2.path, remoteUrl: project2.remoteUrl });
93636
+ if (read.ok) {
93637
+ slot.issues = read.issues;
93638
+ slot.failure = null;
93639
+ slot.readAt = (/* @__PURE__ */ new Date()).toISOString();
93640
+ } else {
93641
+ slot.failure = read.failure;
93642
+ }
93643
+ slot.freshUntil = now() + ISSUE_TTL_MS;
93644
+ return viewOf2(slot);
93645
+ }
93646
+ return {
93647
+ get reads() {
93648
+ return reads;
93649
+ },
93650
+ get(project2) {
93651
+ if (project2.remoteUrl === null || project2.remoteUrl.trim() === "") {
93652
+ return Promise.resolve({ issues: null, failure: NO_HOST, readAt: null });
93653
+ }
93654
+ const slot = slotOf(project2.id);
93655
+ if (slot.inFlight !== null) return slot.inFlight;
93656
+ if (slot.readAt !== null && now() < slot.freshUntil) {
93657
+ return Promise.resolve(viewOf2(slot));
93658
+ }
93659
+ const promise2 = fetch(project2, slot).finally(() => {
93660
+ if (slot.inFlight === promise2) slot.inFlight = null;
93661
+ });
93662
+ slot.inFlight = promise2;
93663
+ return promise2;
93664
+ },
93665
+ forget(projectId) {
93666
+ slots.delete(projectId);
93667
+ }
93668
+ };
93669
+ }
93670
+
93239
93671
  // ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/wrapper.mjs
93240
93672
  var import_stream2 = __toESM(require_stream(), 1);
93241
93673
  var import_extension = __toESM(require_extension(), 1);
@@ -94688,7 +95120,7 @@ var prRouter = router({
94688
95120
  /**
94689
95121
  * O que o formulário propõe, e por que ele não é um campo do `PrStatus`.
94690
95122
  *
94691
- * A [Q4](../../../../docs/prd/pull-request-status/open-questions.md) e a F7.6
95123
+ * A [Q4](../../../../docs/features/013-pull-request-status/open-questions.md) e a F7.6
94692
95124
  * pedem título vindo do assunto do último commit. Isso custa um `git log`, e
94693
95125
  * só interessa quando o formulário abre — dentro do `PrStatus` seria um
94694
95126
  * processo git a cada ciclo de poll, por worktree aberta.
@@ -94768,232 +95200,6 @@ import { existsSync as existsSync5 } from "node:fs";
94768
95200
  import { rename as rename4, rm as rm7 } from "node:fs/promises";
94769
95201
  import { basename as basename4, dirname as dirname11, isAbsolute as isAbsolute6, normalize as normalize4 } from "node:path";
94770
95202
 
94771
- // src/git/clone.ts
94772
- import { spawn as spawn2 } from "node:child_process";
94773
- import { rename as rename3, rm as rm5 } from "node:fs/promises";
94774
- var CloneError = class extends DomainError {
94775
- constructor(failure, message, options) {
94776
- super(failure === "internal" ? "BLOCKED" : "GIT_FAILED", message, options);
94777
- this.failure = failure;
94778
- this.name = "CloneError";
94779
- }
94780
- };
94781
- var DEFAULT_SILENCE_MS = 12e4;
94782
- var SIGKILL_GRACE_MS = 5e3;
94783
- var STDERR_RING_BYTES = 64 * 1024;
94784
- var MAX_LINE = 500;
94785
- async function cloneRepository(options) {
94786
- const { targetPath: targetPath2, tempPath, resolveTarget } = options;
94787
- try {
94788
- await runClone(options);
94789
- await rewriteOrigin(options);
94790
- const finalTarget = resolveTarget ? await resolveTarget() : targetPath2;
94791
- await rename3(tempPath, finalTarget);
94792
- return finalTarget;
94793
- } catch (error40) {
94794
- await rm5(tempPath, { recursive: true, force: true }).catch(() => {
94795
- });
94796
- throw error40;
94797
- }
94798
- }
94799
- function cloneArgs(rawUrl, tempPath) {
94800
- return [
94801
- "-c",
94802
- "protocol.allow=never",
94803
- "-c",
94804
- "protocol.https.allow=always",
94805
- "-c",
94806
- "protocol.http.allow=always",
94807
- "-c",
94808
- "protocol.ssh.allow=always",
94809
- "-c",
94810
- "protocol.file.allow=always",
94811
- "clone",
94812
- "--progress",
94813
- "--no-recurse-submodules",
94814
- "--",
94815
- rawUrl,
94816
- tempPath
94817
- ];
94818
- }
94819
- function cloneEnv(base = process.env) {
94820
- const ssh = base["GIT_SSH_COMMAND"]?.trim();
94821
- return {
94822
- ...base,
94823
- GIT_TERMINAL_PROMPT: "0",
94824
- GIT_ASKPASS: "",
94825
- SSH_ASKPASS: "",
94826
- GIT_OPTIONAL_LOCKS: "0",
94827
- GIT_SSH_COMMAND: `${ssh === void 0 || ssh === "" ? "ssh" : ssh} -o BatchMode=yes`
94828
- };
94829
- }
94830
- function runClone({
94831
- rawUrl,
94832
- tempPath,
94833
- onProgress,
94834
- signal,
94835
- silenceMs = DEFAULT_SILENCE_MS,
94836
- env
94837
- }) {
94838
- return new Promise((resolve6, reject) => {
94839
- const child = spawn2("git", cloneArgs(rawUrl, tempPath), {
94840
- env: cloneEnv(env),
94841
- stdio: ["ignore", "ignore", "pipe"]
94842
- });
94843
- const errors = new Ring(STDERR_RING_BYTES);
94844
- let settled = false;
94845
- let killTimer;
94846
- const silence = new SilenceTimer(silenceMs, () => {
94847
- finish(new CloneError("network", `git ficou ${Math.round(silenceMs / 1e3)}s sem responder`));
94848
- kill();
94849
- });
94850
- function kill() {
94851
- child.kill("SIGTERM");
94852
- killTimer = setTimeout(() => child.kill("SIGKILL"), SIGKILL_GRACE_MS);
94853
- killTimer.unref?.();
94854
- }
94855
- function finish(error40) {
94856
- if (settled) return;
94857
- settled = true;
94858
- silence.stop();
94859
- signal?.removeEventListener("abort", onAbort);
94860
- if (error40) reject(error40);
94861
- else resolve6();
94862
- }
94863
- function onAbort() {
94864
- finish(new CloneError("internal", "clone cancelado"));
94865
- kill();
94866
- }
94867
- if (signal?.aborted) {
94868
- child.kill("SIGKILL");
94869
- finish(new CloneError("internal", "clone cancelado"));
94870
- return;
94871
- }
94872
- signal?.addEventListener("abort", onAbort, { once: true });
94873
- const reader = new ProgressReader((progress) => {
94874
- silence.touch();
94875
- onProgress?.(progress);
94876
- });
94877
- child.stderr.on("data", (chunk) => {
94878
- errors.push(chunk);
94879
- reader.push(chunk.toString("utf8"));
94880
- });
94881
- child.on("error", (error40) => {
94882
- finish(
94883
- error40.code === "ENOENT" ? new CloneError("internal", "git n\xE3o est\xE1 instalado ou n\xE3o est\xE1 no PATH", {
94884
- cause: error40
94885
- }) : new CloneError("internal", error40.message, { cause: error40 })
94886
- );
94887
- });
94888
- child.on("close", (code) => {
94889
- if (killTimer) clearTimeout(killTimer);
94890
- if (code === 0) return finish();
94891
- const stderr = errors.text();
94892
- finish(new CloneError(classify2(stderr), lastMeaningfulLine(stderr) || `git saiu com ${code}`));
94893
- });
94894
- });
94895
- }
94896
- async function rewriteOrigin({ rawUrl, url: url2, tempPath }) {
94897
- if (rawUrl === url2) return;
94898
- await execGit(["remote", "set-url", "origin", url2], { cwd: tempPath });
94899
- }
94900
- function classify2(stderr) {
94901
- if (/authentication failed|could not read username|could not read password|invalid username or password|permission denied \(publickey|terminal prompts disabled|host key verification failed/i.test(
94902
- stderr
94903
- )) {
94904
- return "auth";
94905
- }
94906
- if (/connection refused/i.test(stderr)) return "refused";
94907
- if (/could not resolve host|couldn't connect to server|connection timed out|operation timed out|network is unreachable|no route to host/i.test(
94908
- stderr
94909
- )) {
94910
- return "network";
94911
- }
94912
- return "git";
94913
- }
94914
- function lastMeaningfulLine(stderr) {
94915
- const lines = stderr.split(/[\r\n]+/).map((line) => clean(line)).filter((line) => line !== "");
94916
- const fatal = lines.filter((line) => /^(fatal|error):/i.test(line)).at(-1);
94917
- return fatal ?? lines.at(-1) ?? "";
94918
- }
94919
- function clean(line) {
94920
- const stripped = line.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, "").trim();
94921
- return stripped.length > MAX_LINE ? `${stripped.slice(0, MAX_LINE)}\u2026` : stripped;
94922
- }
94923
- var PHASES = [
94924
- [/^cloning into/i, "connecting"],
94925
- [/enumerating objects|counting objects/i, "counting"],
94926
- [/compressing objects/i, "compressing"],
94927
- [/receiving objects/i, "receiving"],
94928
- [/resolving deltas/i, "resolving"],
94929
- [/updating files|checking out files/i, "checkout"]
94930
- ];
94931
- function phaseOf(line) {
94932
- for (const [pattern, phase] of PHASES) if (pattern.test(line)) return phase;
94933
- return null;
94934
- }
94935
- function percentOf(line) {
94936
- const match = /(\d{1,3})%/.exec(line);
94937
- if (!match) return null;
94938
- return Math.min(100, Number(match[1]));
94939
- }
94940
- var ProgressReader = class {
94941
- constructor(emit) {
94942
- this.emit = emit;
94943
- }
94944
- buffer = "";
94945
- phase = null;
94946
- push(chunk) {
94947
- this.buffer += chunk;
94948
- const parts = this.buffer.split(/[\r\n]/);
94949
- this.buffer = parts.pop() ?? "";
94950
- for (const part of parts) this.line(part);
94951
- }
94952
- line(raw) {
94953
- const message = clean(raw);
94954
- if (message === "") return;
94955
- this.phase = phaseOf(message) ?? this.phase;
94956
- this.emit({ phase: this.phase, percent: percentOf(message), message });
94957
- }
94958
- };
94959
- var Ring = class {
94960
- constructor(limit) {
94961
- this.limit = limit;
94962
- }
94963
- chunks = [];
94964
- size = 0;
94965
- push(chunk) {
94966
- this.chunks.push(chunk);
94967
- this.size += chunk.length;
94968
- while (this.size > this.limit && this.chunks.length > 1) {
94969
- this.size -= this.chunks.shift().length;
94970
- }
94971
- }
94972
- text() {
94973
- return Buffer.concat(this.chunks).toString("utf8");
94974
- }
94975
- get bytes() {
94976
- return this.size;
94977
- }
94978
- };
94979
- var SilenceTimer = class {
94980
- constructor(ms, onSilence) {
94981
- this.ms = ms;
94982
- this.onSilence = onSilence;
94983
- this.touch();
94984
- }
94985
- timer;
94986
- touch() {
94987
- this.stop();
94988
- this.timer = setTimeout(this.onSilence, this.ms);
94989
- this.timer.unref?.();
94990
- }
94991
- stop() {
94992
- if (this.timer) clearTimeout(this.timer);
94993
- this.timer = void 0;
94994
- }
94995
- };
94996
-
94997
95203
  // src/git/clone-plan.ts
94998
95204
  import { homedir } from "node:os";
94999
95205
  import { dirname as dirname9, join as join17, normalize as normalize3 } from "node:path";
@@ -95615,9 +95821,14 @@ var sessionRouter = router({
95615
95821
  });
95616
95822
 
95617
95823
  // src/routers/setup.ts
95618
- import { mkdirSync as mkdirSync4 } from "node:fs";
95824
+ import { existsSync as existsSync9, mkdirSync as mkdirSync4 } from "node:fs";
95619
95825
  import { join as join19 } from "node:path";
95620
95826
 
95827
+ // src/setup/install-adapter.ts
95828
+ import { existsSync as existsSync6, readFileSync as readFileSync3, realpathSync } from "node:fs";
95829
+ import { mkdir as mkdir8 } from "node:fs/promises";
95830
+ import { dirname as dirname12, join as join18, parse as parse5 } from "node:path";
95831
+
95621
95832
  // src/setup/run-command.ts
95622
95833
  import { execFile as execFile3 } from "node:child_process";
95623
95834
  var DEFAULT_VERSION_TIMEOUT_MS = 3e3;
@@ -95642,70 +95853,7 @@ var runCommand = (command, args, { timeoutMs = DEFAULT_VERSION_TIMEOUT_MS } = {}
95642
95853
  );
95643
95854
  });
95644
95855
 
95645
- // src/setup/agents.ts
95646
- function parseVersion(output) {
95647
- const trimmed2 = output.trim();
95648
- if (trimmed2 === "") return null;
95649
- const match = /\d+\.\d+(\.\d+)?/.exec(trimmed2);
95650
- return match?.[0] ?? trimmed2.split("\n")[0]?.slice(0, 60) ?? null;
95651
- }
95652
- async function inspect(command, install, { path, run: run3, preferred }) {
95653
- const resolved = preferred !== void 0 && resolveCommandPath(preferred, { path }) !== null ? preferred : resolveCommandPath(command, { path });
95654
- if (resolved === null) {
95655
- return { command, path: null, managed: false, version: null, versionNote: null, install };
95656
- }
95657
- const outcome = await run3(resolved, ["--version"]);
95658
- const version3 = parseVersion(outcome.output);
95659
- return {
95660
- command,
95661
- path: resolved,
95662
- managed: preferred !== void 0 && resolved === preferred,
95663
- version: version3,
95664
- // A binary that is there but will not say what it is stays usable: the
95665
- // probe is what answers the question that matters.
95666
- versionNote: version3 === null ? outcome.failure ?? "n\xE3o disse a vers\xE3o" : null,
95667
- install
95668
- };
95669
- }
95670
- async function detectAgents({
95671
- path = process.env["PATH"],
95672
- env = process.env,
95673
- run: run3 = runCommand,
95674
- specs = ADAPTERS,
95675
- installedAt
95676
- } = {}) {
95677
- const adapters = await Promise.all(
95678
- specs.map(async (spec) => reportFor(spec, { path, env, run: run3, installedAt }))
95679
- );
95680
- return { adapters };
95681
- }
95682
- async function reportFor(spec, {
95683
- path,
95684
- env,
95685
- run: run3,
95686
- installedAt
95687
- }) {
95688
- const [adapter, cli] = await Promise.all([
95689
- inspect(spec.command, adapterInstallCommand(spec), {
95690
- path,
95691
- run: run3,
95692
- ...installedAt === void 0 ? {} : { preferred: installedAt(spec) }
95693
- }),
95694
- spec.cli === null ? Promise.resolve(null) : inspect(spec.cli.command, spec.cli.install, { path, run: run3 })
95695
- ]);
95696
- return {
95697
- id: spec.id,
95698
- label: spec.label,
95699
- adapter,
95700
- cli,
95701
- apiKeyEnv: spec.apiKeyEnv.find((name) => (env[name] ?? "").trim() !== "") ?? null
95702
- };
95703
- }
95704
-
95705
95856
  // src/setup/install-adapter.ts
95706
- import { existsSync as existsSync6 } from "node:fs";
95707
- import { mkdir as mkdir8 } from "node:fs/promises";
95708
- import { join as join18 } from "node:path";
95709
95857
  function adapterDir(dir, spec = CLAUDE_ADAPTER) {
95710
95858
  return join18(dir, spec.id);
95711
95859
  }
@@ -95715,6 +95863,43 @@ function adapterBinaryPath(dir, spec = CLAUDE_ADAPTER) {
95715
95863
  function legacyAdapterBinaryPath(dir, spec) {
95716
95864
  return join18(dir, "node_modules", ".bin", spec.command);
95717
95865
  }
95866
+ function installedAdapterVersion(root, spec) {
95867
+ if (spec.package === null) return null;
95868
+ return versionIn(join18(root, "node_modules", ...spec.package.split("/"), "package.json"));
95869
+ }
95870
+ function packageVersionOf(binary, packageName) {
95871
+ let dir;
95872
+ try {
95873
+ dir = dirname12(realpathSync(binary));
95874
+ } catch {
95875
+ return null;
95876
+ }
95877
+ const { root } = parse5(dir);
95878
+ while (true) {
95879
+ const manifest = join18(dir, "package.json");
95880
+ if (existsSync6(manifest) && nameIn(manifest) === packageName) return versionIn(manifest);
95881
+ if (dir === root) return null;
95882
+ dir = dirname12(dir);
95883
+ }
95884
+ }
95885
+ function readManifest(manifest) {
95886
+ try {
95887
+ const parsed = JSON.parse(readFileSync3(manifest, "utf8"));
95888
+ return typeof parsed === "object" && parsed !== null ? parsed : null;
95889
+ } catch {
95890
+ return null;
95891
+ }
95892
+ }
95893
+ function stringField(manifest, field) {
95894
+ const value = readManifest(manifest)?.[field];
95895
+ return typeof value === "string" && value.trim() !== "" ? value : null;
95896
+ }
95897
+ function versionIn(manifest) {
95898
+ return existsSync6(manifest) ? stringField(manifest, "version") : null;
95899
+ }
95900
+ function nameIn(manifest) {
95901
+ return stringField(manifest, "name");
95902
+ }
95718
95903
  async function installAdapter({
95719
95904
  spec = CLAUDE_ADAPTER,
95720
95905
  dir,
@@ -95735,11 +95920,17 @@ async function installAdapter({
95735
95920
  const target = adapterDir(dir, spec);
95736
95921
  const binary = adapterBinaryPath(dir, spec);
95737
95922
  if (existsSync6(binary)) {
95738
- return { path: binary, version: spec.pinnedVersion, alreadyInstalled: true };
95923
+ const found = installedAdapterVersion(target, spec);
95924
+ if (found === null || found === spec.pinnedVersion) {
95925
+ return { path: binary, version: found ?? spec.pinnedVersion, alreadyInstalled: true };
95926
+ }
95739
95927
  }
95740
95928
  const legacy = legacyAdapterBinaryPath(dir, spec);
95741
95929
  if (existsSync6(legacy)) {
95742
- return { path: legacy, version: spec.pinnedVersion, alreadyInstalled: true };
95930
+ const found = installedAdapterVersion(dir, spec);
95931
+ if (found === null || found === spec.pinnedVersion) {
95932
+ return { path: legacy, version: found ?? spec.pinnedVersion, alreadyInstalled: true };
95933
+ }
95743
95934
  }
95744
95935
  await mkdir8(target, { recursive: true });
95745
95936
  const outcome = await run3(
@@ -95770,7 +95961,77 @@ ${outcome.output}`.trim()
95770
95961
  `o npm terminou sem erro mas ${binary} n\xE3o existe \u2014 o pacote ${spec.package} pode ter mudado de layout`
95771
95962
  );
95772
95963
  }
95773
- return { path: binary, version: spec.pinnedVersion, alreadyInstalled: false };
95964
+ return {
95965
+ path: binary,
95966
+ version: installedAdapterVersion(target, spec) ?? spec.pinnedVersion,
95967
+ alreadyInstalled: false
95968
+ };
95969
+ }
95970
+
95971
+ // src/setup/agents.ts
95972
+ function parseVersion(output) {
95973
+ const trimmed2 = output.trim();
95974
+ if (trimmed2 === "") return null;
95975
+ const match = /\d+\.\d+(\.\d+)?/.exec(trimmed2);
95976
+ return match?.[0] ?? trimmed2.split("\n")[0]?.slice(0, 60) ?? null;
95977
+ }
95978
+ async function inspect(command, install, {
95979
+ path,
95980
+ run: run3,
95981
+ preferred,
95982
+ packageName
95983
+ }) {
95984
+ const resolved = preferred !== void 0 && resolveCommandPath(preferred, { path }) !== null ? preferred : resolveCommandPath(command, { path });
95985
+ if (resolved === null) {
95986
+ return { command, path: null, managed: false, version: null, versionNote: null, install };
95987
+ }
95988
+ const outcome = await run3(resolved, ["--version"]);
95989
+ const version3 = parseVersion(outcome.output) ?? (packageName == null ? null : packageVersionOf(resolved, packageName));
95990
+ return {
95991
+ command,
95992
+ path: resolved,
95993
+ managed: preferred !== void 0 && resolved === preferred,
95994
+ version: version3,
95995
+ // A binary that is there but will not say what it is stays usable: the
95996
+ // probe is what answers the question that matters.
95997
+ versionNote: version3 === null ? outcome.failure ?? "n\xE3o disse a vers\xE3o" : null,
95998
+ install
95999
+ };
96000
+ }
96001
+ async function detectAgents({
96002
+ path = process.env["PATH"],
96003
+ env = process.env,
96004
+ run: run3 = runCommand,
96005
+ specs = ADAPTERS,
96006
+ installedAt
96007
+ } = {}) {
96008
+ const adapters = await Promise.all(
96009
+ specs.map(async (spec) => reportFor(spec, { path, env, run: run3, installedAt }))
96010
+ );
96011
+ return { adapters };
96012
+ }
96013
+ async function reportFor(spec, {
96014
+ path,
96015
+ env,
96016
+ run: run3,
96017
+ installedAt
96018
+ }) {
96019
+ const [adapter, cli] = await Promise.all([
96020
+ inspect(spec.command, adapterInstallCommand(spec), {
96021
+ path,
96022
+ run: run3,
96023
+ packageName: spec.package,
96024
+ ...installedAt === void 0 ? {} : { preferred: installedAt(spec) }
96025
+ }),
96026
+ spec.cli === null ? Promise.resolve(null) : inspect(spec.cli.command, spec.cli.install, { path, run: run3 })
96027
+ ]);
96028
+ return {
96029
+ id: spec.id,
96030
+ label: spec.label,
96031
+ adapter,
96032
+ cli,
96033
+ apiKeyEnv: spec.apiKeyEnv.find((name) => (env[name] ?? "").trim() !== "") ?? null
96034
+ };
95774
96035
  }
95775
96036
 
95776
96037
  // src/setup/login.ts
@@ -95976,6 +96237,10 @@ function specOf(id) {
95976
96237
  return spec;
95977
96238
  }
95978
96239
  var adapterInput = external_exports.object({ adapterId: external_exports.string().trim().min(1).optional() }).optional();
96240
+ function commandFor(spec, stateDir) {
96241
+ const managed = adapterBinaryPath(adaptersDir(stateDir), spec);
96242
+ return existsSync9(managed) ? managed : spec.command;
96243
+ }
95979
96244
  var setupRouter = router({
95980
96245
  /** The five checks, each one able to fail without the others. */
95981
96246
  preflight: publicProcedure.query(({ ctx }) => preflight({ config: ctx.config })),
@@ -96030,7 +96295,7 @@ var setupRouter = router({
96030
96295
  })
96031
96296
  ).mutation(
96032
96297
  ({ ctx, input }) => domainSafeAsync(async () => {
96033
- const command = input.command ?? specOf(input.adapterId).command;
96298
+ const command = input.command ?? commandFor(specOf(input.adapterId), ctx.config.stateDir);
96034
96299
  const cwd = join19(ctx.config.stateDir, "probe");
96035
96300
  const report = await ctx.acpManager.probe({
96036
96301
  command,
@@ -96095,7 +96360,7 @@ var setupRouter = router({
96095
96360
  mkdirSync4(cwd, { recursive: true });
96096
96361
  return Promise.resolve(
96097
96362
  ctx.agentAuth.start({
96098
- command: input.command ?? spec.command,
96363
+ command: input.command ?? commandFor(spec, ctx.config.stateDir),
96099
96364
  ...input.args === void 0 ? {} : { args: input.args },
96100
96365
  cwd,
96101
96366
  methodId: input.methodId,
@@ -96131,7 +96396,7 @@ var setupRouter = router({
96131
96396
  }).optional()
96132
96397
  ).query(
96133
96398
  ({ ctx, input }) => domainSafeAsync(async () => {
96134
- const command = input?.command ?? specOf(input?.adapterId).command;
96399
+ const command = input?.command ?? commandFor(specOf(input?.adapterId), ctx.config.stateDir);
96135
96400
  const cwd = join19(ctx.config.stateDir, "probe");
96136
96401
  try {
96137
96402
  mkdirSync4(cwd, { recursive: true });
@@ -96320,11 +96585,110 @@ var workspaceRouter = router({
96320
96585
  });
96321
96586
 
96322
96587
  // src/routers/worktree.ts
96323
- import { existsSync as existsSync9 } from "node:fs";
96588
+ import { existsSync as existsSync10, realpathSync as realpathSync2 } from "node:fs";
96324
96589
  var nameSchema4 = external_exports.string().trim().min(1, "informe um nome").max(120).refine((value) => !value.startsWith("-"), "o nome n\xE3o pode come\xE7ar com '-'").refine((value) => !value.includes(".."), "o nome n\xE3o pode conter '..'").refine((value) => !value.startsWith("/") && !value.endsWith("/"), "barra sobrando no nome").refine((value) => !/[\s~^:?*[\\]/.test(value), "o nome tem caracteres que o git n\xE3o aceita");
96325
96590
  var idSchema2 = external_exports.object({ id: external_exports.string().min(1) });
96591
+ var refSchema = external_exports.string().trim().min(1).max(255).refine((value) => !value.startsWith("-"), "a ref n\xE3o pode come\xE7ar com '-'").refine((value) => !value.includes(".."), "a ref n\xE3o pode conter '..'").refine((value) => !/[\s~^:?*[\\\u0000-\u001f\u007f]/.test(value), "a ref tem caracteres que o git n\xE3o aceita");
96592
+ var fromSchema = external_exports.discriminatedUnion("kind", [
96593
+ external_exports.object({ kind: external_exports.literal("default") }),
96594
+ external_exports.object({ kind: external_exports.literal("branch"), ref: refSchema }),
96595
+ external_exports.object({ kind: external_exports.literal("issue"), number: external_exports.number().int().positive() }),
96596
+ external_exports.object({ kind: external_exports.literal("pr"), number: external_exports.number().int().positive() })
96597
+ ]);
96598
+ async function remoteOf2(ctx, project2) {
96599
+ return project2.remoteUrl ?? await ctx.git.getRemoteUrl(project2.path);
96600
+ }
96601
+ async function resolveSource(ctx, project2, name, from) {
96602
+ const origin = from ?? { kind: "default" };
96603
+ switch (origin.kind) {
96604
+ // `issue` corta da default, igual ao `default`: o que a issue decide é o
96605
+ // NOME, e o nome já veio no pedido — montado na tela, sem escrever no host
96606
+ // ([Q1](../../../../docs/features/026-worktree-from/open-questions.md)).
96607
+ case "default":
96608
+ case "issue":
96609
+ return {
96610
+ source: { kind: "new-branch", base: project2.defaultBranch },
96611
+ branch: name
96612
+ };
96613
+ case "branch": {
96614
+ if (await ctx.git.branchExists(project2.path, origin.ref)) {
96615
+ return { source: { kind: "existing-branch" }, branch: origin.ref };
96616
+ }
96617
+ const remote = await remoteHolding(ctx, project2.path, origin.ref);
96618
+ if (remote === null) {
96619
+ throw new DomainError(
96620
+ "BLOCKED",
96621
+ `a branch "${origin.ref}" n\xE3o est\xE1 no disco; rode um fetch neste projeto e tente de novo`
96622
+ );
96623
+ }
96624
+ return {
96625
+ source: { kind: "remote-branch", remoteRef: `${remote}/${origin.ref}` },
96626
+ branch: name
96627
+ };
96628
+ }
96629
+ case "pr": {
96630
+ const entry = await ctx.pr.get({
96631
+ id: project2.id,
96632
+ path: project2.path,
96633
+ remoteUrl: await remoteOf2(ctx, project2)
96634
+ });
96635
+ const pull = entry.snapshot?.pulls.find((item) => item.number === origin.number);
96636
+ if (pull === void 0) {
96637
+ throw new DomainError(
96638
+ "BLOCKED",
96639
+ `o Lumem n\xE3o conhece a PR #${origin.number} deste projeto` + (entry.failure === null ? "" : ` \u2014 ${entry.failure.message}`)
96640
+ );
96641
+ }
96642
+ return prSource(ctx, project2, name, origin.number, pull);
96643
+ }
96644
+ }
96645
+ }
96646
+ async function prSource(ctx, project2, name, number4, pull) {
96647
+ const fork = pull.crossRepository === true;
96648
+ if (!fork) {
96649
+ const holding = await remoteHolding(ctx, project2.path, pull.headRefName);
96650
+ if (holding !== null) {
96651
+ return {
96652
+ source: { kind: "remote-branch", remoteRef: `${holding}/${pull.headRefName}` },
96653
+ branch: name
96654
+ };
96655
+ }
96656
+ }
96657
+ const remote = await remoteToFetchFrom(ctx, project2.path);
96658
+ if (remote === null) {
96659
+ throw new DomainError(
96660
+ "BLOCKED",
96661
+ `este projeto n\xE3o tem remoto configurado, ent\xE3o n\xE3o h\xE1 de onde buscar a PR #${number4}`
96662
+ );
96663
+ }
96664
+ const target = fork ? `refs/remotes/${remote}/pr/${String(number4)}` : `refs/remotes/${remote}/${pull.headRefName}`;
96665
+ const source = fork ? `refs/pull/${String(number4)}/head` : `refs/heads/${pull.headRefName}`;
96666
+ try {
96667
+ await ctx.git.fetchRef({ repoPath: project2.path, remote, refspec: `+${source}:${target}` });
96668
+ } catch (error40) {
96669
+ const detail = error40 instanceof Error ? error40.message : String(error40);
96670
+ throw new DomainError(
96671
+ "BLOCKED",
96672
+ `n\xE3o deu para buscar a branch da PR #${String(number4)}: ${detail}`
96673
+ );
96674
+ }
96675
+ return fork ? { source: { kind: "branch-at", ref: target }, branch: name } : {
96676
+ source: { kind: "remote-branch", remoteRef: `${remote}/${pull.headRefName}` },
96677
+ branch: name
96678
+ };
96679
+ }
96680
+ async function remoteToFetchFrom(ctx, repoPath) {
96681
+ const remotes = await ctx.git.listRemotes(repoPath);
96682
+ if (remotes.length === 0) return null;
96683
+ return remotes.includes("origin") ? "origin" : remotes[0] ?? null;
96684
+ }
96685
+ async function remoteHolding(ctx, repoPath, branch) {
96686
+ const entry = (await ctx.git.listBranches(repoPath)).find((item) => item.name === branch);
96687
+ if (entry === void 0 || entry.remotes.length === 0) return null;
96688
+ return entry.remotes.includes("origin") ? "origin" : entry.remotes[0] ?? null;
96689
+ }
96326
96690
  function withPresence(row) {
96327
- return { ...row, present: existsSync9(row.path) };
96691
+ return { ...row, present: existsSync10(row.path) };
96328
96692
  }
96329
96693
  async function requireProject(ctx, projectId) {
96330
96694
  const project2 = await createProjectRepository(ctx.db).findById(projectId);
@@ -96344,31 +96708,130 @@ var worktreeRouter = router({
96344
96708
  * the execution. A second assembly in the client would be a sentence that lies
96345
96709
  * the first time a flag changes.
96346
96710
  */
96347
- plan: publicProcedure.input(external_exports.object({ projectId: external_exports.string().min(1), name: nameSchema4 })).query(
96711
+ plan: publicProcedure.input(external_exports.object({ projectId: external_exports.string().min(1), name: nameSchema4, from: fromSchema.optional() })).query(
96348
96712
  ({ ctx, input }) => domainSafeAsync(async () => {
96349
96713
  const project2 = await requireProject(ctx, input.projectId);
96350
96714
  const path = worktreeDir(await homeOfProject(ctx, project2), input.name);
96715
+ const { source, branch } = await resolveSource(ctx, project2, input.name, input.from);
96716
+ const baseRef = source.kind === "new-branch" ? source.base : source.kind === "remote-branch" ? source.remoteRef : branch;
96351
96717
  const [branchTaken, occupied, base] = await Promise.all([
96352
- ctx.git.branchExists(project2.path, input.name),
96353
- Promise.resolve(existsSync9(path)),
96354
- // The sha the branch would start from. Null in a repository with no
96355
- // commit yet, which is a repository someone can still cut a worktree
96356
- // from — so it reports null instead of refusing.
96357
- ctx.git.describe(project2.path).then((described) => described.head.shortSha).catch(() => null)
96718
+ // Numa origem que **usa** a branch existente, "já existe" é a
96719
+ // pré-condição e não a recusa: quem recusa é o checkout que já a tem.
96720
+ source.kind === "existing-branch" ? Promise.resolve(false) : ctx.git.branchExists(project2.path, branch),
96721
+ Promise.resolve(existsSync10(path)),
96722
+ /*
96723
+ * O sha **da origem escolhida**, e não o HEAD do checkout principal.
96724
+ *
96725
+ * Null num repositório sem commit — que é um repositório de onde
96726
+ * ainda se pode pedir um preview —, então ele responde null em vez de
96727
+ * recusar. O que ele não pode é emparelhar o nome de uma origem com o
96728
+ * sha de outra: a tela desenha os dois lado a lado.
96729
+ */
96730
+ ctx.git.resolveShortSha(project2.path, baseRef)
96358
96731
  ]);
96732
+ const holder = source.kind === "existing-branch" ? (await ctx.git.listWorktrees(project2.path)).find((entry) => entry.branch === branch) : void 0;
96359
96733
  return {
96360
96734
  name: input.name,
96361
- branch: input.name,
96735
+ branch,
96362
96736
  path,
96363
- baseBranch: project2.defaultBranch,
96737
+ baseBranch: baseRef,
96364
96738
  baseSha: base,
96365
- command: `git worktree add -b ${input.name} ${path} ${project2.defaultBranch}`,
96739
+ // O mesmo vetor que a execução usa — `worktreeAddArgs`, e não uma
96740
+ // string montada aqui. Ver o comentário dela.
96741
+ command: `git ${worktreeAddArgs(branch, path, source).join(" ")}`,
96366
96742
  /** Said here rather than at creation: the refusal is cheaper before. */
96367
- refusal: branchTaken ? `a branch "${input.name}" j\xE1 existe; escolha outro nome` : occupied ? `${path} j\xE1 existe` : null
96743
+ refusal: branchTaken ? `a branch "${branch}" j\xE1 existe; escolha outro nome` : holder !== void 0 ? `a branch "${branch}" j\xE1 est\xE1 no checkout em ${holder.path}` : occupied ? `${path} j\xE1 existe` : null
96744
+ };
96745
+ })
96746
+ ),
96747
+ /**
96748
+ * As branches que servem de origem — **disco, e nada mais**.
96749
+ *
96750
+ * Separada da leitura do host de propósito, e a separação é a F3.5: 10 ms
96751
+ * medidos contra ~730 ms. Numa procedure só, a lista local esperaria a rede
96752
+ * toda vez, e a aba `branch` — a única que existe em projeto sem remoto —
96753
+ * ficaria refém de um `gh` que talvez nem esteja instalado.
96754
+ */
96755
+ branches: publicProcedure.input(external_exports.object({ projectId: external_exports.string().min(1) })).query(
96756
+ ({ ctx, input }) => domainSafeAsync(async () => {
96757
+ const project2 = await requireProject(ctx, input.projectId);
96758
+ const [branches, worktrees] = await Promise.all([
96759
+ ctx.git.listBranches(project2.path),
96760
+ createWorktreeRepository(ctx.db).listByProject(project2.id)
96761
+ ]);
96762
+ const realOf = (path) => {
96763
+ try {
96764
+ return realpathSync2(path);
96765
+ } catch {
96766
+ return path;
96767
+ }
96768
+ };
96769
+ const rowOfPath = new Map(worktrees.map((row) => [realOf(row.path), row]));
96770
+ return branches.map((branch) => {
96771
+ const holder = branch.worktreePath === null ? void 0 : rowOfPath.get(realOf(branch.worktreePath));
96772
+ return {
96773
+ ...branch,
96774
+ worktreeId: holder?.id ?? null,
96775
+ worktreeName: holder?.name ?? null
96776
+ };
96777
+ });
96778
+ })
96779
+ ),
96780
+ /**
96781
+ * O que o host sabe: issues abertas e PRs, com a head marcada.
96782
+ *
96783
+ * As PRs saem do `PrCache`, que a barra já mantém por projeto — nesta
96784
+ * procedure elas costumam custar zero. As issues saem do `IssueCache`, que é
96785
+ * irmão dele e não pesquisa sozinho.
96786
+ */
96787
+ hostOrigins: publicProcedure.input(external_exports.object({ projectId: external_exports.string().min(1) })).query(
96788
+ ({ ctx, input }) => domainSafeAsync(async () => {
96789
+ const project2 = await requireProject(ctx, input.projectId);
96790
+ const remoteUrl = await remoteOf2(ctx, project2);
96791
+ const target = { id: project2.id, path: project2.path, remoteUrl };
96792
+ const [issues, pr, branches] = await Promise.all([
96793
+ ctx.issues.get(target),
96794
+ ctx.pr.get(target),
96795
+ ctx.git.listBranches(project2.path)
96796
+ ]);
96797
+ const published = new Set(
96798
+ branches.filter((branch) => branch.remotes.length > 0).map((branch) => branch.name)
96799
+ );
96800
+ return {
96801
+ /** Como o host se chama na tela. Null quando não há host nenhum. */
96802
+ host: remoteUrl === null ? null : ctx.prHost.supports(remoteUrl) ? ctx.prHost.name : null,
96803
+ issues: { items: issues.issues ?? [], failure: issues.failure, readAt: issues.readAt },
96804
+ pulls: {
96805
+ items: (pr.snapshot?.pulls ?? []).filter((pull) => pull.state === "OPEN").map((pull) => ({
96806
+ number: pull.number,
96807
+ title: pull.title,
96808
+ url: pull.url,
96809
+ headRefName: pull.headRefName,
96810
+ isDraft: pull.isDraft,
96811
+ updatedAt: pull.updatedAt,
96812
+ /*
96813
+ * `onDisk` deixou de ser permissão e passou a ser **previsão de
96814
+ * espera** ([ADR](../../../../docs/adr/2026-09-08-0210-pr-head-is-fetched-on-demand.md)).
96815
+ *
96816
+ * A tela não desabilita mais nada com isto: ela escreve uma nota
96817
+ * cinza dizendo que aquela linha vai à rede antes de cortar. Duas
96818
+ * linhas idênticas se comportando diferente — uma instantânea e
96819
+ * outra com um fetch no meio — é o que a nota evita.
96820
+ *
96821
+ * Fork nunca está "no disco", mesmo com uma branch homônima
96822
+ * local: numa PR cruzada o `headRefName` é o nome no fork, e a
96823
+ * homônima é outra coisa.
96824
+ */
96825
+ crossRepository: pull.crossRepository === true,
96826
+ onDisk: pull.crossRepository !== true && published.has(pull.headRefName)
96827
+ })),
96828
+ failure: pr.failure,
96829
+ readAt: pr.readAt
96830
+ }
96368
96831
  };
96369
96832
  })
96370
96833
  ),
96371
- create: publicProcedure.input(external_exports.object({ projectId: external_exports.string().min(1), name: nameSchema4 })).mutation(
96834
+ create: publicProcedure.input(external_exports.object({ projectId: external_exports.string().min(1), name: nameSchema4, from: fromSchema.optional() })).mutation(
96372
96835
  ({ ctx, input }) => domainSafeAsync(async () => {
96373
96836
  const project2 = await requireProject(ctx, input.projectId);
96374
96837
  if (!await ctx.git.hasCommits(project2.path)) {
@@ -96378,17 +96841,20 @@ var worktreeRouter = router({
96378
96841
  );
96379
96842
  }
96380
96843
  const path = worktreeDir(await homeOfProject(ctx, project2), input.name);
96844
+ const { source, branch } = await resolveSource(ctx, project2, input.name, input.from);
96381
96845
  await ctx.git.addWorktree({
96382
96846
  repoPath: project2.path,
96383
- branch: input.name,
96847
+ branch,
96384
96848
  targetPath: path,
96385
- baseBranch: project2.defaultBranch
96849
+ source
96386
96850
  });
96387
96851
  try {
96388
96852
  const created = await createWorktreeRepository(ctx.db).create({
96389
96853
  projectId: project2.id,
96390
96854
  name: input.name,
96391
- branch: input.name,
96855
+ // Desde a Q9 estes dois podem divergir: cortar de uma branch que já
96856
+ // existe mantém a branch e dá outro nome à worktree.
96857
+ branch,
96392
96858
  path
96393
96859
  });
96394
96860
  ctx.events.emit({ type: "worktree.changed", projectId: project2.id });
@@ -96434,7 +96900,7 @@ var worktreeRouter = router({
96434
96900
  `a worktree tem ${running.length} sess\xE3o(\xF5es) rodando; encerre-as antes de remover`
96435
96901
  );
96436
96902
  }
96437
- if (existsSync9(row.path) && !input.force) {
96903
+ if (existsSync10(row.path) && !input.force) {
96438
96904
  const status = await ctx.git.getStatus(row.path);
96439
96905
  if (!status.clean) {
96440
96906
  throw new DomainError(
@@ -96444,12 +96910,12 @@ var worktreeRouter = router({
96444
96910
  }
96445
96911
  }
96446
96912
  const scope = { scopeType: "worktree", scopeId: row.id };
96447
- if (existsSync9(row.path)) {
96913
+ if (existsSync10(row.path)) {
96448
96914
  await ctx.scripts.runToCompletion(scope, "teardown").catch(() => {
96449
96915
  });
96450
96916
  }
96451
96917
  await ctx.scripts.stopAll(scope);
96452
- if (existsSync9(row.path)) {
96918
+ if (existsSync10(row.path)) {
96453
96919
  await ctx.git.removeWorktree({
96454
96920
  repoPath: project2.path,
96455
96921
  path: row.path,
@@ -96520,6 +96986,7 @@ async function createServer2({
96520
96986
  // noutra aba aparecer nesta sem esperar o próximo ciclo.
96521
96987
  onChange: (projectId) => events.emit({ type: "pr.changed", projectId })
96522
96988
  }),
96989
+ issues = createIssueCache({ host: prHost }),
96523
96990
  agentAuth = createAgentAuthService({ acpManager }),
96524
96991
  logger = false
96525
96992
  }) {
@@ -96540,6 +97007,7 @@ async function createServer2({
96540
97007
  git,
96541
97008
  clones,
96542
97009
  pr,
97010
+ issues,
96543
97011
  prHost,
96544
97012
  agentAuth,
96545
97013
  events