@sf-kmods/kdataforgejs-cli 2026.4.20 → 2026.4.23
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 +16 -2
- package/dist/cli.js +33 -2
- package/dist/commands/add.js +148 -0
- package/dist/commands/dev.js +114 -0
- package/dist/commands/doctor.js +56 -0
- package/dist/commands/gameData.js +162 -4
- package/dist/commands/sync.js +10 -3
- package/package.json +2 -2
- package/templates/default/README.md +5 -0
- package/templates/default/package.json +2 -0
package/README.md
CHANGED
|
@@ -20,7 +20,10 @@ npm run verify
|
|
|
20
20
|
| `kdf validate [dir]` | Checks `pack.yml`, the entry file, the static import graph and the digests of declared imports. |
|
|
21
21
|
| `kdf sync [dir]` | Generates sorted `imports`, SHA-256 digests, `reflectionClasses`, and pack-local config key/value types. |
|
|
22
22
|
| `kdf hash [dir]` | Rewrites stale `sha256` values of declared imports and leaves your comments alone. |
|
|
23
|
-
| `kdf game-data [dir]` | Runs manifest sync, finds a modded Satisfactory installation, starts a full reflection export, closes the game and imports the archive plus generated TypeScript declarations. Use `--game-path <root-or-executable>` to select an installation explicitly; add `--content-types` for schema-derived content document types. |
|
|
23
|
+
| `kdf game-data [dir]` | Runs manifest sync, finds a modded Satisfactory installation, reuses a valid cached export or starts a full reflection export, closes the game and imports the archive plus generated TypeScript declarations. Use `--game-path <root-or-executable>` to select an installation explicitly; add `--content-types` for schema-derived content document types and `--force` to bypass the cache. |
|
|
24
|
+
| `kdf doctor [dir]` | Read-only health report for Node, project checks, manifest drift, installation and imported game data. `--json` emits machine-readable statuses: `pass`, `warn`, `fail`, `unknown`. |
|
|
25
|
+
| `kdf dev [dir]` | Watches authored files, debounces changes, then runs sync, check, lint and validate in order. After success, prints manual `KDF.Reload` instruction. |
|
|
26
|
+
| `kdf add <handler\|hook\|item\|recipe\|document> <name> [dir]` | Creates one scaffold and updates entry imports, handler call and literal capabilities. Existing destinations and computed metadata are refused. Documents default to `cdo`; `--type item` or `--type recipe` selects another minimal document form. |
|
|
24
27
|
|
|
25
28
|
Exit code `0` means all good, `1` means findings, `2` means the command was used wrong.
|
|
26
29
|
|
|
@@ -64,7 +67,7 @@ and mod set. Temporary export and staging directories are removed after the game
|
|
|
64
67
|
`kdf game-data --content-types` opts into schema-derived document entries for `applyDocument`, including schematics,
|
|
65
68
|
research, unlocks, buildings and DataAssets. Field names and structural types are checked locally; runtime validation
|
|
66
69
|
still enforces ranges, conditional rules, reflection, capabilities and lifecycle. Export without the flag to restore
|
|
67
|
-
generic content types. The schemas ship in the CLI package; generation does not fetch schema URLs.
|
|
70
|
+
generic content types. Both modes work on cache hits without relaunching the game. The schemas ship in the CLI package; generation does not fetch schema URLs.
|
|
68
71
|
|
|
69
72
|
`kdf sync` writes `DataForge/typescript/kdataforgejs-config.d.ts` from authored `*.config.yml`/`*.config.yaml` fields.
|
|
70
73
|
These keys type `ctx.config.get` and `onChange`; runtime access still requires `kdf.config.read`. Regenerate the file
|
|
@@ -73,3 +76,14 @@ after changing config definitions. Keep generated files outside your source edit
|
|
|
73
76
|
For CLI maintenance, `pnpm run sync:schemas` refreshes the checked-in `schemas/` snapshot from the workspace's
|
|
74
77
|
`kdataforge-editor/crates/kdf-validation/schemas/`. Normal builds and installed packages use the bundled snapshot and
|
|
75
78
|
do not require a separate editor checkout.
|
|
79
|
+
|
|
80
|
+
Complete exports are cached in `.kdataforge/cache/<input-sha256>/<output-sha256>/` with archive, declarations and a hash receipt.
|
|
81
|
+
The input fingerprint includes platform, installation path, game executable, save, installed mod descriptors and binaries,
|
|
82
|
+
base-game package metadata, loose installed `DataForge` pack files (including scripts and imports), and cache/tool schema.
|
|
83
|
+
Loose pack hashing is limited to 10,000 files or 512 MiB; larger inputs skip caching. A validated hit skips launch; missing or corrupt artifacts trigger a
|
|
84
|
+
fresh export. `--force` bypasses the hit. The game-data archive and declarations still install into normal project paths.
|
|
85
|
+
|
|
86
|
+
`kdf dev` watches project configuration and authored `DataForge/` files. Generated declarations and manifests from its
|
|
87
|
+
own sync do not trigger another run. No automatic game command is sent: run `KDF.Reload` in the local game/server console
|
|
88
|
+
after successful checks. Item and recipe scaffolds contain placeholder definitions; fill in actual parent classes,
|
|
89
|
+
ingredients, products and machines before loading them. Hook scaffolds leave target selection for the author.
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { checkProject } from "./commands/check.js";
|
|
3
|
+
import { addScaffold } from "./commands/add.js";
|
|
4
|
+
import { startDev } from "./commands/dev.js";
|
|
5
|
+
import { doctorProject } from "./commands/doctor.js";
|
|
3
6
|
import { formatProject } from "./commands/format.js";
|
|
4
7
|
import { importGameData } from "./commands/gameData.js";
|
|
5
8
|
import { hashProject } from "./commands/hash.js";
|
|
@@ -18,7 +21,10 @@ Usage:
|
|
|
18
21
|
kdf validate [dir] Check pack.yml, entry, static imports and import digests
|
|
19
22
|
kdf sync [dir] Generate imports, hashes and reflection classes from source
|
|
20
23
|
kdf hash [dir] Update sha256 of declared script imports in pack.yml
|
|
21
|
-
kdf game-data [dir] [--game-path <path>] [--content-types] Export
|
|
24
|
+
kdf game-data [dir] [--game-path <path>] [--content-types] [--force] Export or reuse cached game data
|
|
25
|
+
kdf doctor [dir] [--game-path <path>] [--json] Read-only environment and project health
|
|
26
|
+
kdf dev [dir] Watch authored files; sync, check, lint, validate
|
|
27
|
+
kdf add <handler|hook|item|recipe|document> <name> [dir] [--type <document-type>]
|
|
22
28
|
kdf --help | --version
|
|
23
29
|
`;
|
|
24
30
|
const DEFAULT_DEPENDENCIES = { importGameData };
|
|
@@ -37,6 +43,8 @@ async function runCli(request, dependencies) {
|
|
|
37
43
|
"game-path": { type: "string" },
|
|
38
44
|
timeout: { type: "string" },
|
|
39
45
|
"content-types": { type: "boolean", default: false },
|
|
46
|
+
type: { type: "string" },
|
|
47
|
+
json: { type: "boolean", default: false },
|
|
40
48
|
force: { type: "boolean", default: false },
|
|
41
49
|
help: { type: "boolean", short: "h", default: false },
|
|
42
50
|
version: { type: "boolean", short: "v", default: false },
|
|
@@ -88,12 +96,35 @@ async function runCli(request, dependencies) {
|
|
|
88
96
|
...(values["game-path"] ? { gamePath: values["game-path"] } : {}),
|
|
89
97
|
...(timeoutMilliseconds === undefined ? {} : { timeoutMilliseconds }),
|
|
90
98
|
...(values["content-types"] ? { contentTypes: true } : {}),
|
|
99
|
+
...(values.force ? { force: true } : {}),
|
|
91
100
|
});
|
|
92
|
-
io.out(
|
|
101
|
+
io.out(`${result.cacheHit ? "Reused cached" : "Imported"} game data from ${result.installation.root}`);
|
|
93
102
|
io.out(`Archive: ${result.archivePath}`);
|
|
94
103
|
io.out(`Types: ${result.declarationPath}`);
|
|
95
104
|
return 0;
|
|
96
105
|
}
|
|
106
|
+
case "doctor": {
|
|
107
|
+
const checks = doctorProject(directory, values["game-path"]);
|
|
108
|
+
if (values.json)
|
|
109
|
+
io.out(JSON.stringify({ checks }, null, 2));
|
|
110
|
+
else
|
|
111
|
+
for (const check of checks)
|
|
112
|
+
io.out(`${check.status.toUpperCase()} ${check.name}: ${check.message}`);
|
|
113
|
+
return checks.some((check) => check.status === "fail") ? 1 : 0;
|
|
114
|
+
}
|
|
115
|
+
case "dev":
|
|
116
|
+
startDev(directory, io);
|
|
117
|
+
return 0;
|
|
118
|
+
case "add": {
|
|
119
|
+
const [kind, name, root = "."] = positionals.slice(1);
|
|
120
|
+
if (!kind || !name) {
|
|
121
|
+
io.err(USAGE);
|
|
122
|
+
return 2;
|
|
123
|
+
}
|
|
124
|
+
const path = addScaffold(root, kind, name, values.type);
|
|
125
|
+
io.out(`Created ${path}`);
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
97
128
|
default:
|
|
98
129
|
io.err(`Unknown command '${command}'.\n${USAGE}`);
|
|
99
130
|
return 2;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
import { parseDocument } from "yaml";
|
|
6
|
+
import { RUNTIME_MODULE } from "../conventions.js";
|
|
7
|
+
const CAPABILITY = {
|
|
8
|
+
hook: "kdf.native.hook", item: "kdf.items.define", recipe: "kdf.recipes.define", document: "kdf.documents.apply",
|
|
9
|
+
};
|
|
10
|
+
const NAME = /^[A-Za-z][A-Za-z0-9_-]*$/u;
|
|
11
|
+
export function addScaffold(directory, kind, name, documentType = "cdo") {
|
|
12
|
+
if (!NAME.test(name))
|
|
13
|
+
throw new Error("Name must start with a letter and contain only letters, digits, '-' or '_'.");
|
|
14
|
+
if (!["handler", "hook", "item", "recipe", "document"].includes(kind))
|
|
15
|
+
throw new Error(`Unsupported scaffold '${kind}'.`);
|
|
16
|
+
if (kind === "document" && !NAME.test(documentType))
|
|
17
|
+
throw new Error("Document type must be a safe identifier.");
|
|
18
|
+
const root = resolve(directory);
|
|
19
|
+
const entryPath = join(root, "DataForge/scripts/main.ts");
|
|
20
|
+
if (!existsSync(entryPath))
|
|
21
|
+
throw new Error(`Entry file does not exist: ${entryPath}`);
|
|
22
|
+
const destination = kind === "document" ? join(root, "DataForge", `${name}.yml`) : join(root, "DataForge/scripts", `${name}.ts`);
|
|
23
|
+
if (existsSync(destination))
|
|
24
|
+
throw new Error(`Refusing to overwrite ${destination}`);
|
|
25
|
+
const before = readFileSync(entryPath, "utf8");
|
|
26
|
+
const functionName = `add${name.split(/[-_]/u).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join("")}`;
|
|
27
|
+
const updated = editEntry(before, kind, name, functionName, documentType);
|
|
28
|
+
const content = scaffold(kind, name, functionName, documentType);
|
|
29
|
+
if (kind === "document") {
|
|
30
|
+
const parsed = parseDocument(content);
|
|
31
|
+
if (parsed.errors.length > 0)
|
|
32
|
+
throw new Error(parsed.errors[0]?.message);
|
|
33
|
+
}
|
|
34
|
+
mkdirSync(dirname(destination), { recursive: true });
|
|
35
|
+
writeFileSync(destination, content, { flag: "wx" });
|
|
36
|
+
const stagedEntry = `${entryPath}.${randomUUID()}.tmp`;
|
|
37
|
+
try {
|
|
38
|
+
if (readFileSync(entryPath, "utf8") !== before)
|
|
39
|
+
throw new Error("Entry changed while scaffolding; retry.");
|
|
40
|
+
writeFileSync(stagedEntry, updated, { flag: "wx" });
|
|
41
|
+
renameSync(stagedEntry, entryPath);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
rmSync(stagedEntry, { force: true });
|
|
45
|
+
rmSync(destination);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
return destination;
|
|
49
|
+
}
|
|
50
|
+
function scaffold(kind, name, functionName, documentType) {
|
|
51
|
+
if (kind === "document") {
|
|
52
|
+
const field = { cdo: "patches", item: "items", recipe: "recipes", asset: "assets", dataasset: "assets" }[documentType];
|
|
53
|
+
if (!field)
|
|
54
|
+
throw new Error(`Document type '${documentType}' has no minimal scaffold; create it manually.`);
|
|
55
|
+
return `type: ${documentType}\n${field}: []\n`;
|
|
56
|
+
}
|
|
57
|
+
if (kind === "item")
|
|
58
|
+
return `import type { Context } from "${RUNTIME_MODULE}";\n\nexport function ${functionName}(ctx: Context): void {\n\tctx.createItem({\n\t\tid: "${name}",\n\t\tparent: { classPath: "/Script/FactoryGame.FGItemDescriptor" },\n\t\tdisplayName: { namespace: "${name}", key: "name", source: "${name}" },\n\t\tform: "solid",\n\t\tstackSize: "small",\n\t});\n}\n`;
|
|
59
|
+
if (kind === "recipe")
|
|
60
|
+
return `import type { Context } from "${RUNTIME_MODULE}";\n\nexport function ${functionName}(ctx: Context): void {\n\tctx.createRecipe({\n\t\tid: "${name}",\n\t\tingredients: [],\n\t\tproducts: [],\n\t\tproducedIn: [],\n\t\tdurationSeconds: 1,\n\t});\n}\n`;
|
|
61
|
+
if (kind === "hook")
|
|
62
|
+
return `import type { Context } from "${RUNTIME_MODULE}";\n\nexport function ${functionName}(ctx: Context): void {\n\t// Add ctx.hook(target, hook, callback) after selecting a reflected native target.\n\tvoid ctx;\n}\n`;
|
|
63
|
+
return `import type { Context } from "${RUNTIME_MODULE}";\n\nexport function ${functionName}(ctx: Context): void {\n\tconsole.info(ctx.catalog().digest);\n}\n`;
|
|
64
|
+
}
|
|
65
|
+
function editEntry(before, kind, name, functionName, documentType) {
|
|
66
|
+
const source = ts.createSourceFile("main.ts", before, ts.ScriptTarget.ES2022, true);
|
|
67
|
+
if (ts.transpileModule(before, { reportDiagnostics: true, compilerOptions: { target: ts.ScriptTarget.ES2022 } })
|
|
68
|
+
.diagnostics?.some((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error)) {
|
|
69
|
+
throw new Error("Entry has syntax errors; refusing to edit it.");
|
|
70
|
+
}
|
|
71
|
+
const edits = [];
|
|
72
|
+
if (kind !== "document" && source.statements.some((node) => (ts.isFunctionDeclaration(node) && node.name?.text === functionName) ||
|
|
73
|
+
(ts.isVariableStatement(node) && node.declarationList.declarations.some((declaration) => ts.isIdentifier(declaration.name) && declaration.name.text === functionName)) ||
|
|
74
|
+
(ts.isImportDeclaration(node) && node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings) &&
|
|
75
|
+
node.importClause.namedBindings.elements.some((element) => element.name.text === functionName)))) {
|
|
76
|
+
throw new Error(`Entry already declares '${functionName}'; refusing ambiguous edit.`);
|
|
77
|
+
}
|
|
78
|
+
const capability = CAPABILITY[kind];
|
|
79
|
+
if (capability)
|
|
80
|
+
addCapability(source, capability, edits);
|
|
81
|
+
const assignment = source.statements.find((node) => ts.isExportAssignment(node) && !node.isExportEquals);
|
|
82
|
+
if (!assignment || !ts.isExportAssignment(assignment) || !ts.isCallExpression(assignment.expression) ||
|
|
83
|
+
!ts.isIdentifier(assignment.expression.expression) || assignment.expression.expression.text !== "defineHandler") {
|
|
84
|
+
throw new Error("Entry must default-export a direct defineHandler call; refusing ambiguous edit.");
|
|
85
|
+
}
|
|
86
|
+
const callback = assignment.expression.arguments[0];
|
|
87
|
+
if (!callback || (!ts.isArrowFunction(callback) && !ts.isFunctionExpression(callback)) || !ts.isBlock(callback.body)) {
|
|
88
|
+
throw new Error("defineHandler callback must have a block body; refusing ambiguous edit.");
|
|
89
|
+
}
|
|
90
|
+
const ctx = callback.parameters[0]?.name;
|
|
91
|
+
if (!ctx || !ts.isIdentifier(ctx))
|
|
92
|
+
throw new Error("Cannot identify handler context parameter.");
|
|
93
|
+
const invocation = kind === "document"
|
|
94
|
+
? `${ctx.text}.applyDocument("${documentType}", ${ctx.text}.import("yaml", "${name}.yml") as HandlerDocument<"${documentType}">);`
|
|
95
|
+
: `${functionName}(${ctx.text});`;
|
|
96
|
+
edits.push({ start: callback.body.end - 1, end: callback.body.end - 1, text: `\n\t${invocation}\n` });
|
|
97
|
+
if (kind === "document") {
|
|
98
|
+
const hasHandlerDocument = source.statements.some((node) => ts.isImportDeclaration(node) &&
|
|
99
|
+
ts.isStringLiteral(node.moduleSpecifier) && node.moduleSpecifier.text === RUNTIME_MODULE &&
|
|
100
|
+
node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings) &&
|
|
101
|
+
node.importClause.namedBindings.elements.some((element) => element.name.text === "HandlerDocument" && !element.propertyName));
|
|
102
|
+
if (!hasHandlerDocument)
|
|
103
|
+
edits.push({ start: 0, end: 0, text: `import type { HandlerDocument } from "${RUNTIME_MODULE}";\n` });
|
|
104
|
+
}
|
|
105
|
+
else
|
|
106
|
+
edits.push({ start: 0, end: 0, text: `import { ${functionName} } from "./${name}";\n` });
|
|
107
|
+
return edits.sort((left, right) => right.start - left.start).reduce((content, edit) => content.slice(0, edit.start) + edit.text + content.slice(edit.end), before);
|
|
108
|
+
}
|
|
109
|
+
function addCapability(source, capability, edits) {
|
|
110
|
+
const imported = source.statements.some((node) => ts.isImportDeclaration(node) &&
|
|
111
|
+
ts.isStringLiteral(node.moduleSpecifier) && node.moduleSpecifier.text === RUNTIME_MODULE &&
|
|
112
|
+
!node.importClause?.isTypeOnly && node.importClause?.namedBindings && ts.isNamedImports(node.importClause.namedBindings) &&
|
|
113
|
+
node.importClause.namedBindings.elements.some((element) => element.name.text === "defineMeta" && !element.propertyName && !element.isTypeOnly));
|
|
114
|
+
const meta = source.statements.flatMap((node) => ts.isVariableStatement(node) &&
|
|
115
|
+
node.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)
|
|
116
|
+
? node.declarationList.declarations.filter((declaration) => ts.isIdentifier(declaration.name) && declaration.name.text === "meta") : []);
|
|
117
|
+
if (meta.length > 1)
|
|
118
|
+
throw new Error("Multiple exported meta declarations; refusing ambiguous edit.");
|
|
119
|
+
if (meta.length === 0) {
|
|
120
|
+
if (!imported && source.statements.some((node) => ts.isVariableStatement(node) &&
|
|
121
|
+
node.declarationList.declarations.some((declaration) => ts.isIdentifier(declaration.name) && declaration.name.text === "defineMeta"))) {
|
|
122
|
+
throw new Error("Local defineMeta binding conflicts with required import; refusing ambiguous edit.");
|
|
123
|
+
}
|
|
124
|
+
if (!imported)
|
|
125
|
+
edits.push({ start: 0, end: 0, text: `import { defineMeta } from "${RUNTIME_MODULE}";\n` });
|
|
126
|
+
const assignment = source.statements.find((node) => ts.isExportAssignment(node));
|
|
127
|
+
if (!assignment)
|
|
128
|
+
throw new Error("No default export for metadata insertion.");
|
|
129
|
+
edits.push({ start: assignment.getStart(source), end: assignment.getStart(source),
|
|
130
|
+
text: `export const meta = defineMeta({ capabilities: ["${capability}"] });\n\n` });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (!imported)
|
|
134
|
+
throw new Error("Existing meta lacks an unaliased value defineMeta import; refusing ambiguous edit.");
|
|
135
|
+
const call = meta[0]?.initializer;
|
|
136
|
+
const arg = call && ts.isCallExpression(call) && ts.isIdentifier(call.expression) && call.expression.text === "defineMeta" &&
|
|
137
|
+
call.arguments.length === 1 ? call.arguments[0] : undefined;
|
|
138
|
+
const property = arg && ts.isObjectLiteralExpression(arg) && arg.properties.length === 1 ? arg.properties[0] : undefined;
|
|
139
|
+
const array = property && ts.isPropertyAssignment(property) && ts.isIdentifier(property.name) &&
|
|
140
|
+
property.name.text === "capabilities" && ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined;
|
|
141
|
+
if (!array || array.elements.some((element) => !ts.isStringLiteral(element))) {
|
|
142
|
+
throw new Error("Computed or nonliteral defineMeta capabilities; refusing ambiguous edit.");
|
|
143
|
+
}
|
|
144
|
+
if (array.elements.some((element) => ts.isStringLiteral(element) && element.text === capability))
|
|
145
|
+
return;
|
|
146
|
+
edits.push({ start: array.end - 1, end: array.end - 1,
|
|
147
|
+
text: `${array.elements.hasTrailingComma ? " " : array.elements.length > 0 ? ", " : ""}"${capability}"` });
|
|
148
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { watch, readFileSync, readdirSync, existsSync } from "node:fs";
|
|
2
|
+
import { join, resolve, sep } from "node:path";
|
|
3
|
+
import { findPackRoots } from "../pack/discover.js";
|
|
4
|
+
import { checkProject } from "./check.js";
|
|
5
|
+
import { lintProject } from "./lint.js";
|
|
6
|
+
import { syncProject } from "./sync.js";
|
|
7
|
+
import { validateProject } from "./validate.js";
|
|
8
|
+
import { formatDiagnostic, hasErrors } from "../diagnostics.js";
|
|
9
|
+
const IGNORED = new Set(["node_modules", "typescript", ".kdataforge", ".git"]);
|
|
10
|
+
const DEBOUNCE_MS = 200;
|
|
11
|
+
/** Watches authored files. Generated manifests and declarations cannot feed the watcher. */
|
|
12
|
+
export function startDev(directory, io) {
|
|
13
|
+
const root = resolve(directory);
|
|
14
|
+
const dataForge = join(root, "DataForge");
|
|
15
|
+
if (!existsSync(dataForge))
|
|
16
|
+
throw new Error(`DataForge directory not found in ${root}`);
|
|
17
|
+
const watchers = new Map();
|
|
18
|
+
let timer;
|
|
19
|
+
let running = false;
|
|
20
|
+
let dirty = false;
|
|
21
|
+
let closed = false;
|
|
22
|
+
const generatedManifests = new Map();
|
|
23
|
+
const schedule = () => {
|
|
24
|
+
if (timer)
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
timer = setTimeout(() => { dirty = true; void run(); }, DEBOUNCE_MS);
|
|
27
|
+
};
|
|
28
|
+
const attach = (directoryPath) => {
|
|
29
|
+
if (!existsSync(directoryPath))
|
|
30
|
+
return;
|
|
31
|
+
if (!watchers.has(directoryPath))
|
|
32
|
+
watchers.set(directoryPath, watch(directoryPath, (_event, filename) => {
|
|
33
|
+
if (closed)
|
|
34
|
+
return;
|
|
35
|
+
const name = filename?.toString();
|
|
36
|
+
if (name !== undefined && IGNORED.has(name))
|
|
37
|
+
return;
|
|
38
|
+
if (name === "pack.yml") {
|
|
39
|
+
const path = join(directoryPath, name);
|
|
40
|
+
if (existsSync(path) && generatedManifests.get(path) === readFileSync(path, "utf8"))
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
refresh();
|
|
44
|
+
schedule();
|
|
45
|
+
}));
|
|
46
|
+
for (const entry of readdirSync(directoryPath, { withFileTypes: true })) {
|
|
47
|
+
if (entry.isDirectory() && !IGNORED.has(entry.name))
|
|
48
|
+
attach(join(directoryPath, entry.name));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const refresh = () => {
|
|
52
|
+
for (const path of [...watchers.keys()]) {
|
|
53
|
+
if (!existsSync(path)) {
|
|
54
|
+
watchers.get(path)?.close();
|
|
55
|
+
watchers.delete(path);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
attach(dataForge);
|
|
59
|
+
};
|
|
60
|
+
const run = async () => {
|
|
61
|
+
if (running || closed)
|
|
62
|
+
return;
|
|
63
|
+
running = true;
|
|
64
|
+
while (dirty && !closed) {
|
|
65
|
+
dirty = false;
|
|
66
|
+
try {
|
|
67
|
+
syncProject(root);
|
|
68
|
+
for (const pack of findPackRoots(root)) {
|
|
69
|
+
const path = join(pack, "pack.yml");
|
|
70
|
+
generatedManifests.set(path, readFileSync(path, "utf8"));
|
|
71
|
+
}
|
|
72
|
+
const diagnostics = [...checkProject(root), ...lintProject(root), ...validateProject(root)];
|
|
73
|
+
for (const diagnostic of diagnostics)
|
|
74
|
+
io.err(formatDiagnostic(diagnostic));
|
|
75
|
+
if (hasErrors(diagnostics))
|
|
76
|
+
io.err("Checks failed; reload skipped.");
|
|
77
|
+
else
|
|
78
|
+
io.out("Checks passed. Run KDF.Reload in local game or server console.");
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
io.err(error instanceof Error ? error.message : String(error));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
running = false;
|
|
85
|
+
};
|
|
86
|
+
attach(dataForge);
|
|
87
|
+
watchers.set(root, watch(root, (_event, filename) => {
|
|
88
|
+
if (closed || !filename)
|
|
89
|
+
return;
|
|
90
|
+
if (filename.toString() === "DataForge") {
|
|
91
|
+
for (const path of [...watchers.keys()]) {
|
|
92
|
+
if (path === dataForge || path.startsWith(`${dataForge}${sep}`)) {
|
|
93
|
+
watchers.get(path)?.close();
|
|
94
|
+
watchers.delete(path);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
refresh();
|
|
98
|
+
schedule();
|
|
99
|
+
}
|
|
100
|
+
else if (/^(?:tsconfig(?:\.kdf)?\.json|package\.json)$/u.test(filename.toString()))
|
|
101
|
+
schedule();
|
|
102
|
+
}));
|
|
103
|
+
io.out(`Watching ${dataForge}`);
|
|
104
|
+
dirty = true;
|
|
105
|
+
void run();
|
|
106
|
+
return { close: () => {
|
|
107
|
+
closed = true;
|
|
108
|
+
if (timer)
|
|
109
|
+
clearTimeout(timer);
|
|
110
|
+
for (const watcher of watchers.values())
|
|
111
|
+
watcher.close();
|
|
112
|
+
watchers.clear();
|
|
113
|
+
} };
|
|
114
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join, relative, resolve } from "node:path";
|
|
3
|
+
import { checkProject } from "./check.js";
|
|
4
|
+
import { inspectSyncDrift } from "./sync.js";
|
|
5
|
+
import { validateProject } from "./validate.js";
|
|
6
|
+
import { lintProject } from "./lint.js";
|
|
7
|
+
import { detectGameInstallations, resolveGameInstallation } from "../game/installations.js";
|
|
8
|
+
import { hasErrors } from "../diagnostics.js";
|
|
9
|
+
/** Read-only health report. Unknown means the check could not be run. */
|
|
10
|
+
export function doctorProject(directory, gamePath) {
|
|
11
|
+
const root = resolve(directory);
|
|
12
|
+
const checks = [];
|
|
13
|
+
checks.push({ name: "node", status: Number(process.versions.node.split(".")[0]) >= 20 ? "pass" : "fail",
|
|
14
|
+
message: `Node ${process.versions.node} (requires >=20)` });
|
|
15
|
+
if (!existsSync(root)) {
|
|
16
|
+
checks.push({ name: "project", status: "fail", message: `Project does not exist: ${root}` });
|
|
17
|
+
return checks;
|
|
18
|
+
}
|
|
19
|
+
for (const [name, run] of [
|
|
20
|
+
["validate", () => validateProject(root)],
|
|
21
|
+
["check", () => checkProject(root)],
|
|
22
|
+
["lint", () => lintProject(root)],
|
|
23
|
+
]) {
|
|
24
|
+
try {
|
|
25
|
+
const diagnostics = run();
|
|
26
|
+
checks.push(fromDiagnostics(name, diagnostics));
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
checks.push({ name, status: "unknown", message: error instanceof Error ? error.message : String(error) });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const drift = inspectSyncDrift(root).changedPacks;
|
|
34
|
+
checks.push({ name: "manifest", status: drift.length === 0 ? "pass" : "warn",
|
|
35
|
+
message: drift.length === 0 ? "Manifest synchronized" : `Run kdf sync: ${drift.map((path) => relative(root, path)).join(", ")}` });
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
checks.push({ name: "manifest", status: "unknown", message: error instanceof Error ? error.message : String(error) });
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const installations = gamePath ? [resolveGameInstallation(gamePath)] : detectGameInstallations();
|
|
42
|
+
checks.push({ name: "installation", status: installations.length > 0 ? "pass" : "warn",
|
|
43
|
+
message: installations.length > 0 ? installations.map((item) => item.root).join(", ") : "No modded Satisfactory installation found" });
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
checks.push({ name: "installation", status: "unknown", message: error instanceof Error ? error.message : String(error) });
|
|
47
|
+
}
|
|
48
|
+
const archive = join(root, ".kdataforge/satisfactory.kdfdata");
|
|
49
|
+
checks.push({ name: "game-data", status: existsSync(archive) ? "pass" : "warn",
|
|
50
|
+
message: existsSync(archive) ? `Archive available: ${archive}` : "No imported game data; run kdf game-data if reflection types are needed" });
|
|
51
|
+
return checks;
|
|
52
|
+
}
|
|
53
|
+
function fromDiagnostics(name, diagnostics) {
|
|
54
|
+
const status = hasErrors(diagnostics) ? "fail" : diagnostics.length > 0 ? "warn" : "pass";
|
|
55
|
+
return { name, status, message: diagnostics.length === 0 ? "Passed" : diagnostics.map((item) => `${item.code}: ${item.message}`).join("; ") };
|
|
56
|
+
}
|
|
@@ -1,12 +1,164 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import {
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { appendFileSync, closeSync, copyFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
4
|
import { homedir, tmpdir } from "node:os";
|
|
4
|
-
import { basename, extname, join, resolve } from "node:path";
|
|
5
|
+
import { basename, dirname, extname, join, relative, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
5
7
|
import { detectGameInstallations, resolveGameInstallation, supportedPlatform } from "../game/installations.js";
|
|
6
8
|
import { formatGeneratedContent } from "../types/format.js";
|
|
7
9
|
import { organizeGeneratedDeclarations } from "../types/organize.js";
|
|
8
10
|
const DEFAULT_TIMEOUT_MILLISECONDS = 15 * 60 * 1_000;
|
|
9
11
|
const POLL_INTERVAL_MILLISECONDS = 500;
|
|
12
|
+
const CACHE_SCHEMA = 1;
|
|
13
|
+
const MAX_LOOSE_FILES = 10_000;
|
|
14
|
+
const MAX_LOOSE_BYTES = 512 * 1024 * 1024;
|
|
15
|
+
function toolVersion() {
|
|
16
|
+
let directory = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
for (let depth = 0; depth < 4; depth += 1) {
|
|
18
|
+
const file = join(directory, "package.json");
|
|
19
|
+
if (existsSync(file)) {
|
|
20
|
+
const packageInfo = JSON.parse(readFileSync(file, "utf8"));
|
|
21
|
+
if (packageInfo.name === "@sf-kmods/kdataforgejs-cli" && packageInfo.version)
|
|
22
|
+
return packageInfo.version;
|
|
23
|
+
}
|
|
24
|
+
directory = dirname(directory);
|
|
25
|
+
}
|
|
26
|
+
throw new Error("Cannot determine CLI version for game-data cache key.");
|
|
27
|
+
}
|
|
28
|
+
function sha256(path) {
|
|
29
|
+
const hash = createHash("sha256");
|
|
30
|
+
const file = openSync(path, "r");
|
|
31
|
+
const buffer = Buffer.allocUnsafe(1024 * 1024);
|
|
32
|
+
try {
|
|
33
|
+
let count;
|
|
34
|
+
while ((count = readSync(file, buffer, 0, buffer.length, null)) > 0)
|
|
35
|
+
hash.update(buffer.subarray(0, count));
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
closeSync(file);
|
|
39
|
+
}
|
|
40
|
+
return hash.digest("hex");
|
|
41
|
+
}
|
|
42
|
+
function filesBelow(root) {
|
|
43
|
+
if (!existsSync(root))
|
|
44
|
+
return [];
|
|
45
|
+
const files = [];
|
|
46
|
+
const visit = (directory) => {
|
|
47
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
48
|
+
const path = join(directory, entry.name);
|
|
49
|
+
if (entry.isDirectory())
|
|
50
|
+
visit(path);
|
|
51
|
+
else if (entry.isFile())
|
|
52
|
+
files.push(path);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
visit(root);
|
|
56
|
+
return files.sort();
|
|
57
|
+
}
|
|
58
|
+
function cacheKey(installation, platform, savePath) {
|
|
59
|
+
const hash = createHash("sha256");
|
|
60
|
+
hash.update(JSON.stringify({ schema: CACHE_SCHEMA, tool: toolVersion(), platform,
|
|
61
|
+
root: installation.root, source: installation.source, channel: installation.channel }));
|
|
62
|
+
for (const path of [installation.executable, savePath])
|
|
63
|
+
hash.update(`${path}\0${sha256(path)}\n`);
|
|
64
|
+
const modFiles = filesBelow(join(installation.root, "FactoryGame/Mods"));
|
|
65
|
+
for (const path of modFiles) {
|
|
66
|
+
if (/\.(uplugin|dll|so|pak|ucas|utoc)$/iu.test(path)) {
|
|
67
|
+
hash.update(`${relative(installation.root, path)}\0${sha256(path)}\n`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const factoryGame = join(installation.root, "FactoryGame");
|
|
71
|
+
const looseFiles = [
|
|
72
|
+
...filesBelow(join(factoryGame, "DataForge")),
|
|
73
|
+
...filesBelow(join(factoryGame, "data-editor")),
|
|
74
|
+
...modFiles.filter((path) => /[\\/](?:DataForge|data-editor)[\\/]/iu.test(path)),
|
|
75
|
+
];
|
|
76
|
+
const modPackRoots = modFiles.filter((path) => basename(path).toLowerCase() === "pack.yml").map(dirname);
|
|
77
|
+
for (const path of modFiles) {
|
|
78
|
+
if (modPackRoots.some((packRoot) => path.startsWith(`${packRoot}/`) || path.startsWith(`${packRoot}\\`)))
|
|
79
|
+
looseFiles.push(path);
|
|
80
|
+
}
|
|
81
|
+
let totalBytes = 0;
|
|
82
|
+
const authoredFiles = [...new Set(looseFiles)].filter((path) => !/(?:^|[\\/])(?:node_modules|\.git)(?:[\\/]|$)/iu.test(path) &&
|
|
83
|
+
!/[\\/]typescript[\\/]kdataforgejs[\\/]/iu.test(path) && !/\.kdfdata$/iu.test(path)).sort();
|
|
84
|
+
if (authoredFiles.length > MAX_LOOSE_FILES)
|
|
85
|
+
return undefined;
|
|
86
|
+
for (const path of authoredFiles) {
|
|
87
|
+
totalBytes += statSync(path).size;
|
|
88
|
+
if (totalBytes > MAX_LOOSE_BYTES)
|
|
89
|
+
return undefined;
|
|
90
|
+
hash.update(`${relative(installation.root, path)}\0${sha256(path)}\n`);
|
|
91
|
+
}
|
|
92
|
+
for (const path of filesBelow(join(installation.root, "FactoryGame/Content/Paks"))) {
|
|
93
|
+
const stat = statSync(path);
|
|
94
|
+
hash.update(`${relative(installation.root, path)}\0${stat.size}\0${stat.mtimeMs}\n`);
|
|
95
|
+
}
|
|
96
|
+
return hash.digest("hex");
|
|
97
|
+
}
|
|
98
|
+
function validCache(path) {
|
|
99
|
+
try {
|
|
100
|
+
const receipt = JSON.parse(readFileSync(join(path, "receipt.json"), "utf8"));
|
|
101
|
+
if (receipt.schema !== CACHE_SCHEMA || typeof receipt.files !== "object" || receipt.files === null)
|
|
102
|
+
return false;
|
|
103
|
+
const expected = Object.keys(receipt.files).sort();
|
|
104
|
+
const actual = filesBelow(path).map((file) => relative(path, file).split("\\").join("/")).filter((file) => file !== "receipt.json").sort();
|
|
105
|
+
if (expected.length !== actual.length || expected.some((file, index) => file !== actual[index]))
|
|
106
|
+
return false;
|
|
107
|
+
if (!expected.includes("satisfactory.kdfdata") || !expected.includes("typescript/kdataforgejs/kdataforge.generated.d.ts") ||
|
|
108
|
+
!expected.includes("typescript/kdataforgejs/tsconfig.json"))
|
|
109
|
+
return false;
|
|
110
|
+
return expected.every((file) => sha256(join(path, file)) === receipt.files[file]);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function readCache(cachePath) {
|
|
117
|
+
try {
|
|
118
|
+
const version = readFileSync(join(cachePath, "current"), "utf8").trim();
|
|
119
|
+
if (!/^[a-f0-9]{64}$/u.test(version))
|
|
120
|
+
return undefined;
|
|
121
|
+
const path = join(cachePath, version);
|
|
122
|
+
return validCache(path) ? {
|
|
123
|
+
archive: join(path, "satisfactory.kdfdata"), typesDirectory: join(path, "typescript/kdataforgejs"),
|
|
124
|
+
} : undefined;
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function publishCache(cachePath, artifacts) {
|
|
131
|
+
mkdirSync(cachePath, { recursive: true });
|
|
132
|
+
const stage = mkdtempSync(join(cachePath, ".stage-"));
|
|
133
|
+
try {
|
|
134
|
+
copyFileSync(artifacts.archive, join(stage, "satisfactory.kdfdata"));
|
|
135
|
+
mkdirSync(join(stage, "typescript"), { recursive: true });
|
|
136
|
+
cpSync(artifacts.typesDirectory, join(stage, "typescript/kdataforgejs"), { recursive: true });
|
|
137
|
+
const files = {};
|
|
138
|
+
for (const file of filesBelow(stage))
|
|
139
|
+
files[relative(stage, file).split("\\").join("/")] = sha256(file);
|
|
140
|
+
const receipt = JSON.stringify({ schema: CACHE_SCHEMA, files });
|
|
141
|
+
writeFileSync(join(stage, "receipt.json"), receipt);
|
|
142
|
+
const version = createHash("sha256").update(receipt).digest("hex");
|
|
143
|
+
const versionPath = join(cachePath, version);
|
|
144
|
+
if (existsSync(versionPath) && !validCache(versionPath))
|
|
145
|
+
rmSync(versionPath, { recursive: true, force: true });
|
|
146
|
+
if (!existsSync(versionPath))
|
|
147
|
+
renameSync(stage, versionPath);
|
|
148
|
+
const pointer = join(cachePath, `.current-${process.pid}-${Date.now()}`);
|
|
149
|
+
try {
|
|
150
|
+
writeFileSync(pointer, `${version}\n`, { flag: "wx" });
|
|
151
|
+
renameSync(pointer, join(cachePath, "current"));
|
|
152
|
+
}
|
|
153
|
+
finally {
|
|
154
|
+
rmSync(pointer, { force: true });
|
|
155
|
+
}
|
|
156
|
+
return { archive: join(versionPath, "satisfactory.kdfdata"), typesDirectory: join(versionPath, "typescript/kdataforgejs") };
|
|
157
|
+
}
|
|
158
|
+
finally {
|
|
159
|
+
rmSync(stage, { recursive: true, force: true });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
10
162
|
export async function importGameData(options, dependencies = {}) {
|
|
11
163
|
const timeoutMilliseconds = options.timeoutMilliseconds ?? DEFAULT_TIMEOUT_MILLISECONDS;
|
|
12
164
|
assertValidTimeout(timeoutMilliseconds);
|
|
@@ -14,15 +166,21 @@ export async function importGameData(options, dependencies = {}) {
|
|
|
14
166
|
const installation = selectInstallation(options.gamePath, platform);
|
|
15
167
|
const savePath = resolveSavePath(options.savePath, installation, platform);
|
|
16
168
|
const destination = resolve(options.destination);
|
|
169
|
+
const cacheRoot = join(destination, ".kdataforge/cache");
|
|
170
|
+
const key = cacheKey(installation, platform, savePath);
|
|
171
|
+
const cachePath = key === undefined ? undefined : join(cacheRoot, key);
|
|
172
|
+
const cached = options.force || cachePath === undefined ? undefined : readCache(cachePath);
|
|
173
|
+
if (cached)
|
|
174
|
+
return { ...installExport({ ...options, destination }, installation, cached), cacheHit: true };
|
|
17
175
|
const exportDirectory = mkdtempSync(join(tmpdir(), "kdf-game-data-export-"));
|
|
18
176
|
try {
|
|
19
177
|
const plan = createLaunchPlan(installation, platform, exportDirectory, savePath);
|
|
20
178
|
const launchedGame = await (dependencies.launch ?? launchGame)(plan);
|
|
21
179
|
const artifacts = await waitForExport(exportDirectory, timeoutMilliseconds, dependencies.sleep ?? delay, launchedGame?.exited);
|
|
22
|
-
const result = installExport({ ...options, destination }, installation, artifacts);
|
|
23
180
|
if (launchedGame !== undefined)
|
|
24
181
|
await waitForCleanGameExit(launchedGame.exited);
|
|
25
|
-
|
|
182
|
+
const published = cachePath === undefined ? artifacts : publishCache(cachePath, artifacts);
|
|
183
|
+
return { ...installExport({ ...options, destination }, installation, published), cacheHit: false };
|
|
26
184
|
}
|
|
27
185
|
finally {
|
|
28
186
|
cleanupTemporaryExport(exportDirectory);
|
package/dist/commands/sync.js
CHANGED
|
@@ -9,10 +9,16 @@ import { syncConfigTypes } from "../types/configTypes.js";
|
|
|
9
9
|
export function syncProject(projectRoot) {
|
|
10
10
|
if (!existsSync(projectRoot))
|
|
11
11
|
return { changedPacks: [] };
|
|
12
|
-
const changedPacks = findPackRoots(projectRoot).filter(syncPack);
|
|
12
|
+
const changedPacks = findPackRoots(projectRoot).filter((packRoot) => syncPack(packRoot, true));
|
|
13
13
|
return { changedPacks };
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
/** Reports manifest drift using the same generation path without changing files. */
|
|
16
|
+
export function inspectSyncDrift(projectRoot) {
|
|
17
|
+
if (!existsSync(projectRoot))
|
|
18
|
+
return { changedPacks: [] };
|
|
19
|
+
return { changedPacks: findPackRoots(projectRoot).filter((packRoot) => syncPack(packRoot, false)) };
|
|
20
|
+
}
|
|
21
|
+
function syncPack(packRoot, write) {
|
|
16
22
|
const manifestFile = join(packRoot, "pack.yml");
|
|
17
23
|
const before = readFileSync(manifestFile, "utf8");
|
|
18
24
|
const document = parseDocument(before);
|
|
@@ -33,7 +39,8 @@ function syncPack(packRoot) {
|
|
|
33
39
|
const after = document.toString();
|
|
34
40
|
if (after === before)
|
|
35
41
|
return false;
|
|
36
|
-
|
|
42
|
+
if (write)
|
|
43
|
+
writeFileSync(manifestFile, after);
|
|
37
44
|
return true;
|
|
38
45
|
}
|
|
39
46
|
function setSequence(map, key, values) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sf-kmods/kdataforgejs-cli",
|
|
3
|
-
"version": "2026.4.
|
|
3
|
+
"version": "2026.4.23",
|
|
4
4
|
"description": "kdf - create, type-check and validate KDataForge projects with KDataForgeJS (TypeScript) scripts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Kyri123/Kyrium",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@biomejs/wasm-nodejs": "2.6.3",
|
|
40
40
|
"typescript": ">=5.7.3 <6",
|
|
41
41
|
"yaml": "^2.6.1",
|
|
42
|
-
"@sf-kmods/kdataforgejs": "^2026.4.
|
|
42
|
+
"@sf-kmods/kdataforgejs": "^2026.4.23"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^22.10.0"
|
|
@@ -12,6 +12,8 @@ KDataForge project with a KDataForgeJS (TypeScript) script, created with `kdf in
|
|
|
12
12
|
```sh
|
|
13
13
|
npm install
|
|
14
14
|
npm run refresh # launch game and refresh archive plus generated game types
|
|
15
|
+
npm run doctor # read-only project and installation health
|
|
16
|
+
npm run dev # watch authored files; run KDF.Reload manually after checks pass
|
|
15
17
|
npm run sync # generate imports, hashes and reflection classes from source usage
|
|
16
18
|
npm run check # type-check against @sf-kmods/kdataforgejs
|
|
17
19
|
npm run format # format scripts with bundled Biome
|
|
@@ -21,3 +23,6 @@ npm run hash # refresh sha256 of declared imports after editing them
|
|
|
21
23
|
npm run fix # format scripts and synchronize generated manifest fields
|
|
22
24
|
npm run verify # sync, type-check, lint and validate
|
|
23
25
|
```
|
|
26
|
+
|
|
27
|
+
Use `npx kdf add item Example` (or `recipe`, `handler`, `hook`, `document`) to create a scaffold.
|
|
28
|
+
Edit placeholder item/recipe values before loading the pack. `npx kdf game-data --force` rebuilds cached game data.
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
"description": "KDataForge project with KDataForgeJS (TypeScript) scripts. The DataForge folder is the pack; this file is editor tooling only.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"refresh": "kdf game-data",
|
|
8
|
+
"doctor": "kdf doctor",
|
|
9
|
+
"dev": "kdf dev",
|
|
8
10
|
"sync": "kdf sync",
|
|
9
11
|
"check": "kdf check",
|
|
10
12
|
"format": "kdf format",
|