From 23faa5bad3992f7ef9f69c41658de7b46f5742ed Mon Sep 17 00:00:00 2001 From: Abhishek Mallepalli Date: Wed, 25 Nov 2026 15:15:18 -0800 Subject: [PATCH] Add pak v1: format spec, core, remote, wasm and CLI Add the pak package manager for retro C and assembly development. - docs/spec rev3.md defines the format; schema/pak.schema.json validates .pak.json. - pak-core holds the format rules (manifest, pack, resolve, lock, install plan, include and path rules, messages) and does no I/O. - pak-remote talks to GitHub for git installs. - pak-wasm exposes pak-core to browser-based tools. - The pak binary implements init, install, remove, update, list, outdated, info, why, it, path, verify, check and create. - tests/stories holds 52 end-to-end user stories with fixtures. - CI runs fmt, clippy, tests and the wasm build on Linux, macOS and Windows. --- .github/workflows/ci.yml | 73 + .gitignore | 5 + CLAUDE.md | 21 + Cargo.lock | 975 +++++++++ Cargo.toml | 95 + LICENSE | 21 + LICENSES/MIT.txt | 18 + README.md | 36 + REUSE.toml | 22 + agents/rust-style.md | 101 + crates/core/Cargo.toml | 53 + crates/core/clippy.toml | 51 + crates/core/src/command.rs | 332 +++ crates/core/src/create.rs | 190 ++ crates/core/src/fields.rs | 401 ++++ crates/core/src/fsname.rs | 108 + crates/core/src/include.rs | 167 ++ crates/core/src/info.rs | 205 ++ crates/core/src/info/tests.rs | 217 ++ crates/core/src/init.rs | 150 ++ crates/core/src/init/tests.rs | 81 + crates/core/src/install.rs | 609 ++++++ crates/core/src/install/add.rs | 349 +++ crates/core/src/install/directory.rs | 154 ++ crates/core/src/install/error.rs | 282 +++ crates/core/src/install/tests.rs | 931 ++++++++ crates/core/src/lib.rs | 55 + crates/core/src/list.rs | 134 ++ crates/core/src/list/tests.rs | 254 +++ crates/core/src/lock.rs | 692 ++++++ crates/core/src/lock/tests.rs | 411 ++++ crates/core/src/manifest.rs | 660 ++++++ crates/core/src/manifest/error.rs | 210 ++ crates/core/src/manifest/name.rs | 272 +++ crates/core/src/manifest/path.rs | 234 ++ crates/core/src/manifest/read.rs | 654 ++++++ crates/core/src/manifest/read/tests.rs | 966 +++++++++ crates/core/src/manifest/tests.rs | 83 + crates/core/src/message.rs | 445 ++++ crates/core/src/message/english.rs | 447 ++++ crates/core/src/message/tests.rs | 739 +++++++ crates/core/src/outdated.rs | 278 +++ crates/core/src/pack.rs | 527 +++++ crates/core/src/pack/archive.rs | 220 ++ crates/core/src/pack/archive/tests.rs | 212 ++ crates/core/src/pack/build.rs | 431 ++++ crates/core/src/pack/build/tests.rs | 211 ++ crates/core/src/pack/error.rs | 173 ++ crates/core/src/pack/exclude.rs | 102 + crates/core/src/pack/layout.rs | 170 ++ crates/core/src/pack/project.rs | 197 ++ crates/core/src/pack/tests.rs | 719 +++++++ crates/core/src/paks.rs | 136 ++ crates/core/src/paks/check.rs | 155 ++ crates/core/src/paks/path.rs | 156 ++ crates/core/src/paks/plan.rs | 746 +++++++ crates/core/src/paks/tests.rs | 442 ++++ crates/core/src/paks/verify.rs | 49 + crates/core/src/problems.rs | 166 ++ crates/core/src/resolve.rs | 1884 +++++++++++++++++ crates/core/src/resolve/tests.rs | 1392 ++++++++++++ crates/core/src/shown.rs | 65 + crates/core/src/tags.rs | 267 +++ crates/core/src/tags/tests.rs | 276 +++ crates/core/src/why.rs | 414 ++++ crates/remote/Cargo.toml | 52 + crates/remote/src/github.rs | 466 ++++ crates/remote/src/github/tests.rs | 233 ++ crates/remote/src/host.rs | 101 + crates/remote/src/lib.rs | 37 + crates/wasm/Cargo.toml | 56 + crates/wasm/src/command.rs | 636 ++++++ crates/wasm/src/js.rs | 205 ++ crates/wasm/src/lib.rs | 47 + crates/wasm/src/manifest.rs | 270 +++ crates/wasm/src/pack.rs | 221 ++ crates/wasm/src/paks.rs | 636 ++++++ crates/wasm/src/resolve.rs | 352 +++ crates/wasm/src/tags.rs | 165 ++ crates/wasm/tests/node.rs | 331 +++ devops/build | 44 + devops/clean | 40 + devops/install | 41 + devops/tag | 133 ++ devops/uninstall | 42 + devops/version | 144 ++ devops/wasi | 46 + devops/wasm | 52 + docs/pak-spec.md | 606 ++++++ docs/spec rev3.md | 1060 ++++++++++ schema/pak.schema.json | 435 ++++ src/check.rs | 134 ++ src/command.rs | 94 + src/create.rs | 376 ++++ src/git_credentials.rs | 295 +++ src/github.rs | 531 +++++ src/github/tests.rs | 119 ++ src/info.rs | 112 + src/init.rs | 113 + src/install.rs | 843 ++++++++ src/install/github.rs | 854 ++++++++ src/install/tests.rs | 286 +++ src/installed.rs | 591 ++++++ src/installed/tests.rs | 321 +++ src/list.rs | 71 + src/lockfile.rs | 77 + src/lockfile/tests.rs | 154 ++ src/main.rs | 67 + src/outdated.rs | 124 ++ src/output.rs | 227 ++ src/pack_it.rs | 137 ++ src/path.rs | 121 ++ src/project.rs | 179 ++ src/save.rs | 660 ++++++ src/script.rs | 203 ++ src/verify.rs | 83 + src/why.rs | 82 + tests/manifest_schema.rs | 1091 ++++++++++ tests/stories.rs | 877 ++++++++ tests/stories/01-init-a-project.md | 34 + tests/stories/02-init-a-library.md | 57 + tests/stories/03-init-where-one-exists.md | 29 + tests/stories/04-pack-libnes.md | 39 + .../05-pack-leaves-out-what-never-ships.md | 49 + tests/stories/06-pack-with-files-missing.md | 18 + tests/stories/07-pack-two-files-one-place.md | 31 + .../stories/08-pack-a-project-with-no-name.md | 15 + tests/stories/09-prepack-builds-first.md | 81 + tests/stories/10-add-from-github.md | 59 + tests/stories/11-add-without-a-profile.md | 36 + tests/stories/12-paths-for-the-build.md | 57 + tests/stories/13-a-new-release.md | 81 + tests/stories/14-ci-with-locked.md | 50 + .../15-a-library-pins-exact-versions.md | 58 + tests/stories/16-repo-without-version-tags.md | 101 + tests/stories/17-tag-holds-another-version.md | 42 + tests/stories/18-repo-without-its-pak-file.md | 38 + .../stories/19-typos-and-missing-versions.md | 34 + tests/stories/20-prerelease-tags.md | 58 + tests/stories/21-hand-edited-package.md | 29 + tests/stories/22-two-versions-need-use.md | 90 + tests/stories/23-version-conflict.md | 146 ++ tests/stories/24-hostile-archives.md | 69 + tests/stories/25-remove.md | 35 + tests/stories/26-fork-with-its-own-name.md | 92 + tests/stories/27-fork-that-kept-the-name.md | 57 + .../stories/28-same-header-in-two-packages.md | 40 + .../29-two-packages-share-one-libnes.md | 178 ++ tests/stories/30-add-a-local-pak-file.md | 106 + tests/stories/31-add-a-local-folder.md | 90 + .../32-pack-names-some-systems-refuse.md | 46 + tests/stories/33-install-several-pak-files.md | 80 + tests/stories/34-local-package-folder.md | 45 + tests/stories/35-local-package-kind-paths.md | 72 + tests/stories/36-verify-local-install.md | 67 + tests/stories/37-check-include-warnings.md | 63 + tests/stories/38-check-linked-twice.md | 89 + tests/stories/39-check-clean-project.md | 40 + tests/stories/40-check-alternatives.md | 65 + tests/stories/41-check-accepted-conflict.md | 45 + .../42-unknown-field-warns-everywhere.md | 49 + tests/stories/43-remove-local.md | 68 + tests/stories/44-local-candidates.md | 111 + tests/stories/45-update-local.md | 81 + tests/stories/46-local-source-conflict.md | 65 + tests/stories/47-list.md | 98 + tests/stories/48-info.md | 208 ++ tests/stories/49-create.md | 206 ++ tests/stories/50-help.md | 35 + tests/stories/51-install-starts-a-project.md | 53 + .../52-override-a-dependencys-dependency.md | 254 +++ tests/stories/README.md | 100 + .../github/manybyte/libgfx/4d5e6f7/.pak.json | 12 + .../manybyte/libgfx/4d5e6f7/include/libgfx.h | 1 + .../github/manybyte/libgfx/refs | 3 + .../github/manybyte/sprites/5e6f7a8/.pak.json | 12 + .../sprites/5e6f7a8/include/sprites.h | 1 + .../github/manybyte/sprites/refs | 3 + .../github/shawn/libnes-fix/9b9b9b9/.pak.json | 26 + .../github/shawn/libnes-fix/9b9b9b9/LICENSE | 1 + .../github/shawn/libnes-fix/9b9b9b9/README.md | 1 + .../9b9b9b9/build/lib/libnes-mmc1.lib | 1 + .../9b9b9b9/build/lib/libnes-nrom.lib | 1 + .../9b9b9b9/build/lib/libnes-unrom.lib | 1 + .../libnes-fix/9b9b9b9/cfg/libnes-nrom.cfg | 1 + .../libnes-fix/9b9b9b9/cfg/libnes-unrom.cfg | 1 + .../shawn/libnes-fix/9b9b9b9/inc/nes/sys.inc | 1 + .../libnes-fix/9b9b9b9/include/nes/sys.h | 1 + .../github/shawn/libnes-fix/9b9b9b9/src/sys.s | 1 + .../github/shawn/libnes-fix/refs | 3 + .../github/shawn/libnes/9a9a9a9/.pak.json | 26 + .../github/shawn/libnes/9a9a9a9/LICENSE | 1 + .../github/shawn/libnes/9a9a9a9/README.md | 1 + .../libnes/9a9a9a9/build/lib/libnes-mmc1.lib | 1 + .../libnes/9a9a9a9/build/lib/libnes-nrom.lib | 1 + .../libnes/9a9a9a9/build/lib/libnes-unrom.lib | 1 + .../shawn/libnes/9a9a9a9/cfg/libnes-nrom.cfg | 1 + .../shawn/libnes/9a9a9a9/cfg/libnes-unrom.cfg | 1 + .../shawn/libnes/9a9a9a9/inc/nes/sys.inc | 1 + .../shawn/libnes/9a9a9a9/include/nes/sys.h | 1 + .../github/shawn/libnes/9a9a9a9/src/sys.s | 1 + .../github/shawn/libnes/refs | 3 + .../github/manybyte/libnes/1a2b3c4/.pak.json | 26 + .../github/manybyte/libnes/1a2b3c4/LICENSE | 1 + .../github/manybyte/libnes/1a2b3c4/README.md | 1 + .../libnes/1a2b3c4/build/lib/libnes-mmc1.lib | 1 + .../libnes/1a2b3c4/build/lib/libnes-nrom.lib | 1 + .../libnes/1a2b3c4/build/lib/libnes-unrom.lib | 1 + .../libnes/1a2b3c4/cfg/libnes-nrom.cfg | 1 + .../libnes/1a2b3c4/cfg/libnes-unrom.cfg | 1 + .../manybyte/libnes/1a2b3c4/inc/nes/sys.inc | 1 + .../manybyte/libnes/1a2b3c4/include/nes/sys.h | 1 + .../github/manybyte/libnes/1a2b3c4/src/sys.s | 1 + .../github/manybyte/libnes/2b3c4d5/.pak.json | 26 + .../github/manybyte/libnes/2b3c4d5/LICENSE | 1 + .../github/manybyte/libnes/2b3c4d5/README.md | 1 + .../libnes/2b3c4d5/build/lib/libnes-mmc1.lib | 1 + .../libnes/2b3c4d5/build/lib/libnes-nrom.lib | 1 + .../libnes/2b3c4d5/build/lib/libnes-unrom.lib | 1 + .../libnes/2b3c4d5/cfg/libnes-nrom.cfg | 1 + .../libnes/2b3c4d5/cfg/libnes-unrom.cfg | 1 + .../manybyte/libnes/2b3c4d5/inc/nes/sys.inc | 1 + .../manybyte/libnes/2b3c4d5/include/nes/sys.h | 1 + .../github/manybyte/libnes/2b3c4d5/src/sys.s | 1 + .../github/manybyte/libnes/3c4d5e6/.pak.json | 26 + .../github/manybyte/libnes/3c4d5e6/LICENSE | 1 + .../github/manybyte/libnes/3c4d5e6/README.md | 1 + .../libnes/3c4d5e6/build/lib/libnes-mmc1.lib | 1 + .../libnes/3c4d5e6/build/lib/libnes-nrom.lib | 1 + .../libnes/3c4d5e6/build/lib/libnes-unrom.lib | 1 + .../libnes/3c4d5e6/cfg/libnes-nrom.cfg | 1 + .../libnes/3c4d5e6/cfg/libnes-unrom.cfg | 1 + .../manybyte/libnes/3c4d5e6/inc/nes/sys.inc | 1 + .../manybyte/libnes/3c4d5e6/include/nes/sys.h | 1 + .../github/manybyte/libnes/3c4d5e6/src/sys.s | 1 + .../github-libnes/github/manybyte/libnes/refs | 5 + .../github/acme/nesutil/7c7c7c7/.pak.json | 10 + .../acme/nesutil/7c7c7c7/inc/nes/sys.inc | 1 + .../acme/nesutil/7c7c7c7/inc/nesutil.inc | 1 + .../github-nesutil/github/acme/nesutil/refs | 3 + .../stories/fixtures/libnes-project/.pak.json | 26 + tests/stories/fixtures/libnes-project/LICENSE | 1 + .../stories/fixtures/libnes-project/README.md | 1 + .../libnes-project/build/lib/libnes-mmc1.lib | 1 + .../libnes-project/build/lib/libnes-nrom.lib | 1 + .../libnes-project/build/lib/libnes-unrom.lib | 1 + .../libnes-project/cfg/libnes-nrom.cfg | 1 + .../libnes-project/cfg/libnes-unrom.cfg | 1 + .../fixtures/libnes-project/inc/nes/sys.inc | 1 + .../fixtures/libnes-project/include/nes/sys.h | 1 + .../stories/fixtures/libnes-project/src/sys.s | 1 + .../fixtures/libnes-project/temp/scratch.o | 1 + 252 files changed, 40678 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 CLAUDE.md create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE create mode 100644 LICENSES/MIT.txt create mode 100644 README.md create mode 100644 REUSE.toml create mode 100644 agents/rust-style.md create mode 100644 crates/core/Cargo.toml create mode 100644 crates/core/clippy.toml create mode 100644 crates/core/src/command.rs create mode 100644 crates/core/src/create.rs create mode 100644 crates/core/src/fields.rs create mode 100644 crates/core/src/fsname.rs create mode 100644 crates/core/src/include.rs create mode 100644 crates/core/src/info.rs create mode 100644 crates/core/src/info/tests.rs create mode 100644 crates/core/src/init.rs create mode 100644 crates/core/src/init/tests.rs create mode 100644 crates/core/src/install.rs create mode 100644 crates/core/src/install/add.rs create mode 100644 crates/core/src/install/directory.rs create mode 100644 crates/core/src/install/error.rs create mode 100644 crates/core/src/install/tests.rs create mode 100644 crates/core/src/lib.rs create mode 100644 crates/core/src/list.rs create mode 100644 crates/core/src/list/tests.rs create mode 100644 crates/core/src/lock.rs create mode 100644 crates/core/src/lock/tests.rs create mode 100644 crates/core/src/manifest.rs create mode 100644 crates/core/src/manifest/error.rs create mode 100644 crates/core/src/manifest/name.rs create mode 100644 crates/core/src/manifest/path.rs create mode 100644 crates/core/src/manifest/read.rs create mode 100644 crates/core/src/manifest/read/tests.rs create mode 100644 crates/core/src/manifest/tests.rs create mode 100644 crates/core/src/message.rs create mode 100644 crates/core/src/message/english.rs create mode 100644 crates/core/src/message/tests.rs create mode 100644 crates/core/src/outdated.rs create mode 100644 crates/core/src/pack.rs create mode 100644 crates/core/src/pack/archive.rs create mode 100644 crates/core/src/pack/archive/tests.rs create mode 100644 crates/core/src/pack/build.rs create mode 100644 crates/core/src/pack/build/tests.rs create mode 100644 crates/core/src/pack/error.rs create mode 100644 crates/core/src/pack/exclude.rs create mode 100644 crates/core/src/pack/layout.rs create mode 100644 crates/core/src/pack/project.rs create mode 100644 crates/core/src/pack/tests.rs create mode 100644 crates/core/src/paks.rs create mode 100644 crates/core/src/paks/check.rs create mode 100644 crates/core/src/paks/path.rs create mode 100644 crates/core/src/paks/plan.rs create mode 100644 crates/core/src/paks/tests.rs create mode 100644 crates/core/src/paks/verify.rs create mode 100644 crates/core/src/problems.rs create mode 100644 crates/core/src/resolve.rs create mode 100644 crates/core/src/resolve/tests.rs create mode 100644 crates/core/src/shown.rs create mode 100644 crates/core/src/tags.rs create mode 100644 crates/core/src/tags/tests.rs create mode 100644 crates/core/src/why.rs create mode 100644 crates/remote/Cargo.toml create mode 100644 crates/remote/src/github.rs create mode 100644 crates/remote/src/github/tests.rs create mode 100644 crates/remote/src/host.rs create mode 100644 crates/remote/src/lib.rs create mode 100644 crates/wasm/Cargo.toml create mode 100644 crates/wasm/src/command.rs create mode 100644 crates/wasm/src/js.rs create mode 100644 crates/wasm/src/lib.rs create mode 100644 crates/wasm/src/manifest.rs create mode 100644 crates/wasm/src/pack.rs create mode 100644 crates/wasm/src/paks.rs create mode 100644 crates/wasm/src/resolve.rs create mode 100644 crates/wasm/src/tags.rs create mode 100644 crates/wasm/tests/node.rs create mode 100755 devops/build create mode 100755 devops/clean create mode 100755 devops/install create mode 100755 devops/tag create mode 100755 devops/uninstall create mode 100755 devops/version create mode 100755 devops/wasi create mode 100755 devops/wasm create mode 100644 docs/pak-spec.md create mode 100644 docs/spec rev3.md create mode 100644 schema/pak.schema.json create mode 100644 src/check.rs create mode 100644 src/command.rs create mode 100644 src/create.rs create mode 100644 src/git_credentials.rs create mode 100644 src/github.rs create mode 100644 src/github/tests.rs create mode 100644 src/info.rs create mode 100644 src/init.rs create mode 100644 src/install.rs create mode 100644 src/install/github.rs create mode 100644 src/install/tests.rs create mode 100644 src/installed.rs create mode 100644 src/installed/tests.rs create mode 100644 src/list.rs create mode 100644 src/lockfile.rs create mode 100644 src/lockfile/tests.rs create mode 100644 src/main.rs create mode 100644 src/outdated.rs create mode 100644 src/output.rs create mode 100644 src/pack_it.rs create mode 100644 src/path.rs create mode 100644 src/project.rs create mode 100644 src/save.rs create mode 100644 src/script.rs create mode 100644 src/verify.rs create mode 100644 src/why.rs create mode 100644 tests/manifest_schema.rs create mode 100644 tests/stories.rs create mode 100644 tests/stories/01-init-a-project.md create mode 100644 tests/stories/02-init-a-library.md create mode 100644 tests/stories/03-init-where-one-exists.md create mode 100644 tests/stories/04-pack-libnes.md create mode 100644 tests/stories/05-pack-leaves-out-what-never-ships.md create mode 100644 tests/stories/06-pack-with-files-missing.md create mode 100644 tests/stories/07-pack-two-files-one-place.md create mode 100644 tests/stories/08-pack-a-project-with-no-name.md create mode 100644 tests/stories/09-prepack-builds-first.md create mode 100644 tests/stories/10-add-from-github.md create mode 100644 tests/stories/11-add-without-a-profile.md create mode 100644 tests/stories/12-paths-for-the-build.md create mode 100644 tests/stories/13-a-new-release.md create mode 100644 tests/stories/14-ci-with-locked.md create mode 100644 tests/stories/15-a-library-pins-exact-versions.md create mode 100644 tests/stories/16-repo-without-version-tags.md create mode 100644 tests/stories/17-tag-holds-another-version.md create mode 100644 tests/stories/18-repo-without-its-pak-file.md create mode 100644 tests/stories/19-typos-and-missing-versions.md create mode 100644 tests/stories/20-prerelease-tags.md create mode 100644 tests/stories/21-hand-edited-package.md create mode 100644 tests/stories/22-two-versions-need-use.md create mode 100644 tests/stories/23-version-conflict.md create mode 100644 tests/stories/24-hostile-archives.md create mode 100644 tests/stories/25-remove.md create mode 100644 tests/stories/26-fork-with-its-own-name.md create mode 100644 tests/stories/27-fork-that-kept-the-name.md create mode 100644 tests/stories/28-same-header-in-two-packages.md create mode 100644 tests/stories/29-two-packages-share-one-libnes.md create mode 100644 tests/stories/30-add-a-local-pak-file.md create mode 100644 tests/stories/31-add-a-local-folder.md create mode 100644 tests/stories/32-pack-names-some-systems-refuse.md create mode 100644 tests/stories/33-install-several-pak-files.md create mode 100644 tests/stories/34-local-package-folder.md create mode 100644 tests/stories/35-local-package-kind-paths.md create mode 100644 tests/stories/36-verify-local-install.md create mode 100644 tests/stories/37-check-include-warnings.md create mode 100644 tests/stories/38-check-linked-twice.md create mode 100644 tests/stories/39-check-clean-project.md create mode 100644 tests/stories/40-check-alternatives.md create mode 100644 tests/stories/41-check-accepted-conflict.md create mode 100644 tests/stories/42-unknown-field-warns-everywhere.md create mode 100644 tests/stories/43-remove-local.md create mode 100644 tests/stories/44-local-candidates.md create mode 100644 tests/stories/45-update-local.md create mode 100644 tests/stories/46-local-source-conflict.md create mode 100644 tests/stories/47-list.md create mode 100644 tests/stories/48-info.md create mode 100644 tests/stories/49-create.md create mode 100644 tests/stories/50-help.md create mode 100644 tests/stories/51-install-starts-a-project.md create mode 100644 tests/stories/52-override-a-dependencys-dependency.md create mode 100644 tests/stories/README.md create mode 100644 tests/stories/fixtures/github-libgfx-sprites/github/manybyte/libgfx/4d5e6f7/.pak.json create mode 100644 tests/stories/fixtures/github-libgfx-sprites/github/manybyte/libgfx/4d5e6f7/include/libgfx.h create mode 100644 tests/stories/fixtures/github-libgfx-sprites/github/manybyte/libgfx/refs create mode 100644 tests/stories/fixtures/github-libgfx-sprites/github/manybyte/sprites/5e6f7a8/.pak.json create mode 100644 tests/stories/fixtures/github-libgfx-sprites/github/manybyte/sprites/5e6f7a8/include/sprites.h create mode 100644 tests/stories/fixtures/github-libgfx-sprites/github/manybyte/sprites/refs create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/9b9b9b9/.pak.json create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/9b9b9b9/LICENSE create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/9b9b9b9/README.md create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/9b9b9b9/build/lib/libnes-mmc1.lib create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/9b9b9b9/build/lib/libnes-nrom.lib create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/9b9b9b9/build/lib/libnes-unrom.lib create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/9b9b9b9/cfg/libnes-nrom.cfg create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/9b9b9b9/cfg/libnes-unrom.cfg create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/9b9b9b9/inc/nes/sys.inc create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/9b9b9b9/include/nes/sys.h create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/9b9b9b9/src/sys.s create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes-fix/refs create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/9a9a9a9/.pak.json create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/9a9a9a9/LICENSE create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/9a9a9a9/README.md create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/9a9a9a9/build/lib/libnes-mmc1.lib create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/9a9a9a9/build/lib/libnes-nrom.lib create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/9a9a9a9/build/lib/libnes-unrom.lib create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/9a9a9a9/cfg/libnes-nrom.cfg create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/9a9a9a9/cfg/libnes-unrom.cfg create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/9a9a9a9/inc/nes/sys.inc create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/9a9a9a9/include/nes/sys.h create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/9a9a9a9/src/sys.s create mode 100644 tests/stories/fixtures/github-libnes-forks/github/shawn/libnes/refs create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/1a2b3c4/.pak.json create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/1a2b3c4/LICENSE create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/1a2b3c4/README.md create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/1a2b3c4/build/lib/libnes-mmc1.lib create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/1a2b3c4/build/lib/libnes-nrom.lib create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/1a2b3c4/build/lib/libnes-unrom.lib create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/1a2b3c4/cfg/libnes-nrom.cfg create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/1a2b3c4/cfg/libnes-unrom.cfg create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/1a2b3c4/inc/nes/sys.inc create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/1a2b3c4/include/nes/sys.h create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/1a2b3c4/src/sys.s create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/2b3c4d5/.pak.json create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/2b3c4d5/LICENSE create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/2b3c4d5/README.md create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/2b3c4d5/build/lib/libnes-mmc1.lib create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/2b3c4d5/build/lib/libnes-nrom.lib create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/2b3c4d5/build/lib/libnes-unrom.lib create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/2b3c4d5/cfg/libnes-nrom.cfg create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/2b3c4d5/cfg/libnes-unrom.cfg create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/2b3c4d5/inc/nes/sys.inc create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/2b3c4d5/include/nes/sys.h create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/2b3c4d5/src/sys.s create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/3c4d5e6/.pak.json create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/3c4d5e6/LICENSE create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/3c4d5e6/README.md create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/3c4d5e6/build/lib/libnes-mmc1.lib create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/3c4d5e6/build/lib/libnes-nrom.lib create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/3c4d5e6/build/lib/libnes-unrom.lib create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/3c4d5e6/cfg/libnes-nrom.cfg create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/3c4d5e6/cfg/libnes-unrom.cfg create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/3c4d5e6/inc/nes/sys.inc create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/3c4d5e6/include/nes/sys.h create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/3c4d5e6/src/sys.s create mode 100644 tests/stories/fixtures/github-libnes/github/manybyte/libnes/refs create mode 100644 tests/stories/fixtures/github-nesutil/github/acme/nesutil/7c7c7c7/.pak.json create mode 100644 tests/stories/fixtures/github-nesutil/github/acme/nesutil/7c7c7c7/inc/nes/sys.inc create mode 100644 tests/stories/fixtures/github-nesutil/github/acme/nesutil/7c7c7c7/inc/nesutil.inc create mode 100644 tests/stories/fixtures/github-nesutil/github/acme/nesutil/refs create mode 100644 tests/stories/fixtures/libnes-project/.pak.json create mode 100644 tests/stories/fixtures/libnes-project/LICENSE create mode 100644 tests/stories/fixtures/libnes-project/README.md create mode 100644 tests/stories/fixtures/libnes-project/build/lib/libnes-mmc1.lib create mode 100644 tests/stories/fixtures/libnes-project/build/lib/libnes-nrom.lib create mode 100644 tests/stories/fixtures/libnes-project/build/lib/libnes-unrom.lib create mode 100644 tests/stories/fixtures/libnes-project/cfg/libnes-nrom.cfg create mode 100644 tests/stories/fixtures/libnes-project/cfg/libnes-unrom.cfg create mode 100644 tests/stories/fixtures/libnes-project/inc/nes/sys.inc create mode 100644 tests/stories/fixtures/libnes-project/include/nes/sys.h create mode 100644 tests/stories/fixtures/libnes-project/src/sys.s create mode 100644 tests/stories/fixtures/libnes-project/temp/scratch.o diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5366b99 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,73 @@ +# SPDX-FileCopyrightText: 2026 Abhishek Mallepalli +# SPDX-FileCopyrightText: 2026 Shawn Bullock +# SPDX-License-Identifier: MIT +# +# Origin: https://github.com/manybyte/pak +# +# Author: Abhishek Mallepalli (@noisethanks), +# via https://github.com/manybyte/pak +# Co-author: Shawn Bullock (@shawnthehumble), +# via https://github.com/manybyte/pak +# +# Copyright (c) 2026 Abhishek Mallepalli +# Copyright (c) 2026 Shawn Bullock +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +name: CI + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + checks: + name: Checks (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Install stable Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + components: rustfmt, clippy + target: wasm32-unknown-unknown + cache: false + rustflags: "" + - uses: Swatinem/rust-cache@v2 + - name: Fetch dependencies + run: cargo fetch --locked + - name: Check formatting + if: runner.os == 'Linux' + run: cargo fmt --all --check + - name: Run clippy + if: runner.os == 'Linux' + run: cargo clippy --workspace --all-targets -- -D warnings + - name: Run tests + run: cargo test --workspace --offline + - name: Build WebAssembly + if: runner.os == 'Linux' + run: cargo build -p pak-wasm --target wasm32-unknown-unknown --offline diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..278af94 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/target/ +.DS_Store +/.agents/ +/.idea/ +/crates/wasm/pkg/ diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..207e237 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,21 @@ +## Code + +- Rust code follows `agents/rust-style.md`. +- `docs/spec rev3.md` is the format. Where code and spec disagree, the spec wins or the spec is changed first. +- `pak-core` does no I/O; `crates/core/clippy.toml` fails the lint run on a slip. + +## Before calling a change done + +```sh +cargo fmt --all --check +cargo clippy --workspace --all-targets -- -D warnings +cargo test --workspace +cargo build -p pak-wasm --target wasm32-unknown-unknown +devops/wasi +``` + + +## Compact Instructions + +Route every action on the data root (`.agents/tasky/`) through a `references/*.md` playbook under `~/.claude/skills/tasky/`. "Create a task" / "track this as work" → `structure.md`, even mid-flow on another task. Before the first action that changes a file or produces a deliverable, or on an ask reporting work finished or ticking a criterion, run the Tracked-Work Check in `navigate.md`. On a match, route through `execute.md`. Never create a task; that is `structure.md`. Two or more equal matches → ask which. When a task completes, the hand-back takes the form in `references/report.md`: `STATUS:` first, every line something that matters to the user, a `DECIDE:` line only when the user must decide something. + diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d6d08be --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,975 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bstr" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bb31b46c14244e20ee9984b11bf5c992b91fb6939fea616e3512c8baecdbe5f" +dependencies = [ + "memchr", + "serde_core", +] + +[[package]] +name = "bumpalo" +version = "3.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cc" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ff2a8126fff0f8c839080d619675a585e61720bb12d2baceae45769fd66f155" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "errno" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "flate2" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" +dependencies = [ + "zlib-rs", +] + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "fs4" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e72ed92b67c146290f88e9c89d60ca163ea417a446f61ffd7b72df3e7f1dfd5" +dependencies = [ + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "globset" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98b0d85522dc0a824cfebbc9594ff4a9b289c568bea0370319dfbdf20ccdd2d" +dependencies = [ + "aho-corasick", + "bstr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "junction" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cfc352a66ba903c23239ef51e809508b6fc2b0f90e3476ac7a9ff47e863ae95" +dependencies = [ + "scopeguard", + "windows-sys 0.61.2", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "minicov" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4869b6a491569605d66d3952bcdf03df789e5b536e5f0cf7758a7f08a55ae24d" +dependencies = [ + "cc", + "walkdir", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "pak" +version = "0.1.0" +dependencies = [ + "fs4", + "junction", + "pak-core", + "pak-remote", + "semver", + "serde_json", + "zip", +] + +[[package]] +name = "pak-core" +version = "0.1.0" +dependencies = [ + "globset", + "semver", + "serde", + "serde_json", + "sha2", + "spdx", + "unicode-normalization", + "zip", +] + +[[package]] +name = "pak-remote" +version = "0.1.0" +dependencies = [ + "base64", + "http", + "pak-core", + "serde_json", + "ureq", +] + +[[package]] +name = "pak-wasm" +version = "0.1.0" +dependencies = [ + "js-sys", + "pak-core", + "semver", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-test", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0283386ce02abc0151e1761d08802dfe86c173b0b494af5cbc086574e453da06" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "foldhash", + "indexmap", + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" + +[[package]] +name = "spdx" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "646c5a367da914e3babcb9cd8e91c37ccaac42325b8f86f036513ad103f2a716" +dependencies = [ + "smallvec", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "typed-path" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54ec2755506471f54baf5e4bb5499d8e510cc1caf271270e778a736bd2d7336c" + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-normalization" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75cd3fb03d5288b3ba9a1ee103ac7e9cbb59f0b03d64f8ddfcc04dd42758a85d" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "972d7902c8735f2695410b8aed7df6ed12a47394aa1c8d7af49f0497b731a94d" +dependencies = [ + "base64", + "log", + "percent-encoding", + "rustls", + "rustls-pki-types", + "ureq-proto", + "utf8-zero", + "webpki-roots", +] + +[[package]] +name = "ureq-proto" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da5f78b09e6941e1a0f2e30e695e4b120377b54d5e0aec11b594bb57b3971613" +dependencies = [ + "base64", + "http", + "httparse", + "log", +] + +[[package]] +name = "utf8-zero" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c0a043c9540bae7c578c88f91dda8bd82e59ae27c21baca69c8b191aaf5a6e" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-bindgen-test" +version = "0.3.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b4913c0ade07e01ab574b20d2741538f070efa12cb7a1a1e2d5df6ea41cf522" +dependencies = [ + "cast", + "js-sys", + "libm", + "minicov", + "nu-ansi-term", + "num-traits", + "oorandom", + "serde", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", + "wasm-bindgen-test-shared", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "238071aa4c5b268e57d21018621a2e2403c29dd11c55dbdf790ed47fdb9241c0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "wasm-bindgen-test-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ab365ce29ba0232367502b2894556ae77a9c214d33dbf453fdba7f586905918" + +[[package]] +name = "webpki-roots" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" + +[[package]] +name = "zip" +version = "8.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b" +dependencies = [ + "crc32fast", + "flate2", + "indexmap", + "memchr", + "typed-path", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b76d931 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,95 @@ +# SPDX-FileCopyrightText: 2026 Abhishek Mallepalli +# SPDX-FileCopyrightText: 2026 Shawn Bullock +# SPDX-License-Identifier: MIT +# +# Origin: https://github.com/manybyte/pak +# +# Author: Abhishek Mallepalli (@noisethanks), +# via https://github.com/manybyte/pak +# Co-author: Shawn Bullock (@shawnthehumble), +# via https://github.com/manybyte/pak +# +# Copyright (c) 2026 Abhishek Mallepalli +# Copyright (c) 2026 Shawn Bullock +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +[package] +name = "pak" +description = "Package manager for retro C and assembly development" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +license.workspace = true +repository.workspace = true + +[dependencies] +pak-core.workspace = true +pak-remote.workspace = true +semver.workspace = true + +[target.'cfg(not(target_os = "wasi"))'.dependencies] +fs4.workspace = true + +[target.'cfg(windows)'.dependencies] +junction.workspace = true + +[dev-dependencies] +serde_json.workspace = true +zip.workspace = true + +[lints] +workspace = true + +[workspace] +members = ["crates/core", "crates/remote", "crates/wasm"] +resolver = "3" + +[workspace.package] +version = "0.1.0" +edition = "2024" +rust-version = "1.85" +license = "MIT" +repository = "https://github.com/manybyte/pak" + +[workspace.dependencies] +pak-core = { path = "crates/core", version = "0.1.0" } +pak-remote = { path = "crates/remote", version = "0.1.0" } +base64 = { version = "0.23.1", default-features = false, features = ["alloc"] } +ureq = { version = "3.4.0", default-features = false, features = ["rustls"] } +http = "1.5.0" +fs4 = { version = "1.1.0", default-features = false } +junction = "1.2.0" +globset = { version = "0.4.21", default-features = false } +semver = "1.0.28" +serde = { version = "1.0.229", default-features = false, features = ["std"] } +sha2 = { version = "0.10.9", default-features = false } +serde_json = { version = "1.0.154", features = ["preserve_order"] } +spdx = "0.13.6" +unicode-normalization = { version = "0.1.26", default-features = false } +zip = { version = "8.6.0", default-features = false } +wasm-bindgen = "0.2.130" +js-sys = "0.3.107" +wasm-bindgen-test = "0.3.80" + +[workspace.lints.rust] +unsafe_code = "deny" + +[workspace.lints.clippy] +pedantic = { level = "warn", priority = -1 } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..13c3660 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 manybyte + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..d817195 --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,18 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +associated documentation files (the "Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO +EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..89cce67 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# pak + +pak is a package manager for retro C and assembly development. It packs, publishes and installs paks: versioned packages of headers, libraries, linker configs, sources and assets. It works from the command line and inside browser-based tools, and assumes no CPU, console or toolchain. + +The format is defined in [docs/spec rev3.md](). + +## Layout + +``` +Cargo.toml the pak command line, and the workspace +src/ the command line +crates/ + core/ pak-core: the format rules; never touches disk, network or clock + remote/ pak-remote: registries, GitHub and, later, the pak API + wasm/ pak-wasm: pak-core for browsers +docs/spec rev3.md the format +agents/ how the code is written +``` + +## Development + +Requires Rust 1.85 or newer. + +```sh +cargo build --workspace +cargo test --workspace +cargo fmt --all --check +cargo clippy --workspace --all-targets -- -D warnings +cargo build -p pak-wasm --target wasm32-unknown-unknown +``` + +Code follows [agents/rust-style.md](agents/rust-style.md). + +## License + +MIT diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 0000000..a672118 --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,22 @@ +version = 1 + +[[annotations]] +path = "tests/stories/**" +precedence = "override" +SPDX-FileCopyrightText = ["2026 Shawn Bullock", "2026 Abhishek Mallepalli"] +SPDX-License-Identifier = "MIT" + +[[annotations]] +path = [ + "docs/**", + "agents/**", + "schema/**", + "README.md", + "CLAUDE.md", + "Cargo.lock", + ".gitignore", + "LICENSE", +] +precedence = "override" +SPDX-FileCopyrightText = ["2026 Abhishek Mallepalli", "2026 Shawn Bullock"] +SPDX-License-Identifier = "MIT" diff --git a/agents/rust-style.md b/agents/rust-style.md new file mode 100644 index 0000000..ab13840 --- /dev/null +++ b/agents/rust-style.md @@ -0,0 +1,101 @@ +# Rust style + +How pak's Rust is written. Modeled on Microsoft's [Pragmatic Rust Guidelines](https://microsoft.github.io/rust-guidelines/) (version 2026.6), which build on the Rust team's [API Guidelines](https://rust-lang.github.io/api-guidelines/). Where this file is silent, follow those two, in that order. Bracketed ids such as `[M-IMPL-IO]` point to the matching Microsoft guideline. + +**Must** always holds. **Should** holds unless the code says why not. The reason behind a rule matters more than its wording: understand it before working around it. + +## Tooling + +- Code must pass `cargo fmt --check` with the default settings. No `rustfmt.toml`. +- Code must pass `cargo clippy --workspace --all-targets -- -D warnings`, with `clippy::pedantic` enabled for the workspace. [M-STATIC-VERIFICATION] +- `crates/core/clippy.toml` bans file, network, process, clock and environment calls in `pak-core`, so a slip fails the lint run. +- A lint is silenced with `#[expect(lint, reason = "…")]`, never `#[allow]`, so the override fails once it is no longer needed. [M-LINT-OVERRIDE-EXPECT] +- Every crate uses the latest edition and takes its version, edition, minimum Rust version, lints and shared dependency versions from the workspace `Cargo.toml`. The minimum Rust version moves only when a feature needs it. [M-CARGO-WORKSPACE] [M-LATEST-EDITION] [M-MSRV] + +## Layout + +``` +Cargo.toml the pak command line, and the workspace +src/ the command line +crates/ + core/ the format: no disk, network, shell or clock + remote/ talking to the network: registries, GitHub, later pak's own API + wasm/ core for browsers; translates, holds no rules +``` + +- All library crates are siblings under `crates/`. [M-CRATES-FLAT-FOLDER] +- Business rules live only in `core`. The command line and `wasm` translate between their world and `core`, nothing more. [M-FFI-TRANSLATES] +- `lib.rs` and `main.rs` only declare modules and the public surface. Each module owns one job and is named for it; no `utils`, `helpers` or `common`. [M-BALANCED-MODULES] +- Each public item is reachable through one path. No glob re-exports, no preludes. [M-SINGLE-ITEM-PATH] [M-NO-GLOB-REEXPORTS] [M-NO-PRELUDE] + +## The core never does I/O + +This is the rule the rest of the design leans on. [M-IMPL-IO] + +- `core` takes bytes, text and file lists as arguments and returns results. It never opens a file, reads the clock, spawns a process or touches the network. +- pak does use the network: registries, GitHub, and later its own API. That code lives in `remote`, and `core` never depends on it. +- A step that needs more data partway through, such as resolving dependencies one index file at a time, returns what it needs next. The caller fetches it and hands it back. `core` never calls out. +- So `core` builds for WebAssembly unchanged, and its tests need no network, temporary folders or mocks. + +## Names + +- Casing follows Rust: `snake_case` for functions, variables and modules, `PascalCase` for types and traits, `SCREAMING_SNAKE_CASE` for constants. [C-CASE] +- Full words: `directory`, `config`, `archive_path`, not `dir`, `cfg`, `apath`. Names the spec defines keep the spec's spelling (`cksum`, `pak`). +- Short as the module allows: `pack::Report`, not `pack::PackReport`. [M-SHORT-NAMES] +- No weasel words: no `Manager`, `Helper`, `Service`, `Data`, `Info`. Name what the thing is. [M-WEASEL-WORDS] +- Conversions follow `as_`, `to_`, `into_`. Getters have no `get_` prefix. [C-CONV] [C-GETTER] +- Booleans read as a fact: `is_yanked`, `has_profiles`. + +## Types + +- Prefer concrete types, then generics, then `dyn` traits. A trait appears only when two real implementations exist. [M-DI-HIERARCHY] +- A value with rules gets a type that enforces them on construction: `PackageName`, `Version`, `ArchivePath`. Code past that point trusts it. [M-STRONG-TYPES-GUARD] +- Paths inside an archive or manifest are their own type, never a bare `String` or `PathBuf`. +- Public types implement `Debug`. Types a person reads also implement `Display`. [M-PUBLIC-DEBUG] [M-PUBLIC-DISPLAY] +- No statics or global state. [M-AVOID-STATICS] + +## Errors and panics + +- `core` returns error structs, one per operation, each with a kind and enough context to name the file, field or package. [M-ERRORS-CANONICAL-STRUCTS] +- When a step can find several problems, such as pack finding two missing files, it reports all of them in one error, not the first. +- Errors convert with `From`, not scattered `map_err`. [M-FROM-ERROR] +- The command line may use `anyhow` to add context on the way out. [M-APP-ERROR] +- A panic means a bug in pak, never bad input. Untrusted input (manifests, archives, registry files) must never panic. [M-PANIC-ON-BUG] +- No `unwrap` outside tests. `expect` only where the code has just proven the value exists, with a message saying why. +- No `unsafe`. [M-UNSAFE] + +## Output + +- `core` never prints. It returns what happened, and the host decides how to show it. +- The command line prints through one output module, so every command reports in the same shape. + +## Comments and docs + +- Comments say why, never what. No commented-out code, no change history, no task notes. +- Every public item has a doc comment whose first sentence fits on one line. [M-FIRST-DOC-SENTENCE] +- Each module starts with a short `//!` saying what it owns. [M-MODULE-DOCS] +- Design decisions belong in `docs/`, not in the code. [M-NO-META-DESIGN-DOCUMENTATION] + +## Tests + +- Unit tests sit beside the code in `#[cfg(test)] mod tests`. Tests that drive a whole command live under `tests/`. [M-INTEGRATION-TESTS] +- Each test names the behavior it checks: `pack_fails_when_two_files_share_a_path`. +- Expected values are written out, never computed by the code under test. [M-TAUTOLOGICAL-TESTS] +- Every failure the spec names has a test that sees it fail. +- Input from outside, such as manifests, archives and registry files, gets tests with hostile cases: escaping paths, case collisions, oversized entries. + +## Dependencies + +- A dependency must earn its place: maintained, small, permissively licensed, and building for WebAssembly if `core` uses it. +- Versions are declared once, in the workspace. +- Features are additive. [M-FEATURES-ADDITIVE] + +## Not adopted + +- **mimalloc and `target-cpu`** [M-MIMALLOC-APPS] [M-TARGET-CPU]. pak is a short-lived command that ships to every machine, so it builds for the generic target with the default allocator. +- **Structured telemetry** [M-LOG-STRUCTURED], until pak's API exists. The command line's output is its report. The API service adopts it when it is built. + +## Async + +- `core` is never async; it does no I/O, so it has nothing to await. +- `remote` and anything that serves the API may be async, and its public functions are `async fn`, not functions returning a future. [M-ASYNC-FN] diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml new file mode 100644 index 0000000..6d22c18 --- /dev/null +++ b/crates/core/Cargo.toml @@ -0,0 +1,53 @@ +# SPDX-FileCopyrightText: 2026 Abhishek Mallepalli +# SPDX-FileCopyrightText: 2026 Shawn Bullock +# SPDX-License-Identifier: MIT +# +# Origin: https://github.com/manybyte/pak +# +# Author: Abhishek Mallepalli (@noisethanks), +# via https://github.com/manybyte/pak +# Co-author: Shawn Bullock (@shawnthehumble), +# via https://github.com/manybyte/pak +# +# Copyright (c) 2026 Abhishek Mallepalli +# Copyright (c) 2026 Shawn Bullock +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +[package] +name = "pak-core" +description = "The pak format: manifests, file selection, packing and resolution, with no I/O" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +license.workspace = true +repository.workspace = true + +[dependencies] +globset.workspace = true +semver.workspace = true +serde.workspace = true +sha2.workspace = true +serde_json.workspace = true +spdx.workspace = true +unicode-normalization.workspace = true +zip = { workspace = true, features = ["deflate-flate2-zlib-rs"] } + +[lints] +workspace = true diff --git a/crates/core/clippy.toml b/crates/core/clippy.toml new file mode 100644 index 0000000..1259234 --- /dev/null +++ b/crates/core/clippy.toml @@ -0,0 +1,51 @@ +# SPDX-FileCopyrightText: 2026 Abhishek Mallepalli +# SPDX-FileCopyrightText: 2026 Shawn Bullock +# SPDX-License-Identifier: MIT +# +# Origin: https://github.com/manybyte/pak +# +# Author: Abhishek Mallepalli (@noisethanks), +# via https://github.com/manybyte/pak +# Co-author: Shawn Bullock (@shawnthehumble), +# via https://github.com/manybyte/pak +# +# Copyright (c) 2026 Abhishek Mallepalli +# Copyright (c) 2026 Shawn Bullock +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +# The core must stay free of I/O so it builds for browsers; these make a slip fail the lint run. +disallowed-types = [ + { path = "std::fs::File", reason = "pak-core does no I/O; the host reads and writes" }, + { path = "std::fs::OpenOptions", reason = "pak-core does no I/O; the host reads and writes" }, + { path = "std::net::TcpStream", reason = "pak-core does no I/O; network code belongs in pak-remote" }, + { path = "std::net::UdpSocket", reason = "pak-core does no I/O; network code belongs in pak-remote" }, + { path = "std::process::Command", reason = "pak-core runs nothing; the host runs prepack" }, + { path = "std::time::SystemTime", reason = "pak-core reads no clock; the host passes times in" }, + { path = "std::time::Instant", reason = "pak-core reads no clock; the host passes times in" }, +] +disallowed-methods = [ + { path = "std::fs::read", reason = "pak-core does no I/O; the host reads and writes" }, + { path = "std::fs::read_to_string", reason = "pak-core does no I/O; the host reads and writes" }, + { path = "std::fs::read_dir", reason = "pak-core does no I/O; the host reads and writes" }, + { path = "std::fs::write", reason = "pak-core does no I/O; the host reads and writes" }, + { path = "std::fs::metadata", reason = "pak-core does no I/O; the host reads and writes" }, + { path = "std::env::var", reason = "pak-core reads no environment; the host passes settings in" }, + { path = "std::env::current_dir", reason = "pak-core reads no environment; the host passes paths in" }, +] diff --git a/crates/core/src/command.rs b/crates/core/src/command.rs new file mode 100644 index 0000000..896fdcc --- /dev/null +++ b/crates/core/src/command.rs @@ -0,0 +1,332 @@ +// SPDX-FileCopyrightText: 2026 Abhishek Mallepalli +// SPDX-FileCopyrightText: 2026 Shawn Bullock +// SPDX-License-Identifier: MIT +// +// Origin: https://github.com/manybyte/pak +// +// Author: Abhishek Mallepalli (@noisethanks), +// via https://github.com/manybyte/pak +// Co-author: Shawn Bullock (@shawnthehumble), +// via https://github.com/manybyte/pak +// +// Copyright (c) 2026 Abhishek Mallepalli +// Copyright (c) 2026 Shawn Bullock +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +//! What a command line asks for: the command its arguments name and that command's options, or +//! why they name none. + +use crate::message::{Id, Join, Message, Value}; +use crate::problems::Failure; + +/// What each command takes after its name, as its resolve lists it. +const INIT_TAKES: &[&str] = &[""]; +const INSTALL_TAKES: &[&str] = &[ + "--locked", + "--allow-version-conflict", + "--allow-fsnames", + "...", + "--profile ", +]; +const PATH_TAKES: &[&str] = &["", "--kind "]; +const IT_TAKES: &[&str] = &[ + "--list", + "--allow-local", + "--allow-scripts", + "--allow-fsnames", +]; + +/// The install's lock policy and explicit acceptance of version conflicts. +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] +pub struct InstallOptions { + pub locked: bool, + pub allow_version_conflict: bool, + pub allow_fsnames: bool, +} + +/// How `pak it` was asked to run. +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] +#[expect( + clippy::struct_excessive_bools, + reason = "each is a command-line switch, set on its own" +)] +pub struct PackOptions { + /// `--list`: also print every packed file. + pub list: bool, + /// `--allow-local`: pack even when a dependency is a `.pak` file only this machine has. + pub allow_local: bool, + /// `--allow-scripts`: run `prepack` without asking. + pub allow_scripts: bool, + /// `--allow-fsnames`: pack names that clash on macOS or Windows, or that Windows keeps for + /// devices, with a warning for each. + pub allow_fsnames: bool, +} + +/// A command and what it was given. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Command<'a> { + Init { + name: Option<&'a str>, + }, + Create { + source: &'a str, + path: &'a str, + }, + Remove { + package: &'a str, + }, + Update { + package: Option<&'a str>, + }, + /// With no packages, install what `.pak.json` lists; with packages, add each first. + Install { + packages: Vec<&'a str>, + profile: Option<&'a str>, + options: InstallOptions, + }, + Path { + package: Option<&'a str>, + kind: Option<&'a str>, + }, + List, + Outdated, + Info { + package: &'a str, + }, + Why { + package: &'a str, + }, + Verify, + Check, + It(PackOptions), + /// `pak help`, `--help` or `-h`: every command, or what the one named takes. + Help { + command: Option<&'a str>, + }, +} + +/// The help `pak help ` prints for `command`, or `None` when pak has no such command. +#[must_use] +pub fn help(command: Option<&str>) -> Option { + let id = match command { + None => Id::Help, + Some("init") => Id::HelpInit, + Some("create") => Id::HelpCreate, + Some("install") => Id::HelpInstall, + Some("remove") => Id::HelpRemove, + Some("update") => Id::HelpUpdate, + Some("list") => Id::HelpList, + Some("outdated") => Id::HelpOutdated, + Some("info") => Id::HelpInfo, + Some("why") => Id::HelpWhy, + Some("path") => Id::HelpPath, + Some("verify") => Id::HelpVerify, + Some("check") => Id::HelpCheck, + Some("it") => Id::HelpIt, + Some(_) => return None, + }; + Some(Message::new(id)) +} + +fn is_help(argument: &str) -> bool { + matches!(argument, "--help" | "-h") +} + +/// The command `args`, the words after `pak`, name. +/// +/// # Errors +/// +/// Returns no command, an unknown command or option, or a command missing what it takes, each +/// with the usage that fixes it. +pub fn parse<'a>(args: &[&'a str]) -> Result, Failure> { + match args { + [] => Err(Failure::new(Message::new(Id::NoCommand)).resolve(Message::new(Id::Commands))), + ["help" | "--help" | "-h"] => Ok(Command::Help { command: None }), + ["help", command] => match help(Some(command)) { + Some(_) => Ok(Command::Help { + command: Some(command), + }), + None => Err(unknown_command(command)), + }, + ["help", _, extra, ..] => Err(unknown_option("help", extra, &["[command]"])), + [command, rest @ ..] + if rest.iter().any(|a| is_help(a)) && help(Some(command)).is_some() => + { + Ok(Command::Help { + command: Some(command), + }) + } + ["init"] => Ok(Command::Init { name: None }), + ["init", name] => Ok(Command::Init { name: Some(name) }), + ["init", _, extra, ..] => Err(unknown_option("init", extra, INIT_TAKES)), + ["create", source, path] if !source.starts_with("--") && !path.starts_with("--") => { + Ok(Command::Create { source, path }) + } + ["create", rest @ ..] => Err(match rest { + [_, _, extra, ..] => unknown_option("create", extra, &["", ""]), + _ => Failure::new(takes("create", &["", ""])), + }), + ["remove", package] if !package.starts_with("--") => Ok(Command::Remove { package }), + ["remove", rest @ ..] => Err(match rest { + [option, ..] => unknown_option("remove", option, &[""]), + [] => Failure::new(takes("remove", &[""])), + }), + ["update"] => Ok(Command::Update { package: None }), + ["update", package] if !package.starts_with("--") => Ok(Command::Update { + package: Some(package), + }), + ["update", option, ..] => Err(unknown_option("update", option, &["[pkg]"])), + ["install", rest @ ..] => { + let (packages, profile, options) = install_arguments(rest)?; + Ok(Command::Install { + packages, + profile, + options, + }) + } + ["path", "--kind", kind] => Ok(Command::Path { + package: None, + kind: Some(kind), + }), + ["path", package] if !package.starts_with("--") => Ok(Command::Path { + package: Some(package), + kind: None, + }), + ["path", package, "--kind", kind] if !package.starts_with("--") => Ok(Command::Path { + package: Some(package), + kind: Some(kind), + }), + ["path", rest @ ..] => Err( + match rest + .iter() + .find(|option| option.starts_with("--") && **option != "--kind") + { + Some(option) => unknown_option("path", option, PATH_TAKES), + None => Failure::new(takes("path", PATH_TAKES)), + }, + ), + ["list"] => Ok(Command::List), + ["outdated"] => Ok(Command::Outdated), + ["info", package] if !package.starts_with("--") => Ok(Command::Info { package }), + ["info", rest @ ..] => Err(match rest { + [_, extra, ..] => unknown_option("info", extra, &[""]), + [option] => unknown_option("info", option, &[""]), + [] => Failure::new(takes("info", &[""])), + }), + ["why", package] if !package.starts_with("--") => Ok(Command::Why { package }), + ["why", rest @ ..] => Err(match rest { + [_, extra, ..] => unknown_option("why", extra, &[""]), + [option] => unknown_option("why", option, &[""]), + [] => Failure::new(takes("why", &[""])), + }), + ["verify"] => Ok(Command::Verify), + ["check"] => Ok(Command::Check), + [ + command @ ("verify" | "check" | "outdated" | "list"), + option, + .., + ] => Err(unknown_option(command, option, &[])), + ["it", flags @ ..] => Ok(Command::It(pack_options(flags)?)), + [command, ..] => Err(unknown_command(command)), + } +} + +/// `pak isn't a command`, and the commands there are. +fn unknown_command(command: &str) -> Failure { + Failure::new(Message::new(Id::UnknownCommand).with("command", command)) + .resolve(Message::new(Id::Commands)) +} + +/// `pak has no option