@withandeo/cli 0.19.9 → 0.19.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/dist/api.d.ts +0 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +0 -2
- package/dist/api.js.map +1 -1
- package/dist/contracts.d.ts +8 -0
- package/dist/contracts.d.ts.map +1 -1
- package/dist/documentation.d.ts +12 -2
- package/dist/documentation.d.ts.map +1 -1
- package/dist/documentation.js +107 -11
- package/dist/documentation.js.map +1 -1
- package/dist/flagship-browser.d.ts +18 -0
- package/dist/flagship-browser.d.ts.map +1 -0
- package/dist/flagship-browser.js +63 -0
- package/dist/flagship-browser.js.map +1 -0
- package/dist/flagship-contract.d.ts +4 -37
- package/dist/flagship-contract.d.ts.map +1 -1
- package/dist/flagship-contract.js +23 -65
- package/dist/flagship-contract.js.map +1 -1
- package/dist/flagship-definition.d.ts +67 -0
- package/dist/flagship-definition.d.ts.map +1 -0
- package/dist/flagship-definition.js +207 -0
- package/dist/flagship-definition.js.map +1 -0
- package/dist/flagship-runtime.d.ts +57 -0
- package/dist/flagship-runtime.d.ts.map +1 -0
- package/dist/flagship-runtime.js +79 -0
- package/dist/flagship-runtime.js.map +1 -0
- package/dist/main.js +79 -43
- package/dist/main.js.map +1 -1
- package/dist/public-skill-contract.d.ts +21 -0
- package/dist/public-skill-contract.d.ts.map +1 -0
- package/dist/public-skill-contract.js +47 -0
- package/dist/public-skill-contract.js.map +1 -0
- package/package.json +7 -2
- package/skill/publication.json +3 -0
- package/skill/tender-accounts/SKILL.md +3 -2
- package/skill/tender-accounts/references/feature-flags.md +140 -69
- package/skill/tender-accounts/references/managed-source.md +14 -2
- package/skill/tender-accounts/references/skills.md +7 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { flagKey, flagContext, flagValueType, safeFlagJson } from "./flagship-contract.js";
|
|
2
|
+
export async function nativeFlagDetails(binding, flag, context) {
|
|
3
|
+
safeFlagJson(flag.fallback);
|
|
4
|
+
if (flagValueType(flag.fallback) !== flag.type)
|
|
5
|
+
throw new Error("flagship_fallback_type_invalid");
|
|
6
|
+
switch (flag.type) {
|
|
7
|
+
case "boolean": return binding.getBooleanDetails(flag.key, flag.fallback, context);
|
|
8
|
+
case "string": return binding.getStringDetails(flag.key, flag.fallback, context);
|
|
9
|
+
case "number": return binding.getNumberDetails(flag.key, flag.fallback, context);
|
|
10
|
+
case "json": return binding.getObjectDetails(flag.key, flag.fallback, context);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Application-owned GET endpoint/SSR bootstrap. The server chooses scope and keys;
|
|
14
|
+
* resolveContext must authenticate/enrich trusted properties and select only
|
|
15
|
+
* designated presentation attributes. No management credential or private rules.
|
|
16
|
+
*/
|
|
17
|
+
export function createFlagGateway(input) {
|
|
18
|
+
if (input.flags.length > 64 || new Set(input.flags.map(f => f.key)).size !== input.flags.length)
|
|
19
|
+
throw new Error("flagship_browser_allowlist_invalid");
|
|
20
|
+
safeFlagJson(input.flags);
|
|
21
|
+
for (const flag of input.flags) {
|
|
22
|
+
flagKey(flag.key);
|
|
23
|
+
if (flagValueType(flag.fallback) !== flag.type)
|
|
24
|
+
throw new Error("flagship_browser_allowlist_invalid");
|
|
25
|
+
}
|
|
26
|
+
const flags = structuredClone(input.flags), { binding, environment, resolveContext } = input;
|
|
27
|
+
const refreshAfterMs = input.refreshAfterMs ?? 30000;
|
|
28
|
+
if (!Number.isSafeInteger(refreshAfterMs) || refreshAfterMs < 0 || refreshAfterMs > 60000)
|
|
29
|
+
throw new Error("flagship_refresh_invalid");
|
|
30
|
+
return async (request) => {
|
|
31
|
+
if (request.method !== "GET")
|
|
32
|
+
return new Response(null, { status: 405, headers: { allow: "GET" } });
|
|
33
|
+
// Queries never select flags, apps, environments or trusted targeting properties.
|
|
34
|
+
if (new URL(request.url).search)
|
|
35
|
+
return new Response(null, { status: 400 });
|
|
36
|
+
const context = flagContext(await resolveContext(request));
|
|
37
|
+
const entries = await Promise.all(flags.map(async (flag) => {
|
|
38
|
+
let details;
|
|
39
|
+
try {
|
|
40
|
+
details = await nativeFlagDetails(binding, flag, context);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
details = { flagKey: flag.key, value: flag.fallback, reason: "ERROR", errorCode: "GENERAL" };
|
|
44
|
+
}
|
|
45
|
+
// Explicitly select the public details; never spread provider metadata.
|
|
46
|
+
const publicDetails = { flagKey: flag.key, value: details.value, ...(details.variant ? { variant: details.variant } : {}),
|
|
47
|
+
...(details.reason ? { reason: details.reason } : {}), ...(details.errorCode ? { errorCode: details.errorCode } : {}) };
|
|
48
|
+
safeFlagJson(publicDetails);
|
|
49
|
+
return [flag.key, publicDetails];
|
|
50
|
+
}));
|
|
51
|
+
const bootstrap = { schema: "andeo.flag-bootstrap/v1", environment, refreshAfterMs, values: Object.fromEntries(entries) };
|
|
52
|
+
const body = JSON.stringify(bootstrap);
|
|
53
|
+
if (new TextEncoder().encode(body).length > 64 * 1024)
|
|
54
|
+
throw new Error("flagship_bootstrap_size_exceeded");
|
|
55
|
+
return new Response(body, { headers: { "content-type": "application/json", "cache-control": "private, no-store", vary: "Cookie, Authorization" } });
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Call only when the application actually shows an experience. Caller chooses
|
|
59
|
+
* deduplication lifetime and measurement destination; no raw context is emitted.
|
|
60
|
+
*/
|
|
61
|
+
export function flagExposure(details, environment, experimentVersion) {
|
|
62
|
+
if (details.errorCode || details.reason === "ERROR" || details.reason === "DISABLED" || details.reason === "DEFAULT" || !details.variant || !experimentVersion)
|
|
63
|
+
return null;
|
|
64
|
+
return { flagKey: details.flagKey, variant: details.variant, reason: details.reason, environment, experimentVersion };
|
|
65
|
+
}
|
|
66
|
+
/** Optional server-owned one-year anonymous cookie. Reuse on browser and server
|
|
67
|
+
* actions; login does not change it. Explicit reset returns a new identity.
|
|
68
|
+
*/
|
|
69
|
+
export function flagVisitorIdentity(request, reset = false) {
|
|
70
|
+
const existing = request.headers.get("cookie")?.split(";").map(s => s.trim()).find(s => s.startsWith("andeo_flag_visitor="))?.slice(19);
|
|
71
|
+
if (!reset && existing && /^[a-f0-9-]{36}$/.test(existing))
|
|
72
|
+
return { targetingKey: existing };
|
|
73
|
+
const url = new URL(request.url), loopback = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
74
|
+
if (url.protocol !== "https:" && !loopback)
|
|
75
|
+
throw new Error("flagship_identity_https_required");
|
|
76
|
+
const targetingKey = crypto.randomUUID();
|
|
77
|
+
return { targetingKey, setCookie: `andeo_flag_visitor=${targetingKey}; Path=/; Max-Age=31536000; HttpOnly; SameSite=Lax${url.protocol === "https:" ? "; Secure" : ""}` };
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=flagship-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagship-runtime.js","sourceRoot":"","sources":["../src/flagship-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAwD,MAAM,wBAAwB,CAAC;AAYjJ,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAoB,EAAE,IAAuB,EAAE,OAAoB;IACzG,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5B,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAClG,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS,EAAE,OAAO,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,QAAmB,EAAE,OAAO,CAAC,CAAC;QAC9F,KAAK,QAAQ,EAAE,OAAO,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CA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vironment } from "./andeo-environment.js";
|
|
21
21
|
import { DOC_TOPICS, readDocumentation, installDocumentation, installedSkillCheck } from "./documentation.js";
|
|
22
22
|
import { capabilityPreflight } from "./capability-preflight.js";
|
|
23
|
-
import { flagEnvironment, flagKey,
|
|
23
|
+
import { flagEnvironment, flagKey, validateFlagDefinition, flagContext, FLAGSHIP_SCHEMA, FLAG_DELETION_GUIDANCE, FlagCompatibilityError } from "./flagship-contract.js";
|
|
24
24
|
const packageMetadata = createRequire(import.meta.url)("../package.json");
|
|
25
25
|
if (typeof packageMetadata.version !== "string" || packageMetadata.version.length === 0) {
|
|
26
26
|
throw new Error("Andeo CLI package version is missing.");
|
|
@@ -98,6 +98,16 @@ export async function runCli(argv, overrides = {}) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
async function execute(topic, options, cwd, runtime) {
|
|
101
|
+
if (topic === "artifact finalize") {
|
|
102
|
+
const directory = resolve(cwd, requiredFlag(options, "artifact-directory"));
|
|
103
|
+
const before = await verifyArtifact(directory);
|
|
104
|
+
await packageAppWorkflows(cwd, before.directory, runtime.environment.WRANGLER_ENV);
|
|
105
|
+
const after = await verifyArtifact(directory);
|
|
106
|
+
if (before.envelope.sourceRevision !== after.envelope.sourceRevision)
|
|
107
|
+
throw new CliError("artifact_source_changed", "Packaging changed the attested source revision.");
|
|
108
|
+
return { value: { status: "verified", sourceRevision: after.envelope.sourceRevision, bundleDigest: after.envelope.bundleDigest,
|
|
109
|
+
artifactDirectory: after.directory, workflowCount: after.envelope.manifest.workflows?.declarations.length ?? 0, flags: after.envelope.manifest.flags ?? null } };
|
|
110
|
+
}
|
|
101
111
|
if (topic.startsWith("workflows "))
|
|
102
112
|
return { value: await workflowCommand(topic.slice(10), cwd, options, runtime) };
|
|
103
113
|
if (topic.startsWith("email "))
|
|
@@ -1890,7 +1900,7 @@ async function linkProject(cwd, options, runtime) {
|
|
|
1890
1900
|
}
|
|
1891
1901
|
async function doctor(cwd, options, runtime) {
|
|
1892
1902
|
const checks = [];
|
|
1893
|
-
checks.push(await installedSkillCheck(runtime.homeDirectory));
|
|
1903
|
+
checks.push(await installedSkillCheck(runtime.homeDirectory, { fetcher: runtime.fetcher, cliVersion: CLI_VERSION }));
|
|
1894
1904
|
const nodeMajor = Number(process.versions.node.split(".")[0]);
|
|
1895
1905
|
checks.push({
|
|
1896
1906
|
name: "node",
|
|
@@ -2436,7 +2446,7 @@ async function installSkill(cwd, options, runtime) {
|
|
|
2436
2446
|
if (!base) {
|
|
2437
2447
|
throw new CliError("skill_target_invalid", "--agent must be codex or claude unless --directory is provided.");
|
|
2438
2448
|
}
|
|
2439
|
-
return { status: "installed", agent, ...await installDocumentation(base, options.booleans.has("force"), CLI_VERSION) };
|
|
2449
|
+
return { status: "installed", agent, ...await installDocumentation(base, options.booleans.has("force"), CLI_VERSION, { fetcher: runtime.fetcher, bundled: options.booleans.has("bundled") }) };
|
|
2440
2450
|
}
|
|
2441
2451
|
async function readSkill() {
|
|
2442
2452
|
return await readFile(skillPath(), "utf8");
|
|
@@ -2467,6 +2477,10 @@ function exampleConfig() {
|
|
|
2467
2477
|
};
|
|
2468
2478
|
}
|
|
2469
2479
|
async function flagshipCommand(command, cwd, options, runtime) {
|
|
2480
|
+
const definitionFile = async () => validateFlagDefinition(JSON.parse(new TextDecoder().decode(await readBoundedFile(resolve(cwd, requiredFlag(options, "file")), 192 * 1024))));
|
|
2481
|
+
if (command === "flags validate")
|
|
2482
|
+
return { schema: FLAGSHIP_SCHEMA, definition: await definitionFile() };
|
|
2483
|
+
const createDefinition = command === "flags create" ? await definitionFile() : undefined;
|
|
2470
2484
|
let environment;
|
|
2471
2485
|
try {
|
|
2472
2486
|
environment = flagEnvironment(requiredFlag(options, "env"));
|
|
@@ -2479,21 +2493,33 @@ async function flagshipCommand(command, cwd, options, runtime) {
|
|
|
2479
2493
|
if (!projectId)
|
|
2480
2494
|
throw new CliError("project_required", "Link a project or pass --project.");
|
|
2481
2495
|
const { client } = await authenticatedClient(cwd, context?.link ?? null, options, runtime);
|
|
2482
|
-
if (command
|
|
2483
|
-
return client.flagship(projectId, ["apps", ...(command === "apps ensure" ? ["ensure"] : [])], environment, command === "apps ensure" ? { body: {} } : {});
|
|
2496
|
+
if (command === "apps ensure" || command === "apps list")
|
|
2497
|
+
return client.flagship(projectId, ["apps", ...(command === "apps ensure" ? ["ensure"] : [])], environment, command === "apps ensure" ? { body: { ...(options.flags.has("collection") ? { collection: options.flags.get("collection") } : {}) } } : {});
|
|
2498
|
+
if (command.startsWith("apps ")) {
|
|
2499
|
+
const action = command.slice(5), segments = ["apps", options.positionals[0], action];
|
|
2500
|
+
if (action === "get")
|
|
2501
|
+
return client.flagship(projectId, segments, environment);
|
|
2502
|
+
const revision = requiredFlag(options, "expected-revision");
|
|
2503
|
+
if (!/^\d+$/.test(revision) || !Number.isSafeInteger(Number(revision)))
|
|
2504
|
+
throw new CliError("flagship_revision_invalid", "Use an observed collection revision.");
|
|
2505
|
+
return client.flagship(projectId, segments, environment, { body: { expectedRevision: Number(revision), ...(action === "rename" ? { name: requiredFlag(options, "name") } : {}), ...(action === "delete" || action === "disconnect" ? { confirm: requiredFlag(options, "confirm") } : {}) } });
|
|
2506
|
+
}
|
|
2484
2507
|
const action = command.slice(6), app = options.positionals[0], key = options.positionals[1];
|
|
2485
2508
|
const segments = ["flags", app, ...(key ? [flagKey(key)] : [])];
|
|
2486
2509
|
if (action === "list" || action === "get")
|
|
2487
2510
|
return client.flagship(projectId, segments, environment);
|
|
2488
2511
|
segments.push(action);
|
|
2489
|
-
if (action === "changelog")
|
|
2512
|
+
if (action === "changelog" || action === "export")
|
|
2490
2513
|
return client.flagship(projectId, segments, environment);
|
|
2514
|
+
if (action === "diff")
|
|
2515
|
+
return client.flagship(projectId, segments, environment, { body: { definition: await definitionFile() } });
|
|
2491
2516
|
if (action === "evaluate") {
|
|
2492
|
-
const
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2517
|
+
const file = options.flags.get("context-file");
|
|
2518
|
+
const context = file ? flagContext(JSON.parse(new TextDecoder().decode(await readBoundedFile(resolve(cwd, file), 16 * 1024)))) : {};
|
|
2519
|
+
const type = options.flags.get("type"), fallbackFile = options.flags.get("fallback-file");
|
|
2520
|
+
if (!!type !== !!fallbackFile)
|
|
2521
|
+
throw new CliError("flagship_fallback_type_invalid", "Choose both --type and --fallback-file.");
|
|
2522
|
+
return client.flagship(projectId, segments, environment, { body: { context, ...(type ? { type, fallback: JSON.parse(new TextDecoder().decode(await readBoundedFile(resolve(cwd, fallbackFile), 10000))) } : {}) } });
|
|
2497
2523
|
}
|
|
2498
2524
|
const revision = options.flags.get("expected-revision");
|
|
2499
2525
|
// Read before mutation by default. Server rechecks this revision inside serialization.
|
|
@@ -2508,31 +2534,23 @@ async function flagshipCommand(command, cwd, options, runtime) {
|
|
|
2508
2534
|
else
|
|
2509
2535
|
expectedRevision = (await client.flagship(projectId, segments.slice(0, -1), environment)).revision;
|
|
2510
2536
|
const body = { expectedRevision };
|
|
2511
|
-
if (action === "
|
|
2512
|
-
|
|
2513
|
-
if (
|
|
2514
|
-
throw new CliError("
|
|
2515
|
-
if (
|
|
2516
|
-
body.
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
}
|
|
2525
|
-
body.customerIds = customerIds(value);
|
|
2537
|
+
if (action === "apply" || action === "delete") {
|
|
2538
|
+
// General editing requires a reviewed revision and digest, rather than auto-adopting a new baseline.
|
|
2539
|
+
if (revision === undefined)
|
|
2540
|
+
throw new CliError("flagship_revision_required", "Review flags diff, then supply --expected-revision and --expected-digest.");
|
|
2541
|
+
if (action === "apply")
|
|
2542
|
+
body.definition = await definitionFile();
|
|
2543
|
+
body.expectedDigest = requiredFlag(options, "expected-digest");
|
|
2544
|
+
if (action === "delete") {
|
|
2545
|
+
if (options.flags.get("confirm") !== key)
|
|
2546
|
+
throw new CliError("flagship_delete_confirmation_required", `Use --confirm ${key} after cleanup. ${FLAG_DELETION_GUIDANCE}`);
|
|
2547
|
+
body.confirm = key;
|
|
2548
|
+
if (!options.booleans.has("json"))
|
|
2549
|
+
runtime.stderr.write(`${FLAG_DELETION_GUIDANCE}\n`);
|
|
2526
2550
|
}
|
|
2527
2551
|
}
|
|
2528
|
-
if (action === "
|
|
2529
|
-
|
|
2530
|
-
throw new CliError("flagship_rollout_invalid", "V1 supports --to on --by customerId.");
|
|
2531
|
-
const percentage = requiredFlag(options, "percentage");
|
|
2532
|
-
if (!/^(?:\d+)(?:\.\d{1,2})?$/.test(percentage))
|
|
2533
|
-
throw new CliError("flagship_percentage_invalid", "Use a percentage from 0 to 100 with at most two decimals.");
|
|
2534
|
-
body.percentage = rolloutPercentage(Number(percentage));
|
|
2535
|
-
}
|
|
2552
|
+
if (action === "create")
|
|
2553
|
+
body.definition = createDefinition;
|
|
2536
2554
|
return client.flagship(projectId, segments, environment, { body });
|
|
2537
2555
|
}
|
|
2538
2556
|
function commandTopic(argv) {
|
|
@@ -2552,7 +2570,7 @@ function commandTopic(argv) {
|
|
|
2552
2570
|
const topic = `preview ${argv[1]}`;
|
|
2553
2571
|
return argv.includes("--help") || argv.includes("-h") ? { topic: "help", values: [topic] } : { topic, values: argv.slice(2) };
|
|
2554
2572
|
}
|
|
2555
|
-
if (parent === "email" || parent === "auth" || parent === "delivery" || parent === "source" || parent === "vars" || parent === "skill" || parent === "skills" || parent === "config" || parent === "production" || parent === "workflows") {
|
|
2573
|
+
if (parent === "artifact" || parent === "email" || parent === "auth" || parent === "delivery" || parent === "source" || parent === "vars" || parent === "skill" || parent === "skills" || parent === "config" || parent === "production" || parent === "workflows") {
|
|
2556
2574
|
const child = argv[1];
|
|
2557
2575
|
if (!child || child.startsWith("--"))
|
|
2558
2576
|
return { topic: "help", values: [parent] };
|
|
@@ -2595,7 +2613,7 @@ function parseOptions(values) {
|
|
|
2595
2613
|
const booleans = new Set();
|
|
2596
2614
|
const positionals = [];
|
|
2597
2615
|
const booleanNames = new Set([
|
|
2598
|
-
"json", "token-stdin", "dry-run", "no-wait", "force", "reauthorize", "authorize",
|
|
2616
|
+
"json", "token-stdin", "dry-run", "no-wait", "force", "reauthorize", "authorize", "bundled",
|
|
2599
2617
|
"device", "wait", "no-open", "local", "all", "production",
|
|
2600
2618
|
]);
|
|
2601
2619
|
for (let index = 0; index < values.length; index += 1) {
|
|
@@ -2627,14 +2645,14 @@ function parseOptions(values) {
|
|
|
2627
2645
|
function assertAllowedOptions(topic, options) {
|
|
2628
2646
|
if (topic.startsWith("flagship ")) {
|
|
2629
2647
|
const common = ["cwd", "json", "api-url", "token-stdin", "profile", "project", "env"];
|
|
2630
|
-
const extras = { "flags create": ["expected-revision"], "flags enable": ["expected-revision"], "flags disable": ["expected-revision"],
|
|
2631
|
-
"flags
|
|
2648
|
+
const extras = { "apps ensure": ["collection"], "apps rename": ["expected-revision", "name"], "apps delete": ["expected-revision", "confirm"], "apps disconnect": ["expected-revision", "confirm"], "apps reconcile": ["expected-revision"], "flags delete": ["expected-revision", "expected-digest", "confirm"], "flags validate": ["file"], "flags diff": ["file"], "flags apply": ["file", "expected-revision", "expected-digest"], "flags create": ["expected-revision", "file"], "flags enable": ["expected-revision"], "flags disable": ["expected-revision"],
|
|
2649
|
+
"flags evaluate": ["context-file", "type", "fallback-file"], "flags reconcile": ["expected-revision"] };
|
|
2632
2650
|
const sub = topic.slice(9);
|
|
2633
|
-
if (!["apps ensure", "apps list", "flags list", "flags get", "flags
|
|
2651
|
+
if (!["apps ensure", "apps list", "apps get", "apps rename", "apps delete", "apps disconnect", "apps reconcile", "flags list", "flags get", "flags export", "flags delete", "flags validate", "flags diff", "flags apply", "flags create", "flags enable", "flags disable", "flags evaluate", "flags changelog", "flags reconcile"].includes(sub))
|
|
2634
2652
|
throw new CliError("argument_unknown", "Unknown flagship command.");
|
|
2635
2653
|
if ([...options.flags.keys(), ...options.booleans].some(k => ![...common, ...(extras[sub] ?? [])].includes(k)))
|
|
2636
2654
|
throw new CliError("argument_unknown", "Unsupported flagship option.");
|
|
2637
|
-
const length = sub
|
|
2655
|
+
const length = sub === "apps ensure" || sub === "apps list" || sub === "flags validate" ? 0 : sub.startsWith("apps") || sub === "flags list" ? 1 : 2;
|
|
2638
2656
|
if (options.positionals.length !== length)
|
|
2639
2657
|
throw new CliError("argument_required", `Expected ${length} positional arguments for ${topic}.`);
|
|
2640
2658
|
return;
|
|
@@ -2642,6 +2660,7 @@ function assertAllowedOptions(topic, options) {
|
|
|
2642
2660
|
const common = ["cwd", "json"];
|
|
2643
2661
|
const authentication = ["api-url", "token-stdin", "profile"];
|
|
2644
2662
|
const allowed = {
|
|
2663
|
+
"artifact finalize": [...common, "artifact-directory"],
|
|
2645
2664
|
docs: common,
|
|
2646
2665
|
capabilities: [...common, ...authentication, "project"],
|
|
2647
2666
|
"email capabilities": [...common, ...authentication, "tenant", "project"],
|
|
@@ -2670,7 +2689,7 @@ function assertAllowedOptions(topic, options) {
|
|
|
2670
2689
|
init: [...common, "name", "slug", "directory", "template", "dry-run"],
|
|
2671
2690
|
"config example": common,
|
|
2672
2691
|
"skill print": common,
|
|
2673
|
-
"skill install": [...common, "agent", "directory", "force"],
|
|
2692
|
+
"skill install": [...common, "agent", "directory", "force", "bundled"],
|
|
2674
2693
|
"skills list": [...common, ...authentication],
|
|
2675
2694
|
"skills get": [...common, ...authentication],
|
|
2676
2695
|
"skills file": [...common, ...authentication, "path"],
|
|
@@ -2881,7 +2900,22 @@ function writeOutput(value, options, runtime) {
|
|
|
2881
2900
|
}
|
|
2882
2901
|
function helpText(topic) {
|
|
2883
2902
|
if (topic === "flagship")
|
|
2884
|
-
return
|
|
2903
|
+
return `Usage: andeo flagship apps ensure|list --env ENV [--collection NAME] [--project ID] [--json]
|
|
2904
|
+
andeo flagship apps get|rename|disconnect|delete|reconcile APP_ID --env ENV [--expected-revision N] [--name NAME] [--confirm EXACT_ID]
|
|
2905
|
+
andeo flagship flags validate --file flag.json --json
|
|
2906
|
+
andeo flagship flags list APP_ID --env ENV
|
|
2907
|
+
andeo flagship flags create APP_ID KEY --env ENV --file flag.json [--expected-revision N]
|
|
2908
|
+
andeo flagship flags get|export|enable|disable|changelog|reconcile APP_ID KEY --env ENV [--expected-revision N]
|
|
2909
|
+
andeo flagship flags diff APP_ID KEY --env ENV --file flag.json --json
|
|
2910
|
+
andeo flagship flags apply APP_ID KEY --env ENV --file flag.json --expected-revision N --expected-digest SHA256 --json
|
|
2911
|
+
andeo flagship flags delete APP_ID KEY --env ENV --expected-revision N --expected-digest SHA256 --confirm KEY
|
|
2912
|
+
andeo flagship flags evaluate APP_ID KEY --env ENV [--context-file context.json] [--type boolean|string|number|json --fallback-file fallback.json]
|
|
2913
|
+
|
|
2914
|
+
All definitions use one pinned native Flagship schema. Create requires a complete disabled definition; apply preserves enabled state. Disable returns the configured default, which may differ from the caller fallback. Targeting and rollouts are edited through full definitions; evaluation context uses --context-file. Management numeric/boolean context transport is unverified and fails explicitly; use native evaluation. Pending operations require reconciliation. No conversion analytics or significance calculation is connected.
|
|
2915
|
+
|
|
2916
|
+
Flag deletion requires a disabled saved flag and exact --confirm KEY after cleanup. ${FLAG_DELETION_GUIDANCE} Andeo does not detect remaining evaluations automatically.`;
|
|
2917
|
+
if (topic === "artifact" || topic === "artifact finalize")
|
|
2918
|
+
return "Usage: andeo artifact finalize --artifact-directory DIR [--json]\n\nFinalize workflow coordinators and native Flagship declarations after producer packaging, retaining the attested source revision. Runs offline in the build checkout.";
|
|
2885
2919
|
if (topic === "email" || topic?.startsWith("email "))
|
|
2886
2920
|
return `Usage: andeo email <capabilities|create|list|cursor|wait|read|messages|retire> [options]
|
|
2887
2921
|
|
|
@@ -2991,7 +3025,7 @@ Account workflow entitlement is required for new starts. Run status is authorita
|
|
|
2991
3025
|
"delivery retry": "Usage: andeo delivery retry --delivery dly_... [--reauthorize] [--json]\n\nRetry one requested or failed developer preview idempotently. --reauthorize explicitly authorizes a legacy preview for the same owner and linked project using the current CLI login; it cannot replace another login's recorded grant or publish production. Normal credential refresh needs no flag. A dwf_ production workflow is resumed by a merchant administrator from Activity.",
|
|
2992
3026
|
skill: "Usage: andeo skill <print|install> [options]",
|
|
2993
3027
|
"skill print": "Usage: andeo skill print [--json]",
|
|
2994
|
-
"skill install": "Usage: andeo skill install [--agent codex|claude] [--directory PATH] [--force] [--json]\n\
|
|
3028
|
+
"skill install": "Usage: andeo skill install [--agent codex|claude] [--directory PATH] [--force] [--bundled] [--json]\n\nFetch the latest compatible public Andeo guide without login. A fresh install falls back to the bundled guide during an outage; existing installations are preserved. --bundled explicitly selects this CLI's offline guide. --force replaces owned files, preserving unrelated files. Installs globally: ~/.agents/skills for Codex or ~/.claude/skills for Claude. --directory overrides the location.\n\nExamples:\n andeo skill install --agent codex --json\n andeo skill install --agent codex --force --json\n andeo skill install --bundled --directory ./skills --json",
|
|
2995
3029
|
skills: "Usage: andeo skills <list|get|file> [options]\n\nAuthenticated, session-only access to Andeo practice skills. Content is not installed into the repository.\n\nExamples:\n andeo skills list --json\n andeo skills get recharge-client\n andeo skills file recharge-customer-operations --path references/subscriptions.md",
|
|
2996
3030
|
"skills list": "Usage: andeo skills list [--profile NAME] [--api-url URL] [--json]\n\nList the practice skills available to the authenticated Andeo user.",
|
|
2997
3031
|
"skills get": "Usage: andeo skills get SKILL_ID [--profile NAME] [--api-url URL] [--json]\n\nRead one skill entrypoint for the current invocation.\n\nExample:\n andeo skills get guardrailed-design-system",
|
|
@@ -3004,6 +3038,8 @@ Account workflow entitlement is required for new starts. Run status is authorita
|
|
|
3004
3038
|
return `Andeo merchant developer CLI ${CLI_VERSION}\n\nCommands:\n docs Read version-matched offline guides\n capabilities Inspect scoped support, enablement and permissions\n init Create a new Shopify account starter\n auth login Create or refresh the default login\n auth create Create or re-authorize a named login\n auth activate Bind a named login to a directory tree\n auth deactivate Remove an exact directory binding\n auth status Validate one login or scoped credential\n auth list List local login profiles and bindings\n auth delete Revoke one named login\n auth logout Revoke the default or every login\n link Link this checkout to one permitted project\n doctor Check developer readiness\n dev Run the project-owned local dev command\n check Run project validation\n build Package and verify a portable artifact\n upload Retain a build for administrator publication\n preview Build and deploy an exact preview\n preview entries List eligible connected entry apps\n preview open Reopen an exact deployed preview\n source status Inspect Andeo-managed Git and recent builds\n source branches List exact managed branches and default policy\n source compare Compare two managed branches\n source connect Connect this linked project to managed Git\n source reconnect Prepare, inspect, complete or cancel a tenant namespace cutover\n source pull Clone or fast-forward the exact connected repository\n source token Issue a short-lived repository credential\n source push Push the exact commit without persisting a token\n source promote Fast-forward the default after successful preview checks\n source history Run guarded, archived source-history migration\n email Create and reuse merchant email identities\n workflows Inspect and control app-defined background runs\n vars Manage saved per-environment runtime variables\n source policy Inspect or change automatic publication\n tail Stream logs for one exact linked project\n delivery status Read preview workflow state\n delivery retry Retry a failed preview workflow\n skill install Install the Andeo agent skill\n skills list Discover authenticated practice skills\n skills get Read an authenticated practice skill\n skills file Read one authenticated skill resource\n config example Print the project configuration contract\n\nThere is intentionally no production publish command.\nRun andeo <command> --help for examples.`;
|
|
3005
3039
|
}
|
|
3006
3040
|
function normalizeError(error) {
|
|
3041
|
+
if (error instanceof FlagCompatibilityError)
|
|
3042
|
+
return { code: error.code, message: error.message, details: { field: error.field, schema: FLAGSHIP_SCHEMA } };
|
|
3007
3043
|
if (error instanceof CliApiError) {
|
|
3008
3044
|
return { code: error.code, message: error.message, ...(error.hint ? { hint: error.hint } : {}), ...(error.requestId ? { requestId: error.requestId } : {}), ...(error.details ? { details: error.details } : {}) };
|
|
3009
3045
|
}
|