Skip to main content

oxicode/storage/packages/
mod.rs

1//! Package system for oxicode CLI
2//!
3//! Packages bundle extensions, skills, prompts, and themes for sharing.
4//! Supports local directories, npm packages, git repositories, GitHub
5//! shorthand, and URL-based archives.
6//!
7//! ## Package sources
8//!
9//! - **Local path**: a directory with `oxicode-package.toml` or auto-discoverable resources
10//! - **npm**: `npm:<package>[@<version>]` — resolved from the npm registry
11//! - **git**: `https://github.com/org/repo.git[@ref]`, `git://…`, `git+ssh://…`
12//! - **GitHub shorthand**: `github:org/repo[@ref]`
13//! - **URL**: direct `.tar.gz` / `.zip` archive
14//!
15//! ## Package manifest
16//!
17//! A package is a directory containing an `oxicode-package.toml` file:
18//!
19//! ```toml
20//! name = "@foo/oxicode-tools"
21//! version = "1.0.0"
22//! extensions = ["ext/index.ts"]
23//! skills = ["skills/code-review/SKILL.md"]
24//! prompts = ["prompts/review.md"]
25//! themes = ["themes/dark-pro.json"]
26//! ```
27//!
28//! ## Resource discovery
29//!
30//! When a package lacks explicit resource lists, resources are discovered
31//! automatically by scanning the package directory:
32//! - **Extensions**: `.so`, `.dylib`, `.dll` files, or `index.ts`/`index.js` entries
33//! - **Skills**: Directories containing `SKILL.md`
34//! - **Prompts**: `.md` files in `prompts/` subdirectory
35//! - **Themes**: `.json` files in `themes/` subdirectory
36//!
37//! ## Lockfile
38//!
39//! An `oxicode-lock.json` file records exact versions/refs for reproducibility.
40//!
41//! ## Module layout
42//!
43//! The package subsystem is split across several submodules for
44//! navigability. Public re-exports at the bottom preserve the original
45//! `crate::storage::packages::*` API.
46//!
47//! - `types` — core data types (manifest, kind, scope, progress events)
48//! - `source` — source-spec parsing (`ParsedSource`, npm/git/url helpers)
49//! - `npm` — npm registry client (`NpmPackageInfo`)
50//! - `git_ops` — git command wrappers (`git_clone`, `git_update`, …)
51//! - `lockfile` — lockfile types + SHA-256 integrity helpers
52//! - `discovery` — auto-discovery of resources in a package directory
53//! - `fs` — generic filesystem helpers (`copy_dir_recursive`, …)
54//! - `manager` — `PackageManager` facade + tests
55
56mod discovery;
57mod doctor;
58mod fs;
59mod git_ops;
60mod lockfile;
61mod manager;
62mod npm;
63mod overrides;
64mod runtime_config;
65mod source;
66mod types;
67
68// ── Constants ─────────────────────────────────────────────────────────
69//
70// These three names are referenced by every submodule (manifest paths,
71// the lockfile), so they live here in the parent module and are picked
72// up by children via `super::MANIFEST_NAME`, etc.
73
74pub(super) const LOCKFILE_NAME: &str = "oxicode-lock.json";
75pub(super) const MANIFEST_NAME: &str = "oxicode-package.toml";
76pub(super) const NPM_MANIFEST_NAME: &str = "package.json";
77
78pub use doctor::{DoctorCheck, DoctorReport, EnabledSummary, Health, run as run_doctor};
79pub use lockfile::{LockEntry, Lockfile, ResourceCounts};
80pub use manager::PackageManager;
81pub use npm::{NpmPackageInfo, get_latest_npm_version};
82pub use overrides::{ForceMap, ForceState, ProjectPluginOverrides, resolve_enabled};
83pub use runtime_config::{RUNTIME_CONFIG_FILE, RUNTIME_CONFIG_VERSION, RuntimeConfig};
84pub use source::ParsedSource;
85pub use types::{
86    ConfiguredPackage, DiscoveredResource, PackageManifest, PackageUpdateInfo, PathMetadata,
87    ProgressAction, ProgressCallback, ProgressEvent, ProgressEventType, ResolvedPaths,
88    ResolvedResource, ResourceKind, ResourceOrigin, SourceScope,
89};