@gurulu/cli 0.4.7 → 1.0.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 (182) hide show
  1. package/LICENSE +92 -0
  2. package/README.md +35 -106
  3. package/dist/bin.d.ts +3 -0
  4. package/dist/bin.d.ts.map +1 -0
  5. package/dist/bin.js +25410 -0
  6. package/dist/commands/auth.d.ts +23 -20
  7. package/dist/commands/auth.d.ts.map +1 -0
  8. package/dist/commands/doctor.d.ts +20 -6
  9. package/dist/commands/doctor.d.ts.map +1 -0
  10. package/dist/commands/init.d.ts +25 -11
  11. package/dist/commands/init.d.ts.map +1 -0
  12. package/dist/commands/pull.d.ts +13 -0
  13. package/dist/commands/pull.d.ts.map +1 -0
  14. package/dist/commands/push.d.ts +40 -0
  15. package/dist/commands/push.d.ts.map +1 -0
  16. package/dist/commands/validate.d.ts +36 -0
  17. package/dist/commands/validate.d.ts.map +1 -0
  18. package/dist/index.d.ts +4 -1
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +24985 -876
  21. package/dist/lib/api.d.ts +139 -0
  22. package/dist/lib/api.d.ts.map +1 -0
  23. package/dist/lib/codegen.d.ts +4 -0
  24. package/dist/lib/codegen.d.ts.map +1 -0
  25. package/dist/lib/config.d.ts +43 -0
  26. package/dist/lib/config.d.ts.map +1 -0
  27. package/package.json +40 -20
  28. package/bin/gurulu.js +0 -2
  29. package/dist/api-client.d.ts +0 -33
  30. package/dist/api-client.js +0 -175
  31. package/dist/commands/add-server.d.ts +0 -9
  32. package/dist/commands/add-server.js +0 -162
  33. package/dist/commands/alerts.d.ts +0 -27
  34. package/dist/commands/alerts.js +0 -309
  35. package/dist/commands/api-keys.d.ts +0 -20
  36. package/dist/commands/api-keys.js +0 -130
  37. package/dist/commands/attribution.d.ts +0 -22
  38. package/dist/commands/attribution.js +0 -111
  39. package/dist/commands/audiences.d.ts +0 -23
  40. package/dist/commands/audiences.js +0 -243
  41. package/dist/commands/audit.d.ts +0 -20
  42. package/dist/commands/audit.js +0 -130
  43. package/dist/commands/auth.js +0 -249
  44. package/dist/commands/chat.d.ts +0 -19
  45. package/dist/commands/chat.js +0 -118
  46. package/dist/commands/config.d.ts +0 -10
  47. package/dist/commands/config.js +0 -92
  48. package/dist/commands/consent.d.ts +0 -27
  49. package/dist/commands/consent.js +0 -233
  50. package/dist/commands/conversion-paths.d.ts +0 -19
  51. package/dist/commands/conversion-paths.js +0 -55
  52. package/dist/commands/db.d.ts +0 -25
  53. package/dist/commands/db.js +0 -330
  54. package/dist/commands/destinations.d.ts +0 -20
  55. package/dist/commands/destinations.js +0 -191
  56. package/dist/commands/doctor.js +0 -360
  57. package/dist/commands/errors.d.ts +0 -27
  58. package/dist/commands/errors.js +0 -121
  59. package/dist/commands/events.d.ts +0 -33
  60. package/dist/commands/events.js +0 -371
  61. package/dist/commands/experiments.d.ts +0 -22
  62. package/dist/commands/experiments.js +0 -264
  63. package/dist/commands/funnels.d.ts +0 -17
  64. package/dist/commands/funnels.js +0 -203
  65. package/dist/commands/goals.d.ts +0 -18
  66. package/dist/commands/goals.js +0 -214
  67. package/dist/commands/heatmap.d.ts +0 -27
  68. package/dist/commands/heatmap.js +0 -112
  69. package/dist/commands/identity.d.ts +0 -29
  70. package/dist/commands/identity.js +0 -328
  71. package/dist/commands/init.js +0 -215
  72. package/dist/commands/insights.d.ts +0 -10
  73. package/dist/commands/insights.js +0 -77
  74. package/dist/commands/install.d.ts +0 -259
  75. package/dist/commands/install.js +0 -1590
  76. package/dist/commands/login.d.ts +0 -20
  77. package/dist/commands/login.js +0 -170
  78. package/dist/commands/logout.d.ts +0 -10
  79. package/dist/commands/logout.js +0 -41
  80. package/dist/commands/playground.d.ts +0 -11
  81. package/dist/commands/playground.js +0 -47
  82. package/dist/commands/releases.d.ts +0 -17
  83. package/dist/commands/releases.js +0 -54
  84. package/dist/commands/replay.d.ts +0 -18
  85. package/dist/commands/replay.js +0 -64
  86. package/dist/commands/secrets.d.ts +0 -19
  87. package/dist/commands/secrets.js +0 -145
  88. package/dist/commands/setup.d.ts +0 -21
  89. package/dist/commands/setup.js +0 -67
  90. package/dist/commands/sites.d.ts +0 -18
  91. package/dist/commands/sites.js +0 -139
  92. package/dist/commands/skad.d.ts +0 -18
  93. package/dist/commands/skad.js +0 -53
  94. package/dist/commands/sourcemap.d.ts +0 -33
  95. package/dist/commands/sourcemap.js +0 -204
  96. package/dist/commands/status.d.ts +0 -7
  97. package/dist/commands/status.js +0 -136
  98. package/dist/commands/upgrade.d.ts +0 -21
  99. package/dist/commands/upgrade.js +0 -183
  100. package/dist/commands/warehouse.d.ts +0 -20
  101. package/dist/commands/warehouse.js +0 -65
  102. package/dist/commands/warehouses.d.ts +0 -17
  103. package/dist/commands/warehouses.js +0 -182
  104. package/dist/commands/watch.d.ts +0 -45
  105. package/dist/commands/watch.js +0 -258
  106. package/dist/commands/whoami.d.ts +0 -9
  107. package/dist/commands/whoami.js +0 -50
  108. package/dist/config.d.ts +0 -75
  109. package/dist/config.js +0 -329
  110. package/dist/frameworks/detect.d.ts +0 -8
  111. package/dist/frameworks/detect.js +0 -458
  112. package/dist/install-intent-proposal.d.ts +0 -99
  113. package/dist/install-intent-proposal.js +0 -202
  114. package/dist/utils/api.d.ts +0 -20
  115. package/dist/utils/api.js +0 -47
  116. package/dist/utils/config.d.ts +0 -13
  117. package/dist/utils/config.js +0 -30
  118. package/dist/utils/confirm.d.ts +0 -17
  119. package/dist/utils/confirm.js +0 -40
  120. package/dist/utils/dry-run.d.ts +0 -20
  121. package/dist/utils/dry-run.js +0 -67
  122. package/dist/utils/from-file.d.ts +0 -9
  123. package/dist/utils/from-file.js +0 -72
  124. package/dist/utils/redact.d.ts +0 -14
  125. package/dist/utils/redact.js +0 -48
  126. package/dist/utils/ui.d.ts +0 -14
  127. package/dist/utils/ui.js +0 -59
  128. package/scripts/.gitkeep +0 -0
  129. package/scripts/README-gurulu-agentic-install.md +0 -114
  130. package/scripts/README-gurulu-scan.md +0 -98
  131. package/scripts/audit-cli-scopes.mjs +0 -204
  132. package/scripts/backfill-tenant-id.mjs +0 -172
  133. package/scripts/backfill-tenant-links.ts +0 -252
  134. package/scripts/backup-clickhouse.sh +0 -27
  135. package/scripts/backup-postgres.sh +0 -19
  136. package/scripts/bootstrap-runtime-schema.mjs +0 -87
  137. package/scripts/bootstrap-stripe.mjs +0 -158
  138. package/scripts/gurulu-agentic-install.lib.cjs +0 -762
  139. package/scripts/gurulu-agentic-install.mjs +0 -623
  140. package/scripts/gurulu-scan.lib.cjs +0 -1509
  141. package/scripts/gurulu-scan.mjs +0 -91
  142. package/scripts/gurulu-verify-install.lib.cjs +0 -334
  143. package/scripts/gurulu-verify-install.mjs +0 -59
  144. package/scripts/init-ssl.sh +0 -26
  145. package/scripts/migrate-flow-graph-enums.sh +0 -86
  146. package/scripts/monitor-disk.sh +0 -24
  147. package/scripts/patches/astro.patch.cjs +0 -74
  148. package/scripts/patches/auto-instrument/ast-helper.cjs +0 -480
  149. package/scripts/patches/auto-instrument/astro.cjs +0 -273
  150. package/scripts/patches/auto-instrument/express.cjs +0 -383
  151. package/scripts/patches/auto-instrument/fastify.cjs +0 -262
  152. package/scripts/patches/auto-instrument/hono.cjs +0 -392
  153. package/scripts/patches/auto-instrument/index.cjs +0 -80
  154. package/scripts/patches/auto-instrument/nestjs.cjs +0 -286
  155. package/scripts/patches/auto-instrument/nextjs-app-router.cjs +0 -345
  156. package/scripts/patches/auto-instrument/nextjs-pages.cjs +0 -361
  157. package/scripts/patches/auto-instrument/remix.cjs +0 -168
  158. package/scripts/patches/auto-instrument/sdk-helper-map.cjs +0 -241
  159. package/scripts/patches/auto-instrument/singleton-helper.cjs +0 -193
  160. package/scripts/patches/auto-instrument/sveltekit.cjs +0 -161
  161. package/scripts/patches/auto-instrument/vite-react.cjs +0 -37
  162. package/scripts/patches/auto-instrument/vue.cjs +0 -196
  163. package/scripts/patches/express.patch.cjs +0 -99
  164. package/scripts/patches/fastify.patch.cjs +0 -108
  165. package/scripts/patches/index.cjs +0 -300
  166. package/scripts/patches/nestjs.patch.cjs +0 -112
  167. package/scripts/patches/nextjs-app-router.patch.cjs +0 -97
  168. package/scripts/patches/nextjs-pages.patch.cjs +0 -97
  169. package/scripts/patches/remix.patch.cjs +0 -75
  170. package/scripts/patches/sveltekit.patch.cjs +0 -72
  171. package/scripts/patches/vite-react.patch.cjs +0 -73
  172. package/scripts/patches/vue.patch.cjs +0 -82
  173. package/scripts/renew-ssl.sh +0 -14
  174. package/scripts/resolve-migration.sh +0 -23
  175. package/scripts/seed-cli-dev-keys.mjs +0 -130
  176. package/scripts/seed-test-data.mjs +0 -391
  177. package/scripts/spike-browserless.ts +0 -65
  178. package/scripts/tenant-pivot-consistency-check.mjs +0 -205
  179. package/scripts/tenant-pivot-phase-3-cleanup.lib.cjs +0 -258
  180. package/scripts/tenant-pivot-phase-3-cleanup.mjs +0 -98
  181. package/scripts/test-identity-resolution.ts +0 -804
  182. package/scripts/validate-gurulu-schemas.mjs +0 -79
