@indigoai-us/hq-cli 5.345.220 → 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.
- package/CHANGELOG.md +164 -0
- package/dist/command-catalog.generated.d.ts +175 -2
- package/dist/command-catalog.generated.js +213 -2
- package/dist/commands/auth.js +6 -2
- package/dist/commands/bot-runtime.d.ts +18 -5
- package/dist/commands/bot-runtime.js +29 -12
- package/dist/commands/bot.d.ts +39 -2
- package/dist/commands/bot.js +140 -11
- package/dist/commands/core-delegate-w1b.js +9 -3
- package/dist/commands/core-stop-autosave.d.ts +21 -0
- package/dist/commands/core-stop-autosave.js +300 -0
- package/dist/commands/core.js +2 -0
- package/dist/commands/daemon.d.ts +6 -0
- package/dist/commands/daemon.js +46 -8
- package/dist/commands/doctor-usage.d.ts +5 -0
- package/dist/commands/doctor-usage.js +25 -0
- package/dist/commands/env.d.ts +49 -4
- package/dist/commands/env.js +355 -5
- package/dist/commands/lanes-shared.d.ts +3 -0
- package/dist/commands/lanes.d.ts +3 -0
- package/dist/commands/lanes.js +87 -3
- package/dist/commands/link.d.ts +2 -0
- package/dist/commands/link.js +14 -2
- package/dist/commands/mesh.js +23 -3
- package/dist/commands/sources.js +3 -3
- package/dist/commands/sync-core.d.ts +7 -0
- package/dist/commands/sync-core.js +132 -3
- package/dist/commands/whoami.js +96 -80
- package/dist/data/command-states.json +3 -0
- package/dist/lib/bot/config.d.ts +17 -0
- package/dist/lib/bot/config.js +13 -0
- package/dist/lib/bot/fleet-cron.js +24 -2
- package/dist/lib/bot/fleet-local.d.ts +30 -2
- package/dist/lib/bot/fleet-local.js +60 -1
- package/dist/lib/bot/grok-login-scope.d.ts +36 -0
- package/dist/lib/bot/grok-login-scope.js +93 -0
- package/dist/lib/bot/legacy-provider-login.d.ts +32 -9
- package/dist/lib/bot/legacy-provider-login.js +28 -22
- package/dist/lib/bot/runtime-sign-in-check.js +6 -1
- package/dist/lib/bot/runtime-sign-in.d.ts +2 -0
- package/dist/lib/core-utils/sentry-report.js +2 -0
- package/dist/lib/daemon/catalog.js +2 -0
- package/dist/lib/daemon/install.d.ts +2 -1
- package/dist/lib/daemon/install.js +9 -0
- package/dist/lib/daemon/legacy.d.ts +1 -0
- package/dist/lib/daemon/legacy.js +5 -2
- package/dist/lib/daemon/machine-check-owner.d.ts +2 -0
- package/dist/lib/daemon/machine-check-owner.js +6 -1
- package/dist/lib/daemon/machine-checks.d.ts +29 -2
- package/dist/lib/daemon/machine-checks.js +64 -13
- package/dist/lib/daemon/mesh-owner.d.ts +45 -0
- package/dist/lib/daemon/mesh-owner.js +166 -0
- package/dist/lib/daemon/native-notice-ledger.d.ts +27 -0
- package/dist/lib/daemon/native-notice-ledger.js +113 -0
- package/dist/lib/daemon/run.d.ts +15 -0
- package/dist/lib/daemon/run.js +137 -11
- package/dist/lib/daemon/selfcheck.d.ts +35 -2
- package/dist/lib/daemon/selfcheck.js +118 -9
- package/dist/lib/daemon/stop-autosave-lock.d.ts +19 -0
- package/dist/lib/daemon/stop-autosave-lock.js +166 -0
- package/dist/lib/daemon/stop-autosave.d.ts +28 -0
- package/dist/lib/daemon/stop-autosave.js +111 -0
- package/dist/lib/daemon/stop-diagnostics.d.ts +11 -0
- package/dist/lib/daemon/stop-diagnostics.js +136 -0
- package/dist/lib/daemon/stop-job-executor.d.ts +19 -0
- package/dist/lib/daemon/stop-job-executor.js +126 -0
- package/dist/lib/daemon/stop-jobs.d.ts +93 -0
- package/dist/lib/daemon/stop-jobs.js +599 -0
- package/dist/lib/doctor/checks/fleet-hook-core.js +1 -1
- package/dist/lib/doctor/checks/host-core.js +1 -1
- package/dist/lib/environment/access-probes.d.ts +234 -0
- package/dist/lib/environment/access-probes.js +918 -0
- package/dist/lib/environment/profile.d.ts +15 -2
- package/dist/lib/environment/profile.js +55 -20
- package/dist/lib/environment/rfc3339.d.ts +8 -0
- package/dist/lib/environment/rfc3339.js +26 -0
- package/dist/lib/environment/work-requirements.d.ts +169 -0
- package/dist/lib/environment/work-requirements.js +389 -0
- package/dist/lib/hook-engine/coverage.d.ts +146 -7
- package/dist/lib/hook-engine/coverage.js +1480 -4
- package/dist/lib/hook-engine/fleet-registration.js +2 -2
- package/dist/lib/hook-engine/git-stop-config.json +513 -0
- package/dist/lib/hook-engine/native-stop-compatibility.json +362 -0
- package/dist/lib/hook-engine/reconcile.js +2 -2
- package/dist/lib/hot-channels/alert.d.ts +2 -2
- package/dist/lib/hot-channels/alert.js +8 -5
- package/dist/lib/hot-channels/signals-pass.d.ts +126 -17
- package/dist/lib/hot-channels/signals-pass.js +296 -17
- package/dist/lib/hot-channels/signals-runtime.d.ts +30 -0
- package/dist/lib/hot-channels/signals-runtime.js +82 -0
- package/dist/lib/install/hook-target.js +1 -1
- package/dist/lib/lanes/host-capacity.d.ts +26 -2
- package/dist/lib/lanes/host-capacity.js +17 -2
- package/dist/lib/lanes/host-compute.d.ts +90 -0
- package/dist/lib/lanes/host-compute.js +185 -0
- package/dist/lib/lanes/index.d.ts +2 -0
- package/dist/lib/lanes/index.js +1 -0
- package/dist/lib/lanes/reconcile.js +22 -1
- package/dist/lib/lanes/resource-usage.d.ts +155 -0
- package/dist/lib/lanes/resource-usage.js +589 -0
- package/dist/lib/lanes/run-size.d.ts +46 -0
- package/dist/lib/lanes/run-size.js +197 -0
- package/dist/lib/lanes/store.js +27 -0
- package/dist/lib/lanes/throttle.d.ts +36 -1
- package/dist/lib/lanes/throttle.js +47 -10
- package/dist/lib/lanes/types.d.ts +40 -0
- package/dist/lib/lanes/types.js +2 -2
- package/dist/lib/lanes/watcher.js +13 -4
- package/dist/lib/lanes/worker-process.d.ts +25 -2
- package/dist/lib/lanes/worker-process.js +71 -19
- package/dist/lib/mesh/live/daemon/config.d.ts +8 -1
- package/dist/lib/mesh/live/daemon/config.js +16 -0
- package/dist/lib/mesh/live/daemon/install.d.ts +31 -2
- package/dist/lib/mesh/live/daemon/install.js +142 -1
- package/dist/lib/mesh/live/daemon/login-home.d.ts +5 -0
- package/dist/lib/mesh/live/daemon/login-home.js +27 -0
- package/dist/lib/mesh/live/daemon/unit-home.d.ts +49 -0
- package/dist/lib/mesh/live/daemon/unit-home.js +134 -0
- package/dist/lib/placement/match.d.ts +192 -0
- package/dist/lib/placement/match.js +667 -0
- package/dist/lib/registry/registry.d.ts +35 -7
- package/dist/lib/registry/registry.js +88 -13
- package/dist/lib/safe-store.d.ts +14 -0
- package/dist/lib/safe-store.js +77 -4
- package/dist/lib/scan-packages/index.js +24 -2
- package/dist/lib/search-index/index.d.ts +88 -4
- package/dist/lib/search-index/index.js +288 -24
- package/dist/lib/search-index/max-doc-bytes.d.ts +17 -6
- package/dist/lib/search-index/max-doc-bytes.js +49 -23
- package/dist/lib/service-manager/startup-migration.d.ts +1 -0
- package/dist/lib/service-manager/startup-migration.js +3 -0
- package/dist/lib/signals/codex-lockdown.d.ts +79 -0
- package/dist/lib/signals/codex-lockdown.js +271 -0
- package/dist/lib/signals/codex-login.d.ts +37 -0
- package/dist/lib/signals/codex-login.js +83 -0
- package/dist/lib/signals/engine.d.ts +27 -0
- package/dist/lib/signals/engine.js +70 -0
- package/dist/lib/signals/reply.js +22 -1
- package/dist/lib/signals/run-record.js +6 -1
- package/dist/lib/signals/settings.d.ts +5 -0
- package/dist/lib/signals/settings.js +2 -0
- package/dist/lib/signals/steps/extract.d.ts +85 -9
- package/dist/lib/signals/steps/extract.js +317 -68
- package/dist/lib/signals/steps/types.d.ts +2 -0
- package/dist/lib/sync-core/engine-holds.d.ts +14 -0
- package/dist/lib/sync-core/engine-holds.js +60 -0
- package/dist/lib/sync-core/engine-home.d.ts +37 -1
- package/dist/lib/sync-core/engine-home.js +119 -16
- package/dist/lib/sync-core/reconcile.js +8 -0
- package/dist/lib/sync-core/rollout-state.d.ts +2 -1
- package/dist/lib/sync-core/rollout-state.js +5 -2
- package/dist/lib/sync-core/vault-settings.d.ts +21 -0
- package/dist/lib/sync-core/vault-settings.js +131 -0
- package/dist/lib/sync-core/vault-uid.d.ts +2 -0
- package/dist/lib/sync-core/vault-uid.js +4 -0
- package/dist/lib/windows/install-followup.d.ts +2 -0
- package/dist/lib/windows/install-followup.js +4 -1
- package/dist/schemas/hq-work-requirements.v1.schema.json +145 -0
- package/dist/utils/auth-session-check.d.ts +16 -0
- package/dist/utils/auth-session-check.js +16 -0
- package/dist/utils/client-health-contract.d.ts +6 -0
- package/dist/utils/client-health-contract.js +13 -0
- package/dist/utils/client-health.d.ts +7 -0
- package/dist/utils/client-health.js +22 -1
- package/dist/utils/command-usage.d.ts +40 -0
- package/dist/utils/command-usage.js +61 -0
- package/dist/utils/duplicate-command-usage.d.ts +72 -0
- package/dist/utils/duplicate-command-usage.js +125 -0
- package/dist/utils/host-registration.js +5 -2
- package/dist/utils/pack-contributions.d.ts +3 -0
- package/dist/utils/pack-contributions.js +110 -23
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/self-update.d.ts +3 -1
- package/dist/utils/self-update.js +56 -11
- package/dist/utils/sentry-fingerprint.js +9 -0
- package/dist/utils/update-lock.d.ts +151 -14
- package/dist/utils/update-lock.js +782 -46
- package/dist/utils/version-gate.js +12 -2
- package/dist/utils/windows-bash.d.ts +2 -0
- package/dist/utils/windows-bash.js +2 -1
- package/package.json +9 -8
- package/scripts/bench-core-compare.mjs +313 -0
- package/scripts/bench-core.mjs +399 -12
- package/scripts/check-function-manifest.mjs +116 -3
|
@@ -21,7 +21,7 @@ export interface Registry {
|
|
|
21
21
|
export type ResolveResult = {
|
|
22
22
|
company: string;
|
|
23
23
|
key: string;
|
|
24
|
-
source: RegistrySource;
|
|
24
|
+
source: RegistrySource | "layout";
|
|
25
25
|
} | {
|
|
26
26
|
company: null;
|
|
27
27
|
reason: string;
|
|
@@ -50,11 +50,35 @@ export declare function remoteForDir(dir: string): string | null;
|
|
|
50
50
|
export declare function keyForDir(dir: string): string;
|
|
51
51
|
/** Every key that could describe `dir`, most specific first. */
|
|
52
52
|
export declare function candidateKeys(dir: string): string[];
|
|
53
|
+
export interface ResolveOptions {
|
|
54
|
+
/**
|
|
55
|
+
* The caller's own HQ root. The companies/<slug> layout fallback only runs
|
|
56
|
+
* inside this tree; without it the fallback is off.
|
|
57
|
+
*/
|
|
58
|
+
hqRoot?: string | null;
|
|
59
|
+
}
|
|
53
60
|
/**
|
|
54
61
|
* Resolve the company for `dir`. Among matching keys the highest-ranked source
|
|
55
62
|
* wins (link > prompt > manifest); ties go to the more specific key.
|
|
63
|
+
* With no registry hit, `opts.hqRoot` enables the companies/<slug> layout.
|
|
56
64
|
*/
|
|
57
|
-
export declare function resolveCompanyForDir(registry: Registry, dir: string): ResolveResult;
|
|
65
|
+
export declare function resolveCompanyForDir(registry: Registry, dir: string, opts?: ResolveOptions): ResolveResult;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve `<hqRoot>/companies/<slug>/**` from HQ's own tree. A companies/<slug>
|
|
68
|
+
* folder is the company; it does not use the enclosing HQ git remote.
|
|
69
|
+
*
|
|
70
|
+
* Only the caller's own HQ root counts. A `companies/<slug>` folder in any
|
|
71
|
+
* other tree (a cloned repo, another HQ copy) never binds a company: a folder
|
|
72
|
+
* name alone must not grant a tenant. The walk uses the symlink-resolved path,
|
|
73
|
+
* and the slug must be listed in that root's companies/manifest.yaml.
|
|
74
|
+
*/
|
|
75
|
+
export declare function companyFromHqLayout(dir: string, hqRoot: string): {
|
|
76
|
+
company: string;
|
|
77
|
+
key: string;
|
|
78
|
+
source: "layout";
|
|
79
|
+
} | null;
|
|
80
|
+
/** True when `hq link` would write a key for the enclosing git repo, not this folder. */
|
|
81
|
+
export declare function wouldBindEnclosingRemote(dir: string): boolean;
|
|
58
82
|
export declare function setEntry(registry: Registry, key: string, company: string, source: RegistrySource, now?: Date): RegistryEntry;
|
|
59
83
|
/** Remove every key that describes `dir`. Returns the removed keys. */
|
|
60
84
|
export declare function removeEntriesForDir(registry: Registry, dir: string): string[];
|
|
@@ -64,12 +88,16 @@ export interface SeedResult {
|
|
|
64
88
|
skippedLinked: string[];
|
|
65
89
|
ambiguous: string[];
|
|
66
90
|
}
|
|
91
|
+
/** Resolve a manifest repos[] entry to a local filesystem path. */
|
|
92
|
+
export declare function expandManifestLocalPath(raw: string, hqRoot: string, home?: string): string;
|
|
67
93
|
/**
|
|
68
94
|
* Seed manifest-sourced entries from companies/manifest.yaml repos[]. Entries
|
|
69
|
-
* may be HQ-relative paths (`repos/private/x`), `owner/name`,
|
|
70
|
-
* A local path seeds both its path key and, when it has an
|
|
71
|
-
*
|
|
72
|
-
*
|
|
95
|
+
* may be HQ-relative paths (`repos/private/x`), `~/checkout`, `owner/name`,
|
|
96
|
+
* or remote URLs. A local path seeds both its path key and, when it has an
|
|
97
|
+
* origin, its remote key. `~/…` expands to the home directory; a missing
|
|
98
|
+
* tilde path is skipped rather than treated as `github.com/~/…`. Never
|
|
99
|
+
* overwrites a `link` or `prompt` entry, and skips any key claimed by more
|
|
100
|
+
* than one company.
|
|
73
101
|
*/
|
|
74
|
-
export declare function seedFromManifest(registry: Registry, hqRoot: string, companies: CompaniesManifestMap, now?: Date): SeedResult;
|
|
102
|
+
export declare function seedFromManifest(registry: Registry, hqRoot: string, companies: CompaniesManifestMap, now?: Date, home?: string): SeedResult;
|
|
75
103
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -13,6 +13,9 @@ import * as path from "node:path";
|
|
|
13
13
|
import { atomicWriteJson } from "../work-context/atomic.js";
|
|
14
14
|
import { findEnclosingGitDir, findWorkTreeRoot, readOriginRemoteUrl, } from "../work-context/repo-remote.js";
|
|
15
15
|
import { normalizeManifestRepo, normalizeRemoteUrl } from "./normalize-remote.js";
|
|
16
|
+
import { parseManifestSlugs } from "../core-utils/manifest-slugs.js";
|
|
17
|
+
/** Company slugs HQ stores under `companies/<slug>/`. */
|
|
18
|
+
const COMPANY_SLUG = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
16
19
|
/** Higher wins. An explicit `hq link` beats a prompt answer beats the manifest seed. */
|
|
17
20
|
const SOURCE_RANK = { link: 3, prompt: 2, manifest: 1 };
|
|
18
21
|
export class RegistryFormatError extends Error {
|
|
@@ -146,8 +149,9 @@ export function candidateKeys(dir) {
|
|
|
146
149
|
/**
|
|
147
150
|
* Resolve the company for `dir`. Among matching keys the highest-ranked source
|
|
148
151
|
* wins (link > prompt > manifest); ties go to the more specific key.
|
|
152
|
+
* With no registry hit, `opts.hqRoot` enables the companies/<slug> layout.
|
|
149
153
|
*/
|
|
150
|
-
export function resolveCompanyForDir(registry, dir) {
|
|
154
|
+
export function resolveCompanyForDir(registry, dir, opts = {}) {
|
|
151
155
|
let best = null;
|
|
152
156
|
for (const key of candidateKeys(dir)) {
|
|
153
157
|
const entry = registry.entries[key];
|
|
@@ -157,13 +161,67 @@ export function resolveCompanyForDir(registry, dir) {
|
|
|
157
161
|
best = { key, entry };
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
|
-
if (
|
|
161
|
-
return {
|
|
162
|
-
company: null,
|
|
163
|
-
reason: `No HQ company is linked to ${canonicalDir(dir)}. Run \`hq link <company>\` there.`,
|
|
164
|
-
};
|
|
164
|
+
if (best) {
|
|
165
|
+
return { company: best.entry.company, key: best.key, source: best.entry.source };
|
|
165
166
|
}
|
|
166
|
-
|
|
167
|
+
const layout = opts.hqRoot ? companyFromHqLayout(dir, opts.hqRoot) : null;
|
|
168
|
+
if (layout)
|
|
169
|
+
return layout;
|
|
170
|
+
return {
|
|
171
|
+
company: null,
|
|
172
|
+
reason: `No HQ company is linked to ${canonicalDir(dir)}. Run \`hq link <company>\` there.`,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Resolve `<hqRoot>/companies/<slug>/**` from HQ's own tree. A companies/<slug>
|
|
177
|
+
* folder is the company; it does not use the enclosing HQ git remote.
|
|
178
|
+
*
|
|
179
|
+
* Only the caller's own HQ root counts. A `companies/<slug>` folder in any
|
|
180
|
+
* other tree (a cloned repo, another HQ copy) never binds a company: a folder
|
|
181
|
+
* name alone must not grant a tenant. The walk uses the symlink-resolved path,
|
|
182
|
+
* and the slug must be listed in that root's companies/manifest.yaml.
|
|
183
|
+
*/
|
|
184
|
+
export function companyFromHqLayout(dir, hqRoot) {
|
|
185
|
+
const root = canonicalDir(hqRoot);
|
|
186
|
+
const companiesDir = path.join(root, "companies");
|
|
187
|
+
const real = canonicalDir(dir);
|
|
188
|
+
const rel = path.relative(companiesDir, real);
|
|
189
|
+
if (!rel || rel.startsWith("..") || path.isAbsolute(rel))
|
|
190
|
+
return null;
|
|
191
|
+
const slug = rel.split(path.sep)[0];
|
|
192
|
+
if (!COMPANY_SLUG.test(slug) || slug === "personal")
|
|
193
|
+
return null;
|
|
194
|
+
const cur = path.join(companiesDir, slug);
|
|
195
|
+
let st;
|
|
196
|
+
try {
|
|
197
|
+
st = fs.lstatSync(cur);
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
if (st.isSymbolicLink() || !st.isDirectory())
|
|
203
|
+
return null;
|
|
204
|
+
let manifest;
|
|
205
|
+
try {
|
|
206
|
+
manifest = fs.readFileSync(path.join(companiesDir, "manifest.yaml"), "utf8");
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
if (!parseManifestSlugs(manifest).includes(slug))
|
|
212
|
+
return null;
|
|
213
|
+
return { company: slug, key: pathKey(dir), source: "layout" };
|
|
214
|
+
}
|
|
215
|
+
/** True when `hq link` would write a key for the enclosing git repo, not this folder. */
|
|
216
|
+
export function wouldBindEnclosingRemote(dir) {
|
|
217
|
+
const workTree = findWorkTreeRoot(dir);
|
|
218
|
+
if (!workTree)
|
|
219
|
+
return false;
|
|
220
|
+
if (canonicalDir(dir) === canonicalDir(workTree))
|
|
221
|
+
return false;
|
|
222
|
+
// Any key other than the folder's own path key covers the whole enclosing
|
|
223
|
+
// repo: its origin, or (no origin) the work-tree root's path key.
|
|
224
|
+
return keyForDir(dir) !== pathKey(dir);
|
|
167
225
|
}
|
|
168
226
|
export function setEntry(registry, key, company, source, now = new Date()) {
|
|
169
227
|
const entry = { company, source, linkedAt: now.toISOString() };
|
|
@@ -181,14 +239,28 @@ export function removeEntriesForDir(registry, dir) {
|
|
|
181
239
|
}
|
|
182
240
|
return removed;
|
|
183
241
|
}
|
|
242
|
+
/** Resolve a manifest repos[] entry to a local filesystem path. */
|
|
243
|
+
export function expandManifestLocalPath(raw, hqRoot, home = os.homedir()) {
|
|
244
|
+
const trimmed = raw.trim();
|
|
245
|
+
if (trimmed === "~")
|
|
246
|
+
return home;
|
|
247
|
+
if (trimmed.startsWith("~/") || trimmed.startsWith("~\\")) {
|
|
248
|
+
return path.join(home, trimmed.slice(2));
|
|
249
|
+
}
|
|
250
|
+
if (path.isAbsolute(trimmed))
|
|
251
|
+
return trimmed;
|
|
252
|
+
return path.join(hqRoot, trimmed);
|
|
253
|
+
}
|
|
184
254
|
/**
|
|
185
255
|
* Seed manifest-sourced entries from companies/manifest.yaml repos[]. Entries
|
|
186
|
-
* may be HQ-relative paths (`repos/private/x`), `owner/name`,
|
|
187
|
-
* A local path seeds both its path key and, when it has an
|
|
188
|
-
*
|
|
189
|
-
*
|
|
256
|
+
* may be HQ-relative paths (`repos/private/x`), `~/checkout`, `owner/name`,
|
|
257
|
+
* or remote URLs. A local path seeds both its path key and, when it has an
|
|
258
|
+
* origin, its remote key. `~/…` expands to the home directory; a missing
|
|
259
|
+
* tilde path is skipped rather than treated as `github.com/~/…`. Never
|
|
260
|
+
* overwrites a `link` or `prompt` entry, and skips any key claimed by more
|
|
261
|
+
* than one company.
|
|
190
262
|
*/
|
|
191
|
-
export function seedFromManifest(registry, hqRoot, companies, now = new Date()) {
|
|
263
|
+
export function seedFromManifest(registry, hqRoot, companies, now = new Date(), home = os.homedir()) {
|
|
192
264
|
const claimGroups = [];
|
|
193
265
|
for (const [company, entry] of Object.entries(companies)) {
|
|
194
266
|
const repos = entry && typeof entry === "object" ? entry.repos : undefined;
|
|
@@ -198,7 +270,7 @@ export function seedFromManifest(registry, hqRoot, companies, now = new Date())
|
|
|
198
270
|
if (typeof raw !== "string" || !raw.trim())
|
|
199
271
|
continue;
|
|
200
272
|
const trimmed = raw.trim();
|
|
201
|
-
const local =
|
|
273
|
+
const local = expandManifestLocalPath(trimmed, hqRoot, home);
|
|
202
274
|
let isDir;
|
|
203
275
|
try {
|
|
204
276
|
isDir = fs.statSync(local).isDirectory();
|
|
@@ -214,6 +286,9 @@ export function seedFromManifest(registry, hqRoot, companies, now = new Date())
|
|
|
214
286
|
claimGroups.push({ company, keys });
|
|
215
287
|
continue;
|
|
216
288
|
}
|
|
289
|
+
if (trimmed === "~" || trimmed.startsWith("~/") || trimmed.startsWith("~\\")) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
217
292
|
const normalized = normalizeManifestRepo(trimmed);
|
|
218
293
|
if (normalized)
|
|
219
294
|
claimGroups.push({ company, keys: [remoteKey(normalized)] });
|
package/dist/lib/safe-store.d.ts
CHANGED
|
@@ -155,6 +155,10 @@ export interface OpenStoreDirOptions {
|
|
|
155
155
|
export interface ReadOptions {
|
|
156
156
|
/** Refuse a file larger than this. Default 1 MiB. */
|
|
157
157
|
maxBytes?: number;
|
|
158
|
+
/** Read a bounded window from an append-only queue rather than the whole file. */
|
|
159
|
+
offset?: number;
|
|
160
|
+
/** Include the opened file's device/inode identity for queue cursors. */
|
|
161
|
+
identity?: boolean;
|
|
158
162
|
}
|
|
159
163
|
export interface AppendOptions {
|
|
160
164
|
/** Refuse to append when the file is already this size or larger. */
|
|
@@ -173,6 +177,7 @@ export interface FileFacts {
|
|
|
173
177
|
/** FileFacts plus the exact modification time in nanoseconds (mtimeMs is a float and can round across a millisecond). */
|
|
174
178
|
export interface ReadFacts extends FileFacts {
|
|
175
179
|
mtimeNs: bigint;
|
|
180
|
+
fileIdentity?: string;
|
|
176
181
|
}
|
|
177
182
|
export interface RenameOptions {
|
|
178
183
|
/** Waits in milliseconds between rename attempts on EPERM, EACCES or EBUSY (Windows). Empty: no retry. */
|
|
@@ -212,9 +217,18 @@ export interface SafeStore {
|
|
|
212
217
|
remove(name: string): SafeStoreResult<boolean>;
|
|
213
218
|
/** The names in the folder. */
|
|
214
219
|
list(): SafeStoreResult<string[]>;
|
|
220
|
+
/** Read directory names in bounded batches without materializing the directory. */
|
|
221
|
+
nameCursor(): SafeStoreResult<SafeStoreNameCursor>;
|
|
215
222
|
/** Release the held folder. Later calls are refused with "closed". */
|
|
216
223
|
close(): void;
|
|
217
224
|
}
|
|
225
|
+
export interface SafeStoreNameCursor {
|
|
226
|
+
read(maxNames: number): SafeStoreResult<{
|
|
227
|
+
names: string[];
|
|
228
|
+
done: boolean;
|
|
229
|
+
}>;
|
|
230
|
+
close(): void;
|
|
231
|
+
}
|
|
218
232
|
/** A plain file name: no separator, no NUL, not "." or "..", at most 255 bytes. */
|
|
219
233
|
export declare function isPlainName(name: string): boolean;
|
|
220
234
|
/** Owner and mode facts a check needs, from fs.Stats or fs.BigIntStats. */
|
package/dist/lib/safe-store.js
CHANGED
|
@@ -602,12 +602,17 @@ class HeldStore {
|
|
|
602
602
|
return opened;
|
|
603
603
|
const { fd, stat } = opened.value;
|
|
604
604
|
try {
|
|
605
|
-
|
|
605
|
+
const offset = options.offset ?? 0;
|
|
606
|
+
if (!Number.isSafeInteger(offset) || offset < 0)
|
|
607
|
+
return refusal("io-error", "invalid read offset");
|
|
608
|
+
if (options.offset === undefined && stat.size > BigInt(maxBytes))
|
|
606
609
|
return refusal("too-large", `the file is larger than ${maxBytes} bytes`);
|
|
607
|
-
const buffer = Buffer.alloc(maxBytes + 1);
|
|
610
|
+
const buffer = Buffer.alloc(maxBytes + (options.offset === undefined ? 1 : 0));
|
|
608
611
|
let length = 0;
|
|
609
612
|
for (;;) {
|
|
610
|
-
|
|
613
|
+
if (length === buffer.length)
|
|
614
|
+
break;
|
|
615
|
+
const count = fs.readSync(fd, buffer, length, buffer.length - length, offset + length);
|
|
611
616
|
if (count === 0)
|
|
612
617
|
break;
|
|
613
618
|
length += count;
|
|
@@ -615,7 +620,8 @@ class HeldStore {
|
|
|
615
620
|
return refusal("too-large", `the file is larger than ${maxBytes} bytes`);
|
|
616
621
|
}
|
|
617
622
|
// Bigint stats round mtimeMs down to a whole millisecond; mtimeNs keeps the fraction.
|
|
618
|
-
const facts = { size: length, mtimeMs: Number(stat.mtimeNs) / 1e6, mtimeNs: stat.mtimeNs
|
|
623
|
+
const facts = { size: length, mtimeMs: Number(stat.mtimeNs) / 1e6, mtimeNs: stat.mtimeNs,
|
|
624
|
+
...(options.identity ? { fileIdentity: `${stat.dev}:${stat.ino}` } : {}) };
|
|
619
625
|
return { ok: true, value: { data: Buffer.from(buffer.subarray(0, length)), facts } };
|
|
620
626
|
}
|
|
621
627
|
catch (error) {
|
|
@@ -759,6 +765,73 @@ class HeldStore {
|
|
|
759
765
|
return afterList;
|
|
760
766
|
return { ok: true, value: names };
|
|
761
767
|
}
|
|
768
|
+
nameCursor() {
|
|
769
|
+
const refused = this.start("list");
|
|
770
|
+
if (refused)
|
|
771
|
+
return refused;
|
|
772
|
+
let directory;
|
|
773
|
+
try {
|
|
774
|
+
directory = fs.opendirSync(this.base, { bufferSize: 32 });
|
|
775
|
+
}
|
|
776
|
+
catch (error) {
|
|
777
|
+
return ioError("opening directory cursor", error);
|
|
778
|
+
}
|
|
779
|
+
let closed = false;
|
|
780
|
+
const close = () => {
|
|
781
|
+
if (closed)
|
|
782
|
+
return;
|
|
783
|
+
closed = true;
|
|
784
|
+
try {
|
|
785
|
+
directory.closeSync();
|
|
786
|
+
}
|
|
787
|
+
catch { /* already closed */ }
|
|
788
|
+
};
|
|
789
|
+
const checked = this.check();
|
|
790
|
+
if (checked) {
|
|
791
|
+
close();
|
|
792
|
+
return checked;
|
|
793
|
+
}
|
|
794
|
+
return { ok: true, value: {
|
|
795
|
+
close,
|
|
796
|
+
read: (maxNames) => {
|
|
797
|
+
const before = this.start("list");
|
|
798
|
+
if (before) {
|
|
799
|
+
close();
|
|
800
|
+
return before;
|
|
801
|
+
}
|
|
802
|
+
if (closed)
|
|
803
|
+
return { ok: true, value: { names: [], done: true } };
|
|
804
|
+
if (!Number.isSafeInteger(maxNames) || maxNames < 1 || maxNames > 256) {
|
|
805
|
+
close();
|
|
806
|
+
return ioError("reading directory cursor", new Error("invalid batch size"));
|
|
807
|
+
}
|
|
808
|
+
const names = [];
|
|
809
|
+
let done = false;
|
|
810
|
+
try {
|
|
811
|
+
while (names.length < maxNames) {
|
|
812
|
+
const entry = directory.readSync();
|
|
813
|
+
if (!entry) {
|
|
814
|
+
done = true;
|
|
815
|
+
close();
|
|
816
|
+
break;
|
|
817
|
+
}
|
|
818
|
+
names.push(entry.name);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
catch (error) {
|
|
822
|
+
close();
|
|
823
|
+
return ioError("reading directory cursor", error);
|
|
824
|
+
}
|
|
825
|
+
this.at("after-list", "list");
|
|
826
|
+
const after = this.check();
|
|
827
|
+
if (after) {
|
|
828
|
+
close();
|
|
829
|
+
return after;
|
|
830
|
+
}
|
|
831
|
+
return { ok: true, value: { names, done } };
|
|
832
|
+
},
|
|
833
|
+
} };
|
|
834
|
+
}
|
|
762
835
|
close() {
|
|
763
836
|
if (this.closed)
|
|
764
837
|
return;
|
|
@@ -168,11 +168,33 @@ function targetLookup(target) {
|
|
|
168
168
|
return code === 'ENOENT' || code === 'ENOTDIR' ? 'absent' : code ?? 'unknown error';
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Reindex keeps pack skills at `.claude/skills/<pack>:<item>`. Recreating the
|
|
173
|
+
* unprefixed table dest next to that wrapper duplicates names like `hooks`.
|
|
174
|
+
*/
|
|
175
|
+
function namespacedSkillHostExists(hqRoot, item) {
|
|
176
|
+
const dir = path.join(hqRoot, '.claude', 'skills');
|
|
177
|
+
let names;
|
|
178
|
+
try {
|
|
179
|
+
names = fs.readdirSync(dir);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
const suffix = `:${item}`;
|
|
185
|
+
return names.some((name) => name.endsWith(suffix));
|
|
186
|
+
}
|
|
187
|
+
function ensureSymlink(link, hqRoot, info, warn) {
|
|
172
188
|
if (!existsOrSymlink(link.src)) {
|
|
173
189
|
warn(`payload missing: ${link.src} (declared but not shipped)`);
|
|
174
190
|
return;
|
|
175
191
|
}
|
|
192
|
+
if (link.key === 'skills' &&
|
|
193
|
+
path.basename(link.dst) === link.item &&
|
|
194
|
+
namespacedSkillHostExists(hqRoot, link.item)) {
|
|
195
|
+
info(`skipped ${link.dst} (namespaced skill wrapper already present)`);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
176
198
|
const relativeSrc = path.relative(path.dirname(link.dst), link.src);
|
|
177
199
|
fs.mkdirSync(path.dirname(link.dst), { recursive: true });
|
|
178
200
|
try {
|
|
@@ -372,7 +394,7 @@ export function scanPackages(hqRoot, options = {}) {
|
|
|
372
394
|
continue;
|
|
373
395
|
}
|
|
374
396
|
}
|
|
375
|
-
ensureSymlink(link, info, warn);
|
|
397
|
+
ensureSymlink(link, hqRoot, info, warn);
|
|
376
398
|
}
|
|
377
399
|
}
|
|
378
400
|
}
|
|
@@ -141,6 +141,77 @@ export declare class QmdCollectionExistsError extends QmdExitError {
|
|
|
141
141
|
name: string;
|
|
142
142
|
constructor(message: string, args: string[], status: number | null, stdout: string, stderr: string, collectionName: string);
|
|
143
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* qmd's `collection add` exited non-zero because ANOTHER collection already
|
|
146
|
+
* covers exactly this path and pattern (qmd 2.5.3 prints "A collection already
|
|
147
|
+
* exists for this path and pattern:" and then `Name: <other> (qmd://<other>/)`).
|
|
148
|
+
* For unmanaged names, reconciliation skips its own add, prints a notice and
|
|
149
|
+
* carries on. HQ-managed name collisions remain fatal and captured. Before
|
|
150
|
+
* this, the duplicate aborted the whole `hq index sync`, so no collection was
|
|
151
|
+
* ever updated again on that machine (HQ-CLI-GJ).
|
|
152
|
+
*/
|
|
153
|
+
export declare class QmdCollectionPathTakenError extends QmdExitError {
|
|
154
|
+
readonly existingName: string;
|
|
155
|
+
name: string;
|
|
156
|
+
constructor(message: string, args: string[], status: number | null, stdout: string, stderr: string, existingName: string);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* hq or its qmd child was refused READ access to the HQ folder: EPERM/EACCES on
|
|
160
|
+
* `uv_cwd` (qmd's process.cwd() in the HQ root), or on a scandir/open of a path
|
|
161
|
+
* inside the HQ root. On macOS an EPERM there is the privacy (TCC) gate on a
|
|
162
|
+
* protected location such as Documents, Desktop or iCloud Drive. The message is
|
|
163
|
+
* the platform-specific remedy; the carrier is thrown marked expected, so the
|
|
164
|
+
* boundary prints it and skips capture (HQ-CLI-EJ, HQ-CLI-FV, HQ-CLI-BV,
|
|
165
|
+
* HQ-CLI-FF).
|
|
166
|
+
*/
|
|
167
|
+
export declare class QmdAccessDeniedError extends QmdExitError {
|
|
168
|
+
readonly deniedPath: string;
|
|
169
|
+
readonly errnoCode: 'EPERM' | 'EACCES';
|
|
170
|
+
readonly syscall: string;
|
|
171
|
+
name: string;
|
|
172
|
+
constructor(message: string, args: string[], status: number | null, stdout: string, stderr: string, deniedPath: string, errnoCode: 'EPERM' | 'EACCES', syscall: string);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* qmd could not create or write its own settings folder (QMD_CONFIG_DIR,
|
|
176
|
+
* $XDG_CONFIG_HOME/qmd or ~/.config/qmd): EPERM/EACCES on a path at or above
|
|
177
|
+
* that folder. The user's account cannot write there, typically because the
|
|
178
|
+
* folder was created by a command run with sudo. Thrown marked expected with
|
|
179
|
+
* the remedy as its message (HQ-CLI-GJ).
|
|
180
|
+
*/
|
|
181
|
+
export declare class QmdConfigUnwritableError extends QmdExitError {
|
|
182
|
+
readonly configDir: string;
|
|
183
|
+
readonly errnoCode: 'EPERM' | 'EACCES';
|
|
184
|
+
name: string;
|
|
185
|
+
constructor(message: string, args: string[], status: number | null, stdout: string, stderr: string, configDir: string, errnoCode: 'EPERM' | 'EACCES');
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* qmd's SQLite index file is damaged (SQLITE_CORRUPT / SQLITE_NOTADB). qmd
|
|
189
|
+
* reports it as "sqlite-vec extension is unavailable ... Install Homebrew
|
|
190
|
+
* SQLite", which cannot fix a damaged file. hq names the file and the rebuild
|
|
191
|
+
* step instead. Still captured, because a trend of damaged index files would
|
|
192
|
+
* point at a writer bug (HQ-CLI-EJ).
|
|
193
|
+
*/
|
|
194
|
+
export declare class QmdStoreCorruptError extends QmdExitError {
|
|
195
|
+
readonly storeFile: string | undefined;
|
|
196
|
+
name: string;
|
|
197
|
+
constructor(message: string, args: string[], status: number | null, stdout: string, stderr: string, storeFile: string | undefined);
|
|
198
|
+
}
|
|
199
|
+
type QmdPermissionFailure = {
|
|
200
|
+
code: 'EPERM' | 'EACCES';
|
|
201
|
+
syscall: string;
|
|
202
|
+
path?: string;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Parse an unambiguous fatal Node permission error from stderr, for example
|
|
206
|
+
* `Error: EPERM: operation not permitted, uv_cwd` or
|
|
207
|
+
* `[Error: EACCES: permission denied, mkdir '/home/u/.config/qmd']`.
|
|
208
|
+
* Incidental warnings and output containing another thrown error stay captured.
|
|
209
|
+
*/
|
|
210
|
+
export declare function parseQmdPermissionFailure(text: string): QmdPermissionFailure | undefined;
|
|
211
|
+
/** Remedy for a refused read of the HQ folder, worded for the platform. */
|
|
212
|
+
export declare function qmdAccessDeniedMessage(deniedPath: string, code: 'EPERM' | 'EACCES', platform?: NodeJS.Platform): string;
|
|
213
|
+
/** Remedy for a qmd settings folder the user cannot write. */
|
|
214
|
+
export declare function qmdConfigUnwritableMessage(configDir: string, deniedPath: string, syscall: string, platform?: NodeJS.Platform): string;
|
|
144
215
|
/**
|
|
145
216
|
* qmd did NOT exit — it was KILLED BY A SIGNAL before it finished (spawnSync
|
|
146
217
|
* reports `status: null` with a non-null `signal`). hq-cli passes qmd no timeout
|
|
@@ -553,6 +624,13 @@ export type ReconcileCollectionsOptions = {
|
|
|
553
624
|
runner?: QmdProcessRunner;
|
|
554
625
|
/** Test seam for the default-off collection-path repair rollout. */
|
|
555
626
|
repairPathDrift?: boolean;
|
|
627
|
+
/** Where reconciliation notices go (default: process.stderr). */
|
|
628
|
+
writeStderr?: (text: string) => void;
|
|
629
|
+
/**
|
|
630
|
+
* File that records one-time notices already shown (default
|
|
631
|
+
* `<hqRoot>/.hq/search-index-notices.json`); `null` disables the record.
|
|
632
|
+
*/
|
|
633
|
+
noticesFile?: string | null;
|
|
556
634
|
};
|
|
557
635
|
/**
|
|
558
636
|
* Register expected collections that qmd does not yet know about, returning the
|
|
@@ -566,10 +644,16 @@ export type ReconcileCollectionsOptions = {
|
|
|
566
644
|
* NOT a failure. Reconciliation still issues the `context add`, whose qmd-side
|
|
567
645
|
* resyncConfig re-syncs YAML into SQLite and heals the divergence that provoked
|
|
568
646
|
* the retry, then continues with later collections; such a pre-existing
|
|
569
|
-
* collection is excluded from the returned list.
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
647
|
+
* collection is excluded from the returned list.
|
|
648
|
+
*
|
|
649
|
+
* An unmanaged path+pattern duplicate is not fatal: the files are indexed under
|
|
650
|
+
* that name, but scoped search misses them. Print a notice, skip this add and
|
|
651
|
+
* its `context add`, and continue. It used to abort the whole sync, so
|
|
652
|
+
* `qmd update` never ran again on that machine (HQ-CLI-GJ).
|
|
653
|
+
*
|
|
654
|
+
* Every other qmd failure still propagates: a same-name duplicate that named a
|
|
655
|
+
* different collection, a missing collection, a `context add` failure, a
|
|
656
|
+
* missing/unbuilt qmd binary. HQ-CLI-Q (Sentry 7670823899).
|
|
573
657
|
*/
|
|
574
658
|
export declare function reconcileCollections(hqRoot: string, options?: ReconcileCollectionsOptions): SearchCollection[];
|
|
575
659
|
export declare function listRegisteredCollections(hqRoot: string, options?: RunQmdOptions): Set<string>;
|