@genfeedai/cli 0.2.1 → 0.3.1
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.js +65 -38
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -29515,6 +29515,13 @@ async function setActiveBrand(brandId, profileName) {
|
|
|
29515
29515
|
async function clearActiveBrand(profileName) {
|
|
29516
29516
|
await setProfileField("activeBrand", undefined, profileName);
|
|
29517
29517
|
}
|
|
29518
|
+
async function getOrganizationId() {
|
|
29519
|
+
const { profile } = await getActiveProfile();
|
|
29520
|
+
return profile.organizationId;
|
|
29521
|
+
}
|
|
29522
|
+
async function setOrganizationId(organizationId, profileName) {
|
|
29523
|
+
await setProfileField("organizationId", organizationId, profileName);
|
|
29524
|
+
}
|
|
29518
29525
|
async function setRole(role, profileName) {
|
|
29519
29526
|
await setProfileField("role", role, profileName);
|
|
29520
29527
|
}
|
|
@@ -29672,8 +29679,8 @@ async function requireAuth() {
|
|
|
29672
29679
|
}
|
|
29673
29680
|
|
|
29674
29681
|
// src/api/brands.ts
|
|
29675
|
-
async function listBrands() {
|
|
29676
|
-
const response = await get(
|
|
29682
|
+
async function listBrands(organizationId) {
|
|
29683
|
+
const response = await get(`/organizations/${organizationId}/brands`);
|
|
29677
29684
|
return response.data;
|
|
29678
29685
|
}
|
|
29679
29686
|
async function getBrand(id) {
|
|
@@ -29727,8 +29734,12 @@ function printJson(data) {
|
|
|
29727
29734
|
var brandsCommand = new Command("brands").description("Manage brands").option("--json", "Output as JSON").action(async (options) => {
|
|
29728
29735
|
try {
|
|
29729
29736
|
await requireAuth();
|
|
29737
|
+
const orgId = await getOrganizationId();
|
|
29738
|
+
if (!orgId) {
|
|
29739
|
+
throw new GenfeedError("No organization found", "Re-authenticate with `gf login` to link your organization");
|
|
29740
|
+
}
|
|
29730
29741
|
const spinner = ora("Fetching brands...").start();
|
|
29731
|
-
const brands = await listBrands();
|
|
29742
|
+
const brands = await listBrands(orgId);
|
|
29732
29743
|
spinner.stop();
|
|
29733
29744
|
const activeBrandId = await getActiveBrand();
|
|
29734
29745
|
if (options.json) {
|
|
@@ -29738,7 +29749,7 @@ var brandsCommand = new Command("brands").description("Manage brands").option("-
|
|
|
29738
29749
|
active: b.id === activeBrandId,
|
|
29739
29750
|
description: b.description,
|
|
29740
29751
|
id: b.id,
|
|
29741
|
-
|
|
29752
|
+
label: b.label
|
|
29742
29753
|
}))
|
|
29743
29754
|
});
|
|
29744
29755
|
return;
|
|
@@ -29753,7 +29764,7 @@ var brandsCommand = new Command("brands").description("Manage brands").option("-
|
|
|
29753
29764
|
for (const brand of brands) {
|
|
29754
29765
|
const isActive = brand.id === activeBrandId;
|
|
29755
29766
|
const marker = isActive ? source_default.green("●") : source_default.dim("○");
|
|
29756
|
-
const name = isActive ? source_default.bold(brand.
|
|
29767
|
+
const name = isActive ? source_default.bold(brand.label) : brand.label;
|
|
29757
29768
|
const activeLabel = isActive ? source_default.dim(" (active)") : "";
|
|
29758
29769
|
print(` ${marker} ${name}${activeLabel}`);
|
|
29759
29770
|
if (brand.description) {
|
|
@@ -29769,8 +29780,12 @@ var brandsCommand = new Command("brands").description("Manage brands").option("-
|
|
|
29769
29780
|
brandsCommand.command("select").description("Select the active brand").action(async () => {
|
|
29770
29781
|
try {
|
|
29771
29782
|
await requireAuth();
|
|
29783
|
+
const orgId = await getOrganizationId();
|
|
29784
|
+
if (!orgId) {
|
|
29785
|
+
throw new GenfeedError("No organization found", "Re-authenticate with `gf login` to link your organization");
|
|
29786
|
+
}
|
|
29772
29787
|
const spinner = ora("Fetching brands...").start();
|
|
29773
|
-
const brands = await listBrands();
|
|
29788
|
+
const brands = await listBrands(orgId);
|
|
29774
29789
|
spinner.stop();
|
|
29775
29790
|
if (brands.length === 0) {
|
|
29776
29791
|
throw new GenfeedError("No brands found", "Create a brand at https://app.genfeed.ai");
|
|
@@ -29779,7 +29794,7 @@ brandsCommand.command("select").description("Select the active brand").action(as
|
|
|
29779
29794
|
const selected = await dist_default5({
|
|
29780
29795
|
choices: brands.map((brand) => ({
|
|
29781
29796
|
description: brand.description,
|
|
29782
|
-
name: brand.id === activeBrandId ? `${brand.
|
|
29797
|
+
name: brand.id === activeBrandId ? `${brand.label} (current)` : brand.label,
|
|
29783
29798
|
value: brand.id
|
|
29784
29799
|
})),
|
|
29785
29800
|
default: activeBrandId,
|
|
@@ -29788,7 +29803,7 @@ brandsCommand.command("select").description("Select the active brand").action(as
|
|
|
29788
29803
|
await setActiveBrand(selected);
|
|
29789
29804
|
const selectedBrand = brands.find((b) => b.id === selected);
|
|
29790
29805
|
print();
|
|
29791
|
-
print(formatSuccess(`Active brand: ${source_default.bold(selectedBrand?.
|
|
29806
|
+
print(formatSuccess(`Active brand: ${source_default.bold(selectedBrand?.label)}`));
|
|
29792
29807
|
} catch (error49) {
|
|
29793
29808
|
handleError(error49);
|
|
29794
29809
|
}
|
|
@@ -29814,12 +29829,12 @@ brandsCommand.command("current").description("Show the current active brand").op
|
|
|
29814
29829
|
activeBrand: {
|
|
29815
29830
|
description: brand.description,
|
|
29816
29831
|
id: brand.id,
|
|
29817
|
-
name: brand.
|
|
29832
|
+
name: brand.label
|
|
29818
29833
|
}
|
|
29819
29834
|
});
|
|
29820
29835
|
return;
|
|
29821
29836
|
}
|
|
29822
|
-
print(formatSuccess(`Active brand: ${source_default.bold(brand.
|
|
29837
|
+
print(formatSuccess(`Active brand: ${source_default.bold(brand.label)}`));
|
|
29823
29838
|
if (brand.description) {
|
|
29824
29839
|
print(formatLabel("Description", brand.description));
|
|
29825
29840
|
}
|
|
@@ -30008,7 +30023,7 @@ var chatCommand = new Command("chat").description("Start an interactive agent ch
|
|
|
30008
30023
|
if (!conversationId) {
|
|
30009
30024
|
const spinner = ora("Starting new conversation...").start();
|
|
30010
30025
|
try {
|
|
30011
|
-
const conversation = await post("/
|
|
30026
|
+
const conversation = await post("/agent/conversations", {
|
|
30012
30027
|
source: "cli",
|
|
30013
30028
|
title: "CLI Chat"
|
|
30014
30029
|
});
|
|
@@ -30029,7 +30044,7 @@ var chatCommand = new Command("chat").description("Start an interactive agent ch
|
|
|
30029
30044
|
continue;
|
|
30030
30045
|
const spinner = ora("Thinking...").start();
|
|
30031
30046
|
try {
|
|
30032
|
-
const response = await post(`/
|
|
30047
|
+
const response = await post(`/agent/conversations/${conversationId}/messages`, { content: message, role: "user" });
|
|
30033
30048
|
spinner.stop();
|
|
30034
30049
|
const messages = response.messages ?? [];
|
|
30035
30050
|
const lastMessage = messages[messages.length - 1];
|
|
@@ -33485,7 +33500,7 @@ var libraryCommand = new Command("library").description("Browse content library"
|
|
|
33485
33500
|
if (options.type)
|
|
33486
33501
|
params.set("category", options.type);
|
|
33487
33502
|
params.set("limit", options.limit);
|
|
33488
|
-
const response = await get(`/
|
|
33503
|
+
const response = await get(`/ingredients?${params.toString()}`);
|
|
33489
33504
|
spinner.stop();
|
|
33490
33505
|
const items = response.data ?? [];
|
|
33491
33506
|
if (items.length === 0) {
|
|
@@ -33567,8 +33582,15 @@ function waitForOAuthCallback() {
|
|
|
33567
33582
|
}, CALLBACK_TIMEOUT);
|
|
33568
33583
|
function cleanup() {
|
|
33569
33584
|
clearTimeout(timeout);
|
|
33585
|
+
process.removeListener("SIGINT", onSigint);
|
|
33570
33586
|
server.close();
|
|
33571
33587
|
}
|
|
33588
|
+
function onSigint() {
|
|
33589
|
+
cleanup();
|
|
33590
|
+
reject(new GenfeedError("Authentication cancelled"));
|
|
33591
|
+
process.exit(130);
|
|
33592
|
+
}
|
|
33593
|
+
process.on("SIGINT", onSigint);
|
|
33572
33594
|
server.listen(0, "127.0.0.1", () => {
|
|
33573
33595
|
const addr = server.address();
|
|
33574
33596
|
if (addr && typeof addr === "object") {
|
|
@@ -33627,6 +33649,7 @@ async function completeLogin(apiKey) {
|
|
|
33627
33649
|
try {
|
|
33628
33650
|
const whoamiData = await validateApiKey();
|
|
33629
33651
|
spinner.succeed();
|
|
33652
|
+
await setOrganizationId(whoamiData.organization.id);
|
|
33630
33653
|
print();
|
|
33631
33654
|
print(formatSuccess(`Logged in as ${source_default.bold(whoamiData.organization.name)}`));
|
|
33632
33655
|
print(formatLabel("Email", whoamiData.user.email));
|
|
@@ -33636,25 +33659,29 @@ async function completeLogin(apiKey) {
|
|
|
33636
33659
|
print(formatLabel("Role", source_default.green("admin")));
|
|
33637
33660
|
}
|
|
33638
33661
|
print();
|
|
33639
|
-
|
|
33640
|
-
|
|
33641
|
-
|
|
33642
|
-
|
|
33643
|
-
|
|
33644
|
-
|
|
33645
|
-
|
|
33646
|
-
|
|
33647
|
-
|
|
33648
|
-
|
|
33649
|
-
|
|
33650
|
-
|
|
33651
|
-
|
|
33652
|
-
|
|
33653
|
-
|
|
33654
|
-
|
|
33655
|
-
|
|
33656
|
-
|
|
33657
|
-
|
|
33662
|
+
try {
|
|
33663
|
+
const brands = await listBrands(whoamiData.organization.id);
|
|
33664
|
+
if (brands.length === 0) {
|
|
33665
|
+
print(formatWarning("No brands found. Create one at https://app.genfeed.ai"));
|
|
33666
|
+
} else if (brands.length === 1) {
|
|
33667
|
+
await setActiveBrand(brands[0].id);
|
|
33668
|
+
print(formatSuccess(`Active brand: ${source_default.bold(brands[0].label)}`));
|
|
33669
|
+
} else {
|
|
33670
|
+
const selected = await dist_default5({
|
|
33671
|
+
choices: brands.map((brand) => ({
|
|
33672
|
+
description: brand.description,
|
|
33673
|
+
name: brand.label,
|
|
33674
|
+
value: brand.id
|
|
33675
|
+
})),
|
|
33676
|
+
message: "Select a brand:"
|
|
33677
|
+
});
|
|
33678
|
+
await setActiveBrand(selected);
|
|
33679
|
+
const selectedBrand = brands.find((b) => b.id === selected);
|
|
33680
|
+
print();
|
|
33681
|
+
print(formatSuccess(`Active brand: ${source_default.bold(selectedBrand?.label)}`));
|
|
33682
|
+
}
|
|
33683
|
+
} catch {
|
|
33684
|
+
print(formatWarning("Could not fetch brands. Set one later with `gf brands`"));
|
|
33658
33685
|
}
|
|
33659
33686
|
} catch (error49) {
|
|
33660
33687
|
spinner.fail("Invalid API key");
|
|
@@ -33897,7 +33924,7 @@ var publishCommand = new Command("publish").description("Publish content to soci
|
|
|
33897
33924
|
}
|
|
33898
33925
|
const spinner = ora(`Publishing to ${platforms.join(", ")}...`).start();
|
|
33899
33926
|
try {
|
|
33900
|
-
await post("/
|
|
33927
|
+
await post("/posts", {
|
|
33901
33928
|
caption,
|
|
33902
33929
|
ingredientId,
|
|
33903
33930
|
platforms
|
|
@@ -34166,7 +34193,7 @@ var whoamiCommand = new Command("whoami").description("Show current user and org
|
|
|
34166
34193
|
}
|
|
34167
34194
|
if (options.json) {
|
|
34168
34195
|
printJson({
|
|
34169
|
-
activeBrand: activeBrand ? { id: activeBrand.id,
|
|
34196
|
+
activeBrand: activeBrand ? { id: activeBrand.id, label: activeBrand.label } : null,
|
|
34170
34197
|
organization: info2.organization,
|
|
34171
34198
|
scopes: info2.scopes,
|
|
34172
34199
|
user: info2.user
|
|
@@ -34179,7 +34206,7 @@ var whoamiCommand = new Command("whoami").description("Show current user and org
|
|
|
34179
34206
|
print(formatLabel("Organization", info2.organization.name));
|
|
34180
34207
|
print(formatLabel("Scopes", info2.scopes.join(", ")));
|
|
34181
34208
|
if (activeBrand) {
|
|
34182
|
-
print(formatLabel("Active Brand", activeBrand.
|
|
34209
|
+
print(formatLabel("Active Brand", activeBrand.label));
|
|
34183
34210
|
} else if (activeBrandId) {
|
|
34184
34211
|
print(formatLabel("Active Brand", source_default.dim("(not found - run gf brands select)")));
|
|
34185
34212
|
} else {
|
|
@@ -34196,7 +34223,7 @@ var workflowCommand = new Command("workflow").description("Manage and execute wo
|
|
|
34196
34223
|
await requireAuth();
|
|
34197
34224
|
const spinner = ora("Fetching workflows...").start();
|
|
34198
34225
|
try {
|
|
34199
|
-
const response = await get("/
|
|
34226
|
+
const response = await get("/workflows");
|
|
34200
34227
|
spinner.stop();
|
|
34201
34228
|
const workflows = response.data ?? [];
|
|
34202
34229
|
if (workflows.length === 0) {
|
|
@@ -34229,7 +34256,7 @@ Workflows:
|
|
|
34229
34256
|
await requireAuth();
|
|
34230
34257
|
const spinner = ora("Executing workflow...").start();
|
|
34231
34258
|
try {
|
|
34232
|
-
const response = await post("/
|
|
34259
|
+
const response = await post("/workflow-executions", {
|
|
34233
34260
|
workflowId: id
|
|
34234
34261
|
});
|
|
34235
34262
|
spinner.succeed("Workflow execution started");
|
|
@@ -34252,7 +34279,7 @@ var BANNER = source_default.hex("#7C3AED").bold(`
|
|
|
34252
34279
|
██████ ██
|
|
34253
34280
|
`);
|
|
34254
34281
|
var program2 = new Command;
|
|
34255
|
-
program2.name("gf").description("Unified CLI for Genfeed.ai").version("0.
|
|
34282
|
+
program2.name("gf").description("Unified CLI for Genfeed.ai").version("0.3.0").addCommand(loginCommand).addCommand(logoutCommand).addCommand(whoamiCommand).addCommand(brandsCommand).addCommand(generateCommand).addCommand(statusCommand).addCommand(chatCommand).addCommand(workflowCommand).addCommand(publishCommand).addCommand(libraryCommand).addCommand(profileCommand);
|
|
34256
34283
|
program2.addCommand(darkroomCommand).addCommand(trainCommand).addCommand(personasCommand).addCommand(captionCommand).addCommand(datasetCommand);
|
|
34257
34284
|
program2.exitOverride();
|
|
34258
34285
|
async function printBanner() {
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"gf": "dist/index.js"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"@genfeedai/deserializer": "^1.0.0",
|
|
8
9
|
"@inquirer/prompts": "8.2.0",
|
|
9
10
|
"chalk": "5.6.2",
|
|
10
11
|
"commander": "14.0.3",
|
|
@@ -67,9 +68,10 @@
|
|
|
67
68
|
"prepare": "husky",
|
|
68
69
|
"test": "vitest run",
|
|
69
70
|
"test:coverage": "vitest run --coverage",
|
|
71
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
70
72
|
"test:watch": "vitest",
|
|
71
73
|
"typecheck": "tsc --noEmit"
|
|
72
74
|
},
|
|
73
75
|
"type": "module",
|
|
74
|
-
"version": "0.
|
|
76
|
+
"version": "0.3.1"
|
|
75
77
|
}
|