@indigoai-us/hq-cli 5.345.242 → 5.345.243

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/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [5.345.243] — 2026-11-20
6
+ - Added (`hq doctor`): a `claude-imports` check that warns when `~/.claude/CLAUDE.md` or one of the HQ tree's CLAUDE.md files has an `@import` path written with backslashes (for example `@C:\Users\me\hq\.claude\CLAUDE.md`). Claude Code never loads such an import, so on Windows the HQ charter or another file silently never reached the session. An escaped space (`\ `) is left alone, and imports inside code or HTML comments are ignored. `hq doctor --fix` rewrites those import paths with forward slashes and changes nothing else in the file. The check also warns when the `hq install --global` import in `~/.claude/CLAUDE.md` names a path Claude Code cannot find, such as one cut short by an unescaped space; when the full path exists, `--fix` rewrites that one line with escaped spaces.
7
+ - On hosted agents-v2 and fleet-local bots, the new hook engine now refuses an edit under `core/` (and the other protected scaffold paths) in the bot's HQ folder when the runtime runs the hook from a folder outside that HQ folder, as the released bot adapters do. It also accepts a registered `--hq-root` that has `core/` and `.claude/hooks/hook-gate.sh` but no `companies/` folder, so a plain command such as `date -u` is no longer refused with "the HQ root is unknown". A root that is not an HQ folder is still refused. The replay harness now runs fleet events from outside the HQ folder, as the runtimes do.
8
+ - Internal: `hq-hook` now claims master-hook's own PostToolUse work on the local bot runtime (`master-hook:PostToolUse` on fleet-local). Under the hq-fleet-local v0.4.33 adapter, master-hook ran only for a `.claude/settings.json` PostToolUse record that matches the adapter's canonical tool name, never in a helper session, and read the payload the adapter rebuilt; the native session bind, twin dedupe and timeout journal now follow the same rules and match the released adapter running the real master-hook. A payload with no session id, a tool name the adapter's shell would split, text jq prints differently, a pinned-engine exec entry, a PostToolUse hook the claim does not name and an unreadable settings file are refused natively. Hosted agents (`agents-v2`) are unchanged.
9
+
5
10
  ## [5.345.242] — 2026-11-20
6
11
 