@@ -1,259 +0,0 @@
1
- /**
2
- * Phase 16 A2 — `gurulu install` user-facing auto-install command.
3
- *
4
- * Runs the full bootstrap loop against a target repo:
5
- * 1. scan (scripts/gurulu-scan.mjs)
6
- * 2. confirm (interactive, skipped with --yes)
7
- * 3. agentic plan (scripts/gurulu-agentic-install.mjs --dry-run)
8
- * 4. apply (scripts/gurulu-agentic-install.mjs --apply)
9
- * 5. npm install (pm detected from lockfile)
10
- * 6. .env merge (.env.local for Next.js, .env otherwise)
11
- * 7. ingest ping (POST <ingestUrl>/api/ingest/v1/health)
12
- *
13
- * The command is designed so the flow orchestration (`runInstallFlow`) can
14
- * be unit-tested with injected deps — no real spawns or fetches required.
15
- */
16
- import { type ActiveProfile } from '../config';
17
- import { type InstallIntent, type ProposalDecision, type ProposalIo } from '../install-intent-proposal';
18
- export interface InstallArgs {
19
- path?: string;
20
- siteId?: string;
21
- tenantId?: string;
22
- framework?: string;
23
- dryRun?: boolean;
24
- skipNpm?: boolean;
25
- skipEnv?: boolean;
26
- yes?: boolean;
27
- ingestUrl?: string;
28
- verify?: boolean;
29
- profile?: string;
30
- site?: string;
31
- publishableKey?: string;
32
- apply?: boolean;
33
- rollback?: boolean;
34
- skipIntent?: boolean;
35
- intentDryRun?: boolean;
36
- verticalHint?: string;
37
- autoInstrument?: boolean;
38
- autoProperties?: boolean;
39
- /** Internal: path to the serialized intent JSON forwarded to the agentic-install script. */
40
- intentResultPath?: string;
41
- /**
42
- * Internal: API token (active profile secret key) forwarded to the
43
- * agentic-install script as `--token`. The script's `tryLlmExtraction`
44
- * needs this to call the LLM property-extraction endpoint; without it
45
- * extraction silently 401s and every injected `gurulu.track(...)` ends
46
- * up with `// TODO: <prop>` placeholders. See Sprint A fix A2.
47
- */
48
- authToken?: string;
49
- /** Sprint E1.5 — explicit workspace path inside an npm/pnpm/yarn workspace repo. */
50
- workspace?: string;
51
- /** FA-1 P0-2 — override the tracker tag asset URL (self-hosted ingest). */
52
- scriptSrc?: string;
53
- }
54
- export declare function resolveWorkspaceRoot(repoRoot: string, args: InstallArgs, deps: InstallDeps): Promise<string>;
55
- export interface IntentPreSeedResult {
56
- ok: boolean;
57
- proposalId?: string;
58
- created?: {
59
- goals: number;
60
- funnels: number;
61
- milestones: number;
62
- events?: number;
63
- };
64
- skipped?: {
65
- goals: number;
66
- funnels: number;
67
- };
68
- quotaExceeded?: boolean;
69
- error?: string;
70
- }
71
- export interface IntentProposalDeps {
72
- analyze: (signals: unknown) => Promise<InstallIntent>;
73
- preSeed: (body: {
74
- siteId: string;
75
- intent: InstallIntent;
76
- accepted: ProposalDecision['accepted'];
77
- rejected: ProposalDecision['rejected'];
78
- }) => Promise<IntentPreSeedResult>;
79
- io?: ProposalIo;
80
- }
81
- export interface VerifyResult {
82
- ok: boolean;
83
- reason?: string | null;
84
- pageViewSeen?: boolean;
85
- capturedEventCount?: number;
86
- [k: string]: any;
87
- }
88
- export interface ScanSummary {
89
- framework: {
90
- name: string;
91
- version?: string;
92
- };
93
- orm: {
94
- name: string;
95
- };
96
- auth: {
97
- name: string;
98
- };
99
- routes: Array<{
100
- path: string;
101
- methods?: string[];
102
- file?: string;
103
- }>;
104
- [k: string]: any;
105
- }
106
- export interface SpawnResult {
107
- code: number;
108
- stdout: string;
109
- stderr: string;
110
- }
111
- export interface InstallDeps {
112
- /** Spawn a subprocess (node <script> args...) and collect stdout/stderr. */
113
- runNode: (args: string[], opts?: {
114
- cwd?: string;
115
- input?: string;
116
- }) => Promise<SpawnResult>;
117
- /** Spawn an arbitrary shell command and wait for exit. */
118
- runCmd: (cmd: string, args: string[], opts?: {
119
- cwd?: string;
120
- }) => Promise<SpawnResult>;
121
- /** Make an HTTP POST; must return `{ ok, status }`. */
122
- fetchJson: (url: string, body: any) => Promise<{
123
- ok: boolean;
124
- status: number;
125
- }>;
126
- /** Interactive prompt. */
127
- prompt: (question: string) => Promise<string>;
128
- /** Optional live-smoke verifier (Phase 16 A3). Returns verifier result. */
129
- verify?: (args: {
130
- repoRoot: string;
131
- framework: string;
132
- siteId: string;
133
- tenantId: string;
134
- ingestUrl: string;
135
- scriptsDir: string;
136
- }) => Promise<VerifyResult>;
137
- /** Logger (defaults to the ui helpers). */
138
- log?: {
139
- info: (msg: string) => void;
140
- warn: (msg: string) => void;
141
- error: (msg: string) => void;
142
- step: (msg: string) => void;
143
- success: (msg: string) => void;
144
- };
145
- }
146
- export interface InstallSummary {
147
- scan: ScanSummary | null;
148
- framework: string | null;
149
- planDiff: string;
150
- filesChanged: number;
151
- packageManager: 'pnpm' | 'yarn' | 'npm' | 'bun' | null;
152
- packageInstalled: boolean;
153
- envKeysWritten: string[];
154
- ingestOk: boolean | null;
155
- dryRun: boolean;
156
- verify: VerifyResult | null;
157
- rolledBack: boolean;
158
- errors: string[];
159
- partiallyInstalled?: boolean;
160
- installedComponents?: string[];
161
- intent?: {
162
- skipped: boolean;
163
- dryRun: boolean;
164
- analyzed: boolean;
165
- preSeeded: boolean;
166
- proposalId?: string;
167
- vertical?: string;
168
- accepted?: {
169
- events: number;
170
- funnels: number;
171
- };
172
- created?: {
173
- goals: number;
174
- funnels: number;
175
- milestones: number;
176
- events?: number;
177
- };
178
- error?: string;
179
- };
180
- instrumentation?: {
181
- enabled: boolean;
182
- filesModified: number;
183
- eventsInstrumented: number;
184
- eventsSkipped: number;
185
- notes?: string[];
186
- error?: string;
187
- };
188
- }
189
- /**
190
- * Locate the repo scripts/ directory (works when installed from source tree
191
- * or as a bundled package; falls back to GURULU_SCRIPTS_DIR env override).
192
- */
193
- export declare function resolveScriptsDir(startDir?: string): string;
194
- export declare function detectPackageManager(repoRoot: string): 'pnpm' | 'yarn' | 'npm' | 'bun';
195
- export declare function packageInstallArgs(pm: 'pnpm' | 'yarn' | 'npm' | 'bun'): string[];
196
- export interface EnvMergeResult {
197
- file: string;
198
- added: string[];
199
- skipped: string[];
200
- }
201
- export declare function parseEnvFile(text: string): Set<string>;
202
- export declare function mergeEnvFile(repoRoot: string, framework: string, vars: Record<string, string>): EnvMergeResult;
203
- export declare function createDefaultDeps(scriptsDir: string): InstallDeps;
204
- export declare function runInstallFlow(args: InstallArgs, deps: InstallDeps, scriptsDir: string): Promise<InstallSummary>;
205
- export interface AuthenticatedInstallDeps {
206
- profile: ActiveProfile;
207
- sites: Array<{
208
- id: string;
209
- name: string | null;
210
- domain: string;
211
- publishableKey: string;
212
- }>;
213
- tenantId: string;
214
- postVerify: (body: any) => Promise<{
215
- ok: boolean;
216
- status: number;
217
- }>;
218
- promptSelect?: (question: string, options: string[]) => Promise<number>;
219
- prompt?: (question: string) => Promise<string>;
220
- /** Phase 18.6 — intent analyze + pre-seed integrations. */
221
- intent?: IntentProposalDeps;
222
- }
223
- export declare function isTelemetryDisabled(): boolean;
224
- /**
225
- * First-run consent prompt. Persists the decision so we never re-ask.
226
- * No-op when telemetry is already disabled, when a decision is already
227
- * recorded, or in non-interactive (`--yes` / `--no-interactive`) mode.
228
- */
229
- export declare function maybePromptTelemetryConsent(ask: (q: string) => Promise<string>, args?: {
230
- yes?: boolean;
231
- }): Promise<void>;
232
- export declare function repoHashOf(repoRoot: string, remoteUrl?: string | null): string;
233
- export declare function pickSite(sites: AuthenticatedInstallDeps['sites'], target?: string): {
234
- id: string;
235
- name: string | null;
236
- domain: string;
237
- publishableKey: string;
238
- } | null;
239
- /** Send a telemetry POST. Never throws — quota errors are surfaced via `ok`. */
240
- export declare function emitInstallTelemetry(deps: AuthenticatedInstallDeps, payload: {
241
- siteId: string;
242
- status: 'dry-run' | 'applied' | 'verified' | 'failed' | 'rolled-back';
243
- framework: string;
244
- cliVersion: string;
245
- repoHash: string;
246
- errorMessage?: string | null;
247
- /** Phase 18.7 B — optional auto-instrument summary. Backend treats as opt-in. */
248
- instrumentation?: {
249
- filesModified: number;
250
- eventsInstrumented: number;
251
- eventsSkipped: number;
252
- };
253
- }): Promise<{
254
- ok: boolean;
255
- quotaExceeded: boolean;
256
- }>;
257
- export declare function detectCiEnv(env?: NodeJS.ProcessEnv): boolean;
258
- export declare function runAuthenticatedInstallFlow(args: InstallArgs, authDeps: AuthenticatedInstallDeps, installDeps: InstallDeps, scriptsDir: string): Promise<InstallSummary>;
259
- export declare function installCommand(args: InstallArgs): Promise<void>;