@indigoai-us/hq-cli 5.325.0 → 5.327.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/bin/hq-auth-refresh.js +2 -3
  3. package/dist/command-catalog.generated.d.ts +19 -1
  4. package/dist/command-catalog.generated.js +21 -1
  5. package/dist/commands/anywhere-runtime-flag.d.ts +2 -2
  6. package/dist/commands/anywhere-runtime-flag.js +2 -2
  7. package/dist/commands/auth.js +3 -1
  8. package/dist/commands/core-detect-stale-review-base-fast.d.ts +2 -0
  9. package/dist/commands/core-detect-stale-review-base-fast.js +23 -0
  10. package/dist/commands/core-job-remote-launcher.js +2 -3
  11. package/dist/commands/core-register-project-native.js +1 -1
  12. package/dist/commands/core-repo-run-registry-fast.d.ts +2 -0
  13. package/dist/commands/core-repo-run-registry-fast.js +35 -0
  14. package/dist/commands/core-rrr-worktree-scope-fix-fast-flag.d.ts +7 -0
  15. package/dist/commands/core-rrr-worktree-scope-fix-fast-flag.js +25 -0
  16. package/dist/commands/core-session-journal-native.js +1 -1
  17. package/dist/commands/core-share-suggestion-state-fast.d.ts +2 -0
  18. package/dist/commands/core-share-suggestion-state-fast.js +25 -0
  19. package/dist/commands/daemon.js +1 -1
  20. package/dist/commands/install-global.d.ts +10 -0
  21. package/dist/commands/install-global.js +96 -41
  22. package/dist/commands/logout.js +2 -0
  23. package/dist/commands/mcp-serve.d.ts +28 -0
  24. package/dist/commands/mcp-serve.js +165 -0
  25. package/dist/commands/mcp-status.js +14 -0
  26. package/dist/fast-core.js +3 -6
  27. package/dist/fast-scaffold.js +5 -1
  28. package/dist/index.d.ts +3 -0
  29. package/dist/index.js +9 -0
  30. package/dist/lanes-drain-hook.js +2 -2
  31. package/dist/lib/anywhere-runtime-fast-flag.d.ts +3 -0
  32. package/dist/lib/anywhere-runtime-fast-flag.js +23 -0
  33. package/dist/lib/anywhere-runtime-flag-key.d.ts +3 -0
  34. package/dist/lib/anywhere-runtime-flag-key.js +3 -0
  35. package/dist/lib/daemon/mcp-endpoint.d.ts +8 -0
  36. package/dist/lib/daemon/mcp-endpoint.js +30 -0
  37. package/dist/lib/daemon/mcp-oauth.d.ts +24 -0
  38. package/dist/lib/daemon/mcp-oauth.js +298 -0
  39. package/dist/lib/daemon/ops/mcp.d.ts +53 -0
  40. package/dist/lib/daemon/ops/mcp.js +217 -0
  41. package/dist/lib/daemon/protocol.d.ts +2 -1
  42. package/dist/lib/daemon/protocol.js +3 -1
  43. package/dist/lib/daemon/server.d.ts +5 -0
  44. package/dist/lib/daemon/server.js +78 -11
  45. package/dist/lib/install/claude-targets.d.ts +11 -4
  46. package/dist/lib/install/claude-targets.js +21 -9
  47. package/dist/lib/install/codex-targets.d.ts +8 -4
  48. package/dist/lib/install/codex-targets.js +18 -9
  49. package/dist/lib/lanes/watcher-main.js +2 -4
  50. package/dist/lib/mcp/hosted-search-tools.d.ts +4 -0
  51. package/dist/lib/mcp/hosted-search-tools.js +28 -0
  52. package/dist/lib/mcp/hq-mcp-tools.generated.d.ts +3 -0
  53. package/dist/lib/mcp/hq-mcp-tools.generated.js +538 -0
  54. package/dist/lib/mcp/prompts.d.ts +30 -0
  55. package/dist/lib/mcp/prompts.js +48 -0
  56. package/dist/lib/mcp/tools.d.ts +22 -0
  57. package/dist/lib/mcp/tools.js +82 -0
  58. package/dist/lib/mcp/types.d.ts +6 -0
  59. package/dist/lib/mcp/types.js +2 -0
  60. package/dist/lib/process-flag-company-context-fast.d.ts +4 -0
  61. package/dist/lib/process-flag-company-context-fast.js +20 -0
  62. package/dist/lib/process-flag-company-context-light.d.ts +9 -0
  63. package/dist/lib/process-flag-company-context-light.js +81 -0
  64. package/dist/lib/process-flag-company-context.d.ts +2 -4
  65. package/dist/lib/process-flag-company-context.js +2 -46
  66. package/dist/utils/hq-roots-core.d.ts +130 -0
  67. package/dist/utils/hq-roots-core.js +354 -0
  68. package/dist/utils/hq-roots.d.ts +2 -129
  69. package/dist/utils/hq-roots.js +2 -353
  70. package/dist/utils/is-main-module.d.ts +3 -0
  71. package/dist/utils/is-main-module.js +19 -0
  72. package/dist/utils/package-root-diagnostics.d.ts +5 -36
  73. package/dist/utils/package-root-diagnostics.js +4 -83
  74. package/dist/utils/package-root-resolution-error.d.ts +32 -0
  75. package/dist/utils/package-root-resolution-error.js +79 -0
  76. package/dist/utils/staged-npm-install.js +2 -1
  77. package/package.json +3 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [5.327.0] — 2026-10-02
6
+ - Reduce hook-time startup imports for repo-run-registry and isolate hook-helper handlers from sibling modules.
7
+ - Keep package-root Sentry diagnostics off the fast-route import path unless root diagnostics are needed.
8
+ - `hq mcp login` adds browser-based OAuth sign-in for hosted MCP.
9
+
10
+ ## [5.326.0] — 2026-10-02
11
+ - Company-scoped daemon tools now reject an explicit company that conflicts with the active session or repository binding.
12
+ - Added a flag-gated `hq mcp serve` command and global install hook for the Anywhere runtime.
13
+ - `hq mcp serve` can forward supported calls to hosted hq-mcp, including search and fetch, without a local hq-mcp process.
14
+ - Make standalone HQ auth refresh entry points run through npm bin symlinks.
15
+
5
16
  ## [5.325.0] — 2026-10-02
6
17
  - Match Bash pathname expansion in native derive-trigger-facts when a glob has missing suffixes, a trailing slash, or symlink path components.
7
18
 
@@ -15,8 +15,7 @@
15
15
  import "../node-preflight.js";
16
16
  import { acquireCurrentPackageUseLease } from "../utils/package-use-lease.js";
17
17
  import "../node-network-compat.js";
18
- import { fileURLToPath } from "node:url";
19
- import path from "node:path";
18
+ import { isMainModule } from "../utils/is-main-module.js";
20
19
  const MIN_VALIDITY_FLAG = "--min-validity-seconds";