7
12
  - `hq lanes list` no longer reads `~/.hq/work-mesh/spool.jsonl` as one string. An 800 MB spool used to crash with Node's string-length limit; the liveness index now scans the file in 64 KiB chunks.
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Claude Code `@import` paths that never load.
3
+ *
4
+ * Claude Code finds imports with `(?:^|\s)@((?:[^\s\\]|\\ )+)` and turns each
5
+ * `\ ` into a space, so `\ ` is an escaped space and any other backslash ends
6
+ * the path. `@C:\Users\me\hq\.claude\CLAUDE.md` therefore imports `C:` and
7
+ * nothing loads, while `@C:/Users/me/hq/.claude/CLAUDE.md` loads on Windows
8
+ * too. Nothing reports the failure (feedback_362cdca7).
9
+ *
10
+ * Pure text functions only. Claude Code does not import from code spans,
11
+ * fenced or indented code blocks, or HTML comments, so neither do these.
12
+ */
13
+ /** One `@import` whose path holds a backslash that is not an escaped space. */
14
+ export interface BackslashImport {
15
+ /** One-based line number. */
16
+ line: number;
17
+ /** The import path as written, without the leading `@`. */
18
+ path: string;
19
+ }
20
+ /** Every `@import` in `text` whose path holds a backslash that is not an escaped space. */
21
+ export declare function findBackslashImports(text: string): BackslashImport[];
22
+ /**
23
+ * An import path written as Claude Code reads it: each path backslash becomes
24
+ * `/`, an escaped space (`\ `) stays, and an unescaped space is escaped.
25
+ */
26
+ export declare function toForwardSlashes(importPath: string): string;
27
+ /**
28
+ * `text` with each such `@import` path rewritten by {@link toForwardSlashes}.
29
+ * Nothing else changes: other text, code, comments and line endings keep their
30
+ * bytes. Returns `text` itself when there is nothing to change.
31
+ */
32
+ export declare function normalizeBackslashImports(text: string): string;
33
+ /** The import line inside the hq-anywhere managed block of a CLAUDE.md file. */
34
+ export interface HqBlockImport {
35
+ /** One-based line number. */
36
+ line: number;
37
+ /** Everything after the `@`, trailing whitespace trimmed. */
38
+ raw: string;
39
+ /** The path Claude Code imports from that line (its tokenizer, `\ ` as a space). */
40
+ claudePath: string;
41
+ /** The path the line means: `\ ` as a space, every other backslash as `/`. */
42
+ intendedPath: string;
43
+ }
44
+ /** The managed block's import line, or null when the file has no such block. */
45
+ export declare function findHqBlockImport(text: string): HqBlockImport | null;
46
+ /**
47
+ * `text` with the managed block's import line rewritten as the path it means,
48
+ * forward slashes and every space escaped (`\ `), so Claude Code reads the
49
+ * whole path. Only that one line changes; `text` itself when nothing would.
50
+ */
51
+ export declare function escapeHqBlockImport(text: string): string;
52
+ //# sourceMappingURL=claude-md-imports.d.ts.map
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Claude Code `@import` paths that never load.
3
+ *
4
+ * Claude Code finds imports with `(?:^|\s)@((?:[^\s\\]|\\ )+)` and turns each
5
+ * `\ ` into a space, so `\ ` is an escaped space and any other backslash ends
6
+ * the path. `@C:\Users\me\hq\.claude\CLAUDE.md` therefore imports `C:` and
7
+ * nothing loads, while `@C:/Users/me/hq/.claude/CLAUDE.md` loads on Windows
8
+ * too. Nothing reports the failure (feedback_362cdca7).
9
+ *
10
+ * Pure text functions only. Claude Code does not import from code spans,
11
+ * fenced or indented code blocks, or HTML comments, so neither do these.
12
+ */
13
+ /** `@` at the start of a line or after whitespace, then the path; `\ ` stays inside it. */
14
+ const IMPORT_TOKEN = /(^|\s)@((?:\\ |\S)+)/g;
15
+ /**
16
+ * A path backslash: not an escaped space, and not a Markdown escape (a
17
+ * backslash before ASCII punctuation, as in `my\_file.md`). A path that has
18
+ * one is a Windows path, and all of its backslashes are separators.
19
+ */
20
+ const BAD_BACKSLASH = /\\(?![ !"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/;
21
+ /** One more space-separated chunk after a token, for a Windows path with a space in it. */
22
+ const CONTINUATION = /^ ((?:\\ |\S)+)/;
23
+ /**
24
+ * A chunk that is not part of the path before it: a new path (drive letter,
25
+ * `\`, `.`, `/`, `@`), so `@C:\x\y.md \foo` or `..\other.md` stays text.
26
+ */
27
+ const NEW_PATH = /^(?:[A-Za-z]:|[\\./@])/;
28
+ /** A path that already names a Markdown file is complete. */
29
+ const ENDS_IN_MD = /\.md$/i;
30
+ /** Opening or closing fence of a fenced code block (up to three spaces of indent). */
31
+ const FENCE = /^ {0,3}(`{3,}|~{3,})/;
32
+ /** A list item line, whose indented continuation lines are not code. */
33
+ const LIST_ITEM = /^ {0,3}(?:[-*+]|\d{1,9}[.)])(?:\s|$)/;
34
+ /** Four spaces or a tab of indent: an indented code line when it is not a continuation. */
35
+ const INDENTED = /^(?: {4,}|\t)/;
36
+ const HQ_BLOCK_BEGIN = "<!-- hq-anywhere:begin";
37
+ /** Same text as `CLAUDE_MD_END` in src/lib/install/claude-targets.ts. */
38
+ const HQ_BLOCK_END = "<!-- hq-anywhere:end -->";
39
+ /** Split into lines, keeping each line's own terminator (`\n` or `\r\n`). */
40
+ function splitLines(text) {
41
+ const out = [];
42
+ const parts = text.split(/(\r?\n)/);
43
+ for (let i = 0; i < parts.length; i += 2) {
44
+ out.push({ body: parts[i] ?? "", eol: parts[i + 1] ?? "" });
45
+ }
46
+ return out;
47
+ }
48
+ const blank = (span) => " ".repeat(span.length);
49
+ /**
50
+ * Each line's text as Claude Code would scan it for imports: code spans and
51
+ * HTML comments blanked to spaces (same length), and lines inside fenced or
52
+ * indented code blocks or a multi-line comment replaced by null.
53
+ */
54
+ function scannableLines(text) {
55
+ const out = [];
56
+ let fence = null;
57
+ let inComment = false;
58
+ let prevBlank = true;
59
+ let inIndentedCode = false;
60
+ let inList = false;
61
+ for (const { body } of splitLines(text)) {
62
+ if (fence !== null) {
63
+ const marker = FENCE.exec(body);
64
+ if (marker && marker[1][0] === fence.char && marker[1].length >= fence.length && body.trim() === marker[1])
65
+ fence = null;
66
+ out.push(null);
67
+ continue;
68
+ }
69
+ let line = body;
70
+ if (inComment) {
71
+ const close = line.indexOf("-->");
72
+ if (close === -1) {
73
+ out.push(null);
74
+ continue;
75
+ }
76
+ line = blank(line.slice(0, close + 3)) + line.slice(close + 3);
77
+ inComment = false;
78
+ }
79
+ else {
80
+ const marker = FENCE.exec(line);
81
+ if (marker) {
82
+ fence = { char: marker[1][0], length: marker[1].length };
83
+ out.push(null);
84
+ prevBlank = false;
85
+ inIndentedCode = false;
86
+ continue;
87
+ }
88
+ if (line.trim() === "") {
89
+ prevBlank = true;
90
+ out.push(line);
91
+ continue;
92
+ }
93
+ const indented = INDENTED.test(line);
94
+ if (indented && !inList && (prevBlank || inIndentedCode)) {
95
+ inIndentedCode = true;
96
+ prevBlank = false;
97
+ out.push(null);
98
+ continue;
99
+ }
100
+ inIndentedCode = false;
101
+ if (LIST_ITEM.test(line))
102
+ inList = true;
103
+ else if (!indented)
104
+ inList = false;
105
+ prevBlank = false;
106
+ }
107
+ line = line.replace(/(`+)[^`]*?\1/g, blank).replace(/<!--[\s\S]*?-->/g, blank);
108
+ const open = line.indexOf("<!--");
109
+ if (open !== -1) {
110
+ line = line.slice(0, open) + blank(line.slice(open));
111
+ inComment = true;
112
+ }
113
+ out.push(line);
114
+ }
115
+ return out;
116
+ }
117
+ function locate(text) {
118
+ const found = [];
119
+ scannableLines(text).forEach((line, index) => {
120
+ if (line === null)
121
+ return;
122
+ for (const match of line.matchAll(IMPORT_TOKEN)) {
123
+ let importPath = match[2];
124
+ if (!BAD_BACKSLASH.test(importPath))
125
+ continue;
126
+ const start = match.index + match[1].length + 1;
127
+ // `@C:\Users\John Smith\hq\x.md`: Claude Code would stop at the first
128
+ // backslash anyway, so take the chunks after an unescaped space while
129
+ // each still holds a path backslash and does not start a new path. A
130
+ // path that already ends in .md is complete, so text after it stays.
131
+ for (;;) {
132
+ if (ENDS_IN_MD.test(importPath))
133
+ break;
134
+ const next = CONTINUATION.exec(line.slice(start + importPath.length));
135
+ if (!next || !BAD_BACKSLASH.test(next[1]) || NEW_PATH.test(next[1]))
136
+ break;
137
+ importPath += next[0];
138
+ }
139
+ found.push({ line: index + 1, path: importPath, start });
140
+ }
141
+ });
142
+ return found;
143
+ }
144
+ /** Every `@import` in `text` whose path holds a backslash that is not an escaped space. */
145
+ export function findBackslashImports(text) {
146
+ return locate(text).map(({ line, path }) => ({ line, path }));
147
+ }
148
+ /**
149
+ * An import path written as Claude Code reads it: each path backslash becomes
150
+ * `/`, an escaped space (`\ `) stays, and an unescaped space is escaped.
151
+ */
152
+ export function toForwardSlashes(importPath) {
153
+ return importPath.replace(/\\ |\\| /g, (m) => (m === "\\ " ? m : m === "\\" ? "/" : "\\ "));
154
+ }
155
+ /**
156
+ * `text` with each such `@import` path rewritten by {@link toForwardSlashes}.
157
+ * Nothing else changes: other text, code, comments and line endings keep their
158
+ * bytes. Returns `text` itself when there is nothing to change.
159
+ */
160
+ export function normalizeBackslashImports(text) {
161
+ const hits = locate(text);
162
+ if (hits.length === 0)
163
+ return text;
164
+ const byLine = new Map();
165
+ for (const hit of hits)
166
+ byLine.set(hit.line, [...(byLine.get(hit.line) ?? []), hit]);
167
+ return splitLines(text)
168
+ .map(({ body, eol }, index) => {
169
+ const lineHits = byLine.get(index + 1);
170
+ if (!lineHits)
171
+ return body + eol;
172
+ let next = body;
173
+ // Right to left so earlier offsets stay valid.
174
+ for (const hit of [...lineHits].sort((a, b) => b.start - a.start)) {
175
+ next = next.slice(0, hit.start) + toForwardSlashes(hit.path) + next.slice(hit.start + hit.path.length);
176
+ }
177
+ return next + eol;
178
+ })
179
+ .join("");
180
+ }
181
+ function hqBlockImportIndex(lines) {
182
+ const begin = lines.findIndex(({ body }) => body.startsWith(HQ_BLOCK_BEGIN));
183
+ if (begin === -1)
184
+ return -1;
185
+ for (let i = begin + 1; i < lines.length; i++) {
186
+ const body = lines[i].body;
187
+ if (body.trim() === HQ_BLOCK_END)
188
+ return -1;
189
+ if (body.startsWith("@"))
190
+ return i;
191
+ }
192
+ return -1;
193
+ }
194
+ /** The managed block's import line, or null when the file has no such block. */
195
+ export function findHqBlockImport(text) {
196
+ const lines = splitLines(text);
197
+ const index = hqBlockImportIndex(lines);
198
+ if (index === -1)
199
+ return null;
200
+ const raw = lines[index].body.slice(1).trimEnd();
201
+ const token = /^((?:[^\s\\]|\\ )*)/.exec(raw)[1];
202
+ return {
203
+ line: index + 1,
204
+ raw,
205
+ claudePath: token.replace(/\\ /g, " "),
206
+ intendedPath: raw.replace(/\\ /g, " ").replace(/\\/g, "/"),
207
+ };
208
+ }
209
+ /**
210
+ * `text` with the managed block's import line rewritten as the path it means,
211
+ * forward slashes and every space escaped (`\ `), so Claude Code reads the
212
+ * whole path. Only that one line changes; `text` itself when nothing would.
213
+ */
214
+ export function escapeHqBlockImport(text) {
215
+ const lines = splitLines(text);
216
+ const index = hqBlockImportIndex(lines);
217
+ if (index === -1)
218
+ return text;
219
+ const found = findHqBlockImport(text);
220
+ const next = `@${found.intendedPath.replace(/ /g, "\\ ")}`;
221
+ if (next === lines[index].body)
222
+ return text;
223
+ lines[index] = { body: next, eol: lines[index].eol };
224
+ return lines.map(({ body, eol }) => body + eol).join("");
225
+ }
226
+ //# sourceMappingURL=claude-md-imports.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `hq doctor` claude-imports family: CLAUDE.md `@import` paths written with
3
+ * backslashes (feedback_362cdca7).
4
+ *
5
+ * Claude Code skips an `@import` whose path contains a backslash and says
6
+ * nothing, so on Windows `@C:\Users\me\hq\.claude\CLAUDE.md` leaves every
7
+ * session without the HQ charter. This family reads the CLAUDE.md files HQ
8
+ * relies on (the user-scope file `hq install --global` writes, and the HQ
9
+ * tree's own) and reports each one that has such an import. `hq doctor --fix`
10
+ * rewrites those import paths with forward slashes (fix class
11
+ * `normalize-import-slashes`). The check itself only reads.
12
+ */
13
+ import type { CheckContext, CheckFamily, CheckResult } from "../types.js";
14
+ export declare const CLAUDE_IMPORTS_FAMILY_ID = "claude-imports";
15
+ export declare const CLAUDE_IMPORTS_CHECK_ID = "claude-imports.backslash-path";
16
+ /** The `hq install --global` block's import names a path that is not on disk. */
17
+ export declare const CLAUDE_IMPORTS_UNRESOLVED_CHECK_ID = "claude-imports.unresolved-hq-import";
18
+ /** File names `--fix` may rewrite for this check. */
19
+ export declare const CLAUDE_IMPORT_FILE_NAMES: readonly ["CLAUDE.md", "CLAUDE.local.md", "personal-context.md"];
20
+ export interface ClaudeImportsDeps {
21
+ /** The user's home directory. Default: `os.homedir()`. */
22
+ home?: string;
23
+ }
24
+ /** The CLAUDE.md files this family reads, in report order. */
25
+ export declare function claudeImportFiles(hqRoot: string, home: string): string[];
26
+ export declare function createClaudeImportsFamily(deps?: ClaudeImportsDeps): CheckFamily;
27
+ export declare const claudeImportsFamily: CheckFamily;
28
+ export declare function checkClaudeImports(context: CheckContext, deps?: ClaudeImportsDeps): CheckResult[];
29
+ //# sourceMappingURL=claude-imports.d.ts.map
@@ -0,0 +1,131 @@
1
+ /**
2
+ * `hq doctor` claude-imports family: CLAUDE.md `@import` paths written with
3
+ * backslashes (feedback_362cdca7).
4
+ *
5
+ * Claude Code skips an `@import` whose path contains a backslash and says
6
+ * nothing, so on Windows `@C:\Users\me\hq\.claude\CLAUDE.md` leaves every
7
+ * session without the HQ charter. This family reads the CLAUDE.md files HQ
8
+ * relies on (the user-scope file `hq install --global` writes, and the HQ
9
+ * tree's own) and reports each one that has such an import. `hq doctor --fix`
10
+ * rewrites those import paths with forward slashes (fix class
11
+ * `normalize-import-slashes`). The check itself only reads.
12
+ */
13
+ import * as fs from "node:fs";
14
+ import * as os from "node:os";
15
+ import * as path from "node:path";
16
+ import { findBackslashImports, findHqBlockImport } from "../../claude-md-imports.js";
17
+ export const CLAUDE_IMPORTS_FAMILY_ID = "claude-imports";
18
+ export const CLAUDE_IMPORTS_CHECK_ID = "claude-imports.backslash-path";
19
+ /** The `hq install --global` block's import names a path that is not on disk. */
20
+ export const CLAUDE_IMPORTS_UNRESOLVED_CHECK_ID = "claude-imports.unresolved-hq-import";
21
+ /** File names `--fix` may rewrite for this check. */
22
+ export const CLAUDE_IMPORT_FILE_NAMES = ["CLAUDE.md", "CLAUDE.local.md", "personal-context.md"];
23
+ /** The CLAUDE.md files this family reads, in report order. */
24
+ export function claudeImportFiles(hqRoot, home) {
25
+ const files = [path.join(home, ".claude", "CLAUDE.md")];
26
+ if (hqRoot) {
27
+ files.push(path.join(hqRoot, "CLAUDE.md"), path.join(hqRoot, "CLAUDE.local.md"), path.join(hqRoot, ".claude", "CLAUDE.md"), path.join(hqRoot, ".claude", "personal-context.md"), path.join(hqRoot, "personal", "CLAUDE.md"));
28
+ }
29
+ return [...new Set(files)];
30
+ }
31
+ export function createClaudeImportsFamily(deps = {}) {
32
+ return {
33
+ id: CLAUDE_IMPORTS_FAMILY_ID,
34
+ title: "CLAUDE.md imports",
35
+ run: (context) => Promise.resolve(checkClaudeImports(context, deps)),
36
+ };
37
+ }
38
+ export const claudeImportsFamily = createClaudeImportsFamily();
39
+ export function checkClaudeImports(context, deps = {}) {
40
+ const home = deps.home ?? os.homedir();
41
+ const results = [];
42
+ const userClaudeMd = path.join(home, ".claude", "CLAUDE.md");
43
+ let read = 0;
44
+ for (const file of claudeImportFiles(context.hqRoot, home)) {
45
+ let text;
46
+ try {
47
+ text = fs.readFileSync(file, "utf8");
48
+ }
49
+ catch {
50
+ continue; // Absent or unreadable: nothing Claude Code would import from it either.
51
+ }
52
+ read += 1;
53
+ const hits = findBackslashImports(text);
54
+ if (file === userClaudeMd) {
55
+ const unresolved = checkHqBlockImport(file, text, home, hits);
56
+ if (unresolved)
57
+ results.push(unresolved);
58
+ }
59
+ if (hits.length === 0)
60
+ continue;
61
+ const first = hits[0];
62
+ const more = hits.length > 1 ? ` and ${hits.length - 1} more` : "";
63
+ results.push({
64
+ status: "WARN",
65
+ checkId: CLAUDE_IMPORTS_CHECK_ID,
66
+ target: file,
67
+ message: `${file} line ${first.line}: @${first.path}${more}. Claude Code does not load an @import ` +
68
+ `written with backslashes, so this context never reaches the session.`,
69
+ details: { lines: hits.map((hit) => hit.line) },
70
+ remediation: "hq doctor --fix (rewrites those @import paths with forward slashes)",
71
+ });
72
+ }
73
+ if (results.length > 0)
74
+ return results;
75
+ if (read === 0) {
76
+ return [{ status: "NA", checkId: CLAUDE_IMPORTS_CHECK_ID, message: "No CLAUDE.md files to check." }];
77
+ }
78
+ return [
79
+ {
80
+ status: "PASS",
81
+ checkId: CLAUDE_IMPORTS_CHECK_ID,
82
+ message: `${read} CLAUDE.md file${read === 1 ? "" : "s"} checked; every @import path uses forward slashes.`,
83
+ },
84
+ ];
85
+ }
86
+ /** Whether `p` is an existing file (following links); false on any error. */
87
+ function isFile(p) {
88
+ try {
89
+ return fs.statSync(p).isFile();
90
+ }
91
+ catch {
92
+ return false;
93
+ }
94
+ }
95
+ /** Resolve an import path the way Claude Code does: `~/` from home, relative from the file's folder. */
96
+ function resolveImport(importPath, file, home) {
97
+ if (importPath.startsWith("~/"))
98
+ return path.join(home, importPath.slice(2));
99
+ if (path.isAbsolute(importPath))
100
+ return importPath;
101
+ return path.resolve(path.dirname(file), importPath);
102
+ }
103
+ /**
104
+ * The managed `hq install --global` block's import, read as Claude Code reads
105
+ * it. WARN when that path is not on disk, for example
106
+ * `@C:/Users/John Smith/hq/.claude/CLAUDE.md`, which Claude Code reads as
107
+ * `C:/Users/John`. Skipped when the line already has a backslash finding:
108
+ * that repair runs first and this check looks again afterwards.
109
+ */
110
+ function checkHqBlockImport(file, text, home, hits) {
111
+ const found = findHqBlockImport(text);
112
+ if (!found || hits.some((hit) => hit.line === found.line))
113
+ return null;
114
+ // A file, not just any path: a cut-short `C:/Users/John` is often a real folder.
115
+ if (found.claudePath && isFile(resolveImport(found.claudePath, file, home)))
116
+ return null;
117
+ const repairable = found.intendedPath !== "" && isFile(resolveImport(found.intendedPath, file, home));
118
+ return {
119
+ status: "WARN",
120
+ checkId: CLAUDE_IMPORTS_UNRESOLVED_CHECK_ID,
121
+ target: file,
122
+ message: `${file} line ${found.line}: Claude Code reads the HQ import as @${found.claudePath || "(empty)"}, which does not exist, ` +
123
+ `so the HQ charter never reaches sessions outside HQ.` +
124
+ (repairable ? ` The full path ${found.intendedPath} exists.` : ` ${found.intendedPath || "The import"} does not exist either.`),
125
+ details: { line: found.line, repairable },
126
+ remediation: repairable
127
+ ? "hq doctor --fix (rewrites the HQ import with forward slashes and escaped spaces)"
128
+ : "Run `hq install --global --runtime claude` from your HQ root to rewrite the HQ import.",
129
+ };
130
+ }
131
+ //# sourceMappingURL=claude-imports.js.map
@@ -380,6 +380,13 @@ export declare function defaultRewriteBotNodePath(name: string): {
380
380
  from: string;
381
381
  to: string;
382
382
  } | null;
383
+ /**
384
+ * Post-fix status of one file-targeted finding: the re-run result for this
385
+ * check id and target, else PASS when the re-run produced results for the
386
+ * family but none for this target (the file no longer has the finding), else
387
+ * null. Another file that still has the finding never decides this one.
388
+ */
389
+ export declare function claudeImportStatusForTarget(results: CheckResult[], checkId: string, target: string, familyPrefix: string): DoctorStatus | null;
383
390
  /** Default `remove-ps1-shims` repair: Windows only, a no-op elsewhere. */
384
391
  export declare function defaultRemovePs1Shims(dir: string): RemovePs1ShimsResult;
385
392
  /**
@@ -47,6 +47,10 @@ import { flattenFamilies } from "../report.js";
47
47
  import { STALE_RELEASE_LINK_COPY_PROBLEM, UNLISTABLE_RELEASE_LINK_PROBLEM, repairDanglingReleaseLinks, } from "../checks/release-links.js";
48
48
  import { parseHookGateProfiles, requiredMissingProfiles, } from "../hook-gate-profiles.js";
49
49
  import { createBackup } from "./backup.js";
50
+ import { escapeHqBlockImport, normalizeBackslashImports } from "../../claude-md-imports.js";
51
+ import { CLAUDE_IMPORTS_FAMILY_ID } from "../checks/claude-imports.js";
52
+ import { lineDiff } from "../../install/claude-targets.js";
53
+ import { atomicWrite } from "../../index-render/shared.js";
50
54
  import { removeStrayGateEntries } from "../stray-gate-entries.js";
51
55
  import { removeDuplicateHookRegistrations } from "../duplicate-hook-registrations.js";
52
56
  import { deriveRemediation } from "./remediation.js";
@@ -125,8 +129,12 @@ export async function applyFixes(options) {
125
129
  // Journal refreshes never write hook files. Allow them by class, not
126
130
  // only by empty relpath, so a personal-vault pull and a company pull
127
131
  // still run when SessionStart `--fix --yes` cannot pass `--force`.
132
+ // CLAUDE.md import rewrites never touch hook files either; an in-tree
133
+ // target is still backed up with its pass.
128
134
  const allowed = plans.filter((plan) => plan.fixClass === "refresh-sync" ||
129
135
  plan.fixClass === "refresh-manifest" ||
136
+ plan.fixClass === "normalize-import-slashes" ||
137
+ plan.fixClass === "escape-hq-import-path" ||
130
138
  plan.relpath.length === 0);
131
139
  if (allowed.length === plans.length)
132
140
  return plans;
@@ -911,6 +919,9 @@ function planFix(hqRoot, result, rem, refreshSync, rewriteBotNodePath = defaultR
911
919
  return planRefreshManifest(hqRoot, result, rem, refreshManifest);
912
920
  case "repair-release-link":
913
921
  return planRepairReleaseLink(hqRoot, result, rem);
922
+ case "normalize-import-slashes":
923
+ case "escape-hq-import-path":
924
+ return planClaudeImportRewrite(hqRoot, result, rem, rem.fixClass);
914
925
  default:
915
926
  return null;
916
927
  }
@@ -987,6 +998,72 @@ function planRemovePs1Shims(result, rem, remove) {
987
998
  failureReason: () => failure,
988
999
  };
989
1000
  }
1001
+ /** Check-id prefix shared by every claude-imports result. */
1002
+ const CLAUDE_IMPORTS_FAMILY_PREFIX = `${CLAUDE_IMPORTS_FAMILY_ID}.`;
1003
+ /**
1004
+ * Post-fix status of one file-targeted finding: the re-run result for this
1005
+ * check id and target, else PASS when the re-run produced results for the
1006
+ * family but none for this target (the file no longer has the finding), else
1007
+ * null. Another file that still has the finding never decides this one.
1008
+ */
1009
+ export function claudeImportStatusForTarget(results, checkId, target, familyPrefix) {
1010
+ const own = results.find((entry) => entry.checkId === checkId && entry.target === target);
1011
+ if (own)
1012
+ return own.status;
1013
+ return results.some((entry) => entry.checkId.startsWith(familyPrefix)) ? "PASS" : null;
1014
+ }
1015
+ /**
1016
+ * Rewrite a CLAUDE.md file's dead `@import` paths (feedback_362cdca7):
1017
+ * `normalize-import-slashes` turns path backslashes into forward slashes
1018
+ * (escaped spaces stay); `escape-hq-import-path` rewrites only the import line
1019
+ * in the `hq install --global` block, with escaped spaces. A file inside the
1020
+ * HQ tree is backed up with the pass; the user-scope `~/.claude/CLAUDE.md` is
1021
+ * outside it, so the preview shows every line that changes. A symlinked file
1022
+ * is written through its link.
1023
+ */
1024
+ function planClaudeImportRewrite(hqRoot, result, rem, fixClass) {
1025
+ const file = rem.fixTarget;
1026
+ if (!file || !path.isAbsolute(file))
1027
+ return null;
1028
+ const rewrite = fixClass === "normalize-import-slashes" ? normalizeBackslashImports : escapeHqBlockImport;
1029
+ let before;
1030
+ try {
1031
+ before = fs.readFileSync(file, "utf8");
1032
+ }
1033
+ catch {
1034
+ return null;
1035
+ }
1036
+ const after = rewrite(before);
1037
+ if (after === before)
1038
+ return null;
1039
+ const rel = path.relative(hqRoot, file);
1040
+ const inTree = rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel);
1041
+ const diff = lineDiff(before, after, 0)
1042
+ .split("\n")
1043
+ .map((line) => ` ${line}`)
1044
+ .join("\n");
1045
+ const scope = fixClass === "normalize-import-slashes"
1046
+ ? "only the backslashes in these @import paths change"
1047
+ : "only the HQ import line inside the hq install block changes";
1048
+ return {
1049
+ checkId: result.checkId,
1050
+ fixClass,
1051
+ target: file,
1052
+ relpath: inTree ? rel : "",
1053
+ preview: ` ${file}\n${diff}\n ${scope}`,
1054
+ summary: fixClass === "normalize-import-slashes"
1055
+ ? `rewrite @import paths in ${file} with forward slashes`
1056
+ : `rewrite the HQ import in ${file} with escaped spaces`,
1057
+ apply: () => {
1058
+ const real = fs.realpathSync(file);
1059
+ const current = fs.readFileSync(real, "utf8");
1060
+ const next = rewrite(current);
1061
+ if (next !== current)
1062
+ atomicWrite(real, next);
1063
+ },
1064
+ postStatus: (results) => claudeImportStatusForTarget(results, result.checkId, file, CLAUDE_IMPORTS_FAMILY_PREFIX),
1065
+ };
1066
+ }
990
1067
  /** Default `remove-ps1-shims` repair: Windows only, a no-op elsewhere. */
991
1068
  export function defaultRemovePs1Shims(dir) {
992
1069
  if (process.platform !== "win32")
@@ -50,6 +50,16 @@
50
50
  * entry is removed. Only a link that does not resolve
51
51
  * is touched; a real file or folder never is, and the
52
52
  * link is removed without following it.
53
+ * - `normalize-import-slashes` — rewrite the backslashes in a CLAUDE.md
54
+ * `@import` path as forward slashes. Claude Code never
55
+ * loads a backslash import, so the rewrite only makes
56
+ * a dead import load; no other byte of the file changes
57
+ * (feedback_362cdca7). An escaped space (`\ `) stays.
58
+ * - `escape-hq-import-path` — rewrite the one import line inside the
59
+ * `hq install --global` block of ~/.claude/CLAUDE.md
60
+ * with forward slashes and escaped spaces, when Claude
61
+ * Code reads it as a missing path but the full path
62
+ * exists. Nothing outside that block changes.
53
63
  *
54
64
  * EVERYTHING else — content drift between platform copies, a missing script, a
55
65
  * missing Codex counterpart, an unquoted `$CLAUDE_PROJECT_DIR`, a stale
@@ -61,7 +71,7 @@
61
71
  */
62
72
  import type { CheckResult } from "../types.js";
63
73
  /** The allowlisted safe repair classes `--fix` is permitted to apply. */
64
- export type FixClass = "executable-bit" | "gate-profile" | "remove-stray-gate-entries" | "remove-duplicate-hook-registrations" | "refresh-sync" | "refresh-manifest" | "bot-node-path" | "bot-hq-binary" | "remove-ps1-shims" | "repair-release-link";
74
+ export type FixClass = "executable-bit" | "gate-profile" | "remove-stray-gate-entries" | "remove-duplicate-hook-registrations" | "refresh-sync" | "refresh-manifest" | "bot-node-path" | "bot-hq-binary" | "remove-ps1-shims" | "repair-release-link" | "normalize-import-slashes" | "escape-hq-import-path";
65
75
  /**
66
76
  * A finding's structured remediation. `autoFixable`, `action`, and `command`
67
77
  * are the `--json` surface (AC1); `fixTarget`/`fixClass` are the internal handle
@@ -50,6 +50,16 @@
50
50
  * entry is removed. Only a link that does not resolve
51
51
  * is touched; a real file or folder never is, and the
52
52
  * link is removed without following it.
53
+ * - `normalize-import-slashes` — rewrite the backslashes in a CLAUDE.md
54
+ * `@import` path as forward slashes. Claude Code never
55
+ * loads a backslash import, so the rewrite only makes
56
+ * a dead import load; no other byte of the file changes
57
+ * (feedback_362cdca7). An escaped space (`\ `) stays.
58
+ * - `escape-hq-import-path` — rewrite the one import line inside the
59
+ * `hq install --global` block of ~/.claude/CLAUDE.md
60
+ * with forward slashes and escaped spaces, when Claude
61
+ * Code reads it as a missing path but the full path
62
+ * exists. Nothing outside that block changes.
53
63
  *
54
64
  * EVERYTHING else — content drift between platform copies, a missing script, a
55
65
  * missing Codex counterpart, an unquoted `$CLAUDE_PROJECT_DIR`, a stale
@@ -62,6 +72,7 @@
62
72
  import * as path from "node:path";
63
73
  import { REPAIRABLE_RELEASE_LINK_PROBLEMS, STALE_RELEASE_LINK_COPY_PROBLEM, UNLISTABLE_RELEASE_LINK_PROBLEM, RELEASE_LINKS, RELEASE_LINKS_CHECK_ID, } from "../checks/release-links.js";
64
74
  import { isCompanyJournalSlug, isSafeCompanySlug, isPersonalJournalSlug, journalSlugFromCheckId, } from "../checks/sync-health.js";
75
+ import { CLAUDE_IMPORTS_CHECK_ID, CLAUDE_IMPORTS_UNRESOLVED_CHECK_ID, CLAUDE_IMPORT_FILE_NAMES, } from "../checks/claude-imports.js";
65
76
  /** Matches an exec-bit remediation command, quoted or not: `chmod +x <path>`. */
66
77
  const CHMOD_EXEC = /^chmod\s+\+x\s+(.+)$/;
67
78
  /**
@@ -212,6 +223,37 @@ export function deriveRemediation(result) {
212
223
  command: "hq doctor --fix",
213
224
  };
214
225
  }
226
+ // normalize-import-slashes — a CLAUDE.md @import written with backslashes,
227
+ // which Claude Code never loads (feedback_362cdca7). Only the file names the
228
+ // check reads are eligible.
229
+ if (checkId === CLAUDE_IMPORTS_CHECK_ID &&
230
+ result.status === "WARN" &&
231
+ target &&
232
+ CLAUDE_IMPORT_FILE_NAMES.includes(path.basename(target))) {
233
+ return {
234
+ autoFixable: true,
235
+ fixClass: "normalize-import-slashes",
236
+ fixTarget: target,
237
+ action: `Rewrite the @import paths in ${target} with forward slashes so Claude Code loads them.`,
238
+ command: "hq doctor --fix",
239
+ };
240
+ }
241
+ // escape-hq-import-path — the `hq install --global` block's import names a
242
+ // path Claude Code cannot find (an unescaped space cuts it short), and the
243
+ // full path exists. Only ~/.claude/CLAUDE.md carries that block.
244
+ if (checkId === CLAUDE_IMPORTS_UNRESOLVED_CHECK_ID &&
245
+ result.status === "WARN" &&
246
+ target &&
247
+ path.basename(target) === "CLAUDE.md" &&
248
+ result.details?.repairable === true) {
249
+ return {
250
+ autoFixable: true,
251
+ fixClass: "escape-hq-import-path",
252
+ fixTarget: target,
253
+ action: `Rewrite the HQ import in ${target} with forward slashes and escaped spaces so Claude Code reads the whole path.`,
254
+ command: "hq doctor --fix",
255
+ };
256
+ }
215
257
  // Available hq-core upgrade. WARN is intentional in `hq doctor` and is
216
258
  // not a broken sync; --fix has no mechanical repair for it.
217
259
  if (checkId === "sync.update.core") {
@@ -30,6 +30,7 @@ import { strandedLanesFamily } from "./checks/stranded-lanes.js";
30
30
  import { releaseLinksFamily } from "./checks/release-links.js";
31
31
  import { cliPathFamily } from "./checks/cli-path.js";
32
32
  import { ps1ShimsFamily } from "./checks/ps1-shims.js";
33
+ import { claudeImportsFamily } from "./checks/claude-imports.js";
33
34
  import { tempHomesFamily } from "./checks/temp-homes.js";
34
35
  import { replayRecorderFamily } from "./checks/replay-recorder.js";
35
36
  import { machineChecksFamily } from "./checks/machine-checks.js";
@@ -288,6 +289,9 @@ export function createDefaultRegistry() {
288
289
  // find hq. Registry read only; prints the fix, never edits PATH.
289
290
  registry.register(cliPathFamily);
290
291
  registry.register(ps1ShimsFamily);
292
+ // CLAUDE.md @import paths written with backslashes, which Claude Code never
293
+ // loads (feedback_362cdca7). Reads only; --fix rewrites the slashes.
294
+ registry.register(claudeImportsFamily);
291
295
  // Idle tmp.* throwaway homes holding a Rust toolchain download. Dry-run
292
296
  // scan only; `hq doctor --sweep-temp-homes` is the delete path.
293
297
  registry.register(tempHomesFamily);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.345.242",
3
+ "version": "5.345.243",
4
4
  "description": "HQ by Indigo management CLI — modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -126,11 +126,11 @@
126
126
  "*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
127
127
  },
128
128
  "optionalDependencies": {
129
- "@indigoai-us/hq-hook-win32-x64": "5.345.242",
130
- "@indigoai-us/hq-hook-win32-arm64": "5.345.242",
131
- "@indigoai-us/hq-hook-darwin-x64": "5.345.242",
132
- "@indigoai-us/hq-hook-darwin-arm64": "5.345.242",
133
- "@indigoai-us/hq-hook-linux-x64": "5.345.242",
134
- "@indigoai-us/hq-hook-linux-arm64": "5.345.242"
129
+ "@indigoai-us/hq-hook-win32-x64": "5.345.243",
130
+ "@indigoai-us/hq-hook-win32-arm64": "5.345.243",
131
+ "@indigoai-us/hq-hook-darwin-x64": "5.345.243",
132
+ "@indigoai-us/hq-hook-darwin-arm64": "5.345.243",
133
+ "@indigoai-us/hq-hook-linux-x64": "5.345.243",
134
+ "@indigoai-us/hq-hook-linux-arm64": "5.345.243"
135
135
  }
136
136
  }