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