| Crates.io | capsula-git-context |
| lib.rs | capsula-git-context |
| version | 0.2.0 |
| created_at | 2025-09-21 04:01:02.557198+00 |
| updated_at | 2025-09-21 11:26:58.960925+00 |
| description | A Capsula context that captures Git repository information. |
| homepage | |
| repository | https://github.com/shunichironomura/capsula |
| max_upload_size | |
| id | 1848416 |
| size | 41,742 |
[!WARNING] This project is in early development. The CLI interface and configuration format may change in future releases.
A powerful CLI tool for capturing and preserving the context of your command executions. Capsula automatically records the state of your project environment before and after running commands, making your workflows reproducible and auditable.
cargo install capsula-cli --locked
cargo install --git https://github.com/shunichironomura/capsula --branch rust --locked capsula-cli
capsula.toml) in your project root:[vault]
name = "my-project"
[[phase.pre.contexts]]
type = "git"
name = "repo-name"
path = "."
[[phase.pre.contexts]]
type = "cwd"
[[phase.pre.contexts]]
type = "file"
glob = "config.json"
mode = "copy"
hash = "sha256"
capsula run python train_model.py
capsula capture --phase pre
The capsula.toml configuration file defines:
[vault]
name = "project-name" # Vault identifier
path = ".capsula" # Storage path (optional, defaults to .capsula/{name})
[phase.pre] # Pre-execution contexts
[[phase.pre.contexts]]
type = "git"
# ... context configuration
[phase.post] # Post-execution contexts
[[phase.post.contexts]]
type = "file"
# ... context configuration
Captures git repository state including commit hash and cleanliness check.
[[phase.pre.contexts]]
type = "git"
name = "repo-name" # Context name
path = "." # Repository path
allow_dirty = false # Allow uncommitted changes (default: false)
Output Example:
{
"__meta": { "success": true, "index": 0 },
"type": "git",
"name": "repo-name",
"working_dir": "/path/to/repo",
"sha": "abc123...",
"is_dirty": false,
"abort_on_dirty": false
}
Captures the current working directory path.
[[phase.pre.contexts]]
type = "cwd"
Output Example:
{
"__meta": { "success": true, "index": 1 },
"type": "cwd",
"cwd": "/current/working/directory"
}
Captures file contents and/or metadata.
[[phase.pre.contexts]]
type = "file"
glob = "config.json" # File pattern to capture
mode = "copy" # Capture mode ("copy", "move", or "none". default: "copy")
hash = "sha256" # Calculate file hash ("sha256" or "none". default: "sha256")
Output Example:
{
"__meta": { "success": true, "index": 2 },
"type": "file",
"files": [
{
"path": "/path/to/config.json",
"copied_path": "/vault/run-dir/config.json",
"hash": "sha256:abc123..."
}
]
}
Note: Copy and move modes require a run directory and only work during capsula run command, not standalone capsula capture.
Captures specified environment variables.
[[phase.pre.contexts]]
type = "env"
name = "HOME" # Variable name to capture
Output Example:
{
"__meta": { "success": true, "index": 3 },
"type": "env",
"name": "HOME",
"value": "/home/user"
}
Captures output of shell commands.
[[phase.pre.contexts]]
type = "command"
command = ["uname", "-a"]
abort_on_failure = false # Abort if command fails (default: false)
Captures system information like CPU, memory, and OS details.
[[phase.pre.contexts]]
type = "machine"
capsula run <command>Execute a command with full context capture.
# Run with default config
capsula run python script.py
# Run with custom config
capsula run --config my-config.toml python script.py
# Run with arguments
capsula run python train.py --epochs 100 --lr 0.01
Behavior:
capsula captureCapture context without running a command.
# Capture pre-phase contexts
capsula capture --phase pre
# Capture post-phase contexts
capsula capture --phase post
--config <path>: Specify custom configuration file (default: capsula.toml)--phase <phase>: Specify phase for capture command (pre or post)Every context output includes metadata for traceability:
{
"__meta": {
"success": true, // Capture success status
"index": 0 // Position in configuration (0-based)
}
// ... context-specific data
}
Captured data is organized in the vault:
.capsula/
└── vault-name/
└── 2024-01-15/ # Date-based directory (YYYY-MM-DD, UTC)
└── 143022-example-run--01HKJM2K3L4M5N6P7Q8R9S/ # Unique run directory (timestamp + run name + ULID)
├── metadata.json # Run metadata
├── pre.json # Pre-phase contexts
├── run.json # Command output, exit code, duration
└── post.json # Post-phase contexts