@arcadia-eternity/content-sdk 4.13.0 → 4.14.0
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 -5
- package/dist/appimage-sdk.d.ts +2 -0
- package/dist/appimage-sdk.js +110 -0
- package/dist/author-api.d.ts +6 -1
- package/dist/author-api.js +27 -3
- package/dist/author-environment-install.d.ts +14 -0
- package/dist/author-environment-install.js +104 -0
- package/dist/author-environment-source.d.ts +162 -0
- package/dist/author-environment-source.js +226 -0
- package/dist/author-install.d.ts +22 -0
- package/dist/author-install.js +289 -0
- package/dist/author-reference.d.ts +1 -1
- package/dist/author-reference.js +23 -4
- package/dist/cli.js +56 -23
- package/dist/command-discovery.d.ts +3 -0
- package/dist/command-discovery.js +122 -0
- package/dist/content-query.js +4 -1
- package/dist/content-workspace.d.ts +2 -138
- package/dist/content-workspace.js +6 -6
- package/dist/debug-environment-install.d.ts +15 -0
- package/dist/debug-environment-install.js +130 -0
- package/dist/debug-environments.d.ts +135 -0
- package/dist/debug-environments.js +48 -0
- package/dist/demo.js +22 -8
- package/dist/desktop-cli.d.ts +3 -0
- package/dist/desktop-cli.js +72 -0
- package/dist/desktop-client.d.ts +71 -0
- package/dist/desktop-client.js +162 -0
- package/dist/environment-demo.d.ts +8 -0
- package/dist/environment-demo.js +52 -0
- package/dist/environment-rules.js +38 -19
- package/dist/environment.d.ts +12 -8
- package/dist/environment.js +107 -58
- package/dist/init.d.ts +1 -0
- package/dist/init.js +125 -0
- package/dist/jobs.d.ts +3 -1
- package/dist/jobs.js +34 -15
- package/dist/managed-projects.d.ts +5 -1
- package/dist/managed-projects.js +3 -3
- package/dist/mcp-contracts.d.ts +28 -1
- package/dist/mcp-contracts.js +24 -1
- package/dist/mcp.js +21 -7
- package/dist/official-environment-packages.d.ts +6 -0
- package/dist/official-environment-packages.js +19 -0
- package/dist/official-environments.d.ts +7 -0
- package/dist/official-environments.js +25 -0
- package/dist/pack-project.d.ts +1 -0
- package/dist/pack-project.js +66 -0
- package/dist/package-updates.d.ts +2 -1
- package/dist/package-updates.js +30 -17
- package/dist/prepared-document.d.ts +1 -0
- package/dist/prepared-document.js +5 -13
- package/dist/preview-control.js +24 -1
- package/dist/preview.d.ts +1 -0
- package/dist/preview.js +6 -4
- package/dist/project.d.ts +1 -0
- package/dist/project.js +57 -18
- package/dist/template/README.md +8 -8
- package/dist/template/package.json +2 -2
- package/dist/template/skills/arcadia-content-authoring/SKILL.md +15 -2
- package/dist/template/skills/arcadia-content-authoring/references/tool-workflows.md +25 -1
- package/dist/testing.d.ts +3 -4
- package/dist/testing.js +22 -8
- package/dist/workspace-cli.js +6 -4
- package/dist/workspace.d.ts +1 -0
- package/dist/workspace.js +66 -15
- package/package.json +10 -5
package/dist/workspace.js
CHANGED
|
@@ -2,7 +2,7 @@ import { sha256Hex, sha256StreamHex } from '@arcadia-eternity/const';
|
|
|
2
2
|
import { isContentLocaleField, contentLocaleCollection } from '@arcadia-eternity/schema';
|
|
3
3
|
import { createReadStream } from 'node:fs';
|
|
4
4
|
import { lstat, mkdir, readdir, readFile, realpath, unlink } from 'node:fs/promises';
|
|
5
|
-
import { dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
5
|
+
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
6
6
|
import { EventEmitter } from 'node:events';
|
|
7
7
|
import { isDeepStrictEqual } from 'node:util';
|
|
8
8
|
import YAML from 'yaml';
|
|
@@ -12,6 +12,8 @@ import writeFileAtomic from 'write-file-atomic';
|
|
|
12
12
|
import { resourceReferences, bindingPresentation, validResourceId, validAssetPath } from './lib/presentation.js';
|
|
13
13
|
import { yamlSharing, recordSharing, changedSharedField, sharingSignature } from './lib/yaml-sharing.js';
|
|
14
14
|
import { withSourceLock } from './source-lock.js';
|
|
15
|
+
import { readJson } from './workspace-materials.js';
|
|
16
|
+
import { environmentProjectDocument } from './debug-environments.js';
|
|
15
17
|
import { errorCode, errorMessage, isRecord } from './types.js';
|
|
16
18
|
export const desktopMetadataNames = new Set(['.DS_Store', 'Thumbs.db']);
|
|
17
19
|
const ignored = new Set(['node_modules', 'dist', '.git', '.arcadia', ...desktopMetadataNames]);
|
|
@@ -53,6 +55,32 @@ const textLimit = 2 * 1024 * 1024;
|
|
|
53
55
|
const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
54
56
|
const isBaseManifest = (manifest) => manifest.name === basePackageName || manifest.arcadia?.projectId === baseProjectId;
|
|
55
57
|
const isInstalledPackage = (root) => root.split(sep).includes('node_modules');
|
|
58
|
+
// Author projects can declare local dependency archives under candidates/.
|
|
59
|
+
// Those inputs participate in snapshots, unlike generated pack outputs.
|
|
60
|
+
function ignoredArchive(file) {
|
|
61
|
+
return file.endsWith('.tgz') && !/^candidates\/[a-zA-Z0-9_.-]+\.tgz$/.test(file);
|
|
62
|
+
}
|
|
63
|
+
async function isManagedEnvironment(root) {
|
|
64
|
+
try {
|
|
65
|
+
await lstat(join(root, '.arcadia-prepared.json'));
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (errorCode(error) !== 'ENOENT')
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
const parent = dirname(root);
|
|
73
|
+
if (!['environments', 'staging', 'imports', 'migration-backups'].includes(basename(parent)))
|
|
74
|
+
return false;
|
|
75
|
+
try {
|
|
76
|
+
return (await readJson(join(dirname(parent), 'workspace.json'))).format === 'arcadia.content-workspace/2';
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
if (errorCode(error) === 'ENOENT')
|
|
80
|
+
return false;
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
56
84
|
export class WorkspaceError extends Error {
|
|
57
85
|
code;
|
|
58
86
|
file;
|
|
@@ -150,6 +178,7 @@ function serializeForm(parsed, next, file, original) {
|
|
|
150
178
|
/** Ordinary source files are authoritative. No project database or generated-output writes. */
|
|
151
179
|
export class AuthorWorkspace extends EventEmitter {
|
|
152
180
|
root;
|
|
181
|
+
projectKind = 'pack';
|
|
153
182
|
published = false;
|
|
154
183
|
readOnly = false;
|
|
155
184
|
baseProject;
|
|
@@ -173,17 +202,23 @@ export class AuthorWorkspace extends EventEmitter {
|
|
|
173
202
|
fail('PROJECT_INVALID', '基础包身份不一致', 'pack.json');
|
|
174
203
|
workspace.baseProject = { projectId: baseProjectId, namespace: baseProjectId };
|
|
175
204
|
}
|
|
176
|
-
if (!workspace.baseProject &&
|
|
205
|
+
if (!workspace.baseProject && !manifest.arcadia && object(manifest.arcadiaEnvironment)) {
|
|
206
|
+
workspace.projectKind = 'environment';
|
|
207
|
+
workspace.readOnly ||= await isManagedEnvironment(workspace.root);
|
|
208
|
+
}
|
|
209
|
+
else if (!workspace.baseProject &&
|
|
177
210
|
(!object(manifest.arcadia) ||
|
|
178
211
|
typeof manifest.arcadia.projectId !== 'string' ||
|
|
179
212
|
typeof manifest.arcadia.namespace !== 'string'))
|
|
180
|
-
fail('PROJECT_INVALID', '请选择包含 arcadia
|
|
213
|
+
fail('PROJECT_INVALID', '请选择包含 arcadia 身份的资料包或 arcadiaEnvironment 环境包', 'package.json');
|
|
181
214
|
if (watch) {
|
|
182
215
|
workspace.#watcher = chokidar.watch(workspace.root, {
|
|
183
216
|
ignoreInitial: true,
|
|
184
|
-
ignored: path =>
|
|
185
|
-
.split(sep)
|
|
186
|
-
.some(part =>
|
|
217
|
+
ignored: path => {
|
|
218
|
+
const parts = relative(workspace.root, path).split(sep);
|
|
219
|
+
return (parts.some(part => ignored.has(part) && !(workspace.published && part === 'dist')) ||
|
|
220
|
+
ignoredArchive(parts.join('/')));
|
|
221
|
+
},
|
|
187
222
|
atomic: true,
|
|
188
223
|
awaitWriteFinish: { stabilityThreshold: 150, pollInterval: 50 },
|
|
189
224
|
followSymlinks: false,
|
|
@@ -198,8 +233,10 @@ export class AuthorWorkspace extends EventEmitter {
|
|
|
198
233
|
return workspace;
|
|
199
234
|
}
|
|
200
235
|
async assertWritable() {
|
|
201
|
-
if (this.readOnly ||
|
|
202
|
-
|
|
236
|
+
if (this.readOnly ||
|
|
237
|
+
isBaseManifest(JSON.parse((await this.read('package.json')).text)) ||
|
|
238
|
+
(this.projectKind === 'environment' && (await isManagedEnvironment(this.root))))
|
|
239
|
+
fail('WRITE_DISABLED', '此项目为只读,请在自己的源项目中创作。');
|
|
203
240
|
}
|
|
204
241
|
async path(file, { create = false } = {}) {
|
|
205
242
|
if (this.#closed)
|
|
@@ -245,9 +282,9 @@ export class AuthorWorkspace extends EventEmitter {
|
|
|
245
282
|
const result = [];
|
|
246
283
|
const walk = async (directory, prefix = '') => {
|
|
247
284
|
for (const entry of (await readdir(directory, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
248
|
-
if ((ignored.has(entry.name) && !(this.published && entry.name === 'dist')) || entry.name.endsWith('.tgz'))
|
|
249
|
-
continue;
|
|
250
285
|
const file = prefix + entry.name;
|
|
286
|
+
if ((ignored.has(entry.name) && !(this.published && entry.name === 'dist')) || ignoredArchive(file))
|
|
287
|
+
continue;
|
|
251
288
|
if (entry.isSymbolicLink()) {
|
|
252
289
|
result.push({ file, error: '不支持符号链接' });
|
|
253
290
|
continue;
|
|
@@ -332,6 +369,7 @@ export class AuthorWorkspace extends EventEmitter {
|
|
|
332
369
|
const source = await this.read('package.json');
|
|
333
370
|
const manifest = JSON.parse(source.text);
|
|
334
371
|
const project = this.baseProject ?? manifest.arcadia ?? {};
|
|
372
|
+
const environmentProject = this.projectKind === 'environment';
|
|
335
373
|
const readOnly = this.readOnly || isBaseManifest(manifest);
|
|
336
374
|
const baseSources = new Map();
|
|
337
375
|
if (this.baseProject) {
|
|
@@ -345,7 +383,18 @@ export class AuthorWorkspace extends EventEmitter {
|
|
|
345
383
|
}
|
|
346
384
|
const files = await this.files(), records = [], diagnostics = [], ids = new Set();
|
|
347
385
|
const locales = {}, localeSources = [];
|
|
348
|
-
if (
|
|
386
|
+
if (environmentProject) {
|
|
387
|
+
project.kind = 'environment';
|
|
388
|
+
try {
|
|
389
|
+
const { id, name } = environmentProjectDocument(manifest);
|
|
390
|
+
project.id = id;
|
|
391
|
+
project.name = name;
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
diagnostics.push({ ...diagnostic(error), file: source.file });
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
else if (this.published) {
|
|
349
398
|
const arcadia = manifest.arcadia;
|
|
350
399
|
if (!arcadia)
|
|
351
400
|
fail('PROJECT_INVALID', '安装包缺少内容入口', 'package.json');
|
|
@@ -415,7 +464,7 @@ export class AuthorWorkspace extends EventEmitter {
|
|
|
415
464
|
}
|
|
416
465
|
}
|
|
417
466
|
}
|
|
418
|
-
for (const entry of this.published ? [] : files) {
|
|
467
|
+
for (const entry of this.published || environmentProject ? [] : files) {
|
|
419
468
|
if (entry.error) {
|
|
420
469
|
diagnostics.push({ code: 'PATH_INVALID', severity: 'error', file: entry.file, message: entry.error });
|
|
421
470
|
continue;
|
|
@@ -569,11 +618,11 @@ export class AuthorWorkspace extends EventEmitter {
|
|
|
569
618
|
diagnostics,
|
|
570
619
|
capabilities: {
|
|
571
620
|
sourceEditing: !readOnly,
|
|
572
|
-
structuredSaving: !readOnly,
|
|
573
|
-
localeEditing: !readOnly,
|
|
621
|
+
structuredSaving: !readOnly && !environmentProject,
|
|
622
|
+
localeEditing: !readOnly && !environmentProject,
|
|
574
623
|
yamlSharing: 'read-only-fields',
|
|
575
624
|
externalEditor: !readOnly,
|
|
576
|
-
kinds,
|
|
625
|
+
kinds: environmentProject ? [] : kinds,
|
|
577
626
|
sdkApi: project.sdkApi,
|
|
578
627
|
},
|
|
579
628
|
};
|
|
@@ -738,6 +787,8 @@ export class AuthorWorkspace extends EventEmitter {
|
|
|
738
787
|
/** Prepare the whole review first; commit each source once, reporting partial writes explicitly. */
|
|
739
788
|
async saveChanges({ changes }, { fromForm = false } = {}) {
|
|
740
789
|
await this.assertWritable();
|
|
790
|
+
if (this.projectKind === 'environment')
|
|
791
|
+
fail('PROJECT_INVALID', '资料包内容编辑只适用于资料包项目');
|
|
741
792
|
if (!Array.isArray(changes) || !changes.length || changes.length > 1000)
|
|
742
793
|
fail('SOURCE_INVALID', '请选择 1–1000 项修改');
|
|
743
794
|
const catalog = changes.some(change => ['locale', 'create-record'].includes(change?.kind))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcadia-eternity/content-sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.14.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -16,7 +16,12 @@
|
|
|
16
16
|
"default": "./dist/index.js"
|
|
17
17
|
},
|
|
18
18
|
"./testing": "./dist/testing.js",
|
|
19
|
+
"./desktop": {
|
|
20
|
+
"types": "./dist/desktop-client.d.ts",
|
|
21
|
+
"default": "./dist/desktop-client.js"
|
|
22
|
+
},
|
|
19
23
|
"./workspace": "./dist/author-api.js",
|
|
24
|
+
"./project-teams": "./dist/project-teams.js",
|
|
20
25
|
"./prepared-document": {
|
|
21
26
|
"types": "./dist/prepared-document.d.ts",
|
|
22
27
|
"import": "./dist/prepared-document.js"
|
|
@@ -63,10 +68,10 @@
|
|
|
63
68
|
"zod": "4.6.7",
|
|
64
69
|
"fflate": "0.8.3",
|
|
65
70
|
"simple-git": "4.1.0",
|
|
66
|
-
"@arcadia-eternity/
|
|
67
|
-
"@arcadia-eternity/
|
|
68
|
-
"@arcadia-eternity/const": "4.
|
|
69
|
-
"@arcadia-eternity/
|
|
71
|
+
"@arcadia-eternity/battle": "4.14.0",
|
|
72
|
+
"@arcadia-eternity/pack-loader": "4.14.0",
|
|
73
|
+
"@arcadia-eternity/const": "4.14.0",
|
|
74
|
+
"@arcadia-eternity/schema": "4.14.0"
|
|
70
75
|
},
|
|
71
76
|
"repository": {
|
|
72
77
|
"type": "git",
|