poe-code 3.0.218 → 3.0.220
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/models.js +1 -1
- package/dist/index.js +20923 -18750
- package/dist/index.js.map +4 -4
- package/dist/providers/claude-code.js +1032 -698
- package/dist/providers/claude-code.js.map +4 -4
- package/dist/providers/codex.js +1032 -698
- package/dist/providers/codex.js.map +4 -4
- package/dist/providers/goose.js +3027 -2693
- package/dist/providers/goose.js.map +4 -4
- package/dist/providers/kimi.js +1032 -698
- package/dist/providers/kimi.js.map +4 -4
- package/dist/providers/opencode.js +1027 -693
- package/dist/providers/opencode.js.map +4 -4
- package/dist/providers/poe-agent.js +21316 -20880
- package/dist/providers/poe-agent.js.map +4 -4
- package/package.json +1 -1
- package/packages/config-mutations/dist/execution/apply-mutation.js +3 -3
- package/packages/config-mutations/dist/mutations/template-mutation.d.ts +3 -3
- package/packages/config-mutations/dist/template/render.d.ts +0 -1
- package/packages/config-mutations/dist/template/render.js +2 -22
- package/packages/design-system/dist/acp/components.js +15 -13
- package/packages/design-system/dist/components/color.d.ts +31 -0
- package/packages/design-system/dist/components/color.js +101 -0
- package/packages/design-system/dist/components/help-formatter-plain.d.ts +1 -0
- package/packages/design-system/dist/components/help-formatter-plain.js +1 -1
- package/packages/design-system/dist/components/index.d.ts +4 -0
- package/packages/design-system/dist/components/index.js +2 -0
- package/packages/design-system/dist/components/logger.js +2 -2
- package/packages/design-system/dist/components/symbols.js +3 -3
- package/packages/design-system/dist/components/table.js +191 -40
- package/packages/design-system/dist/components/template.d.ts +6 -0
- package/packages/design-system/dist/components/template.js +271 -0
- package/packages/design-system/dist/components/text.d.ts +1 -0
- package/packages/design-system/dist/components/text.js +11 -3
- package/packages/design-system/dist/dashboard/buffer.js +12 -12
- package/packages/design-system/dist/index.d.ts +4 -0
- package/packages/design-system/dist/index.js +2 -0
- package/packages/design-system/dist/internal/color-support.d.ts +9 -0
- package/packages/design-system/dist/internal/color-support.js +12 -0
- package/packages/design-system/dist/prompts/index.js +2 -2
- package/packages/design-system/dist/prompts/primitives/cancel.js +2 -2
- package/packages/design-system/dist/prompts/primitives/intro.js +2 -2
- package/packages/design-system/dist/prompts/primitives/log.js +4 -4
- package/packages/design-system/dist/prompts/primitives/note.js +5 -5
- package/packages/design-system/dist/prompts/primitives/outro.js +2 -2
- package/packages/design-system/dist/prompts/primitives/spinner.js +3 -3
- package/packages/design-system/dist/static/menu.js +5 -5
- package/packages/design-system/dist/static/spinner.js +8 -8
- package/packages/design-system/dist/tokens/colors.js +29 -29
- package/packages/design-system/dist/tokens/typography.js +6 -6
- package/packages/memory/dist/index.js +6329 -5995
- package/packages/memory/dist/index.js.map +4 -4
- package/packages/superintendent/dist/commands/superintendent-group.js +2 -2
- package/packages/superintendent/dist/templates/SKILL_superintendent.md +1 -1
package/dist/providers/codex.js
CHANGED
|
@@ -1700,217 +1700,970 @@ function cloneValue(value) {
|
|
|
1700
1700
|
|
|
1701
1701
|
// packages/config-extends/src/resolve.ts
|
|
1702
1702
|
import path11 from "node:path";
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
const resolvedBase = shouldResolveBase(parsedDocument, options.autoExtend) ? await resolveBaseChain({
|
|
1709
|
-
name: documentLayer.baseName ?? getBaseName(documentLayer.filePath),
|
|
1710
|
-
baseLayers,
|
|
1711
|
-
options,
|
|
1712
|
-
optional: !parsedDocument.extends,
|
|
1713
|
-
visited: /* @__PURE__ */ new Set([documentLayer.filePath]),
|
|
1714
|
-
depth: 1
|
|
1715
|
-
}) : void 0;
|
|
1716
|
-
const composedPrompt = composePromptChain(
|
|
1717
|
-
{
|
|
1718
|
-
source: documentLayer.source,
|
|
1719
|
-
data: parsedDocument.data
|
|
1720
|
-
},
|
|
1721
|
-
resolvedBase?.layers ?? []
|
|
1722
|
-
);
|
|
1723
|
-
const merged = mergeLayers([
|
|
1724
|
-
...collectDataLayers(chain.slice(0, documentIndex)),
|
|
1725
|
-
{
|
|
1726
|
-
source: documentLayer.source,
|
|
1727
|
-
data: withResolvedPrompt(parsedDocument.data, composedPrompt?.prompt)
|
|
1728
|
-
},
|
|
1729
|
-
...stripResolvedBasePrompts(resolvedBase?.layers ?? [], composedPrompt?.consumedBaseIndexes ?? /* @__PURE__ */ new Set()),
|
|
1730
|
-
...collectDataLayers(chain.slice(documentIndex + 1))
|
|
1731
|
-
]);
|
|
1732
|
-
if (composedPrompt !== void 0 && merged.sources.prompt === documentLayer.source && composedPrompt.source !== void 0) {
|
|
1733
|
-
merged.sources.prompt = composedPrompt.source;
|
|
1703
|
+
|
|
1704
|
+
// packages/design-system/src/internal/color-support.ts
|
|
1705
|
+
function supportsColor(env = process.env, stream = process.stdout) {
|
|
1706
|
+
if (env.FORCE_COLOR !== void 0 && env.FORCE_COLOR !== "0") {
|
|
1707
|
+
return true;
|
|
1734
1708
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
sources: merged.sources,
|
|
1738
|
-
chain: [documentLayer.filePath, ...resolvedBase?.chain ?? []]
|
|
1739
|
-
};
|
|
1740
|
-
}
|
|
1741
|
-
function classifyChain(chain) {
|
|
1742
|
-
const baseLayers = [];
|
|
1743
|
-
const documentLayers = [];
|
|
1744
|
-
for (const [index, layer] of chain.entries()) {
|
|
1745
|
-
if (isDataLayer(layer)) {
|
|
1746
|
-
continue;
|
|
1747
|
-
}
|
|
1748
|
-
if (isDocumentLayer(layer)) {
|
|
1749
|
-
documentLayers.push({ index, layer });
|
|
1750
|
-
continue;
|
|
1751
|
-
}
|
|
1752
|
-
if (isBaseLayer(layer)) {
|
|
1753
|
-
baseLayers.push(layer);
|
|
1754
|
-
}
|
|
1709
|
+
if (env.NO_COLOR !== void 0) {
|
|
1710
|
+
return false;
|
|
1755
1711
|
}
|
|
1756
|
-
if (
|
|
1757
|
-
|
|
1712
|
+
if (stream.isTTY !== true) {
|
|
1713
|
+
return false;
|
|
1758
1714
|
}
|
|
1715
|
+
return typeof env.TERM === "string" && env.TERM.length > 0 && env.TERM !== "dumb";
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
// packages/design-system/src/components/color.ts
|
|
1719
|
+
var reset = "\x1B[0m";
|
|
1720
|
+
var ansiStyles = {
|
|
1721
|
+
reset: { open: reset },
|
|
1722
|
+
bold: { open: "\x1B[1m" },
|
|
1723
|
+
dim: { open: "\x1B[2m" },
|
|
1724
|
+
italic: { open: "\x1B[3m" },
|
|
1725
|
+
underline: { open: "\x1B[4m" },
|
|
1726
|
+
inverse: { open: "\x1B[7m" },
|
|
1727
|
+
strikethrough: { open: "\x1B[9m" },
|
|
1728
|
+
black: { open: "\x1B[30m" },
|
|
1729
|
+
red: { open: "\x1B[31m" },
|
|
1730
|
+
green: { open: "\x1B[32m" },
|
|
1731
|
+
yellow: { open: "\x1B[33m" },
|
|
1732
|
+
blue: { open: "\x1B[34m" },
|
|
1733
|
+
magenta: { open: "\x1B[35m" },
|
|
1734
|
+
cyan: { open: "\x1B[36m" },
|
|
1735
|
+
white: { open: "\x1B[37m" },
|
|
1736
|
+
gray: { open: "\x1B[90m" },
|
|
1737
|
+
magentaBright: { open: "\x1B[95m" },
|
|
1738
|
+
cyanBright: { open: "\x1B[96m" },
|
|
1739
|
+
bgRed: { open: "\x1B[41m" },
|
|
1740
|
+
bgGreen: { open: "\x1B[42m" },
|
|
1741
|
+
bgYellow: { open: "\x1B[43m" },
|
|
1742
|
+
bgBlue: { open: "\x1B[44m" },
|
|
1743
|
+
bgMagenta: { open: "\x1B[45m" }
|
|
1744
|
+
};
|
|
1745
|
+
var styleNames = Object.keys(ansiStyles);
|
|
1746
|
+
function replaceAll(value, search, replacement) {
|
|
1747
|
+
return value.split(search).join(replacement);
|
|
1748
|
+
}
|
|
1749
|
+
function applyStyles(text5, styles) {
|
|
1750
|
+
if (!supportsColor() || styles.length === 0) {
|
|
1751
|
+
return text5;
|
|
1752
|
+
}
|
|
1753
|
+
const open4 = styles.map((style) => style.open).join("");
|
|
1754
|
+
const output = text5.includes(reset) ? replaceAll(text5, reset, `${reset}${open4}`) : text5;
|
|
1755
|
+
return `${open4}${output}${reset}`;
|
|
1756
|
+
}
|
|
1757
|
+
function clampRgb(value) {
|
|
1758
|
+
if (Number.isNaN(value)) {
|
|
1759
|
+
return 0;
|
|
1760
|
+
}
|
|
1761
|
+
return Math.min(255, Math.max(0, Math.round(value)));
|
|
1762
|
+
}
|
|
1763
|
+
function hexChannel(value, offset) {
|
|
1764
|
+
return Number.parseInt(value.slice(offset, offset + 2), 16);
|
|
1765
|
+
}
|
|
1766
|
+
function normalizeHex(value) {
|
|
1767
|
+
const normalized = value.startsWith("#") ? value.slice(1) : value;
|
|
1768
|
+
if (normalized.length === 3) {
|
|
1769
|
+
const red = normalized[0];
|
|
1770
|
+
const green = normalized[1];
|
|
1771
|
+
const blue = normalized[2];
|
|
1772
|
+
return [
|
|
1773
|
+
Number.parseInt(`${red}${red}`, 16),
|
|
1774
|
+
Number.parseInt(`${green}${green}`, 16),
|
|
1775
|
+
Number.parseInt(`${blue}${blue}`, 16)
|
|
1776
|
+
];
|
|
1777
|
+
}
|
|
1778
|
+
if (normalized.length === 6) {
|
|
1779
|
+
return [
|
|
1780
|
+
hexChannel(normalized, 0),
|
|
1781
|
+
hexChannel(normalized, 2),
|
|
1782
|
+
hexChannel(normalized, 4)
|
|
1783
|
+
];
|
|
1784
|
+
}
|
|
1785
|
+
return [0, 0, 0];
|
|
1786
|
+
}
|
|
1787
|
+
function rgbStyle(red, green, blue) {
|
|
1759
1788
|
return {
|
|
1760
|
-
|
|
1761
|
-
documentIndex: documentLayers[0].index,
|
|
1762
|
-
documentLayer: documentLayers[0].layer
|
|
1789
|
+
open: `\x1B[38;2;${clampRgb(red)};${clampRgb(green)};${clampRgb(blue)}m`
|
|
1763
1790
|
};
|
|
1764
1791
|
}
|
|
1765
|
-
|
|
1766
|
-
name,
|
|
1767
|
-
baseLayers,
|
|
1768
|
-
options,
|
|
1769
|
-
optional,
|
|
1770
|
-
visited,
|
|
1771
|
-
depth
|
|
1772
|
-
}) {
|
|
1773
|
-
if (depth > MAX_EXTENDS_DEPTH) {
|
|
1774
|
-
throw new Error(`Maximum extends depth exceeded (${MAX_EXTENDS_DEPTH}).`);
|
|
1775
|
-
}
|
|
1776
|
-
let discoveredBase;
|
|
1777
|
-
try {
|
|
1778
|
-
discoveredBase = await findBase(
|
|
1779
|
-
name,
|
|
1780
|
-
baseLayers.map((layer) => layer.path),
|
|
1781
|
-
options.fs
|
|
1782
|
-
);
|
|
1783
|
-
} catch (error2) {
|
|
1784
|
-
if (optional && isBaseNotFoundError(error2)) {
|
|
1785
|
-
return void 0;
|
|
1786
|
-
}
|
|
1787
|
-
throw error2;
|
|
1788
|
-
}
|
|
1789
|
-
if (visited.has(discoveredBase.filePath)) {
|
|
1790
|
-
if (optional) {
|
|
1791
|
-
return void 0;
|
|
1792
|
-
}
|
|
1793
|
-
throw new Error(
|
|
1794
|
-
`Circular extends detected.
|
|
1795
|
-
Visited files:
|
|
1796
|
-
- ${[...visited, discoveredBase.filePath].join("\n- ")}`
|
|
1797
|
-
);
|
|
1798
|
-
}
|
|
1799
|
-
const matchedBaseIndex = baseLayers.findIndex(
|
|
1800
|
-
(layer) => layer.path === path11.dirname(discoveredBase.filePath)
|
|
1801
|
-
);
|
|
1802
|
-
if (matchedBaseIndex === -1) {
|
|
1803
|
-
throw new Error(`Resolved base is outside configured base paths: ${discoveredBase.filePath}`);
|
|
1804
|
-
}
|
|
1805
|
-
const parsedBase = parseDocument3(discoveredBase.content, discoveredBase.filePath);
|
|
1806
|
-
const nextVisited = new Set(visited);
|
|
1807
|
-
nextVisited.add(discoveredBase.filePath);
|
|
1808
|
-
const nestedBase = parsedBase.extends ? await resolveBaseChain({
|
|
1809
|
-
name: getBaseName(discoveredBase.filePath),
|
|
1810
|
-
baseLayers: baseLayers.slice(matchedBaseIndex + 1),
|
|
1811
|
-
options,
|
|
1812
|
-
optional: false,
|
|
1813
|
-
visited: nextVisited,
|
|
1814
|
-
depth: depth + 1
|
|
1815
|
-
}) : void 0;
|
|
1792
|
+
function bgRgbStyle(red, green, blue) {
|
|
1816
1793
|
return {
|
|
1817
|
-
|
|
1818
|
-
{
|
|
1819
|
-
source: baseLayers[matchedBaseIndex].source,
|
|
1820
|
-
data: parsedBase.data
|
|
1821
|
-
},
|
|
1822
|
-
...nestedBase?.layers ?? []
|
|
1823
|
-
],
|
|
1824
|
-
chain: [discoveredBase.filePath, ...nestedBase?.chain ?? []]
|
|
1794
|
+
open: `\x1B[48;2;${clampRgb(red)};${clampRgb(green)};${clampRgb(blue)}m`
|
|
1825
1795
|
};
|
|
1826
1796
|
}
|
|
1827
|
-
function
|
|
1828
|
-
|
|
1797
|
+
function createColor(styles = []) {
|
|
1798
|
+
const builder = ((text5) => applyStyles(String(text5), styles));
|
|
1799
|
+
for (const name of styleNames) {
|
|
1800
|
+
Object.defineProperty(builder, name, {
|
|
1801
|
+
configurable: true,
|
|
1802
|
+
enumerable: true,
|
|
1803
|
+
get: () => createColor([...styles, ansiStyles[name]])
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
builder.hex = (value) => {
|
|
1807
|
+
const [red, green, blue] = normalizeHex(value);
|
|
1808
|
+
return createColor([...styles, rgbStyle(red, green, blue)]);
|
|
1809
|
+
};
|
|
1810
|
+
builder.rgb = (red, green, blue) => createColor([...styles, rgbStyle(red, green, blue)]);
|
|
1811
|
+
builder.bgHex = (value) => {
|
|
1812
|
+
const [red, green, blue] = normalizeHex(value);
|
|
1813
|
+
return createColor([...styles, bgRgbStyle(red, green, blue)]);
|
|
1814
|
+
};
|
|
1815
|
+
builder.bgRgb = (red, green, blue) => createColor([...styles, bgRgbStyle(red, green, blue)]);
|
|
1816
|
+
return builder;
|
|
1829
1817
|
}
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1818
|
+
var color = createColor();
|
|
1819
|
+
|
|
1820
|
+
// packages/design-system/src/tokens/colors.ts
|
|
1821
|
+
var dark = {
|
|
1822
|
+
header: (text5) => color.magentaBright.bold(text5),
|
|
1823
|
+
divider: (text5) => color.dim(text5),
|
|
1824
|
+
prompt: (text5) => color.cyan(text5),
|
|
1825
|
+
number: (text5) => color.cyanBright(text5),
|
|
1826
|
+
intro: (text5) => color.bgMagenta.white(` Poe - ${text5} `),
|
|
1827
|
+
resolvedSymbol: color.magenta("\u25C7"),
|
|
1828
|
+
errorSymbol: color.red("\u25A0"),
|
|
1829
|
+
accent: (text5) => color.cyan(text5),
|
|
1830
|
+
muted: (text5) => color.dim(text5),
|
|
1831
|
+
success: (text5) => color.green(text5),
|
|
1832
|
+
warning: (text5) => color.yellow(text5),
|
|
1833
|
+
error: (text5) => color.red(text5),
|
|
1834
|
+
info: (text5) => color.magenta(text5),
|
|
1835
|
+
badge: (text5) => color.bgYellow.black(` ${text5} `)
|
|
1836
|
+
};
|
|
1837
|
+
var light = {
|
|
1838
|
+
header: (text5) => color.hex("#a200ff").bold(text5),
|
|
1839
|
+
divider: (text5) => color.hex("#666666")(text5),
|
|
1840
|
+
prompt: (text5) => color.hex("#006699").bold(text5),
|
|
1841
|
+
number: (text5) => color.hex("#0077cc").bold(text5),
|
|
1842
|
+
intro: (text5) => color.bgHex("#a200ff").white(` Poe - ${text5} `),
|
|
1843
|
+
resolvedSymbol: color.hex("#a200ff")("\u25C7"),
|
|
1844
|
+
errorSymbol: color.hex("#cc0000")("\u25A0"),
|
|
1845
|
+
accent: (text5) => color.hex("#006699").bold(text5),
|
|
1846
|
+
muted: (text5) => color.hex("#666666")(text5),
|
|
1847
|
+
success: (text5) => color.hex("#008800")(text5),
|
|
1848
|
+
warning: (text5) => color.hex("#cc6600")(text5),
|
|
1849
|
+
error: (text5) => color.hex("#cc0000")(text5),
|
|
1850
|
+
info: (text5) => color.hex("#a200ff")(text5),
|
|
1851
|
+
badge: (text5) => color.bgHex("#cc6600").white(` ${text5} `)
|
|
1852
|
+
};
|
|
1853
|
+
|
|
1854
|
+
// packages/design-system/src/internal/output-format.ts
|
|
1855
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
1856
|
+
var VALID_FORMATS = /* @__PURE__ */ new Set(["terminal", "markdown", "json"]);
|
|
1857
|
+
var formatStorage = new AsyncLocalStorage();
|
|
1858
|
+
var cached;
|
|
1859
|
+
function resolveOutputFormat(env = process.env) {
|
|
1860
|
+
const scoped = formatStorage.getStore();
|
|
1861
|
+
if (scoped) {
|
|
1862
|
+
return scoped;
|
|
1834
1863
|
}
|
|
1835
|
-
if (
|
|
1836
|
-
|
|
1864
|
+
if (cached) {
|
|
1865
|
+
return cached;
|
|
1837
1866
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1867
|
+
const raw = env.OUTPUT_FORMAT?.toLowerCase();
|
|
1868
|
+
cached = VALID_FORMATS.has(raw) ? raw : "terminal";
|
|
1869
|
+
return cached;
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
// packages/design-system/src/internal/theme-detect.ts
|
|
1873
|
+
function detectThemeFromEnv(env) {
|
|
1874
|
+
const apple = env.APPLE_INTERFACE_STYLE;
|
|
1875
|
+
if (typeof apple === "string") {
|
|
1876
|
+
return apple.toLowerCase() === "dark" ? "dark" : "light";
|
|
1877
|
+
}
|
|
1878
|
+
const vscodeKind = env.VSCODE_COLOR_THEME_KIND;
|
|
1879
|
+
if (typeof vscodeKind === "string") {
|
|
1880
|
+
const normalized = vscodeKind.toLowerCase();
|
|
1881
|
+
if (normalized.includes("light")) {
|
|
1882
|
+
return "light";
|
|
1848
1883
|
}
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
prompt = composeAdjacentPrompts(prompt, candidate);
|
|
1852
|
-
if (source === void 0 && candidate !== "") {
|
|
1853
|
-
source = layer.source;
|
|
1884
|
+
if (normalized.includes("dark")) {
|
|
1885
|
+
return "dark";
|
|
1854
1886
|
}
|
|
1855
1887
|
}
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1888
|
+
const colorFGBG = env.COLORFGBG;
|
|
1889
|
+
if (typeof colorFGBG === "string") {
|
|
1890
|
+
const parts = colorFGBG.split(";").map((part) => Number.parseInt(part, 10));
|
|
1891
|
+
const background = parts.at(-1);
|
|
1892
|
+
if (Number.isFinite(background)) {
|
|
1893
|
+
return background >= 8 ? "light" : "dark";
|
|
1894
|
+
}
|
|
1861
1895
|
}
|
|
1862
|
-
return
|
|
1863
|
-
consumedBaseIndexes,
|
|
1864
|
-
prompt,
|
|
1865
|
-
source
|
|
1866
|
-
};
|
|
1896
|
+
return void 0;
|
|
1867
1897
|
}
|
|
1868
|
-
function
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
if (high.includes(YIELD_TOKEN)) {
|
|
1873
|
-
return replaceYield(high, low);
|
|
1874
|
-
}
|
|
1875
|
-
if (low.includes(YIELD_TOKEN)) {
|
|
1876
|
-
return replaceYield(low, high);
|
|
1898
|
+
function resolveThemeName(env = process.env) {
|
|
1899
|
+
const raw = (env.POE_CODE_THEME ?? env.POE_THEME)?.toLowerCase();
|
|
1900
|
+
if (raw === "light" || raw === "dark") {
|
|
1901
|
+
return raw;
|
|
1877
1902
|
}
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
return prompt.replace(YIELD_TOKEN, replacement);
|
|
1882
|
-
}
|
|
1883
|
-
function assertValidYieldCount(prompt) {
|
|
1884
|
-
if (countYieldTokens(prompt) > 1) {
|
|
1885
|
-
throw new Error('Prompt composition supports exactly one "{{yield}}" token per prompt.');
|
|
1903
|
+
const detected = detectThemeFromEnv(env);
|
|
1904
|
+
if (detected) {
|
|
1905
|
+
return detected;
|
|
1886
1906
|
}
|
|
1907
|
+
return "dark";
|
|
1887
1908
|
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
if (prompt === void 0) {
|
|
1893
|
-
return data;
|
|
1909
|
+
var cachedTheme;
|
|
1910
|
+
function getTheme(env) {
|
|
1911
|
+
if (cachedTheme) {
|
|
1912
|
+
return cachedTheme;
|
|
1894
1913
|
}
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
};
|
|
1899
|
-
}
|
|
1900
|
-
function stripResolvedBasePrompts(layers, consumedBaseIndexes) {
|
|
1901
|
-
return layers.map((layer, index) => {
|
|
1902
|
-
if (!consumedBaseIndexes.has(index) || typeof layer.data.prompt !== "string") {
|
|
1903
|
-
return layer;
|
|
1904
|
-
}
|
|
1905
|
-
const { prompt: ignoredPrompt, ...data } = layer.data;
|
|
1906
|
-
void ignoredPrompt;
|
|
1907
|
-
return {
|
|
1908
|
-
source: layer.source,
|
|
1909
|
-
data
|
|
1910
|
-
};
|
|
1911
|
-
});
|
|
1914
|
+
const themeName = resolveThemeName(env);
|
|
1915
|
+
cachedTheme = themeName === "light" ? light : dark;
|
|
1916
|
+
return cachedTheme;
|
|
1912
1917
|
}
|
|
1913
|
-
|
|
1918
|
+
|
|
1919
|
+
// packages/design-system/src/components/symbols.ts
|
|
1920
|
+
var symbols = {
|
|
1921
|
+
get info() {
|
|
1922
|
+
const format = resolveOutputFormat();
|
|
1923
|
+
if (format === "json") return "info";
|
|
1924
|
+
if (format === "markdown") return "(i)";
|
|
1925
|
+
return color.magenta("\u25CF");
|
|
1926
|
+
},
|
|
1927
|
+
get success() {
|
|
1928
|
+
const format = resolveOutputFormat();
|
|
1929
|
+
if (format === "json") return "success";
|
|
1930
|
+
if (format === "markdown") return "[ok]";
|
|
1931
|
+
return color.magenta("\u25C6");
|
|
1932
|
+
},
|
|
1933
|
+
get resolved() {
|
|
1934
|
+
const format = resolveOutputFormat();
|
|
1935
|
+
if (format === "json") return "resolved";
|
|
1936
|
+
if (format === "markdown") return ">";
|
|
1937
|
+
return getTheme().resolvedSymbol;
|
|
1938
|
+
},
|
|
1939
|
+
get errorResolved() {
|
|
1940
|
+
const format = resolveOutputFormat();
|
|
1941
|
+
if (format === "json") return "error";
|
|
1942
|
+
if (format === "markdown") return "[!]";
|
|
1943
|
+
return getTheme().errorSymbol;
|
|
1944
|
+
},
|
|
1945
|
+
get bar() {
|
|
1946
|
+
const format = resolveOutputFormat();
|
|
1947
|
+
if (format === "json") return "";
|
|
1948
|
+
if (format === "markdown") return "|";
|
|
1949
|
+
return "\u2502";
|
|
1950
|
+
},
|
|
1951
|
+
cornerTopRight: "\u256E",
|
|
1952
|
+
cornerBottomRight: "\u256F",
|
|
1953
|
+
get warning() {
|
|
1954
|
+
const format = resolveOutputFormat();
|
|
1955
|
+
if (format === "json") return "warning";
|
|
1956
|
+
if (format === "markdown") return "[!]";
|
|
1957
|
+
return "\u25B2";
|
|
1958
|
+
},
|
|
1959
|
+
get active() {
|
|
1960
|
+
const format = resolveOutputFormat();
|
|
1961
|
+
if (format === "json") return "active";
|
|
1962
|
+
if (format === "markdown") return "[x]";
|
|
1963
|
+
return "\u25C6";
|
|
1964
|
+
},
|
|
1965
|
+
get inactive() {
|
|
1966
|
+
const format = resolveOutputFormat();
|
|
1967
|
+
if (format === "json") return "inactive";
|
|
1968
|
+
if (format === "markdown") return "[ ]";
|
|
1969
|
+
return "\u25CB";
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
|
|
1973
|
+
// packages/design-system/src/internal/strip-ansi.ts
|
|
1974
|
+
function stripAnsi(value) {
|
|
1975
|
+
return value.replace(/\u001b\[[0-9;]*m/g, "");
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
// packages/design-system/src/prompts/primitives/log.ts
|
|
1979
|
+
function writeTerminalMessage(msg, {
|
|
1980
|
+
symbol = color.gray("\u2502"),
|
|
1981
|
+
secondarySymbol = color.gray("\u2502"),
|
|
1982
|
+
spacing: spacing2 = 1,
|
|
1983
|
+
withGuide = true
|
|
1984
|
+
} = {}) {
|
|
1985
|
+
const lines = [];
|
|
1986
|
+
const showGuide = withGuide !== false;
|
|
1987
|
+
const contentLines = msg.split("\n");
|
|
1988
|
+
const prefix = showGuide ? `${symbol} ` : "";
|
|
1989
|
+
const continuationPrefix = showGuide ? `${secondarySymbol} ` : "";
|
|
1990
|
+
const emptyGuide = showGuide ? secondarySymbol : "";
|
|
1991
|
+
for (let index = 0; index < spacing2; index += 1) {
|
|
1992
|
+
lines.push(emptyGuide);
|
|
1993
|
+
}
|
|
1994
|
+
if (contentLines.length === 0) {
|
|
1995
|
+
process.stdout.write("\n");
|
|
1996
|
+
return;
|
|
1997
|
+
}
|
|
1998
|
+
const [firstLine = "", ...continuationLines] = contentLines;
|
|
1999
|
+
if (firstLine.length > 0) {
|
|
2000
|
+
lines.push(`${prefix}${firstLine}`);
|
|
2001
|
+
} else {
|
|
2002
|
+
lines.push(showGuide ? symbol : "");
|
|
2003
|
+
}
|
|
2004
|
+
for (const line of continuationLines) {
|
|
2005
|
+
if (line.length > 0) {
|
|
2006
|
+
lines.push(`${continuationPrefix}${line}`);
|
|
2007
|
+
continue;
|
|
2008
|
+
}
|
|
2009
|
+
lines.push(emptyGuide);
|
|
2010
|
+
}
|
|
2011
|
+
process.stdout.write(`${lines.join("\n")}
|
|
2012
|
+
`);
|
|
2013
|
+
}
|
|
2014
|
+
function message(msg, options) {
|
|
2015
|
+
const format = resolveOutputFormat();
|
|
2016
|
+
if (format === "markdown") {
|
|
2017
|
+
process.stdout.write(`- ${stripAnsi(msg)}
|
|
2018
|
+
`);
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
if (format === "json") {
|
|
2022
|
+
process.stdout.write(
|
|
2023
|
+
`${JSON.stringify({ level: "message", message: stripAnsi(msg) })}
|
|
2024
|
+
`
|
|
2025
|
+
);
|
|
2026
|
+
return;
|
|
2027
|
+
}
|
|
2028
|
+
writeTerminalMessage(msg, options);
|
|
2029
|
+
}
|
|
2030
|
+
function info(msg) {
|
|
2031
|
+
const format = resolveOutputFormat();
|
|
2032
|
+
if (format === "markdown") {
|
|
2033
|
+
process.stdout.write(`- **info:** ${stripAnsi(msg)}
|
|
2034
|
+
`);
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
2037
|
+
if (format === "json") {
|
|
2038
|
+
process.stdout.write(
|
|
2039
|
+
`${JSON.stringify({ level: "info", message: stripAnsi(msg) })}
|
|
2040
|
+
`
|
|
2041
|
+
);
|
|
2042
|
+
return;
|
|
2043
|
+
}
|
|
2044
|
+
message(msg, { symbol: symbols.info });
|
|
2045
|
+
}
|
|
2046
|
+
function success(msg) {
|
|
2047
|
+
const format = resolveOutputFormat();
|
|
2048
|
+
if (format === "markdown") {
|
|
2049
|
+
process.stdout.write(`- **success:** ${stripAnsi(msg)}
|
|
2050
|
+
`);
|
|
2051
|
+
return;
|
|
2052
|
+
}
|
|
2053
|
+
if (format === "json") {
|
|
2054
|
+
process.stdout.write(
|
|
2055
|
+
`${JSON.stringify({ level: "success", message: stripAnsi(msg) })}
|
|
2056
|
+
`
|
|
2057
|
+
);
|
|
2058
|
+
return;
|
|
2059
|
+
}
|
|
2060
|
+
message(msg, { symbol: symbols.success });
|
|
2061
|
+
}
|
|
2062
|
+
function warn(msg) {
|
|
2063
|
+
const format = resolveOutputFormat();
|
|
2064
|
+
if (format === "markdown") {
|
|
2065
|
+
process.stdout.write(`- **warning:** ${stripAnsi(msg)}
|
|
2066
|
+
`);
|
|
2067
|
+
return;
|
|
2068
|
+
}
|
|
2069
|
+
if (format === "json") {
|
|
2070
|
+
process.stdout.write(
|
|
2071
|
+
`${JSON.stringify({ level: "warn", message: stripAnsi(msg) })}
|
|
2072
|
+
`
|
|
2073
|
+
);
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
message(msg, { symbol: color.yellow("\u25B2") });
|
|
2077
|
+
}
|
|
2078
|
+
function error(msg) {
|
|
2079
|
+
const format = resolveOutputFormat();
|
|
2080
|
+
if (format === "markdown") {
|
|
2081
|
+
process.stdout.write(`- **error:** ${stripAnsi(msg)}
|
|
2082
|
+
`);
|
|
2083
|
+
return;
|
|
2084
|
+
}
|
|
2085
|
+
if (format === "json") {
|
|
2086
|
+
process.stdout.write(
|
|
2087
|
+
`${JSON.stringify({ level: "error", message: stripAnsi(msg) })}
|
|
2088
|
+
`
|
|
2089
|
+
);
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2092
|
+
message(msg, { symbol: color.red("\u25A0") });
|
|
2093
|
+
}
|
|
2094
|
+
var log = {
|
|
2095
|
+
info,
|
|
2096
|
+
success,
|
|
2097
|
+
message,
|
|
2098
|
+
warn,
|
|
2099
|
+
error
|
|
2100
|
+
};
|
|
2101
|
+
|
|
2102
|
+
// packages/design-system/src/components/logger.ts
|
|
2103
|
+
function createLogger(emitter) {
|
|
2104
|
+
const emit = (level, message2) => {
|
|
2105
|
+
if (emitter) {
|
|
2106
|
+
emitter(message2);
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
if (level === "success") {
|
|
2110
|
+
log.success(message2);
|
|
2111
|
+
return;
|
|
2112
|
+
}
|
|
2113
|
+
if (level === "warn") {
|
|
2114
|
+
log.warn(message2);
|
|
2115
|
+
return;
|
|
2116
|
+
}
|
|
2117
|
+
if (level === "error") {
|
|
2118
|
+
log.error(message2);
|
|
2119
|
+
return;
|
|
2120
|
+
}
|
|
2121
|
+
log.info(message2);
|
|
2122
|
+
};
|
|
2123
|
+
return {
|
|
2124
|
+
info(message2) {
|
|
2125
|
+
emit("info", message2);
|
|
2126
|
+
},
|
|
2127
|
+
success(message2) {
|
|
2128
|
+
emit("success", message2);
|
|
2129
|
+
},
|
|
2130
|
+
warn(message2) {
|
|
2131
|
+
emit("warn", message2);
|
|
2132
|
+
},
|
|
2133
|
+
error(message2) {
|
|
2134
|
+
emit("error", message2);
|
|
2135
|
+
},
|
|
2136
|
+
resolved(label, value) {
|
|
2137
|
+
if (emitter) {
|
|
2138
|
+
emitter(`${label}: ${value}`);
|
|
2139
|
+
return;
|
|
2140
|
+
}
|
|
2141
|
+
log.message(`${label}
|
|
2142
|
+
${value}`, { symbol: symbols.resolved });
|
|
2143
|
+
},
|
|
2144
|
+
errorResolved(label, value) {
|
|
2145
|
+
if (emitter) {
|
|
2146
|
+
emitter(`${label}: ${value}`);
|
|
2147
|
+
return;
|
|
2148
|
+
}
|
|
2149
|
+
log.message(`${label}
|
|
2150
|
+
${value}`, { symbol: symbols.errorResolved });
|
|
2151
|
+
},
|
|
2152
|
+
message(message2, symbol) {
|
|
2153
|
+
if (emitter) {
|
|
2154
|
+
emitter(message2);
|
|
2155
|
+
return;
|
|
2156
|
+
}
|
|
2157
|
+
log.message(message2, { symbol: symbol ?? color.gray("\u2502") });
|
|
2158
|
+
}
|
|
2159
|
+
};
|
|
2160
|
+
}
|
|
2161
|
+
var logger = createLogger();
|
|
2162
|
+
|
|
2163
|
+
// packages/design-system/src/components/table.ts
|
|
2164
|
+
var graphemeSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
2165
|
+
|
|
2166
|
+
// packages/design-system/src/components/template.ts
|
|
2167
|
+
var HTML_ESCAPE = {
|
|
2168
|
+
"&": "&",
|
|
2169
|
+
"<": "<",
|
|
2170
|
+
">": ">",
|
|
2171
|
+
'"': """,
|
|
2172
|
+
"'": "'",
|
|
2173
|
+
"/": "/",
|
|
2174
|
+
"`": "`",
|
|
2175
|
+
"=": "="
|
|
2176
|
+
};
|
|
2177
|
+
function renderTemplate(template, view, options = {}) {
|
|
2178
|
+
const prepared = options.yield === void 0 ? template : template.split("{{yield}}").join(options.yield);
|
|
2179
|
+
const tokens = parseTemplate(prepared);
|
|
2180
|
+
const escape = options.escape === "none" ? String : escapeHtml;
|
|
2181
|
+
const preserveMissing = options.yield !== void 0 && options.escape === "none";
|
|
2182
|
+
return renderTokens(tokens, { view }, prepared, escape, preserveMissing);
|
|
2183
|
+
}
|
|
2184
|
+
function renderTemplateInContext(template, context, escape, preserveMissing) {
|
|
2185
|
+
return renderTokens(parseTemplate(template), context, template, escape, preserveMissing);
|
|
2186
|
+
}
|
|
2187
|
+
function parseTemplate(template) {
|
|
2188
|
+
const root = [];
|
|
2189
|
+
const stack = [];
|
|
2190
|
+
let tokens = root;
|
|
2191
|
+
let index = 0;
|
|
2192
|
+
while (index < template.length) {
|
|
2193
|
+
const open4 = template.indexOf("{{", index);
|
|
2194
|
+
if (open4 === -1) {
|
|
2195
|
+
appendText(tokens, template.slice(index), index);
|
|
2196
|
+
break;
|
|
2197
|
+
}
|
|
2198
|
+
appendText(tokens, template.slice(index, open4), index);
|
|
2199
|
+
const parsed = parseTag(template, open4);
|
|
2200
|
+
const standalone = getStandalone(template, open4, parsed.end, parsed.kind);
|
|
2201
|
+
if (standalone !== void 0) {
|
|
2202
|
+
trimTextAfter(tokens, standalone.lineStart);
|
|
2203
|
+
}
|
|
2204
|
+
if (parsed.kind === "comment") {
|
|
2205
|
+
index = standalone?.nextIndex ?? parsed.end;
|
|
2206
|
+
continue;
|
|
2207
|
+
}
|
|
2208
|
+
if (parsed.kind === "partial") {
|
|
2209
|
+
throw new Error(`Partials are not supported: "${parsed.name}"`);
|
|
2210
|
+
}
|
|
2211
|
+
if (parsed.kind === "delimiter") {
|
|
2212
|
+
throw new Error("Custom delimiters are not supported");
|
|
2213
|
+
}
|
|
2214
|
+
if (parsed.kind === "section" || parsed.kind === "inverted") {
|
|
2215
|
+
const token = {
|
|
2216
|
+
type: parsed.kind,
|
|
2217
|
+
name: parsed.name,
|
|
2218
|
+
children: [],
|
|
2219
|
+
rawStart: parsed.end,
|
|
2220
|
+
rawEnd: standalone?.lineStart ?? open4
|
|
2221
|
+
};
|
|
2222
|
+
tokens.push(token);
|
|
2223
|
+
stack.push({ token, parent: tokens });
|
|
2224
|
+
tokens = token.children;
|
|
2225
|
+
index = standalone?.nextIndex ?? parsed.end;
|
|
2226
|
+
continue;
|
|
2227
|
+
}
|
|
2228
|
+
if (parsed.kind === "close") {
|
|
2229
|
+
const frame2 = stack.pop();
|
|
2230
|
+
if (frame2 === void 0) {
|
|
2231
|
+
throw new Error(`Closing unopened section "${parsed.name}"`);
|
|
2232
|
+
}
|
|
2233
|
+
if (frame2.token.name !== parsed.name) {
|
|
2234
|
+
throw new Error(`Unclosed section "${frame2.token.name}" before closing "${parsed.name}"`);
|
|
2235
|
+
}
|
|
2236
|
+
frame2.token.rawEnd = open4;
|
|
2237
|
+
tokens = frame2.parent;
|
|
2238
|
+
index = standalone?.nextIndex ?? parsed.end;
|
|
2239
|
+
continue;
|
|
2240
|
+
}
|
|
2241
|
+
tokens.push({ type: parsed.kind, name: parsed.name, raw: template.slice(open4, parsed.end) });
|
|
2242
|
+
index = parsed.end;
|
|
2243
|
+
}
|
|
2244
|
+
const frame = stack.pop();
|
|
2245
|
+
if (frame !== void 0) {
|
|
2246
|
+
throw new Error(`Unclosed section "${frame.token.name}"`);
|
|
2247
|
+
}
|
|
2248
|
+
return root;
|
|
2249
|
+
}
|
|
2250
|
+
function parseTag(template, open4) {
|
|
2251
|
+
if (template.startsWith("{{{", open4)) {
|
|
2252
|
+
const close2 = template.indexOf("}}}", open4 + 3);
|
|
2253
|
+
if (close2 === -1) {
|
|
2254
|
+
throw new Error("Unclosed unescaped tag");
|
|
2255
|
+
}
|
|
2256
|
+
return { kind: "unescaped", name: template.slice(open4 + 3, close2).trim(), end: close2 + 3 };
|
|
2257
|
+
}
|
|
2258
|
+
const close = template.indexOf("}}", open4 + 2);
|
|
2259
|
+
if (close === -1) {
|
|
2260
|
+
throw new Error("Unclosed tag");
|
|
2261
|
+
}
|
|
2262
|
+
const raw = template.slice(open4 + 2, close).trim();
|
|
2263
|
+
const sigil = raw[0];
|
|
2264
|
+
const name = sigil === void 0 ? "" : raw.slice(1).trim();
|
|
2265
|
+
const end = close + 2;
|
|
2266
|
+
if (sigil === "#") return { kind: "section", name, end };
|
|
2267
|
+
if (sigil === "^") return { kind: "inverted", name, end };
|
|
2268
|
+
if (sigil === "/") return { kind: "close", name, end };
|
|
2269
|
+
if (sigil === "!") return { kind: "comment", name, end };
|
|
2270
|
+
if (sigil === "&") return { kind: "unescaped", name, end };
|
|
2271
|
+
if (sigil === ">") return { kind: "partial", name, end };
|
|
2272
|
+
if (sigil === "=" && raw.endsWith("=")) return { kind: "delimiter", name, end };
|
|
2273
|
+
return { kind: "name", name: raw, end };
|
|
2274
|
+
}
|
|
2275
|
+
function getStandalone(template, tagStart, tagEnd, kind) {
|
|
2276
|
+
if (!["section", "inverted", "close", "comment", "partial", "delimiter"].includes(kind)) {
|
|
2277
|
+
return void 0;
|
|
2278
|
+
}
|
|
2279
|
+
const lineStart = template.lastIndexOf("\n", tagStart - 1) + 1;
|
|
2280
|
+
if (!isWhitespace(template.slice(lineStart, tagStart))) {
|
|
2281
|
+
return void 0;
|
|
2282
|
+
}
|
|
2283
|
+
let cursor = tagEnd;
|
|
2284
|
+
while (cursor < template.length && (template[cursor] === " " || template[cursor] === " ")) {
|
|
2285
|
+
cursor += 1;
|
|
2286
|
+
}
|
|
2287
|
+
if (template.startsWith("\r\n", cursor)) {
|
|
2288
|
+
return { lineStart, nextIndex: cursor + 2 };
|
|
2289
|
+
}
|
|
2290
|
+
if (template[cursor] === "\n") {
|
|
2291
|
+
return { lineStart, nextIndex: cursor + 1 };
|
|
2292
|
+
}
|
|
2293
|
+
if (cursor === template.length) {
|
|
2294
|
+
return { lineStart, nextIndex: cursor };
|
|
2295
|
+
}
|
|
2296
|
+
return void 0;
|
|
2297
|
+
}
|
|
2298
|
+
function renderTokens(tokens, context, template, escape, preserveMissing) {
|
|
2299
|
+
let output = "";
|
|
2300
|
+
for (const token of tokens) {
|
|
2301
|
+
switch (token.type) {
|
|
2302
|
+
case "text":
|
|
2303
|
+
output += token.value;
|
|
2304
|
+
continue;
|
|
2305
|
+
case "name":
|
|
2306
|
+
case "unescaped": {
|
|
2307
|
+
const value = lookup2(context, token.name);
|
|
2308
|
+
if (value == null) {
|
|
2309
|
+
if (preserveMissing) {
|
|
2310
|
+
output += token.raw;
|
|
2311
|
+
}
|
|
2312
|
+
continue;
|
|
2313
|
+
}
|
|
2314
|
+
const rendered = String(value);
|
|
2315
|
+
output += token.type === "name" ? escape(rendered) : rendered;
|
|
2316
|
+
continue;
|
|
2317
|
+
}
|
|
2318
|
+
case "inverted": {
|
|
2319
|
+
const value = lookup2(context, token.name);
|
|
2320
|
+
if (!value || Array.isArray(value) && value.length === 0) {
|
|
2321
|
+
output += renderTokens(token.children, context, template, escape, preserveMissing);
|
|
2322
|
+
}
|
|
2323
|
+
continue;
|
|
2324
|
+
}
|
|
2325
|
+
case "section": {
|
|
2326
|
+
const value = lookup2(context, token.name);
|
|
2327
|
+
if (!value) {
|
|
2328
|
+
continue;
|
|
2329
|
+
}
|
|
2330
|
+
if (Array.isArray(value)) {
|
|
2331
|
+
for (const item of value) {
|
|
2332
|
+
output += renderTokens(token.children, pushContext(context, item), template, escape, preserveMissing);
|
|
2333
|
+
}
|
|
2334
|
+
continue;
|
|
2335
|
+
}
|
|
2336
|
+
if (typeof value === "function") {
|
|
2337
|
+
const raw = template.slice(token.rawStart, token.rawEnd);
|
|
2338
|
+
const rendered = value.call(
|
|
2339
|
+
context.view,
|
|
2340
|
+
raw,
|
|
2341
|
+
(nextTemplate) => renderTemplateInContext(nextTemplate, context, escape, preserveMissing)
|
|
2342
|
+
);
|
|
2343
|
+
if (rendered != null) {
|
|
2344
|
+
output += String(rendered);
|
|
2345
|
+
}
|
|
2346
|
+
continue;
|
|
2347
|
+
}
|
|
2348
|
+
if (typeof value === "object" || typeof value === "string" || typeof value === "number") {
|
|
2349
|
+
output += renderTokens(token.children, pushContext(context, value), template, escape, preserveMissing);
|
|
2350
|
+
continue;
|
|
2351
|
+
}
|
|
2352
|
+
output += renderTokens(token.children, context, template, escape, preserveMissing);
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
return output;
|
|
2357
|
+
}
|
|
2358
|
+
function lookup2(context, name) {
|
|
2359
|
+
if (name === ".") {
|
|
2360
|
+
return callLambda(context.view, context.view);
|
|
2361
|
+
}
|
|
2362
|
+
let cursor = context;
|
|
2363
|
+
while (cursor !== void 0) {
|
|
2364
|
+
const result = name.includes(".") ? lookupDotted(cursor.view, name) : lookupName(cursor.view, name);
|
|
2365
|
+
if (result.hit) {
|
|
2366
|
+
return callLambda(result.value, cursor.view);
|
|
2367
|
+
}
|
|
2368
|
+
cursor = cursor.parent;
|
|
2369
|
+
}
|
|
2370
|
+
return void 0;
|
|
2371
|
+
}
|
|
2372
|
+
function lookupName(view, name) {
|
|
2373
|
+
if (!isPropertyContainer(view) || !hasProperty(view, name)) {
|
|
2374
|
+
return { hit: false, value: void 0 };
|
|
2375
|
+
}
|
|
2376
|
+
return { hit: true, value: view[name] };
|
|
2377
|
+
}
|
|
2378
|
+
function lookupDotted(view, name) {
|
|
2379
|
+
const parts = name.split(".");
|
|
2380
|
+
let value = view;
|
|
2381
|
+
let hit = false;
|
|
2382
|
+
for (let index = 0; value != null && index < parts.length; index += 1) {
|
|
2383
|
+
const part = parts[index] ?? "";
|
|
2384
|
+
if (index === parts.length - 1) {
|
|
2385
|
+
hit = hasProperty(Object(value), part);
|
|
2386
|
+
}
|
|
2387
|
+
value = Object(value)[part];
|
|
2388
|
+
}
|
|
2389
|
+
return { hit, value };
|
|
2390
|
+
}
|
|
2391
|
+
function callLambda(value, view) {
|
|
2392
|
+
return typeof value === "function" ? value.call(view) : value;
|
|
2393
|
+
}
|
|
2394
|
+
function pushContext(parent, view) {
|
|
2395
|
+
return { view, parent };
|
|
2396
|
+
}
|
|
2397
|
+
function appendText(tokens, value, start) {
|
|
2398
|
+
if (value === "") {
|
|
2399
|
+
return;
|
|
2400
|
+
}
|
|
2401
|
+
const previous = tokens[tokens.length - 1];
|
|
2402
|
+
if (previous?.type === "text") {
|
|
2403
|
+
previous.value += value;
|
|
2404
|
+
return;
|
|
2405
|
+
}
|
|
2406
|
+
tokens.push({ type: "text", value, start });
|
|
2407
|
+
}
|
|
2408
|
+
function trimTextAfter(tokens, lineStart) {
|
|
2409
|
+
const previous = tokens[tokens.length - 1];
|
|
2410
|
+
if (previous?.type !== "text") {
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
const keep = Math.max(0, lineStart - previous.start);
|
|
2414
|
+
previous.value = previous.value.slice(0, keep);
|
|
2415
|
+
if (previous.value === "") {
|
|
2416
|
+
tokens.pop();
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
function escapeHtml(value) {
|
|
2420
|
+
return value.replace(/[&<>"'`=/]/g, (char) => HTML_ESCAPE[char] ?? char);
|
|
2421
|
+
}
|
|
2422
|
+
function isWhitespace(value) {
|
|
2423
|
+
return value.trim() === "";
|
|
2424
|
+
}
|
|
2425
|
+
function isPropertyContainer(value) {
|
|
2426
|
+
return typeof value === "object" && value !== null || typeof value === "function";
|
|
2427
|
+
}
|
|
2428
|
+
function hasProperty(value, key) {
|
|
2429
|
+
return key in value;
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
// packages/design-system/src/acp/writer.ts
|
|
2433
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
2434
|
+
var storage = new AsyncLocalStorage2();
|
|
2435
|
+
|
|
2436
|
+
// packages/design-system/src/dashboard/terminal.ts
|
|
2437
|
+
import readline from "node:readline";
|
|
2438
|
+
import { PassThrough } from "node:stream";
|
|
2439
|
+
|
|
2440
|
+
// packages/design-system/src/explorer/state.ts
|
|
2441
|
+
var REGION_HEADER = 1 << 0;
|
|
2442
|
+
var REGION_LIST = 1 << 1;
|
|
2443
|
+
var REGION_DETAIL = 1 << 2;
|
|
2444
|
+
var REGION_FOOTER = 1 << 3;
|
|
2445
|
+
var REGION_MODAL = 1 << 4;
|
|
2446
|
+
var REGION_TOAST = 1 << 5;
|
|
2447
|
+
var REGION_ALL = REGION_HEADER | REGION_LIST | REGION_DETAIL | REGION_FOOTER | REGION_MODAL | REGION_TOAST;
|
|
2448
|
+
|
|
2449
|
+
// packages/design-system/src/prompts/index.ts
|
|
2450
|
+
import * as clack from "@clack/prompts";
|
|
2451
|
+
|
|
2452
|
+
// packages/design-system/src/prompts/primitives/cancel.ts
|
|
2453
|
+
import { isCancel } from "@clack/prompts";
|
|
2454
|
+
|
|
2455
|
+
// packages/config-extends/src/resolve.ts
|
|
2456
|
+
var MAX_EXTENDS_DEPTH = 5;
|
|
2457
|
+
var YIELD_TOKEN = "{{yield}}";
|
|
2458
|
+
async function resolve(chain, options) {
|
|
2459
|
+
const { baseLayers, documentIndex, documentLayer } = classifyChain(chain);
|
|
2460
|
+
const parsedDocument = parseDocument3(documentLayer.content, documentLayer.filePath);
|
|
2461
|
+
const resolvedBase = shouldResolveBase(parsedDocument, options.autoExtend) ? await resolveBaseChain({
|
|
2462
|
+
name: documentLayer.baseName ?? getBaseName(documentLayer.filePath),
|
|
2463
|
+
baseLayers,
|
|
2464
|
+
options,
|
|
2465
|
+
optional: !parsedDocument.extends,
|
|
2466
|
+
visited: /* @__PURE__ */ new Set([documentLayer.filePath]),
|
|
2467
|
+
depth: 1
|
|
2468
|
+
}) : void 0;
|
|
2469
|
+
const composedPrompt = composePromptChain(
|
|
2470
|
+
{
|
|
2471
|
+
source: documentLayer.source,
|
|
2472
|
+
data: parsedDocument.data
|
|
2473
|
+
},
|
|
2474
|
+
resolvedBase?.layers ?? []
|
|
2475
|
+
);
|
|
2476
|
+
const merged = mergeLayers([
|
|
2477
|
+
...collectDataLayers(chain.slice(0, documentIndex)),
|
|
2478
|
+
{
|
|
2479
|
+
source: documentLayer.source,
|
|
2480
|
+
data: withResolvedPrompt(parsedDocument.data, composedPrompt?.prompt)
|
|
2481
|
+
},
|
|
2482
|
+
...stripResolvedBasePrompts(resolvedBase?.layers ?? [], composedPrompt?.consumedBaseIndexes ?? /* @__PURE__ */ new Set()),
|
|
2483
|
+
...collectDataLayers(chain.slice(documentIndex + 1))
|
|
2484
|
+
]);
|
|
2485
|
+
if (composedPrompt !== void 0 && merged.sources.prompt === documentLayer.source && composedPrompt.source !== void 0) {
|
|
2486
|
+
merged.sources.prompt = composedPrompt.source;
|
|
2487
|
+
}
|
|
2488
|
+
return {
|
|
2489
|
+
data: merged.data,
|
|
2490
|
+
sources: merged.sources,
|
|
2491
|
+
chain: [documentLayer.filePath, ...resolvedBase?.chain ?? []]
|
|
2492
|
+
};
|
|
2493
|
+
}
|
|
2494
|
+
function classifyChain(chain) {
|
|
2495
|
+
const baseLayers = [];
|
|
2496
|
+
const documentLayers = [];
|
|
2497
|
+
for (const [index, layer] of chain.entries()) {
|
|
2498
|
+
if (isDataLayer(layer)) {
|
|
2499
|
+
continue;
|
|
2500
|
+
}
|
|
2501
|
+
if (isDocumentLayer(layer)) {
|
|
2502
|
+
documentLayers.push({ index, layer });
|
|
2503
|
+
continue;
|
|
2504
|
+
}
|
|
2505
|
+
if (isBaseLayer(layer)) {
|
|
2506
|
+
baseLayers.push(layer);
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
if (documentLayers.length !== 1) {
|
|
2510
|
+
throw new Error(`Exactly one document layer is required, received ${documentLayers.length}.`);
|
|
2511
|
+
}
|
|
2512
|
+
return {
|
|
2513
|
+
baseLayers,
|
|
2514
|
+
documentIndex: documentLayers[0].index,
|
|
2515
|
+
documentLayer: documentLayers[0].layer
|
|
2516
|
+
};
|
|
2517
|
+
}
|
|
2518
|
+
async function resolveBaseChain({
|
|
2519
|
+
name,
|
|
2520
|
+
baseLayers,
|
|
2521
|
+
options,
|
|
2522
|
+
optional,
|
|
2523
|
+
visited,
|
|
2524
|
+
depth
|
|
2525
|
+
}) {
|
|
2526
|
+
if (depth > MAX_EXTENDS_DEPTH) {
|
|
2527
|
+
throw new Error(`Maximum extends depth exceeded (${MAX_EXTENDS_DEPTH}).`);
|
|
2528
|
+
}
|
|
2529
|
+
let discoveredBase;
|
|
2530
|
+
try {
|
|
2531
|
+
discoveredBase = await findBase(
|
|
2532
|
+
name,
|
|
2533
|
+
baseLayers.map((layer) => layer.path),
|
|
2534
|
+
options.fs
|
|
2535
|
+
);
|
|
2536
|
+
} catch (error2) {
|
|
2537
|
+
if (optional && isBaseNotFoundError(error2)) {
|
|
2538
|
+
return void 0;
|
|
2539
|
+
}
|
|
2540
|
+
throw error2;
|
|
2541
|
+
}
|
|
2542
|
+
if (visited.has(discoveredBase.filePath)) {
|
|
2543
|
+
if (optional) {
|
|
2544
|
+
return void 0;
|
|
2545
|
+
}
|
|
2546
|
+
throw new Error(
|
|
2547
|
+
`Circular extends detected.
|
|
2548
|
+
Visited files:
|
|
2549
|
+
- ${[...visited, discoveredBase.filePath].join("\n- ")}`
|
|
2550
|
+
);
|
|
2551
|
+
}
|
|
2552
|
+
const matchedBaseIndex = baseLayers.findIndex(
|
|
2553
|
+
(layer) => layer.path === path11.dirname(discoveredBase.filePath)
|
|
2554
|
+
);
|
|
2555
|
+
if (matchedBaseIndex === -1) {
|
|
2556
|
+
throw new Error(`Resolved base is outside configured base paths: ${discoveredBase.filePath}`);
|
|
2557
|
+
}
|
|
2558
|
+
const parsedBase = parseDocument3(discoveredBase.content, discoveredBase.filePath);
|
|
2559
|
+
const nextVisited = new Set(visited);
|
|
2560
|
+
nextVisited.add(discoveredBase.filePath);
|
|
2561
|
+
const nestedBase = parsedBase.extends ? await resolveBaseChain({
|
|
2562
|
+
name: getBaseName(discoveredBase.filePath),
|
|
2563
|
+
baseLayers: baseLayers.slice(matchedBaseIndex + 1),
|
|
2564
|
+
options,
|
|
2565
|
+
optional: false,
|
|
2566
|
+
visited: nextVisited,
|
|
2567
|
+
depth: depth + 1
|
|
2568
|
+
}) : void 0;
|
|
2569
|
+
return {
|
|
2570
|
+
layers: [
|
|
2571
|
+
{
|
|
2572
|
+
source: baseLayers[matchedBaseIndex].source,
|
|
2573
|
+
data: parsedBase.data
|
|
2574
|
+
},
|
|
2575
|
+
...nestedBase?.layers ?? []
|
|
2576
|
+
],
|
|
2577
|
+
chain: [discoveredBase.filePath, ...nestedBase?.chain ?? []]
|
|
2578
|
+
};
|
|
2579
|
+
}
|
|
2580
|
+
function collectDataLayers(chain) {
|
|
2581
|
+
return chain.filter(isDataLayer);
|
|
2582
|
+
}
|
|
2583
|
+
function composePromptChain(documentLayer, baseLayers) {
|
|
2584
|
+
const documentPrompt = documentLayer.data.prompt;
|
|
2585
|
+
if (documentPrompt !== void 0 && typeof documentPrompt !== "string") {
|
|
2586
|
+
return void 0;
|
|
2587
|
+
}
|
|
2588
|
+
if (documentPrompt !== void 0) {
|
|
2589
|
+
assertValidYieldCount(documentPrompt);
|
|
2590
|
+
}
|
|
2591
|
+
let prompt = documentPrompt;
|
|
2592
|
+
let source = prompt === void 0 || prompt === "" ? void 0 : documentLayer.source;
|
|
2593
|
+
const consumedBaseIndexes = /* @__PURE__ */ new Set();
|
|
2594
|
+
for (const [index, layer] of baseLayers.entries()) {
|
|
2595
|
+
const candidate = layer.data.prompt;
|
|
2596
|
+
if (candidate === void 0) {
|
|
2597
|
+
continue;
|
|
2598
|
+
}
|
|
2599
|
+
if (typeof candidate !== "string") {
|
|
2600
|
+
break;
|
|
2601
|
+
}
|
|
2602
|
+
assertValidYieldCount(candidate);
|
|
2603
|
+
consumedBaseIndexes.add(index);
|
|
2604
|
+
prompt = composeAdjacentPrompts(prompt, candidate);
|
|
2605
|
+
if (source === void 0 && candidate !== "") {
|
|
2606
|
+
source = layer.source;
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
if (prompt !== void 0 && prompt.includes(YIELD_TOKEN)) {
|
|
2610
|
+
throw new Error('Final resolved prompt contains an unresolved "{{yield}}" token.');
|
|
2611
|
+
}
|
|
2612
|
+
if (prompt === void 0) {
|
|
2613
|
+
return void 0;
|
|
2614
|
+
}
|
|
2615
|
+
return {
|
|
2616
|
+
consumedBaseIndexes,
|
|
2617
|
+
prompt,
|
|
2618
|
+
source
|
|
2619
|
+
};
|
|
2620
|
+
}
|
|
2621
|
+
function composeAdjacentPrompts(high, low) {
|
|
2622
|
+
if (high === void 0 || high === "") {
|
|
2623
|
+
return low.includes(YIELD_TOKEN) ? replaceYield(low, "") : low;
|
|
2624
|
+
}
|
|
2625
|
+
if (high.includes(YIELD_TOKEN)) {
|
|
2626
|
+
return replaceYield(high, low);
|
|
2627
|
+
}
|
|
2628
|
+
if (low.includes(YIELD_TOKEN)) {
|
|
2629
|
+
return replaceYield(low, high);
|
|
2630
|
+
}
|
|
2631
|
+
return high;
|
|
2632
|
+
}
|
|
2633
|
+
function replaceYield(prompt, replacement) {
|
|
2634
|
+
return renderTemplate(prompt, {}, { yield: replacement, escape: "none" });
|
|
2635
|
+
}
|
|
2636
|
+
function assertValidYieldCount(prompt) {
|
|
2637
|
+
if (countYieldTokens(prompt) > 1) {
|
|
2638
|
+
throw new Error('Prompt composition supports exactly one "{{yield}}" token per prompt.');
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
function countYieldTokens(prompt) {
|
|
2642
|
+
return prompt.split(YIELD_TOKEN).length - 1;
|
|
2643
|
+
}
|
|
2644
|
+
function withResolvedPrompt(data, prompt) {
|
|
2645
|
+
if (prompt === void 0) {
|
|
2646
|
+
return data;
|
|
2647
|
+
}
|
|
2648
|
+
return {
|
|
2649
|
+
...data,
|
|
2650
|
+
prompt
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
function stripResolvedBasePrompts(layers, consumedBaseIndexes) {
|
|
2654
|
+
return layers.map((layer, index) => {
|
|
2655
|
+
if (!consumedBaseIndexes.has(index) || typeof layer.data.prompt !== "string") {
|
|
2656
|
+
return layer;
|
|
2657
|
+
}
|
|
2658
|
+
const { prompt: ignoredPrompt, ...data } = layer.data;
|
|
2659
|
+
void ignoredPrompt;
|
|
2660
|
+
return {
|
|
2661
|
+
source: layer.source,
|
|
2662
|
+
data
|
|
2663
|
+
};
|
|
2664
|
+
});
|
|
2665
|
+
}
|
|
2666
|
+
function getBaseName(filePath) {
|
|
1914
2667
|
return path11.basename(filePath, path11.extname(filePath));
|
|
1915
2668
|
}
|
|
1916
2669
|
function shouldResolveBase(parsedDocument, autoExtend) {
|
|
@@ -2047,15 +2800,12 @@ var templateMutation = {
|
|
|
2047
2800
|
mergeJson
|
|
2048
2801
|
};
|
|
2049
2802
|
|
|
2050
|
-
// packages/config-mutations/src/execution/apply-mutation.ts
|
|
2051
|
-
import Mustache from "mustache";
|
|
2052
|
-
|
|
2053
2803
|
// packages/config-mutations/src/formats/json.ts
|
|
2054
2804
|
import * as jsonc from "jsonc-parser";
|
|
2055
2805
|
function isConfigObject(value) {
|
|
2056
2806
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2057
2807
|
}
|
|
2058
|
-
function
|
|
2808
|
+
function parse3(content) {
|
|
2059
2809
|
if (!content || content.trim() === "") {
|
|
2060
2810
|
return {};
|
|
2061
2811
|
}
|
|
@@ -2128,7 +2878,7 @@ function prune2(obj, shape) {
|
|
|
2128
2878
|
return { changed, result };
|
|
2129
2879
|
}
|
|
2130
2880
|
var jsonFormat = {
|
|
2131
|
-
parse:
|
|
2881
|
+
parse: parse3,
|
|
2132
2882
|
serialize,
|
|
2133
2883
|
merge: merge2,
|
|
2134
2884
|
prune: prune2
|
|
@@ -2139,7 +2889,7 @@ import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
|
|
|
2139
2889
|
function isConfigObject2(value) {
|
|
2140
2890
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2141
2891
|
}
|
|
2142
|
-
function
|
|
2892
|
+
function parse4(content) {
|
|
2143
2893
|
if (!content || content.trim() === "") {
|
|
2144
2894
|
return {};
|
|
2145
2895
|
}
|
|
@@ -2203,7 +2953,7 @@ function prune3(obj, shape) {
|
|
|
2203
2953
|
return { changed, result };
|
|
2204
2954
|
}
|
|
2205
2955
|
var tomlFormat = {
|
|
2206
|
-
parse:
|
|
2956
|
+
parse: parse4,
|
|
2207
2957
|
serialize: serialize2,
|
|
2208
2958
|
merge: merge3,
|
|
2209
2959
|
prune: prune3
|
|
@@ -2214,7 +2964,7 @@ import { parse as parseYaml2, stringify as stringifyYaml } from "yaml";
|
|
|
2214
2964
|
function isConfigObject3(value) {
|
|
2215
2965
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2216
2966
|
}
|
|
2217
|
-
function
|
|
2967
|
+
function parse5(content) {
|
|
2218
2968
|
if (!content || content.trim() === "") {
|
|
2219
2969
|
return {};
|
|
2220
2970
|
}
|
|
@@ -2278,7 +3028,7 @@ function prune4(obj, shape) {
|
|
|
2278
3028
|
return { changed, result };
|
|
2279
3029
|
}
|
|
2280
3030
|
var yamlFormat = {
|
|
2281
|
-
parse:
|
|
3031
|
+
parse: parse5,
|
|
2282
3032
|
serialize: serialize3,
|
|
2283
3033
|
merge: merge4,
|
|
2284
3034
|
prune: prune4
|
|
@@ -2853,7 +3603,7 @@ async function applyTemplateWrite(mutation, context, options) {
|
|
|
2853
3603
|
};
|
|
2854
3604
|
const template = await context.templates(mutation.templateId);
|
|
2855
3605
|
const templateContext = mutation.context ? resolveValue(mutation.context, options) : {};
|
|
2856
|
-
const rendered =
|
|
3606
|
+
const rendered = renderTemplate(template, templateContext);
|
|
2857
3607
|
const existed = await pathExists(context.fs, targetPath);
|
|
2858
3608
|
if (!context.dryRun) {
|
|
2859
3609
|
await context.fs.writeFile(targetPath, rendered, { encoding: "utf8" });
|
|
@@ -2883,7 +3633,7 @@ async function applyTemplateMerge(mutation, context, options, formatName) {
|
|
|
2883
3633
|
const format = getConfigFormat(formatName);
|
|
2884
3634
|
const template = await context.templates(mutation.templateId);
|
|
2885
3635
|
const templateContext = mutation.context ? resolveValue(mutation.context, options) : {};
|
|
2886
|
-
const rendered =
|
|
3636
|
+
const rendered = renderTemplate(template, templateContext);
|
|
2887
3637
|
let templateDoc;
|
|
2888
3638
|
try {
|
|
2889
3639
|
templateDoc = format.parse(rendered);
|
|
@@ -2964,10 +3714,6 @@ async function executeMutation(mutation, context, options) {
|
|
|
2964
3714
|
}
|
|
2965
3715
|
}
|
|
2966
3716
|
|
|
2967
|
-
// packages/config-mutations/src/template/render.ts
|
|
2968
|
-
import Mustache2 from "mustache";
|
|
2969
|
-
var originalEscape = Mustache2.escape;
|
|
2970
|
-
|
|
2971
3717
|
// packages/config-mutations/src/types.ts
|
|
2972
3718
|
function isConfigObject5(value) {
|
|
2973
3719
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -3351,7 +4097,7 @@ import { mkdtempSync as mkdtempSync2, rmSync as rmSync2 } from "node:fs";
|
|
|
3351
4097
|
import { readFile as readFile4, writeFile } from "node:fs/promises";
|
|
3352
4098
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
3353
4099
|
import path20 from "node:path";
|
|
3354
|
-
import { PassThrough, Writable as Writable2 } from "node:stream";
|
|
4100
|
+
import { PassThrough as PassThrough2, Writable as Writable2 } from "node:stream";
|
|
3355
4101
|
|
|
3356
4102
|
// packages/runner-e2b/src/job-handle.ts
|
|
3357
4103
|
import path19 from "node:path";
|
|
@@ -3598,8 +4344,8 @@ function createOpenedE2bEnv(input) {
|
|
|
3598
4344
|
return env;
|
|
3599
4345
|
}
|
|
3600
4346
|
function runE2bCommand(sandbox, spec) {
|
|
3601
|
-
const stdout = spec.stdout === "inherit" ? null : new
|
|
3602
|
-
const stderr = spec.stderr === "inherit" ? null : new
|
|
4347
|
+
const stdout = spec.stdout === "inherit" ? null : new PassThrough2();
|
|
4348
|
+
const stderr = spec.stderr === "inherit" ? null : new PassThrough2();
|
|
3603
4349
|
let e2bHandle = null;
|
|
3604
4350
|
const command = shellCommand([spec.command, ...spec.args ?? []]);
|
|
3605
4351
|
const started = sandbox.commands.run(command, {
|
|
@@ -3673,7 +4419,7 @@ function runE2bCommand(sandbox, spec) {
|
|
|
3673
4419
|
};
|
|
3674
4420
|
}
|
|
3675
4421
|
function runE2bPty(sandbox, spec) {
|
|
3676
|
-
const stdout = new
|
|
4422
|
+
const stdout = new PassThrough2();
|
|
3677
4423
|
let handleRef = null;
|
|
3678
4424
|
const stdin = new Writable2({
|
|
3679
4425
|
write(chunk, _encoding, callback) {
|
|
@@ -4316,9 +5062,9 @@ var allSpawnConfigs = [
|
|
|
4316
5062
|
kimiSpawnConfig,
|
|
4317
5063
|
gooseSpawnConfig
|
|
4318
5064
|
];
|
|
4319
|
-
var
|
|
5065
|
+
var lookup3 = /* @__PURE__ */ new Map();
|
|
4320
5066
|
for (const config of allSpawnConfigs) {
|
|
4321
|
-
|
|
5067
|
+
lookup3.set(config.agentId, config);
|
|
4322
5068
|
}
|
|
4323
5069
|
var acpLookup = /* @__PURE__ */ new Map();
|
|
4324
5070
|
acpLookup.set(openCodeAcpSpawnConfig.agentId, openCodeAcpSpawnConfig);
|
|
@@ -4329,7 +5075,7 @@ function getSpawnConfig(input) {
|
|
|
4329
5075
|
if (!resolvedId) {
|
|
4330
5076
|
return void 0;
|
|
4331
5077
|
}
|
|
4332
|
-
return
|
|
5078
|
+
return lookup3.get(resolvedId);
|
|
4333
5079
|
}
|
|
4334
5080
|
function listMcpSupportedAgents() {
|
|
4335
5081
|
const supported = [];
|
|
@@ -4394,511 +5140,99 @@ function stripModelNamespace(model) {
|
|
|
4394
5140
|
}
|
|
4395
5141
|
|
|
4396
5142
|
// packages/agent-spawn/src/spawn.ts
|
|
4397
|
-
function resolveCliConfig(agentId) {
|
|
4398
|
-
const resolved = resolveConfig(agentId);
|
|
4399
|
-
if (!resolved.spawnConfig) {
|
|
4400
|
-
throw new Error(`Agent "${resolved.agentId}" has no spawn config.`);
|
|
4401
|
-
}
|
|
4402
|
-
if (resolved.spawnConfig.kind !== "cli") {
|
|
4403
|
-
throw new Error(`Agent "${resolved.agentId}" does not support CLI spawn.`);
|
|
4404
|
-
}
|
|
4405
|
-
if (!resolved.binaryName) {
|
|
4406
|
-
throw new Error(`Agent "${resolved.agentId}" has no binaryName.`);
|
|
4407
|
-
}
|
|
4408
|
-
return {
|
|
4409
|
-
agentId: resolved.agentId,
|
|
4410
|
-
binaryName: resolved.binaryName,
|
|
4411
|
-
spawnConfig: resolved.spawnConfig
|
|
4412
|
-
};
|
|
4413
|
-
}
|
|
4414
|
-
function getDefaultArgsPosition(config) {
|
|
4415
|
-
return config.defaultArgsPosition ?? "afterPrompt";
|
|
4416
|
-
}
|
|
4417
|
-
function getMcpArgsPosition(config) {
|
|
4418
|
-
if (config.mcpArgsPosition) {
|
|
4419
|
-
return config.mcpArgsPosition;
|
|
4420
|
-
}
|
|
4421
|
-
return config.mcpArgsBeforeCommand ? "beforeCommand" : "afterCommand";
|
|
4422
|
-
}
|
|
4423
|
-
function buildCliArgs(config, options, stdinMode) {
|
|
4424
|
-
const mcpArgs = getMcpArgs(config, options.mcpServers);
|
|
4425
|
-
const resumeArgs = getResumeArgs(config, options);
|
|
4426
|
-
const defaultArgsPosition = getDefaultArgsPosition(config);
|
|
4427
|
-
const mcpArgsPosition = getMcpArgsPosition(config);
|
|
4428
|
-
const resumeArgsPosition = config.resume?.position ?? "afterPrompt";
|
|
4429
|
-
const args = [];
|
|
4430
|
-
if (mcpArgsPosition === "beforeCommand") {
|
|
4431
|
-
args.push(...mcpArgs);
|
|
4432
|
-
}
|
|
4433
|
-
if (defaultArgsPosition === "beforePrompt") {
|
|
4434
|
-
args.push(...config.defaultArgs);
|
|
4435
|
-
}
|
|
4436
|
-
if (mcpArgsPosition === "beforePrompt") {
|
|
4437
|
-
args.push(...mcpArgs);
|
|
4438
|
-
}
|
|
4439
|
-
if (stdinMode) {
|
|
4440
|
-
args.push(config.promptFlag);
|
|
4441
|
-
if (resumeArgsPosition === "beforePrompt") {
|
|
4442
|
-
args.push(...resumeArgs);
|
|
4443
|
-
}
|
|
4444
|
-
args.push(...stdinMode.omitPrompt ? [] : [options.prompt], ...stdinMode.extraArgs);
|
|
4445
|
-
} else {
|
|
4446
|
-
args.push(config.promptFlag);
|
|
4447
|
-
if (resumeArgsPosition === "beforePrompt") {
|
|
4448
|
-
args.push(...resumeArgs);
|
|
4449
|
-
}
|
|
4450
|
-
args.push(options.prompt);
|
|
4451
|
-
}
|
|
4452
|
-
if (options.model && config.modelFlag) {
|
|
4453
|
-
let model = config.modelStripProviderPrefix ? stripModelNamespace(options.model) : options.model;
|
|
4454
|
-
if (config.modelTransform) model = config.modelTransform(model);
|
|
4455
|
-
args.push(config.modelFlag, model);
|
|
4456
|
-
}
|
|
4457
|
-
if (defaultArgsPosition === "afterPrompt") {
|
|
4458
|
-
args.push(...config.defaultArgs);
|
|
4459
|
-
}
|
|
4460
|
-
if (mcpArgsPosition === "afterCommand") {
|
|
4461
|
-
args.push(...mcpArgs);
|
|
4462
|
-
}
|
|
4463
|
-
const mode = resolveModeConfig(config.modes[options.mode ?? "yolo"]);
|
|
4464
|
-
args.push(...mode.args);
|
|
4465
|
-
if (options.args && options.args.length > 0) {
|
|
4466
|
-
if (resumeArgsPosition === "afterPrompt") {
|
|
4467
|
-
args.push(...resumeArgs);
|
|
4468
|
-
}
|
|
4469
|
-
args.push(...options.args);
|
|
4470
|
-
} else if (resumeArgsPosition === "afterPrompt") {
|
|
4471
|
-
args.push(...resumeArgs);
|
|
4472
|
-
}
|
|
4473
|
-
return { args, env: mode.env };
|
|
4474
|
-
}
|
|
4475
|
-
function getResumeArgs(config, options) {
|
|
4476
|
-
if (!options.resumeThreadId) {
|
|
4477
|
-
return [];
|
|
4478
|
-
}
|
|
4479
|
-
if (!config.resume) {
|
|
4480
|
-
throw new Error(`Agent "${config.agentId}" does not support resumeThreadId.`);
|
|
4481
|
-
}
|
|
4482
|
-
return config.resume.args(options.resumeThreadId, options.cwd ?? process.cwd());
|
|
4483
|
-
}
|
|
4484
|
-
function buildSpawnArgs(agentId, options) {
|
|
4485
|
-
const { binaryName, spawnConfig } = resolveCliConfig(agentId);
|
|
4486
|
-
const stdinMode = options.useStdin && spawnConfig.stdinMode ? spawnConfig.stdinMode : void 0;
|
|
4487
|
-
const result = buildCliArgs(spawnConfig, options, stdinMode);
|
|
4488
|
-
return { binaryName, args: result.args, env: result.env };
|
|
4489
|
-
}
|
|
4490
|
-
|
|
4491
|
-
// packages/design-system/src/tokens/colors.ts
|
|
4492
|
-
import chalk from "chalk";
|
|
4493
|
-
var dark = {
|
|
4494
|
-
header: (text5) => chalk.magentaBright.bold(text5),
|
|
4495
|
-
divider: (text5) => chalk.dim(text5),
|
|
4496
|
-
prompt: (text5) => chalk.cyan(text5),
|
|
4497
|
-
number: (text5) => chalk.cyanBright(text5),
|
|
4498
|
-
intro: (text5) => chalk.bgMagenta.white(` Poe - ${text5} `),
|
|
4499
|
-
resolvedSymbol: chalk.magenta("\u25C7"),
|
|
4500
|
-
errorSymbol: chalk.red("\u25A0"),
|
|
4501
|
-
accent: (text5) => chalk.cyan(text5),
|
|
4502
|
-
muted: (text5) => chalk.dim(text5),
|
|
4503
|
-
success: (text5) => chalk.green(text5),
|
|
4504
|
-
warning: (text5) => chalk.yellow(text5),
|
|
4505
|
-
error: (text5) => chalk.red(text5),
|
|
4506
|
-
info: (text5) => chalk.magenta(text5),
|
|
4507
|
-
badge: (text5) => chalk.bgYellow.black(` ${text5} `)
|
|
4508
|
-
};
|
|
4509
|
-
var light = {
|
|
4510
|
-
header: (text5) => chalk.hex("#a200ff").bold(text5),
|
|
4511
|
-
divider: (text5) => chalk.hex("#666666")(text5),
|
|
4512
|
-
prompt: (text5) => chalk.hex("#006699").bold(text5),
|
|
4513
|
-
number: (text5) => chalk.hex("#0077cc").bold(text5),
|
|
4514
|
-
intro: (text5) => chalk.bgHex("#a200ff").white(` Poe - ${text5} `),
|
|
4515
|
-
resolvedSymbol: chalk.hex("#a200ff")("\u25C7"),
|
|
4516
|
-
errorSymbol: chalk.hex("#cc0000")("\u25A0"),
|
|
4517
|
-
accent: (text5) => chalk.hex("#006699").bold(text5),
|
|
4518
|
-
muted: (text5) => chalk.hex("#666666")(text5),
|
|
4519
|
-
success: (text5) => chalk.hex("#008800")(text5),
|
|
4520
|
-
warning: (text5) => chalk.hex("#cc6600")(text5),
|
|
4521
|
-
error: (text5) => chalk.hex("#cc0000")(text5),
|
|
4522
|
-
info: (text5) => chalk.hex("#a200ff")(text5),
|
|
4523
|
-
badge: (text5) => chalk.bgHex("#cc6600").white(` ${text5} `)
|
|
4524
|
-
};
|
|
4525
|
-
|
|
4526
|
-
// packages/design-system/src/tokens/typography.ts
|
|
4527
|
-
import chalk2 from "chalk";
|
|
4528
|
-
|
|
4529
|
-
// packages/design-system/src/components/text.ts
|
|
4530
|
-
import chalk3 from "chalk";
|
|
4531
|
-
|
|
4532
|
-
// packages/design-system/src/internal/output-format.ts
|
|
4533
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4534
|
-
var VALID_FORMATS = /* @__PURE__ */ new Set(["terminal", "markdown", "json"]);
|
|
4535
|
-
var formatStorage = new AsyncLocalStorage();
|
|
4536
|
-
var cached;
|
|
4537
|
-
function resolveOutputFormat(env = process.env) {
|
|
4538
|
-
const scoped = formatStorage.getStore();
|
|
4539
|
-
if (scoped) {
|
|
4540
|
-
return scoped;
|
|
4541
|
-
}
|
|
4542
|
-
if (cached) {
|
|
4543
|
-
return cached;
|
|
4544
|
-
}
|
|
4545
|
-
const raw = env.OUTPUT_FORMAT?.toLowerCase();
|
|
4546
|
-
cached = VALID_FORMATS.has(raw) ? raw : "terminal";
|
|
4547
|
-
return cached;
|
|
4548
|
-
}
|
|
4549
|
-
|
|
4550
|
-
// packages/design-system/src/internal/theme-detect.ts
|
|
4551
|
-
function detectThemeFromEnv(env) {
|
|
4552
|
-
const apple = env.APPLE_INTERFACE_STYLE;
|
|
4553
|
-
if (typeof apple === "string") {
|
|
4554
|
-
return apple.toLowerCase() === "dark" ? "dark" : "light";
|
|
4555
|
-
}
|
|
4556
|
-
const vscodeKind = env.VSCODE_COLOR_THEME_KIND;
|
|
4557
|
-
if (typeof vscodeKind === "string") {
|
|
4558
|
-
const normalized = vscodeKind.toLowerCase();
|
|
4559
|
-
if (normalized.includes("light")) {
|
|
4560
|
-
return "light";
|
|
4561
|
-
}
|
|
4562
|
-
if (normalized.includes("dark")) {
|
|
4563
|
-
return "dark";
|
|
4564
|
-
}
|
|
4565
|
-
}
|
|
4566
|
-
const colorFGBG = env.COLORFGBG;
|
|
4567
|
-
if (typeof colorFGBG === "string") {
|
|
4568
|
-
const parts = colorFGBG.split(";").map((part) => Number.parseInt(part, 10));
|
|
4569
|
-
const background = parts.at(-1);
|
|
4570
|
-
if (Number.isFinite(background)) {
|
|
4571
|
-
return background >= 8 ? "light" : "dark";
|
|
4572
|
-
}
|
|
4573
|
-
}
|
|
4574
|
-
return void 0;
|
|
4575
|
-
}
|
|
4576
|
-
function resolveThemeName(env = process.env) {
|
|
4577
|
-
const raw = (env.POE_CODE_THEME ?? env.POE_THEME)?.toLowerCase();
|
|
4578
|
-
if (raw === "light" || raw === "dark") {
|
|
4579
|
-
return raw;
|
|
4580
|
-
}
|
|
4581
|
-
const detected = detectThemeFromEnv(env);
|
|
4582
|
-
if (detected) {
|
|
4583
|
-
return detected;
|
|
4584
|
-
}
|
|
4585
|
-
return "dark";
|
|
4586
|
-
}
|
|
4587
|
-
var cachedTheme;
|
|
4588
|
-
function getTheme(env) {
|
|
4589
|
-
if (cachedTheme) {
|
|
4590
|
-
return cachedTheme;
|
|
4591
|
-
}
|
|
4592
|
-
const themeName = resolveThemeName(env);
|
|
4593
|
-
cachedTheme = themeName === "light" ? light : dark;
|
|
4594
|
-
return cachedTheme;
|
|
4595
|
-
}
|
|
4596
|
-
|
|
4597
|
-
// packages/design-system/src/components/symbols.ts
|
|
4598
|
-
import chalk4 from "chalk";
|
|
4599
|
-
var symbols = {
|
|
4600
|
-
get info() {
|
|
4601
|
-
const format = resolveOutputFormat();
|
|
4602
|
-
if (format === "json") return "info";
|
|
4603
|
-
if (format === "markdown") return "(i)";
|
|
4604
|
-
return chalk4.magenta("\u25CF");
|
|
4605
|
-
},
|
|
4606
|
-
get success() {
|
|
4607
|
-
const format = resolveOutputFormat();
|
|
4608
|
-
if (format === "json") return "success";
|
|
4609
|
-
if (format === "markdown") return "[ok]";
|
|
4610
|
-
return chalk4.magenta("\u25C6");
|
|
4611
|
-
},
|
|
4612
|
-
get resolved() {
|
|
4613
|
-
const format = resolveOutputFormat();
|
|
4614
|
-
if (format === "json") return "resolved";
|
|
4615
|
-
if (format === "markdown") return ">";
|
|
4616
|
-
return getTheme().resolvedSymbol;
|
|
4617
|
-
},
|
|
4618
|
-
get errorResolved() {
|
|
4619
|
-
const format = resolveOutputFormat();
|
|
4620
|
-
if (format === "json") return "error";
|
|
4621
|
-
if (format === "markdown") return "[!]";
|
|
4622
|
-
return getTheme().errorSymbol;
|
|
4623
|
-
},
|
|
4624
|
-
get bar() {
|
|
4625
|
-
const format = resolveOutputFormat();
|
|
4626
|
-
if (format === "json") return "";
|
|
4627
|
-
if (format === "markdown") return "|";
|
|
4628
|
-
return "\u2502";
|
|
4629
|
-
},
|
|
4630
|
-
cornerTopRight: "\u256E",
|
|
4631
|
-
cornerBottomRight: "\u256F",
|
|
4632
|
-
get warning() {
|
|
4633
|
-
const format = resolveOutputFormat();
|
|
4634
|
-
if (format === "json") return "warning";
|
|
4635
|
-
if (format === "markdown") return "[!]";
|
|
4636
|
-
return "\u25B2";
|
|
4637
|
-
},
|
|
4638
|
-
get active() {
|
|
4639
|
-
const format = resolveOutputFormat();
|
|
4640
|
-
if (format === "json") return "active";
|
|
4641
|
-
if (format === "markdown") return "[x]";
|
|
4642
|
-
return "\u25C6";
|
|
4643
|
-
},
|
|
4644
|
-
get inactive() {
|
|
4645
|
-
const format = resolveOutputFormat();
|
|
4646
|
-
if (format === "json") return "inactive";
|
|
4647
|
-
if (format === "markdown") return "[ ]";
|
|
4648
|
-
return "\u25CB";
|
|
4649
|
-
}
|
|
4650
|
-
};
|
|
4651
|
-
|
|
4652
|
-
// packages/design-system/src/components/logger.ts
|
|
4653
|
-
import chalk6 from "chalk";
|
|
4654
|
-
|
|
4655
|
-
// packages/design-system/src/prompts/primitives/log.ts
|
|
4656
|
-
import chalk5 from "chalk";
|
|
4657
|
-
|
|
4658
|
-
// packages/design-system/src/internal/strip-ansi.ts
|
|
4659
|
-
function stripAnsi(value) {
|
|
4660
|
-
return value.replace(/\u001b\[[0-9;]*m/g, "");
|
|
4661
|
-
}
|
|
4662
|
-
|
|
4663
|
-
// packages/design-system/src/prompts/primitives/log.ts
|
|
4664
|
-
function writeTerminalMessage(msg, {
|
|
4665
|
-
symbol = chalk5.gray("\u2502"),
|
|
4666
|
-
secondarySymbol = chalk5.gray("\u2502"),
|
|
4667
|
-
spacing: spacing2 = 1,
|
|
4668
|
-
withGuide = true
|
|
4669
|
-
} = {}) {
|
|
4670
|
-
const lines = [];
|
|
4671
|
-
const showGuide = withGuide !== false;
|
|
4672
|
-
const contentLines = msg.split("\n");
|
|
4673
|
-
const prefix = showGuide ? `${symbol} ` : "";
|
|
4674
|
-
const continuationPrefix = showGuide ? `${secondarySymbol} ` : "";
|
|
4675
|
-
const emptyGuide = showGuide ? secondarySymbol : "";
|
|
4676
|
-
for (let index = 0; index < spacing2; index += 1) {
|
|
4677
|
-
lines.push(emptyGuide);
|
|
5143
|
+
function resolveCliConfig(agentId) {
|
|
5144
|
+
const resolved = resolveConfig(agentId);
|
|
5145
|
+
if (!resolved.spawnConfig) {
|
|
5146
|
+
throw new Error(`Agent "${resolved.agentId}" has no spawn config.`);
|
|
4678
5147
|
}
|
|
4679
|
-
if (
|
|
4680
|
-
|
|
4681
|
-
return;
|
|
5148
|
+
if (resolved.spawnConfig.kind !== "cli") {
|
|
5149
|
+
throw new Error(`Agent "${resolved.agentId}" does not support CLI spawn.`);
|
|
4682
5150
|
}
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
lines.push(`${prefix}${firstLine}`);
|
|
4686
|
-
} else {
|
|
4687
|
-
lines.push(showGuide ? symbol : "");
|
|
5151
|
+
if (!resolved.binaryName) {
|
|
5152
|
+
throw new Error(`Agent "${resolved.agentId}" has no binaryName.`);
|
|
4688
5153
|
}
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
5154
|
+
return {
|
|
5155
|
+
agentId: resolved.agentId,
|
|
5156
|
+
binaryName: resolved.binaryName,
|
|
5157
|
+
spawnConfig: resolved.spawnConfig
|
|
5158
|
+
};
|
|
5159
|
+
}
|
|
5160
|
+
function getDefaultArgsPosition(config) {
|
|
5161
|
+
return config.defaultArgsPosition ?? "afterPrompt";
|
|
5162
|
+
}
|
|
5163
|
+
function getMcpArgsPosition(config) {
|
|
5164
|
+
if (config.mcpArgsPosition) {
|
|
5165
|
+
return config.mcpArgsPosition;
|
|
4695
5166
|
}
|
|
4696
|
-
|
|
4697
|
-
`);
|
|
5167
|
+
return config.mcpArgsBeforeCommand ? "beforeCommand" : "afterCommand";
|
|
4698
5168
|
}
|
|
4699
|
-
function
|
|
4700
|
-
const
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
5169
|
+
function buildCliArgs(config, options, stdinMode) {
|
|
5170
|
+
const mcpArgs = getMcpArgs(config, options.mcpServers);
|
|
5171
|
+
const resumeArgs = getResumeArgs(config, options);
|
|
5172
|
+
const defaultArgsPosition = getDefaultArgsPosition(config);
|
|
5173
|
+
const mcpArgsPosition = getMcpArgsPosition(config);
|
|
5174
|
+
const resumeArgsPosition = config.resume?.position ?? "afterPrompt";
|
|
5175
|
+
const args = [];
|
|
5176
|
+
if (mcpArgsPosition === "beforeCommand") {
|
|
5177
|
+
args.push(...mcpArgs);
|
|
4705
5178
|
}
|
|
4706
|
-
if (
|
|
4707
|
-
|
|
4708
|
-
`${JSON.stringify({ level: "message", message: stripAnsi(msg) })}
|
|
4709
|
-
`
|
|
4710
|
-
);
|
|
4711
|
-
return;
|
|
5179
|
+
if (defaultArgsPosition === "beforePrompt") {
|
|
5180
|
+
args.push(...config.defaultArgs);
|
|
4712
5181
|
}
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
function info(msg) {
|
|
4716
|
-
const format = resolveOutputFormat();
|
|
4717
|
-
if (format === "markdown") {
|
|
4718
|
-
process.stdout.write(`- **info:** ${stripAnsi(msg)}
|
|
4719
|
-
`);
|
|
4720
|
-
return;
|
|
5182
|
+
if (mcpArgsPosition === "beforePrompt") {
|
|
5183
|
+
args.push(...mcpArgs);
|
|
4721
5184
|
}
|
|
4722
|
-
if (
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
5185
|
+
if (stdinMode) {
|
|
5186
|
+
args.push(config.promptFlag);
|
|
5187
|
+
if (resumeArgsPosition === "beforePrompt") {
|
|
5188
|
+
args.push(...resumeArgs);
|
|
5189
|
+
}
|
|
5190
|
+
args.push(...stdinMode.omitPrompt ? [] : [options.prompt], ...stdinMode.extraArgs);
|
|
5191
|
+
} else {
|
|
5192
|
+
args.push(config.promptFlag);
|
|
5193
|
+
if (resumeArgsPosition === "beforePrompt") {
|
|
5194
|
+
args.push(...resumeArgs);
|
|
5195
|
+
}
|
|
5196
|
+
args.push(options.prompt);
|
|
4728
5197
|
}
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
if (format === "markdown") {
|
|
4734
|
-
process.stdout.write(`- **success:** ${stripAnsi(msg)}
|
|
4735
|
-
`);
|
|
4736
|
-
return;
|
|
5198
|
+
if (options.model && config.modelFlag) {
|
|
5199
|
+
let model = config.modelStripProviderPrefix ? stripModelNamespace(options.model) : options.model;
|
|
5200
|
+
if (config.modelTransform) model = config.modelTransform(model);
|
|
5201
|
+
args.push(config.modelFlag, model);
|
|
4737
5202
|
}
|
|
4738
|
-
if (
|
|
4739
|
-
|
|
4740
|
-
`${JSON.stringify({ level: "success", message: stripAnsi(msg) })}
|
|
4741
|
-
`
|
|
4742
|
-
);
|
|
4743
|
-
return;
|
|
5203
|
+
if (defaultArgsPosition === "afterPrompt") {
|
|
5204
|
+
args.push(...config.defaultArgs);
|
|
4744
5205
|
}
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
function warn(msg) {
|
|
4748
|
-
const format = resolveOutputFormat();
|
|
4749
|
-
if (format === "markdown") {
|
|
4750
|
-
process.stdout.write(`- **warning:** ${stripAnsi(msg)}
|
|
4751
|
-
`);
|
|
4752
|
-
return;
|
|
5206
|
+
if (mcpArgsPosition === "afterCommand") {
|
|
5207
|
+
args.push(...mcpArgs);
|
|
4753
5208
|
}
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
5209
|
+
const mode = resolveModeConfig(config.modes[options.mode ?? "yolo"]);
|
|
5210
|
+
args.push(...mode.args);
|
|
5211
|
+
if (options.args && options.args.length > 0) {
|
|
5212
|
+
if (resumeArgsPosition === "afterPrompt") {
|
|
5213
|
+
args.push(...resumeArgs);
|
|
5214
|
+
}
|
|
5215
|
+
args.push(...options.args);
|
|
5216
|
+
} else if (resumeArgsPosition === "afterPrompt") {
|
|
5217
|
+
args.push(...resumeArgs);
|
|
4760
5218
|
}
|
|
4761
|
-
|
|
5219
|
+
return { args, env: mode.env };
|
|
4762
5220
|
}
|
|
4763
|
-
function
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
process.stdout.write(`- **error:** ${stripAnsi(msg)}
|
|
4767
|
-
`);
|
|
4768
|
-
return;
|
|
5221
|
+
function getResumeArgs(config, options) {
|
|
5222
|
+
if (!options.resumeThreadId) {
|
|
5223
|
+
return [];
|
|
4769
5224
|
}
|
|
4770
|
-
if (
|
|
4771
|
-
|
|
4772
|
-
`${JSON.stringify({ level: "error", message: stripAnsi(msg) })}
|
|
4773
|
-
`
|
|
4774
|
-
);
|
|
4775
|
-
return;
|
|
5225
|
+
if (!config.resume) {
|
|
5226
|
+
throw new Error(`Agent "${config.agentId}" does not support resumeThreadId.`);
|
|
4776
5227
|
}
|
|
4777
|
-
|
|
5228
|
+
return config.resume.args(options.resumeThreadId, options.cwd ?? process.cwd());
|
|
4778
5229
|
}
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
error
|
|
4785
|
-
};
|
|
4786
|
-
|
|
4787
|
-
// packages/design-system/src/components/logger.ts
|
|
4788
|
-
function createLogger(emitter) {
|
|
4789
|
-
const emit = (level, message2) => {
|
|
4790
|
-
if (emitter) {
|
|
4791
|
-
emitter(message2);
|
|
4792
|
-
return;
|
|
4793
|
-
}
|
|
4794
|
-
if (level === "success") {
|
|
4795
|
-
log.success(message2);
|
|
4796
|
-
return;
|
|
4797
|
-
}
|
|
4798
|
-
if (level === "warn") {
|
|
4799
|
-
log.warn(message2);
|
|
4800
|
-
return;
|
|
4801
|
-
}
|
|
4802
|
-
if (level === "error") {
|
|
4803
|
-
log.error(message2);
|
|
4804
|
-
return;
|
|
4805
|
-
}
|
|
4806
|
-
log.info(message2);
|
|
4807
|
-
};
|
|
4808
|
-
return {
|
|
4809
|
-
info(message2) {
|
|
4810
|
-
emit("info", message2);
|
|
4811
|
-
},
|
|
4812
|
-
success(message2) {
|
|
4813
|
-
emit("success", message2);
|
|
4814
|
-
},
|
|
4815
|
-
warn(message2) {
|
|
4816
|
-
emit("warn", message2);
|
|
4817
|
-
},
|
|
4818
|
-
error(message2) {
|
|
4819
|
-
emit("error", message2);
|
|
4820
|
-
},
|
|
4821
|
-
resolved(label, value) {
|
|
4822
|
-
if (emitter) {
|
|
4823
|
-
emitter(`${label}: ${value}`);
|
|
4824
|
-
return;
|
|
4825
|
-
}
|
|
4826
|
-
log.message(`${label}
|
|
4827
|
-
${value}`, { symbol: symbols.resolved });
|
|
4828
|
-
},
|
|
4829
|
-
errorResolved(label, value) {
|
|
4830
|
-
if (emitter) {
|
|
4831
|
-
emitter(`${label}: ${value}`);
|
|
4832
|
-
return;
|
|
4833
|
-
}
|
|
4834
|
-
log.message(`${label}
|
|
4835
|
-
${value}`, { symbol: symbols.errorResolved });
|
|
4836
|
-
},
|
|
4837
|
-
message(message2, symbol) {
|
|
4838
|
-
if (emitter) {
|
|
4839
|
-
emitter(message2);
|
|
4840
|
-
return;
|
|
4841
|
-
}
|
|
4842
|
-
log.message(message2, { symbol: symbol ?? chalk6.gray("\u2502") });
|
|
4843
|
-
}
|
|
4844
|
-
};
|
|
5230
|
+
function buildSpawnArgs(agentId, options) {
|
|
5231
|
+
const { binaryName, spawnConfig } = resolveCliConfig(agentId);
|
|
5232
|
+
const stdinMode = options.useStdin && spawnConfig.stdinMode ? spawnConfig.stdinMode : void 0;
|
|
5233
|
+
const result = buildCliArgs(spawnConfig, options, stdinMode);
|
|
5234
|
+
return { binaryName, args: result.args, env: result.env };
|
|
4845
5235
|
}
|
|
4846
|
-
var logger = createLogger();
|
|
4847
|
-
|
|
4848
|
-
// packages/design-system/src/components/table.ts
|
|
4849
|
-
import { Table } from "console-table-printer";
|
|
4850
|
-
|
|
4851
|
-
// packages/design-system/src/acp/components.ts
|
|
4852
|
-
import chalk7 from "chalk";
|
|
4853
|
-
|
|
4854
|
-
// packages/design-system/src/acp/writer.ts
|
|
4855
|
-
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
4856
|
-
var storage = new AsyncLocalStorage2();
|
|
4857
|
-
|
|
4858
|
-
// packages/design-system/src/acp/components.ts
|
|
4859
|
-
var AGENT_PREFIX = `${chalk7.green.bold("\u2713")} agent: `;
|
|
4860
|
-
|
|
4861
|
-
// packages/design-system/src/dashboard/buffer.ts
|
|
4862
|
-
import chalk8 from "chalk";
|
|
4863
|
-
|
|
4864
|
-
// packages/design-system/src/dashboard/terminal.ts
|
|
4865
|
-
import readline from "node:readline";
|
|
4866
|
-
import { PassThrough as PassThrough2 } from "node:stream";
|
|
4867
|
-
|
|
4868
|
-
// packages/design-system/src/explorer/state.ts
|
|
4869
|
-
var REGION_HEADER = 1 << 0;
|
|
4870
|
-
var REGION_LIST = 1 << 1;
|
|
4871
|
-
var REGION_DETAIL = 1 << 2;
|
|
4872
|
-
var REGION_FOOTER = 1 << 3;
|
|
4873
|
-
var REGION_MODAL = 1 << 4;
|
|
4874
|
-
var REGION_TOAST = 1 << 5;
|
|
4875
|
-
var REGION_ALL = REGION_HEADER | REGION_LIST | REGION_DETAIL | REGION_FOOTER | REGION_MODAL | REGION_TOAST;
|
|
4876
|
-
|
|
4877
|
-
// packages/design-system/src/prompts/index.ts
|
|
4878
|
-
import chalk15 from "chalk";
|
|
4879
|
-
import * as clack from "@clack/prompts";
|
|
4880
|
-
|
|
4881
|
-
// packages/design-system/src/prompts/primitives/cancel.ts
|
|
4882
|
-
import chalk9 from "chalk";
|
|
4883
|
-
import { isCancel } from "@clack/prompts";
|
|
4884
|
-
|
|
4885
|
-
// packages/design-system/src/prompts/primitives/intro.ts
|
|
4886
|
-
import chalk10 from "chalk";
|
|
4887
|
-
|
|
4888
|
-
// packages/design-system/src/prompts/primitives/note.ts
|
|
4889
|
-
import chalk11 from "chalk";
|
|
4890
|
-
|
|
4891
|
-
// packages/design-system/src/prompts/primitives/outro.ts
|
|
4892
|
-
import chalk12 from "chalk";
|
|
4893
|
-
|
|
4894
|
-
// packages/design-system/src/prompts/primitives/spinner.ts
|
|
4895
|
-
import chalk14 from "chalk";
|
|
4896
|
-
|
|
4897
|
-
// packages/design-system/src/static/spinner.ts
|
|
4898
|
-
import chalk13 from "chalk";
|
|
4899
|
-
|
|
4900
|
-
// packages/design-system/src/static/menu.ts
|
|
4901
|
-
import chalk16 from "chalk";
|
|
4902
5236
|
|
|
4903
5237
|
// packages/agent-spawn/src/autonomous.ts
|
|
4904
5238
|
var DEFAULT_ACTIVITY_TIMEOUT_MS = 10 * 60 * 1e3;
|