@indigoai-us/hq-cli 5.345.221 → 5.345.222

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 (64) hide show
  1. package/CHANGELOG.md +47 -1
  2. package/dist/command-catalog.generated.d.ts +31 -0
  3. package/dist/command-catalog.generated.js +38 -0
  4. package/dist/commands/auth.js +2 -1
  5. package/dist/commands/core-delegate-w1b.js +9 -3
  6. package/dist/commands/daemon.d.ts +1 -0
  7. package/dist/commands/daemon.js +15 -1
  8. package/dist/commands/link.d.ts +2 -0
  9. package/dist/commands/link.js +14 -2
  10. package/dist/commands/mesh.js +23 -3
  11. package/dist/commands/sync-core.d.ts +6 -0
  12. package/dist/commands/sync-core.js +55 -0
  13. package/dist/data/command-states.json +3 -0
  14. package/dist/lib/daemon/catalog.js +2 -0
  15. package/dist/lib/daemon/install.d.ts +2 -1
  16. package/dist/lib/daemon/install.js +9 -0
  17. package/dist/lib/daemon/legacy.d.ts +1 -0
  18. package/dist/lib/daemon/legacy.js +5 -2
  19. package/dist/lib/daemon/machine-check-owner.d.ts +2 -0
  20. package/dist/lib/daemon/machine-check-owner.js +6 -1
  21. package/dist/lib/daemon/machine-checks.d.ts +7 -1
  22. package/dist/lib/daemon/machine-checks.js +10 -1
  23. package/dist/lib/daemon/mesh-owner.d.ts +45 -0
  24. package/dist/lib/daemon/mesh-owner.js +166 -0
  25. package/dist/lib/daemon/native-notice-ledger.d.ts +27 -0
  26. package/dist/lib/daemon/native-notice-ledger.js +113 -0
  27. package/dist/lib/daemon/run.d.ts +15 -0
  28. package/dist/lib/daemon/run.js +71 -3
  29. package/dist/lib/daemon/selfcheck.d.ts +35 -2
  30. package/dist/lib/daemon/selfcheck.js +118 -9
  31. package/dist/lib/hook-engine/coverage.d.ts +9 -0
  32. package/dist/lib/hook-engine/coverage.js +56 -0
  33. package/dist/lib/hook-engine/native-stop-compatibility.json +56 -5
  34. package/dist/lib/mesh/live/daemon/config.d.ts +8 -1
  35. package/dist/lib/mesh/live/daemon/config.js +16 -0
  36. package/dist/lib/mesh/live/daemon/install.d.ts +31 -2
  37. package/dist/lib/mesh/live/daemon/install.js +142 -1
  38. package/dist/lib/mesh/live/daemon/login-home.d.ts +5 -0
  39. package/dist/lib/mesh/live/daemon/login-home.js +27 -0
  40. package/dist/lib/mesh/live/daemon/unit-home.d.ts +49 -0
  41. package/dist/lib/mesh/live/daemon/unit-home.js +134 -0
  42. package/dist/lib/registry/registry.d.ts +35 -7
  43. package/dist/lib/registry/registry.js +88 -13
  44. package/dist/lib/scan-packages/index.js +24 -2
  45. package/dist/lib/search-index/max-doc-bytes.js +2 -1
  46. package/dist/lib/service-manager/startup-migration.d.ts +1 -0
  47. package/dist/lib/service-manager/startup-migration.js +3 -0
  48. package/dist/lib/sync-core/engine-holds.d.ts +14 -0
  49. package/dist/lib/sync-core/engine-holds.js +60 -0
  50. package/dist/lib/sync-core/engine-home.d.ts +2 -0
  51. package/dist/lib/sync-core/reconcile.js +8 -0
  52. package/dist/lib/sync-core/vault-settings.d.ts +21 -0
  53. package/dist/lib/sync-core/vault-settings.js +131 -0
  54. package/dist/lib/windows/install-followup.d.ts +2 -0
  55. package/dist/lib/windows/install-followup.js +4 -1
  56. package/dist/utils/host-registration.js +3 -1
  57. package/dist/utils/pack-contributions.d.ts +3 -0
  58. package/dist/utils/pack-contributions.js +110 -23
  59. package/dist/utils/self-update.d.ts +3 -1
  60. package/dist/utils/self-update.js +56 -11
  61. package/dist/utils/update-lock.d.ts +151 -14
  62. package/dist/utils/update-lock.js +782 -46
  63. package/dist/utils/version-gate.js +12 -2
  64. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -2,6 +2,53 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [5.345.222] — 2026-11-16
