|
| 1 | +# cosmic-containers — Agent Instructions |
| 2 | + |
| 3 | +<!-- SNAKEFLOW:STRUCTURE:BEGIN — auto-generated by SnakeFlow. Do not edit manually. --> |
| 4 | +**Layer boundaries**: imports flow one direction only (utils → services → commands → extension). Extract to a shared module when logic is duplicated 2+ times. |
| 5 | + |
| 6 | +**Don't touch**: `target/**` |
| 7 | + |
| 8 | +> For numeric thresholds (line count, function length, complexity, etc.) run `Ctrl+Alt+F` — values live in VS Code settings, not here. |
| 9 | +<!-- SNAKEFLOW:STRUCTURE:END --> |
| 10 | +
|
| 11 | +## Overview |
| 12 | + |
| 13 | +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. |
| 14 | + |
| 15 | +**Chat language**: Reply to the user in **Ukrainian** unless they ask for another language. Keep code, identifiers, commits, and this file in **English**. |
| 16 | + |
| 17 | +When requirements are unclear, ask once with concrete options rather than guessing architecture. |
| 18 | + |
| 19 | +## Tech Stack |
| 20 | + |
| 21 | +| Item | Value | |
| 22 | +|------|--------| |
| 23 | +| Language | Rust | |
| 24 | +| Edition | 2024 (`Cargo.toml`) | |
| 25 | +| Package manager | Cargo | |
| 26 | +| Build output | `target/` (gitignored) | |
| 27 | + |
| 28 | +## Commands |
| 29 | + |
| 30 | +```bash |
| 31 | +# Build (debug) |
| 32 | +cargo build |
| 33 | + |
| 34 | +# Run applet (COSMIC session, requires system deps + --features applet) |
| 35 | +cargo run --release |
| 36 | + |
| 37 | +# Release build |
| 38 | +cargo build --release |
| 39 | + |
| 40 | +# Check without full link |
| 41 | +cargo check |
| 42 | + |
| 43 | +# Format |
| 44 | +cargo fmt |
| 45 | + |
| 46 | +# Lint |
| 47 | +cargo clippy |
| 48 | +``` |
| 49 | + |
| 50 | +Prefer `cargo check` for fast feedback during edits; run `cargo build` or `cargo run` before claiming a change works. |
| 51 | + |
| 52 | +## Code Style |
| 53 | + |
| 54 | +- Match existing style: minimal, direct Rust without premature abstractions. |
| 55 | +- Keep diffs small; do not refactor unrelated code in the same change. |
| 56 | +- Prefer `Result` and explicit error handling over `unwrap()` in non-trivial paths. |
| 57 | +- Use `cargo fmt` before finishing; keep `Cargo.toml` dependencies justified. |
| 58 | +- Comments only for non-obvious behavior; let names and types carry intent. |
| 59 | + |
| 60 | +## Architecture |
| 61 | + |
| 62 | +``` |
| 63 | +cosmic-containers/ |
| 64 | + AGENTS.md # This file |
| 65 | + Cargo.toml # `applet` feature → libcosmic |
| 66 | + src/lib.rs # APP_ID, ContainerSummary, parse_ps_output |
| 67 | + src/main.rs # cosmic::applet::run |
| 68 | + src/app.rs # Application impl (panel + popup) |
| 69 | + src/services/docker.rs # async docker CLI |
| 70 | + resources/ # .desktop, metainfo, icon |
| 71 | + scripts/install-local.sh |
| 72 | + .githooks/ |
| 73 | + .cursor/skills/ |
| 74 | +``` |
| 75 | + |
| 76 | +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`. |
| 77 | + |
| 78 | +## Testing |
| 79 | + |
| 80 | +- Do not add tests unless the user asks or they cover real, non-trivial behavior. |
| 81 | +- Pre-commit (when configured): `cargo test` runs via SnakeFlow custom checks in `.vscode/settings.json`. |
| 82 | +- After adding tests, run `cargo test` before claiming the change works. |
| 83 | + |
| 84 | +## Security |
| 85 | + |
| 86 | +**Never**: commit `target/`, secrets, API keys, or machine-specific paths in agent context files. |
| 87 | + |
| 88 | +**Always**: read `Cargo.toml` and relevant `src/**/*.rs` before proposing changes; justify new dependencies in `Cargo.toml`. |
| 89 | + |
| 90 | +## PR / Commit |
| 91 | + |
| 92 | +- Create commits only when the user explicitly asks. |
| 93 | +- Do not force-push to `main`/`master` or skip hooks (`--no-verify`) unless the user explicitly requests it. |
| 94 | +- Pre-commit hook: `.githooks/pre-commit` (SnakeFlow). Requires SnakeFlow extension CLI when installed; otherwise exits 0. |
| 95 | + |
| 96 | +## Agent Workflows |
| 97 | + |
| 98 | +1. Read `Cargo.toml` and relevant `src/**/*.rs` before proposing changes. |
| 99 | +2. Implement the smallest change that satisfies the request. |
| 100 | +3. Verify with `cargo check` (minimum) or `cargo run` when behavior matters. |
| 101 | + |
| 102 | +**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`. |
| 103 | + |
| 104 | +## Verify / Acceptance |
| 105 | + |
| 106 | +Before marking work done: |
| 107 | + |
| 108 | +| Step | Command | |
| 109 | +|------|---------| |
| 110 | +| Fast compile check | `cargo check` | |
| 111 | +| Format | `cargo fmt --check` | |
| 112 | +| Lint (if enabled in pre-commit) | `cargo clippy -- -D warnings` | |
| 113 | +| Tests (if present / requested) | `cargo test` | |
| 114 | +| Run behavior | `cargo run` when output or CLI behavior matters | |
| 115 | + |
| 116 | +## Pre-Planning Protocol |
| 117 | + |
| 118 | +For non-trivial work: |
| 119 | + |
| 120 | +1. **Clarify**: ask focused questions about scope, target platform (desktop integration vs CLI), and error-handling expectations before coding. |
| 121 | +2. **Test plan**: decide whether `cargo check`, `cargo test`, or `cargo run` proves the change; note any manual steps on Pop!_OS if relevant. |
| 122 | +3. **Read first**: `Cargo.toml`, `src/main.rs`, and any new modules touched; skip for trivial one-line fixes. |
0 commit comments