refactor(office): Office 技能统一读取包内 assets,移除包外 office-skills 拷贝与 DSH_BUNDLED_OFFICE_SKILLS
- web-app、sdk-app 的 skill-office 不再覆盖 assetRoot;pythonEnvironment 不变 - Desktop 与 Python SDK 打包不再生成 office-skills 资源目录,删除 prepareOfficeSkillAssets 与 skillSource - Desktop 打包 smoke 校验 4 个 Office 技能可从运行时归档列出并加载 - 同步测试、README、Agent Note,新增升级指南 office-skill-resources
This commit is contained in:
1 parent
3f6cd80c9d
commit
9df26413ee
49 files changed
+232
-214
No files matched your search
@@ -26,5 +26,7 @@ describe('Python runtime executable assets', () => {
|
||||
expect(result.stdout).not.toContain('skill-badge/assets/**/*')
|
||||
expect(result.stdout).toContain('node_modules/@deepseek-ai/dsh-sandbox-windows-acl/assets/**/*')
|
||||
expect(result.stdout).not.toContain('node_modules/**/*.py')
|
||||
// skill-office reads its SKILL.md files from the package's assets directory.
|
||||
expect(result.stdout).toContain('"node_modules/**/*.md"')
|
||||
})
|
||||
})
|
||||
@@ -179,7 +179,8 @@ describe('Python runtime executable builder CLI', () => {
|
||||
expect(result.stdout).toContain('exec pkg')
|
||||
expect(result.stdout).toContain('--sea --compress Brotli --targets node24-macos-x64')
|
||||
expect(result.stdout).toContain('keep only node-pty prebuilds darwin-x64')
|
||||
expect(result.stdout).toContain('lock optional resource downloads and copy Office skills')
|
||||
expect(result.stdout).toContain(`lock optional resource downloads in ${join(root, 'dist-exe', 'macos-x64')}`)
|
||||
expect(result.stdout).not.toContain('office-skills')
|
||||
expect(result.stdout).toContain(join(root, 'dist-exe', 'macos-x64'))
|
||||
})
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import { resolveLinuxNodePtyAddon, resolveWindowsNodePtyAddons } from './executa
|
||||
import { officeSidecarArchives, runtimeNpmArchive, OFFICE_ASSET_IGNORES } from './build-exe-for-python-sdk-office.ts'
|
||||
import { syncPythonRuntimeProduct } from './build-exe-for-python-sdk-resources.ts'
|
||||
import { deduplicateStagedWorkspacePackages, materializeStagedLinks } from './build-exe-for-python-sdk-staging.ts'
|
||||
import { prepareOfficeSkillAssets } from './primary-runtime/prepare.ts'
|
||||
import primaryLock from './primary-runtime/lock.json' with { type: 'json' }
|
||||
|
||||
const root = resolve(import.meta.dirname, '..')
|
||||
@@ -412,7 +411,7 @@ class SingleExeBuild {
|
||||
const ripgrep = await this.copyRipgrepSidecar(target, product)
|
||||
const resources = join(this.outDir, `${target.platform}-${target.arch}`)
|
||||
if (this.cli.dryRun) {
|
||||
console.log(`build-exe-for-python-sdk: [dry-run] lock optional resource downloads and copy Office skills to ${resources}`)
|
||||
console.log(`build-exe-for-python-sdk: [dry-run] lock optional resource downloads in ${resources}`)
|
||||
} else {
|
||||
await rm(resources, { recursive: true, force: true })
|
||||
await mkdir(resources, { recursive: true })
|
||||
@@ -422,7 +421,6 @@ class SingleExeBuild {
|
||||
const inputs = { version, target: `${target.platform === 'macos' ? 'mac' : target.platform}-${target.arch}`, office, pnpm }
|
||||
const identity = createHash('sha256').update(JSON.stringify({ ...inputs, primaryLock })).digest('hex')
|
||||
await writeFile(join(resources, 'downloads.json'), JSON.stringify({ ...inputs, identity }, undefined, 2) + '\n')
|
||||
await prepareOfficeSkillAssets(join(this.staging, 'node_modules/@deepseek-ai/dsh-skill-office/assets'), join(resources, 'office-skills'))
|
||||
}
|
||||
if (target.platform !== 'macos') return [product, ripgrep, resources]
|
||||
const spawnHelper = `${product}-spawn-helper`
|
||||
|
||||
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os'
|
||||
import { basename, join } from 'node:path'
|
||||
import { zipSync } from 'fflate'
|
||||
import { expect, it } from 'vitest'
|
||||
import { downloadPrimaryRuntimeAsset, prepareOfficeSkillAssets, primaryRuntimePayloadDigest, prunePnpmForeignNativePackages, smokePrimaryRuntime, unpackPrimaryRuntimeWheel } from './prepare.ts'
|
||||
import { downloadPrimaryRuntimeAsset, primaryRuntimePayloadDigest, prunePnpmForeignNativePackages, smokePrimaryRuntime, unpackPrimaryRuntimeWheel } from './prepare.ts'
|
||||
import lock from './lock.json' with { type: 'json' }
|
||||
|
||||
it('covers every SDK wheel target with the shared interpreter lock', () => {
|
||||
@@ -132,26 +132,6 @@ it('rejects library files requiring an unsupported installation scheme', async (
|
||||
}
|
||||
})
|
||||
|
||||
it('copies complete Office resources outside the application archive and removes obsolete assets', async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'desktop-office-assets-'))
|
||||
try {
|
||||
const source = join(root, 'package', 'assets')
|
||||
const destination = join(root, 'Contents', 'Resources', 'runtime', 'office-skills')
|
||||
await mkdir(source, { recursive: true })
|
||||
for (const name of ['office-docx', 'office-pptx', 'office-xlsx']) {
|
||||
await mkdir(join(source, name))
|
||||
await writeFile(join(source, name, 'SKILL.md'), `# ${name}\n`)
|
||||
}
|
||||
await prepareOfficeSkillAssets(source, destination)
|
||||
await writeFile(join(destination, 'obsolete.py'), 'old helper')
|
||||
await prepareOfficeSkillAssets(source, destination)
|
||||
for (const name of ['office-docx', 'office-pptx', 'office-xlsx']) {
|
||||
expect(await readFile(join(destination, name, 'SKILL.md'), 'utf8')).toBe(`# ${name}\n`)
|
||||
}
|
||||
await expect(readFile(join(destination, 'obsolete.py'))).rejects.toMatchObject({ code: 'ENOENT' })
|
||||
} finally { await rm(root, { recursive: true, force: true }) }
|
||||
})
|
||||
|
||||
it('gives Python-only payloads a distinct identity', () => {
|
||||
expect(primaryRuntimePayloadDigest('linux-x64', lock, undefined)).not.toBe(primaryRuntimePayloadDigest('linux-x64', lock, '11.7.0'))
|
||||
})
|
||||
|
||||
@@ -172,17 +172,6 @@ export function prunePnpmForeignNativePackages(pnpm: string, platform: NodeJS.Pl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the skill package's complete asset tree to ordinary filesystem resources.
|
||||
* @param source - The package's assets directory.
|
||||
* @param destination - External Office skill resource directory.
|
||||
* @returns Resolves after replacing the external assets with the complete package tree.
|
||||
*/
|
||||
export async function prepareOfficeSkillAssets(source: string, destination: string): Promise<void> {
|
||||
rmSync(destination, { recursive: true, force: true })
|
||||
await cp(source, destination, { recursive: true, dereference: true })
|
||||
}
|
||||
|
||||
/** A locked interpreter and wheel target. */
|
||||
export type PrimaryRuntimeTarget = keyof typeof lock.targets
|
||||
|
||||
@@ -190,7 +179,7 @@ export type PrimaryRuntimeTarget = keyof typeof lock.targets
|
||||
export interface PreparePrimaryRuntimeOptions {
|
||||
/** Target whose archives and wheels are downloaded. */
|
||||
readonly target: PrimaryRuntimeTarget
|
||||
/** Resource directory receiving primary-runtime/ and office-skills/. */
|
||||
/** Resource directory receiving primary-runtime/. */
|
||||
readonly output: string
|
||||
/** SHA-256-addressed archive cache. */
|
||||
readonly cache: string
|
||||
@@ -198,16 +187,14 @@ export interface PreparePrimaryRuntimeOptions {
|
||||
readonly version: string
|
||||
/** Locked npm pnpm tarball for installed carriers; build hosts otherwise copy their installed pnpm. */
|
||||
readonly pnpmArchive?: RuntimeNpmArchive
|
||||
/** Ordinary filesystem Office assets; build hosts otherwise resolve the workspace package. */
|
||||
readonly skillSource?: string
|
||||
/** Omit Node.js and pnpm for carriers providing only Python. */
|
||||
readonly pythonOnly?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Materialize locked interpreters, libraries and Office resources without executing target code.
|
||||
* Materialize locked interpreters and libraries without executing target code.
|
||||
* @param options - Explicit target and carrier-owned output locations.
|
||||
* @returns Resolves after the complete payload and skills have been copied to the output directory.
|
||||
* @returns Resolves after the complete payload has been copied to the output directory.
|
||||
*/
|
||||
export async function preparePrimaryRuntime(options: PreparePrimaryRuntimeOptions): Promise<void> {
|
||||
const { target } = options
|
||||
@@ -259,9 +246,6 @@ export async function preparePrimaryRuntime(options: PreparePrimaryRuntimeOption
|
||||
} finally {
|
||||
rmSync(staging, { recursive: true, force: true })
|
||||
}
|
||||
const assets = options.skillSource ?? join(dirname(createRequire(import.meta.url).resolve('@deepseek-ai/dsh-skill-office/package.json')), 'assets')
|
||||
await prepareOfficeSkillAssets(assets,
|
||||
join(paths.runtime, 'office-skills'))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -407,7 +407,6 @@ describe('translation scope discovery', () => {
|
||||
'coverage/report/README.md',
|
||||
'python/sdk-runtime/src/deepseek_harness_runtime/runtime/deepseek-harness-sdk-runtime-macos-arm64/README.md',
|
||||
'python/sdk-runtime/src/deepseek_harness_runtime/runtime/node/README.md',
|
||||
'python/sdk-runtime/src/deepseek_harness_runtime/runtime/macos-arm64/office-skills/office-docx/SKILL.md',
|
||||
])('excludes non-source or non-README path %s', (file) => {
|
||||
expect(isTranslationScopeFile(file)).toBe(false)
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user