@indigoai-us/hq-cli 5.345.241 → 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.
Files changed (125) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/assets/scaffold/core/scripts/hq-delegate-grant.sh +170 -8
  3. package/assets/scaffold/core/scripts/hq-delegate-publish.sh +21 -1
  4. package/assets/scaffold/core/scripts/lib/delegate-engine.sh +77 -0
  5. package/dist/command-catalog.generated.d.ts +28 -8
  6. package/dist/command-catalog.generated.js +33 -8
  7. package/dist/commands/cloud-off-gate.d.ts +7 -7
  8. package/dist/commands/cloud-off-gate.js +26 -38
  9. package/dist/commands/core-delegate-w1b.js +307 -26
  10. package/dist/commands/core-delegate.js +2 -0
  11. package/dist/commands/core-handoff.js +1 -1
  12. package/dist/commands/core-job-model-auth.d.ts +95 -0
  13. package/dist/commands/core-job-model-auth.js +247 -0
  14. package/dist/commands/core-job-run-native.js +280 -12
  15. package/dist/commands/core.js +1 -0
  16. package/dist/commands/files-browse.js +2 -0
  17. package/dist/commands/files.js +4 -0
  18. package/dist/commands/integrations-core.d.ts +11 -0
  19. package/dist/commands/integrations-core.js +15 -1
  20. package/dist/commands/lanes-link.js +2 -2
  21. package/dist/commands/lanes-loop.d.ts +2 -2
  22. package/dist/commands/lanes-loop.js +5 -5
  23. package/dist/commands/lanes-questions.js +1 -1
  24. package/dist/commands/lanes-stories.js +1 -1
  25. package/dist/commands/lanes.js +80 -14
  26. package/dist/commands/rescue.d.ts +3 -2
  27. package/dist/commands/rescue.js +48 -34
  28. package/dist/commands/search.d.ts +6 -0
  29. package/dist/commands/search.js +24 -4
  30. package/dist/commands/sources.js +6 -2
  31. package/dist/commands/sync-core.d.ts +8 -0
  32. package/dist/commands/sync-core.js +43 -0
  33. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +1737 -1450
  34. package/dist/hq-cloud-sync-runner/package.json +1 -1
  35. package/dist/lib/capacity/accounts.d.ts +1 -1
  36. package/dist/lib/capacity/accounts.js +1 -1
  37. package/dist/lib/capacity/freshness.d.ts +1 -1
  38. package/dist/lib/capacity/freshness.js +1 -1
  39. package/dist/lib/capacity/route.js +1 -1
  40. package/dist/lib/claude-md-imports.d.ts +52 -0
  41. package/dist/lib/claude-md-imports.js +226 -0
  42. package/dist/lib/daemon/catalog.d.ts +3 -0
  43. package/dist/lib/daemon/hook-requests.d.ts +1 -1
  44. package/dist/lib/daemon/hook-requests.js +4 -2
  45. package/dist/lib/daemon/run.js +16 -22
  46. package/dist/lib/doctor/checks/claude-imports.d.ts +29 -0
  47. package/dist/lib/doctor/checks/claude-imports.js +131 -0
  48. package/dist/lib/doctor/fix/apply.d.ts +7 -0
  49. package/dist/lib/doctor/fix/apply.js +77 -0
  50. package/dist/lib/doctor/fix/remediation.d.ts +11 -1
  51. package/dist/lib/doctor/fix/remediation.js +42 -0
  52. package/dist/lib/doctor/registry.js +4 -0
  53. package/dist/lib/environment/work-requirements.d.ts +1 -1
  54. package/dist/lib/environment/work-requirements.js +1 -1
  55. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  56. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  57. package/dist/lib/hook-engine/coverage.js +11 -3
  58. package/dist/lib/hook-engine/git-stop-config.json +510 -510
  59. package/dist/lib/hook-engine/native-precompact-compatibility.json +443 -443
  60. package/dist/lib/hook-engine/native-stop-compatibility.json +359 -359
  61. package/dist/lib/hot-channels/adapters/meetings.d.ts +1 -16
  62. package/dist/lib/hot-channels/adapters/meetings.js +3 -28
  63. package/dist/lib/hot-channels/adapters/slack.d.ts +3 -1
  64. package/dist/lib/hot-channels/adapters/slack.js +4 -1
  65. package/dist/lib/hot-channels/contract.d.ts +14 -0
  66. package/dist/lib/hot-channels/fleet-complete.d.ts +18 -2
  67. package/dist/lib/hot-channels/fleet-complete.js +29 -4
  68. package/dist/lib/hot-channels/meeting-source-ref.d.ts +17 -0
  69. package/dist/lib/hot-channels/meeting-source-ref.js +32 -0
  70. package/dist/lib/hot-channels/prompts/signals-pass.md +6 -1
  71. package/dist/lib/hot-channels/run.d.ts +10 -0
  72. package/dist/lib/hot-channels/run.js +34 -0
  73. package/dist/lib/hot-channels/signals-pass.d.ts +27 -0
  74. package/dist/lib/hot-channels/signals-pass.js +57 -2
  75. package/dist/lib/hot-channels/signals-runtime.js +3 -2
  76. package/dist/lib/lanes/accounts.js +2 -2
  77. package/dist/lib/lanes/claude-balance.d.ts +6 -0
  78. package/dist/lib/lanes/claude-balance.js +124 -0
  79. package/dist/lib/lanes/grants.js +15 -2
  80. package/dist/lib/lanes/hq-root.d.ts +1 -1
  81. package/dist/lib/lanes/hq-root.js +1 -1
  82. package/dist/lib/lanes/links.d.ts +1 -1
  83. package/dist/lib/lanes/liveness.d.ts +3 -0
  84. package/dist/lib/lanes/liveness.js +61 -7
  85. package/dist/lib/lanes/models.d.ts +1 -1
  86. package/dist/lib/lanes/models.js +1 -1
  87. package/dist/lib/lanes/questions.d.ts +1 -1
  88. package/dist/lib/lanes/questions.js +2 -2
  89. package/dist/lib/lanes/spawn.js +4 -6
  90. package/dist/lib/lanes/store.d.ts +13 -2
  91. package/dist/lib/lanes/store.js +13 -5
  92. package/dist/lib/lanes/types.d.ts +7 -7
  93. package/dist/lib/lanes/types.js +1 -1
  94. package/dist/lib/lanes/watcher-main.js +1 -1
  95. package/dist/lib/lanes/watcher.d.ts +1 -1
  96. package/dist/lib/lanes/watcher.js +1 -1
  97. package/dist/lib/onboarding/cli/onboard.js +5 -0
  98. package/dist/lib/signals/sanitize.d.ts +19 -0
  99. package/dist/lib/signals/sanitize.js +103 -7
  100. package/dist/lib/signals/steps/upload.d.ts +40 -1
  101. package/dist/lib/signals/steps/upload.js +122 -6
  102. package/dist/lib/sync-core/access-refresh.d.ts +29 -0
  103. package/dist/lib/sync-core/access-refresh.js +97 -0
  104. package/dist/lib/sync-core/company-adoption.d.ts +33 -0
  105. package/dist/lib/sync-core/company-adoption.js +223 -0
  106. package/dist/lib/sync-core/engine-home.d.ts +1 -0
  107. package/dist/lib/sync-core/engine-owned.d.ts +13 -0
  108. package/dist/lib/sync-core/engine-owned.js +38 -0
  109. package/dist/lib/sync-core/hand-back.d.ts +17 -0
  110. package/dist/lib/sync-core/hand-back.js +23 -0
  111. package/dist/lib/sync-core/post-apply-reindex.d.ts +33 -0
  112. package/dist/lib/sync-core/post-apply-reindex.js +149 -0
  113. package/dist/lib/sync-core/reconcile.d.ts +10 -0
  114. package/dist/lib/sync-core/reconcile.js +117 -12
  115. package/dist/lib/sync-core/rollout-state.d.ts +2 -0
  116. package/dist/lib/sync-core/rollout-state.js +6 -0
  117. package/dist/lib/vault-sync-switches.d.ts +14 -0
  118. package/dist/lib/vault-sync-switches.js +22 -0
  119. package/dist/lib/workers-registry/index.d.ts +1 -1
  120. package/dist/lib/workers-registry/index.js +1 -1
  121. package/dist/utils/github-tag-fallback.d.ts +16 -0
  122. package/dist/utils/github-tag-fallback.js +126 -0
  123. package/dist/utils/version-report.d.ts +2 -1
  124. package/dist/utils/version-report.js +40 -27
  125. package/package.json +8 -8
