0xray 4.0.8 → 4.0.10

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.
@@ -0,0 +1,120 @@
1
+ /**
2
+ * wear-vendored-repertoire.cjs — Materialize @0xray/repertoire from the
3
+ * packed vendor tree. Published 0xray must not ship a `file:` dependency:
4
+ * npm --install-links, pnpm, and yarn resolve that path from the consumer
5
+ * root (ENOENT on vendor/@0xray/repertoire), not from node_modules/0xray.
6
+ */
7
+
8
+ const fs = require("fs");
9
+ const path = require("path");
10
+
11
+ function resolveVendoredRepertoire(packageRoot) {
12
+ const vendor = path.join(packageRoot, "vendor", "@0xray", "repertoire");
13
+ if (fs.existsSync(path.join(vendor, "package.json"))) return vendor;
14
+ return null;
15
+ }
16
+
17
+ function repertoirePackageName(dir) {
18
+ try {
19
+ const pkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
20
+ return pkg.name || null;
21
+ } catch {
22
+ return null;
23
+ }
24
+ }
25
+
26
+ function destAlreadyWorn(dest, vendor) {
27
+ try {
28
+ if (!fs.existsSync(path.join(dest, "package.json"))) return false;
29
+ if (repertoirePackageName(dest) !== "@0xray/repertoire") return false;
30
+ return fs.realpathSync(dest) === fs.realpathSync(vendor);
31
+ } catch {
32
+ return false;
33
+ }
34
+ }
35
+
36
+ function destIsUsableRepertoire(dest) {
37
+ return repertoirePackageName(dest) === "@0xray/repertoire";
38
+ }
39
+
40
+ function removeBrokenDest(dest) {
41
+ try {
42
+ const st = fs.lstatSync(dest);
43
+ if (st.isSymbolicLink() && !fs.existsSync(dest)) {
44
+ fs.unlinkSync(dest);
45
+ }
46
+ } catch {
47
+ /* dest absent */
48
+ }
49
+ }
50
+
51
+ function wearOne(vendor, dest, log) {
52
+ removeBrokenDest(dest);
53
+ if (destAlreadyWorn(dest, vendor)) return true;
54
+ if (fs.existsSync(dest) && destIsUsableRepertoire(dest)) return true;
55
+
56
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
57
+ const rel = path.relative(path.dirname(dest), vendor);
58
+ const linkType = process.platform === "win32" ? "junction" : "dir";
59
+ try {
60
+ fs.symlinkSync(rel, dest, linkType);
61
+ return true;
62
+ } catch (linkErr) {
63
+ try {
64
+ fs.cpSync(vendor, dest, { recursive: true });
65
+ return true;
66
+ } catch (copyErr) {
67
+ if (typeof log === "function") {
68
+ log("wear-repertoire", "failed to wear vendored organ", "warning", {
69
+ dest,
70
+ linkError: linkErr.message,
71
+ copyError: copyErr.message,
72
+ });
73
+ }
74
+ return false;
75
+ }
76
+ }
77
+ }
78
+
79
+ function wearDestinations(packageRoot, targetDir) {
80
+ const dests = [path.join(packageRoot, "node_modules", "@0xray", "repertoire")];
81
+ if (targetDir && path.resolve(targetDir) !== path.resolve(packageRoot)) {
82
+ dests.push(path.join(targetDir, "node_modules", "@0xray", "repertoire"));
83
+ }
84
+ return dests;
85
+ }
86
+
87
+ function wearVendoredRepertoire(packageRoot, targetDir, log) {
88
+ const vendor = resolveVendoredRepertoire(packageRoot);
89
+ if (!vendor) return { worn: [], vendor: null };
90
+
91
+ const worn = [];
92
+ for (const dest of wearDestinations(packageRoot, targetDir)) {
93
+ if (wearOne(vendor, dest, log)) worn.push(dest);
94
+ }
95
+ if (worn.length && typeof log === "function") {
96
+ log("wear-repertoire", "vendored @0xray/repertoire worn", "info", {
97
+ vendor,
98
+ dests: worn,
99
+ });
100
+ }
101
+ return { worn, vendor };
102
+ }
103
+
104
+ function hasFileProtocolDependency(pkg) {
105
+ const buckets = [pkg.dependencies, pkg.optionalDependencies, pkg.peerDependencies];
106
+ for (const bucket of buckets) {
107
+ if (!bucket || typeof bucket !== "object") continue;
108
+ for (const spec of Object.values(bucket)) {
109
+ if (String(spec).startsWith("file:")) return true;
110
+ }
111
+ }
112
+ return false;
113
+ }
114
+
115
+ module.exports = {
116
+ resolveVendoredRepertoire,
117
+ wearVendoredRepertoire,
118
+ wearDestinations,
119
+ hasFileProtocolDependency,
120
+ };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xray-pre-tool",
3
- "version": "4.0.4",
3
+ "version": "4.0.10",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "0xRay constitution + temperament PreToolUse for OpenClaw",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "./features.schema.json",
3
- "version": "4.0.8",
3
+ "version": "4.0.10",
4
4
  "description": "0xRay Framework - Unified Feature Configuration",
5
5
  "suit_temperament": {
6
6
  "profile": "auto",