@contentful/experience-design-system-cli 2.37.1-dev-build-7314a760.0 → 2.37.1-dev-build-be7b0e35.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/app.js +999 -248
- package/dist/index.js +1083 -259
- package/dist/package.json +1 -1
- package/dist/src/tui/help/file-locations.d.ts +23 -0
- package/dist/src/tui/settings/agents/AgentDetail.d.ts +13 -0
- package/dist/src/tui/settings/agents/AgentScreens.d.ts +11 -0
- package/dist/src/tui/settings/agents/AgentStatusBadge.d.ts +10 -0
- package/dist/src/tui/settings/agents/agent-status.d.ts +80 -0
- package/dist/src/tui/settings/agents/agent-store.d.ts +17 -0
- package/dist/src/tui/settings/agents/apply-binary-overrides.d.ts +13 -0
- package/dist/src/tui/settings/contentful-configuration/ContentfulConfigScreen.d.ts +1 -0
- package/dist/src/tui/settings/contentful-configuration/ProjectConfigScreen.d.ts +5 -0
- package/dist/src/tui/settings/shared/FieldForm.d.ts +35 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1500,7 +1500,7 @@ async function runAgent(options) {
|
|
|
1500
1500
|
promptLen: prompt.length,
|
|
1501
1501
|
promptHead: prompt.slice(0, 500)
|
|
1502
1502
|
});
|
|
1503
|
-
return new Promise((
|
|
1503
|
+
return new Promise((resolve28) => {
|
|
1504
1504
|
const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
|
|
1505
1505
|
const child = spawn(binary, args, {
|
|
1506
1506
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -1549,7 +1549,7 @@ async function runAgent(options) {
|
|
|
1549
1549
|
stderrLen: stderr.length,
|
|
1550
1550
|
stderrTail: stderr.slice(-1e3)
|
|
1551
1551
|
});
|
|
1552
|
-
|
|
1552
|
+
resolve28(result);
|
|
1553
1553
|
});
|
|
1554
1554
|
});
|
|
1555
1555
|
}
|
|
@@ -1571,7 +1571,7 @@ async function checkAgentAuth(agent) {
|
|
|
1571
1571
|
return "not-found";
|
|
1572
1572
|
if (agent !== "claude")
|
|
1573
1573
|
return "ok";
|
|
1574
|
-
return new Promise((
|
|
1574
|
+
return new Promise((resolve28) => {
|
|
1575
1575
|
const child = spawn2(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
|
|
1576
1576
|
let stdout = "";
|
|
1577
1577
|
let done = false;
|
|
@@ -1580,7 +1580,7 @@ async function checkAgentAuth(agent) {
|
|
|
1580
1580
|
return;
|
|
1581
1581
|
done = true;
|
|
1582
1582
|
child.kill("SIGTERM");
|
|
1583
|
-
|
|
1583
|
+
resolve28("unauthenticated");
|
|
1584
1584
|
}, 5e3);
|
|
1585
1585
|
child.stdout?.on("data", (chunk) => {
|
|
1586
1586
|
stdout += chunk.toString();
|
|
@@ -1591,14 +1591,14 @@ async function checkAgentAuth(agent) {
|
|
|
1591
1591
|
done = true;
|
|
1592
1592
|
clearTimeout(timer);
|
|
1593
1593
|
if (code !== 0) {
|
|
1594
|
-
|
|
1594
|
+
resolve28("unauthenticated");
|
|
1595
1595
|
return;
|
|
1596
1596
|
}
|
|
1597
1597
|
try {
|
|
1598
1598
|
const status = JSON.parse(stdout);
|
|
1599
|
-
|
|
1599
|
+
resolve28(status.loggedIn ? "ok" : "unauthenticated");
|
|
1600
1600
|
} catch {
|
|
1601
|
-
|
|
1601
|
+
resolve28("unauthenticated");
|
|
1602
1602
|
}
|
|
1603
1603
|
});
|
|
1604
1604
|
});
|
|
@@ -1608,9 +1608,9 @@ async function binaryIsOnPath(binary) {
|
|
|
1608
1608
|
const fs = await import("node:fs/promises");
|
|
1609
1609
|
return fs.access(binary).then(() => true, () => false);
|
|
1610
1610
|
}
|
|
1611
|
-
return new Promise((
|
|
1611
|
+
return new Promise((resolve28) => {
|
|
1612
1612
|
const child = spawn2(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
|
|
1613
|
-
child.on("close", (code) =>
|
|
1613
|
+
child.on("close", (code) => resolve28(code === 0));
|
|
1614
1614
|
});
|
|
1615
1615
|
}
|
|
1616
1616
|
var init_check_agent_auth = __esm({
|
|
@@ -7916,10 +7916,10 @@ function extractVueSlotsFromSetup(options) {
|
|
|
7916
7916
|
if (!body)
|
|
7917
7917
|
return [];
|
|
7918
7918
|
const slotsByName = /* @__PURE__ */ new Map();
|
|
7919
|
-
for (const
|
|
7920
|
-
if (
|
|
7919
|
+
for (const access7 of body.getDescendantsOfKind(SyntaxKind5.PropertyAccessExpression)) {
|
|
7920
|
+
if (access7.getExpression().getText() !== slotsName)
|
|
7921
7921
|
continue;
|
|
7922
|
-
const slotName =
|
|
7922
|
+
const slotName = access7.getName();
|
|
7923
7923
|
if (!slotsByName.has(slotName)) {
|
|
7924
7924
|
slotsByName.set(slotName, {
|
|
7925
7925
|
name: slotName,
|
|
@@ -14333,7 +14333,7 @@ function errorMessage(error) {
|
|
|
14333
14333
|
return error instanceof Error && error.message ? error.message : String(error);
|
|
14334
14334
|
}
|
|
14335
14335
|
function defaultSleep(delayMs) {
|
|
14336
|
-
return new Promise((
|
|
14336
|
+
return new Promise((resolve28) => setTimeout(resolve28, delayMs));
|
|
14337
14337
|
}
|
|
14338
14338
|
var MAX_RETRY_AFTER_MS;
|
|
14339
14339
|
var init_http_utils = __esm({
|
|
@@ -14609,7 +14609,7 @@ var init_api_client = __esm({
|
|
|
14609
14609
|
const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
|
|
14610
14610
|
const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
|
|
14611
14611
|
const jitter = Math.random() * baseDelay * 0.15;
|
|
14612
|
-
await new Promise((
|
|
14612
|
+
await new Promise((resolve28) => setTimeout(resolve28, baseDelay + jitter));
|
|
14613
14613
|
}
|
|
14614
14614
|
}
|
|
14615
14615
|
throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
|
|
@@ -18527,7 +18527,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
|
|
|
18527
18527
|
const message = error instanceof Error ? error.message : String(error);
|
|
18528
18528
|
if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
|
|
18529
18529
|
throw error;
|
|
18530
|
-
await new Promise((
|
|
18530
|
+
await new Promise((resolve28) => setTimeout(resolve28, Math.min(250 * attempt, 2e3)));
|
|
18531
18531
|
}
|
|
18532
18532
|
}
|
|
18533
18533
|
}
|
|
@@ -19446,6 +19446,7 @@ var init_src4 = __esm({
|
|
|
19446
19446
|
init_agents();
|
|
19447
19447
|
init_agent_name();
|
|
19448
19448
|
init_models();
|
|
19449
|
+
init_binaries();
|
|
19449
19450
|
init_is_agent_name();
|
|
19450
19451
|
init_agent_supports_bedrock();
|
|
19451
19452
|
init_check_agent_auth();
|
|
@@ -19565,6 +19566,97 @@ var init_v1_store = __esm({
|
|
|
19565
19566
|
}
|
|
19566
19567
|
});
|
|
19567
19568
|
|
|
19569
|
+
// packages/experience-design-system-cli/src/tui/settings/agents/agent-store.ts
|
|
19570
|
+
function emptyAgents() {
|
|
19571
|
+
return Object.fromEntries(AGENT_NAMES.map((name) => [name, { model: "", binary: "" }]));
|
|
19572
|
+
}
|
|
19573
|
+
async function readAgentConfig() {
|
|
19574
|
+
const store = await readV1Store();
|
|
19575
|
+
const stored = asString(store["agent"]);
|
|
19576
|
+
const defaultAgent = isAgentName(stored) ? stored : DEFAULT_AGENT3;
|
|
19577
|
+
const agents = emptyAgents();
|
|
19578
|
+
const saved = store["agents"];
|
|
19579
|
+
if (saved && typeof saved === "object") {
|
|
19580
|
+
for (const name of AGENT_NAMES) {
|
|
19581
|
+
const entry = saved[name];
|
|
19582
|
+
if (entry && typeof entry === "object") {
|
|
19583
|
+
const fields = entry;
|
|
19584
|
+
agents[name] = { model: asString(fields["model"]), binary: asString(fields["binary"]) };
|
|
19585
|
+
}
|
|
19586
|
+
}
|
|
19587
|
+
}
|
|
19588
|
+
const legacyModel = asString(store["agentModel"]);
|
|
19589
|
+
if (legacyModel && !agents[defaultAgent].model)
|
|
19590
|
+
agents[defaultAgent] = { ...agents[defaultAgent], model: legacyModel };
|
|
19591
|
+
return { defaultAgent, agents };
|
|
19592
|
+
}
|
|
19593
|
+
async function writeAgentConfig(config) {
|
|
19594
|
+
const existing = await readV1Store();
|
|
19595
|
+
const merged = { ...existing };
|
|
19596
|
+
const agents = {};
|
|
19597
|
+
for (const name of AGENT_NAMES) {
|
|
19598
|
+
const model = config.agents[name].model.trim();
|
|
19599
|
+
const binary = config.agents[name].binary.trim();
|
|
19600
|
+
if (model || binary) agents[name] = { ...model ? { model } : {}, ...binary ? { binary } : {} };
|
|
19601
|
+
}
|
|
19602
|
+
merged["agent"] = config.defaultAgent;
|
|
19603
|
+
const defaultModel = agents[config.defaultAgent]?.model;
|
|
19604
|
+
if (defaultModel) merged["agentModel"] = defaultModel;
|
|
19605
|
+
else delete merged["agentModel"];
|
|
19606
|
+
if (Object.keys(agents).length > 0) merged["agents"] = agents;
|
|
19607
|
+
else delete merged["agents"];
|
|
19608
|
+
await writeV1Store(merged);
|
|
19609
|
+
}
|
|
19610
|
+
var DEFAULT_AGENT3, AGENT_LABELS, AGENT_HINTS, asString;
|
|
19611
|
+
var init_agent_store = __esm({
|
|
19612
|
+
"packages/experience-design-system-cli/src/tui/settings/agents/agent-store.ts"() {
|
|
19613
|
+
"use strict";
|
|
19614
|
+
init_src4();
|
|
19615
|
+
init_v1_store();
|
|
19616
|
+
DEFAULT_AGENT3 = "claude";
|
|
19617
|
+
AGENT_LABELS = {
|
|
19618
|
+
claude: "Claude Code",
|
|
19619
|
+
codex: "OpenAI Codex",
|
|
19620
|
+
opencode: "OpenCode",
|
|
19621
|
+
cursor: "Cursor",
|
|
19622
|
+
copilot: "GitHub Copilot"
|
|
19623
|
+
};
|
|
19624
|
+
AGENT_HINTS = {
|
|
19625
|
+
claude: "claude",
|
|
19626
|
+
codex: "codex",
|
|
19627
|
+
opencode: "opencode",
|
|
19628
|
+
cursor: "cursor-agent",
|
|
19629
|
+
copilot: "copilot"
|
|
19630
|
+
};
|
|
19631
|
+
asString = (value) => typeof value === "string" ? value : "";
|
|
19632
|
+
}
|
|
19633
|
+
});
|
|
19634
|
+
|
|
19635
|
+
// packages/experience-design-system-cli/src/tui/settings/agents/apply-binary-overrides.ts
|
|
19636
|
+
function applyBinaryOverrides(config) {
|
|
19637
|
+
for (const name of AGENT_NAMES) {
|
|
19638
|
+
const key = `EDS_AGENT_BINARY_${name.toUpperCase()}`;
|
|
19639
|
+
const binary = config.agents[name].binary.trim();
|
|
19640
|
+
if (binary) {
|
|
19641
|
+
if (!shellValues.has(key)) shellValues.set(key, process.env[key]);
|
|
19642
|
+
process.env[key] = binary;
|
|
19643
|
+
} else if (shellValues.has(key)) {
|
|
19644
|
+
const shellValue = shellValues.get(key);
|
|
19645
|
+
if (shellValue === void 0) delete process.env[key];
|
|
19646
|
+
else process.env[key] = shellValue;
|
|
19647
|
+
shellValues.delete(key);
|
|
19648
|
+
}
|
|
19649
|
+
}
|
|
19650
|
+
}
|
|
19651
|
+
var shellValues;
|
|
19652
|
+
var init_apply_binary_overrides = __esm({
|
|
19653
|
+
"packages/experience-design-system-cli/src/tui/settings/agents/apply-binary-overrides.ts"() {
|
|
19654
|
+
"use strict";
|
|
19655
|
+
init_src4();
|
|
19656
|
+
shellValues = /* @__PURE__ */ new Map();
|
|
19657
|
+
}
|
|
19658
|
+
});
|
|
19659
|
+
|
|
19568
19660
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
|
|
19569
19661
|
async function readAnalyticsSetting() {
|
|
19570
19662
|
const store = await readV1Store();
|
|
@@ -32273,7 +32365,7 @@ var init_save = __esm({
|
|
|
32273
32365
|
writeFile: (path5, contents) => writeFile7(path5, contents),
|
|
32274
32366
|
appendRun,
|
|
32275
32367
|
buildSourceFingerprint,
|
|
32276
|
-
sleep: (ms) => new Promise((
|
|
32368
|
+
sleep: (ms) => new Promise((resolve28) => setTimeout(resolve28, ms)),
|
|
32277
32369
|
warn: (message) => process.stderr.write(message)
|
|
32278
32370
|
});
|
|
32279
32371
|
}
|
|
@@ -32824,13 +32916,48 @@ var init_debug_store = __esm({
|
|
|
32824
32916
|
}
|
|
32825
32917
|
});
|
|
32826
32918
|
|
|
32919
|
+
// packages/experience-design-system-cli/src/tui/help/file-locations.ts
|
|
32920
|
+
import { join as join26, resolve as resolve27 } from "node:path";
|
|
32921
|
+
function describeFileLocations({
|
|
32922
|
+
contentfulBaseDir,
|
|
32923
|
+
debugModeEnabled,
|
|
32924
|
+
currentSessionDir: currentSessionDir2
|
|
32925
|
+
}) {
|
|
32926
|
+
if (!debugModeEnabled) {
|
|
32927
|
+
return {
|
|
32928
|
+
debugLogs: "none while Debug Mode is off",
|
|
32929
|
+
importFiles: `${join26("<project>", ".contentful")}/ (tokens.json, components.json)`
|
|
32930
|
+
};
|
|
32931
|
+
}
|
|
32932
|
+
const base = contentfulBaseDir ? resolve27(contentfulBaseDir) : "<project>";
|
|
32933
|
+
const session = currentSessionDir2 ?? join26(base, ".contentful", "<date>-session-<n>");
|
|
32934
|
+
return {
|
|
32935
|
+
debugLogs: join26(session, "debug"),
|
|
32936
|
+
importFiles: `${join26(session, "dsi-import-<n>")}/ (tokens.json, components.json)`
|
|
32937
|
+
};
|
|
32938
|
+
}
|
|
32939
|
+
var init_file_locations = __esm({
|
|
32940
|
+
"packages/experience-design-system-cli/src/tui/help/file-locations.ts"() {
|
|
32941
|
+
"use strict";
|
|
32942
|
+
}
|
|
32943
|
+
});
|
|
32944
|
+
|
|
32827
32945
|
// packages/experience-design-system-cli/src/tui/help/help-info.ts
|
|
32828
32946
|
async function readHelpInfo() {
|
|
32829
|
-
const debugMode = await readDebugModeSetting();
|
|
32947
|
+
const [debugMode, settings] = await Promise.all([readDebugModeSetting(), readSettings2()]);
|
|
32948
|
+
const base = settings["contentfulBaseDir"];
|
|
32949
|
+
const locations = describeFileLocations({
|
|
32950
|
+
contentfulBaseDir: typeof base === "string" ? base : "",
|
|
32951
|
+
debugModeEnabled: debugMode.enabled,
|
|
32952
|
+
currentSessionDir: currentSessionDir()
|
|
32953
|
+
});
|
|
32830
32954
|
return {
|
|
32831
32955
|
storage: [
|
|
32832
32956
|
{ label: "Config folder", value: configRoot2() },
|
|
32833
|
-
{ label: "Settings file", value: configFilePath2() }
|
|
32957
|
+
{ label: "Settings file", value: configFilePath2() },
|
|
32958
|
+
{ label: "Agent settings", value: `${configFilePath2()} (keys: agent, agentModel, agents)` },
|
|
32959
|
+
{ label: "Debug logs", value: locations.debugLogs },
|
|
32960
|
+
{ label: "Import files", value: locations.importFiles }
|
|
32834
32961
|
],
|
|
32835
32962
|
troubleshooting: [
|
|
32836
32963
|
{ label: "CLI version", value: readPackageVersion() },
|
|
@@ -32851,6 +32978,7 @@ var init_help_info = __esm({
|
|
|
32851
32978
|
init_debug_store();
|
|
32852
32979
|
init_debug_mode_store();
|
|
32853
32980
|
init_version();
|
|
32981
|
+
init_file_locations();
|
|
32854
32982
|
}
|
|
32855
32983
|
});
|
|
32856
32984
|
|
|
@@ -32862,7 +32990,7 @@ function Section({ title, rows }) {
|
|
|
32862
32990
|
return /* @__PURE__ */ jsxs43(Box42, { flexDirection: "column", children: [
|
|
32863
32991
|
/* @__PURE__ */ jsx53(Text44, { bold: true, color: PALETTE.accent, children: title }),
|
|
32864
32992
|
rows.map((row) => /* @__PURE__ */ jsxs43(Box42, { gap: 1, children: [
|
|
32865
|
-
/* @__PURE__ */ jsx53(Box42, { width:
|
|
32993
|
+
/* @__PURE__ */ jsx53(Box42, { width: 16, flexShrink: 0, children: /* @__PURE__ */ jsx53(Text44, { color: PALETTE.muted, children: row.label }) }),
|
|
32866
32994
|
/* @__PURE__ */ jsx53(Text44, { children: row.value })
|
|
32867
32995
|
] }, row.label))
|
|
32868
32996
|
] });
|
|
@@ -32977,6 +33105,730 @@ var init_PageContainer3 = __esm({
|
|
|
32977
33105
|
}
|
|
32978
33106
|
});
|
|
32979
33107
|
|
|
33108
|
+
// packages/experience-design-system-cli/src/tui/settings/agents/agent-status.ts
|
|
33109
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
33110
|
+
import { access as access6, constants } from "node:fs/promises";
|
|
33111
|
+
function effectiveBinary(name, savedBinary) {
|
|
33112
|
+
return savedBinary.trim() || AGENT_BINARIES[name];
|
|
33113
|
+
}
|
|
33114
|
+
function defaultModelLabel(name) {
|
|
33115
|
+
const model = DEFAULT_MODELS[name];
|
|
33116
|
+
return model && model !== "Auto" ? model : "chosen by the agent";
|
|
33117
|
+
}
|
|
33118
|
+
function resolveOnPath(binary) {
|
|
33119
|
+
if (binary.includes("/")) {
|
|
33120
|
+
return access6(binary, constants.X_OK).then(
|
|
33121
|
+
() => binary,
|
|
33122
|
+
() => null
|
|
33123
|
+
);
|
|
33124
|
+
}
|
|
33125
|
+
return new Promise((resolve28) => {
|
|
33126
|
+
execFile2(
|
|
33127
|
+
process.platform === "win32" ? "where" : "which",
|
|
33128
|
+
[binary],
|
|
33129
|
+
(error, stdout) => resolve28(error ? null : stdout.split("\n")[0]?.trim() ?? null)
|
|
33130
|
+
);
|
|
33131
|
+
});
|
|
33132
|
+
}
|
|
33133
|
+
function readVersion(binary) {
|
|
33134
|
+
return new Promise((resolve28) => {
|
|
33135
|
+
execFile2(binary, ["--version"], { timeout: VERSION_TIMEOUT_MS }, (error, stdout) => {
|
|
33136
|
+
const line = stdout.split("\n")[0]?.trim() ?? "";
|
|
33137
|
+
if (!error && line) resolve28(pass("version", line));
|
|
33138
|
+
else resolve28(fail3("version", "runs, but did not report a version"));
|
|
33139
|
+
});
|
|
33140
|
+
});
|
|
33141
|
+
}
|
|
33142
|
+
async function inspectAgent(name, binary) {
|
|
33143
|
+
const target = effectiveBinary(name, binary);
|
|
33144
|
+
const found = await resolveOnPath(target);
|
|
33145
|
+
if (!found) return [fail3("path", `\`${target}\` was not found or is not executable`)];
|
|
33146
|
+
const checks = [pass("path", found)];
|
|
33147
|
+
checks.push(await readVersion(found));
|
|
33148
|
+
if (name === "claude") {
|
|
33149
|
+
const auth = await withBinaryEnv(name, found, () => checkAgentAuth(name));
|
|
33150
|
+
checks.push(
|
|
33151
|
+
auth === "ok" ? pass("login", "logged in") : fail3("login", auth === "not-found" ? "binary not found" : `not logged in: ${LOGIN_HINTS.claude}`)
|
|
33152
|
+
);
|
|
33153
|
+
}
|
|
33154
|
+
return checks;
|
|
33155
|
+
}
|
|
33156
|
+
async function testAgent(name, binary, model) {
|
|
33157
|
+
const checks = await inspectAgent(name, binary);
|
|
33158
|
+
if (!checks.every((check) => check.step === "version" || check.ok)) return checks;
|
|
33159
|
+
const target = effectiveBinary(name, binary);
|
|
33160
|
+
const found = await resolveOnPath(target) ?? target;
|
|
33161
|
+
const started = Date.now();
|
|
33162
|
+
const result = await withBinaryEnv(
|
|
33163
|
+
name,
|
|
33164
|
+
found,
|
|
33165
|
+
() => createLocalCliAgentInvoker().invoke({
|
|
33166
|
+
agent: name,
|
|
33167
|
+
...model.trim() ? { model: model.trim() } : {},
|
|
33168
|
+
prompt: TEST_PROMPT,
|
|
33169
|
+
timeoutMs: PROMPT_TIMEOUT_MS
|
|
33170
|
+
})
|
|
33171
|
+
);
|
|
33172
|
+
const seconds = ((Date.now() - started) / 1e3).toFixed(1);
|
|
33173
|
+
if (result.timedOut) {
|
|
33174
|
+
return [...checks, { ...fail3("prompt", `no answer within ${PROMPT_TIMEOUT_MS / 1e3}s`), timedOut: true }];
|
|
33175
|
+
}
|
|
33176
|
+
if (result.exitCode !== 0) {
|
|
33177
|
+
const reason = result.stderr.trim().split("\n").pop()?.slice(0, 160) || `exited with code ${result.exitCode}`;
|
|
33178
|
+
return [...checks, fail3("prompt", reason)];
|
|
33179
|
+
}
|
|
33180
|
+
return [...checks, pass("prompt", `answered in ${seconds}s`)];
|
|
33181
|
+
}
|
|
33182
|
+
function statusFromChecks(name, checks, savedBinary) {
|
|
33183
|
+
if (checks.length === 0) return "checking";
|
|
33184
|
+
if (checks.some((check) => check.step === "path" && !check.ok)) {
|
|
33185
|
+
return savedBinary.trim() ? "not-found" : "not-configured";
|
|
33186
|
+
}
|
|
33187
|
+
const prompt = checks.find((check) => check.step === "prompt");
|
|
33188
|
+
if (prompt) {
|
|
33189
|
+
if (prompt.ok) return "ready";
|
|
33190
|
+
return prompt.timedOut ? "timed-out" : "test-failed";
|
|
33191
|
+
}
|
|
33192
|
+
const login = checks.find((check) => check.step === "login");
|
|
33193
|
+
if (login) return login.ok ? "ready" : "not-logged-in";
|
|
33194
|
+
return name === "claude" ? "ready" : "unknown";
|
|
33195
|
+
}
|
|
33196
|
+
function setupHint(name, status) {
|
|
33197
|
+
if (status === "not-configured") return `${INSTALL_HINTS[name]}, or set its command path in settings`;
|
|
33198
|
+
if (status === "not-found") return `${INSTALL_HINTS[name]}, or correct the command path in settings`;
|
|
33199
|
+
if (status === "not-logged-in") return LOGIN_HINTS[name];
|
|
33200
|
+
if (status === "test-failed") return `read the test message; if it is a login problem, ${LOGIN_HINTS[name]}`;
|
|
33201
|
+
if (status === "timed-out") return "it may be slow or waiting for input; run the test again, or try it in a terminal";
|
|
33202
|
+
if (status === "unknown") return "run a full test to confirm it is logged in";
|
|
33203
|
+
return "";
|
|
33204
|
+
}
|
|
33205
|
+
function testOutcome(checks) {
|
|
33206
|
+
const prompt = checks?.find((check) => check.step === "prompt");
|
|
33207
|
+
if (!prompt) return void 0;
|
|
33208
|
+
if (prompt.ok) return { ok: true, text: `Test passed: ${prompt.detail}` };
|
|
33209
|
+
if (prompt.timedOut) return { ok: false, text: `Test timed out: ${prompt.detail}` };
|
|
33210
|
+
return { ok: false, text: `Test failed: ${prompt.detail}` };
|
|
33211
|
+
}
|
|
33212
|
+
function modelLine(name, savedModel) {
|
|
33213
|
+
const model = savedModel.trim();
|
|
33214
|
+
return model ? model : `${defaultModelLabel(name)} (built-in default)`;
|
|
33215
|
+
}
|
|
33216
|
+
function panelRows(name, checks, settings) {
|
|
33217
|
+
if (!checks) return [{ label: "Command", value: "checking...", tone: "muted" }];
|
|
33218
|
+
const status = statusFromChecks(name, checks, settings.binary);
|
|
33219
|
+
const path5 = checks.find((check) => check.step === "path");
|
|
33220
|
+
if (!path5?.ok) {
|
|
33221
|
+
const rows2 = [
|
|
33222
|
+
{
|
|
33223
|
+
label: "Command",
|
|
33224
|
+
value: settings.binary.trim() ? path5?.detail ?? "not found" : "not found on your PATH",
|
|
33225
|
+
tone: settings.binary.trim() ? "bad" : "muted"
|
|
33226
|
+
}
|
|
33227
|
+
];
|
|
33228
|
+
const hint2 = setupHint(name, status);
|
|
33229
|
+
if (hint2) rows2.push({ label: "Setup", value: hint2, tone: "muted" });
|
|
33230
|
+
return rows2;
|
|
33231
|
+
}
|
|
33232
|
+
const rows = [{ label: "Command", value: path5.detail, tone: "ok" }];
|
|
33233
|
+
const version = checks.find((check) => check.step === "version");
|
|
33234
|
+
if (version?.ok) rows.push({ label: "Version", value: version.detail, tone: "ok" });
|
|
33235
|
+
rows.push({ label: "Model", value: modelLine(name, settings.model), tone: "muted" });
|
|
33236
|
+
const hint = setupHint(name, status);
|
|
33237
|
+
if (hint) rows.push({ label: "Setup", value: hint, tone: "muted" });
|
|
33238
|
+
return rows;
|
|
33239
|
+
}
|
|
33240
|
+
function statusRows(_name, checks, savedBinary) {
|
|
33241
|
+
if (!checks) return [{ label: "Command", value: "checking...", tone: "muted" }];
|
|
33242
|
+
const find = (step) => checks.find((check) => check.step === step);
|
|
33243
|
+
const path5 = find("path");
|
|
33244
|
+
if (!path5?.ok) {
|
|
33245
|
+
if (savedBinary.trim()) return [{ label: "Command", value: path5?.detail ?? "not found", tone: "bad" }];
|
|
33246
|
+
return [{ label: "Command", value: "not configured (not on the PATH)", tone: "muted" }];
|
|
33247
|
+
}
|
|
33248
|
+
const rows = [{ label: "Command", value: path5.detail, tone: "ok" }];
|
|
33249
|
+
const version = find("version");
|
|
33250
|
+
if (version) {
|
|
33251
|
+
rows.push({
|
|
33252
|
+
label: "Version",
|
|
33253
|
+
value: version.ok ? version.detail : "could not be read",
|
|
33254
|
+
tone: version.ok ? "ok" : "muted"
|
|
33255
|
+
});
|
|
33256
|
+
}
|
|
33257
|
+
const login = find("login");
|
|
33258
|
+
const prompt = find("prompt");
|
|
33259
|
+
if (login) {
|
|
33260
|
+
rows.push({ label: "Login", value: login.detail, tone: login.ok ? "ok" : "bad" });
|
|
33261
|
+
} else if (prompt) {
|
|
33262
|
+
rows.push({
|
|
33263
|
+
label: "Login",
|
|
33264
|
+
value: prompt.ok ? "confirmed by the test" : prompt.timedOut ? "unknown (the test timed out)" : "see the test result",
|
|
33265
|
+
tone: prompt.ok ? "ok" : prompt.timedOut ? "muted" : "bad"
|
|
33266
|
+
});
|
|
33267
|
+
} else {
|
|
33268
|
+
rows.push({ label: "Login", value: "not checked (use Run test)", tone: "muted" });
|
|
33269
|
+
}
|
|
33270
|
+
if (prompt) rows.push({ label: "Test", value: prompt.detail, tone: prompt.ok ? "ok" : "bad" });
|
|
33271
|
+
return rows;
|
|
33272
|
+
}
|
|
33273
|
+
async function withBinaryEnv(name, binary, run) {
|
|
33274
|
+
const key = `EDS_AGENT_BINARY_${name.toUpperCase()}`;
|
|
33275
|
+
const previous = process.env[key];
|
|
33276
|
+
process.env[key] = binary;
|
|
33277
|
+
try {
|
|
33278
|
+
return await run();
|
|
33279
|
+
} finally {
|
|
33280
|
+
if (previous === void 0) delete process.env[key];
|
|
33281
|
+
else process.env[key] = previous;
|
|
33282
|
+
}
|
|
33283
|
+
}
|
|
33284
|
+
var VERSION_TIMEOUT_MS, PROMPT_TIMEOUT_MS, TEST_PROMPT, INSTALL_HINTS, LOGIN_HINTS, fail3, pass, LIST_STATUS;
|
|
33285
|
+
var init_agent_status = __esm({
|
|
33286
|
+
"packages/experience-design-system-cli/src/tui/settings/agents/agent-status.ts"() {
|
|
33287
|
+
"use strict";
|
|
33288
|
+
init_src4();
|
|
33289
|
+
VERSION_TIMEOUT_MS = 5e3;
|
|
33290
|
+
PROMPT_TIMEOUT_MS = 6e4;
|
|
33291
|
+
TEST_PROMPT = "Reply with the single word: ok";
|
|
33292
|
+
INSTALL_HINTS = {
|
|
33293
|
+
claude: "npm install -g @anthropic-ai/claude-code",
|
|
33294
|
+
codex: "npm install -g @openai/codex",
|
|
33295
|
+
opencode: "npm install -g opencode-ai",
|
|
33296
|
+
cursor: "install Cursor\u2019s `cursor-agent` command",
|
|
33297
|
+
copilot: "npm install -g @github/copilot"
|
|
33298
|
+
};
|
|
33299
|
+
LOGIN_HINTS = {
|
|
33300
|
+
claude: "run `claude login`",
|
|
33301
|
+
codex: "set OPENAI_API_KEY, or sign in with a ChatGPT account",
|
|
33302
|
+
opencode: "run `opencode auth`",
|
|
33303
|
+
cursor: "sign in from Cursor",
|
|
33304
|
+
copilot: "run `copilot` and sign in"
|
|
33305
|
+
};
|
|
33306
|
+
fail3 = (step, detail) => ({ step, ok: false, detail });
|
|
33307
|
+
pass = (step, detail) => ({ step, ok: true, detail });
|
|
33308
|
+
LIST_STATUS = {
|
|
33309
|
+
checking: { symbol: "\u2026", text: "checking", tone: "muted" },
|
|
33310
|
+
ready: { symbol: "\u25CF", text: "ready", tone: "ok" },
|
|
33311
|
+
"not-configured": { symbol: "\u25CB", text: "not installed", tone: "muted" },
|
|
33312
|
+
"not-found": { symbol: "\u25CB", text: "not installed", tone: "bad" },
|
|
33313
|
+
"not-logged-in": { symbol: "\u25D0", text: "not logged in", tone: "bad" },
|
|
33314
|
+
"test-failed": { symbol: "\u2717", text: "test failed", tone: "bad" },
|
|
33315
|
+
"timed-out": { symbol: "\u2717", text: "test timed out", tone: "bad" },
|
|
33316
|
+
unknown: { symbol: "\u25D0", text: "installed, login unknown", tone: "muted" }
|
|
33317
|
+
};
|
|
33318
|
+
}
|
|
33319
|
+
});
|
|
33320
|
+
|
|
33321
|
+
// packages/experience-design-system-cli/src/tui/settings/agents/AgentStatusBadge.tsx
|
|
33322
|
+
import { Text as Text46 } from "ink";
|
|
33323
|
+
import { jsx as jsx55 } from "react/jsx-runtime";
|
|
33324
|
+
function AgentStatusBadge({
|
|
33325
|
+
name,
|
|
33326
|
+
checks,
|
|
33327
|
+
binary
|
|
33328
|
+
}) {
|
|
33329
|
+
const { symbol, text, tone } = LIST_STATUS[checks ? statusFromChecks(name, checks, binary) : "checking"];
|
|
33330
|
+
return /* @__PURE__ */ jsx55(Text46, { color: TONE_COLOR[tone], children: `${symbol} ${text}` });
|
|
33331
|
+
}
|
|
33332
|
+
var TONE_COLOR;
|
|
33333
|
+
var init_AgentStatusBadge = __esm({
|
|
33334
|
+
"packages/experience-design-system-cli/src/tui/settings/agents/AgentStatusBadge.tsx"() {
|
|
33335
|
+
"use strict";
|
|
33336
|
+
init_theme();
|
|
33337
|
+
init_agent_status();
|
|
33338
|
+
TONE_COLOR = {
|
|
33339
|
+
ok: PALETTE.success,
|
|
33340
|
+
bad: PALETTE.error,
|
|
33341
|
+
muted: PALETTE.muted
|
|
33342
|
+
};
|
|
33343
|
+
}
|
|
33344
|
+
});
|
|
33345
|
+
|
|
33346
|
+
// packages/experience-design-system-cli/src/tui/settings/agents/AgentDetail.tsx
|
|
33347
|
+
import { useEffect as useEffect22, useState as useState29 } from "react";
|
|
33348
|
+
import { Box as Box44, Text as Text47, useInput as useInput11 } from "ink";
|
|
33349
|
+
import TextInput4 from "ink-text-input";
|
|
33350
|
+
import { jsx as jsx56, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
33351
|
+
function Row2({
|
|
33352
|
+
pointer,
|
|
33353
|
+
label,
|
|
33354
|
+
labelProps,
|
|
33355
|
+
children
|
|
33356
|
+
}) {
|
|
33357
|
+
return /* @__PURE__ */ jsxs45(Box44, { children: [
|
|
33358
|
+
/* @__PURE__ */ jsx56(Box44, { width: POINTER_WIDTH, flexShrink: 0, children: pointer }),
|
|
33359
|
+
/* @__PURE__ */ jsx56(Box44, { width: LABEL_WIDTH + LABEL_GAP, flexShrink: 0, children: /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, ...labelProps, children: label }) }),
|
|
33360
|
+
children
|
|
33361
|
+
] });
|
|
33362
|
+
}
|
|
33363
|
+
function Section2({
|
|
33364
|
+
title,
|
|
33365
|
+
note,
|
|
33366
|
+
interactive = false,
|
|
33367
|
+
children
|
|
33368
|
+
}) {
|
|
33369
|
+
return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", marginTop: 1, children: [
|
|
33370
|
+
/* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
|
|
33371
|
+
/* @__PURE__ */ jsx56(Text47, { bold: true, color: interactive ? PALETTE.accent : PALETTE.muted, children: title }),
|
|
33372
|
+
/* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: `\xB7 ${note}` })
|
|
33373
|
+
] }),
|
|
33374
|
+
children
|
|
33375
|
+
] });
|
|
33376
|
+
}
|
|
33377
|
+
function AgentDetail({
|
|
33378
|
+
name,
|
|
33379
|
+
config,
|
|
33380
|
+
setConfig,
|
|
33381
|
+
onBack
|
|
33382
|
+
}) {
|
|
33383
|
+
const settings = config.agents[name];
|
|
33384
|
+
const [focusIndex, setFocusIndex] = useState29(0);
|
|
33385
|
+
const [editing, setEditing] = useState29(false);
|
|
33386
|
+
const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
|
|
33387
|
+
const [saving, setSaving] = useState29(false);
|
|
33388
|
+
const [testing, setTesting] = useState29(false);
|
|
33389
|
+
const [notice, setNotice] = useState29(null);
|
|
33390
|
+
const [checks, setChecks] = useState29(void 0);
|
|
33391
|
+
useEffect22(() => {
|
|
33392
|
+
let active = true;
|
|
33393
|
+
setChecks(void 0);
|
|
33394
|
+
void inspectAgent(name, settings.binary).then((result) => active && setChecks(result));
|
|
33395
|
+
return () => {
|
|
33396
|
+
active = false;
|
|
33397
|
+
};
|
|
33398
|
+
}, [name, settings.binary]);
|
|
33399
|
+
const setField = (field, value) => {
|
|
33400
|
+
setConfig({ ...config, agents: { ...config.agents, [name]: { ...settings, [field]: value } } });
|
|
33401
|
+
setNotice(null);
|
|
33402
|
+
};
|
|
33403
|
+
const save = () => {
|
|
33404
|
+
setSaving(true);
|
|
33405
|
+
setNotice(null);
|
|
33406
|
+
writeAgentConfig(config).then(() => {
|
|
33407
|
+
applyBinaryOverrides(config);
|
|
33408
|
+
setNotice({ kind: "success", text: `Saved: ${AGENT_LABELS[name]} settings are written to config.json` });
|
|
33409
|
+
}).catch(
|
|
33410
|
+
(err) => setNotice({ kind: "error", text: `Not saved: ${err instanceof Error ? err.message : String(err)}` })
|
|
33411
|
+
).finally(() => setSaving(false));
|
|
33412
|
+
};
|
|
33413
|
+
const runTest = () => {
|
|
33414
|
+
setTesting(true);
|
|
33415
|
+
setNotice(null);
|
|
33416
|
+
testAgent(name, settings.binary, settings.model).then((result) => {
|
|
33417
|
+
setChecks(result);
|
|
33418
|
+
const outcome = testOutcome(result);
|
|
33419
|
+
setNotice(
|
|
33420
|
+
outcome ? { kind: outcome.ok ? "success" : "error", text: outcome.text } : { kind: "error", text: "Test not run: the agent could not be started (see Status)" }
|
|
33421
|
+
);
|
|
33422
|
+
}).catch(
|
|
33423
|
+
(err) => setNotice({ kind: "error", text: `Test could not run: ${err instanceof Error ? err.message : String(err)}` })
|
|
33424
|
+
).finally(() => setTesting(false));
|
|
33425
|
+
};
|
|
33426
|
+
const focused = FOCUS_ORDER[focusIndex];
|
|
33427
|
+
const focusedField = focused === "test" ? null : focused;
|
|
33428
|
+
useInput11((input, key) => {
|
|
33429
|
+
if (saving || testing) return;
|
|
33430
|
+
if (editing) {
|
|
33431
|
+
if (key.escape && focusedField) {
|
|
33432
|
+
setField(focusedField, valueBeforeEdit);
|
|
33433
|
+
setEditing(false);
|
|
33434
|
+
}
|
|
33435
|
+
return;
|
|
33436
|
+
}
|
|
33437
|
+
if (key.escape || input === "q") {
|
|
33438
|
+
onBack();
|
|
33439
|
+
return;
|
|
33440
|
+
}
|
|
33441
|
+
if (input === "s") {
|
|
33442
|
+
save();
|
|
33443
|
+
return;
|
|
33444
|
+
}
|
|
33445
|
+
if (key.upArrow) {
|
|
33446
|
+
setFocusIndex((i) => (i - 1 + FOCUS_ORDER.length) % FOCUS_ORDER.length);
|
|
33447
|
+
return;
|
|
33448
|
+
}
|
|
33449
|
+
if (key.downArrow || key.tab) {
|
|
33450
|
+
setFocusIndex((i) => (i + 1) % FOCUS_ORDER.length);
|
|
33451
|
+
return;
|
|
33452
|
+
}
|
|
33453
|
+
if (input === "c" && focusedField) {
|
|
33454
|
+
setField(focusedField, "");
|
|
33455
|
+
return;
|
|
33456
|
+
}
|
|
33457
|
+
if (key.return) {
|
|
33458
|
+
if (focusedField) {
|
|
33459
|
+
setValueBeforeEdit(settings[focusedField]);
|
|
33460
|
+
setEditing(true);
|
|
33461
|
+
} else {
|
|
33462
|
+
runTest();
|
|
33463
|
+
}
|
|
33464
|
+
}
|
|
33465
|
+
});
|
|
33466
|
+
const status = checks ? statusFromChecks(name, checks, settings.binary) : "checking";
|
|
33467
|
+
const hint = setupHint(name, status);
|
|
33468
|
+
const pointer = (isFocused) => /* @__PURE__ */ jsx56(Text47, { color: isFocused ? PALETTE.accent : void 0, children: isFocused ? "\u276F" : " " });
|
|
33469
|
+
return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
33470
|
+
/* @__PURE__ */ jsx56(Text47, { bold: true, children: AGENT_LABELS[name] }),
|
|
33471
|
+
/* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: config.defaultAgent === name ? "This is the default agent." : `Runs the \`${AGENT_HINTS[name]}\` command.` }),
|
|
33472
|
+
(notice || testing || saving) && /* @__PURE__ */ jsx56(Box44, { marginTop: 1, children: testing || saving ? /* @__PURE__ */ jsx56(Text47, { color: PALETTE.accent, children: testing ? "\u2026 Running the test (up to 60s)" : "\u2026 Saving" }) : notice && /* @__PURE__ */ jsxs45(Text47, { bold: true, color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
|
|
33473
|
+
notice.kind === "success" ? "\u2713" : "\u2717",
|
|
33474
|
+
" ",
|
|
33475
|
+
notice.text
|
|
33476
|
+
] }) }),
|
|
33477
|
+
/* @__PURE__ */ jsxs45(Section2, { title: "CONFIGURE", note: "you can change these", interactive: true, children: [
|
|
33478
|
+
FIELDS2.map((field) => {
|
|
33479
|
+
const isFocused = focused === field;
|
|
33480
|
+
const value = settings[field];
|
|
33481
|
+
const display = isFocused && editing ? /* @__PURE__ */ jsx56(TextInput4, { value, onChange: (next) => setField(field, next), onSubmit: () => setEditing(false) }) : value ? /* @__PURE__ */ jsx56(Text47, { bold: true, children: value }) : /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: fieldHint(name, field) });
|
|
33482
|
+
return /* @__PURE__ */ jsx56(
|
|
33483
|
+
Row2,
|
|
33484
|
+
{
|
|
33485
|
+
pointer: pointer(isFocused),
|
|
33486
|
+
label: FIELD_LABEL[field],
|
|
33487
|
+
labelProps: { bold: isFocused, color: isFocused ? PALETTE.accent : PALETTE.muted },
|
|
33488
|
+
children: display
|
|
33489
|
+
},
|
|
33490
|
+
field
|
|
33491
|
+
);
|
|
33492
|
+
}),
|
|
33493
|
+
/* @__PURE__ */ jsx56(
|
|
33494
|
+
Row2,
|
|
33495
|
+
{
|
|
33496
|
+
pointer: pointer(focused === "test"),
|
|
33497
|
+
label: "Run test",
|
|
33498
|
+
labelProps: { bold: focused === "test", color: focused === "test" ? PALETTE.accent : PALETTE.muted },
|
|
33499
|
+
children: /* @__PURE__ */ jsx56(Text47, { color: testing ? PALETTE.accent : PALETTE.muted, children: testing ? "running..." : "sends one small prompt (uses a few tokens)" })
|
|
33500
|
+
}
|
|
33501
|
+
)
|
|
33502
|
+
] }),
|
|
33503
|
+
/* @__PURE__ */ jsxs45(Section2, { title: "STATUS", note: "read only", children: [
|
|
33504
|
+
statusRows(name, checks, settings.binary).map((row) => /* @__PURE__ */ jsx56(Row2, { pointer: null, label: row.label, children: /* @__PURE__ */ jsx56(Text47, { color: TONE_COLOR[row.tone], children: row.value }) }, row.label)),
|
|
33505
|
+
hint && /* @__PURE__ */ jsx56(Row2, { pointer: null, label: "Setup", children: /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: hint }) })
|
|
33506
|
+
] }),
|
|
33507
|
+
/* @__PURE__ */ jsx56(Text47, { children: " " }),
|
|
33508
|
+
/* @__PURE__ */ jsx56(
|
|
33509
|
+
ControlHints,
|
|
33510
|
+
{
|
|
33511
|
+
hints: editing ? [
|
|
33512
|
+
{ keys: "type", label: "edit" },
|
|
33513
|
+
{ keys: "\u2190/\u2192", label: "move cursor" },
|
|
33514
|
+
{ keys: "\u23CE", label: "done" },
|
|
33515
|
+
{ keys: "Esc", label: "cancel edit" }
|
|
33516
|
+
] : [
|
|
33517
|
+
{ keys: "\u2191/\u2193", label: "move" },
|
|
33518
|
+
{ keys: "\u23CE", label: focusedField ? "edit" : "run test" },
|
|
33519
|
+
...focusedField ? [{ keys: "c", label: "clear" }] : [],
|
|
33520
|
+
{ keys: "s", label: "save" },
|
|
33521
|
+
{ keys: "Esc/q", label: "back without saving" }
|
|
33522
|
+
]
|
|
33523
|
+
}
|
|
33524
|
+
)
|
|
33525
|
+
] });
|
|
33526
|
+
}
|
|
33527
|
+
var FOCUS_ORDER, FIELDS2, FIELD_LABEL, LABEL_WIDTH, LABEL_GAP, POINTER_WIDTH, fieldHint;
|
|
33528
|
+
var init_AgentDetail = __esm({
|
|
33529
|
+
"packages/experience-design-system-cli/src/tui/settings/agents/AgentDetail.tsx"() {
|
|
33530
|
+
"use strict";
|
|
33531
|
+
init_theme();
|
|
33532
|
+
init_control_hints();
|
|
33533
|
+
init_agent_store();
|
|
33534
|
+
init_agent_status();
|
|
33535
|
+
init_AgentStatusBadge();
|
|
33536
|
+
init_apply_binary_overrides();
|
|
33537
|
+
FOCUS_ORDER = ["binary", "model", "test"];
|
|
33538
|
+
FIELDS2 = ["binary", "model"];
|
|
33539
|
+
FIELD_LABEL = { binary: "Command path", model: "Model" };
|
|
33540
|
+
LABEL_WIDTH = "Command path".length;
|
|
33541
|
+
LABEL_GAP = 2;
|
|
33542
|
+
POINTER_WIDTH = 2;
|
|
33543
|
+
fieldHint = (name, field) => field === "binary" ? `(empty: \`${AGENT_HINTS[name]}\` from the PATH)` : `(empty: ${defaultModelLabel(name)})`;
|
|
33544
|
+
}
|
|
33545
|
+
});
|
|
33546
|
+
|
|
33547
|
+
// packages/experience-design-system-cli/src/tui/settings/agents/AgentScreens.tsx
|
|
33548
|
+
import { useEffect as useEffect23, useState as useState30 } from "react";
|
|
33549
|
+
import { Box as Box45, Text as Text48, useInput as useInput12 } from "ink";
|
|
33550
|
+
import { Fragment as Fragment17, jsx as jsx57, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
33551
|
+
function AgentsScreen({ onDone }) {
|
|
33552
|
+
const [config, setConfig] = useState30(null);
|
|
33553
|
+
const [focus, setFocus] = useState30(0);
|
|
33554
|
+
const [open, setOpen] = useState30(null);
|
|
33555
|
+
const [notice, setNotice] = useState30(null);
|
|
33556
|
+
const [saving, setSaving] = useState30(false);
|
|
33557
|
+
const [checks, setChecks] = useState30({});
|
|
33558
|
+
const inspectAll = (loaded) => {
|
|
33559
|
+
for (const name of AGENT_NAMES) {
|
|
33560
|
+
void inspectAgent(name, loaded.agents[name].binary).then(
|
|
33561
|
+
(result) => setChecks((previous) => ({ ...previous, [name]: result }))
|
|
33562
|
+
);
|
|
33563
|
+
}
|
|
33564
|
+
};
|
|
33565
|
+
useEffect23(() => {
|
|
33566
|
+
void readAgentConfig().then((loaded) => {
|
|
33567
|
+
setConfig(loaded);
|
|
33568
|
+
inspectAll(loaded);
|
|
33569
|
+
startDebugRun({
|
|
33570
|
+
flow: "settings/agents",
|
|
33571
|
+
step: "01-agents",
|
|
33572
|
+
menuOption: "Configuration > Agents",
|
|
33573
|
+
inputs: { default_agent: loaded.defaultAgent }
|
|
33574
|
+
});
|
|
33575
|
+
});
|
|
33576
|
+
}, []);
|
|
33577
|
+
const makeDefault = (name) => {
|
|
33578
|
+
if (!config || saving) return;
|
|
33579
|
+
if (name === config.defaultAgent) {
|
|
33580
|
+
setNotice({ kind: "success", text: `${AGENT_LABELS[name]} is already the default agent` });
|
|
33581
|
+
return;
|
|
33582
|
+
}
|
|
33583
|
+
setSaving(true);
|
|
33584
|
+
setNotice(null);
|
|
33585
|
+
writeAgentConfig({ ...config, defaultAgent: name }).then(() => {
|
|
33586
|
+
setConfig((current) => current ? { ...current, defaultAgent: name } : current);
|
|
33587
|
+
setNotice({ kind: "success", text: `Default agent is now ${AGENT_LABELS[name]}` });
|
|
33588
|
+
}).catch(
|
|
33589
|
+
(err) => setNotice({
|
|
33590
|
+
kind: "error",
|
|
33591
|
+
text: `Default agent not changed: ${err instanceof Error ? err.message : String(err)}`
|
|
33592
|
+
})
|
|
33593
|
+
).finally(() => setSaving(false));
|
|
33594
|
+
};
|
|
33595
|
+
useInput12((input, key) => {
|
|
33596
|
+
if (!config || open || saving) return;
|
|
33597
|
+
const focused = AGENT_NAMES[focus];
|
|
33598
|
+
if (key.upArrow || key.downArrow || key.tab) setNotice(null);
|
|
33599
|
+
if (key.upArrow) {
|
|
33600
|
+
setFocus((i) => (i - 1 + AGENT_NAMES.length) % AGENT_NAMES.length);
|
|
33601
|
+
return;
|
|
33602
|
+
}
|
|
33603
|
+
if (key.downArrow || key.tab) {
|
|
33604
|
+
setFocus((i) => (i + 1) % AGENT_NAMES.length);
|
|
33605
|
+
return;
|
|
33606
|
+
}
|
|
33607
|
+
if (key.return) {
|
|
33608
|
+
makeDefault(focused);
|
|
33609
|
+
return;
|
|
33610
|
+
}
|
|
33611
|
+
if (key.rightArrow) {
|
|
33612
|
+
setNotice(null);
|
|
33613
|
+
setOpen(focused);
|
|
33614
|
+
return;
|
|
33615
|
+
}
|
|
33616
|
+
if (key.escape || input === "q") {
|
|
33617
|
+
void finishDebugRun({ outputs: { default_agent: config.defaultAgent }, status: "success", exitMethod: "saved" });
|
|
33618
|
+
onDone();
|
|
33619
|
+
}
|
|
33620
|
+
});
|
|
33621
|
+
if (!config) {
|
|
33622
|
+
return /* @__PURE__ */ jsxs46(Box45, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
33623
|
+
/* @__PURE__ */ jsx57(Text48, { bold: true, children: "Agents" }),
|
|
33624
|
+
/* @__PURE__ */ jsx57(Text48, { children: " " }),
|
|
33625
|
+
/* @__PURE__ */ jsx57(Text48, { color: PALETTE.accent, children: "Loading..." })
|
|
33626
|
+
] });
|
|
33627
|
+
}
|
|
33628
|
+
if (open) {
|
|
33629
|
+
return /* @__PURE__ */ jsx57(
|
|
33630
|
+
AgentDetail,
|
|
33631
|
+
{
|
|
33632
|
+
name: open,
|
|
33633
|
+
config,
|
|
33634
|
+
setConfig,
|
|
33635
|
+
onBack: () => {
|
|
33636
|
+
setOpen(null);
|
|
33637
|
+
void readAgentConfig().then((saved) => {
|
|
33638
|
+
setConfig(saved);
|
|
33639
|
+
inspectAll(saved);
|
|
33640
|
+
});
|
|
33641
|
+
}
|
|
33642
|
+
}
|
|
33643
|
+
);
|
|
33644
|
+
}
|
|
33645
|
+
const focusedAgent = AGENT_NAMES[focus];
|
|
33646
|
+
return /* @__PURE__ */ jsxs46(Box45, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
33647
|
+
/* @__PURE__ */ jsx57(Text48, { bold: true, children: "Agents" }),
|
|
33648
|
+
/* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: "The coding agent the CLI runs, and what was found for each one." }),
|
|
33649
|
+
/* @__PURE__ */ jsx57(Text48, { children: " " }),
|
|
33650
|
+
/* @__PURE__ */ jsxs46(Box45, { gap: 1, children: [
|
|
33651
|
+
/* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: "Default agent" }),
|
|
33652
|
+
/* @__PURE__ */ jsx57(Text48, { bold: true, children: AGENT_LABELS[config.defaultAgent] }),
|
|
33653
|
+
saving && /* @__PURE__ */ jsx57(Text48, { color: PALETTE.accent, children: "\u2026 saving" })
|
|
33654
|
+
] }),
|
|
33655
|
+
/* @__PURE__ */ jsxs46(Box45, { marginTop: 1, gap: 1, children: [
|
|
33656
|
+
/* @__PURE__ */ jsx57(Text48, { children: " " }),
|
|
33657
|
+
/* @__PURE__ */ jsx57(Text48, { children: " " }),
|
|
33658
|
+
/* @__PURE__ */ jsx57(Box45, { width: NAME_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: "AGENT" }) }),
|
|
33659
|
+
/* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: "STATUS" })
|
|
33660
|
+
] }),
|
|
33661
|
+
AGENT_NAMES.map((name) => {
|
|
33662
|
+
const isFocused = focusedAgent === name;
|
|
33663
|
+
return /* @__PURE__ */ jsxs46(Box45, { gap: 1, children: [
|
|
33664
|
+
/* @__PURE__ */ jsx57(Text48, { color: isFocused ? PALETTE.accent : void 0, children: isFocused ? "\u276F" : " " }),
|
|
33665
|
+
/* @__PURE__ */ jsx57(Text48, { color: PALETTE.success, children: name === config.defaultAgent ? "\u2605" : " " }),
|
|
33666
|
+
/* @__PURE__ */ jsx57(Box45, { width: NAME_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx57(Text48, { bold: isFocused, color: isFocused ? PALETTE.accent : void 0, children: AGENT_LABELS[name] }) }),
|
|
33667
|
+
/* @__PURE__ */ jsx57(AgentStatusBadge, { name, checks: checks[name], binary: config.agents[name].binary })
|
|
33668
|
+
] }, name);
|
|
33669
|
+
}),
|
|
33670
|
+
/* @__PURE__ */ jsxs46(Box45, { flexDirection: "column", marginTop: 1, children: [
|
|
33671
|
+
/* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: `\u2500 ${AGENT_LABELS[focusedAgent]} ${"\u2500".repeat(30)}` }),
|
|
33672
|
+
panelRows(focusedAgent, checks[focusedAgent], config.agents[focusedAgent]).map((row) => /* @__PURE__ */ jsxs46(Box45, { gap: 1, paddingLeft: 1, children: [
|
|
33673
|
+
/* @__PURE__ */ jsx57(Box45, { width: PANEL_LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: row.label }) }),
|
|
33674
|
+
/* @__PURE__ */ jsx57(Text48, { color: TONE_COLOR[row.tone], children: row.value })
|
|
33675
|
+
] }, row.label))
|
|
33676
|
+
] }),
|
|
33677
|
+
notice && /* @__PURE__ */ jsxs46(Fragment17, { children: [
|
|
33678
|
+
/* @__PURE__ */ jsx57(Text48, { children: " " }),
|
|
33679
|
+
/* @__PURE__ */ jsxs46(Text48, { bold: true, color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
|
|
33680
|
+
notice.kind === "success" ? "\u2713" : "\u2717",
|
|
33681
|
+
" ",
|
|
33682
|
+
notice.text
|
|
33683
|
+
] })
|
|
33684
|
+
] }),
|
|
33685
|
+
/* @__PURE__ */ jsx57(Text48, { children: " " }),
|
|
33686
|
+
/* @__PURE__ */ jsx57(
|
|
33687
|
+
ControlHints,
|
|
33688
|
+
{
|
|
33689
|
+
hints: [
|
|
33690
|
+
{ keys: "\u2191/\u2193", label: "move" },
|
|
33691
|
+
{ keys: "\u23CE", label: "make default" },
|
|
33692
|
+
{ keys: "\u2192", label: "settings and test" },
|
|
33693
|
+
{ keys: "Esc/q", label: "back" }
|
|
33694
|
+
]
|
|
33695
|
+
}
|
|
33696
|
+
)
|
|
33697
|
+
] });
|
|
33698
|
+
}
|
|
33699
|
+
var NAME_WIDTH, PANEL_LABEL_WIDTH;
|
|
33700
|
+
var init_AgentScreens = __esm({
|
|
33701
|
+
"packages/experience-design-system-cli/src/tui/settings/agents/AgentScreens.tsx"() {
|
|
33702
|
+
"use strict";
|
|
33703
|
+
init_src4();
|
|
33704
|
+
init_theme();
|
|
33705
|
+
init_control_hints();
|
|
33706
|
+
init_debug_store();
|
|
33707
|
+
init_agent_store();
|
|
33708
|
+
init_agent_status();
|
|
33709
|
+
init_AgentDetail();
|
|
33710
|
+
init_AgentStatusBadge();
|
|
33711
|
+
NAME_WIDTH = 16;
|
|
33712
|
+
PANEL_LABEL_WIDTH = "Command".length;
|
|
33713
|
+
}
|
|
33714
|
+
});
|
|
33715
|
+
|
|
33716
|
+
// packages/experience-design-system-cli/src/tui/settings/shared/FieldForm.tsx
|
|
33717
|
+
import { useState as useState31 } from "react";
|
|
33718
|
+
import { Box as Box46, Text as Text49, useInput as useInput13 } from "ink";
|
|
33719
|
+
import TextInput5 from "ink-text-input";
|
|
33720
|
+
import { Fragment as Fragment18, jsx as jsx58, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
33721
|
+
function FieldForm({
|
|
33722
|
+
title,
|
|
33723
|
+
subtitle,
|
|
33724
|
+
fields,
|
|
33725
|
+
values,
|
|
33726
|
+
onChange,
|
|
33727
|
+
onSave,
|
|
33728
|
+
onQuit,
|
|
33729
|
+
notice,
|
|
33730
|
+
busy = false,
|
|
33731
|
+
footer
|
|
33732
|
+
}) {
|
|
33733
|
+
const [active, setActive] = useState31(0);
|
|
33734
|
+
const [editing, setEditing] = useState31(false);
|
|
33735
|
+
const [valueBeforeEdit, setValueBeforeEdit] = useState31("");
|
|
33736
|
+
const labelWidth = Math.max(...fields.map((field) => field.label.length));
|
|
33737
|
+
const current = fields[active];
|
|
33738
|
+
useInput13((input, key) => {
|
|
33739
|
+
if (busy) return;
|
|
33740
|
+
if (editing) {
|
|
33741
|
+
if (key.escape) {
|
|
33742
|
+
onChange(current.key, valueBeforeEdit);
|
|
33743
|
+
setEditing(false);
|
|
33744
|
+
}
|
|
33745
|
+
return;
|
|
33746
|
+
}
|
|
33747
|
+
if (key.escape || input === "q") {
|
|
33748
|
+
onQuit();
|
|
33749
|
+
return;
|
|
33750
|
+
}
|
|
33751
|
+
if (input === "s") {
|
|
33752
|
+
onSave();
|
|
33753
|
+
return;
|
|
33754
|
+
}
|
|
33755
|
+
if (input === "c") {
|
|
33756
|
+
onChange(current.key, "");
|
|
33757
|
+
return;
|
|
33758
|
+
}
|
|
33759
|
+
if (key.tab || key.downArrow) {
|
|
33760
|
+
setActive((i) => (i + 1) % fields.length);
|
|
33761
|
+
return;
|
|
33762
|
+
}
|
|
33763
|
+
if (key.upArrow) {
|
|
33764
|
+
setActive((i) => (i - 1 + fields.length) % fields.length);
|
|
33765
|
+
return;
|
|
33766
|
+
}
|
|
33767
|
+
if (key.return) {
|
|
33768
|
+
setValueBeforeEdit(values[current.key]);
|
|
33769
|
+
setEditing(true);
|
|
33770
|
+
}
|
|
33771
|
+
});
|
|
33772
|
+
return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
33773
|
+
/* @__PURE__ */ jsx58(Text49, { bold: true, children: title }),
|
|
33774
|
+
subtitle && /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: subtitle }),
|
|
33775
|
+
/* @__PURE__ */ jsx58(Text49, { children: " " }),
|
|
33776
|
+
/* @__PURE__ */ jsx58(Box46, { flexDirection: "column", children: fields.map((field, index) => {
|
|
33777
|
+
const isActive = index === active;
|
|
33778
|
+
const value = values[field.key];
|
|
33779
|
+
const display = field.masked ? "\u2022".repeat(value.length) : value;
|
|
33780
|
+
return /* @__PURE__ */ jsxs47(Box46, { gap: 1, children: [
|
|
33781
|
+
/* @__PURE__ */ jsx58(Text49, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
|
|
33782
|
+
/* @__PURE__ */ jsx58(Box46, { width: labelWidth, flexShrink: 0, children: /* @__PURE__ */ jsx58(Text49, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: field.label }) }),
|
|
33783
|
+
isActive && editing ? /* @__PURE__ */ jsx58(
|
|
33784
|
+
TextInput5,
|
|
33785
|
+
{
|
|
33786
|
+
value,
|
|
33787
|
+
onChange: (next) => onChange(field.key, next),
|
|
33788
|
+
onSubmit: () => setEditing(false),
|
|
33789
|
+
mask: field.masked ? "\u2022" : void 0
|
|
33790
|
+
}
|
|
33791
|
+
) : /* @__PURE__ */ jsx58(Text49, { bold: !!display, children: display || (field.hint ? "" : /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "(empty)" })) }),
|
|
33792
|
+
field.hint && /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: field.hint })
|
|
33793
|
+
] }, field.key);
|
|
33794
|
+
}) }),
|
|
33795
|
+
notice && /* @__PURE__ */ jsxs47(Fragment18, { children: [
|
|
33796
|
+
/* @__PURE__ */ jsx58(Text49, { children: " " }),
|
|
33797
|
+
/* @__PURE__ */ jsxs47(Text49, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
|
|
33798
|
+
notice.kind === "success" ? "\u2713" : "\u2717",
|
|
33799
|
+
" ",
|
|
33800
|
+
notice.text
|
|
33801
|
+
] })
|
|
33802
|
+
] }),
|
|
33803
|
+
footer,
|
|
33804
|
+
/* @__PURE__ */ jsx58(Text49, { children: " " }),
|
|
33805
|
+
/* @__PURE__ */ jsx58(
|
|
33806
|
+
ControlHints,
|
|
33807
|
+
{
|
|
33808
|
+
hints: editing ? [
|
|
33809
|
+
{ keys: "type", label: "edit" },
|
|
33810
|
+
{ keys: "\u2190/\u2192", label: "move cursor" },
|
|
33811
|
+
{ keys: "\u23CE", label: "done" },
|
|
33812
|
+
{ keys: "Esc", label: "cancel edit" }
|
|
33813
|
+
] : [
|
|
33814
|
+
{ keys: "\u2191/\u2193", label: "move" },
|
|
33815
|
+
{ keys: "\u23CE", label: "edit" },
|
|
33816
|
+
{ keys: "c", label: "clear" },
|
|
33817
|
+
{ keys: "s", label: "save" },
|
|
33818
|
+
{ keys: "Esc/q", label: "back without saving" }
|
|
33819
|
+
]
|
|
33820
|
+
}
|
|
33821
|
+
)
|
|
33822
|
+
] });
|
|
33823
|
+
}
|
|
33824
|
+
var init_FieldForm = __esm({
|
|
33825
|
+
"packages/experience-design-system-cli/src/tui/settings/shared/FieldForm.tsx"() {
|
|
33826
|
+
"use strict";
|
|
33827
|
+
init_theme();
|
|
33828
|
+
init_control_hints();
|
|
33829
|
+
}
|
|
33830
|
+
});
|
|
33831
|
+
|
|
32980
33832
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/config-store.ts
|
|
32981
33833
|
async function readCredentials() {
|
|
32982
33834
|
const store = await readV1Store();
|
|
@@ -33008,11 +33860,10 @@ var init_config_store = __esm({
|
|
|
33008
33860
|
}
|
|
33009
33861
|
});
|
|
33010
33862
|
|
|
33011
|
-
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/
|
|
33012
|
-
import { useEffect as
|
|
33013
|
-
import { Box as
|
|
33014
|
-
import
|
|
33015
|
-
import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
33863
|
+
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ProjectConfigScreen.tsx
|
|
33864
|
+
import { useEffect as useEffect24, useState as useState32 } from "react";
|
|
33865
|
+
import { Box as Box47, Text as Text50 } from "ink";
|
|
33866
|
+
import { jsx as jsx59, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
33016
33867
|
function debugFields(config) {
|
|
33017
33868
|
return {
|
|
33018
33869
|
space_id: config?.spaceId ?? "",
|
|
@@ -33024,189 +33875,159 @@ function debugFields(config) {
|
|
|
33024
33875
|
contentful_base_dir: config?.contentfulBaseDir ?? ""
|
|
33025
33876
|
};
|
|
33026
33877
|
}
|
|
33027
|
-
function
|
|
33028
|
-
const [
|
|
33029
|
-
const [
|
|
33030
|
-
const [
|
|
33031
|
-
const [
|
|
33032
|
-
|
|
33033
|
-
|
|
33034
|
-
const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
|
|
33035
|
-
useEffect22(() => {
|
|
33036
|
-
readCredentials().then((cfg) => {
|
|
33878
|
+
function ProjectConfigScreen({ onDone }) {
|
|
33879
|
+
const [config, setConfig] = useState32(null);
|
|
33880
|
+
const [saving, setSaving] = useState32(false);
|
|
33881
|
+
const [notice, setNotice] = useState32(null);
|
|
33882
|
+
const [lastSaved, setLastSaved] = useState32(null);
|
|
33883
|
+
useEffect24(() => {
|
|
33884
|
+
void readCredentials().then((cfg) => {
|
|
33037
33885
|
setConfig(cfg);
|
|
33038
|
-
setStage("form");
|
|
33039
33886
|
startDebugRun({
|
|
33040
33887
|
flow: "settings/contentful-configuration",
|
|
33041
33888
|
step: "01-configuration",
|
|
33042
|
-
menuOption: "Configuration",
|
|
33889
|
+
menuOption: "Configuration > Project",
|
|
33043
33890
|
inputs: debugFields(cfg)
|
|
33044
33891
|
});
|
|
33045
33892
|
});
|
|
33046
33893
|
}, []);
|
|
33047
|
-
|
|
33048
|
-
|
|
33049
|
-
|
|
33050
|
-
|
|
33051
|
-
|
|
33052
|
-
|
|
33053
|
-
setConfig({ ...config, [field]: value });
|
|
33054
|
-
setNotice(null);
|
|
33894
|
+
if (!config) {
|
|
33895
|
+
return /* @__PURE__ */ jsxs48(Box47, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
33896
|
+
/* @__PURE__ */ jsx59(Text50, { bold: true, children: "Project" }),
|
|
33897
|
+
/* @__PURE__ */ jsx59(Text50, { children: " " }),
|
|
33898
|
+
/* @__PURE__ */ jsx59(Text50, { color: PALETTE.accent, children: "Loading..." })
|
|
33899
|
+
] });
|
|
33055
33900
|
}
|
|
33056
|
-
|
|
33057
|
-
|
|
33058
|
-
setStage("saving");
|
|
33901
|
+
const save = () => {
|
|
33902
|
+
setSaving(true);
|
|
33059
33903
|
setNotice(null);
|
|
33060
33904
|
writeCredentials(config).then(() => {
|
|
33061
33905
|
setLastSaved(config);
|
|
33062
33906
|
if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
|
|
33063
|
-
setNotice({ kind: "success", text: "
|
|
33064
|
-
setStage("form");
|
|
33907
|
+
setNotice({ kind: "success", text: "Project settings saved" });
|
|
33065
33908
|
}).catch((err) => {
|
|
33066
33909
|
setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
|
|
33067
|
-
|
|
33068
|
-
|
|
33069
|
-
|
|
33070
|
-
function quit() {
|
|
33910
|
+
}).finally(() => setSaving(false));
|
|
33911
|
+
};
|
|
33912
|
+
const quit = () => {
|
|
33071
33913
|
void finishDebugRun(
|
|
33072
33914
|
lastSaved ? { outputs: debugFields(lastSaved), status: "success", exitMethod: "saved" } : { outputs: {}, status: "success", exitMethod: "discarded" }
|
|
33073
33915
|
);
|
|
33074
33916
|
onDone();
|
|
33075
|
-
}
|
|
33076
|
-
|
|
33077
|
-
|
|
33078
|
-
|
|
33079
|
-
|
|
33080
|
-
|
|
33081
|
-
|
|
33082
|
-
|
|
33083
|
-
|
|
33084
|
-
|
|
33085
|
-
|
|
33086
|
-
|
|
33087
|
-
|
|
33088
|
-
|
|
33089
|
-
|
|
33090
|
-
|
|
33091
|
-
return;
|
|
33092
|
-
}
|
|
33093
|
-
if (input === "c") {
|
|
33094
|
-
setFieldValue(activeField, "");
|
|
33095
|
-
return;
|
|
33917
|
+
};
|
|
33918
|
+
return /* @__PURE__ */ jsx59(
|
|
33919
|
+
FieldForm,
|
|
33920
|
+
{
|
|
33921
|
+
title: "Project",
|
|
33922
|
+
subtitle: "The Contentful space and where the CLI keeps its files.",
|
|
33923
|
+
fields: FIELDS3,
|
|
33924
|
+
values: valuesOf(config),
|
|
33925
|
+
onChange: (key, value) => {
|
|
33926
|
+
setConfig({ ...config, [key]: value });
|
|
33927
|
+
setNotice(null);
|
|
33928
|
+
},
|
|
33929
|
+
onSave: save,
|
|
33930
|
+
onQuit: quit,
|
|
33931
|
+
notice,
|
|
33932
|
+
busy: saving
|
|
33096
33933
|
}
|
|
33097
|
-
|
|
33098
|
-
|
|
33099
|
-
|
|
33934
|
+
);
|
|
33935
|
+
}
|
|
33936
|
+
var FIELDS3, valuesOf;
|
|
33937
|
+
var init_ProjectConfigScreen = __esm({
|
|
33938
|
+
"packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ProjectConfigScreen.tsx"() {
|
|
33939
|
+
"use strict";
|
|
33940
|
+
init_theme();
|
|
33941
|
+
init_debug_store();
|
|
33942
|
+
init_FieldForm();
|
|
33943
|
+
init_config_store();
|
|
33944
|
+
FIELDS3 = [
|
|
33945
|
+
{ key: "spaceId", label: "Space ID" },
|
|
33946
|
+
{ key: "environmentId", label: "Environment ID" },
|
|
33947
|
+
{ key: "cmaToken", label: "CMA Token", masked: true },
|
|
33948
|
+
{ key: "host", label: "API Host" },
|
|
33949
|
+
{ key: "defaultComponentDir", label: "Default component directory" },
|
|
33950
|
+
{ key: "defaultTokenFile", label: "Default token file" },
|
|
33951
|
+
{ key: "contentfulBaseDir", label: "Root Project Directory", hint: "(where .contentful goes)" }
|
|
33952
|
+
];
|
|
33953
|
+
valuesOf = (config) => Object.fromEntries(FIELDS3.map(({ key }) => [key, config[key] || ""]));
|
|
33954
|
+
}
|
|
33955
|
+
});
|
|
33956
|
+
|
|
33957
|
+
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
33958
|
+
import { useState as useState33 } from "react";
|
|
33959
|
+
import { Box as Box48, Text as Text51, useInput as useInput14 } from "ink";
|
|
33960
|
+
import { jsx as jsx60, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
33961
|
+
function ConfigurationScreen({ onDone }) {
|
|
33962
|
+
const [focus, setFocus] = useState33(0);
|
|
33963
|
+
const [open, setOpen] = useState33(null);
|
|
33964
|
+
const close = () => setOpen(null);
|
|
33965
|
+
useInput14((input, key) => {
|
|
33966
|
+
if (open) return;
|
|
33967
|
+
if (key.upArrow) {
|
|
33968
|
+
setFocus((i) => (i - 1 + SECTIONS.length) % SECTIONS.length);
|
|
33100
33969
|
return;
|
|
33101
33970
|
}
|
|
33102
|
-
if (key.
|
|
33103
|
-
|
|
33104
|
-
setActiveField(FIELD_ORDER[(idx - 1 + FIELD_ORDER.length) % FIELD_ORDER.length]);
|
|
33971
|
+
if (key.downArrow || key.tab) {
|
|
33972
|
+
setFocus((i) => (i + 1) % SECTIONS.length);
|
|
33105
33973
|
return;
|
|
33106
33974
|
}
|
|
33107
33975
|
if (key.return) {
|
|
33108
|
-
|
|
33109
|
-
|
|
33976
|
+
setOpen(SECTIONS[focus].id);
|
|
33977
|
+
return;
|
|
33110
33978
|
}
|
|
33979
|
+
if (key.escape || input === "q") onDone();
|
|
33111
33980
|
});
|
|
33112
|
-
if (
|
|
33113
|
-
|
|
33114
|
-
|
|
33115
|
-
|
|
33116
|
-
|
|
33117
|
-
|
|
33118
|
-
|
|
33119
|
-
|
|
33120
|
-
|
|
33121
|
-
|
|
33122
|
-
/* @__PURE__ */
|
|
33123
|
-
|
|
33124
|
-
const value = fieldValue(field);
|
|
33125
|
-
const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
|
|
33126
|
-
return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
|
|
33127
|
-
/* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
|
|
33128
|
-
/* @__PURE__ */ jsx55(Box44, { width: LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: FIELD_LABELS[field] }) }),
|
|
33129
|
-
isActive && editing ? /* @__PURE__ */ jsx55(
|
|
33130
|
-
TextInput4,
|
|
33131
|
-
{
|
|
33132
|
-
value,
|
|
33133
|
-
onChange: (next) => setFieldValue(field, next),
|
|
33134
|
-
onSubmit: () => setEditing(false),
|
|
33135
|
-
mask: field === "cmaToken" ? "\u2022" : void 0
|
|
33136
|
-
}
|
|
33137
|
-
) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (FIELD_HINTS[field] ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
|
|
33138
|
-
FIELD_HINTS[field] && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: FIELD_HINTS[field] })
|
|
33139
|
-
] }, field);
|
|
33140
|
-
}) }),
|
|
33141
|
-
notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
|
|
33142
|
-
/* @__PURE__ */ jsx55(Text46, { children: " " }),
|
|
33143
|
-
/* @__PURE__ */ jsxs45(Text46, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
|
|
33144
|
-
notice.kind === "success" ? "\u2713" : "\u2717",
|
|
33145
|
-
" ",
|
|
33146
|
-
notice.text
|
|
33147
|
-
] })
|
|
33148
|
-
] }),
|
|
33149
|
-
/* @__PURE__ */ jsx55(Text46, { children: " " }),
|
|
33150
|
-
/* @__PURE__ */ jsx55(
|
|
33981
|
+
if (open === "project") return /* @__PURE__ */ jsx60(ProjectConfigScreen, { onDone: close });
|
|
33982
|
+
if (open === "agents") return /* @__PURE__ */ jsx60(AgentsScreen, { onDone: close });
|
|
33983
|
+
return /* @__PURE__ */ jsxs49(Box48, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
33984
|
+
/* @__PURE__ */ jsx60(Text51, { bold: true, children: "Configuration" }),
|
|
33985
|
+
/* @__PURE__ */ jsx60(Text51, { children: " " }),
|
|
33986
|
+
SECTIONS.map((section, index) => /* @__PURE__ */ jsxs49(Box48, { gap: 1, children: [
|
|
33987
|
+
/* @__PURE__ */ jsx60(Text51, { color: index === focus ? PALETTE.accent : void 0, children: index === focus ? "\u276F" : " " }),
|
|
33988
|
+
/* @__PURE__ */ jsx60(Box48, { width: 9, flexShrink: 0, children: /* @__PURE__ */ jsx60(Text51, { bold: index === focus, color: index === focus ? PALETTE.accent : void 0, children: section.label }) }),
|
|
33989
|
+
/* @__PURE__ */ jsx60(Text51, { color: PALETTE.muted, children: section.description })
|
|
33990
|
+
] }, section.id)),
|
|
33991
|
+
/* @__PURE__ */ jsx60(Text51, { children: " " }),
|
|
33992
|
+
/* @__PURE__ */ jsx60(
|
|
33151
33993
|
ControlHints,
|
|
33152
33994
|
{
|
|
33153
|
-
hints:
|
|
33154
|
-
{ keys: "type", label: "edit" },
|
|
33155
|
-
{ keys: "\u2190/\u2192", label: "move cursor" },
|
|
33156
|
-
{ keys: "\u23CE", label: "done" },
|
|
33157
|
-
{ keys: "Esc", label: "cancel edit" }
|
|
33158
|
-
] : [
|
|
33995
|
+
hints: [
|
|
33159
33996
|
{ keys: "\u2191/\u2193", label: "move" },
|
|
33160
|
-
{ keys: "\u23CE", label: "
|
|
33161
|
-
{ keys: "
|
|
33162
|
-
{ keys: "s", label: "save" },
|
|
33163
|
-
{ keys: "Esc/q", label: "quit without saving" }
|
|
33997
|
+
{ keys: "\u23CE", label: "open" },
|
|
33998
|
+
{ keys: "Esc/q", label: "back" }
|
|
33164
33999
|
]
|
|
33165
34000
|
}
|
|
33166
34001
|
)
|
|
33167
34002
|
] });
|
|
33168
34003
|
}
|
|
33169
|
-
var
|
|
34004
|
+
var SECTIONS;
|
|
33170
34005
|
var init_ContentfulConfigScreen = __esm({
|
|
33171
34006
|
"packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx"() {
|
|
33172
34007
|
"use strict";
|
|
33173
34008
|
init_theme();
|
|
33174
|
-
init_config_store();
|
|
33175
|
-
init_debug_store();
|
|
33176
34009
|
init_control_hints();
|
|
33177
|
-
|
|
33178
|
-
|
|
33179
|
-
|
|
33180
|
-
|
|
33181
|
-
|
|
33182
|
-
|
|
33183
|
-
|
|
33184
|
-
|
|
34010
|
+
init_AgentScreens();
|
|
34011
|
+
init_ProjectConfigScreen();
|
|
34012
|
+
SECTIONS = [
|
|
34013
|
+
{
|
|
34014
|
+
id: "project",
|
|
34015
|
+
label: "Project",
|
|
34016
|
+
description: "Contentful space, credentials, defaults and where .contentful goes"
|
|
34017
|
+
},
|
|
34018
|
+
{ id: "agents", label: "Agents", description: "Which coding agent the CLI uses, and each agent\u2019s settings" }
|
|
33185
34019
|
];
|
|
33186
|
-
FIELD_LABELS = {
|
|
33187
|
-
spaceId: "Space ID",
|
|
33188
|
-
environmentId: "Environment ID",
|
|
33189
|
-
cmaToken: "CMA Token",
|
|
33190
|
-
host: "API Host",
|
|
33191
|
-
defaultComponentDir: "Default component directory",
|
|
33192
|
-
defaultTokenFile: "Default token file",
|
|
33193
|
-
contentfulBaseDir: "Root Project Directory"
|
|
33194
|
-
};
|
|
33195
|
-
FIELD_HINTS = {
|
|
33196
|
-
contentfulBaseDir: "(where .contentful goes)"
|
|
33197
|
-
};
|
|
33198
|
-
LABEL_WIDTH = Math.max(...Object.values(FIELD_LABELS).map((label) => label.length));
|
|
33199
34020
|
}
|
|
33200
34021
|
});
|
|
33201
34022
|
|
|
33202
34023
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
33203
|
-
import { useEffect as
|
|
33204
|
-
import { Box as
|
|
33205
|
-
import { Fragment as
|
|
34024
|
+
import { useEffect as useEffect25, useState as useState34 } from "react";
|
|
34025
|
+
import { Box as Box49, Text as Text52, useInput as useInput15 } from "ink";
|
|
34026
|
+
import { Fragment as Fragment19, jsx as jsx61, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
33206
34027
|
function OptInAnalyticsScreen({ onDone }) {
|
|
33207
|
-
const [loading, setLoading] =
|
|
33208
|
-
const [enabled, setEnabled] =
|
|
33209
|
-
|
|
34028
|
+
const [loading, setLoading] = useState34(true);
|
|
34029
|
+
const [enabled, setEnabled] = useState34(true);
|
|
34030
|
+
useEffect25(() => {
|
|
33210
34031
|
readAnalyticsSetting().then((setting) => {
|
|
33211
34032
|
setEnabled(setting.enabled);
|
|
33212
34033
|
setLoading(false);
|
|
@@ -33218,7 +34039,7 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
33218
34039
|
});
|
|
33219
34040
|
});
|
|
33220
34041
|
}, []);
|
|
33221
|
-
|
|
34042
|
+
useInput15((input, key) => {
|
|
33222
34043
|
if (loading) return;
|
|
33223
34044
|
if (key.return || input === " ") {
|
|
33224
34045
|
setEnabled((current) => {
|
|
@@ -33233,21 +34054,21 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
33233
34054
|
onDone();
|
|
33234
34055
|
}
|
|
33235
34056
|
});
|
|
33236
|
-
return /* @__PURE__ */
|
|
33237
|
-
/* @__PURE__ */
|
|
33238
|
-
/* @__PURE__ */
|
|
33239
|
-
loading ? /* @__PURE__ */
|
|
33240
|
-
/* @__PURE__ */
|
|
34057
|
+
return /* @__PURE__ */ jsxs50(Box49, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
34058
|
+
/* @__PURE__ */ jsx61(Text52, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
|
|
34059
|
+
/* @__PURE__ */ jsx61(Text52, { children: " " }),
|
|
34060
|
+
loading ? /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs50(Fragment19, { children: [
|
|
34061
|
+
/* @__PURE__ */ jsxs50(Text52, { children: [
|
|
33241
34062
|
"Share anonymous usage data:",
|
|
33242
34063
|
" ",
|
|
33243
|
-
/* @__PURE__ */
|
|
34064
|
+
/* @__PURE__ */ jsx61(Text52, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
33244
34065
|
] }),
|
|
33245
|
-
/* @__PURE__ */
|
|
33246
|
-
/* @__PURE__ */
|
|
33247
|
-
/* @__PURE__ */
|
|
34066
|
+
/* @__PURE__ */ jsx61(Text52, { children: " " }),
|
|
34067
|
+
/* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Shares which CLI commands are used and where imports succeed or fail." }),
|
|
34068
|
+
/* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Never includes source code, file paths, credentials, or authored content." })
|
|
33248
34069
|
] }),
|
|
33249
|
-
/* @__PURE__ */
|
|
33250
|
-
/* @__PURE__ */
|
|
34070
|
+
/* @__PURE__ */ jsx61(Text52, { children: " " }),
|
|
34071
|
+
/* @__PURE__ */ jsx61(
|
|
33251
34072
|
ControlHints,
|
|
33252
34073
|
{
|
|
33253
34074
|
hints: [
|
|
@@ -33269,12 +34090,12 @@ var init_screen11 = __esm({
|
|
|
33269
34090
|
});
|
|
33270
34091
|
|
|
33271
34092
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
33272
|
-
import { useEffect as
|
|
33273
|
-
import { Box as
|
|
33274
|
-
import { jsx as
|
|
34093
|
+
import { useEffect as useEffect26, useState as useState35 } from "react";
|
|
34094
|
+
import { Box as Box50, Text as Text53, useInput as useInput16 } from "ink";
|
|
34095
|
+
import { jsx as jsx62, jsxs as jsxs51 } from "react/jsx-runtime";
|
|
33275
34096
|
function UpgradeScreen({ onDone }) {
|
|
33276
|
-
const [upgradeCheck, setUpgradeCheck] =
|
|
33277
|
-
|
|
34097
|
+
const [upgradeCheck, setUpgradeCheck] = useState35();
|
|
34098
|
+
useEffect26(() => {
|
|
33278
34099
|
startDebugRun({
|
|
33279
34100
|
flow: "upgrade",
|
|
33280
34101
|
step: "01-upgrade",
|
|
@@ -33283,7 +34104,7 @@ function UpgradeScreen({ onDone }) {
|
|
|
33283
34104
|
});
|
|
33284
34105
|
checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
|
|
33285
34106
|
}, []);
|
|
33286
|
-
|
|
34107
|
+
useInput16((_input, key) => {
|
|
33287
34108
|
if (key.return) {
|
|
33288
34109
|
void finishDebugRun({
|
|
33289
34110
|
outputs: upgradeCheck ?? {},
|
|
@@ -33294,12 +34115,12 @@ function UpgradeScreen({ onDone }) {
|
|
|
33294
34115
|
return;
|
|
33295
34116
|
}
|
|
33296
34117
|
});
|
|
33297
|
-
return /* @__PURE__ */
|
|
33298
|
-
/* @__PURE__ */
|
|
33299
|
-
/* @__PURE__ */
|
|
34118
|
+
return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
34119
|
+
/* @__PURE__ */ jsx62(Text53, { bold: true, children: "Upgrade" }),
|
|
34120
|
+
/* @__PURE__ */ jsx62(Text53, { children: " " }),
|
|
33300
34121
|
renderBody(upgradeCheck),
|
|
33301
|
-
/* @__PURE__ */
|
|
33302
|
-
/* @__PURE__ */
|
|
34122
|
+
/* @__PURE__ */ jsx62(Text53, { children: " " }),
|
|
34123
|
+
/* @__PURE__ */ jsxs51(Text53, { bold: true, color: PALETTE.accent, children: [
|
|
33303
34124
|
FOCUS_MARKER,
|
|
33304
34125
|
" Go Back"
|
|
33305
34126
|
] })
|
|
@@ -33307,34 +34128,34 @@ function UpgradeScreen({ onDone }) {
|
|
|
33307
34128
|
}
|
|
33308
34129
|
function renderBody(upgradeCheck) {
|
|
33309
34130
|
if (!upgradeCheck) {
|
|
33310
|
-
return /* @__PURE__ */
|
|
34131
|
+
return /* @__PURE__ */ jsx62(Text53, { color: PALETTE.muted, children: "Checking for updates\u2026" });
|
|
33311
34132
|
}
|
|
33312
34133
|
if (upgradeCheck.status === "error") {
|
|
33313
|
-
return /* @__PURE__ */
|
|
34134
|
+
return /* @__PURE__ */ jsx62(Text53, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
|
|
33314
34135
|
}
|
|
33315
34136
|
if (upgradeCheck.status === "up-to-date") {
|
|
33316
|
-
return /* @__PURE__ */
|
|
34137
|
+
return /* @__PURE__ */ jsxs51(Text53, { color: PALETTE.success, children: [
|
|
33317
34138
|
"You're already on the latest version (v",
|
|
33318
34139
|
upgradeCheck.current,
|
|
33319
34140
|
")."
|
|
33320
34141
|
] });
|
|
33321
34142
|
}
|
|
33322
|
-
return /* @__PURE__ */
|
|
33323
|
-
/* @__PURE__ */
|
|
33324
|
-
/* @__PURE__ */
|
|
34143
|
+
return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", children: [
|
|
34144
|
+
/* @__PURE__ */ jsxs51(Text53, { color: PALETTE.muted, children: [
|
|
34145
|
+
/* @__PURE__ */ jsxs51(Text53, { bold: true, color: PALETTE.success, children: [
|
|
33325
34146
|
"v",
|
|
33326
34147
|
upgradeCheck.latest
|
|
33327
34148
|
] }),
|
|
33328
34149
|
" ",
|
|
33329
34150
|
"is available (you're on ",
|
|
33330
|
-
/* @__PURE__ */
|
|
34151
|
+
/* @__PURE__ */ jsxs51(Text53, { bold: true, children: [
|
|
33331
34152
|
"v",
|
|
33332
34153
|
upgradeCheck.current
|
|
33333
34154
|
] }),
|
|
33334
34155
|
"). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
|
|
33335
34156
|
] }),
|
|
33336
|
-
/* @__PURE__ */
|
|
33337
|
-
/* @__PURE__ */
|
|
34157
|
+
/* @__PURE__ */ jsx62(Text53, { children: " " }),
|
|
34158
|
+
/* @__PURE__ */ jsx62(Box50, { flexDirection: "column", borderStyle: "round", borderColor: PALETTE.border, paddingX: 1, children: UPGRADE_COMMANDS.map((cmd) => /* @__PURE__ */ jsx62(Text53, { bold: true, children: cmd }, cmd)) })
|
|
33338
34159
|
] });
|
|
33339
34160
|
}
|
|
33340
34161
|
var UPGRADE_COMMANDS;
|
|
@@ -33350,13 +34171,13 @@ var init_PageContainer4 = __esm({
|
|
|
33350
34171
|
});
|
|
33351
34172
|
|
|
33352
34173
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
33353
|
-
import { useEffect as
|
|
33354
|
-
import { Box as
|
|
33355
|
-
import { jsx as
|
|
34174
|
+
import { useEffect as useEffect27, useState as useState36 } from "react";
|
|
34175
|
+
import { Box as Box51, Text as Text54, useInput as useInput17 } from "ink";
|
|
34176
|
+
import { jsx as jsx63, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
33356
34177
|
function DebugModeScreen({ onDone }) {
|
|
33357
|
-
const [loading, setLoading] =
|
|
33358
|
-
const [enabled, setEnabled] =
|
|
33359
|
-
|
|
34178
|
+
const [loading, setLoading] = useState36(true);
|
|
34179
|
+
const [enabled, setEnabled] = useState36(true);
|
|
34180
|
+
useEffect27(() => {
|
|
33360
34181
|
readDebugModeSetting().then((setting) => {
|
|
33361
34182
|
setEnabled(setting.enabled);
|
|
33362
34183
|
setLoading(false);
|
|
@@ -33368,7 +34189,7 @@ function DebugModeScreen({ onDone }) {
|
|
|
33368
34189
|
});
|
|
33369
34190
|
});
|
|
33370
34191
|
}, []);
|
|
33371
|
-
|
|
34192
|
+
useInput17((input, key) => {
|
|
33372
34193
|
if (loading) return;
|
|
33373
34194
|
if (key.return || input === " ") {
|
|
33374
34195
|
setEnabled((current) => {
|
|
@@ -33383,16 +34204,16 @@ function DebugModeScreen({ onDone }) {
|
|
|
33383
34204
|
onDone();
|
|
33384
34205
|
}
|
|
33385
34206
|
});
|
|
33386
|
-
return /* @__PURE__ */
|
|
33387
|
-
/* @__PURE__ */
|
|
33388
|
-
/* @__PURE__ */
|
|
33389
|
-
loading ? /* @__PURE__ */
|
|
34207
|
+
return /* @__PURE__ */ jsxs52(Box51, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
34208
|
+
/* @__PURE__ */ jsx63(Text54, { bold: true, children: "Settings \u203A Debug Mode" }),
|
|
34209
|
+
/* @__PURE__ */ jsx63(Text54, { children: " " }),
|
|
34210
|
+
loading ? /* @__PURE__ */ jsx63(Text54, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs52(Text54, { children: [
|
|
33390
34211
|
"Debug logging:",
|
|
33391
34212
|
" ",
|
|
33392
|
-
/* @__PURE__ */
|
|
34213
|
+
/* @__PURE__ */ jsx63(Text54, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
33393
34214
|
] }),
|
|
33394
|
-
/* @__PURE__ */
|
|
33395
|
-
/* @__PURE__ */
|
|
34215
|
+
/* @__PURE__ */ jsx63(Text54, { children: " " }),
|
|
34216
|
+
/* @__PURE__ */ jsx63(
|
|
33396
34217
|
ControlHints,
|
|
33397
34218
|
{
|
|
33398
34219
|
hints: [
|
|
@@ -33418,20 +34239,20 @@ var app_exports = {};
|
|
|
33418
34239
|
__export(app_exports, {
|
|
33419
34240
|
runApp: () => runApp
|
|
33420
34241
|
});
|
|
33421
|
-
import { join as
|
|
33422
|
-
import { useEffect as
|
|
33423
|
-
import { Fragment as
|
|
34242
|
+
import { join as join27 } from "node:path";
|
|
34243
|
+
import { useEffect as useEffect28, useState as useState37 } from "react";
|
|
34244
|
+
import { Fragment as Fragment20, jsx as jsx64 } from "react/jsx-runtime";
|
|
33424
34245
|
function App({ importOptions, inkClear }) {
|
|
33425
|
-
const [screen, setScreen] =
|
|
33426
|
-
const [importExitCode, setImportExitCode] =
|
|
34246
|
+
const [screen, setScreen] = useState37("start");
|
|
34247
|
+
const [importExitCode, setImportExitCode] = useState37();
|
|
33427
34248
|
const showImportResult = importExitCode !== void 0;
|
|
33428
|
-
const [projectPath, setProjectPath] =
|
|
33429
|
-
const [tokensPath, setTokensPath] =
|
|
33430
|
-
const [scannedFiles, setScannedFiles] =
|
|
33431
|
-
const [pendingLaunch, setPendingLaunch] =
|
|
33432
|
-
const [extractionRun, setExtractionRun] =
|
|
34249
|
+
const [projectPath, setProjectPath] = useState37();
|
|
34250
|
+
const [tokensPath, setTokensPath] = useState37();
|
|
34251
|
+
const [scannedFiles, setScannedFiles] = useState37();
|
|
34252
|
+
const [pendingLaunch, setPendingLaunch] = useState37();
|
|
34253
|
+
const [extractionRun, setExtractionRun] = useState37();
|
|
33433
34254
|
const extraction = useExtraction(extractionRun?.input);
|
|
33434
|
-
const [scopeRun, setScopeRun] =
|
|
34255
|
+
const [scopeRun, setScopeRun] = useState37();
|
|
33435
34256
|
const scopeFlow = useScopeGateFlow(
|
|
33436
34257
|
scopeRun && {
|
|
33437
34258
|
sessionId: scopeRun.extraction.sessionId,
|
|
@@ -33446,12 +34267,12 @@ function App({ importOptions, inkClear }) {
|
|
|
33446
34267
|
}
|
|
33447
34268
|
}
|
|
33448
34269
|
);
|
|
33449
|
-
const [generationInput, setGenerationInput] =
|
|
34270
|
+
const [generationInput, setGenerationInput] = useState37();
|
|
33450
34271
|
const generation = useGeneration(generationInput);
|
|
33451
|
-
const [flowStart, setFlowStart] =
|
|
34272
|
+
const [flowStart, setFlowStart] = useState37();
|
|
33452
34273
|
const flow = useFlow(flowStart, { beforeStepChange: inkClear });
|
|
33453
|
-
const [importDefaults, setImportDefaults] =
|
|
33454
|
-
|
|
34274
|
+
const [importDefaults, setImportDefaults] = useState37();
|
|
34275
|
+
useEffect28(() => {
|
|
33455
34276
|
if (screen !== "import") {
|
|
33456
34277
|
setImportDefaults(void 0);
|
|
33457
34278
|
return;
|
|
@@ -33469,7 +34290,7 @@ function App({ importOptions, inkClear }) {
|
|
|
33469
34290
|
const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
|
|
33470
34291
|
const state2 = await inspectTokens({
|
|
33471
34292
|
rawTokensPath: tokens,
|
|
33472
|
-
contentfulDir:
|
|
34293
|
+
contentfulDir: join27(resolveUserPath(projectPath2), ".contentful"),
|
|
33473
34294
|
cache: importOptions.cache
|
|
33474
34295
|
});
|
|
33475
34296
|
if (state2.kind === "cached") {
|
|
@@ -33511,12 +34332,12 @@ function App({ importOptions, inkClear }) {
|
|
|
33511
34332
|
}
|
|
33512
34333
|
});
|
|
33513
34334
|
};
|
|
33514
|
-
|
|
34335
|
+
useEffect28(() => {
|
|
33515
34336
|
if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
|
|
33516
34337
|
setExtractionRun(void 0);
|
|
33517
34338
|
setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
|
|
33518
34339
|
}, [extraction, extractionRun]);
|
|
33519
|
-
|
|
34340
|
+
useEffect28(() => {
|
|
33520
34341
|
if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
|
|
33521
34342
|
const { extraction: produced, input, generatePromptPath } = scopeRun;
|
|
33522
34343
|
setGenerationInput({
|
|
@@ -33534,7 +34355,7 @@ function App({ importOptions, inkClear }) {
|
|
|
33534
34355
|
...generatePromptPath ? { generatePromptPath } : {}
|
|
33535
34356
|
});
|
|
33536
34357
|
}, [scopeFlow, scopeRun, generationInput]);
|
|
33537
|
-
|
|
34358
|
+
useEffect28(() => {
|
|
33538
34359
|
if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
|
|
33539
34360
|
const { credentialsSkipped, tokenStrategy, extraction: produced, input, generatePromptPath } = scopeRun;
|
|
33540
34361
|
inkClear();
|
|
@@ -33577,9 +34398,9 @@ function App({ importOptions, inkClear }) {
|
|
|
33577
34398
|
};
|
|
33578
34399
|
switch (screen) {
|
|
33579
34400
|
case "import":
|
|
33580
|
-
if (showImportResult) return /* @__PURE__ */
|
|
34401
|
+
if (showImportResult) return /* @__PURE__ */ jsx64(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
|
|
33581
34402
|
if (flow && flowStart) {
|
|
33582
|
-
return /* @__PURE__ */
|
|
34403
|
+
return /* @__PURE__ */ jsx64(
|
|
33583
34404
|
FlowScreen,
|
|
33584
34405
|
{
|
|
33585
34406
|
state: flow.state,
|
|
@@ -33589,12 +34410,12 @@ function App({ importOptions, inkClear }) {
|
|
|
33589
34410
|
}
|
|
33590
34411
|
);
|
|
33591
34412
|
}
|
|
33592
|
-
if (importDefaults === void 0) return /* @__PURE__ */
|
|
34413
|
+
if (importDefaults === void 0) return /* @__PURE__ */ jsx64(Fragment20, {});
|
|
33593
34414
|
if (projectPath === void 0) {
|
|
33594
|
-
return /* @__PURE__ */
|
|
34415
|
+
return /* @__PURE__ */ jsx64(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
|
|
33595
34416
|
}
|
|
33596
34417
|
if (tokensPath === void 0) {
|
|
33597
|
-
return /* @__PURE__ */
|
|
34418
|
+
return /* @__PURE__ */ jsx64(
|
|
33598
34419
|
TokenInputScreen,
|
|
33599
34420
|
{
|
|
33600
34421
|
initialPath: importDefaults.tokenFile,
|
|
@@ -33604,7 +34425,7 @@ function App({ importOptions, inkClear }) {
|
|
|
33604
34425
|
);
|
|
33605
34426
|
}
|
|
33606
34427
|
if (scannedFiles === void 0) {
|
|
33607
|
-
return /* @__PURE__ */
|
|
34428
|
+
return /* @__PURE__ */ jsx64(
|
|
33608
34429
|
PathValidationScreen,
|
|
33609
34430
|
{
|
|
33610
34431
|
projectPath,
|
|
@@ -33616,10 +34437,10 @@ function App({ importOptions, inkClear }) {
|
|
|
33616
34437
|
}
|
|
33617
34438
|
if (extractionRun) {
|
|
33618
34439
|
if (extraction?.status === "done" && !extraction.result.ok) {
|
|
33619
|
-
return /* @__PURE__ */
|
|
34440
|
+
return /* @__PURE__ */ jsx64(ErrorStep, { stepName: extraction.result.step, message: extraction.result.message, onExit: leaveImport });
|
|
33620
34441
|
}
|
|
33621
34442
|
if (extraction?.status === "running") {
|
|
33622
|
-
return /* @__PURE__ */
|
|
34443
|
+
return /* @__PURE__ */ jsx64(
|
|
33623
34444
|
ExtractionScreen,
|
|
33624
34445
|
{
|
|
33625
34446
|
progress: extraction.progress,
|
|
@@ -33628,14 +34449,14 @@ function App({ importOptions, inkClear }) {
|
|
|
33628
34449
|
}
|
|
33629
34450
|
);
|
|
33630
34451
|
}
|
|
33631
|
-
return /* @__PURE__ */
|
|
34452
|
+
return /* @__PURE__ */ jsx64(Fragment20, {});
|
|
33632
34453
|
}
|
|
33633
34454
|
if (scopeRun && scopeFlow) {
|
|
33634
34455
|
if (scopeFlow.status === "failed") {
|
|
33635
|
-
return /* @__PURE__ */
|
|
34456
|
+
return /* @__PURE__ */ jsx64(ErrorStep, { stepName: "scope gate", message: scopeFlow.message, onExit: leaveImport });
|
|
33636
34457
|
}
|
|
33637
34458
|
if (scopeFlow.status === "deciding") {
|
|
33638
|
-
return /* @__PURE__ */
|
|
34459
|
+
return /* @__PURE__ */ jsx64(
|
|
33639
34460
|
ScopeGateScreen,
|
|
33640
34461
|
{
|
|
33641
34462
|
components: scopeFlow.load.components,
|
|
@@ -33645,7 +34466,7 @@ function App({ importOptions, inkClear }) {
|
|
|
33645
34466
|
);
|
|
33646
34467
|
}
|
|
33647
34468
|
if (generation?.status === "done" && !generation.result.ok) {
|
|
33648
|
-
return /* @__PURE__ */
|
|
34469
|
+
return /* @__PURE__ */ jsx64(ErrorStep, { stepName: generation.result.step, message: generation.result.message, onExit: leaveImport });
|
|
33649
34470
|
}
|
|
33650
34471
|
if (generation?.status === "running") {
|
|
33651
34472
|
const hasRawTokens = scopeRun.input.rawTokensPath !== "";
|
|
@@ -33653,7 +34474,7 @@ function App({ importOptions, inkClear }) {
|
|
|
33653
34474
|
hasRawTokens,
|
|
33654
34475
|
mapTokensEligible: generation.progress.mapTokensEligible
|
|
33655
34476
|
});
|
|
33656
|
-
return /* @__PURE__ */
|
|
34477
|
+
return /* @__PURE__ */ jsx64(
|
|
33657
34478
|
GenerationScreen,
|
|
33658
34479
|
{
|
|
33659
34480
|
progress: generation.progress,
|
|
@@ -33665,10 +34486,10 @@ function App({ importOptions, inkClear }) {
|
|
|
33665
34486
|
}
|
|
33666
34487
|
);
|
|
33667
34488
|
}
|
|
33668
|
-
return /* @__PURE__ */
|
|
34489
|
+
return /* @__PURE__ */ jsx64(Fragment20, {});
|
|
33669
34490
|
}
|
|
33670
34491
|
if (pendingLaunch?.cached) {
|
|
33671
|
-
return /* @__PURE__ */
|
|
34492
|
+
return /* @__PURE__ */ jsx64(
|
|
33672
34493
|
TokenReuseScreen,
|
|
33673
34494
|
{
|
|
33674
34495
|
tokensPath: pendingLaunch.cached.tokensPath,
|
|
@@ -33679,7 +34500,7 @@ function App({ importOptions, inkClear }) {
|
|
|
33679
34500
|
}
|
|
33680
34501
|
);
|
|
33681
34502
|
}
|
|
33682
|
-
return /* @__PURE__ */
|
|
34503
|
+
return /* @__PURE__ */ jsx64(
|
|
33683
34504
|
CredentialsScreen,
|
|
33684
34505
|
{
|
|
33685
34506
|
initial: importDefaults.credentials,
|
|
@@ -33688,19 +34509,19 @@ function App({ importOptions, inkClear }) {
|
|
|
33688
34509
|
}
|
|
33689
34510
|
);
|
|
33690
34511
|
case "help":
|
|
33691
|
-
return /* @__PURE__ */
|
|
34512
|
+
return /* @__PURE__ */ jsx64(HelpScreen, { onDone: goToStart });
|
|
33692
34513
|
case "upgrade":
|
|
33693
|
-
return /* @__PURE__ */
|
|
34514
|
+
return /* @__PURE__ */ jsx64(UpgradeScreen, { onDone: goToStart });
|
|
33694
34515
|
case "settings":
|
|
33695
|
-
return /* @__PURE__ */
|
|
34516
|
+
return /* @__PURE__ */ jsx64(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
|
|
33696
34517
|
case "settings-configuration":
|
|
33697
|
-
return /* @__PURE__ */
|
|
34518
|
+
return /* @__PURE__ */ jsx64(ConfigurationScreen, { onDone: goToSettings });
|
|
33698
34519
|
case "settings-opt-in-analytics":
|
|
33699
|
-
return /* @__PURE__ */
|
|
34520
|
+
return /* @__PURE__ */ jsx64(OptInAnalyticsScreen, { onDone: goToSettings });
|
|
33700
34521
|
case "settings-debug-mode":
|
|
33701
|
-
return /* @__PURE__ */
|
|
34522
|
+
return /* @__PURE__ */ jsx64(DebugModeScreen, { onDone: goToSettings });
|
|
33702
34523
|
case "start":
|
|
33703
|
-
return /* @__PURE__ */
|
|
34524
|
+
return /* @__PURE__ */ jsx64(HomeScreen, { onNavigate: setScreen });
|
|
33704
34525
|
}
|
|
33705
34526
|
}
|
|
33706
34527
|
async function runApp(renderApp, importOptions) {
|
|
@@ -33708,7 +34529,7 @@ async function runApp(renderApp, importOptions) {
|
|
|
33708
34529
|
instance.clear?.();
|
|
33709
34530
|
process.stdout.write("\x1B[H\x1B[0J");
|
|
33710
34531
|
};
|
|
33711
|
-
const instance = renderApp(/* @__PURE__ */
|
|
34532
|
+
const instance = renderApp(/* @__PURE__ */ jsx64(App, { importOptions, inkClear }));
|
|
33712
34533
|
await instance.waitUntilExit();
|
|
33713
34534
|
}
|
|
33714
34535
|
var init_app = __esm({
|
|
@@ -33743,7 +34564,7 @@ var init_app = __esm({
|
|
|
33743
34564
|
// packages/experience-design-system-cli/program.ts
|
|
33744
34565
|
init_src4();
|
|
33745
34566
|
import { readFileSync as readFileSync9 } from "node:fs";
|
|
33746
|
-
import { join as
|
|
34567
|
+
import { join as join28 } from "node:path";
|
|
33747
34568
|
import { Command } from "commander";
|
|
33748
34569
|
|
|
33749
34570
|
// packages/experience-design-system-cli/src/commands/import-options.ts
|
|
@@ -33771,14 +34592,14 @@ function runDevWatch(args) {
|
|
|
33771
34592
|
process.stderr.write("--watch only works from a checkout of the repo (scripts/dev.mjs is not in the package).\n");
|
|
33772
34593
|
return Promise.resolve(1);
|
|
33773
34594
|
}
|
|
33774
|
-
return new Promise((
|
|
34595
|
+
return new Promise((resolve28) => {
|
|
33775
34596
|
const child = spawn3(process.execPath, [script, ...args], { stdio: "inherit" });
|
|
33776
34597
|
process.on("SIGINT", () => void 0);
|
|
33777
|
-
child.on("exit", (code) =>
|
|
34598
|
+
child.on("exit", (code) => resolve28(code ?? 0));
|
|
33778
34599
|
child.on("error", (err) => {
|
|
33779
34600
|
process.stderr.write(`${err.message}
|
|
33780
34601
|
`);
|
|
33781
|
-
|
|
34602
|
+
resolve28(1);
|
|
33782
34603
|
});
|
|
33783
34604
|
});
|
|
33784
34605
|
}
|
|
@@ -33803,11 +34624,13 @@ function registerImportCommand(program, openTui) {
|
|
|
33803
34624
|
}
|
|
33804
34625
|
|
|
33805
34626
|
// packages/experience-design-system-cli/program.ts
|
|
34627
|
+
init_agent_store();
|
|
34628
|
+
init_apply_binary_overrides();
|
|
33806
34629
|
init_analytics_store();
|
|
33807
34630
|
init_package_root();
|
|
33808
34631
|
var pkg = JSON.parse(
|
|
33809
34632
|
readFileSync9(
|
|
33810
|
-
|
|
34633
|
+
join28(findPackageRoot(import.meta.url, "@contentful/experience-design-system-cli"), "package.json"),
|
|
33811
34634
|
"utf8"
|
|
33812
34635
|
)
|
|
33813
34636
|
);
|
|
@@ -33824,6 +34647,7 @@ function createProgram() {
|
|
|
33824
34647
|
const commandChain = chain.join(" ") || actionCommand.name();
|
|
33825
34648
|
const { enabled } = await readAnalyticsSetting();
|
|
33826
34649
|
setPersistedAnalyticsDisabled(!enabled);
|
|
34650
|
+
await readAgentConfig().then(applyBinaryOverrides, () => void 0);
|
|
33827
34651
|
setCliVersion(pkg.version);
|
|
33828
34652
|
noteCommandStart(commandChain);
|
|
33829
34653
|
});
|
|
@@ -33847,7 +34671,7 @@ init_config();
|
|
|
33847
34671
|
init_package_root();
|
|
33848
34672
|
import { existsSync as existsSync11 } from "node:fs";
|
|
33849
34673
|
import { mkdir as mkdir10, readFile as readFile19, rename as rename3, rmdir, unlink } from "node:fs/promises";
|
|
33850
|
-
import { dirname as dirname16, join as
|
|
34674
|
+
import { dirname as dirname16, join as join29 } from "node:path";
|
|
33851
34675
|
var PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
|
|
33852
34676
|
async function readJson(path5) {
|
|
33853
34677
|
try {
|
|
@@ -33858,9 +34682,9 @@ async function readJson(path5) {
|
|
|
33858
34682
|
}
|
|
33859
34683
|
async function migrateOldConfig() {
|
|
33860
34684
|
try {
|
|
33861
|
-
const oldCredentials =
|
|
33862
|
-
const oldRuns =
|
|
33863
|
-
const oldDebugMode =
|
|
34685
|
+
const oldCredentials = join29(oldConfigDir2(), "credentials.json");
|
|
34686
|
+
const oldRuns = join29(oldConfigDir2(), "runs.json");
|
|
34687
|
+
const oldDebugMode = join29(
|
|
33864
34688
|
findPackageRoot(import.meta.url, PACKAGE_NAME3),
|
|
33865
34689
|
".contentful",
|
|
33866
34690
|
"config",
|