@@ -1 +1 @@
1
- {"name":"hq-cli-daemon-sync-runner","type":"module","version":"6.18.117","bundleSha256":"425e7b51afda9223d469b19d2a657cd4ea6af5c2c0bbd1354b837dc682faecfc","formatVersion":1}
1
+ {"name":"hq-cli-daemon-sync-runner","type":"module","version":"6.18.118","bundleSha256":"7f7e31221249ffacdaee78e883c2d2e761d189b251d6cb8b57824e97ee185d2f","formatVersion":1}
@@ -23,7 +23,7 @@ export interface CapacityAccount {
23
23
  * `disabled_reason` that marks a registry account as capacity-only. Signing in
24
24
  * for usage visibility must not opt an account into lane work, because lanes
25
25
  * spread work across every enabled account and the accounts can belong to
26
- * different companies. `hq lanes accounts enable` opts one in.
26
+ * different companies. `hq runners accounts enable` opts one in.
27
27
  */
28
28
  export declare const CAPACITY_ONLY_REASON = "capacity-only: read for usage, not used by lanes";
29
29
  export interface ListCapacityAccountsOptions {
@@ -17,7 +17,7 @@ import { LANE_PROVIDERS } from "../lanes/types.js";
17
17
  * `disabled_reason` that marks a registry account as capacity-only. Signing in
18
18
  * for usage visibility must not opt an account into lane work, because lanes
19
19
  * spread work across every enabled account and the accounts can belong to
20
- * different companies. `hq lanes accounts enable` opts one in.
20
+ * different companies. `hq runners accounts enable` opts one in.
21
21
  */
22
22
  export const CAPACITY_ONLY_REASON = "capacity-only: read for usage, not used by lanes";
23
23
  const DEFAULT_DIR = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Capacity view freshness. Kept in lib (not commands/capacity.ts) so resident
3
- * paths such as `hq lanes` can check staleness without pulling in the capacity
3
+ * paths such as `hq runners` can check staleness without pulling in the capacity
4
4
  * command module and its lazy collector imports.
5
5
  */
6
6
  /** now.json older than this is stale: the collector is not keeping the view current. */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Capacity view freshness. Kept in lib (not commands/capacity.ts) so resident
3
- * paths such as `hq lanes` can check staleness without pulling in the capacity
3
+ * paths such as `hq runners` can check staleness without pulling in the capacity
4
4
  * command module and its lazy collector imports.
5
5
  */
6
6
  /** now.json older than this is stale: the collector is not keeping the view current. */
@@ -1,6 +1,6 @@
1
1
  import { codexSnapshotStale, hasCodexCreditRoom } from "./codex-availability.js";
2
2
  /**
3
- * Pure router for `hq capacity route` and `hq lanes create --account auto`.
3
+ * Pure router for `hq capacity route` and `hq runners create --account auto`.
4
4
  *
5
5
  * Port of personal/skills/boss-mode/boss-route.mjs into hq-cli. Owner decision
6
6
  * 2026-10-11: all accounts are one pool across companies; the pick names the
@@ -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
@@ -12,6 +12,7 @@
12
12
  import type { MachineType } from "./machine-type.js";
13
13
  import type { SyncOwner, DaemonConfig } from "./config.js";
14
14
  import { type SyncCoreVaultPlan } from "../sync-core/engine-home.js";
15
+ import type { HandBackVault } from "../sync-core/hand-back.js";
15
16
  import type { RemoteControlPoolsConfig } from "./remote-control-pools.js";
16
17
  import { type SyncRunnerProcess } from "./sync-runner.js";
17
18
  import { type VaultSyncSwitches } from "../vault-sync-switches.js";
@@ -187,6 +188,8 @@ export interface PlanContext {
187
188
  /** Persisted/effective owner selected for this machine. */
188
189
  syncOwner: SyncOwner;
189
190
  syncCoreVaults?: readonly SyncCoreVaultPlan[];
191
+ /** Full vaults leaving the engine (rollout.json handingBack), returned to the current sync once their engine has stopped. */
192
+ syncCoreHandingBack?: readonly HandBackVault[];
190
193
  syncCoreRunning?: SyncCoreRunning;
191
194
  legacySyncReadyForCore?: boolean;
192
195
  legacySyncHolder?: LegacySyncHolder;
@@ -89,7 +89,7 @@ export type HookOperation = {
89
89
  * adapter's payload is the note's `.body` file (`host::fleet_settings`). */
90
90
  | {
91
91
  kind: "fleet-local-settings";
92
- event: "PostToolUse" | "SessionEnd";
92
+ event: "PostToolUse" | "SessionEnd" | "SubagentStop";
93
93
  commands: FleetLocalSettingsCommand[];
94
94
  }
95
95
  /** The Work Mesh register step of a mid-session company bind (`spawn_work_mesh_register`, owner decision 36). */
@@ -332,11 +332,13 @@ export function parseHookRequest(text, stem) {
332
332
  }
333
333
  return { stem, id: value.id, at, root: value.hqRoot, session: value.session, operation };
334
334
  }
335
- /** The args of a `fleet-local-settings` note: exactly `event` (PostToolUse or SessionEnd) and 1 to 64 typed commands. */
335
+ /** The args of a `fleet-local-settings` note: exactly `event` (PostToolUse, SessionEnd or SubagentStop) and 1 to 64 typed commands. */
336
336
  function parseFleetLocalSettings(args) {
337
337
  const keys = Object.keys(args).sort();
338
338
  const event = args.event;
339
- if (keys.length !== 2 || keys[0] !== "commands" || keys[1] !== "event" || (event !== "PostToolUse" && event !== "SessionEnd"))
339
+ if (keys.length !== 2 || keys[0] !== "commands" || keys[1] !== "event")
340
+ return undefined;
341
+ if (event !== "PostToolUse" && event !== "SessionEnd" && event !== "SubagentStop")
340
342
  return undefined;
341
343
  const list = args.commands;
342
344
  if (!Array.isArray(list) || list.length === 0 || list.length > FLEET_LOCAL_SETTINGS_MAX_COMMANDS)
@@ -30,9 +30,10 @@ import { createLegacyHandover, LEGACY_HANDOVER_STUCK_FILE, writeLegacyHandoverSt
30
30
  import { effectiveSyncOwner, readDaemonConfig } from "./config.js";
31
31
  import { backgroundQosCommand } from "./background-qos.js";
32
32
  import { serveQmdWorker } from "../search-index/worker-process.js";
33
- import { inspectEngineHome } from "../sync-core/engine-home.js";
33
+ import { inspectEngineHome, syncCoreUnitId } from "../sync-core/engine-home.js";
34
34
  import { fullModeHold } from "../sync-core/reconcile.js";
35
35
  import { engineVaultCount, readSyncCoreRolloutState } from "../sync-core/rollout-state.js";
36
+ import { engineOwnsVault, finishLegacyHandBack } from "../sync-core/hand-back.js";
36
37
  import { effectiveEngineSettings, readSyncCoreVaultSettings } from "../sync-core/vault-settings.js";
37
38
  import { assertPersonalServiceSessionCapability, readRemoteControlPoolsConfig, remoteControlPoolSecretsEnv, } from "./remote-control-pools.js";
38
39
  import { loadLanesConfig } from "../lanes/config.js";
@@ -48,7 +49,7 @@ import { createLanesReconcileWatcher } from "./lanes-reconcile-watcher.js";
48
49
  import { createLanesReconcileStatus, withLanesReconcileUnit } from "./lanes-reconcile-status.js";
49
50
  import { findLegacyUnits, legacyMeshUnitsToRetire, legacyOwnerLookup, } from "./legacy.js";
50
51
  import { readLegacySyncEnv } from "./legacy-sync-env.js";
51
- import { readVaultSwitchOnTimes, readVaultSyncSwitches, unreadableSwitchesWarning, writeVaultSyncSwitches } from "../vault-sync-switches.js";
52
+ import { legacySwitchRestorePatch, readVaultSwitchOnTimes, readVaultSyncSwitches, unreadableSwitchesWarning } from "../vault-sync-switches.js";
52
53
  import { scheduleDaemonPlistRefresh } from "./plist-refresh.js";
53
54
  import { acquireDaemonLock, isProcessAlive, processCommandLine, releaseDaemonLock } from "./lock.js";
54
55
  import { retireLegacyMeshUnits } from "./migrate.js";
@@ -108,6 +109,7 @@ export function syncCoreVaultPlans(home, hqRoot, platform) {
108
109
  binaryPath: state.binaryPath,
109
110
  release: state.release,
110
111
  ...(vault.legacyOffSince ? { legacyOffSince: vault.legacyOffSince } : {}),
112
+ ...(vault.legacyAlreadyOff ? { legacyAlreadyOff: true } : {}),
111
113
  ...(effective ? { settings: effective } : {}),
112
114
  }, platform);
113
115
  const releaseHold = vault.phase === "full" ? fullModeHold(vault, state.release, platform) : undefined;
@@ -140,27 +142,18 @@ export function planUnitsWithSyncCoreInterlock(services, context, supervisor, re
140
142
  if (context.vaultSync && !context.vaultSync.allOff) {
141
143
  let personalOff = context.vaultSync.personalOff;
142
144
  const offCompanies = new Set(context.vaultSync.offCompanies);
143
- let restorePersonal = false;
144
- const restoreCompanies = {};
145
- for (const vault of context.syncCoreVaults ?? []) {
146
- if (vault.phase !== "full" || runningVaults.has(vault.uid) || !fullModeHold(vault, vault.release, context.platform))
147
- continue;
148
- if (vault.kind === "personal") {
149
- restorePersonal = personalOff;
150
- personalOff = false;
151
- }
152
- else if (vault.slug) {
153
- if (offCompanies.has(vault.slug))
154
- restoreCompanies[vault.slug] = true;
155
- offCompanies.delete(vault.slug);
156
- }
157
- }
158
- if (restorePersonal || Object.keys(restoreCompanies).length > 0) {
145
+ const engineStopped = (uid) => !!supervisor && supervisor.runningPlanKey(syncCoreUnitId(uid)) === undefined;
146
+ const held = (context.syncCoreVaults ?? []).filter((vault) => vault.phase === "full" && engineStopped(vault.uid) && fullModeHold(vault, vault.release, context.platform));
147
+ const handingBack = (context.syncCoreHandingBack ?? []).filter((vault) => engineStopped(vault.uid) && engineOwnsVault(context.home, vault.uid));
148
+ const handBack = [...held, ...handingBack];
149
+ const restore = legacySwitchRestorePatch(handBack, context.vaultSync);
150
+ if (restore.personal)
151
+ personalOff = false;
152
+ for (const slug of Object.keys(restore.companies))
153
+ offCompanies.delete(slug);
154
+ if (handBack.length > 0) {
159
155
  try {
160
- writeVaultSyncSwitches(context.home, {
161
- ...(restorePersonal ? { personal: true } : {}),
162
- companies: restoreCompanies,
163
- });
156
+ finishLegacyHandBack(context.home, handBack, context.vaultSync);
164
157
  }
165
158
  catch {
166
159
  fallbackPersistenceFailed = true;
@@ -1616,6 +1609,7 @@ export async function runDaemon(opts) {
1616
1609
  })(),
1617
1610
  syncOwner,
1618
1611
  syncCoreVaults: syncCoreVaultPlans(home, hqRoot, platform),
1612
+ syncCoreHandingBack: readSyncCoreRolloutState(home)?.handingBack ?? [],
1619
1613
  desktopAppManagesSync: appManagesSync,
1620
1614
  legacySyncUnitManagesSync: legacy.some((u) => u.service === "sync" && !u.migratable),
1621
1615
  syncRunnerProcesses,
@@ -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
  /**