@indigoai-us/hq-cloud 5.48.4 → 6.0.1

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 (55) hide show
  1. package/dist/cli/index.d.ts +2 -2
  2. package/dist/cli/index.d.ts.map +1 -1
  3. package/dist/cli/index.js +2 -2
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/cli/reindex.d.ts +23 -0
  6. package/dist/cli/reindex.d.ts.map +1 -0
  7. package/dist/cli/reindex.js +45 -0
  8. package/dist/cli/reindex.js.map +1 -0
  9. package/dist/cli/reindex.test.d.ts +11 -0
  10. package/dist/cli/reindex.test.d.ts.map +1 -0
  11. package/dist/cli/{master-sync.test.js → reindex.test.js} +15 -15
  12. package/dist/cli/reindex.test.js.map +1 -0
  13. package/dist/cli/rescue.d.ts.map +1 -1
  14. package/dist/cli/rescue.js +16 -1
  15. package/dist/cli/rescue.js.map +1 -1
  16. package/dist/cli/rescue.reindex.test.d.ts +2 -0
  17. package/dist/cli/rescue.reindex.test.d.ts.map +1 -0
  18. package/dist/cli/rescue.reindex.test.js +41 -0
  19. package/dist/cli/rescue.reindex.test.js.map +1 -0
  20. package/dist/cli/share.d.ts.map +1 -1
  21. package/dist/cli/share.js +21 -1
  22. package/dist/cli/share.js.map +1 -1
  23. package/dist/cli/share.test.js +108 -2
  24. package/dist/cli/share.test.js.map +1 -1
  25. package/dist/cli/sync.d.ts +9 -0
  26. package/dist/cli/sync.d.ts.map +1 -1
  27. package/dist/cli/sync.js +17 -0
  28. package/dist/cli/sync.js.map +1 -1
  29. package/dist/cli/sync.test.js +20 -0
  30. package/dist/cli/sync.test.js.map +1 -1
  31. package/dist/index.d.ts +2 -2
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +2 -2
  34. package/dist/index.js.map +1 -1
  35. package/package.json +1 -1
  36. package/scripts/{master-sync.sh → reindex.sh} +10 -10
  37. package/scripts/replace-rescue.sh +20 -20
  38. package/src/cli/index.ts +3 -3
  39. package/src/cli/{master-sync.test.ts → reindex.test.ts} +14 -14
  40. package/src/cli/reindex.ts +57 -0
  41. package/src/cli/rescue.reindex.test.ts +46 -0
  42. package/src/cli/rescue.ts +15 -1
  43. package/src/cli/share.test.ts +138 -2
  44. package/src/cli/share.ts +23 -1
  45. package/src/cli/sync.test.ts +23 -0
  46. package/src/cli/sync.ts +27 -0
  47. package/src/index.ts +3 -3
  48. package/dist/cli/master-sync.d.ts +0 -22
  49. package/dist/cli/master-sync.d.ts.map +0 -1
  50. package/dist/cli/master-sync.js +0 -44
  51. package/dist/cli/master-sync.js.map +0 -1
  52. package/dist/cli/master-sync.test.d.ts +0 -11
  53. package/dist/cli/master-sync.test.d.ts.map +0 -1
  54. package/dist/cli/master-sync.test.js.map +0 -1
  55. package/src/cli/master-sync.ts +0 -56
@@ -36,8 +36,15 @@ vi.mock("../s3.js", async () => {
36
36
  };
37
37
  });
38
38
 
39
+ // Mock the post-sync refresh so tests neither spawn the real reindex.sh nor
40
+ // mutate the temp hqRoot, and we can assert the wiring directly.
41
+ vi.mock("./reindex.js", () => ({
42
+ reindex: vi.fn(() => ({ status: 0 })),
43
+ }));
44
+
39
45
  import { sync } from "./sync.js";
40
46
  import * as s3Module from "../s3.js";
47
+ import { reindex } from "./reindex.js";
41
48
 
