mirror of
https://github.com/iflytek/skillhub.git
synced 2026-09-06 08:15:57 +00:00
Merge pull request #780 from iflytek/fix/cli-fingerprint-order
fix(cli): stabilize namespace sync fingerprints
This commit is contained in:
commit
b896c698cd
2 changed files with 21 additions and 1 deletions
|
|
@ -50,5 +50,5 @@ async function listSkillFiles(root: string): Promise<string[]> {
|
|||
}
|
||||
|
||||
await walk(root)
|
||||
return files.sort((left, right) => left.localeCompare(right))
|
||||
return files.sort()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { createHash } from 'node:crypto'
|
||||
import { mkdir, writeFile } from 'node:fs/promises'
|
||||
import { join } from 'node:path'
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
|
|
@ -5,6 +6,25 @@ import { createTempHome } from '../../helpers/temp-env'
|
|||
import { diffSkillFiles, snapshotSkillDirectory } from '../../../src/services/skill-fingerprint'
|
||||
|
||||
describe('skill fingerprint', () => {
|
||||
test('matches the server fingerprint for mixed-case package paths', async () => {
|
||||
const env = await createTempHome()
|
||||
const skillDir = join(env.cwd, 'mixed-case-paths')
|
||||
const skillContent = '# Mixed-case paths\n'
|
||||
const referenceContent = 'Reference\n'
|
||||
await mkdir(join(skillDir, 'references'), { recursive: true })
|
||||
await writeFile(join(skillDir, 'SKILL.md'), skillContent)
|
||||
await writeFile(join(skillDir, 'references', 'guide.md'), referenceContent)
|
||||
|
||||
const skillHash = createHash('sha256').update(skillContent).digest('hex')
|
||||
const referenceHash = createHash('sha256').update(referenceContent).digest('hex')
|
||||
const serverFingerprint = createHash('sha256')
|
||||
.update(`SKILL.md:${skillHash}\n`)
|
||||
.update(`references/guide.md:${referenceHash}\n`)
|
||||
.digest('hex')
|
||||
|
||||
expect((await snapshotSkillDirectory(skillDir)).fingerprint).toBe(`sha256:${serverFingerprint}`)
|
||||
})
|
||||
|
||||
test('ignores SkillHub metadata and reports changed files', async () => {
|
||||
const env = await createTempHome()
|
||||
const skillDir = join(env.cwd, 'demo')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue