@indigoai-us/hq-cli 5.345.242 → 5.345.244
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 +13 -0
- package/dist/command-catalog.generated.d.ts +3 -3
- package/dist/command-catalog.generated.js +3 -3
- package/dist/commands/bot.d.ts +12 -0
- package/dist/commands/bot.js +126 -44
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +285 -225
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/bot/config.d.ts +10 -0
- package/dist/lib/bot/config.js +15 -0
- package/dist/lib/bot/continuity.js +2 -2
- package/dist/lib/bot/promote-sign-in.d.ts +78 -0
- package/dist/lib/bot/promote-sign-in.js +152 -0
- package/dist/lib/bot/promote.d.ts +19 -1
- package/dist/lib/bot/promote.js +25 -5
- package/dist/lib/bot/scaffold.d.ts +20 -3
- package/dist/lib/bot/scaffold.js +18 -8
- package/dist/lib/claude-md-imports.d.ts +52 -0
- package/dist/lib/claude-md-imports.js +226 -0
- package/dist/lib/daemon/hook-requests-fleet-session-start.d.ts +10 -0
- package/dist/lib/daemon/hook-requests-fleet-session-start.js +86 -42
- package/dist/lib/daemon/hook-requests.d.ts +2 -2
- package/dist/lib/daemon/hook-requests.js +13 -3
- package/dist/lib/doctor/checks/claude-imports.d.ts +29 -0
- package/dist/lib/doctor/checks/claude-imports.js +131 -0
- package/dist/lib/doctor/fix/apply.d.ts +7 -0
- package/dist/lib/doctor/fix/apply.js +77 -0
- package/dist/lib/doctor/fix/remediation.d.ts +11 -1
- package/dist/lib/doctor/fix/remediation.js +42 -0
- package/dist/lib/doctor/registry.js +4 -0
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/lanes/liveness.js +46 -16
- package/package.json +8 -8
|
@@ -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);
|