42
49
  const mockConfig: VaultServiceConfig = {
43
50
  apiUrl: "https://vault-api.test",
@@ -114,6 +121,22 @@ describe("sync", () => {
114
121
  delete process.env.HQ_STATE_DIR;
115
122
  });
116
123
 
124
+ it("runs reindex against hqRoot after a sync that downloaded files", async () => {
125
+ await sync({ company: "acme", vaultConfig: mockConfig, hqRoot: tmpDir });
126
+ expect(reindex).toHaveBeenCalledWith({ repoRoot: tmpDir });
127
+ });
128
+
129
+ it("skips reindex when skipReindex is set", async () => {
130
+ const result = await sync({
131
+ company: "acme",
132
+ vaultConfig: mockConfig,
133
+ hqRoot: tmpDir,
134
+ skipReindex: true,
135
+ });
136
+ expect(result.filesDownloaded).toBe(2);
137
+ expect(reindex).not.toHaveBeenCalled();
138
+ });
139
+
117
140
  it("downloads remote files under companies/{slug}/ so two companies don't collide", async () => {
118
141
  const result = await sync({
119
142
  company: "acme",
package/src/cli/sync.ts CHANGED
@@ -49,6 +49,7 @@ import {
49
49
  readShortMachineId,
50
50
  } from "../lib/conflict-file.js";
51
51
  import { appendConflictEntry } from "../lib/conflict-index.js";
52
+ import { reindex } from "./reindex.js";
52
53
 
53
54
  /**
54
55
  * Per-file events emitted by `sync()` as it progresses.
@@ -329,6 +330,15 @@ export interface SyncOptions {
329
330
  * tombstoned. Mirrors `hq sync narrow --force`.
330
331
  */
331
332
  forceScopeShrink?: boolean;
333
+ /**
334
+ * Skip the post-sync `reindex()` refresh (skill wrappers + personal overlay
335
+ * mirrors + workers registry). By default, when a sync changes on-disk
336
+ * sources (downloads, tombstones, or scope-orphan removals), `sync()`
337
+ * re-runs reindex so the generated `.claude/skills/<ns>:<skill>` wrappers
338
+ * stay in sync. An orchestrator syncing many companies in one pass can set
339
+ * this and run `reindex()` once itself instead of per-company.
340
+ */
341
+ skipReindex?: boolean;
332
342
  }
333
343
 
334
344
  export interface SyncResult {
@@ -1263,6 +1273,23 @@ export async function sync(options: SyncOptions): Promise<SyncResult> {
1263
1273
  journal.lastSync = new Date().toISOString();
1264
1274
  writeJournal(journalSlug, journal);
1265
1275
 
1276
+ // When the pull actually changed on-disk sources (new files, tombstoned
1277
+ // removals, or scope-orphan cleanups), refresh the generated skill wrappers,
1278
+ // personal-overlay mirrors, and workers registry. reindex is idempotent and
1279
+ // best-effort — it must never fail a sync, and is skipped on no-op syncs
1280
+ // (the common daemon case) and when the caller opts out via skipReindex.
1281
+ const changedOnDisk =
1282
+ filesDownloaded > 0 ||
1283
+ filesTombstoned > 0 ||
1284
+ shrinkResult.cleanRemoved > 0;
1285
+ if (!options.skipReindex && changedOnDisk) {
1286
+ try {
1287
+ reindex({ repoRoot: hqRoot });
1288
+ } catch {
1289
+ // best-effort: a post-sync refresh failure never fails the sync
1290
+ }
1291
+ }
1292
+
1266
1293
  return {
1267
1294
  filesDownloaded,
1268
1295
  bytesDownloaded,
package/src/index.ts CHANGED
@@ -212,9 +212,9 @@ export type { AcceptOptions, AcceptResult } from "./cli/index.js";
212
212
  export { promote } from "./cli/index.js";
213
213
  export type { PromoteOptions, PromoteResult } from "./cli/index.js";
214
214
 
215
- // Skill/personal-overlay mirroring + workers-registry regen (`hq master-sync`).
216
- export { masterSync, masterSyncScriptPath } from "./cli/index.js";
217
- export type { MasterSyncOptions, MasterSyncResult } from "./cli/index.js";
215
+ // Skill/personal-overlay mirroring + workers-registry regen (`hq reindex`).
216
+ export { reindex, reindexScriptPath } from "./cli/index.js";
217
+ export type { ReindexOptions, ReindexResult } from "./cli/index.js";
218
218
 
219
219
  // Drift-preserving HQ-core re-sync — shared by the HQ Sync app and `hq rescue`.
220
220
  export { rescue, rescueScriptPath, buildRescueArgs } from "./cli/index.js";
@@ -1,22 +0,0 @@
1
- /**
2
- * Absolute path to the bundled master-sync.sh. From the compiled module at
3
- * dist/cli/master-sync.js, the package root is two levels up; the script lives
4
- * at <package-root>/scripts/master-sync.sh.
5
- */
6
- export declare function masterSyncScriptPath(): string;
7
- export interface MasterSyncOptions {
8
- /** HQ root to operate on. Defaults to process.cwd(). */
9
- repoRoot?: string;
10
- }
11
- export interface MasterSyncResult {
12
- /** Exit status of the underlying script (0 = success). */
13
- status: number;
14
- }
15
- /**
16
- * Run master-sync against an HQ root. Synchronous — the script is cheap and
17
- * idempotent, and callers (the hook shim, tests) want the exit status.
18
- * stdout/stderr from the script are forwarded to stderr so the caller's stdout
19
- * stays clean (hooks must not emit stdout that the agent interprets).
20
- */
21
- export declare function masterSync(opts?: MasterSyncOptions): MasterSyncResult;
22
- //# sourceMappingURL=master-sync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"master-sync.d.ts","sourceRoot":"","sources":["../../src/cli/master-sync.ts"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED,MAAM,WAAW,iBAAiB;IAChC,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,GAAE,iBAAsB,GAAG,gBAAgB,CAWzE"}
@@ -1,44 +0,0 @@
1
- /**
2
- * hq master-sync — surfaces namespaced skills as Claude Code skill wrappers,
3
- * mirrors personal/{knowledge,policies,workers,settings} into core/, prunes
4
- * orphan wrappers, and regenerates the workers registry.
5
- *
6
- * The implementation lives in scripts/master-sync.sh, shipped with this
7
- * package. This module resolves that script relative to the package (dist/cli
8
- * → package root) and execs it against the caller's HQ root. Historically the
9
- * script ran directly as a Claude Code hook inside hq-core; it now lives here
10
- * so a single copy is maintained, and the hq-core hook is a thin shim over
11
- * `hq master-sync`.
12
- */
13
- import { spawnSync } from "child_process";
14
- import { fileURLToPath } from "url";
15
- import path from "path";
16
- const __filename = fileURLToPath(import.meta.url);
17
- const __dirname = path.dirname(__filename);
18
- /**
19
- * Absolute path to the bundled master-sync.sh. From the compiled module at
20
- * dist/cli/master-sync.js, the package root is two levels up; the script lives
21
- * at <package-root>/scripts/master-sync.sh.
22
- */
23
- export function masterSyncScriptPath() {
24
- return path.resolve(__dirname, "..", "..", "scripts", "master-sync.sh");
25
- }
26
- /**
27
- * Run master-sync against an HQ root. Synchronous — the script is cheap and
28
- * idempotent, and callers (the hook shim, tests) want the exit status.
29
- * stdout/stderr from the script are forwarded to stderr so the caller's stdout
30
- * stays clean (hooks must not emit stdout that the agent interprets).
31
- */
32
- export function masterSync(opts = {}) {
33
- const repoRoot = opts.repoRoot ?? process.cwd();
34
- const script = masterSyncScriptPath();
35
- const res = spawnSync("bash", [script, repoRoot], {
36
- stdio: ["ignore", "inherit", "inherit"],
37
- });
38
- if (res.error) {
39
- process.stderr.write(`master-sync: failed to run ${script}: ${res.error.message}\n`);
40
- return { status: 1 };
41
- }
42
- return { status: res.status ?? 1 };
43
- }
44
- //# sourceMappingURL=master-sync.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"master-sync.js","sourceRoot":"","sources":["../../src/cli/master-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAC1E,CAAC;AAYD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAA0B,EAAE;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAChD,MAAM,MAAM,GAAG,oBAAoB,EAAE,CAAC;IACtC,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE;QAChD,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;KACxC,CAAC,CAAC;IACH,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;QACrF,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACvB,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;AACrC,CAAC"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Unit tests for `hq master-sync` (the formerly-bash hq-core hook, now shipped
3
- * in this package and invoked via the CLI).
4
- *
5
- * The logic itself lives in scripts/master-sync.sh; these tests exercise it via
6
- * the masterSync() wrapper against a temp HQ tree, asserting the observable
7
- * filesystem outcomes (skill wrappers, personal-overlay mirroring) rather than
8
- * re-deriving the bash internals.
9
- */
10
- export {};
11
- //# sourceMappingURL=master-sync.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"master-sync.test.d.ts","sourceRoot":"","sources":["../../src/cli/master-sync.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"master-sync.test.js","sourceRoot":"","sources":["../../src/cli/master-sync.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,CAAC,GAAG,oBAAoB,EAAE,CAAC;QACjC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtE,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAA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CAAC,CAAC,CAAC,CAAC;QACtD,MAAM,CACJ,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,mCAAmC,CAAC,CAAC,CACtE,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,56 +0,0 @@
1
- /**
2
- * hq master-sync — surfaces namespaced skills as Claude Code skill wrappers,
3
- * mirrors personal/{knowledge,policies,workers,settings} into core/, prunes
4
- * orphan wrappers, and regenerates the workers registry.
5
- *
6
- * The implementation lives in scripts/master-sync.sh, shipped with this
7
- * package. This module resolves that script relative to the package (dist/cli
8
- * → package root) and execs it against the caller's HQ root. Historically the
9
- * script ran directly as a Claude Code hook inside hq-core; it now lives here
10
- * so a single copy is maintained, and the hq-core hook is a thin shim over
11
- * `hq master-sync`.
12
- */
13
- import { spawnSync } from "child_process";
14
- import { fileURLToPath } from "url";
15
- import path from "path";
16
-
17
- const __filename = fileURLToPath(import.meta.url);
18
- const __dirname = path.dirname(__filename);
19
-
20
- /**
21
- * Absolute path to the bundled master-sync.sh. From the compiled module at
22
- * dist/cli/master-sync.js, the package root is two levels up; the script lives
23
- * at <package-root>/scripts/master-sync.sh.
24
- */
25
- export function masterSyncScriptPath(): string {
26
- return path.resolve(__dirname, "..", "..", "scripts", "master-sync.sh");
27
- }
28
-
29
- export interface MasterSyncOptions {
30
- /** HQ root to operate on. Defaults to process.cwd(). */
31
- repoRoot?: string;
32
- }
33
-
34
- export interface MasterSyncResult {
35
- /** Exit status of the underlying script (0 = success). */
36
- status: number;
37
- }
38
-
39
- /**
40
- * Run master-sync against an HQ root. Synchronous — the script is cheap and
41
- * idempotent, and callers (the hook shim, tests) want the exit status.
42
- * stdout/stderr from the script are forwarded to stderr so the caller's stdout
43
- * stays clean (hooks must not emit stdout that the agent interprets).
44
- */
45
- export function masterSync(opts: MasterSyncOptions = {}): MasterSyncResult {
46
- const repoRoot = opts.repoRoot ?? process.cwd();
47
- const script = masterSyncScriptPath();
48
- const res = spawnSync("bash", [script, repoRoot], {
49
- stdio: ["ignore", "inherit", "inherit"],
50
- });
51
- if (res.error) {
52
- process.stderr.write(`master-sync: failed to run ${script}: ${res.error.message}\n`);
53
- return { status: 1 };
54
- }
55
- return { status: res.status ?? 1 };
56
- }