agentful 0.4.37 → 0.4.38
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/index.cjs +137 -102
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13,8 +13,8 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
13
13
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
14
|
};
|
|
15
15
|
var __export = (target, all) => {
|
|
16
|
-
for (var
|
|
17
|
-
__defProp(target,
|
|
16
|
+
for (var name2 in all)
|
|
17
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
18
18
|
};
|
|
19
19
|
var __copyProps = (to, from, except, desc) => {
|
|
20
20
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -83,25 +83,25 @@ var require_argument = __commonJS({
|
|
|
83
83
|
* @param {string} name
|
|
84
84
|
* @param {string} [description]
|
|
85
85
|
*/
|
|
86
|
-
constructor(
|
|
86
|
+
constructor(name2, description) {
|
|
87
87
|
this.description = description || "";
|
|
88
88
|
this.variadic = false;
|
|
89
89
|
this.parseArg = void 0;
|
|
90
90
|
this.defaultValue = void 0;
|
|
91
91
|
this.defaultValueDescription = void 0;
|
|
92
92
|
this.argChoices = void 0;
|
|
93
|
-
switch (
|
|
93
|
+
switch (name2[0]) {
|
|
94
94
|
case "<":
|
|
95
95
|
this.required = true;
|
|
96
|
-
this._name =
|
|
96
|
+
this._name = name2.slice(1, -1);
|
|
97
97
|
break;
|
|
98
98
|
case "[":
|
|
99
99
|
this.required = false;
|
|
100
|
-
this._name =
|
|
100
|
+
this._name = name2.slice(1, -1);
|
|
101
101
|
break;
|
|
102
102
|
default:
|
|
103
103
|
this.required = true;
|
|
104
|
-
this._name =
|
|
104
|
+
this._name = name2;
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
107
|
if (this._name.length > 3 && this._name.slice(-3) === "...") {
|
|
@@ -720,8 +720,8 @@ var require_option = __commonJS({
|
|
|
720
720
|
* @param {string} name
|
|
721
721
|
* @return {Option}
|
|
722
722
|
*/
|
|
723
|
-
env(
|
|
724
|
-
this.envVar =
|
|
723
|
+
env(name2) {
|
|
724
|
+
this.envVar = name2;
|
|
725
725
|
return this;
|
|
726
726
|
}
|
|
727
727
|
/**
|
|
@@ -986,7 +986,7 @@ var require_command = __commonJS({
|
|
|
986
986
|
*
|
|
987
987
|
* @param {string} [name]
|
|
988
988
|
*/
|
|
989
|
-
constructor(
|
|
989
|
+
constructor(name2) {
|
|
990
990
|
super();
|
|
991
991
|
this.commands = [];
|
|
992
992
|
this.options = [];
|
|
@@ -999,7 +999,7 @@ var require_command = __commonJS({
|
|
|
999
999
|
this.rawArgs = [];
|
|
1000
1000
|
this.processedArgs = [];
|
|
1001
1001
|
this._scriptPath = null;
|
|
1002
|
-
this._name =
|
|
1002
|
+
this._name = name2 || "";
|
|
1003
1003
|
this._optionValues = {};
|
|
1004
1004
|
this._optionValueSources = {};
|
|
1005
1005
|
this._storeOptionsAsProperties = false;
|
|
@@ -1097,8 +1097,8 @@ var require_command = __commonJS({
|
|
|
1097
1097
|
desc = null;
|
|
1098
1098
|
}
|
|
1099
1099
|
opts = opts || {};
|
|
1100
|
-
const [,
|
|
1101
|
-
const cmd = this.createCommand(
|
|
1100
|
+
const [, name2, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
1101
|
+
const cmd = this.createCommand(name2);
|
|
1102
1102
|
if (desc) {
|
|
1103
1103
|
cmd.description(desc);
|
|
1104
1104
|
cmd._executableHandler = true;
|
|
@@ -1122,8 +1122,8 @@ var require_command = __commonJS({
|
|
|
1122
1122
|
* @param {string} [name]
|
|
1123
1123
|
* @return {Command} new command
|
|
1124
1124
|
*/
|
|
1125
|
-
createCommand(
|
|
1126
|
-
return new _Command(
|
|
1125
|
+
createCommand(name2) {
|
|
1126
|
+
return new _Command(name2);
|
|
1127
1127
|
}
|
|
1128
1128
|
/**
|
|
1129
1129
|
* You can customise the help with a subclass of Help by overriding createHelp,
|
|
@@ -1222,8 +1222,8 @@ var require_command = __commonJS({
|
|
|
1222
1222
|
* @param {string} [description]
|
|
1223
1223
|
* @return {Argument} new argument
|
|
1224
1224
|
*/
|
|
1225
|
-
createArgument(
|
|
1226
|
-
return new Argument2(
|
|
1225
|
+
createArgument(name2, description) {
|
|
1226
|
+
return new Argument2(name2, description);
|
|
1227
1227
|
}
|
|
1228
1228
|
/**
|
|
1229
1229
|
* Define argument syntax for command.
|
|
@@ -1241,8 +1241,8 @@ var require_command = __commonJS({
|
|
|
1241
1241
|
* @param {*} [defaultValue]
|
|
1242
1242
|
* @return {Command} `this` command for chaining
|
|
1243
1243
|
*/
|
|
1244
|
-
argument(
|
|
1245
|
-
const argument = this.createArgument(
|
|
1244
|
+
argument(name2, description, fn, defaultValue) {
|
|
1245
|
+
const argument = this.createArgument(name2, description);
|
|
1246
1246
|
if (typeof fn === "function") {
|
|
1247
1247
|
argument.default(defaultValue).argParser(fn);
|
|
1248
1248
|
} else {
|
|
@@ -1494,7 +1494,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1494
1494
|
return [cmd.name()].concat(cmd.aliases());
|
|
1495
1495
|
};
|
|
1496
1496
|
const alreadyUsed = knownBy(command).find(
|
|
1497
|
-
(
|
|
1497
|
+
(name2) => this._findCommand(name2)
|
|
1498
1498
|
);
|
|
1499
1499
|
if (alreadyUsed) {
|
|
1500
1500
|
const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
|
|
@@ -1514,24 +1514,24 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1514
1514
|
addOption(option) {
|
|
1515
1515
|
this._registerOption(option);
|
|
1516
1516
|
const oname = option.name();
|
|
1517
|
-
const
|
|
1517
|
+
const name2 = option.attributeName();
|
|
1518
1518
|
if (option.negate) {
|
|
1519
1519
|
const positiveLongFlag = option.long.replace(/^--no-/, "--");
|
|
1520
1520
|
if (!this._findOption(positiveLongFlag)) {
|
|
1521
1521
|
this.setOptionValueWithSource(
|
|
1522
|
-
|
|
1522
|
+
name2,
|
|
1523
1523
|
option.defaultValue === void 0 ? true : option.defaultValue,
|
|
1524
1524
|
"default"
|
|
1525
1525
|
);
|
|
1526
1526
|
}
|
|
1527
1527
|
} else if (option.defaultValue !== void 0) {
|
|
1528
|
-
this.setOptionValueWithSource(
|
|
1528
|
+
this.setOptionValueWithSource(name2, option.defaultValue, "default");
|
|
1529
1529
|
}
|
|
1530
1530
|
const handleOptionValue = (val, invalidValueMessage, valueSource) => {
|
|
1531
1531
|
if (val == null && option.presetArg !== void 0) {
|
|
1532
1532
|
val = option.presetArg;
|
|
1533
1533
|
}
|
|
1534
|
-
const oldValue = this.getOptionValue(
|
|
1534
|
+
const oldValue = this.getOptionValue(name2);
|
|
1535
1535
|
if (val !== null && option.parseArg) {
|
|
1536
1536
|
val = this._callParseArg(option, val, oldValue, invalidValueMessage);
|
|
1537
1537
|
} else if (val !== null && option.variadic) {
|
|
@@ -1546,7 +1546,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1546
1546
|
val = "";
|
|
1547
1547
|
}
|
|
1548
1548
|
}
|
|
1549
|
-
this.setOptionValueWithSource(
|
|
1549
|
+
this.setOptionValueWithSource(name2, val, valueSource);
|
|
1550
1550
|
};
|
|
1551
1551
|
this.on("option:" + oname, (val) => {
|
|
1552
1552
|
const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
|
|
@@ -2258,10 +2258,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2258
2258
|
* @private
|
|
2259
2259
|
* @return {Command | undefined}
|
|
2260
2260
|
*/
|
|
2261
|
-
_findCommand(
|
|
2262
|
-
if (!
|
|
2261
|
+
_findCommand(name2) {
|
|
2262
|
+
if (!name2) return void 0;
|
|
2263
2263
|
return this.commands.find(
|
|
2264
|
-
(cmd) => cmd._name ===
|
|
2264
|
+
(cmd) => cmd._name === name2 || cmd._aliases.includes(name2)
|
|
2265
2265
|
);
|
|
2266
2266
|
}
|
|
2267
2267
|
/**
|
|
@@ -2535,8 +2535,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2535
2535
|
* @param {string} name
|
|
2536
2536
|
* @private
|
|
2537
2537
|
*/
|
|
2538
|
-
missingArgument(
|
|
2539
|
-
const message = `error: missing required argument '${
|
|
2538
|
+
missingArgument(name2) {
|
|
2539
|
+
const message = `error: missing required argument '${name2}'`;
|
|
2540
2540
|
this.error(message, { code: "commander.missingArgument" });
|
|
2541
2541
|
}
|
|
2542
2542
|
/**
|
|
@@ -3020,9 +3020,9 @@ var require_commander = __commonJS({
|
|
|
3020
3020
|
var { Help: Help2 } = require_help();
|
|
3021
3021
|
var { Option: Option2 } = require_option();
|
|
3022
3022
|
exports2.program = new Command2();
|
|
3023
|
-
exports2.createCommand = (
|
|
3023
|
+
exports2.createCommand = (name2) => new Command2(name2);
|
|
3024
3024
|
exports2.createOption = (flags, description) => new Option2(flags, description);
|
|
3025
|
-
exports2.createArgument = (
|
|
3025
|
+
exports2.createArgument = (name2, description) => new Argument2(name2, description);
|
|
3026
3026
|
exports2.Command = Command2;
|
|
3027
3027
|
exports2.Option = Option2;
|
|
3028
3028
|
exports2.Argument = Argument2;
|
|
@@ -3044,7 +3044,7 @@ var VERSION, brand, useColor, wrap, paint, tuiDesign, sym, ui;
|
|
|
3044
3044
|
var init_branding = __esm({
|
|
3045
3045
|
"src/branding.ts"() {
|
|
3046
3046
|
"use strict";
|
|
3047
|
-
VERSION = "0.4.
|
|
3047
|
+
VERSION = "0.4.38" ? "0.4.38" : null.version;
|
|
3048
3048
|
brand = {
|
|
3049
3049
|
name: "agentful",
|
|
3050
3050
|
// the command users type
|
|
@@ -4639,12 +4639,12 @@ function requireProject(cwd = process.cwd()) {
|
|
|
4639
4639
|
return config;
|
|
4640
4640
|
}
|
|
4641
4641
|
async function createProject(auth, title, cwd = process.cwd()) {
|
|
4642
|
-
const
|
|
4642
|
+
const name2 = (title || "").trim() || (0, import_node_path3.basename)(cwd);
|
|
4643
4643
|
const record = await request(`${PB_URL}/api/collections/projects/records`, {
|
|
4644
4644
|
token: auth.pb_token,
|
|
4645
|
-
body: { title:
|
|
4645
|
+
body: { title: name2, description: "Created with the Agentful CLI", user_id: auth.user_id, status: "draft", environment: "Auto" }
|
|
4646
4646
|
});
|
|
4647
|
-
const config = { projectId: record.id, userId: auth.user_id, title:
|
|
4647
|
+
const config = { projectId: record.id, userId: auth.user_id, title: name2, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4648
4648
|
writeProjectConfig(config, cwd);
|
|
4649
4649
|
return config;
|
|
4650
4650
|
}
|
|
@@ -5110,13 +5110,13 @@ export function setCurrentYear() {
|
|
|
5110
5110
|
var STARTERS = starters_default.starters;
|
|
5111
5111
|
var STARTER_NAMES = Object.keys(STARTERS);
|
|
5112
5112
|
var IGNORABLE = /* @__PURE__ */ new Set([".git", ".agentful", ".DS_Store"]);
|
|
5113
|
-
function materializeStarter(
|
|
5114
|
-
const starter = STARTERS[
|
|
5113
|
+
function materializeStarter(name2, targetDir, projectName) {
|
|
5114
|
+
const starter = STARTERS[name2];
|
|
5115
5115
|
if (!starter) {
|
|
5116
5116
|
throw new ApiError(
|
|
5117
5117
|
0,
|
|
5118
5118
|
"unknown_template",
|
|
5119
|
-
`Unknown template '${
|
|
5119
|
+
`Unknown template '${name2}'. Available: ${STARTER_NAMES.join(", ")}.`
|
|
5120
5120
|
);
|
|
5121
5121
|
}
|
|
5122
5122
|
const blockers = (0, import_node_fs3.existsSync)(targetDir) ? (0, import_node_fs3.readdirSync)(targetDir).filter((entry) => !IGNORABLE.has(entry)) : [];
|
|
@@ -5125,7 +5125,7 @@ function materializeStarter(name, targetDir, projectName) {
|
|
|
5125
5125
|
0,
|
|
5126
5126
|
"directory_not_empty",
|
|
5127
5127
|
`This directory is not empty (found ${blockers.slice(0, 3).join(", ")}${blockers.length > 3 ? ", \u2026" : ""}). \`init --template\` scaffolds into an empty directory only \u2014 it never overwrites your files.
|
|
5128
|
-
Pass a new folder name instead: \`agentful init --template ${
|
|
5128
|
+
Pass a new folder name instead: \`agentful init --template ${name2} my-app\` (creates it for you).`
|
|
5129
5129
|
);
|
|
5130
5130
|
}
|
|
5131
5131
|
let written = 0;
|
|
@@ -6377,7 +6377,7 @@ var ALWAYS_EXCLUDE_DIRS = /* @__PURE__ */ new Set([
|
|
|
6377
6377
|
".netlify"
|
|
6378
6378
|
]);
|
|
6379
6379
|
var ALWAYS_EXCLUDE_BASENAMES = /* @__PURE__ */ new Set([".ds_store", "thumbs.db"]);
|
|
6380
|
-
var isEnvFile = (
|
|
6380
|
+
var isEnvFile = (name2) => name2 === ".env" || name2.startsWith(".env.");
|
|
6381
6381
|
function scanTree(rootDir, mode) {
|
|
6382
6382
|
const ig = (0, import_ignore.default)();
|
|
6383
6383
|
let gitignoreApplied = false;
|
|
@@ -6555,8 +6555,8 @@ function checkBackendDeclaration(rootDir = process.cwd()) {
|
|
|
6555
6555
|
continue;
|
|
6556
6556
|
}
|
|
6557
6557
|
presentFiles.add(entry);
|
|
6558
|
-
const
|
|
6559
|
-
if (
|
|
6558
|
+
const name2 = entry.endsWith(".js") ? entry.slice(0, -3) : null;
|
|
6559
|
+
if (name2 === null || !ACTION_NAME.test(name2)) {
|
|
6560
6560
|
issues.push(
|
|
6561
6561
|
`.server/actions/${entry}: invalid action filename \u2014 must match [a-z][a-z0-9_-]{0,62}.js (names starting with _ are reserved). The platform rejects the whole push otherwise.`
|
|
6562
6562
|
);
|
|
@@ -6565,25 +6565,25 @@ function checkBackendDeclaration(rootDir = process.cwd()) {
|
|
|
6565
6565
|
}
|
|
6566
6566
|
const decl = readBackendDeclaration(rootDir);
|
|
6567
6567
|
const declared = decl?.actions ?? [];
|
|
6568
|
-
for (const
|
|
6569
|
-
if (!ACTION_NAME.test(
|
|
6568
|
+
for (const name2 of declared) {
|
|
6569
|
+
if (!ACTION_NAME.test(name2)) {
|
|
6570
6570
|
issues.push(
|
|
6571
|
-
`.agentful/backend.json declares action "${
|
|
6571
|
+
`.agentful/backend.json declares action "${name2}" \u2014 names must match [a-z][a-z0-9_-]{0,62} (the filename without .js).`
|
|
6572
6572
|
);
|
|
6573
6573
|
continue;
|
|
6574
6574
|
}
|
|
6575
|
-
if (!presentFiles.has(`${
|
|
6575
|
+
if (!presentFiles.has(`${name2}.js`)) {
|
|
6576
6576
|
issues.push(
|
|
6577
|
-
`.agentful/backend.json declares action "${
|
|
6577
|
+
`.agentful/backend.json declares action "${name2}" but .server/actions/${name2}.js does not exist \u2014 create the file or remove the declaration entry.`
|
|
6578
6578
|
);
|
|
6579
6579
|
}
|
|
6580
6580
|
}
|
|
6581
6581
|
const declaredSet = new Set(declared);
|
|
6582
6582
|
for (const file of presentFiles) {
|
|
6583
|
-
const
|
|
6584
|
-
if (ACTION_NAME.test(
|
|
6583
|
+
const name2 = file.endsWith(".js") ? file.slice(0, -3) : file;
|
|
6584
|
+
if (ACTION_NAME.test(name2) && !declaredSet.has(name2)) {
|
|
6585
6585
|
warnings.push(
|
|
6586
|
-
`.server/actions/${file} is not declared in .agentful/backend.json \u2014 it will deploy, but \`agentful backend\` and the Backend tab won't know about it. Add "${
|
|
6586
|
+
`.server/actions/${file} is not declared in .agentful/backend.json \u2014 it will deploy, but \`agentful backend\` and the Backend tab won't know about it. Add "${name2}" to the actions list.`
|
|
6587
6587
|
);
|
|
6588
6588
|
}
|
|
6589
6589
|
}
|
|
@@ -6611,9 +6611,9 @@ var INJECTABLE_NAMES = new Set(
|
|
|
6611
6611
|
var ALWAYS_DEFINED_NAMES = new Set(
|
|
6612
6612
|
BUILD_ENV.injected.filter((e) => e.when === "always").flatMap((e) => e.prefixes.map((p) => `${p}${e.suffix}`))
|
|
6613
6613
|
);
|
|
6614
|
-
var splitName = (
|
|
6615
|
-
const prefix = PUBLIC_PREFIXES.find((p) =>
|
|
6616
|
-
return prefix ? { prefix, suffix:
|
|
6614
|
+
var splitName = (name2) => {
|
|
6615
|
+
const prefix = PUBLIC_PREFIXES.find((p) => name2.startsWith(p));
|
|
6616
|
+
return prefix ? { prefix, suffix: name2.slice(prefix.length) } : null;
|
|
6617
6617
|
};
|
|
6618
6618
|
var injectedEntry = (suffix) => BUILD_ENV.injected.find((e) => e.suffix === suffix);
|
|
6619
6619
|
var SCAN_FILE = /\.(js|jsx|ts|tsx|mjs|cjs|vue|svelte|astro)$/;
|
|
@@ -6630,7 +6630,7 @@ var DESTRUCTURED_READ = new RegExp(String.raw`\{([^{}]*)\}\s*=\s*${ENV_OBJECT}\b
|
|
|
6630
6630
|
var QUOTED = /'(?:[^'\\\n]|\\.)*'|"(?:[^"\\\n]|\\.)*"/g;
|
|
6631
6631
|
var MENTIONS_ENV = /\benv\s*[.[]/;
|
|
6632
6632
|
var stripNonCode = (text) => text.replace(QUOTED, (quoted) => MENTIONS_ENV.test(quoted) ? "''" : quoted).replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:'"`\\])\/\/[^\n]*/g, "$1");
|
|
6633
|
-
var isReportable = (
|
|
6633
|
+
var isReportable = (name2) => !BUILTINS.has(name2) && splitName(name2) !== null;
|
|
6634
6634
|
function collectFiles2(dir, out, budget) {
|
|
6635
6635
|
if (budget.left <= 0 || !(0, import_node_fs6.existsSync)(dir)) return;
|
|
6636
6636
|
for (const entry of (0, import_node_fs6.readdirSync)(dir, { withFileTypes: true })) {
|
|
@@ -6658,8 +6658,8 @@ function scanEnvReads(rootDir) {
|
|
|
6658
6658
|
if (text.length > MAX_SCAN_BYTES || !/\benv\b/.test(text)) continue;
|
|
6659
6659
|
text = stripNonCode(text);
|
|
6660
6660
|
const inFile = /* @__PURE__ */ new Map();
|
|
6661
|
-
const note = (
|
|
6662
|
-
if (isReportable(
|
|
6661
|
+
const note = (name2, hasFallback) => {
|
|
6662
|
+
if (isReportable(name2)) inFile.set(name2, (inFile.get(name2) ?? true) && hasFallback);
|
|
6663
6663
|
};
|
|
6664
6664
|
for (const m of text.matchAll(MEMBER_READ)) note(m[1] || m[2], Boolean(m[3]));
|
|
6665
6665
|
for (const m of text.matchAll(DESTRUCTURED_READ)) {
|
|
@@ -6669,7 +6669,7 @@ function scanEnvReads(rootDir) {
|
|
|
6669
6669
|
}
|
|
6670
6670
|
}
|
|
6671
6671
|
const file = (0, import_node_path8.relative)(rootDir, abs).split(import_node_path8.sep).join("/");
|
|
6672
|
-
for (const [
|
|
6672
|
+
for (const [name2, hasFallback] of inFile) reads.push({ name: name2, file, hasFallback });
|
|
6673
6673
|
}
|
|
6674
6674
|
return reads;
|
|
6675
6675
|
}
|
|
@@ -6693,8 +6693,8 @@ function envFileNames(rootDir) {
|
|
|
6693
6693
|
}
|
|
6694
6694
|
var sampleFiles = (files) => files.slice(0, 3).join(", ") + (files.length > 3 ? ", \u2026" : "");
|
|
6695
6695
|
var prefixList = (prefixes) => prefixes.map((p) => `${p}*`).join("/");
|
|
6696
|
-
function platformHint(
|
|
6697
|
-
const { prefix, suffix } = splitName(
|
|
6696
|
+
function platformHint(name2, opts) {
|
|
6697
|
+
const { prefix, suffix } = splitName(name2);
|
|
6698
6698
|
const entry = injectedEntry(suffix);
|
|
6699
6699
|
if (!entry.prefixes.includes(prefix)) {
|
|
6700
6700
|
return `The platform defines ${suffix} only as ${entry.prefixes.map((p) => `${p}${suffix}`).join(" and ")} \u2014 read one of those, or keep the value in an ordinary source constant.`;
|
|
@@ -6718,29 +6718,29 @@ function judgeEnvReads(reads, opts) {
|
|
|
6718
6718
|
}
|
|
6719
6719
|
const verdict = { errors: [], warnings: [] };
|
|
6720
6720
|
const build = opts.backendUnknown ? "the cloud build" : "this build";
|
|
6721
|
-
for (const
|
|
6722
|
-
const group = byName.get(
|
|
6721
|
+
for (const name2 of [...byName.keys()].sort()) {
|
|
6722
|
+
const group = byName.get(name2);
|
|
6723
6723
|
const files = sampleFiles(group.map((r) => r.file).sort());
|
|
6724
|
-
const { prefix, suffix } = splitName(
|
|
6724
|
+
const { prefix, suffix } = splitName(name2);
|
|
6725
6725
|
const entry = injectedEntry(suffix);
|
|
6726
6726
|
const taught = entry !== void 0;
|
|
6727
6727
|
const bare = group.filter((r) => !r.hasFallback);
|
|
6728
|
-
const local = opts.localOnly?.has(
|
|
6728
|
+
const local = opts.localOnly?.has(name2) ? " Your local .env defines it, but .env files never leave this machine." : "";
|
|
6729
6729
|
if (opts.backendUnknown && entry && entry.when === "byo_supabase" && entry.prefixes.includes(prefix)) {
|
|
6730
6730
|
verdict.warnings.push(
|
|
6731
|
-
`${
|
|
6731
|
+
`${name2} is read in ${files}. The cloud build defines it only while your own Supabase database is connected in the Backend tab (Database \u2192 own Supabase)` + (bare.length > 0 ? " \u2014 without that it rejects the build, because the value would compile to `undefined` without any build error." : "; without that the app runs on its own fallback.") + local
|
|
6732
6732
|
);
|
|
6733
6733
|
} else if (taught && bare.length > 0) {
|
|
6734
6734
|
verdict.errors.push(
|
|
6735
|
-
`${
|
|
6735
|
+
`${name2} is read in ${sampleFiles(bare.map((r) => r.file).sort())}, but ${build} does not define it \u2014 it would compile to \`undefined\` without any build error. ${platformHint(name2, opts)}${local}`
|
|
6736
6736
|
);
|
|
6737
6737
|
} else if (taught) {
|
|
6738
6738
|
verdict.warnings.push(
|
|
6739
|
-
`${
|
|
6739
|
+
`${name2} is read in ${files} and ${build} does not define it \u2014 the app runs on its own fallback. ${platformHint(name2, opts)}${local}`
|
|
6740
6740
|
);
|
|
6741
6741
|
} else {
|
|
6742
6742
|
verdict.warnings.push(
|
|
6743
|
-
`${
|
|
6743
|
+
`${name2} is read in ${files}, but no cloud build defines it \u2014 it compiles to \`undefined\`. This platform sets no build variables of your own: keep public values in an ordinary source constant (a fallback such as \`?? '/api'\` is fine).${local}`
|
|
6744
6744
|
);
|
|
6745
6745
|
}
|
|
6746
6746
|
}
|
|
@@ -6754,7 +6754,7 @@ function feature(id) {
|
|
|
6754
6754
|
return found;
|
|
6755
6755
|
}
|
|
6756
6756
|
var FRAMEWORK_TABLE = contract_default.frameworks;
|
|
6757
|
-
var SUPPORTED_FRAMEWORKS = FRAMEWORK_TABLE.map((f) => f.display_name).map((
|
|
6757
|
+
var SUPPORTED_FRAMEWORKS = FRAMEWORK_TABLE.map((f) => f.display_name).map((name2, i, all) => i === all.length - 1 ? `or ${name2}` : name2).join(", ");
|
|
6758
6758
|
var PLATFORM_CONTRACT = contract_default.contract_statement;
|
|
6759
6759
|
function frameworkDisplayName(id) {
|
|
6760
6760
|
return FRAMEWORK_TABLE.find((f) => f.id === id)?.display_name ?? id;
|
|
@@ -6828,7 +6828,7 @@ function collectSourceFiles(dir, out, budget) {
|
|
|
6828
6828
|
function checkNextjs(rootDir) {
|
|
6829
6829
|
const issues = [];
|
|
6830
6830
|
const warnings = [];
|
|
6831
|
-
const configName = NEXT_CONFIG_BASENAMES.find((
|
|
6831
|
+
const configName = NEXT_CONFIG_BASENAMES.find((name2) => (0, import_node_fs7.existsSync)((0, import_node_path9.join)(rootDir, name2)));
|
|
6832
6832
|
let hasStaticExport = true;
|
|
6833
6833
|
if (configName) {
|
|
6834
6834
|
const config = (0, import_node_fs7.readFileSync)((0, import_node_path9.join)(rootDir, configName), "utf8");
|
|
@@ -7060,12 +7060,12 @@ var samplePaths = (paths) => paths.slice(0, 3).join(", ") + (paths.length > 3 ?
|
|
|
7060
7060
|
function groupSizes(files, keyOf) {
|
|
7061
7061
|
const groups = /* @__PURE__ */ new Map();
|
|
7062
7062
|
for (const file of files) {
|
|
7063
|
-
const
|
|
7064
|
-
const group = groups.get(
|
|
7063
|
+
const name2 = keyOf(file);
|
|
7064
|
+
const group = groups.get(name2) ?? { name: name2, files: 0, bytes: 0, zip_bytes: 0 };
|
|
7065
7065
|
group.files += 1;
|
|
7066
7066
|
group.bytes += file.bytes;
|
|
7067
7067
|
group.zip_bytes += file.zip_bytes;
|
|
7068
|
-
groups.set(
|
|
7068
|
+
groups.set(name2, group);
|
|
7069
7069
|
}
|
|
7070
7070
|
return [...groups.values()].sort((a, b) => b.bytes - a.bytes || (a.name < b.name ? -1 : 1));
|
|
7071
7071
|
}
|
|
@@ -7188,7 +7188,7 @@ function analyzePush(options) {
|
|
|
7188
7188
|
const byPathMap = new Map(measured.map((file) => [file.path, file]));
|
|
7189
7189
|
const stored = measured.filter((file) => view.stored.has(file.path));
|
|
7190
7190
|
const storedBytes = stored.reduce((total, file) => total + file.bytes, 0);
|
|
7191
|
-
const storedNames = new Map([...view.stored].map(([local,
|
|
7191
|
+
const storedNames = new Map([...view.stored].map(([local, name2]) => [name2, local]));
|
|
7192
7192
|
const dropped = view.dropped.map((drop) => ({ path: drop.rel, bytes: byPathMap.get(drop.rel)?.bytes ?? 0, reason: drop.reason, matched: drop.matched })).sort(byPath);
|
|
7193
7193
|
const byHash = /* @__PURE__ */ new Map();
|
|
7194
7194
|
for (const file of measured) {
|
|
@@ -7516,10 +7516,10 @@ var printAnalysis = (analysis) => `${JSON.stringify(analysis.view === "summary"
|
|
|
7516
7516
|
`;
|
|
7517
7517
|
function summarize(analysis, divisor) {
|
|
7518
7518
|
const shortened = {};
|
|
7519
|
-
const cut = (
|
|
7519
|
+
const cut = (name2, list, cap, alreadyOmitted = 0) => {
|
|
7520
7520
|
const keep = Math.max(1, Math.floor(cap / divisor));
|
|
7521
7521
|
const omitted = Math.max(0, list.length - keep) + alreadyOmitted;
|
|
7522
|
-
if (omitted > 0) shortened[
|
|
7522
|
+
if (omitted > 0) shortened[name2] = (shortened[name2] ?? 0) + omitted;
|
|
7523
7523
|
return list.slice(0, keep);
|
|
7524
7524
|
};
|
|
7525
7525
|
const finding = (kind) => (item) => item.paths ? { ...item, paths: cut(`${kind}.paths`, item.paths, SUMMARY_LISTS.finding_paths) } : item;
|
|
@@ -8527,10 +8527,10 @@ function ensureCliOnPath() {
|
|
|
8527
8527
|
(0, import_node_fs10.mkdirSync)(binDir, { recursive: true });
|
|
8528
8528
|
const entry = process.argv[1];
|
|
8529
8529
|
if (!entry) return binDir;
|
|
8530
|
-
const restore = (
|
|
8531
|
-
const original = process.env[
|
|
8532
|
-
return original === void 0 ? `unset ${
|
|
8533
|
-
` : `export ${
|
|
8530
|
+
const restore = (name2) => {
|
|
8531
|
+
const original = process.env[name2];
|
|
8532
|
+
return original === void 0 ? `unset ${name2}
|
|
8533
|
+
` : `export ${name2}=${JSON.stringify(original)}
|
|
8534
8534
|
`;
|
|
8535
8535
|
};
|
|
8536
8536
|
const wrapper = (0, import_node_path12.join)(binDir, "agentful");
|
|
@@ -8553,6 +8553,36 @@ function ensureCliOnPath() {
|
|
|
8553
8553
|
// src/commands/tui.ts
|
|
8554
8554
|
init_branding();
|
|
8555
8555
|
|
|
8556
|
+
// src/lib/creditSummary.ts
|
|
8557
|
+
var NAME_MAX_CHARS = 80;
|
|
8558
|
+
var LEADS_MAX = 3;
|
|
8559
|
+
function name(value) {
|
|
8560
|
+
return typeof value === "string" ? value.replace(/\s+/g, " ").trim().slice(0, NAME_MAX_CHARS) : "";
|
|
8561
|
+
}
|
|
8562
|
+
function budgetSummaryLines(answer) {
|
|
8563
|
+
if (!answer || answer.reason !== "budget_exhausted" || answer.allowed === true) return void 0;
|
|
8564
|
+
const level = answer.budget_level || "";
|
|
8565
|
+
const responsible = answer.budget_responsible || {};
|
|
8566
|
+
const department = name(responsible.department_name);
|
|
8567
|
+
const leads = Array.isArray(responsible.leads) ? responsible.leads.map(name).filter(Boolean).slice(0, LEADS_MAX) : [];
|
|
8568
|
+
const page = `${APP_URL}/dashboard/organization`;
|
|
8569
|
+
if (level === "seat") {
|
|
8570
|
+
return [
|
|
8571
|
+
"Your team seat's included credits for this month are used up, and your organization does not allow paying with your own credits.",
|
|
8572
|
+
`Contact an admin of your organization: ${page}`
|
|
8573
|
+
];
|
|
8574
|
+
}
|
|
8575
|
+
let whose = "Your organization's budget";
|
|
8576
|
+
if (level === "department") whose = department ? `The budget of your department "${department}"` : "Your department's budget";
|
|
8577
|
+
if (level === "person") whose = "Your personal budget";
|
|
8578
|
+
const lines = [`${whose} for this month is used up. It starts again on the first of next month (UTC).`];
|
|
8579
|
+
lines.push(leads.length > 0 ? `Ask ${leads.join(", ")} (lead of your department) or an admin for more budget: ${page}?budget_request=1` : `Ask an admin of your organization for more budget: ${page}?budget_request=1`);
|
|
8580
|
+
if (answer.budget?.self_pay_allowed === true) {
|
|
8581
|
+
lines.push(`Your organization allows paying with your own credits: ${APP_URL}/settings/subscription?tab=credits`);
|
|
8582
|
+
}
|
|
8583
|
+
return lines;
|
|
8584
|
+
}
|
|
8585
|
+
|
|
8556
8586
|
// src/lib/engine.ts
|
|
8557
8587
|
var import_node_fs11 = require("fs");
|
|
8558
8588
|
var import_node_crypto3 = require("crypto");
|
|
@@ -8813,14 +8843,14 @@ function frameworkTable() {
|
|
|
8813
8843
|
return rows.join("\n");
|
|
8814
8844
|
}
|
|
8815
8845
|
function sessionLine(framework) {
|
|
8816
|
-
const
|
|
8846
|
+
const name2 = frameworkDisplayName2(framework);
|
|
8817
8847
|
switch (framework) {
|
|
8818
8848
|
case "nextjs":
|
|
8819
|
-
return `Detected framework in this directory: **${
|
|
8849
|
+
return `Detected framework in this directory: **${name2}** \u2014 next.config must keep \`output: 'export'\`; no route handlers/middleware/server actions.`;
|
|
8820
8850
|
case "unknown":
|
|
8821
8851
|
return "Detected framework in this directory: **none of the supported ones** \u2014 a push would be rejected. Fine for local-only work; for a deployable project use one of the frameworks above.";
|
|
8822
8852
|
default:
|
|
8823
|
-
return `Detected framework in this directory: **${
|
|
8853
|
+
return `Detected framework in this directory: **${name2}**.`;
|
|
8824
8854
|
}
|
|
8825
8855
|
}
|
|
8826
8856
|
var LOGIN_QUESTION = 'If the task implies end-user accounts or sign-in (login, registration, members, profiles, per-user data, protected areas) and no login is configured yet, ask the user which sign-in the app\'s users should get \u2014 EXACTLY these three options, in the user\'s language: no login / email + password / email + Google (keep the literal words "E-Mail" and "Google" in the labels; never offer any other provider). Record the answer in `.agentful/backend.json` \u2192 `auth.end_user_login` (e.g. `["email", "google"]`); `agentful push` persists it \u2014 you cannot persist it yourself, and asking is your only part of that step.';
|
|
@@ -8907,7 +8937,7 @@ function serverSideSection() {
|
|
|
8907
8937
|
}
|
|
8908
8938
|
var PUSH_ANALYSIS_COMMAND = "agentful push --dry-run --json --summary";
|
|
8909
8939
|
function pushSection() {
|
|
8910
|
-
const excludedDirs = [...ALWAYS_EXCLUDE_DIRS].filter((
|
|
8940
|
+
const excludedDirs = [...ALWAYS_EXCLUDE_DIRS].filter((name2) => /^[a-z]/.test(name2)).map((name2) => `\`${name2}\``).join(", ");
|
|
8911
8941
|
return `## Pushing to the platform (\`agentful push\`)
|
|
8912
8942
|
|
|
8913
8943
|
Two ways to upload. Every push replaces the previous upload completely, so a
|
|
@@ -9241,8 +9271,8 @@ Apart from a change I approved in step 2, do not modify project files.`
|
|
|
9241
9271
|
template: "Run `agentful whoami` using the bash tool. Then read .agentful/project.json and report the linked project title and id, plus the preview URL https://preview-<projectId>.agentful.page/. If the file does not exist, say that this directory is not linked yet and that `/setup` creates the link."
|
|
9242
9272
|
}
|
|
9243
9273
|
};
|
|
9244
|
-
function commandMarkdown(
|
|
9245
|
-
const cmd = SLASH_COMMANDS[
|
|
9274
|
+
function commandMarkdown(name2) {
|
|
9275
|
+
const cmd = SLASH_COMMANDS[name2];
|
|
9246
9276
|
const description = JSON.stringify(cmd.description);
|
|
9247
9277
|
return `---
|
|
9248
9278
|
description: ${description}
|
|
@@ -9432,8 +9462,8 @@ async function writeEngineSession(session, catalog, localProviders = {}, framewo
|
|
|
9432
9462
|
plugin_enabled: DISABLED_ENGINE_PLUGINS
|
|
9433
9463
|
}, null, 2));
|
|
9434
9464
|
(0, import_node_fs14.writeFileSync)((0, import_node_path16.join)(themesDir, "agentful.json"), JSON.stringify(await resolveTheme(), null, 2));
|
|
9435
|
-
for (const
|
|
9436
|
-
(0, import_node_fs14.writeFileSync)((0, import_node_path16.join)(commandsDir, `${
|
|
9465
|
+
for (const name2 of Object.keys(SLASH_COMMANDS)) {
|
|
9466
|
+
(0, import_node_fs14.writeFileSync)((0, import_node_path16.join)(commandsDir, `${name2}.md`), commandMarkdown(name2));
|
|
9437
9467
|
}
|
|
9438
9468
|
for (const legacy of ["xdg-config", "xdg-data", "xdg-state"]) {
|
|
9439
9469
|
try {
|
|
@@ -9532,17 +9562,17 @@ function selectSkills(framework, rootDir) {
|
|
|
9532
9562
|
if (scaffold) names.push(scaffold);
|
|
9533
9563
|
}
|
|
9534
9564
|
names.push(MANAGED_DB_SKILL);
|
|
9535
|
-
return names.filter((
|
|
9565
|
+
return names.filter((name2) => name2 in SKILLS);
|
|
9536
9566
|
}
|
|
9537
|
-
function skillBody(
|
|
9538
|
-
const raw = SKILLS[
|
|
9567
|
+
function skillBody(name2) {
|
|
9568
|
+
const raw = SKILLS[name2];
|
|
9539
9569
|
const match = raw.match(/^---\n[\s\S]*?\n---\n/);
|
|
9540
9570
|
return (match ? raw.slice(match[0].length) : raw).trim();
|
|
9541
9571
|
}
|
|
9542
9572
|
function renderSkillsInstruction(names) {
|
|
9543
|
-
const known = names.filter((
|
|
9573
|
+
const known = names.filter((name2) => name2 in SKILLS);
|
|
9544
9574
|
if (known.length === 0) return null;
|
|
9545
|
-
const sections = known.map((
|
|
9575
|
+
const sections = known.map((name2) => skillBody(name2));
|
|
9546
9576
|
if (known.includes(MANAGED_DB_SKILL)) sections.push(MANAGED_DB_LOCAL_ADDENDUM);
|
|
9547
9577
|
return "# Platform deployment skills (mandatory)\n\nThese are the same skills the cloud build agent loads for this stack.\nFollow them when scaffolding or editing \u2014 they are not optional hints.\n\n" + sections.join("\n\n---\n\n") + "\n";
|
|
9548
9578
|
}
|
|
@@ -10544,7 +10574,12 @@ async function tuiCommand(opts = {}) {
|
|
|
10544
10574
|
`${PB_URL}/api/credits/check`,
|
|
10545
10575
|
{ token: auth.pb_token, timeoutMs: 8e3 }
|
|
10546
10576
|
);
|
|
10547
|
-
|
|
10577
|
+
const budgetLines = budgetSummaryLines(credits);
|
|
10578
|
+
if (budgetLines) {
|
|
10579
|
+
console.log("");
|
|
10580
|
+
ui.warn(budgetLines[0]);
|
|
10581
|
+
for (const line of budgetLines.slice(1)) ui.info(line);
|
|
10582
|
+
} else if (typeof credits.credits_remaining === "number") {
|
|
10548
10583
|
console.log("");
|
|
10549
10584
|
ui.info(`Credits remaining: ${paint.bold(String(Math.floor(credits.credits_remaining)))}${credits.tier ? paint.dim(` (${credits.tier})`) : ""}`);
|
|
10550
10585
|
}
|
|
@@ -10640,21 +10675,21 @@ async function publishCommand(subdomain, opts = {}) {
|
|
|
10640
10675
|
if (!opts.json) console.log(banner());
|
|
10641
10676
|
const auth = await ensureAuth();
|
|
10642
10677
|
const project = requireProject();
|
|
10643
|
-
const
|
|
10644
|
-
if (!SUBDOMAIN_RE.test(
|
|
10678
|
+
const name2 = subdomain.trim().toLowerCase();
|
|
10679
|
+
if (!SUBDOMAIN_RE.test(name2)) {
|
|
10645
10680
|
throw new ApiError(
|
|
10646
10681
|
0,
|
|
10647
10682
|
"invalid_subdomain",
|
|
10648
10683
|
"Subdomain must be 3-63 chars, lowercase letters/digits/hyphens, no leading/trailing hyphen."
|
|
10649
10684
|
);
|
|
10650
10685
|
}
|
|
10651
|
-
say(`Checking availability of ${
|
|
10686
|
+
say(`Checking availability of ${name2}.${PUBLISHED_DOMAIN}\u2026`);
|
|
10652
10687
|
const check = await request(
|
|
10653
|
-
`${PUBLIC_API_URL}/api/subdomains/check/${
|
|
10688
|
+
`${PUBLIC_API_URL}/api/subdomains/check/${name2}`,
|
|
10654
10689
|
{ token: auth.pb_token }
|
|
10655
10690
|
);
|
|
10656
10691
|
if (check.available === false) {
|
|
10657
|
-
throw new ApiError(409, "subdomain_taken", check.message || `"${
|
|
10692
|
+
throw new ApiError(409, "subdomain_taken", check.message || `"${name2}" is not available.`);
|
|
10658
10693
|
}
|
|
10659
10694
|
say("Publishing\u2026");
|
|
10660
10695
|
const res = await request(
|
|
@@ -10663,20 +10698,20 @@ async function publishCommand(subdomain, opts = {}) {
|
|
|
10663
10698
|
token: auth.pb_token,
|
|
10664
10699
|
// publish_newest: the newest build goes live, also with "publish new
|
|
10665
10700
|
// builds automatically" off (default for new projects since O8).
|
|
10666
|
-
body: { user_id: project.userId, project_id: project.projectId, subdomain:
|
|
10701
|
+
body: { user_id: project.userId, project_id: project.projectId, subdomain: name2, publish_newest: true },
|
|
10667
10702
|
timeoutMs: 12e4
|
|
10668
10703
|
}
|
|
10669
10704
|
);
|
|
10670
10705
|
if (res.success === false) {
|
|
10671
10706
|
throw new ApiError(0, "publish_failed", res.message || "Publish failed.");
|
|
10672
10707
|
}
|
|
10673
|
-
const publicUrl = res.public_url || `https://${
|
|
10708
|
+
const publicUrl = res.public_url || `https://${name2}.${PUBLISHED_DOMAIN}`;
|
|
10674
10709
|
const securityCheck = await readPublishCheck(auth.pb_token, project.userId, project.projectId);
|
|
10675
10710
|
if (opts.json) {
|
|
10676
10711
|
process.stdout.write(JSON.stringify({
|
|
10677
10712
|
published: true,
|
|
10678
10713
|
public_url: publicUrl,
|
|
10679
|
-
subdomain: res.subdomain ||
|
|
10714
|
+
subdomain: res.subdomain || name2,
|
|
10680
10715
|
publish_check: publishCheckJson(securityCheck)
|
|
10681
10716
|
}, null, 2) + "\n");
|
|
10682
10717
|
return;
|