@indigoai-us/hq-cli 5.345.252 → 5.345.253

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 (43) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/contracts/host-canary-release.json +5 -5
  3. package/dist/command-catalog.generated.d.ts +148 -0
  4. package/dist/command-catalog.generated.js +182 -0
  5. package/dist/command-registration-plan.d.ts +6 -0
  6. package/dist/command-registration-plan.js +1 -0
  7. package/dist/commands/ci-intake.d.ts +15 -0
  8. package/dist/commands/ci-intake.js +252 -0
  9. package/dist/commands/ci-metrics.d.ts +8 -0
  10. package/dist/commands/ci-metrics.js +55 -0
  11. package/dist/commands/ci.d.ts +13 -0
  12. package/dist/commands/ci.js +10 -0
  13. package/dist/commands/files.d.ts +62 -0
  14. package/dist/commands/files.js +249 -8
  15. package/dist/lib/bot/fleet-cron.d.ts +15 -0
  16. package/dist/lib/bot/fleet-cron.js +119 -20
  17. package/dist/lib/daemon/run.js +4 -3
  18. package/dist/lib/delivery/migrations.d.ts +32 -1
  19. package/dist/lib/delivery/migrations.js +69 -8
  20. package/dist/lib/hook-engine/adapter-core-pin.d.ts +2 -1
  21. package/dist/lib/hook-engine/adapter-core-pin.js +2 -1
  22. package/dist/lib/hook-engine/coverage.d.ts +15 -0
  23. package/dist/lib/hook-engine/coverage.js +62 -1
  24. package/dist/lib/smart-ci/cost.d.ts +72 -0
  25. package/dist/lib/smart-ci/cost.js +120 -0
  26. package/dist/lib/smart-ci/github.d.ts +112 -0
  27. package/dist/lib/smart-ci/github.js +267 -0
  28. package/dist/lib/smart-ci/intake.d.ts +288 -0
  29. package/dist/lib/smart-ci/intake.js +1078 -0
  30. package/dist/lib/smart-ci/ledger.d.ts +218 -0
  31. package/dist/lib/smart-ci/ledger.js +527 -0
  32. package/dist/lib/smart-ci/metrics.d.ts +137 -0
  33. package/dist/lib/smart-ci/metrics.js +249 -0
  34. package/dist/lib/smart-ci/records.d.ts +265 -0
  35. package/dist/lib/smart-ci/records.js +281 -0
  36. package/dist/lib/smart-ci/reducer.d.ts +67 -0
  37. package/dist/lib/smart-ci/reducer.js +261 -0
  38. package/dist/lib/sync-core/engine-holds.d.ts +14 -0
  39. package/dist/lib/sync-core/engine-holds.js +78 -11
  40. package/dist/lib/sync-core/hand-back.d.ts +1 -0
  41. package/dist/lib/sync-core/hand-back.js +7 -2
  42. package/dist/lib/sync-core/reconcile.js +10 -2
  43. package/package.json +9 -7
@@ -104,7 +104,17 @@ export function readEngineHoldKinds(engineHome, vaultUid) {
104
104
  return [];
105
105
  }
106
106
  }
