@gurulu/cli 0.4.2 → 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/attribution.d.ts +22 -0
- package/dist/commands/attribution.js +111 -0
- package/dist/commands/consent.d.ts +27 -0
- package/dist/commands/consent.js +233 -0
- package/dist/commands/conversion-paths.d.ts +19 -0
- package/dist/commands/conversion-paths.js +55 -0
- package/dist/commands/db.js +8 -0
- package/dist/commands/errors.d.ts +27 -0
- package/dist/commands/errors.js +121 -0
- package/dist/commands/identity.d.ts +16 -0
- package/dist/commands/identity.js +222 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/install.d.ts +21 -3
- package/dist/commands/install.js +562 -26
- package/dist/commands/releases.d.ts +17 -0
- package/dist/commands/releases.js +54 -0
- package/dist/commands/replay.d.ts +18 -0
- package/dist/commands/replay.js +64 -0
- package/dist/commands/secrets.d.ts +19 -0
- package/dist/commands/secrets.js +145 -0
- package/dist/commands/skad.d.ts +18 -0
- package/dist/commands/skad.js +53 -0
- package/dist/commands/upgrade.d.ts +21 -0
- package/dist/commands/upgrade.js +183 -0
- package/dist/frameworks/detect.d.ts +1 -1
- package/dist/frameworks/detect.js +60 -0
- package/dist/index.js +225 -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/scripts/gurulu-agentic-install.lib.cjs +32 -4
- package/scripts/gurulu-agentic-install.mjs +10 -2
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,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sprint E SE-B — `gurulu attribution report|compare|channels`.
|
|
3
|
+
*
|
|
4
|
+
* Mirror of MCP tools `gurulu.attribution.report` / `.compare` / `.channels`.
|
|
5
|
+
* Hits new `/api/cli/attribution/*` proxy endpoints (CLI-auth, not session-auth)
|
|
6
|
+
* so the same surface is reachable from agents and humans.
|
|
7
|
+
*/
|
|
8
|
+
export interface AttributionArgs {
|
|
9
|
+
action?: string;
|
|
10
|
+
site?: string;
|
|
11
|
+
from?: string;
|
|
12
|
+
to?: string;
|
|
13
|
+
range?: string;
|
|
14
|
+
model?: string;
|
|
15
|
+
baselineModel?: string;
|
|
16
|
+
variantModel?: string;
|
|
17
|
+
conversionEvent?: string;
|
|
18
|
+
format?: string;
|
|
19
|
+
json?: boolean;
|
|
20
|
+
profile?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function attributionCommand(args: AttributionArgs): Promise<void>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Sprint E SE-B — `gurulu attribution report|compare|channels`.
|
|
4
|
+
*
|
|
5
|
+
* Mirror of MCP tools `gurulu.attribution.report` / `.compare` / `.channels`.
|
|
6
|
+
* Hits new `/api/cli/attribution/*` proxy endpoints (CLI-auth, not session-auth)
|
|
7
|
+
* so the same surface is reachable from agents and humans.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.attributionCommand = attributionCommand;
|
|
11
|
+
const api_client_1 = require("../api-client");
|
|
12
|
+
const ui_1 = require("../utils/ui");
|
|
13
|
+
async function attributionCommand(args) {
|
|
14
|
+
const action = args.action || '';
|
|
15
|
+
switch (action) {
|
|
16
|
+
case 'report':
|
|
17
|
+
return reportCmd(args);
|
|
18
|
+
case 'compare':
|
|
19
|
+
return compareCmd(args);
|
|
20
|
+
case 'channels':
|
|
21
|
+
return channelsCmd(args);
|
|
22
|
+
default:
|
|
23
|
+
(0, ui_1.error)(`Unknown attribution action: ${action}`);
|
|
24
|
+
(0, ui_1.info)('Usage: gurulu attribution [report|compare|channels] --site=<id> [...]');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function buildQuery(params) {
|
|
29
|
+
const usp = new URLSearchParams();
|
|
30
|
+
for (const [k, v] of Object.entries(params)) {
|
|
31
|
+
if (v === undefined || v === '' || v === null)
|
|
32
|
+
continue;
|
|
33
|
+
usp.set(k, String(v));
|
|
34
|
+
}
|
|
35
|
+
const s = usp.toString();
|
|
36
|
+
return s ? `?${s}` : '';
|
|
37
|
+
}
|
|
38
|
+
function emit(args, body, table) {
|
|
39
|
+
const format = args.format || (args.json ? 'json' : 'json');
|
|
40
|
+
if (format === 'table') {
|
|
41
|
+
process.stdout.write(table());
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
process.stdout.write(JSON.stringify(body, null, 2) + '\n');
|
|
45
|
+
}
|
|
46
|
+
async function reportCmd(args) {
|
|
47
|
+
if (!args.site) {
|
|
48
|
+
(0, ui_1.error)('Usage: gurulu attribution report --site=<id> [--from=ISO --to=ISO | --range=7d|30d|90d] [--model=...]');
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
const path = `/api/cli/attribution/report${buildQuery({
|
|
52
|
+
site: args.site,
|
|
53
|
+
from: args.from,
|
|
54
|
+
to: args.to,
|
|
55
|
+
range: args.range,
|
|
56
|
+
model: args.model,
|
|
57
|
+
conversionEvent: args.conversionEvent,
|
|
58
|
+
})}`;
|
|
59
|
+
const body = await (0, api_client_1.cliApiJson)(path, { profile: args.profile });
|
|
60
|
+
emit(args, body, () => {
|
|
61
|
+
const rows = body.results || [];
|
|
62
|
+
const out = [['CHANNEL', 'CREDIT', 'CONVERSIONS', 'REVENUE'].join('\t')];
|
|
63
|
+
for (const r of rows) {
|
|
64
|
+
out.push([r.channel ?? '-', r.credit ?? 0, r.conversions ?? 0, r.revenue ?? 0].join('\t'));
|
|
65
|
+
}
|
|
66
|
+
return out.join('\n') + '\n';
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async function compareCmd(args) {
|
|
70
|
+
if (!args.site || !args.baselineModel || !args.variantModel) {
|
|
71
|
+
(0, ui_1.error)('Usage: gurulu attribution compare --site=<id> --baseline-model=<m> --variant-model=<m>');
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
const path = `/api/cli/attribution/compare${buildQuery({
|
|
75
|
+
site: args.site,
|
|
76
|
+
baselineModel: args.baselineModel,
|
|
77
|
+
variantModel: args.variantModel,
|
|
78
|
+
from: args.from,
|
|
79
|
+
to: args.to,
|
|
80
|
+
range: args.range,
|
|
81
|
+
conversionEvent: args.conversionEvent,
|
|
82
|
+
})}`;
|
|
83
|
+
const body = await (0, api_client_1.cliApiJson)(path, { profile: args.profile });
|
|
84
|
+
emit(args, body, () => {
|
|
85
|
+
const rows = body.comparison || body.results || [];
|
|
86
|
+
const out = [['CHANNEL', 'BASELINE', 'VARIANT', 'DELTA'].join('\t')];
|
|
87
|
+
for (const r of rows) {
|
|
88
|
+
out.push([r.channel ?? '-', r.baseline ?? 0, r.variant ?? 0, r.delta ?? 0].join('\t'));
|
|
89
|
+
}
|
|
90
|
+
return out.join('\n') + '\n';
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async function channelsCmd(args) {
|
|
94
|
+
if (!args.site) {
|
|
95
|
+
(0, ui_1.error)('Usage: gurulu attribution channels --site=<id>');
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
const path = `/api/cli/attribution/channels${buildQuery({
|
|
99
|
+
site: args.site,
|
|
100
|
+
range: args.range,
|
|
101
|
+
})}`;
|
|
102
|
+
const body = await (0, api_client_1.cliApiJson)(path, { profile: args.profile });
|
|
103
|
+
emit(args, body, () => {
|
|
104
|
+
const rows = body.channels || [];
|
|
105
|
+
const out = [['CHANNEL', 'SESSIONS', 'CONVERSIONS'].join('\t')];
|
|
106
|
+
for (const r of rows) {
|
|
107
|
+
out.push([r.channel ?? '-', r.sessions ?? 0, r.conversions ?? 0].join('\t'));
|
|
108
|
+
}
|
|
109
|
+
return out.join('\n') + '\n';
|
|
110
|
+
});
|
|
111
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sprint E SE-B — `gurulu conversion-paths list`.
|
|
3
|
+
*
|
|
4
|
+
* Mirror of MCP `gurulu.conversion_paths.list`. Hits new
|
|
5
|
+
* `/api/cli/conversion-paths` proxy endpoint (CLI-auth).
|
|
6
|
+
*/
|
|
7
|
+
export interface ConversionPathsArgs {
|
|
8
|
+
action?: string;
|
|
9
|
+
site?: string;
|
|
10
|
+
from?: string;
|
|
11
|
+
to?: string;
|
|
12
|
+
range?: string;
|
|
13
|
+
conversionEvent?: string;
|
|
14
|
+
limit?: number;
|
|
15
|
+
format?: string;
|
|
16
|
+
json?: boolean;
|
|
17
|
+
profile?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function conversionPathsCommand(args: ConversionPathsArgs): Promise<void>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Sprint E SE-B — `gurulu conversion-paths list`.
|
|
4
|
+
*
|
|
5
|
+
* Mirror of MCP `gurulu.conversion_paths.list`. Hits new
|
|
6
|
+
* `/api/cli/conversion-paths` proxy endpoint (CLI-auth).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.conversionPathsCommand = conversionPathsCommand;
|
|
10
|
+
const api_client_1 = require("../api-client");
|
|
11
|
+
const ui_1 = require("../utils/ui");
|
|
12
|
+
async function conversionPathsCommand(args) {
|
|
13
|
+
const action = args.action || 'list';
|
|
14
|
+
switch (action) {
|
|
15
|
+
case 'list':
|
|
16
|
+
return listCmd(args);
|
|
17
|
+
default:
|
|
18
|
+
(0, ui_1.error)(`Unknown conversion-paths action: ${action}`);
|
|
19
|
+
(0, ui_1.info)('Usage: gurulu conversion-paths list --site=<id> [--range=30d] [--limit=20]');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function listCmd(args) {
|
|
24
|
+
if (!args.site) {
|
|
25
|
+
(0, ui_1.error)('Usage: gurulu conversion-paths list --site=<id> [--range=30d] [--limit=20]');
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
const usp = new URLSearchParams();
|
|
29
|
+
usp.set('site', args.site);
|
|
30
|
+
if (args.from)
|
|
31
|
+
usp.set('from', args.from);
|
|
32
|
+
if (args.to)
|
|
33
|
+
usp.set('to', args.to);
|
|
34
|
+
if (args.range)
|
|
35
|
+
usp.set('range', args.range);
|
|
36
|
+
if (args.conversionEvent)
|
|
37
|
+
usp.set('conversionEvent', args.conversionEvent);
|
|
38
|
+
if (args.limit)
|
|
39
|
+
usp.set('limit', String(args.limit));
|
|
40
|
+
const body = await (0, api_client_1.cliApiJson)(`/api/cli/conversion-paths?${usp.toString()}`, {
|
|
41
|
+
profile: args.profile,
|
|
42
|
+
});
|
|
43
|
+
if (args.format === 'table') {
|
|
44
|
+
const rows = body.paths || [];
|
|
45
|
+
process.stdout.write(['PATH', 'CONVERSIONS', 'REVENUE'].join('\t') + '\n');
|
|
46
|
+
for (const p of rows) {
|
|
47
|
+
const path = Array.isArray(p.path)
|
|
48
|
+
? p.path.join(' → ')
|
|
49
|
+
: String(p.path ?? '-');
|
|
50
|
+
process.stdout.write([path.slice(0, 80), p.conversions ?? 0, p.revenue ?? 0].join('\t') + '\n');
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
process.stdout.write(JSON.stringify(body, null, 2) + '\n');
|
|
55
|
+
}
|
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 = {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sprint E SE-B — `gurulu errors list|detail|resolve|mute`.
|
|
3
|
+
*
|
|
4
|
+
* Mirror of MCP `gurulu.errors.list` / `.detail` plus two new write tools
|
|
5
|
+
* (`.resolve`, `.mute`). Hits new `/api/cli/errors/*` proxy endpoints which
|
|
6
|
+
* use CLI-auth instead of the session-auth used by `/api/analytics/error-groups`.
|
|
7
|
+
*
|
|
8
|
+
* Note: `gurulu errors upload-sourcemap` and `upload-native-symbols` are
|
|
9
|
+
* documented aliases of `gurulu sourcemap upload [--platform=...]` — see
|
|
10
|
+
* `commands/sourcemap.ts`.
|
|
11
|
+
*/
|
|
12
|
+
export interface ErrorsArgs {
|
|
13
|
+
action?: string;
|
|
14
|
+
site?: string;
|
|
15
|
+
fingerprint?: string;
|
|
16
|
+
level?: string;
|
|
17
|
+
resolved?: string;
|
|
18
|
+
environment?: string;
|
|
19
|
+
releaseId?: string;
|
|
20
|
+
limit?: number;
|
|
21
|
+
duration?: string;
|
|
22
|
+
format?: string;
|
|
23
|
+
json?: boolean;
|
|
24
|
+
yes?: boolean;
|
|
25
|
+
profile?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function errorsCommand(args: ErrorsArgs): Promise<void>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Sprint E SE-B — `gurulu errors list|detail|resolve|mute`.
|
|
4
|
+
*
|
|
5
|
+
* Mirror of MCP `gurulu.errors.list` / `.detail` plus two new write tools
|
|
6
|
+
* (`.resolve`, `.mute`). Hits new `/api/cli/errors/*` proxy endpoints which
|
|
7
|
+
* use CLI-auth instead of the session-auth used by `/api/analytics/error-groups`.
|
|
8
|
+
*
|
|
9
|
+
* Note: `gurulu errors upload-sourcemap` and `upload-native-symbols` are
|
|
10
|
+
* documented aliases of `gurulu sourcemap upload [--platform=...]` — see
|
|
11
|
+
* `commands/sourcemap.ts`.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.errorsCommand = errorsCommand;
|
|
15
|
+
const api_client_1 = require("../api-client");
|
|
16
|
+
const ui_1 = require("../utils/ui");
|
|
17
|
+
const confirm_1 = require("../utils/confirm");
|
|
18
|
+
async function errorsCommand(args) {
|
|
19
|
+
const action = args.action || '';
|
|
20
|
+
switch (action) {
|
|
21
|
+
case 'list':
|
|
22
|
+
return listCmd(args);
|
|
23
|
+
case 'detail':
|
|
24
|
+
return detailCmd(args);
|
|
25
|
+
case 'resolve':
|
|
26
|
+
return resolveCmd(args);
|
|
27
|
+
case 'mute':
|
|
28
|
+
return muteCmd(args);
|
|
29
|
+
case 'upload-sourcemap':
|
|
30
|
+
case 'upload-native-symbols':
|
|
31
|
+
(0, ui_1.info)('Use `gurulu sourcemap upload [--platform=ios|android|web|server] ...` — these names are aliases.');
|
|
32
|
+
return;
|
|
33
|
+
default:
|
|
34
|
+
(0, ui_1.error)(`Unknown errors action: ${action}`);
|
|
35
|
+
(0, ui_1.info)('Usage: gurulu errors [list|detail|resolve|mute] --site=<id> [--fingerprint=<hash>] ...');
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function listCmd(args) {
|
|
40
|
+
if (!args.site) {
|
|
41
|
+
(0, ui_1.error)('Usage: gurulu errors list --site=<id> [--level=error|warning] [--resolved=false] [--limit=20]');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const usp = new URLSearchParams();
|
|
45
|
+
usp.set('site', args.site);
|
|
46
|
+
if (args.level)
|
|
47
|
+
usp.set('level', args.level);
|
|
48
|
+
if (args.resolved !== undefined)
|
|
49
|
+
usp.set('resolved', args.resolved);
|
|
50
|
+
if (args.environment)
|
|
51
|
+
usp.set('environment', args.environment);
|
|
52
|
+
if (args.releaseId)
|
|
53
|
+
usp.set('releaseId', args.releaseId);
|
|
54
|
+
if (args.limit)
|
|
55
|
+
usp.set('limit', String(args.limit));
|
|
56
|
+
const body = await (0, api_client_1.cliApiJson)(`/api/cli/errors?${usp.toString()}`, {
|
|
57
|
+
profile: args.profile,
|
|
58
|
+
});
|
|
59
|
+
if (args.format === 'table') {
|
|
60
|
+
const rows = body.groups || [];
|
|
61
|
+
process.stdout.write(['FINGERPRINT', 'COUNT', 'LEVEL', 'STATUS', 'TITLE'].join('\t') + '\n');
|
|
62
|
+
for (const g of rows) {
|
|
63
|
+
process.stdout.write([
|
|
64
|
+
(g.fingerprint || '').slice(0, 16),
|
|
65
|
+
g.count ?? 0,
|
|
66
|
+
g.level ?? '-',
|
|
67
|
+
g.status ?? 'unresolved',
|
|
68
|
+
String(g.title || '-').slice(0, 80),
|
|
69
|
+
].join('\t') + '\n');
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
process.stdout.write(JSON.stringify(body, null, 2) + '\n');
|
|
74
|
+
}
|
|
75
|
+
async function detailCmd(args) {
|
|
76
|
+
if (!args.site || !args.fingerprint) {
|
|
77
|
+
(0, ui_1.error)('Usage: gurulu errors detail --site=<id> --fingerprint=<hash>');
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
const path = `/api/cli/errors/${encodeURIComponent(args.fingerprint)}?site=${encodeURIComponent(args.site)}`;
|
|
81
|
+
const body = await (0, api_client_1.cliApiJson)(path, { profile: args.profile });
|
|
82
|
+
process.stdout.write(JSON.stringify(body, null, 2) + '\n');
|
|
83
|
+
}
|
|
84
|
+
async function resolveCmd(args) {
|
|
85
|
+
if (!args.site || !args.fingerprint) {
|
|
86
|
+
(0, ui_1.error)('Usage: gurulu errors resolve --site=<id> --fingerprint=<hash>');
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
const ok = await (0, confirm_1.promptConfirm)(`Mark error ${args.fingerprint.slice(0, 12)} as resolved?`, { yes: args.yes, defaultYes: true });
|
|
90
|
+
if (!ok) {
|
|
91
|
+
(0, ui_1.info)('Aborted.');
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const body = await (0, api_client_1.cliApiJson)(`/api/cli/errors/${encodeURIComponent(args.fingerprint)}/resolve`, {
|
|
95
|
+
profile: args.profile,
|
|
96
|
+
method: 'POST',
|
|
97
|
+
json: { siteId: args.site },
|
|
98
|
+
});
|
|
99
|
+
if (args.json) {
|
|
100
|
+
process.stdout.write(JSON.stringify(body, null, 2) + '\n');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
(0, ui_1.success)(`Resolved ${args.fingerprint.slice(0, 12)}.`);
|
|
104
|
+
}
|
|
105
|
+
async function muteCmd(args) {
|
|
106
|
+
if (!args.site || !args.fingerprint) {
|
|
107
|
+
(0, ui_1.error)('Usage: gurulu errors mute --site=<id> --fingerprint=<hash> [--duration=24h]');
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
const duration = args.duration || '24h';
|
|
111
|
+
const body = await (0, api_client_1.cliApiJson)(`/api/cli/errors/${encodeURIComponent(args.fingerprint)}/mute`, {
|
|
112
|
+
profile: args.profile,
|
|
113
|
+
method: 'POST',
|
|
114
|
+
json: { siteId: args.site, duration },
|
|
115
|
+
});
|
|
116
|
+
if (args.json) {
|
|
117
|
+
process.stdout.write(JSON.stringify(body, null, 2) + '\n');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
(0, ui_1.success)(`Muted ${args.fingerprint.slice(0, 12)} for ${duration}.`);
|
|
121
|
+
}
|