0xray 4.0.30 → 4.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.grok-plugin/plugin.json +1 -1
- package/.opencode/skills/orchestrator/SKILL.md +12 -0
- package/.xray/features.json +1 -1
- package/dist/CHANGELOG.md +9 -0
- package/dist/cli/commands/validate.js +5 -0
- package/dist/cli/index.js +16 -1
- package/dist/integrations/grok/hooks/grok-hook-utils.js +24 -4
- package/dist/integrations/grok/hooks/post-tool-use.js +2 -1
- package/dist/integrations/grok/hooks/pre-tool-use.js +90 -5
- package/dist/integrations/grok/hooks/session-start.js +7 -2
- package/dist/integrations/hooks/goggles-pipeline.mjs +568 -0
- package/dist/integrations/hooks/goggles-planes.json +28 -0
- package/dist/integrations/hooks/plates.cjs +23 -0
- package/dist/integrations/hooks/station-hook-runtime.cjs +40 -11
- package/dist/integrations/hooks/station-memory-ingest.mjs +3 -0
- package/dist/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
- package/dist/mcps/orchestrator/config/agent-capabilities.js +7 -0
- package/dist/memory-routing/plates.d.ts +1 -1
- package/dist/memory-routing/plates.js +5 -0
- package/dist/memory-routing/provider-loader.js +2 -0
- package/dist/nucleus/thin-dispatch.d.ts +1 -0
- package/dist/nucleus/thin-dispatch.js +4 -2
- package/dist/skills/orchestrator/SKILL.md +12 -0
- package/docs-site/docs/plates/glossary.md +27 -0
- package/docs-site/docs/plates/goggles.md +18 -0
- package/docs-site/docs/plates/grokbot.md +41 -0
- package/docs-site/docs/plates/host-pack.md +32 -0
- package/docs-site/docs/plates/house.md +42 -39
- package/docs-site/docs/plates/index.md +13 -1
- package/docs-site/docs/plates/kits.md +28 -0
- package/docs-site/docs/plates/suit.md +40 -0
- package/package.json +1 -1
- package/scripts/foundry/assert-packed-dist-cli.mjs +5 -0
- package/scripts/node/consumer-install-smoke.mjs +5 -0
- package/src/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
- package/src/mcps/orchestrator/config/agent-capabilities.ts +8 -0
- package/src/skills/orchestrator/SKILL.md +12 -0
- package/vendor/@0xray/repertoire/dist/paths.js +4 -0
- package/xray/features.json +1 -1
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Goggles. Kind 0 name-checks the six outer names.
|
|
3
|
+
* Digest and triage return one card. Empty stays empty.
|
|
4
|
+
* A held plane stays quiet. A leave is denied.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { dirname, join, resolve } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const FIELD_ORDER = ['plate', 'entry', 'exit', 'files', 'skills', 'setup', 'teardown', 'worn'];
|
|
11
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const WORN_PLANES = ['dichotomy', 'syncopate', 'synthesis', 'digest', 'triage', 'loop'];
|
|
13
|
+
const CARD_PLANES = ['ground', 'routing', 'house', 'boot', 'governance', 'memory-recall', 'orchestration', 'processor', 'reporting'];
|
|
14
|
+
const CARD_FLAVORS = ['digest', 'triage'];
|
|
15
|
+
const SCOPE_ZOOM = ['ecosystem', 'part', 'one flow', 'one artifact'];
|
|
16
|
+
|
|
17
|
+
function drawnPlanes() {
|
|
18
|
+
try {
|
|
19
|
+
const data = JSON.parse(readFileSync(join(HERE, 'goggles-planes.json'), 'utf8'));
|
|
20
|
+
return Array.isArray(data.planes) ? data.planes.map((name) => String(name)) : [];
|
|
21
|
+
} catch {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function actualityOf(map, worn) {
|
|
27
|
+
const left = Array.isArray(map) ? map : [];
|
|
28
|
+
const right = Array.isArray(worn) ? worn : [];
|
|
29
|
+
const same = left.length === right.length && left.every((name, index) => name === right[index]);
|
|
30
|
+
return same ? '' : 'Actuality. Drift: worn is not the map.';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function actualityLine() {
|
|
34
|
+
return actualityOf(drawnPlanes(), WORN_PLANES);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function acceptedPlanes() {
|
|
38
|
+
const map = new Set(drawnPlanes());
|
|
39
|
+
return WORN_PLANES.filter((name) => map.has(name));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function readingLine(name, scope) {
|
|
43
|
+
return scope ? `The reading is ${name}. Scope is ${scope}.` : `The reading is ${name}.`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function organDeny(reason) {
|
|
47
|
+
return { gate: 'goggles', decision: 'deny', reason };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function planeWord(name, text) {
|
|
51
|
+
return new RegExp(`(?:^|[^A-Za-z0-9-])${String(name).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?:[^A-Za-z0-9-]|$)`, 'i').test(String(text || ''));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function withoutPaths(text) {
|
|
55
|
+
return String(text || '').replace(/(?:[\w.@~-]+\/)+[\w.-]+/g, ' ');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function organStop(held, action) {
|
|
59
|
+
if (!held) return null;
|
|
60
|
+
if (held.drift) return organDeny(held.drift);
|
|
61
|
+
const plane = held.plane;
|
|
62
|
+
if (!plane) return null;
|
|
63
|
+
const text = String(action?.text || '');
|
|
64
|
+
const paths = (action?.paths || []).map(String).filter(Boolean);
|
|
65
|
+
const tool = String(action?.tool || '');
|
|
66
|
+
if (/docs-site\/docs\/plates\/[a-z0-9-]+\.md/i.test([text, ...paths].join('\n'))) {
|
|
67
|
+
return organDeny(`The reading is ${plane}. That drawing is not the plane.`);
|
|
68
|
+
}
|
|
69
|
+
const stripped = withoutPaths(text);
|
|
70
|
+
const others = acceptedPlanes().filter((name) => name !== plane && planeWord(name, stripped));
|
|
71
|
+
const namesThis = planeWord(plane, stripped);
|
|
72
|
+
if (others.length > 1 || (others.length === 1 && namesThis)) {
|
|
73
|
+
return organDeny(`The reading is ${plane}. The action names two planes.`);
|
|
74
|
+
}
|
|
75
|
+
if (others.length === 1) {
|
|
76
|
+
return organDeny(`The reading is ${plane}. The action is ${others[0]}.`);
|
|
77
|
+
}
|
|
78
|
+
return scopeStop(plane, held.scope, tool, paths);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function scopeStop(plane, scope, tool, paths) {
|
|
82
|
+
if (!scope || scope === 'ecosystem') return null;
|
|
83
|
+
if (scope === 'part') {
|
|
84
|
+
const dirs = new Set(paths.map((file) => dirname(file)));
|
|
85
|
+
if (dirs.size > 1) return organDeny(`The reading is ${plane}. Scope is part. This action crosses parts.`);
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
if (scope === 'one flow') {
|
|
89
|
+
if (/grep|search|glob|read|open/i.test(tool) && paths.length !== 1) {
|
|
90
|
+
return organDeny(`The reading is ${plane}. Scope is one flow. This action is not one flow.`);
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
if (scope === 'one artifact') {
|
|
95
|
+
if (/bash|shell/i.test(tool) || paths.length !== 1) {
|
|
96
|
+
return organDeny(`The reading is ${plane}. Scope is one artifact. This action is wider.`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function readingPath(root) {
|
|
103
|
+
return join(root, '.xray', 'state', 'goggles-reading.json');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function loadReading(root) {
|
|
107
|
+
try {
|
|
108
|
+
const data = JSON.parse(readFileSync(readingPath(root), 'utf8'));
|
|
109
|
+
if (!data || typeof data !== 'object') return null;
|
|
110
|
+
if (typeof data.drift === 'string' && data.drift) return { drift: data.drift };
|
|
111
|
+
if (typeof data.plane !== 'string' || !data.plane) return null;
|
|
112
|
+
return { plane: data.plane, scope: typeof data.scope === 'string' ? data.scope : '' };
|
|
113
|
+
} catch {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function saveReading(root, rec) {
|
|
119
|
+
const file = readingPath(root);
|
|
120
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
121
|
+
writeFileSync(file, `${JSON.stringify(rec)}\n`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function clearReading(root) {
|
|
125
|
+
const file = readingPath(root);
|
|
126
|
+
if (existsSync(file)) unlinkSync(file);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function findScopes(words) {
|
|
130
|
+
let rest = ` ${words.join(' ').toLowerCase()} `;
|
|
131
|
+
const hits = [];
|
|
132
|
+
const ordered = [...SCOPE_ZOOM].sort((a, b) => b.length - a.length);
|
|
133
|
+
for (const scope of ordered) {
|
|
134
|
+
const needle = ` ${scope} `;
|
|
135
|
+
if (!rest.includes(needle)) continue;
|
|
136
|
+
hits.push(scope);
|
|
137
|
+
rest = rest.split(needle).join(' ');
|
|
138
|
+
}
|
|
139
|
+
return hits;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function kindPastOne(words) {
|
|
143
|
+
const lower = words.map((word) => word.toLowerCase());
|
|
144
|
+
if (lower.length === 1 && /^\d+$/.test(lower[0]) && Number(lower[0]) > 1) return true;
|
|
145
|
+
for (let i = 0; i < lower.length; i += 1) {
|
|
146
|
+
if (!/^(kind|pull|pull-up|level)$/.test(lower[i])) continue;
|
|
147
|
+
const next = lower[i + 1];
|
|
148
|
+
if (next && /^\d+$/.test(next) && Number(next) > 1) return true;
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function isKindZero(lower) {
|
|
154
|
+
if (lower.includes('actuality')) return true;
|
|
155
|
+
if (lower.length === 1 && lower[0] === '0') return true;
|
|
156
|
+
for (let i = 0; i < lower.length; i += 1) {
|
|
157
|
+
if ((lower[i] === 'kind' || lower[i] === 'level') && lower[i + 1] === '0') return true;
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function namesTheSet(lower) {
|
|
163
|
+
const joined = lower.join(' ');
|
|
164
|
+
if (joined === 'kind 1' || joined === 'level 1') return true;
|
|
165
|
+
const mentionsSet = lower.includes('outer') || lower.includes('outer-loop');
|
|
166
|
+
if (!mentionsSet) return false;
|
|
167
|
+
const planes = acceptedPlanes().filter((name) => lower.includes(name));
|
|
168
|
+
if (planes.length === 0) return true;
|
|
169
|
+
return planes.length === 1 && planes[0] === 'loop' && findScopes(lower).length === 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function readGoggles(argv) {
|
|
173
|
+
const words = [];
|
|
174
|
+
for (const raw of argv || []) {
|
|
175
|
+
const arg = String(raw || '').trim();
|
|
176
|
+
if (!arg || arg.toLowerCase() === 'pop') continue;
|
|
177
|
+
words.push(arg);
|
|
178
|
+
}
|
|
179
|
+
const lower = words.map((word) => word.toLowerCase());
|
|
180
|
+
if (lower.includes('calling')) return ok('');
|
|
181
|
+
if (kindPastOne(words)) return ok('');
|
|
182
|
+
if (words.length === 0) return ok('');
|
|
183
|
+
if (namesTheSet(lower)) return ok('Name one plane.');
|
|
184
|
+
if (isKindZero(lower)) {
|
|
185
|
+
if (findScopes(words).length) return ok('');
|
|
186
|
+
if (acceptedPlanes().some((name) => lower.includes(name))) return ok('');
|
|
187
|
+
return ok(actualityLine());
|
|
188
|
+
}
|
|
189
|
+
const flavors = CARD_FLAVORS.filter((name) => lower.includes(name));
|
|
190
|
+
if (flavors.length > 1) return ok('');
|
|
191
|
+
if (flavors.length === 1) {
|
|
192
|
+
const others = acceptedPlanes().filter((name) => name !== flavors[0] && lower.includes(name));
|
|
193
|
+
if (others.length) return ok('');
|
|
194
|
+
return ok(cardLook(flavors[0], lower));
|
|
195
|
+
}
|
|
196
|
+
const planes = acceptedPlanes().filter((name) => lower.includes(name));
|
|
197
|
+
if (planes.length !== 1) return ok('');
|
|
198
|
+
const scopes = findScopes(words.filter((word) => word.toLowerCase() !== planes[0]));
|
|
199
|
+
if (scopes.length > 1) return ok('');
|
|
200
|
+
return ok(readingLine(planes[0], scopes[0] || ''));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function cardPlanesNamed(lower) {
|
|
204
|
+
return CARD_PLANES.filter((name) => lower.includes(name));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function fileList(plane) {
|
|
208
|
+
const files = Array.isArray(plane.files) ? plane.files : [];
|
|
209
|
+
const unpathed = Array.isArray(plane.unpathed) ? plane.unpathed : [];
|
|
210
|
+
const parts = [...files];
|
|
211
|
+
for (const name of unpathed) {
|
|
212
|
+
parts.push(name === 'mill' ? 'mill has no path' : name);
|
|
213
|
+
}
|
|
214
|
+
return parts.join(', ');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function cardRows(plane, scope) {
|
|
218
|
+
const files = Array.isArray(plane.files) ? plane.files : [];
|
|
219
|
+
if (scope === 'one artifact' && files.length !== 1) return null;
|
|
220
|
+
const rows = [
|
|
221
|
+
['Plane', plane.id],
|
|
222
|
+
['From', plane.id === 'ground' ? '' : 'ground'],
|
|
223
|
+
['Digest', plane.digest || ''],
|
|
224
|
+
['Plate', plane.plate || ''],
|
|
225
|
+
['Entry', plane.entry || ''],
|
|
226
|
+
['Exit', plane.exit || ''],
|
|
227
|
+
['Files', scope === 'one artifact' ? files[0] : fileList(plane)],
|
|
228
|
+
['Skills', plane.skills || ''],
|
|
229
|
+
['Setup', plane.setup || ''],
|
|
230
|
+
['Teardown', plane.teardown || ''],
|
|
231
|
+
['Worn', plane.worn || ''],
|
|
232
|
+
];
|
|
233
|
+
if (scope === 'one flow' || scope === 'one artifact') {
|
|
234
|
+
return rows.filter(([key]) => key === 'Plane' || key === 'Digest' || key === 'Files');
|
|
235
|
+
}
|
|
236
|
+
return rows;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function triageNote(plane, root) {
|
|
240
|
+
const filled = new Set(filledOf(plane));
|
|
241
|
+
const empty = FIELD_ORDER.filter((name) => !filled.has(name));
|
|
242
|
+
const exam = examinePlane(plane, root);
|
|
243
|
+
const lines = [];
|
|
244
|
+
if (empty.length) lines.push(`Empty: ${empty.join(', ')}`);
|
|
245
|
+
lines.push(exam.text);
|
|
246
|
+
return lines.join('\n');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function formatPlaneCard(plane, scope, flavor, root) {
|
|
250
|
+
const rows = cardRows(plane, scope);
|
|
251
|
+
if (!rows) return null;
|
|
252
|
+
let text = rows.map(([key, value]) => `${key}: ${value}`.trimEnd()).join('\n');
|
|
253
|
+
if (flavor === 'triage') text = `${text}\n${triageNote(plane, root)}`;
|
|
254
|
+
return text;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function cardLook(flavor, lower) {
|
|
258
|
+
const named = cardPlanesNamed(lower);
|
|
259
|
+
const scopes = findScopes(lower.filter((word) => word !== flavor && !named.includes(word)));
|
|
260
|
+
if (named.length > 1 || scopes.length > 1) return '';
|
|
261
|
+
const scope = scopes[0] || '';
|
|
262
|
+
if (!named.length && (scope === 'part' || scope === 'one flow' || scope === 'one artifact')) return '';
|
|
263
|
+
const platesDir = findPlatesDir(HERE);
|
|
264
|
+
if (!platesDir) return '';
|
|
265
|
+
const ids = named.length ? named : CARD_PLANES;
|
|
266
|
+
const root = repoRootFrom(platesDir);
|
|
267
|
+
const blocks = [];
|
|
268
|
+
for (const id of ids) {
|
|
269
|
+
const plane = assemblePlane(id, platesDir);
|
|
270
|
+
if (!plane) continue;
|
|
271
|
+
const text = formatPlaneCard(plane, scope, flavor, root);
|
|
272
|
+
if (text === null) return '';
|
|
273
|
+
blocks.push(text);
|
|
274
|
+
}
|
|
275
|
+
return blocks.join('\n\n');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export function findPlatesDir(start) {
|
|
279
|
+
let dir = start;
|
|
280
|
+
for (let depth = 0; depth < 8; depth += 1) {
|
|
281
|
+
const candidate = join(dir, 'docs-site', 'docs', 'plates');
|
|
282
|
+
if (existsSync(join(candidate, 'index.md'))) return candidate;
|
|
283
|
+
const parent = dirname(dir);
|
|
284
|
+
if (parent === dir) break;
|
|
285
|
+
dir = parent;
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
function stripFrontmatter(raw) {
|
|
292
|
+
return String(raw).replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '').trim();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
function boxTitles(line) {
|
|
297
|
+
const titles = [];
|
|
298
|
+
for (const part of String(line).split('│')) {
|
|
299
|
+
const title = part.replace(/\s+/g, ' ').trim();
|
|
300
|
+
if (!/[A-Za-z]/.test(title)) continue;
|
|
301
|
+
if (title.startsWith('·') || title.includes('LAYER')) continue;
|
|
302
|
+
titles.push(title);
|
|
303
|
+
}
|
|
304
|
+
return titles;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function doorsOf(body) {
|
|
308
|
+
let layer = '';
|
|
309
|
+
let want = false;
|
|
310
|
+
const found = { input: [], output: [] };
|
|
311
|
+
for (const line of String(body).split(/\r?\n/)) {
|
|
312
|
+
if (line.includes('INPUT LAYER')) { layer = 'input'; want = false; continue; }
|
|
313
|
+
if (line.includes('OUTPUT LAYER')) { layer = 'output'; want = false; continue; }
|
|
314
|
+
if (line.includes('PROCESSING LAYER')) { layer = ''; want = false; continue; }
|
|
315
|
+
if (layer !== 'input' && layer !== 'output') continue;
|
|
316
|
+
if (line.includes('┌')) { want = true; continue; }
|
|
317
|
+
if (!want) continue;
|
|
318
|
+
const titles = boxTitles(line);
|
|
319
|
+
if (!titles.length) continue;
|
|
320
|
+
found[layer].push(...titles);
|
|
321
|
+
want = false;
|
|
322
|
+
}
|
|
323
|
+
const join = (list) => (list.length ? list.join(' · ') : null);
|
|
324
|
+
return { entry: join(found.input), exit: join(found.output) };
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function takeOf(body) {
|
|
328
|
+
const lines = String(body).split(/\r?\n/);
|
|
329
|
+
const prose = [];
|
|
330
|
+
let pastHeading = false;
|
|
331
|
+
for (const line of lines) {
|
|
332
|
+
if (!pastHeading) {
|
|
333
|
+
if (/^#\s+/.test(line)) pastHeading = true;
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (line.startsWith('```')) break;
|
|
337
|
+
if (!line.trim()) {
|
|
338
|
+
if (prose.length) break;
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
prose.push(line.trim());
|
|
342
|
+
}
|
|
343
|
+
const paragraph = prose.join(' ');
|
|
344
|
+
const sentence = paragraph.match(/^.*?[.!?](?:\s|$)/);
|
|
345
|
+
return (sentence ? sentence[0] : paragraph).trim();
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
function overlayTable() {
|
|
350
|
+
const file = join(HERE, 'goggles-planes.json');
|
|
351
|
+
if (!existsSync(file)) return {};
|
|
352
|
+
return JSON.parse(readFileSync(file, 'utf8'));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function present(value) {
|
|
356
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
357
|
+
return Boolean(value);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export function filledOf(plane) {
|
|
361
|
+
const flags = {
|
|
362
|
+
plate: present(plane.plate),
|
|
363
|
+
entry: present(plane.entry),
|
|
364
|
+
exit: present(plane.exit),
|
|
365
|
+
files: present(plane.files) || present(plane.unpathed),
|
|
366
|
+
skills: present(plane.skills),
|
|
367
|
+
setup: present(plane.setup),
|
|
368
|
+
teardown: present(plane.teardown),
|
|
369
|
+
worn: present(plane.worn),
|
|
370
|
+
};
|
|
371
|
+
return FIELD_ORDER.filter((name) => flags[name]);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export function assemblePlane(id, platesDir) {
|
|
375
|
+
const extra = overlayTable()[id] || {};
|
|
376
|
+
let plate = null;
|
|
377
|
+
let digest = extra.digest || '';
|
|
378
|
+
let doors = { entry: null, exit: null };
|
|
379
|
+
if (id !== 'ground') {
|
|
380
|
+
const abs = join(platesDir, `${id}.md`);
|
|
381
|
+
if (!existsSync(abs)) return null;
|
|
382
|
+
const raw = readFileSync(abs, 'utf8');
|
|
383
|
+
plate = join('docs-site', 'docs', 'plates', `${id}.md`);
|
|
384
|
+
if (!digest) digest = takeOf(stripFrontmatter(raw));
|
|
385
|
+
doors = doorsOf(raw);
|
|
386
|
+
}
|
|
387
|
+
if (!digest) return null;
|
|
388
|
+
return {
|
|
389
|
+
id,
|
|
390
|
+
digest,
|
|
391
|
+
plate,
|
|
392
|
+
entry: extra.entry || doors.entry || null,
|
|
393
|
+
exit: extra.exit || doors.exit || null,
|
|
394
|
+
entryIsMark: Boolean(extra.entry),
|
|
395
|
+
exitIsMark: Boolean(extra.exit),
|
|
396
|
+
files: extra.files || null,
|
|
397
|
+
unpathed: extra.unpathed || null,
|
|
398
|
+
skills: extra.skills || null,
|
|
399
|
+
setup: extra.setup || null,
|
|
400
|
+
teardown: extra.teardown || null,
|
|
401
|
+
worn: extra.worn || null,
|
|
402
|
+
mark: extra.mark || null,
|
|
403
|
+
wornMark: extra.wornMark || null,
|
|
404
|
+
pick: extra.pick || null,
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function repoRootFrom(platesDir) {
|
|
409
|
+
return dirname(dirname(dirname(platesDir)));
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function miss(text) {
|
|
413
|
+
return { ok: false, text };
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function ok(text) {
|
|
417
|
+
return { ok: true, text };
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function holds() {
|
|
421
|
+
return { kind: 'holds', text: 'Holds.' };
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function drift(text) {
|
|
425
|
+
return { kind: 'drift', text: `Drift: ${text}` };
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function drawing() {
|
|
429
|
+
return { kind: 'drawing', text: 'Drawing only.' };
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function fileHas(root, rel, mark) {
|
|
433
|
+
if (!rel || !mark) return false;
|
|
434
|
+
const full = join(root, rel);
|
|
435
|
+
return existsSync(full) && readFileSync(full, 'utf8').includes(mark);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
function examinePlane(plane, root) {
|
|
440
|
+
const files = Array.isArray(plane.files) ? plane.files : [];
|
|
441
|
+
const checkable = files.length > 0 || plane.skills || plane.worn;
|
|
442
|
+
if (!checkable) return drawing();
|
|
443
|
+
for (const rel of files) {
|
|
444
|
+
if (!existsSync(join(root, rel))) return drift(`${rel} is not there`);
|
|
445
|
+
}
|
|
446
|
+
if (plane.mark && !fileHas(root, files[0], plane.mark)) {
|
|
447
|
+
return drift(`${plane.mark} is not in ${files[0]}`);
|
|
448
|
+
}
|
|
449
|
+
if (plane.worn && !fileHas(root, plane.worn, plane.wornMark || plane.mark)) {
|
|
450
|
+
return drift(`the worn build is not ${files[0] || plane.worn}`);
|
|
451
|
+
}
|
|
452
|
+
if (plane.skills && !existsSync(join(root, plane.skills))) {
|
|
453
|
+
return drift(`${plane.skills} is not there`);
|
|
454
|
+
}
|
|
455
|
+
if (plane.entryIsMark && plane.entry && files[0] && !fileHas(root, files[0], plane.entry)) {
|
|
456
|
+
return drift(`${plane.entry} is not in ${files[0]}`);
|
|
457
|
+
}
|
|
458
|
+
if (plane.exitIsMark && plane.exit && files[0] && !fileHas(root, files[0], plane.exit)) {
|
|
459
|
+
return drift(`${plane.exit} is not in ${files[0]}`);
|
|
460
|
+
}
|
|
461
|
+
return holds();
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
export function look(argv) {
|
|
466
|
+
return readGoggles(argv);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
function isGogglesWork(text) {
|
|
471
|
+
return /(?<![A-Za-z0-9-])goggles(?![A-Za-z0-9-])/i.test(String(text || ''));
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
export function cardStop(root, toolName, text, paths = []) {
|
|
476
|
+
const raw = [String(text || ''), ...(paths || [])].join('\n');
|
|
477
|
+
if (isGogglesWork(raw)) {
|
|
478
|
+
clearReading(root);
|
|
479
|
+
clearCardLine(root);
|
|
480
|
+
return null;
|
|
481
|
+
}
|
|
482
|
+
const held = loadReading(root);
|
|
483
|
+
if (!held) return null;
|
|
484
|
+
const drift = actualityLine();
|
|
485
|
+
if (drift) return organDeny(drift);
|
|
486
|
+
return organStop(held, { tool: toolName, text, paths });
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function stationFile(root) {
|
|
490
|
+
return join(root, '.xray', 'state', 'STATION.md');
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function withoutCardLines(text) {
|
|
494
|
+
return String(text || '')
|
|
495
|
+
.split(/\r?\n/)
|
|
496
|
+
.filter((row) => !/^Card:\s/.test(row.trim()))
|
|
497
|
+
.join('\n')
|
|
498
|
+
.replace(/\n{3,}/g, '\n\n');
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function clearCardLine(root) {
|
|
502
|
+
const dest = stationFile(root);
|
|
503
|
+
if (!existsSync(dest)) return;
|
|
504
|
+
const prev = readFileSync(dest, 'utf8');
|
|
505
|
+
const next = withoutCardLines(prev).replace(/\s*$/, '');
|
|
506
|
+
const body = next ? `${next}\n` : '';
|
|
507
|
+
if (body !== prev) writeFileSync(dest, body);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
function intentWords(text) {
|
|
512
|
+
return String(text || '').toLowerCase().split(/[^a-z0-9-]+/).filter(Boolean);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
export function handCard(root, intent) {
|
|
516
|
+
try {
|
|
517
|
+
clearCardLine(root);
|
|
518
|
+
const text = String(intent || '');
|
|
519
|
+
if (isGogglesWork(text)) {
|
|
520
|
+
clearReading(root);
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
const words = intentWords(text);
|
|
524
|
+
const looked = readGoggles(words);
|
|
525
|
+
if (looked.text.startsWith('Actuality. Drift')) {
|
|
526
|
+
saveReading(root, { drift: looked.text });
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
const planes = acceptedPlanes().filter((name) => words.includes(name));
|
|
530
|
+
if (planes.length !== 1) {
|
|
531
|
+
clearReading(root);
|
|
532
|
+
return null;
|
|
533
|
+
}
|
|
534
|
+
const scopes = findScopes(words.filter((word) => word !== planes[0]));
|
|
535
|
+
if (scopes.length > 1) {
|
|
536
|
+
clearReading(root);
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
const next = { plane: planes[0], scope: scopes[0] || '' };
|
|
540
|
+
const prev = loadReading(root);
|
|
541
|
+
if (prev && prev.plane === next.plane && (prev.scope || '') === next.scope && !prev.drift) return null;
|
|
542
|
+
saveReading(root, next);
|
|
543
|
+
return null;
|
|
544
|
+
} catch {
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
export function lensPath(root) {
|
|
551
|
+
return join(root, '.xray', 'state', 'LENS.md');
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
export function maintainLens(root) {
|
|
556
|
+
const text = actualityLine();
|
|
557
|
+
mkdirSync(dirname(lensPath(root)), { recursive: true });
|
|
558
|
+
writeFileSync(lensPath(root), `${text}\n`);
|
|
559
|
+
return ok(text);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
const isMain = Boolean(process.argv[1]) && resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
564
|
+
if (isMain) {
|
|
565
|
+
const result = readGoggles(process.argv.slice(2));
|
|
566
|
+
process.stdout.write(`${result.text}\n`);
|
|
567
|
+
process.exit(result.ok ? 0 : 1);
|
|
568
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"actuality": "map vs worn",
|
|
3
|
+
"planes": ["dichotomy", "syncopate", "synthesis", "digest", "triage", "loop"],
|
|
4
|
+
"scope": ["ecosystem", "part", "one flow", "one artifact"],
|
|
5
|
+
"ground": {
|
|
6
|
+
"digest": "Home. The dev plane.",
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"grok-bot/OP-PROC.md",
|
|
10
|
+
"src/opencode/agents",
|
|
11
|
+
"Agents.md",
|
|
12
|
+
"src/integrations",
|
|
13
|
+
"package.json",
|
|
14
|
+
"scripts/foundry"
|
|
15
|
+
],
|
|
16
|
+
"skills": "SKILLS.md"
|
|
17
|
+
},
|
|
18
|
+
"routing": {
|
|
19
|
+
"files": ["src/nucleus/thin-dispatch.ts"],
|
|
20
|
+
"worn": "dist/nucleus/thin-dispatch.js",
|
|
21
|
+
"mark": "export function scoreAndRoute",
|
|
22
|
+
"wornMark": "function scoreAndRoute",
|
|
23
|
+
"pick": "resolveThinDispatch"
|
|
24
|
+
},
|
|
25
|
+
"house": {
|
|
26
|
+
"files": ["grok-bot/lib/seat-doctor.cjs"]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -15,6 +15,11 @@ const PLATE_IDS = Object.freeze([
|
|
|
15
15
|
"reporting",
|
|
16
16
|
"memory-recall",
|
|
17
17
|
"house",
|
|
18
|
+
"goggles",
|
|
19
|
+
"suit",
|
|
20
|
+
"kits",
|
|
21
|
+
"host-pack",
|
|
22
|
+
"glossary",
|
|
18
23
|
]);
|
|
19
24
|
|
|
20
25
|
/** Id token, then extra phrases. Equal top scores recall nothing. */
|
|
@@ -68,6 +73,24 @@ const CUES = {
|
|
|
68
73
|
[/GROK_BOT_HOUSE/i, 4],
|
|
69
74
|
[/setup-house/i, 4],
|
|
70
75
|
],
|
|
76
|
+
goggles: [
|
|
77
|
+
[/\bgoggles\b/i, 6],
|
|
78
|
+
],
|
|
79
|
+
suit: [
|
|
80
|
+
[/suit plate/i, 6],
|
|
81
|
+
[/plates\/suit\b/i, 6],
|
|
82
|
+
],
|
|
83
|
+
kits: [
|
|
84
|
+
[/\bkits plate\b/i, 6],
|
|
85
|
+
[/\bkits\b/i, 5],
|
|
86
|
+
],
|
|
87
|
+
"host-pack": [
|
|
88
|
+
[/host\s*pack/i, 6],
|
|
89
|
+
[/host-pack/i, 6],
|
|
90
|
+
],
|
|
91
|
+
glossary: [
|
|
92
|
+
[/\bglossary\b/i, 6],
|
|
93
|
+
],
|
|
71
94
|
};
|
|
72
95
|
|
|
73
96
|
function platesDir() {
|