hacklab 0.10.4 → 0.11.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 (42) hide show
  1. package/README.md +54 -12
  2. package/dist/cli.js +1 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/config.d.ts.map +1 -1
  5. package/dist/commands/config.js +27 -2
  6. package/dist/commands/config.js.map +1 -1
  7. package/dist/commands/daemon.d.ts +6 -2
  8. package/dist/commands/daemon.d.ts.map +1 -1
  9. package/dist/commands/daemon.js +12 -8
  10. package/dist/commands/daemon.js.map +1 -1
  11. package/dist/commands/sync.d.ts +1 -0
  12. package/dist/commands/sync.d.ts.map +1 -1
  13. package/dist/commands/sync.js +158 -7
  14. package/dist/commands/sync.js.map +1 -1
  15. package/dist/config.d.ts +6 -0
  16. package/dist/config.d.ts.map +1 -1
  17. package/dist/config.js.map +1 -1
  18. package/dist/daily-sync.d.ts +20 -3
  19. package/dist/daily-sync.d.ts.map +1 -1
  20. package/dist/daily-sync.js +154 -44
  21. package/dist/daily-sync.js.map +1 -1
  22. package/dist/prompt-consent.d.ts +61 -0
  23. package/dist/prompt-consent.d.ts.map +1 -0
  24. package/dist/prompt-consent.js +167 -0
  25. package/dist/prompt-consent.js.map +1 -0
  26. package/dist/prompt-stats.d.ts +72 -0
  27. package/dist/prompt-stats.d.ts.map +1 -0
  28. package/dist/prompt-stats.js +244 -0
  29. package/dist/prompt-stats.js.map +1 -0
  30. package/dist/scanners/incremental.d.ts +144 -0
  31. package/dist/scanners/incremental.d.ts.map +1 -0
  32. package/dist/scanners/incremental.js +519 -0
  33. package/dist/scanners/incremental.js.map +1 -0
  34. package/dist/scanners/index.d.ts +44 -0
  35. package/dist/scanners/index.d.ts.map +1 -1
  36. package/dist/scanners/index.js +160 -126
  37. package/dist/scanners/index.js.map +1 -1
  38. package/dist/sync.d.ts +25 -0
  39. package/dist/sync.d.ts.map +1 -1
  40. package/dist/sync.js +52 -5
  41. package/dist/sync.js.map +1 -1
  42. package/package.json +1 -1
