@arcadia-eternity/content-sdk 4.6.0 → 4.7.1

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.
Files changed (72) hide show
  1. package/README.md +2 -2
  2. package/dist/author-api.d.ts +12 -2
  3. package/dist/author-api.js +11 -2
  4. package/dist/author-git.d.ts +63 -0
  5. package/dist/author-git.js +324 -0
  6. package/dist/author-reference.d.ts +15 -1
  7. package/dist/author-reference.js +20 -1
  8. package/dist/cli.js +5 -4
  9. package/dist/content-query.d.ts +15 -1
  10. package/dist/content-query.js +53 -11
  11. package/dist/content-workspace.d.ts +423 -3
  12. package/dist/content-workspace.js +194 -51
  13. package/dist/debug-environments.d.ts +393 -25
  14. package/dist/debug-environments.js +3 -42
  15. package/dist/demo.js +1 -1
  16. package/dist/effect-declarations.d.ts +14 -0
  17. package/dist/effect-declarations.js +103 -0
  18. package/dist/environment-host-base.d.ts +175 -0
  19. package/dist/environment-host-base.js +86 -0
  20. package/dist/environment-member-transfer.d.ts +5 -0
  21. package/dist/environment-member-transfer.js +95 -0
  22. package/dist/environment-rules.d.ts +728 -3
  23. package/dist/environment-rules.js +158 -74
  24. package/dist/environment-sharing.d.ts +51 -0
  25. package/dist/environment-sharing.js +321 -0
  26. package/dist/environment.d.ts +2 -0
  27. package/dist/environment.js +32 -9
  28. package/dist/jobs.d.ts +5 -0
  29. package/dist/jobs.js +59 -10
  30. package/dist/learnsets.d.ts +47 -0
  31. package/dist/learnsets.js +124 -0
  32. package/dist/lib/content.d.ts +1 -1
  33. package/dist/lib/content.js +26 -2
  34. package/dist/lib/presentation.js +5 -11
  35. package/dist/managed-projects.d.ts +6 -0
  36. package/dist/managed-projects.js +137 -45
  37. package/dist/managed-sources.d.ts +17 -0
  38. package/dist/managed-sources.js +28 -10
  39. package/dist/mcp-contracts.d.ts +405 -4
  40. package/dist/mcp-contracts.js +3 -1
  41. package/dist/mcp.js +23 -1
  42. package/dist/pack-project.d.ts +2 -1
  43. package/dist/pack-project.js +40 -5
  44. package/dist/prepared-document.d.ts +476 -0
  45. package/dist/prepared-document.js +47 -0
  46. package/dist/preview.js +5 -5
  47. package/dist/project.d.ts +3 -1
  48. package/dist/project.js +47 -4
  49. package/dist/rule-composition.d.ts +290 -0
  50. package/dist/rule-composition.js +267 -0
  51. package/dist/template/.github/scripts/release-payload.mjs +91 -0
  52. package/dist/template/.github/scripts/release-test-npm.mjs +27 -0
  53. package/dist/template/.github/scripts/verify-release.mjs +138 -0
  54. package/dist/template/.github/workflows/release-pack.yml +77 -0
  55. package/dist/template/README.md +15 -2
  56. package/dist/template/gitignore-template +7 -0
  57. package/dist/template/npm-lock-template.json +2319 -0
  58. package/dist/template/package.json +4 -2
  59. package/dist/template/skills/arcadia-content-authoring/references/tool-workflows.md +1 -1
  60. package/dist/template/skills/arcadia-content-git/SKILL.md +14 -0
  61. package/dist/template/skills/arcadia-content-release/SKILL.md +29 -0
  62. package/dist/template/test/pack.test.mjs +24 -5
  63. package/dist/testing.d.ts +1 -0
  64. package/dist/testing.js +26 -7
  65. package/dist/workspace-cli.js +2 -2
  66. package/dist/workspace-materials.d.ts +4 -1
  67. package/dist/workspace-materials.js +8 -2
  68. package/dist/workspace.d.ts +11 -0
  69. package/dist/workspace.js +191 -31
  70. package/package.json +16 -4
  71. package/release-payload.mjs +91 -0
  72. package/release-test-npm.mjs +27 -0
