@toothfairyai/tfdesign 0.4.4 → 0.4.5
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
|
}
|
|
@@ -1717,34 +1689,34 @@ async function buildResult(base, project, conversationId, { rounds, finalText, m
|
|
|
1717
1689
|
};
|
|
1718
1690
|
}
|
|
1719
1691
|
async function mirrorProject(base, projectId, mirrorRoot, projectName) {
|
|
1720
|
-
const mirrorPath =
|
|
1721
|
-
|
|
1692
|
+
const mirrorPath = path3.join(mirrorRoot, slugify(projectName));
|
|
1693
|
+
fs2.mkdirSync(mirrorPath, { recursive: true });
|
|
1722
1694
|
const filesData = await getJson(
|
|
1723
1695
|
`${base}/api/projects/${encodeURIComponent(projectId)}/files`
|
|
1724
1696
|
).catch(() => null);
|
|
1725
1697
|
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
1698
|
const mirrored = [];
|
|
1727
1699
|
for (const name of names) {
|
|
1728
|
-
const dest =
|
|
1729
|
-
|
|
1700
|
+
const dest = path3.join(mirrorPath, ...name.split("/"));
|
|
1701
|
+
fs2.mkdirSync(path3.dirname(dest), { recursive: true });
|
|
1730
1702
|
const resp = await fetch(
|
|
1731
1703
|
`${base}/api/projects/${encodeURIComponent(projectId)}/raw/${name.split("/").map(encodeURIComponent).join("/")}`
|
|
1732
1704
|
).catch(() => null);
|
|
1733
1705
|
if (!resp || !resp.ok) continue;
|
|
1734
|
-
|
|
1706
|
+
fs2.writeFileSync(dest, Buffer.from(await resp.arrayBuffer()));
|
|
1735
1707
|
mirrored.push(name);
|
|
1736
1708
|
}
|
|
1737
1709
|
const present = new Set(
|
|
1738
|
-
mirrored.map((n) =>
|
|
1710
|
+
mirrored.map((n) => path3.join(mirrorPath, ...n.split("/")))
|
|
1739
1711
|
);
|
|
1740
1712
|
const walk = (dir) => {
|
|
1741
|
-
for (const entry of
|
|
1742
|
-
const abs =
|
|
1713
|
+
for (const entry of fs2.readdirSync(dir, { withFileTypes: true })) {
|
|
1714
|
+
const abs = path3.join(dir, entry.name);
|
|
1743
1715
|
if (entry.isDirectory()) {
|
|
1744
1716
|
walk(abs);
|
|
1745
|
-
if (
|
|
1717
|
+
if (fs2.readdirSync(abs).length === 0) fs2.rmdirSync(abs);
|
|
1746
1718
|
} else if (!present.has(abs)) {
|
|
1747
|
-
|
|
1719
|
+
fs2.rmSync(abs);
|
|
1748
1720
|
}
|
|
1749
1721
|
}
|
|
1750
1722
|
};
|
|
@@ -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.5",
|
|
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",
|