@nanonets/graft 0.10.0 → 0.12.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.
- package/README.md +34 -13
- package/dist/ai/crux.d.ts.map +1 -1
- package/dist/ai/crux.js +7 -6
- package/dist/ai/crux.js.map +1 -1
- package/dist/ai/failure.d.ts +49 -0
- package/dist/ai/failure.d.ts.map +1 -0
- package/dist/ai/failure.js +74 -0
- package/dist/ai/failure.js.map +1 -0
- package/dist/ai/llm/anthropic.d.ts.map +1 -1
- package/dist/ai/llm/anthropic.js +4 -1
- package/dist/ai/llm/anthropic.js.map +1 -1
- package/dist/ai/llm/claude-cli.d.ts +60 -0
- package/dist/ai/llm/claude-cli.d.ts.map +1 -0
- package/dist/ai/llm/claude-cli.js +417 -0
- package/dist/ai/llm/claude-cli.js.map +1 -0
- package/dist/ai/llm/openai.d.ts.map +1 -1
- package/dist/ai/llm/openai.js +2 -0
- package/dist/ai/llm/openai.js.map +1 -1
- package/dist/ai/llm/types.d.ts +9 -0
- package/dist/ai/llm/types.d.ts.map +1 -1
- package/dist/ai/llm/types.js +12 -1
- package/dist/ai/llm/types.js.map +1 -1
- package/dist/ask/ask.d.ts.map +1 -1
- package/dist/ask/ask.js +39 -45
- package/dist/ask/ask.js.map +1 -1
- package/dist/ask/fuse.d.ts +83 -46
- package/dist/ask/fuse.d.ts.map +1 -1
- package/dist/ask/fuse.js +165 -67
- package/dist/ask/fuse.js.map +1 -1
- package/dist/blast/blast-cli.d.ts +30 -0
- package/dist/blast/blast-cli.d.ts.map +1 -0
- package/dist/blast/blast-cli.js +163 -0
- package/dist/blast/blast-cli.js.map +1 -0
- package/dist/blast/blast.d.ts +119 -0
- package/dist/blast/blast.d.ts.map +1 -0
- package/dist/blast/blast.js +383 -0
- package/dist/blast/blast.js.map +1 -0
- package/dist/blast/diff.d.ts +53 -0
- package/dist/blast/diff.d.ts.map +1 -0
- package/dist/blast/diff.js +193 -0
- package/dist/blast/diff.js.map +1 -0
- package/dist/blast/modules.d.ts +33 -0
- package/dist/blast/modules.d.ts.map +1 -0
- package/dist/blast/modules.js +83 -0
- package/dist/blast/modules.js.map +1 -0
- package/dist/blast/name.d.ts +61 -0
- package/dist/blast/name.d.ts.map +1 -0
- package/dist/blast/name.js +233 -0
- package/dist/blast/name.js.map +1 -0
- package/dist/blast/render.d.ts +37 -0
- package/dist/blast/render.d.ts.map +1 -0
- package/dist/blast/render.js +300 -0
- package/dist/blast/render.js.map +1 -0
- package/dist/blast/viz.d.ts +17 -0
- package/dist/blast/viz.d.ts.map +1 -0
- package/dist/blast/viz.js +324 -0
- package/dist/blast/viz.js.map +1 -0
- package/dist/claude/hooks.d.ts +13 -0
- package/dist/claude/hooks.d.ts.map +1 -1
- package/dist/claude/hooks.js +44 -4
- package/dist/claude/hooks.js.map +1 -1
- package/dist/claude/shim-template.d.ts.map +1 -1
- package/dist/claude/shim-template.js +45 -15
- package/dist/claude/shim-template.js.map +1 -1
- package/dist/claude/state.d.ts +5 -0
- package/dist/claude/state.d.ts.map +1 -1
- package/dist/claude/state.js.map +1 -1
- package/dist/cli-picker.d.ts +44 -5
- package/dist/cli-picker.d.ts.map +1 -1
- package/dist/cli-picker.js +73 -26
- package/dist/cli-picker.js.map +1 -1
- package/dist/cli.js +270 -14
- package/dist/cli.js.map +1 -1
- package/dist/context/build.d.ts +8 -0
- package/dist/context/build.d.ts.map +1 -1
- package/dist/context/build.js +57 -9
- package/dist/context/build.js.map +1 -1
- package/dist/context/check.d.ts.map +1 -1
- package/dist/context/check.js +7 -6
- package/dist/context/check.js.map +1 -1
- package/dist/context/node-file.d.ts.map +1 -1
- package/dist/context/node-file.js +9 -2
- package/dist/context/node-file.js.map +1 -1
- package/dist/graph/bindings.d.ts.map +1 -1
- package/dist/graph/bindings.js +245 -2
- package/dist/graph/bindings.js.map +1 -1
- package/dist/graph/build.d.ts.map +1 -1
- package/dist/graph/build.js +36 -16
- package/dist/graph/build.js.map +1 -1
- package/dist/graph/check.d.ts +4 -0
- package/dist/graph/check.d.ts.map +1 -1
- package/dist/graph/check.js +8 -1
- package/dist/graph/check.js.map +1 -1
- package/dist/graph/container.d.ts +63 -0
- package/dist/graph/container.d.ts.map +1 -0
- package/dist/graph/container.js +185 -0
- package/dist/graph/container.js.map +1 -0
- package/dist/graph/enrich.d.ts +18 -0
- package/dist/graph/enrich.d.ts.map +1 -1
- package/dist/graph/enrich.js +55 -2
- package/dist/graph/enrich.js.map +1 -1
- package/dist/graph/extract.d.ts +8 -1
- package/dist/graph/extract.d.ts.map +1 -1
- package/dist/graph/extract.js +401 -12
- package/dist/graph/extract.js.map +1 -1
- package/dist/graph/generic.d.ts +34 -1
- package/dist/graph/generic.d.ts.map +1 -1
- package/dist/graph/generic.js +176 -6
- package/dist/graph/generic.js.map +1 -1
- package/dist/graph/invariants.d.ts +32 -0
- package/dist/graph/invariants.d.ts.map +1 -0
- package/dist/graph/invariants.js +49 -0
- package/dist/graph/invariants.js.map +1 -0
- package/dist/graph/queries/clojure.scm +58 -0
- package/dist/graph/resolve.d.ts.map +1 -1
- package/dist/graph/resolve.js +249 -23
- package/dist/graph/resolve.js.map +1 -1
- package/dist/graph/scopes.d.ts +2 -2
- package/dist/graph/scopes.d.ts.map +1 -1
- package/dist/graph/scopes.js +8 -6
- package/dist/graph/scopes.js.map +1 -1
- package/dist/graph/source-files.d.ts +13 -4
- package/dist/graph/source-files.d.ts.map +1 -1
- package/dist/graph/source-files.js +35 -12
- package/dist/graph/source-files.js.map +1 -1
- package/dist/graph/types.d.ts +3 -1
- package/dist/graph/types.d.ts.map +1 -1
- package/dist/graph/workspace-cli.d.ts +2 -0
- package/dist/graph/workspace-cli.d.ts.map +1 -1
- package/dist/graph/workspace-cli.js +10 -4
- package/dist/graph/workspace-cli.js.map +1 -1
- package/dist/graph/workspace.d.ts +11 -6
- package/dist/graph/workspace.d.ts.map +1 -1
- package/dist/graph/workspace.js +24 -13
- package/dist/graph/workspace.js.map +1 -1
- package/dist/graph/write.d.ts.map +1 -1
- package/dist/graph/write.js +25 -2
- package/dist/graph/write.js.map +1 -1
- package/dist/hosts/antigravity.d.ts +7 -0
- package/dist/hosts/antigravity.d.ts.map +1 -0
- package/dist/hosts/antigravity.js +42 -0
- package/dist/hosts/antigravity.js.map +1 -0
- package/dist/hosts/codex-hooks.d.ts +3 -3
- package/dist/hosts/codex-hooks.d.ts.map +1 -1
- package/dist/hosts/codex-hooks.js +27 -21
- package/dist/hosts/codex-hooks.js.map +1 -1
- package/dist/hosts/init.d.ts.map +1 -1
- package/dist/hosts/init.js +6 -1
- package/dist/hosts/init.js.map +1 -1
- package/dist/hosts/mcp-config.d.ts.map +1 -1
- package/dist/hosts/mcp-config.js +7 -0
- package/dist/hosts/mcp-config.js.map +1 -1
- package/dist/hosts/plan.d.ts +1 -1
- package/dist/hosts/plan.d.ts.map +1 -1
- package/dist/hosts/plan.js +2 -0
- package/dist/hosts/plan.js.map +1 -1
- package/dist/hosts/registry.d.ts.map +1 -1
- package/dist/hosts/registry.js +13 -0
- package/dist/hosts/registry.js.map +1 -1
- package/dist/ingest/fs.d.ts +9 -2
- package/dist/ingest/fs.d.ts.map +1 -1
- package/dist/ingest/fs.js +100 -16
- package/dist/ingest/fs.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +45 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/telemetry/contract.d.ts +90 -0
- package/dist/telemetry/contract.d.ts.map +1 -0
- package/dist/telemetry/contract.js +203 -0
- package/dist/telemetry/contract.js.map +1 -0
- package/dist/telemetry/flush.d.ts +21 -0
- package/dist/telemetry/flush.d.ts.map +1 -0
- package/dist/telemetry/flush.js +84 -0
- package/dist/telemetry/flush.js.map +1 -0
- package/dist/telemetry/gate.d.ts +16 -0
- package/dist/telemetry/gate.d.ts.map +1 -0
- package/dist/telemetry/gate.js +64 -0
- package/dist/telemetry/gate.js.map +1 -0
- package/dist/telemetry/identity.d.ts +33 -0
- package/dist/telemetry/identity.d.ts.map +1 -0
- package/dist/telemetry/identity.js +80 -0
- package/dist/telemetry/identity.js.map +1 -0
- package/dist/telemetry/index.d.ts +18 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +16 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/key.d.ts +21 -0
- package/dist/telemetry/key.d.ts.map +1 -0
- package/dist/telemetry/key.js +49 -0
- package/dist/telemetry/key.js.map +1 -0
- package/dist/telemetry/notice.d.ts +19 -0
- package/dist/telemetry/notice.d.ts.map +1 -0
- package/dist/telemetry/notice.js +90 -0
- package/dist/telemetry/notice.js.map +1 -0
- package/dist/telemetry/queue.d.ts +35 -0
- package/dist/telemetry/queue.d.ts.map +1 -0
- package/dist/telemetry/queue.js +162 -0
- package/dist/telemetry/queue.js.map +1 -0
- package/dist/telemetry/send.d.ts +19 -0
- package/dist/telemetry/send.d.ts.map +1 -0
- package/dist/telemetry/send.js +84 -0
- package/dist/telemetry/send.js.map +1 -0
- package/dist/telemetry/sessions.d.ts +8 -0
- package/dist/telemetry/sessions.d.ts.map +1 -0
- package/dist/telemetry/sessions.js +81 -0
- package/dist/telemetry/sessions.js.map +1 -0
- package/dist/telemetry/track.d.ts +43 -0
- package/dist/telemetry/track.d.ts.map +1 -0
- package/dist/telemetry/track.js +108 -0
- package/dist/telemetry/track.js.map +1 -0
- package/dist/upkeep-run.d.ts +15 -0
- package/dist/upkeep-run.d.ts.map +1 -0
- package/dist/upkeep-run.js +60 -0
- package/dist/upkeep-run.js.map +1 -0
- package/dist/upkeep.d.ts +114 -0
- package/dist/upkeep.d.ts.map +1 -0
- package/dist/upkeep.js +232 -0
- package/dist/upkeep.js.map +1 -0
- package/dist/util/num.d.ts +3 -0
- package/dist/util/num.d.ts.map +1 -0
- package/dist/util/num.js +20 -0
- package/dist/util/num.js.map +1 -0
- package/dist/util/state.d.ts +11 -4
- package/dist/util/state.d.ts.map +1 -1
- package/dist/util/state.js +9 -0
- package/dist/util/state.js.map +1 -1
- package/dist/viewer/app.js +1 -1
- package/dist/viewer/index.html +1 -0
- package/dist/viewer/style.css +23 -2
- package/dist/viz/assemble.d.ts +33 -0
- package/dist/viz/assemble.d.ts.map +1 -1
- package/dist/viz/assemble.js.map +1 -1
- package/dist/viz/export.d.ts +39 -0
- package/dist/viz/export.d.ts.map +1 -0
- package/dist/viz/export.js +98 -0
- package/dist/viz/export.js.map +1 -0
- package/package.json +15 -5
- package/scripts/stamp-telemetry-key.mjs +53 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The telemetry contract: the complete, machine-enforced list of what graft may
|
|
3
|
+
* send. `TELEMETRY.md` is the same list in prose, and the two are kept in
|
|
4
|
+
* lockstep — an event or property that is not in this file cannot be sent, and
|
|
5
|
+
* one that is not in `TELEMETRY.md` must not be added here.
|
|
6
|
+
*
|
|
7
|
+
* Why an allowlist rather than a review rule: every telemetry incident in the
|
|
8
|
+
* tools we studied came from a call site quietly adding a property nobody
|
|
9
|
+
* audited. `track()` (track.ts) drops unknown events and unknown keys instead of
|
|
10
|
+
* trusting its callers, so a future `track('query', { path })` sends `query`
|
|
11
|
+
* with no `path` rather than leaking one. The blast radius of a careless call
|
|
12
|
+
* site is "we lose a metric", never "we received someone's source tree".
|
|
13
|
+
*
|
|
14
|
+
* The other half of that guarantee is the value side: every number crosses as a
|
|
15
|
+
* BUCKET and every string as a member of a fixed union. A raw file count plus a
|
|
16
|
+
* language set starts to fingerprint a specific repo; `"100-500"` does not. A
|
|
17
|
+
* raw error message is a path, a symbol, and sometimes a snippet of code; an
|
|
18
|
+
* enum member is not.
|
|
19
|
+
*
|
|
20
|
+
* This module is pure — no I/O, no config, no clock. It is the file a reviewer
|
|
21
|
+
* (or a suspicious user, since the repo is public) reads to verify the claim.
|
|
22
|
+
*/
|
|
23
|
+
/* -------------------------------------------------------------------------- */
|
|
24
|
+
/* the event → allowed-property-keys map */
|
|
25
|
+
/* -------------------------------------------------------------------------- */
|
|
26
|
+
/**
|
|
27
|
+
* The contract itself. Common properties (see {@link COMMON_KEYS}) are stamped
|
|
28
|
+
* centrally by `track()` and are deliberately not repeated per event.
|
|
29
|
+
*/
|
|
30
|
+
export const EVENTS = {
|
|
31
|
+
/** Once per machine, when the install id is first minted. The denominator. */
|
|
32
|
+
first_run: new Set(),
|
|
33
|
+
/** `graft init` completed. Tells us which agents people actually wire, and
|
|
34
|
+
* how many decline telemetry at the picker. */
|
|
35
|
+
init_completed: new Set(['agents', 'consent']),
|
|
36
|
+
/** A build finished. The activation event — an install that never reaches one
|
|
37
|
+
* of these is the funnel leak we most want to see. */
|
|
38
|
+
build_completed: new Set(['files_bucket', 'langs', 'mode', 'duration_bucket', 'incremental']),
|
|
39
|
+
/** A build threw. `stage`/`code` are enums; the message never travels. */
|
|
40
|
+
build_failed: new Set(['stage', 'code']),
|
|
41
|
+
/** One query, from any surface. The DAU backbone and the dead-command detector. */
|
|
42
|
+
query: new Set(['command', 'surface', 'hit']),
|
|
43
|
+
/** One closed agent session, summarised. `graft_reads` vs `source_reads` is
|
|
44
|
+
* the single number that says whether an agent prefers graft to grep. */
|
|
45
|
+
session_summary: new Set(['graft_reads_bucket', 'source_reads_bucket', 'saved_tokens_bucket']),
|
|
46
|
+
};
|
|
47
|
+
/** Stamped on every event by `track()`; not listed per event above. */
|
|
48
|
+
export const COMMON_KEYS = [
|
|
49
|
+
'app_version',
|
|
50
|
+
'os',
|
|
51
|
+
'arch',
|
|
52
|
+
'node_major',
|
|
53
|
+
'ci',
|
|
54
|
+
'agent_host',
|
|
55
|
+
'repo_id',
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* The commands worth counting. A command absent here is simply not reported —
|
|
59
|
+
* `track()` drops the event rather than sending a free-form string, which is
|
|
60
|
+
* what keeps a future `graft <something-user-named>` from becoming a data leak.
|
|
61
|
+
*/
|
|
62
|
+
export const TRACKED_COMMANDS = [
|
|
63
|
+
'ask', 'grep', 'callers', 'skeleton', 'map', 'check', 'blast', 'viz',
|
|
64
|
+
];
|
|
65
|
+
export function isTrackedCommand(name) {
|
|
66
|
+
return TRACKED_COMMANDS.includes(name);
|
|
67
|
+
}
|
|
68
|
+
/** Where a failing build died. Coarse on purpose: enough to route a bug, not
|
|
69
|
+
* enough to describe anyone's repo. */
|
|
70
|
+
export const BUILD_STAGES = ['walk', 'extract', 'graph', 'summarize', 'synthesize', 'write'];
|
|
71
|
+
/**
|
|
72
|
+
* The failure taxonomy. Anything unrecognised becomes `E_UNKNOWN` — the point of
|
|
73
|
+
* a closed set is that an unclassified error contributes a count and nothing
|
|
74
|
+
* else, so no message text can ride along inside a "code".
|
|
75
|
+
*/
|
|
76
|
+
export const ERROR_CODES = [
|
|
77
|
+
'E_UNKNOWN', 'E_PARSE', 'E_TIMEOUT', 'E_LLM', 'E_AUTH', 'E_RATE_LIMIT',
|
|
78
|
+
'E_NETWORK', 'E_DISK', 'E_PERMISSION', 'E_OOM', 'E_LOCK',
|
|
79
|
+
];
|
|
80
|
+
/**
|
|
81
|
+
* Map a thrown value to a code without letting its text through. Only fixed
|
|
82
|
+
* substrings are matched, and only a member of {@link ERROR_CODES} is returned —
|
|
83
|
+
* the error's own message is never the return value, not even in part.
|
|
84
|
+
*/
|
|
85
|
+
export function errorCode(err) {
|
|
86
|
+
const code = err?.code;
|
|
87
|
+
if (typeof code === 'string') {
|
|
88
|
+
if (code === 'ENOSPC' || code === 'EDQUOT')
|
|
89
|
+
return 'E_DISK';
|
|
90
|
+
if (code === 'EACCES' || code === 'EPERM')
|
|
91
|
+
return 'E_PERMISSION';
|
|
92
|
+
if (code === 'ENOMEM')
|
|
93
|
+
return 'E_OOM';
|
|
94
|
+
if (code === 'ETIMEDOUT' || code === 'ESOCKETTIMEDOUT')
|
|
95
|
+
return 'E_TIMEOUT';
|
|
96
|
+
if (code === 'ENOTFOUND' || code === 'ECONNREFUSED' || code === 'ECONNRESET')
|
|
97
|
+
return 'E_NETWORK';
|
|
98
|
+
}
|
|
99
|
+
const status = err?.status;
|
|
100
|
+
if (typeof status === 'number') {
|
|
101
|
+
if (status === 401 || status === 403)
|
|
102
|
+
return 'E_AUTH';
|
|
103
|
+
if (status === 429)
|
|
104
|
+
return 'E_RATE_LIMIT';
|
|
105
|
+
if (status >= 500)
|
|
106
|
+
return 'E_LLM';
|
|
107
|
+
}
|
|
108
|
+
const msg = err instanceof Error ? err.message.toLowerCase() : '';
|
|
109
|
+
if (msg.includes('timeout') || msg.includes('timed out'))
|
|
110
|
+
return 'E_TIMEOUT';
|
|
111
|
+
if (msg.includes('parse') || msg.includes('syntax'))
|
|
112
|
+
return 'E_PARSE';
|
|
113
|
+
if (msg.includes('lock'))
|
|
114
|
+
return 'E_LOCK';
|
|
115
|
+
return 'E_UNKNOWN';
|
|
116
|
+
}
|
|
117
|
+
/* -------------------------------------------------------------------------- */
|
|
118
|
+
/* buckets — every number crosses the wire as a label */
|
|
119
|
+
/* -------------------------------------------------------------------------- */
|
|
120
|
+
/** Repo scale. Exact counts fingerprint a repo; these five labels answer the
|
|
121
|
+
* only question we have ("toy, service, or monorepo?"). */
|
|
122
|
+
export function filesBucket(n) {
|
|
123
|
+
if (n <= 0)
|
|
124
|
+
return '0';
|
|
125
|
+
if (n < 50)
|
|
126
|
+
return '1-49';
|
|
127
|
+
if (n < 200)
|
|
128
|
+
return '50-199';
|
|
129
|
+
if (n < 1000)
|
|
130
|
+
return '200-999';
|
|
131
|
+
if (n < 5000)
|
|
132
|
+
return '1000-4999';
|
|
133
|
+
return '5000+';
|
|
134
|
+
}
|
|
135
|
+
/** Wall-clock for a build. Coarse enough that it says "fast/slow", not "this
|
|
136
|
+
* exact machine on this exact tree". */
|
|
137
|
+
export function durationBucket(ms) {
|
|
138
|
+
const s = ms / 1000;
|
|
139
|
+
if (s < 1)
|
|
140
|
+
return '<1s';
|
|
141
|
+
if (s < 5)
|
|
142
|
+
return '1-5s';
|
|
143
|
+
if (s < 30)
|
|
144
|
+
return '5-30s';
|
|
145
|
+
if (s < 120)
|
|
146
|
+
return '30s-2m';
|
|
147
|
+
if (s < 600)
|
|
148
|
+
return '2-10m';
|
|
149
|
+
return '10m+';
|
|
150
|
+
}
|
|
151
|
+
/** Generic small-count bucket, for the per-session read counters. */
|
|
152
|
+
export function countBucket(n) {
|
|
153
|
+
if (n <= 0)
|
|
154
|
+
return '0';
|
|
155
|
+
if (n < 5)
|
|
156
|
+
return '1-4';
|
|
157
|
+
if (n < 20)
|
|
158
|
+
return '5-19';
|
|
159
|
+
if (n < 50)
|
|
160
|
+
return '20-49';
|
|
161
|
+
if (n < 200)
|
|
162
|
+
return '50-199';
|
|
163
|
+
return '200+';
|
|
164
|
+
}
|
|
165
|
+
/** Estimated tokens saved in one session — the README's central claim, in the
|
|
166
|
+
* only resolution we need to defend it. */
|
|
167
|
+
export function savedTokensBucket(n) {
|
|
168
|
+
if (n <= 0)
|
|
169
|
+
return '0';
|
|
170
|
+
if (n < 1000)
|
|
171
|
+
return '<1k';
|
|
172
|
+
if (n < 5000)
|
|
173
|
+
return '1-5k';
|
|
174
|
+
if (n < 20000)
|
|
175
|
+
return '5-20k';
|
|
176
|
+
if (n < 100000)
|
|
177
|
+
return '20-100k';
|
|
178
|
+
return '100k+';
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Languages, normalised, filtered to a safe shape, and capped.
|
|
182
|
+
*
|
|
183
|
+
* Sorted so `["go","ts"]` and `["ts","go"]` aggregate as one value, deduped, and
|
|
184
|
+
* cut to eight — a repo with a very long tail of languages is itself a
|
|
185
|
+
* distinguishing fact, and the tail answers no question we have.
|
|
186
|
+
*
|
|
187
|
+
* The character filter is the part that matters. This is the only property in
|
|
188
|
+
* the contract that is not drawn from a closed set defined in this file: the
|
|
189
|
+
* values come from the parser registry, several modules away, via
|
|
190
|
+
* `languageLabelOf() ?? container.name ?? generic.name ?? "unknown"`. That is
|
|
191
|
+
* safe today, but it means the no-free-text guarantee would rest on a promise
|
|
192
|
+
* made elsewhere — and a future generic extractor naming itself after the
|
|
193
|
+
* extension it matched would quietly turn this into a channel for file
|
|
194
|
+
* metadata. Anything outside `[a-z0-9+#._-]`, or longer than 24 characters, is
|
|
195
|
+
* therefore dropped here rather than trusted.
|
|
196
|
+
*/
|
|
197
|
+
export function langsValue(langs) {
|
|
198
|
+
const clean = langs
|
|
199
|
+
.map((l) => l.toLowerCase().trim())
|
|
200
|
+
.filter((l) => l.length > 0 && l.length <= 24 && /^[a-z0-9+#._-]+$/.test(l));
|
|
201
|
+
return [...new Set(clean)].sort().slice(0, 8).join(',');
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/telemetry/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAwC;IACzD,8EAA8E;IAC9E,SAAS,EAAE,IAAI,GAAG,EAAU;IAC5B;oDACgD;IAChD,cAAc,EAAE,IAAI,GAAG,CAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACtD;2DACuD;IACvD,eAAe,EAAE,IAAI,GAAG,CAAS,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;IACrG,0EAA0E;IAC1E,YAAY,EAAE,IAAI,GAAG,CAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAChD,mFAAmF;IACnF,KAAK,EAAE,IAAI,GAAG,CAAS,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACrD;8EAC0E;IAC1E,eAAe,EAAE,IAAI,GAAG,CAAS,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;CACvG,CAAC;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,WAAW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,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;SAClC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,EAAE,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/E,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type SendResult } from './send.js';
|
|
2
|
+
/** Matches `UPDATE_TTL_MS`: a day is the natural period for both. */
|
|
3
|
+
export declare const FLUSH_TTL_MS: number;
|
|
4
|
+
export declare function needsFlush(flushedAt: number | undefined, now?: number): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Spawn the flush if the queue has something in it and a day has passed. Returns
|
|
7
|
+
* whether a child was started, for tests. Never waits, never throws.
|
|
8
|
+
*/
|
|
9
|
+
export declare function maybeFlushInBackground(home?: string, now?: number): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether a failed send is worth keeping the batch for.
|
|
12
|
+
*
|
|
13
|
+
* A 5xx or a transport failure is ours to retry — a week offline should not be
|
|
14
|
+
* a week of lost events. A 4xx is not: a bad key or a malformed batch will fail
|
|
15
|
+
* identically forever, and retrying it would pin the queue at its cap until it
|
|
16
|
+
* starts dropping the events that WOULD have sent.
|
|
17
|
+
*/
|
|
18
|
+
export declare function shouldRequeue(res: SendResult): boolean;
|
|
19
|
+
/** The `graft _telemetry-flush` body, running in the detached child. */
|
|
20
|
+
export declare function runFlush(home?: string): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=flush.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flush.d.ts","sourceRoot":"","sources":["../../src/telemetry/flush.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvD,qEAAqE;AACrE,eAAO,MAAM,YAAY,QAAsB,CAAC;AAMhD,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,SAAa,GAAG,OAAO,CAEnF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,OAAO,CAe/E;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAGtD;AAED,wEAAwE;AACxE,wBAAsB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3D"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Getting the queue off the machine without any command ever waiting for it.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately the same shape as `maybeRefreshInBackground` in `upkeep.ts`,
|
|
5
|
+
* which has been doing this for the npm registry check since 0.7: check a
|
|
6
|
+
* timestamp, write the timestamp BEFORE spawning so a child that dies cannot
|
|
7
|
+
* make every subsequent command spawn another one, then `spawn` detached and
|
|
8
|
+
* `unref`. The parent returns immediately and never learns the outcome.
|
|
9
|
+
*
|
|
10
|
+
* Once a day, not once a command. Events are cheap to hold and the questions we
|
|
11
|
+
* are asking ("how many repos activated this week") do not get better answers
|
|
12
|
+
* from lower latency.
|
|
13
|
+
*/
|
|
14
|
+
import { spawn } from 'node:child_process';
|
|
15
|
+
import { statSync } from 'node:fs';
|
|
16
|
+
import { graftCliPath } from '../claude/paths.js';
|
|
17
|
+
import { drain, queuePath, requeue } from './queue.js';
|
|
18
|
+
import { patchState, readState } from './identity.js';
|
|
19
|
+
import { sendBatch } from './send.js';
|
|
20
|
+
import { telemetryOn } from './gate.js';
|
|
21
|
+
/** Matches `UPDATE_TTL_MS`: a day is the natural period for both. */
|
|
22
|
+
export const FLUSH_TTL_MS = 24 * 60 * 60 * 1000;
|
|
23
|
+
function queueHasEvents(home) {
|
|
24
|
+
try {
|
|
25
|
+
return statSync(queuePath(home)).size > 0;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function needsFlush(flushedAt, now = Date.now()) {
|
|
32
|
+
return typeof flushedAt !== 'number' || now - flushedAt >= FLUSH_TTL_MS;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Spawn the flush if the queue has something in it and a day has passed. Returns
|
|
36
|
+
* whether a child was started, for tests. Never waits, never throws.
|
|
37
|
+
*/
|
|
38
|
+
export function maybeFlushInBackground(home, now = Date.now()) {
|
|
39
|
+
try {
|
|
40
|
+
if (!telemetryOn(home))
|
|
41
|
+
return false;
|
|
42
|
+
if (!queueHasEvents(home))
|
|
43
|
+
return false;
|
|
44
|
+
if (!needsFlush(readState(home)?.flushedAt, now))
|
|
45
|
+
return false;
|
|
46
|
+
patchState({ flushedAt: now }, home); // before the spawn, so a dying child costs one attempt
|
|
47
|
+
const child = spawn(process.execPath, [graftCliPath(), '_telemetry-flush'], {
|
|
48
|
+
detached: true,
|
|
49
|
+
stdio: 'ignore',
|
|
50
|
+
});
|
|
51
|
+
child.unref();
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return false; // no spawn available (sandbox, ENOMEM) — try again tomorrow
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Whether a failed send is worth keeping the batch for.
|
|
60
|
+
*
|
|
61
|
+
* A 5xx or a transport failure is ours to retry — a week offline should not be
|
|
62
|
+
* a week of lost events. A 4xx is not: a bad key or a malformed batch will fail
|
|
63
|
+
* identically forever, and retrying it would pin the queue at its cap until it
|
|
64
|
+
* starts dropping the events that WOULD have sent.
|
|
65
|
+
*/
|
|
66
|
+
export function shouldRequeue(res) {
|
|
67
|
+
if (res.ok)
|
|
68
|
+
return false;
|
|
69
|
+
return res.status === undefined || res.status >= 500;
|
|
70
|
+
}
|
|
71
|
+
/** The `graft _telemetry-flush` body, running in the detached child. */
|
|
72
|
+
export async function runFlush(home) {
|
|
73
|
+
try {
|
|
74
|
+
if (!telemetryOn(home))
|
|
75
|
+
return;
|
|
76
|
+
const events = drain(home);
|
|
77
|
+
if (events.length === 0)
|
|
78
|
+
return;
|
|
79
|
+
if (shouldRequeue(await sendBatch(events)))
|
|
80
|
+
requeue(events, home);
|
|
81
|
+
}
|
|
82
|
+
catch { /* a failed flush is a non-event by design */ }
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=flush.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flush.js","sourceRoot":"","sources":["../../src/telemetry/flush.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,SAAS,EAAmB,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qEAAqE;AACrE,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,SAAS,cAAc,CAAC,IAAa;IACnC,IAAI,CAAC;QAAC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAA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AAwE;AACxE,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAa;IAC1C,IAAI,CAAC;QACH,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YAAE,OAAO;QAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAChC,IAAI,aAAa,CAAC,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;YAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC,CAAC,6CAA6C,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type OffReason = 'no-key' | 'do-not-track' | 'ci' | 'disabled';
|
|
2
|
+
/** The `DO_NOT_TRACK` convention: set and not `0`/empty means "off". */
|
|
3
|
+
export declare function doNotTrack(env?: NodeJS.ProcessEnv): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* CI detection. `CI` covers essentially every provider; the rest are the ones
|
|
6
|
+
* that historically did not set it. Deliberately generous — a false positive
|
|
7
|
+
* costs one uncounted user, a false negative pollutes the dataset.
|
|
8
|
+
*/
|
|
9
|
+
export declare function inCi(env?: NodeJS.ProcessEnv): boolean;
|
|
10
|
+
/** Null when telemetry may run, otherwise the first gate that closed. */
|
|
11
|
+
export declare function offReason(home?: string, env?: NodeJS.ProcessEnv): OffReason | null;
|
|
12
|
+
export declare function telemetryOn(home?: string, env?: NodeJS.ProcessEnv): boolean;
|
|
13
|
+
/** One line for `graft telemetry status`, naming the gate that is closed so a
|
|
14
|
+
* user who thinks they disabled it can see which switch actually took. */
|
|
15
|
+
export declare function explainOff(reason: OffReason): string;
|
|
16
|
+
//# sourceMappingURL=gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../../src/telemetry/gate.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,cAAc,GAAG,IAAI,GAAG,UAAU,CAAC;AAEtE,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAGxE;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAMlE;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,SAAS,GAAG,IAAI,CAM/F;AAED,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAExF;AAED;2EAC2E;AAC3E,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAOpD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single "may we send?" predicate, checked before every append and again
|
|
3
|
+
* before every send.
|
|
4
|
+
*
|
|
5
|
+
* Four independent gates, in the order a user would expect them to win:
|
|
6
|
+
*
|
|
7
|
+
* 1. A key at all — dev builds and forks have none (see key.ts), so the whole
|
|
8
|
+
* subsystem is inert for anyone who did not install a published graft.
|
|
9
|
+
* 2. `DO_NOT_TRACK` — the cross-tool convention (consoledonottrack.com).
|
|
10
|
+
* Honoured unconditionally: it outranks our own setting, because a user who
|
|
11
|
+
* set it machine-wide has already answered the question for every tool.
|
|
12
|
+
* 3. CI — a build server is not a user. Counting it would inflate every number
|
|
13
|
+
* we care about and tell us nothing about a person.
|
|
14
|
+
* 4. The user's own choice, from the `graft init` picker or
|
|
15
|
+
* `graft telemetry disable`. Default on when never set.
|
|
16
|
+
*
|
|
17
|
+
* Re-checked at every append rather than cached at boot, so `graft telemetry
|
|
18
|
+
* disable` in one terminal takes effect in a long-lived MCP server in another
|
|
19
|
+
* without a restart.
|
|
20
|
+
*/
|
|
21
|
+
import { posthogKey } from './key.js';
|
|
22
|
+
import { readState } from './identity.js';
|
|
23
|
+
/** The `DO_NOT_TRACK` convention: set and not `0`/empty means "off". */
|
|
24
|
+
export function doNotTrack(env = process.env) {
|
|
25
|
+
const v = env.DO_NOT_TRACK;
|
|
26
|
+
return v !== undefined && v !== '' && v !== '0';
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* CI detection. `CI` covers essentially every provider; the rest are the ones
|
|
30
|
+
* that historically did not set it. Deliberately generous — a false positive
|
|
31
|
+
* costs one uncounted user, a false negative pollutes the dataset.
|
|
32
|
+
*/
|
|
33
|
+
export function inCi(env = process.env) {
|
|
34
|
+
if (env.CI !== undefined && env.CI !== '' && env.CI !== '0' && env.CI !== 'false')
|
|
35
|
+
return true;
|
|
36
|
+
return Boolean(env.GITHUB_ACTIONS || env.GITLAB_CI || env.BUILDKITE || env.CIRCLECI ||
|
|
37
|
+
env.TEAMCITY_VERSION || env.JENKINS_URL || env.TF_BUILD || env.BUILD_NUMBER);
|
|
38
|
+
}
|
|
39
|
+
/** Null when telemetry may run, otherwise the first gate that closed. */
|
|
40
|
+
export function offReason(home, env = process.env) {
|
|
41
|
+
if (!posthogKey())
|
|
42
|
+
return 'no-key';
|
|
43
|
+
if (doNotTrack(env))
|
|
44
|
+
return 'do-not-track';
|
|
45
|
+
if (inCi(env))
|
|
46
|
+
return 'ci';
|
|
47
|
+
if (readState(home)?.enabled === false)
|
|
48
|
+
return 'disabled';
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
export function telemetryOn(home, env = process.env) {
|
|
52
|
+
return offReason(home, env) === null;
|
|
53
|
+
}
|
|
54
|
+
/** One line for `graft telemetry status`, naming the gate that is closed so a
|
|
55
|
+
* user who thinks they disabled it can see which switch actually took. */
|
|
56
|
+
export function explainOff(reason) {
|
|
57
|
+
switch (reason) {
|
|
58
|
+
case 'no-key': return 'off — this build has no telemetry key (a fork, or a local `npm run build`); nothing can be sent';
|
|
59
|
+
case 'do-not-track': return 'off — DO_NOT_TRACK is set in this environment';
|
|
60
|
+
case 'ci': return 'off — this looks like CI';
|
|
61
|
+
case 'disabled': return 'off — you disabled it (`graft telemetry enable` to turn it back on)';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.js","sourceRoot":"","sources":["../../src/telemetry/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAI1C,wEAAwE;AACxE,MAAM,UAAU,UAAU,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC7D,MAAM,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC;IAC3B,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,MAAyB,OAAO,CAAC,GAAG;IACvD,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,CAAC,EAAE,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IAC/F,OAAO,OAAO,CACZ,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,QAAQ;QACpE,GAAG,CAAC,gBAAgB,IAAI,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,YAAY,CAC5E,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,SAAS,CAAC,IAAa,EAAE,MAAyB,OAAO,CAAC,GAAG;IAC3E,IAAI,CAAC,UAAU,EAAE;QAAE,OAAO,QAAQ,CAAC;IACnC,IAAI,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,cAAc,CAAC;IAC3C,IAAI,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,KAAK;QAAE,OAAO,UAAU,CAAC;IAC1D,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAa,EAAE,MAAyB,OAAO,CAAC,GAAG;IAC7E,OAAO,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;AACvC,CAAC;AAED;2EAC2E;AAC3E,MAAM,UAAU,UAAU,CAAC,MAAiB;IAC1C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,QAAQ,CAAC,CAAQ,OAAO,iGAAiG,CAAC;QAC/H,KAAK,cAAc,CAAC,CAAE,OAAO,+CAA+C,CAAC;QAC7E,KAAK,IAAI,CAAC,CAAY,OAAO,0BAA0B,CAAC;QACxD,KAAK,UAAU,CAAC,CAAM,OAAO,qEAAqE,CAAC;IACrG,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Machine-global telemetry state. Shares `~/.graft/` with `update-check.json`. */
|
|
2
|
+
export interface TelemetryState {
|
|
3
|
+
installId: string;
|
|
4
|
+
/** The user's choice. Absent means "never chosen" → the default (on) applies. */
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
/** ISO stamp of the one-time first-run notice, so it prints exactly once. */
|
|
7
|
+
noticeShownAt?: string;
|
|
8
|
+
/** Epoch ms of the last flush ATTEMPT, mirroring `UpdateCache.checkedAt`. */
|
|
9
|
+
flushedAt?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function statePath(home?: string): string;
|
|
12
|
+
export declare function readState(home?: string): TelemetryState | null;
|
|
13
|
+
/** Read-modify-write. Not atomic across processes; a lost update costs at most a
|
|
14
|
+
* duplicated notice or an extra flush attempt, never corruption. */
|
|
15
|
+
export declare function patchState(patch: Partial<TelemetryState>, home?: string): TelemetryState;
|
|
16
|
+
export interface Install {
|
|
17
|
+
id: string;
|
|
18
|
+
/** True when this call minted the id, i.e. this is the machine's first run. */
|
|
19
|
+
firstRun: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** The install id, minted on first call. */
|
|
22
|
+
export declare function installId(home?: string): Install;
|
|
23
|
+
/**
|
|
24
|
+
* The repo id, in `graft/.cache/` rather than `.graft/config.json`.
|
|
25
|
+
*
|
|
26
|
+
* `.graft/config.json` would have been the tidier home, but writing it runs
|
|
27
|
+
* `ensureBuildConfigIgnored`, which appends to the repo's `.gitignore`. Minting
|
|
28
|
+
* an id during a read-only `graft ask` must not modify a file the user has
|
|
29
|
+
* committed. `graft/.cache/` is already derived, already git-ignored, and
|
|
30
|
+
* already where every other per-repo sidecar lives.
|
|
31
|
+
*/
|
|
32
|
+
export declare function repoId(repo: string): string;
|
|
33
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/telemetry/identity.ts"],"names":[],"mappings":"AA0BA,mFAAmF;AACnF,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,SAAS,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,CAE1D;AAED,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAE9D;AAED;qEACqE;AACrE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,CAIxF;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,+EAA+E;IAC/E,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,4CAA4C;AAC5C,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAahD;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO3C"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two identifiers, and why neither of them identifies anyone.
|
|
3
|
+
*
|
|
4
|
+
* • install id — one per machine, in `~/.graft/telemetry.json`, beside the
|
|
5
|
+
* update-check cache that already lives there. Lets us count people rather
|
|
6
|
+
* than events, so a dev running forty queries is one user and not forty.
|
|
7
|
+
* • repo id — one per checkout, in `graft/.cache/`. Activation and retention
|
|
8
|
+
* for graft are per-repo facts ("did this repo ever get past build?"), and
|
|
9
|
+
* the install id alone cannot express them.
|
|
10
|
+
*
|
|
11
|
+
* Both are `randomUUID()`. Not a machine id, not a hash of the git remote, not
|
|
12
|
+
* derived from anything real — a coin flip, written down. A hash would at least
|
|
13
|
+
* be guessable by us (we could hash a public repo URL and look for it); a random
|
|
14
|
+
* UUID cannot be reversed or confirmed even in principle. Deleting `~/.graft/`
|
|
15
|
+
* or `graft/` deletes them, and the user simply looks like someone new.
|
|
16
|
+
*
|
|
17
|
+
* Every function here is fail-soft: an unwritable home is a very common state
|
|
18
|
+
* (a locked-down CI image, a read-only container) and it must cost the caller
|
|
19
|
+
* nothing. A failed persist yields an ephemeral id for this process — still
|
|
20
|
+
* anonymous, just not stable — and never a throw.
|
|
21
|
+
*/
|
|
22
|
+
import { homedir } from 'node:os';
|
|
23
|
+
import { join } from 'node:path';
|
|
24
|
+
import { randomUUID } from 'node:crypto';
|
|
25
|
+
import { cacheDir, readJson, writeJsonAtomic } from '../util/state.js';
|
|
26
|
+
export function statePath(home = homedir()) {
|
|
27
|
+
return join(home, '.graft', 'telemetry.json');
|
|
28
|
+
}
|
|
29
|
+
export function readState(home) {
|
|
30
|
+
return readJson(statePath(home));
|
|
31
|
+
}
|
|
32
|
+
/** Read-modify-write. Not atomic across processes; a lost update costs at most a
|
|
33
|
+
* duplicated notice or an extra flush attempt, never corruption. */
|
|
34
|
+
export function patchState(patch, home) {
|
|
35
|
+
const next = { ...(readState(home) ?? { installId: randomUUID() }), ...patch };
|
|
36
|
+
try {
|
|
37
|
+
writeJsonAtomic(statePath(home), next);
|
|
38
|
+
}
|
|
39
|
+
catch { /* unwritable home — in-memory only */ }
|
|
40
|
+
return next;
|
|
41
|
+
}
|
|
42
|
+
/** The install id, minted on first call. */
|
|
43
|
+
export function installId(home) {
|
|
44
|
+
const existing = readState(home);
|
|
45
|
+
if (existing?.installId)
|
|
46
|
+
return { id: existing.installId, firstRun: false };
|
|
47
|
+
const id = randomUUID();
|
|
48
|
+
try {
|
|
49
|
+
writeJsonAtomic(statePath(home), { ...(existing ?? {}), installId: id });
|
|
50
|
+
return { id, firstRun: true };
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Unwritable home: use the id for this process rather than failing closed.
|
|
54
|
+
// Reported as firstRun:false so a machine that can never persist doesn't
|
|
55
|
+
// send a first_run event on every single command.
|
|
56
|
+
return { id, firstRun: false };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The repo id, in `graft/.cache/` rather than `.graft/config.json`.
|
|
61
|
+
*
|
|
62
|
+
* `.graft/config.json` would have been the tidier home, but writing it runs
|
|
63
|
+
* `ensureBuildConfigIgnored`, which appends to the repo's `.gitignore`. Minting
|
|
64
|
+
* an id during a read-only `graft ask` must not modify a file the user has
|
|
65
|
+
* committed. `graft/.cache/` is already derived, already git-ignored, and
|
|
66
|
+
* already where every other per-repo sidecar lives.
|
|
67
|
+
*/
|
|
68
|
+
export function repoId(repo) {
|
|
69
|
+
const path = join(cacheDir(repo), 'telemetry-repo-id.json');
|
|
70
|
+
const existing = readJson(path);
|
|
71
|
+
if (existing?.repoId)
|
|
72
|
+
return existing.repoId;
|
|
73
|
+
const id = randomUUID();
|
|
74
|
+
try {
|
|
75
|
+
writeJsonAtomic(path, { repoId: id });
|
|
76
|
+
}
|
|
77
|
+
catch { /* unwritable — ephemeral */ }
|
|
78
|
+
return id;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/telemetry/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAavE,MAAM,UAAU,SAAS,CAAC,OAAe,OAAO,EAAE;IAChD,OAAO,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,OAAO,QAAQ,CAAiB,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AACnD,CAAC;AAED;qEACqE;AACrE,MAAM,UAAU,UAAU,CAAC,KAA8B,EAAE,IAAa;IACtE,MAAM,IAAI,GAAmB,EAAE,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAC/F,IAAI,CAAC;QAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CA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
1
|
+
/**
|
|
2
|
+
* Anonymous adoption telemetry. `TELEMETRY.md` is the public contract;
|
|
3
|
+
* `contract.ts` is the same list enforced in code.
|
|
4
|
+
*
|
|
5
|
+
* The whole subsystem is inert unless four things are true at once: the build
|
|
6
|
+
* carries a key (published releases only), `DO_NOT_TRACK` is unset, this is not
|
|
7
|
+
* CI, and the user has not disabled it. See `gate.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export { EVENTS, COMMON_KEYS, isTrackedCommand, errorCode, filesBucket, durationBucket, countBucket, savedTokensBucket, langsValue } from './contract.js';
|
|
10
|
+
export type { AgentHost, Surface, TrackedCommand, BuildStage, ErrorCode } from './contract.js';
|
|
11
|
+
export { track, trackFirstRunIfNew, detectHost } from './track.js';
|
|
12
|
+
export type { QueuedEvent, TrackContext } from './track.js';
|
|
13
|
+
export { telemetryOn, offReason, explainOff } from './gate.js';
|
|
14
|
+
export { maybeFlushInBackground, runFlush } from './flush.js';
|
|
15
|
+
export { firstRunNotice, formatStatus, formatDebug, NOTICE, TELEMETRY_DOC_URL } from './notice.js';
|
|
16
|
+
export { patchState, readState } from './identity.js';
|
|
17
|
+
export { flushClosedSessions } from './sessions.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC1J,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACnE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anonymous adoption telemetry. `TELEMETRY.md` is the public contract;
|
|
3
|
+
* `contract.ts` is the same list enforced in code.
|
|
4
|
+
*
|
|
5
|
+
* The whole subsystem is inert unless four things are true at once: the build
|
|
6
|
+
* carries a key (published releases only), `DO_NOT_TRACK` is unset, this is not
|
|
7
|
+
* CI, and the user has not disabled it. See `gate.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export { EVENTS, COMMON_KEYS, isTrackedCommand, errorCode, filesBucket, durationBucket, countBucket, savedTokensBucket, langsValue } from './contract.js';
|
|
10
|
+
export { track, trackFirstRunIfNew, detectHost } from './track.js';
|
|
11
|
+
export { telemetryOn, offReason, explainOff } from './gate.js';
|
|
12
|
+
export { maybeFlushInBackground, runFlush } from './flush.js';
|
|
13
|
+
export { firstRunNotice, formatStatus, formatDebug, NOTICE, TELEMETRY_DOC_URL } from './notice.js';
|
|
14
|
+
export { patchState, readState } from './identity.js';
|
|
15
|
+
export { flushClosedSessions } from './sessions.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1J,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The PostHog project key, and the reason forks stay silent.
|
|
3
|
+
*
|
|
4
|
+
* `BAKED_KEY` is empty in the repository and is rewritten in place by
|
|
5
|
+
* `scripts/stamp-telemetry-key.mjs`, which runs from `prepublishOnly`. So the
|
|
6
|
+
* key exists only in the published tarball: a clone, a fork, and a plain
|
|
7
|
+
* `npm run build` all compile to `''`, and every send path short-circuits. A
|
|
8
|
+
* contributor cannot accidentally send us their own usage, and a fork cannot
|
|
9
|
+
* send us anything at all.
|
|
10
|
+
*
|
|
11
|
+
* `GRAFT_POSTHOG_KEY` overrides it at runtime so a maintainer can exercise the
|
|
12
|
+
* real path locally without publishing.
|
|
13
|
+
*
|
|
14
|
+
* Public project keys are write-only ingestion keys — they authorise capture and
|
|
15
|
+
* nothing else — which is why one may sit in a published artifact at all. It is
|
|
16
|
+
* still not committed here: an empty default is what makes "forks never send"
|
|
17
|
+
* true by construction rather than by policy.
|
|
18
|
+
*/
|
|
19
|
+
export declare function posthogKey(): string;
|
|
20
|
+
export declare function posthogHost(): string;
|
|
21
|
+
//# sourceMappingURL=key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../src/telemetry/key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA4BH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
|