mason-context 0.17.4 → 0.19.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.
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env node
2
+ if (!import.meta.url.endsWith("/mason-runtime.js")) await import("./mason-runtime.js").then(m => m.registerRuntime());
2
3
 
3
4
  // src/hook/hook.ts
4
- import fs5 from "fs/promises";
5
+ import fs6 from "fs/promises";
5
6
  import path10 from "path";
6
- import os from "os";
7
+ import os2 from "os";
7
8
 
8
9
  // src/decisions/decisions.ts
9
- import fs3 from "fs/promises";
10
+ import fs4 from "fs/promises";
10
11
  import path7 from "path";
11
12
  import { createHash } from "crypto";
12
13
  import { z as z3 } from "zod";
@@ -141,6 +142,10 @@ async function readStoreJson(root, relative) {
141
142
  import path5 from "path";
142
143
  import { z } from "zod";
143
144
 
145
+ // src/utils/store-lock.ts
146
+ import fs3 from "fs/promises";
147
+ import os from "os";
148
+
144
149
  // src/test-map.ts
145
150
  import path4 from "path";
146
151
 
@@ -150,6 +155,7 @@ var verificationFields = {
150
155
  refreshedHash: z.string().optional(),
151
156
  verifiedAt: z.string().optional(),
152
157
  verifiedHash: z.string().optional(),
158
+ verificationToken: z.string().optional(),
153
159
  verificationFailed: z.boolean().optional(),
154
160
  verificationNote: z.string().optional()
155
161
  };
@@ -369,7 +375,7 @@ async function loadDecisionStore(rootDir) {
369
375
  const diagnostics = [];
370
376
  let entries;
371
377
  try {
372
- entries = await fs3.readdir(await storePath(rootDir, ".mason/decisions"));
378
+ entries = await fs4.readdir(await storePath(rootDir, ".mason/decisions"));
373
379
  } catch (error) {
374
380
  if (error.code !== "ENOENT") diagnostics.push({ path: ".mason/decisions", message: String(error) });
375
381
  return { records, diagnostics };
@@ -395,7 +401,7 @@ import { createHash as createHash2 } from "crypto";
395
401
  import path9 from "path";
396
402
 
397
403
  // src/drift/drift.ts
398
- import fs4 from "fs/promises";
404
+ import fs5 from "fs/promises";
399
405
  import path8 from "path";
400
406
  function parseChanges(output) {
401
407
  const fields = output.split("\0");
@@ -473,7 +479,7 @@ var MAX_WALK_UP = 30;
473
479
  var SUPPORTED_TOOLS = /* @__PURE__ */ new Set(["Read", "Edit", "Write"]);
474
480
  async function exists(p) {
475
481
  try {
476
- await fs5.access(p);
482
+ await fs6.access(p);
477
483
  return true;
478
484
  } catch {
479
485
  return false;
@@ -502,7 +508,7 @@ function stateKey(input) {
502
508
  }
503
509
  async function loadInjected(stateFile) {
504
510
  try {
505
- const parsed = JSON.parse(await fs5.readFile(stateFile, "utf-8"));
511
+ const parsed = JSON.parse(await fs6.readFile(stateFile, "utf-8"));
506
512
  return new Set(Array.isArray(parsed) ? parsed.filter((x) => typeof x === "string") : []);
507
513
  } catch {
508
514
  return /* @__PURE__ */ new Set();
@@ -543,7 +549,7 @@ async function runHook(stdinText, env = {}) {
543
549
  const relPath = path10.relative(root, absPath).split(path10.sep).join("/");
544
550
  if (relPath.startsWith("..")) return null;
545
551
  const { records } = await loadDecisionStore(root);
546
- const stateDir = env.stateDir ?? os.tmpdir();
552
+ const stateDir = env.stateDir ?? os2.tmpdir();
547
553
  const stateFile = path10.join(stateDir, `mason-hook-${createHash2("sha256").update(root).digest("hex").slice(0, 12)}-${stateKey(input)}.json`);
548
554
  const injected = await loadInjected(stateFile);
549
555
  const recordKey = (record) => `${record.id}:${createHash2("sha256").update(JSON.stringify(record)).digest("hex")}`;
@@ -561,7 +567,7 @@ async function runHook(stdinText, env = {}) {
561
567
  const drift = await computeDecisionDrift(root, selected);
562
568
  for (const record of selected) injected.add(recordKey(record));
563
569
  try {
564
- await fs5.writeFile(stateFile, JSON.stringify([...injected]), "utf-8");
570
+ await fs6.writeFile(stateFile, JSON.stringify([...injected]), "utf-8");
565
571
  } catch {
566
572
  }
567
573
  return JSON.stringify({