Libraries
Publishing a library
Apsi libraries are .apsil files built and uploaded by the apsi command line. Uploads are only accepted with an API token, so every version is traceable to its author.
Create the library
Start from the library template, or add a
[package]table to an existing project’sapsi.toml.apsi new my-physics --template lib cd my-physics[project] name = "my-physics" # lowercase letters, digits, "-" or "_"; 2–64 characters version = "1.0.0" # semantic versioning: MAJOR.MINOR.PATCH description = "Orbital mechanics helpers" [package] entry = "src/main.apsi" # what `use my_physics` loads license = "MIT" authors = ["Your Name"] keywords = ["physics", "orbits"] include = ["src/**", "README*", "LICENSE*", "examples/**"] [dependencies] linalg-extra = "^1.2" # other libraries this one needsBuild it into
dist/apsi packchecks every source file (types and units), then writesdist/NAME-VERSION.apsil: a reproducible archive with a manifest that lists the SHA-256 of every file. The same sources always produce the same bytes.apsi pack # built dist/my-physics-1.0.0.apsil (12.4 KB, 4 files, sha256 3f9a…)Create an API token
Open Settings → Developer, give the token a name, choose its permissions —
publish:newto create new libraries andpublish:updateto add versions — optionally limit it to one library, and copy it. It is shown only once.Upload
Store the token once and publish. The Apsi command line uses this registry by default.
apsi lib login --token apsi_xxxxxxxxxxxxxxxxxxxx apsi publish # uploads the newest file in dist/Files larger than 64 MB are sent automatically in resumable 32 MB pieces; an interrupted upload continues where it stopped. In CI, pass the token through the
APSI_TOKENenvironment variable instead of storing it.Install it anywhere
apsi install my-physics # newest version apsi install my-physics@^1.0 # newest 1.x apsi install "my-physics>=1.2,<2" apsi install # everything in [dependencies], then writes apsi-packages.lockThen use it like a standard module:
use my_physics(dashes become underscores).
Rules
- A version can be uploaded only once. To fix a mistake, publish a new version; you can yank a broken one so that new installs skip it while existing lock files keep working.
- Pre-release versions such as
2.0.0-rc.1are installed only when asked for explicitly. - Names that differ only in “-” and “_” are the same name; the first owner keeps it.
- Every download is verified against the registry’s SHA-256 and every file against the manifest, and Apsi Guard scans the code before it can be used.
- Malware, credential stealing, hidden network access and name squatting are removed and the account is suspended. Report a library from its page.
The .apsil format
A ZIP archive (format version 1) containing apsil.json — name, version, summary, authors, license, entry file, dependencies, required Apsi version, and the SHA-256 and size of every other file — followed by the library’s files under their relative paths. Archives with files that are not listed, paths that leave the package, encrypted entries or mismatching sizes are rejected.
Registry API
| Request | Purpose |
|---|---|
GET /api/v1/packages/NAME | All versions with size, SHA-256, publish time and download URL |
GET /api/v1/packages/NAME/VERSION | One version, including its manifest |
GET /api/v1/packages/NAME/VERSION/download | The .apsil file (supports Range requests) |
GET /api/v1/search?q=WORDS | Search |
POST /api/v1/upload | Multipart upload with Authorization: Bearer TOKEN |
POST /api/v1/packages/NAME/VERSION/yank | Yank or restore a version ({"yanked": true}) |