@@ -14,6 +14,11 @@ export type InstallResult = {
14
14
  /** The daily background job writes here; launchd/systemd also point stdout+stderr
15
15
  * at it. Lives next to the session file so it honors HACKLAB_SESSION_PATH. */
16
16
  export declare function syncLogPath(): string;
17
+ export declare const SYNC_LOG_MAX_BYTES = 1000000;
18
+ export declare const SYNC_LOG_KEEP_LINES = 200;
19
+ /** Cut an oversized sync.log down to its last few hundred lines. Best-effort,
20
+ * and a no-op while the log is small — which is the normal case. */
21
+ export declare function trimSyncLog(maxBytes?: number, keepLines?: number): Promise<void>;
17
22
  /** Append a timestamped line to the background-sync log (best-effort). */
18
23
  export declare function appendSyncLog(line: string): Promise<void>;
19
24
  /** Record that the background sync can't continue (e.g. the session expired), so
@@ -29,27 +34,39 @@ export declare function launchdPlist(cmd: SyncCommand, time: {
29
34
  hour: number;
30
35
  minute: number;
31
36
  }, logPath: string): string;
37
+ /** The minutely tick. StartInterval (not a calendar interval) so launchd just
38
+ * re-runs it every 60s; a tick with nothing to report exits without a request. */
39
+ export declare function launchdTickPlist(cmd: SyncCommand, logPath: string): string;
32
40
  export declare function systemdService(cmd: SyncCommand): string;
33
41
  export declare function systemdTimer(): string;
42
+ export declare function systemdTickService(cmd: SyncCommand): string;
43
+ export declare function systemdTickTimer(): string;
34
44
  /** Where the Windows scheduled task's wrapper batch file lives. Next to the
35
45
  * session file so it honors HACKLAB_SESSION_PATH, mirroring syncLogPath(). */
36
46
  export declare function syncWrapperPath(): string;
47
+ /** The tick's own wrapper — same pattern, its own file so the two tasks can be
48
+ * created and deleted independently. */
49
+ export declare function tickWrapperPath(): string;
37
50
  /** The batch wrapper Task Scheduler runs. schtasks' `/TR` chokes on the nested
38
51
  * quotes a full `"node" "script" …` command needs, so we point the task at this
39
52
  * one-line .cmd instead and do the quoting here, where plain-batch rules apply.
40
53
  * Output is redirected to the same sync.log the job also appends to, so a crash
41
54
  * before the CLI's own logging still leaves a trace. */
42
55
  export declare function schtasksWrapper(cmd: SyncCommand, logPath: string): string;
56
+ /** Same wrapper for the minutely tick, logging to the same sync.log. */
57
+ export declare function schtasksTickWrapper(cmd: SyncCommand, logPath: string): string;
43
58
  /** Args for `schtasks /Create`. The `/TR` value is a single pre-quoted path;
44
59
  * spawn must run with windowsVerbatimArguments so Node doesn't re-escape it. */
45
60
  export declare function schtasksCreateArgs(wrapperPath: string, time: {
46
61
  hour: number;
47
62
  minute: number;
48
63
  }): string[];
64
+ /** Args for `schtasks /Create` for the tick: every minute, forever. */
65
+ export declare function schtasksTickCreateArgs(wrapperPath: string): string[];
49
66
  export declare function manualInstructions(cmd: SyncCommand): string;
50
- /** Install (or refresh) the daily background sync for the current OS. */
67
+ /** Install (or refresh) both background jobs (tick + daily) for the current OS. */
51
68
  export declare function installDailySync(): Promise<InstallResult>;
52
- /** Remove the daily background sync. Best-effort and never throws, so it's safe
53
- * to call from `logout` whether or not it was ever installed. */
69
+ /** Remove both background jobs. Best-effort and never throws, so it's safe to
70
+ * call from `logout` whether or not they were ever installed. */
54
71
  export declare function uninstallDailySync(): Promise<void>;
55
72
  //# sourceMappingURL=daily-sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"daily-sync.d.ts","sourceRoot":"","sources":["../src/daily-sync.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1D,MAAM,MAAM,aAAa,GACrB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3E;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,QAAQ,GAAG,aAAa,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAA;AAgB5E;8EAC8E;AAC9E,wBAAgB,WAAW,IAAI,MAAM,CAEp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AED;kFACkF;AAClF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAS1E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CASvD;AAED,wBAAgB,YAAY,IAAI,MAAM,CAcrC;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAQ3D;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAgBzC;AAED;8EAC8E;AAC9E,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;wCACwC;AACxC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;wDAIwD;AACxD,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED,wEAAwE;AACxE,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;gFACgF;AAChF,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACrC,MAAM,EAAE,CAaV;AAED,uEAAuE;AACvE,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAapE;AAID,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAS3D;AAiID,mFAAmF;AACnF,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,CAwB/D;AAED;iEACiE;AACjE,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CA0BxD"}
@@ -1,17 +1,24 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { realpathSync } from 'node:fs';
3
- import { appendFile, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
3
+ import { appendFile, mkdir, readFile, rm, stat, writeFile, } from 'node:fs/promises';
4
4
  import { homedir, platform } from 'node:os';
5
5
  import { dirname, join } from 'node:path';
6
6
  import { getSessionPath } from './session.js';
7
- // Sets up (and tears down) an OS-native daily run of `hacklab sync --quiet`:
8
- // launchd on macOS, a systemd user timer on Linux, and printed instructions
9
- // when neither fits. The scheduled command is resolved to an absolute
10
- // `node <entry>` pair so a scheduler running with a bare PATH (cron/launchd/
11
- // systemd often have almost none) can launch it without a `hacklab` shim.
7
+ // Sets up (and tears down) the two OS-native background jobs: a `hacklab sync
8
+ // --tick` every minute (the incremental one — reads only what the AI tools
9
+ // appended since the last run) and the full `hacklab sync --quiet` once a day
10
+ // (the repair pass, which also re-bases the tick's state). launchd on macOS, a
11
+ // systemd user timer on Linux, Task Scheduler on Windows, and printed
12
+ // instructions when none of those fit. The scheduled command is resolved to an
13
+ // absolute `node <entry>` pair so a scheduler running with a bare PATH
14
+ // (cron/launchd/systemd often have almost none) can launch it without a
15
+ // `hacklab` shim.
12
16
  const LAUNCHD_LABEL = 'so.hacklab.sync';
17
+ const LAUNCHD_TICK_LABEL = 'so.hacklab.tick';
13
18
  const SYSTEMD_UNIT = 'hacklab-sync';
19
+ const SYSTEMD_TICK_UNIT = 'hacklab-tick';
14
20
  const SCHTASKS_TASK = 'hacklab-sync';
21
+ const SCHTASKS_TICK_TASK = 'hacklab-tick';
15
22
  /** Run a command without ever rejecting: resolves the exit code (127 when the
16
23
  * binary can't even be spawned, e.g. `systemctl` absent). */
17
24
  function run(cmd, args, opts = {}) {
@@ -29,6 +36,25 @@ export function syncLogPath() {
29
36
  function pausedMarkerPath() {
30
37
  return join(dirname(getSessionPath()), 'sync-paused');
31
38
  }
39
+ // The tick runs 1440 times a day, so the log has to be bounded even if every
40
+ // one of those runs has something to say.
41
+ export const SYNC_LOG_MAX_BYTES = 1_000_000;
42
+ export const SYNC_LOG_KEEP_LINES = 200;
43
+ /** Cut an oversized sync.log down to its last few hundred lines. Best-effort,
44
+ * and a no-op while the log is small — which is the normal case. */
45
+ export async function trimSyncLog(maxBytes = SYNC_LOG_MAX_BYTES, keepLines = SYNC_LOG_KEEP_LINES) {
46
+ try {
47
+ const path = syncLogPath();
48
+ if ((await stat(path)).size <= maxBytes)
49
+ return;
50
+ const lines = (await readFile(path, 'utf8')).split('\n');
51
+ const kept = lines.slice(-keepLines).join('\n');
52
+ await writeFile(path, kept.endsWith('\n') ? kept : `${kept}\n`, 'utf8');
53
+ }
54
+ catch {
55
+ // no log yet, or we can't rewrite it — either way, nothing to do
56
+ }
57
+ }
32
58
  /** Append a timestamped line to the background-sync log (best-effort). */
33
59
  export async function appendSyncLog(line) {
34
60
  try {
@@ -86,8 +112,9 @@ function xmlEscape(s) {
86
112
  return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
87
113
  }
88
114
  const pad2 = (n) => String(n).padStart(2, '0');
89
- export function launchdPlist(cmd, time, logPath) {
90
- const args = [cmd.node, cmd.script, 'sync', '--quiet']
115
+ /** The plist skeleton both jobs share — same command shape, different schedule. */
116
+ function launchdDoc(label, cmd, mode, schedule, logPath) {
117
+ const args = [cmd.node, cmd.script, 'sync', mode]
91
118
  .map((a) => ` <string>${xmlEscape(a)}</string>`)
92
119
  .join('\n');
93
120
  return `<?xml version="1.0" encoding="UTF-8"?>
@@ -95,18 +122,12 @@ export function launchdPlist(cmd, time, logPath) {
95
122
  <plist version="1.0">
96
123
  <dict>
97
124
  <key>Label</key>
98
- <string>${LAUNCHD_LABEL}</string>
125
+ <string>${label}</string>
99
126
  <key>ProgramArguments</key>
100
127
  <array>
101
128
  ${args}
102
129
  </array>
103
- <key>StartCalendarInterval</key>
104
- <dict>
105
- <key>Hour</key>
106
- <integer>${time.hour}</integer>
107
- <key>Minute</key>
108
- <integer>${time.minute}</integer>
109
- </dict>
130
+ ${schedule}
110
131
  <key>StandardOutPath</key>
111
132
  <string>${xmlEscape(logPath)}</string>
112
133
  <key>StandardErrorPath</key>
@@ -117,6 +138,21 @@ ${args}
117
138
  </plist>
118
139
  `;
119
140
  }
141
+ export function launchdPlist(cmd, time, logPath) {
142
+ return launchdDoc(LAUNCHD_LABEL, cmd, '--quiet', ` <key>StartCalendarInterval</key>
143
+ <dict>
144
+ <key>Hour</key>
145
+ <integer>${time.hour}</integer>
146
+ <key>Minute</key>
147
+ <integer>${time.minute}</integer>
148
+ </dict>`, logPath);
149
+ }
150
+ /** The minutely tick. StartInterval (not a calendar interval) so launchd just
151
+ * re-runs it every 60s; a tick with nothing to report exits without a request. */
152
+ export function launchdTickPlist(cmd, logPath) {
153
+ return launchdDoc(LAUNCHD_TICK_LABEL, cmd, '--tick', ` <key>StartInterval</key>
154
+ <integer>60</integer>`, logPath);
155
+ }
120
156
  export function systemdService(cmd) {
121
157
  // Quote node + script so paths with spaces survive systemd's parser.
122
158
  return `[Unit]
@@ -138,6 +174,32 @@ OnCalendar=daily
138
174
  Persistent=true
139
175
  RandomizedDelaySec=3600
140
176
 
177
+ [Install]
178
+ WantedBy=timers.target
179
+ `;
180
+ }
181
+ export function systemdTickService(cmd) {
182
+ return `[Unit]
183
+ Description=hacklab token tick
184
+
185
+ [Service]
186
+ Type=oneshot
187
+ ExecStart="${cmd.node}" "${cmd.script}" sync --tick
188
+ `;
189
+ }
190
+ export function systemdTickTimer() {
191
+ // OnUnitActiveSec re-arms a minute after each run finishes (so a slow tick
192
+ // can't stack up), OnBootSec gives the desktop a moment to settle first, and
193
+ // AccuracySec lets systemd batch the wakeup with others — a minutely timer is
194
+ // otherwise a needless drain on a laptop.
195
+ return `[Unit]
196
+ Description=hacklab token tick
197
+
198
+ [Timer]
199
+ OnBootSec=2min
200
+ OnUnitActiveSec=1min
201
+ AccuracySec=30s
202
+
141
203
  [Install]
142
204
  WantedBy=timers.target
143
205
  `;
@@ -147,6 +209,11 @@ WantedBy=timers.target
147
209
  export function syncWrapperPath() {
148
210
  return join(dirname(getSessionPath()), 'hacklab-sync.cmd');
149
211
  }
212
+ /** The tick's own wrapper — same pattern, its own file so the two tasks can be
213
+ * created and deleted independently. */
214
+ export function tickWrapperPath() {
215
+ return join(dirname(getSessionPath()), 'hacklab-tick.cmd');
216
+ }
150
217
  /** The batch wrapper Task Scheduler runs. schtasks' `/TR` chokes on the nested
151
218
  * quotes a full `"node" "script" …` command needs, so we point the task at this
152
219
  * one-line .cmd instead and do the quoting here, where plain-batch rules apply.
@@ -155,6 +222,10 @@ export function syncWrapperPath() {
155
222
  export function schtasksWrapper(cmd, logPath) {
156
223
  return `@echo off\r\n"${cmd.node}" "${cmd.script}" sync --quiet >> "${logPath}" 2>&1\r\n`;
157
224
  }
225
+ /** Same wrapper for the minutely tick, logging to the same sync.log. */
226
+ export function schtasksTickWrapper(cmd, logPath) {
227
+ return `@echo off\r\n"${cmd.node}" "${cmd.script}" sync --tick >> "${logPath}" 2>&1\r\n`;
228
+ }
158
229
  /** Args for `schtasks /Create`. The `/TR` value is a single pre-quoted path;
159
230
  * spawn must run with windowsVerbatimArguments so Node doesn't re-escape it. */
160
231
  export function schtasksCreateArgs(wrapperPath, time) {
@@ -171,35 +242,61 @@ export function schtasksCreateArgs(wrapperPath, time) {
171
242
  '/F',
172
243
  ];
173
244
  }
245
+ /** Args for `schtasks /Create` for the tick: every minute, forever. */
246
+ export function schtasksTickCreateArgs(wrapperPath) {
247
+ return [
248
+ '/Create',
249
+ '/SC',
250
+ 'MINUTE',
251
+ '/MO',
252
+ '1',
253
+ '/TN',
254
+ SCHTASKS_TICK_TASK,
255
+ '/TR',
256
+ `"${wrapperPath}"`,
257
+ '/F',
258
+ ];
259
+ }
174
260
  // Generic fallback text, reused for both "Linux without a systemd user manager"
175
261
  // and "OS we don't auto-schedule on" — so it must not name a specific mechanism.
176
262
  export function manualInstructions(cmd) {
177
263
  return [
178
- "Couldn't set up an automatic daily sync on this system.",
179
- 'To run it yourself, schedule this command to run once a day with cron, a',
180
- "systemd timer, or your init system's scheduler:",
264
+ "Couldn't set up the automatic background sync on this system.",
265
+ 'To run it yourself, schedule these two commands with cron, a systemd timer,',
266
+ "or your init system's scheduler — the tick every minute, the full sync once",
267
+ 'a day:',
268
+ ` "${cmd.node}" "${cmd.script}" sync --tick`,
181
269
  ` "${cmd.node}" "${cmd.script}" sync --quiet`,
182
270
  ].join('\n');
183
271
  }
272
+ function launchAgentPath(label) {
273
+ return join(homedir(), 'Library', 'LaunchAgents', `${label}.plist`);
274
+ }
275
+ /** Write a plist and (re)load it. Unload first so a re-run replaces the agent
276
+ * rather than stacking a second copy. */
277
+ async function loadAgent(path, contents) {
278
+ await mkdir(dirname(path), { recursive: true });
279
+ await writeFile(path, contents, 'utf8');
280
+ await run('launchctl', ['unload', path]);
281
+ return run('launchctl', ['load', '-w', path]);
282
+ }
184
283
  async function installLaunchd(cmd, logPath) {
185
- const plistPath = join(homedir(), 'Library', 'LaunchAgents', `${LAUNCHD_LABEL}.plist`);
284
+ const plistPath = launchAgentPath(LAUNCHD_LABEL);
186
285
  // Randomize the time so installs don't all hit the API at the same instant.
187
286
  const time = {
188
287
  hour: Math.floor(Math.random() * 24),
189
288
  minute: Math.floor(Math.random() * 60),
190
289
  };
191
- await mkdir(dirname(plistPath), { recursive: true });
192
- await writeFile(plistPath, launchdPlist(cmd, time, logPath), 'utf8');
193
- // Reload idempotently. A plist in ~/Library/LaunchAgents also loads at next
194
- // login, so even if `load` fails now the agent activates then — report that
195
- // honestly rather than claiming it's already running.
196
- await run('launchctl', ['unload', plistPath]);
197
- const loaded = await run('launchctl', ['load', '-w', plistPath]);
290
+ const loaded = await loadAgent(plistPath, launchdPlist(cmd, time, logPath));
291
+ await loadAgent(launchAgentPath(LAUNCHD_TICK_LABEL), launchdTickPlist(cmd, logPath));
292
+ // A plist in ~/Library/LaunchAgents also loads at next login, so even if
293
+ // `load` fails now the agent activates then — report that honestly rather
294
+ // than claiming it's already running.
198
295
  return {
199
296
  ok: true,
200
297
  mechanism: 'launchd',
201
298
  detail: loaded === 0
202
- ? `daily around ${pad2(time.hour)}:${pad2(time.minute)} (${plistPath})`
299
+ ? `tick every minute, full sync daily around ${pad2(time.hour)}:${pad2(time.minute)} (${plistPath})`
203
300
  : `installed (${plistPath}) — activates at next login`,
204
301
  };
205
302
  }
@@ -219,18 +316,27 @@ async function installSystemd(cmd) {
219
316
  await mkdir(dir, { recursive: true });
220
317
  await writeFile(join(dir, `${SYSTEMD_UNIT}.service`), systemdService(cmd), 'utf8');
221
318
  await writeFile(join(dir, `${SYSTEMD_UNIT}.timer`), systemdTimer(), 'utf8');
319
+ await writeFile(join(dir, `${SYSTEMD_TICK_UNIT}.service`), systemdTickService(cmd), 'utf8');
320
+ await writeFile(join(dir, `${SYSTEMD_TICK_UNIT}.timer`), systemdTickTimer(), 'utf8');
222
321
  await run('systemctl', ['--user', 'daemon-reload']);
223
322
  await run('systemctl', ['--user', 'enable', '--now', `${SYSTEMD_UNIT}.timer`]);
323
+ await run('systemctl', [
324
+ '--user',
325
+ 'enable',
326
+ '--now',
327
+ `${SYSTEMD_TICK_UNIT}.timer`,
328
+ ]);
224
329
  return {
225
330
  ok: true,
226
331
  mechanism: 'systemd',
227
- detail: `systemd user timer (${SYSTEMD_UNIT}.timer); logs in journalctl --user -u ${SYSTEMD_UNIT}. To keep it running while logged out: loginctl enable-linger`,
332
+ detail: `systemd user timers (${SYSTEMD_TICK_UNIT}.timer every minute, ${SYSTEMD_UNIT}.timer daily); logs in journalctl --user -u ${SYSTEMD_UNIT}. To keep them running while logged out: loginctl enable-linger`,
228
333
  };
229
334
  }
230
335
  async function installSchtasks(cmd) {
231
336
  const wrapperPath = syncWrapperPath();
232
337
  await mkdir(dirname(wrapperPath), { recursive: true });
233
338
  await writeFile(wrapperPath, schtasksWrapper(cmd, syncLogPath()), 'utf8');
339
+ await writeFile(tickWrapperPath(), schtasksTickWrapper(cmd, syncLogPath()), 'utf8');
234
340
  // Randomize the time so installs don't all hit the API at the same instant.
235
341
  const time = {
236
342
  hour: Math.floor(Math.random() * 24),
@@ -249,13 +355,16 @@ async function installSchtasks(cmd) {
249
355
  instructions: manualInstructions(cmd),
250
356
  };
251
357
  }
358
+ // The daily job is the one that must exist; a refused minutely task (some
359
+ // policies cap task frequency) costs freshness, not the streak.
360
+ const tick = await run('schtasks', schtasksTickCreateArgs(tickWrapperPath()), { windowsVerbatimArguments: true });
252
361
  return {
253
362
  ok: true,
254
363
  mechanism: 'schtasks',
255
- detail: `daily around ${pad2(time.hour)}:${pad2(time.minute)} (Task Scheduler task "${SCHTASKS_TASK}")`,
364
+ detail: `${tick === 0 ? 'tick every minute, ' : ''}full sync daily around ${pad2(time.hour)}:${pad2(time.minute)} (Task Scheduler task "${SCHTASKS_TASK}")`,
256
365
  };
257
366
  }
258
- /** Install (or refresh) the daily background sync for the current OS. */
367
+ /** Install (or refresh) both background jobs (tick + daily) for the current OS. */
259
368
  export async function installDailySync() {
260
369
  const cmd = resolveSyncCommand();
261
370
  try {
@@ -283,31 +392,32 @@ export async function installDailySync() {
283
392
  };
284
393
  }
285
394
  }
286
- /** Remove the daily background sync. Best-effort and never throws, so it's safe
287
- * to call from `logout` whether or not it was ever installed. */
395
+ /** Remove both background jobs. Best-effort and never throws, so it's safe to
396
+ * call from `logout` whether or not they were ever installed. */
288
397
  export async function uninstallDailySync() {
289
398
  const os = platform();
290
399
  try {
291
400
  if (os === 'darwin') {
292
- const plistPath = join(homedir(), 'Library', 'LaunchAgents', `${LAUNCHD_LABEL}.plist`);
293
- await run('launchctl', ['unload', plistPath]);
294
- await rm(plistPath, { force: true });
401
+ for (const label of [LAUNCHD_LABEL, LAUNCHD_TICK_LABEL]) {
402
+ const plistPath = launchAgentPath(label);
403
+ await run('launchctl', ['unload', plistPath]);
404
+ await rm(plistPath, { force: true });
405
+ }
295
406
  }
296
407
  else if (os === 'linux') {
297
- await run('systemctl', [
298
- '--user',
299
- 'disable',
300
- '--now',
301
- `${SYSTEMD_UNIT}.timer`,
302
- ]);
303
408
  const dir = join(homedir(), '.config', 'systemd', 'user');
304
- await rm(join(dir, `${SYSTEMD_UNIT}.timer`), { force: true });
305
- await rm(join(dir, `${SYSTEMD_UNIT}.service`), { force: true });
409
+ for (const unit of [SYSTEMD_UNIT, SYSTEMD_TICK_UNIT]) {
410
+ await run('systemctl', ['--user', 'disable', '--now', `${unit}.timer`]);
411
+ await rm(join(dir, `${unit}.timer`), { force: true });
412
+ await rm(join(dir, `${unit}.service`), { force: true });
413
+ }
306
414
  await run('systemctl', ['--user', 'daemon-reload']);
307
415
  }
308
416
  else if (os === 'win32') {
309
417
  await run('schtasks', ['/Delete', '/TN', SCHTASKS_TASK, '/F']);
418
+ await run('schtasks', ['/Delete', '/TN', SCHTASKS_TICK_TASK, '/F']);
310
419
  await rm(syncWrapperPath(), { force: true });
420
+ await rm(tickWrapperPath(), { force: true });
311
421
  }
312
422
  }
313
423
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"daily-sync.js","sourceRoot":"","sources":["../src/daily-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,6EAA6E;AAC7E,4EAA4E;AAC5E,sEAAsE;AACtE,6EAA6E;AAC7E,0EAA0E;AAE1E,MAAM,aAAa,GAAG,iBAAiB,CAAA;AACvC,MAAM,YAAY,GAAG,cAAc,CAAA;AACnC,MAAM,aAAa,GAAG,cAAc,CAAA;AAQpC;6DAC6D;AAC7D,SAAS,GAAG,CACV,GAAW,EACX,IAAc,EACd,OAA+C,EAAE;IAEjD,OAAO,IAAI,OAAO,CAAC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,EAAE,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,cAAc;IAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Consent for uploading anything derived from the user's Claude Code
3
+ * conversations.
4
+ *
5
+ * Nothing conversation-derived leaves the machine until someone has answered
6
+ * this explicitly. The tiers are additive:
7
+ *
8
+ * none token counts only — exactly what the CLI did before this existed
9
+ * stats + prompt-length histogram and per-project prompt counts (numbers
10
+ * only; no prompt text ever leaves the machine)
11
+ * full + a sample of the raw prompt text, so the backend can score how
12
+ * technical the prompting is. It scores the sample and discards it.
13
+ *
14
+ * The answer is remembered in ~/.hacklab/config.json so the question is asked
15
+ * once, and can be changed or revoked at any time with
16
+ * `hacklab config prompt-stats <tier>`.
17
+ */
18
+ export declare const PROMPT_CONSENT_TIERS: readonly ["none", "stats", "full"];
19
+ export type PromptConsentTier = (typeof PROMPT_CONSENT_TIERS)[number];
20
+ export declare function isPromptConsentTier(value: unknown): value is PromptConsentTier;
21
+ /** The stored answer, or null when the user has never been asked. */
22
+ export declare function loadPromptConsent(): Promise<PromptConsentTier | null>;
23
+ export declare function savePromptConsent(tier: PromptConsentTier): Promise<void>;
24
+ /**
25
+ * Read `--share-prompt-stats[=<tier>]` out of a command's args.
26
+ *
27
+ * This is the agent-friendly path: it answers the question up front so an
28
+ * unattended run never blocks on a prompt it can't see. Bare
29
+ * `--share-prompt-stats` means the numbers-only tier — the safe reading of an
30
+ * unqualified yes, since sending prompt *text* should always be deliberate.
31
+ * `--no-share-prompt-stats` is an explicit refusal.
32
+ *
33
+ * Returns the chosen tier, or null when the flag is absent. `rest` is the args
34
+ * with the flag removed so per-command parsing never sees it.
35
+ */
36
+ export declare function parsePromptStatsFlag(args: string[]): {
37
+ tier: PromptConsentTier | null;
38
+ rest: string[];
39
+ };
40
+ /**
41
+ * Ask a yes/no question with no default: Enter alone re-asks, and only `y` or
42
+ * `n` settles it. Deliberately not @clack/prompts' confirm, which ships a
43
+ * highlighted default that can be accepted with a stray Enter — consent to
44
+ * upload conversation data should never be something you agree to by
45
+ * reflex.
46
+ *
47
+ * Returns null on a non-TTY stdin or EOF, which callers treat as "unanswered"
48
+ * rather than as a yes.
49
+ */
50
+ export declare function askYesNo(question: string): Promise<boolean | null>;
51
+ /**
52
+ * Resolve the consent tier for this run.
53
+ *
54
+ * Precedence: an explicit flag wins (and is remembered), then the stored
55
+ * answer, then the interactive questions. An unattended run that has never
56
+ * answered gets `none` — silence is never consent.
57
+ */
58
+ export declare function resolvePromptConsent(flagTier: PromptConsentTier | null, opts?: {
59
+ interactive?: boolean;
60
+ }): Promise<PromptConsentTier>;
61
+ //# sourceMappingURL=prompt-consent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-consent.d.ts","sourceRoot":"","sources":["../src/prompt-consent.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,oBAAoB,oCAAqC,CAAA;AACtE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAErE,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,iBAAiB,CAK5B;AAED,qEAAqE;AACrE,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAK3E;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IACpD,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC9B,IAAI,EAAE,MAAM,EAAE,CAAA;CACf,CAsBA;AAED;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAoBxE;AA+BD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,EAClC,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACnC,OAAO,CAAC,iBAAiB,CAAC,CAyC5B"}