hy-sde/dsh-fs-archive--packages-fs-archive ↗★ 0
@hy-sde-org/dsh-fs-archive
Pure-TS multi-format archive engine (zip/tar/tar.gz/rar/7z/iso/deb/rpm/cpio/cab/arj/asar + codecs), ported from @oh-my-pi/pi-utils (MIT), as a standalone npm package. 适合需要对 zip、tar、7z 等多种压缩包格式进行读取、列表和解压的开发任务。
Install
This plugin has no verified bundle, or compatibility checks failed. Read the repository notes first. Read the full README ↗
README
Read the full README ↗@hy-sde-org/dsh-fs-archive
A pure-TS multi-format archive engine — zip, tar, tar.gz, rar, 7z, iso, deb, rpm, cpio, cab, arj, asar — plus the codec layer (gzip, bzip2, ncompress LZW, xz, deflate, zstd) behind them. Ported from @oh-my-pi/pi-utils.
This is the durable core of the harness read tool's multi-format support: foo.zip lists an archive's root, foo.zip:dir lists a directory, and foo.zip:dir/file.txt reads one member as text. Published standalone as @hy-sde-org/dsh-fs-archive; it mirrors @deepseek-ai/dsh-fs-archive in the hy-sde deepseek-harness fork.
Format detection sniffs content signatures (sniffArchiveFormat) and falls back to extension inference (archiveFormatFromPath); member reads are bounded by ArchiveLimits (entry count, index size, in-memory size, member size, path bytes, link depth) so attacker-controlled archives cannot drive unbounded allocation.
Port differences
- No
Bunruntime:Bun.hash.crc32is table-driven CRC-32,Bun.CryptoHasherisnode:cryptoSHA-256, andBun.file/Bun.writearenode:fs/node:fs/promisesequivalents. - All relative imports carry the
.tsextension (reporewriteRelativeImportExtensions). formatBytes, the smallLRUCache, and the publicindex.tssurface replace the upstream package-level re-exports; tests load fixtures from one bundledtar.gz(the same layout upstream uses to keep checkout state quiet).- The optional
./invariantcompanion registers the package into a Cordis host'sctx.invariantsservice (no-op); it needs@deepseek-ai/cordis+@deepseek-ai/dsh-invariantspeers only when you use that entry.
Otherwise the port is algorithmically 1:1 with the original source. Keep the two sources in sync when the fork backports upstream archive-engine fixes.
Known Limitations and Deferred Work
- The harness
readtool member reads go throughctx.fs.readByteswith a boundedreadMaxArchiveBytes(default 256 MiB): the archive file is loaded into memory for indexing. No streaming/localfileByteSourcepath is wired into the tool yet, so very large archives stay beyond the cap even though the engine itself supports lazy source reads. - The harness
readtool serves member text and listings only; archive writing is not exposed through the tool (members are immutable there), though this package'swriteArchiveAPI supports zip/tar/tar.gz/asar writing for programmatic use. - Detection needs either content sniffing or an archive extension on the path; a member named with a supported archive extension inside a container is interpreted by longest-prefix rules from
parseArchivePathCandidates.
Package API:
import {
openArchive,
parseArchivePathCandidates,
sniffArchiveFormat,
formatArchiveEntryLines,
} from '@hy-sde-org/dsh-fs-archive'
openArchive(source, options)— open a file path or{ bytes, format }into anArchiveReader;getNoderesolves members,listDirectorylists,readFilereads one member's bytes,indexEntriesenumerates.parseArchivePathCandidates(filePath)— splitarchive.ext:member/pathinto resolution candidates (longest archive prefix first).sniffArchiveFormat(bytes)/archiveFormatFromPath(path)— format rules.formatArchiveEntryLines(entries)— one line per member,name/for directories andname (size)for files.- See
src/index.tsfor the full export surface.
License
Port of MIT-licensed code. Original copyright: Copyright (c) 2025-2026 Can Bölük and contributors. Derived files carry header attribution; see the inline file headers and THIRD-PARTY-NOTICES.md.