@toothfairyai/tfdesign 0.4.4 → 0.4.6
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.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
resolveDataRoot,
|
|
3
4
|
startServer
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-VIER63EE.js";
|
|
5
6
|
import {
|
|
6
7
|
getJson,
|
|
7
8
|
resolveProjectId
|
|
@@ -736,8 +737,8 @@ async function runLiveArtifactsToolCli(args) {
|
|
|
736
737
|
|
|
737
738
|
// apps/daemon/src/run-cli.ts
|
|
738
739
|
import { randomUUID } from "node:crypto";
|
|
739
|
-
import
|
|
740
|
-
import
|
|
740
|
+
import fs2 from "node:fs";
|
|
741
|
+
import path3 from "node:path";
|
|
741
742
|
|
|
742
743
|
// packages/contracts/dist/question-form.mjs
|
|
743
744
|
var OPEN_RE = /<question-form\b([^>]*)>/i;
|
|
@@ -914,35 +915,6 @@ function formatFormAnswers(form, answers) {
|
|
|
914
915
|
return lines.join("\n");
|
|
915
916
|
}
|
|
916
917
|
|
|
917
|
-
// apps/daemon/src/layout.ts
|
|
918
|
-
import fs2 from "node:fs";
|
|
919
|
-
import path3 from "node:path";
|
|
920
|
-
var REPO_DATA_DIR = ".od";
|
|
921
|
-
var PACKAGE_DATA_DIR = ".tfdesign";
|
|
922
|
-
function detectLayout(moduleDir) {
|
|
923
|
-
const base = path3.basename(moduleDir);
|
|
924
|
-
const daemonDir = base === "dist" || base === "src" ? path3.dirname(moduleDir) : moduleDir;
|
|
925
|
-
const candidate = path3.resolve(daemonDir, "../..");
|
|
926
|
-
const repo = fs2.existsSync(path3.join(candidate, "pnpm-workspace.yaml")) && fs2.existsSync(path3.join(candidate, "apps", "daemon"));
|
|
927
|
-
return repo ? { root: candidate, repo: true } : { root: daemonDir, repo: false };
|
|
928
|
-
}
|
|
929
|
-
function defaultDataRoot(moduleDir, cwd = process.cwd()) {
|
|
930
|
-
const layout = detectLayout(moduleDir);
|
|
931
|
-
return path3.join(
|
|
932
|
-
layout.repo ? layout.root : cwd,
|
|
933
|
-
layout.repo ? REPO_DATA_DIR : PACKAGE_DATA_DIR
|
|
934
|
-
);
|
|
935
|
-
}
|
|
936
|
-
function expandDataRoot(raw, cwd = process.cwd()) {
|
|
937
|
-
if (raw.startsWith("~/"))
|
|
938
|
-
return path3.join(process.env.HOME ?? "~", raw.slice(2));
|
|
939
|
-
return path3.isAbsolute(raw) ? raw : path3.resolve(cwd, raw);
|
|
940
|
-
}
|
|
941
|
-
function resolveDataRoot(moduleDir, cwd = process.cwd()) {
|
|
942
|
-
const raw = process.env.TFDESIGN_DATA_DIR || process.env.OD_DATA_DIR;
|
|
943
|
-
return raw ? expandDataRoot(raw, cwd) : defaultDataRoot(moduleDir, cwd);
|
|
944
|
-
}
|
|
945
|
-
|
|
946
918
|
// apps/daemon/src/run-cli.ts
|
|
947
919
|
var RUN_STRING_FLAGS = /* @__PURE__ */ new Set([
|
|
948
920
|
"project",
|
|
@@ -1057,7 +1029,7 @@ async function runDesignRun(rawArgs) {
|
|
|
1057
1029
|
process.exit(4);
|
|
1058
1030
|
}
|
|
1059
1031
|
const projectUrl = `${base}/projects/${encodeURIComponent(project.id)}`;
|
|
1060
|
-
const mirrorRoot = flags["mirror-root"] ?
|
|
1032
|
+
const mirrorRoot = flags["mirror-root"] ? path3.resolve(flags["mirror-root"]) : null;
|
|
1061
1033
|
emit({
|
|
1062
1034
|
type: "run_start",
|
|
1063
1035
|
project: { id: project.id, name: project.name },
|
|
@@ -1303,16 +1275,16 @@ async function fetchHealth(base) {
|
|
|
1303
1275
|
function sameRoot(a, b) {
|
|
1304
1276
|
const norm = (p) => {
|
|
1305
1277
|
try {
|
|
1306
|
-
return
|
|
1278
|
+
return fs2.realpathSync(String(p));
|
|
1307
1279
|
} catch {
|
|
1308
|
-
return
|
|
1280
|
+
return path3.resolve(String(p));
|
|
1309
1281
|
}
|
|
1310
1282
|
};
|
|
1311
1283
|
return norm(a) === norm(b);
|
|
1312
1284
|
}
|
|
1313
1285
|
async function bootInProcess(root) {
|
|
1314
1286
|
process.env.TFDESIGN_DATA_DIR = root;
|
|
1315
|
-
const { startServer: startServer2 } = await import("./server-
|
|
1287
|
+
const { startServer: startServer2 } = await import("./server-RXVSJGZG.js");
|
|
1316
1288
|
const { url, server } = await startServer2({ port: 0, returnServer: true });
|
|
1317
1289
|
return { url, booted: true, server, dataRoot: root };
|
|
1318
1290
|
}
|
|
@@ -1662,16 +1634,20 @@ function resolveOption(input, options) {
|
|
|
1662
1634
|
}
|
|
1663
1635
|
async function buildResult(base, project, conversationId, { rounds, finalText, mirrorRoot }) {
|
|
1664
1636
|
const projectId = project.id;
|
|
1665
|
-
const
|
|
1637
|
+
const filesUrl = `${base}/api/projects/${encodeURIComponent(projectId)}/files`;
|
|
1638
|
+
const fetchFiles = async () => (await getJson(filesUrl).catch(() => null))?.files ?? [];
|
|
1639
|
+
let filesRaw = await fetchFiles();
|
|
1640
|
+
for (let wait = 0; filesRaw.length === 0 && wait < 10; wait++) {
|
|
1641
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
1642
|
+
filesRaw = await fetchFiles();
|
|
1643
|
+
}
|
|
1644
|
+
const [projectData] = await Promise.all([
|
|
1666
1645
|
getJson(`${base}/api/projects/${encodeURIComponent(projectId)}`).catch(
|
|
1667
1646
|
() => null
|
|
1668
|
-
)
|
|
1669
|
-
getJson(
|
|
1670
|
-
`${base}/api/projects/${encodeURIComponent(projectId)}/files`
|
|
1671
|
-
).catch(() => null)
|
|
1647
|
+
)
|
|
1672
1648
|
]);
|
|
1673
1649
|
const record = projectData?.project ?? projectData ?? project;
|
|
1674
|
-
const files =
|
|
1650
|
+
const files = filesRaw.filter(
|
|
1675
1651
|
(f) => typeof f?.name === "string" && f.name.length > 0 && !f.name.split("/").some((s) => s.startsWith("."))
|
|
1676
1652
|
);
|
|
1677
1653
|
let entryFile = record?.metadata?.entryFile ?? null;
|
|
@@ -1717,34 +1693,34 @@ async function buildResult(base, project, conversationId, { rounds, finalText, m
|
|
|
1717
1693
|
};
|
|
1718
1694
|
}
|
|
1719
1695
|
async function mirrorProject(base, projectId, mirrorRoot, projectName) {
|
|
1720
|
-
const mirrorPath =
|
|
1721
|
-
|
|
1696
|
+
const mirrorPath = path3.join(mirrorRoot, slugify(projectName));
|
|
1697
|
+
fs2.mkdirSync(mirrorPath, { recursive: true });
|
|
1722
1698
|
const filesData = await getJson(
|
|
1723
1699
|
`${base}/api/projects/${encodeURIComponent(projectId)}/files`
|
|
1724
1700
|
).catch(() => null);
|
|
1725
1701
|
const names = (filesData?.files ?? []).map((f) => f?.name).filter((n) => typeof n === "string" && n.length > 0).filter((n) => !n.split("/").some((s) => s.startsWith(".")));
|
|
1726
1702
|
const mirrored = [];
|
|
1727
1703
|
for (const name of names) {
|
|
1728
|
-
const dest =
|
|
1729
|
-
|
|
1704
|
+
const dest = path3.join(mirrorPath, ...name.split("/"));
|
|
1705
|
+
fs2.mkdirSync(path3.dirname(dest), { recursive: true });
|
|
1730
1706
|
const resp = await fetch(
|
|
1731
1707
|
`${base}/api/projects/${encodeURIComponent(projectId)}/raw/${name.split("/").map(encodeURIComponent).join("/")}`
|
|
1732
1708
|
).catch(() => null);
|
|
1733
1709
|
if (!resp || !resp.ok) continue;
|
|
1734
|
-
|
|
1710
|
+
fs2.writeFileSync(dest, Buffer.from(await resp.arrayBuffer()));
|
|
1735
1711
|
mirrored.push(name);
|
|
1736
1712
|
}
|
|
1737
1713
|
const present = new Set(
|
|
1738
|
-
mirrored.map((n) =>
|
|
1714
|
+
mirrored.map((n) => path3.join(mirrorPath, ...n.split("/")))
|
|
1739
1715
|
);
|
|
1740
1716
|
const walk = (dir) => {
|
|
1741
|
-
for (const entry of
|
|
1742
|
-
const abs =
|
|
1717
|
+
for (const entry of fs2.readdirSync(dir, { withFileTypes: true })) {
|
|
1718
|
+
const abs = path3.join(dir, entry.name);
|
|
1743
1719
|
if (entry.isDirectory()) {
|
|
1744
1720
|
walk(abs);
|
|
1745
|
-
if (
|
|
1721
|
+
if (fs2.readdirSync(abs).length === 0) fs2.rmdirSync(abs);
|
|
1746
1722
|
} else if (!present.has(abs)) {
|
|
1747
|
-
|
|
1723
|
+
fs2.rmSync(abs);
|
|
1748
1724
|
}
|
|
1749
1725
|
}
|
|
1750
1726
|
};
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
createCompatApiError,
|
|
8
8
|
createCompatApiErrorResponse,
|
|
9
9
|
createSseResponse,
|
|
10
|
+
dataRoot,
|
|
11
|
+
detectLayout,
|
|
10
12
|
isLocalSameOrigin,
|
|
11
13
|
normalizeCommentAttachments,
|
|
12
14
|
normalizeProjectDisplayStatus,
|
|
@@ -23,7 +25,7 @@ import {
|
|
|
23
25
|
rewriteSkillAssetUrls,
|
|
24
26
|
startServer,
|
|
25
27
|
validateCodexGeneratedImagesDir
|
|
26
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-VIER63EE.js";
|
|
27
29
|
import "./chunk-MLKGABMK.js";
|
|
28
30
|
export {
|
|
29
31
|
SSE_KEEPALIVE_INTERVAL_MS,
|
|
@@ -34,6 +36,8 @@ export {
|
|
|
34
36
|
createCompatApiError,
|
|
35
37
|
createCompatApiErrorResponse,
|
|
36
38
|
createSseResponse,
|
|
39
|
+
dataRoot,
|
|
40
|
+
detectLayout,
|
|
37
41
|
isLocalSameOrigin,
|
|
38
42
|
normalizeCommentAttachments,
|
|
39
43
|
normalizeProjectDisplayStatus,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toothfairyai/tfdesign",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "TF Design — the local design workspace CLI: headless design runs (decks, posters, sites) through the tfdesign daemon, delegable from tfcode.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|