@@ -0,0 +1,138 @@
1
+ // Run from the checked-out project after npm ci. The locked SDK builds the content
2
+ // and executes its battle scenarios in a consumer workspace containing the release files.
3
+ import assert from 'node:assert/strict'
4
+ import { execFile } from 'node:child_process'
5
+ import { createHash } from 'node:crypto'
6
+ import { cp, glob, mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises'
7
+ import { createRequire } from 'node:module'
8
+ import { tmpdir } from 'node:os'
9
+ import { basename, dirname, join } from 'node:path'
10
+ import { promisify } from 'node:util'
11
+ import { pathToFileURL } from 'node:url'
12
+ import { ManagedProjects } from '@arcadia-eternity/content-sdk/managed-projects'
13
+ import { releasePayload, normalizeReleaseArchive } from './release-payload.mjs'
14
+
15
+ const root = process.cwd()
16
+ const require = createRequire(import.meta.url)
17
+ const sdk = createRequire(require.resolve('@arcadia-eternity/content-sdk'))
18
+ const { emptyNpmContentHost, prepareNpmProject, resolveNpmInvocation } = await import(
19
+ pathToFileURL(sdk.resolve('@arcadia-eternity/pack-loader/node')).href
20
+ )
21
+ const run = promisify(execFile)
22
+ const json = async file => JSON.parse(await readFile(file, 'utf8'))
23
+ const npm = async (args, cwd) => {
24
+ const command = await resolveNpmInvocation(args)
25
+ return run(command.file, command.args, { cwd, maxBuffer: 32 * 1024 * 1024 })
26
+ }
27
+ const temporary = await mkdtemp(join(tmpdir(), 'arcadia-release-'))
28
+ const staged = join(temporary, 'runtime')
29
+ const installer = new ManagedProjects(join(temporary, 'installer'), { allowThirdPartyContent: true })
30
+ try {
31
+ await mkdir(staged)
32
+ const { stdout } = await npm(['exec', '--offline', '--', 'arcadia-content', 'pack'], root)
33
+ const receipt = JSON.parse(
34
+ stdout
35
+ .split(/\r?\n/)
36
+ .find(line => line.startsWith('ARCADIA_RESULT='))
37
+ .slice('ARCADIA_RESULT='.length),
38
+ )
39
+ assert.match(receipt.filename, /^[a-z0-9][a-z0-9._-]*\.tgz$/)
40
+ const archive = join(root, receipt.filename)
41
+ const built = join(temporary, 'built')
42
+ await mkdir(built)
43
+ await sdk('tar').x({ file: archive, cwd: built, strip: 1, strict: true })
44
+ const source = await json(join(built, 'package.json'))
45
+ const presentation = source.arcadia.presentation ? await json(join(built, source.arcadia.presentation)) : undefined
46
+ const manifest = releasePayload(source, receipt.files, presentation)
47
+ for (const file of manifest.files) {
48
+ if (file === 'package.json') continue
49
+ await mkdir(dirname(join(staged, file)), { recursive: true })
50
+ await cp(join(built, file), join(staged, file))
51
+ }
52
+ await writeFile(join(staged, 'package.json'), JSON.stringify(manifest, null, 2) + '\n')
53
+ const { stdout: packed } = await npm(['pack', '--json', '--ignore-scripts', '--pack-destination', temporary], staged)
54
+ const [result] = JSON.parse(packed)
55
+ assert.equal(result.filename, receipt.filename)
56
+ assert.deepEqual(result.files.map(entry => entry.path).sort(), manifest.files)
57
+ const file = join(temporary, result.filename)
58
+ const normalized = await normalizeReleaseArchive(file)
59
+ const digest = createHash('sha512')
60
+ .update(await readFile(file))
61
+ .digest()
62
+ const integrity = 'sha512-' + digest.toString('base64')
63
+ assert.equal(normalized.integrity, integrity)
64
+ if (process.env.EXPECTED_INTEGRITY)
65
+ assert.equal(integrity, process.env.EXPECTED_INTEGRITY, 'Archive differs from the verified desktop release')
66
+
67
+ const consumer = join(temporary, 'consumer')
68
+ await mkdir(join(consumer, 'candidates'), { recursive: true })
69
+ await cp(file, join(consumer, 'candidates/release.tgz'))
70
+ await installer.prepareProject(
71
+ {
72
+ schemaVersion: 1,
73
+ id: 'release',
74
+ name: 'Release',
75
+ packages: { [manifest.name]: 'file:candidates/release.tgz' },
76
+ sources: [],
77
+ },
78
+ { projectDirectory: consumer },
79
+ async directory => {
80
+ const environment = await prepareNpmProject(
81
+ directory,
82
+ emptyNpmContentHost,
83
+ { policy: { profile: 'local-development' } },
84
+ { effectPreparation: 'prebuilt-only' },
85
+ )
86
+ await environment.dispose()
87
+ },
88
+ )
89
+ for (const name of ['test', 'tests', 'debug', 'arcadia.config.mjs']) {
90
+ await cp(join(root, name), join(staged, name), { recursive: true }).catch(error => {
91
+ if (error.code !== 'ENOENT') throw error
92
+ })
93
+ }
94
+ await cp(file, join(staged, result.filename))
95
+ await symlink(
96
+ join(root, 'node_modules'),
97
+ join(staged, 'node_modules'),
98
+ process.platform === 'win32' ? 'junction' : 'dir',
99
+ )
100
+ const scenarios = await Array.fromAsync(
101
+ glob(['test/**/*.test.{mjs,js,cjs}', 'tests/**/*.test.{mjs,js,cjs}'], { cwd: staged }),
102
+ )
103
+ assert.ok(scenarios.length, 'No battle scenarios found')
104
+ const results = await run(process.execPath, ['--test', '--test-reporter=tap', ...scenarios], {
105
+ cwd: staged,
106
+ env: {
107
+ ...process.env,
108
+ ARCADIA_AUTHOR_RESULT: '1',
109
+ ARCADIA_TEST_RELEASE_ROOT: staged,
110
+ ARCADIA_TEST_RELEASE_ARCHIVE: result.filename,
111
+ ARCADIA_TEST_RELEASE_INTEGRITY: integrity,
112
+ ARCADIA_TEST_BASE_NPM: process.env.ARCADIA_NPM_CLI ?? '',
113
+ ARCADIA_NPM_CLI: join(root, '.github/scripts/release-test-npm.mjs'),
114
+ },
115
+ maxBuffer: 32 * 1024 * 1024,
116
+ }).catch(error => {
117
+ process.stderr.write(error.stdout || '')
118
+ throw error
119
+ })
120
+ process.stdout.write(results.stdout)
121
+ const candidates = results.stdout
122
+ .split(/\r?\n/)
123
+ .map(line => line.replace(/^# /, ''))
124
+ .filter(line => line.startsWith('ARCADIA_RESULT='))
125
+ .map(line => JSON.parse(line.slice('ARCADIA_RESULT='.length)).candidate)
126
+ .filter(Boolean)
127
+ assert.ok(
128
+ candidates.length && candidates.every(candidate => candidate.integrity === integrity),
129
+ 'Battle scenarios did not exercise the release archive',
130
+ )
131
+ const output = join(root, 'release-output')
132
+ await mkdir(output)
133
+ await cp(file, join(output, basename(file)))
134
+ await writeFile(join(output, 'SHA512SUMS'), digest.toString('hex') + ' ' + basename(file) + '\n')
135
+ } finally {
136
+ await installer.close()
137
+ await rm(temporary, { recursive: true, force: true })
138
+ }
@@ -0,0 +1,77 @@
1
+ name: Release content pack
2
+ on:
3
+ workflow_dispatch:
4
+ inputs:
5
+ expected_integrity:
6
+ description: SHA-512 integrity of the desktop release archive
7
+ type: string
8
+ required: false
9
+ publish_npm:
10
+ description: Publish the verified archive to npm
11
+ type: boolean
12
+ default: false
13
+ permissions: {}
14
+ jobs:
15
+ verify:
16
+ runs-on: ubuntu-latest
17
+ permissions:
18
+ contents: read
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ with:
22
+ persist-credentials: false
23
+ - uses: actions/setup-node@v4
24
+ with:
25
+ node-version: '24'
26
+ - name: Check selected tag
27
+ run: |
28
+ test "$GITHUB_REF_TYPE" = tag
29
+ test "$GITHUB_REF_NAME" = "v$(node -p 'require("./package.json").version')"
30
+ - run: npm ci --ignore-scripts
31
+ - name: Build and verify release archive
32
+ env:
33
+ EXPECTED_INTEGRITY: ${{ inputs.expected_integrity }}
34
+ run: node .github/scripts/verify-release.mjs
35
+ - uses: actions/upload-artifact@v4
36
+ with:
37
+ name: content-pack
38
+ path: release-output/
39
+ if-no-files-found: error
40
+ github:
41
+ needs: verify
42
+ runs-on: ubuntu-latest
43
+ permissions:
44
+ contents: write
45
+ steps:
46
+ - uses: actions/download-artifact@v4
47
+ with:
48
+ name: content-pack
49
+ - run: sha512sum -c SHA512SUMS
50
+ - name: Publish GitHub Release
51
+ env:
52
+ GH_TOKEN: ${{ github.token }}
53
+ run: gh release create "$GITHUB_REF_NAME" ./*.tgz SHA512SUMS --repo "$GITHUB_REPOSITORY" --verify-tag --generate-notes
54
+ npm:
55
+ if: inputs.publish_npm
56
+ needs: verify
57
+ runs-on: ubuntu-latest
58
+ permissions:
59
+ id-token: write
60
+ contents: read
61
+ steps:
62
+ - uses: actions/download-artifact@v4
63
+ with:
64
+ name: content-pack
65
+ - uses: actions/setup-node@v4
66
+ with:
67
+ node-version: '24'
68
+ - run: sha512sum -c SHA512SUMS
69
+ - name: Check npm repository identity
70
+ run: |
71
+ tar -xOf ./*.tgz package/package.json | node --input-type=commonjs -e '
72
+ const {repository} = JSON.parse(require("node:fs").readFileSync(0, "utf8"))
73
+ const actual = repository?.url?.replace(/^git\+/, "").replace(/\.git$/, "")
74
+ if (actual !== process.env.GITHUB_SERVER_URL + "/" + process.env.GITHUB_REPOSITORY)
75
+ throw Error("Set package.json repository.url to the HTTPS address of this GitHub repository")
76
+ '
77
+ - run: npm publish ./*.tgz --ignore-scripts --access public --registry=https://registry.npmjs.org/
@@ -6,14 +6,27 @@
6
6
 
7
7
  ## Agent 提示与 skill
8
8
 
9
- SDK 构建模板携带 `skills/arcadia-content-authoring/SKILL.md` 和 `skills/seer2-recreate-pet/SKILL.md`。通用内容创作使用前者;按提供的资料复刻精灵使用后者,其中包含文件组织、机制取舍和测试规范,不附带外部数据或获取地址。可让 Agent 直接读取相应文件,无需主仓库。已有项目也可读取安装的 `@arcadia-eternity/content-sdk/dist/template/skills/` 目录;SDK 更新不会自动覆盖项目中的 skill 副本。
9
+ 让助手按任务读取项目中的技能。
10
+
11
+ | 任务 | 文件 |
12
+ | ------------------------ | ------------------------------------------- |
13
+ | 创作内容、编写效果和测试 | `skills/arcadia-content-authoring/SKILL.md` |
14
+ | 根据资料复刻精灵 | `skills/seer2-recreate-pet/SKILL.md` |
15
+ | 提交或同步源码 | `skills/arcadia-content-git/SKILL.md` |
16
+ | 检查发行归档、发布版本 | `skills/arcadia-content-release/SKILL.md` |
17
+
18
+ 已有项目可通过新版 MCP 的 `author_reference` 读取 `git` 或 `release` 主题,也可直接读取已安装 SDK 的 `dist/template/skills/` 目录。
10
19
 
11
20
  ## 分离的表现与资源(v2)
12
21
 
13
22
  表现关联位于 `data/presentations/main.yaml`,资源定义位于 `data/resources/main.yaml`。规则只描述游戏内容,表现通过对象 ID 关联,图片与声音使用稳定资源 ID。移动素材时只更新资源定义的 `source`。见 [表现说明](docs/presentation.md)。
14
23
 
15
- `data/`、`locales/` 和 `src/` 只用于源项目创作。`npm run pack` 发布的归档只包含 `dist/`、被表现清单引用的素材及包元数据;安装后的包为只读,修改内容需要回到本项目重新构建并发布新版本。
24
+ `data/`、`locales/` 和 `src/` 只用于源项目创作。发行检查生成的归档包含预构建内容、效果、声明的素材及包元数据;安装后的包为只读,修改内容需要回到本项目重新构建并发布新版本。
16
25
 
17
26
  ## 依赖内容包
18
27
 
19
28
  复用其他包的技能、印记或资源时,将其声明为 `package.json` 的运行依赖(`dependencies`),并使用已安装版本支持的引用格式。`npm test` 使用标准助手,通过 npm 安装候选及其依赖,再由共享加载器组装环境;不需要另写依赖加载器。官方 base 同样必须是运行依赖,且使用包含静态适配产物的构建版本。不要把开发目录中的 `file:../sdk/*.tgz` 当成可分发的依赖地址。
29
+
30
+ ## 发行
31
+
32
+ 在 Arcadia 工作台选择「检查并生成发行包」,也可以用支持发行检查的 SDK 执行 `arcadia-content workspace . release --execute`。源项目保留 `private: true`。提交版本和锁文件后创建 `v<版本>` 标签。在 GitHub Actions 手动选择该标签运行 **Release content pack**。可选的 npm Trusted Publishing 与 GitHub Release 分发同一份经测试的归档。模板的发行脚本可使用锁定的公开 SDK 4.6.0 运行。桌面启动工作流时会核对本地归档的 SHA-512。
@@ -0,0 +1,7 @@
1
+ node_modules/
2
+ dist/
3
+ .arcadia/
4
+ *.tgz
5
+ release-output/
6
+ .DS_Store
7
+ Thumbs.db