6
+ - `hq packs uninstall` removes the namespaced `.claude/skills/<pack>:<skill>` host (symlink or empty reindex wrapper) and the uninstall rescan no longer adds unprefixed skill links next to those wrappers.
7
+
8
+ - The native `policy-enforcement-gate` in the new hook core (`hq-hook run`) no longer lets through two outbound calls the shell gate refuses. A Bash command sent as an argument list (for example `["bash","-c","hq dm <one person> ..."]`) is now also checked as the shell gate read it, as JSON text, so it is not treated as an exempt one-person `hq dm`. `HQ_NATIVE_POLICY_STATE_ROOT` in the hook's environment no longer moves the gate's session state to another folder, which had let an outbound send that lacked a required skill or brief through.
9
+ - Tests only, no change to `hq` behaviour: the environment profile's credential-shape scan is no longer checked against a one-second wall-clock limit for 1 MB, which failed on loaded CI runners under coverage although the scan is linear. The test now counts what the scan hands to the regular expression engine (every input at most 4097 characters, at most 16 characters per character of text) and checks that 32 times the text takes at most 128 times as long. The first check fails when an expression is run over the whole text, and the second fails when a loop outside the engine grows with the text.
10
+ - Machine-check findings are shown again on a machine whose HOME is reached through a link. `hq core machine-check-owner` already answered `legacy` there, because the native SessionStart notice cannot use its ledger, so the legacy hooks ran the checks. The daemon's hourly schedule did not apply the same rule and kept running its batch, which left the checks' cooldown stamps behind (check-hq-update's under the HQ root, the setup nag's under HOME); the legacy run then printed nothing, so neither path showed the finding. The schedule now runs no batch when the native notice cannot use its ledger, logging "machine checks skipped: the native notice cannot use its ledger". The ledger rule moved to `src/lib/daemon/native-notice-ledger.ts` so the owner and the schedule share it.
11
+ - Native `hq core delegate verify` now re-reads the manifest after publishing, so the publication receipt survives and a following native `send` no longer refuses with "verified publication receipt missing".
12
+ - `hq-hook dispatch` now skips the two per-prompt machine checks (`30-ensure-hq-cli.sh`, `31-ensure-hq-desktop.sh`) when the daemon runs them on its schedule, as `master-hook.sh` already does. The engine decides this itself from the same files `hq core machine-check-owner` reads, without starting `hq` or any other process; whenever it cannot tell, the checks run as before. Optional machine-check skip tracing ignores special files and opens nonblocking so a trace FIFO without a reader cannot hang dispatch.
13
+ - Test only: the dispatch machine-check parity tests no longer depend on how fast the machine starts the stub `hq`. No behaviour change.
14
+ - hq-hook: a new test, `run_starts_no_interpreter`, runs every recorded host payload through `hq-hook run` with `PATH` holding only stand-in programs named `bash`, `node`, `jq`, `hq`, `git`, `pwsh` and others, and fails if any of them is started. It runs on macOS, Linux and Windows. It also checks that turning the new core off (`HQ_CORE_NEXT=off`) does reach the stand-in `bash`, and it fails on any absolute interpreter path (such as `/bin/bash`) added to the crate's sources without a recorded reason.
15
+ - hq-hook: `run_starts_no_interpreter` allows exactly one process, as an exception Corey approved on 2026-11-16: `hq --version`, started at SessionStart by the native conduct-lanes-session-start port. The test checks that disabling that hook removes the start, and any other process (`hq` with other arguments, a second start, bash, sh, node, python) still fails it. The stand-in `PATH` now also holds `qmd`, so the hook no longer adds `/opt/homebrew/bin` or `/usr/local/bin` in front of it and start a real `hq` the test could not see.
16
+ - hq-hook: fix Linux host parity while retaining native refusals. Env-file validation keeps Q18's native deny of content outside ASCII in a multibyte locale off macOS and Windows; the branch's earlier, narrower Linux check is removed. Oversized image-ledger totals produce one native refusal line. On glibc, credential matching follows the host's case-insensitive regex behavior. The scope port and its Bash reference name the canonical owner root list. Parity tests probe the host tools and apply exact ledgered differences only where native still denies. Bash-version diagnostic probes have a deadline and bounded output, so an unresponsive shell cannot hang either guard.
17
+ - Linux parity ledger: each env-file input where Q18 changes the result against legacy Bash is its own entry, with both results pinned. It is either a legacy allow that native blocks, or a new kind, both block with a different message (Corey, 2026-11-16). An input missing from the ledger still fails its test. Tests only.
18
+ - Run Linux env-file, image-context, worktree, diagnostic deadline and parity ledger tests on PRs with GNU basename and the Estonian locale; recognize absolute Bash paths in locale warnings while preserving native refusals.
19
+ - `hq-hook run --host grok`: two prompt hooks of one session saving deferred context at the same time can no longer delete each other's file and leave nothing held while stderr says "deferred". The held file is now renamed over the old one in one step, so both saves land and the later one is held; a save that fails removes nothing and its stderr line says the context was not deferred. Every save and delivery attempt also runs a bounded sweep of the `grok-deferred` state folder (at most 16 entries checked and 4 removed per call) that removes any session's held context and dead claims past the 10-minute TTL, and temporary files a crashed writer left. A fresh file of any session, a claim still inside its TTL, and links are left alone. Decisions and exit codes are unchanged.
20
+ - `hq-hook run --host grok PostToolUse` now runs the three PostToolUse hooks the hq-core v16.0.48-beta.68 Grok adapter ran for them (`policy-enforcement-gate`, `screenshot-resize-trigger`, `conduct-lanes-link-deliver`), rebuilding the Claude-shaped payload and returning `hookSpecificOutput.additionalContext`. A `decision: block` from a hook is not a block on Grok. Codex PostToolUse is unchanged. Unmodelled inputs are refused with one line. Settings-file hooks, auto-capture-registry, master-hook fan-out and the held policy reminder are not part of this port, and `grok-adapter:PostToolUse` is not claimed in covers.
21
+ - Machine-check findings are no longer lost when HOME is reached through a link. The native SessionStart notice records what it shows in a ledger that the hq-hook store refuses to open through a link above its folder, so on such a machine it showed nothing while `hq core machine-check-owner` still answered `daemon` and the legacy hooks stood down. The owner check (TypeScript and the native dispatcher port) now answers `legacy` when that ledger could not be used: a link that is not root's on its path, a folder others may write or another account owns, or a ledger file that is a link or has a second name. The store's link rule is unchanged.
22
+ - On macOS, `hq mesh daemon install`, its uninstall, the automatic install on a command's first run after an update, the restart after an update, the startup LaunchAgent migration and `hq daemon`'s takeover of an older Work Mesh service now leave launchd alone when `HOME` is not the account's own home folder. macOS keeps one `ai.getindigo.hq-mesh-daemon` service per login, so a command run with a temporary `HOME` used to replace the real Work Mesh service with one that had no sign-in.
23
+ - `hq daemon install`, `start` and `uninstall` on macOS refuse to act when `HOME` is not the account's own home folder, for the same reason: macOS keeps one `ai.getindigo.hq-daemon` service per login.
24
+ - A Mac whose Work Mesh or `hq daemon` service was already replaced this way repairs itself on the first `hq` command after updating to this release, run from the account's own home folder. It stops a service loaded from outside the home folder and waits for it to exit, loads the account's own `hq daemon` service again when its plist exists and the desktop app or a foreground `hq daemon` does not already run the daemon, and loads or installs the right Work Mesh service unless `hq daemon` runs Work Mesh for that account. A repair that fails is retried an hour later. An `hq daemon` repair interrupted after the old service was stopped is remembered in `~/.hq/launchd-heal-pending.json` and finished on that retry. When the retry runs outside the HQ folder with no `HQ_ROOT`, `hq mesh daemon install --if-stale` uses the HQ folder of the installed Work Mesh service, or else the last one it trusted. The restart after later CLI updates does the same. `hq daemon` checks the Work Mesh service when it starts: it stops such a service and runs Work Mesh itself when it is the account's background service with Work Mesh on, and otherwise loads or installs the right one, or says how to turn Work Mesh back on.
25
+ - The sync engine self-check (`hq daemon service sync-core-selfcheck`) now reports, in its once-a-day DM, when a sync engine is running and Work Mesh is meant to run but two checks at least 30 minutes apart found its change-notification marker stale or not connected. This report does not delay a DM about a sync engine that has stopped syncing.
26
+ - Add native command safety rules to the optional `hq-hook run` entrypoint, including package acquisition, file edits, cached flags, and image accounting. They run at registry slot 4 after PreToolUse batch 1, which keeps answering `block-env-dump`, so each call is refused at most once.
27
+ - Preserve legacy merge-gate registration until its state producer is available; refuse missing merge authority, check every edit path, and read command flags from company scope.
28
+ - Retain legacy ownership for live command flags and repository identity; directly invoked native guards refuse operations whose authority is not yet available.
29
+ - Limit the Windows image-store refusal to image candidates, so ordinary text reads and shell calls retain their existing behavior.
30
+ - Preserve package checks through shell command options and rc-file glob destinations, and retain merge holds and required reviews when a command segment cannot be parsed.
31
+ - Run the command-rule and changed-guard integration tests (command_rules, command_guards, image_context_guard, env_file, repo_worktree) in hq-hook PR CI.
32
+ - Preserve legacy package-install refusals for quoted manager names after remote-command wrappers, and refuse package-scan wrapper nesting past 64 layers before it can exhaust the evaluator stack.
33
+ - Preserve trailing operands in split-string and package call launchers, unwrap manager names after assignments in both scans, and count quoted names toward the launcher nesting cap.
34
+ - The repository-worktree rule refuses a repo edit only in an HQ root that has the legacy `block-repo-edits-use-worktree` hook script, as master-hook runs it; elsewhere the edit keeps its existing warning.
35
+ - The native PreCompact (`hq-hook run ... PreCompact`) now accepts the PreCompact files of hq-core v16.0.48-beta.104 and beta.105, where it refused every compaction before. It pins the versions those releases ship of master-hook.sh, hook-lib.sh, hook-gate.sh, hook-adapter-core.sh and hook-timeout-watchdog.sh, and pins core/scripts/lib/session-id.sh, which the beta.104 master-hook sources. Under a beta.104 or later master-hook it refuses what that dispatcher reads differently and the native PreCompact does not model: a payload that names a conversation id without `session_id`, a Cursor payload (`cursor_version`), an earlier session-id.sh beside it, and `SESSION_ID_PAYLOAD_JQ` set when session-id.sh is missing.
36
+ - The new hook core (`hq-hook run`) no longer refuses every tool call on HQ roots whose `hook-registry.json` gives the `policy-enforcement-gate` PreToolUse row `"runner":"source"`, as hq-core 16.0.46, 16.0.47 and the 16.0.48 betas from beta.88 through beta.105 do. The `source` and `exec` runners run the gate the same way and are both modelled; any other runner value is still refused natively. The new core also answers the `policy-enforcement-gate.sh` that hq-core v16.0.48-beta.90 through beta.105 ship, with the libraries those betas ship, instead of refusing UserPromptSubmit with "not a version the port reproduces". That gate's one change, rewriting the count wording "attachment count(s)" before it tests a prompt for a declared brief, is reproduced byte for byte.
37
+ - The native Stop (`hq-hook run ... Stop`) now accepts the Stop files of hq-core v16.0.48-beta.104 and beta.105, where it held every Stop on master-hook before. It ports what changed there: master-hook reads a Cursor chat's session from `conversation_id`, does not run the five Claude-only Stop gates on a Cursor payload, gives each folder Stop hook 10 seconds within a shared 30-second Stop budget, and exports `HQ_HOOK_CURSOR`; the Work Mesh turn-end hook takes the session master-hook read when no session variable is set. An HQ whose Stop files mix releases from before and after beta.104 is held on master-hook, as is one with the later Stop files and a `.claude/hooks/master-hook.sh` that is not a released beta.104 or later version, and so is a Stop the port does not model: a Cursor Stop with personal, pack or company Stop hooks or under the Stop dedupe, a payload that names `conversation_id` without `session_id`, a session id the turn-end hook would use as an unchecked file name, and `HQ_MASTER_STOP_BUDGET` or `HQ_MASTER_STOP_CHILD_TIMEOUT` set.
38
+ - The new hook core (`hq-hook run`) now does six more PreToolUse hooks natively, with no bash, jq, git, perl, node or `hq` process: `block-hq-worktree-session`, `block-hq-glob`, `block-hq-grep`, `block-foreground-timeout-over-harness-ceiling`, `block-hq-unbounded-search` and `block-inline-story-impl`. A refusal reads byte for byte as the old dispatcher printed it (the hook's message, then `Blocked by hook <id>.`), and the inline-story warning still goes to stderr. Input a port does not model is refused with one line naming the hook, including a Bash command whose quotes or substitutions nest more than 200 levels deep, which `block-hq-unbounded-search` now refuses instead of overflowing the stack. `block-hq-glob` reads the Git top level the way git does (including the `safe.directory` ownership refusal) and refuses a Glob with a path when that answer cannot be proven without running git, which includes any `GIT_CONFIG_SYSTEM` or `GIT_CONFIG_NOSYSTEM` setting (the port does not guess which system config git reads); the worktree guard refuses every call when no HQ root is known (no `CLAUDE_PROJECT_DIR` or `HQ_ROOT`, no `--hq-root` and no HQ around the binary), since the old hook used its own install folder and blocked when that folder was a linked worktree. Two decisions are stricter: the foreground-timeout guard reads only the `HQ_FLAG_CLI_FOREGROUND_TIMEOUT_GUARD` override of its rollout gate and otherwise blocks for every identity, and the worktree guard keeps its block where the old hook asked the flag service for the safe-directory flag. The foreground-timeout guard refuses a Bash `timeout` that is not a finite number (such as `1e400`, which the old guard read as Infinity and blocked). The worktree guard reads `agent_id`, `session_id` and `cwd` the way the old hook did when master-hook's own parse fails, compares the git dir and common dir as bash spells them (a case-variant `commondir` on macOS is a linked worktree), and refuses a `.git` or `commondir` first line that holds a NUL byte (bash 3.2, the macOS `/bin/bash`, ends the line at the NUL where bash 4 drops it), is longer than 64 KiB or is not UTF-8. `hq-hook capabilities --json` lists the six under `covers.PreToolUse`; PreToolUse stays on the old dispatcher until every PreToolUse hook is covered. Grok’s camelCase `toolInput.timeout` is checked as well as the snake_case timeout, and the worktree guard also checks the decoded directory on other hosts (including Grok’s `workspaceRoot` and a command’s `workdir`); neither additional check can erase an existing refusal. Grok’s camelCase Grep patterns retain the original hook refusal, and camelCase session-spawn inputs are checked alongside snake_case inputs so neither spelling can erase a refusal. The inline-story warning also reads Grok’s camelCase edit input. Timeout numbers at or beyond 2^53 are refused natively rather than printing digits that differ from JavaScript’s shortest numeric representation. Worktree guard cache reads are capped at 64 KiB; oversized caches miss and the guard checks the call afresh.
39
+ - Company skill files edited or written without a registered skill id are still blocked when the native hook core runs, on Claude Code, Codex and Grok Build, including from a subfolder of HQ without CLAUDE_PROJECT_DIR (the registered HQ root is used, a trailing slash on it no longer lets the edit through, a path relative to the session folder, a ./ or ../ path, or one spelled with // or /./ is checked as the file it names, and an edit is refused when no HQ root can be found, the root is not absolute, or the path cannot be resolved), while reading them stays allowed; the infra-policy reminder stays silent, matching the current hooks.
40
+ - Keep the company skill guard enabled when disabled-hook entries contain non-ASCII whitespace, and recognize valid YAML registry layouts, including merge keys (`<<`), when refusing generated legacy wrappers. A legacy wrapper write is refused when companies/manifest.yaml exists but cannot be read as one YAML document or names the owning company with a non-string key, and a path under CLAUDE_PROJECT_DIR is checked even when the registered HQ root differs.
41
+ - The new hook core (`core.next`) now does two more PreToolUse hooks natively: the start_session half of `conduct-link-inherit` (a session on a conduct link records an invite for the session it starts, byte for byte as the node lib wrote it, with no node needed) and `core/hooks/PreToolUse/50-prefer-agent-browser.sh` (the agent-browser nudge on Claude-in-Chrome and Playwright MCP tools, with the same text and the same `PATH` lookup). Neither ever blocks; an input either port does not model is refused with a reason instead of being allowed. `hq-hook capabilities --json` lists both as covered for PreToolUse. `spawn-company-handoff` is not ported yet, since the new core cannot hand back a changed tool input. PreToolUse stays on the old dispatcher until every hook it runs is covered.
42
+ - The new hook core (`core.next`) now does the work of two more SessionStart hooks natively, with no bash, no `node` or `hq` process and no network call. `migrate-policy-triggers` checks whether a policy changed since its last run and, if so, backfills `when:`/`on:` into policies that lack them, as `hq core migrate-policy-triggers` does, with the same cooldown, lock and stamps; it no longer needs `hq` installed. `merged-write-guard-shadow-refresh` clears the session's shadow-guard marker when no flag service is configured. Each honours `HQ_HOOK_PROFILE` and `HQ_DISABLED_HOOKS`. An input a port does not model (a configured flag service, an edited hook script, a policy with non-ASCII tags, ...) skips that port, with the reason printed on stderr (with no HQ root registered, as when `hq-hook run` gets no `--hq-root`, both ports skip and print one line each); later SessionStart work still runs and a session start is never blocked. `hq-hook capabilities --json` lists the two under `covers.SessionStart`. SessionStart stays on the old dispatcher until every one of its hooks is covered.
43
+ - The new hook core (`hq-hook run`) now does three UserPromptSubmit hooks itself: it delivers queued `hq monitor` events to a Claude Code or Codex session (`hq-monitor-session-hook`), joins a session started from a conduct-linked session to that link and adds the link's standing rules (`conduct-link-inherit`), and its policy injector now stands in for `inject-policy-on-trigger` on that event; when `HQ_DISABLED_HOOKS` turns that hook off, or the HQ root's `hook-gate.sh` cannot be read, it refuses the prompt with one line instead of skipping its checks. UserPromptSubmit still runs on the old dispatcher until every hook registered for it has a port; an unusual registry row or a stored value the native port cannot read the way the old hook did refuses the prompt with one line saying what to fix.
44
+ - qmd size-exclusion no longer treats an unrecognised collection mask as a finished walk, so previously owned ignore entries stay until the mask can be parsed.
45
+ - hq-hook: the replay recorder now stores events from a hosted agents-v2 box under `host: agents-v2`. The agents-v2 adapter sets `HQ_CHECKPOINT_RUNTIME=agents-v2` and no `HQ_HARNESS`, so these rows used to be labelled `claude-code`. The native `hq-hook run --host agents-v2` early-exit rows (unreadable payload, core off with no dispatcher, stalled checks, PreCompact) used to be labelled `fleet-session` and are now `agents-v2` too. The fleet session launcher's own events keep `fleet-session`. Nothing else about how rows are recorded or redacted changed.
46
+ - `hq resolve-company --path` now binds `companies/<slug>/**` from HQ's own tree, `hq link` refuses a folder that would steal the enclosing repo's origin, and manifest `~/…` repo entries expand instead of seeding `github.com/~/…`.
47
+ - `hq sync-core config <vault> parallel-downloads on|off` and `hq sync-core config <vault> download-streams <1-32>|default` set the new sync engine's parallel downloads for one vault on this computer only. `<vault>` is a company slug, `personal`, or a vault uid on the new engine here; `hq sync-core config <vault>` shows the current setting. The setting lives in `~/.hq/sync-core/vault-settings.json`, which the reconcile does not rewrite. hq daemon passes it to that vault's engine as `HQ_SYNC_PARALLEL_DOWNLOADS` / `HQ_SYNC_DOWNLOAD_STREAMS` and restarts only that engine within about 15 seconds, both when it is turned on and when it is turned off. Parallel downloads stay off by default, other computers, vaults and companies are not changed, and the rollout flag is not touched. An unknown setting or an out-of-range value is refused. Engine releases without parallel downloads ignore the setting.
48
+ - When a vault switches back from the new sync engine to the current sync while the engine holds deletes for it, the reconcile log now names the vault, the number of held deletes, and up to 20 of the held paths that the current sync will now apply. The switch-back itself is unchanged and still happens at once.
49
+ - The shared HQ CLI update lock is safer when several updaters race. HQ writes the lock to a temporary file and links it into place, so other processes never see it empty. Creating a lock, taking over a stale lock and releasing a lock now all happen inside a short-lived `cli-update.lock.takeover` folder that the HQ desktop app uses too, so no process can slip into the lock name while a takeover is checking it. If the fallback write on filesystems without hard links fails or stops short, HQ removes the file and reports that it does not hold the lock. A stale lock is moved aside and deleted only if it still matches what was judged stale; otherwise it is put back, or kept under its moved-aside name and cleaned up after 10 minutes. If the folder is left behind by a crash, HQ takes it over after 30 seconds by renaming the holder's file inside it, so two processes cannot both take it and an out-of-date check cannot affect a newer holder, and a process that cannot take it keeps to its wait limit. Releasing leaves the lock in place when the folder stays busy, or when another process has already replaced the lock; a lock left behind is reclaimed once its holder exits or after 10 minutes. An unreadable lock younger than 30 seconds is left alone. Before installing, the updater checks that the lock is still its own and skips the update if not. An older HQ desktop app or CLI without this change can still race with a newer one until both are updated. Matches the HQ desktop app fix for indigoai-us/hq-desktop-app-src#1949. The HQ CLI keeps its update lock fresh while an install runs. Every 60 seconds it rewrites the lock's start time, the same way the HQ desktop app does, so an install that runs longer than 10 minutes is no longer treated as abandoned and a second install cannot start over it. The CLI now applies the desktop app's rules for when a lock is stale: a lock dated 10 or more minutes in the future is stale, and an older lock with no process id expires by age only. When the CLI starts up and needs to update, it waits at most 1 second (was 10) for another process that is in the middle of taking over the lock. If releasing the lock finds another process busy with it, the CLI tries once more when it exits.
50
+ - Mark `hq auth login`, `hq auth logout` and `hq packages install` retiring in the command states table and the function manifest (use `hq login`, `hq logout` and `hq install`). They still run exactly as before.
51
+
5
52
  ## [5.345.221] — 2026-11-16
6
53
  - `hq-hook run` now treats a hook event that names only an agent type (`agent_type`) or a parent session or thread id as coming from inside an agent, as HQ's bash hooks already do. When such a prompt or compaction event cannot be evaluated, it is now refused instead of let through.
7
54
  - When the same hook registration is loaded twice, an earlier answer for a tool call is no longer reused for a call with the same id from another agent, or from the main thread. Each one is now evaluated on its own.
@@ -67,7 +114,6 @@
67
114
  - The native Stop now looks for `hq` on PATH as bash's `command -v` does. An `hq` on PATH that cannot be run (for example an `npm link` target rebuilt without its execute bit) is the one the lanes Monitor gate uses when no runnable `hq` comes after it; the gate fails on it as the shell gate did, instead of finding another `hq` in an install folder. An empty PATH entry is the working directory and a relative entry is read from it. Native hook PATH setup now also puts `~/.npm-global/bin` ahead of `~/.local/bin`, as every released hook-gate.sh does, and only skips a folder already on PATH when its text matches, as the shell does.
68
115
  - On macOS the native Stop now decides which `hq` (and `id` and `find`) bash's lookup finds from the file's mode bits, as both macOS bashes do, so an `hq` with execute bits that an ACL or a `noexec` volume stops is the one the lanes gate runs and fails on, as the shell did. A leading `~` in a PATH entry (`export PATH="~/bin:$PATH"`) is expanded as bash expands it for the lanes gate and the checkpoint gate, and not for the conduct deliver hook, whose `env hq` does not expand it. The native Stop now refuses, on every call and retry, a Stop whose environment exports a bash function other than the usual host login functions, a PATH that is not UTF-8, a PATH entry starting with `~+`, `~-` or `~` and a digit, a `~` entry under `POSIXLY_CORRECT` or `POSIX_PEDANTIC`, and a hook-gate.sh whose `hq_augment_path` or `hq_highest_node_version` is not the released body (an edited or older copy, or a missing one).
69
116
  - The native observe-patterns now folds case in ASCII only, as the shell's `grep -i` does on macOS in every locale. Commit summaries such as `ſcript` or `hooK` (with U+017F or the Kelvin sign) no longer produce an observation the shell never wrote.
70
- - The native Stop and `hq reindex` now accept only plain Git config lines: blank lines, `#` or `;` comment lines, a `[section]` or `[section "subsection"]` header with at most a comment after it, and a `key` or `key = value` line whose value has no backslash, double quote or control character and may end in a comment. Any other line keeps master-hook ("unmodeled Git config syntax"): a backslash continuation or escape, a quoted value, CRLF line ends, a setting on the header line (`[core] repositoryformatversion = 1`), the legacy `[section.subsection]` header, or a non-ASCII header. git reads several of these differently from a line-by-line reader, for example a value ending in `\` that hides the next `[section]` header, so such a repository is no longer let through where git refuses it or reads another file. A leading UTF-8 byte-order mark is skipped, as git skips it.
71
117
  - The native Stop and PreCompact accept the `core/scripts/hook-lib.sh` that hq-core v16.0.48-beta.98 ships.
72
118
  - The native Stop and `hq reindex` now check Git config against an allowlist. In a section that git reads during observe-patterns' commands (for example `core`, `diff`, `color`, `user`, `push`, `fetch`, `trace2` or `safe`), a variable keeps the shell Stop unless it is one the native Stop models, with a value in that variable's strict grammar. Examples that keep the shell Stop: `core.filemode = maybe`, `core.deltaBaseCacheLimit = -0`, `core.disambiguate`, `[diff "color"]`, or a bare `trace2.*` key. A repository extension git refuses (for example `refStorage` under `repositoryformatversion = 0`) also keeps it. git dies on these, so the shell's observe-patterns writes nothing, where the native reader used to write an observation. The modeled variables cover a default `git init` and the common developer settings (`user.*`, `init.defaultBranch`, `push.default`, `fetch.prune`, `diff.algorithm`, `color.ui`, `core.editor`, `core.pager`, `core.excludesFile`, `core.hooksPath`, `safe.directory`, and so on). Values are read with git's own config syntax, so quoted values (`editor = "code --wait"`), escapes, inline `#` and `;` comments and a trailing `\` continuation are read as git reads them; a file git refuses with "bad config line" keeps the shell Stop, as do CR, NUL and the legacy `[section.sub]` header. The modeled variables also include `branch.autoSetupMerge`, `branch.autoSetupRebase`, `branch.sort`, the common `core.*` keys (`compression`, `quotePath`, `fsmonitor`, `untrackedCache`, `sshCommand`, `whitespace`, `sparseCheckout` and others), `log.date`, `log.decorate` (off or `auto`), `color.diff`, `color.status`, `color.branch` and `[color "diff"]` slots, `diff.colorMoved`, `diff.renames`, `diff.mnemonicPrefix`, `diff.tool`, `index.version`, `index.sparse`, `gc.auto`, `init.templateDir`, `feature.manyFiles`, `protocol.version`, `transfer.fsckObjects`, `fetch.writeCommitGraph`, `fetch.pruneTags`, `fetch.all`, `push.followTags`, `submodule.recurse`, `advice.*` and `pager.<command>`; `diff.algorithm` and the color words are matched ignoring case, as git matches them. `core.notesRef`, `log.showSignature = true` and `color.* = always` still keep the shell Stop, since they change what `git log` prints. `[include]` and `[includeIf]` files are now read and checked the same way, instead of always keeping the shell Stop, except an `includeIf "hasconfig:..."` include, which keeps it (git fails when the file it names sets a remote URL, whether or not the condition matches). For an HQ root inside another Git repository (a folder below the repository's top, at any depth), or a linked worktree (`git worktree add`), the native Stop now checks the config of the repository git finds: the parent's `.git/config`, or the worktree's shared config and its own `config.worktree`, plus the global and system files. Before, the folder inside a repository was not checked at all, and a linked worktree always kept the shell Stop. A layout the check does not model still keeps the shell Stop: a gitfile or `commondir` git cannot follow, a bare repository on the way up, a `.git` past a file-system boundary, a repository the current user does not own, or a project folder reached through a link whose path and real path lead to different repositories. The sections come from running git 2.50.1 over every documented and compiled-in config name in the system, global, local and worktree files (`crates/hq-hook/tests/git-config-lab/derive.mjs`).
73
119
  - Native Stop and `hq reindex`: a repository with `extensions.worktreeConfig` in repository format 0 no longer keeps Stop on master-hook. Each value, read with git's own config tokenizer, must be a boolean git and gix read the same way (`true`, `yes`, `on`, `1`, `false`, `no`, `off`, `0` in any case, or a bare key); any other value, an empty one included, is still refused. The main worktree's `.git/config.worktree`, which git loads with the extension on, is checked under the same rules as `.git/config`, the Git config allowlist included, so a guarded key there is still refused. In a linked worktree, the worktree's own `config.worktree` is checked the same way; repository format 1 is still refused. A key on its section header's line and a value continued with a trailing backslash are read as git reads them, and a byte-order mark at the start of a file is skipped as git does; before, each of these could hide a guarded key. The native check and the reindex check run the same cases (`crates/hq-hook/tests/fixtures/stop-git-config/cases.json`). The native Stop also refuses edited PATH helpers in hook-gate.sh: a helper that changes the hook profile could previously make native Stop skip a hook that master-hook would run and block. A Stop registration timeout too large to represent now refuses every Stop instead of panicking before the hooks run. On Windows, absolute Git config and PATH locations now replace the HQ base path, matching the native reader, instead of being appended to it.
@@ -19730,6 +19730,37 @@ export declare const COMMAND_CATALOG: readonly [{
19730
19730
  readonly hidden: false;
19731
19731
  }];
19732
19732
  readonly subcommands: readonly [];
19733
+ }, {
19734
+ readonly name: "config";
19735
+ readonly description: "Show or change this computer's new sync engine settings for one vault: parallel-downloads on|off, download-streams 1-32|default";
19736
+ readonly aliases: readonly [];
19737
+ readonly hidden: false;
19738
+ readonly helpOption: true;
19739
+ readonly helpCommand: false;
19740
+ readonly usage: "[options] <vault> [key] [value]";
19741
+ readonly helpText: readonly [];
19742
+ readonly arguments: readonly [{
19743
+ readonly name: "vault";
19744
+ readonly required: true;
19745
+ readonly variadic: false;
19746
+ readonly description: "";
19747
+ }, {
19748
+ readonly name: "key";
19749
+ readonly required: false;
19750
+ readonly variadic: false;
19751
+ readonly description: "";
19752
+ }, {
19753
+ readonly name: "value";
19754
+ readonly required: false;
19755
+ readonly variadic: false;
19756
+ readonly description: "";
19757
+ }];
19758
+ readonly options: readonly [{
19759
+ readonly flags: "--json";
19760
+ readonly description: "Print JSON";
19761
+ readonly hidden: false;
19762
+ }];
19763
+ readonly subcommands: readonly [];
19733
19764
  }, {
19734
19765
  readonly name: "status";
19735
19766
  readonly description: "Show which vaults are on the new sync engine on this machine";
@@ -24065,6 +24065,44 @@ export const COMMAND_CATALOG = [
24065
24065
  ],
24066
24066
  "subcommands": []
24067
24067
  },
24068
+ {
24069
+ "name": "config",
24070
+ "description": "Show or change this computer's new sync engine settings for one vault: parallel-downloads on|off, download-streams 1-32|default",
24071
+ "aliases": [],
24072
+ "hidden": false,
24073
+ "helpOption": true,
24074
+ "helpCommand": false,
24075
+ "usage": "[options] <vault> [key] [value]",
24076
+ "helpText": [],
24077
+ "arguments": [
24078
+ {
24079
+ "name": "vault",
24080
+ "required": true,
24081
+ "variadic": false,
24082
+ "description": ""
24083
+ },
24084
+ {
24085
+ "name": "key",
24086
+ "required": false,
24087
+ "variadic": false,
24088
+ "description": ""
24089
+ },
24090
+ {
24091
+ "name": "value",
24092
+ "required": false,
24093
+ "variadic": false,
24094
+ "description": ""
24095
+ }
24096
+ ],
24097
+ "options": [
24098
+ {
24099
+ "flags": "--json",
24100
+ "description": "Print JSON",
24101
+ "hidden": false
24102
+ }
24103
+ ],
24104
+ "subcommands": []
24105
+ },
24068
24106
  {
24069
24107
  "name": "status",
24070
24108
  "description": "Show which vaults are on the new sync engine on this machine",
@@ -328,7 +328,8 @@ export function registerAuthCommands(program) {
328
328
  .action(async () => {
329
329
  // Second name for `hq logout`. It signs out exactly as `hq logout` does,
330
330
  // so the refresh token is revoked on the server on this path too. It is
331
- // not marked retiring yet: the shipped /hq-logout skill still runs it.
331
+ // marked retiring (US-041: the core skills now run `hq logout`), but the
332
+ // retiring gate is off, so this command still runs exactly as before.
332
333
  const { runLogout } = await import("./logout.js");
333
334
  await runLogout();
334
335
  });
@@ -1307,9 +1307,15 @@ function runVerify(args, context) {
1307
1307
  const publishCode = runPublish(["--manifest", manifestPath, "--lock-held"], context);
1308
1308
  if (publishCode !== 0)
1309
1309
  return fail("verify", "final dossier publication failed; notification blocked");
1310
- manifest.status = "verified";
1311
- manifest.verifiedAt = currentTime();
1312
- writeJsonAtomically(manifestPath, manifest, true);
1310
+ // Publish rewrote the manifest with its checksums and publication receipt,
1311
+ // so the copy read above is stale. Re-read it, as the shell companion's jq
1312
+ // update does, so the verified write keeps the receipt send requires.
1313
+ const published = jsonFile(manifestPath);
1314
+ if (!published)
1315
+ return fail("verify", "published manifest is unreadable; notification blocked");
1316
+ published.status = "verified";
1317
+ published.verifiedAt = currentTime();
1318
+ writeJsonAtomically(manifestPath, published, true);
1313
1319
  out(`hq-delegate-verify: all ${prefixes.length} prefix(es) reachable — manifest status advanced to 'verified'\n`);
1314
1320
  return 0;
1315
1321
  }
@@ -27,6 +27,7 @@ export declare function loadDaemonRunner(release?: () => void, load?: () => Prom
27
27
  export interface DaemonCommandDeps {
28
28
  env: NodeJS.ProcessEnv;
29
29
  home: string;
30
+ loginHome?: string;
30
31
  platform: NodeJS.Platform;
31
32
  out: (line: string) => void;
32
33
  err: (line: string) => void;
@@ -17,6 +17,8 @@
17
17
  import * as fs from "node:fs";
18
18
  import * as os from "node:os";
19
19
  import * as path from "node:path";
20
+ import { SYNC_WAKE_STATE_BASENAME, workMeshRoot } from "../lib/mesh/live/paths.js";
21
+ import { homeIsLoginSafe, meshJobLoadedForHome } from "../lib/mesh/live/daemon/unit-home.js";
20
22
  import { randomBytes } from "node:crypto";
21
23
  import { spawn, spawnSync } from "node:child_process";
22
24
  import { once } from "node:events";
@@ -110,6 +112,7 @@ async function loadDefaults(over) {
110
112
  return {
111
113
  env,
112
114
  home,
115
+ loginHome: over.loginHome,
113
116
  platform,
114
117
  out: over.out ?? ((l) => console.log(l)),
115
118
  err: over.err ?? ((l) => console.error(l)),
@@ -134,7 +137,8 @@ async function loadDefaults(over) {
134
137
  home: dir ?? home,
135
138
  existsSync: fs.existsSync,
136
139
  listDir: (dir) => fs.readdirSync(dir),
137
- launchdJobLoaded: (label) => run("launchctl", ["print", `gui/${process.getuid?.() ?? 0}/${label}`]).status === 0,
140
+ launchdJobLoaded: (label) => meshJobLoadedForHome(run("launchctl", ["print", `gui/${process.getuid?.() ?? 0}/${label}`]), dir ?? home),
141
+ homeIsLogin: platform === "darwin" ? homeIsLoginSafe(dir ?? home) : true,
138
142
  windowsTaskOwner: (task) => classifyWindowsTask(run, task, {
139
143
  windowsSid: over.windowsSid ?? readWindowsSid(run),
140
144
  windowsUser: over.windowsUser ?? mesh.resolveWindowsUser(env),
@@ -211,6 +215,7 @@ function hostFor(d, paths, pathEnv) {
211
215
  windowsHeadlessLauncher: d.windowsHeadlessLauncher,
212
216
  systemUnitDir: d.systemUnitDir ?? SYSTEM_UNIT_DIR,
213
217
  env,
218
+ loginHome: d.loginHome,
214
219
  };
215
220
  }
216
221
  /**
@@ -1934,6 +1939,15 @@ export function registerDaemonCommand(program, over = {}) {
1934
1939
  }
1935
1940
  },
1936
1941
  sendToOwner: (message) => sendDmToMachineOwner(message),
1942
+ wake: {
1943
+ markerPath: path.join(workMeshRoot(d.home, d.env), SYNC_WAKE_STATE_BASENAME),
1944
+ watchPath: path.join(paths.root, "selfcheck-wake.json"),
1945
+ meshWanted: () => {
1946
+ const config = readDaemonConfig(paths.configPath);
1947
+ const { detected } = currentHost(d);
1948
+ return enabledServices(detected.type, config).includes("mesh");
1949
+ },
1950
+ },
1937
1951
  ...(await selfCheckVaults(d.home)),
1938
1952
  log: (line) => d.out(line),
1939
1953
  });
@@ -14,6 +14,8 @@ export interface LinkDeps {
14
14
  /** Active memberships for the signed-in user (reuses GET /membership/me). */
15
15
  listMemberships?: () => Promise<MembershipCompany[]>;
16
16
  now?: () => Date;
17
+ /** HQ root for the companies/<slug> layout fallback (default: $HQ_ROOT). */
18
+ hqRoot?: string;
17
19
  }
18
20
  export interface LinkCommandDeps {
19
21
  /** Test seam for the combined hq-flags and person-setting gate. */
@@ -11,7 +11,7 @@ import { ensureCognitoToken } from "../utils/cognito-session.js";
11
11
  import { listActiveMembershipCompanies } from "../lib/mesh/api.js";
12
12
  import { anywhereRuntimeAllowed } from "../lib/anywhere-person-setting.js";
13
13
  import { readCompaniesManifestMap } from "../lib/work-context/repo-remote.js";
14
- import { canonicalDir, keyForDir, readRegistry, registryDir, registryFile, removeEntriesForDir, resolveCompanyForDir, seedFromManifest, setEntry, writeRegistry, } from "../lib/registry/registry.js";
14
+ import { canonicalDir, keyForDir, readRegistry, registryDir, registryFile, removeEntriesForDir, resolveCompanyForDir, seedFromManifest, setEntry, wouldBindEnclosingRemote, writeRegistry, } from "../lib/registry/registry.js";
15
15
  async function requireAnywhereRuntime(deps) {
16
16
  if (!(await (deps.runtimeAllowed ?? (() => anywhereRuntimeAllowed()))())) {
17
17
  throw new Error("HQ Anywhere is disabled until both the runtime flag and your person setting are on.");
@@ -34,6 +34,9 @@ export async function linkFolder(company, dir, deps = {}) {
34
34
  if (!slug)
35
35
  throw Object.assign(new Error("Company slug is required."), { expected: true });
36
36
  const folder = targetDir(dir);
37
+ if (wouldBindEnclosingRemote(folder)) {
38
+ throw Object.assign(new Error(`Refusing to link ${folder}: it sits inside another git work tree, so the registry key would be that repo's origin and every folder in the repo would resolve to '${slug}'. Link a standalone checkout instead.`), { expected: true });
39
+ }
37
40
  const memberships = await (deps.listMemberships ?? defaultListMemberships)();
38
41
  const match = memberships.find((m) => m.companySlug.toLowerCase() === slug.toLowerCase() || m.companyUid === slug);
39
42
  if (!match) {
@@ -63,7 +66,16 @@ export function resolveCompany(dir, deps = {}) {
63
66
  catch (err) {
64
67
  return { company: null, reason: err.message };
65
68
  }
66
- return resolveCompanyForDir(registry, folder);
69
+ return resolveCompanyForDir(registry, folder, { hqRoot: layoutHqRoot(deps) });
70
+ }
71
+ /**
72
+ * The HQ root the companies/<slug> layout fallback may trust: an explicit
73
+ * dependency or $HQ_ROOT only. Never a cwd walk or CLAUDE_PROJECT_DIR, which
74
+ * in a session started outside HQ is that foreign folder.
75
+ */
76
+ function layoutHqRoot(deps) {
77
+ const raw = deps.hqRoot ?? process.env.HQ_ROOT ?? "";
78
+ return raw.trim() ? path.resolve(raw.trim()) : null;
67
79
  }
68
80
  /** Seed manifest-sourced entries; called by `hq install --global` (US-005). */
69
81
  export function seedRegistryFromHqRoot(hqRoot, deps = {}) {
@@ -40,8 +40,9 @@ import { generateUlid } from "../lib/mesh/live/ulid.js";
40
40
  import { readLegacyBacklog } from "../lib/mesh/live/emit-replay.js";
41
41
  import { resolveMeshEmitMode, writeMeshConfigMode, } from "../lib/mesh/live/daemon/mode.js";
42
42
  import { workMeshRoot } from "../lib/mesh/live/paths.js";
43
- import { buildInstallPaths, daemonServiceIsLoaded, daemonServiceStatus, detectPlatform, installDaemonIfStale, installDaemonService, resolveAbsoluteNodeBinary, resolveRunningCliEntry, uninstallDaemonService, } from "../lib/mesh/live/daemon/install.js";
44
- import { findAncestorHqRoot, resolveInstallHqRoot, } from "../lib/mesh/live/daemon/config.js";
43
+ import { buildInstallPaths, daemonServiceIsLoaded, daemonServiceStatus, detectPlatform, installDaemonIfStale, installDaemonService, resolveAbsoluteNodeBinary, resolveRunningCliEntry, uninstallDaemonService, installedUnitHqRoot, } from "../lib/mesh/live/daemon/install.js";
44
+ import { findAncestorHqRoot, resolveIfStaleHqRoot, resolveInstallHqRoot, } from "../lib/mesh/live/daemon/config.js";
45
+ import { daemonDir as meshDaemonDir } from "../lib/mesh/live/daemon/paths.js";
45
46
  import { collectDaemonDoctor, formatCliIdentityLines, formatDaemonDoctor, } from "../lib/mesh/live/daemon/doctor.js";
46
47
  import { readDaemonState } from "../lib/mesh/live/daemon/state.js";
47
48
  import { defaultRunCommand } from "../lib/service-manager/launchd.js";
@@ -62,6 +63,7 @@ import { deriveRemoteOwnerSlug, deriveRepoIdentityKey, } from "../lib/work-conte
62
63
  import { promptRepoCompany, } from "../lib/work-context/repo-prompt.js";
63
64
  import { requeueQuarantinedOutbox } from "../lib/work-context/outbox.js";
64
65
  import { handOffInstallHere } from "../lib/daemon/handoff.js";
66
+ import { repairServiceUnitsFromOtherHome } from "../lib/daemon/mesh-owner.js";
65
67
  import { runResidentCommandWithPackageLease } from "../utils/resident-package-preload.js";
66
68
  export function formatCheckLines(threads, company, projectId) {
67
69
  if (threads.length === 0) {
@@ -3139,6 +3141,18 @@ async function runDaemonInstall(opts) {
3139
3141
  // `hq daemon` runs mesh on this machine: installing a second unit would run it twice.
3140
3142
  // An explicit --hq-root is verified the same way as below and saved for the daemon.
3141
3143
  const explicitRoot = opts.hqRoot ? resolveInstallHqRoot({ explicit: opts.hqRoot }).root : undefined;
3144
+ if (opts.ifStale && !opts.systemUser) {
3145
+ const repair = repairServiceUnitsFromOtherHome({ home: os.homedir(), env: process.env, hqRoot: explicitRoot ?? process.env.HQ_ROOT });
3146
+ for (const message of repair.messages)
3147
+ console.error(message);
3148
+ if (repair.failed)
3149
+ process.exitCode = 1;
3150
+ if (repair.meshReplaced) {
3151
+ const message = repair.messages.join(" ");
3152
+ console.log(opts.json ? JSON.stringify({ ok: true, action: "repaired", reinstalled: true, message }) : message);
3153
+ return;
3154
+ }
3155
+ }
3142
3156
  const handedOff = opts.systemUser
3143
3157
  ? null
3144
3158
  : handOffInstallHere(["mesh"], process.env, { hqRoot: explicitRoot, ifStale: opts.ifStale });
@@ -3148,7 +3162,13 @@ async function runDaemonInstall(opts) {
3148
3162
  }
3149
3163
  // Verified root only: a repo's own .claude/ must never become the daemon's
3150
3164
  // HQ root (that path is persisted as trusted and used for attribution).
3151
- const hqRoot = resolveInstallHqRoot({ explicit: opts.hqRoot });
3165
+ const hqRoot = opts.ifStale
3166
+ ? resolveIfStaleHqRoot({
3167
+ explicit: opts.hqRoot,
3168
+ daemonDirectory: meshDaemonDir(undefined, os.homedir(), process.env),
3169
+ installedUnitRoot: installedUnitHqRoot(os.homedir()),
3170
+ })
3171
+ : resolveInstallHqRoot({ explicit: opts.hqRoot });
3152
3172
  const paths = buildInstallPaths({
3153
3173
  systemUser: opts.systemUser,
3154
3174
  hqRoot: hqRoot.root,
@@ -36,5 +36,11 @@ export declare function runSyncCoreManifest(opts: SyncCoreManifestCommandOptions
36
36
  export declare function runSyncCoreStatus(opts: {
37
37
  json?: boolean;
38
38
  }, d?: SyncCoreCommandDeps): void;
39
+ export declare function resolveSyncCoreVault(home: string, name: string, opts?: {
40
+ clearing?: boolean;
41
+ }): string;
42
+ export declare function runSyncCoreConfig(vault: string, key: string | undefined, value: string | undefined, opts: {
43
+ json?: boolean;
44
+ }, d?: SyncCoreCommandDeps): void;
39
45
  export declare function registerSyncCoreCommand(program: Command, over?: Partial<SyncCoreCommandDeps>): void;
40
46
  //# sourceMappingURL=sync-core.d.ts.map
@@ -8,6 +8,8 @@ import { reconcileSyncCore } from "../lib/sync-core/reconcile.js";
8
8
  import { engineOwnedManifestScopes, manifestScopeArg } from "../lib/sync-core/manifest-scopes.js";
9
9
  import { readSyncCoreRolloutState, syncCoreRolloutStatePath } from "../lib/sync-core/rollout-state.js";
10
10
  import { readVaultSyncSwitches } from "../lib/vault-sync-switches.js";
11
+ import { isSyncCoreVaultUid } from "../lib/sync-core/vault-uid.js";
12
+ import { readSyncCoreVaultSettings, setSyncCoreVaultSetting, SyncCoreVaultSettingError, } from "../lib/sync-core/vault-settings.js";
11
13
  function defaultDeps() {
12
14
  return {
13
15
  home: os.homedir(),
@@ -213,6 +215,54 @@ export function runSyncCoreStatus(opts, d = defaultDeps()) {
213
215
  if (state.vaults.length === 0)
214
216
  d.out(" no vault is switched to the new sync engine");
215
217
  }
218
+ export function resolveSyncCoreVault(home, name, opts = {}) {
219
+ const wanted = name.trim();
220
+ const vaults = readSyncCoreRolloutState(home)?.vaults ?? [];
221
+ if (isSyncCoreVaultUid(wanted)) {
222
+ if (vaults.some((vault) => vault.uid === wanted))
223
+ return wanted;
224
+ if (opts.clearing && readSyncCoreVaultSettings(home).has(wanted))
225
+ return wanted;
226
+ }
227
+ const match = wanted === "personal"
228
+ ? vaults.filter((vault) => vault.kind === "personal")
229
+ : vaults.filter((vault) => vault.kind === "company" && vault.slug === wanted);
230
+ if (match.length === 1)
231
+ return match[0].uid;
232
+ throw new SyncCoreVaultSettingError(`No vault named ${JSON.stringify(wanted)} is on the new sync engine on this machine. Pass a company slug from hq sync-core status, personal, or a vault uid.`);
233
+ }
234
+ function describeSettings(settings) {
235
+ if (!settings?.parallelDownloads)
236
+ return "parallel-downloads off (default)";
237
+ return `parallel-downloads on, download-streams ${settings.downloadStreams ?? "default"}`;
238
+ }
239
+ export function runSyncCoreConfig(vault, key, value, opts, d = defaultDeps()) {
240
+ try {
241
+ const clearing = key !== undefined && (value === "off" || value === "default");
242
+ const uid = resolveSyncCoreVault(d.home, vault, { clearing });
243
+ let settings;
244
+ if (key === undefined) {
245
+ settings = readSyncCoreVaultSettings(d.home).get(uid);
246
+ }
247
+ else {
248
+ if (value === undefined)
249
+ throw new SyncCoreVaultSettingError(`Give a value for ${key}`);
250
+ settings = setSyncCoreVaultSetting(d.home, uid, key, value);
251
+ }
252
+ if (opts.json) {
253
+ d.out(JSON.stringify({ vault: uid, parallelDownloads: settings?.parallelDownloads === true, downloadStreams: settings?.downloadStreams ?? null }));
254
+ return;
255
+ }
256
+ d.out(`${uid}: ${describeSettings(settings)}`);
257
+ if (key !== undefined) {
258
+ d.out("Only this computer is changed. hq daemon restarts this vault's sync engine within about 15 seconds. Engine releases without parallel downloads ignore the setting.");
259
+ }
260
+ }
261
+ catch (error) {
262
+ d.err(error instanceof Error ? error.message : String(error));
263
+ process.exitCode = 1;
264
+ }
265
+ }
216
266
  export function registerSyncCoreCommand(program, over = {}) {
217
267
  const deps = () => ({ ...defaultDeps(), ...over });
218
268
  const syncCore = program
@@ -235,6 +285,11 @@ export function registerSyncCoreCommand(program, over = {}) {
235
285
  process.exitCode = 1;
236
286
  }
237
287
  });
288
+ syncCore
289
+ .command("config <vault> [key] [value]")
290
+ .description("Show or change this computer's new sync engine settings for one vault: parallel-downloads on|off, download-streams 1-32|default")
291
+ .option("--json", "Print JSON")
292
+ .action((vault, key, value, opts) => runSyncCoreConfig(vault, key, value, opts, deps()));
238
293
  syncCore
239
294
  .command("status")
240
295
  .description("Show which vaults are on the new sync engine on this machine")
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "commands": {
4
+ "auth login": { "state": "retiring", "replacedBy": "hq login" },
5
+ "auth logout": { "state": "retiring", "replacedBy": "hq logout" },
4
6
  "crm entity get": { "state": "retiring" },
5
7
  "crm entity list": { "state": "retiring" },
8
+ "packages install": { "state": "retiring", "replacedBy": "hq install" },
6
9
  "packages packs list": { "state": "retiring", "replacedBy": "hq packs list" },
7
10
  "packages packs uninstall": { "state": "retiring", "replacedBy": "hq packs uninstall" },
8
11
  "packages packs update": { "state": "retiring", "replacedBy": "hq packs update" },
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import * as path from "node:path";
13
13
  import { syncCoreUnitId } from "../sync-core/engine-home.js";
14
+ import { engineSettingsEnv } from "../sync-core/vault-settings.js";
14
15
  import { engineOwnedManifestScopes } from "../sync-core/manifest-scopes.js";
15
16
  import { SYNC_RUNNER_OWNER, syncRunnerUnleasedBlockReason } from "./sync-runner.js";
16
17
  import { vaultSkipEnv } from "../vault-sync-switches.js";
@@ -268,6 +269,7 @@ function planService(service, ctx) {
268
269
  HQ_SYNC_MODE: full ? "full" : "readonly",
269
270
  ...(full ? { HQ_SYNC_FULL_VAULT: "1", HQ_SYNC_PROTOCOL: "1" } : {}),
270
271
  HQ_SYNC_CORE_RELEASE: vault.release,
272
+ ...engineSettingsEnv(vault.settings),
271
273
  },
272
274
  ...(full ? { heartbeatTimeoutMs: 180_000 } : {}),
273
275
  blocked: firstBlock([
@@ -68,6 +68,7 @@ export interface DaemonHost {
68
68
  systemUnitDir: string;
69
69
  /** Extra environment baked into the unit (PATH of the installing shell, HQ_DAEMON_DIR). */
70
70
  env?: Record<string, string>;
71
+ loginHome?: string;
71
72
  }
72
73
  export interface InstallOptions {
73
74
  scope: InstallScope;
@@ -198,7 +199,7 @@ export interface RefreshDaemonPlistResult {
198
199
  * finds the old plist (see daemonPlistNeedsRefresh). It must not run inside
199
200
  * the daemon's own job: the bootout would end the caller before the bootstrap.
200
201
  */
201
- export declare function refreshDaemonPlist(host: Pick<DaemonHost, "home" | "uid">, deps: {
202
+ export declare function refreshDaemonPlist(host: Pick<DaemonHost, "home" | "uid" | "loginHome">, deps: {
202
203
  run: RunCommand;
203
204
  sleep?: SleepFn;
204
205
  }): RefreshDaemonPlistResult;
@@ -26,6 +26,7 @@ import { readPidLock } from "../mesh/live/daemon/pid-lock.js";
26
26
  import { userToolDirs } from "./tools.js";
27
27
  import { liveDaemonLock, verifyDaemonForKill } from "./lock.js";
28
28
  import { daemonPaths } from "./paths.js";
29
+ import { assertLoginHome, homeIsLoginSafe } from "../mesh/live/daemon/unit-home.js";
29
30
  export const DAEMON_LAUNCHD_LABEL = "ai.getindigo.hq-daemon";
30
31
  export const DAEMON_SYSTEMD_UNIT = "hq-daemon.service";
31
32
  /**
@@ -427,6 +428,8 @@ function activate(plan, host, run, sleep, previous = null) {
427
428
  }
428
429
  }
429
430
  export function installDaemonUnit(host, options, deps) {
431
+ if (host.platform === "darwin")
432
+ assertLoginHome("install", host.home, host.loginHome, DAEMON_LAUNCHD_LABEL);
430
433
  const plan = planDaemonUnit(host, options);
431
434
  if (plan.kind === "manual") {
432
435
  return { kind: plan.kind, unitPath: "", installed: false, running: false, manualCommand: plan.manualCommand };
@@ -584,6 +587,8 @@ export function retryLaunchdBootstrap(plistPath, run, uid, sleep = blockingSleep
584
587
  */
585
588
  export function refreshDaemonPlist(host, deps) {
586
589
  const plistPath = launchdPlistPath(host.home, { label: DAEMON_LAUNCHD_LABEL });
590
+ if (!homeIsLoginSafe(host.home, host.loginHome))
591
+ return { action: "none", plistPath };
587
592
  if (!fs.existsSync(plistPath))
588
593
  return { action: "none", plistPath };
589
594
  const source = fs.readFileSync(plistPath, "utf8");
@@ -751,6 +756,8 @@ export function daemonServiceStatus(host, run, daemonPid) {
751
756
  */
752
757
  export function startDaemonUnit(host, deps) {
753
758
  const sleep = deps.sleep ?? blockingSleep;
759
+ if (host.platform === "darwin")
760
+ assertLoginHome("start", host.home, host.loginHome, DAEMON_LAUNCHD_LABEL);
754
761
  // An older install's plist runs through HQ.app and is skipped at login:
755
762
  // rewrite it first, so the unit this loads or starts is the fixed one.
756
763
  const previousPid = deps.daemonPid();
@@ -954,6 +961,8 @@ export function windowsInteractiveSession(run, user) {
954
961
  });
955
962
  }
956
963
  export function uninstallDaemonUnit(host, options, deps) {
964
+ if (host.platform === "darwin")
965
+ assertLoginHome("remove", host.home, host.loginHome, DAEMON_LAUNCHD_LABEL);
957
966
  // A system uninstall does not need the login user; only the unit path matters.
958
967
  const plan = host.platform === "linux" && options.scope === "system"
959
968
  ? { kind: "systemd-system", unitPath: path.join(host.systemUnitDir, DAEMON_SYSTEMD_UNIT), rendered: "" }
@@ -30,6 +30,7 @@ export interface LegacyProbeDeps {
30
30
  listDir: (dir: string) => string[];
31
31
  /** True when launchctl can print the GUI-domain job despite a missing plist. */
32
32
  launchdJobLoaded: (label: string) => boolean;
33
+ homeIsLogin?: boolean;
33
34
  /** Whether the task exists and runs as the current user. Another user's task is never taken over. */
34
35
  windowsTaskOwner: (taskName: string) => WindowsTaskOwner;
35
36
  /**
@@ -55,8 +55,11 @@ function darwinUnits(deps) {
55
55
  const at = (label) => path.join(dir, `${label}.plist`);
56
56
  const add = (unitId, service, label, migratable = true) => units.push({ unitId, service, kind: "launchd", name: label, path: at(label), migratable });
57
57
  const meshLabel = "ai.getindigo.hq-mesh-daemon";
58
- if (deps.existsSync(at(meshLabel)) || deps.launchdJobLoaded(meshLabel))
59
- add("mesh", "mesh", meshLabel);
58
+ if (deps.existsSync(at(meshLabel)) || deps.launchdJobLoaded(meshLabel)) {
59
+ add("mesh", "mesh", meshLabel, deps.homeIsLogin !== false);
60
+ if (deps.homeIsLogin === false)
61
+ units[units.length - 1].notMineReason = "HOME is not this account's home folder, and macOS has one Work Mesh service per login";
62
+ }
60
63
  for (const file of safeList(deps, dir).sort()) {
61
64
  const m = /^ai\.getindigo\.hq-bot\.(.+)\.plist$/.exec(file);
62
65
  if (m)
@@ -1,9 +1,11 @@
1
+ import { NATIVE_NOTICE_LEDGER_FILE, NATIVE_NOTICE_LEDGER_REFUSED, nativeNoticeLedgerUsable } from "./native-notice-ledger.js";
1
2
  /**
2
3
  * How old the daemon's machine-check results file may be and still count as
3
4
  * proof the schedule is running: two hourly intervals plus the first delay,
4
5
  * so one late or skipped batch does not flip the owner.
5
6
  */
6
7
  export declare const MACHINE_CHECK_RESULTS_FRESH_MS: number;
8
+ export { NATIVE_NOTICE_LEDGER_FILE, NATIVE_NOTICE_LEDGER_REFUSED, nativeNoticeLedgerUsable };
7
9
  /** Internal, offline protocol shared with the legacy dispatcher. */
8
10
  export declare function machineCheckOwner(env?: NodeJS.ProcessEnv, home?: string, options?: {
9
11
  now?: Date;