@abloatai/cli 0.52.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1030 -719
- package/package.json +3 -3
package/dist/cli.cjs
CHANGED
|
@@ -787,8 +787,8 @@ ${import_picocolors2.default.gray(d2)} ${t}
|
|
|
787
787
|
if (i) process.stdout.write(`${I2} ${l2}...`);
|
|
788
788
|
else if (t === "timer") process.stdout.write(`${I2} ${l2} ${O2(g2)}`);
|
|
789
789
|
else {
|
|
790
|
-
const
|
|
791
|
-
process.stdout.write(`${I2} ${l2}${
|
|
790
|
+
const z8 = ".".repeat(Math.floor(w2)).slice(0, 3);
|
|
791
|
+
process.stdout.write(`${I2} ${l2}${z8}`);
|
|
792
792
|
}
|
|
793
793
|
h2 = h2 + 1 < n.length ? h2 + 1 : 0, w2 = w2 < n.length ? w2 + 0.125 : 0;
|
|
794
794
|
}, r2);
|
|
@@ -3086,11 +3086,11 @@ var init_dbRole = __esm({
|
|
|
3086
3086
|
});
|
|
3087
3087
|
|
|
3088
3088
|
// src/controlPlane.ts
|
|
3089
|
-
function apiBaseUrl() {
|
|
3090
|
-
return (process.env.ABLO_API_URL ?? DEFAULT_URL)
|
|
3089
|
+
function apiBaseUrl(explicit) {
|
|
3090
|
+
return (0, import_baseUrl.normalizeAbloBaseUrl)(explicit ?? process.env.ABLO_API_URL ?? DEFAULT_URL);
|
|
3091
3091
|
}
|
|
3092
3092
|
async function requestControlPlane(req) {
|
|
3093
|
-
const base = (req.baseUrl
|
|
3093
|
+
const base = apiBaseUrl(req.baseUrl);
|
|
3094
3094
|
const url = `${base}/api${req.path}`;
|
|
3095
3095
|
const doFetch = req.fetchImpl ?? fetch;
|
|
3096
3096
|
const ctrl = req.timeoutMs !== void 0 ? new AbortController() : null;
|
|
@@ -3139,7 +3139,7 @@ async function tryControlPlane(req) {
|
|
|
3139
3139
|
return { ok: false, error: err instanceof import_errors4.AbloError ? err : new import_errors4.AbloError(String(err)) };
|
|
3140
3140
|
}
|
|
3141
3141
|
}
|
|
3142
|
-
var import_zod, import_errors4, import_hostedEndpoints, DEFAULT_URL;
|
|
3142
|
+
var import_zod, import_errors4, import_hostedEndpoints, import_baseUrl, DEFAULT_URL;
|
|
3143
3143
|
var init_controlPlane = __esm({
|
|
3144
3144
|
"src/controlPlane.ts"() {
|
|
3145
3145
|
"use strict";
|
|
@@ -3147,6 +3147,7 @@ var init_controlPlane = __esm({
|
|
|
3147
3147
|
import_zod = require("zod");
|
|
3148
3148
|
import_errors4 = require("@abloatai/transaction/errors");
|
|
3149
3149
|
import_hostedEndpoints = require("@abloatai/transaction/auth/hostedEndpoints");
|
|
3150
|
+
import_baseUrl = require("@abloatai/transaction/auth/baseUrl");
|
|
3150
3151
|
DEFAULT_URL = import_hostedEndpoints.ABLO_DEFAULT_BASE_URL;
|
|
3151
3152
|
}
|
|
3152
3153
|
});
|
|
@@ -3452,9 +3453,6 @@ var init_theme = __esm({
|
|
|
3452
3453
|
});
|
|
3453
3454
|
|
|
3454
3455
|
// src/projects.ts
|
|
3455
|
-
function apiUrl() {
|
|
3456
|
-
return (process.env.ABLO_API_URL ?? import_hostedEndpoints2.ABLO_DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
3457
|
-
}
|
|
3458
3456
|
function requireKey() {
|
|
3459
3457
|
const apiKey = resolveOrgManagementKey();
|
|
3460
3458
|
if (!apiKey) {
|
|
@@ -3712,16 +3710,17 @@ async function projects(argv) {
|
|
|
3712
3710
|
);
|
|
3713
3711
|
process.exit(1);
|
|
3714
3712
|
}
|
|
3715
|
-
var import_picocolors3,
|
|
3713
|
+
var import_picocolors3, import_wire, apiUrl, ANSI_ESCAPE, visibleLength, pad;
|
|
3716
3714
|
var init_projects = __esm({
|
|
3717
3715
|
"src/projects.ts"() {
|
|
3718
3716
|
"use strict";
|
|
3719
3717
|
init_cjs_shims();
|
|
3720
3718
|
import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
3721
3719
|
init_config();
|
|
3722
|
-
|
|
3720
|
+
init_controlPlane();
|
|
3723
3721
|
import_wire = require("@abloatai/transaction/wire");
|
|
3724
3722
|
init_theme();
|
|
3723
|
+
apiUrl = apiBaseUrl;
|
|
3725
3724
|
ANSI_ESCAPE = /\u001B\[[0-9;]*m/g;
|
|
3726
3725
|
visibleLength = (s) => s.replace(ANSI_ESCAPE, "").length;
|
|
3727
3726
|
pad = (s, width) => s + " ".repeat(Math.max(0, width - visibleLength(s)));
|
|
@@ -3971,7 +3970,7 @@ var init_observeCliError = __esm({
|
|
|
3971
3970
|
import_errorObservation = require("@abloatai/transaction/errorObservation");
|
|
3972
3971
|
import_errors5 = require("@abloatai/transaction/errors");
|
|
3973
3972
|
dsn = process.env.ABLO_CLI_SENTRY_DSN ?? "https://1ac154bff10b06836e1ea9de9e0d92f0@o4510928209772544.ingest.de.sentry.io/4511660691423312" ?? "";
|
|
3974
|
-
release = process.env.ABLO_CLI_RELEASE ?? "@abloatai/cli@0.
|
|
3973
|
+
release = process.env.ABLO_CLI_RELEASE ?? "@abloatai/cli@0.54.0";
|
|
3975
3974
|
initialized = false;
|
|
3976
3975
|
nativeProcessExit = process.exit.bind(process);
|
|
3977
3976
|
exitBoundaryInstalled = false;
|
|
@@ -4296,6 +4295,30 @@ var init_src2 = __esm({
|
|
|
4296
4295
|
}
|
|
4297
4296
|
});
|
|
4298
4297
|
|
|
4298
|
+
// src/cliEnvironment.ts
|
|
4299
|
+
function cliVersion() {
|
|
4300
|
+
return "0.54.0";
|
|
4301
|
+
}
|
|
4302
|
+
function cliOs() {
|
|
4303
|
+
const value = (0, import_node_os.platform)();
|
|
4304
|
+
return value === "darwin" || value === "linux" || value === "win32" ? value : "other";
|
|
4305
|
+
}
|
|
4306
|
+
function cliArchitecture() {
|
|
4307
|
+
const value = (0, import_node_os.arch)();
|
|
4308
|
+
return value === "arm64" || value === "x64" || value === "ia32" ? value : "other";
|
|
4309
|
+
}
|
|
4310
|
+
function nodeMajorVersion() {
|
|
4311
|
+
return Number(process.versions.node.split(".")[0]);
|
|
4312
|
+
}
|
|
4313
|
+
var import_node_os;
|
|
4314
|
+
var init_cliEnvironment = __esm({
|
|
4315
|
+
"src/cliEnvironment.ts"() {
|
|
4316
|
+
"use strict";
|
|
4317
|
+
init_cjs_shims();
|
|
4318
|
+
import_node_os = require("os");
|
|
4319
|
+
}
|
|
4320
|
+
});
|
|
4321
|
+
|
|
4299
4322
|
// src/telemetry.ts
|
|
4300
4323
|
function telemetryPath() {
|
|
4301
4324
|
return (0, import_node_path.join)(configDir(), "telemetry.json");
|
|
@@ -4456,17 +4479,6 @@ function environmentBlocker() {
|
|
|
4456
4479
|
function truthyEnvironmentValue(value) {
|
|
4457
4480
|
return value !== void 0 && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
4458
4481
|
}
|
|
4459
|
-
function cliVersion() {
|
|
4460
|
-
return "0.52.0";
|
|
4461
|
-
}
|
|
4462
|
-
function cliOs() {
|
|
4463
|
-
const value = (0, import_node_os.platform)();
|
|
4464
|
-
return value === "darwin" || value === "linux" || value === "win32" ? value : "other";
|
|
4465
|
-
}
|
|
4466
|
-
function cliArchitecture() {
|
|
4467
|
-
const value = (0, import_node_os.arch)();
|
|
4468
|
-
return value === "arm64" || value === "x64" || value === "ia32" ? value : "other";
|
|
4469
|
-
}
|
|
4470
4482
|
function durationBucket(durationMs) {
|
|
4471
4483
|
if (durationMs < 1e3) return "under_1s";
|
|
4472
4484
|
if (durationMs < 5e3) return "1s_to_5s";
|
|
@@ -4490,16 +4502,16 @@ function runTelemetryCommand(argv) {
|
|
|
4490
4502
|
if (status2.blockedBy) console.log(`Environment override: ${status2.blockedBy}`);
|
|
4491
4503
|
console.log(`Queued events: ${status2.queuedEvents}`);
|
|
4492
4504
|
}
|
|
4493
|
-
var import_node_crypto2, import_node_fs,
|
|
4505
|
+
var import_node_crypto2, import_node_fs, import_node_path, TELEMETRY_FILE_VERSION, MAX_QUEUED_EVENTS, MAX_FLUSH_EVENTS, DEFAULT_FLUSH_TIMEOUT_MS, flushInFlight;
|
|
4494
4506
|
var init_telemetry = __esm({
|
|
4495
4507
|
"src/telemetry.ts"() {
|
|
4496
4508
|
"use strict";
|
|
4497
4509
|
init_cjs_shims();
|
|
4498
4510
|
import_node_crypto2 = require("crypto");
|
|
4499
4511
|
import_node_fs = require("fs");
|
|
4500
|
-
import_node_os = require("os");
|
|
4501
4512
|
import_node_path = require("path");
|
|
4502
4513
|
init_src2();
|
|
4514
|
+
init_cliEnvironment();
|
|
4503
4515
|
init_controlPlane();
|
|
4504
4516
|
init_config();
|
|
4505
4517
|
TELEMETRY_FILE_VERSION = 1;
|
|
@@ -4559,7 +4571,7 @@ async function pushSchema(schema, args) {
|
|
|
4559
4571
|
function parsePushArgs(argv) {
|
|
4560
4572
|
let schemaPath = DEFAULT_SCHEMA_PATH;
|
|
4561
4573
|
let exportName = DEFAULT_EXPORT;
|
|
4562
|
-
let url
|
|
4574
|
+
let url;
|
|
4563
4575
|
let force = false;
|
|
4564
4576
|
let yes = false;
|
|
4565
4577
|
let dryRun = false;
|
|
@@ -4621,7 +4633,7 @@ function parsePushArgs(argv) {
|
|
|
4621
4633
|
throw new import_errors7.AbloValidationError(`unknown flag: ${arg}`, { code: "cli_invalid_arguments" });
|
|
4622
4634
|
}
|
|
4623
4635
|
}
|
|
4624
|
-
url = url
|
|
4636
|
+
url = apiBaseUrl(url);
|
|
4625
4637
|
return {
|
|
4626
4638
|
schemaPath,
|
|
4627
4639
|
exportName,
|
|
@@ -219755,11 +219767,11 @@ var require_commonjs2 = __commonJS({
|
|
|
219755
219767
|
if (pad2) {
|
|
219756
219768
|
const need = width - c.length;
|
|
219757
219769
|
if (need > 0) {
|
|
219758
|
-
const
|
|
219770
|
+
const z8 = new Array(need + 1).join("0");
|
|
219759
219771
|
if (i < 0) {
|
|
219760
|
-
c = "-" +
|
|
219772
|
+
c = "-" + z8 + c.slice(1);
|
|
219761
219773
|
} else {
|
|
219762
|
-
c =
|
|
219774
|
+
c = z8 + c;
|
|
219763
219775
|
}
|
|
219764
219776
|
}
|
|
219765
219777
|
}
|
|
@@ -283733,7 +283745,7 @@ Node text: ${this.#forgottenText}`;
|
|
|
283733
283745
|
|
|
283734
283746
|
// src/index.ts
|
|
283735
283747
|
init_cjs_shims();
|
|
283736
|
-
var
|
|
283748
|
+
var import_picocolors31 = __toESM(require_picocolors(), 1);
|
|
283737
283749
|
|
|
283738
283750
|
// src/migrate.ts
|
|
283739
283751
|
init_cjs_shims();
|
|
@@ -284086,11 +284098,289 @@ function truncate(text, max) {
|
|
|
284086
284098
|
return collapsed.length <= max ? collapsed : `${collapsed.slice(0, max - 1).trimEnd()}\u2026`;
|
|
284087
284099
|
}
|
|
284088
284100
|
|
|
284089
|
-
// src/
|
|
284101
|
+
// ../product-analytics/src/feedback.ts
|
|
284090
284102
|
init_cjs_shims();
|
|
284103
|
+
var import_node_crypto3 = require("crypto");
|
|
284104
|
+
var import_zod5 = require("zod");
|
|
284105
|
+
init_events();
|
|
284106
|
+
var AGENT_FEEDBACK_VERSION = 1;
|
|
284107
|
+
var MAX_FEEDBACK_SUMMARY_LENGTH = 200;
|
|
284108
|
+
var MAX_FEEDBACK_DETAIL_LENGTH = 4e3;
|
|
284109
|
+
var FEEDBACK_KINDS = ["bug", "docs", "feature", "friction"];
|
|
284110
|
+
var feedbackKindSchema = import_zod5.z.enum(FEEDBACK_KINDS);
|
|
284111
|
+
var FEEDBACK_KIND_DESCRIPTIONS = {
|
|
284112
|
+
bug: "It broke, or did something other than what it said it would.",
|
|
284113
|
+
docs: "The answer was missing from the docs, or the docs were wrong.",
|
|
284114
|
+
feature: "The thing you needed does not exist yet.",
|
|
284115
|
+
friction: "It worked, and it was harder than it should have been."
|
|
284116
|
+
};
|
|
284117
|
+
var shortToken2 = import_zod5.z.string().trim().min(1).max(100);
|
|
284118
|
+
var feedbackContextSchema = import_zod5.z.strictObject({
|
|
284119
|
+
/** The command in play, e.g. `push` — the registry name, not the full argv. */
|
|
284120
|
+
command: shortToken2.optional(),
|
|
284121
|
+
/** A code from the `ERROR_CODES` registry. The strongest clustering signal
|
|
284122
|
+
* there is: it groups reports by the failure, not by how it was worded. */
|
|
284123
|
+
errorCode: shortToken2.optional(),
|
|
284124
|
+
/** Which agent is reporting, e.g. `claude-code`. The world owns this set and
|
|
284125
|
+
* adds to it faster than we could ship an enum, so it stays an open token. */
|
|
284126
|
+
reportedBy: shortToken2.optional(),
|
|
284127
|
+
cliVersion: shortToken2.optional(),
|
|
284128
|
+
os: cliOsSchema.optional(),
|
|
284129
|
+
architecture: cliArchitectureSchema.optional(),
|
|
284130
|
+
nodeMajorVersion: import_zod5.z.number().int().min(18).max(100).optional()
|
|
284131
|
+
});
|
|
284132
|
+
var agentFeedbackSchema = import_zod5.z.strictObject({
|
|
284133
|
+
feedbackVersion: import_zod5.z.literal(AGENT_FEEDBACK_VERSION),
|
|
284134
|
+
/** Idempotency: a retried submission is the same report, not a second one. */
|
|
284135
|
+
submissionId: import_zod5.z.uuid(),
|
|
284136
|
+
occurredAt: import_zod5.z.iso.datetime({ offset: true }),
|
|
284137
|
+
kind: feedbackKindSchema,
|
|
284138
|
+
/** One line. This is the ticket title a human reads in a list. */
|
|
284139
|
+
summary: import_zod5.z.string().trim().min(1).max(MAX_FEEDBACK_SUMMARY_LENGTH),
|
|
284140
|
+
/** What happened, in the reporter's own words. */
|
|
284141
|
+
detail: import_zod5.z.string().trim().min(1).max(MAX_FEEDBACK_DETAIL_LENGTH).optional(),
|
|
284142
|
+
context: feedbackContextSchema.default({})
|
|
284143
|
+
});
|
|
284144
|
+
var agentFeedbackSubmissionSchema = import_zod5.z.strictObject({
|
|
284145
|
+
feedback: agentFeedbackSchema
|
|
284146
|
+
});
|
|
284147
|
+
var agentFeedbackReceiptSchema = import_zod5.z.strictObject({
|
|
284148
|
+
submissionId: import_zod5.z.uuid(),
|
|
284149
|
+
accepted: import_zod5.z.boolean(),
|
|
284150
|
+
duplicate: import_zod5.z.boolean(),
|
|
284151
|
+
clusterKey: import_zod5.z.string(),
|
|
284152
|
+
clusterCount: import_zod5.z.number().int().positive()
|
|
284153
|
+
});
|
|
284154
|
+
|
|
284155
|
+
// src/feedback.ts
|
|
284156
|
+
init_cjs_shims();
|
|
284157
|
+
var import_node_crypto4 = require("crypto");
|
|
284158
|
+
var import_node_fs2 = require("fs");
|
|
284091
284159
|
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
284160
|
+
init_dist2();
|
|
284161
|
+
var import_errors12 = require("@abloatai/transaction/errors");
|
|
284162
|
+
var import_errorObservation2 = require("@abloatai/transaction/errorObservation");
|
|
284163
|
+
init_cliEnvironment();
|
|
284164
|
+
init_controlPlane();
|
|
284165
|
+
init_config();
|
|
284166
|
+
init_theme();
|
|
284167
|
+
var KIND_WIDTH = Math.max(...FEEDBACK_KINDS.map((kind) => kind.length));
|
|
284168
|
+
var USAGE_LINES = FEEDBACK_KINDS.map(
|
|
284169
|
+
(kind) => ` npx ablo feedback ${kind.padEnd(KIND_WIDTH)} "<one line>" [--detail <text>]`
|
|
284170
|
+
).join("\n");
|
|
284171
|
+
var KIND_LINES = FEEDBACK_KINDS.map(
|
|
284172
|
+
(kind) => ` ${kind.padEnd(KIND_WIDTH + 2)}${FEEDBACK_KIND_DESCRIPTIONS[kind]}`
|
|
284173
|
+
).join("\n");
|
|
284174
|
+
var FEEDBACK_USAGE = ` ablo feedback \u2014 tell us what got in your way
|
|
284175
|
+
|
|
284176
|
+
Usage
|
|
284177
|
+
${USAGE_LINES}
|
|
284178
|
+
|
|
284179
|
+
Kinds
|
|
284180
|
+
${KIND_LINES}
|
|
284181
|
+
|
|
284182
|
+
Options
|
|
284183
|
+
--detail <text> What happened, at length. Use \`-\` to read stdin.
|
|
284184
|
+
--command <name> The command in play, e.g. \`push\`.
|
|
284185
|
+
--error-code <code> The code the failure printed, e.g. \`schema_unknown_model\`.
|
|
284186
|
+
--from <agent> Who is reporting, e.g. \`claude-code\`. Detected when omitted.
|
|
284187
|
+
--yes Send without the confirmation step (agents/CI).
|
|
284188
|
+
--json Print the receipt as JSON.
|
|
284189
|
+
|
|
284190
|
+
Connection strings, API keys, and addresses are removed from what you write
|
|
284191
|
+
before it is sent, and on a terminal you see the redacted text first. Nothing
|
|
284192
|
+
is read from your repository. Reports are grouped by what they describe, so
|
|
284193
|
+
the receipt tells you how many others have hit the same thing.`;
|
|
284194
|
+
function parseFeedbackArgs(argv) {
|
|
284195
|
+
const kindRaw = argv[0];
|
|
284196
|
+
const kind = feedbackKindSchema.safeParse(kindRaw);
|
|
284197
|
+
if (!kind.success) {
|
|
284198
|
+
throw new import_errors12.AbloValidationError(
|
|
284199
|
+
`\`ablo feedback\` needs a kind first: ${FEEDBACK_KINDS.join(", ")}.`,
|
|
284200
|
+
{ code: "cli_invalid_arguments" }
|
|
284201
|
+
);
|
|
284202
|
+
}
|
|
284203
|
+
const positional2 = [];
|
|
284204
|
+
let detail;
|
|
284205
|
+
let command;
|
|
284206
|
+
let errorCode;
|
|
284207
|
+
let from;
|
|
284208
|
+
let yes = false;
|
|
284209
|
+
let json = false;
|
|
284210
|
+
const flagValue = (flag2, value) => {
|
|
284211
|
+
if (value === void 0 || value.startsWith("--")) {
|
|
284212
|
+
throw new import_errors12.AbloValidationError(`\`${flag2}\` needs a value.`, {
|
|
284213
|
+
code: "cli_invalid_arguments"
|
|
284214
|
+
});
|
|
284215
|
+
}
|
|
284216
|
+
return value;
|
|
284217
|
+
};
|
|
284218
|
+
for (let i = 1; i < argv.length; i++) {
|
|
284219
|
+
const arg = argv[i];
|
|
284220
|
+
switch (arg) {
|
|
284221
|
+
case "--detail":
|
|
284222
|
+
detail = flagValue("--detail", argv[++i]);
|
|
284223
|
+
break;
|
|
284224
|
+
case "--command":
|
|
284225
|
+
command = flagValue("--command", argv[++i]);
|
|
284226
|
+
break;
|
|
284227
|
+
case "--error-code":
|
|
284228
|
+
errorCode = flagValue("--error-code", argv[++i]);
|
|
284229
|
+
break;
|
|
284230
|
+
case "--from":
|
|
284231
|
+
from = flagValue("--from", argv[++i]);
|
|
284232
|
+
break;
|
|
284233
|
+
case "--yes":
|
|
284234
|
+
yes = true;
|
|
284235
|
+
break;
|
|
284236
|
+
case "--json":
|
|
284237
|
+
json = true;
|
|
284238
|
+
break;
|
|
284239
|
+
default:
|
|
284240
|
+
if (arg !== void 0 && arg.startsWith("--")) {
|
|
284241
|
+
throw new import_errors12.AbloValidationError(`\`${arg}\` is not an option of this command.`, {
|
|
284242
|
+
code: "cli_invalid_arguments"
|
|
284243
|
+
});
|
|
284244
|
+
}
|
|
284245
|
+
if (arg !== void 0) positional2.push(arg);
|
|
284246
|
+
}
|
|
284247
|
+
}
|
|
284248
|
+
const summary = positional2.join(" ").trim();
|
|
284249
|
+
if (!summary) {
|
|
284250
|
+
throw new import_errors12.AbloValidationError(
|
|
284251
|
+
"Say in one line what got in your way, in quotes after the kind.",
|
|
284252
|
+
{ code: "cli_invalid_arguments" }
|
|
284253
|
+
);
|
|
284254
|
+
}
|
|
284255
|
+
if (summary.length > MAX_FEEDBACK_SUMMARY_LENGTH) {
|
|
284256
|
+
throw new import_errors12.AbloValidationError(
|
|
284257
|
+
`Keep the first line under ${MAX_FEEDBACK_SUMMARY_LENGTH} characters and put the rest in \`--detail\`.`,
|
|
284258
|
+
{ code: "cli_invalid_arguments" }
|
|
284259
|
+
);
|
|
284260
|
+
}
|
|
284261
|
+
return {
|
|
284262
|
+
kind: kind.data,
|
|
284263
|
+
summary,
|
|
284264
|
+
...detail !== void 0 ? { detail } : {},
|
|
284265
|
+
...command !== void 0 ? { command } : {},
|
|
284266
|
+
...errorCode !== void 0 ? { errorCode } : {},
|
|
284267
|
+
...from !== void 0 ? { from } : {},
|
|
284268
|
+
yes,
|
|
284269
|
+
json
|
|
284270
|
+
};
|
|
284271
|
+
}
|
|
284272
|
+
async function feedback(argv) {
|
|
284273
|
+
if (argv.includes("--help") || argv.includes("-h") || argv.length === 0) {
|
|
284274
|
+
console.log(FEEDBACK_USAGE);
|
|
284275
|
+
return;
|
|
284276
|
+
}
|
|
284277
|
+
const args = parseFeedbackArgs(argv);
|
|
284278
|
+
const detail = args.detail === "-" ? readStdin() : args.detail;
|
|
284279
|
+
if (detail !== void 0 && detail.length > MAX_FEEDBACK_DETAIL_LENGTH) {
|
|
284280
|
+
throw new import_errors12.AbloValidationError(
|
|
284281
|
+
`\`--detail\` holds up to ${MAX_FEEDBACK_DETAIL_LENGTH} characters.`,
|
|
284282
|
+
{ code: "cli_invalid_arguments" }
|
|
284283
|
+
);
|
|
284284
|
+
}
|
|
284285
|
+
const reporter = reportedBy(args.from);
|
|
284286
|
+
const report = agentFeedbackSchema.parse({
|
|
284287
|
+
feedbackVersion: AGENT_FEEDBACK_VERSION,
|
|
284288
|
+
submissionId: (0, import_node_crypto4.randomUUID)(),
|
|
284289
|
+
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
284290
|
+
kind: args.kind,
|
|
284291
|
+
summary: (0, import_errorObservation2.redactObservationString)(args.summary),
|
|
284292
|
+
...detail ? { detail: (0, import_errorObservation2.redactObservationString)(detail) } : {},
|
|
284293
|
+
context: {
|
|
284294
|
+
...args.command !== void 0 ? { command: args.command } : {},
|
|
284295
|
+
...args.errorCode !== void 0 ? { errorCode: args.errorCode } : {},
|
|
284296
|
+
...reporter !== void 0 ? { reportedBy: reporter } : {},
|
|
284297
|
+
cliVersion: cliVersion(),
|
|
284298
|
+
os: cliOs(),
|
|
284299
|
+
architecture: cliArchitecture(),
|
|
284300
|
+
nodeMajorVersion: nodeMajorVersion()
|
|
284301
|
+
}
|
|
284302
|
+
});
|
|
284303
|
+
const interactive = Boolean(process.stdout.isTTY && process.stdin.isTTY) && !args.yes;
|
|
284304
|
+
if (interactive) {
|
|
284305
|
+
printPreview(report);
|
|
284306
|
+
const proceed = await ye({ message: "Send this?" });
|
|
284307
|
+
if (pD(proceed) || !proceed) {
|
|
284308
|
+
console.log(` ${import_picocolors14.default.dim("Nothing sent.")}`);
|
|
284309
|
+
return;
|
|
284310
|
+
}
|
|
284311
|
+
}
|
|
284312
|
+
const managementKey = resolveManagementKey();
|
|
284313
|
+
const receipt = await requestControlPlane({
|
|
284314
|
+
path: "/v1/feedback",
|
|
284315
|
+
method: "POST",
|
|
284316
|
+
body: { feedback: report },
|
|
284317
|
+
...managementKey !== void 0 ? { apiKey: managementKey } : {},
|
|
284318
|
+
responseSchema: agentFeedbackReceiptSchema,
|
|
284319
|
+
timeoutMs: 1e4
|
|
284320
|
+
});
|
|
284321
|
+
if (args.json || process.env.ABLO_JSON === "1") {
|
|
284322
|
+
console.log(JSON.stringify(receipt, null, 2));
|
|
284323
|
+
return;
|
|
284324
|
+
}
|
|
284325
|
+
if (receipt.duplicate) {
|
|
284326
|
+
console.log(` ${import_picocolors14.default.dim("Already recorded \u2014 this report was sent before.")}`);
|
|
284327
|
+
return;
|
|
284328
|
+
}
|
|
284329
|
+
console.log(` ${import_picocolors14.default.green("\u2713")} Thank you. Recorded as ${import_picocolors14.default.dim(receipt.submissionId)}`);
|
|
284330
|
+
if (receipt.clusterCount > 1) {
|
|
284331
|
+
console.log(
|
|
284332
|
+
` ${import_picocolors14.default.dim(`${receipt.clusterCount} reports describe this same thing.`)}`
|
|
284333
|
+
);
|
|
284334
|
+
}
|
|
284335
|
+
}
|
|
284336
|
+
function printPreview(report) {
|
|
284337
|
+
console.log(`
|
|
284338
|
+
${brand("ablo")} ${import_picocolors14.default.dim("feedback")} ${import_picocolors14.default.dim(report.kind)}
|
|
284339
|
+
`);
|
|
284340
|
+
console.log(` ${report.summary}`);
|
|
284341
|
+
if (report.detail) {
|
|
284342
|
+
console.log();
|
|
284343
|
+
for (const line of report.detail.split("\n")) console.log(` ${import_picocolors14.default.dim(line)}`);
|
|
284344
|
+
}
|
|
284345
|
+
const context = [
|
|
284346
|
+
report.context.command ? `command ${report.context.command}` : null,
|
|
284347
|
+
report.context.errorCode ? `code ${report.context.errorCode}` : null,
|
|
284348
|
+
report.context.reportedBy ? `from ${report.context.reportedBy}` : null,
|
|
284349
|
+
report.context.cliVersion ? `cli ${report.context.cliVersion}` : null,
|
|
284350
|
+
report.context.os ?? null
|
|
284351
|
+
].filter((entry) => entry !== null);
|
|
284352
|
+
console.log(`
|
|
284353
|
+
${import_picocolors14.default.dim(context.join(" \xB7 "))}
|
|
284354
|
+
`);
|
|
284355
|
+
}
|
|
284356
|
+
function reportedBy(explicit) {
|
|
284357
|
+
if (explicit) return explicit;
|
|
284358
|
+
const configured = process.env.ABLO_AGENT?.trim();
|
|
284359
|
+
if (configured) return configured;
|
|
284360
|
+
if (process.env.CLAUDECODE || process.env.CLAUDE_CODE_ENTRYPOINT) return "claude-code";
|
|
284361
|
+
return void 0;
|
|
284362
|
+
}
|
|
284363
|
+
function readStdin() {
|
|
284364
|
+
if (process.stdin.isTTY) {
|
|
284365
|
+
throw new import_errors12.AbloValidationError(
|
|
284366
|
+
"`--detail -` reads piped input. Pass the text directly instead.",
|
|
284367
|
+
{ code: "cli_invalid_arguments" }
|
|
284368
|
+
);
|
|
284369
|
+
}
|
|
284370
|
+
try {
|
|
284371
|
+
return (0, import_node_fs2.readFileSync)(0, "utf8").trim();
|
|
284372
|
+
} catch {
|
|
284373
|
+
throw new import_errors12.AbloValidationError("Could not read `--detail` from stdin.", {
|
|
284374
|
+
code: "cli_invalid_arguments"
|
|
284375
|
+
});
|
|
284376
|
+
}
|
|
284377
|
+
}
|
|
284378
|
+
|
|
284379
|
+
// src/branches.ts
|
|
284380
|
+
init_cjs_shims();
|
|
284381
|
+
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
284092
284382
|
var import_branches = require("@abloatai/transaction/branches");
|
|
284093
|
-
|
|
284383
|
+
init_controlPlane();
|
|
284094
284384
|
init_config();
|
|
284095
284385
|
var BRANCH_USAGE = `Usage:
|
|
284096
284386
|
ablo branch list [--json]
|
|
@@ -284103,9 +284393,7 @@ var BRANCH_USAGE = `Usage:
|
|
|
284103
284393
|
|
|
284104
284394
|
Branches are scoped by the active project's management credential. Slugs are display handles;
|
|
284105
284395
|
automation should retain the immutable branch id returned by create/ensure.`;
|
|
284106
|
-
|
|
284107
|
-
return (baseUrl2 ?? process.env.ABLO_API_URL ?? import_hostedEndpoints3.ABLO_DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
284108
|
-
}
|
|
284396
|
+
var apiUrl2 = apiBaseUrl;
|
|
284109
284397
|
function requireKey2(explicit) {
|
|
284110
284398
|
const key = explicit ?? resolveManagementKey();
|
|
284111
284399
|
if (!key) {
|
|
@@ -284153,12 +284441,12 @@ function valueAfter(argv, flag2) {
|
|
|
284153
284441
|
function print(branches2) {
|
|
284154
284442
|
const slugWidth = Math.max(...branches2.map((branch) => branch.slug.length), 6);
|
|
284155
284443
|
for (const branch of branches2) {
|
|
284156
|
-
const marker = branch.root ?
|
|
284157
|
-
const kind = branch.root ?
|
|
284158
|
-
const state = branch.state === "ready" ?
|
|
284159
|
-
const expiry = branch.expires_at ?
|
|
284444
|
+
const marker = branch.root ? import_picocolors15.default.green("\u25CF") : import_picocolors15.default.dim("\u25CB");
|
|
284445
|
+
const kind = branch.root ? import_picocolors15.default.green("root") : import_picocolors15.default.dim(branch.kind);
|
|
284446
|
+
const state = branch.state === "ready" ? import_picocolors15.default.green(branch.state) : import_picocolors15.default.yellow(branch.state);
|
|
284447
|
+
const expiry = branch.expires_at ? import_picocolors15.default.dim(` expires ${new Date(branch.expires_at).toLocaleDateString()}`) : "";
|
|
284160
284448
|
console.log(
|
|
284161
|
-
` ${marker} ${branch.slug.padEnd(slugWidth)} ${kind.padEnd(12)} ${state.padEnd(14)} ${
|
|
284449
|
+
` ${marker} ${branch.slug.padEnd(slugWidth)} ${kind.padEnd(12)} ${state.padEnd(14)} ${import_picocolors15.default.dim(branch.id)}${expiry}`
|
|
284162
284450
|
);
|
|
284163
284451
|
}
|
|
284164
284452
|
}
|
|
@@ -284206,32 +284494,32 @@ async function readStatus(ref, context = {}) {
|
|
|
284206
284494
|
}
|
|
284207
284495
|
function printStatus(status2) {
|
|
284208
284496
|
const { branch, schema, storage, data_source: source } = status2;
|
|
284209
|
-
console.log(` ${
|
|
284497
|
+
console.log(` ${import_picocolors15.default.bold(branch.slug)} ${import_picocolors15.default.dim(branch.id)}`);
|
|
284210
284498
|
console.log(
|
|
284211
|
-
` ${
|
|
284499
|
+
` ${import_picocolors15.default.dim("state")} ${branch.state === "ready" ? import_picocolors15.default.green(branch.state) : import_picocolors15.default.yellow(branch.state)}`
|
|
284212
284500
|
);
|
|
284213
284501
|
console.log(
|
|
284214
|
-
` ${
|
|
284502
|
+
` ${import_picocolors15.default.dim("schema")} ${schema.active ? `${import_picocolors15.default.green("active")} ${import_picocolors15.default.dim(`v${schema.version ?? "?"} \xB7 ${schema.hash ?? "no hash"}`)}` : import_picocolors15.default.red("missing")}`
|
|
284215
284503
|
);
|
|
284216
284504
|
if (!branch.root) {
|
|
284217
|
-
const counts = schema.changes > 0 ?
|
|
284505
|
+
const counts = schema.changes > 0 ? import_picocolors15.default.dim(
|
|
284218
284506
|
` \xB7 ${schema.changes} changes, ${schema.warnings} warnings, ${schema.blockers} blockers`
|
|
284219
284507
|
) : "";
|
|
284220
284508
|
console.log(
|
|
284221
|
-
` ${
|
|
284509
|
+
` ${import_picocolors15.default.dim("parent")} ${import_picocolors15.default.bold(schema.parent_compatibility)}${counts}`
|
|
284222
284510
|
);
|
|
284223
284511
|
}
|
|
284224
284512
|
const sourceLabel = source ? `${source.connection} \xB7 ${source.host ?? "unknown host"}${source.database ? `/${source.database}` : ""} \xB7 ${source.status}` : storage.kind === "unbound" ? "not connected to a database" : storage.kind === "internal" ? `Ablo internal product storage \xB7 ${storage.implementation}` : storage.kind === "blocked" ? "storage configuration needs attention" : "customer database connection unavailable";
|
|
284225
|
-
console.log(` ${
|
|
284513
|
+
console.log(` ${import_picocolors15.default.dim("data")} ${sourceLabel}`);
|
|
284226
284514
|
if (status2.ready) {
|
|
284227
284515
|
console.log(`
|
|
284228
|
-
${
|
|
284516
|
+
${import_picocolors15.default.green("\u2713 ready")}`);
|
|
284229
284517
|
} else {
|
|
284230
284518
|
console.log(`
|
|
284231
|
-
${
|
|
284519
|
+
${import_picocolors15.default.red("\u2717 not ready")}`);
|
|
284232
284520
|
for (const blocker2 of status2.blockers) {
|
|
284233
|
-
console.log(` ${
|
|
284234
|
-
console.log(` ${
|
|
284521
|
+
console.log(` ${import_picocolors15.default.red("\u2022")} ${blocker2.problem}`);
|
|
284522
|
+
console.log(` ${import_picocolors15.default.dim(`Fix: ${blocker2.fix}`)}`);
|
|
284235
284523
|
}
|
|
284236
284524
|
}
|
|
284237
284525
|
}
|
|
@@ -284297,12 +284585,12 @@ async function branches(argv) {
|
|
|
284297
284585
|
)
|
|
284298
284586
|
);
|
|
284299
284587
|
} else {
|
|
284300
|
-
console.log(` ${
|
|
284301
|
-
console.log(
|
|
284588
|
+
console.log(` ${import_picocolors15.default.green("\u2713")} ${row.slug} ${import_picocolors15.default.dim(row.id)}`);
|
|
284589
|
+
console.log(import_picocolors15.default.dim(` parent ${row.parent_branch_id ?? "none"} \xB7 ${row.state}`));
|
|
284302
284590
|
if (credential) {
|
|
284303
284591
|
console.log(credential.api_key);
|
|
284304
284592
|
console.error(
|
|
284305
|
-
|
|
284593
|
+
import_picocolors15.default.dim(` expires ${credential.expires_at} \xB7 branch ${credential.branch_id}`)
|
|
284306
284594
|
);
|
|
284307
284595
|
}
|
|
284308
284596
|
}
|
|
@@ -284327,7 +284615,7 @@ async function branches(argv) {
|
|
|
284327
284615
|
throw new Error(message(response.body, `Could not delete branch (HTTP ${response.status}).`));
|
|
284328
284616
|
}
|
|
284329
284617
|
const row = import_branches.branchResponseSchema.parse(response.body);
|
|
284330
|
-
console.log(` ${
|
|
284618
|
+
console.log(` ${import_picocolors15.default.green("\u2713")} deleted ${row.slug} ${import_picocolors15.default.dim(row.id)}`);
|
|
284331
284619
|
return;
|
|
284332
284620
|
}
|
|
284333
284621
|
if (command === "credential") {
|
|
@@ -284339,7 +284627,7 @@ async function branches(argv) {
|
|
|
284339
284627
|
if (argv.includes("--json")) console.log(JSON.stringify(credential, null, 2));
|
|
284340
284628
|
else {
|
|
284341
284629
|
console.log(credential.api_key);
|
|
284342
|
-
console.error(
|
|
284630
|
+
console.error(import_picocolors15.default.dim(` expires ${credential.expires_at} \xB7 branch ${credential.branch_id}`));
|
|
284343
284631
|
}
|
|
284344
284632
|
return;
|
|
284345
284633
|
}
|
|
@@ -284348,18 +284636,18 @@ async function branches(argv) {
|
|
|
284348
284636
|
|
|
284349
284637
|
// src/branchDev.ts
|
|
284350
284638
|
init_cjs_shims();
|
|
284351
|
-
var
|
|
284639
|
+
var import_node_crypto5 = require("crypto");
|
|
284352
284640
|
var import_node_child_process = require("child_process");
|
|
284353
284641
|
var import_branches2 = require("@abloatai/transaction/branches");
|
|
284354
|
-
var
|
|
284642
|
+
var import_errors14 = require("@abloatai/transaction/errors");
|
|
284355
284643
|
init_config();
|
|
284356
284644
|
init_telemetry();
|
|
284357
284645
|
|
|
284358
284646
|
// src/dev.ts
|
|
284359
284647
|
init_cjs_shims();
|
|
284360
|
-
var
|
|
284648
|
+
var import_errors13 = require("@abloatai/transaction/errors");
|
|
284361
284649
|
var import_credentialPolicy2 = require("@abloatai/transaction/auth/credentialPolicy");
|
|
284362
|
-
var
|
|
284650
|
+
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
284363
284651
|
init_dist2();
|
|
284364
284652
|
var import_fs7 = require("fs");
|
|
284365
284653
|
var import_path5 = require("path");
|
|
@@ -284374,7 +284662,7 @@ var import_source3 = require("@abloatai/transaction/source");
|
|
|
284374
284662
|
function parseDevArgs(argv) {
|
|
284375
284663
|
let schemaPath = DEFAULT_SCHEMA_PATH;
|
|
284376
284664
|
let exportName = DEFAULT_EXPORT;
|
|
284377
|
-
let url
|
|
284665
|
+
let url;
|
|
284378
284666
|
let watchEnabled = false;
|
|
284379
284667
|
let local = false;
|
|
284380
284668
|
let sourcePath = "ablo/data-source.ts";
|
|
@@ -284403,10 +284691,10 @@ function parseDevArgs(argv) {
|
|
|
284403
284691
|
sourcePath = argv[++i] ?? sourcePath;
|
|
284404
284692
|
break;
|
|
284405
284693
|
default:
|
|
284406
|
-
throw new
|
|
284694
|
+
throw new import_errors13.AbloValidationError(`unknown flag: ${arg}`, { code: "cli_invalid_arguments" });
|
|
284407
284695
|
}
|
|
284408
284696
|
}
|
|
284409
|
-
url = url
|
|
284697
|
+
url = apiBaseUrl(url);
|
|
284410
284698
|
return {
|
|
284411
284699
|
schemaPath,
|
|
284412
284700
|
exportName,
|
|
@@ -284421,8 +284709,8 @@ function parseDevArgs(argv) {
|
|
|
284421
284709
|
async function loadLocalSourceHandler(sourcePath) {
|
|
284422
284710
|
const abs = (0, import_path5.resolve)(process.cwd(), sourcePath);
|
|
284423
284711
|
if (!(0, import_fs7.existsSync)(abs)) {
|
|
284424
|
-
throw new
|
|
284425
|
-
`local Data Source not found at ${
|
|
284712
|
+
throw new import_errors13.AbloValidationError(
|
|
284713
|
+
`local Data Source not found at ${import_picocolors16.default.bold(sourcePath)}. Add the signed Data Source handler described by ${import_picocolors16.default.bold("npx ablo docs data-sources")}, or pass ${import_picocolors16.default.bold("--source <path>")}.`,
|
|
284426
284714
|
{ code: "cli_invalid_arguments" }
|
|
284427
284715
|
);
|
|
284428
284716
|
}
|
|
@@ -284432,8 +284720,8 @@ async function loadLocalSourceHandler(sourcePath) {
|
|
|
284432
284720
|
const nested = mod.default && typeof mod.default === "object" ? mod.default : void 0;
|
|
284433
284721
|
const handler = mod.POST ?? nested?.POST;
|
|
284434
284722
|
if (typeof handler !== "function") {
|
|
284435
|
-
throw new
|
|
284436
|
-
`${
|
|
284723
|
+
throw new import_errors13.AbloValidationError(
|
|
284724
|
+
`${import_picocolors16.default.bold(sourcePath)} must export a ${import_picocolors16.default.bold("POST(request)")} Data Source handler.`,
|
|
284437
284725
|
{ code: "cli_invalid_arguments" }
|
|
284438
284726
|
);
|
|
284439
284727
|
}
|
|
@@ -284456,7 +284744,7 @@ async function registerLocalSource(args) {
|
|
|
284456
284744
|
});
|
|
284457
284745
|
if (!response.ok) {
|
|
284458
284746
|
const body = await response.text();
|
|
284459
|
-
throw new
|
|
284747
|
+
throw new import_errors13.AbloValidationError(
|
|
284460
284748
|
`Could not register the local Data Source (${response.status}): ${body}`,
|
|
284461
284749
|
{ code: "cli_invalid_arguments" }
|
|
284462
284750
|
);
|
|
@@ -284466,19 +284754,19 @@ function classifyKey(apiKey) {
|
|
|
284466
284754
|
if (!apiKey) {
|
|
284467
284755
|
return {
|
|
284468
284756
|
ok: false,
|
|
284469
|
-
reason: `No API key. Run ${
|
|
284757
|
+
reason: `No API key. Run ${import_picocolors16.default.bold("npx ablo login")}, or set a branch-bound ${import_picocolors16.default.bold("ABLO_API_KEY")}. ${import_picocolors16.default.bold("npx ablo dev")} prepares a development branch.`
|
|
284470
284758
|
};
|
|
284471
284759
|
}
|
|
284472
284760
|
if ((0, import_credentialPolicy2.classifyCredentialKind)(apiKey) === "secret") return { ok: true };
|
|
284473
284761
|
if ((0, import_credentialPolicy2.classifyCredentialKind)(apiKey) === "restricted") {
|
|
284474
284762
|
return {
|
|
284475
284763
|
ok: false,
|
|
284476
|
-
reason: `Authoring schema needs a branch-bound secret ${
|
|
284764
|
+
reason: `Authoring schema needs a branch-bound secret ${import_picocolors16.default.bold("sk_")} key. ${import_picocolors16.default.bold("npx ablo dev")} prepares a development branch. A restricted ${import_picocolors16.default.bold("rk_")} key carries only the scopes it was minted with.`
|
|
284477
284765
|
};
|
|
284478
284766
|
}
|
|
284479
284767
|
return {
|
|
284480
284768
|
ok: false,
|
|
284481
|
-
reason: `${
|
|
284769
|
+
reason: `${import_picocolors16.default.bold("ABLO_API_KEY")} is not a secret Ablo key. Expected a branch-bound ${import_picocolors16.default.bold("sk_\u2026")} credential. Run ${import_picocolors16.default.bold("npx ablo dev")} to prepare a development branch.`
|
|
284482
284770
|
};
|
|
284483
284771
|
}
|
|
284484
284772
|
function wireEnvLocal(apiKey, cwd = process.cwd(), projectId, branchId) {
|
|
@@ -284496,7 +284784,7 @@ ${projectLine ? `${projectLine}
|
|
|
284496
284784
|
` : ""}`,
|
|
284497
284785
|
{ mode: 384 }
|
|
284498
284786
|
);
|
|
284499
|
-
action = `Created ${
|
|
284787
|
+
action = `Created ${import_picocolors16.default.bold(".env.local")} with ${import_picocolors16.default.bold("ABLO_API_KEY")}`;
|
|
284500
284788
|
} else {
|
|
284501
284789
|
const content = (0, import_fs7.readFileSync)(envPath, "utf8");
|
|
284502
284790
|
const match = /^ABLO_API_KEY=(.*)$/m.exec(content);
|
|
@@ -284504,12 +284792,12 @@ ${projectLine ? `${projectLine}
|
|
|
284504
284792
|
if (!match) {
|
|
284505
284793
|
(0, import_fs7.appendFileSync)(envPath, `${content.endsWith("\n") || content.length === 0 ? "" : "\n"}${line}
|
|
284506
284794
|
`);
|
|
284507
|
-
action = `Added ${
|
|
284795
|
+
action = `Added ${import_picocolors16.default.bold("ABLO_API_KEY")} to ${import_picocolors16.default.bold(".env.local")}`;
|
|
284508
284796
|
} else if (existing === apiKey) {
|
|
284509
|
-
action = `${
|
|
284797
|
+
action = `${import_picocolors16.default.bold(".env.local")} already has this key`;
|
|
284510
284798
|
} else {
|
|
284511
284799
|
(0, import_fs7.writeFileSync)(envPath, content.replace(/^ABLO_API_KEY=.*$/m, line));
|
|
284512
|
-
action = `Updated ${
|
|
284800
|
+
action = `Updated ${import_picocolors16.default.bold("ABLO_API_KEY")} in ${import_picocolors16.default.bold(".env.local")} ${import_picocolors16.default.dim(`(was ${existing.slice(0, 12)}\u2026)`)}`;
|
|
284513
284801
|
}
|
|
284514
284802
|
if (projectLine) {
|
|
284515
284803
|
const next = (0, import_fs7.readFileSync)(envPath, "utf8");
|
|
@@ -284541,7 +284829,7 @@ ${projectLine ? `${projectLine}
|
|
|
284541
284829
|
`}.env.local
|
|
284542
284830
|
`
|
|
284543
284831
|
);
|
|
284544
|
-
gitignoreNote = ` Added ${
|
|
284832
|
+
gitignoreNote = ` Added ${import_picocolors16.default.bold(".env.local")} to ${import_picocolors16.default.bold(".gitignore")} so the key can't be committed.`;
|
|
284545
284833
|
}
|
|
284546
284834
|
return `${action}.${gitignoreNote}`;
|
|
284547
284835
|
}
|
|
@@ -284556,7 +284844,7 @@ async function runPush(schema, args) {
|
|
|
284556
284844
|
if (ok) {
|
|
284557
284845
|
return {
|
|
284558
284846
|
ok: true,
|
|
284559
|
-
message: body.unchanged ? `schema unchanged ${
|
|
284847
|
+
message: body.unchanged ? `schema unchanged ${import_picocolors16.default.dim(`(v${body.version})`)}` : `schema pushed (${args.planeLabel}) ${import_picocolors16.default.dim(`(v${body.version}, hash ${body.hash})`)}`
|
|
284560
284848
|
};
|
|
284561
284849
|
}
|
|
284562
284850
|
if (status2 === 409) {
|
|
@@ -284565,9 +284853,9 @@ async function runPush(schema, args) {
|
|
|
284565
284853
|
return {
|
|
284566
284854
|
ok: false,
|
|
284567
284855
|
message: [
|
|
284568
|
-
|
|
284569
|
-
...models.map((model) =>
|
|
284570
|
-
|
|
284856
|
+
import_picocolors16.default.bold("Replication reset required \u2014 a removed model still has live rows in this log plane."),
|
|
284857
|
+
...models.map((model) => import_picocolors16.default.yellow(` Live vanished model: ${String(model)}`)),
|
|
284858
|
+
import_picocolors16.default.dim(` Use ${import_picocolors16.default.bold("--rename old:new")} to carry it forward, or ${import_picocolors16.default.bold("--force")} to accept the drop/reset.`)
|
|
284571
284859
|
].join("\n")
|
|
284572
284860
|
};
|
|
284573
284861
|
}
|
|
@@ -284577,46 +284865,46 @@ async function runPush(schema, args) {
|
|
|
284577
284865
|
(s) => s.shadowed != null
|
|
284578
284866
|
);
|
|
284579
284867
|
const lines = [
|
|
284580
|
-
|
|
284868
|
+
import_picocolors16.default.bold("Incompatible schema change \u2014 not safe to apply as-is."),
|
|
284581
284869
|
"",
|
|
284582
|
-
...unexecutable.map((u2) =>
|
|
284583
|
-
...warnings.map((w2) =>
|
|
284870
|
+
...unexecutable.map((u2) => import_picocolors16.default.red(fmtSignal(u2))),
|
|
284871
|
+
...warnings.map((w2) => import_picocolors16.default.yellow(fmtSignal(w2))),
|
|
284584
284872
|
"",
|
|
284585
284873
|
...hasShadowed ? [
|
|
284586
|
-
|
|
284874
|
+
import_picocolors16.default.dim(
|
|
284587
284875
|
" These models exist in the baseline above but not in your push. Sandbox readers"
|
|
284588
284876
|
),
|
|
284589
|
-
|
|
284877
|
+
import_picocolors16.default.dim(
|
|
284590
284878
|
" fall back to the production schema until you push your own, so applying this drops them."
|
|
284591
284879
|
),
|
|
284592
284880
|
""
|
|
284593
284881
|
] : [],
|
|
284594
|
-
|
|
284595
|
-
` Fix: ${
|
|
284882
|
+
import_picocolors16.default.dim(
|
|
284883
|
+
` Fix: ${import_picocolors16.default.bold("ablo push --force")} to apply anyway, or ${import_picocolors16.default.bold("--rename old:new")} if you renamed a model.`
|
|
284596
284884
|
)
|
|
284597
284885
|
];
|
|
284598
284886
|
return { ok: false, message: lines.join("\n") };
|
|
284599
284887
|
}
|
|
284600
284888
|
if (status2 === 403) {
|
|
284601
284889
|
const serverSays = body.message ?? body.reason;
|
|
284602
|
-
const hint = schemaPushStorageHint(body.code) ?? (body.code === "database_role_cannot_enforce_rls" ? `Run ${
|
|
284890
|
+
const hint = schemaPushStorageHint(body.code) ?? (body.code === "database_role_cannot_enforce_rls" ? `Run ${import_picocolors16.default.bold("npx ablo migrate")} \u2014 it creates the scoped role for you (your DB credential never leaves this machine).` : `Schema authoring needs a branch-bound ${import_picocolors16.default.bold("sk_")} key with ${import_picocolors16.default.bold("schema:push")} \u2014 manage keys at ${import_picocolors16.default.cyan("https://abloatai.com")}.`);
|
|
284603
284891
|
return {
|
|
284604
284892
|
ok: false,
|
|
284605
284893
|
message: `${serverSays ?? "This key can't author schema (missing schema:push scope)."}
|
|
284606
|
-
` +
|
|
284894
|
+
` + import_picocolors16.default.dim(hint)
|
|
284607
284895
|
};
|
|
284608
284896
|
}
|
|
284609
284897
|
const serverMessage = String(body.message ?? body.reason ?? bodyText);
|
|
284610
284898
|
const storageHint = schemaPushStorageHint(body.code);
|
|
284611
284899
|
if (storageHint) {
|
|
284612
284900
|
return { ok: false, message: `${serverMessage}
|
|
284613
|
-
${
|
|
284901
|
+
${import_picocolors16.default.dim(storageHint)}` };
|
|
284614
284902
|
}
|
|
284615
284903
|
if (looksLikeCredentialRefusal(serverMessage)) {
|
|
284616
284904
|
const pooled = await poolerExplanation(apiBaseUrl(), args.apiKey);
|
|
284617
284905
|
if (pooled) {
|
|
284618
284906
|
return { ok: false, message: `${serverMessage}
|
|
284619
|
-
${
|
|
284907
|
+
${import_picocolors16.default.dim(pooled)}` };
|
|
284620
284908
|
}
|
|
284621
284909
|
}
|
|
284622
284910
|
return { ok: false, message: `Push failed (${status2}): ${serverMessage}` };
|
|
@@ -284626,32 +284914,32 @@ async function dev(argv, runtime = {}) {
|
|
|
284626
284914
|
try {
|
|
284627
284915
|
args = parseDevArgs(argv);
|
|
284628
284916
|
} catch (err) {
|
|
284629
|
-
console.error(
|
|
284917
|
+
console.error(import_picocolors16.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
284630
284918
|
process.exit(1);
|
|
284631
284919
|
}
|
|
284632
284920
|
if (runtime.apiKey) args.apiKey = runtime.apiKey;
|
|
284633
284921
|
else if (!args.apiKey) args.apiKey = resolveRuntimeApiKey("sandbox").key;
|
|
284634
284922
|
if (runtime.branch) args.planeLabel = runtime.branch.slug;
|
|
284635
284923
|
if (args.local && !args.watch) {
|
|
284636
|
-
throw new
|
|
284637
|
-
`${
|
|
284924
|
+
throw new import_errors13.AbloValidationError(
|
|
284925
|
+
`${import_picocolors16.default.bold("--local")} opens a long-lived secure connector and cannot be combined with ${import_picocolors16.default.bold("--no-watch")}.`,
|
|
284638
284926
|
{ code: "cli_invalid_arguments" }
|
|
284639
284927
|
);
|
|
284640
284928
|
}
|
|
284641
284929
|
const key = classifyKey(args.apiKey);
|
|
284642
284930
|
if (!key.ok) {
|
|
284643
|
-
console.error(
|
|
284931
|
+
console.error(import_picocolors16.default.red(` ${key.reason}`));
|
|
284644
284932
|
process.exit(1);
|
|
284645
284933
|
}
|
|
284646
284934
|
console.log(`
|
|
284647
|
-
${brand("ablo")} ${
|
|
284935
|
+
${brand("ablo")} ${import_picocolors16.default.dim("push")} ${import_picocolors16.default.dim(`(${args.planeLabel})`)}
|
|
284648
284936
|
`);
|
|
284649
284937
|
if (runtime.branch) {
|
|
284650
284938
|
console.log(
|
|
284651
|
-
` ${
|
|
284939
|
+
` ${import_picocolors16.default.dim("branch")} ${import_picocolors16.default.bold(runtime.branch.slug)} ${import_picocolors16.default.dim(runtime.branch.id)}`
|
|
284652
284940
|
);
|
|
284653
284941
|
console.log(
|
|
284654
|
-
` ${
|
|
284942
|
+
` ${import_picocolors16.default.dim("key")} temporary \xB7 expires ${runtime.branch.expiresAt}`
|
|
284655
284943
|
);
|
|
284656
284944
|
}
|
|
284657
284945
|
let localAbort = null;
|
|
@@ -284671,27 +284959,27 @@ async function dev(argv, runtime = {}) {
|
|
|
284671
284959
|
client: "ablo-dev",
|
|
284672
284960
|
onStatus(status2) {
|
|
284673
284961
|
if (status2 === "ready") {
|
|
284674
|
-
console.log(` ${
|
|
284962
|
+
console.log(` ${import_picocolors16.default.green("\u2713")} local Postgres connected through the secure reverse channel`);
|
|
284675
284963
|
}
|
|
284676
284964
|
},
|
|
284677
284965
|
onError(error) {
|
|
284678
|
-
console.error(
|
|
284966
|
+
console.error(import_picocolors16.default.yellow(` local connector: ${error instanceof Error ? error.message : String(error)}`));
|
|
284679
284967
|
}
|
|
284680
284968
|
});
|
|
284681
284969
|
void connector.run(localAbort.signal).catch((error) => {
|
|
284682
|
-
console.error(
|
|
284970
|
+
console.error(import_picocolors16.default.red(` local connector stopped: ${error instanceof Error ? error.message : String(error)}`));
|
|
284683
284971
|
});
|
|
284684
|
-
console.log(` ${
|
|
284972
|
+
console.log(` ${import_picocolors16.default.dim("source")} ${args.sourcePath} ${import_picocolors16.default.dim("(outbound connector; no public URL)")}`);
|
|
284685
284973
|
}
|
|
284686
284974
|
const schema = await loadSchema(args.schemaPath, args.exportName);
|
|
284687
284975
|
const modelCount = Object.keys(schema.models).length;
|
|
284688
284976
|
console.log(
|
|
284689
|
-
` ${
|
|
284977
|
+
` ${import_picocolors16.default.dim("schema")} ${import_picocolors16.default.bold(args.schemaPath)} ${import_picocolors16.default.dim(`(${modelCount} models, hash ${(0, import_schema6.schemaHash)(schema)})`)}`
|
|
284690
284978
|
);
|
|
284691
284979
|
if (!runtime.branch) {
|
|
284692
|
-
console.log(` ${
|
|
284980
|
+
console.log(` ${import_picocolors16.default.dim("key")} ${args.apiKey.slice(0, 12)}\u2026`);
|
|
284693
284981
|
}
|
|
284694
|
-
console.log(` ${
|
|
284982
|
+
console.log(` ${import_picocolors16.default.dim("api")} ${args.url}
|
|
284695
284983
|
`);
|
|
284696
284984
|
const s = Y2();
|
|
284697
284985
|
s.start("Pushing schema definition (development branch)");
|
|
@@ -284704,30 +284992,30 @@ async function dev(argv, runtime = {}) {
|
|
|
284704
284992
|
if (runtime.branch) {
|
|
284705
284993
|
console.log(
|
|
284706
284994
|
`
|
|
284707
|
-
${
|
|
284995
|
+
${import_picocolors16.default.green("\u2713")} ${wireEnvLocal(args.apiKey, process.cwd(), runtime.branch.projectId, runtime.branch.id)}`
|
|
284708
284996
|
);
|
|
284709
284997
|
console.log(
|
|
284710
|
-
` ${
|
|
284998
|
+
` ${import_picocolors16.default.dim(`Temporary branch credential expires ${runtime.branch.expiresAt}; rerun ablo dev to rotate it.`)}`
|
|
284711
284999
|
);
|
|
284712
285000
|
if (process.env.ABLO_API_KEY && process.env.ABLO_API_KEY !== args.apiKey) {
|
|
284713
285001
|
console.log(
|
|
284714
|
-
|
|
285002
|
+
import_picocolors16.default.yellow(
|
|
284715
285003
|
` An exported ABLO_API_KEY overrides .env.local for child processes; unset it before starting your app.`
|
|
284716
285004
|
)
|
|
284717
285005
|
);
|
|
284718
285006
|
}
|
|
284719
285007
|
} else if (process.env.ABLO_API_KEY) {
|
|
284720
285008
|
console.log(`
|
|
284721
|
-
${
|
|
285009
|
+
${import_picocolors16.default.green("\u2713")} ${import_picocolors16.default.bold("ABLO_API_KEY")} is set in this shell \u2014 the SDK reads it directly.`);
|
|
284722
285010
|
} else {
|
|
284723
285011
|
console.log(`
|
|
284724
|
-
${
|
|
284725
|
-
console.log(` ${
|
|
285012
|
+
${import_picocolors16.default.green("\u2713")} ${wireEnvLocal(args.apiKey)}`);
|
|
285013
|
+
console.log(` ${import_picocolors16.default.dim("Frameworks load it automatically; plain Node: node --env-file=.env.local app.ts")}`);
|
|
284726
285014
|
}
|
|
284727
285015
|
console.log(` Your app is wired for ${runtime.branch ? `branch ${runtime.branch.slug}` : "this branch"}.`);
|
|
284728
285016
|
if (!args.watch) return;
|
|
284729
285017
|
const abs = (0, import_path5.resolve)(process.cwd(), args.schemaPath);
|
|
284730
|
-
console.log(` ${
|
|
285018
|
+
console.log(` ${import_picocolors16.default.dim(`watching ${args.schemaPath} \u2026 (Ctrl-C to stop)`)}
|
|
284731
285019
|
`);
|
|
284732
285020
|
let timer2 = null;
|
|
284733
285021
|
let pushing = false;
|
|
@@ -284747,7 +285035,7 @@ async function dev(argv, runtime = {}) {
|
|
|
284747
285035
|
const r2 = await runPush(next, args);
|
|
284748
285036
|
s2.stop(r2.message, r2.ok ? 0 : 1);
|
|
284749
285037
|
} catch (err) {
|
|
284750
|
-
s2.stop(
|
|
285038
|
+
s2.stop(import_picocolors16.default.red(`schema reload failed: ${err instanceof Error ? err.message : String(err)}`), 1);
|
|
284751
285039
|
} finally {
|
|
284752
285040
|
pushing = false;
|
|
284753
285041
|
}
|
|
@@ -284756,7 +285044,7 @@ async function dev(argv, runtime = {}) {
|
|
|
284756
285044
|
watcher.close();
|
|
284757
285045
|
localAbort?.abort();
|
|
284758
285046
|
console.log(`
|
|
284759
|
-
${
|
|
285047
|
+
${import_picocolors16.default.dim("stopped.")}`);
|
|
284760
285048
|
process.exit(0);
|
|
284761
285049
|
};
|
|
284762
285050
|
process.on("SIGINT", stop);
|
|
@@ -284784,7 +285072,7 @@ function parseBranchDevArgs(argv) {
|
|
|
284784
285072
|
const arg = argv[index];
|
|
284785
285073
|
if (!arg) continue;
|
|
284786
285074
|
if (arg === "--no-branch") {
|
|
284787
|
-
throw new
|
|
285075
|
+
throw new import_errors14.AbloValidationError(
|
|
284788
285076
|
"--no-branch was removed: development is branch-isolated. Use --branch <slug> to select explicitly.",
|
|
284789
285077
|
{ code: "cli_invalid_arguments" }
|
|
284790
285078
|
);
|
|
@@ -284792,7 +285080,7 @@ function parseBranchDevArgs(argv) {
|
|
|
284792
285080
|
if (arg === "--branch") {
|
|
284793
285081
|
branchSlug = argv[++index];
|
|
284794
285082
|
if (!branchSlug) {
|
|
284795
|
-
throw new
|
|
285083
|
+
throw new import_errors14.AbloValidationError("--branch requires a slug", {
|
|
284796
285084
|
code: "cli_invalid_arguments"
|
|
284797
285085
|
});
|
|
284798
285086
|
}
|
|
@@ -284801,7 +285089,7 @@ function parseBranchDevArgs(argv) {
|
|
|
284801
285089
|
if (arg === "--branch-ttl-hours") {
|
|
284802
285090
|
const value = Number(argv[++index]);
|
|
284803
285091
|
if (!Number.isInteger(value) || value < 1 || value > 168) {
|
|
284804
|
-
throw new
|
|
285092
|
+
throw new import_errors14.AbloValidationError("--branch-ttl-hours must be between 1 and 168", {
|
|
284805
285093
|
code: "cli_invalid_arguments"
|
|
284806
285094
|
});
|
|
284807
285095
|
}
|
|
@@ -284819,12 +285107,12 @@ function parseBranchDevArgs(argv) {
|
|
|
284819
285107
|
function branchSlugFromRef(ref) {
|
|
284820
285108
|
const base = ref.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
284821
285109
|
if (!base) {
|
|
284822
|
-
throw new
|
|
285110
|
+
throw new import_errors14.AbloValidationError(`cannot derive an Ablo branch slug from "${ref}"`, {
|
|
284823
285111
|
code: "cli_invalid_arguments"
|
|
284824
285112
|
});
|
|
284825
285113
|
}
|
|
284826
285114
|
const nonRoot = base === "production" ? "production-dev" : base;
|
|
284827
|
-
const shortened = nonRoot.length <= 40 ? nonRoot : `${nonRoot.slice(0, 31).replace(/-+$/g, "")}-${(0,
|
|
285115
|
+
const shortened = nonRoot.length <= 40 ? nonRoot : `${nonRoot.slice(0, 31).replace(/-+$/g, "")}-${(0, import_node_crypto5.createHash)("sha256").update(nonRoot).digest("hex").slice(0, 8)}`;
|
|
284828
285116
|
return import_branches2.branchSlugSchema.parse(shortened);
|
|
284829
285117
|
}
|
|
284830
285118
|
function gitBranch() {
|
|
@@ -284841,7 +285129,7 @@ function gitBranch() {
|
|
|
284841
285129
|
function discoverBranchRef(explicit, env = process.env, readGitBranch = gitBranch) {
|
|
284842
285130
|
const value = explicit ?? env.ABLO_BRANCH ?? env.GITHUB_HEAD_REF ?? env.GITHUB_REF_NAME ?? env.VERCEL_GIT_COMMIT_REF ?? env.CI_COMMIT_REF_NAME ?? readGitBranch();
|
|
284843
285131
|
if (!value) {
|
|
284844
|
-
throw new
|
|
285132
|
+
throw new import_errors14.AbloValidationError(
|
|
284845
285133
|
"Could not determine the Git branch. Pass --branch <slug> or set ABLO_BRANCH.",
|
|
284846
285134
|
{ code: "cli_invalid_arguments" }
|
|
284847
285135
|
);
|
|
@@ -284859,18 +285147,18 @@ async function runBranchDev(argv, dependencies = {}) {
|
|
|
284859
285147
|
const slug = branchSlugFromRef(ref);
|
|
284860
285148
|
const managementKey = dependencies.resolveManagementKey?.() ?? resolveManagementKey();
|
|
284861
285149
|
if (!managementKey) {
|
|
284862
|
-
throw new
|
|
285150
|
+
throw new import_errors14.AbloValidationError(
|
|
284863
285151
|
"Creating a development branch needs a project management credential. Run `npx ablo login` or set ABLO_MANAGEMENT_KEY.",
|
|
284864
285152
|
{ code: "cli_invalid_arguments" }
|
|
284865
285153
|
);
|
|
284866
285154
|
}
|
|
284867
285155
|
if (!managementKey.startsWith("mk_")) {
|
|
284868
|
-
throw new
|
|
285156
|
+
throw new import_errors14.AbloValidationError(
|
|
284869
285157
|
"Branch creation needs the active project management credential (mk_\u2026). Run `npx ablo login` to refresh it.",
|
|
284870
285158
|
{ code: "cli_invalid_arguments" }
|
|
284871
285159
|
);
|
|
284872
285160
|
}
|
|
284873
|
-
const baseUrl2 = valueAfter2(parsed.devArgv, "--url")
|
|
285161
|
+
const baseUrl2 = apiBaseUrl(valueAfter2(parsed.devArgv, "--url"));
|
|
284874
285162
|
const result = await (dependencies.bootstrap ?? ensureBranchCredential)({
|
|
284875
285163
|
slug,
|
|
284876
285164
|
apiKey: managementKey,
|
|
@@ -284893,8 +285181,8 @@ async function runBranchDev(argv, dependencies = {}) {
|
|
|
284893
285181
|
|
|
284894
285182
|
// src/whoami.ts
|
|
284895
285183
|
init_cjs_shims();
|
|
284896
|
-
var
|
|
284897
|
-
var
|
|
285184
|
+
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
285185
|
+
var import_errors15 = require("@abloatai/transaction/errors");
|
|
284898
285186
|
init_config();
|
|
284899
285187
|
init_controlPlane();
|
|
284900
285188
|
|
|
@@ -284969,7 +285257,7 @@ function parseWhoamiArgs(argv) {
|
|
|
284969
285257
|
case "--key": {
|
|
284970
285258
|
const value = argv[++i];
|
|
284971
285259
|
if (!value || value.startsWith("--")) {
|
|
284972
|
-
throw new
|
|
285260
|
+
throw new import_errors15.AbloValidationError("`--key` needs a credential value.", {
|
|
284973
285261
|
code: "cli_invalid_arguments"
|
|
284974
285262
|
});
|
|
284975
285263
|
}
|
|
@@ -284979,12 +285267,12 @@ function parseWhoamiArgs(argv) {
|
|
|
284979
285267
|
case "--key-env": {
|
|
284980
285268
|
const value = argv[++i];
|
|
284981
285269
|
if (!value || value.startsWith("--")) {
|
|
284982
|
-
throw new
|
|
285270
|
+
throw new import_errors15.AbloValidationError("`--key-env` needs an environment variable name.", {
|
|
284983
285271
|
code: "cli_invalid_arguments"
|
|
284984
285272
|
});
|
|
284985
285273
|
}
|
|
284986
285274
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value)) {
|
|
284987
|
-
throw new
|
|
285275
|
+
throw new import_errors15.AbloValidationError(
|
|
284988
285276
|
`\`${value}\` is not a valid environment variable name.`,
|
|
284989
285277
|
{ code: "cli_invalid_arguments" }
|
|
284990
285278
|
);
|
|
@@ -284993,13 +285281,13 @@ function parseWhoamiArgs(argv) {
|
|
|
284993
285281
|
break;
|
|
284994
285282
|
}
|
|
284995
285283
|
default:
|
|
284996
|
-
throw new
|
|
285284
|
+
throw new import_errors15.AbloValidationError(`unknown whoami flag: ${arg}`, {
|
|
284997
285285
|
code: "cli_invalid_arguments"
|
|
284998
285286
|
});
|
|
284999
285287
|
}
|
|
285000
285288
|
}
|
|
285001
285289
|
if (key && keyEnv) {
|
|
285002
|
-
throw new
|
|
285290
|
+
throw new import_errors15.AbloValidationError("Choose one credential source: `--key` or `--key-env`.", {
|
|
285003
285291
|
code: "cli_invalid_arguments"
|
|
285004
285292
|
});
|
|
285005
285293
|
}
|
|
@@ -285010,7 +285298,7 @@ function selectWhoamiCredential(args, cwd = process.cwd()) {
|
|
|
285010
285298
|
if (args.keyEnv) {
|
|
285011
285299
|
const found = readProjectEnvVariable(args.keyEnv, cwd);
|
|
285012
285300
|
if (!found) {
|
|
285013
|
-
throw new
|
|
285301
|
+
throw new import_errors15.AbloAuthenticationError(
|
|
285014
285302
|
`${args.keyEnv} is not set in the process environment, .env.local, or .env.`,
|
|
285015
285303
|
{ code: "cli_api_key_missing" }
|
|
285016
285304
|
);
|
|
@@ -285039,7 +285327,7 @@ function selectWhoamiCredential(args, cwd = process.cwd()) {
|
|
|
285039
285327
|
};
|
|
285040
285328
|
}
|
|
285041
285329
|
const ambient = ambientEnvKeyNote();
|
|
285042
|
-
throw new
|
|
285330
|
+
throw new import_errors15.AbloAuthenticationError(
|
|
285043
285331
|
`No credential found. Run \`ablo login\`, set ABLO_API_KEY, or pass \`--key-env <NAME>\`.${ambient ? `
|
|
285044
285332
|
|
|
285045
285333
|
${ambient}` : ""}`,
|
|
@@ -285057,7 +285345,7 @@ async function whoami(argv) {
|
|
|
285057
285345
|
});
|
|
285058
285346
|
const confirmed = target.confirmed;
|
|
285059
285347
|
if (!confirmed) {
|
|
285060
|
-
throw new
|
|
285348
|
+
throw new import_errors15.AbloAuthenticationError(
|
|
285061
285349
|
"The server did not confirm an identity for this credential.",
|
|
285062
285350
|
{ code: "identity_resolve_failed" }
|
|
285063
285351
|
);
|
|
@@ -285094,18 +285382,18 @@ async function whoami(argv) {
|
|
|
285094
285382
|
return;
|
|
285095
285383
|
}
|
|
285096
285384
|
console.log(`
|
|
285097
|
-
${brand("ablo")} ${
|
|
285385
|
+
${brand("ablo")} ${import_picocolors17.default.dim("whoami")}
|
|
285098
285386
|
`);
|
|
285099
285387
|
console.log(
|
|
285100
|
-
` ${
|
|
285388
|
+
` ${import_picocolors17.default.dim("key")} ${selected.key.slice(0, 12)}\u2026 ${import_picocolors17.default.dim(`(${selected.source} \xB7 ${capability.label})`)}`
|
|
285101
285389
|
);
|
|
285102
|
-
console.log(` ${
|
|
285390
|
+
console.log(` ${import_picocolors17.default.dim("org")} ${import_picocolors17.default.dim(confirmed.organizationId)}`);
|
|
285103
285391
|
console.log(
|
|
285104
|
-
` ${
|
|
285392
|
+
` ${import_picocolors17.default.dim("project")} ${import_picocolors17.default.bold(projectLabel)}${project ? ` ${import_picocolors17.default.dim(`(${project.id})`)}` : ""}`
|
|
285105
285393
|
);
|
|
285106
|
-
console.log(` ${
|
|
285394
|
+
console.log(` ${import_picocolors17.default.dim("acts on")} ${import_picocolors17.default.bold(actsOn)}`);
|
|
285107
285395
|
console.log(`
|
|
285108
|
-
${
|
|
285396
|
+
${import_picocolors17.default.green("\u2713")} ${import_picocolors17.default.dim("credential accepted; target confirmed by the server")}
|
|
285109
285397
|
`);
|
|
285110
285398
|
}
|
|
285111
285399
|
|
|
@@ -285114,14 +285402,14 @@ init_push();
|
|
|
285114
285402
|
|
|
285115
285403
|
// src/setup/run.ts
|
|
285116
285404
|
init_cjs_shims();
|
|
285117
|
-
var
|
|
285118
|
-
var
|
|
285405
|
+
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
285406
|
+
var import_errors16 = require("@abloatai/transaction/errors");
|
|
285119
285407
|
init_theme();
|
|
285120
285408
|
|
|
285121
285409
|
// src/setup/discover.ts
|
|
285122
285410
|
init_cjs_shims();
|
|
285123
|
-
var
|
|
285124
|
-
var
|
|
285411
|
+
var import_node_fs3 = require("fs");
|
|
285412
|
+
var import_node_crypto6 = require("crypto");
|
|
285125
285413
|
var import_node_child_process2 = require("child_process");
|
|
285126
285414
|
var import_node_path2 = require("path");
|
|
285127
285415
|
init_controlPlane();
|
|
@@ -285129,18 +285417,18 @@ init_config();
|
|
|
285129
285417
|
|
|
285130
285418
|
// src/doctor.ts
|
|
285131
285419
|
init_cjs_shims();
|
|
285132
|
-
var
|
|
285420
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
285133
285421
|
init_theme();
|
|
285134
285422
|
init_controlPlane();
|
|
285135
285423
|
init_config();
|
|
285136
285424
|
init_target();
|
|
285137
285425
|
init_readiness();
|
|
285138
285426
|
function render(check2) {
|
|
285139
|
-
const mark = check2.state === "ok" ?
|
|
285427
|
+
const mark = check2.state === "ok" ? import_picocolors18.default.green("\u2713") : check2.state === "fail" ? import_picocolors18.default.red("\u2717") : import_picocolors18.default.dim("\u2013");
|
|
285140
285428
|
console.log(
|
|
285141
|
-
` ${mark} ${check2.label.padEnd(10)} ${check2.state === "fail" ? check2.detail :
|
|
285429
|
+
` ${mark} ${check2.label.padEnd(10)} ${check2.state === "fail" ? check2.detail : import_picocolors18.default.dim(check2.detail)}`
|
|
285142
285430
|
);
|
|
285143
|
-
if (check2.fix) console.log(` ${" ".repeat(11)}${
|
|
285431
|
+
if (check2.fix) console.log(` ${" ".repeat(11)}${import_picocolors18.default.dim(`\u2192 ${check2.fix}`)}`);
|
|
285144
285432
|
}
|
|
285145
285433
|
async function ping(apiUrl3) {
|
|
285146
285434
|
const ctrl = new AbortController();
|
|
@@ -285309,24 +285597,24 @@ async function inspectDoctor(options = {}) {
|
|
|
285309
285597
|
}
|
|
285310
285598
|
function renderDoctorReport(report) {
|
|
285311
285599
|
console.log(`
|
|
285312
|
-
${brand("ablo")} ${
|
|
285600
|
+
${brand("ablo")} ${import_picocolors18.default.dim("doctor")}
|
|
285313
285601
|
`);
|
|
285314
285602
|
for (const check2 of report.checks) render(check2);
|
|
285315
285603
|
console.log();
|
|
285316
285604
|
if (report.failed > 0) {
|
|
285317
285605
|
console.log(
|
|
285318
|
-
` ${
|
|
285606
|
+
` ${import_picocolors18.default.red("\u2717")} ${import_picocolors18.default.bold(`${report.failed} problem${report.failed === 1 ? "" : "s"}`)}` + import_picocolors18.default.dim(report.skipped > 0 ? `, ${report.skipped} check${report.skipped === 1 ? "" : "s"} skipped` : "")
|
|
285319
285607
|
);
|
|
285320
285608
|
console.log(
|
|
285321
|
-
|
|
285609
|
+
import_picocolors18.default.dim(" Fix them in the order above \u2014 an earlier one often explains a later one.")
|
|
285322
285610
|
);
|
|
285323
285611
|
} else if (report.skipped > 0) {
|
|
285324
285612
|
console.log(
|
|
285325
|
-
` ${
|
|
285613
|
+
` ${import_picocolors18.default.yellow("?")} ${import_picocolors18.default.dim(`nothing is blocking a write, but ${report.skipped} check${report.skipped === 1 ? "" : "s"} could not be run`)}`
|
|
285326
285614
|
);
|
|
285327
285615
|
} else {
|
|
285328
285616
|
console.log(
|
|
285329
|
-
` ${
|
|
285617
|
+
` ${import_picocolors18.default.green("\u2713")} ${import_picocolors18.default.dim("write infrastructure is ready \u2014 your database constraints and row-level policies still apply")}`
|
|
285330
285618
|
);
|
|
285331
285619
|
}
|
|
285332
285620
|
console.log();
|
|
@@ -285339,10 +285627,10 @@ async function doctor() {
|
|
|
285339
285627
|
|
|
285340
285628
|
// src/setup/contracts.ts
|
|
285341
285629
|
init_cjs_shims();
|
|
285342
|
-
var
|
|
285630
|
+
var import_zod6 = require("zod");
|
|
285343
285631
|
var SETUP_CONTRACT_VERSION = 1;
|
|
285344
|
-
var setupEvidenceSchema =
|
|
285345
|
-
source:
|
|
285632
|
+
var setupEvidenceSchema = import_zod6.z.object({
|
|
285633
|
+
source: import_zod6.z.enum([
|
|
285346
285634
|
"filesystem",
|
|
285347
285635
|
"package_manifest",
|
|
285348
285636
|
"git",
|
|
@@ -285352,32 +285640,32 @@ var setupEvidenceSchema = import_zod5.z.object({
|
|
|
285352
285640
|
"inference",
|
|
285353
285641
|
"user"
|
|
285354
285642
|
]),
|
|
285355
|
-
locator:
|
|
285356
|
-
detail:
|
|
285357
|
-
observedAt:
|
|
285643
|
+
locator: import_zod6.z.string().min(1).optional(),
|
|
285644
|
+
detail: import_zod6.z.string().min(1),
|
|
285645
|
+
observedAt: import_zod6.z.iso.datetime()
|
|
285358
285646
|
}).strict();
|
|
285359
|
-
var setupFactSchema =
|
|
285360
|
-
key:
|
|
285361
|
-
value:
|
|
285362
|
-
confidence:
|
|
285363
|
-
evidence:
|
|
285647
|
+
var setupFactSchema = import_zod6.z.object({
|
|
285648
|
+
key: import_zod6.z.string().min(1),
|
|
285649
|
+
value: import_zod6.z.json(),
|
|
285650
|
+
confidence: import_zod6.z.enum(["high", "medium", "low"]),
|
|
285651
|
+
evidence: import_zod6.z.array(setupEvidenceSchema).min(1)
|
|
285364
285652
|
}).strict();
|
|
285365
|
-
var setupCoordinationAdoptionDispositionSchema =
|
|
285653
|
+
var setupCoordinationAdoptionDispositionSchema = import_zod6.z.enum([
|
|
285366
285654
|
"existing_state_reuse_candidate",
|
|
285367
285655
|
"model_migration_required",
|
|
285368
285656
|
"coordination_path_undetermined"
|
|
285369
285657
|
]);
|
|
285370
|
-
var setupDecisionSchema =
|
|
285371
|
-
id:
|
|
285372
|
-
question:
|
|
285373
|
-
status:
|
|
285374
|
-
choices:
|
|
285375
|
-
value:
|
|
285376
|
-
label:
|
|
285377
|
-
consequence:
|
|
285658
|
+
var setupDecisionSchema = import_zod6.z.object({
|
|
285659
|
+
id: import_zod6.z.string().min(1),
|
|
285660
|
+
question: import_zod6.z.string().min(1),
|
|
285661
|
+
status: import_zod6.z.enum(["unresolved", "resolved", "not_applicable"]),
|
|
285662
|
+
choices: import_zod6.z.array(import_zod6.z.object({
|
|
285663
|
+
value: import_zod6.z.string().min(1),
|
|
285664
|
+
label: import_zod6.z.string().min(1),
|
|
285665
|
+
consequence: import_zod6.z.string().min(1)
|
|
285378
285666
|
}).strict()),
|
|
285379
|
-
selected:
|
|
285380
|
-
reason:
|
|
285667
|
+
selected: import_zod6.z.string().min(1).optional(),
|
|
285668
|
+
reason: import_zod6.z.string().min(1)
|
|
285381
285669
|
}).strict().superRefine((decision, ctx) => {
|
|
285382
285670
|
if (decision.status === "resolved" && decision.selected === void 0) {
|
|
285383
285671
|
ctx.addIssue({ code: "custom", message: "A resolved decision needs a selected value." });
|
|
@@ -285386,17 +285674,17 @@ var setupDecisionSchema = import_zod5.z.object({
|
|
|
285386
285674
|
ctx.addIssue({ code: "custom", message: "The selected value must be one of the choices." });
|
|
285387
285675
|
}
|
|
285388
285676
|
});
|
|
285389
|
-
var setupMutationClassSchema =
|
|
285677
|
+
var setupMutationClassSchema = import_zod6.z.enum([
|
|
285390
285678
|
"read_only",
|
|
285391
285679
|
"local_write",
|
|
285392
285680
|
"remote_write",
|
|
285393
285681
|
"database_write"
|
|
285394
285682
|
]);
|
|
285395
|
-
var setupApprovalClassSchema =
|
|
285396
|
-
var setupActionSchema =
|
|
285397
|
-
id:
|
|
285398
|
-
stepId:
|
|
285399
|
-
kind:
|
|
285683
|
+
var setupApprovalClassSchema = import_zod6.z.enum(["none", "review", "explicit"]);
|
|
285684
|
+
var setupActionSchema = import_zod6.z.object({
|
|
285685
|
+
id: import_zod6.z.string().min(1),
|
|
285686
|
+
stepId: import_zod6.z.string().min(1),
|
|
285687
|
+
kind: import_zod6.z.enum([
|
|
285400
285688
|
"inspect_repository",
|
|
285401
285689
|
"analyze_compatibility",
|
|
285402
285690
|
"select_application",
|
|
@@ -285411,20 +285699,20 @@ var setupActionSchema = import_zod5.z.object({
|
|
|
285411
285699
|
"verify",
|
|
285412
285700
|
"run_canary"
|
|
285413
285701
|
]),
|
|
285414
|
-
summary:
|
|
285702
|
+
summary: import_zod6.z.string().min(1),
|
|
285415
285703
|
mutation: setupMutationClassSchema,
|
|
285416
285704
|
approval: setupApprovalClassSchema,
|
|
285417
|
-
executor:
|
|
285418
|
-
status:
|
|
285419
|
-
blockedBy:
|
|
285420
|
-
paths:
|
|
285421
|
-
preconditions:
|
|
285705
|
+
executor: import_zod6.z.enum(["deterministic", "agent", "user"]).default("deterministic"),
|
|
285706
|
+
status: import_zod6.z.enum(["planned", "blocked", "not_needed"]),
|
|
285707
|
+
blockedBy: import_zod6.z.array(import_zod6.z.string().min(1)).default([]),
|
|
285708
|
+
paths: import_zod6.z.array(import_zod6.z.string().min(1)).default([]),
|
|
285709
|
+
preconditions: import_zod6.z.array(import_zod6.z.string().min(1)).default([])
|
|
285422
285710
|
}).strict();
|
|
285423
|
-
var setupMutationSiteSchema =
|
|
285424
|
-
path:
|
|
285425
|
-
line:
|
|
285426
|
-
kind:
|
|
285427
|
-
operation:
|
|
285711
|
+
var setupMutationSiteSchema = import_zod6.z.object({
|
|
285712
|
+
path: import_zod6.z.string().min(1),
|
|
285713
|
+
line: import_zod6.z.number().int().positive(),
|
|
285714
|
+
kind: import_zod6.z.enum(["prisma", "drizzle", "sql", "http", "ablo"]),
|
|
285715
|
+
operation: import_zod6.z.enum([
|
|
285428
285716
|
"create",
|
|
285429
285717
|
"update",
|
|
285430
285718
|
"delete",
|
|
@@ -285435,35 +285723,35 @@ var setupMutationSiteSchema = import_zod5.z.object({
|
|
|
285435
285723
|
"sql_write",
|
|
285436
285724
|
"http_write"
|
|
285437
285725
|
]),
|
|
285438
|
-
modelHint:
|
|
285439
|
-
confidence:
|
|
285726
|
+
modelHint: import_zod6.z.string().min(1).nullable(),
|
|
285727
|
+
confidence: import_zod6.z.enum(["high", "medium", "low"])
|
|
285440
285728
|
}).strict();
|
|
285441
|
-
var setupDatabaseColumnSchema =
|
|
285442
|
-
table:
|
|
285443
|
-
column:
|
|
285444
|
-
dataType:
|
|
285445
|
-
nullable:
|
|
285446
|
-
defaultExpression:
|
|
285447
|
-
generatedBy:
|
|
285729
|
+
var setupDatabaseColumnSchema = import_zod6.z.object({
|
|
285730
|
+
table: import_zod6.z.string().min(1),
|
|
285731
|
+
column: import_zod6.z.string().min(1),
|
|
285732
|
+
dataType: import_zod6.z.string().min(1),
|
|
285733
|
+
nullable: import_zod6.z.boolean(),
|
|
285734
|
+
defaultExpression: import_zod6.z.string().min(1).nullable(),
|
|
285735
|
+
generatedBy: import_zod6.z.enum(["application", "database"]).default("application")
|
|
285448
285736
|
}).strict();
|
|
285449
|
-
var setupCompatibilityBlockerCodeSchema =
|
|
285737
|
+
var setupCompatibilityBlockerCodeSchema = import_zod6.z.enum([
|
|
285450
285738
|
"database_schema_unavailable",
|
|
285451
285739
|
"identity_type_unsupported",
|
|
285452
285740
|
"stable_identity_missing"
|
|
285453
285741
|
]);
|
|
285454
|
-
var setupDatabaseMappingSchema =
|
|
285455
|
-
table:
|
|
285456
|
-
field:
|
|
285457
|
-
column:
|
|
285458
|
-
databaseType:
|
|
285742
|
+
var setupDatabaseMappingSchema = import_zod6.z.object({
|
|
285743
|
+
table: import_zod6.z.string().min(1),
|
|
285744
|
+
field: import_zod6.z.enum(["id", "organizationId", "createdBy"]),
|
|
285745
|
+
column: import_zod6.z.string().min(1).nullable(),
|
|
285746
|
+
databaseType: import_zod6.z.enum([
|
|
285459
285747
|
"text",
|
|
285460
285748
|
"uuid",
|
|
285461
285749
|
"bigint"
|
|
285462
285750
|
]).nullable(),
|
|
285463
|
-
generatedBy:
|
|
285464
|
-
status:
|
|
285465
|
-
reason:
|
|
285466
|
-
evidence:
|
|
285751
|
+
generatedBy: import_zod6.z.enum(["application", "ablo", "database"]).nullable(),
|
|
285752
|
+
status: import_zod6.z.enum(["ready", "review_required"]),
|
|
285753
|
+
reason: import_zod6.z.string().min(1),
|
|
285754
|
+
evidence: import_zod6.z.array(setupEvidenceSchema).min(1)
|
|
285467
285755
|
}).strict().superRefine((mapping, ctx) => {
|
|
285468
285756
|
if (mapping.column === null && (mapping.databaseType !== null || mapping.generatedBy !== null)) {
|
|
285469
285757
|
ctx.addIssue({
|
|
@@ -285478,53 +285766,53 @@ var setupDatabaseMappingSchema = import_zod5.z.object({
|
|
|
285478
285766
|
});
|
|
285479
285767
|
}
|
|
285480
285768
|
});
|
|
285481
|
-
var setupCompatibilityRemediationSchema =
|
|
285482
|
-
kind:
|
|
285483
|
-
summary:
|
|
285769
|
+
var setupCompatibilityRemediationSchema = import_zod6.z.object({
|
|
285770
|
+
kind: import_zod6.z.enum(["migration", "translation", "retain_direct_path", "unsupported"]),
|
|
285771
|
+
summary: import_zod6.z.string().min(1)
|
|
285484
285772
|
}).strict();
|
|
285485
|
-
var setupCompatibilityBlockerSchema =
|
|
285773
|
+
var setupCompatibilityBlockerSchema = import_zod6.z.object({
|
|
285486
285774
|
code: setupCompatibilityBlockerCodeSchema,
|
|
285487
|
-
table:
|
|
285488
|
-
field:
|
|
285489
|
-
observed:
|
|
285490
|
-
expected:
|
|
285491
|
-
remediations:
|
|
285492
|
-
evidence:
|
|
285775
|
+
table: import_zod6.z.string().min(1).nullable(),
|
|
285776
|
+
field: import_zod6.z.string().min(1).nullable(),
|
|
285777
|
+
observed: import_zod6.z.string().min(1),
|
|
285778
|
+
expected: import_zod6.z.string().min(1),
|
|
285779
|
+
remediations: import_zod6.z.array(setupCompatibilityRemediationSchema).min(1),
|
|
285780
|
+
evidence: import_zod6.z.array(setupEvidenceSchema).min(1)
|
|
285493
285781
|
}).strict();
|
|
285494
|
-
var incompatibleDispositionSchema =
|
|
285495
|
-
blockers:
|
|
285496
|
-
mappings:
|
|
285782
|
+
var incompatibleDispositionSchema = import_zod6.z.object({
|
|
285783
|
+
blockers: import_zod6.z.array(setupCompatibilityBlockerSchema).min(1),
|
|
285784
|
+
mappings: import_zod6.z.array(setupDatabaseMappingSchema)
|
|
285497
285785
|
}).strict();
|
|
285498
|
-
var setupCompatibilityDispositionSchema =
|
|
285499
|
-
|
|
285500
|
-
status:
|
|
285501
|
-
blockers:
|
|
285502
|
-
mappings:
|
|
285786
|
+
var setupCompatibilityDispositionSchema = import_zod6.z.discriminatedUnion("status", [
|
|
285787
|
+
import_zod6.z.object({
|
|
285788
|
+
status: import_zod6.z.literal("compatible"),
|
|
285789
|
+
blockers: import_zod6.z.array(import_zod6.z.never()).length(0),
|
|
285790
|
+
mappings: import_zod6.z.array(setupDatabaseMappingSchema)
|
|
285503
285791
|
}).strict(),
|
|
285504
|
-
incompatibleDispositionSchema.extend({ status:
|
|
285505
|
-
incompatibleDispositionSchema.extend({ status:
|
|
285506
|
-
incompatibleDispositionSchema.extend({ status:
|
|
285507
|
-
incompatibleDispositionSchema.extend({ status:
|
|
285792
|
+
incompatibleDispositionSchema.extend({ status: import_zod6.z.literal("migration_required") }),
|
|
285793
|
+
incompatibleDispositionSchema.extend({ status: import_zod6.z.literal("translation_required") }),
|
|
285794
|
+
incompatibleDispositionSchema.extend({ status: import_zod6.z.literal("migration_or_translation_required") }),
|
|
285795
|
+
incompatibleDispositionSchema.extend({ status: import_zod6.z.literal("unsupported") })
|
|
285508
285796
|
]);
|
|
285509
|
-
var setupAdaptationTaskSchema =
|
|
285510
|
-
schemaVersion:
|
|
285511
|
-
kind:
|
|
285512
|
-
recordId:
|
|
285513
|
-
actionId:
|
|
285514
|
-
repositoryRoot:
|
|
285515
|
-
applicationRoot:
|
|
285516
|
-
selectedModels:
|
|
285517
|
-
databaseMappings:
|
|
285518
|
-
discoveryHints:
|
|
285519
|
-
scope:
|
|
285520
|
-
allowedRoot:
|
|
285521
|
-
mustExploreBeyondHints:
|
|
285522
|
-
mayReadEnvironmentValues:
|
|
285523
|
-
maximumMutation:
|
|
285797
|
+
var setupAdaptationTaskSchema = import_zod6.z.object({
|
|
285798
|
+
schemaVersion: import_zod6.z.literal(SETUP_CONTRACT_VERSION),
|
|
285799
|
+
kind: import_zod6.z.literal("ablo_setup_adaptation_task"),
|
|
285800
|
+
recordId: import_zod6.z.string().min(1),
|
|
285801
|
+
actionId: import_zod6.z.string().min(1),
|
|
285802
|
+
repositoryRoot: import_zod6.z.string().min(1),
|
|
285803
|
+
applicationRoot: import_zod6.z.string().min(1),
|
|
285804
|
+
selectedModels: import_zod6.z.array(import_zod6.z.string().min(1)).min(1),
|
|
285805
|
+
databaseMappings: import_zod6.z.array(setupDatabaseMappingSchema).default([]),
|
|
285806
|
+
discoveryHints: import_zod6.z.array(setupMutationSiteSchema),
|
|
285807
|
+
scope: import_zod6.z.object({
|
|
285808
|
+
allowedRoot: import_zod6.z.string().min(1),
|
|
285809
|
+
mustExploreBeyondHints: import_zod6.z.literal(true),
|
|
285810
|
+
mayReadEnvironmentValues: import_zod6.z.literal(false),
|
|
285811
|
+
maximumMutation: import_zod6.z.literal("local_write")
|
|
285524
285812
|
}).strict(),
|
|
285525
|
-
objective:
|
|
285526
|
-
constraints:
|
|
285527
|
-
acceptanceCriteria:
|
|
285813
|
+
objective: import_zod6.z.string().min(1),
|
|
285814
|
+
constraints: import_zod6.z.array(import_zod6.z.string().min(1)).min(1),
|
|
285815
|
+
acceptanceCriteria: import_zod6.z.array(import_zod6.z.string().min(1)).min(1)
|
|
285528
285816
|
}).strict().superRefine((record, ctx) => {
|
|
285529
285817
|
if (record.applicationRoot !== record.scope.allowedRoot) {
|
|
285530
285818
|
ctx.addIssue({
|
|
@@ -285534,233 +285822,233 @@ var setupAdaptationTaskSchema = import_zod5.z.object({
|
|
|
285534
285822
|
});
|
|
285535
285823
|
}
|
|
285536
285824
|
});
|
|
285537
|
-
var setupSkillFileSchema =
|
|
285538
|
-
path:
|
|
285539
|
-
sha256:
|
|
285540
|
-
content:
|
|
285825
|
+
var setupSkillFileSchema = import_zod6.z.object({
|
|
285826
|
+
path: import_zod6.z.string().min(1),
|
|
285827
|
+
sha256: import_zod6.z.string().regex(/^[a-f0-9]{64}$/),
|
|
285828
|
+
content: import_zod6.z.string().min(1)
|
|
285541
285829
|
}).strict();
|
|
285542
|
-
var setupSkillBundleSchema =
|
|
285543
|
-
schemaVersion:
|
|
285544
|
-
kind:
|
|
285545
|
-
id:
|
|
285546
|
-
version:
|
|
285547
|
-
entrypoint:
|
|
285548
|
-
files:
|
|
285830
|
+
var setupSkillBundleSchema = import_zod6.z.object({
|
|
285831
|
+
schemaVersion: import_zod6.z.literal(SETUP_CONTRACT_VERSION),
|
|
285832
|
+
kind: import_zod6.z.literal("ablo_setup_skill"),
|
|
285833
|
+
id: import_zod6.z.literal("integrate-ablo"),
|
|
285834
|
+
version: import_zod6.z.string().min(1),
|
|
285835
|
+
entrypoint: import_zod6.z.literal("SKILL.md"),
|
|
285836
|
+
files: import_zod6.z.array(setupSkillFileSchema).min(1)
|
|
285549
285837
|
}).strict();
|
|
285550
|
-
var setupAgentBundleSchema =
|
|
285551
|
-
schemaVersion:
|
|
285552
|
-
kind:
|
|
285553
|
-
createdAt:
|
|
285838
|
+
var setupAgentBundleSchema = import_zod6.z.object({
|
|
285839
|
+
schemaVersion: import_zod6.z.literal(SETUP_CONTRACT_VERSION),
|
|
285840
|
+
kind: import_zod6.z.literal("ablo_setup_agent_bundle"),
|
|
285841
|
+
createdAt: import_zod6.z.iso.datetime(),
|
|
285554
285842
|
record: setupAdaptationTaskSchema,
|
|
285555
285843
|
skill: setupSkillBundleSchema
|
|
285556
285844
|
}).strict();
|
|
285557
|
-
var setupWorkspaceSnapshotSchema =
|
|
285558
|
-
schemaVersion:
|
|
285559
|
-
kind:
|
|
285560
|
-
repositoryRoot:
|
|
285561
|
-
capturedAt:
|
|
285562
|
-
truncated:
|
|
285563
|
-
files:
|
|
285564
|
-
path:
|
|
285565
|
-
fingerprint:
|
|
285566
|
-
size:
|
|
285567
|
-
protectedEnvironment:
|
|
285845
|
+
var setupWorkspaceSnapshotSchema = import_zod6.z.object({
|
|
285846
|
+
schemaVersion: import_zod6.z.literal(SETUP_CONTRACT_VERSION),
|
|
285847
|
+
kind: import_zod6.z.literal("ablo_setup_workspace_snapshot"),
|
|
285848
|
+
repositoryRoot: import_zod6.z.string().min(1),
|
|
285849
|
+
capturedAt: import_zod6.z.iso.datetime(),
|
|
285850
|
+
truncated: import_zod6.z.boolean(),
|
|
285851
|
+
files: import_zod6.z.array(import_zod6.z.object({
|
|
285852
|
+
path: import_zod6.z.string().min(1),
|
|
285853
|
+
fingerprint: import_zod6.z.string().regex(/^[a-f0-9]{64}$/),
|
|
285854
|
+
size: import_zod6.z.number().int().nonnegative(),
|
|
285855
|
+
protectedEnvironment: import_zod6.z.boolean()
|
|
285568
285856
|
}).strict())
|
|
285569
285857
|
}).strict();
|
|
285570
|
-
var setupDiffEvaluationSchema =
|
|
285571
|
-
schemaVersion:
|
|
285572
|
-
kind:
|
|
285573
|
-
createdAt:
|
|
285574
|
-
selectedModels:
|
|
285575
|
-
changes:
|
|
285576
|
-
path:
|
|
285577
|
-
kind:
|
|
285858
|
+
var setupDiffEvaluationSchema = import_zod6.z.object({
|
|
285859
|
+
schemaVersion: import_zod6.z.literal(SETUP_CONTRACT_VERSION),
|
|
285860
|
+
kind: import_zod6.z.literal("ablo_setup_diff_evaluation"),
|
|
285861
|
+
createdAt: import_zod6.z.iso.datetime(),
|
|
285862
|
+
selectedModels: import_zod6.z.array(import_zod6.z.string().min(1)).min(1),
|
|
285863
|
+
changes: import_zod6.z.array(import_zod6.z.object({
|
|
285864
|
+
path: import_zod6.z.string().min(1),
|
|
285865
|
+
kind: import_zod6.z.enum(["created", "modified", "deleted"])
|
|
285578
285866
|
}).strict()),
|
|
285579
|
-
checks:
|
|
285580
|
-
id:
|
|
285581
|
-
status:
|
|
285582
|
-
detail:
|
|
285583
|
-
evidencePaths:
|
|
285867
|
+
checks: import_zod6.z.array(import_zod6.z.object({
|
|
285868
|
+
id: import_zod6.z.string().min(1),
|
|
285869
|
+
status: import_zod6.z.enum(["pass", "fail", "review"]),
|
|
285870
|
+
detail: import_zod6.z.string().min(1),
|
|
285871
|
+
evidencePaths: import_zod6.z.array(import_zod6.z.string().min(1))
|
|
285584
285872
|
}).strict()),
|
|
285585
|
-
outcome:
|
|
285586
|
-
summary:
|
|
285873
|
+
outcome: import_zod6.z.enum(["candidate", "incomplete", "unsafe"]),
|
|
285874
|
+
summary: import_zod6.z.string().min(1)
|
|
285587
285875
|
}).strict();
|
|
285588
|
-
var setupEvalVerificationSchema =
|
|
285589
|
-
id:
|
|
285590
|
-
status:
|
|
285591
|
-
detail:
|
|
285592
|
-
durationMs:
|
|
285876
|
+
var setupEvalVerificationSchema = import_zod6.z.object({
|
|
285877
|
+
id: import_zod6.z.string().min(1),
|
|
285878
|
+
status: import_zod6.z.enum(["pass", "fail", "error"]),
|
|
285879
|
+
detail: import_zod6.z.string().min(1),
|
|
285880
|
+
durationMs: import_zod6.z.number().int().nonnegative()
|
|
285593
285881
|
}).strict();
|
|
285594
|
-
var setupAgentHandoffSchema =
|
|
285595
|
-
outcome:
|
|
285596
|
-
changedFiles:
|
|
285597
|
-
exploredWritePaths:
|
|
285598
|
-
model:
|
|
285599
|
-
path:
|
|
285600
|
-
role:
|
|
285882
|
+
var setupAgentHandoffSchema = import_zod6.z.object({
|
|
285883
|
+
outcome: import_zod6.z.enum(["candidate", "blocked", "failed"]),
|
|
285884
|
+
changedFiles: import_zod6.z.array(import_zod6.z.string().min(1)),
|
|
285885
|
+
exploredWritePaths: import_zod6.z.array(import_zod6.z.object({
|
|
285886
|
+
model: import_zod6.z.string().min(1),
|
|
285887
|
+
path: import_zod6.z.string().min(1),
|
|
285888
|
+
role: import_zod6.z.string().min(1)
|
|
285601
285889
|
}).strict()),
|
|
285602
|
-
directWriteExceptions:
|
|
285603
|
-
path:
|
|
285604
|
-
reason:
|
|
285890
|
+
directWriteExceptions: import_zod6.z.array(import_zod6.z.object({
|
|
285891
|
+
path: import_zod6.z.string().min(1),
|
|
285892
|
+
reason: import_zod6.z.string().min(1)
|
|
285605
285893
|
}).strict()),
|
|
285606
|
-
verification:
|
|
285607
|
-
command:
|
|
285608
|
-
exitCode:
|
|
285609
|
-
result:
|
|
285894
|
+
verification: import_zod6.z.array(import_zod6.z.object({
|
|
285895
|
+
command: import_zod6.z.string().min(1),
|
|
285896
|
+
exitCode: import_zod6.z.number().int().nullable(),
|
|
285897
|
+
result: import_zod6.z.string().min(1)
|
|
285610
285898
|
}).strict()),
|
|
285611
|
-
blockers:
|
|
285899
|
+
blockers: import_zod6.z.array(import_zod6.z.string().min(1))
|
|
285612
285900
|
}).strict();
|
|
285613
|
-
var setupEvalResultSchema =
|
|
285614
|
-
schemaVersion:
|
|
285615
|
-
kind:
|
|
285616
|
-
caseId:
|
|
285617
|
-
runner:
|
|
285618
|
-
model:
|
|
285619
|
-
startedAt:
|
|
285620
|
-
finishedAt:
|
|
285621
|
-
durationMs:
|
|
285622
|
-
agent:
|
|
285623
|
-
status:
|
|
285624
|
-
exitCode:
|
|
285901
|
+
var setupEvalResultSchema = import_zod6.z.object({
|
|
285902
|
+
schemaVersion: import_zod6.z.literal(SETUP_CONTRACT_VERSION),
|
|
285903
|
+
kind: import_zod6.z.literal("ablo_setup_eval_result"),
|
|
285904
|
+
caseId: import_zod6.z.string().min(1),
|
|
285905
|
+
runner: import_zod6.z.string().min(1),
|
|
285906
|
+
model: import_zod6.z.string().min(1).nullable(),
|
|
285907
|
+
startedAt: import_zod6.z.iso.datetime(),
|
|
285908
|
+
finishedAt: import_zod6.z.iso.datetime(),
|
|
285909
|
+
durationMs: import_zod6.z.number().int().nonnegative(),
|
|
285910
|
+
agent: import_zod6.z.object({
|
|
285911
|
+
status: import_zod6.z.enum(["completed", "failed", "timed_out"]),
|
|
285912
|
+
exitCode: import_zod6.z.number().int().nullable(),
|
|
285625
285913
|
handoff: setupAgentHandoffSchema.nullable()
|
|
285626
285914
|
}).strict(),
|
|
285627
285915
|
diff: setupDiffEvaluationSchema,
|
|
285628
|
-
verification:
|
|
285629
|
-
outcome:
|
|
285630
|
-
summary:
|
|
285916
|
+
verification: import_zod6.z.array(setupEvalVerificationSchema),
|
|
285917
|
+
outcome: import_zod6.z.enum(["passed", "blocked", "failed", "incomplete", "unsafe"]),
|
|
285918
|
+
summary: import_zod6.z.string().min(1)
|
|
285631
285919
|
}).strict();
|
|
285632
|
-
var setupRepositoryBenchmarkCaseSchema =
|
|
285633
|
-
schemaVersion:
|
|
285634
|
-
kind:
|
|
285635
|
-
caseId:
|
|
285636
|
-
repository:
|
|
285637
|
-
url:
|
|
285638
|
-
commit:
|
|
285920
|
+
var setupRepositoryBenchmarkCaseSchema = import_zod6.z.object({
|
|
285921
|
+
schemaVersion: import_zod6.z.literal(SETUP_CONTRACT_VERSION),
|
|
285922
|
+
kind: import_zod6.z.literal("ablo_setup_repository_benchmark_case"),
|
|
285923
|
+
caseId: import_zod6.z.string().min(1),
|
|
285924
|
+
repository: import_zod6.z.object({
|
|
285925
|
+
url: import_zod6.z.url(),
|
|
285926
|
+
commit: import_zod6.z.string().regex(/^[a-f0-9]{40}$/)
|
|
285639
285927
|
}).strict(),
|
|
285640
|
-
expectations:
|
|
285641
|
-
applicationRoot:
|
|
285642
|
-
persistenceIncludes:
|
|
285643
|
-
requiredMutationPaths:
|
|
285644
|
-
forbiddenMutationPathPrefixes:
|
|
285928
|
+
expectations: import_zod6.z.object({
|
|
285929
|
+
applicationRoot: import_zod6.z.string().min(1),
|
|
285930
|
+
persistenceIncludes: import_zod6.z.array(import_zod6.z.string().min(1)),
|
|
285931
|
+
requiredMutationPaths: import_zod6.z.array(import_zod6.z.string().min(1)),
|
|
285932
|
+
forbiddenMutationPathPrefixes: import_zod6.z.array(import_zod6.z.string().min(1)),
|
|
285645
285933
|
coordinationAdoption: setupCoordinationAdoptionDispositionSchema
|
|
285646
285934
|
}).strict()
|
|
285647
285935
|
}).strict();
|
|
285648
|
-
var setupRepositoryBenchmarkResultSchema =
|
|
285649
|
-
schemaVersion:
|
|
285650
|
-
kind:
|
|
285651
|
-
caseId:
|
|
285652
|
-
repositoryUrl:
|
|
285653
|
-
commit:
|
|
285654
|
-
checks:
|
|
285655
|
-
id:
|
|
285656
|
-
status:
|
|
285657
|
-
detail:
|
|
285936
|
+
var setupRepositoryBenchmarkResultSchema = import_zod6.z.object({
|
|
285937
|
+
schemaVersion: import_zod6.z.literal(SETUP_CONTRACT_VERSION),
|
|
285938
|
+
kind: import_zod6.z.literal("ablo_setup_repository_benchmark_result"),
|
|
285939
|
+
caseId: import_zod6.z.string().min(1),
|
|
285940
|
+
repositoryUrl: import_zod6.z.url(),
|
|
285941
|
+
commit: import_zod6.z.string().regex(/^[a-f0-9]{40}$/),
|
|
285942
|
+
checks: import_zod6.z.array(import_zod6.z.object({
|
|
285943
|
+
id: import_zod6.z.string().min(1),
|
|
285944
|
+
status: import_zod6.z.enum(["pass", "fail"]),
|
|
285945
|
+
detail: import_zod6.z.string().min(1)
|
|
285658
285946
|
}).strict()),
|
|
285659
|
-
outcome:
|
|
285947
|
+
outcome: import_zod6.z.enum(["passed", "failed"])
|
|
285660
285948
|
}).strict();
|
|
285661
|
-
var setupStepResultBaseSchema =
|
|
285662
|
-
stepId:
|
|
285663
|
-
summary:
|
|
285664
|
-
facts:
|
|
285665
|
-
decisions:
|
|
285666
|
-
actions:
|
|
285667
|
-
startedAt:
|
|
285668
|
-
finishedAt:
|
|
285949
|
+
var setupStepResultBaseSchema = import_zod6.z.object({
|
|
285950
|
+
stepId: import_zod6.z.string().min(1),
|
|
285951
|
+
summary: import_zod6.z.string().min(1),
|
|
285952
|
+
facts: import_zod6.z.array(setupFactSchema).default([]),
|
|
285953
|
+
decisions: import_zod6.z.array(setupDecisionSchema).default([]),
|
|
285954
|
+
actions: import_zod6.z.array(setupActionSchema).default([]),
|
|
285955
|
+
startedAt: import_zod6.z.iso.datetime(),
|
|
285956
|
+
finishedAt: import_zod6.z.iso.datetime()
|
|
285669
285957
|
}).strict();
|
|
285670
|
-
var setupStepResultSchema =
|
|
285671
|
-
setupStepResultBaseSchema.extend({ status:
|
|
285958
|
+
var setupStepResultSchema = import_zod6.z.discriminatedUnion("status", [
|
|
285959
|
+
setupStepResultBaseSchema.extend({ status: import_zod6.z.literal("complete") }),
|
|
285672
285960
|
setupStepResultBaseSchema.extend({
|
|
285673
|
-
status:
|
|
285674
|
-
next:
|
|
285961
|
+
status: import_zod6.z.literal("incomplete"),
|
|
285962
|
+
next: import_zod6.z.string().min(1)
|
|
285675
285963
|
}),
|
|
285676
285964
|
setupStepResultBaseSchema.extend({
|
|
285677
|
-
status:
|
|
285678
|
-
blockers:
|
|
285679
|
-
next:
|
|
285965
|
+
status: import_zod6.z.literal("blocked"),
|
|
285966
|
+
blockers: import_zod6.z.array(import_zod6.z.string().min(1)).min(1),
|
|
285967
|
+
next: import_zod6.z.string().min(1)
|
|
285680
285968
|
}),
|
|
285681
285969
|
setupStepResultBaseSchema.extend({
|
|
285682
|
-
status:
|
|
285683
|
-
error:
|
|
285684
|
-
code:
|
|
285685
|
-
message:
|
|
285970
|
+
status: import_zod6.z.literal("failed"),
|
|
285971
|
+
error: import_zod6.z.object({
|
|
285972
|
+
code: import_zod6.z.string().min(1),
|
|
285973
|
+
message: import_zod6.z.string().min(1)
|
|
285686
285974
|
}).strict()
|
|
285687
285975
|
})
|
|
285688
285976
|
]);
|
|
285689
|
-
var setupTargetSchema =
|
|
285690
|
-
repositoryRoot:
|
|
285691
|
-
applicationRoot:
|
|
285692
|
-
packageName:
|
|
285693
|
-
abloProjectId:
|
|
285694
|
-
abloBranchId:
|
|
285695
|
-
databaseFingerprint:
|
|
285696
|
-
localSchemaDigest:
|
|
285697
|
-
pushedSchemaDigest:
|
|
285977
|
+
var setupTargetSchema = import_zod6.z.object({
|
|
285978
|
+
repositoryRoot: import_zod6.z.string().min(1),
|
|
285979
|
+
applicationRoot: import_zod6.z.string().min(1).nullable(),
|
|
285980
|
+
packageName: import_zod6.z.string().min(1).nullable(),
|
|
285981
|
+
abloProjectId: import_zod6.z.string().min(1).nullable(),
|
|
285982
|
+
abloBranchId: import_zod6.z.string().min(1).nullable(),
|
|
285983
|
+
databaseFingerprint: import_zod6.z.string().min(1).nullable(),
|
|
285984
|
+
localSchemaDigest: import_zod6.z.string().min(1).nullable(),
|
|
285985
|
+
pushedSchemaDigest: import_zod6.z.string().min(1).nullable()
|
|
285698
285986
|
}).strict();
|
|
285699
|
-
var setupPostconditionSchema =
|
|
285700
|
-
id:
|
|
285701
|
-
description:
|
|
285702
|
-
status:
|
|
285703
|
-
evidence:
|
|
285987
|
+
var setupPostconditionSchema = import_zod6.z.object({
|
|
285988
|
+
id: import_zod6.z.string().min(1),
|
|
285989
|
+
description: import_zod6.z.string().min(1),
|
|
285990
|
+
status: import_zod6.z.enum(["unverified", "satisfied", "unsatisfied", "blocked"]),
|
|
285991
|
+
evidence: import_zod6.z.array(setupEvidenceSchema).default([])
|
|
285704
285992
|
}).strict();
|
|
285705
|
-
var setupInitPlanProjectionSchema =
|
|
285706
|
-
root:
|
|
285707
|
-
actions:
|
|
285708
|
-
kind:
|
|
285709
|
-
path:
|
|
285710
|
-
note:
|
|
285711
|
-
precondition:
|
|
285712
|
-
|
|
285713
|
-
|
|
285714
|
-
kind:
|
|
285715
|
-
sha256:
|
|
285993
|
+
var setupInitPlanProjectionSchema = import_zod6.z.object({
|
|
285994
|
+
root: import_zod6.z.string().min(1),
|
|
285995
|
+
actions: import_zod6.z.array(import_zod6.z.object({
|
|
285996
|
+
kind: import_zod6.z.enum(["create", "update", "unchanged"]),
|
|
285997
|
+
path: import_zod6.z.string().min(1),
|
|
285998
|
+
note: import_zod6.z.string().optional(),
|
|
285999
|
+
precondition: import_zod6.z.discriminatedUnion("kind", [
|
|
286000
|
+
import_zod6.z.object({ kind: import_zod6.z.literal("absent") }).strict(),
|
|
286001
|
+
import_zod6.z.object({
|
|
286002
|
+
kind: import_zod6.z.literal("content"),
|
|
286003
|
+
sha256: import_zod6.z.string().regex(/^[a-f0-9]{64}$/)
|
|
285716
286004
|
}).strict()
|
|
285717
286005
|
]).optional()
|
|
285718
286006
|
}).strict()),
|
|
285719
|
-
conflicts:
|
|
285720
|
-
path:
|
|
285721
|
-
reason:
|
|
286007
|
+
conflicts: import_zod6.z.array(import_zod6.z.object({
|
|
286008
|
+
path: import_zod6.z.string().min(1),
|
|
286009
|
+
reason: import_zod6.z.literal("occupied")
|
|
285722
286010
|
}).strict())
|
|
285723
286011
|
}).strict();
|
|
285724
|
-
var setupInitResultSchema =
|
|
285725
|
-
status:
|
|
286012
|
+
var setupInitResultSchema = import_zod6.z.object({
|
|
286013
|
+
status: import_zod6.z.enum(["planned", "applied"]),
|
|
285726
286014
|
plan: setupInitPlanProjectionSchema
|
|
285727
286015
|
}).strict();
|
|
285728
|
-
var setupPlanSchema =
|
|
285729
|
-
schemaVersion:
|
|
285730
|
-
kind:
|
|
285731
|
-
mode:
|
|
285732
|
-
createdAt:
|
|
286016
|
+
var setupPlanSchema = import_zod6.z.object({
|
|
286017
|
+
schemaVersion: import_zod6.z.literal(SETUP_CONTRACT_VERSION),
|
|
286018
|
+
kind: import_zod6.z.literal("ablo_setup_plan"),
|
|
286019
|
+
mode: import_zod6.z.literal("plan"),
|
|
286020
|
+
createdAt: import_zod6.z.iso.datetime(),
|
|
285733
286021
|
target: setupTargetSchema,
|
|
285734
286022
|
compatibility: setupCompatibilityDispositionSchema,
|
|
285735
|
-
steps:
|
|
285736
|
-
facts:
|
|
285737
|
-
decisions:
|
|
285738
|
-
actions:
|
|
285739
|
-
postconditions:
|
|
285740
|
-
outcome:
|
|
285741
|
-
summary:
|
|
286023
|
+
steps: import_zod6.z.array(setupStepResultSchema),
|
|
286024
|
+
facts: import_zod6.z.array(setupFactSchema),
|
|
286025
|
+
decisions: import_zod6.z.array(setupDecisionSchema),
|
|
286026
|
+
actions: import_zod6.z.array(setupActionSchema),
|
|
286027
|
+
postconditions: import_zod6.z.array(setupPostconditionSchema),
|
|
286028
|
+
outcome: import_zod6.z.enum(["ready_to_apply", "needs_decisions", "blocked"]),
|
|
286029
|
+
summary: import_zod6.z.string().min(1)
|
|
285742
286030
|
}).strict();
|
|
285743
|
-
var setupCheckpointSchema =
|
|
285744
|
-
schemaVersion:
|
|
285745
|
-
kind:
|
|
285746
|
-
programId:
|
|
285747
|
-
repositoryRoot:
|
|
285748
|
-
createdAt:
|
|
285749
|
-
updatedAt:
|
|
285750
|
-
completedStepIds:
|
|
285751
|
-
results:
|
|
286031
|
+
var setupCheckpointSchema = import_zod6.z.object({
|
|
286032
|
+
schemaVersion: import_zod6.z.literal(SETUP_CONTRACT_VERSION),
|
|
286033
|
+
kind: import_zod6.z.literal("ablo_setup_checkpoint"),
|
|
286034
|
+
programId: import_zod6.z.string().min(1),
|
|
286035
|
+
repositoryRoot: import_zod6.z.string().min(1),
|
|
286036
|
+
createdAt: import_zod6.z.iso.datetime(),
|
|
286037
|
+
updatedAt: import_zod6.z.iso.datetime(),
|
|
286038
|
+
completedStepIds: import_zod6.z.array(import_zod6.z.string().min(1)),
|
|
286039
|
+
results: import_zod6.z.array(setupStepResultSchema)
|
|
285752
286040
|
}).strict();
|
|
285753
|
-
var setupReportSchema =
|
|
285754
|
-
schemaVersion:
|
|
285755
|
-
kind:
|
|
285756
|
-
createdAt:
|
|
286041
|
+
var setupReportSchema = import_zod6.z.object({
|
|
286042
|
+
schemaVersion: import_zod6.z.literal(SETUP_CONTRACT_VERSION),
|
|
286043
|
+
kind: import_zod6.z.literal("ablo_setup_report"),
|
|
286044
|
+
createdAt: import_zod6.z.iso.datetime(),
|
|
285757
286045
|
target: setupTargetSchema,
|
|
285758
|
-
outcome:
|
|
285759
|
-
facts:
|
|
285760
|
-
decisions:
|
|
285761
|
-
actions:
|
|
285762
|
-
postconditions:
|
|
285763
|
-
next:
|
|
286046
|
+
outcome: import_zod6.z.enum(["complete", "incomplete", "blocked", "failed"]),
|
|
286047
|
+
facts: import_zod6.z.array(setupFactSchema),
|
|
286048
|
+
decisions: import_zod6.z.array(setupDecisionSchema),
|
|
286049
|
+
actions: import_zod6.z.array(setupActionSchema),
|
|
286050
|
+
postconditions: import_zod6.z.array(setupPostconditionSchema),
|
|
286051
|
+
next: import_zod6.z.array(import_zod6.z.string().min(1))
|
|
285764
286052
|
}).strict();
|
|
285765
286053
|
|
|
285766
286054
|
// src/setup/program.ts
|
|
@@ -286135,7 +286423,7 @@ function walkFiles(root, maxDepth = 5) {
|
|
|
286135
286423
|
const current = stack.pop();
|
|
286136
286424
|
let entries;
|
|
286137
286425
|
try {
|
|
286138
|
-
entries = (0,
|
|
286426
|
+
entries = (0, import_node_fs3.readdirSync)(current.path, { withFileTypes: true });
|
|
286139
286427
|
} catch {
|
|
286140
286428
|
continue;
|
|
286141
286429
|
}
|
|
@@ -286155,7 +286443,7 @@ function walkFiles(root, maxDepth = 5) {
|
|
|
286155
286443
|
}
|
|
286156
286444
|
function readManifest(path) {
|
|
286157
286445
|
try {
|
|
286158
|
-
const parsed = JSON.parse((0,
|
|
286446
|
+
const parsed = JSON.parse((0, import_node_fs3.readFileSync)(path, "utf8"));
|
|
286159
286447
|
return {
|
|
286160
286448
|
root: (0, import_node_path2.resolve)(path, ".."),
|
|
286161
286449
|
name: typeof parsed.name === "string" ? parsed.name : null,
|
|
@@ -286232,8 +286520,8 @@ function detectedPersistence(manifest, files) {
|
|
|
286232
286520
|
if (!SOURCE_EXTENSIONS.has(sourceExtension(path))) continue;
|
|
286233
286521
|
let source;
|
|
286234
286522
|
try {
|
|
286235
|
-
if ((0,
|
|
286236
|
-
source = (0,
|
|
286523
|
+
if ((0, import_node_fs3.lstatSync)(path).size > MAX_SOURCE_BYTES) continue;
|
|
286524
|
+
source = (0, import_node_fs3.readFileSync)(path, "utf8");
|
|
286237
286525
|
} catch {
|
|
286238
286526
|
continue;
|
|
286239
286527
|
}
|
|
@@ -286261,17 +286549,17 @@ function coordinationAdoptionReason(disposition, persistence) {
|
|
|
286261
286549
|
}
|
|
286262
286550
|
}
|
|
286263
286551
|
function packageManager(root) {
|
|
286264
|
-
if ((0,
|
|
286265
|
-
if ((0,
|
|
286266
|
-
if ((0,
|
|
286552
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path2.join)(root, "pnpm-lock.yaml"))) return "pnpm";
|
|
286553
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path2.join)(root, "yarn.lock"))) return "yarn";
|
|
286554
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path2.join)(root, "bun.lockb")) || (0, import_node_fs3.existsSync)((0, import_node_path2.join)(root, "bun.lock"))) return "bun";
|
|
286267
286555
|
return "npm";
|
|
286268
286556
|
}
|
|
286269
286557
|
function environmentKeyNames(root) {
|
|
286270
286558
|
const names = [".env.local", ".env.development.local", ".env.development", ".env"];
|
|
286271
286559
|
return names.flatMap((name) => {
|
|
286272
286560
|
const path = (0, import_node_path2.join)(root, name);
|
|
286273
|
-
if (!(0,
|
|
286274
|
-
const keys = (0,
|
|
286561
|
+
if (!(0, import_node_fs3.existsSync)(path)) return [];
|
|
286562
|
+
const keys = (0, import_node_fs3.readFileSync)(path, "utf8").split(/\r?\n/).flatMap((line) => {
|
|
286275
286563
|
const match = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(line);
|
|
286276
286564
|
return match ? [match[1]] : [];
|
|
286277
286565
|
});
|
|
@@ -286286,8 +286574,8 @@ function abloSourceFiles(root, files) {
|
|
|
286286
286574
|
return files.flatMap((path) => {
|
|
286287
286575
|
if (!SOURCE_EXTENSIONS.has(sourceExtension(path))) return [];
|
|
286288
286576
|
try {
|
|
286289
|
-
if ((0,
|
|
286290
|
-
return (0,
|
|
286577
|
+
if ((0, import_node_fs3.lstatSync)(path).size > MAX_SOURCE_BYTES) return [];
|
|
286578
|
+
return (0, import_node_fs3.readFileSync)(path, "utf8").includes("@abloatai/") ? [(0, import_node_path2.relative)(root, path) || "."] : [];
|
|
286291
286579
|
} catch {
|
|
286292
286580
|
return [];
|
|
286293
286581
|
}
|
|
@@ -286314,8 +286602,8 @@ function discoverMutationSites(root, files) {
|
|
|
286314
286602
|
if (!SOURCE_EXTENSIONS.has(sourceExtension(path))) continue;
|
|
286315
286603
|
let source;
|
|
286316
286604
|
try {
|
|
286317
|
-
if ((0,
|
|
286318
|
-
source = (0,
|
|
286605
|
+
if ((0, import_node_fs3.lstatSync)(path).size > MAX_SOURCE_BYTES) continue;
|
|
286606
|
+
source = (0, import_node_fs3.readFileSync)(path, "utf8");
|
|
286319
286607
|
} catch {
|
|
286320
286608
|
continue;
|
|
286321
286609
|
}
|
|
@@ -286355,9 +286643,9 @@ function isProductionMutationFile(root, path) {
|
|
|
286355
286643
|
return !/(?:^|\/)(?:test|tests|__tests__|scripts)(?:\/|$)/.test(locator) && !/\.(?:test|spec)\.[cm]?[jt]sx?$/.test(locator);
|
|
286356
286644
|
}
|
|
286357
286645
|
function digestFile(path) {
|
|
286358
|
-
if (!(0,
|
|
286646
|
+
if (!(0, import_node_fs3.existsSync)(path)) return null;
|
|
286359
286647
|
try {
|
|
286360
|
-
return (0,
|
|
286648
|
+
return (0, import_node_crypto6.createHash)("sha256").update((0, import_node_fs3.readFileSync)(path)).digest("hex");
|
|
286361
286649
|
} catch {
|
|
286362
286650
|
return null;
|
|
286363
286651
|
}
|
|
@@ -286401,8 +286689,8 @@ function localDiscoveryStep(state) {
|
|
|
286401
286689
|
if (!SOURCE_EXTENSIONS.has(sourceExtension(path))) continue;
|
|
286402
286690
|
let source;
|
|
286403
286691
|
try {
|
|
286404
|
-
if ((0,
|
|
286405
|
-
source = (0,
|
|
286692
|
+
if ((0, import_node_fs3.lstatSync)(path).size > MAX_SOURCE_BYTES) continue;
|
|
286693
|
+
source = (0, import_node_fs3.readFileSync)(path, "utf8");
|
|
286406
286694
|
} catch {
|
|
286407
286695
|
continue;
|
|
286408
286696
|
}
|
|
@@ -286443,8 +286731,8 @@ function localDiscoveryStep(state) {
|
|
|
286443
286731
|
"src/app/providers.tsx",
|
|
286444
286732
|
"app/api/ablo-session/route.ts",
|
|
286445
286733
|
"src/app/api/ablo-session/route.ts"
|
|
286446
|
-
].filter((path) => (0,
|
|
286447
|
-
const localSchemaPath = [(0, import_node_path2.join)(envRoot, "ablo", "schema.ts"), (0, import_node_path2.join)(envRoot, "src", "ablo", "schema.ts")].find((path) => (0,
|
|
286734
|
+
].filter((path) => (0, import_node_fs3.existsSync)((0, import_node_path2.join)(envRoot, path)));
|
|
286735
|
+
const localSchemaPath = [(0, import_node_path2.join)(envRoot, "ablo", "schema.ts"), (0, import_node_path2.join)(envRoot, "src", "ablo", "schema.ts")].find((path) => (0, import_node_fs3.existsSync)(path)) ?? (0, import_node_path2.join)(envRoot, "ablo", "schema.ts");
|
|
286448
286736
|
state.localSchemaDigest = digestFile(localSchemaPath);
|
|
286449
286737
|
const facts = [
|
|
286450
286738
|
fact("repository.root", root, "git", tryGit(root, ["rev-parse", "--show-toplevel"]) ? "Resolved from Git." : "No Git root was available; using the requested directory.", root),
|
|
@@ -286846,7 +287134,7 @@ function parseSetupArgs(args) {
|
|
|
286846
287134
|
if (arg === "--root") {
|
|
286847
287135
|
const next = args[index + 1];
|
|
286848
287136
|
if (!next || next.startsWith("-")) {
|
|
286849
|
-
throw new
|
|
287137
|
+
throw new import_errors16.AbloValidationError("`--root` requires a directory.", {
|
|
286850
287138
|
code: "cli_invalid_arguments"
|
|
286851
287139
|
});
|
|
286852
287140
|
}
|
|
@@ -286855,7 +287143,7 @@ function parseSetupArgs(args) {
|
|
|
286855
287143
|
continue;
|
|
286856
287144
|
}
|
|
286857
287145
|
if (!allowedFlags.has(arg)) {
|
|
286858
|
-
throw new
|
|
287146
|
+
throw new import_errors16.AbloValidationError(`Unknown setup option: ${arg}`, {
|
|
286859
287147
|
code: "cli_invalid_arguments"
|
|
286860
287148
|
});
|
|
286861
287149
|
}
|
|
@@ -286867,7 +287155,7 @@ function parseSetupArgs(args) {
|
|
|
286867
287155
|
};
|
|
286868
287156
|
}
|
|
286869
287157
|
function renderValue(value) {
|
|
286870
|
-
if (value === null) return
|
|
287158
|
+
if (value === null) return import_picocolors19.default.dim("unknown");
|
|
286871
287159
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
286872
287160
|
return String(value);
|
|
286873
287161
|
}
|
|
@@ -286879,69 +287167,69 @@ function renderStatus(value) {
|
|
|
286879
287167
|
}
|
|
286880
287168
|
function renderHumanPlan(plan) {
|
|
286881
287169
|
console.log(`
|
|
286882
|
-
${brand("ablo")} ${
|
|
287170
|
+
${brand("ablo")} ${import_picocolors19.default.dim("setup plan")} ${import_picocolors19.default.dim("(read-only)")}
|
|
286883
287171
|
`);
|
|
286884
|
-
console.log(` ${
|
|
287172
|
+
console.log(` ${import_picocolors19.default.bold("Target")}`);
|
|
286885
287173
|
console.log(` repository ${plan.target.repositoryRoot}`);
|
|
286886
|
-
console.log(` application ${plan.target.applicationRoot ??
|
|
286887
|
-
console.log(` package ${plan.target.packageName ??
|
|
286888
|
-
console.log(` project ${plan.target.abloProjectId ??
|
|
286889
|
-
console.log(` branch ${plan.target.abloBranchId ??
|
|
286890
|
-
console.log(` compatibility ${plan.compatibility.status === "compatible" ?
|
|
287174
|
+
console.log(` application ${plan.target.applicationRoot ?? import_picocolors19.default.yellow("unresolved")}`);
|
|
287175
|
+
console.log(` package ${plan.target.packageName ?? import_picocolors19.default.dim("unknown")}`);
|
|
287176
|
+
console.log(` project ${plan.target.abloProjectId ?? import_picocolors19.default.dim("unconfirmed")}`);
|
|
287177
|
+
console.log(` branch ${plan.target.abloBranchId ?? import_picocolors19.default.dim("unconfirmed")}`);
|
|
287178
|
+
console.log(` compatibility ${plan.compatibility.status === "compatible" ? import_picocolors19.default.green("compatible") : import_picocolors19.default.yellow(renderStatus(plan.compatibility.status))}`);
|
|
286891
287179
|
if (plan.compatibility.blockers.length > 0) {
|
|
286892
287180
|
console.log(`
|
|
286893
|
-
${
|
|
287181
|
+
${import_picocolors19.default.bold("Compatibility blockers")}`);
|
|
286894
287182
|
for (const blocker2 of plan.compatibility.blockers) {
|
|
286895
287183
|
const location = blocker2.table ? `${blocker2.table}${blocker2.field ? ` (${blocker2.field})` : ""}` : "Repository";
|
|
286896
|
-
console.log(` ${
|
|
287184
|
+
console.log(` ${import_picocolors19.default.bold(location)} ${import_picocolors19.default.yellow(renderStatus(blocker2.code))}`);
|
|
286897
287185
|
console.log(` ${blocker2.observed}`);
|
|
286898
|
-
console.log(` ${
|
|
287186
|
+
console.log(` ${import_picocolors19.default.dim(`Required: ${blocker2.expected}`)}`);
|
|
286899
287187
|
for (const remediation of blocker2.remediations) {
|
|
286900
|
-
console.log(` ${
|
|
287188
|
+
console.log(` ${import_picocolors19.default.dim(`${renderStatus(remediation.kind)} \u2014 ${remediation.summary}`)}`);
|
|
286901
287189
|
}
|
|
286902
287190
|
}
|
|
286903
287191
|
}
|
|
286904
287192
|
if (plan.compatibility.mappings.length > 0) {
|
|
286905
287193
|
console.log(`
|
|
286906
|
-
${
|
|
287194
|
+
${import_picocolors19.default.bold("Database mappings")}`);
|
|
286907
287195
|
for (const mapping of plan.compatibility.mappings) {
|
|
286908
287196
|
const target = mapping.column === null ? "disabled" : `${mapping.column} \xB7 ${mapping.databaseType ?? "unmapped"}`;
|
|
286909
|
-
const status2 = mapping.status === "ready" ?
|
|
287197
|
+
const status2 = mapping.status === "ready" ? import_picocolors19.default.green("ready") : import_picocolors19.default.yellow("review");
|
|
286910
287198
|
console.log(` ${`${mapping.table}.${mapping.field}`.padEnd(34)} ${target} \xB7 ${status2}`);
|
|
286911
|
-
if (mapping.status === "review_required") console.log(` ${
|
|
287199
|
+
if (mapping.status === "review_required") console.log(` ${import_picocolors19.default.dim(mapping.reason)}`);
|
|
286912
287200
|
}
|
|
286913
287201
|
}
|
|
286914
287202
|
console.log(`
|
|
286915
|
-
${
|
|
287203
|
+
${import_picocolors19.default.bold("Evidence")}`);
|
|
286916
287204
|
for (const item of plan.facts) {
|
|
286917
287205
|
console.log(` ${item.key.padEnd(34)} ${renderValue(item.value)}`);
|
|
286918
287206
|
}
|
|
286919
287207
|
console.log(`
|
|
286920
|
-
${
|
|
287208
|
+
${import_picocolors19.default.bold("Decisions")}`);
|
|
286921
287209
|
for (const decision of plan.decisions) {
|
|
286922
|
-
const marker = decision.status === "resolved" ?
|
|
287210
|
+
const marker = decision.status === "resolved" ? import_picocolors19.default.green("\u2713") : import_picocolors19.default.yellow("?");
|
|
286923
287211
|
console.log(` ${marker} ${decision.question}`);
|
|
286924
|
-
console.log(` ${
|
|
287212
|
+
console.log(` ${import_picocolors19.default.dim(decision.reason)}`);
|
|
286925
287213
|
}
|
|
286926
287214
|
console.log(`
|
|
286927
|
-
${
|
|
287215
|
+
${import_picocolors19.default.bold("Actions")}`);
|
|
286928
287216
|
for (const action of plan.actions) {
|
|
286929
|
-
const marker = action.status === "blocked" ?
|
|
286930
|
-
console.log(` ${marker.padEnd(18)} ${action.summary} ${
|
|
287217
|
+
const marker = action.status === "blocked" ? import_picocolors19.default.yellow("blocked") : import_picocolors19.default.green(action.status);
|
|
287218
|
+
console.log(` ${marker.padEnd(18)} ${action.summary} ${import_picocolors19.default.dim(`[${action.executor}]`)}`);
|
|
286931
287219
|
if (action.blockedBy.length > 0) {
|
|
286932
|
-
console.log(` ${
|
|
287220
|
+
console.log(` ${import_picocolors19.default.dim(`needs ${action.blockedBy.join(", ")}`)}`);
|
|
286933
287221
|
}
|
|
286934
287222
|
}
|
|
286935
287223
|
console.log(`
|
|
286936
|
-
${
|
|
287224
|
+
${import_picocolors19.default.bold("Result")} ${import_picocolors19.default.yellow(plan.outcome)}`);
|
|
286937
287225
|
console.log(` ${plan.summary}`);
|
|
286938
|
-
console.log(
|
|
287226
|
+
console.log(import_picocolors19.default.dim(" Machine-readable: npx ablo setup --plan --json"));
|
|
286939
287227
|
console.log();
|
|
286940
287228
|
}
|
|
286941
287229
|
async function runSetup(args) {
|
|
286942
287230
|
const options = parseSetupArgs(args);
|
|
286943
287231
|
if (options.json && !options.plan) {
|
|
286944
|
-
throw new
|
|
287232
|
+
throw new import_errors16.AbloValidationError(
|
|
286945
287233
|
"`--json` is a plan renderer. Use `ablo setup --plan --json`.",
|
|
286946
287234
|
{ code: "cli_invalid_arguments" }
|
|
286947
287235
|
);
|
|
@@ -287120,6 +287408,28 @@ var COMMANDS = [
|
|
|
287120
287408
|
]
|
|
287121
287409
|
}
|
|
287122
287410
|
},
|
|
287411
|
+
{
|
|
287412
|
+
// Sits beside `docs` on purpose. An agent that just failed to find an
|
|
287413
|
+
// answer is already reading this block, and the command that reports the
|
|
287414
|
+
// gap is the next line down rather than somewhere it would have to know to
|
|
287415
|
+
// look. Discoverability IS the feature: a channel an agent never finds
|
|
287416
|
+
// collects nothing.
|
|
287417
|
+
name: "feedback",
|
|
287418
|
+
usage: FEEDBACK_USAGE,
|
|
287419
|
+
core: { group: "More", does: "Tell us what got in your way, so the next agent does not hit it" },
|
|
287420
|
+
full: {
|
|
287421
|
+
group: "Read the docs",
|
|
287422
|
+
rows: [
|
|
287423
|
+
// The kinds come from the taxonomy rather than being spelled out here:
|
|
287424
|
+
// a help screen listing four when the schema knows five is the drift
|
|
287425
|
+
// this registry exists to stop.
|
|
287426
|
+
{ run: `feedback <${FEEDBACK_KINDS.join("|")}> "<one line>"`, does: "Report one wall you hit" },
|
|
287427
|
+
{ run: 'feedback bug "..." --detail <text>', does: "Add what happened, at length (`-` reads stdin)" },
|
|
287428
|
+
{ run: " [--command <name>] [--error-code <code>] [--from <agent>]" },
|
|
287429
|
+
{ run: " [--yes] [--json]" }
|
|
287430
|
+
]
|
|
287431
|
+
}
|
|
287432
|
+
},
|
|
287123
287433
|
{
|
|
287124
287434
|
name: "whoami",
|
|
287125
287435
|
usage: WHOAMI_USAGE,
|
|
@@ -287260,15 +287570,15 @@ function fullRows(group) {
|
|
|
287260
287570
|
}
|
|
287261
287571
|
|
|
287262
287572
|
// src/index.ts
|
|
287263
|
-
var
|
|
287573
|
+
var import_errors25 = require("@abloatai/transaction/errors");
|
|
287264
287574
|
init_push();
|
|
287265
287575
|
|
|
287266
287576
|
// src/generate.ts
|
|
287267
287577
|
init_cjs_shims();
|
|
287268
|
-
var
|
|
287578
|
+
var import_errors17 = require("@abloatai/transaction/errors");
|
|
287269
287579
|
var import_fs8 = require("fs");
|
|
287270
287580
|
var import_path6 = require("path");
|
|
287271
|
-
var
|
|
287581
|
+
var import_picocolors20 = __toESM(require_picocolors(), 1);
|
|
287272
287582
|
var import_schema7 = require("@abloatai/transaction/schema");
|
|
287273
287583
|
init_push();
|
|
287274
287584
|
var DEFAULT_SCHEMA_PATH4 = "ablo/schema.ts";
|
|
@@ -287291,7 +287601,7 @@ function parseGenerateArgs(argv) {
|
|
|
287291
287601
|
out = argv[++i] ?? out;
|
|
287292
287602
|
break;
|
|
287293
287603
|
default:
|
|
287294
|
-
throw new
|
|
287604
|
+
throw new import_errors17.AbloValidationError(`unknown flag: ${arg}`, { code: "cli_invalid_arguments" });
|
|
287295
287605
|
}
|
|
287296
287606
|
}
|
|
287297
287607
|
return { schemaPath, exportName, out };
|
|
@@ -287301,7 +287611,7 @@ async function generate(argv) {
|
|
|
287301
287611
|
try {
|
|
287302
287612
|
args = parseGenerateArgs(argv);
|
|
287303
287613
|
} catch (err) {
|
|
287304
|
-
console.error(
|
|
287614
|
+
console.error(import_picocolors20.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
287305
287615
|
process.exit(1);
|
|
287306
287616
|
}
|
|
287307
287617
|
let source;
|
|
@@ -287310,21 +287620,21 @@ async function generate(argv) {
|
|
|
287310
287620
|
const schemaJson = JSON.parse((0, import_schema7.serializeSchema)(schema));
|
|
287311
287621
|
source = (0, import_schema7.generateTypes)(schemaJson);
|
|
287312
287622
|
} catch (err) {
|
|
287313
|
-
console.error(
|
|
287623
|
+
console.error(import_picocolors20.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
287314
287624
|
process.exit(1);
|
|
287315
287625
|
}
|
|
287316
287626
|
const abs = (0, import_path6.resolve)(process.cwd(), args.out);
|
|
287317
287627
|
(0, import_fs8.mkdirSync)((0, import_path6.dirname)(abs), { recursive: true });
|
|
287318
287628
|
(0, import_fs8.writeFileSync)(abs, source);
|
|
287319
|
-
console.log(` ${
|
|
287629
|
+
console.log(` ${import_picocolors20.default.green("\u2713")} Generated types \u2192 ${import_picocolors20.default.bold(args.out)}`);
|
|
287320
287630
|
}
|
|
287321
287631
|
|
|
287322
287632
|
// src/login.ts
|
|
287323
287633
|
init_cjs_shims();
|
|
287324
287634
|
var import_child_process2 = require("child_process");
|
|
287325
|
-
var
|
|
287635
|
+
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
287326
287636
|
init_dist2();
|
|
287327
|
-
var
|
|
287637
|
+
var import_errors18 = require("@abloatai/transaction/errors");
|
|
287328
287638
|
var import_wire8 = require("@abloatai/transaction/wire");
|
|
287329
287639
|
init_config();
|
|
287330
287640
|
init_theme();
|
|
@@ -287386,9 +287696,9 @@ async function deviceLogin(argv, deps = {}) {
|
|
|
287386
287696
|
const code = await codeRes.json();
|
|
287387
287697
|
const approvePath = `/cli?user_code=${code.user_code}${targetOrg ? `&org=${encodeURIComponent(targetOrg)}` : ""}`;
|
|
287388
287698
|
const url = account === "signup" ? `${DASHBOARD_URL}/signup?next=${encodeURIComponent(approvePath)}` : `${DASHBOARD_URL}${approvePath}`;
|
|
287389
|
-
Me(`${
|
|
287699
|
+
Me(`${import_picocolors21.default.bold(code.user_code)}
|
|
287390
287700
|
|
|
287391
|
-
${
|
|
287701
|
+
${import_picocolors21.default.dim(url)}`, "Approve in your browser");
|
|
287392
287702
|
openUrl(url);
|
|
287393
287703
|
const s = Y2();
|
|
287394
287704
|
s.start("Waiting for approval\u2026");
|
|
@@ -287458,7 +287768,7 @@ ${import_picocolors20.default.dim(url)}`, "Approve in your browser");
|
|
|
287458
287768
|
}
|
|
287459
287769
|
if (!provRes.ok) {
|
|
287460
287770
|
s.stop("Could not provision a key.");
|
|
287461
|
-
const err = (0,
|
|
287771
|
+
const err = (0, import_errors18.translateHttpError)(
|
|
287462
287772
|
provRes.status,
|
|
287463
287773
|
await provRes.json().catch(() => null),
|
|
287464
287774
|
provRes.headers.get("x-request-id") ?? void 0
|
|
@@ -287466,11 +287776,11 @@ ${import_picocolors20.default.dim(url)}`, "Approve in your browser");
|
|
|
287466
287776
|
M2.error(err.message);
|
|
287467
287777
|
if (err.code === "entity_not_found" && targetProject) {
|
|
287468
287778
|
M2.error(
|
|
287469
|
-
`If that isn't the account you meant, run ${
|
|
287779
|
+
`If that isn't the account you meant, run ${import_picocolors21.default.bold("npx ablo logout")} and sign in again. Otherwise create it with ${import_picocolors21.default.bold(`npx ablo projects create ${targetProject}`)}.`
|
|
287470
287780
|
);
|
|
287471
287781
|
} else {
|
|
287472
287782
|
M2.error(
|
|
287473
|
-
`The browser approval succeeded but the credential handoff failed. Try ${
|
|
287783
|
+
`The browser approval succeeded but the credential handoff failed. Try ${import_picocolors21.default.bold("npx ablo login")} again.`
|
|
287474
287784
|
);
|
|
287475
287785
|
}
|
|
287476
287786
|
process.exit(1);
|
|
@@ -287481,7 +287791,7 @@ ${import_picocolors20.default.dim(url)}`, "Approve in your browser");
|
|
|
287481
287791
|
if (!parsedProv.success) {
|
|
287482
287792
|
s.stop("Could not provision a key.");
|
|
287483
287793
|
M2.error("The key handoff returned something this version does not recognize.");
|
|
287484
|
-
M2.error(`Try again, or upgrade with ${
|
|
287794
|
+
M2.error(`Try again, or upgrade with ${import_picocolors21.default.bold("npm i -g @abloatai/ablo")}.`);
|
|
287485
287795
|
process.exit(1);
|
|
287486
287796
|
}
|
|
287487
287797
|
const prov = parsedProv.data;
|
|
@@ -287493,7 +287803,7 @@ ${import_picocolors20.default.dim(url)}`, "Approve in your browser");
|
|
|
287493
287803
|
});
|
|
287494
287804
|
if (targetOrg && prov.organizationSlug && prov.organizationSlug !== targetOrg) {
|
|
287495
287805
|
M2.warn(
|
|
287496
|
-
`The approval chose ${
|
|
287806
|
+
`The approval chose ${import_picocolors21.default.bold(prov.organizationSlug)}, not ${import_picocolors21.default.bold(targetOrg)}. The credential is scoped to ${import_picocolors21.default.bold(prov.organizationSlug)}.`
|
|
287497
287807
|
);
|
|
287498
287808
|
}
|
|
287499
287809
|
const profileName = prov.project?.slug ?? DEFAULT_PROFILE;
|
|
@@ -287505,10 +287815,10 @@ ${import_picocolors20.default.dim(url)}`, "Approve in your browser");
|
|
|
287505
287815
|
{ mode: "sandbox", activeProject: prov.project ?? void 0 }
|
|
287506
287816
|
);
|
|
287507
287817
|
s.stop(`Saved project credential to ${path}`);
|
|
287508
|
-
const orgLabel = prov.organizationSlug ? ` to ${
|
|
287509
|
-
const where = prov.project ? ` ${
|
|
287818
|
+
const orgLabel = prov.organizationSlug ? ` to ${import_picocolors21.default.bold(prov.organizationSlug)}` : "";
|
|
287819
|
+
const where = prov.project ? ` ${import_picocolors21.default.dim(`(project ${prov.project.slug})`)}` : "";
|
|
287510
287820
|
Se(
|
|
287511
|
-
`${
|
|
287821
|
+
`${import_picocolors21.default.green("\u2713")} Logged in${orgLabel}${where}. Run ${import_picocolors21.default.bold("npx ablo dev")} to create or resume your Git branch and start with an expiring runtime key.`
|
|
287512
287822
|
);
|
|
287513
287823
|
}
|
|
287514
287824
|
async function login(argv = [], deps = {}) {
|
|
@@ -287517,14 +287827,14 @@ async function login(argv = [], deps = {}) {
|
|
|
287517
287827
|
function logout() {
|
|
287518
287828
|
const removed = clearCredential();
|
|
287519
287829
|
if (removed) {
|
|
287520
|
-
console.log(` ${
|
|
287830
|
+
console.log(` ${import_picocolors21.default.green("\u2713")} Logged out ${import_picocolors21.default.dim(`(credentials removed from ${configDir()})`)}`);
|
|
287521
287831
|
} else {
|
|
287522
|
-
console.log(` ${
|
|
287832
|
+
console.log(` ${import_picocolors21.default.dim("\u25CB")} Not logged in \u2014 nothing to remove.`);
|
|
287523
287833
|
}
|
|
287524
287834
|
if (process.env.ABLO_MANAGEMENT_KEY) {
|
|
287525
287835
|
console.log(
|
|
287526
|
-
|
|
287527
|
-
` Note: ${
|
|
287836
|
+
import_picocolors21.default.dim(
|
|
287837
|
+
` Note: ${import_picocolors21.default.bold("ABLO_MANAGEMENT_KEY")} is still set in this shell and takes precedence.`
|
|
287528
287838
|
)
|
|
287529
287839
|
);
|
|
287530
287840
|
}
|
|
@@ -287535,7 +287845,7 @@ init_projects();
|
|
|
287535
287845
|
|
|
287536
287846
|
// src/status.ts
|
|
287537
287847
|
init_cjs_shims();
|
|
287538
|
-
var
|
|
287848
|
+
var import_picocolors22 = __toESM(require_picocolors(), 1);
|
|
287539
287849
|
init_config();
|
|
287540
287850
|
init_target();
|
|
287541
287851
|
init_theme();
|
|
@@ -287545,9 +287855,9 @@ init_readiness();
|
|
|
287545
287855
|
function expiryLabel(iso) {
|
|
287546
287856
|
const ms = Date.parse(iso) - Date.now();
|
|
287547
287857
|
if (Number.isNaN(ms)) return "";
|
|
287548
|
-
if (ms <= 0) return
|
|
287858
|
+
if (ms <= 0) return import_picocolors22.default.red("expired");
|
|
287549
287859
|
const days = Math.floor(ms / (24 * 60 * 60 * 1e3));
|
|
287550
|
-
return
|
|
287860
|
+
return import_picocolors22.default.dim(days > 0 ? `expires in ${days}d` : "expires <1d");
|
|
287551
287861
|
}
|
|
287552
287862
|
async function ping2(apiUrl3) {
|
|
287553
287863
|
const ctrl = new AbortController();
|
|
@@ -287574,38 +287884,38 @@ function printTargetLines(target, localProject, storedOrganizationId, storedOrga
|
|
|
287574
287884
|
const confirmed = target?.confirmed ?? null;
|
|
287575
287885
|
const org = confirmed?.organizationId ?? storedOrganizationId;
|
|
287576
287886
|
if (org) {
|
|
287577
|
-
const suffix = confirmed?.organizationId ? "" : ` ${
|
|
287887
|
+
const suffix = confirmed?.organizationId ? "" : ` ${import_picocolors22.default.yellow("(unconfirmed)")}`;
|
|
287578
287888
|
const slug = org === storedOrganizationId ? storedOrganizationSlug : void 0;
|
|
287579
|
-
const label = slug ? `${
|
|
287580
|
-
console.log(` ${
|
|
287889
|
+
const label = slug ? `${import_picocolors22.default.bold(slug)} ${import_picocolors22.default.dim(`(${org})`)}` : import_picocolors22.default.dim(org);
|
|
287890
|
+
console.log(` ${import_picocolors22.default.dim("org")} ${label}${suffix}`);
|
|
287581
287891
|
} else {
|
|
287582
287892
|
console.log(
|
|
287583
|
-
` ${
|
|
287893
|
+
` ${import_picocolors22.default.dim("org")} ${import_picocolors22.default.yellow("unknown")} ${import_picocolors22.default.dim("(the server did not confirm one for this key)")}`
|
|
287584
287894
|
);
|
|
287585
287895
|
}
|
|
287586
287896
|
let projectLine;
|
|
287587
287897
|
if (confirmed?.project) {
|
|
287588
287898
|
const p2 = confirmed.project;
|
|
287589
|
-
projectLine = p2.isDefault ? `${
|
|
287899
|
+
projectLine = p2.isDefault ? `${import_picocolors22.default.bold("default")} ${import_picocolors22.default.dim("(org-default)")}` : `${import_picocolors22.default.bold(p2.slug)} ${import_picocolors22.default.dim(`(${p2.id})`)}`;
|
|
287590
287900
|
} else if (confirmed) {
|
|
287591
|
-
projectLine = `${
|
|
287901
|
+
projectLine = `${import_picocolors22.default.bold("default")} ${import_picocolors22.default.dim("(org-default)")}`;
|
|
287592
287902
|
} else if (localProject) {
|
|
287593
|
-
projectLine = `${
|
|
287903
|
+
projectLine = `${import_picocolors22.default.bold(localProject.slug)} ${import_picocolors22.default.dim(`(${localProject.id})`)} ${import_picocolors22.default.yellow("(unconfirmed)")}`;
|
|
287594
287904
|
} else {
|
|
287595
|
-
projectLine = `${
|
|
287905
|
+
projectLine = `${import_picocolors22.default.bold("default")} ${target ? import_picocolors22.default.yellow("(unconfirmed)") : import_picocolors22.default.dim("(org-default)")}`;
|
|
287596
287906
|
}
|
|
287597
|
-
console.log(` ${
|
|
287907
|
+
console.log(` ${import_picocolors22.default.dim("project")} ${projectLine}`);
|
|
287598
287908
|
const branch = confirmed?.branchId ?? null;
|
|
287599
287909
|
const env = confirmed?.environment ?? target?.keyEnv ?? null;
|
|
287600
287910
|
if (branch) {
|
|
287601
287911
|
const label = confirmed?.branchRoot ? "production root" : `branch ${branch}`;
|
|
287602
|
-
console.log(` ${
|
|
287912
|
+
console.log(` ${import_picocolors22.default.dim("acts on")} ${import_picocolors22.default.bold(label)}`);
|
|
287603
287913
|
} else if (env) {
|
|
287604
|
-
const suffix = confirmed ? "" : ` ${
|
|
287605
|
-
console.log(` ${
|
|
287914
|
+
const suffix = confirmed ? "" : ` ${import_picocolors22.default.yellow("(unconfirmed)")}`;
|
|
287915
|
+
console.log(` ${import_picocolors22.default.dim("acts on")} ${import_picocolors22.default.bold(env)}${suffix}`);
|
|
287606
287916
|
}
|
|
287607
287917
|
const divergence = describeMismatches(target?.mismatches ?? []);
|
|
287608
|
-
if (divergence) console.log(` ${
|
|
287918
|
+
if (divergence) console.log(` ${import_picocolors22.default.yellow(`\u26A0 ${divergence}`)}`);
|
|
287609
287919
|
}
|
|
287610
287920
|
async function status(args = []) {
|
|
287611
287921
|
const apiUrl3 = apiBaseUrl();
|
|
@@ -287689,15 +287999,15 @@ async function status(args = []) {
|
|
|
287689
287999
|
return;
|
|
287690
288000
|
}
|
|
287691
288001
|
console.log(`
|
|
287692
|
-
${brand("ablo")} ${
|
|
288002
|
+
${brand("ablo")} ${import_picocolors22.default.dim("status")}
|
|
287693
288003
|
`);
|
|
287694
288004
|
if (runtimeKey.key && runtimeKey.source && runtimeKey.source !== "stored") {
|
|
287695
288005
|
const label = runtimeKey.source === "env" ? "ABLO_API_KEY env" : runtimeKey.source;
|
|
287696
288006
|
console.log(
|
|
287697
|
-
` ${
|
|
288007
|
+
` ${import_picocolors22.default.dim("key")} ${runtimeKey.key.slice(0, 12)}\u2026 ${import_picocolors22.default.dim(`(${label} \u2014 overrides stored)`)}`
|
|
287698
288008
|
);
|
|
287699
288009
|
} else if (!cfg) {
|
|
287700
|
-
console.log(` ${
|
|
288010
|
+
console.log(` ${import_picocolors22.default.yellow("!")} Not logged in \u2014 run ${import_picocolors22.default.bold("ablo login")}.`);
|
|
287701
288011
|
}
|
|
287702
288012
|
const activeEntry = getKeyEntry(mode);
|
|
287703
288013
|
const activeProject = getActiveProject();
|
|
@@ -287709,9 +288019,9 @@ async function status(args = []) {
|
|
|
287709
288019
|
);
|
|
287710
288020
|
const management = getManagementKeyEntry();
|
|
287711
288021
|
console.log(
|
|
287712
|
-
` ${
|
|
288022
|
+
` ${import_picocolors22.default.dim("\u25CB")} ${"management".padEnd(12)} ${management ? import_picocolors22.default.dim(
|
|
287713
288023
|
`${management.apiKey.slice(0, 12)}\u2026${management.expiresAt ? ` \xB7 ${expiryLabel(management.expiresAt)}` : ""}`
|
|
287714
|
-
) :
|
|
288024
|
+
) : import_picocolors22.default.dim("\u2014 no key")}`
|
|
287715
288025
|
);
|
|
287716
288026
|
for (const { key: m2, label } of [
|
|
287717
288027
|
{ key: "sandbox", label: "legacy child" },
|
|
@@ -287723,21 +288033,21 @@ async function status(args = []) {
|
|
|
287723
288033
|
credentialCapability(entry.apiKey).label,
|
|
287724
288034
|
entry.expiresAt ? expiryLabel(entry.expiresAt) : ""
|
|
287725
288035
|
].filter(Boolean);
|
|
287726
|
-
const trail = facts.length ? ` ${
|
|
288036
|
+
const trail = facts.length ? ` ${import_picocolors22.default.dim("\xB7")} ${facts.join(import_picocolors22.default.dim(" \xB7 "))}` : "";
|
|
287727
288037
|
console.log(
|
|
287728
|
-
` ${
|
|
288038
|
+
` ${import_picocolors22.default.dim("\u25CB")} ${label.padEnd(12)} ${import_picocolors22.default.dim(`${entry.apiKey.slice(0, 12)}\u2026`)}${trail}`
|
|
287729
288039
|
);
|
|
287730
288040
|
}
|
|
287731
288041
|
}
|
|
287732
288042
|
const pushBranch = target?.confirmed?.branchRoot === true ? "production root" : target?.confirmed?.branchId ? `branch ${target.confirmed.branchId}` : runtimeKey.key ? "unknown branch" : "no branch";
|
|
287733
288043
|
console.log(
|
|
287734
|
-
` ${
|
|
288044
|
+
` ${import_picocolors22.default.dim("push")} ${runtimeKey.key ? `${import_picocolors22.default.bold(pushBranch)} ${import_picocolors22.default.dim(`with ${runtimeKey.key.slice(0, 12)}\u2026 (${runtimeKey.source})`)}` : `${import_picocolors22.default.bold(pushBranch)} ${import_picocolors22.default.yellow("\u2014 no runtime key")} ${import_picocolors22.default.dim(`(set ${import_picocolors22.default.bold("ABLO_API_KEY")} or run ${import_picocolors22.default.bold("ablo dev")})`)}`}`
|
|
287735
288045
|
);
|
|
287736
288046
|
const capability = credentialCapability(runtimeKey.key);
|
|
287737
|
-
if (capability.note) console.log(` ${
|
|
287738
|
-
process.stdout.write(` ${
|
|
288047
|
+
if (capability.note) console.log(` ${import_picocolors22.default.dim(capability.note)}`);
|
|
288048
|
+
process.stdout.write(` ${import_picocolors22.default.dim("api")} ${apiUrl3} `);
|
|
287739
288049
|
const reachable = await ping2(apiUrl3);
|
|
287740
|
-
console.log(reachable ?
|
|
288050
|
+
console.log(reachable ? import_picocolors22.default.green("reachable") : import_picocolors22.default.red("unreachable"));
|
|
287741
288051
|
const introspectKey = runtimeKey.key;
|
|
287742
288052
|
const { source: dataSource, validation } = reachable ? await fetchRoutingState(apiUrl3, introspectKey) : { source: { kind: "unknown", detail: "unreachable" }, validation: null };
|
|
287743
288053
|
if (dataSource.kind === "connected") {
|
|
@@ -287745,65 +288055,65 @@ async function status(args = []) {
|
|
|
287745
288055
|
const pooled = detectPoolerIn(dataSource.hosts);
|
|
287746
288056
|
const unreachable = validation && !validation.ok ? validation.message : void 0;
|
|
287747
288057
|
console.log(
|
|
287748
|
-
` ${
|
|
288058
|
+
` ${import_picocolors22.default.dim("data")} ${import_picocolors22.default.green("\u2713")} ${import_picocolors22.default.dim(`database connected to this plane (${how})`)}`
|
|
287749
288059
|
);
|
|
287750
288060
|
if (pooled) {
|
|
287751
288061
|
console.log(
|
|
287752
|
-
` ${
|
|
288062
|
+
` ${import_picocolors22.default.yellow("\u26A0")} ${import_picocolors22.default.dim(
|
|
287753
288063
|
`${pooled.host} is a connection pooler` + (pooled.direct ? `; register the direct host instead: ${pooled.direct}` : "; register the direct host instead")
|
|
287754
288064
|
)}`
|
|
287755
288065
|
);
|
|
287756
288066
|
}
|
|
287757
288067
|
if (unreachable) {
|
|
287758
|
-
console.log(` ${
|
|
288068
|
+
console.log(` ${import_picocolors22.default.red("\u2717")} ${import_picocolors22.default.dim(`Ablo could not reach it \u2014 ${unreachable}`)}`);
|
|
287759
288069
|
}
|
|
287760
288070
|
if (validation?.ok && validation.initialSnapshot?.status === "loading") {
|
|
287761
288071
|
console.log(
|
|
287762
|
-
` ${
|
|
287763
|
-
`loading rows that predate the connection \u2014 automatic; check with ${
|
|
288072
|
+
` ${import_picocolors22.default.yellow("\u25CC")} ${import_picocolors22.default.dim(
|
|
288073
|
+
`loading rows that predate the connection \u2014 automatic; check with ${import_picocolors22.default.bold("ablo connect check")}`
|
|
287764
288074
|
)}`
|
|
287765
288075
|
);
|
|
287766
288076
|
} else if (validation?.ok && validation.initialSnapshot?.status === "retrying") {
|
|
287767
288077
|
console.log(
|
|
287768
|
-
` ${
|
|
288078
|
+
` ${import_picocolors22.default.red("\u2717")} ${import_picocolors22.default.dim(
|
|
287769
288079
|
`loading existing rows is retrying${validation.initialSnapshot.detail ? ` \u2014 ${validation.initialSnapshot.detail}` : ""}`
|
|
287770
288080
|
)}`
|
|
287771
288081
|
);
|
|
287772
288082
|
}
|
|
287773
288083
|
} else if (dataSource.kind === "none") {
|
|
287774
288084
|
console.log(
|
|
287775
|
-
` ${
|
|
288085
|
+
` ${import_picocolors22.default.dim("data")} ${import_picocolors22.default.red("\u2717 this branch is not connected to a database")} ${import_picocolors22.default.dim("\u2014 writes are held")}`
|
|
287776
288086
|
);
|
|
287777
288087
|
} else if (reachable) {
|
|
287778
288088
|
console.log(
|
|
287779
|
-
` ${
|
|
288089
|
+
` ${import_picocolors22.default.dim("data")} ${import_picocolors22.default.yellow("?")} ${import_picocolors22.default.dim(`could not read this branch's database connection (${dataSource.detail})`)}`
|
|
287780
288090
|
);
|
|
287781
288091
|
}
|
|
287782
288092
|
const pushed = reachable ? await fetchPushedSchema(apiUrl3, introspectKey) : null;
|
|
287783
288093
|
if (reachable) {
|
|
287784
288094
|
if (pushed?.active) {
|
|
287785
|
-
const when = pushed.pushedAt ? ` ${
|
|
287786
|
-
const ver = pushed.version != null ? ` ${
|
|
287787
|
-
const hashLabel = pushed.hash ? ` ${
|
|
288095
|
+
const when = pushed.pushedAt ? ` ${import_picocolors22.default.dim(`@ ${pushed.pushedAt.slice(0, 10)}`)}` : "";
|
|
288096
|
+
const ver = pushed.version != null ? ` ${import_picocolors22.default.dim(`(rev ${pushed.version})`)}` : "";
|
|
288097
|
+
const hashLabel = pushed.hash ? ` ${import_picocolors22.default.dim(`hash ${pushed.hash}`)}` : "";
|
|
287788
288098
|
console.log(
|
|
287789
|
-
` ${
|
|
288099
|
+
` ${import_picocolors22.default.dim("schema")} ${import_picocolors22.default.bold(`${pushed.models.length} models pushed`)}${ver}${hashLabel}${when}`
|
|
287790
288100
|
);
|
|
287791
288101
|
for (const m2 of pushed.models) {
|
|
287792
|
-
const tn = m2.typename === m2.key ?
|
|
288102
|
+
const tn = m2.typename === m2.key ? import_picocolors22.default.dim(`typename=${m2.typename}`) : import_picocolors22.default.yellow(`typename=${m2.typename}`);
|
|
287793
288103
|
const conflict = formatConflict(m2.conflict);
|
|
287794
|
-
const conflictStr2 = conflict ? ` ${
|
|
287795
|
-
console.log(` ${
|
|
288104
|
+
const conflictStr2 = conflict ? ` ${import_picocolors22.default.dim(`conflict=${conflict}`)}` : "";
|
|
288105
|
+
console.log(` ${import_picocolors22.default.dim("\u2022")} ${m2.key.padEnd(14)} ${tn}${conflictStr2}`);
|
|
287796
288106
|
}
|
|
287797
288107
|
} else if (pushed && !pushed.active) {
|
|
287798
288108
|
console.log(
|
|
287799
|
-
` ${
|
|
288109
|
+
` ${import_picocolors22.default.dim("schema")} ${import_picocolors22.default.yellow("none pushed")} ${import_picocolors22.default.dim(`(run ${import_picocolors22.default.bold("ablo push")} or ${import_picocolors22.default.bold("ablo dev")})`)}`
|
|
287800
288110
|
);
|
|
287801
288111
|
}
|
|
287802
288112
|
}
|
|
287803
288113
|
const drift = schemaDrift(await readLocalSchemaHash(), pushed?.hash);
|
|
287804
288114
|
if (drift) {
|
|
287805
288115
|
console.log(
|
|
287806
|
-
` ${
|
|
288116
|
+
` ${import_picocolors22.default.dim("drift")} ${import_picocolors22.default.red("\u2717 local schema differs from the server")} ` + import_picocolors22.default.dim(`(local ${drift.local}, server ${drift.server})`)
|
|
287807
288117
|
);
|
|
287808
288118
|
}
|
|
287809
288119
|
const found = blockers({
|
|
@@ -287815,18 +288125,18 @@ async function status(args = []) {
|
|
|
287815
288125
|
});
|
|
287816
288126
|
console.log();
|
|
287817
288127
|
if (found.length > 0) {
|
|
287818
|
-
console.log(` ${
|
|
288128
|
+
console.log(` ${import_picocolors22.default.red("\u2717")} ${import_picocolors22.default.bold("writes would fail right now")}`);
|
|
287819
288129
|
for (const b4 of found) {
|
|
287820
|
-
console.log(` ${
|
|
287821
|
-
console.log(` ${
|
|
288130
|
+
console.log(` ${import_picocolors22.default.dim("\xB7")} ${b4.problem}`);
|
|
288131
|
+
console.log(` ${import_picocolors22.default.dim(b4.fix)}`);
|
|
287822
288132
|
}
|
|
287823
288133
|
} else if (dataSource.kind === "unknown") {
|
|
287824
288134
|
console.log(
|
|
287825
|
-
` ${
|
|
288135
|
+
` ${import_picocolors22.default.yellow("?")} ${import_picocolors22.default.dim("nothing is blocking a write, but this key could not read the branch's database connection \u2014 some checks were skipped")}`
|
|
287826
288136
|
);
|
|
287827
288137
|
} else {
|
|
287828
288138
|
console.log(
|
|
287829
|
-
` ${
|
|
288139
|
+
` ${import_picocolors22.default.green("\u2713")} ${import_picocolors22.default.dim("write infrastructure is ready \u2014 database constraints and row-level policies still apply")}`
|
|
287830
288140
|
);
|
|
287831
288141
|
}
|
|
287832
288142
|
console.log();
|
|
@@ -287834,9 +288144,9 @@ async function status(args = []) {
|
|
|
287834
288144
|
|
|
287835
288145
|
// src/logs.ts
|
|
287836
288146
|
init_cjs_shims();
|
|
287837
|
-
var
|
|
288147
|
+
var import_errors19 = require("@abloatai/transaction/errors");
|
|
287838
288148
|
var import_wire9 = require("@abloatai/transaction/wire");
|
|
287839
|
-
var
|
|
288149
|
+
var import_picocolors23 = __toESM(require_picocolors(), 1);
|
|
287840
288150
|
init_config();
|
|
287841
288151
|
init_theme();
|
|
287842
288152
|
init_controlPlane();
|
|
@@ -287876,12 +288186,12 @@ function parseLogsArgs(argv) {
|
|
|
287876
288186
|
args.json = true;
|
|
287877
288187
|
break;
|
|
287878
288188
|
case "--mode":
|
|
287879
|
-
throw new
|
|
288189
|
+
throw new import_errors19.AbloValidationError(
|
|
287880
288190
|
"--mode was removed. Logs follow the branch bound to ABLO_API_KEY; select a different branch by supplying its key.",
|
|
287881
288191
|
{ code: "cli_invalid_arguments" }
|
|
287882
288192
|
);
|
|
287883
288193
|
default:
|
|
287884
|
-
throw new
|
|
288194
|
+
throw new import_errors19.AbloValidationError(`unknown flag: ${arg}`, { code: "cli_invalid_arguments" });
|
|
287885
288195
|
}
|
|
287886
288196
|
}
|
|
287887
288197
|
return args;
|
|
@@ -287900,10 +288210,10 @@ function resolveSince(since) {
|
|
|
287900
288210
|
var sleep2 = (ms) => new Promise((r2) => setTimeout(r2, ms));
|
|
287901
288211
|
function colorOp(op) {
|
|
287902
288212
|
const label = op.padEnd(6);
|
|
287903
|
-
if (op === "create") return
|
|
287904
|
-
if (op === "update") return
|
|
287905
|
-
if (op === "delete") return
|
|
287906
|
-
return
|
|
288213
|
+
if (op === "create") return import_picocolors23.default.green(label);
|
|
288214
|
+
if (op === "update") return import_picocolors23.default.yellow(label);
|
|
288215
|
+
if (op === "delete") return import_picocolors23.default.red(label);
|
|
288216
|
+
return import_picocolors23.default.dim(label);
|
|
287907
288217
|
}
|
|
287908
288218
|
function render2(e2, json) {
|
|
287909
288219
|
if (json) {
|
|
@@ -287912,21 +288222,21 @@ function render2(e2, json) {
|
|
|
287912
288222
|
return;
|
|
287913
288223
|
}
|
|
287914
288224
|
const t = new Date(e2.at).toLocaleTimeString();
|
|
287915
|
-
const actor = e2.actor ?
|
|
287916
|
-
console.log(` ${
|
|
288225
|
+
const actor = e2.actor ? import_picocolors23.default.dim(` ${e2.actor}`) : "";
|
|
288226
|
+
console.log(` ${import_picocolors23.default.dim(t)} ${colorOp(e2.op)} ${import_picocolors23.default.bold(e2.model)} ${import_picocolors23.default.dim(e2.recordId)}${actor}`);
|
|
287917
288227
|
}
|
|
287918
288228
|
async function logs(argv) {
|
|
287919
288229
|
let args;
|
|
287920
288230
|
try {
|
|
287921
288231
|
args = parseLogsArgs(argv);
|
|
287922
288232
|
} catch (err) {
|
|
287923
|
-
console.error(
|
|
288233
|
+
console.error(import_picocolors23.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
287924
288234
|
process.exit(1);
|
|
287925
288235
|
}
|
|
287926
288236
|
const apiKey = resolveRuntimeApiKey().key;
|
|
287927
288237
|
if (!apiKey) {
|
|
287928
288238
|
console.error(
|
|
287929
|
-
|
|
288239
|
+
import_picocolors23.default.red(` No API key.`) + import_picocolors23.default.dim(` Run ${import_picocolors23.default.bold("ablo login")} or set ${import_picocolors23.default.bold("ABLO_API_KEY")}.`)
|
|
287930
288240
|
);
|
|
287931
288241
|
process.exit(1);
|
|
287932
288242
|
}
|
|
@@ -287940,7 +288250,7 @@ async function logs(argv) {
|
|
|
287940
288250
|
if (!res) return null;
|
|
287941
288251
|
if (!res.ok) {
|
|
287942
288252
|
const body = await res.json().catch(() => ({}));
|
|
287943
|
-
console.error(
|
|
288253
|
+
console.error(import_picocolors23.default.red(` logs failed (${res.status}): ${body.reason ?? body.message ?? ""}`));
|
|
287944
288254
|
process.exit(1);
|
|
287945
288255
|
}
|
|
287946
288256
|
const json = await res.json();
|
|
@@ -287951,7 +288261,7 @@ async function logs(argv) {
|
|
|
287951
288261
|
}
|
|
287952
288262
|
if (!args.json) {
|
|
287953
288263
|
console.log(`
|
|
287954
|
-
${brand("ablo")} ${
|
|
288264
|
+
${brand("ablo")} ${import_picocolors23.default.dim("logs")}
|
|
287955
288265
|
`);
|
|
287956
288266
|
}
|
|
287957
288267
|
const initial = await fetchPage({
|
|
@@ -287961,13 +288271,13 @@ async function logs(argv) {
|
|
|
287961
288271
|
...args.op ? { op: args.op } : {}
|
|
287962
288272
|
});
|
|
287963
288273
|
if (!initial) {
|
|
287964
|
-
console.error(
|
|
288274
|
+
console.error(import_picocolors23.default.red(` Couldn't reach ${baseUrl2}.`));
|
|
287965
288275
|
process.exit(1);
|
|
287966
288276
|
}
|
|
287967
288277
|
for (const e2 of initial.events) render2(e2, args.json);
|
|
287968
288278
|
let cursor = initial.cursor;
|
|
287969
288279
|
if (!args.follow) return;
|
|
287970
|
-
if (!args.json) console.log(` ${
|
|
288280
|
+
if (!args.json) console.log(` ${import_picocolors23.default.dim("watching for new activity \u2026 (Ctrl-C to stop)")}
|
|
287971
288281
|
`);
|
|
287972
288282
|
for (; ; ) {
|
|
287973
288283
|
await sleep2(1500);
|
|
@@ -287987,7 +288297,7 @@ async function logs(argv) {
|
|
|
287987
288297
|
// src/webhooks.ts
|
|
287988
288298
|
init_cjs_shims();
|
|
287989
288299
|
var import_fs9 = require("fs");
|
|
287990
|
-
var
|
|
288300
|
+
var import_picocolors24 = __toESM(require_picocolors(), 1);
|
|
287991
288301
|
var import_credentialPolicy4 = require("@abloatai/transaction/auth/credentialPolicy");
|
|
287992
288302
|
init_config();
|
|
287993
288303
|
init_theme();
|
|
@@ -288020,12 +288330,12 @@ function requireKey3(mode) {
|
|
|
288020
288330
|
const apiKey = resolveMutationApiKey(mode);
|
|
288021
288331
|
if (!apiKey) {
|
|
288022
288332
|
console.error(
|
|
288023
|
-
|
|
288333
|
+
import_picocolors24.default.red(" No API key.") + import_picocolors24.default.dim(` Run ${import_picocolors24.default.bold("ablo login")} or set ${import_picocolors24.default.bold("ABLO_API_KEY")}.`)
|
|
288024
288334
|
);
|
|
288025
288335
|
process.exit(1);
|
|
288026
288336
|
}
|
|
288027
288337
|
if ((0, import_credentialPolicy4.classifyCredentialKind)(apiKey) !== "secret") {
|
|
288028
|
-
console.error(
|
|
288338
|
+
console.error(import_picocolors24.default.red(" Managing webhooks requires a branch-bound secret key ") + import_picocolors24.default.dim("(sk_)."));
|
|
288029
288339
|
process.exit(1);
|
|
288030
288340
|
}
|
|
288031
288341
|
return apiKey;
|
|
@@ -288041,12 +288351,12 @@ async function api(apiKey, method, path, body) {
|
|
|
288041
288351
|
...body ? { body: JSON.stringify(body) } : {}
|
|
288042
288352
|
}).catch(() => null);
|
|
288043
288353
|
if (!res) {
|
|
288044
|
-
console.error(
|
|
288354
|
+
console.error(import_picocolors24.default.red(` Couldn't reach ${baseUrl()}.`));
|
|
288045
288355
|
process.exit(1);
|
|
288046
288356
|
}
|
|
288047
288357
|
if (!res.ok) {
|
|
288048
288358
|
const err = await res.json().catch(() => ({}));
|
|
288049
|
-
console.error(
|
|
288359
|
+
console.error(import_picocolors24.default.red(` Request failed (${res.status}): ${err.message ?? err.reason ?? ""}`));
|
|
288050
288360
|
process.exit(1);
|
|
288051
288361
|
}
|
|
288052
288362
|
return await res.json();
|
|
@@ -288068,11 +288378,11 @@ ${line}
|
|
|
288068
288378
|
return file;
|
|
288069
288379
|
}
|
|
288070
288380
|
function printEndpoint(e2) {
|
|
288071
|
-
const dot = e2.status === "enabled" ?
|
|
288072
|
-
const health = e2.last_error ?
|
|
288073
|
-
console.log(` ${dot} ${
|
|
288381
|
+
const dot = e2.status === "enabled" ? import_picocolors24.default.green("\u25CF") : import_picocolors24.default.red("\u25CF");
|
|
288382
|
+
const health = e2.last_error ? import_picocolors24.default.red(` last error: ${e2.last_error}`) : "";
|
|
288383
|
+
console.log(` ${dot} ${import_picocolors24.default.bold(e2.id)} ${e2.url}`);
|
|
288074
288384
|
console.log(
|
|
288075
|
-
|
|
288385
|
+
import_picocolors24.default.dim(
|
|
288076
288386
|
` ${e2.status} \xB7 ${e2.environment} \xB7 events ${e2.enabled_events.join(",")} \xB7 cursor ${e2.cursor ?? "\u2014"}${health}`
|
|
288077
288387
|
)
|
|
288078
288388
|
);
|
|
@@ -288084,7 +288394,7 @@ async function webhooks(argv) {
|
|
|
288084
288394
|
if (sub === "create") {
|
|
288085
288395
|
const url = positional(rest);
|
|
288086
288396
|
if (!url) {
|
|
288087
|
-
console.error(
|
|
288397
|
+
console.error(import_picocolors24.default.red(" Usage: ") + brand("ablo webhooks create <url>"));
|
|
288088
288398
|
process.exit(1);
|
|
288089
288399
|
}
|
|
288090
288400
|
const apiKey = requireKey3(mode);
|
|
@@ -288096,8 +288406,8 @@ async function webhooks(argv) {
|
|
|
288096
288406
|
});
|
|
288097
288407
|
const file = writeSecretToEnv(created.secret);
|
|
288098
288408
|
console.log(`
|
|
288099
|
-
${
|
|
288100
|
-
console.log(` ${
|
|
288409
|
+
${import_picocolors24.default.green("\u2713")} Registered ${import_picocolors24.default.bold(created.id)} \u2192 ${created.url}`);
|
|
288410
|
+
console.log(` ${import_picocolors24.default.green("\u2713")} Wrote ${import_picocolors24.default.bold(ENV_KEY)} to ${import_picocolors24.default.bold(file)} ${import_picocolors24.default.dim("(shown once)")}
|
|
288101
288411
|
`);
|
|
288102
288412
|
return;
|
|
288103
288413
|
}
|
|
@@ -288105,7 +288415,7 @@ async function webhooks(argv) {
|
|
|
288105
288415
|
const apiKey = requireKey3(mode);
|
|
288106
288416
|
const { data } = await api(apiKey, "GET", "");
|
|
288107
288417
|
if (data.length === 0) {
|
|
288108
|
-
console.log(
|
|
288418
|
+
console.log(import_picocolors24.default.dim(" No webhook endpoints. ") + brand("ablo webhooks create <url>"));
|
|
288109
288419
|
return;
|
|
288110
288420
|
}
|
|
288111
288421
|
console.log();
|
|
@@ -288116,40 +288426,40 @@ async function webhooks(argv) {
|
|
|
288116
288426
|
if (sub === "roll") {
|
|
288117
288427
|
const id = positional(rest);
|
|
288118
288428
|
if (!id) {
|
|
288119
|
-
console.error(
|
|
288429
|
+
console.error(import_picocolors24.default.red(" Usage: ") + brand("ablo webhooks roll <id>"));
|
|
288120
288430
|
process.exit(1);
|
|
288121
288431
|
}
|
|
288122
288432
|
const apiKey = requireKey3(mode);
|
|
288123
288433
|
const rolled = await api(apiKey, "POST", `/${id}/roll_secret`);
|
|
288124
288434
|
const file = writeSecretToEnv(rolled.secret);
|
|
288125
288435
|
console.log(`
|
|
288126
|
-
${
|
|
288436
|
+
${import_picocolors24.default.green("\u2713")} Rolled secret for ${import_picocolors24.default.bold(id)} \u2192 ${import_picocolors24.default.bold(file)} ${import_picocolors24.default.dim("(old secret now invalid)")}
|
|
288127
288437
|
`);
|
|
288128
288438
|
return;
|
|
288129
288439
|
}
|
|
288130
288440
|
if (sub === "enable") {
|
|
288131
288441
|
const id = positional(rest);
|
|
288132
288442
|
if (!id) {
|
|
288133
|
-
console.error(
|
|
288443
|
+
console.error(import_picocolors24.default.red(" Usage: ") + brand("ablo webhooks enable <id>"));
|
|
288134
288444
|
process.exit(1);
|
|
288135
288445
|
}
|
|
288136
288446
|
const apiKey = requireKey3(mode);
|
|
288137
288447
|
const e2 = await api(apiKey, "POST", `/${id}/enable`);
|
|
288138
|
-
console.log(` ${
|
|
288448
|
+
console.log(` ${import_picocolors24.default.green("\u2713")} Re-enabled ${import_picocolors24.default.bold(e2.id)}`);
|
|
288139
288449
|
return;
|
|
288140
288450
|
}
|
|
288141
288451
|
if (sub === "rm" || sub === "delete") {
|
|
288142
288452
|
const id = positional(rest);
|
|
288143
288453
|
if (!id) {
|
|
288144
|
-
console.error(
|
|
288454
|
+
console.error(import_picocolors24.default.red(" Usage: ") + brand("ablo webhooks rm <id>"));
|
|
288145
288455
|
process.exit(1);
|
|
288146
288456
|
}
|
|
288147
288457
|
const apiKey = requireKey3(mode);
|
|
288148
288458
|
await api(apiKey, "DELETE", `/${id}`);
|
|
288149
|
-
console.log(` ${
|
|
288459
|
+
console.log(` ${import_picocolors24.default.green("\u2713")} Removed ${import_picocolors24.default.bold(id)}`);
|
|
288150
288460
|
return;
|
|
288151
288461
|
}
|
|
288152
|
-
console.log(` ${
|
|
288462
|
+
console.log(` ${import_picocolors24.default.bold("Usage:")}`);
|
|
288153
288463
|
console.log(` ${brand("ablo webhooks create <url>")} Register an endpoint; writes ${ENV_KEY}`);
|
|
288154
288464
|
console.log(` ${brand("ablo webhooks list")} List endpoints + delivery health`);
|
|
288155
288465
|
console.log(` ${brand("ablo webhooks roll <id>")} Mint a fresh signing secret`);
|
|
@@ -288160,8 +288470,8 @@ async function webhooks(argv) {
|
|
|
288160
288470
|
|
|
288161
288471
|
// src/check.ts
|
|
288162
288472
|
init_cjs_shims();
|
|
288163
|
-
var
|
|
288164
|
-
var
|
|
288473
|
+
var import_errors20 = require("@abloatai/transaction/errors");
|
|
288474
|
+
var import_picocolors25 = __toESM(require_picocolors(), 1);
|
|
288165
288475
|
init_src();
|
|
288166
288476
|
var import_schema9 = require("@abloatai/transaction/schema");
|
|
288167
288477
|
init_push();
|
|
@@ -288308,7 +288618,7 @@ function parseCheckArgs(argv) {
|
|
|
288308
288618
|
appSchema = argv[++i] ?? appSchema;
|
|
288309
288619
|
break;
|
|
288310
288620
|
default:
|
|
288311
|
-
throw new
|
|
288621
|
+
throw new import_errors20.AbloValidationError(`unknown flag: ${arg}`, { code: "cli_invalid_arguments" });
|
|
288312
288622
|
}
|
|
288313
288623
|
}
|
|
288314
288624
|
return { schemaPath, exportName, appSchema };
|
|
@@ -288322,22 +288632,22 @@ function hostOf(connectionString) {
|
|
|
288322
288632
|
}
|
|
288323
288633
|
async function reportReadSubject(dbUrl) {
|
|
288324
288634
|
const host = hostOf(dbUrl);
|
|
288325
|
-
console.log(` ${
|
|
288635
|
+
console.log(` ${import_picocolors25.default.dim("reading")} ${import_picocolors25.default.bold(host ?? "your database")}`);
|
|
288326
288636
|
const runtimeKey = resolveRuntimeApiKey();
|
|
288327
288637
|
const state = await fetchDataSourceState(apiBaseUrl(), runtimeKey.key);
|
|
288328
288638
|
if (state.kind === "unknown") {
|
|
288329
288639
|
console.log(
|
|
288330
|
-
` ${
|
|
288640
|
+
` ${import_picocolors25.default.dim("ablo")} ${import_picocolors25.default.yellow("?")} ${import_picocolors25.default.dim(`couldn't ask which database Ablo reads (${state.detail})`)}
|
|
288331
288641
|
`
|
|
288332
288642
|
);
|
|
288333
288643
|
return;
|
|
288334
288644
|
}
|
|
288335
288645
|
if (state.kind === "none") {
|
|
288336
288646
|
console.log(
|
|
288337
|
-
` ${
|
|
288647
|
+
` ${import_picocolors25.default.dim("ablo")} ${import_picocolors25.default.yellow("!")} this branch is not connected to a database, so Ablo does not read this one`
|
|
288338
288648
|
);
|
|
288339
288649
|
console.log(
|
|
288340
|
-
` ${
|
|
288650
|
+
` ${import_picocolors25.default.dim(`Connect it with ${import_picocolors25.default.bold("ablo connect apply")}. Until then a table here is invisible to the engine.`)}
|
|
288341
288651
|
`
|
|
288342
288652
|
);
|
|
288343
288653
|
return;
|
|
@@ -288345,15 +288655,15 @@ async function reportReadSubject(dbUrl) {
|
|
|
288345
288655
|
const registered = [...new Set(state.hosts)];
|
|
288346
288656
|
if (host && registered.length > 0 && !registered.includes(host)) {
|
|
288347
288657
|
console.log(
|
|
288348
|
-
` ${
|
|
288658
|
+
` ${import_picocolors25.default.dim("ablo")} ${import_picocolors25.default.yellow("!")} Ablo reads ${import_picocolors25.default.bold(registered.join(", "))}`
|
|
288349
288659
|
);
|
|
288350
288660
|
console.log(
|
|
288351
|
-
` ${
|
|
288661
|
+
` ${import_picocolors25.default.dim("If that is this database under a pooled hostname, this is fine \u2014 otherwise the report below describes a database Ablo never reads.")}
|
|
288352
288662
|
`
|
|
288353
288663
|
);
|
|
288354
288664
|
return;
|
|
288355
288665
|
}
|
|
288356
|
-
console.log(` ${
|
|
288666
|
+
console.log(` ${import_picocolors25.default.dim("ablo")} ${import_picocolors25.default.green("\u2713")} ${import_picocolors25.default.dim("reads this database")}
|
|
288357
288667
|
`);
|
|
288358
288668
|
}
|
|
288359
288669
|
async function check(argv) {
|
|
@@ -288361,20 +288671,20 @@ async function check(argv) {
|
|
|
288361
288671
|
try {
|
|
288362
288672
|
args = parseCheckArgs(argv);
|
|
288363
288673
|
} catch (err) {
|
|
288364
|
-
console.error(
|
|
288674
|
+
console.error(import_picocolors25.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
288365
288675
|
process.exit(1);
|
|
288366
288676
|
}
|
|
288367
288677
|
const dbUrl = readProjectAdminDatabaseUrl();
|
|
288368
288678
|
if (!dbUrl) {
|
|
288369
288679
|
console.error(
|
|
288370
|
-
|
|
288680
|
+
import_picocolors25.default.red(` No database.`) + import_picocolors25.default.dim(` Set ${import_picocolors25.default.bold(ADMIN_URL_VAR)} to the Postgres you want Ablo to adopt.`)
|
|
288371
288681
|
);
|
|
288372
288682
|
process.exit(1);
|
|
288373
288683
|
}
|
|
288374
288684
|
const schema = await loadSchema(args.schemaPath, args.exportName);
|
|
288375
288685
|
const schemaJson = JSON.parse((0, import_schema9.serializeSchema)(schema));
|
|
288376
288686
|
console.log(`
|
|
288377
|
-
${brand("ablo")} ${
|
|
288687
|
+
${brand("ablo")} ${import_picocolors25.default.dim("check")} ${import_picocolors25.default.dim(`schema "${args.appSchema}"`)}
|
|
288378
288688
|
`);
|
|
288379
288689
|
await reportReadSubject(dbUrl);
|
|
288380
288690
|
const sql = src_default(dbUrl, { max: 1, prepare: false, onnotice: () => {
|
|
@@ -288386,7 +288696,7 @@ async function check(argv) {
|
|
|
288386
288696
|
[args.appSchema]
|
|
288387
288697
|
);
|
|
288388
288698
|
} catch (err) {
|
|
288389
|
-
console.error(
|
|
288699
|
+
console.error(import_picocolors25.default.red(` Couldn't read the database: ${err instanceof Error ? err.message : String(err)}`));
|
|
288390
288700
|
await sql.end({ timeout: 2 });
|
|
288391
288701
|
process.exit(1);
|
|
288392
288702
|
}
|
|
@@ -288408,7 +288718,7 @@ async function check(argv) {
|
|
|
288408
288718
|
declaredTables.add(table);
|
|
288409
288719
|
const present = colsByTable.get(table);
|
|
288410
288720
|
if (!present) {
|
|
288411
|
-
console.log(` ${
|
|
288721
|
+
console.log(` ${import_picocolors25.default.red("\u2717")} ${import_picocolors25.default.bold(key)} ${import_picocolors25.default.dim("\u2192")} table ${import_picocolors25.default.bold(table)} ${import_picocolors25.default.red("not found")}`);
|
|
288412
288722
|
errors++;
|
|
288413
288723
|
continue;
|
|
288414
288724
|
}
|
|
@@ -288430,26 +288740,26 @@ async function check(argv) {
|
|
|
288430
288740
|
if (!present.has(col)) problems.push(`missing column "${col}" (field ${fieldName})`);
|
|
288431
288741
|
}
|
|
288432
288742
|
if (problems.length > 0) {
|
|
288433
|
-
console.log(` ${
|
|
288434
|
-
for (const p2 of problems) console.log(` ${
|
|
288435
|
-
for (const w2 of warns) console.log(` ${
|
|
288743
|
+
console.log(` ${import_picocolors25.default.red("\u2717")} ${import_picocolors25.default.bold(key)} ${import_picocolors25.default.dim("\u2192")} ${table}`);
|
|
288744
|
+
for (const p2 of problems) console.log(` ${import_picocolors25.default.red("\u2022")} ${p2}`);
|
|
288745
|
+
for (const w2 of warns) console.log(` ${import_picocolors25.default.yellow("\u2022")} ${w2}`);
|
|
288436
288746
|
errors++;
|
|
288437
288747
|
} else if (warns.length > 0) {
|
|
288438
|
-
console.log(` ${
|
|
288439
|
-
for (const w2 of warns) console.log(` ${
|
|
288748
|
+
console.log(` ${import_picocolors25.default.yellow("!")} ${import_picocolors25.default.bold(key)} ${import_picocolors25.default.dim("\u2192")} ${table}`);
|
|
288749
|
+
for (const w2 of warns) console.log(` ${import_picocolors25.default.yellow("\u2022")} ${w2}`);
|
|
288440
288750
|
warnings++;
|
|
288441
288751
|
} else {
|
|
288442
|
-
console.log(` ${
|
|
288752
|
+
console.log(` ${import_picocolors25.default.green("\u2713")} ${import_picocolors25.default.bold(key)} ${import_picocolors25.default.dim(`\u2192 ${table} (id, ${orgCol ?? "no org"} ok)`)}`);
|
|
288443
288753
|
}
|
|
288444
288754
|
}
|
|
288445
288755
|
const modelCount = Object.keys(schemaJson.models).length;
|
|
288446
288756
|
const ignored = [...colsByTable.keys()].filter((t) => !declaredTables.has(t)).length;
|
|
288447
288757
|
console.log(
|
|
288448
288758
|
`
|
|
288449
|
-
${modelCount} model${modelCount === 1 ? "" : "s"} \xB7 ${
|
|
288759
|
+
${modelCount} model${modelCount === 1 ? "" : "s"} \xB7 ${import_picocolors25.default.green(`${modelCount - errors - warnings} ok`)}` + (warnings ? ` \xB7 ${import_picocolors25.default.yellow(`${warnings} warning${warnings === 1 ? "" : "s"}`)}` : "") + (errors ? ` \xB7 ${import_picocolors25.default.red(`${errors} error${errors === 1 ? "" : "s"}`)}` : "")
|
|
288450
288760
|
);
|
|
288451
288761
|
if (ignored > 0) {
|
|
288452
|
-
console.log(` ${
|
|
288762
|
+
console.log(` ${import_picocolors25.default.dim(`${ignored} other table${ignored === 1 ? "" : "s"} in your database \u2014 ignored by Ablo`)}`);
|
|
288453
288763
|
}
|
|
288454
288764
|
console.log();
|
|
288455
288765
|
process.exit(errors > 0 ? 1 : 0);
|
|
@@ -288457,7 +288767,7 @@ async function check(argv) {
|
|
|
288457
288767
|
|
|
288458
288768
|
// src/upgrade.ts
|
|
288459
288769
|
init_cjs_shims();
|
|
288460
|
-
var
|
|
288770
|
+
var import_picocolors26 = __toESM(require_picocolors(), 1);
|
|
288461
288771
|
var import_ts_morph = __toESM(require_ts_morph(), 1);
|
|
288462
288772
|
var DEFAULT_GLOBS = ["app/**/*.{ts,tsx}", "src/**/*.{ts,tsx}", "ablo/**/*.{ts,tsx}", "lib/**/*.{ts,tsx}"];
|
|
288463
288773
|
var VERB_ARGS = {
|
|
@@ -288535,7 +288845,7 @@ async function upgrade(argv) {
|
|
|
288535
288845
|
project.addSourceFilesAtPaths(globs.length > 0 ? globs : DEFAULT_GLOBS);
|
|
288536
288846
|
const files = project.getSourceFiles();
|
|
288537
288847
|
if (files.length === 0) {
|
|
288538
|
-
console.log(
|
|
288848
|
+
console.log(import_picocolors26.default.yellow(' No .ts/.tsx files found. Pass a glob, e.g. `ablo upgrade "src/**/*.tsx"`.'));
|
|
288539
288849
|
return;
|
|
288540
288850
|
}
|
|
288541
288851
|
const edits = [];
|
|
@@ -288609,39 +288919,39 @@ async function upgrade(argv) {
|
|
|
288609
288919
|
const rel = (f) => f.replace(cwd + "/", "");
|
|
288610
288920
|
console.log();
|
|
288611
288921
|
if (edits.length === 0 && manual.length === 0) {
|
|
288612
|
-
console.log(
|
|
288922
|
+
console.log(import_picocolors26.default.green(" \u2713 Nothing to migrate \u2014 your code is already on the current API."));
|
|
288613
288923
|
return;
|
|
288614
288924
|
}
|
|
288615
288925
|
if (edits.length > 0) {
|
|
288616
|
-
console.log(
|
|
288926
|
+
console.log(import_picocolors26.default.bold(` ${write ? "Applied" : "Would apply"} ${edits.length} change${edits.length === 1 ? "" : "s"}:`));
|
|
288617
288927
|
for (const e2 of edits) {
|
|
288618
|
-
console.log(` ${
|
|
288619
|
-
console.log(` ${
|
|
288620
|
-
console.log(` ${
|
|
288928
|
+
console.log(` ${import_picocolors26.default.dim(`${rel(e2.file)}:${e2.line}`)} ${import_picocolors26.default.cyan(e2.rule)}`);
|
|
288929
|
+
console.log(` ${import_picocolors26.default.red("-")} ${e2.before}`);
|
|
288930
|
+
console.log(` ${import_picocolors26.default.green("+")} ${e2.after}`);
|
|
288621
288931
|
}
|
|
288622
288932
|
}
|
|
288623
288933
|
if (manual.length > 0) {
|
|
288624
288934
|
console.log();
|
|
288625
|
-
console.log(
|
|
288935
|
+
console.log(import_picocolors26.default.bold(import_picocolors26.default.yellow(` ${manual.length} spot${manual.length === 1 ? "" : "s"} need manual review (structural):`)));
|
|
288626
288936
|
for (const m2 of manual) {
|
|
288627
|
-
console.log(` ${
|
|
288628
|
-
console.log(` ${
|
|
288937
|
+
console.log(` ${import_picocolors26.default.dim(`${rel(m2.file)}:${m2.line}`)} ${import_picocolors26.default.yellow(m2.rule)}`);
|
|
288938
|
+
console.log(` ${import_picocolors26.default.dim(m2.snippet)}`);
|
|
288629
288939
|
console.log(` \u2192 ${m2.hint}`);
|
|
288630
288940
|
}
|
|
288631
288941
|
}
|
|
288632
288942
|
console.log();
|
|
288633
288943
|
if (write) {
|
|
288634
288944
|
await project.save();
|
|
288635
|
-
console.log(
|
|
288945
|
+
console.log(import_picocolors26.default.green(` \u2713 Wrote ${edits.length} change${edits.length === 1 ? "" : "s"}. Review the diff, run your typecheck.`));
|
|
288636
288946
|
} else {
|
|
288637
|
-
console.log(
|
|
288947
|
+
console.log(import_picocolors26.default.dim(" Dry run. Re-run with `--write` to apply the auto-fixes above (manual items are never auto-written)."));
|
|
288638
288948
|
}
|
|
288639
288949
|
}
|
|
288640
288950
|
|
|
288641
288951
|
// src/pull.ts
|
|
288642
288952
|
init_cjs_shims();
|
|
288643
|
-
var
|
|
288644
|
-
var
|
|
288953
|
+
var import_errors21 = require("@abloatai/transaction/errors");
|
|
288954
|
+
var import_picocolors27 = __toESM(require_picocolors(), 1);
|
|
288645
288955
|
init_src();
|
|
288646
288956
|
var import_fs10 = require("fs");
|
|
288647
288957
|
init_theme();
|
|
@@ -288669,7 +288979,7 @@ function parsePullArgs(argv) {
|
|
|
288669
288979
|
force = true;
|
|
288670
288980
|
break;
|
|
288671
288981
|
default:
|
|
288672
|
-
throw new
|
|
288982
|
+
throw new import_errors21.AbloValidationError(`unknown flag: ${arg}`, { code: "cli_invalid_arguments" });
|
|
288673
288983
|
}
|
|
288674
288984
|
}
|
|
288675
288985
|
return { out, appSchema, importPath, force };
|
|
@@ -288739,56 +289049,56 @@ async function pull(argv) {
|
|
|
288739
289049
|
try {
|
|
288740
289050
|
args = parsePullArgs(argv);
|
|
288741
289051
|
} catch (err) {
|
|
288742
|
-
console.error(
|
|
289052
|
+
console.error(import_picocolors27.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
288743
289053
|
process.exit(1);
|
|
288744
289054
|
}
|
|
288745
289055
|
const dbUrl = readProjectAdminDatabaseUrl();
|
|
288746
289056
|
if (!dbUrl) {
|
|
288747
289057
|
console.error(
|
|
288748
|
-
|
|
289058
|
+
import_picocolors27.default.red(` No database.`) + import_picocolors27.default.dim(` Set ${import_picocolors27.default.bold(ADMIN_URL_VAR)} to the Postgres to pull from.`)
|
|
288749
289059
|
);
|
|
288750
289060
|
process.exit(1);
|
|
288751
289061
|
}
|
|
288752
289062
|
if ((0, import_fs10.existsSync)(args.out) && !args.force) {
|
|
288753
289063
|
console.error(
|
|
288754
|
-
|
|
289064
|
+
import_picocolors27.default.red(` ${args.out} already exists.`) + import_picocolors27.default.dim(` Re-run with ${import_picocolors27.default.bold("--force")} to overwrite.`)
|
|
288755
289065
|
);
|
|
288756
289066
|
process.exit(1);
|
|
288757
289067
|
}
|
|
288758
289068
|
console.log(`
|
|
288759
|
-
${brand("ablo")} ${
|
|
289069
|
+
${brand("ablo")} ${import_picocolors27.default.dim("pull")} ${import_picocolors27.default.dim(`schema "${args.appSchema}"`)}
|
|
288760
289070
|
`);
|
|
288761
289071
|
let result;
|
|
288762
289072
|
try {
|
|
288763
289073
|
result = await buildSchemaSourceFromDb({ dbUrl, appSchema: args.appSchema, importPath: args.importPath });
|
|
288764
289074
|
} catch (err) {
|
|
288765
|
-
console.error(
|
|
289075
|
+
console.error(import_picocolors27.default.red(` Couldn't read the database: ${err instanceof Error ? err.message : String(err)}`));
|
|
288766
289076
|
process.exit(1);
|
|
288767
289077
|
}
|
|
288768
289078
|
if (result.models.length === 0) {
|
|
288769
289079
|
console.error(
|
|
288770
|
-
|
|
289080
|
+
import_picocolors27.default.yellow(` No adoptable tables found`) + import_picocolors27.default.dim(` (a model needs an ${import_picocolors27.default.bold("id")} + ${import_picocolors27.default.bold("organization_id")} column).`)
|
|
288771
289081
|
);
|
|
288772
289082
|
process.exit(1);
|
|
288773
289083
|
}
|
|
288774
289084
|
(0, import_fs10.writeFileSync)(args.out, result.source);
|
|
288775
|
-
console.log(` ${
|
|
288776
|
-
console.log(` ${
|
|
289085
|
+
console.log(` ${import_picocolors27.default.green("\u2713")} wrote ${import_picocolors27.default.bold(args.out)} ${import_picocolors27.default.dim(`(${result.models.length} models)`)}`);
|
|
289086
|
+
console.log(` ${import_picocolors27.default.dim(`models: ${result.models.join(", ")}`)}`);
|
|
288777
289087
|
if (result.skipped.length > 0) {
|
|
288778
|
-
console.log(` ${
|
|
288779
|
-
for (const s of result.skipped) console.log(` ${
|
|
289088
|
+
console.log(` ${import_picocolors27.default.dim(`${result.skipped.length} table(s) skipped:`)}`);
|
|
289089
|
+
for (const s of result.skipped) console.log(` ${import_picocolors27.default.dim(`- ${s.name}: ${s.reason}`)}`);
|
|
288780
289090
|
}
|
|
288781
289091
|
console.log(
|
|
288782
289092
|
`
|
|
288783
|
-
${
|
|
289093
|
+
${import_picocolors27.default.dim("Introspection is lossy (enums, JSON shape, relations). Review the file, then")} ${import_picocolors27.default.bold("ablo check")}.
|
|
288784
289094
|
`
|
|
288785
289095
|
);
|
|
288786
289096
|
}
|
|
288787
289097
|
|
|
288788
289098
|
// src/prismaPull.ts
|
|
288789
289099
|
init_cjs_shims();
|
|
288790
|
-
var
|
|
288791
|
-
var
|
|
289100
|
+
var import_errors22 = require("@abloatai/transaction/errors");
|
|
289101
|
+
var import_picocolors28 = __toESM(require_picocolors(), 1);
|
|
288792
289102
|
var import_fs11 = require("fs");
|
|
288793
289103
|
init_theme();
|
|
288794
289104
|
var DEFAULT_SCHEMA = "prisma/schema.prisma";
|
|
@@ -288985,7 +289295,7 @@ function parsePrismaPullArgs(argv) {
|
|
|
288985
289295
|
force = true;
|
|
288986
289296
|
break;
|
|
288987
289297
|
default:
|
|
288988
|
-
if (arg.startsWith("--")) throw new
|
|
289298
|
+
if (arg.startsWith("--")) throw new import_errors22.AbloValidationError(`unknown flag: ${arg}`, { code: "cli_invalid_arguments" });
|
|
288989
289299
|
schema = arg;
|
|
288990
289300
|
}
|
|
288991
289301
|
}
|
|
@@ -288996,56 +289306,56 @@ async function prismaPull(argv) {
|
|
|
288996
289306
|
try {
|
|
288997
289307
|
args = parsePrismaPullArgs(argv);
|
|
288998
289308
|
} catch (err) {
|
|
288999
|
-
console.error(
|
|
289309
|
+
console.error(import_picocolors28.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
289000
289310
|
process.exit(1);
|
|
289001
289311
|
}
|
|
289002
289312
|
if (!(0, import_fs11.existsSync)(args.schema)) {
|
|
289003
289313
|
console.error(
|
|
289004
|
-
|
|
289314
|
+
import_picocolors28.default.red(` No Prisma schema at ${import_picocolors28.default.bold(args.schema)}.`) + import_picocolors28.default.dim(` Pass a path: ${import_picocolors28.default.bold("ablo pull prisma <path>")}.`)
|
|
289005
289315
|
);
|
|
289006
289316
|
process.exit(1);
|
|
289007
289317
|
}
|
|
289008
289318
|
if ((0, import_fs11.existsSync)(args.out) && !args.force) {
|
|
289009
289319
|
console.error(
|
|
289010
|
-
|
|
289320
|
+
import_picocolors28.default.red(` ${args.out} already exists.`) + import_picocolors28.default.dim(` Re-run with ${import_picocolors28.default.bold("--force")} to overwrite.`)
|
|
289011
289321
|
);
|
|
289012
289322
|
process.exit(1);
|
|
289013
289323
|
}
|
|
289014
289324
|
console.log(`
|
|
289015
|
-
${brand("ablo")} ${
|
|
289325
|
+
${brand("ablo")} ${import_picocolors28.default.dim("pull prisma")} ${import_picocolors28.default.dim(args.schema)}
|
|
289016
289326
|
`);
|
|
289017
289327
|
let result;
|
|
289018
289328
|
try {
|
|
289019
289329
|
const src = (0, import_fs11.readFileSync)(args.schema, "utf8");
|
|
289020
289330
|
result = buildSchemaSourceFromPrisma({ src, importPath: args.importPath });
|
|
289021
289331
|
} catch (err) {
|
|
289022
|
-
console.error(
|
|
289332
|
+
console.error(import_picocolors28.default.red(` Couldn't parse the schema: ${err instanceof Error ? err.message : String(err)}`));
|
|
289023
289333
|
process.exit(1);
|
|
289024
289334
|
}
|
|
289025
289335
|
if (result.models.length === 0) {
|
|
289026
289336
|
console.error(
|
|
289027
|
-
|
|
289337
|
+
import_picocolors28.default.yellow(` No adoptable models found`) + import_picocolors28.default.dim(` (a model needs an ${import_picocolors28.default.bold("id")} + ${import_picocolors28.default.bold("organizationId")} / ${import_picocolors28.default.bold("organization_id")}).`)
|
|
289028
289338
|
);
|
|
289029
289339
|
process.exit(1);
|
|
289030
289340
|
}
|
|
289031
289341
|
(0, import_fs11.writeFileSync)(args.out, result.source);
|
|
289032
|
-
console.log(` ${
|
|
289033
|
-
console.log(` ${
|
|
289342
|
+
console.log(` ${import_picocolors28.default.green("\u2713")} wrote ${import_picocolors28.default.bold(args.out)} ${import_picocolors28.default.dim(`(${result.models.length} models)`)}`);
|
|
289343
|
+
console.log(` ${import_picocolors28.default.dim(`models: ${result.models.join(", ")}`)}`);
|
|
289034
289344
|
if (result.skipped.length > 0) {
|
|
289035
|
-
console.log(` ${
|
|
289036
|
-
for (const s of result.skipped) console.log(` ${
|
|
289345
|
+
console.log(` ${import_picocolors28.default.dim(`${result.skipped.length} model(s) skipped:`)}`);
|
|
289346
|
+
for (const s of result.skipped) console.log(` ${import_picocolors28.default.dim(`- ${s.name}: ${s.reason}`)}`);
|
|
289037
289347
|
}
|
|
289038
289348
|
console.log(
|
|
289039
289349
|
`
|
|
289040
|
-
${
|
|
289350
|
+
${import_picocolors28.default.dim("Enums and relations were preserved. Review the file, then")} ${import_picocolors28.default.bold("ablo check")}.
|
|
289041
289351
|
`
|
|
289042
289352
|
);
|
|
289043
289353
|
}
|
|
289044
289354
|
|
|
289045
289355
|
// src/drizzlePull.ts
|
|
289046
289356
|
init_cjs_shims();
|
|
289047
|
-
var
|
|
289048
|
-
var
|
|
289357
|
+
var import_picocolors29 = __toESM(require_picocolors(), 1);
|
|
289358
|
+
var import_errors23 = require("@abloatai/transaction/errors");
|
|
289049
289359
|
var import_fs12 = require("fs");
|
|
289050
289360
|
var import_path7 = require("path");
|
|
289051
289361
|
init_theme();
|
|
@@ -289152,7 +289462,7 @@ function parseDrizzlePullArgs(argv) {
|
|
|
289152
289462
|
force = true;
|
|
289153
289463
|
break;
|
|
289154
289464
|
default:
|
|
289155
|
-
if (arg.startsWith("--")) throw new
|
|
289465
|
+
if (arg.startsWith("--")) throw new import_errors23.AbloValidationError(`unknown flag: ${arg}`, { code: "cli_invalid_arguments" });
|
|
289156
289466
|
schema = arg;
|
|
289157
289467
|
}
|
|
289158
289468
|
}
|
|
@@ -289169,27 +289479,27 @@ async function drizzlePull(argv) {
|
|
|
289169
289479
|
try {
|
|
289170
289480
|
args = parseDrizzlePullArgs(argv);
|
|
289171
289481
|
} catch (err) {
|
|
289172
|
-
console.error(
|
|
289482
|
+
console.error(import_picocolors29.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
289173
289483
|
process.exit(1);
|
|
289174
289484
|
}
|
|
289175
289485
|
if (!args.schema) {
|
|
289176
289486
|
console.error(
|
|
289177
|
-
|
|
289487
|
+
import_picocolors29.default.red(` No Drizzle schema given.`) + import_picocolors29.default.dim(` Pass the module: ${import_picocolors29.default.bold("ablo pull drizzle src/db/schema.ts")}.`)
|
|
289178
289488
|
);
|
|
289179
289489
|
process.exit(1);
|
|
289180
289490
|
}
|
|
289181
289491
|
if (!(0, import_fs12.existsSync)(args.schema)) {
|
|
289182
|
-
console.error(
|
|
289492
|
+
console.error(import_picocolors29.default.red(` No file at ${import_picocolors29.default.bold(args.schema)}.`));
|
|
289183
289493
|
process.exit(1);
|
|
289184
289494
|
}
|
|
289185
289495
|
if ((0, import_fs12.existsSync)(args.out) && !args.force) {
|
|
289186
289496
|
console.error(
|
|
289187
|
-
|
|
289497
|
+
import_picocolors29.default.red(` ${args.out} already exists.`) + import_picocolors29.default.dim(` Re-run with ${import_picocolors29.default.bold("--force")} to overwrite.`)
|
|
289188
289498
|
);
|
|
289189
289499
|
process.exit(1);
|
|
289190
289500
|
}
|
|
289191
289501
|
console.log(`
|
|
289192
|
-
${brand("ablo")} ${
|
|
289502
|
+
${brand("ablo")} ${import_picocolors29.default.dim("pull drizzle")} ${import_picocolors29.default.dim(args.schema)}
|
|
289193
289503
|
`);
|
|
289194
289504
|
let result;
|
|
289195
289505
|
try {
|
|
@@ -289197,26 +289507,26 @@ async function drizzlePull(argv) {
|
|
|
289197
289507
|
result = await buildSchemaSourceFromDrizzle({ mod, importPath: args.importPath });
|
|
289198
289508
|
} catch (err) {
|
|
289199
289509
|
const msg = err instanceof Error ? err.message : String(err);
|
|
289200
|
-
const hint = msg.includes("Cannot find package 'drizzle-orm'") ?
|
|
289201
|
-
console.error(
|
|
289510
|
+
const hint = msg.includes("Cannot find package 'drizzle-orm'") ? import_picocolors29.default.dim(` (install ${import_picocolors29.default.bold("drizzle-orm")} in this project)`) : "";
|
|
289511
|
+
console.error(import_picocolors29.default.red(` Couldn't load the schema: ${msg}`) + hint);
|
|
289202
289512
|
process.exit(1);
|
|
289203
289513
|
}
|
|
289204
289514
|
if (result.models.length === 0) {
|
|
289205
289515
|
console.error(
|
|
289206
|
-
|
|
289516
|
+
import_picocolors29.default.yellow(` No adoptable tables found`) + import_picocolors29.default.dim(` (a table needs an ${import_picocolors29.default.bold("id")} + ${import_picocolors29.default.bold("organization_id")} column).`)
|
|
289207
289517
|
);
|
|
289208
289518
|
process.exit(1);
|
|
289209
289519
|
}
|
|
289210
289520
|
(0, import_fs12.writeFileSync)(args.out, result.source);
|
|
289211
|
-
console.log(` ${
|
|
289212
|
-
console.log(` ${
|
|
289521
|
+
console.log(` ${import_picocolors29.default.green("\u2713")} wrote ${import_picocolors29.default.bold(args.out)} ${import_picocolors29.default.dim(`(${result.models.length} models)`)}`);
|
|
289522
|
+
console.log(` ${import_picocolors29.default.dim(`models: ${result.models.join(", ")}`)}`);
|
|
289213
289523
|
if (result.skipped.length > 0) {
|
|
289214
|
-
console.log(` ${
|
|
289215
|
-
for (const s of result.skipped) console.log(` ${
|
|
289524
|
+
console.log(` ${import_picocolors29.default.dim(`${result.skipped.length} table(s) skipped:`)}`);
|
|
289525
|
+
for (const s of result.skipped) console.log(` ${import_picocolors29.default.dim(`- ${s.name}: ${s.reason}`)}`);
|
|
289216
289526
|
}
|
|
289217
289527
|
console.log(
|
|
289218
289528
|
`
|
|
289219
|
-
${
|
|
289529
|
+
${import_picocolors29.default.dim("Enums and relations were preserved. Review the file, then")} ${import_picocolors29.default.bold("ablo check")}.
|
|
289220
289530
|
`
|
|
289221
289531
|
);
|
|
289222
289532
|
}
|
|
@@ -289229,7 +289539,7 @@ init_telemetry();
|
|
|
289229
289539
|
|
|
289230
289540
|
// src/init/options.ts
|
|
289231
289541
|
init_cjs_shims();
|
|
289232
|
-
var
|
|
289542
|
+
var import_node_fs4 = require("fs");
|
|
289233
289543
|
var import_node_path3 = require("path");
|
|
289234
289544
|
var INIT_FRAMEWORKS = ["nextjs", "vite", "remix", "vanilla"];
|
|
289235
289545
|
var INIT_AUTHS = [
|
|
@@ -289269,7 +289579,7 @@ function parseInitArgs(args) {
|
|
|
289269
289579
|
function detectOrm(override, root = process.cwd()) {
|
|
289270
289580
|
if (override === "prisma" || override === "drizzle" || override === "none") return override;
|
|
289271
289581
|
try {
|
|
289272
|
-
const pkg = JSON.parse((0,
|
|
289582
|
+
const pkg = JSON.parse((0, import_node_fs4.readFileSync)((0, import_node_path3.resolve)(root, "package.json"), "utf8"));
|
|
289273
289583
|
const dependencies = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
289274
289584
|
if (dependencies["@prisma/client"] || dependencies.prisma) return "prisma";
|
|
289275
289585
|
if (dependencies["drizzle-orm"]) return "drizzle";
|
|
@@ -289278,24 +289588,24 @@ function detectOrm(override, root = process.cwd()) {
|
|
|
289278
289588
|
return "none";
|
|
289279
289589
|
}
|
|
289280
289590
|
function detectNextLayout(root = process.cwd()) {
|
|
289281
|
-
const useSrc = (0,
|
|
289591
|
+
const useSrc = (0, import_node_fs4.existsSync)((0, import_node_path3.resolve)(root, "src", "app")) || !(0, import_node_fs4.existsSync)((0, import_node_path3.resolve)(root, "app")) && (0, import_node_fs4.existsSync)((0, import_node_path3.resolve)(root, "src"));
|
|
289282
289592
|
return useSrc ? { appBase: (0, import_node_path3.join)("src", "app"), aliasBase: "src" } : { appBase: "app", aliasBase: "." };
|
|
289283
289593
|
}
|
|
289284
289594
|
function detectPackageManager(root = process.cwd()) {
|
|
289285
|
-
if ((0,
|
|
289286
|
-
if ((0,
|
|
289287
|
-
if ((0,
|
|
289595
|
+
if ((0, import_node_fs4.existsSync)((0, import_node_path3.resolve)(root, "pnpm-lock.yaml"))) return "pnpm";
|
|
289596
|
+
if ((0, import_node_fs4.existsSync)((0, import_node_path3.resolve)(root, "yarn.lock"))) return "yarn";
|
|
289597
|
+
if ((0, import_node_fs4.existsSync)((0, import_node_path3.resolve)(root, "bun.lockb"))) return "bun";
|
|
289288
289598
|
return "npm";
|
|
289289
289599
|
}
|
|
289290
289600
|
|
|
289291
289601
|
// src/init/run.ts
|
|
289292
289602
|
init_cjs_shims();
|
|
289293
289603
|
var import_node_child_process3 = require("child_process");
|
|
289294
|
-
var
|
|
289604
|
+
var import_node_fs6 = require("fs");
|
|
289295
289605
|
var import_node_path5 = require("path");
|
|
289296
289606
|
init_dist2();
|
|
289297
|
-
var
|
|
289298
|
-
var
|
|
289607
|
+
var import_picocolors30 = __toESM(require_picocolors(), 1);
|
|
289608
|
+
var import_errors24 = require("@abloatai/transaction/errors");
|
|
289299
289609
|
init_dbRole();
|
|
289300
289610
|
init_config();
|
|
289301
289611
|
init_projects();
|
|
@@ -289720,9 +290030,9 @@ export function RecordList() {
|
|
|
289720
290030
|
|
|
289721
290031
|
// src/init/writer.ts
|
|
289722
290032
|
init_cjs_shims();
|
|
289723
|
-
var
|
|
290033
|
+
var import_node_fs5 = require("fs");
|
|
289724
290034
|
var import_node_path4 = require("path");
|
|
289725
|
-
var
|
|
290035
|
+
var import_node_crypto7 = require("crypto");
|
|
289726
290036
|
function projectInitWritePlan(plan) {
|
|
289727
290037
|
return setupInitPlanProjectionSchema.parse({
|
|
289728
290038
|
root: plan.root,
|
|
@@ -289744,10 +290054,10 @@ function absolute(root, path) {
|
|
|
289744
290054
|
return target;
|
|
289745
290055
|
}
|
|
289746
290056
|
function sha2562(content) {
|
|
289747
|
-
return (0,
|
|
290057
|
+
return (0, import_node_crypto7.createHash)("sha256").update(content).digest("hex");
|
|
289748
290058
|
}
|
|
289749
290059
|
function readIfPresent(path) {
|
|
289750
|
-
return (0,
|
|
290060
|
+
return (0, import_node_fs5.existsSync)(path) ? (0, import_node_fs5.readFileSync)(path, "utf8") : void 0;
|
|
289751
290061
|
}
|
|
289752
290062
|
function mergeEnvironmentTemplate(existing, template) {
|
|
289753
290063
|
const assignments = template.split(/\r?\n/).map((line) => {
|
|
@@ -289816,18 +290126,18 @@ function planInitWrites(input) {
|
|
|
289816
290126
|
return { root, actions, conflicts };
|
|
289817
290127
|
}
|
|
289818
290128
|
function writeAtomic(path, content, kind) {
|
|
289819
|
-
(0,
|
|
289820
|
-
const temporary = (0, import_node_path4.join)((0, import_node_path4.dirname)(path), `.${(0,
|
|
289821
|
-
(0,
|
|
290129
|
+
(0, import_node_fs5.mkdirSync)((0, import_node_path4.dirname)(path), { recursive: true });
|
|
290130
|
+
const temporary = (0, import_node_path4.join)((0, import_node_path4.dirname)(path), `.${(0, import_node_crypto7.randomUUID)()}.ablo-init.tmp`);
|
|
290131
|
+
(0, import_node_fs5.writeFileSync)(temporary, content, { flag: "wx" });
|
|
289822
290132
|
try {
|
|
289823
290133
|
if (kind === "create") {
|
|
289824
|
-
(0,
|
|
289825
|
-
(0,
|
|
290134
|
+
(0, import_node_fs5.linkSync)(temporary, path);
|
|
290135
|
+
(0, import_node_fs5.unlinkSync)(temporary);
|
|
289826
290136
|
} else {
|
|
289827
|
-
(0,
|
|
290137
|
+
(0, import_node_fs5.renameSync)(temporary, path);
|
|
289828
290138
|
}
|
|
289829
290139
|
} catch (error) {
|
|
289830
|
-
if ((0,
|
|
290140
|
+
if ((0, import_node_fs5.existsSync)(temporary)) (0, import_node_fs5.unlinkSync)(temporary);
|
|
289831
290141
|
throw error;
|
|
289832
290142
|
}
|
|
289833
290143
|
}
|
|
@@ -289861,7 +290171,7 @@ function bailIfCancelled(value) {
|
|
|
289861
290171
|
async function chooseOption(name, flagValue, fallback, allowed, interactive, prompt) {
|
|
289862
290172
|
if (flagValue !== void 0) {
|
|
289863
290173
|
if (!allowed.includes(flagValue)) {
|
|
289864
|
-
throw new
|
|
290174
|
+
throw new import_errors24.AbloValidationError(
|
|
289865
290175
|
`Invalid --${name} "${flagValue}". Allowed: ${allowed.join(", ")}`,
|
|
289866
290176
|
{ code: "cli_invalid_arguments" }
|
|
289867
290177
|
);
|
|
@@ -289885,7 +290195,7 @@ async function ensureInitProject(opts) {
|
|
|
289885
290195
|
const slug = opts.project ?? projectSlugFromPackageName(
|
|
289886
290196
|
(() => {
|
|
289887
290197
|
try {
|
|
289888
|
-
return JSON.parse((0,
|
|
290198
|
+
return JSON.parse((0, import_node_fs6.readFileSync)("package.json", "utf8")).name;
|
|
289889
290199
|
} catch {
|
|
289890
290200
|
return void 0;
|
|
289891
290201
|
}
|
|
@@ -289895,7 +290205,7 @@ async function ensureInitProject(opts) {
|
|
|
289895
290205
|
const ensured = await ensureProject(slug);
|
|
289896
290206
|
if (ensured) {
|
|
289897
290207
|
console.log(
|
|
289898
|
-
` ${
|
|
290208
|
+
` ${import_picocolors30.default.green("\u2713")} ${ensured.created ? "Created" : "Using"} project ${import_picocolors30.default.bold(ensured.slug)} ${import_picocolors30.default.dim(`(${ensured.id})`)} \u2014 keys you mint for it are isolated from the org's other apps.`
|
|
289899
290209
|
);
|
|
289900
290210
|
}
|
|
289901
290211
|
}
|
|
@@ -289907,16 +290217,16 @@ function renderWritePlan(actions) {
|
|
|
289907
290217
|
}
|
|
289908
290218
|
function renderAppliedWrites(actions) {
|
|
289909
290219
|
return actions.map((action) => {
|
|
289910
|
-
const status2 = action.kind === "create" ?
|
|
289911
|
-
return `${
|
|
290220
|
+
const status2 = action.kind === "create" ? import_picocolors30.default.green("created") : action.kind === "update" ? import_picocolors30.default.yellow("updated") : import_picocolors30.default.dim("unchanged");
|
|
290221
|
+
return `${import_picocolors30.default.green("\u2713")} ${action.path}${action.note ?? ""} ${import_picocolors30.default.dim(`(${status2})`)}`;
|
|
289912
290222
|
}).join("\n");
|
|
289913
290223
|
}
|
|
289914
290224
|
async function runInit(args = []) {
|
|
289915
290225
|
const opts = parseInitArgs(args);
|
|
289916
290226
|
const interactive = Boolean(process.stdin.isTTY) && !opts.yes && !process.env.CI;
|
|
289917
|
-
Ie(`${brand("ablo")} ${
|
|
289918
|
-
if (!(0,
|
|
289919
|
-
throw new
|
|
290227
|
+
Ie(`${brand("ablo")} ${import_picocolors30.default.dim("sync engine")}`);
|
|
290228
|
+
if (!(0, import_node_fs6.existsSync)("package.json")) {
|
|
290229
|
+
throw new import_errors24.AbloValidationError("No package.json found. Run this from your project root.", {
|
|
289920
290230
|
code: "cli_invalid_arguments"
|
|
289921
290231
|
});
|
|
289922
290232
|
}
|
|
@@ -289992,7 +290302,7 @@ async function runInit(args = []) {
|
|
|
289992
290302
|
if (pullExisting) {
|
|
289993
290303
|
const dbUrl = readProjectAdminDatabaseUrl();
|
|
289994
290304
|
if (!dbUrl) {
|
|
289995
|
-
schemaNote =
|
|
290305
|
+
schemaNote = import_picocolors30.default.dim(` (no ${ADMIN_URL_VAR} \u2014 wrote starter; run \`ablo pull\` later)`);
|
|
289996
290306
|
} else {
|
|
289997
290307
|
try {
|
|
289998
290308
|
const pulled = await buildSchemaSourceFromDb({
|
|
@@ -290002,12 +290312,12 @@ async function runInit(args = []) {
|
|
|
290002
290312
|
});
|
|
290003
290313
|
if (pulled.models.length > 0) {
|
|
290004
290314
|
schemaSource = pulled.source;
|
|
290005
|
-
schemaNote =
|
|
290315
|
+
schemaNote = import_picocolors30.default.dim(` (pulled ${pulled.models.length} models)`);
|
|
290006
290316
|
} else {
|
|
290007
|
-
schemaNote =
|
|
290317
|
+
schemaNote = import_picocolors30.default.dim(" (no adoptable tables \u2014 wrote starter)");
|
|
290008
290318
|
}
|
|
290009
290319
|
} catch {
|
|
290010
|
-
schemaNote =
|
|
290320
|
+
schemaNote = import_picocolors30.default.dim(" (pull failed \u2014 wrote starter)");
|
|
290011
290321
|
}
|
|
290012
290322
|
}
|
|
290013
290323
|
}
|
|
@@ -290051,7 +290361,7 @@ async function runInit(args = []) {
|
|
|
290051
290361
|
const writePlan = planInitWrites({ files, environment: { path: envFile, template: envBody } });
|
|
290052
290362
|
if (writePlan.conflicts.length > 0) {
|
|
290053
290363
|
const occupied = writePlan.conflicts.map(({ path }) => ` - ${path}`).join("\n");
|
|
290054
|
-
throw new
|
|
290364
|
+
throw new import_errors24.AbloValidationError(
|
|
290055
290365
|
`Ablo init did not change any files because these application-owned paths already contain different contents:
|
|
290056
290366
|
${occupied}
|
|
290057
290367
|
|
|
@@ -290061,7 +290371,7 @@ Move them, reconcile Ablo manually, or rerun after they match the generated scaf
|
|
|
290061
290371
|
}
|
|
290062
290372
|
if (opts.plan) {
|
|
290063
290373
|
Me(renderWritePlan(writePlan.actions), "Plan (no files changed)");
|
|
290064
|
-
Se(`Dry run complete. Re-run without ${
|
|
290374
|
+
Se(`Dry run complete. Re-run without ${import_picocolors30.default.bold("--plan")} to apply it.`);
|
|
290065
290375
|
return setupInitResultSchema.parse({
|
|
290066
290376
|
status: "planned",
|
|
290067
290377
|
plan: projectInitWritePlan(writePlan)
|
|
@@ -290082,28 +290392,28 @@ Move them, reconcile Ablo manually, or rerun after they match the generated scaf
|
|
|
290082
290392
|
progress.stop("Installed @abloatai/ablo");
|
|
290083
290393
|
} catch {
|
|
290084
290394
|
progress.stop(
|
|
290085
|
-
`${
|
|
290395
|
+
`${import_picocolors30.default.yellow("!")} Couldn't auto-install \u2014 run ${import_picocolors30.default.bold(`${packageManager2} install @abloatai/ablo`)}`
|
|
290086
290396
|
);
|
|
290087
290397
|
}
|
|
290088
290398
|
}
|
|
290089
290399
|
const steps = [
|
|
290090
|
-
`Run ${
|
|
290091
|
-
`Set ${
|
|
290092
|
-
`Run ${
|
|
290400
|
+
`Run ${import_picocolors30.default.bold("npx ablo login")} to authorize branch management`,
|
|
290401
|
+
`Set ${import_picocolors30.default.bold("DATABASE_URL")} in ${import_picocolors30.default.bold(envFile)} \u2014 your Postgres is the system of record; rows live there, never with Ablo`,
|
|
290402
|
+
`Run ${import_picocolors30.default.bold("npx ablo dev")} \u2014 pushes your schema definition and watches for changes`,
|
|
290093
290403
|
...storage === "replication" ? [
|
|
290094
|
-
`Connect your database \u2014 ${
|
|
290095
|
-
`Verify it \u2014 ${
|
|
290096
|
-
`Register it \u2014 ${
|
|
290404
|
+
`Connect your database \u2014 ${import_picocolors30.default.bold("npx ablo connect")} prints the one-time logical-replication setup SQL to run on your Postgres`,
|
|
290405
|
+
`Verify it \u2014 ${import_picocolors30.default.bold("npx ablo connect check")} walks wal_level, the publication, the role, and replica identity, with the exact fix for anything missing`,
|
|
290406
|
+
`Register it \u2014 ${import_picocolors30.default.bold("npx ablo connect register")} tells Ablo to start replicating; your app keeps writing through your own backend while Ablo tails the WAL`
|
|
290097
290407
|
] : [
|
|
290098
|
-
`Provision your DB: ${
|
|
290408
|
+
`Provision your DB: ${import_picocolors30.default.bold("npx ablo migrate")} (creates your Ablo-model tables + the adapter tables; keep your own migrations for everything else), then mount ${import_picocolors30.default.bold(`${abloDir}/data-source.ts`)} at ${import_picocolors30.default.bold("/api/ablo/source")}`
|
|
290099
290409
|
],
|
|
290100
290410
|
...framework === "nextjs" ? [
|
|
290101
|
-
`Wrap ${
|
|
290411
|
+
`Wrap ${import_picocolors30.default.bold((0, import_node_path5.join)(layout.appBase, "layout.tsx"))} in ${import_picocolors30.default.bold("<Providers>")} (${(0, import_node_path5.join)(layout.appBase, "providers.tsx")}) and add your auth to ${import_picocolors30.default.bold((0, import_node_path5.join)(layout.appBase, "api", "ablo-session", "route.ts"))}`
|
|
290102
290412
|
] : [],
|
|
290103
|
-
`Run ${
|
|
290413
|
+
`Run ${import_picocolors30.default.bold(`${packageManager2} run dev`)} and open two browser tabs \u2014 changes sync in real-time`,
|
|
290104
290414
|
...agent ? [
|
|
290105
|
-
`Run ${
|
|
290106
|
-
`Run ${
|
|
290415
|
+
`Run ${import_picocolors30.default.bold(`npx tsx ${abloDir}/agent.ts`)} \u2014 an AI teammate edits the same records`,
|
|
290416
|
+
`Run ${import_picocolors30.default.bold("npx ablo logs")} to watch human + agent commits stream by`
|
|
290107
290417
|
] : []
|
|
290108
290418
|
];
|
|
290109
290419
|
Me(steps.map((step, index) => `${index + 1}. ${step}`).join("\n"), "Next steps");
|
|
@@ -290111,26 +290421,26 @@ Move them, reconcile Ablo manually, or rerun after they match the generated scaf
|
|
|
290111
290421
|
if (existingKey) {
|
|
290112
290422
|
await ensureInitProject(opts);
|
|
290113
290423
|
Se(
|
|
290114
|
-
`Already authorized ${
|
|
290424
|
+
`Already authorized ${import_picocolors30.default.dim(`(${existingKey.slice(0, 11)}\u2026)`)}. Run ${import_picocolors30.default.bold("npx ablo dev")} next. ${import_picocolors30.default.dim("Docs:")} https://abloatai.com/docs`
|
|
290115
290425
|
);
|
|
290116
290426
|
return initResult;
|
|
290117
290427
|
}
|
|
290118
290428
|
if (interactive && opts.login) {
|
|
290119
290429
|
const loginNow = await ye({ message: "Log in now? (opens your browser)", initialValue: true });
|
|
290120
290430
|
if (!pD(loginNow) && loginNow) {
|
|
290121
|
-
Se(`${
|
|
290431
|
+
Se(`${import_picocolors30.default.dim("Docs:")} https://abloatai.com/docs`);
|
|
290122
290432
|
await login();
|
|
290123
290433
|
await ensureInitProject(opts);
|
|
290124
290434
|
return initResult;
|
|
290125
290435
|
}
|
|
290126
290436
|
}
|
|
290127
|
-
Se(`Run ${
|
|
290437
|
+
Se(`Run ${import_picocolors30.default.bold("npx ablo login")} when ready. ${import_picocolors30.default.dim("Docs:")} https://abloatai.com/docs`);
|
|
290128
290438
|
return initResult;
|
|
290129
290439
|
}
|
|
290130
290440
|
|
|
290131
290441
|
// src/index.ts
|
|
290132
290442
|
var LOGO = `
|
|
290133
|
-
${brand("ablo")} ${
|
|
290443
|
+
${brand("ablo")} ${import_picocolors31.default.dim("sync engine")}
|
|
290134
290444
|
`;
|
|
290135
290445
|
var HANDLERS = {
|
|
290136
290446
|
setup: (argv) => runSetup(argv),
|
|
@@ -290149,6 +290459,7 @@ var HANDLERS = {
|
|
|
290149
290459
|
webhooks: (argv) => webhooks([...argv]),
|
|
290150
290460
|
check: (argv) => check([...argv]),
|
|
290151
290461
|
docs: (argv) => docs([...argv]),
|
|
290462
|
+
feedback: (argv) => feedback([...argv]),
|
|
290152
290463
|
connect: (argv) => connect([...argv]),
|
|
290153
290464
|
migrate: (argv) => migrate([...argv]),
|
|
290154
290465
|
upgrade: (argv) => upgrade([...argv]),
|
|
@@ -290162,7 +290473,7 @@ async function runDev(argv) {
|
|
|
290162
290473
|
const devArgs = [...argv];
|
|
290163
290474
|
const oneShot = devArgs.includes("--no-watch");
|
|
290164
290475
|
console.log(
|
|
290165
|
-
|
|
290476
|
+
import_picocolors31.default.dim(
|
|
290166
290477
|
oneShot ? " `ablo dev --no-watch` prepares this Git branch and pushes once." : " `ablo dev` prepares this Git branch and watches the schema."
|
|
290167
290478
|
)
|
|
290168
290479
|
);
|
|
@@ -290180,7 +290491,7 @@ async function runPush2(argv) {
|
|
|
290180
290491
|
}
|
|
290181
290492
|
function runRenamedSchema(argv) {
|
|
290182
290493
|
const forwarded = argv.slice(1).join(" ");
|
|
290183
|
-
console.error(` ${
|
|
290494
|
+
console.error(` ${import_picocolors31.default.red("\u2717")} \`ablo schema push\` was renamed to \`${brand("ablo push")}\`.`);
|
|
290184
290495
|
console.error(` Run \`ablo push${forwarded ? " " + forwarded : ""}\` instead.`);
|
|
290185
290496
|
process.exitCode = 1;
|
|
290186
290497
|
}
|
|
@@ -290190,7 +290501,7 @@ async function main() {
|
|
|
290190
290501
|
const argv = process.argv.slice(3);
|
|
290191
290502
|
if (!command && raw !== void 0 && raw !== "help" && !raw.startsWith("-")) {
|
|
290192
290503
|
const suggestion = suggestCommand(raw);
|
|
290193
|
-
throw new
|
|
290504
|
+
throw new import_errors25.AbloValidationError(
|
|
290194
290505
|
`\`${raw}\` isn't an ablo command.` + (suggestion ? ` Did you mean \`ablo ${suggestion}\`?` : " Run `ablo help --all` to see every command."),
|
|
290195
290506
|
{ code: "cli_invalid_arguments" }
|
|
290196
290507
|
);
|
|
@@ -290231,7 +290542,7 @@ function printCoreHelp() {
|
|
|
290231
290542
|
const width = Math.max(...rows.map((r2) => r2.run.length)) + 4;
|
|
290232
290543
|
console.log(LOGO);
|
|
290233
290544
|
for (const group of CORE_GROUPS) {
|
|
290234
|
-
console.log(` ${
|
|
290545
|
+
console.log(` ${import_picocolors31.default.bold(group)}`);
|
|
290235
290546
|
const printed = group === "More" ? [...coreRows(group), ...extra] : coreRows(group);
|
|
290236
290547
|
for (const row of printed) console.log(` npx ablo ${row.run.padEnd(width)}${row.does}`);
|
|
290237
290548
|
console.log();
|
|
@@ -290240,7 +290551,7 @@ function printCoreHelp() {
|
|
|
290240
290551
|
}
|
|
290241
290552
|
function printSchemaReminder() {
|
|
290242
290553
|
console.log(
|
|
290243
|
-
|
|
290554
|
+
import_picocolors31.default.dim(` Edit ${import_picocolors31.default.bold("ablo/schema.ts")}, then push \u2014 writes to models you haven't pushed fail with `) + import_picocolors31.default.yellow("server_execute_unknown_model") + import_picocolors31.default.dim(".")
|
|
290244
290555
|
);
|
|
290245
290556
|
console.log();
|
|
290246
290557
|
}
|
|
@@ -290250,7 +290561,7 @@ function printFullHelp() {
|
|
|
290250
290561
|
) + 2;
|
|
290251
290562
|
console.log(LOGO);
|
|
290252
290563
|
for (const group of FULL_GROUPS) {
|
|
290253
|
-
console.log(` ${
|
|
290564
|
+
console.log(` ${import_picocolors31.default.bold(group)}`);
|
|
290254
290565
|
for (const row of fullRows(group)) {
|
|
290255
290566
|
console.log(row.does === void 0 ? ` ${" ".repeat(9)}${row.run}` : ` npx ablo ${row.run.padEnd(width)}${row.does}`);
|
|
290256
290567
|
}
|