21
20
  function parseMinimumValiditySeconds(argv, env) {
22
21
  let raw;
@@ -109,7 +108,7 @@ export async function startAuthRefresh(acquireLease = acquireCurrentPackageUseLe
109
108
  initSentry();
110
109
  return runAuthRefresh();
111
110
  }
112
- if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
111
+ if (isMainModule(import.meta.url)) {
113
112
  void startAuthRefresh().then((exitCode) => process.exit(exitCode));
114
113
  }
115
114
  //# sourceMappingURL=hq-auth-refresh.js.map
@@ -3720,6 +3720,24 @@ export declare const COMMAND_CATALOG: readonly [{
3720
3720
  readonly arguments: readonly [];
3721
3721
  readonly options: readonly [];
3722
3722
  readonly subcommands: readonly [{
3723
+ readonly name: "serve";
3724
+ readonly description: "Run the HQ stdio MCP server; every tool call is answered by hqd (`hq daemon status`)";
3725
+ readonly aliases: readonly [];
3726
+ readonly hidden: false;
3727
+ readonly usage: "[options]";
3728
+ readonly arguments: readonly [];
3729
+ readonly options: readonly [];
3730
+ readonly subcommands: readonly [];
3731
+ }, {
3732
+ readonly name: "login";
3733
+ readonly description: "Sign in to the hosted HQ MCP connector with browser OAuth";
3734
+ readonly aliases: readonly [];
3735
+ readonly hidden: false;
3736
+ readonly usage: "[options]";
3737
+ readonly arguments: readonly [];
3738
+ readonly options: readonly [];
3739
+ readonly subcommands: readonly [];
3740
+ }, {
3723
3741
  readonly name: "status";
3724
3742
  readonly description: "Show installed MCP packs/servers and their health in BOTH Claude and Codex (PARTIAL/DRIFT flagged; secrets redacted)";
3725
3743
  readonly aliases: readonly ["list"];
@@ -9927,7 +9945,7 @@ export declare const COMMAND_CATALOG: readonly [{
9927
9945
  readonly subcommands: readonly [];
9928
9946
  }, {
9929
9947
  readonly name: "call";
9930
- readonly description: "Send one request to hqd (policy.check, journal.append, memory.get, memory.put, mesh.presence, …) and print the result as JSON";
9948
+ readonly description: "Send one request to hqd (policy.check, journal.append, memory.get, memory.put, mesh.presence, mcp.call, …) and print the result as JSON";
9931
9949
  readonly aliases: readonly [];
9932
9950
  readonly hidden: false;
9933
9951
  readonly usage: "[options] <op>";
@@ -4801,6 +4801,26 @@ export const COMMAND_CATALOG = [
4801
4801
  "arguments": [],
4802
4802
  "options": [],
4803
4803
  "subcommands": [
4804
+ {
4805
+ "name": "serve",
4806
+ "description": "Run the HQ stdio MCP server; every tool call is answered by hqd (`hq daemon status`)",
4807
+ "aliases": [],
4808
+ "hidden": false,
4809
+ "usage": "[options]",
4810
+ "arguments": [],
4811
+ "options": [],
4812
+ "subcommands": []
4813
+ },
4814
+ {
4815
+ "name": "login",
4816
+ "description": "Sign in to the hosted HQ MCP connector with browser OAuth",
4817
+ "aliases": [],
4818
+ "hidden": false,
4819
+ "usage": "[options]",
4820
+ "arguments": [],
4821
+ "options": [],
4822
+ "subcommands": []
4823
+ },
4804
4824
  {
4805
4825
  "name": "status",
4806
4826
  "description": "Show installed MCP packs/servers and their health in BOTH Claude and Codex (PARTIAL/DRIFT flagged; secrets redacted)",
@@ -12789,7 +12809,7 @@ export const COMMAND_CATALOG = [
12789
12809
  },
12790
12810
  {
12791
12811
  "name": "call",
12792
- "description": "Send one request to hqd (policy.check, journal.append, memory.get, memory.put, mesh.presence, …) and print the result as JSON",
12812
+ "description": "Send one request to hqd (policy.check, journal.append, memory.get, memory.put, mesh.presence, mcp.call, …) and print the result as JSON",
12793
12813
  "aliases": [],
12794
12814
  "hidden": false,
12795
12815
  "usage": "[options] <op>",
@@ -1,5 +1,5 @@
1
- /** hq-flags key for the staged HQ Anywhere runtime. The registry default is off. */
2
- export declare const HQ_ANYWHERE_RUNTIME_FLAG = "hq-anywhere-runtime";
1
+ import { HQ_ANYWHERE_RUNTIME_FLAG } from "../lib/anywhere-runtime-flag-key.js";
2
+ export { HQ_ANYWHERE_RUNTIME_FLAG };
3
3
  export declare class AnywhereRuntimeDisabledError extends Error {
4
4
  readonly expected: true;
5
5
  constructor();
@@ -1,6 +1,6 @@
1
1
  import { resolveFlagGate, resolveProcessFlagGate } from "../lib/flag-registry.js";
2
- /** hq-flags key for the staged HQ Anywhere runtime. The registry default is off. */
3
- export const HQ_ANYWHERE_RUNTIME_FLAG = "hq-anywhere-runtime";
2
+ import { HQ_ANYWHERE_RUNTIME_FLAG } from "../lib/anywhere-runtime-flag-key.js";
3
+ export { HQ_ANYWHERE_RUNTIME_FLAG };
4
4
  export class AnywhereRuntimeDisabledError extends Error {
5
5
  expected = true;
6
6
  constructor() {
@@ -264,7 +264,9 @@ export function registerAuthCommands(program) {
264
264
  authCmd
265
265
  .command("logout")
266
266
  .description("Clear the cached HQ Cognito session")
267
- .action(() => {
267
+ .action(async () => {
268
+ const { clearMcpOAuthCaches } = await import("../lib/daemon/mcp-oauth.js");
269
+ clearMcpOAuthCaches();
268
270
  const existing = loadCachedTokens();
269
271
  if (!existing) {
270
272
  console.log(chalk.yellow("No cached HQ session"));
@@ -0,0 +1,2 @@
1
+ export declare function runDetectStaleReviewBaseFast(args: readonly string[], _stdin: string, _cwd: string, hqRoot: string | undefined): Promise<number>;
2
+ //# sourceMappingURL=core-detect-stale-review-base-fast.d.ts.map
@@ -0,0 +1,23 @@
1
+ /** Fast-route adapter isolated from the other hook-helper command modules. */
2
+ import { resolveBundledAsset } from "../utils/hq-roots-core.js";
3
+ import { runDetectStaleReviewBase, DETECT_STALE_REVIEW_BASE_ASSET } from "./core-detect-stale-review-base-native.js";
4
+ function writeResult(result) {
5
+ if (result.stdout)
6
+ process.stdout.write(result.stdout);
7
+ if (result.stderr)
8
+ process.stderr.write(result.stderr);
9
+ return result.code;
10
+ }
11
+ export async function runDetectStaleReviewBaseFast(args, _stdin, _cwd, hqRoot) {
12
+ let root = hqRoot;
13
+ if (!root) {
14
+ const { resolveLiveRoot } = await import("../utils/hq-roots-core.js");
15
+ root = resolveLiveRoot();
16
+ }
17
+ return writeResult(runDetectStaleReviewBase(args, {
18
+ cwd: root,
19
+ env: { ...process.env, HQ_ROOT: root },
20
+ scriptPath: resolveBundledAsset(DETECT_STALE_REVIEW_BASE_ASSET),
21
+ }));
22
+ }
23
+ //# sourceMappingURL=core-detect-stale-review-base-fast.js.map
@@ -1,7 +1,6 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import * as fs from "node:fs";
3
- import * as path from "node:path";
4
- import { fileURLToPath } from "node:url";
3
+ import { isMainModule } from "../utils/is-main-module.js";
5
4
  function signalNumber(signal) {
6
5
  if (!signal)
7
6
  return 0;
@@ -40,7 +39,7 @@ export async function runRemoteLauncher(argv, injected = {}) {
40
39
  await deps.sleep(15_000);
41
40
  return exitCode;
42
41
  }
43
- if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
42
+ if (isMainModule(import.meta.url)) {
44
43
  void runRemoteLauncher(process.argv.slice(2))
45
44
  .then((exitCode) => { process.exitCode = exitCode; })
46
45
  .catch((error) => {
@@ -4,7 +4,7 @@ import * as os from "node:os";
4
4
  import * as path from "node:path";
5
5
  import { spawnSync } from "node:child_process";
6
6
  import { serializeJqJson } from "../lib/core-utils/jq-json-serializer.js";
7
- import { resolveBundledAsset } from "../utils/hq-roots.js";
7
+ import { resolveBundledAsset } from "../utils/hq-roots-core.js";
8
8
  export const REGISTER_PROJECT_ASSET = "core/scripts/register-project.sh";
9
9
  const USAGE = "usage: register-project.sh <company> <project> | --audit <company> | --backfill <company> --only-active [--yes] | --retry-pending <company>";
10
10
  const MIN_HQ_CLI = "5.139.0";
@@ -0,0 +1,2 @@
1
+ export declare function runRepoRunRegistryFast(args: readonly string[], _stdin: string, _cwd: string, hqRoot: string | undefined, _commandName: string, _hqRootArg?: string, worktreeScopeFixEnabled?: boolean): Promise<number>;
2
+ //# sourceMappingURL=core-repo-run-registry-fast.d.ts.map
@@ -0,0 +1,35 @@
1
+ /** Fast-route adapter isolated from the other hook-helper command modules. */
2
+ import { runBundledScript } from "../utils/run-bundled-script.js";
3
+ import { runRepoRunRegistry, REPO_RUN_REGISTRY_ASSET } from "./core-repo-run-registry-native.js";
4
+ function writeResult(result) {
5
+ if (result.stdout)
6
+ process.stdout.write(result.stdout);
7
+ if (result.stderr)
8
+ process.stderr.write(result.stderr);
9
+ return result.code;
10
+ }
11
+ async function liveRoot(hqRoot) {
12
+ if (hqRoot)
13
+ return hqRoot;
14
+ const { resolveLiveRoot } = await import("../utils/hq-roots-core.js");
15
+ return resolveLiveRoot();
16
+ }
17
+ export async function runRepoRunRegistryFast(args, _stdin, _cwd, hqRoot, _commandName, _hqRootArg, worktreeScopeFixEnabled = false) {
18
+ const root = await liveRoot(hqRoot);
19
+ return writeResult(runRepoRunRegistry(args, {
20
+ root,
21
+ cwd: root,
22
+ env: process.env,
23
+ worktreeScopeFixEnabled,
24
+ runShellFallback: (fallbackArgs) => {
25
+ const { code } = runBundledScript({
26
+ asset: REPO_RUN_REGISTRY_ASSET,
27
+ args: [...fallbackArgs],
28
+ cwd: root,
29
+ hqRoot: root,
30
+ });
31
+ return { code, stdout: "", stderr: "" };
32
+ },
33
+ }));
34
+ }
35
+ //# sourceMappingURL=core-repo-run-registry-fast.js.map
@@ -0,0 +1,7 @@
1
+ /** Light company-scoped reader for the repo-run-registry worktree-scope flag. */
2
+ /**
3
+ * Resolve the same default-off, company-scoped flag without loading the full
4
+ * flag registry and work-context graph on the ordinary UID-scoped path.
5
+ */
6
+ export declare function coreRrrWorktreeScopeFixFastFlagEnabled(env?: NodeJS.ProcessEnv): Promise<boolean>;
7
+ //# sourceMappingURL=core-rrr-worktree-scope-fix-fast-flag.d.ts.map
@@ -0,0 +1,25 @@
1
+ /** Light company-scoped reader for the repo-run-registry worktree-scope flag. */
2
+ import { readLocalOverride } from "@indigoai-us/hq-flags-client";
3
+ import { readFlagSnapshotFile } from "../lib/flag-snapshot-file.js";
4
+ import { resolveFastProcessFlagCompanyContext } from "../lib/process-flag-company-context-fast.js";
5
+ /**
6
+ * Resolve the same default-off, company-scoped flag without loading the full
7
+ * flag registry and work-context graph on the ordinary UID-scoped path.
8
+ */
9
+ export async function coreRrrWorktreeScopeFixFastFlagEnabled(env = process.env) {
10
+ const flagKey = "core-rrr-worktree-scope-fix";
11
+ const override = readLocalOverride(flagKey, env);
12
+ if (override !== null)
13
+ return override;
14
+ try {
15
+ const context = await resolveFastProcessFlagCompanyContext(env);
16
+ if (!context.companyUid)
17
+ return false;
18
+ return readFlagSnapshotFile(context.companyUid, { env })?.flags[flagKey] === true;
19
+ }
20
+ catch {
21
+ // Keep the fast gate's established fail-closed default for unavailable scope or cache data.
22
+ return false;
23
+ }
24
+ }
25
+ //# sourceMappingURL=core-rrr-worktree-scope-fix-fast-flag.js.map
@@ -1,7 +1,7 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
3
  import { resolveSessionHelperRuntime } from "./core-session-helper-runtime.js";
4
- import { resolveBundledAsset } from "../utils/hq-roots.js";
4
+ import { resolveBundledAsset } from "../utils/hq-roots-core.js";
5
5
  const USAGE = `session-journal.sh: usage:
6
6
  session-journal.sh write "<title>" [--files f1,f2,...] [--body-file PATH] [--session KEY]
7
7
  session-journal.sh list [--date YYYY-MM-DD]
@@ -0,0 +1,2 @@
1
+ export declare function runShareSuggestionStateFast(args: readonly string[], stdin: string, _cwd: string, hqRoot: string | undefined): Promise<number>;
2
+ //# sourceMappingURL=core-share-suggestion-state-fast.d.ts.map
@@ -0,0 +1,25 @@
1
+ /** Fast-route adapter isolated from the other hook-helper command modules. */
2
+ import { runShareSuggestionState } from "./core-share-suggestion-state-native.js";
3
+ function writeResult(result) {
4
+ if (result.stdout)
5
+ process.stdout.write(result.stdout);
6
+ if (result.stderr)
7
+ process.stderr.write(result.stderr);
8
+ return result.code;
9
+ }
10
+ async function liveRoot(hqRoot) {
11
+ if (hqRoot)
12
+ return hqRoot;
13
+ const { resolveLiveRoot } = await import("../utils/hq-roots-core.js");
14
+ return resolveLiveRoot();
15
+ }
16
+ export async function runShareSuggestionStateFast(args, stdin, _cwd, hqRoot) {
17
+ const root = await liveRoot(hqRoot);
18
+ return writeResult(runShareSuggestionState(args, stdin, {
19
+ root,
20
+ cwd: root,
21
+ env: process.env,
22
+ stdinIsTty: process.stdin.isTTY,
23
+ }));
24
+ }
25
+ //# sourceMappingURL=core-share-suggestion-state-fast.js.map
@@ -769,7 +769,7 @@ export function registerDaemonCommand(program, over = {}) {
769
769
  }));
770
770
  daemon
771
771
  .command("call <op>")
772
- .description("Send one request to hqd (policy.check, journal.append, memory.get, memory.put, mesh.presence, …) and print the result as JSON")
772
+ .description("Send one request to hqd (policy.check, journal.append, memory.get, memory.put, mesh.presence, mcp.call, …) and print the result as JSON")
773
773
  .option("--json <args>", "Request args as a JSON object", "{}")
774
774
  .option("--timeout <ms>", "Give up after this many milliseconds")
775
775
  .action(wrap(async (d, op, opts) => {
@@ -1,5 +1,6 @@
1
1
  import { Command } from 'commander';
2
2
  import { AnywhereRuntimeDisabledError } from './anywhere-runtime-flag.js';
3
+ import { type HookTarget } from '../lib/install/claude-targets.js';
3
4
  export interface GlobalInstallOptions {
4
5
  /** HQ checkout to install from (absolute). */
5
6
  hqRoot: string;
@@ -14,7 +15,16 @@ export interface GlobalInstallOptions {
14
15
  /** Registry file override (default ~/.hq/registry.json under `home`). */
15
16
  registryFile?: string;
16
17
  log?: (line: string) => void;
18
+ /** Is the hq daemon installed? Default: look for its launchd/systemd unit under `home`. */
19
+ daemonInstalled?: boolean;
17
20
  }
21
+ /** True when an hq daemon unit (launchd plist or systemd unit) exists. */
22
+ export declare function isDaemonInstalled(home: string, platform?: NodeJS.Platform, queryTask?: (task: string) => boolean): boolean;
23
+ /**
24
+ * US-010: with hqd installed (and the checkout shipping the shim), hooks go to
25
+ * the hqd shim; otherwise to master-hook.sh / the Codex adapter.
26
+ */
27
+ export declare function hookTargetFor(hqRoot: string, home: string, daemonInstalled?: boolean, env?: NodeJS.ProcessEnv): HookTarget;
18
28
  export { AnywhereRuntimeDisabledError as AnywhereDisabledError };
19
29
  export declare const isAnywhereEnabled: (_home: string, env?: NodeJS.ProcessEnv) => boolean;
20
30
  /** Install HQ into Claude Code user scope. Returns the files touched (or that would be). */