Download packages/agent-core-v2/test/app/plugin/archive.test.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/test/app/plugin/archive.test.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/agent-core-v2/test/app/plugin/archive.test.ts
-
curl -L -o archive.test.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/test/app/plugin/archive.test.ts
1.3 kB
| import { execFileSync } from 'node:child_process'; | |
| import { readFile } from 'node:fs/promises'; | |
| import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises'; | |
| import { tmpdir } from 'node:os'; | |
| import { join } from 'node:path'; | |
| import { afterEach, beforeEach, describe, expect, it } from 'vitest'; | |
| import { extractZip } from '#/app/plugin/archive'; | |
| describe('plugin archive extraction', () => { | |
| let dir: string; | |
| beforeEach(async () => { | |
| dir = await mkdtemp(join(tmpdir(), 'plugin-archive-test-')); | |
| }); | |
| afterEach(async () => { | |
| await rm(dir, { recursive: true, force: true }); | |
| }); | |
| it('extracts a zip and detects a nested plugin root', async () => { | |
| const source = join(dir, 'source'); | |
| const nested = join(source, 'plugin'); | |
| await mkdir(nested, { recursive: true }); | |
| await writeFile(join(nested, 'kimi.plugin.json'), JSON.stringify({ name: 'zip-demo' }), 'utf8'); | |
| const zipPath = join(dir, 'plugin.zip'); | |
| execFileSync('zip', ['-qr', zipPath, '.'], { cwd: source }); | |
| const outDir = join(dir, 'out'); | |
| const detectedRoot = await extractZip(await readFile(zipPath), outDir); | |
| expect(detectedRoot).toBe(join(outDir, 'plugin')); | |
| await expect(readFile(join(detectedRoot, 'kimi.plugin.json'), 'utf8')).resolves.toContain('zip-demo'); | |
| }); | |
| }); | |