@zixt/host 0.0.61 → 0.0.62

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.
Files changed (2) hide show
  1. package/dist/index.js +35 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ import { homedir } from "node:os";
31
31
  // package.json
32
32
  var package_default = {
33
33
  name: "@zixt/host",
34
- version: "0.0.61",
34
+ version: "0.0.62",
35
35
  type: "module",
36
36
  exports: {
37
37
  ".": "./src/client.ts",
@@ -16152,6 +16152,7 @@ var taskGitSummaryLabel = (maxLength, label) => external_exports.string().min(1)
16152
16152
  isSafeSingleLineDisplayText,
16153
16153
  `${label} must not contain control, line-separator, or bidirectional formatting characters`
16154
16154
  );
16155
+ var PullRequestLookup = external_exports.enum(["observed", "unavailable"]);
16155
16156
  var TaskGitSummary = external_exports.object({
16156
16157
  repositories: external_exports.array(
16157
16158
  external_exports.object({
@@ -16166,6 +16167,12 @@ var TaskGitSummary = external_exports.object({
16166
16167
  ahead: external_exports.number().int().min(0),
16167
16168
  behind: external_exports.number().int().min(0),
16168
16169
  changedFiles: external_exports.number().int().min(0),
16170
+ /**
16171
+ * Whether Zixt could actually ask GitHub about this branch.
16172
+ * Absent is a Host that never reported it, which is also "Zixt
16173
+ * does not know" — never evidence that no pull request exists.
16174
+ */
16175
+ pullRequestLookup: PullRequestLookup.optional(),
16169
16176
  pullRequest: external_exports.object({
16170
16177
  number: external_exports.number().int().min(1),
16171
16178
  url: external_exports.string().max(2e3).regex(
@@ -16555,6 +16562,12 @@ var TaskWorkingContextBase = external_exports.object({
16555
16562
  changedFiles: external_exports.number().int().min(0),
16556
16563
  /** Present only for a safely parsed github.com remote. */
16557
16564
  githubRepository: GithubRepositoryName.optional(),
16565
+ /**
16566
+ * Whether the authenticated branch read reached GitHub at all.
16567
+ * Absence of a pull request only means "there is none" when this
16568
+ * says `observed`.
16569
+ */
16570
+ pullRequestLookup: PullRequestLookup.optional(),
16558
16571
  /** Present only when GitHub associates this exact branch with a PR. */
16559
16572
  pullRequest: external_exports.object({
16560
16573
  number: external_exports.number().int().min(1),
@@ -34836,9 +34849,9 @@ function selectPullRequest(output, expectedBaseRepository, expectedHeadRepositor
34836
34849
  try {
34837
34850
  value = JSON.parse(output);
34838
34851
  } catch {
34839
- return void 0;
34852
+ return { lookup: "unavailable" };
34840
34853
  }
34841
- if (!Array.isArray(value)) return void 0;
34854
+ if (!Array.isArray(value)) return { lookup: "unavailable" };
34842
34855
  let best;
34843
34856
  for (const entry of value.slice(0, PULL_REQUEST_LIST_LIMIT)) {
34844
34857
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
@@ -34853,16 +34866,17 @@ function selectPullRequest(output, expectedBaseRepository, expectedHeadRepositor
34853
34866
  best = parsed;
34854
34867
  }
34855
34868
  }
34856
- return best;
34869
+ return { lookup: "observed", ...best ? { pullRequest: best } : {} };
34857
34870
  }
34858
34871
  async function pullRequest(command, gitCommand, repositoryCwd, commandCwd, repository, branch, signal) {
34859
- if (!command || !repository || !branch) return void 0;
34872
+ if (!command || !repository || !branch) return { lookup: "unavailable" };
34860
34873
  const baseRepositories = await pullRequestBaseRepositories(
34861
34874
  gitCommand,
34862
34875
  repositoryCwd,
34863
34876
  repository,
34864
34877
  signal
34865
34878
  );
34879
+ let answered = false;
34866
34880
  for (const baseRepository of baseRepositories) {
34867
34881
  const output = await run(
34868
34882
  command.executablePath,
@@ -34886,10 +34900,11 @@ async function pullRequest(command, gitCommand, repositoryCwd, commandCwd, repos
34886
34900
  signal
34887
34901
  );
34888
34902
  if (!output) continue;
34889
- const parsed = selectPullRequest(output, baseRepository, repository, branch);
34890
- if (parsed) return parsed;
34903
+ const observation = selectPullRequest(output, baseRepository, repository, branch);
34904
+ if (observation.lookup === "observed") answered = true;
34905
+ if (observation.pullRequest) return observation;
34891
34906
  }
34892
- return void 0;
34907
+ return { lookup: answered ? "observed" : "unavailable" };
34893
34908
  }
34894
34909
  async function repositoryState(directory, git, env, signal) {
34895
34910
  if (!git.available || !git.executablePath) return null;
@@ -35034,9 +35049,10 @@ var WorkingContextPullRequestCache = class {
35034
35049
  }
35035
35050
  #entries = /* @__PURE__ */ new Map();
35036
35051
  async enrich(context, command, options = {}) {
35037
- if (!command || !context.repositories || context.repositories.length === 0) return context;
35052
+ if (!context.repositories || context.repositories.length === 0) return context;
35038
35053
  const repositories = await Promise.all(
35039
35054
  context.repositories.map(async (repository) => {
35055
+ if (!command) return { ...repository, pullRequestLookup: "unavailable" };
35040
35056
  if (!repository.githubRepository || !repository.branch) return repository;
35041
35057
  const key = JSON.stringify([
35042
35058
  repository.githubRepository.toLocaleLowerCase("en-US"),
@@ -35044,7 +35060,7 @@ var WorkingContextPullRequestCache = class {
35044
35060
  repository.headSha
35045
35061
  ]);
35046
35062
  const cached2 = this.#entries.get(key);
35047
- let observed = cached2?.pullRequest;
35063
+ let observed = cached2?.observation ?? { lookup: "unavailable" };
35048
35064
  if (options.force || !cached2 || this.now() - cached2.checkedAt >= this.ttlMs) {
35049
35065
  observed = await pullRequest(
35050
35066
  command,
@@ -35057,7 +35073,7 @@ var WorkingContextPullRequestCache = class {
35057
35073
  );
35058
35074
  if (!options.signal?.aborted) {
35059
35075
  this.#entries.delete(key);
35060
- this.#entries.set(key, { checkedAt: this.now(), pullRequest: observed });
35076
+ this.#entries.set(key, { checkedAt: this.now(), observation: observed });
35061
35077
  while (this.#entries.size > Math.max(1, this.maxEntries)) {
35062
35078
  const oldest = this.#entries.keys().next().value;
35063
35079
  if (oldest === void 0) break;
@@ -35065,7 +35081,14 @@ var WorkingContextPullRequestCache = class {
35065
35081
  }
35066
35082
  }
35067
35083
  }
35068
- return observed ? { ...repository, pullRequest: observed } : repository;
35084
+ if (observed.lookup === "unavailable") {
35085
+ return repository.pullRequest || repository.pullRequestLookup === "observed" ? repository : { ...repository, pullRequestLookup: "unavailable" };
35086
+ }
35087
+ return {
35088
+ ...repository,
35089
+ pullRequestLookup: observed.lookup,
35090
+ ...observed.pullRequest ? { pullRequest: observed.pullRequest } : {}
35091
+ };
35069
35092
  })
35070
35093
  );
35071
35094
  return TaskWorkingContextObservation.parse({ ...context, repositories });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zixt/host",
3
- "version": "0.0.61",
3
+ "version": "0.0.62",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/client.ts",