@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
package/dist/config.js DELETED
@@ -1,329 +0,0 @@
1
- "use strict";
2
- /**
3
- * Phase 18.5 W2 — Multi-profile CLI config.
4
- *
5
- * Replaces the single-profile `~/.gurulu/config.json` used by earlier phases
6
- * with a profile-aware store, while keeping backward compatibility for
7
- * commands that still call `utils/config.ts` (they now read from the
8
- * currently-active profile).
9
- *
10
- * Resolution order for a live session:
11
- * 1. GURULU_SECRET_KEY (env-var override — bypasses the file entirely)
12
- * 2. --profile <name> (CLI flag)
13
- * 3. GURULU_PROFILE (env)
14
- * 4. default_profile (from file)
15
- * 5. 'personal' (final fallback)
16
- *
17
- * Optional macOS keychain integration: if `keytar` is available at runtime,
18
- * secrets can be stored there under service 'io.gurulu.cli' account
19
- * `<profile>`. If unavailable, secrets fall back to the plaintext file.
20
- * Keytar is a **soft runtime require** — never a hard dependency, because
21
- * it's a native module and we don't want to force its install.
22
- */
23
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- var desc = Object.getOwnPropertyDescriptor(m, k);
26
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
- desc = { enumerable: true, get: function() { return m[k]; } };
28
- }
29
- Object.defineProperty(o, k2, desc);
30
- }) : (function(o, m, k, k2) {
31
- if (k2 === undefined) k2 = k;
32
- o[k2] = m[k];
33
- }));
34
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
- Object.defineProperty(o, "default", { enumerable: true, value: v });
36
- }) : function(o, v) {
37
- o["default"] = v;
38
- });
39
- var __importStar = (this && this.__importStar) || (function () {
40
- var ownKeys = function(o) {
41
- ownKeys = Object.getOwnPropertyNames || function (o) {
42
- var ar = [];
43
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
44
- return ar;
45
- };
46
- return ownKeys(o);
47
- };
48
- return function (mod) {
49
- if (mod && mod.__esModule) return mod;
50
- var result = {};
51
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
52
- __setModuleDefault(result, mod);
53
- return result;
54
- };
55
- })();
56
- Object.defineProperty(exports, "__esModule", { value: true });
57
- exports.ProfileNotFoundError = void 0;
58
- exports.configPath = configPath;
59
- exports.readKeychainSecret = readKeychainSecret;
60
- exports.writeKeychainSecret = writeKeychainSecret;
61
- exports.deleteKeychainSecret = deleteKeychainSecret;
62
- exports.isKeychainAvailable = isKeychainAvailable;
63
- exports.listProfiles = listProfiles;
64
- exports.getStoredProfile = getStoredProfile;
65
- exports.getDefaultProfileName = getDefaultProfileName;
66
- exports.setDefaultProfile = setDefaultProfile;
67
- exports.saveProfile = saveProfile;
68
- exports.deleteProfile = deleteProfile;
69
- exports.deleteAllProfiles = deleteAllProfiles;
70
- exports.loadActiveProfile = loadActiveProfile;
71
- exports.getActiveProfile = getActiveProfile;
72
- exports.defaultApiBase = defaultApiBase;
73
- const fs = __importStar(require("fs"));
74
- const path = __importStar(require("path"));
75
- const os = __importStar(require("os"));
76
- const DEFAULT_API_BASE = 'https://gurulu.io';
77
- const KEYCHAIN_SERVICE = 'io.gurulu.cli';
78
- function configHome() {
79
- if (process.env.GURULU_CONFIG_HOME)
80
- return process.env.GURULU_CONFIG_HOME;
81
- return path.join(os.homedir(), '.gurulu');
82
- }
83
- function configPath() {
84
- return path.join(configHome(), 'config.json');
85
- }
86
- function emptyFile() {
87
- return { default_profile: 'personal', profiles: {} };
88
- }
89
- function readFileRaw() {
90
- const p = configPath();
91
- if (!fs.existsSync(p))
92
- return emptyFile();
93
- try {
94
- const txt = fs.readFileSync(p, 'utf8');
95
- const parsed = JSON.parse(txt);
96
- if (parsed && typeof parsed === 'object' && parsed.profiles) {
97
- return parsed;
98
- }
99
- // Migrate legacy `{ apiKey, email }` single-profile config.
100
- if (parsed && typeof parsed === 'object' && parsed.apiKey) {
101
- const migrated = {
102
- default_profile: 'personal',
103
- profiles: {
104
- personal: {
105
- email: parsed.email || '',
106
- secret_key: parsed.apiKey,
107
- api_base: DEFAULT_API_BASE,
108
- },
109
- },
110
- };
111
- return migrated;
112
- }
113
- return emptyFile();
114
- }
115
- catch {
116
- return emptyFile();
117
- }
118
- }
119
- function writeFileRaw(cfg) {
120
- const home = configHome();
121
- if (!fs.existsSync(home)) {
122
- fs.mkdirSync(home, { recursive: true, mode: 0o700 });
123
- }
124
- else {
125
- try {
126
- fs.chmodSync(home, 0o700);
127
- }
128
- catch {
129
- /* ignore */
130
- }
131
- }
132
- const p = configPath();
133
- fs.writeFileSync(p, JSON.stringify(cfg, null, 2));
134
- try {
135
- fs.chmodSync(p, 0o600);
136
- }
137
- catch {
138
- /* ignore on non-unix */
139
- }
140
- }
141
- function warnBadPermissions() {
142
- const p = configPath();
143
- if (!fs.existsSync(p))
144
- return;
145
- try {
146
- const stat = fs.statSync(p);
147
- const mode = stat.mode & 0o777;
148
- if (mode & 0o077) {
149
- // Group/world readable — warn on stderr only.
150
- process.stderr.write(`[warn] ${p} has insecure permissions (${mode.toString(8)}). Run: chmod 600 ${p}\n`);
151
- }
152
- }
153
- catch {
154
- /* ignore */
155
- }
156
- }
157
- function tryRequireKeytar() {
158
- if (process.env.GURULU_DISABLE_KEYCHAIN === '1')
159
- return null;
160
- try {
161
- // eslint-disable-next-line @typescript-eslint/no-var-requires
162
- return require('keytar');
163
- }
164
- catch {
165
- return null;
166
- }
167
- }
168
- async function readKeychainSecret(profile) {
169
- const kt = tryRequireKeytar();
170
- if (!kt)
171
- return null;
172
- try {
173
- return await kt.getPassword(KEYCHAIN_SERVICE, profile);
174
- }
175
- catch {
176
- return null;
177
- }
178
- }
179
- async function writeKeychainSecret(profile, secret) {
180
- const kt = tryRequireKeytar();
181
- if (!kt)
182
- return false;
183
- try {
184
- await kt.setPassword(KEYCHAIN_SERVICE, profile, secret);
185
- return true;
186
- }
187
- catch {
188
- return false;
189
- }
190
- }
191
- async function deleteKeychainSecret(profile) {
192
- const kt = tryRequireKeytar();
193
- if (!kt)
194
- return;
195
- try {
196
- await kt.deletePassword(KEYCHAIN_SERVICE, profile);
197
- }
198
- catch {
199
- /* ignore */
200
- }
201
- }
202
- function isKeychainAvailable() {
203
- return tryRequireKeytar() !== null;
204
- }
205
- // --- public API --------------------------------------------------------------
206
- function listProfiles() {
207
- const cfg = readFileRaw();
208
- return Object.entries(cfg.profiles).map(([name, p]) => ({
209
- name,
210
- email: p.email,
211
- api_base: p.api_base,
212
- isDefault: name === cfg.default_profile,
213
- keychain: !!p.keychain,
214
- }));
215
- }
216
- function getStoredProfile(name) {
217
- const cfg = readFileRaw();
218
- return cfg.profiles[name] || null;
219
- }
220
- function getDefaultProfileName() {
221
- const cfg = readFileRaw();
222
- return cfg.default_profile || 'personal';
223
- }
224
- function setDefaultProfile(name) {
225
- const cfg = readFileRaw();
226
- if (!cfg.profiles[name]) {
227
- throw new Error(`Profile '${name}' does not exist.`);
228
- }
229
- cfg.default_profile = name;
230
- writeFileRaw(cfg);
231
- }
232
- async function saveProfile(name, profile, opts = {}) {
233
- const cfg = readFileRaw();
234
- const wantKeychain = !!opts.useKeychain && isKeychainAvailable();
235
- let storedInKeychain = false;
236
- if (wantKeychain) {
237
- storedInKeychain = await writeKeychainSecret(name, profile.secret_key);
238
- }
239
- cfg.profiles[name] = storedInKeychain
240
- ? { email: profile.email, api_base: profile.api_base, keychain: true }
241
- : { email: profile.email, api_base: profile.api_base, secret_key: profile.secret_key };
242
- if (!cfg.default_profile || !cfg.profiles[cfg.default_profile]) {
243
- cfg.default_profile = name;
244
- }
245
- writeFileRaw(cfg);
246
- return { storedInKeychain };
247
- }
248
- async function deleteProfile(name) {
249
- const cfg = readFileRaw();
250
- if (!cfg.profiles[name])
251
- return false;
252
- delete cfg.profiles[name];
253
- if (cfg.default_profile === name) {
254
- const remaining = Object.keys(cfg.profiles);
255
- cfg.default_profile = remaining[0] || 'personal';
256
- }
257
- writeFileRaw(cfg);
258
- await deleteKeychainSecret(name);
259
- return true;
260
- }
261
- async function deleteAllProfiles() {
262
- const cfg = readFileRaw();
263
- const names = Object.keys(cfg.profiles);
264
- for (const n of names)
265
- await deleteKeychainSecret(n);
266
- writeFileRaw({ default_profile: 'personal', profiles: {} });
267
- return names;
268
- }
269
- /**
270
- * Resolve the active profile given CLI flags. Throws if no usable profile.
271
- * Accepts the `GURULU_SECRET_KEY` env var as an override for CI.
272
- */
273
- async function loadActiveProfile(flags = {}) {
274
- // 1. Environment override (bypasses file entirely — used by CI)
275
- const envKey = process.env.GURULU_SECRET_KEY;
276
- if (envKey) {
277
- return {
278
- name: flags.profile || process.env.GURULU_PROFILE || 'env',
279
- email: process.env.GURULU_EMAIL || 'env@gurulu.local',
280
- secret_key: envKey,
281
- api_base: process.env.GURULU_API_BASE || DEFAULT_API_BASE,
282
- source: 'env',
283
- };
284
- }
285
- warnBadPermissions();
286
- const cfg = readFileRaw();
287
- const name = flags.profile || process.env.GURULU_PROFILE || cfg.default_profile || 'personal';
288
- const stored = cfg.profiles[name];
289
- if (!stored) {
290
- throw new ProfileNotFoundError(name);
291
- }
292
- let secret = stored.secret_key || '';
293
- let source = 'file';
294
- if (stored.keychain) {
295
- const kc = await readKeychainSecret(name);
296
- if (kc) {
297
- secret = kc;
298
- source = 'keychain';
299
- }
300
- else if (!secret) {
301
- throw new Error(`Profile '${name}' is marked as keychain-stored but the secret is missing. Run 'gurulu login --profile ${name}' again.`);
302
- }
303
- }
304
- return {
305
- name,
306
- email: stored.email,
307
- secret_key: secret,
308
- api_base: stored.api_base || DEFAULT_API_BASE,
309
- source,
310
- };
311
- }
312
- async function getActiveProfile(flags = {}) {
313
- try {
314
- return await loadActiveProfile(flags);
315
- }
316
- catch {
317
- return null;
318
- }
319
- }
320
- class ProfileNotFoundError extends Error {
321
- constructor(name) {
322
- super(`Profile '${name}' not found. Run 'gurulu login' first.`);
323
- this.name = 'ProfileNotFoundError';
324
- }
325
- }
326
- exports.ProfileNotFoundError = ProfileNotFoundError;
327
- function defaultApiBase() {
328
- return process.env.GURULU_API_BASE || DEFAULT_API_BASE;
329
- }
@@ -1,8 +0,0 @@
1
- export type Framework = 'nextjs-app' | 'nextjs-pages' | 'react-vite' | 'react-cra' | 'vue3' | 'nuxt3' | 'svelte' | 'sveltekit' | 'astro' | 'express' | 'fastify' | 'hono' | 'nestjs' | 'html' | 'react-native' | 'ios-swift' | 'android-kotlin' | 'flutter' | 'unknown';
2
- export declare function detectFramework(projectDir: string): Framework;
3
- export declare function getSetupSnippet(framework: Framework, siteId: string, token: string): {
4
- file: string;
5
- code: string;
6
- instruction: string;
7
- };
8
- export declare function getFrameworkDisplayName(fw: Framework): string;