Layer boundaries: imports flow one direction only (utils → services → commands → extension). Extract to a shared module when logic is duplicated 2+ times.
Don't touch: target/**
For numeric thresholds (line count, function length, complexity, etc.) run
Ctrl+Alt+F— values live in VS Code settings, not here.
Rust crate (cosmic-containers): Cosmic Containers — COSMIC panel applet for Pop!_OS that lists and starts/stops Docker containers via CLI (libcosmic, cosmic::applet::run). Binary requires feature applet, Docker in PATH, and system Wayland/GTK-related dev packages. See README.md for install and “Add widget” steps.
Chat language: Reply to the user in Ukrainian unless they ask for another language. Keep code, identifiers, commits, and this file in English.
When requirements are unclear, ask once with concrete options rather than guessing architecture.
| Item | Value |
|---|---|
| Language | Rust |
| Edition | 2024 (Cargo.toml) |
| Package manager | Cargo |
| Build output | target/ (gitignored) |
# Build (debug)
cargo build
# Run applet (COSMIC session, requires system deps + --features applet)
cargo run --release
# Release build
cargo build --release
# Check without full link
cargo check
# Format
cargo fmt
# Lint
cargo clippyPrefer cargo check for fast feedback during edits; run cargo build or cargo run before claiming a change works.
- Match existing style: minimal, direct Rust without premature abstractions.
- Keep diffs small; do not refactor unrelated code in the same change.
- Prefer
Resultand explicit error handling overunwrap()in non-trivial paths. - Use
cargo fmtbefore finishing; keepCargo.tomldependencies justified. - Comments only for non-obvious behavior; let names and types carry intent.
cosmic-containers/
AGENTS.md # This file
Cargo.toml # `applet` feature → libcosmic
src/lib.rs # APP_ID, ContainerSummary, parse_ps_output
src/main.rs # cosmic::applet::run
src/app.rs # Application impl (panel + popup)
src/services/docker.rs # async docker CLI
resources/ # .desktop, metainfo, icon
scripts/install-local.sh
.githooks/
.cursor/skills/
Panel UI lives in src/app.rs; parsing and types in src/lib.rs; Docker in src/services/docker.rs. Register applets with X-CosmicApplet=true in resources/*.desktop.
- Do not add tests unless the user asks or they cover real, non-trivial behavior.
- Pre-commit (when configured):
cargo testruns via SnakeFlow custom checks in.vscode/settings.json. - After adding tests, run
cargo testbefore claiming the change works.
Never: commit target/, secrets, API keys, or machine-specific paths in agent context files.
Always: read Cargo.toml and relevant src/**/*.rs before proposing changes; justify new dependencies in Cargo.toml.
- Create commits only when the user explicitly asks.
- Do not force-push to
main/masteror skip hooks (--no-verify) unless the user explicitly requests it. - Pre-commit hook:
.githooks/pre-commit(SnakeFlow). Requires SnakeFlow extension CLI when installed; otherwise exits 0.
- Read
Cargo.tomland relevantsrc/**/*.rsbefore proposing changes. - Implement the smallest change that satisfies the request.
- Verify with
cargo check(minimum) orcargo runwhen behavior matters.
Dev environment (SnakeFlow): use .cursor/skills/setup-dev-manager/SKILL.md. Fetch live docs from https://snakeflow.pages.dev/getting-started/cursor-setup-skill/ when configuring devManager.* in .vscode/settings.json.
Before marking work done:
| Step | Command |
|---|---|
| Fast compile check | cargo check |
| Format | cargo fmt --check |
| Lint (if enabled in pre-commit) | cargo clippy -- -D warnings |
| Tests (if present / requested) | cargo test |
| Run behavior | cargo run when output or CLI behavior matters |
For non-trivial work:
- Clarify: ask focused questions about scope, target platform (desktop integration vs CLI), and error-handling expectations before coding.
- Test plan: decide whether
cargo check,cargo test, orcargo runproves the change; note any manual steps on Pop!_OS if relevant. - Read first:
Cargo.toml,src/main.rs, and any new modules touched; skip for trivial one-line fixes.