hacklab 0.22.2 → 26.921.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -430
- package/dist/index.js +132 -23
- package/package.json +20 -42
- package/LICENSE +0 -21
- package/dist/agent-handoff.d.ts +0 -51
- package/dist/agent-handoff.d.ts.map +0 -1
- package/dist/agent-handoff.js +0 -91
- package/dist/agent-handoff.js.map +0 -1
- package/dist/api-client.d.ts +0 -18
- package/dist/api-client.d.ts.map +0 -1
- package/dist/api-client.js +0 -40
- package/dist/api-client.js.map +0 -1
- package/dist/belt.d.ts +0 -25
- package/dist/belt.d.ts.map +0 -1
- package/dist/belt.js +0 -113
- package/dist/belt.js.map +0 -1
- package/dist/card.d.ts +0 -66
- package/dist/card.d.ts.map +0 -1
- package/dist/card.js +0 -151
- package/dist/card.js.map +0 -1
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -238
- package/dist/cli.js.map +0 -1
- package/dist/commands/book.d.ts +0 -14
- package/dist/commands/book.d.ts.map +0 -1
- package/dist/commands/book.js +0 -90
- package/dist/commands/book.js.map +0 -1
- package/dist/commands/chat.d.ts +0 -36
- package/dist/commands/chat.d.ts.map +0 -1
- package/dist/commands/chat.js +0 -642
- package/dist/commands/chat.js.map +0 -1
- package/dist/commands/config.d.ts +0 -2
- package/dist/commands/config.d.ts.map +0 -1
- package/dist/commands/config.js +0 -84
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/daemon.d.ts +0 -19
- package/dist/commands/daemon.d.ts.map +0 -1
- package/dist/commands/daemon.js +0 -72
- package/dist/commands/daemon.js.map +0 -1
- package/dist/commands/drop.d.ts +0 -12
- package/dist/commands/drop.d.ts.map +0 -1
- package/dist/commands/drop.js +0 -103
- package/dist/commands/drop.js.map +0 -1
- package/dist/commands/drops.d.ts +0 -9
- package/dist/commands/drops.d.ts.map +0 -1
- package/dist/commands/drops.js +0 -96
- package/dist/commands/drops.js.map +0 -1
- package/dist/commands/essay.d.ts +0 -40
- package/dist/commands/essay.d.ts.map +0 -1
- package/dist/commands/essay.js +0 -651
- package/dist/commands/essay.js.map +0 -1
- package/dist/commands/hackathon.d.ts +0 -2
- package/dist/commands/hackathon.d.ts.map +0 -1
- package/dist/commands/hackathon.js +0 -893
- package/dist/commands/hackathon.js.map +0 -1
- package/dist/commands/hacker.d.ts +0 -2
- package/dist/commands/hacker.d.ts.map +0 -1
- package/dist/commands/hacker.js +0 -87
- package/dist/commands/hacker.js.map +0 -1
- package/dist/commands/jobs.d.ts +0 -18
- package/dist/commands/jobs.d.ts.map +0 -1
- package/dist/commands/jobs.js +0 -138
- package/dist/commands/jobs.js.map +0 -1
- package/dist/commands/keys.d.ts +0 -2
- package/dist/commands/keys.d.ts.map +0 -1
- package/dist/commands/keys.js +0 -138
- package/dist/commands/keys.js.map +0 -1
- package/dist/commands/login.d.ts +0 -83
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -236
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts +0 -2
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js +0 -22
- package/dist/commands/logout.js.map +0 -1
- package/dist/commands/org-jobs.d.ts +0 -50
- package/dist/commands/org-jobs.d.ts.map +0 -1
- package/dist/commands/org-jobs.js +0 -383
- package/dist/commands/org-jobs.js.map +0 -1
- package/dist/commands/org.d.ts +0 -67
- package/dist/commands/org.d.ts.map +0 -1
- package/dist/commands/org.js +0 -1244
- package/dist/commands/org.js.map +0 -1
- package/dist/commands/ping.d.ts +0 -2
- package/dist/commands/ping.d.ts.map +0 -1
- package/dist/commands/ping.js +0 -50
- package/dist/commands/ping.js.map +0 -1
- package/dist/commands/profile.d.ts +0 -72
- package/dist/commands/profile.d.ts.map +0 -1
- package/dist/commands/profile.js +0 -672
- package/dist/commands/profile.js.map +0 -1
- package/dist/commands/project.d.ts +0 -2
- package/dist/commands/project.d.ts.map +0 -1
- package/dist/commands/project.js +0 -583
- package/dist/commands/project.js.map +0 -1
- package/dist/commands/referral.d.ts +0 -6
- package/dist/commands/referral.d.ts.map +0 -1
- package/dist/commands/referral.js +0 -93
- package/dist/commands/referral.js.map +0 -1
- package/dist/commands/rtfm.d.ts +0 -9
- package/dist/commands/rtfm.d.ts.map +0 -1
- package/dist/commands/rtfm.js +0 -114
- package/dist/commands/rtfm.js.map +0 -1
- package/dist/commands/scan.d.ts +0 -13
- package/dist/commands/scan.d.ts.map +0 -1
- package/dist/commands/scan.js +0 -286
- package/dist/commands/scan.js.map +0 -1
- package/dist/commands/scout.d.ts +0 -18
- package/dist/commands/scout.d.ts.map +0 -1
- package/dist/commands/scout.js +0 -232
- package/dist/commands/scout.js.map +0 -1
- package/dist/commands/setup-rail.d.ts +0 -58
- package/dist/commands/setup-rail.d.ts.map +0 -1
- package/dist/commands/setup-rail.js +0 -135
- package/dist/commands/setup-rail.js.map +0 -1
- package/dist/commands/setup.d.ts +0 -29
- package/dist/commands/setup.d.ts.map +0 -1
- package/dist/commands/setup.js +0 -442
- package/dist/commands/setup.js.map +0 -1
- package/dist/commands/sync.d.ts +0 -9
- package/dist/commands/sync.d.ts.map +0 -1
- package/dist/commands/sync.js +0 -345
- package/dist/commands/sync.js.map +0 -1
- package/dist/commands/update.d.ts +0 -2
- package/dist/commands/update.d.ts.map +0 -1
- package/dist/commands/update.js +0 -92
- package/dist/commands/update.js.map +0 -1
- package/dist/commands/whoami.d.ts +0 -2
- package/dist/commands/whoami.d.ts.map +0 -1
- package/dist/commands/whoami.js +0 -41
- package/dist/commands/whoami.js.map +0 -1
- package/dist/config.d.ts +0 -78
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -93
- package/dist/config.js.map +0 -1
- package/dist/daily-sync.d.ts +0 -150
- package/dist/daily-sync.d.ts.map +0 -1
- package/dist/daily-sync.js +0 -665
- package/dist/daily-sync.js.map +0 -1
- package/dist/dossier.d.ts +0 -73
- package/dist/dossier.d.ts.map +0 -1
- package/dist/dossier.js +0 -141
- package/dist/dossier.js.map +0 -1
- package/dist/field-normalize.d.ts +0 -4
- package/dist/field-normalize.d.ts.map +0 -1
- package/dist/field-normalize.js +0 -8
- package/dist/field-normalize.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/job-fields.d.ts +0 -47
- package/dist/job-fields.d.ts.map +0 -1
- package/dist/job-fields.js +0 -148
- package/dist/job-fields.js.map +0 -1
- package/dist/machine.d.ts +0 -15
- package/dist/machine.d.ts.map +0 -1
- package/dist/machine.js +0 -64
- package/dist/machine.js.map +0 -1
- package/dist/org-fields.d.ts +0 -57
- package/dist/org-fields.d.ts.map +0 -1
- package/dist/org-fields.js +0 -167
- package/dist/org-fields.js.map +0 -1
- package/dist/posthog.d.ts +0 -38
- package/dist/posthog.d.ts.map +0 -1
- package/dist/posthog.js +0 -224
- package/dist/posthog.js.map +0 -1
- package/dist/project-fields.d.ts +0 -40
- package/dist/project-fields.d.ts.map +0 -1
- package/dist/project-fields.js +0 -79
- package/dist/project-fields.js.map +0 -1
- package/dist/prompt-consent.d.ts +0 -73
- package/dist/prompt-consent.d.ts.map +0 -1
- package/dist/prompt-consent.js +0 -191
- package/dist/prompt-consent.js.map +0 -1
- package/dist/prompt-stats.d.ts +0 -226
- package/dist/prompt-stats.d.ts.map +0 -1
- package/dist/prompt-stats.js +0 -561
- package/dist/prompt-stats.js.map +0 -1
- package/dist/referral.d.ts +0 -14
- package/dist/referral.d.ts.map +0 -1
- package/dist/referral.js +0 -28
- package/dist/referral.js.map +0 -1
- package/dist/registry.d.ts +0 -15
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -180
- package/dist/registry.js.map +0 -1
- package/dist/resolve-command.d.ts +0 -20
- package/dist/resolve-command.d.ts.map +0 -1
- package/dist/resolve-command.js +0 -21
- package/dist/resolve-command.js.map +0 -1
- package/dist/scanners/antigravity.d.ts +0 -41
- package/dist/scanners/antigravity.d.ts.map +0 -1
- package/dist/scanners/antigravity.js +0 -210
- package/dist/scanners/antigravity.js.map +0 -1
- package/dist/scanners/github-copilot-telemetry.d.ts +0 -23
- package/dist/scanners/github-copilot-telemetry.d.ts.map +0 -1
- package/dist/scanners/github-copilot-telemetry.js +0 -220
- package/dist/scanners/github-copilot-telemetry.js.map +0 -1
- package/dist/scanners/github-copilot.d.ts +0 -68
- package/dist/scanners/github-copilot.d.ts.map +0 -1
- package/dist/scanners/github-copilot.js +0 -262
- package/dist/scanners/github-copilot.js.map +0 -1
- package/dist/scanners/incremental.d.ts +0 -282
- package/dist/scanners/incremental.d.ts.map +0 -1
- package/dist/scanners/incremental.js +0 -788
- package/dist/scanners/incremental.js.map +0 -1
- package/dist/scanners/index.d.ts +0 -116
- package/dist/scanners/index.d.ts.map +0 -1
- package/dist/scanners/index.js +0 -726
- package/dist/scanners/index.js.map +0 -1
- package/dist/scanners/sqlite.d.ts +0 -18
- package/dist/scanners/sqlite.d.ts.map +0 -1
- package/dist/scanners/sqlite.js +0 -63
- package/dist/scanners/sqlite.js.map +0 -1
- package/dist/scanners/util.d.ts +0 -112
- package/dist/scanners/util.d.ts.map +0 -1
- package/dist/scanners/util.js +0 -167
- package/dist/scanners/util.js.map +0 -1
- package/dist/session.d.ts +0 -106
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -191
- package/dist/session.js.map +0 -1
- package/dist/share-card-colors.d.ts +0 -19
- package/dist/share-card-colors.d.ts.map +0 -1
- package/dist/share-card-colors.js +0 -36
- package/dist/share-card-colors.js.map +0 -1
- package/dist/share-card.d.ts +0 -32
- package/dist/share-card.d.ts.map +0 -1
- package/dist/share-card.js +0 -420
- package/dist/share-card.js.map +0 -1
- package/dist/share.d.ts +0 -17
- package/dist/share.d.ts.map +0 -1
- package/dist/share.js +0 -77
- package/dist/share.js.map +0 -1
- package/dist/sync.d.ts +0 -100
- package/dist/sync.d.ts.map +0 -1
- package/dist/sync.js +0 -304
- package/dist/sync.js.map +0 -1
- package/dist/ui.d.ts +0 -33
- package/dist/ui.d.ts.map +0 -1
- package/dist/ui.js +0 -127
- package/dist/ui.js.map +0 -1
- package/dist/utils/npmGlobal.d.ts +0 -30
- package/dist/utils/npmGlobal.d.ts.map +0 -1
- package/dist/utils/npmGlobal.js +0 -69
- package/dist/utils/npmGlobal.js.map +0 -1
- package/dist/utils/openBrowser.d.ts +0 -14
- package/dist/utils/openBrowser.d.ts.map +0 -1
- package/dist/utils/openBrowser.js +0 -47
- package/dist/utils/openBrowser.js.map +0 -1
- package/dist/utils/updateCheck.d.ts +0 -16
- package/dist/utils/updateCheck.d.ts.map +0 -1
- package/dist/utils/updateCheck.js +0 -111
- package/dist/utils/updateCheck.js.map +0 -1
- package/dist/utils/waitForEnter.d.ts +0 -12
- package/dist/utils/waitForEnter.d.ts.map +0 -1
- package/dist/utils/waitForEnter.js +0 -43
- package/dist/utils/waitForEnter.js.map +0 -1
package/dist/prompt-consent.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Consent for syncing anything derived from supported local harness
|
|
3
|
-
* conversations, including IDE chats.
|
|
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 — nothing prompt-related leaves the machine
|
|
9
|
-
* stats + continuous prompt metadata: counts, word counts, timestamps and
|
|
10
|
-
* session ids, synced every minute alongside tokens, so the profile
|
|
11
|
-
* can show sessions, concurrent sessions and prompt counts. Prompt
|
|
12
|
-
* text never leaves the machine.
|
|
13
|
-
* full + a rolling sample of the most recent prompts (up to 20,000
|
|
14
|
-
* characters) sent with the daily sync, used only to estimate a
|
|
15
|
-
* technical-level score and then discarded. Never stored.
|
|
16
|
-
*
|
|
17
|
-
* The answer is remembered in ~/.hacklab/config.json under `promptSync` so the
|
|
18
|
-
* question is asked once, and can be changed or revoked at any time with
|
|
19
|
-
* `hacklab config prompt-sync <tier>`.
|
|
20
|
-
*/
|
|
21
|
-
export declare const PROMPT_SYNC_TIERS: readonly ["none", "stats", "full"];
|
|
22
|
-
export type PromptSyncTier = (typeof PROMPT_SYNC_TIERS)[number];
|
|
23
|
-
export declare function isPromptSyncTier(value: unknown): value is PromptSyncTier;
|
|
24
|
-
/**
|
|
25
|
-
* The stored answer for the current source scope. A refusal remains a refusal;
|
|
26
|
-
* a positive answer to the older Claude-only disclosure needs fresh consent.
|
|
27
|
-
*/
|
|
28
|
-
export declare function loadPromptSync(): Promise<PromptSyncTier | null>;
|
|
29
|
-
/**
|
|
30
|
-
* Remember the answer. Read-modify-write via `updateConfig` rather than a bare
|
|
31
|
-
* `saveConfig`, because the background jobs call this too and must never
|
|
32
|
-
* flatten a config file they couldn't read. The obsolete key goes with it, so
|
|
33
|
-
* a machine is never carrying two answers to two different questions.
|
|
34
|
-
*/
|
|
35
|
-
export declare function savePromptSync(tier: PromptSyncTier): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Read `--share-prompt-sync[=<tier>]` out of a command's args.
|
|
38
|
-
*
|
|
39
|
-
* This is the agent-friendly path: it answers the question up front so an
|
|
40
|
-
* unattended run never blocks on a prompt it can't see. Bare
|
|
41
|
-
* `--share-prompt-sync` means the metadata-only tier — the safe reading of an
|
|
42
|
-
* unqualified yes, since sending prompt *text* should always be deliberate.
|
|
43
|
-
* `--no-share-prompt-sync` is an explicit refusal.
|
|
44
|
-
*
|
|
45
|
-
* Returns the chosen tier, or null when the flag is absent. `rest` is the args
|
|
46
|
-
* with the flag removed so per-command parsing never sees it.
|
|
47
|
-
*/
|
|
48
|
-
export declare function parsePromptSyncFlag(args: string[]): {
|
|
49
|
-
tier: PromptSyncTier | null;
|
|
50
|
-
rest: string[];
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Ask a yes/no question with no default: Enter alone re-asks, and only `y` or
|
|
54
|
-
* `n` settles it. Deliberately not @clack/prompts' confirm, which ships a
|
|
55
|
-
* highlighted default that can be accepted with a stray Enter — consent to
|
|
56
|
-
* upload conversation data should never be something you agree to by
|
|
57
|
-
* reflex.
|
|
58
|
-
*
|
|
59
|
-
* Returns null on a non-TTY stdin or EOF, which callers treat as "unanswered"
|
|
60
|
-
* rather than as a yes.
|
|
61
|
-
*/
|
|
62
|
-
export declare function askYesNo(question: string): Promise<boolean | null>;
|
|
63
|
-
/**
|
|
64
|
-
* Resolve the prompt-sync tier for this run.
|
|
65
|
-
*
|
|
66
|
-
* Precedence: an explicit flag wins (and is remembered), then the stored
|
|
67
|
-
* answer, then the interactive questions. An unattended run that has never
|
|
68
|
-
* answered gets `none` — silence is never consent.
|
|
69
|
-
*/
|
|
70
|
-
export declare function resolvePromptSync(flagTier: PromptSyncTier | null, opts?: {
|
|
71
|
-
interactive?: boolean;
|
|
72
|
-
}): Promise<PromptSyncTier>;
|
|
73
|
-
//# sourceMappingURL=prompt-consent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-consent.d.ts","sourceRoot":"","sources":["../src/prompt-consent.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,iBAAiB,oCAAqC,CAAA;AACnE,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AAK/D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAKxE;AAED;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAOrE;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAOxE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IACnD,IAAI,EAAE,cAAc,GAAG,IAAI,CAAA;IAC3B,IAAI,EAAE,MAAM,EAAE,CAAA;CACf,CAsBA;AAED;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAoBxE;AAkCD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,cAAc,GAAG,IAAI,EAC/B,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACnC,OAAO,CAAC,cAAc,CAAC,CA8CzB"}
|
package/dist/prompt-consent.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { createInterface } from 'node:readline';
|
|
2
|
-
import { loadConfig, updateConfig } from './config.js';
|
|
3
|
-
import { bold, dim, info } from './ui.js';
|
|
4
|
-
/**
|
|
5
|
-
* Consent for syncing anything derived from supported local harness
|
|
6
|
-
* conversations, including IDE chats.
|
|
7
|
-
*
|
|
8
|
-
* Nothing conversation-derived leaves the machine until someone has answered
|
|
9
|
-
* this explicitly. The tiers are additive:
|
|
10
|
-
*
|
|
11
|
-
* none token counts only — nothing prompt-related leaves the machine
|
|
12
|
-
* stats + continuous prompt metadata: counts, word counts, timestamps and
|
|
13
|
-
* session ids, synced every minute alongside tokens, so the profile
|
|
14
|
-
* can show sessions, concurrent sessions and prompt counts. Prompt
|
|
15
|
-
* text never leaves the machine.
|
|
16
|
-
* full + a rolling sample of the most recent prompts (up to 20,000
|
|
17
|
-
* characters) sent with the daily sync, used only to estimate a
|
|
18
|
-
* technical-level score and then discarded. Never stored.
|
|
19
|
-
*
|
|
20
|
-
* The answer is remembered in ~/.hacklab/config.json under `promptSync` so the
|
|
21
|
-
* question is asked once, and can be changed or revoked at any time with
|
|
22
|
-
* `hacklab config prompt-sync <tier>`.
|
|
23
|
-
*/
|
|
24
|
-
export const PROMPT_SYNC_TIERS = ['none', 'stats', 'full'];
|
|
25
|
-
// Version 1 disclosed only Claude Code. An old yes cannot authorize IDE chats.
|
|
26
|
-
const PROMPT_SYNC_VERSION = 2;
|
|
27
|
-
export function isPromptSyncTier(value) {
|
|
28
|
-
return (typeof value === 'string' &&
|
|
29
|
-
PROMPT_SYNC_TIERS.includes(value));
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The stored answer for the current source scope. A refusal remains a refusal;
|
|
33
|
-
* a positive answer to the older Claude-only disclosure needs fresh consent.
|
|
34
|
-
*/
|
|
35
|
-
export async function loadPromptSync() {
|
|
36
|
-
const config = await loadConfig();
|
|
37
|
-
if (config.promptSync === 'none')
|
|
38
|
-
return 'none';
|
|
39
|
-
return config.promptSyncVersion === PROMPT_SYNC_VERSION &&
|
|
40
|
-
isPromptSyncTier(config.promptSync)
|
|
41
|
-
? config.promptSync
|
|
42
|
-
: null;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Remember the answer. Read-modify-write via `updateConfig` rather than a bare
|
|
46
|
-
* `saveConfig`, because the background jobs call this too and must never
|
|
47
|
-
* flatten a config file they couldn't read. The obsolete key goes with it, so
|
|
48
|
-
* a machine is never carrying two answers to two different questions.
|
|
49
|
-
*/
|
|
50
|
-
export async function savePromptSync(tier) {
|
|
51
|
-
await updateConfig((config) => {
|
|
52
|
-
config.promptSync = tier;
|
|
53
|
-
config.promptSyncVersion = PROMPT_SYNC_VERSION;
|
|
54
|
-
delete config.promptStatsConsent;
|
|
55
|
-
return config;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Read `--share-prompt-sync[=<tier>]` out of a command's args.
|
|
60
|
-
*
|
|
61
|
-
* This is the agent-friendly path: it answers the question up front so an
|
|
62
|
-
* unattended run never blocks on a prompt it can't see. Bare
|
|
63
|
-
* `--share-prompt-sync` means the metadata-only tier — the safe reading of an
|
|
64
|
-
* unqualified yes, since sending prompt *text* should always be deliberate.
|
|
65
|
-
* `--no-share-prompt-sync` is an explicit refusal.
|
|
66
|
-
*
|
|
67
|
-
* Returns the chosen tier, or null when the flag is absent. `rest` is the args
|
|
68
|
-
* with the flag removed so per-command parsing never sees it.
|
|
69
|
-
*/
|
|
70
|
-
export function parsePromptSyncFlag(args) {
|
|
71
|
-
const rest = [];
|
|
72
|
-
let tier = null;
|
|
73
|
-
for (const arg of args) {
|
|
74
|
-
if (arg === '--no-share-prompt-sync') {
|
|
75
|
-
tier = 'none';
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (arg === '--share-prompt-sync') {
|
|
79
|
-
tier = 'stats';
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
if (arg.startsWith('--share-prompt-sync=')) {
|
|
83
|
-
const value = arg.slice('--share-prompt-sync='.length);
|
|
84
|
-
tier = isPromptSyncTier(value) ? value : 'stats';
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
rest.push(arg);
|
|
88
|
-
}
|
|
89
|
-
return { tier, rest };
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Ask a yes/no question with no default: Enter alone re-asks, and only `y` or
|
|
93
|
-
* `n` settles it. Deliberately not @clack/prompts' confirm, which ships a
|
|
94
|
-
* highlighted default that can be accepted with a stray Enter — consent to
|
|
95
|
-
* upload conversation data should never be something you agree to by
|
|
96
|
-
* reflex.
|
|
97
|
-
*
|
|
98
|
-
* Returns null on a non-TTY stdin or EOF, which callers treat as "unanswered"
|
|
99
|
-
* rather than as a yes.
|
|
100
|
-
*/
|
|
101
|
-
export async function askYesNo(question) {
|
|
102
|
-
if (!process.stdin.isTTY)
|
|
103
|
-
return null;
|
|
104
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
105
|
-
try {
|
|
106
|
-
for (;;) {
|
|
107
|
-
const answer = await new Promise((resolve) => {
|
|
108
|
-
rl.question(`${question} ${dim('[y/n]')} `, (value) => resolve(value));
|
|
109
|
-
rl.once('close', () => resolve(null));
|
|
110
|
-
});
|
|
111
|
-
if (answer === null)
|
|
112
|
-
return null;
|
|
113
|
-
const normalized = answer.trim().toLowerCase();
|
|
114
|
-
if (normalized === 'y' || normalized === 'yes')
|
|
115
|
-
return true;
|
|
116
|
-
if (normalized === 'n' || normalized === 'no')
|
|
117
|
-
return false;
|
|
118
|
-
// Anything else (including a bare Enter) is not an answer.
|
|
119
|
-
console.log(dim(' please press y or n.'));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
finally {
|
|
123
|
-
rl.close();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/** The disclosure. Printed verbatim before the first question. */
|
|
127
|
-
function printDisclosure() {
|
|
128
|
-
console.log('');
|
|
129
|
-
console.log(bold(' sync your prompt activity?'));
|
|
130
|
-
console.log('');
|
|
131
|
-
info(' hacklab can keep your profile up to date with how you work with AI,');
|
|
132
|
-
info(' reading Claude Code, GitHub Copilot (VS Code/CLI), and readable');
|
|
133
|
-
info(' Antigravity CLI/IDE chat history stored on this machine.');
|
|
134
|
-
console.log('');
|
|
135
|
-
info(` ${bold('what would be synced, every minute:')}`);
|
|
136
|
-
info(` ${dim('-')} how many prompts you send, and how long they are in words`);
|
|
137
|
-
info(` ${dim('-')} when each session started and last ran, and its session id`);
|
|
138
|
-
info(` ${dim('-')} a prompt count per project, matched by its git remote`);
|
|
139
|
-
console.log('');
|
|
140
|
-
info(` ${bold('what stays on this machine:')}`);
|
|
141
|
-
info(` ${dim('-')} the text of your prompts, unless you separately say yes below`);
|
|
142
|
-
info(` ${dim('-')} local project paths; only git remotes identify projects`);
|
|
143
|
-
console.log('');
|
|
144
|
-
info(dim(' your profile shows your sessions, how many you run at once, and'));
|
|
145
|
-
info(dim(' your prompt counts. change or revoke this any time with'));
|
|
146
|
-
info(dim(' `hacklab config prompt-sync <none|stats|full>`.'));
|
|
147
|
-
console.log('');
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Resolve the prompt-sync tier for this run.
|
|
151
|
-
*
|
|
152
|
-
* Precedence: an explicit flag wins (and is remembered), then the stored
|
|
153
|
-
* answer, then the interactive questions. An unattended run that has never
|
|
154
|
-
* answered gets `none` — silence is never consent.
|
|
155
|
-
*/
|
|
156
|
-
export async function resolvePromptSync(flagTier, opts = {}) {
|
|
157
|
-
if (flagTier) {
|
|
158
|
-
await savePromptSync(flagTier);
|
|
159
|
-
return flagTier;
|
|
160
|
-
}
|
|
161
|
-
const stored = await loadPromptSync();
|
|
162
|
-
if (stored)
|
|
163
|
-
return stored;
|
|
164
|
-
if (!opts.interactive || !process.stdin.isTTY)
|
|
165
|
-
return 'none';
|
|
166
|
-
printDisclosure();
|
|
167
|
-
const shareActivity = await askYesNo(' sync this to hacklab?');
|
|
168
|
-
if (shareActivity === null)
|
|
169
|
-
return 'none';
|
|
170
|
-
if (!shareActivity) {
|
|
171
|
-
await savePromptSync('none');
|
|
172
|
-
console.log('');
|
|
173
|
-
info(dim(' no problem — syncing token counts only.'));
|
|
174
|
-
return 'none';
|
|
175
|
-
}
|
|
176
|
-
console.log('');
|
|
177
|
-
info(' optional: a rolling sample of your most recent prompts (up to 20,000');
|
|
178
|
-
info(' characters) can go out with the daily sync, so a model can estimate');
|
|
179
|
-
info(` how technical your prompting is. hacklab scores it and ${bold('discards it')} —`);
|
|
180
|
-
info(' the text is never stored.');
|
|
181
|
-
console.log('');
|
|
182
|
-
const shareText = await askYesNo(' also send a sample of your most recent prompts?');
|
|
183
|
-
const tier = shareText === true ? 'full' : 'stats';
|
|
184
|
-
await savePromptSync(tier);
|
|
185
|
-
console.log('');
|
|
186
|
-
info(dim(tier === 'full'
|
|
187
|
-
? ' syncing prompt activity and a text sample.'
|
|
188
|
-
: ' syncing prompt activity. numbers only, no text.'));
|
|
189
|
-
return tier;
|
|
190
|
-
}
|
|
191
|
-
//# sourceMappingURL=prompt-consent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-consent.js","sourceRoot":"","sources":["../src/prompt-consent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM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,CAAC,EAAE,CAAC,CAAA;IACf,IAAI,CAAC,wEAAwE,CAAC,CAAA;IAC9E,IAAI,CAAC,uEAAuE,CAAC,CAAA;IAC7E,IAAI,CACF,4DAA4D,IAAI,CAAC,aAAa,CAAC,IAAI,CACpF,CAAA;IACD,IAAI,CAAC,6BAA6B,CAAC,CAAA;IACnC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEf,MAAM,SAAS,GAAG,MAAM,QAAQ,CAC9B,mDAAmD,CACpD,CAAA;IACD,MAAM,IAAI,GAAmB,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAA;IAClE,MAAM,cAAc,CAAC,IAAI,CAAC,CAAA;IAE1B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACf,IAAI,CACF,GAAG,CACD,IAAI,KAAK,MAAM;QACb,CAAC,CAAC,8CAA8C;QAChD,CAAC,CAAC,mDAAmD,CACxD,CACF,CAAA;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/prompt-stats.d.ts
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { antigravityTranscriptFiles, scanAntigravityPrompts } from './scanners/antigravity.js';
|
|
2
|
-
/** Buckets are `1..bucketMax`, so the axis stays readable at any prompt length. */
|
|
3
|
-
export declare const PROMPT_LENGTH_BUCKET_MIN = 10;
|
|
4
|
-
export declare const PROMPT_LENGTH_BUCKET_MAX = 100;
|
|
5
|
-
/** The percentile that sets `bucketMax`; everything above it lands in `tail`. */
|
|
6
|
-
export declare const PROMPT_LENGTH_AXIS_PERCENTILE = 0.9;
|
|
7
|
-
/** The server's cap on `tail` entries; longer distributions are coarsened. */
|
|
8
|
-
export declare const PROMPT_TAIL_MAX_ENTRIES = 400;
|
|
9
|
-
/** Matches the backend's cap — anything longer is truncated before upload. */
|
|
10
|
-
export declare const CONVERSATION_SAMPLE_MAX_CHARS = 20000;
|
|
11
|
-
/**
|
|
12
|
-
* Which definition of "a prompt the user typed" produced this upload.
|
|
13
|
-
*
|
|
14
|
-
* Version 1 is implicit — every CLI shipped before this field existed counted
|
|
15
|
-
* harness-generated `user` entries (subagent task notifications, skill bodies,
|
|
16
|
-
* slash-command echoes, interrupt markers) as prompts, which inflated the
|
|
17
|
-
* counts and blew out the word tallies. Version 2 is the scan with
|
|
18
|
-
* `isHarnessNoise` in it.
|
|
19
|
-
*
|
|
20
|
-
* It rides on every sync as a top-level `scannerVersion`; the server ignores
|
|
21
|
-
* `promptStats` / `promptActivity` from anything below 2, so an un-upgraded CLI
|
|
22
|
-
* can't keep writing the old numbers into a table that was wiped to fix them.
|
|
23
|
-
*/
|
|
24
|
-
export declare const PROMPT_SCANNER_VERSION = 2;
|
|
25
|
-
/**
|
|
26
|
-
* Is this entry text something the harness wrote rather than the user?
|
|
27
|
-
*
|
|
28
|
-
* Deliberately a prefix test and nothing more — no stripping of inline
|
|
29
|
-
* `<system-reminder>` blocks out of otherwise-typed prompts. Those measured at
|
|
30
|
-
* zero words of real contribution, and rewriting prompt text in place is a
|
|
31
|
-
* bigger risk than the noise it would remove.
|
|
32
|
-
*/
|
|
33
|
-
export declare function isHarnessNoise(text: string): boolean;
|
|
34
|
-
export type PromptStatsProject = {
|
|
35
|
-
repoUrl: string;
|
|
36
|
-
promptCount: number;
|
|
37
|
-
lastActiveAt: string;
|
|
38
|
-
};
|
|
39
|
-
/** One session's running aggregate, as both the tick and a full scan build it. */
|
|
40
|
-
export type PromptSessionAggregate = {
|
|
41
|
-
/** ISO timestamp of the first prompt seen in this session. */
|
|
42
|
-
startedAt: string;
|
|
43
|
-
/** ISO timestamp of the most recent one. */
|
|
44
|
-
lastActiveAt: string;
|
|
45
|
-
promptCount: number;
|
|
46
|
-
};
|
|
47
|
-
/** One day's running tally. Cumulative for this machine, never a delta. */
|
|
48
|
-
export type PromptDayAggregate = {
|
|
49
|
-
prompts: number;
|
|
50
|
-
words: number;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* The whole prompt-activity aggregate, keyed for cheap merging: sessions by
|
|
54
|
-
* session id, days by YYYY-MM-DD.
|
|
55
|
-
*/
|
|
56
|
-
export type PromptActivityAggregate = {
|
|
57
|
-
sessions: Record<string, PromptSessionAggregate>;
|
|
58
|
-
daily: Record<string, PromptDayAggregate>;
|
|
59
|
-
};
|
|
60
|
-
/** Prompt-only sources: no token estimates and no token harness registration. */
|
|
61
|
-
export declare const IDE_PROMPT_SOURCES: {
|
|
62
|
-
id: string;
|
|
63
|
-
files: typeof antigravityTranscriptFiles;
|
|
64
|
-
scan: typeof scanAntigravityPrompts;
|
|
65
|
-
}[];
|
|
66
|
-
export type ScannedPromptActivity = PromptActivityAggregate & {
|
|
67
|
-
/** Local-only partitions, so replacing one source never erases another. */
|
|
68
|
-
sources?: Record<string, PromptActivityAggregate>;
|
|
69
|
-
};
|
|
70
|
-
export declare function mergePromptActivities(sources: Iterable<PromptActivityAggregate>): PromptActivityAggregate;
|
|
71
|
-
export type PromptStats = {
|
|
72
|
-
totalPrompts: number;
|
|
73
|
-
bucketMax: number;
|
|
74
|
-
histogram: {
|
|
75
|
-
length: number;
|
|
76
|
-
count: number;
|
|
77
|
-
}[];
|
|
78
|
-
/**
|
|
79
|
-
* The exact distribution above `bucketMax`, and the only place those prompts
|
|
80
|
-
* are reported — the histogram stops at `bucketMax`. One entry per distinct
|
|
81
|
-
* word count, ascending, coarsened if there are more than
|
|
82
|
-
* `PROMPT_TAIL_MAX_ENTRIES` of them. Always present, empty when nothing
|
|
83
|
-
* exceeds `bucketMax`: the field's presence is what tells the server this
|
|
84
|
-
* histogram is exact, as opposed to a legacy snapshot whose last bar lumped
|
|
85
|
-
* everything at or above `bucketMax`.
|
|
86
|
-
*/
|
|
87
|
-
tail: {
|
|
88
|
-
length: number;
|
|
89
|
-
count: number;
|
|
90
|
-
}[];
|
|
91
|
-
projects: PromptStatsProject[];
|
|
92
|
-
/**
|
|
93
|
-
* Sessions and per-day counts for the whole local history. Not part of the
|
|
94
|
-
* `promptStats` block on the wire — the caller hands it to `stageFullScan`,
|
|
95
|
-
* which re-bases the tick's incremental state on it and works out which rows
|
|
96
|
-
* this upload still has to carry.
|
|
97
|
-
*/
|
|
98
|
-
activity: ScannedPromptActivity;
|
|
99
|
-
/** Only ever set under the `full` consent tier. */
|
|
100
|
-
conversationSample?: string;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* The user's own prompt text from one transcript line, or null when the line
|
|
104
|
-
* isn't one.
|
|
105
|
-
*
|
|
106
|
-
* A transcript's `user` entries cover more than typed prompts: tool results
|
|
107
|
-
* come back as synthetic user turns too. Those carry `tool_result` content
|
|
108
|
-
* blocks, so a line only counts when its content is a plain string or an array
|
|
109
|
-
* of nothing but `text` blocks. Sidechain entries (subagent conversations) are
|
|
110
|
-
* the agent talking to itself, not the person typing, so they're excluded.
|
|
111
|
-
*
|
|
112
|
-
* That still leaves the harness's own writing, which is indistinguishable by
|
|
113
|
-
* shape: subagent reports, injected skill bodies, slash-command echoes,
|
|
114
|
-
* interrupt markers. Those are dropped two ways — `isMeta`, which Claude Code
|
|
115
|
-
* sets on the entries it generates, and the text prefixes in
|
|
116
|
-
* `isHarnessNoise` for the ones it doesn't.
|
|
117
|
-
*
|
|
118
|
-
* This is the single chokepoint: both the full scan and the minutely tick go
|
|
119
|
-
* through here, so the histogram, the tail, the per-project counts, the
|
|
120
|
-
* activity aggregate and the technical-score sample all see the same prompts.
|
|
121
|
-
*/
|
|
122
|
-
export declare function promptTextFrom(entry: unknown): string | null;
|
|
123
|
-
/** Whitespace-separated word count. Zero-word prompts are dropped by callers. */
|
|
124
|
-
export declare function countWords(text: string): number;
|
|
125
|
-
/** The server's cap on a session id. Longer than this and the row is rejected. */
|
|
126
|
-
export declare const PROMPT_SESSION_ID_MAX_CHARS = 128;
|
|
127
|
-
/** One prompt, reduced to the three facts the activity aggregate needs. */
|
|
128
|
-
export type PromptLine = {
|
|
129
|
-
sessionId: string;
|
|
130
|
-
/** Canonical ISO-8601 UTC, so string order is time order. */
|
|
131
|
-
timestamp: string;
|
|
132
|
-
words: number;
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* A transcript line as prompt activity, or null when it isn't one.
|
|
136
|
-
*
|
|
137
|
-
* Stricter than `promptTextFrom` on purpose: a prompt with no session id or no
|
|
138
|
-
* usable timestamp can't be placed on a session or a day, and the server's
|
|
139
|
-
* schema would reject it, so it counts towards the histogram (which needs
|
|
140
|
-
* neither) and nothing else.
|
|
141
|
-
*/
|
|
142
|
-
export declare function parsePromptLine(line: string): PromptLine | null;
|
|
143
|
-
/** An ISO-8601 UTC string, or null when the value isn't a usable instant. */
|
|
144
|
-
export declare function normalizeTimestamp(value: unknown): string | null;
|
|
145
|
-
export declare function emptyPromptActivity(): PromptActivityAggregate;
|
|
146
|
-
/**
|
|
147
|
-
* Fold one prompt into an activity aggregate, returning the session and date it
|
|
148
|
-
* landed on so an incremental caller can mark exactly those dirty.
|
|
149
|
-
*
|
|
150
|
-
* The date is the UTC day of the timestamp — the same attribution
|
|
151
|
-
* `toDateStr` gives every token daily row, so the two halves of a sync agree
|
|
152
|
-
* about which day a piece of work belongs to.
|
|
153
|
-
*/
|
|
154
|
-
export declare function addPromptToActivity(activity: PromptActivityAggregate, line: PromptLine): {
|
|
155
|
-
sessionId: string;
|
|
156
|
-
date: string;
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* Where the histogram's axis ends for this user's own distribution: their p90
|
|
160
|
-
* prompt length rounded up to a multiple of 10, clamped to [10, 100]. Anything
|
|
161
|
-
* longer is reported by `buildTail` instead.
|
|
162
|
-
*
|
|
163
|
-
* Per-user rather than fixed because prompt length varies enormously between
|
|
164
|
-
* people — a fixed axis would either crush a terse user's histogram into the
|
|
165
|
-
* first two buckets or run a verbose one off the end.
|
|
166
|
-
*/
|
|
167
|
-
export declare function bucketMaxFor(wordCounts: number[]): number;
|
|
168
|
-
/**
|
|
169
|
-
* Bucket the word counts. Every bucket `1..bucketMax` is an exact word count —
|
|
170
|
-
* there is no overflow bar. Empty buckets are omitted; the chart fills the gaps.
|
|
171
|
-
*
|
|
172
|
-
* Prompts longer than `bucketMax` are not in here at all: they are reported by
|
|
173
|
-
* `buildTail`, and only there. So the histogram and the tail partition the
|
|
174
|
-
* scan — sum(histogram counts) + sum(tail counts) === totalPrompts, always.
|
|
175
|
-
*/
|
|
176
|
-
export declare function buildHistogram(wordCounts: number[], bucketMax: number): {
|
|
177
|
-
length: number;
|
|
178
|
-
count: number;
|
|
179
|
-
}[];
|
|
180
|
-
/**
|
|
181
|
-
* The exact distribution of everything *longer* than `bucketMax`, which the
|
|
182
|
-
* histogram does not cover at all. One entry per distinct word count,
|
|
183
|
-
* ascending; empty (never absent) when nothing exceeds `bucketMax` — the
|
|
184
|
-
* field's presence on the wire is the marker that the histogram's bars are
|
|
185
|
-
* exact.
|
|
186
|
-
*
|
|
187
|
-
* Lengths only — no prompt text is involved here, or anywhere near it.
|
|
188
|
-
*
|
|
189
|
-
* A machine with a long history can have thousands of distinct long lengths,
|
|
190
|
-
* far past what the server accepts, so an over-cap tail is coarsened: lengths
|
|
191
|
-
* are rounded to multiples of 2, then 4, 8, … until at most
|
|
192
|
-
* `PROMPT_TAIL_MAX_ENTRIES` entries remain, summing the counts that collapse
|
|
193
|
-
* together. Rounding is *up* so that a coarsened entry still sits above
|
|
194
|
-
* `bucketMax` — rounding down could claim a length inside the histogram's own
|
|
195
|
-
* exact range for a prompt the histogram never counted.
|
|
196
|
-
*
|
|
197
|
-
* Deterministic: the result depends only on the multiset of word counts.
|
|
198
|
-
*/
|
|
199
|
-
export declare function buildTail(wordCounts: number[], bucketMax: number): {
|
|
200
|
-
length: number;
|
|
201
|
-
count: number;
|
|
202
|
-
}[];
|
|
203
|
-
/**
|
|
204
|
-
* The `origin` remote of the repo at `cwd`, or null when there isn't one (not
|
|
205
|
-
* a repo, no origin, no git binary, or the directory is gone). The URL is sent
|
|
206
|
-
* as-is; the backend normalizes it before matching against the user's own
|
|
207
|
-
* projects.
|
|
208
|
-
*/
|
|
209
|
-
export declare function gitOriginUrl(cwd: string): Promise<string | null>;
|
|
210
|
-
/**
|
|
211
|
-
* Scan local Claude Code and supported IDE/agent chat transcripts.
|
|
212
|
-
*
|
|
213
|
-
* `includeSample` gates the raw prompt text: only the `full` consent tier
|
|
214
|
-
* passes true, and the sample never touches disk here — it goes straight into
|
|
215
|
-
* the upload payload the caller builds.
|
|
216
|
-
*/
|
|
217
|
-
export declare function scanPromptStats(options?: {
|
|
218
|
-
includeSample?: boolean;
|
|
219
|
-
}): Promise<PromptStats | null>;
|
|
220
|
-
/**
|
|
221
|
-
* The `promptStats` block as the server takes it. `activity` is deliberately
|
|
222
|
-
* dropped: it is local bookkeeping for the tick's incremental state, and it
|
|
223
|
-
* travels under its own top-level `promptActivity` field instead.
|
|
224
|
-
*/
|
|
225
|
-
export declare function promptStatsPayload(stats: PromptStats): Omit<PromptStats, 'activity'>;
|
|
226
|
-
//# sourceMappingURL=prompt-stats.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-stats.d.ts","sourceRoot":"","sources":["../src/prompt-stats.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,2BAA2B,CAAA;AAkClC,mFAAmF;AACnF,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAC1C,eAAO,MAAM,wBAAwB,MAAM,CAAA;AAC3C,iFAAiF;AACjF,eAAO,MAAM,6BAA6B,MAAM,CAAA;AAChD,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,MAAM,CAAA;AAC1C,8EAA8E;AAC9E,eAAO,MAAM,6BAA6B,QAAS,CAAA;AAEnD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAyCvC;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD;AAED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