@arcadia-eternity/content-sdk 4.3.3 → 4.4.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 +3 -3
- package/bin/arcadia-content-mcp.mjs +2 -0
- package/bin/arcadia-content.mjs +2 -0
- package/dist/asset-inspect.d.ts +30 -0
- package/dist/asset-inspect.js +84 -0
- package/dist/author-api.d.ts +48 -0
- package/dist/author-api.js +128 -0
- package/dist/author-reference.d.ts +61 -0
- package/dist/author-reference.js +130 -0
- package/dist/build-content.d.ts +2 -0
- package/dist/build-content.js +29 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +81 -0
- package/dist/content-query.d.ts +30 -0
- package/dist/content-query.js +326 -0
- package/dist/content-workspace.d.ts +204 -0
- package/dist/content-workspace.js +981 -0
- package/dist/debug-environments.d.ts +96 -0
- package/dist/debug-environments.js +135 -0
- package/dist/demo.d.ts +1 -0
- package/dist/demo.js +18 -0
- package/dist/effect-build.d.ts +3 -0
- package/dist/effect-build.js +44 -0
- package/dist/environment-rules.d.ts +7 -0
- package/dist/environment-rules.js +94 -0
- package/dist/environment.d.ts +48 -0
- package/dist/environment.js +184 -0
- package/dist/job-journal.d.ts +19 -0
- package/dist/job-journal.js +110 -0
- package/dist/jobs.d.ts +103 -0
- package/dist/jobs.js +626 -0
- package/dist/lib/content.d.ts +24 -0
- package/dist/lib/content.js +106 -0
- package/dist/lib/presentation.d.ts +26 -0
- package/dist/lib/presentation.js +252 -0
- package/dist/lib/yaml-sharing.d.ts +16 -0
- package/dist/lib/yaml-sharing.js +130 -0
- package/dist/managed-projects.d.ts +37 -0
- package/dist/managed-projects.js +305 -0
- package/dist/managed-sources.d.ts +28 -0
- package/dist/managed-sources.js +541 -0
- package/dist/mcp-contracts.d.ts +420 -0
- package/dist/mcp-contracts.js +146 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +228 -0
- package/dist/module-path.d.ts +1 -0
- package/dist/module-path.js +8 -0
- package/dist/pack-project.d.ts +10 -0
- package/dist/pack-project.js +178 -0
- package/dist/preview-control.d.ts +17 -0
- package/dist/preview-control.js +273 -0
- package/dist/preview.d.ts +24 -0
- package/dist/preview.js +332 -0
- package/dist/project-teams.d.ts +51 -0
- package/dist/project-teams.js +106 -0
- package/dist/project.d.ts +18 -0
- package/dist/project.js +146 -0
- package/dist/rename.d.ts +2 -0
- package/dist/rename.js +128 -0
- package/dist/setup.d.ts +2 -0
- package/dist/setup.js +117 -0
- package/dist/source-lock.d.ts +9 -0
- package/dist/source-lock.js +117 -0
- package/dist/template/README.md +2 -0
- package/dist/template/docs/presentation.md +3 -3
- package/dist/template/package.json +3 -7
- package/dist/template/test/pack.test.mjs +10 -7
- package/dist/testing.d.ts +58 -0
- package/dist/testing.js +205 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.js +14 -0
- package/dist/workbench-context.d.ts +10 -0
- package/dist/workbench-context.js +27 -0
- package/dist/workspace-cli.d.ts +1 -0
- package/dist/workspace-cli.js +66 -0
- package/dist/workspace-materials.d.ts +19 -0
- package/dist/workspace-materials.js +165 -0
- package/dist/workspace.d.ts +190 -0
- package/dist/workspace.js +726 -0
- package/package.json +34 -27
- package/dist/asset-inspect.mjs +0 -67
- package/dist/author-api.mjs +0 -112
- package/dist/author-reference.mjs +0 -121
- package/dist/build-content.mjs +0 -30
- package/dist/cli.mjs +0 -76
- package/dist/content-query.mjs +0 -283
- package/dist/content-workspace.d.mts +0 -161
- package/dist/content-workspace.mjs +0 -936
- package/dist/debug-environments.mjs +0 -154
- package/dist/demo.mjs +0 -22
- package/dist/effect-build.d.mts +0 -2
- package/dist/effect-build.mjs +0 -46
- package/dist/environment-rules.d.mts +0 -5
- package/dist/environment-rules.mjs +0 -92
- package/dist/environment.mjs +0 -183
- package/dist/job-journal.mjs +0 -94
- package/dist/jobs.mjs +0 -579
- package/dist/lib/content.mjs +0 -95
- package/dist/lib/presentation.mjs +0 -240
- package/dist/lib/yaml-sharing.mjs +0 -101
- package/dist/managed-projects.d.mts +0 -35
- package/dist/managed-projects.mjs +0 -303
- package/dist/managed-sources.d.mts +0 -19
- package/dist/managed-sources.mjs +0 -503
- package/dist/mcp-contracts.mjs +0 -153
- package/dist/mcp.mjs +0 -369
- package/dist/pack-project.mjs +0 -157
- package/dist/preview-control.mjs +0 -260
- package/dist/preview.mjs +0 -313
- package/dist/project-teams.mjs +0 -98
- package/dist/project.mjs +0 -140
- package/dist/rename.mjs +0 -112
- package/dist/setup.mjs +0 -134
- package/dist/source-lock.mjs +0 -103
- package/dist/testing.mjs +0 -204
- package/dist/workbench-context.mjs +0 -18
- package/dist/workspace-cli.mjs +0 -60
- package/dist/workspace-materials.mjs +0 -153
- package/dist/workspace.mjs +0 -684
- /package/dist/{index.d.mts → index.d.ts} +0 -0
- /package/dist/{index.mjs → index.js} +0 -0
package/package.json
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcadia-eternity/content-sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=24 <25"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
|
-
"arcadia-content": "./
|
|
11
|
-
"arcadia-content-mcp": "./
|
|
10
|
+
"arcadia-content": "./bin/arcadia-content.mjs",
|
|
11
|
+
"arcadia-content-mcp": "./bin/arcadia-content-mcp.mjs"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"types": "./dist/index.d.
|
|
16
|
-
"default": "./dist/index.
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
17
|
},
|
|
18
|
-
"./testing": "./dist/testing.
|
|
19
|
-
"./workspace": "./dist/author-api.
|
|
18
|
+
"./testing": "./dist/testing.js",
|
|
19
|
+
"./workspace": "./dist/author-api.js",
|
|
20
20
|
"./management-workspace": {
|
|
21
|
-
"types": "./dist/content-workspace.d.
|
|
22
|
-
"import": "./dist/content-workspace.
|
|
23
|
-
"default": "./dist/content-workspace.
|
|
21
|
+
"types": "./dist/content-workspace.d.ts",
|
|
22
|
+
"import": "./dist/content-workspace.js",
|
|
23
|
+
"default": "./dist/content-workspace.js"
|
|
24
24
|
},
|
|
25
25
|
"./managed-projects": {
|
|
26
|
-
"types": "./dist/managed-projects.d.
|
|
27
|
-
"import": "./dist/managed-projects.
|
|
28
|
-
"default": "./dist/managed-projects.
|
|
26
|
+
"types": "./dist/managed-projects.d.ts",
|
|
27
|
+
"import": "./dist/managed-projects.js",
|
|
28
|
+
"default": "./dist/managed-projects.js"
|
|
29
29
|
},
|
|
30
30
|
"./environment-rules": {
|
|
31
|
-
"types": "./dist/environment-rules.d.
|
|
32
|
-
"import": "./dist/environment-rules.
|
|
33
|
-
"default": "./dist/environment-rules.
|
|
31
|
+
"types": "./dist/environment-rules.d.ts",
|
|
32
|
+
"import": "./dist/environment-rules.js",
|
|
33
|
+
"default": "./dist/environment-rules.js"
|
|
34
34
|
},
|
|
35
35
|
"./build": {
|
|
36
|
-
"types": "./dist/effect-build.d.
|
|
37
|
-
"import": "./dist/effect-build.
|
|
36
|
+
"types": "./dist/effect-build.d.ts",
|
|
37
|
+
"import": "./dist/effect-build.js"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
|
+
"bin",
|
|
41
42
|
"dist",
|
|
42
43
|
"LICENSE"
|
|
43
44
|
],
|
|
@@ -45,16 +46,16 @@
|
|
|
45
46
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
46
47
|
"chokidar": "^6.0.0",
|
|
47
48
|
"mime-types": "^3.0.2",
|
|
48
|
-
"semver": "7.
|
|
49
|
-
"tar": "^7.5.
|
|
50
|
-
"
|
|
51
|
-
"typescript": "6.0.3",
|
|
49
|
+
"semver": "7.8.6",
|
|
50
|
+
"tar": "^7.5.22",
|
|
51
|
+
"typescript": "npm:typescript-native-bridge@6.0.3-bridge.19.tsgo.7.0.2",
|
|
52
52
|
"write-file-atomic": "^8.0.0",
|
|
53
|
-
"yaml": "2.
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"@arcadia-eternity/
|
|
57
|
-
"@arcadia-eternity/
|
|
53
|
+
"yaml": "2.9.1",
|
|
54
|
+
"yauzl": "3.4.0",
|
|
55
|
+
"zod": "4.6.7",
|
|
56
|
+
"@arcadia-eternity/battle": "4.4.0",
|
|
57
|
+
"@arcadia-eternity/schema": "4.4.0",
|
|
58
|
+
"@arcadia-eternity/pack-loader": "4.4.0"
|
|
58
59
|
},
|
|
59
60
|
"repository": {
|
|
60
61
|
"type": "git",
|
|
@@ -65,6 +66,12 @@
|
|
|
65
66
|
"registry": "https://registry.npmjs.org",
|
|
66
67
|
"access": "public"
|
|
67
68
|
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@types/mime-types": "^3.0.1",
|
|
71
|
+
"@types/semver": "7.8.0",
|
|
72
|
+
"@types/write-file-atomic": "^4.0.3",
|
|
73
|
+
"@types/yauzl": "^3.4.0"
|
|
74
|
+
},
|
|
68
75
|
"scripts": {
|
|
69
76
|
"build": "node build.mjs",
|
|
70
77
|
"test:run": "node --test --test-concurrency=1 test/*.test.mjs",
|
package/dist/asset-inspect.mjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { stat } from 'node:fs/promises'
|
|
2
|
-
import { lookup } from 'mime-types'
|
|
3
|
-
import { validResourceId } from './lib/presentation.mjs'
|
|
4
|
-
import { WorkspaceError } from './workspace.mjs'
|
|
5
|
-
|
|
6
|
-
export const imageByteLimit = 2 * 1024 * 1024
|
|
7
|
-
const fail = (code, message) => {
|
|
8
|
-
throw new WorkspaceError(code, message)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** Read declared local resources only; remote URLs remain metadata and are never fetched. */
|
|
12
|
-
export async function inspectAsset(workspace, { id, includeImage = false } = {}) {
|
|
13
|
-
if (!validResourceId(id)) fail('RESOURCE_INVALID', '需要已声明资源的稳定 ID')
|
|
14
|
-
if (typeof includeImage !== 'boolean') fail('RESOURCE_INVALID', 'includeImage 必须是布尔值')
|
|
15
|
-
const snapshot = await workspace.snapshot()
|
|
16
|
-
const resources = snapshot.records.filter(row => row.kind === 'resources' && row.record.id === id)
|
|
17
|
-
if (!resources.length) fail('RESOURCE_UNKNOWN', '此项目没有声明该资源')
|
|
18
|
-
if (resources.length !== 1) fail('RESOURCE_AMBIGUOUS', '资源 ID 不唯一,请先修复重复声明')
|
|
19
|
-
const definition = resources[0]
|
|
20
|
-
const { kind, source } = definition.record
|
|
21
|
-
if (typeof source !== 'string') fail('RESOURCE_INVALID', '资源缺少有效位置')
|
|
22
|
-
const metadata = { id, kind, source, definition: definition.file, definitionVersion: definition.version }
|
|
23
|
-
if (/^https?:\/\//.test(source)) {
|
|
24
|
-
let url
|
|
25
|
-
try {
|
|
26
|
-
url = new URL(source)
|
|
27
|
-
} catch {
|
|
28
|
-
fail('RESOURCE_INVALID', '资源 URL 无效')
|
|
29
|
-
}
|
|
30
|
-
if (url.username || url.password) fail('RESOURCE_INVALID', '资源 URL 不能含有凭据')
|
|
31
|
-
return { metadata: { ...metadata, remote: true, imageAvailable: false, reason: 'REMOTE_NOT_FETCHED' } }
|
|
32
|
-
}
|
|
33
|
-
const path = await workspace.path(source)
|
|
34
|
-
const info = await stat(path)
|
|
35
|
-
if (!info.isFile()) fail('RESOURCE_INVALID', '资源必须是普通文件')
|
|
36
|
-
// Follow the source filename, as the authoring resource pipeline does. Decoding belongs to the client.
|
|
37
|
-
const mimeType = lookup(source) || 'application/octet-stream'
|
|
38
|
-
if (kind !== 'image' && mimeType.startsWith('image/'))
|
|
39
|
-
fail('RESOURCE_KIND_MISMATCH', '声明的资源类型与图片文件名不同')
|
|
40
|
-
const reason =
|
|
41
|
-
kind !== 'image'
|
|
42
|
-
? 'NOT_IMAGE'
|
|
43
|
-
: !mimeType.startsWith('image/')
|
|
44
|
-
? 'IMAGE_FORMAT_UNKNOWN'
|
|
45
|
-
: info.size > imageByteLimit
|
|
46
|
-
? 'IMAGE_TOO_LARGE'
|
|
47
|
-
: undefined
|
|
48
|
-
const result = {
|
|
49
|
-
metadata: {
|
|
50
|
-
...metadata,
|
|
51
|
-
remote: false,
|
|
52
|
-
bytes: info.size,
|
|
53
|
-
mimeType,
|
|
54
|
-
imageAvailable: !reason,
|
|
55
|
-
...(reason ? { reason } : {}),
|
|
56
|
-
imageByteLimit,
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
if (!includeImage) return result
|
|
60
|
-
if (reason) fail(reason, '此资源不能直接返回图片;请读取元数据或在页面查看')
|
|
61
|
-
const asset = await workspace.asset(source)
|
|
62
|
-
if (asset.bytes.length > imageByteLimit) fail('IMAGE_TOO_LARGE', '图片超过 2 MiB')
|
|
63
|
-
result.metadata.bytes = asset.bytes.length
|
|
64
|
-
result.metadata.version = asset.version
|
|
65
|
-
result.image = { type: 'image', mimeType, data: asset.bytes.toString('base64') }
|
|
66
|
-
return result
|
|
67
|
-
}
|
package/dist/author-api.mjs
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { DebugEnvironments } from './debug-environments.mjs'
|
|
2
|
-
import { ProjectTeams } from './project-teams.mjs'
|
|
3
|
-
import { AuthorWorkspace, WorkspaceError } from './workspace.mjs'
|
|
4
|
-
import { readWorkbenchContext } from './workbench-context.mjs'
|
|
5
|
-
import { AuthorJobs } from './jobs.mjs'
|
|
6
|
-
import { queryContent } from './content-query.mjs'
|
|
7
|
-
import { authorReference } from './author-reference.mjs'
|
|
8
|
-
import { inspectAsset } from './asset-inspect.mjs'
|
|
9
|
-
import { callPreviewControl } from './preview-control.mjs'
|
|
10
|
-
export { createSourceProject, connectDevelopmentSdk, authorConnection } from './project.mjs'
|
|
11
|
-
export { ContentWorkspace } from './content-workspace.mjs'
|
|
12
|
-
export { normalizeEnvironmentDocument } from './debug-environments.mjs'
|
|
13
|
-
|
|
14
|
-
/** Shared operations for the desktop, CLI and MCP adapters. */
|
|
15
|
-
export async function openAuthorSession(directory, options = {}) {
|
|
16
|
-
const workspace = await AuthorWorkspace.open(directory, options)
|
|
17
|
-
const jobs = new AuthorJobs(workspace, options)
|
|
18
|
-
await jobs.initialize()
|
|
19
|
-
return {
|
|
20
|
-
workspace,
|
|
21
|
-
jobs,
|
|
22
|
-
teams: new ProjectTeams(workspace),
|
|
23
|
-
environments: new DebugEnvironments(workspace),
|
|
24
|
-
async describe() {
|
|
25
|
-
const snapshot = await workspace.snapshot()
|
|
26
|
-
return {
|
|
27
|
-
protocolVersion: 1,
|
|
28
|
-
root: snapshot.root,
|
|
29
|
-
name: snapshot.name,
|
|
30
|
-
project: snapshot.project,
|
|
31
|
-
sourceRevision: await workspace.revision(),
|
|
32
|
-
capabilities: { ...snapshot.capabilities, codeExecution: !workspace.readOnly && jobs.execute },
|
|
33
|
-
diagnostics: snapshot.diagnostics,
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
async query(input = {}) {
|
|
37
|
-
return queryContent(workspace, input)
|
|
38
|
-
},
|
|
39
|
-
async call(operation, input = {}) {
|
|
40
|
-
switch (operation) {
|
|
41
|
-
case 'context':
|
|
42
|
-
return readWorkbenchContext(options.contextFile, workspace.root)
|
|
43
|
-
case 'describe':
|
|
44
|
-
return this.describe()
|
|
45
|
-
case 'query':
|
|
46
|
-
return this.query(input)
|
|
47
|
-
case 'reference':
|
|
48
|
-
return authorReference(input)
|
|
49
|
-
case 'asset-inspect':
|
|
50
|
-
return inspectAsset(workspace, input)
|
|
51
|
-
case 'snapshot':
|
|
52
|
-
return workspace.snapshot()
|
|
53
|
-
case 'read':
|
|
54
|
-
return workspace.read(input.file)
|
|
55
|
-
case 'write':
|
|
56
|
-
if (options.readOnly) throw new WorkspaceError('WRITE_DISABLED', '此会话为只读')
|
|
57
|
-
return workspace.write(input)
|
|
58
|
-
case 'save':
|
|
59
|
-
if (options.readOnly) throw new WorkspaceError('WRITE_DISABLED', '此会话为只读')
|
|
60
|
-
return workspace.saveChanges(input)
|
|
61
|
-
case 'start':
|
|
62
|
-
return jobs.start(input)
|
|
63
|
-
case 'job':
|
|
64
|
-
await jobs.refresh()
|
|
65
|
-
return jobs.get(input.jobId)
|
|
66
|
-
case 'jobs':
|
|
67
|
-
await jobs.refresh()
|
|
68
|
-
return jobs.list()
|
|
69
|
-
case 'job-query':
|
|
70
|
-
return jobs.queryJob(input)
|
|
71
|
-
case 'jobs-query':
|
|
72
|
-
return jobs.queryJobs(input)
|
|
73
|
-
case 'job-output':
|
|
74
|
-
return jobs.readJobOutput(input)
|
|
75
|
-
case 'cancel-query':
|
|
76
|
-
await jobs.refresh()
|
|
77
|
-
await jobs.cancel(input.jobId)
|
|
78
|
-
return jobs.queryJob({ jobId: input.jobId })
|
|
79
|
-
case 'team-list':
|
|
80
|
-
return { items: await this.teams.list() }
|
|
81
|
-
case 'team-save':
|
|
82
|
-
return this.teams.save(input)
|
|
83
|
-
case 'team-remove':
|
|
84
|
-
await this.teams.remove(input)
|
|
85
|
-
return { id: input.id, removed: true }
|
|
86
|
-
case 'environment-list':
|
|
87
|
-
return { items: await this.environments.list() }
|
|
88
|
-
case 'environment-save':
|
|
89
|
-
return this.environments.save(input)
|
|
90
|
-
case 'battle': {
|
|
91
|
-
if (workspace.readOnly || !jobs.execute)
|
|
92
|
-
throw new WorkspaceError('EXECUTION_DISABLED', '自动化对局需要可执行的作者会话。')
|
|
93
|
-
await jobs.refresh()
|
|
94
|
-
const job = jobs.get(input.jobId)
|
|
95
|
-
if (job.kind !== 'preview' || job.state !== 'succeeded' || !job.result?.preview?.endpoint)
|
|
96
|
-
throw new WorkspaceError('PREVIEW_NOT_ACTIVE', '此任务没有运行中的试玩候选。')
|
|
97
|
-
const { jobId: _jobId, operation: action, ...args } = input
|
|
98
|
-
return callPreviewControl(job.result.preview.endpoint, action, args)
|
|
99
|
-
}
|
|
100
|
-
case 'cancel':
|
|
101
|
-
await jobs.refresh()
|
|
102
|
-
return jobs.cancel(input.jobId)
|
|
103
|
-
default:
|
|
104
|
-
throw new WorkspaceError('OPERATION_INVALID', '不支持的作者操作')
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
async close() {
|
|
108
|
-
await jobs.close()
|
|
109
|
-
await workspace.close()
|
|
110
|
-
},
|
|
111
|
-
}
|
|
112
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises'
|
|
2
|
-
import { toJsonSchemaCompat } from '@modelcontextprotocol/sdk/server/zod-json-schema-compat.js'
|
|
3
|
-
import { NativeSpeciesSchema, NativeSkillSchema, NativeMarkSchema } from '@arcadia-eternity/battle/engine'
|
|
4
|
-
import { teamEnvelopeSchema, portablePetSchema } from './project-teams.mjs'
|
|
5
|
-
import { EnvironmentDocumentSchema } from './debug-environments.mjs'
|
|
6
|
-
import { WorkspaceError } from './workspace.mjs'
|
|
7
|
-
|
|
8
|
-
export const referenceTopics = ['species', 'skills', 'marks', 'team', 'environment', 'descriptions', 'effects']
|
|
9
|
-
const parserSchemas = { species: NativeSpeciesSchema, skills: NativeSkillSchema, marks: NativeMarkSchema }
|
|
10
|
-
const examples = { species: 'data/species/pet.yaml', skills: 'data/skills/strike.yaml', marks: 'data/marks/slow.yaml' }
|
|
11
|
-
|
|
12
|
-
async function template(file) {
|
|
13
|
-
try {
|
|
14
|
-
return await readFile(new URL(`./template/${file}`, import.meta.url), 'utf8')
|
|
15
|
-
} catch (error) {
|
|
16
|
-
if (error.code !== 'ENOENT') throw error
|
|
17
|
-
return readFile(new URL(`../template/${file}`, import.meta.url), 'utf8')
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Discover installed SDK contracts, without importing a content project's executable effects. */
|
|
22
|
-
export async function authorReference({ topic } = {}) {
|
|
23
|
-
if (!referenceTopics.includes(topic)) throw new WorkspaceError('REFERENCE_UNKNOWN', '请选择有效的作者参考主题')
|
|
24
|
-
if (parserSchemas[topic]) {
|
|
25
|
-
return {
|
|
26
|
-
topic,
|
|
27
|
-
title: `${topic}: parser fields and source example`,
|
|
28
|
-
source: '@arcadia-eternity/battle/engine',
|
|
29
|
-
stage: 'linked-runtime',
|
|
30
|
-
schema: toJsonSchemaCompat(parserSchemas[topic]),
|
|
31
|
-
examples: [{ language: 'yaml', text: await template(examples[topic]) }],
|
|
32
|
-
notes: [
|
|
33
|
-
'This is the actual parser schema AFTER package linking, not a validator for unlinked source documents. JSON Schema cannot express every Zod refinement; run check and tests.',
|
|
34
|
-
'Source IDs are local stable IDs. Package linking produces namespace:id runtime IDs. Official base references retain their existing IDs.',
|
|
35
|
-
'Source relationship slots use {$ref:{projectId,kind,id}} for package content: species learnable_skills[].skill_id uses kind skill; ability/emblem use mark; skills/marks behaviors[].definitionId uses behavior. Declare dependencies and resolve actual IDs before writing.',
|
|
36
|
-
'Keep rules, data/presentations, data/resources and localized names/descriptions separate. Do not infer behavior from description text.',
|
|
37
|
-
],
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (topic === 'team') {
|
|
41
|
-
const schema = toJsonSchemaCompat(teamEnvelopeSchema)
|
|
42
|
-
schema.properties.team.items = JSON.parse(JSON.stringify(portablePetSchema))
|
|
43
|
-
return {
|
|
44
|
-
topic,
|
|
45
|
-
title: 'Portable project team',
|
|
46
|
-
source: '@arcadia-eternity/content-sdk/project-teams',
|
|
47
|
-
stage: 'source',
|
|
48
|
-
schema,
|
|
49
|
-
examples: [{ language: 'yaml', text: 'schemaVersion: 1\nid: blue\nname: 蓝队\nteam: []\n' }],
|
|
50
|
-
notes: [
|
|
51
|
-
'Save debug/teams/<id>.yaml with expectedVersion. Pets have no runtime id. Order determines the lead pet; an empty team is editable but cannot start a battle.',
|
|
52
|
-
'Saving project teams does not change local page drafts, selected teams or an already running battle. Re-read before retrying a conflict.',
|
|
53
|
-
],
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (topic === 'environment') {
|
|
57
|
-
return {
|
|
58
|
-
topic,
|
|
59
|
-
title: 'Named project environment',
|
|
60
|
-
source: '@arcadia-eternity/content-sdk/debug-environments',
|
|
61
|
-
stage: 'source',
|
|
62
|
-
schema: toJsonSchemaCompat(EnvironmentDocumentSchema),
|
|
63
|
-
examples: [
|
|
64
|
-
{
|
|
65
|
-
language: 'json',
|
|
66
|
-
text: JSON.stringify({ schemaVersion: 1, id: 'interaction', name: '双包交互', packages: {}, sources: [] }),
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
notes: [
|
|
70
|
-
'default is built in and cannot be saved as a named environment. Names must be nonblank; source package names must be unique.',
|
|
71
|
-
'packages accepts registry version constraints, never file:/link:/workspace: or filesystem paths. sources lists package names already mapped locally; it does not contain paths.',
|
|
72
|
-
'Save with expectedVersion. Updating a named environment neither selects it in the page nor changes a running candidate; prepare a new preview explicitly.',
|
|
73
|
-
],
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (topic === 'effects') {
|
|
77
|
-
return {
|
|
78
|
-
topic,
|
|
79
|
-
title: 'Native TypeScript effects',
|
|
80
|
-
source: '@arcadia-eternity/content-sdk/dist/template/src/effects/slow.effect.ts',
|
|
81
|
-
examples: [{ language: 'typescript', text: await template('src/effects/slow.effect.ts') }],
|
|
82
|
-
notes: [
|
|
83
|
-
'Import EffectModuleContext from @arcadia-eternity/content-sdk and use the host-supplied SDK. Importing an effect module must not register global state.',
|
|
84
|
-
'defineCodeEffect uses triggers/apply. ctx.trigger identifies the trigger; ctx.parent is the typed parent context. Use stable namespaced IDs and actual behavior definitions.',
|
|
85
|
-
'This installed template is the executable example. Query content, read source versions, check, and run behavior tests after edits. No Rule Graph/DSL conversion is needed.',
|
|
86
|
-
],
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
topic,
|
|
91
|
-
title: 'ICU descriptions and semantic tags',
|
|
92
|
-
source: 'docs/guides/content-presentation.md; packages/web-ui/src/i18n/richDescription.ts',
|
|
93
|
-
tags: [
|
|
94
|
-
'markName',
|
|
95
|
-
'status',
|
|
96
|
-
'guaranteedHit',
|
|
97
|
-
'damage',
|
|
98
|
-
'heal',
|
|
99
|
-
'shield',
|
|
100
|
-
'buff',
|
|
101
|
-
'debuff',
|
|
102
|
-
'rage',
|
|
103
|
-
'strong',
|
|
104
|
-
'emphasis',
|
|
105
|
-
'mark',
|
|
106
|
-
],
|
|
107
|
-
examples: [
|
|
108
|
-
{
|
|
109
|
-
language: 'text',
|
|
110
|
-
text: '造成 <damage>{power}</damage> 点伤害,并附加 <mark>example-content-pack:slow</mark>。',
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
notes: [
|
|
114
|
-
'Names are plain text. Descriptions use ICU flat variables such as {power}, plural/select, and the listed semantic tags; no Markdown, HTML attributes, dotted expressions, or legacy color codes.',
|
|
115
|
-
'Only scalar public values from the actual rendering context are available. Definition previews have no live stack and preserve {stack}; battle descriptions use the real instance stack.',
|
|
116
|
-
'markName highlights ordinary marks in cyan. status highlights the adverse/exceptional display subclass in orange. guaranteedHit describes the skill property in lime. Do not modify gameplay tags merely for color.',
|
|
117
|
-
'<mark>namespace:id</mark> is the current mark reference. Plain highlighted names are not identities. Resolve real dependency-visible targets; never guess a matching object by name.',
|
|
118
|
-
'A general cross-kind reference protocol, exhaustive variable contract and shared reference-integrity validator are not implemented. Formatting checks do not prove all references are valid.',
|
|
119
|
-
],
|
|
120
|
-
}
|
|
121
|
-
}
|
package/dist/build-content.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { mkdir, rename, rm, writeFile } from 'node:fs/promises'
|
|
3
|
-
import { join, resolve } from 'node:path'
|
|
4
|
-
import { readContentSources, assembleContent } from './lib/content.mjs'
|
|
5
|
-
import { buildPresentation } from './lib/presentation.mjs'
|
|
6
|
-
|
|
7
|
-
const args = process.argv.slice(2)
|
|
8
|
-
if (args.length && (args.length !== 1 || args[0] !== '--check')) throw new Error('Usage: build-content.mjs [--check]')
|
|
9
|
-
const root = resolve('.')
|
|
10
|
-
const sources = await readContentSources(root)
|
|
11
|
-
const content = assembleContent(sources)
|
|
12
|
-
const presentation = await buildPresentation(root, sources)
|
|
13
|
-
if (!args.includes('--check')) {
|
|
14
|
-
const directory = join(root, 'dist')
|
|
15
|
-
await mkdir(directory, { recursive: true })
|
|
16
|
-
const temporary = join(directory, `content.${process.pid}.tmp`)
|
|
17
|
-
try {
|
|
18
|
-
await writeFile(temporary, JSON.stringify(content, null, 2) + '\n', { flag: 'wx' })
|
|
19
|
-
await writeFile(join(directory, 'presentation.json.tmp'), JSON.stringify(presentation, null, 2) + '\n')
|
|
20
|
-
await rename(join(directory, 'presentation.json.tmp'), join(directory, 'presentation.json'))
|
|
21
|
-
await rename(temporary, join(directory, 'content.json'))
|
|
22
|
-
} finally {
|
|
23
|
-
await rm(temporary, { force: true })
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
console.log(
|
|
27
|
-
`${args.includes('--check') ? 'Checked' : 'Built'} ${sources.length} data files: ${Object.entries(content.data)
|
|
28
|
-
.map(([kind, records]) => `${kind}=${records.length}`)
|
|
29
|
-
.join(', ')}`,
|
|
30
|
-
)
|
package/dist/cli.mjs
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { spawn } from 'node:child_process'
|
|
3
|
-
import { createRequire } from 'node:module'
|
|
4
|
-
import { fileURLToPath } from 'node:url'
|
|
5
|
-
const require = createRequire(import.meta.url)
|
|
6
|
-
const [command, ...args] = process.argv.slice(2)
|
|
7
|
-
const help = `arcadia-content <command>
|
|
8
|
-
check Check TypeScript and JSON/YAML content
|
|
9
|
-
build Compile TypeScript and assemble content/media/locales metadata
|
|
10
|
-
rename Change package/project/namespace identities and local references
|
|
11
|
-
demo Run the battle configured in arcadia.config.mjs
|
|
12
|
-
preview Prepare a local candidate for the full battle client; stop with Ctrl+C
|
|
13
|
-
pack Check, build and create an npm content package
|
|
14
|
-
setup Install the pinned development SDK and tool
|
|
15
|
-
workspace <directory> <operation> [--execute] Structured author operations
|
|
16
|
-
`
|
|
17
|
-
function run(file, arguments_) {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
const child = spawn(file, arguments_, { stdio: 'inherit', cwd: process.cwd() })
|
|
20
|
-
child.on('error', reject)
|
|
21
|
-
child.on('exit', (code, signal) =>
|
|
22
|
-
code === 0 ? resolve() : reject(new Error(`${file} failed (${signal ?? code})`)),
|
|
23
|
-
)
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
const modulePath = name => fileURLToPath(new URL(name, import.meta.url))
|
|
27
|
-
async function data(check = false) {
|
|
28
|
-
await run(process.execPath, [modulePath('./build-content.mjs'), ...(check ? ['--check'] : [])])
|
|
29
|
-
}
|
|
30
|
-
async function types(check = false) {
|
|
31
|
-
await run(process.execPath, [
|
|
32
|
-
require.resolve('typescript/bin/tsc'),
|
|
33
|
-
'-p',
|
|
34
|
-
'tsconfig.json',
|
|
35
|
-
...(check ? ['--noEmit'] : []),
|
|
36
|
-
])
|
|
37
|
-
}
|
|
38
|
-
async function build() {
|
|
39
|
-
await data(true)
|
|
40
|
-
await types()
|
|
41
|
-
await data()
|
|
42
|
-
const { buildEffects } = await import('./effect-build.mjs')
|
|
43
|
-
await buildEffects(process.cwd())
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
if (!command || command === '--help' || command === '-h') console.log(help)
|
|
47
|
-
else if (command === 'workspace') {
|
|
48
|
-
const { workspaceCli } = await import('./workspace-cli.mjs')
|
|
49
|
-
await workspaceCli(args)
|
|
50
|
-
} else if (command === 'setup') {
|
|
51
|
-
const { setup } = await import('./setup.mjs')
|
|
52
|
-
await setup(args)
|
|
53
|
-
} else if (command === 'rename') await run(process.execPath, [modulePath('./rename.mjs'), ...args])
|
|
54
|
-
else {
|
|
55
|
-
if (!['check', 'build', 'demo', 'preview', 'pack'].includes(command) || args.length)
|
|
56
|
-
throw new Error(`Unknown command or option.\n${help}`)
|
|
57
|
-
if (command === 'check') {
|
|
58
|
-
await data(true)
|
|
59
|
-
await types(true)
|
|
60
|
-
} else if (command === 'build') await build()
|
|
61
|
-
else if (command === 'demo') await import('./demo.mjs')
|
|
62
|
-
else if (command === 'preview') await (await import('./preview.mjs')).previewCommand()
|
|
63
|
-
else {
|
|
64
|
-
await build()
|
|
65
|
-
const { packBuiltProject } = await import('./pack-project.mjs')
|
|
66
|
-
const packed = await packBuiltProject()
|
|
67
|
-
console.log(`Packed ${packed.filename}`)
|
|
68
|
-
console.log(
|
|
69
|
-
`ARCADIA_RESULT=${JSON.stringify({ filename: packed.filename, integrity: packed.integrity, shasum: packed.shasum, files: packed.files.map(file => file.path) })}`,
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} catch (error) {
|
|
74
|
-
console.error(error.message)
|
|
75
|
-
process.exitCode = 1
|
|
76
|
-
}
|