Browse Source

【初始】

PJ568 1 năm trước cách đây
commit
a0ac67de42
9 tập tin đã thay đổi với 3561 bổ sung và 0 xóa
  1. 1 0
      .gitignore
  2. 35 0
      CONTRIBUTING.md
  3. 1967 0
      Cargo.lock
  4. 23 0
      Cargo.toml
  5. 195 0
      LICENSE.md
  6. 126 0
      README.md
  7. 1 0
      docs/draft.md
  8. 1 0
      docs/prompt.md
  9. 1212 0
      src/main.rs

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+/target

+ 35 - 0
CONTRIBUTING.md

@@ -0,0 +1,35 @@
+# 贡献指北
+
+## 项目版本管理
+
+我们使用[语义化版本](https://semver.org/lang/zh-CN/)进行版本管理。
+任何对代码库的更改都不应使用现有版本发布。
+
+## 提交信息格式
+
+提交信息应遵循 [PJ568 提交说明规范](https://github.com/PJ-568/git-commit-regulation)。
+
+## 提交更改
+
+1. Fork 此仓库,在您的仓库新建一个基于此仓库默认分支(branch)的分支。
+2. 在该新建分支对项目进行更改,确保语法不存在问题后应用更改您的仓库。
+3. 向我们的仓库提交拉取请求。请确保您遵循了上述说明。
+4. 我们将定期审查拉取请求,并告知您我们的问题以及在合并您的拉取请求之前需要进行的任何更改。
+5. 我们希望您在 15 日内作出回应,之后如果没有显示活动,您的拉取请求可能会被关闭。
+
+### 参考流程
+
+1. Fork 源码,下载到本地并运行项目;
+2. 添加或修改代码;
+3. 配置 rust 环境并运行 `cargo check` 对修改的代码进行静态检查;
+4. 对相关改动进行全面的自我测试;
+5. 确认无误后提交修改到 Github;
+6. 提交 Pull Request。
+
+### 注意事项
+
+- 单次 Pull Request 不应提交过多修改,请确保每次提交都针对特定的功能且务必说明本次改动的具体目的,例如:修复某 bug 、优化某方法 等,方便进行 Code Review;
+- 对于 bug 的修复,应该将本次 Pull Request 和相对应 bug 的 issue 关联起来,让别人知道该问题已经被修复;
+- 对于较大的新功能,你需要先提交 Issues,例如 “【新增】添加 XXX 功能”,确认该功能有被添加的必要后,再开始工作;
+- 对于一些主观的样式、交互逻辑调整:如颜色、图标的使用,某些预设配置的增减修改等,一般不予通过。但可以在 Discussions 中进行讨论;
+- 其他如简单的代码优化、文档修正等,只要修改合理都会被接受。

+ 1967 - 0
Cargo.lock

@@ -0,0 +1,1967 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "addr2line"
+version = "0.24.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
+dependencies = [
+ "gimli",
+]
+
+[[package]]
+name = "adler2"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
+
+[[package]]
+name = "anstream"
+version = "0.6.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is_terminal_polyfill",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
+
+[[package]]
+name = "anstyle-parse"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9"
+dependencies = [
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882"
+dependencies = [
+ "anstyle",
+ "once_cell_polyfill",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "anyhow"
+version = "1.0.98"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
+
+[[package]]
+name = "atomic-waker"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
+
+[[package]]
+name = "autocfg"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
+
+[[package]]
+name = "backtrace"
+version = "0.3.75"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
+dependencies = [
+ "addr2line",
+ "cfg-if",
+ "libc",
+ "miniz_oxide",
+ "object",
+ "rustc-demangle",
+ "windows-targets",
+]
+
+[[package]]
+name = "base64"
+version = "0.22.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+
+[[package]]
+name = "bitflags"
+version = "2.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
+
+[[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 = "bumpalo"
+version = "3.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
+
+[[package]]
+name = "bytes"
+version = "1.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
+
+[[package]]
+name = "cc"
+version = "1.2.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7"
+dependencies = [
+ "shlex",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
+
+[[package]]
+name = "clap"
+version = "4.5.41"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9"
+dependencies = [
+ "clap_builder",
+ "clap_derive",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.5.41"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "clap_lex",
+ "strsim",
+]
+
+[[package]]
+name = "clap_derive"
+version = "4.5.41"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "clap_lex"
+version = "0.7.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
+
+[[package]]
+name = "colorchoice"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
+
+[[package]]
+name = "core-foundation"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+
+[[package]]
+name = "cpufeatures"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "crypto-common"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
+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 = "dirs"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
+dependencies = [
+ "dirs-sys",
+]
+
+[[package]]
+name = "dirs-sys"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
+dependencies = [
+ "libc",
+ "option-ext",
+ "redox_users",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "displaydoc"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "encoding_rs"
+version = "0.8.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "equivalent"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
+
+[[package]]
+name = "errno"
+version = "0.3.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
+dependencies = [
+ "libc",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "fastrand"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
+
+[[package]]
+name = "fnv"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
+
+[[package]]
+name = "foreign-types"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
+dependencies = [
+ "foreign-types-shared",
+]
+
+[[package]]
+name = "foreign-types-shared"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
+
+[[package]]
+name = "form_urlencoded"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
+dependencies = [
+ "percent-encoding",
+]
+
+[[package]]
+name = "futures-channel"
+version = "0.3.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
+dependencies = [
+ "futures-core",
+]
+
+[[package]]
+name = "futures-core"
+version = "0.3.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
+
+[[package]]
+name = "futures-sink"
+version = "0.3.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
+
+[[package]]
+name = "futures-task"
+version = "0.3.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
+
+[[package]]
+name = "futures-util"
+version = "0.3.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "pin-project-lite",
+ "pin-utils",
+]
+
+[[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.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi 0.11.1+wasi-snapshot-preview1",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "r-efi",
+ "wasi 0.14.2+wasi-0.2.4",
+]
+
+[[package]]
+name = "gimli"
+version = "0.31.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
+
+[[package]]
+name = "h2"
+version = "0.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "17da50a276f1e01e0ba6c029e47b7100754904ee8a278f886546e98575380785"
+dependencies = [
+ "atomic-waker",
+ "bytes",
+ "fnv",
+ "futures-core",
+ "futures-sink",
+ "http",
+ "indexmap",
+ "slab",
+ "tokio",
+ "tokio-util",
+ "tracing",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.15.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "http"
+version = "1.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565"
+dependencies = [
+ "bytes",
+ "fnv",
+ "itoa",
+]
+
+[[package]]
+name = "http-body"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
+dependencies = [
+ "bytes",
+ "http",
+]
+
+[[package]]
+name = "http-body-util"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "http",
+ "http-body",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "httparse"
+version = "1.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
+
+[[package]]
+name = "hyper"
+version = "1.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "httparse",
+ "itoa",
+ "pin-project-lite",
+ "smallvec",
+ "tokio",
+ "want",
+]
+
+[[package]]
+name = "hyper-rustls"
+version = "0.27.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58"
+dependencies = [
+ "http",
+ "hyper",
+ "hyper-util",
+ "rustls",
+ "rustls-pki-types",
+ "tokio",
+ "tokio-rustls",
+ "tower-service",
+]
+
+[[package]]
+name = "hyper-tls"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
+dependencies = [
+ "bytes",
+ "http-body-util",
+ "hyper",
+ "hyper-util",
+ "native-tls",
+ "tokio",
+ "tokio-native-tls",
+ "tower-service",
+]
+
+[[package]]
+name = "hyper-util"
+version = "0.1.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e"
+dependencies = [
+ "base64",
+ "bytes",
+ "futures-channel",
+ "futures-core",
+ "futures-util",
+ "http",
+ "http-body",
+ "hyper",
+ "ipnet",
+ "libc",
+ "percent-encoding",
+ "pin-project-lite",
+ "socket2 0.6.0",
+ "system-configuration",
+ "tokio",
+ "tower-service",
+ "tracing",
+ "windows-registry",
+]
+
+[[package]]
+name = "icu_collections"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47"
+dependencies = [
+ "displaydoc",
+ "potential_utf",
+ "yoke",
+ "zerofrom",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_locale_core"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a"
+dependencies = [
+ "displaydoc",
+ "litemap",
+ "tinystr",
+ "writeable",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979"
+dependencies = [
+ "displaydoc",
+ "icu_collections",
+ "icu_normalizer_data",
+ "icu_properties",
+ "icu_provider",
+ "smallvec",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer_data"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3"
+
+[[package]]
+name = "icu_properties"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b"
+dependencies = [
+ "displaydoc",
+ "icu_collections",
+ "icu_locale_core",
+ "icu_properties_data",
+ "icu_provider",
+ "potential_utf",
+ "zerotrie",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_properties_data"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632"
+
+[[package]]
+name = "icu_provider"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af"
+dependencies = [
+ "displaydoc",
+ "icu_locale_core",
+ "stable_deref_trait",
+ "tinystr",
+ "writeable",
+ "yoke",
+ "zerofrom",
+ "zerotrie",
+ "zerovec",
+]
+
+[[package]]
+name = "idna"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
+dependencies = [
+ "idna_adapter",
+ "smallvec",
+ "utf8_iter",
+]
+
+[[package]]
+name = "idna_adapter"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344"
+dependencies = [
+ "icu_normalizer",
+ "icu_properties",
+]
+
+[[package]]
+name = "indexmap"
+version = "2.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661"
+dependencies = [
+ "equivalent",
+ "hashbrown",
+]
+
+[[package]]
+name = "io-uring"
+version = "0.7.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4"
+dependencies = [
+ "bitflags",
+ "cfg-if",
+ "libc",
+]
+
+[[package]]
+name = "ipnet"
+version = "2.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130"
+
+[[package]]
+name = "iri-string"
+version = "0.7.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2"
+dependencies = [
+ "memchr",
+ "serde",
+]
+
+[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
+
+[[package]]
+name = "itoa"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
+
+[[package]]
+name = "js-sys"
+version = "0.3.77"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
+dependencies = [
+ "once_cell",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.174"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
+
+[[package]]
+name = "libredox"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4488594b9328dee448adb906d8b126d9b7deb7cf5c22161ee591610bb1be83c0"
+dependencies = [
+ "bitflags",
+ "libc",
+]
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
+
+[[package]]
+name = "litemap"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956"
+
+[[package]]
+name = "lock_api"
+version = "0.4.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765"
+dependencies = [
+ "autocfg",
+ "scopeguard",
+]
+
+[[package]]
+name = "log"
+version = "0.4.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
+
+[[package]]
+name = "memchr"
+version = "2.7.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
+
+[[package]]
+name = "mime"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
+
+[[package]]
+name = "miniz_oxide"
+version = "0.8.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
+dependencies = [
+ "adler2",
+]
+
+[[package]]
+name = "mio"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
+dependencies = [
+ "libc",
+ "wasi 0.11.1+wasi-snapshot-preview1",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "native-tls"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e"
+dependencies = [
+ "libc",
+ "log",
+ "openssl",
+ "openssl-probe",
+ "openssl-sys",
+ "schannel",
+ "security-framework",
+ "security-framework-sys",
+ "tempfile",
+]
+
+[[package]]
+name = "object"
+version = "0.36.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.21.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
+
+[[package]]
+name = "once_cell_polyfill"
+version = "1.70.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
+
+[[package]]
+name = "openssl"
+version = "0.10.73"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
+dependencies = [
+ "bitflags",
+ "cfg-if",
+ "foreign-types",
+ "libc",
+ "once_cell",
+ "openssl-macros",
+ "openssl-sys",
+]
+
+[[package]]
+name = "openssl-macros"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "openssl-probe"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
+
+[[package]]
+name = "openssl-sys"
+version = "0.9.109"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "option-ext"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
+
+[[package]]
+name = "pageos-pkgr"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "clap",
+ "dirs",
+ "reqwest",
+ "serde",
+ "serde_json",
+ "sha2",
+ "tokio",
+ "toml",
+ "walkdir",
+]
+
+[[package]]
+name = "parking_lot"
+version = "0.12.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13"
+dependencies = [
+ "lock_api",
+ "parking_lot_core",
+]
+
+[[package]]
+name = "parking_lot_core"
+version = "0.9.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall",
+ "smallvec",
+ "windows-targets",
+]
+
+[[package]]
+name = "percent-encoding"
+version = "2.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
+
+[[package]]
+name = "pin-utils"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
+
+[[package]]
+name = "pkg-config"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
+
+[[package]]
+name = "potential_utf"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585"
+dependencies = [
+ "zerovec",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.95"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.40"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "r-efi"
+version = "5.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
+
+[[package]]
+name = "redox_syscall"
+version = "0.5.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "de3a5d9f0aba1dbcec1cc47f0ff94a4b778fe55bca98a6dfa92e4e094e57b1c4"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "redox_users"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b"
+dependencies = [
+ "getrandom 0.2.16",
+ "libredox",
+ "thiserror",
+]
+
+[[package]]
+name = "reqwest"
+version = "0.12.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cbc931937e6ca3a06e3b6c0aa7841849b160a90351d6ab467a8b9b9959767531"
+dependencies = [
+ "base64",
+ "bytes",
+ "encoding_rs",
+ "futures-core",
+ "h2",
+ "http",
+ "http-body",
+ "http-body-util",
+ "hyper",
+ "hyper-rustls",
+ "hyper-tls",
+ "hyper-util",
+ "js-sys",
+ "log",
+ "mime",
+ "native-tls",
+ "percent-encoding",
+ "pin-project-lite",
+ "rustls-pki-types",
+ "serde",
+ "serde_json",
+ "serde_urlencoded",
+ "sync_wrapper",
+ "tokio",
+ "tokio-native-tls",
+ "tower",
+ "tower-http",
+ "tower-service",
+ "url",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-sys",
+]
+
+[[package]]
+name = "ring"
+version = "0.17.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
+dependencies = [
+ "cc",
+ "cfg-if",
+ "getrandom 0.2.16",
+ "libc",
+ "untrusted",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "rustc-demangle"
+version = "0.1.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
+
+[[package]]
+name = "rustix"
+version = "1.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "rustls"
+version = "0.23.29"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2491382039b29b9b11ff08b76ff6c97cf287671dbb74f0be44bda389fffe9bd1"
+dependencies = [
+ "once_cell",
+ "rustls-pki-types",
+ "rustls-webpki",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-pki-types"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79"
+dependencies = [
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-webpki"
+version = "0.103.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc"
+dependencies = [
+ "ring",
+ "rustls-pki-types",
+ "untrusted",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
+
+[[package]]
+name = "ryu"
+version = "1.0.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
+
+[[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 = "schannel"
+version = "0.1.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d"
+dependencies = [
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+[[package]]
+name = "security-framework"
+version = "2.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
+dependencies = [
+ "bitflags",
+ "core-foundation",
+ "core-foundation-sys",
+ "libc",
+ "security-framework-sys",
+]
+
+[[package]]
+name = "security-framework-sys"
+version = "2.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "serde"
+version = "1.0.219"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.219"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.141"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3"
+dependencies = [
+ "itoa",
+ "memchr",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "serde_spanned"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "40734c41988f7306bb04f0ecf60ec0f3f1caa34290e4e8ea471dcd3346483b83"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "serde_urlencoded"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
+dependencies = [
+ "form_urlencoded",
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[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 = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
+
+[[package]]
+name = "signal-hook-registry"
+version = "1.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "slab"
+version = "0.4.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d"
+
+[[package]]
+name = "smallvec"
+version = "1.15.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
+
+[[package]]
+name = "socket2"
+version = "0.5.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
+dependencies = [
+ "libc",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "socket2"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807"
+dependencies = [
+ "libc",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "stable_deref_trait"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "subtle"
+version = "2.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
+
+[[package]]
+name = "syn"
+version = "2.0.104"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "sync_wrapper"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
+dependencies = [
+ "futures-core",
+]
+
+[[package]]
+name = "synstructure"
+version = "0.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "system-configuration"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
+dependencies = [
+ "bitflags",
+ "core-foundation",
+ "system-configuration-sys",
+]
+
+[[package]]
+name = "system-configuration-sys"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "tempfile"
+version = "3.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1"
+dependencies = [
+ "fastrand",
+ "getrandom 0.3.3",
+ "once_cell",
+ "rustix",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "thiserror"
+version = "2.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "2.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "tinystr"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b"
+dependencies = [
+ "displaydoc",
+ "zerovec",
+]
+
+[[package]]
+name = "tokio"
+version = "1.46.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17"
+dependencies = [
+ "backtrace",
+ "bytes",
+ "io-uring",
+ "libc",
+ "mio",
+ "parking_lot",
+ "pin-project-lite",
+ "signal-hook-registry",
+ "slab",
+ "socket2 0.5.10",
+ "tokio-macros",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "tokio-native-tls"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
+dependencies = [
+ "native-tls",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-rustls"
+version = "0.26.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b"
+dependencies = [
+ "rustls",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-util"
+version = "0.7.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "toml"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed0aee96c12fa71097902e0bb061a5e1ebd766a6636bb605ba401c45c1650eac"
+dependencies = [
+ "indexmap",
+ "serde",
+ "serde_spanned",
+ "toml_datetime",
+ "toml_parser",
+ "toml_writer",
+ "winnow",
+]
+
+[[package]]
+name = "toml_datetime"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bade1c3e902f58d73d3f294cd7f20391c1cb2fbcb643b73566bc773971df91e3"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "toml_parser"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97200572db069e74c512a14117b296ba0a80a30123fbbb5aa1f4a348f639ca30"
+dependencies = [
+ "winnow",
+]
+
+[[package]]
+name = "toml_writer"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64"
+
+[[package]]
+name = "tower"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9"
+dependencies = [
+ "futures-core",
+ "futures-util",
+ "pin-project-lite",
+ "sync_wrapper",
+ "tokio",
+ "tower-layer",
+ "tower-service",
+]
+
+[[package]]
+name = "tower-http"
+version = "0.6.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
+dependencies = [
+ "bitflags",
+ "bytes",
+ "futures-util",
+ "http",
+ "http-body",
+ "iri-string",
+ "pin-project-lite",
+ "tower",
+ "tower-layer",
+ "tower-service",
+]
+
+[[package]]
+name = "tower-layer"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
+
+[[package]]
+name = "tower-service"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"
+
+[[package]]
+name = "tracing"
+version = "0.1.41"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
+dependencies = [
+ "pin-project-lite",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678"
+dependencies = [
+ "once_cell",
+]
+
+[[package]]
+name = "try-lock"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
+
+[[package]]
+name = "typenum"
+version = "1.18.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
+
+[[package]]
+name = "untrusted"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
+
+[[package]]
+name = "url"
+version = "2.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60"
+dependencies = [
+ "form_urlencoded",
+ "idna",
+ "percent-encoding",
+]
+
+[[package]]
+name = "utf8_iter"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
+
+[[package]]
+name = "utf8parse"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
+
+[[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 = "want"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
+dependencies = [
+ "try-lock",
+]
+
+[[package]]
+name = "wasi"
+version = "0.11.1+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
+
+[[package]]
+name = "wasi"
+version = "0.14.2+wasi-0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
+dependencies = [
+ "wit-bindgen-rt",
+]
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "rustversion",
+ "wasm-bindgen-macro",
+]
+
+[[package]]
+name = "wasm-bindgen-backend"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
+dependencies = [
+ "bumpalo",
+ "log",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-futures"
+version = "0.4.50"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61"
+dependencies = [
+ "cfg-if",
+ "js-sys",
+ "once_cell",
+ "wasm-bindgen",
+ "web-sys",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-backend",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "web-sys"
+version = "0.3.77"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "winapi-util"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
+dependencies = [
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
+
+[[package]]
+name = "windows-registry"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e"
+dependencies = [
+ "windows-link",
+ "windows-result",
+ "windows-strings",
+]
+
+[[package]]
+name = "windows-result"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-strings"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"
+dependencies = [
+ "windows-link",
+]
+
+[[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.59.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
+dependencies = [
+ "windows-targets",
+]
+
+[[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 = "winnow"
+version = "0.7.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95"
+
+[[package]]
+name = "wit-bindgen-rt"
+version = "0.39.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "writeable"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb"
+
+[[package]]
+name = "yoke"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc"
+dependencies = [
+ "serde",
+ "stable_deref_trait",
+ "yoke-derive",
+ "zerofrom",
+]
+
+[[package]]
+name = "yoke-derive"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
+
+[[package]]
+name = "zerofrom"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5"
+dependencies = [
+ "zerofrom-derive",
+]
+
+[[package]]
+name = "zerofrom-derive"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
+
+[[package]]
+name = "zeroize"
+version = "1.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
+
+[[package]]
+name = "zerotrie"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595"
+dependencies = [
+ "displaydoc",
+ "yoke",
+ "zerofrom",
+]
+
+[[package]]
+name = "zerovec"
+version = "0.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428"
+dependencies = [
+ "yoke",
+ "zerofrom",
+ "zerovec-derive",
+]
+
+[[package]]
+name = "zerovec-derive"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]

+ 23 - 0
Cargo.toml

@@ -0,0 +1,23 @@
+[package]
+name = "pageos-pkgr"
+version = "0.1.0"
+authors = ["PJ568 <[email protected]>"]
+edition = "2024"
+license = "MPL-2.0"
+description = "PageOS 系统的网页应用仓库管理工具,用于管理网页应用的安装、更新和仓库维护"
+repository = "https://github.com/swaybien/pageos-pkgr"
+homepage = "https://github.com/swaybien/pageos-pkgr"
+keywords = ["package-manager", "web-app", "pageos", "rust"]
+categories = ["command-line-utilities", "development-tools"]
+
+[dependencies]
+clap = { version = "4.5", features = ["derive"] }
+serde = { version = "1.0", features = ["derive"] }
+serde_json = "1.0"
+dirs = "6.0"
+anyhow = "1.0"
+reqwest = { version = "0.12.22", features = ["json"] }
+tokio = { version = "1.46.1", features = ["full"] }
+toml = "0.9"
+walkdir = "2.5.0"
+sha2 = "0.10.9"

+ 195 - 0
LICENSE.md

@@ -0,0 +1,195 @@
+# Mozilla Public License  
+
+Version 2.0
+
+## 1\. Definitions
+
+1.1. “Contributor”
+
+means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.
+
+1.2. “Contributor Version”
+
+means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution.
+
+1.3. “Contribution”
+
+means Covered Software of a particular Contributor.
+
+1.4. “Covered Software”
+
+means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof.
+
+1.5. “Incompatible With Secondary Licenses”
+
+means
+
+1. that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or
+
+2. that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License.
+
+1.6. “Executable Form”
+
+means any form of the work other than Source Code Form.
+
+1.7. “Larger Work”
+
+means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software.
+
+1.8. “License”
+
+means this document.
+
+1.9. “Licensable”
+
+means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License.
+
+1.10. “Modifications”
+
+means any of the following:
+
+1. any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or
+
+2. any new file in Source Code Form that contains any Covered Software.
+
+1.11. “Patent Claims” of a Contributor
+
+means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.
+
+1.12. “Secondary License”
+
+means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.
+
+1.13. “Source Code Form”
+
+means the form of the work preferred for making modifications.
+
+1.14. “You” (or “Your”)
+
+means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
+
+## 2\. License Grants and Conditions
+
+### 2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
+
+1. under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and
+
+2. under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version.
+
+### 2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution.
+
+### 2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor:
+
+1. for any code that a Contributor has removed from Covered Software; or
+
+2. for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or
+
+3. under Patent Claims infringed by Covered Software in the absence of its Contributions.
+
+This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4).
+
+### 2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3).
+
+### 2.5. Representation
+
+Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License.
+
+### 2.6. Fair Use
+
+This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents.
+
+### 2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1.
+
+## 3\. Responsibilities
+
+### 3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form.
+
+### 3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+1. such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and
+
+2. You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License.
+
+### 3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).
+
+### 3.4. Notices
+
+You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies.
+
+### 3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.
+
+## 4\. Inability to Comply Due to Statute or Regulation
+
+If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
+
+## 5\. Termination
+
+5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.
+
+## 6\. Disclaimer of Warranty
+
+_Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer._
+
+## 7\. Limitation of Liability
+
+_Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You._
+
+## 8\. Litigation
+
+Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims.
+
+## 9\. Miscellaneous
+
+This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.
+
+## 10\. Versions of the License
+
+### 10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.
+
+### 10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.
+
+### 10.3. Modified Versions
+
+If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License).
+
+### 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.
+
+## Exhibit A - Source Code Form License Notice
+
+> This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
+
+If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+## Exhibit B - “Incompatible With Secondary Licenses” Notice
+
+> This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.

+ 126 - 0
README.md

@@ -0,0 +1,126 @@
+# PageOS 网页应用包管理器 (pageos-pkgr)
+
+[![License: MPL-2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)
+
+PageOS-pkgr 是 PageOS 系统的网页应用仓库管理工具,用于管理网页应用的安装、更新和仓库维护。
+
+## 项目背景
+
+PageOS 是一个基于 Arch Linux 的图形化发行版,采用 Wayland 下的 cage 显示全屏的 Firefox 浏览器作为用户界面。所有用户交互都在网页中实现,通过 Rust 双向服务端程序使用 WebSocket 进行系统交互。
+
+## 功能特性
+
+- 管理本地和在线网页应用仓库
+- 支持应用包的安装、升级和卸载
+- 提供应用包元数据管理 (metadata.json)
+- 支持版本控制和增量更新
+- 提供命令行界面进行仓库管理
+
+## 仓库结构
+
+### 本地仓库
+
+```
+~/.local/share/pageos/
+├── local/                  # 本地仓库
+│   └── applications/
+│       ├── pageos/
+│       │   └── settings-manager/
+│       │       ├── 1.0.0/
+│       │       │   ├── metadata.json
+│       │       │   └── ... # 应用文件
+│       │       ├── 1.1.0/
+│       │       └── versions.txt
+│       └── %USER_NAME%/
+│           └── app2/
+├── remote/                 # 远程仓库缓存
+├── config.toml             # 软件源配置
+└── index.json              # 全局索引文件
+```
+
+### 在线仓库
+
+```
+./applications/
+├── %APP_NAME%/
+│   ├── %VERSION%/
+│   │   ├── metadata.json
+│   │   └── ...           # 应用文件
+│   └── versions.txt
+├── config.toml           # 设置文件
+└── index.json            # 索引文件
+```
+
+## 安装
+
+```bash
+cargo install pageos-pkgr
+```
+
+## 使用说明
+
+### 应用包管理
+
+```bash
+# 创建新应用包
+pageos-pkgr app new <package-name>
+
+# 在当前目录初始化应用包
+pageos-pkgr app init
+
+# 添加文件到应用包
+pageos-pkgr app add <file-path>
+```
+
+### 软件源管理
+
+```bash
+# 创建新软件源
+pageos-pkgr source new <source-repo-path>
+
+# 添加软件包到仓库
+pageos-pkgr source add <package-path>
+
+# 更新仓库索引
+pageos-pkgr source update
+```
+
+### 本地仓库管理
+
+```bash
+# 创建本地仓库
+pageos-pkgr local new <local-repo-path>
+
+# 安装软件包
+pageos-pkgr local install <package-name>
+
+# 升级软件包
+pageos-pkgr local upgrade
+```
+
+## 开发
+
+### 依赖
+
+- Rust 1.70+
+- Cargo
+
+### 构建
+
+```bash
+cargo build --release
+```
+
+## 许可证
+
+本项目采用 [Mozilla Public License 2.0](https://www.mozilla.org/en-US/MPL/2.0/) 开源许可证。
+
+## 贡献
+
+欢迎提交 Pull Request 或 Issue 报告问题。
+
+## 相关项目
+
+- [pageos-greet](https://github.com/swaybien/pageos-greet) - PageOS 登录界面
+- [pageos-core](https://github.com/swaybien/pageos-core) - PageOS 核心框架
+- [pageos-apps](https://github.com/swaybien/pageos-apps) - 官方网页应用仓库

+ 1 - 0
docs/draft.md

@@ -0,0 +1 @@
+../../pageos-core/docs/draft.md

+ 1 - 0
docs/prompt.md

@@ -0,0 +1 @@
+../../pageos-core/docs/prompt.md

+ 1212 - 0
src/main.rs

@@ -0,0 +1,1212 @@
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+use clap::{Parser, Subcommand};
+use sha2::Digest;
+use toml;
+use walkdir::WalkDir;
+
+#[derive(Parser)]
+#[command(version, about, long_about = None)]
+struct Cli {
+    /// 跳过确认提示
+    #[arg(short, long)]
+    yes: bool,
+
+    #[command(subcommand)]
+    command: Commands,
+}
+
+#[derive(Subcommand)]
+enum SourceCommand {
+    /// 创建新的在线软件源仓库
+    New {
+        /// 软件源仓库路径
+        path: String,
+    },
+    /// 添加新软件(或升级软件版本)到仓库
+    Add {
+        /// 安装包路径
+        package_path: String,
+    },
+    /// 从仓库删除软件(版本)
+    Remove {
+        /// 软件包名称和版本,格式为 "包名:版本"
+        package_spec: String,
+    },
+    /// 更新仓库索引
+    Update,
+    /// 从其它软件源增量同步
+    Sync {
+        /// 远程软件源 URL
+        remote_url: String,
+        /// 是否镜像同步(完全覆盖本地)
+        #[arg(short, long)]
+        mirror: bool,
+    },
+}
+
+#[derive(Subcommand)]
+enum LocalCommand {
+    /// 创建新的本地软件仓库
+    New {
+        /// 本地仓库路径
+        path: String,
+    },
+    /// 更新本地索引
+    Update,
+    /// 升级已安装软件包
+    Upgrade,
+    /// 安装软件包
+    Install {
+        /// 软件包名称
+        package_name: String,
+    },
+    /// 卸载软件包
+    Remove {
+        /// 软件包名称
+        package_name: String,
+    },
+}
+
+#[derive(Subcommand)]
+enum AppCommand {
+    /// 创建新的应用包
+    New {
+        /// 应用包名称 (user/repo)
+        name: String,
+    },
+    /// 在当前目录初始化应用包
+    Init,
+    /// 添加文件或目录到应用包
+    Add {
+        /// 要添加的文件或目录路径
+        path: String,
+    },
+}
+
+#[derive(Subcommand)]
+enum Commands {
+    /// 应用包管理
+    App {
+        #[command(subcommand)]
+        command: AppCommand,
+    },
+    /// 软件源仓库管理
+    Source {
+        #[command(subcommand)]
+        command: SourceCommand,
+    },
+    /// 本地仓库管理
+    Local {
+        #[command(subcommand)]
+        command: LocalCommand,
+    },
+}
+
+use anyhow::{Context, Result};
+use serde::{Deserialize, Serialize};
+use std::collections::HashMap;
+use std::fs;
+use std::path::Path;
+
+#[tokio::main]
+async fn main() {
+    if let Err(e) = run().await {
+        eprintln!("错误: {}", e);
+        std::process::exit(1);
+    }
+}
+
+async fn run() -> Result<()> {
+    let cli = Cli::parse();
+
+    // 在执行命令前进行确认检查
+    if !cli.yes && !confirm_action(&cli.command)? {
+        println!("操作已取消");
+        return Ok(());
+    }
+
+    match cli.command {
+        Commands::App { command } => match command {
+            AppCommand::New { name } => {
+                println!("创建新应用包: {}", name);
+                // 创建包目录
+                let dir_path = Path::new(&name);
+                if dir_path.exists() {
+                    anyhow::bail!("目录 '{}' 已存在", name);
+                }
+
+                fs::create_dir(&dir_path).with_context(|| format!("创建目录 '{}' 失败", name))?;
+
+                // 在新目录中初始化包
+                initialize_package(&dir_path).context("初始化软件包失败")?;
+
+                println!("应用包 '{}' 创建成功", name);
+                Ok(())
+            }
+            AppCommand::Init => {
+                let current_dir = std::env::current_dir()?;
+                initialize_package(&current_dir).context("初始化软件包失败")?;
+                println!("软件包初始化完成");
+                Ok(())
+            }
+            AppCommand::Add { path } => {
+                handle_app_add(&path)?;
+                Ok(())
+            }
+        },
+        Commands::Source { command } => match command {
+            SourceCommand::New { path } => {
+                create_source_repo(&path)?;
+                println!("成功创建软件源仓库于: {}", path);
+                Ok(())
+            }
+            SourceCommand::Add { package_path } => {
+                add_package_to_repo(&package_path)?;
+                println!("成功添加软件包: {}", package_path);
+                Ok(())
+            }
+            SourceCommand::Remove { package_spec } => {
+                remove_package_from_repo(&package_spec)?;
+                println!("成功删除软件包: {}", package_spec);
+                Ok(())
+            }
+            SourceCommand::Update => {
+                update_source_index()?;
+                println!("成功更新仓库索引");
+                Ok(())
+            }
+            SourceCommand::Sync { remote_url, mirror } => {
+                sync_from_remote(&remote_url, mirror).await?;
+                println!("成功从 {} 同步软件源", remote_url);
+                Ok(())
+            }
+        },
+        Commands::Local { command } => match command {
+            LocalCommand::New { path } => {
+                create_local_repo(&path)?;
+                println!("成功创建本地软件仓库于: {}", path);
+                Ok(())
+            }
+            LocalCommand::Update => {
+                update_local_index().await?;
+                println!("成功更新本地索引");
+                Ok(())
+            }
+            LocalCommand::Upgrade => {
+                // 先更新本地索引
+                update_local_index().await?;
+
+                // 获取本地和远程索引
+                let local_index = get_local_index()?;
+                let remote_index = {
+                    let repo_root = std::env::current_dir()?;
+                    let remote_index_path = repo_root.join("remote").join("index.json");
+                    if !remote_index_path.exists() {
+                        anyhow::bail!("远程索引不存在,请先运行 local update");
+                    }
+                    let content = fs::read_to_string(&remote_index_path)?;
+                    serde_json::from_str::<Vec<AppIndex>>(&content)?
+                };
+
+                // 找出需要更新的包
+                let updates = compare_versions(&local_index, &remote_index);
+                if updates.is_empty() {
+                    println!("所有软件包已是最新版本");
+                    return Ok(());
+                }
+
+                println!("以下软件包可升级:");
+                for update in &updates {
+                    println!(
+                        "- {}: {} -> {}",
+                        update.id, update.current_version, update.latest_version
+                    );
+                }
+
+                // 确认升级
+                if !cli.yes {
+                    println!("确定要升级这些软件包吗?(y/N)");
+                    let mut input = String::new();
+                    std::io::stdin().read_line(&mut input)?;
+                    if !input.trim().eq_ignore_ascii_case("y") {
+                        println!("升级已取消");
+                        return Ok(());
+                    }
+                }
+
+                // 从配置获取远程仓库URL
+                let repo_root = std::env::current_dir()?;
+                let config_path = repo_root.join("config.toml");
+                let config_content = fs::read_to_string(&config_path)?;
+                let config: toml::Table = toml::from_str(&config_content)?;
+                let remote_url = config["remote"]["url"]
+                    .as_str()
+                    .ok_or_else(|| anyhow::anyhow!("配置文件中缺少远程仓库 URL"))?;
+
+                // 执行升级
+                for update in updates {
+                    println!("正在升级 {}...", update.id);
+
+                    // 下载新版本
+                    let package_url = format!(
+                        "{}/applications/{}/{}/",
+                        remote_url.trim_end_matches('/'),
+                        update.id,
+                        update.latest_version
+                    );
+
+                    let target_dir = repo_root
+                        .join("local")
+                        .join("applications")
+                        .join(&update.id)
+                        .join(&update.latest_version);
+
+                    fs::create_dir_all(&target_dir)?;
+
+                    // 下载元数据
+                    let metadata_url = format!("{}metadata.json", package_url);
+                    let metadata_path = target_dir.join("metadata.json");
+                    download_file(&metadata_url, &metadata_path).await?;
+
+                    // 下载应用文件
+                    let metadata: Metadata =
+                        serde_json::from_str(&fs::read_to_string(&metadata_path)?)?;
+                    for (file_path, _) in metadata.all_files {
+                        let file_url = format!("{}{}", package_url, file_path);
+                        let dest_path = target_dir.join(file_path);
+
+                        if let Some(parent) = dest_path.parent() {
+                            fs::create_dir_all(parent)?;
+                        }
+
+                        download_file(&file_url, &dest_path).await?;
+                    }
+
+                    // 更新 versions.txt
+                    let versions_file = target_dir.parent().unwrap().join("versions.txt");
+                    let mut versions = get_versions_from_file(&versions_file).unwrap_or_default();
+                    if !versions.contains(&update.latest_version) {
+                        versions.push(update.latest_version.clone());
+                        write_versions_to_file(&versions_file, &versions)?;
+                    }
+
+                    println!("成功升级 {} 到 {}", update.id, update.latest_version);
+                }
+
+                // 更新本地索引
+                let local_index_path = repo_root.join("local").join("index.json");
+                fs::write(
+                    &local_index_path,
+                    serde_json::to_string_pretty(&remote_index)?,
+                )?;
+
+                println!("所有软件包升级完成");
+                Ok(())
+            }
+            LocalCommand::Install { package_name } => {
+                // 先更新本地索引
+                update_local_index().await?;
+
+                // 获取远程索引
+                let repo_root = std::env::current_dir()?;
+                let remote_index_path = repo_root.join("remote").join("index.json");
+                if !remote_index_path.exists() {
+                    anyhow::bail!("远程索引不存在,请先运行 local update");
+                }
+                let content = fs::read_to_string(&remote_index_path)?;
+                let remote_index: Vec<AppIndex> = serde_json::from_str(&content)?;
+
+                // 查找要安装的包
+                let package = remote_index
+                    .iter()
+                    .find(|app| app.id == package_name)
+                    .ok_or_else(|| anyhow::anyhow!("找不到软件包: {}", package_name))?;
+
+                // 从配置获取远程仓库URL
+                let config_path = repo_root.join("config.toml");
+                let config_content = fs::read_to_string(&config_path)?;
+                let config: toml::Table = toml::from_str(&config_content)?;
+                let remote_url = config["remote"]["url"]
+                    .as_str()
+                    .ok_or_else(|| anyhow::anyhow!("配置文件中缺少远程仓库 URL"))?;
+
+                println!("正在安装 {}...", package_name);
+
+                // 下载软件包
+                let package_url = format!(
+                    "{}/applications/{}/{}/",
+                    remote_url.trim_end_matches('/'),
+                    package.id,
+                    package.latest_version
+                );
+
+                let target_dir = repo_root
+                    .join("local")
+                    .join("applications")
+                    .join(&package.id)
+                    .join(&package.latest_version);
+
+                fs::create_dir_all(&target_dir)?;
+
+                // 下载元数据
+                let metadata_url = format!("{}metadata.json", package_url);
+                let metadata_path = target_dir.join("metadata.json");
+                download_file(&metadata_url, &metadata_path).await?;
+
+                // 下载应用文件
+                let metadata: Metadata =
+                    serde_json::from_str(&fs::read_to_string(&metadata_path)?)?;
+                for (file_path, _) in metadata.all_files {
+                    let file_url = format!("{}{}", package_url, file_path);
+                    let dest_path = target_dir.join(file_path);
+
+                    if let Some(parent) = dest_path.parent() {
+                        fs::create_dir_all(parent)?;
+                    }
+
+                    download_file(&file_url, &dest_path).await?;
+                }
+
+                // 更新 versions.txt
+                let versions_file = target_dir.parent().unwrap().join("versions.txt");
+                let mut versions = get_versions_from_file(&versions_file).unwrap_or_default();
+                if !versions.contains(&package.latest_version) {
+                    versions.push(package.latest_version.clone());
+                    write_versions_to_file(&versions_file, &versions)?;
+                }
+
+                // 更新本地索引
+                let local_index_path = repo_root.join("local").join("index.json");
+                let mut local_index = get_local_index()?;
+                if !local_index.iter().any(|app| app.id == package.id) {
+                    local_index.push(AppIndex {
+                        id: package.id.clone(),
+                        name: package.name.clone(),
+                        author: package.author.clone(),
+                        latest_version: package.latest_version.clone(),
+                        description: package.description.clone(),
+                        location: format!("applications/{}/{}", package.id, package.latest_version),
+                    });
+                    fs::write(
+                        &local_index_path,
+                        serde_json::to_string_pretty(&local_index)?,
+                    )?;
+                }
+
+                println!("成功安装 {} 版本 {}", package_name, package.latest_version);
+                Ok(())
+            }
+            LocalCommand::Remove { package_name } => {
+                // 获取仓库根目录
+                let repo_root = std::env::current_dir()?;
+                let local_dir = repo_root.join("local");
+
+                // 构建应用目录路径
+                let app_dir = local_dir.join("applications").join(&package_name);
+                if !app_dir.exists() {
+                    anyhow::bail!("找不到软件包: {}", package_name);
+                }
+
+                // 删除应用目录
+                fs::remove_dir_all(&app_dir)?;
+                println!("已卸载软件包: {}", package_name);
+
+                // 更新本地索引
+                let local_index_path = local_dir.join("index.json");
+                if local_index_path.exists() {
+                    let mut index: Vec<AppIndex> =
+                        serde_json::from_str(&fs::read_to_string(&local_index_path)?)?;
+                    index.retain(|app| app.id != package_name);
+                    fs::write(&local_index_path, serde_json::to_string_pretty(&index)?)?;
+                }
+
+                Ok(())
+            }
+        },
+    }
+}
+
+/// 确认操作
+fn confirm_action(command: &Commands) -> Result<bool> {
+    let prompt = match command {
+        Commands::App { command } => match command {
+            AppCommand::New { name } => format!("确定要创建新应用包 '{}' 吗?(y/N)", name),
+            AppCommand::Init => "确定要在当前目录初始化应用包吗?(y/N)".to_string(),
+            AppCommand::Add { path } => format!("确定要添加路径 '{}' 到应用包吗?(y/N)", path),
+        },
+        Commands::Source { command } => match command {
+            SourceCommand::New { path } => format!("确定要创建新软件源仓库于 '{}' 吗?(y/N)", path),
+            SourceCommand::Add { package_path } => {
+                format!("确定要添加软件包 '{}' 到仓库吗?(y/N)", package_path)
+            }
+            SourceCommand::Remove { package_spec } => {
+                format!("确定要从仓库删除软件包 '{}' 吗?(y/N)", package_spec)
+            }
+            SourceCommand::Update => "确定要更新仓库索引吗?(y/N)".to_string(),
+            SourceCommand::Sync { remote_url, mirror } => format!(
+                "确定要从 {} {}同步软件源吗?(y/N)",
+                remote_url,
+                if *mirror { "镜像" } else { "" }
+            ),
+        },
+        Commands::Local { command } => match command {
+            LocalCommand::New { path } => format!("确定要创建新本地仓库于 '{}' 吗?(y/N)", path),
+            LocalCommand::Update => "确定要更新本地索引吗?(y/N)".to_string(),
+            LocalCommand::Upgrade => "确定要升级已安装软件包吗?(y/N)".to_string(),
+            LocalCommand::Install { package_name } => {
+                format!("确定要安装软件包 '{}' 吗?(y/N)", package_name)
+            }
+            LocalCommand::Remove { package_name } => {
+                format!("确定要卸载软件包 '{}' 吗?(y/N)", package_name)
+            }
+        },
+    };
+
+    println!("{}", prompt);
+    let mut input = String::new();
+    std::io::stdin().read_line(&mut input)?;
+    Ok(input.trim().eq_ignore_ascii_case("y"))
+}
+
+/// 检查目录项是否是 dot 文件或目录(以点开头)
+fn is_dot_file_or_dir(entry: &walkdir::DirEntry) -> bool {
+    entry
+        .file_name()
+        .to_str()
+        .map(|s| s.starts_with('.'))
+        .unwrap_or(false)
+}
+
+fn initialize_package(base_path: &Path) -> Result<()> {
+    let metadata_path = base_path.join("metadata.json");
+
+    if metadata_path.exists() {
+        anyhow::bail!("metadata.json 已存在");
+    }
+
+    // 遍历目录生成文件哈希
+    let mut all_files = HashMap::new();
+    for entry in WalkDir::new(base_path)
+        .into_iter()
+        .filter_entry(|e| !is_dot_file_or_dir(e)) // 跳过 dot 文件(夹)
+        .filter_map(|e| e.ok())
+        .filter(|e| e.file_type().is_file())
+    {
+        let rel_path = entry
+            .path()
+            .strip_prefix(base_path)?
+            .to_str()
+            .ok_or_else(|| anyhow::anyhow!("无效的文件路径"))?
+            .replace('\\', "/");
+
+        // 跳过metadata.json本身
+        if rel_path == "metadata.json" {
+            continue;
+        }
+
+        let content = fs::read(entry.path())?;
+        let hash = format!("{:x}", sha2::Sha256::digest(&content));
+        all_files.insert(rel_path, hash);
+    }
+
+    let mut default_metadata = serde_json::json!({
+        "name": "",
+        "id": "",
+        "version": "0.1.0",
+        "description": "",
+        "author": "",
+        "type": "",
+        "category": "",
+        "permissions": [],
+        "entry": "index.html",
+        "all_files": all_files
+    });
+
+    // 保留用户可能已填写的基础字段
+    if let Ok(existing_content) = fs::read_to_string(&metadata_path) {
+        if let Ok(existing) = serde_json::from_str::<serde_json::Value>(&existing_content) {
+            for field in [
+                "name",
+                "id",
+                "version",
+                "description",
+                "author",
+                "type",
+                "category",
+            ] {
+                if existing.get(field).is_some() {
+                    default_metadata[field] = existing[field].clone();
+                }
+            }
+        }
+    }
+
+    fs::write(
+        &metadata_path,
+        serde_json::to_string_pretty(&default_metadata)?,
+    )
+    .context("写入 metadata.json 失败")?;
+
+    Ok(())
+}
+
+/// 添加文件或目录到应用包的 metadata.json
+fn handle_app_add(path: &str) -> Result<()> {
+    let base_path = std::env::current_dir()?;
+    let target_path = base_path.join(path);
+    let metadata_path = base_path.join("metadata.json");
+
+    // 检查 metadata.json 是否存在
+    if !metadata_path.exists() {
+        anyhow::bail!("当前目录下没有 metadata.json 文件,请先运行 app init");
+    }
+
+    // 读取并解析 metadata.json
+    let metadata_content = fs::read_to_string(&metadata_path)?;
+    let mut metadata: Metadata = serde_json::from_str(&metadata_content)?;
+
+    // 计算文件/目录的哈希
+    let mut new_files = HashMap::new();
+    if target_path.is_file() {
+        let rel_path = target_path
+            .strip_prefix(&base_path)?
+            .to_str()
+            .ok_or_else(|| anyhow::anyhow!("路径包含无效字符"))?
+            .replace('\\', "/");
+        let content = fs::read(&target_path)?;
+        let hash = format!("{:x}", sha2::Sha256::digest(&content));
+        new_files.insert(rel_path, hash);
+    } else if target_path.is_dir() {
+        for entry in WalkDir::new(&target_path)
+            .into_iter()
+            .filter_entry(|e| !is_dot_file_or_dir(e))
+            .filter_map(|e| e.ok())
+            .filter(|e| e.file_type().is_file())
+        {
+            let entry_path = entry.path();
+            let rel_path = entry_path
+                .strip_prefix(&base_path)?
+                .to_str()
+                .ok_or_else(|| anyhow::anyhow!("路径包含无效字符"))?
+                .replace('\\', "/");
+            let content = fs::read(entry_path)?;
+            let hash = format!("{:x}", sha2::Sha256::digest(&content));
+            new_files.insert(rel_path, hash);
+        }
+    } else {
+        anyhow::bail!("路径不存在: {}", path);
+    }
+
+    // 更新 metadata 的 all_files
+    let num_files = new_files.len(); // 先保存长度
+    for (file, hash) in new_files {
+        metadata.all_files.insert(file, hash);
+    }
+
+    // 写回 metadata.json
+    fs::write(&metadata_path, serde_json::to_string_pretty(&metadata)?)?;
+    println!("成功添加 {} 个文件到 metadata.json", num_files); // 使用保存的长度
+    Ok(())
+}
+
+fn create_source_repo(path: &str) -> Result<()> {
+    let repo_path = Path::new(path);
+    if repo_path.exists() {
+        anyhow::bail!("目录 '{}' 已存在", path);
+    }
+
+    fs::create_dir(repo_path).with_context(|| format!("创建目录 '{}' 失败", path))?;
+
+    // 创建 applications 目录
+    let applications_path = repo_path.join("applications");
+    fs::create_dir(&applications_path).context("创建 applications 目录失败")?;
+
+    // 创建 config.toml 文件
+    let config_path = repo_path.join("config.toml");
+    fs::write(&config_path, "# 软件源配置\n").context("写入 config.toml 失败")?;
+
+    // 创建 index.json 文件
+    let index_path = repo_path.join("index.json");
+    fs::write(&index_path, "[]").context("写入 index.json 失败")?;
+
+    Ok(())
+}
+
+#[derive(Serialize, Deserialize)]
+struct Metadata {
+    id: String,
+    version: String,
+    name: String,
+    author: String,
+    description: Option<String>,
+    #[serde(rename = "type")]
+    app_type: Option<String>,
+    category: Option<String>,
+    permissions: Vec<String>,
+    entry: String,
+    all_files: HashMap<String, String>,
+}
+
+#[derive(Serialize, Deserialize)]
+struct AppIndex {
+    id: String,
+    name: String,
+    author: String,
+    latest_version: String,
+    description: Option<String>,
+    location: String,
+}
+
+fn add_package_to_repo(package_path: &str) -> Result<()> {
+    let package_path = Path::new(package_path);
+    let metadata_path = package_path.join("metadata.json");
+
+    // 读取并解析元数据
+    let metadata_content = fs::read_to_string(&metadata_path)
+        .with_context(|| format!("无法读取文件: {}", metadata_path.display()))?;
+    let metadata: Metadata = serde_json::from_str(&metadata_content)
+        .with_context(|| format!("解析 metadata.json 失败: {}", metadata_path.display()))?;
+
+    // 获取当前工作目录(仓库根目录)
+    let repo_root = std::env::current_dir()?;
+    let applications_dir = repo_root.join("applications");
+    let app_dir = applications_dir.join(&metadata.id);
+    let version_dir = app_dir.join(&metadata.version);
+
+    // 创建应用目录和版本目录
+    fs::create_dir_all(&version_dir)
+        .with_context(|| format!("创建目录失败: {}", version_dir.display()))?;
+
+    // 复制整个软件包
+    copy_dir_all(package_path, &version_dir).with_context(|| "复制软件包失败".to_string())?;
+
+    // 更新 versions.txt
+    let versions_file = app_dir.join("versions.txt");
+    let mut versions = get_versions_from_file(&versions_file)?;
+
+    if !versions.contains(&metadata.version) {
+        versions.push(metadata.version.clone());
+        write_versions_to_file(&versions_file, &versions)?;
+    }
+
+    // 更新索引文件
+    let index_file = repo_root.join("index.json");
+    let mut index: Vec<AppIndex> = if index_file.exists() {
+        let content = fs::read_to_string(&index_file)?;
+        serde_json::from_str(&content)?
+    } else {
+        Vec::new()
+    };
+
+    // 更新或添加索引条目
+    if let Some(existing) = index.iter_mut().find(|app| app.id == metadata.id) {
+        existing.latest_version = metadata.version.clone();
+        existing.name = metadata.name.clone();
+        existing.author = metadata.author.clone();
+        existing.description = metadata.description.clone();
+    } else {
+        index.push(AppIndex {
+            id: metadata.id.clone(),
+            name: metadata.name.clone(),
+            author: metadata.author.clone(),
+            latest_version: metadata.version.clone(),
+            description: metadata.description.clone(),
+            location: format!("applications/{}/{}", metadata.id, metadata.version),
+        });
+    }
+
+    // 写入更新后的索引
+    fs::write(&index_file, serde_json::to_string_pretty(&index)?)
+        .with_context(|| format!("写入索引文件失败: {}", index_file.display()))?;
+
+    Ok(())
+}
+
+/// 递归复制目录及其内容
+fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()> {
+    for entry in fs::read_dir(src)? {
+        let entry = entry?;
+        let ty = entry.file_type()?;
+        let file_name = entry.file_name();
+        let file_name_str = file_name.to_string_lossy();
+
+        // 跳过 dot 文件(夹)
+        if file_name_str.starts_with('.') {
+            continue;
+        }
+
+        let target = dst.as_ref().join(&file_name);
+
+        if ty.is_dir() {
+            fs::create_dir_all(&target)?; // 只在需要时创建目录
+            copy_dir_all(entry.path(), target)?;
+        } else {
+            if let Some(parent) = target.parent() {
+                fs::create_dir_all(parent)?; // 确保父目录存在
+            }
+            fs::copy(entry.path(), &target)?;
+        }
+    }
+    Ok(())
+}
+
+/// 从仓库删除软件(版本)
+fn remove_package_from_repo(package_spec: &str) -> Result<()> {
+    // 分割包名和版本
+    let parts: Vec<&str> = package_spec.split(':').collect();
+    if parts.len() != 2 {
+        anyhow::bail!("无效的软件包格式,应为 '包名:版本'");
+    }
+    let package_name = parts[0];
+    let version = parts[1];
+
+    // 获取当前工作目录(仓库根目录)
+    let repo_root = std::env::current_dir()?;
+    let applications_dir = repo_root.join("applications");
+    let package_dir = applications_dir.join(package_name);
+    let version_dir = package_dir.join(version);
+
+    // 检查版本目录是否存在
+    if !version_dir.exists() {
+        anyhow::bail!("版本目录不存在: {}", version_dir.display());
+    }
+
+    // 删除版本目录
+    fs::remove_dir_all(&version_dir)?;
+
+    // 更新 versions.txt
+    let versions_file = package_dir.join("versions.txt");
+    let versions = get_versions_from_file(&versions_file)?;
+    let new_versions: Vec<String> = versions.iter().filter(|v| *v != version).cloned().collect();
+
+    if new_versions.is_empty() {
+        // 如果没有其他版本,删除整个包目录
+        fs::remove_dir_all(&package_dir)?;
+    } else {
+        // 更新 versions.txt 文件
+        write_versions_to_file(&versions_file, &new_versions)?;
+    }
+
+    // 更新索引文件 index.json
+    let index_file = repo_root.join("index.json");
+    if index_file.exists() {
+        let index_content = fs::read_to_string(&index_file)?;
+        let mut index: Vec<AppIndex> = serde_json::from_str(&index_content)?;
+
+        // 移除已删除的包(如果包目录不存在)或更新最新版本
+        index.retain(|app| app.id != package_name || package_dir.exists());
+
+        // 如果包还存在,更新最新版本
+        if package_dir.exists() {
+            if let Some(app) = index.iter_mut().find(|app| app.id == package_name) {
+                let versions_content = fs::read_to_string(&package_dir.join("versions.txt"))?;
+                let versions: Vec<&str> = versions_content.lines().collect();
+                if let Some(latest) = versions.last() {
+                    app.latest_version = latest.to_string();
+                }
+            }
+        }
+
+        // 写入更新后的索引
+        fs::write(&index_file, serde_json::to_string_pretty(&index)?)?;
+    }
+
+    Ok(())
+}
+
+fn get_versions_from_file(path: &Path) -> Result<Vec<String>> {
+    if path.exists() {
+        let content = fs::read_to_string(path)?;
+        Ok(content.lines().map(|s| s.to_string()).collect())
+    } else {
+        Ok(Vec::new())
+    }
+}
+
+#[derive(Debug)]
+struct PackageUpdate {
+    id: String,
+    current_version: String,
+    latest_version: String,
+}
+
+/// 获取本地索引
+fn get_local_index() -> Result<Vec<AppIndex>> {
+    let index_file = std::env::current_dir()?.join("index.json");
+    if !index_file.exists() {
+        return Ok(Vec::new());
+    }
+    let content = fs::read_to_string(&index_file)?;
+    serde_json::from_str(&content).context("解析本地索引失败")
+}
+
+/// 比较本地和远程版本,返回需要更新的包
+fn compare_versions(local: &[AppIndex], remote: &[AppIndex]) -> Vec<PackageUpdate> {
+    let mut updates = Vec::new();
+
+    for remote_app in remote {
+        if let Some(local_app) = local.iter().find(|a| a.id == remote_app.id) {
+            if local_app.latest_version != remote_app.latest_version {
+                updates.push(PackageUpdate {
+                    id: remote_app.id.clone(),
+                    current_version: local_app.latest_version.clone(),
+                    latest_version: remote_app.latest_version.clone(),
+                });
+            }
+        } else {
+            // 新应用
+            updates.push(PackageUpdate {
+                id: remote_app.id.clone(),
+                current_version: "无".to_string(),
+                latest_version: remote_app.latest_version.clone(),
+            });
+        }
+    }
+
+    updates
+}
+
+/// 下载文件并保存到本地
+async fn download_file(url: &str, path: &Path) -> Result<()> {
+    let response = reqwest::get(url)
+        .await
+        .with_context(|| format!("下载文件失败: {}", url))?;
+
+    if !response.status().is_success() {
+        anyhow::bail!("下载文件失败: {} - {}", url, response.status());
+    }
+
+    let content = response
+        .bytes()
+        .await
+        .with_context(|| format!("读取文件内容失败: {}", url))?;
+
+    fs::write(path, content).with_context(|| format!("保存文件失败: {}", path.display()))?;
+
+    Ok(())
+}
+
+fn write_versions_to_file(path: &Path, versions: &[String]) -> Result<()> {
+    fs::write(path, versions.join("\n"))?;
+    Ok(())
+}
+
+/// 从远程仓库同步应用包
+async fn sync_from_remote(remote_url: &str, mirror: bool) -> Result<()> {
+    println!("正在从 {} 同步……", remote_url);
+    println!("镜像模式: {}", mirror);
+
+    // 获取远程索引
+    let remote_index_url = format!("{}/index.json", remote_url.trim_end_matches('/'));
+    println!("正在获取远程索引: {}", remote_index_url);
+
+    let response = reqwest::get(&remote_index_url)
+        .await
+        .with_context(|| format!("请求远程索引失败: {}", remote_index_url))?;
+
+    if !response.status().is_success() {
+        anyhow::bail!("远程服务器返回错误状态: {}", response.status());
+    }
+
+    let remote_index: Vec<AppIndex> = response
+        .json()
+        .await
+        .with_context(|| "解析远程索引JSON失败".to_string())?;
+
+    println!("成功获取到 {} 个应用的索引", remote_index.len());
+
+    // 获取本地索引
+    let local_index = get_local_index()?;
+
+    // 比较版本并找出需要更新的应用
+    let updates = compare_versions(&local_index, &remote_index);
+    println!("需要更新 {} 个应用包", updates.len());
+
+    if !updates.is_empty() {
+        println!("需要更新的应用包:");
+        for update in &updates {
+            println!(
+                "- {} (当前: {}, 最新: {})",
+                update.id, update.current_version, update.latest_version
+            );
+        }
+
+        // 镜像模式:删除所有本地应用,只保留远程应用
+        if mirror {
+            println!("镜像模式 - 清空本地仓库……");
+            let applications_dir = std::env::current_dir()?.join("applications");
+            if applications_dir.exists() {
+                fs::remove_dir_all(&applications_dir)?;
+                fs::create_dir(&applications_dir)?;
+            }
+        }
+
+        // 下载新增/更新的应用包
+        for update in updates {
+            let package_url = format!(
+                "{}/applications/{}/{}/",
+                remote_url.trim_end_matches('/'),
+                update.id,
+                update.latest_version
+            );
+
+            println!("正在下载: {}", package_url);
+
+            // 创建目标目录
+            let target_dir = std::env::current_dir()?
+                .join("applications")
+                .join(&update.id)
+                .join(&update.latest_version);
+
+            fs::create_dir_all(&target_dir)
+                .with_context(|| format!("创建目录失败: {}", target_dir.display()))?;
+
+            // 下载元数据文件
+            let metadata_url = format!("{}metadata.json", package_url);
+            let metadata_path = target_dir.join("metadata.json");
+            download_file(&metadata_url, &metadata_path).await?;
+
+            // 解析元数据获取文件列表
+            let metadata: Metadata = serde_json::from_str(&fs::read_to_string(&metadata_path)?)
+                .context("解析元数据失败")?;
+
+            // 下载所有文件
+            for (file_path, _) in metadata.all_files {
+                let file_url = format!("{}{}", package_url, file_path);
+                let file_path = target_dir.join(file_path);
+
+                if let Some(parent) = file_path.parent() {
+                    fs::create_dir_all(parent)?;
+                }
+
+                download_file(&file_url, &file_path).await?;
+            }
+
+            // 更新versions.txt
+            let versions_file = target_dir.parent().unwrap().join("versions.txt");
+            let mut versions = get_versions_from_file(&versions_file)?;
+            if !versions.contains(&update.latest_version) {
+                versions.push(update.latest_version.clone());
+                write_versions_to_file(&versions_file, &versions)?;
+            }
+
+            println!("成功下载: {}", update.id);
+        }
+
+        // 更新本地索引
+        update_source_index()?;
+        println!("本地索引已更新");
+    } else {
+        println!("所有应用包都是最新版本");
+    }
+
+    Ok(())
+}
+
+/// 更新仓库索引
+fn update_source_index() -> Result<()> {
+    let repo_root = std::env::current_dir()?;
+    let applications_dir = repo_root.join("applications");
+    let index_file = repo_root.join("index.json");
+
+    // 如果 applications 目录不存在,则创建一个空的索引
+    if !applications_dir.exists() {
+        let empty_index: Vec<AppIndex> = Vec::new();
+        fs::write(&index_file, serde_json::to_string_pretty(&empty_index)?)?;
+        return Ok(());
+    }
+
+    let mut index = Vec::new();
+
+    // 遍历所有应用目录
+    for app_dir_entry in fs::read_dir(applications_dir)? {
+        let app_dir_entry = app_dir_entry?;
+        let app_dir_path = app_dir_entry.path();
+        if !app_dir_path.is_dir() {
+            continue;
+        }
+
+        // 获取应用ID
+        let app_id = app_dir_path
+            .file_name()
+            .and_then(|n| n.to_str())
+            .ok_or_else(|| anyhow::anyhow!("无效的应用目录名: {:?}", app_dir_path))?
+            .to_string();
+
+        // 读取 versions.txt 文件
+        let versions_file = app_dir_path.join("versions.txt");
+        if !versions_file.exists() {
+            eprintln!("警告: 应用 '{}' 没有 versions.txt 文件,跳过", app_id);
+            continue;
+        }
+
+        let versions_content = fs::read_to_string(&versions_file)?;
+        let versions: Vec<&str> = versions_content.lines().collect();
+
+        if versions.is_empty() {
+            eprintln!("警告: 应用 '{}' 没有版本,跳过", app_id);
+            continue;
+        }
+
+        // 获取最新版本(最后一个版本)
+        let latest_version = versions.last().unwrap().to_string();
+
+        // 读取最新版本目录下的 metadata.json
+        let version_dir = app_dir_path.join(&latest_version);
+        let metadata_path = version_dir.join("metadata.json");
+        if !metadata_path.exists() {
+            eprintln!(
+                "警告: 应用 '{}' 的版本 '{}' 没有 metadata.json 文件,跳过",
+                app_id, latest_version
+            );
+            continue;
+        }
+
+        let metadata_content = fs::read_to_string(&metadata_path)
+            .with_context(|| format!("无法读取元数据文件: {}", metadata_path.display()))?;
+        let metadata: Metadata = serde_json::from_str(&metadata_content)
+            .with_context(|| format!("解析元数据失败: {}", metadata_path.display()))?;
+
+        // 构建索引项
+        index.push(AppIndex {
+            id: app_id.clone(),
+            name: metadata.name,
+            author: metadata.author,
+            latest_version: latest_version.clone(),
+            description: metadata.description,
+            location: format!("applications/{}/{}", app_id, latest_version),
+        });
+    }
+
+    // 写入更新后的索引
+    fs::write(&index_file, serde_json::to_string_pretty(&index)?)?;
+
+    Ok(())
+}
+
+/// 更新本地仓库索引
+async fn update_local_index() -> Result<()> {
+    // 读取本地仓库配置
+    let repo_root = std::env::current_dir()?;
+    let config_path = repo_root.join("config.toml");
+
+    if !config_path.exists() {
+        anyhow::bail!("找不到 config.toml 文件");
+    }
+
+    let config_content = fs::read_to_string(&config_path)?;
+    let config: toml::Table = toml::from_str(&config_content)?;
+
+    // 获取远程仓库 URLs (支持单 URL 或多镜像源)
+    let remote_urls: Vec<String> = if let Some(url) = config["remote"]["url"].as_str() {
+        vec![url.to_string()]
+    } else if let Some(urls) = config["remote"]["urls"].as_array() {
+        urls.iter()
+            .filter_map(|v| v.as_str().map(|s| s.to_string()))
+            .collect()
+    } else {
+        anyhow::bail!("配置文件中缺少远程仓库 URL 或 URLs 配置");
+    };
+
+    // 尝试每个镜像源直到成功
+    let mut last_error = None;
+    let mut remote_index: Option<Vec<AppIndex>> = None;
+    for remote_url in &remote_urls {
+        println!("正在尝试从远程仓库 {} 更新索引……", remote_url);
+
+        let remote_index_url = format!("{}/index.json", remote_url.trim_end_matches('/'));
+        let response = match reqwest::get(&remote_index_url).await {
+            Ok(r) if r.status().is_success() => r,
+            Ok(r) => {
+                last_error = Some(format!(
+                    "镜像源 {} 返回错误状态: {}",
+                    remote_url,
+                    r.status()
+                ));
+                continue;
+            }
+            Err(e) => {
+                last_error = Some(format!("镜像源 {} 连接失败: {}", remote_url, e));
+                continue;
+            }
+        };
+
+        match response.json::<Vec<AppIndex>>().await {
+            Ok(index) => {
+                remote_index = Some(index);
+                break;
+            }
+            Err(e) => {
+                last_error = Some(format!("镜像源 {} 解析索引失败: {}", remote_url, e));
+                continue;
+            }
+        }
+    }
+
+    let remote_index = remote_index.ok_or_else(|| {
+        anyhow::anyhow!(
+            "所有镜像源尝试失败:\n{}",
+            last_error.unwrap_or_else(|| "未知错误".to_string())
+        )
+    })?;
+
+    // 获取本地索引
+    let local_index_path = repo_root.join("index.json");
+    let local_index: Vec<AppIndex> = if local_index_path.exists() {
+        let content = fs::read_to_string(&local_index_path)?;
+        serde_json::from_str(&content)?
+    } else {
+        Vec::new()
+    };
+
+    // 比较差异
+    let updates = compare_versions(&local_index, &remote_index);
+
+    if updates.is_empty() {
+        println!("本地索引已是最新");
+        return Ok(());
+    }
+
+    // 更新本地索引文件
+    fs::write(
+        &local_index_path,
+        serde_json::to_string_pretty(&remote_index)?,
+    )?;
+
+    println!("成功更新本地索引,共更新 {} 个应用", updates.len());
+    Ok(())
+}
+
+/// 创建本地软件仓库
+fn create_local_repo(path: &str) -> Result<()> {
+    let repo_path = Path::new(path);
+    if repo_path.exists() {
+        anyhow::bail!("目录 '{}' 已存在", path);
+    }
+
+    fs::create_dir(repo_path).with_context(|| format!("创建目录 '{}' 失败", path))?;
+
+    // 创建本地仓库目录结构
+    let local_dir = repo_path.join("local");
+    fs::create_dir(&local_dir).context("创建 local 目录失败")?;
+
+    let applications_dir = local_dir.join("applications");
+    fs::create_dir(&applications_dir).context("创建 applications 目录失败")?;
+
+    // 创建 remote 目录
+    let remote_dir = repo_path.join("remote");
+    fs::create_dir(&remote_dir).context("创建 remote 目录失败")?;
+
+    // 创建 config.toml 文件
+    let config_path = repo_path.join("config.toml");
+    fs::write(&config_path, "# 本地仓库配置\n").context("写入 config.toml 失败")?;
+
+    // 创建 index.json 文件
+    let index_path = repo_path.join("index.json");
+    fs::write(&index_path, "[]").context("写入 index.json 失败")?;
+
+    Ok(())
+}