Skip to content

The VS Code of video editing, built for agents.

TypeScript

Refactor CLI installation and status handling to support `diffusion` command

konstantin-paulus2f05fbea8f54
diff --git a/apps/desktop/src/cli-install.ts b/apps/desktop/src/cli-install.ts
index 0ee9d95c..83c4996c 100644
--- a/apps/desktop/src/cli-install.ts
+++ b/apps/desktop/src/cli-install.ts
@@ -11,11 +11,18 @@ import { addShimToPath, removeShimFromPath, shimOnPath, shimPath, writeShim } fr
import type { CliInstallResult, CliStatus, CliUninstallResult } from "./main-channels";
-export const CLI_LINK_PATH = "/usr/local/bin/dapi";
+export const CLI_LINK_DIR = "/usr/local/bin";
// The dev workflow links the workspace build into Homebrew's bin instead
// (`npm run link` in apps/cli), so that location counts as installed too.
-const DEV_LINK_PATH = "/opt/homebrew/bin/dapi";
+const DEV_LINK_DIR = "/opt/homebrew/bin";
+
+// `diffusion` is what we point to first when reporting status; `dapi` rides
+// alongside it as an alias, and is also what an install from before this
+// pair existed left behind.
+const LINK_NAMES = ["diffusion", "dapi"] as const;
+
+const linkPaths = (dir: string): string[] => LINK_NAMES.map((name) => `${dir}/${name}`);
/**
* Whether `path` is a symlink — dangling or not, since a link left behind
@@ -26,10 +33,12 @@ function isLink(path: string): boolean {
return lstatSync(path, { throwIfNoEntry: false })?.isSymbolicLink() ?? false;
}
-/** The first of the two locations that holds anything, or null. */
-function installedPath(): string | null {
- for (const path of [CLI_LINK_PATH, DEV_LINK_PATH]) {
- if (isLink(path) || existsSync(path)) return path;
+/** The first of the two locations that holds any of our links, or null. */
+function installedDir(): string | null {
+ for (const dir of [CLI_LINK_DIR, DEV_LINK_DIR]) {
+ if (linkPaths(dir).some((path) => isLink(path) || existsSync(path))) {
+ return dir;
+ }
}
return null;
}
@@ -53,14 +62,15 @@ async function cliStatusWin32(): Promise<CliStatus> {
}
async function cliStatusDarwin(): Promise<CliStatus> {
- const path = installedPath();
- if (path) {
+ const dir = installedDir();
+ if (dir) {
+ const path = linkPaths(dir).find((candidate) => isLink(candidate) || existsSync(candidate))!;
return { installed: true, path, managed: isLink(path), available: true };
}
return { installed: false, path: null, managed: false, available: app.isPackaged };
}
-/** Where `dapi` stands on this machine, without asking for a password. */
+/** Where `diffusion` (or its `dapi` alias) stands on this machine, without asking for a password. */
export async function cliStatus(): Promise<CliStatus> {
if (process.platform === "win32") return cliStatusWin32();
if (process.platform === "darwin") return cliStatusDarwin();
@@ -81,8 +91,9 @@ const cancelled = (e: unknown): boolean => ((e as Error).message ?? "").includes
async function installCliDarwin(): Promise<CliInstallResult> {
const wrapper = join(process.resourcesPath, "cli", "bin", "dapi");
+ const links = linkPaths(CLI_LINK_DIR).map((path) => `ln -sf '${wrapper}' '${path}'`).join(" && ");
try {
- await elevated(`mkdir -p /usr/local/bin && ln -sf '${wrapper}' '${CLI_LINK_PATH}'`);
+ await elevated(`mkdir -p ${CLI_LINK_DIR} && ${links}`);
return { status: "installed" };
} catch (e) {
return cancelled(e) ? { status: "cancelled" } : { status: "error", error: (e as Error).message };
@@ -126,20 +137,23 @@ async function uninstallCliWin32(): Promise<CliUninstallResult> {
}
async function uninstallCliDarwin(): Promise<CliUninstallResult> {
- const path = installedPath();
- if (!path) return { status: "absent" };
- if (!isLink(path)) {
- return { status: "error", error: `${path} is not a link, so it was left alone.` };
+ const dir = installedDir();
+ if (!dir) return { status: "absent" };
+ const present = linkPaths(dir).filter((path) => isLink(path) || existsSync(path));
+ const notLinks = present.filter((path) => !isLink(path));
+ if (notLinks.length > 0) {
+ const is = notLinks.length > 1 ? "are not links" : "is not a link";
+ return { status: "error", error: `${notLinks.join(", ")} ${is}, so nothing was removed.` };
}
try {
- unlinkSync(path);
+ for (const path of present) unlinkSync(path);
return { status: "removed" };
} catch (e) {
const code = (e as NodeJS.ErrnoException).code;
if (code !== "EACCES" && code !== "EPERM") return { status: "error", error: (e as Error).message };
}
try {
- await elevated(`rm -f '${path}'`);
+ await elevated(`rm -f ${present.map((path) => `'${path}'`).join(" ")}`);
return { status: "removed" };
} catch (e) {
return cancelled(e) ? { status: "cancelled" } : { status: "error", error: (e as Error).message };
@@ -148,7 +162,8 @@ async function uninstallCliDarwin(): Promise<CliUninstallResult> {
/**
- * Takes the `dapi` link off PATH, whichever of the two locations holds it.
+ * Takes the `diffusion`/`dapi` links off PATH, whichever of the two
+ * locations holds them.
*/
export async function uninstallCli(): Promise<CliUninstallResult> {
if (process.platform === "win32") return uninstallCliWin32();
diff --git a/apps/desktop/src/cli-windows.ts b/apps/desktop/src/cli-windows.ts
index 156e2000..a0bb2665 100644
--- a/apps/desktop/src/cli-windows.ts
+++ b/apps/desktop/src/cli-windows.ts
@@ -2,15 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-// The `dapi` command on Windows. Squirrel installs every version into its own
-// `app-<version>` folder, so nothing durable may point at the wrapper the app
-// ships in its resources. What goes on PATH (and into the agents' MCP
-// configs) is a shim in a folder that never moves:
+// The `diffusion` (and `dapi` alias) commands on Windows. Squirrel installs
+// every version into its own `app-<version>` folder, so nothing durable may
+// point at the wrapper the app ships in its resources. What goes on PATH
+// (and, for `dapi.cmd`, into the agents' MCP configs) is a pair of shims in a
+// folder that never moves:
// %LOCALAPPDATA%\DiffusionStudio\bin\dapi.cmd
-// The app rewrites it on every packaged launch and from Squirrel's update
-// hook, so it always names the current executable. Installing the CLI is then
-// only a matter of putting that folder on the user's PATH, which needs no
-// administrator.
+// %LOCALAPPDATA%\DiffusionStudio\bin\diffusion.cmd
+// The app rewrites both on every packaged launch and from Squirrel's update
+// hook, so they always name the current executable. Installing the CLI is
+// then only a matter of putting that folder on the user's PATH, which needs
+// no administrator.
//
// Nothing here imports electron, so the Squirrel hooks can use it before the
// app is ready and the tests can run it anywhere.
@@ -32,6 +34,13 @@ export function shimPath(env: NodeJS.ProcessEnv = process.env): string {
return win32.join(shimDir(env), "dapi.cmd");
}
+// `dapi.cmd` is the one `mcp-install.ts` registers with agents, so its name
+// and behavior above stay fixed. `diffusion.cmd` rides beside it purely so
+// the name on PATH matches the one in the docs; both run the same script.
+export function shimPaths(env: NodeJS.ProcessEnv = process.env): string[] {
+ return ["dapi.cmd", "diffusion.cmd"].map((name) => win32.join(shimDir(env), name));
+}
+
/** `dapi.js` as the packaged app stages it, next to `execPath`'s resources. */
export function stagedScript(execPath: string): string {
return win32.join(win32.dirname(execPath), "resources", "cli", "dapi.js");
@@ -58,7 +67,8 @@ export function shimContent(execPath: string, script: string = stagedScript(exec
/** Points the shim at `execPath`. Safe to repeat; the write lands whole. */
export async function writeShim(execPath: string = process.execPath, script?: string): Promise<void> {
await mkdir(shimDir(), { recursive: true });
- await writeFileAtomic(shimPath(), shimContent(execPath, script));
+ const content = shimContent(execPath, script);
+ await Promise.all(shimPaths().map((path) => writeFileAtomic(path, content)));
}
export async function removeShim(): Promise<void> {
diff --git a/apps/desktop/src/dapi/server.ts b/apps/desktop/src/dapi/server.ts
index 386bd251..a434504f 100644
--- a/apps/desktop/src/dapi/server.ts
+++ b/apps/desktop/src/dapi/server.ts
@@ -16,7 +16,8 @@ import type { MainContext, MainToolName } from "./handler";
/**
* The name the server introduces itself with, and so the namespace an agent
* shows the tools under: `mcp__diffusion__<tool>`. The same word as our URL
- * scheme, and not `dapi`, which is the CLI.
+ * scheme and the CLI's primary name (`dapi` still works there too, as an
+ * alias).
*/
const SERVER_NAME = "diffusion";
@@ -32,7 +33,7 @@ export type DapiServerDeps = {
/**
* The app's MCP server: Streamable HTTP on a fixed loopback port, the URL
- * agents register and the `dapi` CLI calls. Each client gets its own MCP
+ * agents register and the `diffusion` CLI calls. Each client gets its own MCP
* session over one catalog. Main-process tools run here; renderer tools are
* forwarded over IPC and their results presented (files written, small
* images inlined) before they go back out.
diff --git a/apps/desktop/src/main-channels.ts b/apps/desktop/src/main-channels.ts
index 4bf0230a..60a8e2b3 100644
--- a/apps/desktop/src/main-channels.ts
+++ b/apps/desktop/src/main-channels.ts
@@ -137,7 +137,7 @@ export type McpApplyResult = {
failures: { id: AgentId; error: string }[];
};
-// Where the `dapi` command stands. `managed` means what is there is a
+// Where the `diffusion` command stands. `managed` means what is there is a
// symlink (the app's own, or the dev workflow's Homebrew link), which
// "Uninstall" can remove; `available` that this build can create the app's
// link (a dev build cannot: that is `npm run link` in apps/cli).
@@ -148,7 +148,7 @@ export type CliStatus = {
available: boolean;
};
-// Outcome of linking the bundled dapi CLI into PATH. "cancelled" means the
+// Outcome of linking the bundled diffusion CLI into PATH. "cancelled" means the
// user dismissed the macOS admin prompt — not an error, not installed.
export type CliInstallResult =
| { status: "installed" }
@@ -321,7 +321,7 @@ export type MainRequestMap = {
response: { url: string } | null;
};
// The app's MCP server in the agents' configs (see mcp-install.ts), and
- // the `dapi` command on PATH (see cli-install.ts). The install/uninstall
+ // the `diffusion` command on PATH (see cli-install.ts). The install/uninstall
// calls put the macOS admin prompt on screen.
[MAIN_CHANNELS.MCP_STATUS]: { request: void; response: McpStatus };
[MAIN_CHANNELS.MCP_APPLY]: { request: McpApplyRequest; response: McpApplyResult };
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index 5b4cb2c3..8dcad13c 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -132,7 +132,7 @@ function docsDir(): string | null {
return existsSync(dir) ? dir : null;
}
-// The MCP server agents and the dapi CLI talk to. Started once the app is
+// The MCP server agents and the diffusion CLI talk to. Started once the app is
// ready; the first connection switches the app into headless mode.
const dapi = new DapiServer({
version: app.getVersion(),
diff --git a/apps/desktop/src/mcp-install.ts b/apps/desktop/src/mcp-install.ts
index 4762badc..60deffe0 100644
--- a/apps/desktop/src/mcp-install.ts
+++ b/apps/desktop/src/mcp-install.ts
@@ -6,7 +6,7 @@
// at a time as the settings page asks: the fixed loopback URL for agents
// that speak HTTP, the bundled `dapi mcp` proxy for the rest. No PATH
// symlink and no admin prompt — that is `cli-install.ts`, for people who
-// type `dapi`.
+// type `diffusion` (or its `dapi` alias).
import { app } from "electron";
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
diff --git a/apps/desktop/src/projects.ts b/apps/desktop/src/projects.ts
index f39a9ea5..8221bd40 100644
--- a/apps/desktop/src/projects.ts
+++ b/apps/desktop/src/projects.ts
@@ -449,7 +449,7 @@ const JSX_VERSION = "latest";
const SOLID_VERSION = "^1.9.10";
/**
- * The dapi surface as npm scripts: the CLI is how a project is inspected and
+ * The diffusion surface as npm scripts: the CLI is how a project is inspected and
* cut, so its commands belong in the record of the project they act on —
* `npm run` prints the menu, `npm run <name> -- <args>` runs one. Named after
* the command rather than its path (`grab`, not `media:grab`): the `media`
@@ -540,7 +540,7 @@ on the canvas.
## Agents
-Everything an agent needs is in the app's MCP server (\`dapi\`): its tools
+Everything an agent needs is in the app's MCP server (\`diffusion\`): its tools
are the API, its instructions say how to work, and its resources are the
authoring reference for the installed version. If it is not among your tools,
add it — the app serves it at \`${MCP_URL}\` while it is running — and start
@@ -551,7 +551,7 @@ a new session.
| Path | What it is |
| ---- | ---------- |
| \`index.tsx\` | The entry. Its default export renders the composition. |
-| \`package.json\` | The project record: \`projectId\` (its identity, kept across renames), \`displayName\` (the name shown in the app), \`main\` (the entry), \`diffusion\` (how each scene is exported), and the dapi commands as scripts. |
+| \`package.json\` | The project record: \`projectId\` (its identity, kept across renames), \`displayName\` (the name shown in the app), \`main\` (the entry), \`diffusion\` (how each scene is exported), and the diffusion commands as scripts. |
| \`tsconfig.json\` | Types for the composition tags, through \`jsxImportSource\`. |
| \`assets.yml\` | The asset library: for every asset its library path, where its bytes are, and what it was found to be; for a generation without bytes, where it stands. Written by the app; hand edits are read on the next load. |
| \`assets/\` | The library's files: put one here and it is taken in while the app watches, and the app writes its own here too — generations under \`assets/generated/\`. Media imported through the app is linked where it lies instead, never copied. |
@@ -602,7 +602,7 @@ export default function Project() {
survives the file being relinked), an asset id, a URL, or an absolute path.
- Generated assets are declared rather than fetched: \`src={generate.image({ prompt })}\`,
and \`generate.video\`, \`generate.voice\`, \`generate.audio\`. They are produced on
- mount, in dependency order. \`dapi context\` reports where each stands:
+ mount, in dependency order. \`diffusion context\` reports where each stands:
generating, failed with the reason, or done with the asset path it landed as.
- Solid is fully available while mounting: \`<For>\`, \`<Show>\`, \`createMemo\`, and
\`useTicker()\` for values that follow the playhead.
@@ -616,27 +616,27 @@ yourself with \`npx tsc --noEmit\`.
## Commands
-Every dapi command is a script here: \`npm run\` lists them, and
+Every diffusion command is a script here: \`npm run\` lists them, and
\`npm run <name> -- <args>\` runs one (\`npm run grab -- b-roll/drone.mp4 -c 6\`).
All of them talk to the running app, except \`fonts\`.
| Script | Command | What it does |
| ------ | ------- | ------------ |
-| \`open\` | \`dapi open .\` | Launch the app with this project open. |
-| \`context\` | \`dapi context\` | Which project the app has open, where its playhead sits, its fonts, where its generations stand. |
-| \`capture\` | \`dapi capture <id>\` | Render frames of a scene, as an export would, to labelled PNG contact sheets. |
-| \`probe\` | \`dapi media probe <id\\|path>\` | Container and per-track metadata, without decoding. |
-| \`transcribe\` | \`dapi media transcribe <id\\|path>\` | Timed speech transcript, word by word. |
-| \`grab\` | \`dapi media grab <id\\|path>\` | Decode frames of a video to labelled PNG contact sheets. |
-| \`filmstrip\` | \`dapi media filmstrip <id\\|path>\` | Thumbnail grid across a window of a video. |
-| \`waveform\` | \`dapi media waveform <id\\|path>\` | Loudness over time, with the silences marked. |
-| \`listen\` | \`dapi media listen <id\\|path>\` | Ask a multimodal model what is in an audio track. |
-| \`models\` | \`dapi models [type]\` | Generation models and their per-model constraints. |
-| \`voices\` | \`dapi voices\` | Speech voices for \`generate.voice\`. |
-| \`fonts\` | \`dapi fonts\` | Local font families, valid as \`fontFamily\`. |
-| \`logs\` | \`dapi logs\` | Recent console output from the app. |
-| \`screenshot\` | \`dapi screenshot\` | The whole app window as a PNG. |
-| \`report\` | \`dapi report <title>\` | File a bug against the editor, with diagnostics attached. |
+| \`open\` | \`diffusion open .\` | Launch the app with this project open. |
+| \`context\` | \`diffusion context\` | Which project the app has open, where its playhead sits, its fonts, where its generations stand. |
+| \`capture\` | \`diffusion capture <id>\` | Render frames of a scene, as an export would, to labelled PNG contact sheets. |
+| \`probe\` | \`diffusion media probe <id\\|path>\` | Container and per-track metadata, without decoding. |
+| \`transcribe\` | \`diffusion media transcribe <id\\|path>\` | Timed speech transcript, word by word. |
+| \`grab\` | \`diffusion media grab <id\\|path>\` | Decode frames of a video to labelled PNG contact sheets. |
+| \`filmstrip\` | \`diffusion media filmstrip <id\\|path>\` | Thumbnail grid across a window of a video. |
+| \`waveform\` | \`diffusion media waveform <id\\|path>\` | Loudness over time, with the silences marked. |
+| \`listen\` | \`diffusion media listen <id\\|path>\` | Ask a multimodal model what is in an audio track. |
+| \`models\` | \`diffusion models [type]\` | Generation models and their per-model constraints. |
+| \`voices\` | \`diffusion voices\` | Speech voices for \`generate.voice\`. |
+| \`fonts\` | \`diffusion fonts\` | Local font families, valid as \`fontFamily\`. |
+| \`logs\` | \`diffusion logs\` | Recent console output from the app. |
+| \`screenshot\` | \`diffusion screenshot\` | The whole app window as a PNG. |
+| \`report\` | \`diffusion report <title>\` | File a bug against the editor, with diagnostics attached. |
## Reference
@@ -674,7 +674,7 @@ async function ensurePackage(dir: string, name: string, displayName: string, ent
if (typeof next.displayName !== "string") next.displayName = displayName;
if (typeof next.main !== "string") next.main = entry;
// The commands are a menu rather than a record: a project that keeps its own
- // scripts is left with them, one with none is given the dapi surface.
+ // scripts is left with them, one with none is given the diffusion surface.
if (typeof next.scripts !== "object" || next.scripts === null) next.scripts = { ...SCRIPTS };
if (
next.projectId !== pkg.projectId ||
@@ -729,7 +729,7 @@ async function ensureRecord(dir: string, displayName = basename(dir)): Promise<s
* .gitignore, which come with a project created from the dashboard (see
* `scaffold`); a folder opened from anywhere on disk stays the user's. A
* folder that is already a project comes back untouched. How
- * `dapi open <path>` opens a folder.
+ * `diffusion open <path>` opens a folder.
*/
export async function initProject(window: BrowserWindow | null, dir: string): Promise<ProjectInfo> {
if (!isAbsolute(dir)) {
diff --git a/apps/desktop/src/squirrel.ts b/apps/desktop/src/squirrel.ts
index f77527bb..c918dcbc 100644
--- a/apps/desktop/src/squirrel.ts
+++ b/apps/desktop/src/squirrel.ts
@@ -6,10 +6,10 @@
// uninstall, with a `--squirrel-*` flag as the only argument, and expects it
// to do its housekeeping and exit. That is the moment the Start Menu
// shortcut is created and removed (through Squirrel's own Update.exe, one
-// folder up from the versioned app folder), where the `dapi` shim is pointed
-// at the new version and taken away again, and where the agents' MCP entries
-// are taken out of their configs so no agent is left calling an app that is
-// gone.
+// folder up from the versioned app folder), where the `diffusion`/`dapi`
+// shims are pointed at the new version and taken away again, and where the
+// agents' MCP entries are taken out of their configs so no agent is left
+// calling an app that is gone.
// `--squirrel-firstrun` is the ordinary first launch and is not an event.
import { app } from "electron";
diff --git a/apps/web/src/lib/mcp.ts b/apps/web/src/lib/mcp.ts
index 6b8d5ea3..2b254001 100644
--- a/apps/web/src/lib/mcp.ts
+++ b/apps/web/src/lib/mcp.ts
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// The renderer's view of the agent setup main keeps: which agents carry the
-// app's MCP entry, and whether `dapi` is on PATH. Desktop only — in the
+// app's MCP entry, and whether `diffusion` is on PATH. Desktop only — in the
// browser there are no configs to write, and every call here says so by
// resolving to null.
diff --git a/apps/web/src/projects/host.ts b/apps/web/src/projects/host.ts
index 5c8653ae..209bf2ad 100644
--- a/apps/web/src/projects/host.ts
+++ b/apps/web/src/projects/host.ts
@@ -218,7 +218,7 @@ export async function resolveProject(ref: string): Promise<ProjectInfo | null> {
* the folder is created if missing and, when nothing in it can be an entry,
* given an `index.tsx` holding an empty stage — and nothing else. Put on the
* list, so it stays reachable by name or id across relaunches. How
- * `dapi open <path>` lands anywhere on disk.
+ * `diffusion open <path>` lands anywhere on disk.
*/
export async function openProjectFolder(dir: string): Promise<ProjectInfo> {
if (!isDesktop()) throw new Error('Opening a project folder requires the desktop app.');
diff --git a/apps/web/src/utils/gen-ai.ts b/apps/web/src/utils/gen-ai.ts
index 2738fbbb..7a73fd81 100644
--- a/apps/web/src/utils/gen-ai.ts
+++ b/apps/web/src/utils/gen-ai.ts
@@ -586,7 +586,7 @@ function sceneHasAudio(world: World, scene: Entity): boolean {
}
/**
- * Per-model constraints (`dapi models video`); unknown models are left to the server.
+ * Per-model constraints (`diffusion models video`); unknown models are left to the server.
*/
function checkVideoConstraints(spec: Extract<ResolvedGeneration, { type: "video" }>): void {
const model = PROMPT_INPUT_VIDEO_MODEL_OPTIONS.find((option) => option.id === spec.model);
diff --git a/docs/reference/jsx/module.md b/docs/reference/jsx/module.md
index 4d94708f..f887472b 100644
--- a/docs/reference/jsx/module.md
+++ b/docs/reference/jsx/module.md
@@ -23,7 +23,7 @@ The component receives no props. [`open`](../tools/open.md) opens the folder —
| Path | What it is |
| ---- | ---------- |
| `index.tsx` | The entry. Its default export renders the composition. |
-| `package.json` | The project record: `projectId` (its identity, kept across renames), `displayName`, `main`, and the dapi commands as scripts. |
+| `package.json` | The project record: `projectId` (its identity, kept across renames), `displayName`, `main`, and the diffusion commands as scripts. |
| `tsconfig.json` | Types for the composition tags, through `jsxImportSource`. |
| `assets.yml` | The asset library (see [media.md](./media.md#the-library)). |
| `assets/` | The library's files: symlinks to media brought in from elsewhere, plus what the app produced itself, generations under `assets/generated/`. Media imported through the app is linked where it lies, never copied. |
diff --git a/docs/reference/tools/open.md b/docs/reference/tools/open.md
index d3cdeb3a..5e3e07ad 100644
--- a/docs/reference/tools/open.md
+++ b/docs/reference/tools/open.md
@@ -20,7 +20,7 @@ The folder may live anywhere on disk, and does not have to be a project yet. Ope
- a missing folder is created;
- a folder with no entry file (package.json `main`, or `index.tsx` and friends) gains an `index.tsx` holding an empty stage;
-- a folder with no project record gains one in `package.json` — `projectId`, `displayName`, `main`, and the dapi commands as `scripts` — which is what the app remembers the folder by. A package.json that is already there keeps everything it has and only gains the fields it lacks.
+- a folder with no project record gains one in `package.json` — `projectId`, `displayName`, `main`, and the diffusion commands as `scripts` — which is what the app remembers the folder by. A package.json that is already there keeps everything it has and only gains the fields it lacks.
Nothing else is written — no tsconfig, README, or .gitignore. Those come with a project created from the app's dashboard; a folder opened from anywhere on disk stays the user's. A folder that is already a project is opened untouched, wherever it lives. A JavaScript project (an entry ending in `.js` or `.jsx`) is left entirely alone, record included.