@gurulu/cli 0.4.3 → 0.4.4
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 +24 -0
- package/dist/commands/consent.d.ts +27 -0
- package/dist/commands/consent.js +233 -0
- package/dist/commands/db.js +8 -0
- package/dist/commands/identity.d.ts +3 -0
- package/dist/commands/identity.js +138 -1
- package/dist/commands/install.d.ts +16 -3
- package/dist/commands/install.js +389 -30
- package/dist/commands/secrets.d.ts +19 -0
- package/dist/commands/secrets.js +145 -0
- package/dist/commands/upgrade.d.ts +21 -0
- package/dist/commands/upgrade.js +183 -0
- package/dist/index.js +65 -2
- package/dist/utils/redact.d.ts +14 -0
- package/dist/utils/redact.js +48 -0
- package/package.json +1 -1
- package/scripts/bootstrap-runtime-schema.mjs +7 -25
package/README.md
CHANGED
|
@@ -101,3 +101,27 @@ gurulu events list --json
|
|
|
101
101
|
gurulu status --json
|
|
102
102
|
gurulu doctor --json
|
|
103
103
|
```
|
|
104
|
+
|
|
105
|
+
## Telemetry
|
|
106
|
+
|
|
107
|
+
`gurulu install` records anonymous install telemetry — framework, CLI version,
|
|
108
|
+
install status, and a SHA-256 hash of the absolute repo path — to help us
|
|
109
|
+
improve framework detection and patch reliability. **No source code, file
|
|
110
|
+
contents, or environment variables are ever sent.**
|
|
111
|
+
|
|
112
|
+
On the first interactive install you'll be asked to opt in. Your choice is
|
|
113
|
+
persisted to `~/.gurulu/config.json` (`telemetry: true|false`) and never
|
|
114
|
+
re-asked.
|
|
115
|
+
|
|
116
|
+
To opt out:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
gurulu install --no-telemetry # one-off
|
|
120
|
+
export GURULU_TELEMETRY=off # session / shell
|
|
121
|
+
export DO_NOT_TRACK=1 # honored across most CLI tools
|
|
122
|
+
echo '{"telemetry": false}' > ~/.gurulu/config.json # permanent
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Any of `GURULU_TELEMETRY=off|0|false|no`, `DO_NOT_TRACK=1`, `--no-telemetry`,
|
|
126
|
+
or `telemetry: false` in `~/.gurulu/config.json` disables telemetry — the repo
|
|
127
|
+
hash is never computed and no network request is made.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI@0.4.4 — `gurulu consent` — manage per-user consent scopes (GDPR).
|
|
3
|
+
*
|
|
4
|
+
* Subcommands:
|
|
5
|
+
* gurulu consent set --user-id X --scope marketing_external --state granted|denied
|
|
6
|
+
* gurulu consent get --user-id X
|
|
7
|
+
* gurulu consent revoke --user-id X
|
|
8
|
+
* gurulu consent check --user-id X --destination capi
|
|
9
|
+
*
|
|
10
|
+
* TODO(Sprint K): backend endpoints below are not yet live. The CLI command
|
|
11
|
+
* surface is implemented now so customers can wire automation; once the API
|
|
12
|
+
* routes ship, the cliApi calls will succeed without any further CLI changes.
|
|
13
|
+
* - POST /api/cli/consent/set { userId, scope, state }
|
|
14
|
+
* - GET /api/cli/consent/get?userId=... (returns scopes[])
|
|
15
|
+
* - POST /api/cli/consent/revoke { userId } (denies all scopes)
|
|
16
|
+
* - GET /api/cli/consent/check?userId=...&destination=... (returns { allowed: boolean })
|
|
17
|
+
*/
|
|
18
|
+
export interface ConsentArgs {
|
|
19
|
+
action?: string;
|
|
20
|
+
userId?: string;
|
|
21
|
+
scope?: string;
|
|
22
|
+
state?: string;
|
|
23
|
+
destination?: string;
|
|
24
|
+
json?: boolean;
|
|
25
|
+
profile?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function consentCommand(args: ConsentArgs): Promise<void>;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CLI@0.4.4 — `gurulu consent` — manage per-user consent scopes (GDPR).
|
|
4
|
+
*
|
|
5
|
+
* Subcommands:
|
|
6
|
+
* gurulu consent set --user-id X --scope marketing_external --state granted|denied
|
|
7
|
+
* gurulu consent get --user-id X
|
|
8
|
+
* gurulu consent revoke --user-id X
|
|
9
|
+
* gurulu consent check --user-id X --destination capi
|
|
10
|
+
*
|
|
11
|
+
* TODO(Sprint K): backend endpoints below are not yet live. The CLI command
|
|
12
|
+
* surface is implemented now so customers can wire automation; once the API
|
|
13
|
+
* routes ship, the cliApi calls will succeed without any further CLI changes.
|
|
14
|
+
* - POST /api/cli/consent/set { userId, scope, state }
|
|
15
|
+
* - GET /api/cli/consent/get?userId=... (returns scopes[])
|
|
16
|
+
* - POST /api/cli/consent/revoke { userId } (denies all scopes)
|
|
17
|
+
* - GET /api/cli/consent/check?userId=...&destination=... (returns { allowed: boolean })
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.consentCommand = consentCommand;
|
|
21
|
+
const config_1 = require("../config");
|
|
22
|
+
const api_client_1 = require("../api-client");
|
|
23
|
+
const ui_1 = require("../utils/ui");
|
|
24
|
+
async function consentCommand(args) {
|
|
25
|
+
switch (args.action) {
|
|
26
|
+
case 'set':
|
|
27
|
+
return consentSet(args);
|
|
28
|
+
case 'get':
|
|
29
|
+
return consentGet(args);
|
|
30
|
+
case 'revoke':
|
|
31
|
+
return consentRevoke(args);
|
|
32
|
+
case 'check':
|
|
33
|
+
return consentCheck(args);
|
|
34
|
+
default:
|
|
35
|
+
(0, ui_1.error)(`Unknown action: ${args.action}. Use: set, get, revoke, check`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function loadProfileOrExit(args) {
|
|
40
|
+
try {
|
|
41
|
+
return await (0, config_1.loadActiveProfile)({ profile: args.profile });
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
(0, ui_1.error)('Not authenticated. Run "gurulu login" first.');
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function emitFallbackNotice(json) {
|
|
49
|
+
if (json)
|
|
50
|
+
return;
|
|
51
|
+
(0, ui_1.info)((0, ui_1.dim)('Note: backend endpoint not yet live (Sprint K candidate). Command-shape is stable.'));
|
|
52
|
+
}
|
|
53
|
+
// ── set ────────────────────────────────────────────────────────────────────
|
|
54
|
+
async function consentSet(args) {
|
|
55
|
+
if (!args.userId || !args.scope || !args.state) {
|
|
56
|
+
(0, ui_1.error)('Usage: gurulu consent set --user-id <id> --scope <scope> --state <granted|denied>');
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
if (args.state !== 'granted' && args.state !== 'denied') {
|
|
60
|
+
(0, ui_1.error)('--state must be one of: granted, denied');
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
const profile = await loadProfileOrExit(args);
|
|
64
|
+
try {
|
|
65
|
+
const res = await (0, api_client_1.cliApi)('/api/cli/consent/set', {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
body: JSON.stringify({ userId: args.userId, scope: args.scope, state: args.state }),
|
|
68
|
+
preloadedProfile: profile,
|
|
69
|
+
});
|
|
70
|
+
const data = await res.json().catch(() => ({}));
|
|
71
|
+
if (res.status === 404) {
|
|
72
|
+
emitFallbackNotice(args.json);
|
|
73
|
+
if (args.json) {
|
|
74
|
+
console.log(JSON.stringify({ ok: false, pending: true, userId: args.userId, scope: args.scope, state: args.state }));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
(0, ui_1.info)(`Pending: would set consent[${args.scope}] = ${args.state} for ${args.userId}`);
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!res.ok) {
|
|
82
|
+
const msg = data.message || data.error || `HTTP ${res.status}`;
|
|
83
|
+
if (args.json)
|
|
84
|
+
console.log(JSON.stringify({ ok: false, error: msg }));
|
|
85
|
+
else
|
|
86
|
+
(0, ui_1.error)(msg);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
if (args.json)
|
|
90
|
+
console.log(JSON.stringify(data, null, 2));
|
|
91
|
+
else
|
|
92
|
+
(0, ui_1.success)(`Consent[${args.scope}] = ${args.state} for ${args.userId}`);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
if (args.json)
|
|
96
|
+
console.log(JSON.stringify({ ok: false, error: err.message }));
|
|
97
|
+
else
|
|
98
|
+
(0, ui_1.error)(`Failed: ${err.message}`);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// ── get ────────────────────────────────────────────────────────────────────
|
|
103
|
+
async function consentGet(args) {
|
|
104
|
+
if (!args.userId) {
|
|
105
|
+
(0, ui_1.error)('Usage: gurulu consent get --user-id <id>');
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
const profile = await loadProfileOrExit(args);
|
|
109
|
+
try {
|
|
110
|
+
const res = await (0, api_client_1.cliApi)(`/api/cli/consent/get?userId=${encodeURIComponent(args.userId)}`, { preloadedProfile: profile });
|
|
111
|
+
const data = await res.json().catch(() => ({}));
|
|
112
|
+
if (res.status === 404) {
|
|
113
|
+
emitFallbackNotice(args.json);
|
|
114
|
+
if (args.json)
|
|
115
|
+
console.log(JSON.stringify({ ok: false, pending: true, userId: args.userId, scopes: [] }));
|
|
116
|
+
else
|
|
117
|
+
(0, ui_1.info)(`Pending: would fetch consent scopes for ${args.userId}`);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!res.ok) {
|
|
121
|
+
const msg = data.message || data.error || `HTTP ${res.status}`;
|
|
122
|
+
if (args.json)
|
|
123
|
+
console.log(JSON.stringify({ ok: false, error: msg }));
|
|
124
|
+
else
|
|
125
|
+
(0, ui_1.error)(msg);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
if (args.json) {
|
|
129
|
+
console.log(JSON.stringify(data, null, 2));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const scopes = data.scopes || [];
|
|
133
|
+
if (scopes.length === 0) {
|
|
134
|
+
(0, ui_1.info)(`No consent records for ${args.userId}`);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
console.log((0, ui_1.bold)(`Consent scopes for ${args.userId}:`));
|
|
138
|
+
for (const s of scopes) {
|
|
139
|
+
const ts = s.updatedAt ? (0, ui_1.dim)(` (${s.updatedAt})`) : '';
|
|
140
|
+
(0, ui_1.step)(`${s.scope}: ${s.state}${ts}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
if (args.json)
|
|
145
|
+
console.log(JSON.stringify({ ok: false, error: err.message }));
|
|
146
|
+
else
|
|
147
|
+
(0, ui_1.error)(`Failed: ${err.message}`);
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// ── revoke ─────────────────────────────────────────────────────────────────
|
|
152
|
+
async function consentRevoke(args) {
|
|
153
|
+
if (!args.userId) {
|
|
154
|
+
(0, ui_1.error)('Usage: gurulu consent revoke --user-id <id>');
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
const profile = await loadProfileOrExit(args);
|
|
158
|
+
try {
|
|
159
|
+
const res = await (0, api_client_1.cliApi)('/api/cli/consent/revoke', {
|
|
160
|
+
method: 'POST',
|
|
161
|
+
body: JSON.stringify({ userId: args.userId }),
|
|
162
|
+
preloadedProfile: profile,
|
|
163
|
+
});
|
|
164
|
+
const data = await res.json().catch(() => ({}));
|
|
165
|
+
if (res.status === 404) {
|
|
166
|
+
emitFallbackNotice(args.json);
|
|
167
|
+
if (args.json)
|
|
168
|
+
console.log(JSON.stringify({ ok: false, pending: true, userId: args.userId }));
|
|
169
|
+
else
|
|
170
|
+
(0, ui_1.info)(`Pending: would deny all consent scopes for ${args.userId}`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!res.ok) {
|
|
174
|
+
const msg = data.message || data.error || `HTTP ${res.status}`;
|
|
175
|
+
if (args.json)
|
|
176
|
+
console.log(JSON.stringify({ ok: false, error: msg }));
|
|
177
|
+
else
|
|
178
|
+
(0, ui_1.error)(msg);
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
if (args.json)
|
|
182
|
+
console.log(JSON.stringify(data, null, 2));
|
|
183
|
+
else
|
|
184
|
+
(0, ui_1.success)(`All consent scopes revoked for ${args.userId}`);
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
if (args.json)
|
|
188
|
+
console.log(JSON.stringify({ ok: false, error: err.message }));
|
|
189
|
+
else
|
|
190
|
+
(0, ui_1.error)(`Failed: ${err.message}`);
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// ── check ─────────────────────────────────────────────────────────────────
|
|
195
|
+
async function consentCheck(args) {
|
|
196
|
+
if (!args.userId || !args.destination) {
|
|
197
|
+
(0, ui_1.error)('Usage: gurulu consent check --user-id <id> --destination <capi|ga4|...>');
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
const profile = await loadProfileOrExit(args);
|
|
201
|
+
try {
|
|
202
|
+
const data = await (0, api_client_1.cliApiJson)(`/api/cli/consent/check?userId=${encodeURIComponent(args.userId)}&destination=${encodeURIComponent(args.destination)}`, { preloadedProfile: profile });
|
|
203
|
+
if (args.json) {
|
|
204
|
+
console.log(JSON.stringify(data, null, 2));
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (data.allowed) {
|
|
208
|
+
(0, ui_1.success)(`Dispatch ALLOWED to ${args.destination} for ${args.userId}`);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
(0, ui_1.info)(`Dispatch DENIED to ${args.destination} for ${args.userId}${data.reason ? ` (${data.reason})` : ''}`);
|
|
212
|
+
}
|
|
213
|
+
// Exit code mirrors the boolean for shell scripting.
|
|
214
|
+
process.exit(data.allowed ? 0 : 2);
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
const msg = err.message || '';
|
|
218
|
+
// 404 from the API client means the endpoint isn't live yet.
|
|
219
|
+
if (/HTTP 404|Not Found/i.test(msg)) {
|
|
220
|
+
emitFallbackNotice(args.json);
|
|
221
|
+
if (args.json)
|
|
222
|
+
console.log(JSON.stringify({ ok: false, pending: true, allowed: null, userId: args.userId, destination: args.destination }));
|
|
223
|
+
else
|
|
224
|
+
(0, ui_1.info)(`Pending: would check consent for ${args.userId} → ${args.destination}`);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (args.json)
|
|
228
|
+
console.log(JSON.stringify({ ok: false, error: msg }));
|
|
229
|
+
else
|
|
230
|
+
(0, ui_1.error)(`Failed: ${msg}`);
|
|
231
|
+
process.exit(1);
|
|
232
|
+
}
|
|
233
|
+
}
|
package/dist/commands/db.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.dbCommand = dbCommand;
|
|
|
13
13
|
const config_1 = require("../config");
|
|
14
14
|
const api_client_1 = require("../api-client");
|
|
15
15
|
const ui_1 = require("../utils/ui");
|
|
16
|
+
const redact_1 = require("../utils/redact");
|
|
16
17
|
async function dbCommand(args) {
|
|
17
18
|
switch (args.action) {
|
|
18
19
|
case 'connect':
|
|
@@ -79,6 +80,13 @@ async function dbConnect(args) {
|
|
|
79
80
|
}
|
|
80
81
|
const effectivePort = port || (dbType === 'mysql' ? 3306 : 5432);
|
|
81
82
|
(0, ui_1.info)('Testing connection...');
|
|
83
|
+
// CLI@0.4.4 P0 security — never echo password to stdout/telemetry.
|
|
84
|
+
// The verbose/debug path used to dump the raw args object; route it through
|
|
85
|
+
// the redaction helper so password/token/secret keys are masked.
|
|
86
|
+
if (process.env.GURULU_DEBUG === '1') {
|
|
87
|
+
const safeArgs = (0, redact_1.redactSensitiveArgs)({ ...args });
|
|
88
|
+
console.log(`[debug] db connect args: ${(0, redact_1.safeStringifyArgs)(safeArgs)}`);
|
|
89
|
+
}
|
|
82
90
|
try {
|
|
83
91
|
// First call: test + potentially list tables
|
|
84
92
|
const body = {
|
|
@@ -5,10 +5,45 @@
|
|
|
5
5
|
* Sprint E SE-D — `gurulu identity identify|alias|merge` write surface
|
|
6
6
|
* (mirrors MCP `gurulu.identity.identify` / `.alias` / `.merge`).
|
|
7
7
|
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
8
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
42
|
exports.identityCommand = identityCommand;
|
|
10
43
|
const api_client_1 = require("../api-client");
|
|
11
44
|
const ui_1 = require("../utils/ui");
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
const path = __importStar(require("path"));
|
|
12
47
|
async function identityCommand(args) {
|
|
13
48
|
const action = args.action || '';
|
|
14
49
|
switch (action) {
|
|
@@ -24,9 +59,11 @@ async function identityCommand(args) {
|
|
|
24
59
|
return aliasCmd(args);
|
|
25
60
|
case 'merge':
|
|
26
61
|
return mergeCmd(args);
|
|
62
|
+
case 'bulk':
|
|
63
|
+
return bulkCmd(args);
|
|
27
64
|
default:
|
|
28
65
|
(0, ui_1.error)(`Unknown identity action: ${action}`);
|
|
29
|
-
(0, ui_1.info)('Usage: gurulu identity [decay stats|transfers list|cdc-sources list|identify|alias|merge]');
|
|
66
|
+
(0, ui_1.info)('Usage: gurulu identity [decay stats|transfers list|cdc-sources list|identify|alias|merge|bulk]');
|
|
30
67
|
process.exit(1);
|
|
31
68
|
}
|
|
32
69
|
}
|
|
@@ -140,6 +177,106 @@ async function aliasCmd(args) {
|
|
|
140
177
|
}
|
|
141
178
|
(0, ui_1.success)(`Aliased ${args.previousUserId} → ${args.newUserId}.`);
|
|
142
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* `gurulu identity bulk --site=<id> --file=<path> [--format=csv|json]
|
|
182
|
+
* [--resume-from=<offset>]`.
|
|
183
|
+
*
|
|
184
|
+
* Streams a CSV or JSON file to `/api/ingest/v1/identify/bulk` for
|
|
185
|
+
* server-side fan-out. The endpoint chunks records server-side (500 per
|
|
186
|
+
* tx); we only enforce a 10 000-record max here as a friendly preflight.
|
|
187
|
+
*
|
|
188
|
+
* `--resume-from` is forwarded as the `x-resume-from` header so a partial
|
|
189
|
+
* import can pick up where it left off without reuploading the whole
|
|
190
|
+
* file.
|
|
191
|
+
*/
|
|
192
|
+
async function bulkCmd(args) {
|
|
193
|
+
if (!args.site || !args.file) {
|
|
194
|
+
(0, ui_1.error)('Usage: gurulu identity bulk --site=<id> --file=<path> [--format=csv|json] [--resume-from=<offset>]');
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
const filePath = path.resolve(args.file);
|
|
198
|
+
if (!fs.existsSync(filePath)) {
|
|
199
|
+
(0, ui_1.error)(`File not found: ${filePath}`);
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
// Auto-detect format from extension when --format is not supplied.
|
|
203
|
+
let format = (args.format || '').toLowerCase();
|
|
204
|
+
if (!format) {
|
|
205
|
+
const ext = path.extname(filePath).slice(1).toLowerCase();
|
|
206
|
+
format = ext === 'csv' ? 'csv' : 'json';
|
|
207
|
+
}
|
|
208
|
+
if (format !== 'csv' && format !== 'json') {
|
|
209
|
+
(0, ui_1.error)('--format must be csv or json');
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
212
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
213
|
+
let body;
|
|
214
|
+
let contentType;
|
|
215
|
+
if (format === 'csv') {
|
|
216
|
+
contentType = 'text/csv';
|
|
217
|
+
body = raw;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
contentType = 'application/json';
|
|
221
|
+
// Allow files that are either { records: [...] } or a bare array.
|
|
222
|
+
let parsed;
|
|
223
|
+
try {
|
|
224
|
+
parsed = JSON.parse(raw);
|
|
225
|
+
}
|
|
226
|
+
catch (err) {
|
|
227
|
+
(0, ui_1.error)(`JSON file is invalid: ${err.message}`);
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
const records = Array.isArray(parsed)
|
|
231
|
+
? parsed
|
|
232
|
+
: Array.isArray(parsed?.records)
|
|
233
|
+
? parsed.records
|
|
234
|
+
: null;
|
|
235
|
+
if (!records) {
|
|
236
|
+
(0, ui_1.error)('JSON file must be an array or { records: [...] }');
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
239
|
+
body = JSON.stringify({ siteId: args.site, records });
|
|
240
|
+
}
|
|
241
|
+
const headers = { 'content-type': contentType };
|
|
242
|
+
if (args.resumeFrom && args.resumeFrom > 0) {
|
|
243
|
+
headers['x-resume-from'] = String(args.resumeFrom);
|
|
244
|
+
}
|
|
245
|
+
const url = `/api/ingest/v1/identify/bulk?site=${encodeURIComponent(args.site)}`;
|
|
246
|
+
let parsedBody;
|
|
247
|
+
try {
|
|
248
|
+
const res = await (0, api_client_1.cliApi)(url, {
|
|
249
|
+
profile: args.profile,
|
|
250
|
+
method: 'POST',
|
|
251
|
+
headers,
|
|
252
|
+
body,
|
|
253
|
+
});
|
|
254
|
+
const text = await res.text();
|
|
255
|
+
parsedBody = text ? JSON.parse(text) : {};
|
|
256
|
+
if (!res.ok) {
|
|
257
|
+
throw new api_client_1.CliApiError(res.status, parsedBody?.error || 'http_error', parsedBody?.message || `HTTP ${res.status}`, parsedBody);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
if (err instanceof api_client_1.CliApiError) {
|
|
262
|
+
(0, ui_1.error)(`Bulk import failed: ${err.code} (${err.message})`);
|
|
263
|
+
process.exit(1);
|
|
264
|
+
}
|
|
265
|
+
throw err;
|
|
266
|
+
}
|
|
267
|
+
if (args.json) {
|
|
268
|
+
process.stdout.write(JSON.stringify(parsedBody, null, 2) + '\n');
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
(0, ui_1.success)(`Bulk identify done. processed=${parsedBody.processed ?? 0} succeeded=${parsedBody.succeeded ?? 0} failed=${parsedBody.failed ?? 0}`);
|
|
272
|
+
if (parsedBody.errors && parsedBody.errors.length > 0) {
|
|
273
|
+
const sample = parsedBody.errors.slice(0, 5);
|
|
274
|
+
(0, ui_1.info)(`First ${sample.length} error(s):`);
|
|
275
|
+
for (const e of sample) {
|
|
276
|
+
process.stdout.write(` [${e.index}] ${e.message}\n`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
143
280
|
async function mergeCmd(args) {
|
|
144
281
|
if (!args.site || !args.canonicalId || !args.duplicateId) {
|
|
145
282
|
(0, ui_1.error)('Usage: gurulu identity merge --site=<id> --canonical-id=<winner> --duplicate-id=<loser>');
|
|
@@ -48,6 +48,8 @@ export interface InstallArgs {
|
|
|
48
48
|
authToken?: string;
|
|
49
49
|
/** Sprint E1.5 — explicit workspace path inside an npm/pnpm/yarn workspace repo. */
|
|
50
50
|
workspace?: string;
|
|
51
|
+
/** FA-1 P0-2 — override the tracker tag asset URL (self-hosted ingest). */
|
|
52
|
+
scriptSrc?: string;
|
|
51
53
|
}
|
|
52
54
|
export declare function resolveWorkspaceRoot(repoRoot: string, args: InstallArgs, deps: InstallDeps): Promise<string>;
|
|
53
55
|
export interface IntentPreSeedResult {
|
|
@@ -146,7 +148,7 @@ export interface InstallSummary {
|
|
|
146
148
|
framework: string | null;
|
|
147
149
|
planDiff: string;
|
|
148
150
|
filesChanged: number;
|
|
149
|
-
packageManager: 'pnpm' | 'yarn' | 'npm' | null;
|
|
151
|
+
packageManager: 'pnpm' | 'yarn' | 'npm' | 'bun' | null;
|
|
150
152
|
packageInstalled: boolean;
|
|
151
153
|
envKeysWritten: string[];
|
|
152
154
|
ingestOk: boolean | null;
|
|
@@ -189,13 +191,14 @@ export interface InstallSummary {
|
|
|
189
191
|
* or as a bundled package; falls back to GURULU_SCRIPTS_DIR env override).
|
|
190
192
|
*/
|
|
191
193
|
export declare function resolveScriptsDir(startDir?: string): string;
|
|
192
|
-
export declare function detectPackageManager(repoRoot: string): 'pnpm' | 'yarn' | 'npm';
|
|
193
|
-
export declare function packageInstallArgs(pm: 'pnpm' | 'yarn' | 'npm'): string[];
|
|
194
|
+
export declare function detectPackageManager(repoRoot: string): 'pnpm' | 'yarn' | 'npm' | 'bun';
|
|
195
|
+
export declare function packageInstallArgs(pm: 'pnpm' | 'yarn' | 'npm' | 'bun'): string[];
|
|
194
196
|
export interface EnvMergeResult {
|
|
195
197
|
file: string;
|
|
196
198
|
added: string[];
|
|
197
199
|
skipped: string[];
|
|
198
200
|
}
|
|
201
|
+
export declare function parseEnvFile(text: string): Set<string>;
|
|
199
202
|
export declare function mergeEnvFile(repoRoot: string, framework: string, vars: Record<string, string>): EnvMergeResult;
|
|
200
203
|
export declare function createDefaultDeps(scriptsDir: string): InstallDeps;
|
|
201
204
|
export declare function runInstallFlow(args: InstallArgs, deps: InstallDeps, scriptsDir: string): Promise<InstallSummary>;
|
|
@@ -217,6 +220,15 @@ export interface AuthenticatedInstallDeps {
|
|
|
217
220
|
/** Phase 18.6 — intent analyze + pre-seed integrations. */
|
|
218
221
|
intent?: IntentProposalDeps;
|
|
219
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>;
|
|
220
232
|
export declare function repoHashOf(repoRoot: string, remoteUrl?: string | null): string;
|
|
221
233
|
export declare function pickSite(sites: AuthenticatedInstallDeps['sites'], target?: string): {
|
|
222
234
|
id: string;
|
|
@@ -242,5 +254,6 @@ export declare function emitInstallTelemetry(deps: AuthenticatedInstallDeps, pay
|
|
|
242
254
|
ok: boolean;
|
|
243
255
|
quotaExceeded: boolean;
|
|
244
256
|
}>;
|
|
257
|
+
export declare function detectCiEnv(env?: NodeJS.ProcessEnv): boolean;
|
|
245
258
|
export declare function runAuthenticatedInstallFlow(args: InstallArgs, authDeps: AuthenticatedInstallDeps, installDeps: InstallDeps, scriptsDir: string): Promise<InstallSummary>;
|
|
246
259
|
export declare function installCommand(args: InstallArgs): Promise<void>;
|