@levnikolaevich/hex-line-mcp 1.6.0 → 1.7.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.
- package/dist/hook.mjs +37 -18
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
package/dist/hook.mjs
CHANGED
|
@@ -250,28 +250,47 @@ function isHexLineDisabled(configPath) {
|
|
|
250
250
|
function _resetHexLineDisabledCache() {
|
|
251
251
|
_hexLineDisabled = null;
|
|
252
252
|
}
|
|
253
|
+
var _hookMode;
|
|
254
|
+
function getHookMode() {
|
|
255
|
+
if (_hookMode !== void 0) return _hookMode;
|
|
256
|
+
_hookMode = "blocking";
|
|
257
|
+
try {
|
|
258
|
+
const stateFile = resolve(process.cwd(), ".hex-skills/environment_state.json");
|
|
259
|
+
const data = JSON.parse(readFileSync(stateFile, "utf-8"));
|
|
260
|
+
if (data.hooks?.mode === "advisory") _hookMode = "advisory";
|
|
261
|
+
} catch {
|
|
262
|
+
}
|
|
263
|
+
return _hookMode;
|
|
264
|
+
}
|
|
253
265
|
function block(reason, context) {
|
|
254
266
|
const output = {
|
|
255
267
|
hookSpecificOutput: {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
268
|
+
permissionDecision: "deny"
|
|
269
|
+
},
|
|
270
|
+
systemMessage: context ? `${reason}
|
|
271
|
+
${context}` : reason
|
|
260
272
|
};
|
|
261
|
-
if (context) output.hookSpecificOutput.additionalContext = context;
|
|
262
273
|
process.stdout.write(JSON.stringify(output));
|
|
263
274
|
process.exit(2);
|
|
264
275
|
}
|
|
265
|
-
function advise(reason) {
|
|
266
|
-
|
|
276
|
+
function advise(reason, context) {
|
|
277
|
+
const output = {
|
|
267
278
|
hookSpecificOutput: {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
279
|
+
permissionDecision: "allow"
|
|
280
|
+
},
|
|
281
|
+
systemMessage: context ? `${reason}
|
|
282
|
+
${context}` : reason
|
|
283
|
+
};
|
|
284
|
+
process.stdout.write(JSON.stringify(output));
|
|
273
285
|
process.exit(0);
|
|
274
286
|
}
|
|
287
|
+
function redirect(reason, context) {
|
|
288
|
+
if (getHookMode() === "advisory") {
|
|
289
|
+
advise(reason, context);
|
|
290
|
+
} else {
|
|
291
|
+
block(reason, context);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
275
294
|
function handlePreToolUse(data) {
|
|
276
295
|
const toolName = data.tool_name || "";
|
|
277
296
|
const toolInput = data.tool_input || {};
|
|
@@ -312,7 +331,7 @@ function handlePreToolUse(data) {
|
|
|
312
331
|
advise("hex-line read_file returns hash-annotated lines for verified edit workflow. For code files, outline gives a compact structural map first.");
|
|
313
332
|
}
|
|
314
333
|
const target = filePath ? `Use mcp__hex-line__outline or mcp__hex-line__read_file with path="${filePath}"` : "Use mcp__hex-line__directory_tree or mcp__hex-line__read_file";
|
|
315
|
-
|
|
334
|
+
redirect(target, "For large or unknown full reads: call outline first, then read_file with offset/limit or ranges. Do not use built-in Read here.");
|
|
316
335
|
}
|
|
317
336
|
if (toolName === "Edit") {
|
|
318
337
|
const oldText = String(toolInput.old_string || "");
|
|
@@ -321,15 +340,15 @@ function handlePreToolUse(data) {
|
|
|
321
340
|
process.exit(0);
|
|
322
341
|
}
|
|
323
342
|
const target = filePath ? `Use mcp__hex-line__grep_search or mcp__hex-line__read_file, then mcp__hex-line__edit_file with path="${filePath}"` : "Use mcp__hex-line__grep_search or mcp__hex-line__read_file, then mcp__hex-line__edit_file";
|
|
324
|
-
|
|
343
|
+
redirect(target, "For large or repeated edits: locate anchors/checksums first, then call edit_file once with batched edits.");
|
|
325
344
|
}
|
|
326
345
|
if (toolName === "Write") {
|
|
327
346
|
const pathNote = filePath ? ` with path="${filePath}"` : "";
|
|
328
|
-
|
|
347
|
+
redirect(`Use mcp__hex-line__write_file${pathNote}`, TOOL_HINTS.Write);
|
|
329
348
|
}
|
|
330
349
|
if (toolName === "Grep") {
|
|
331
350
|
const pathNote = filePath ? ` with path="${filePath}"` : "";
|
|
332
|
-
|
|
351
|
+
redirect(`Use mcp__hex-line__grep_search${pathNote}`, TOOL_HINTS.Grep);
|
|
333
352
|
}
|
|
334
353
|
}
|
|
335
354
|
if (toolName === "Bash") {
|
|
@@ -352,7 +371,7 @@ function handlePreToolUse(data) {
|
|
|
352
371
|
if (regex.test(firstCmd)) {
|
|
353
372
|
const hint = TOOL_HINTS[key];
|
|
354
373
|
const toolName2 = hint.split(" (")[0];
|
|
355
|
-
|
|
374
|
+
redirect(`Use ${toolName2} instead of piped command`, hint);
|
|
356
375
|
}
|
|
357
376
|
}
|
|
358
377
|
process.exit(0);
|
|
@@ -363,7 +382,7 @@ function handlePreToolUse(data) {
|
|
|
363
382
|
const toolName2 = hint.split(" (")[0];
|
|
364
383
|
const args = command.split(/\s+/).slice(1).join(" ");
|
|
365
384
|
const argsNote = args ? ` \u2014 args: "${args}"` : "";
|
|
366
|
-
|
|
385
|
+
redirect(`Use ${toolName2}${argsNote}`, hint);
|
|
367
386
|
}
|
|
368
387
|
}
|
|
369
388
|
}
|
package/dist/server.mjs
CHANGED
|
@@ -2837,7 +2837,7 @@ OUTPUT_CAPPED: Output exceeded ${MAX_BULK_OUTPUT_CHARS} chars.`;
|
|
|
2837
2837
|
}
|
|
2838
2838
|
|
|
2839
2839
|
// server.mjs
|
|
2840
|
-
var version = true ? "1.
|
|
2840
|
+
var version = true ? "1.7.0" : (await null).createRequire(import.meta.url)("./package.json").version;
|
|
2841
2841
|
var { server, StdioServerTransport } = await createServerRuntime({
|
|
2842
2842
|
name: "hex-line-mcp",
|
|
2843
2843
|
version
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levnikolaevich/hex-line-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"mcpName": "io.github.levnikolaevich/hex-line-mcp",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Hash-verified file editing MCP + token efficiency hook for AI coding agents. 11 tools: read, edit, write, grep, outline, verify, directory_tree, file_info, setup_hooks, changes, bulk_replace.",
|