glimmervoid 0.46.2-next.167 → 0.46.2-next.169
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/dist/bin/glimmervoid.js +7 -7
- package/dist/chunks/{adapters-Br_PA1X_.js → adapters-3RuVH2qm.js} +3 -1
- package/dist/chunks/{adapters-CKy7FjTT.js → adapters-yHbHeeiD.js} +1 -1
- package/dist/chunks/{agent-setup-cli-C8PNC8YA.js → agent-setup-cli-DHqTFNcZ.js} +3 -68
- package/dist/chunks/grok-DnkhGGf5.js +369 -0
- package/dist/chunks/kimi-BiLAVDKd.js +232 -0
- package/dist/chunks/kimi-CjswbYS5.js +1 -0
- package/dist/chunks/{kimi-BGYddMlv.js → kimi-home-CYJpt82i.js} +19 -667
- package/dist/chunks/kimi-home-DyWG81oB.js +1 -0
- package/dist/chunks/{main-DMmxYBnP.js → main-DlFaQ_Hm.js} +38 -11
- package/dist/chunks/spawn-env-BFfAkGlR.js +82 -0
- package/dist/client/assets/{alert-sound-CSvkaH2H.js → alert-sound-BYNZpXPr.js} +1 -1
- package/dist/client/assets/alert-sound-BYNZpXPr.js.br +0 -0
- package/dist/client/assets/{benchmark-panel-mns1UqN5.js → benchmark-panel-B9judchZ.js} +1 -1
- package/dist/client/assets/benchmark-panel-B9judchZ.js.br +0 -0
- package/dist/client/assets/{celebration-player-CFSer-rB.js → celebration-player-DM6WUypY.js} +1 -1
- package/dist/client/assets/celebration-player-DM6WUypY.js.br +0 -0
- package/dist/client/assets/{dialogs-sZ-eTR1o.js → dialogs-D9feZqzN.js} +1 -1
- package/dist/client/assets/dialogs-D9feZqzN.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-gUZSzoaA.js → doc-editor-ui-pekEW6BL.js} +1 -1
- package/dist/client/assets/doc-editor-ui-pekEW6BL.js.br +0 -0
- package/dist/client/assets/{feature-hint-BwFF1r0i.js → feature-hint-C9bbGqHr.js} +1 -1
- package/dist/client/assets/feature-hint-C9bbGqHr.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-Cdpb_P4N.js → first-run-checklist-BJc15-du.js} +1 -1
- package/dist/client/assets/first-run-checklist-BJc15-du.js.br +0 -0
- package/dist/client/assets/{hooks-panel-D9BcT9I0.js → hooks-panel-DPtcrTiT.js} +1 -1
- package/dist/client/assets/hooks-panel-DPtcrTiT.js.br +0 -0
- package/dist/client/assets/{index-tjVjVTuz.js → index-CdlMzKpC.js} +5 -5
- package/dist/client/assets/index-CdlMzKpC.js.br +0 -0
- package/dist/client/assets/{issues-panel-C-9kUGqO.js → issues-panel-MDtaRGw_.js} +1 -1
- package/dist/client/assets/issues-panel-MDtaRGw_.js.br +0 -0
- package/dist/client/assets/{nyan-cat-DLU7L0F2.js → nyan-cat-BpxWambO.js} +1 -1
- package/dist/client/assets/nyan-cat-BpxWambO.js.br +0 -0
- package/dist/client/assets/{phone-shell-CAlVRH-A.js → phone-shell-ChuNZ6VV.js} +1 -1
- package/dist/client/assets/phone-shell-ChuNZ6VV.js.br +0 -0
- package/dist/client/assets/{plan-face-WpVYeXGh.js → plan-face-CB9ujzAf.js} +1 -1
- package/dist/client/assets/plan-face-CB9ujzAf.js.br +0 -0
- package/dist/client/assets/{plan-render-D7--c3qq.js → plan-render-C9e3Uepn.js} +1 -1
- package/dist/client/assets/plan-render-C9e3Uepn.js.br +0 -0
- package/dist/client/assets/{pr-scope-tabs-SPjQar96.js → pr-scope-tabs-DUZ9yJK2.js} +1 -1
- package/dist/client/assets/pr-scope-tabs-DUZ9yJK2.js.br +0 -0
- package/dist/client/assets/{radar-panel-BhU8Tox1.js → radar-panel-CvDlwkHz.js} +1 -1
- package/dist/client/assets/radar-panel-CvDlwkHz.js.br +0 -0
- package/dist/client/assets/{resume-dialog-DvcFxs0T.js → resume-dialog-Cqe8jFmB.js} +1 -1
- package/dist/client/assets/resume-dialog-Cqe8jFmB.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-CXxo72KX.js → review-queue-panel-Cxqaoi8C.js} +1 -1
- package/dist/client/assets/review-queue-panel-Cxqaoi8C.js.br +0 -0
- package/dist/client/assets/{settings-panel-eElgQ9sl.js → settings-panel-BKNXBw7e.js} +2 -2
- package/dist/client/assets/settings-panel-BKNXBw7e.js.br +0 -0
- package/dist/client/assets/{shown-lightbox-DLBCDlmL.js → shown-lightbox-BtWekWFk.js} +1 -1
- package/dist/client/assets/shown-lightbox-BtWekWFk.js.br +0 -0
- package/dist/client/assets/{trace-panel-B1eQQqmW.js → trace-panel-D7HDzB5R.js} +1 -1
- package/dist/client/assets/trace-panel-D7HDzB5R.js.br +0 -0
- package/dist/client/assets/{usage-panel-BK3HGdI3.js → usage-panel-DZaKCQR1.js} +1 -1
- package/dist/client/assets/usage-panel-DZaKCQR1.js.br +0 -0
- package/dist/client/assets/{visions-panel-BXARteeE.js → visions-panel-CSxO54ew.js} +1 -1
- package/dist/client/assets/visions-panel-CSxO54ew.js.br +0 -0
- package/dist/client/index.html +1 -1
- package/dist/client/index.html.br +0 -0
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/alert-sound-CSvkaH2H.js.br +0 -0
- package/dist/client/assets/benchmark-panel-mns1UqN5.js.br +0 -0
- package/dist/client/assets/celebration-player-CFSer-rB.js.br +0 -0
- package/dist/client/assets/dialogs-sZ-eTR1o.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-gUZSzoaA.js.br +0 -0
- package/dist/client/assets/feature-hint-BwFF1r0i.js.br +0 -0
- package/dist/client/assets/first-run-checklist-Cdpb_P4N.js.br +0 -0
- package/dist/client/assets/hooks-panel-D9BcT9I0.js.br +0 -0
- package/dist/client/assets/index-tjVjVTuz.js.br +0 -0
- package/dist/client/assets/issues-panel-C-9kUGqO.js.br +0 -0
- package/dist/client/assets/nyan-cat-DLU7L0F2.js.br +0 -0
- package/dist/client/assets/phone-shell-CAlVRH-A.js.br +0 -0
- package/dist/client/assets/plan-face-WpVYeXGh.js.br +0 -0
- package/dist/client/assets/plan-render-D7--c3qq.js.br +0 -0
- package/dist/client/assets/pr-scope-tabs-SPjQar96.js.br +0 -0
- package/dist/client/assets/radar-panel-BhU8Tox1.js.br +0 -0
- package/dist/client/assets/resume-dialog-DvcFxs0T.js.br +0 -0
- package/dist/client/assets/review-queue-panel-CXxo72KX.js.br +0 -0
- package/dist/client/assets/settings-panel-eElgQ9sl.js.br +0 -0
- package/dist/client/assets/shown-lightbox-DLBCDlmL.js.br +0 -0
- package/dist/client/assets/trace-panel-B1eQQqmW.js.br +0 -0
- package/dist/client/assets/usage-panel-BK3HGdI3.js.br +0 -0
- package/dist/client/assets/visions-panel-BXARteeE.js.br +0 -0
package/dist/bin/glimmervoid.js
CHANGED
|
@@ -27,7 +27,6 @@ Commands:
|
|
|
27
27
|
pair --list List paired devices
|
|
28
28
|
pair --revoke <id> Revoke a paired device
|
|
29
29
|
agent setup grok Install the Grok hook relay, which does nothing outside Glimmervoid
|
|
30
|
-
agent setup kimi Add the Kimi Code hook relay block to its config.toml, inert outside Glimmervoid
|
|
31
30
|
|
|
32
31
|
Editor integration (Visions):
|
|
33
32
|
visions install Install the Visions extension into every VS Code family editor on PATH
|
|
@@ -70,7 +69,7 @@ var OWN_SUBCOMMAND_RUNNERS = [
|
|
|
70
69
|
return runPairCli(subcommandArgs);
|
|
71
70
|
}],
|
|
72
71
|
["agent", async (subcommandArgs) => {
|
|
73
|
-
const { runAgentSetupCli } = await import("../chunks/agent-setup-cli-
|
|
72
|
+
const { runAgentSetupCli } = await import("../chunks/agent-setup-cli-DHqTFNcZ.js");
|
|
74
73
|
return runAgentSetupCli(subcommandArgs);
|
|
75
74
|
}],
|
|
76
75
|
["settings", async (subcommandArgs) => {
|
|
@@ -235,7 +234,7 @@ async function runDoctor() {
|
|
|
235
234
|
}
|
|
236
235
|
switchSection("Agents");
|
|
237
236
|
try {
|
|
238
|
-
const { listAgentIds, describeAgentResolvability, setCustomAgents } = await import("../chunks/adapters-
|
|
237
|
+
const { listAgentIds, describeAgentResolvability, setCustomAgents } = await import("../chunks/adapters-yHbHeeiD.js");
|
|
239
238
|
const declaredCustomAgents = await readDeclaredCustomAgents();
|
|
240
239
|
if (declaredCustomAgents.error) line("config", declaredCustomAgents.error);
|
|
241
240
|
setCustomAgents(declaredCustomAgents.declared);
|
|
@@ -243,11 +242,12 @@ async function runDoctor() {
|
|
|
243
242
|
const { label, path: resolvedPath } = describeAgentResolvability(id);
|
|
244
243
|
line(`${id} (${label})`, resolvedPath ?? missingAgentText(id));
|
|
245
244
|
}
|
|
246
|
-
const { inspectGrokAgentSetup
|
|
245
|
+
const { inspectGrokAgentSetup } = await import("../chunks/agent-setup-cli-DHqTFNcZ.js");
|
|
247
246
|
const grokSetup = inspectGrokAgentSetup();
|
|
248
247
|
line("grok hook setup", `${grokSetup.classification}: ${grokSetup.filePath}`);
|
|
249
|
-
const
|
|
250
|
-
|
|
248
|
+
const { default: kimi } = await import("../chunks/kimi-CjswbYS5.js");
|
|
249
|
+
const { describeKimiHome } = await import("../chunks/kimi-home-DyWG81oB.js");
|
|
250
|
+
line("kimi home", describeKimiHome(kimi.expectedHooksBlock()));
|
|
251
251
|
} catch (err) {
|
|
252
252
|
line("agents", `probe failed: ${firstLine(errorText(err))}`);
|
|
253
253
|
}
|
|
@@ -262,7 +262,7 @@ async function runDoctor() {
|
|
|
262
262
|
try {
|
|
263
263
|
const { resolvePackageBin } = await import("../chunks/runtime-paths-Cc0_ZR6V.js");
|
|
264
264
|
const { execFileSync } = await import("../chunks/child-process-safe-CjVtRjDD.js");
|
|
265
|
-
const { inspectGrokAgentSetup } = await import("../chunks/agent-setup-cli-
|
|
265
|
+
const { inspectGrokAgentSetup } = await import("../chunks/agent-setup-cli-DHqTFNcZ.js");
|
|
266
266
|
const binPath = resolvePackageBin("cc-safety-net", "cc-safety-net");
|
|
267
267
|
line("Sane YOLO", binPath || "not installed");
|
|
268
268
|
if (binPath) line("cc-safety-net version", execFileSync(process.execPath, [binPath, "--version"], {
|
|
@@ -7,10 +7,12 @@ import { c as textOr, i as numberOr, s as rawTextOr } from "./coerce-NSst8oRP.js
|
|
|
7
7
|
import { n as resolveAgentCommand, t as buildAgentSpawnCommand } from "./spawn-command-Cc40FiZI.js";
|
|
8
8
|
import { n as parseJsonRecord } from "./json-core-dfa_7Fak.js";
|
|
9
9
|
import { r as nextBackoffMs } from "./backoff-DjVpfHk7.js";
|
|
10
|
-
import {
|
|
10
|
+
import { t as buildAgentEnv } from "./spawn-env-BFfAkGlR.js";
|
|
11
11
|
import { t as buildHookCommand } from "./hook-command-core-qTNK-xMF.js";
|
|
12
|
+
import { i as isSpinnerChar, n as classifyAgentTitle, r as isBrailleChar, t as grok } from "./grok-DnkhGGf5.js";
|
|
12
13
|
import { n as isExperimentalBuild, t as compareReleaseVersions } from "./build-channel-DqsP-nkH.js";
|
|
13
14
|
import { n as mergeCodexPreToolUse, t as HOOK_TOOLS } from "./hook-tools-Cr97Vdap.js";
|
|
15
|
+
import { t as kimi } from "./kimi-BiLAVDKd.js";
|
|
14
16
|
import fs from "node:fs";
|
|
15
17
|
import path from "node:path";
|
|
16
18
|
//#region session/adapters/claude-code.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as describeAgentResolvability, l as listAgentIds, f as setCustomAgents } from "./adapters-
|
|
1
|
+
export { a as describeAgentResolvability, l as listAgentIds, f as setCustomAgents } from "./adapters-3RuVH2qm.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as isMissingFileError, r as errorMessage } from "./text-DoirglWV.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as classifyGrokHooksFile, o as renderGrokHooksFile, t as grok } from "./grok-DnkhGGf5.js";
|
|
3
3
|
import { p as writeTextAtomicSync } from "./json-file-BjFK_eSH.js";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
//#region server/agent-setup-cli.ts
|
|
7
|
-
var USAGE = "Usage: glimmervoid agent setup
|
|
7
|
+
var USAGE = "Usage: glimmervoid agent setup grok";
|
|
8
8
|
function setupInputs(env = process.env) {
|
|
9
9
|
return {
|
|
10
10
|
filePath: grok.hooksFilePath(env),
|
|
@@ -110,65 +110,6 @@ function runGrokSetup({ env, fileSystem, log, error }) {
|
|
|
110
110
|
log(`Installed Grok hooks at ${inputs.filePath}`);
|
|
111
111
|
return 0;
|
|
112
112
|
}
|
|
113
|
-
var KIMI_REFUSAL_MESSAGES = {
|
|
114
|
-
foreign: (filePath) => `Refusing to edit ${filePath}: its glimmervoid hooks block was edited by hand. Delete the block between the glimmervoid markers and run setup again.`,
|
|
115
|
-
conflicting: (filePath) => `Refusing to edit ${filePath}: it defines hooks as a key or [hooks] table, which a [[hooks]] block would break. Rewrite those hooks as [[hooks]] tables and run setup again.`
|
|
116
|
-
};
|
|
117
|
-
function readKimiConfig(filePath, readFileSync) {
|
|
118
|
-
try {
|
|
119
|
-
return { contents: readFileSync(filePath, "utf8") };
|
|
120
|
-
} catch (error) {
|
|
121
|
-
if (isMissingFileError(error, { includeNotDir: false })) return { contents: null };
|
|
122
|
-
return { reason: errorMessage(error) };
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function inspectKimiAgentSetup({ env = process.env, readFileSync = fs.readFileSync } = {}) {
|
|
126
|
-
const filePath = kimi.configFilePath(env);
|
|
127
|
-
const expectedBlock = kimi.expectedHooksBlock();
|
|
128
|
-
if (expectedBlock === null) return {
|
|
129
|
-
filePath,
|
|
130
|
-
classification: "unrenderable"
|
|
131
|
-
};
|
|
132
|
-
const config = readKimiConfig(filePath, readFileSync);
|
|
133
|
-
if ("reason" in config) return {
|
|
134
|
-
filePath,
|
|
135
|
-
classification: "unreadable",
|
|
136
|
-
reason: config.reason
|
|
137
|
-
};
|
|
138
|
-
return {
|
|
139
|
-
filePath,
|
|
140
|
-
classification: classifyKimiConfig(config.contents, expectedBlock)
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function runKimiSetup({ env, fileSystem, log, error }) {
|
|
144
|
-
const filePath = kimi.configFilePath(env);
|
|
145
|
-
const expectedBlock = kimi.expectedHooksBlock();
|
|
146
|
-
if (expectedBlock === null) {
|
|
147
|
-
error("Could not render the Kimi Code hooks block. Nothing was written.");
|
|
148
|
-
return 1;
|
|
149
|
-
}
|
|
150
|
-
const config = readKimiConfig(filePath, fileSystem.readFileSync);
|
|
151
|
-
if ("reason" in config) {
|
|
152
|
-
error(`Refusing to edit ${filePath}: the existing file is unreadable (${config.reason}).`);
|
|
153
|
-
return 1;
|
|
154
|
-
}
|
|
155
|
-
const splice = spliceKimiHooksBlock(config.contents, expectedBlock);
|
|
156
|
-
if ("refused" in splice) {
|
|
157
|
-
error(KIMI_REFUSAL_MESSAGES[splice.refused](filePath));
|
|
158
|
-
return 1;
|
|
159
|
-
}
|
|
160
|
-
if (!splice.changed) {
|
|
161
|
-
log(`Kimi Code hooks are already current in ${filePath}`);
|
|
162
|
-
return 0;
|
|
163
|
-
}
|
|
164
|
-
const writeFailure = writeAgentHooksFile(filePath, splice.contents, fileSystem);
|
|
165
|
-
if (writeFailure) {
|
|
166
|
-
error(writeFailure);
|
|
167
|
-
return 1;
|
|
168
|
-
}
|
|
169
|
-
log(`Installed Kimi Code hooks in ${filePath}`);
|
|
170
|
-
return 0;
|
|
171
|
-
}
|
|
172
113
|
function runAgentSetupCli(args, deps = {}) {
|
|
173
114
|
const { env = process.env, fileSystem = fs, log = console.log, error = console.error } = deps;
|
|
174
115
|
if (args[0] === "setup" && args[1] === "grok" && args.length === 2) return runGrokSetup({
|
|
@@ -177,14 +118,8 @@ function runAgentSetupCli(args, deps = {}) {
|
|
|
177
118
|
log,
|
|
178
119
|
error
|
|
179
120
|
});
|
|
180
|
-
if (args[0] === "setup" && args[1] === "kimi" && args.length === 2) return runKimiSetup({
|
|
181
|
-
env,
|
|
182
|
-
fileSystem,
|
|
183
|
-
log,
|
|
184
|
-
error
|
|
185
|
-
});
|
|
186
121
|
error(USAGE);
|
|
187
122
|
return 1;
|
|
188
123
|
}
|
|
189
124
|
//#endregion
|
|
190
|
-
export { inspectGrokAgentSetup,
|
|
125
|
+
export { inspectGrokAgentSetup, runAgentSetupCli };
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { r as errorMessage } from "./text-DoirglWV.js";
|
|
2
|
+
import { s as relayPath } from "./runtime-paths-ghcH9CeW.js";
|
|
3
|
+
import { n as isRecord } from "./coerce-NSst8oRP.js";
|
|
4
|
+
import { t as buildAgentEnv } from "./spawn-env-BFfAkGlR.js";
|
|
5
|
+
import { t as buildHookCommand } from "./hook-command-core-qTNK-xMF.js";
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
//#region session/core/grok-hooks-file-core.ts
|
|
10
|
+
function hookGroup(command) {
|
|
11
|
+
return [{ hooks: [{
|
|
12
|
+
type: "command",
|
|
13
|
+
command
|
|
14
|
+
}] }];
|
|
15
|
+
}
|
|
16
|
+
function renderGrokHooksFile({ relayPath, events, hookToolRelayPath }) {
|
|
17
|
+
const hooks = {};
|
|
18
|
+
for (const event of events) {
|
|
19
|
+
const command = buildHookCommand(relayPath, event);
|
|
20
|
+
if (!command) return null;
|
|
21
|
+
hooks[event] = hookGroup(command);
|
|
22
|
+
}
|
|
23
|
+
if (hookToolRelayPath) {
|
|
24
|
+
const command = buildHookCommand(hookToolRelayPath, "saneYolo");
|
|
25
|
+
if (!command) return null;
|
|
26
|
+
hooks.PreToolUse = hookGroup(command);
|
|
27
|
+
}
|
|
28
|
+
return `${JSON.stringify({ hooks }, null, 2)}\n`;
|
|
29
|
+
}
|
|
30
|
+
function hasOnlyKeys(value, expectedKeys) {
|
|
31
|
+
if (!isRecord(value)) return false;
|
|
32
|
+
const actualKeys = Object.keys(value).sort();
|
|
33
|
+
const sortedExpectedKeys = [...expectedKeys].sort();
|
|
34
|
+
return actualKeys.length === sortedExpectedKeys.length && actualKeys.every((key, index) => key === sortedExpectedKeys[index]);
|
|
35
|
+
}
|
|
36
|
+
var MANAGED_RELAY_RE = /(?:^|\/)(hook-relay|hook-tool-relay)\.(?:js|ts)$/;
|
|
37
|
+
function isManagedCommand(command, event) {
|
|
38
|
+
if (typeof command !== "string") return false;
|
|
39
|
+
const match = command.match(/^node (?:(?:"([^"\r\n]+)")|([^\s"']+)) ([A-Za-z][A-Za-z0-9_-]{0,63})$/);
|
|
40
|
+
if (!match) return false;
|
|
41
|
+
const relayPath = match[1] || match[2];
|
|
42
|
+
const relayMatch = relayPath.match(MANAGED_RELAY_RE);
|
|
43
|
+
if (!relayMatch) return false;
|
|
44
|
+
const expectedRelay = event === "PreToolUse" ? "hook-tool-relay" : "hook-relay";
|
|
45
|
+
const expectedToken = event === "PreToolUse" ? "saneYolo" : event;
|
|
46
|
+
if (relayMatch[1] !== expectedRelay || match[3] !== expectedToken) return false;
|
|
47
|
+
return buildHookCommand(relayPath, expectedToken) === command;
|
|
48
|
+
}
|
|
49
|
+
function isManagedHookGroup(group, event) {
|
|
50
|
+
if (!Array.isArray(group) || group.length !== 1) return false;
|
|
51
|
+
const matcherGroup = group[0];
|
|
52
|
+
if (!hasOnlyKeys(matcherGroup, ["hooks"])) return false;
|
|
53
|
+
if (!Array.isArray(matcherGroup.hooks) || matcherGroup.hooks.length !== 1) return false;
|
|
54
|
+
const handler = matcherGroup.hooks[0];
|
|
55
|
+
if (!hasOnlyKeys(handler, ["type", "command"])) return false;
|
|
56
|
+
if (handler.type !== "command") return false;
|
|
57
|
+
return isManagedCommand(handler.command, event);
|
|
58
|
+
}
|
|
59
|
+
function classifyGrokHooksFile(contents, { relayPath, events, managedEventSets = [], hookToolRelayPath }) {
|
|
60
|
+
if (contents == null) return "absent";
|
|
61
|
+
if (contents === renderGrokHooksFile({
|
|
62
|
+
relayPath,
|
|
63
|
+
events,
|
|
64
|
+
hookToolRelayPath
|
|
65
|
+
})) return "current";
|
|
66
|
+
if (contents === renderGrokHooksFile({
|
|
67
|
+
relayPath,
|
|
68
|
+
events
|
|
69
|
+
})) return "current";
|
|
70
|
+
let parsed = null;
|
|
71
|
+
try {
|
|
72
|
+
parsed = JSON.parse(contents);
|
|
73
|
+
} catch {
|
|
74
|
+
return "foreign";
|
|
75
|
+
}
|
|
76
|
+
if (!hasOnlyKeys(parsed, ["hooks"])) return "foreign";
|
|
77
|
+
const hooksValue = parsed.hooks;
|
|
78
|
+
if (hooksValue === null || hooksValue === void 0) throw new TypeError("hooks must be an object");
|
|
79
|
+
if (!isRecord(hooksValue)) return "foreign";
|
|
80
|
+
const actualEvents = Object.keys(hooksValue);
|
|
81
|
+
if (!hasOnlyKeys(hooksValue, actualEvents)) return "foreign";
|
|
82
|
+
const hooks = hooksValue;
|
|
83
|
+
if (![events, ...managedEventSets].some((managedEvents) => hasOnlyKeys(hooks, managedEvents) || hasOnlyKeys(hooks, [...managedEvents, "PreToolUse"]))) return "foreign";
|
|
84
|
+
for (const event of actualEvents) if (!isManagedHookGroup(hooks[event], event)) return "foreign";
|
|
85
|
+
return "managed-stale";
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region session/core/title-classifier-core.ts
|
|
89
|
+
var BRAILLE_MIN = 10240;
|
|
90
|
+
var BRAILLE_MAX = 10495;
|
|
91
|
+
var CIRCLE_HALVES_SPINNER_CODEPOINTS = /* @__PURE__ */ new Set([
|
|
92
|
+
9680,
|
|
93
|
+
9681,
|
|
94
|
+
9682,
|
|
95
|
+
9683
|
|
96
|
+
]);
|
|
97
|
+
function isBrailleChar(char) {
|
|
98
|
+
if (!char) return false;
|
|
99
|
+
const codePoint = char.codePointAt(0) ?? 0;
|
|
100
|
+
return codePoint >= BRAILLE_MIN && codePoint <= BRAILLE_MAX;
|
|
101
|
+
}
|
|
102
|
+
function isSpinnerChar(char) {
|
|
103
|
+
if (!char) return false;
|
|
104
|
+
if (isBrailleChar(char)) return true;
|
|
105
|
+
return CIRCLE_HALVES_SPINNER_CODEPOINTS.has(char.codePointAt(0) ?? 0);
|
|
106
|
+
}
|
|
107
|
+
function isPathLikeTitle(title) {
|
|
108
|
+
return title.includes("/") || title.includes("\\");
|
|
109
|
+
}
|
|
110
|
+
function firstCharOfTitle(title) {
|
|
111
|
+
if (title.length === 0) return "";
|
|
112
|
+
return String.fromCodePoint(title.codePointAt(0) ?? 0);
|
|
113
|
+
}
|
|
114
|
+
function classifyAgentTitle(title, { cwdBasename = null }, vocabulary) {
|
|
115
|
+
const trimmedTitle = title.trim();
|
|
116
|
+
if (vocabulary.busyTitle && trimmedTitle === vocabulary.busyTitle) return "working";
|
|
117
|
+
if (vocabulary.idleTitle && trimmedTitle === vocabulary.idleTitle) return "ready";
|
|
118
|
+
if (isPathLikeTitle(title)) return "ignore";
|
|
119
|
+
if (vocabulary.isSpinnerChar(firstCharOfTitle(title))) return "working";
|
|
120
|
+
if (!cwdBasename) return "ignore";
|
|
121
|
+
const cwdAwareClassification = vocabulary.classifyAgainstCwdBasename?.(title, cwdBasename) ?? null;
|
|
122
|
+
if (cwdAwareClassification) return cwdAwareClassification;
|
|
123
|
+
if (trimmedTitle === cwdBasename) return "ready";
|
|
124
|
+
return "unknown";
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region session/adapters/grok.ts
|
|
128
|
+
var ID = "grok";
|
|
129
|
+
var COMMAND_NAME = "grok";
|
|
130
|
+
var RELAY_PATH = relayPath("hook-relay");
|
|
131
|
+
var HOOK_TOOL_RELAY_PATH = relayPath("hook-tool-relay");
|
|
132
|
+
var HOOK_EVENTS = [
|
|
133
|
+
"UserPromptSubmit",
|
|
134
|
+
"Stop",
|
|
135
|
+
"StopFailure",
|
|
136
|
+
"StopCancelled",
|
|
137
|
+
"Notification",
|
|
138
|
+
"SubagentStart",
|
|
139
|
+
"SubagentStop"
|
|
140
|
+
];
|
|
141
|
+
var MANAGED_HOOK_EVENT_SETS = [[
|
|
142
|
+
"UserPromptSubmit",
|
|
143
|
+
"Stop",
|
|
144
|
+
"StopFailure",
|
|
145
|
+
"StopCancelled",
|
|
146
|
+
"Notification"
|
|
147
|
+
]];
|
|
148
|
+
var ACTION_REQUIRED_MARKER = String.fromCodePoint(9888);
|
|
149
|
+
var CLAUDE_COMPAT_HOOKS_ENV = "GROK_CLAUDE_HOOKS_ENABLED";
|
|
150
|
+
var PROJECT_CONFIG_CANDIDATES = Object.freeze([Object.freeze({
|
|
151
|
+
relPath: ".claude/settings.json",
|
|
152
|
+
presenceIsHit: false
|
|
153
|
+
}), Object.freeze({
|
|
154
|
+
relPath: ".claude/settings.local.json",
|
|
155
|
+
presenceIsHit: false
|
|
156
|
+
})]);
|
|
157
|
+
var envProfile = {
|
|
158
|
+
scrub: [],
|
|
159
|
+
set: { [CLAUDE_COMPAT_HOOKS_ENV]: "false" }
|
|
160
|
+
};
|
|
161
|
+
function notificationType(payload) {
|
|
162
|
+
return String(payload?.notificationType || payload?.notification_type || "").toLowerCase();
|
|
163
|
+
}
|
|
164
|
+
function isMainSessionPayload(payload) {
|
|
165
|
+
return !payload?.subagentType && !payload?.subagent_type;
|
|
166
|
+
}
|
|
167
|
+
function mapBackgroundTask(task) {
|
|
168
|
+
if (!isRecord(task)) return task;
|
|
169
|
+
return {
|
|
170
|
+
...task,
|
|
171
|
+
...typeof task.agentType === "string" ? { agent_type: task.agentType } : {}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function mapHookPayload(_event, payload) {
|
|
175
|
+
if (!isRecord(payload)) return payload;
|
|
176
|
+
return {
|
|
177
|
+
...payload,
|
|
178
|
+
...typeof payload.subagentId === "string" ? { agent_id: payload.subagentId } : {},
|
|
179
|
+
...typeof payload.subagentType === "string" ? { agent_type: payload.subagentType } : {},
|
|
180
|
+
...Array.isArray(payload.backgroundTasks) ? { background_tasks: payload.backgroundTasks.map(mapBackgroundTask) } : {}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function mayContributeHooks(configText) {
|
|
184
|
+
if (typeof configText !== "string") return false;
|
|
185
|
+
let settings;
|
|
186
|
+
try {
|
|
187
|
+
settings = JSON.parse(configText);
|
|
188
|
+
} catch {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
if (!isRecord(settings)) return false;
|
|
192
|
+
return Object.hasOwn(settings, "hooks");
|
|
193
|
+
}
|
|
194
|
+
function userConfigFolders() {
|
|
195
|
+
return [path.join(os.homedir(), ".claude")];
|
|
196
|
+
}
|
|
197
|
+
function mapHookToSignal(event, payload) {
|
|
198
|
+
const normalizedEvent = String(event || "").toLowerCase();
|
|
199
|
+
if (normalizedEvent === "subagentstart") return "subagent-start";
|
|
200
|
+
if (normalizedEvent === "subagentstop") return "subagent-stop";
|
|
201
|
+
if (!isMainSessionPayload(payload)) return null;
|
|
202
|
+
switch (normalizedEvent) {
|
|
203
|
+
case "sessionstart": return "session-start";
|
|
204
|
+
case "sessionend": return "session-end";
|
|
205
|
+
case "userpromptsubmit": return "resume";
|
|
206
|
+
case "stop": return payload?.reason === "end_turn" ? "ready" : null;
|
|
207
|
+
case "stopfailure":
|
|
208
|
+
case "stopcancelled": return "ready";
|
|
209
|
+
case "notification": {
|
|
210
|
+
const type = notificationType(payload);
|
|
211
|
+
if (type === "idle_prompt") return "ready";
|
|
212
|
+
if (type === "permission_prompt" || type === "approval_required") return "awaiting-input";
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
default: return null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function mapHookConfidence(event, payload) {
|
|
219
|
+
if (String(event || "").toLowerCase() === "notification" && notificationType(payload) === "idle_prompt") return "low";
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
function mapHookPromptKind(event, payload) {
|
|
223
|
+
if (String(event || "").toLowerCase() !== "notification") return null;
|
|
224
|
+
const type = notificationType(payload);
|
|
225
|
+
if (type === "permission_prompt" || type === "approval_required") return "permission";
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
function sessionIdOf(payload) {
|
|
229
|
+
return payload?.sessionId;
|
|
230
|
+
}
|
|
231
|
+
function classifyTitle(title) {
|
|
232
|
+
const normalizedTitle = String(title || "");
|
|
233
|
+
if (isPathLikeTitle(normalizedTitle)) return "ignore";
|
|
234
|
+
if (isBrailleChar(firstCharOfTitle(normalizedTitle))) return "working";
|
|
235
|
+
if (normalizedTitle.startsWith(ACTION_REQUIRED_MARKER)) return "awaiting-input";
|
|
236
|
+
return "unknown";
|
|
237
|
+
}
|
|
238
|
+
var titleProfile = {
|
|
239
|
+
classifyTitle,
|
|
240
|
+
taskTitle: {
|
|
241
|
+
readsTranscriptTitle: false,
|
|
242
|
+
genericTitles: [ID],
|
|
243
|
+
agentSuffix: ` - ${ID}`
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
function grokHome(env = process.env, homedir = os.homedir(), platform = process.platform) {
|
|
247
|
+
const pathApi = platform === "win32" ? path.win32 : path;
|
|
248
|
+
const configuredHome = typeof env.GROK_HOME === "string" ? env.GROK_HOME.trim() : "";
|
|
249
|
+
if (configuredHome) return pathApi.resolve(configuredHome);
|
|
250
|
+
return pathApi.join(homedir, ".grok");
|
|
251
|
+
}
|
|
252
|
+
function hooksFilePath(env = process.env, homedir = os.homedir()) {
|
|
253
|
+
return path.join(grokHome(env, homedir), "hooks", "glimmervoid.json");
|
|
254
|
+
}
|
|
255
|
+
function nativeBinaryPath({ platform = process.platform, env = process.env, homedir = os.homedir() } = {}) {
|
|
256
|
+
const pathApi = platform === "win32" ? path.win32 : path;
|
|
257
|
+
const binaryName = platform === "win32" ? "grok.exe" : "grok";
|
|
258
|
+
return pathApi.join(grokHome(env, homedir, platform), "bin", binaryName);
|
|
259
|
+
}
|
|
260
|
+
function resolveCommand({ platform = process.platform, env = process.env, homedir = os.homedir(), existsSync = fs.existsSync, realpathSync = fs.realpathSync, warn = console.warn } = {}) {
|
|
261
|
+
const candidate = nativeBinaryPath({
|
|
262
|
+
platform,
|
|
263
|
+
env,
|
|
264
|
+
homedir
|
|
265
|
+
});
|
|
266
|
+
try {
|
|
267
|
+
if (existsSync(candidate)) return {
|
|
268
|
+
path: realpathSync(candidate),
|
|
269
|
+
kind: "exe"
|
|
270
|
+
};
|
|
271
|
+
} catch (error) {
|
|
272
|
+
warn(`[glimmervoid] could not resolve the native 'grok' binary at ${candidate}: ${errorMessage(error)}`);
|
|
273
|
+
return {
|
|
274
|
+
path: null,
|
|
275
|
+
kind: "unresolved"
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
warn(`[glimmervoid] could not resolve the native 'grok' binary at ${candidate}`);
|
|
279
|
+
return {
|
|
280
|
+
path: null,
|
|
281
|
+
kind: "unresolved"
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function buildSpawnCommand({ resolved, settingsArgs = [], agentArgs = [] }) {
|
|
285
|
+
if (!resolved?.path) throw new Error("the native grok binary is not resolved");
|
|
286
|
+
return {
|
|
287
|
+
file: resolved.path,
|
|
288
|
+
args: [...settingsArgs, ...agentArgs]
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function buildEnv(baseEnv, extraEnv, options) {
|
|
292
|
+
return buildAgentEnv(baseEnv, extraEnv, envProfile, options);
|
|
293
|
+
}
|
|
294
|
+
function buildArgs({ dangerouslySkipPermissions = false, resumeSessionId = null, extraArgs = [], initialPrompt = null } = {}) {
|
|
295
|
+
const args = ["--no-auto-update"];
|
|
296
|
+
if (dangerouslySkipPermissions) args.push("--always-approve");
|
|
297
|
+
if (resumeSessionId) args.push("-r", resumeSessionId);
|
|
298
|
+
if (extraArgs.length > 0) args.push(...extraArgs);
|
|
299
|
+
if (initialPrompt != null) args.push(initialPrompt);
|
|
300
|
+
return args;
|
|
301
|
+
}
|
|
302
|
+
var grok = {
|
|
303
|
+
id: ID,
|
|
304
|
+
label: "Grok Build",
|
|
305
|
+
usageVendor: "grok",
|
|
306
|
+
commandName: COMMAND_NAME,
|
|
307
|
+
envProfile,
|
|
308
|
+
titleProfile,
|
|
309
|
+
hooks: {
|
|
310
|
+
mapSignal: mapHookToSignal,
|
|
311
|
+
mapConfidence: mapHookConfidence,
|
|
312
|
+
mapPromptKind: mapHookPromptKind,
|
|
313
|
+
mapPayload: mapHookPayload,
|
|
314
|
+
injection: {
|
|
315
|
+
kind: "home-hooks-file",
|
|
316
|
+
setupCommand: "glimmervoid agent setup grok",
|
|
317
|
+
filePath: hooksFilePath,
|
|
318
|
+
isSaneYoloReady: (contents) => contents === renderGrokHooksFile({
|
|
319
|
+
relayPath: RELAY_PATH,
|
|
320
|
+
events: HOOK_EVENTS,
|
|
321
|
+
hookToolRelayPath: HOOK_TOOL_RELAY_PATH
|
|
322
|
+
}),
|
|
323
|
+
classifyContents: (contents) => classifyGrokHooksFile(contents, {
|
|
324
|
+
relayPath: RELAY_PATH,
|
|
325
|
+
events: HOOK_EVENTS,
|
|
326
|
+
managedEventSets: MANAGED_HOOK_EVENT_SETS,
|
|
327
|
+
hookToolRelayPath: HOOK_TOOL_RELAY_PATH
|
|
328
|
+
}),
|
|
329
|
+
projectConfigCandidates: PROJECT_CONFIG_CANDIDATES,
|
|
330
|
+
userConfigFolders,
|
|
331
|
+
mayContributeHooks
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
resolveCommand,
|
|
335
|
+
buildSpawnCommand,
|
|
336
|
+
buildEnv,
|
|
337
|
+
buildArgs,
|
|
338
|
+
sessionIdOf,
|
|
339
|
+
mapHookPayload,
|
|
340
|
+
mapHookToSignal,
|
|
341
|
+
mapHookConfidence,
|
|
342
|
+
mapHookPromptKind,
|
|
343
|
+
classifyTitle,
|
|
344
|
+
grokHome,
|
|
345
|
+
hooksFilePath,
|
|
346
|
+
nativeBinaryPath,
|
|
347
|
+
mayContributeHooks,
|
|
348
|
+
PROJECT_CONFIG_CANDIDATES,
|
|
349
|
+
CLAUDE_COMPAT_HOOKS_ENV,
|
|
350
|
+
HOOK_TOOL_RELAY_PATH,
|
|
351
|
+
HOOK_EVENTS,
|
|
352
|
+
MANAGED_HOOK_EVENT_SETS,
|
|
353
|
+
RELAY_PATH,
|
|
354
|
+
ACTION_REQUIRED_MARKER,
|
|
355
|
+
capabilities: {
|
|
356
|
+
hooks: true,
|
|
357
|
+
awaitingInput: true,
|
|
358
|
+
backgroundAgents: true,
|
|
359
|
+
resume: true,
|
|
360
|
+
statusLine: false,
|
|
361
|
+
rtk: false,
|
|
362
|
+
saneYolo: true,
|
|
363
|
+
compactQuiet: false,
|
|
364
|
+
skipPermissionsFlag: true,
|
|
365
|
+
headless: true
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
//#endregion
|
|
369
|
+
export { classifyGrokHooksFile as a, isSpinnerChar as i, classifyAgentTitle as n, renderGrokHooksFile as o, isBrailleChar as r, grok as t };
|