107
- export function readEngineHeldDeletes(engineHome, vaultUid, warn = () => { }) {
107
+ export const ENGINE_HOLD_DIRECTIONS = [
108
+ "delete_local",
109
+ "delete_remote",
110
+ "overwrite_local",
111
+ "overwrite_remote",
112
+ "merge",
113
+ "undecided",
114
+ "not_approvable",
115
+ ];
116
+ const LOCAL_BODY_DIRECTIONS = new Set(["overwrite_remote", "merge", "undecided", "not_approvable"]);
117
+ function readEngineHold(engineHome, vaultUid) {
108
118
  let text;
109
119
  try {
110
120
  const file = engineHoldFile(engineHome, vaultUid);
@@ -114,7 +124,7 @@ export function readEngineHeldDeletes(engineHome, vaultUid, warn = () => { }) {
114
124
  text = fs.readFileSync(file, "utf8");
115
125
  }
116
126
  catch (error) {
117
- return error.code === "ENOENT" ? null : "unreadable";
127
+ return error.code === "ENOENT" ? null : "read-failed";
118
128
  }
119
129
  let hold;
120
130
  try {
@@ -125,6 +135,21 @@ export function readEngineHeldDeletes(engineHome, vaultUid, warn = () => { }) {
125
135
  }
126
136
  if (!hold || !Array.isArray(hold.groups))
127
137
  return "unreadable";
138
+ return hold;
139
+ }
140
+ function groupPaths(group) {
141
+ return Array.isArray(group.paths) ? group.paths.filter((p) => typeof p === "string") : [];
142
+ }
143
+ function groupCount(group, paths) {
144
+ const declared = typeof group.count === "number" && Number.isSafeInteger(group.count) && group.count >= 0 ? group.count : 0;
145
+ return Math.max(paths.length, declared);
146
+ }
147
+ export function readEngineHeldDeletes(engineHome, vaultUid, warn = () => { }) {
148
+ const hold = readEngineHold(engineHome, vaultUid);
149
+ if (hold === null)
150
+ return null;
151
+ if (hold === "unreadable" || hold === "read-failed")
152
+ return "unreadable";
128
153
  const deletes = [];
129
154
  const unknown = new Set();
130
155
  let count = 0;
@@ -132,25 +157,67 @@ export function readEngineHeldDeletes(engineHome, vaultUid, warn = () => { }) {
132
157
  const group = record(value);
133
158
  if (!group || typeof group.direction !== "string")
134
159
  return "unreadable";
135
- if (group.direction === "overwrite_local")
160
+ const direction = group.direction;
161
+ if (direction === "overwrite_local" || LOCAL_BODY_DIRECTIONS.has(direction))
136
162
  continue;
137
- if (group.direction !== "delete_local" && group.direction !== "delete_remote") {
138
- if (!unknown.has(group.direction)) {
139
- unknown.add(group.direction);
140
- warn(`${vaultUid}: the new sync engine's hold file ${engineHoldFile(engineHome, vaultUid)} has a kind of hold this hq does not know (direction ${JSON.stringify(group.direction.slice(0, 64))}); it is not passed to the current sync, the deletes held beside it are`);
163
+ if (direction !== "delete_local" && direction !== "delete_remote") {
164
+ if (!unknown.has(direction) && groupCount(group, groupPaths(group)) > 0) {
165
+ unknown.add(direction);
166
+ warn(`${vaultUid}: the new sync engine's hold file ${engineHoldFile(engineHome, vaultUid)} has a kind of hold this hq does not know (direction ${printable(direction.slice(0, 64))}); the vault is not handed to the current sync while it is held, so its local copies stay as they are`);
141
167
  }
142
168
  continue;
143
169
  }
144
- const paths = Array.isArray(group.paths) ? group.paths.filter((p) => typeof p === "string") : [];
145
- const declared = typeof group.count === "number" && Number.isSafeInteger(group.count) && group.count >= 0 ? group.count : 0;
146
- count += Math.max(paths.length, declared);
170
+ const paths = groupPaths(group);
171
+ count += groupCount(group, paths);
147
172
  for (const p of paths)
148
- deletes.push({ path: p, direction: group.direction });
173
+ deletes.push({ path: p, direction });
149
174
  }
150
175
  if (count === 0)
151
176
  return null;
152
177
  return { ...(typeof hold.holdId === "string" && hold.holdId ? { holdId: hold.holdId } : {}), count, deletes };
153
178
  }
179
+ export function readEngineHeldLocalBodies(engineHome, vaultUid) {
180
+ const hold = readEngineHold(engineHome, vaultUid);
181
+ if (hold === null || hold === "unreadable")
182
+ return null;
183
+ if (hold === "read-failed")
184
+ return { count: 0, paths: [], directions: [], readFailed: true };
185
+ const paths = [];
186
+ const directions = new Set();
187
+ let count = 0;
188
+ for (const value of hold.groups) {
189
+ const group = record(value) ?? {};
190
+ const direction = typeof group.direction === "string" ? group.direction : "unknown";
191
+ if (direction === "delete_local" || direction === "delete_remote" || direction === "overwrite_local")
192
+ continue;
193
+ const held = groupPaths(group);
194
+ const n = typeof group.direction === "string" ? groupCount(group, held) : Math.max(1, groupCount(group, held));
195
+ if (n === 0)
196
+ continue;
197
+ count += n;
198
+ directions.add(direction);
199
+ for (const p of held)
200
+ paths.push({ path: p, direction });
201
+ }
202
+ if (count === 0)
203
+ return null;
204
+ return {
205
+ ...(typeof hold.holdId === "string" && hold.holdId ? { holdId: hold.holdId } : {}),
206
+ count,
207
+ paths,
208
+ directions: [...directions].sort(),
209
+ };
210
+ }
211
+ export function heldLocalBodiesHandoverLine(vaultUid, held) {
212
+ if (held.readFailed) {
213
+ return `${vaultUid}: not handed back to the current sync yet: the new sync engine's hold file could not be read just now, so it may hold local copies the current sync would replace; the vault stays off both syncs until the file can be read`;
214
+ }
215
+ const shown = held.paths.slice(0, HELD_DELETE_LOG_LIMIT).map((entry) => printable(entry.path));
216
+ const more = held.count > shown.length ? `; and ${held.count - shown.length} more` : "";
217
+ const id = held.holdId ? ` (hold ${/^[A-Za-z0-9_-]{1,64}$/.test(held.holdId) ? held.holdId : printable(held.holdId)})` : "";
218
+ const kinds = held.directions.map((direction) => printable(direction.slice(0, 64))).join(", ");
219
+ return `${vaultUid}: not handed back to the current sync yet: the new sync engine held ${held.count} change${held.count === 1 ? "" : "s"} that keep this device's copy (${kinds})${id}, and the current sync would replace those local copies with the vault's; the local copies stay as they are and the vault stays off both syncs until the new sync engine can run this vault again and the hold is decided: ${shown.join(", ")}${more}`;
220
+ }
154
221
  function printable(value) {
155
222
  return JSON.stringify(value);
156
223
  }
@@ -7,6 +7,7 @@ export interface HandBackVault {
7
7
  legacyAlreadyOff?: boolean;
8
8
  }
9
9
  export declare function engineOwnsVault(home: string, uid: string): boolean;
10
+ export declare function engineHoldBlocksHandBack(home: string, uid: string): boolean;
10
11
  /**
11
12
  * Returns vaults whose engine has stopped to the current sync: turns the
12
13
  * old-sync switch back on (not for a vault the user had off before the move),
@@ -2,11 +2,15 @@ import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
3
  import { legacySwitchRestorePatch, writeVaultSyncSwitches } from "../vault-sync-switches.js";
4
4
  import { removeEngineOwnership, syncCoreEngineHome } from "./engine-home.js";
5
+ import { readEngineHeldLocalBodies } from "./engine-holds.js";
5
6
  import { removeLegacyJournalExport } from "./legacy-journal-export.js";
6
7
  const reportedRemovalFailures = new Set();
7
8
  export function engineOwnsVault(home, uid) {
8
9
  return fs.existsSync(path.join(syncCoreEngineHome(home, uid), ".hq", "sync-core", "owned", `${uid}.json`));
9
10
  }
11
+ export function engineHoldBlocksHandBack(home, uid) {
12
+ return readEngineHeldLocalBodies(syncCoreEngineHome(home, uid), uid) !== null;
13
+ }
10
14
  /**
11
15
  * Returns vaults whose engine has stopped to the current sync: turns the
12
16
  * old-sync switch back on (not for a vault the user had off before the move),
@@ -15,10 +19,11 @@ export function engineOwnsVault(home, uid) {
15
19
  * before removing any record when menubar.json cannot be written.
16
20
  */
17
21
  export function finishLegacyHandBack(home, vaults, switches, warn = (line) => void process.stderr.write(`${line}\n`), removeExport = removeLegacyJournalExport) {
18
- const patch = legacySwitchRestorePatch(vaults, switches);
22
+ const ready = vaults.filter((vault) => !engineHoldBlocksHandBack(home, vault.uid));
23
+ const patch = legacySwitchRestorePatch(ready, switches);
19
24
  if (patch.personal || Object.keys(patch.companies).length > 0)
20
25
  writeVaultSyncSwitches(home, patch);
21
- for (const vault of vaults) {
26
+ for (const vault of ready) {
22
27
  const key = `${home}\0${vault.uid}`;
23
28
  try {
24
29
  removeExport(home, vault);
@@ -7,7 +7,7 @@ import { clearEngineStatus, engineFirstCycle, isSyncCoreVaultUid, removeEngineOw
7
7
  import { SYNC_CORE_FULL_RELEASE, SYNC_CORE_RELEASE, compareSyncCoreReleases, fullModeAllowed, installedSyncCoreRelease, syncCoreBinaryPath, windowsFullRelease, } from "./release.js";
8
8
  import { readSyncCoreSkips } from "./skip.js";
9
9
  import { isLiveCompanyEntity, joinedCompanySlug, setUpJoinedCompany } from "./company-adoption.js";
10
- import { heldDeletesHandoverLine, readEngineHeldDeletes, writeHandbackKeep } from "./engine-holds.js";
10
+ import { heldDeletesHandoverLine, heldLocalBodiesHandoverLine, readEngineHeldDeletes, readEngineHeldLocalBodies, writeHandbackKeep } from "./engine-holds.js";
11
11
  import { dropStaleLegacyJournalExport, legacyJournalDirs, legacyJournalExportState, markLegacyJournalExportStale, removeLegacyJournalExport, writeLegacyJournalExport, } from "./legacy-journal-export.js";
12
12
  import { SYNC_RUST_ENGINE_ROLLOUT_FLAG } from "./flag.js";
13
13
  import { readSyncCoreRolloutState, syncCoreRolloutStatePath, writeSyncCoreRolloutState, } from "./rollout-state.js";
@@ -400,7 +400,10 @@ export async function reconcileSyncCore(deps) {
400
400
  warnings.push(`could not record the ${heldDeletes.count} deletes the new sync engine held for ${vault.uid}; the current sync may apply them: ${message(error)}`);
401
401
  }
402
402
  }
403
- if (heldDeletes)
403
+ const heldLocalBodies = readEngineHeldLocalBodies(engineHome, vault.uid);
404
+ if (heldLocalBodies)
405
+ handover.push(heldLocalBodiesHandoverLine(vault.uid, heldLocalBodies));
406
+ else if (heldDeletes)
404
407
  handover.push(heldDeletesHandoverLine(vault.uid, heldDeletes, engineHome, deps.home));
405
408
  handedBack.push(vault);
406
409
  }
@@ -410,6 +413,11 @@ export async function reconcileSyncCore(deps) {
410
413
  && !handedBack.some((back) => back.uid === vault.uid)
411
414
  && engineOwnsVault(deps.home, vault.uid)),
412
415
  ];
416
+ for (const vault of handingBack) {
417
+ const heldLocalBodies = readEngineHeldLocalBodies(syncCoreEngineHome(deps.home, vault.uid), vault.uid);
418
+ if (heldLocalBodies)
419
+ warnings.push(heldLocalBodiesHandoverLine(vault.uid, heldLocalBodies));
420
+ }
413
421
  for (const company of companiesHere) {
414
422
  if (desired.some((vault) => vault.uid === company.uid) || handingBack.some((vault) => vault.uid === company.uid))
415
423
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.345.252",
3
+ "version": "5.345.253",
4
4
  "description": "HQ by Indigo management CLI — modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -55,6 +55,8 @@
55
55
  "postinstall": "node scripts/install-hook-engine.mjs || node -e \"process.exit(0)\"",
56
56
  "prepare": "husky || true",
57
57
  "check:no-hermes": "bash scripts/check-no-hermes.sh",
58
+ "changelog:check": "node scripts/changelog-fragment.mjs check",
59
+ "changelog:new": "node scripts/changelog-fragment.mjs new",
58
60
  "prepack": "node scripts/hook-engine-manifest.mjs",
59
61
  "postpublish": "node scripts/hook-engine-manifest.mjs restore",
60
62
  "build:ci": "node scripts/prepare-fixture-privacy-baseline.mjs && pnpm run build"
@@ -126,11 +128,11 @@
126
128
  "*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
127
129
  },
128
130
  "optionalDependencies": {
129
- "@indigoai-us/hq-hook-win32-x64": "5.345.252",
130
- "@indigoai-us/hq-hook-win32-arm64": "5.345.252",
131
- "@indigoai-us/hq-hook-darwin-x64": "5.345.252",
132
- "@indigoai-us/hq-hook-darwin-arm64": "5.345.252",
133
- "@indigoai-us/hq-hook-linux-x64": "5.345.252",
134
- "@indigoai-us/hq-hook-linux-arm64": "5.345.252"
131
+ "@indigoai-us/hq-hook-win32-x64": "5.345.253",
132
+ "@indigoai-us/hq-hook-win32-arm64": "5.345.253",
133
+ "@indigoai-us/hq-hook-darwin-x64": "5.345.253",
134
+ "@indigoai-us/hq-hook-darwin-arm64": "5.345.253",
135
+ "@indigoai-us/hq-hook-linux-x64": "5.345.253",
136
+ "@indigoai-us/hq-hook-linux-arm64": "5.345.253"
135
137
  }
136
138
  }