@indigoai-us/hq-cli 5.345.215 → 5.345.217
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 +141 -0
- package/README.md +45 -0
- package/assets/scaffold/core/scripts/lib/epochrealtime.sh +30 -0
- package/assets/scaffold/core/scripts/lib/work-mesh-enqueue.sh +12 -5
- package/dist/command-catalog.generated.d.ts +59 -4
- package/dist/command-catalog.generated.js +74 -4
- package/dist/command-help.js +3 -1
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/auth.d.ts +1 -1
- package/dist/commands/auth.js +11 -52
- package/dist/commands/bot.js +11 -4
- package/dist/commands/cloud-demote.d.ts +19 -4
- package/dist/commands/cloud-demote.js +85 -12
- package/dist/commands/cloud-provision.d.ts +5 -1
- package/dist/commands/cloud-provision.js +6 -2
- package/dist/commands/cloud.d.ts +36 -0
- package/dist/commands/cloud.js +109 -26
- package/dist/commands/core.js +1 -0
- package/dist/commands/daemon.js +4 -1
- package/dist/commands/dm.js +7 -0
- package/dist/commands/doctor-usage.d.ts +8 -0
- package/dist/commands/doctor-usage.js +20 -0
- package/dist/commands/doctor.js +7 -1
- package/dist/commands/env.d.ts +18 -0
- package/dist/commands/env.js +82 -0
- package/dist/commands/install-global.js +2 -2
- package/dist/commands/lanes.js +100 -24
- package/dist/commands/logout.d.ts +7 -0
- package/dist/commands/logout.js +41 -34
- package/dist/commands/sources.d.ts +8 -2
- package/dist/commands/sources.js +65 -9
- package/dist/commands/whoami.js +26 -1
- package/dist/data/command-states.json +15 -0
- package/dist/index.js +52 -4
- package/dist/lazy-commands.js +2 -1
- package/dist/lib/anywhere-person-setting.d.ts +2 -0
- package/dist/lib/anywhere-person-setting.js +6 -3
- package/dist/lib/billing/usage-card.d.ts +25 -4
- package/dist/lib/billing/usage-card.js +76 -9
- package/dist/lib/billing/usage-cost.d.ts +3 -3
- package/dist/lib/billing/usage-cost.js +35 -13
- package/dist/lib/billing/usage-only.js +4 -2
- package/dist/lib/billing/usage-rate-card.d.ts +2 -2
- package/dist/lib/billing/usage-rate-card.js +3 -0
- package/dist/lib/bot/fleet-cron.js +93 -6
- package/dist/lib/bot/inflight.d.ts +9 -0
- package/dist/lib/bot/inflight.js +10 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +12 -1
- package/dist/lib/bot/runtime/grok-acp.d.ts +1 -0
- package/dist/lib/bot/runtime/grok-acp.js +26 -11
- package/dist/lib/bot/runtime/grok.js +1 -1
- package/dist/lib/daemon/flag-monitor.d.ts +8 -0
- package/dist/lib/daemon/flag-monitor.js +17 -6
- package/dist/lib/daemon/flag.d.ts +65 -1
- package/dist/lib/daemon/flag.js +190 -40
- package/dist/lib/daemon/ops/policy.js +62 -5
- package/dist/lib/daemon/paths.d.ts +72 -2
- package/dist/lib/daemon/paths.js +154 -3
- package/dist/lib/daemon/run.js +25 -20
- package/dist/lib/daemon/selfcheck.d.ts +22 -0
- package/dist/lib/daemon/selfcheck.js +40 -1
- package/dist/lib/daemon/server.d.ts +3 -1
- package/dist/lib/daemon/server.js +7 -22
- package/dist/lib/daemon/state-file-switch.d.ts +57 -0
- package/dist/lib/daemon/state-file-switch.js +88 -0
- package/dist/lib/daemon/state-file.d.ts +198 -0
- package/dist/lib/daemon/state-file.js +419 -0
- package/dist/lib/daemon/timed-flag-monitors.d.ts +47 -0
- package/dist/lib/daemon/timed-flag-monitors.js +75 -0
- package/dist/lib/doctor/checks/host-core.d.ts +50 -0
- package/dist/lib/doctor/checks/host-core.js +269 -0
- package/dist/lib/doctor/checks/replay-recorder.d.ts +39 -0
- package/dist/lib/doctor/checks/replay-recorder.js +261 -0
- package/dist/lib/doctor/registry.js +4 -0
- package/dist/lib/environment/profile.d.ts +239 -0
- package/dist/lib/environment/profile.js +251 -0
- package/dist/lib/hook-engine/reconcile.js +39 -13
- package/dist/lib/hook-engine/registration.d.ts +9 -0
- package/dist/lib/hook-engine/registration.js +19 -0
- package/dist/lib/hot-channels/adapters/slack.d.ts +21 -5
- package/dist/lib/hot-channels/adapters/slack.js +64 -21
- package/dist/lib/hot-channels/alert.d.ts +2 -0
- package/dist/lib/hot-channels/alert.js +8 -1
- package/dist/lib/hot-channels/contract.d.ts +12 -0
- package/dist/lib/hot-channels/contract.js +7 -0
- package/dist/lib/hot-channels/loop.js +1 -0
- package/dist/lib/hot-channels/run.d.ts +6 -0
- package/dist/lib/hot-channels/run.js +4 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +64 -1
- package/dist/lib/hot-channels/signals-pass.js +21 -49
- package/dist/lib/install/claude-targets.d.ts +12 -1
- package/dist/lib/install/claude-targets.js +57 -5
- package/dist/lib/install/codex-targets.d.ts +2 -2
- package/dist/lib/install/codex-targets.js +36 -6
- package/dist/lib/install/hook-target.d.ts +3 -0
- package/dist/lib/install/hook-target.js +11 -0
- package/dist/lib/lanes/canonical-host.d.ts +35 -0
- package/dist/lib/lanes/canonical-host.js +65 -0
- package/dist/lib/lanes/host-capacity.d.ts +30 -0
- package/dist/lib/lanes/host-capacity.js +29 -3
- package/dist/lib/mesh/live/daemon/run.d.ts +2 -0
- package/dist/lib/mesh/live/daemon/run.js +5 -2
- package/dist/lib/mesh/live/flush.d.ts +5 -1
- package/dist/lib/mesh/live/flush.js +12 -6
- package/dist/lib/mesh/live/reporting-privacy.d.ts +32 -0
- package/dist/lib/mesh/live/reporting-privacy.js +56 -1
- package/dist/lib/mesh/live/spool.d.ts +7 -0
- package/dist/lib/mesh/live/spool.js +25 -0
- package/dist/lib/person-setting-cache.d.ts +38 -0
- package/dist/lib/person-setting-cache.js +98 -0
- package/dist/lib/safe-store.d.ts +245 -0
- package/dist/lib/safe-store.js +777 -0
- package/dist/lib/signals/engine.d.ts +29 -2
- package/dist/lib/signals/engine.js +103 -4
- package/dist/lib/signals/reply.js +73 -18
- package/dist/lib/signals/steps/adapters.js +7 -2
- package/dist/lib/signals/steps/extract.d.ts +13 -0
- package/dist/lib/signals/steps/extract.js +84 -4
- package/dist/main.js +46 -3
- package/dist/schemas/hq-environment-profile.v1.schema.json +438 -0
- package/dist/utils/auth-expiry.d.ts +8 -0
- package/dist/utils/auth-expiry.js +53 -0
- package/dist/utils/cli-telemetry.d.ts +21 -0
- package/dist/utils/cli-telemetry.js +34 -0
- package/dist/utils/command-usage.d.ts +275 -0
- package/dist/utils/command-usage.js +797 -0
- package/dist/utils/hook-trust.d.ts +7 -0
- package/dist/utils/hook-trust.js +31 -4
- package/dist/utils/host-registration.d.ts +126 -0
- package/dist/utils/host-registration.js +378 -0
- package/dist/utils/resident-package-preload.js +2 -0
- package/package.json +10 -8
- package/scripts/bench-core.mjs +1096 -0
- package/scripts/check-function-manifest.mjs +702 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local command usage count, and the retiring-command gate, which ships
|
|
3
|
+
* switched off ({@link RETIRING_GATE_ENABLED}): no command is refused and no
|
|
4
|
+
* retiring notice is printed. The gate code is kept for when it is turned on.
|
|
5
|
+
*
|
|
6
|
+
* Every `hq` run appends one line to a file under `~/.hq/command-usage/`:
|
|
7
|
+
* the UTC date, a kind, a count, and the command path (`secrets env`,
|
|
8
|
+
* `doctor usage`). The command path is built only from command names the CLI
|
|
9
|
+
* itself declares, so an argument, a flag value, a company slug, a file path,
|
|
10
|
+
* the working directory, or an environment value can never be part of it.
|
|
11
|
+
*
|
|
12
|
+
* The file stays on this computer. Nothing here opens a socket, and the file
|
|
13
|
+
* sits outside every folder that sync, vault upload, telemetry, or `hq
|
|
14
|
+
* feedback` reads (see command-usage.test.ts for the checks). `HQ_TELEMETRY=0`
|
|
15
|
+
* therefore does not turn the count off.
|
|
16
|
+
*
|
|
17
|
+
* `src/index.ts` imports this module on every route, including the hook fast
|
|
18
|
+
* routes, so it imports Node builtins and the store helper only (which imports
|
|
19
|
+
* Node builtins only), and the per-run work is one small
|
|
20
|
+
* append: no read of the usage file, no directory listing. A write error is
|
|
21
|
+
* swallowed; counting must never fail or slow a command.
|
|
22
|
+
*
|
|
23
|
+
* Size: the file is compacted to one line per date, kind and command once it
|
|
24
|
+
* passes COMMAND_USAGE_COMPACT_AT_BYTES. Compaction drops dates older than the
|
|
25
|
+
* 30-day window, and then the oldest dates until the result fits
|
|
26
|
+
* COMMAND_USAGE_MAX_COMPACTED_BYTES. The file from before the last compaction
|
|
27
|
+
* is kept until the next one, so the folder holds about twice the compaction
|
|
28
|
+
* threshold at most (about 512 KiB).
|
|
29
|
+
*
|
|
30
|
+
* Every read and write of the usage folder goes through the shared store
|
|
31
|
+
* helper (`src/lib/safe-store.ts`): the folder is held open and checked by its
|
|
32
|
+
* descriptor, files are opened without following a link and without blocking,
|
|
33
|
+
* and only a regular single-link file of this user is written or read. A named
|
|
34
|
+
* pipe, a link (symbolic or hard), or a folder at the usage path means no count
|
|
35
|
+
* is kept; so does a usage folder that is a link, belongs to another user, or
|
|
36
|
+
* is writable by the group or others, and a folder swapped for another while
|
|
37
|
+
* a write runs. The command runs as it would otherwise.
|
|
38
|
+
*
|
|
39
|
+
* When the gate is switched on, it matches the whole command path. An entry
|
|
40
|
+
* for a command group (`core job`) does not gate the commands under it
|
|
41
|
+
* (`core job run`); each command to retire is listed by its own path. While it
|
|
42
|
+
* is off, the `refused` count stays 0 and `hq doctor usage` does not show it.
|
|
43
|
+
*/
|
|
44
|
+
import { type OpenStoreDirOptions } from "../lib/safe-store.js";
|
|
45
|
+
/**
|
|
46
|
+
* The switch for the retiring-command gate. Off: no command is refused and no
|
|
47
|
+
* retiring notice is printed, whatever `src/data/command-states.json` marks.
|
|
48
|
+
*
|
|
49
|
+
* Owner decision (Corey, 2026-11-13): "let's not retire commands right now.
|
|
50
|
+
* just evolve towards new platform". Every command runs as it did in
|
|
51
|
+
* v5.345.215. The marking data and the local usage count stay, so the gate can
|
|
52
|
+
* be switched back on later by setting this to true.
|
|
53
|
+
*/
|
|
54
|
+
export declare const RETIRING_GATE_ENABLED: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Global flag that, with the gate on, runs a command whose state is
|
|
57
|
+
* `retiring`. With the gate off it is still accepted and taken out of argv
|
|
58
|
+
* where hq reads it; it only marks the run of a marked command as a
|
|
59
|
+
* `still-use` run in the local count.
|
|
60
|
+
*/
|
|
61
|
+
export declare const STILL_USE_FLAG = "--i-still-use-this";
|
|
62
|
+
/** Help text for the flag on the root program (main.ts and command-help.ts). */
|
|
63
|
+
export declare const STILL_USE_FLAG_DESCRIPTION: string;
|
|
64
|
+
/** `hq doctor usage` reports this many days, and compaction keeps the same. */
|
|
65
|
+
export declare const COMMAND_USAGE_WINDOW_DAYS = 30;
|
|
66
|
+
/** The usage file is compacted once an append takes it past this size. */
|
|
67
|
+
export declare const COMMAND_USAGE_COMPACT_AT_BYTES: number;
|
|
68
|
+
/** A compacted file is cut to this size by dropping its oldest dates. */
|
|
69
|
+
export declare const COMMAND_USAGE_MAX_COMPACTED_BYTES: number;
|
|
70
|
+
/**
|
|
71
|
+
* Appends stop at this size. It is reached only when compaction keeps failing
|
|
72
|
+
* (for example a lock that cannot be taken); normal use stays near the
|
|
73
|
+
* compaction threshold.
|
|
74
|
+
*/
|
|
75
|
+
export declare const COMMAND_USAGE_HARD_MAX_BYTES: number;
|
|
76
|
+
/** Folder under `~/.hq`. Not `logs/`, `locks/` or `jobs/`: `hq feedback` reads those. */
|
|
77
|
+
export declare const COMMAND_USAGE_DIRNAME = "command-usage";
|
|
78
|
+
export declare const COMMAND_USAGE_FILENAME = "usage.tsv";
|
|
79
|
+
export type CommandUseKind = "run" | "still-use" | "refused";
|
|
80
|
+
export interface CommandStateEntry {
|
|
81
|
+
state: string;
|
|
82
|
+
replacedBy?: string;
|
|
83
|
+
}
|
|
84
|
+
/** `commands` of `src/data/command-states.json`: only commands that are not `live`. */
|
|
85
|
+
export type CommandStates = Readonly<Record<string, CommandStateEntry>>;
|
|
86
|
+
export interface CommandUsageOptions {
|
|
87
|
+
/** Usage folder. Defaults to {@link commandUsageDir}. */
|
|
88
|
+
dir?: string | null;
|
|
89
|
+
/** Clock, in epoch milliseconds. */
|
|
90
|
+
now?: number;
|
|
91
|
+
env?: NodeJS.ProcessEnv;
|
|
92
|
+
/** Test seam: passed to the store helper, which calls it between the steps of each operation. */
|
|
93
|
+
at?: OpenStoreDirOptions["at"];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Where the count is kept, or null when this run keeps none.
|
|
97
|
+
*
|
|
98
|
+
* A test run never writes to the real home: it counts only into the folder a
|
|
99
|
+
* test names with HQ_TEST_COMMAND_USAGE_DIR. That variable is ignored outside
|
|
100
|
+
* a test run, so it is not a way to move or switch off the count.
|
|
101
|
+
*
|
|
102
|
+
* A test run is `NODE_ENV=test` or `VITEST=true`. A person who has
|
|
103
|
+
* `NODE_ENV=test` set in their shell therefore keeps no count (the README says
|
|
104
|
+
* so). The retiring gate does not depend on it: see {@link loadCommandStates}.
|
|
105
|
+
*/
|
|
106
|
+
export declare function commandUsageDir(env?: NodeJS.ProcessEnv): string | null;
|
|
107
|
+
/** Test seam: forget the cached state table and the once-per-process mark. */
|
|
108
|
+
export declare function _resetCommandUsageForTests(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Read the command states that ship inside the CLI. The file lists only
|
|
111
|
+
* commands whose state is not `live`; a command absent from it is `live`.
|
|
112
|
+
* A missing or damaged file gates nothing: a broken table must not stop
|
|
113
|
+
* every command from running.
|
|
114
|
+
*
|
|
115
|
+
* HQ_TEST_COMMAND_STATES_FILE names another table for this repository's own
|
|
116
|
+
* tests. It is read only in a test run of a source checkout. An installed CLI
|
|
117
|
+
* never reads it, whatever the environment holds, so a person's environment
|
|
118
|
+
* cannot switch the gate off or point it at another table.
|
|
119
|
+
*/
|
|
120
|
+
export declare function loadCommandStates(env?: NodeJS.ProcessEnv, sourceCheckout?: () => boolean): CommandStates;
|
|
121
|
+
/**
|
|
122
|
+
* True when the flag appears anywhere before a `--` terminator. `src/index.ts`
|
|
123
|
+
* uses this to send such a run to the full command graph, which knows the
|
|
124
|
+
* command names and decides whether the flag is hq's ({@link takeStillUseFlag}).
|
|
125
|
+
*/
|
|
126
|
+
export declare function hasStillUseFlag(argv: readonly string[]): boolean;
|
|
127
|
+
/** The parts of a Commander command {@link takeStillUseFlag} reads. */
|
|
128
|
+
export interface CommandTreeNode {
|
|
129
|
+
name(): string;
|
|
130
|
+
aliases(): string[];
|
|
131
|
+
commands: readonly CommandTreeNode[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Take the flag out of `argv` in place where hq reads it, and say whether it
|
|
135
|
+
* was there.
|
|
136
|
+
*
|
|
137
|
+
* hq reads the flag only before the command's own arguments begin: before the
|
|
138
|
+
* command name, between the names of a command path, or directly after the
|
|
139
|
+
* last name (`hq --i-still-use-this whoami`, `hq core --i-still-use-this job
|
|
140
|
+
* run`, `hq whoami --i-still-use-this`). The first operand or option of the
|
|
141
|
+
* command ends that span, and so does `--`. A flag after that point stays in
|
|
142
|
+
* `argv` and belongs to the command: `hq run tool --i-still-use-this` hands it
|
|
143
|
+
* to `tool`.
|
|
144
|
+
*
|
|
145
|
+
* `root` is the command graph, so a name is told from an operand by the
|
|
146
|
+
* commands the CLI declares. This runs before Commander parses `argv`, which
|
|
147
|
+
* therefore never sees a flag hq took, and neither does a command that reads
|
|
148
|
+
* its arguments straight from `process.argv`.
|
|
149
|
+
*/
|
|
150
|
+
export declare function takeStillUseFlag(argv: string[], root: CommandTreeNode): boolean;
|
|
151
|
+
/** The parts of a Commander command this module reads. */
|
|
152
|
+
export interface CommandNode {
|
|
153
|
+
name(): string;
|
|
154
|
+
aliases(): string[];
|
|
155
|
+
/** Operands and unparsed arguments Commander left for this command. */
|
|
156
|
+
args: string[];
|
|
157
|
+
parent: CommandNode | null;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The command path of the command Commander is about to run.
|
|
161
|
+
*
|
|
162
|
+
* `canonical` joins the declared command names from the root down. `typed`
|
|
163
|
+
* is the same path with each name replaced by the alias the person typed,
|
|
164
|
+
* when they typed one.
|
|
165
|
+
*
|
|
166
|
+
* Nothing is read from argv. Commander dispatches a subcommand on the first
|
|
167
|
+
* operand its parent was left with (`parent.args[0]`), after the parent's
|
|
168
|
+
* own options and their values are taken out. That word is used only when it
|
|
169
|
+
* is a declared name or alias of the dispatched command, so a positional
|
|
170
|
+
* value or an option value cannot become part of the path.
|
|
171
|
+
*/
|
|
172
|
+
export declare function commandPathOf(actionCommand: CommandNode): {
|
|
173
|
+
typed: string;
|
|
174
|
+
canonical: string;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Append one use of `commandPath`. Never throws. Creates the usage folder but
|
|
178
|
+
* never `~/.hq` itself: a computer with no HQ state keeps no count.
|
|
179
|
+
*/
|
|
180
|
+
export declare function recordCommandUse(commandPath: string, kind: CommandUseKind, options?: CommandUsageOptions): void;
|
|
181
|
+
/**
|
|
182
|
+
* Whether `dir` is a usage folder this module works in (see
|
|
183
|
+
* {@link openUsageStore}). With `create`, a missing leaf folder is made first.
|
|
184
|
+
*/
|
|
185
|
+
export declare function usageDirIsSafe(dir: string, create?: boolean): boolean;
|
|
186
|
+
/** The one message a refused command prints. */
|
|
187
|
+
export declare function retiringRefusalMessage(commandPath: string, entry: CommandStateEntry): string;
|
|
188
|
+
export interface CommandRun {
|
|
189
|
+
/** Command path as typed (aliases kept). This is what the count records. */
|
|
190
|
+
typed: string;
|
|
191
|
+
/** Command path by declared names, when it differs from `typed`. */
|
|
192
|
+
canonical?: string;
|
|
193
|
+
/** Whether the run carries {@link STILL_USE_FLAG}. */
|
|
194
|
+
stillUse: boolean;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Count one command run and apply the retiring gate.
|
|
198
|
+
*
|
|
199
|
+
* The gate is off ({@link RETIRING_GATE_ENABLED}): this then always returns
|
|
200
|
+
* null and only counts the run. A run of a command marked `retiring` that
|
|
201
|
+
* carries the flag is still counted as `still-use`; nothing is counted as
|
|
202
|
+
* `refused`.
|
|
203
|
+
*
|
|
204
|
+
* With the gate on, returns null when the command may run, or the refusal
|
|
205
|
+
* message when its state is `retiring` and the run does not carry the flag. A refused attempt
|
|
206
|
+
* is counted as `refused`, and a run that used the flag on a retiring command
|
|
207
|
+
* as `still-use`, both apart from ordinary runs. Other states are not gated.
|
|
208
|
+
*
|
|
209
|
+
* The table is matched on the whole command path, as typed and by declared
|
|
210
|
+
* names. An entry for a group does not gate the commands under it, and an
|
|
211
|
+
* entry for a command does not gate the group above it. Retiring a group
|
|
212
|
+
* means listing each of its commands, so a command is never refused without
|
|
213
|
+
* its own entry.
|
|
214
|
+
*
|
|
215
|
+
* One process counts one run: a fast route that hands the command on to the
|
|
216
|
+
* full command graph is not counted a second time there.
|
|
217
|
+
*/
|
|
218
|
+
export declare function admitCommandRun(run: CommandRun, options?: CommandUsageOptions & {
|
|
219
|
+
states?: CommandStates;
|
|
220
|
+
/** Defaults to {@link RETIRING_GATE_ENABLED}. Tests of the dormant gate pass true. */
|
|
221
|
+
gateEnabled?: boolean;
|
|
222
|
+
}): string | null;
|
|
223
|
+
/** Take the compaction lock of `dir`. Returns the token, or null. */
|
|
224
|
+
export declare function acquireCompactLock(dir: string, now?: number): string | null;
|
|
225
|
+
/** Take over the lock of `dir` judged stale with content `judged`. Returns the token, or null. */
|
|
226
|
+
export declare function claimStaleCompactLock(dir: string, judged: string, now?: number): string | null;
|
|
227
|
+
/** Give the lock of `dir` back. Does nothing when another process has taken it over. */
|
|
228
|
+
export declare function releaseCompactLock(dir: string, token: string): void;
|
|
229
|
+
/**
|
|
230
|
+
* Fold the usage file into one line per date, kind and command.
|
|
231
|
+
*
|
|
232
|
+
* One process at a time, behind a lock that a later run takes over after a
|
|
233
|
+
* minute (see {@link acquireHeldLock}). The live file is renamed first, so
|
|
234
|
+
* other hq processes keep appending to a fresh file. The folded lines are
|
|
235
|
+
* then appended to that fresh file with a marker that names the renamed file
|
|
236
|
+
* and how many of its bytes were folded.
|
|
237
|
+
*
|
|
238
|
+
* The renamed file is kept until the next compaction. A process that opened
|
|
239
|
+
* it just before the rename can still write its line there; the next
|
|
240
|
+
* compaction (or `hq doctor usage`) reads what lies past the marked length,
|
|
241
|
+
* and only then is the file removed. A renamed file left by a crash is
|
|
242
|
+
* handled the same way: folded once, by its marker.
|
|
243
|
+
*
|
|
244
|
+
* Every rename, append and removal goes through the store helper, so each
|
|
245
|
+
* runs only while the folder's path still leads to the held folder, and the
|
|
246
|
+
* lock is checked again before the rename and before the append.
|
|
247
|
+
* Returns whether this call compacted.
|
|
248
|
+
*/
|
|
249
|
+
export declare function compactCommandUsage(dir: string, now?: number): boolean;
|
|
250
|
+
export interface CommandUsageRow {
|
|
251
|
+
command: string;
|
|
252
|
+
/** Runs without {@link STILL_USE_FLAG}. */
|
|
253
|
+
runs: number;
|
|
254
|
+
/** Runs of a retiring command that carried the flag. */
|
|
255
|
+
stillUseRuns: number;
|
|
256
|
+
/** Attempts on a retiring command that were refused. */
|
|
257
|
+
refused: number;
|
|
258
|
+
}
|
|
259
|
+
export interface CommandUsageReport {
|
|
260
|
+
schema: 1;
|
|
261
|
+
windowDays: number;
|
|
262
|
+
/** First and last UTC date of the window, inclusive. */
|
|
263
|
+
from: string;
|
|
264
|
+
to: string;
|
|
265
|
+
/** The usage file, or null when this run keeps no count. */
|
|
266
|
+
file: string | null;
|
|
267
|
+
bytes: number;
|
|
268
|
+
leavesThisComputer: false;
|
|
269
|
+
commands: CommandUsageRow[];
|
|
270
|
+
}
|
|
271
|
+
/** Counts per command for the last {@link COMMAND_USAGE_WINDOW_DAYS} days. */
|
|
272
|
+
export declare function readCommandUsage(options?: CommandUsageOptions): CommandUsageReport;
|
|
273
|
+
/** Plain-text report for `hq doctor usage`. */
|
|
274
|
+
export declare function renderCommandUsageText(report: CommandUsageReport): string;
|
|
275
|
+
//# sourceMappingURL=command-usage.d.ts.map
|