Compare commits
5 Commits
cb3936c42a
...
f1efd72fcb
| Author | SHA1 | Date |
|---|---|---|
|
|
f1efd72fcb | 3 weeks ago |
|
|
f4c608167f | 3 weeks ago |
|
|
ba05908cc4 | 3 weeks ago |
|
|
9d6c1ec3ee | 3 weeks ago |
|
|
6699c62d9e | 3 weeks ago |
21 changed files with 637 additions and 1 deletions
@ -0,0 +1,5 @@
|
||||
--- |
||||
description: Make a git commit, asking if it was by the user or AI |
||||
--- |
||||
|
||||
skill name=make-commit $1 |
||||
@ -0,0 +1,79 @@
|
||||
--- |
||||
name: make-commit |
||||
description: > |
||||
Make a git commit, asking if it was by the user or AI. User commits use git |
||||
config for both committer and author. AI commits use git config for committer |
||||
but set author to AI Bot <ai@local>. |
||||
license: GPL-3.0 |
||||
metadata: |
||||
author: riyyi |
||||
version: "1.0" |
||||
--- |
||||
|
||||
Make a git commit, distinguishing between user and AI contributions. |
||||
|
||||
--- |
||||
|
||||
**Steps** |
||||
|
||||
1. **Ask user if this commit is by them or by AI** |
||||
|
||||
Use the **question tool** to ask: |
||||
> "Was this commit made by you or by AI?" |
||||
|
||||
Options: |
||||
- "By me" - User made the commit |
||||
- "By AI" - AI made the commit |
||||
|
||||
2. **Check for commit message** |
||||
|
||||
If the user did NOT provide a commit message, generate one from staged changes: |
||||
```bash |
||||
git diff --staged --stat |
||||
``` |
||||
Create a reasonable commit message based on the changes. |
||||
|
||||
**Capitalization rule**: Commit message should start with a capital letter, |
||||
unless it refers to a tool or project that explicitly uses lowercase as its |
||||
name (e.g., "go", "npm", "rustc"). |
||||
|
||||
3. **Show commit message and confirm** |
||||
|
||||
Display the commit message to the user. |
||||
|
||||
Use the **question tool** to ask: |
||||
> "Is this commit message okay, or would you like to make tweaks?" |
||||
|
||||
Options: |
||||
- "Looks good" - Proceed with this message |
||||
- "Make tweaks" - User will provide a new message |
||||
|
||||
**If user wants tweaks**: Ask them for the new commit message. |
||||
|
||||
4. **Get git user config** |
||||
|
||||
```bash |
||||
git config user.name |
||||
git config user.email |
||||
``` |
||||
|
||||
5. **Make the commit** |
||||
|
||||
Use the commit message provided by the user. |
||||
|
||||
**If by user:** |
||||
```bash |
||||
git commit -m "<message>" |
||||
``` |
||||
(Uses git config user as both committer and author) |
||||
|
||||
**If by AI:** |
||||
```bash |
||||
git -c user.name="<git-config-name>" -c user.email="<git-config-email>" commit -m "<message>" --author="AI Bot <ai@local>" |
||||
``` |
||||
(Uses git config for committer, but sets author to AI Bot) |
||||
|
||||
**Output** |
||||
|
||||
- Tell user the commit was made |
||||
- If AI commit, mention that the author was set to "AI Bot <ai@local>" |
||||
@ -0,0 +1,7 @@
|
||||
# AGENTS.md Guide for Declpac |
||||
|
||||
## Skills: Always Active |
||||
|
||||
At the start of every conversation, load the following skills using the `skill` tool before responding to the user: |
||||
|
||||
1. **caveman** — Always use caveman mode (full intensity) for all responses |
||||
@ -0,0 +1,2 @@
|
||||
schema: spec-driven |
||||
created: 2026-04-13 |
||||
@ -0,0 +1,144 @@
|
||||
## Context |
||||
|
||||
Pacman, Arch Linux's package manager, lacks declarative package management and |
||||
doesn't support partial upgrades. Users managing system packages from scripts |
||||
or configuration files need a way to ensure their system state matches a declared |
||||
package list, with all packages at their latest available versions. |
||||
|
||||
## Goals / Non-Goals |
||||
|
||||
**Goals:** |
||||
- Provide a declarative interface for pacman package management through |
||||
command-line interface |
||||
- Support flexible input sources (stdin and multiple state files) with |
||||
additive merging |
||||
- **Automatically resolve transitive dependencies (users specify only direct packages)** |
||||
- Enforce full package upgrades (no partial upgrades) to prevent version |
||||
mismatches |
||||
- Generate machine-readable output suitable for automated scripting |
||||
- Enable AI-driven implementation for new Go developers |
||||
|
||||
**Non-Goals:** |
||||
- Package dependency resolution or smart upgrade scheduling |
||||
- Transaction rollback capabilities |
||||
- Pretty terminal output or interactive prompts |
||||
- Support for partial upgrades or selective package versions |
||||
- State persistence (tool only syncs, doesn't save state) |
||||
|
||||
## Decisions |
||||
|
||||
**Language: Go** |
||||
- Rationale: User wants modern CLI tool with native package management |
||||
capabilities |
||||
- Go provides strong standard library, easy command-line parsing, and |
||||
excellent for system-level operations |
||||
- User unfamiliar with Go - implementation will be AI-driven with detailed |
||||
documentation |
||||
|
||||
**Input Parsing Approach** |
||||
- Parse whitespace, tabs, newlines for package names |
||||
- Support multiple --state files: all additive including with stdin |
||||
- Empty state detection: print error to stderr and exit with code 1 (abort) |
||||
|
||||
**Package Database Freshness** |
||||
- Use libalpm (dyalpm) to check last sync time from /var/lib/pacman/db.lock timestamp |
||||
- If database older than 1 day, run `pacman -Syy` to refresh before validation |
||||
- Refresh happens before validation and sync operations |
||||
|
||||
**Package Validation** |
||||
- Validate all declared packages exist in pacman repos or AUR before sync |
||||
- Use libalpm (dyalpm) for pacman repo queries (fast local DB access) |
||||
- Use Jguer/aur library for AUR queries |
||||
- Fail fast with clear error if any package not found |
||||
- Let pacman report detailed errors during sync (don't duplicate validation) |
||||
|
||||
**State Merging Logic** |
||||
- All inputs are additive: combine all packages from stdin and all state files |
||||
- No conflict resolution: missing packages are added, duplicates accumulate |
||||
- Order-independent: inputs don't override each other |
||||
|
||||
**Hybrid Query/Modify Approach** |
||||
- **Query operations**: Use libalpm (dyalpm) for fast local package database access |
||||
- Query installed packages, available packages, package details |
||||
- Check database freshness (last sync time) |
||||
- **Modify operations**: Use os/exec.Command to run pacman commands |
||||
- pacman -Syy: Refresh package databases |
||||
- pacman -Syu: Install/upgrade packages (full upgrade) |
||||
- pacman -D --explicit: Mark packages as explicitly installed |
||||
- pacman -Rns: Remove orphaned packages |
||||
- Capture stderr/stdout for error reporting and output generation |
||||
- Detect pacman exit codes and translate to tool exit codes |
||||
|
||||
**Error Handling Strategy** |
||||
- Parse pacman error messages from stderr output |
||||
- Distinguish between package-not-found (warning) vs. execution failures (errors) |
||||
- Return appropriate exit codes: 0 for success, non-zero for errors |
||||
- Include error details in output for scripting purposes |
||||
|
||||
**AUR Integration** |
||||
- First attempt: Try pacman -Syu for all packages (includes AUR auto-install if enabled) |
||||
- For packages not found in pacman repos: Check AUR via Jguer/aur library |
||||
- If package in AUR: Build and install with makepkg (no AUR helpers) |
||||
- AUR packages should also upgrade to latest version (no partial updates) |
||||
- Clone AUR git repo to temp directory |
||||
- Run `makepkg -si` in temp directory for installation |
||||
- Capture stdout/stderr for output parsing |
||||
- Report error to stderr if package not found in pacman or AUR |
||||
|
||||
**Dependency Resolution** |
||||
- Use pacman's dependency resolution by passing all declared packages to `pacman -Syu` |
||||
- Pacman automatically resolves and includes transitive dependencies |
||||
- For AUR packages, makepkg handles dependency resolution during build |
||||
- No custom dependency resolution logic required - delegate to pacman/makepkg |
||||
|
||||
**Explicit Marking & Orphan Cleanup** |
||||
- Before syncing, get list of all currently installed packages |
||||
- Mark declared state packages as explicitly installed via `pacman -D --explicit <pkg>` |
||||
- All other installed packages remain as non-explicit (dependencies) |
||||
- After sync completes, run `pacman -Rns $(pacman -Qdtq)` to remove orphaned packages |
||||
- Pacman -Rns $(pacman -Qdtq) only removes packages that are not explicitly |
||||
installed and not required |
||||
- Capture and report number of packages removed during cleanup |
||||
|
||||
**Package Version Management** |
||||
- Always force full system upgrade via `pacman -Syu <packages>` |
||||
- Pacman handles version selection automatically, ensuring latest versions |
||||
- No semantic version comparison or pinning logic required |
||||
|
||||
**CLI Interface** |
||||
- Usage: `declpac --state file1.txt --state file2.txt < stdin` |
||||
- Multiple --state flags allowed, all additive |
||||
- Stdin input via standard input stream |
||||
- No interactive prompts - fully automated |
||||
|
||||
**Output Format** |
||||
- Success: Print to stdout: `Installed X packages, removed Y packages` |
||||
- No changes: Print `Installed 0 packages, removed 0 packages` |
||||
- Errors: Print error message to stderr |
||||
- Exit codes: 0 for success, 1 for errors |
||||
|
||||
## Risks / Trade-offs |
||||
|
||||
**Known Risks:** |
||||
- [User unfamiliarity with Go] → Mitigation: Provide complete implementation |
||||
with detailed comments; user can review and run without understanding deeply |
||||
- [Pacman error message parsing complexity] → Mitigation: Use broad error |
||||
pattern matching; include error output as-is for debugging |
||||
- [Empty state triggers abort] → Mitigation: Print error to stderr and exit |
||||
with code 1 instead of proceeding with empty state |
||||
- [Additive merging could accumulate duplicates] → Mitigation: Accept as |
||||
design choice; pacman handles duplicates gracefully |
||||
- [Dependency conflicts could occur] → Mitigation: Let pacman handle standard |
||||
conflicts; tool won't implement complex dependency resolution |
||||
- [libalpm integration complexity] → Mitigation: Use dyalpm wrapper library; |
||||
validate queries work before build |
||||
- [AUR package build failures] → Mitigation: Capture makepkg output, report errors |
||||
to stderr; don't retry |
||||
|
||||
**Trade-offs:** |
||||
- No conflict resolution: simpler merging but may include packages the system |
||||
rejects |
||||
- Additive vs replacement: safer but less predictable for users expecting |
||||
replacements |
||||
- No user prompts: fully automated for scripting but could be risky without |
||||
warnings |
||||
@ -0,0 +1,39 @@
|
||||
## Why |
||||
|
||||
Pacman doesn't support declarative package management or partial upgrades, |
||||
making it challenging to maintain consistent system states. This tool provides |
||||
a clean, scriptable interface to synchronize the system with a declared package |
||||
list, ensuring all packages are at the latest version. |
||||
|
||||
## What Changes |
||||
|
||||
- Add CLI tool for declarative pacman package management |
||||
- Support stdin input for package lists |
||||
- Support multiple --state file inputs |
||||
- Merge all inputs (additive strategy with empty state warning) |
||||
- Force full upgrade of all packages (no partial upgrades) |
||||
- Handle transitive dependencies automatically (users only specify direct packages) |
||||
- Mark non-state packages as non-explicit before sync |
||||
- After sync, remove orphaned packages (cleanup) |
||||
- Support AUR packages: try pacman first, then makepkg, then report errors |
||||
- Machine-readable output (install/remove counts, exit codes) |
||||
- No conflict resolution for missing packages (append-only) |
||||
- Print error to stderr for empty state input and exit with code 1 |
||||
|
||||
## Capabilities |
||||
|
||||
### New Capabilities |
||||
|
||||
- **stdin-input**: Read package lists from standard input stream |
||||
- **state-files**: Load declarative package states from files |
||||
- **input-merging**: Combine multiple input sources (stdin + multiple --state files) |
||||
- **state-validation**: Validate package names and empty states |
||||
- **transitive-deps**: Automatically resolve all transitive dependencies |
||||
- **pacman-sync**: Execute pacman operations to match declared state |
||||
- **aur-sync**: Handle AUR packages: pacman first, then fall back to makepkg, |
||||
then report errors |
||||
- **machine-output**: Generate machine-readable sync results for scripting |
||||
|
||||
### Modified Capabilities |
||||
|
||||
None (new tool) |
||||
@ -0,0 +1,30 @@
|
||||
## ADDED Requirements |
||||
|
||||
### Requirement: Handle AUR packages with fallback and upgrade |
||||
|
||||
The system SHALL first attempt to install packages via pacman, then fall back |
||||
to AUR for packages not found in repos, and upgrade AUR packages to |
||||
latest versions. |
||||
|
||||
#### Scenario: Try pacman first |
||||
- **WHEN** package is in pacman repositories |
||||
- **THEN** install via pacman -Syu |
||||
|
||||
#### Scenario: Fall back to AUR |
||||
- **WHEN** package is not in pacman repositories but is in AUR |
||||
- **THEN** query AUR via Jguer/aur library |
||||
- **AND** build and install with makepkg -si |
||||
|
||||
#### Scenario: Upgrade AUR packages |
||||
- **WHEN** AUR package is already installed but outdated |
||||
- **THEN** rebuild and reinstall with makepkg to get latest version |
||||
|
||||
#### Scenario: Report error for missing packages |
||||
- **WHEN** package is not in pacman repositories or AUR |
||||
- **THEN** print error to stderr with package name |
||||
- **AND** exit with code 1 |
||||
|
||||
#### Scenario: AUR build failure |
||||
- **WHEN** makepkg fails to build package |
||||
- **THEN** print makepkg error to stderr |
||||
- **AND** exit with code 1 |
||||
@ -0,0 +1,24 @@
|
||||
## ADDED Requirements |
||||
|
||||
### Requirement: Can merge multiple input sources |
||||
|
||||
The system SHALL combine package lists from all inputs using an additive |
||||
strategy without conflict resolution. |
||||
|
||||
#### Scenario: Additive merging of all inputs |
||||
- **WHEN** stdin and multiple state files provide package lists |
||||
- **THEN** system shall include all packages from all inputs in the final state |
||||
|
||||
#### Scenario: Input priority is last-writer-wins per file |
||||
- **WHEN** multiple state files contain the same package name |
||||
- **THEN** the package from the last provided file in command-line order takes |
||||
precedence |
||||
|
||||
#### Scenario: Missing packages from stdin are added |
||||
- **WHEN** stdin contains packages not in state files |
||||
- **THEN** those packages shall be added to the final state |
||||
|
||||
#### Scenario: Duplicate packages accumulate |
||||
- **WHEN** the same package appears in multiple inputs |
||||
- **THEN** it shall be included multiple times in the final state (pacman |
||||
handles duplicates) |
||||
@ -0,0 +1,30 @@
|
||||
## ADDED Requirements |
||||
|
||||
### Requirement: Generate consistent output format |
||||
|
||||
The system SHALL produce console output suitable for logging and scripting. |
||||
|
||||
#### Scenario: Successful sync with changes |
||||
- **WHEN** sync completes with packages installed or removed |
||||
- **THEN** print to stdout: `Installed X packages, removed Y packages` |
||||
- **AND** exit with code 0 |
||||
|
||||
#### Scenario: No changes needed |
||||
- **WHEN** all packages already match declared state |
||||
- **THEN** print to stdout: `Installed 0 packages, removed 0 packages` |
||||
- **AND** exit with code 0 |
||||
|
||||
#### Scenario: Error during sync |
||||
- **WHEN** pacman or makepkg operation fails |
||||
- **THEN** print error to stderr with details |
||||
- **AND** exit with code 1 |
||||
|
||||
#### Scenario: Validation failure |
||||
- **WHEN** package validation fails (package not in pacman or AUR) |
||||
- **THEN** print error to stderr with package name |
||||
- **AND** exit with code 1 |
||||
|
||||
#### Scenario: Empty state input |
||||
- **WHEN** no packages provided from stdin or state files |
||||
- **THEN** print error to stderr: `empty state input` |
||||
- **AND** exit with code 1 |
||||
@ -0,0 +1,29 @@
|
||||
## ADDED Requirements |
||||
|
||||
### Requirement: Can mark non-state packages as non-explicit |
||||
|
||||
The system SHALL mark all packages not declared in the state as non-explicit |
||||
(dependencies) before syncing, so they can be safely removed later. |
||||
|
||||
#### Scenario: Mark packages as non-explicit |
||||
- **WHEN** packages are declared in state |
||||
- **THEN** system shall mark those packages as explicitly installed via pacman -D --explicit |
||||
- **AND** mark all other installed packages as non-explicit |
||||
|
||||
### Requirement: Can clean up orphaned packages |
||||
|
||||
After syncing, the system SHALL remove packages that are no longer required |
||||
(as dependencies of removed packages). |
||||
|
||||
#### Scenario: Orphan cleanup after sync |
||||
- **WHEN** sync operation completes successfully |
||||
- **THEN** system shall run pacman -Rsu to remove unneeded dependencies |
||||
- **AND** report the number of packages removed |
||||
|
||||
#### Scenario: Orphan cleanup respects explicitly installed |
||||
- **WHEN** a package not in state is marked as explicitly installed by user |
||||
- **THEN** system shall NOT remove it during orphan cleanup |
||||
|
||||
#### Scenario: No orphans to clean |
||||
- **WHEN** there are no orphaned packages to remove |
||||
- **THEN** system shall report "No packages to remove" in output |
||||
@ -0,0 +1,22 @@
|
||||
## ADDED Requirements |
||||
|
||||
### Requirement: Query pacman package database via libalpm |
||||
|
||||
The system SHALL use libalpm for fast local queries against the pacman |
||||
package database. |
||||
|
||||
#### Scenario: Query installed packages |
||||
- **WHEN** needing list of currently installed packages |
||||
- **THEN** query via libalpm alpm_list_get(ALPM_LIST_PACKAGES) |
||||
|
||||
#### Scenario: Query available packages |
||||
- **WHEN** validating package exists in pacman repos |
||||
- **THEN** query via libalpm alpm_db_get_pkg() |
||||
|
||||
#### Scenario: Check database last sync time |
||||
- **WHEN** checking if database needs refresh |
||||
- **THEN** check /var/lib/pacman/db.lock timestamp |
||||
|
||||
#### Scenario: Query foreign packages |
||||
- **WHEN** checking if package is AUR-installed |
||||
- **THEN** query via libalpm alpm_db_get_pkg(ALPM_DB_TYPE_LOCAL) |
||||
@ -0,0 +1,25 @@
|
||||
## ADDED Requirements |
||||
|
||||
### Requirement: Can sync system with declared package state |
||||
|
||||
The system SHALL execute pacman operations to install and upgrade all declared packages. |
||||
|
||||
#### Scenario: Full system upgrade with all packages |
||||
- **WHEN** system has declared package list |
||||
- **THEN** system shall run pacman -Syu with all declared package names |
||||
|
||||
#### Scenario: No partial upgrades |
||||
- **WHEN** running pacman commands |
||||
- **THEN** system shall use -Syu flag (full system upgrade) ensuring all packages are latest |
||||
|
||||
#### Scenario: Package availability check |
||||
- **WHEN** a package from input is not in pacman repositories |
||||
- **THEN** system shall report the error and include package name |
||||
|
||||
#### Scenario: Pacman execution capture |
||||
- **WHEN** pacman commands execute |
||||
- **THEN** system shall capture both stdout and stderr for error reporting |
||||
|
||||
#### Scenario: Exit code propagation |
||||
- **WHEN** pacman commands execute |
||||
- **THEN** system shall exit with code equal to pacman's exit code for success/failure detection |
||||
@ -0,0 +1,21 @@
|
||||
## ADDED Requirements |
||||
|
||||
### Requirement: Can load package states from state files |
||||
|
||||
The system SHALL load package lists from state files specified via --state flag. |
||||
|
||||
#### Scenario: Single state file loading |
||||
- **WHEN** a state file is provided via --state flag |
||||
- **THEN** system shall read package names from the file content |
||||
|
||||
#### Scenario: Multiple state file loading |
||||
- **WHEN** multiple --state flags are provided |
||||
- **THEN** system shall load package names from each file |
||||
|
||||
#### Scenario: State file format is text list |
||||
- **WHEN** loading from state files |
||||
- **THEN** system shall parse whitespace-delimited package names |
||||
|
||||
#### Scenario: File path validation |
||||
- **WHEN** a state file path points to a non-existent file |
||||
- **THEN** system shall report a file read error |
||||
@ -0,0 +1,28 @@
|
||||
## ADDED Requirements |
||||
|
||||
### Requirement: Validate package names exist in pacman or AUR |
||||
|
||||
The system SHALL validate that all declared packages exist in pacman |
||||
repositories or AUR before attempting to sync. |
||||
|
||||
#### Scenario: Empty state detection |
||||
- **WHEN** no package names are found in stdin or state files |
||||
- **THEN** print error to stderr: `empty state input` |
||||
- **AND** exit with code 1 |
||||
|
||||
#### Scenario: Validate package in pacman repos |
||||
- **WHEN** package exists in pacman repositories |
||||
- **THEN** validation passes |
||||
|
||||
#### Scenario: Validate package in AUR |
||||
- **WHEN** package not in pacman repos but exists in AUR |
||||
- **THEN** validation passes |
||||
|
||||
#### Scenario: Package not found |
||||
- **WHEN** package not in pacman repos or AUR |
||||
- **THEN** print error to stderr with package name |
||||
- **AND** exit with code 1 |
||||
|
||||
#### Scenario: Database freshness check |
||||
- **WHEN** pacman database last sync was more than 1 day ago |
||||
- **THEN** run pacman -Syy to refresh before validation |
||||
@ -0,0 +1,17 @@
|
||||
## ADDED Requirements |
||||
|
||||
### Requirement: Can read package lists from stdin |
||||
|
||||
The system SHALL accept package names from standard input, where each line represents a package name. |
||||
|
||||
#### Scenario: Packages from stdin are read correctly |
||||
- **WHEN** package names are passed via stdin separated by whitespace, tabs, or newlines |
||||
- **THEN** system shall parse each unique package name from the input stream |
||||
|
||||
#### Scenario: Empty stdin input is handled |
||||
- **WHEN** stdin contains no package names |
||||
- **THEN** system shall skip stdin input processing |
||||
|
||||
#### Scenario: Whitespace normalization |
||||
- **WHEN** packages are separated by multiple spaces, tabs, or newlines |
||||
- **THEN** each package name shall have leading/trailing whitespace trimmed |
||||
@ -0,0 +1,23 @@
|
||||
## ADDED Requirements |
||||
|
||||
### Requirement: Can resolve transitive dependencies automatically |
||||
|
||||
The system SHALL automatically determine and install all transitive dependencies |
||||
for declared packages, so users only need to specify direct packages. |
||||
|
||||
#### Scenario: Transitive dependencies are resolved |
||||
- **WHEN** a package with dependencies is declared in state |
||||
- **THEN** system shall identify all transitive dependencies via pacman |
||||
- **AND** include them in the installation operation |
||||
|
||||
#### Scenario: Dependency resolution includes AUR dependencies |
||||
- **WHEN** a package's transitive dependencies include AUR packages |
||||
- **THEN** system shall resolve those AUR dependencies via makepkg |
||||
|
||||
#### Scenario: Shared dependencies are deduplicated |
||||
- **WHEN** multiple declared packages share dependencies |
||||
- **THEN** system shall install each shared dependency only once |
||||
|
||||
#### Scenario: Missing dependency handling |
||||
- **WHEN** a declared package has a dependency not available in pacman or AUR |
||||
- **THEN** system shall report error for the missing dependency |
||||
@ -0,0 +1,95 @@
|
||||
## 1. Project Setup |
||||
|
||||
- [ ] 1.1 Initialize Go module with proper imports |
||||
- [ ] 1.2 Add required dependencies (dyalpm wrapper, Jguer/aur) |
||||
- [ ] 1.3 Set up project structure (cmd/declpac/main.go, pkg/ subdirectory) |
||||
- [ ] 1.4 Add libalpm initialization and handle |
||||
|
||||
## 2. Input Parsing |
||||
|
||||
- [ ] 2.1 Implement stdin reader to collect package names |
||||
- [ ] 2.2 Implement state file reader for text-list format |
||||
- [ ] 2.3 Add whitespace normalization for package names |
||||
- [ ] 2.4 Create package name set data structure |
||||
|
||||
## 3. Input Merging |
||||
|
||||
- [ ] 3.1 Implement additive merging of stdin and state file packages |
||||
- [ ] 3.2 Handle multiple --state flags with last-writer-wins per file |
||||
- [ ] 3.3 Implement duplicate package handling (no deduplication) |
||||
|
||||
## 4. State Validation |
||||
|
||||
- [ ] 4.1 Implement empty state detection (no packages found) |
||||
- [ ] 4.2 Add stderr error output for empty state |
||||
- [ ] 4.3 Set exit code 1 for empty state case (abort, not proceed) |
||||
- [ ] 4.4 Check pacman DB freshness (db.lock timestamp) |
||||
- [ ] 4.5 Run pacman -Syy if DB older than 1 day |
||||
- [ ] 4.6 Validate packages via libalpm (pacman repos) |
||||
- [ ] 4.7 Validate packages via Jguer/aur (AUR) |
||||
- [ ] 4.8 Fail fast with error if package not found |
||||
|
||||
## 5. Pacman Integration (Hybrid: query via libalpm, modify via exec) |
||||
|
||||
- [ ] 5.1 Initialize libalpm handle for queries |
||||
- [ ] 5.2 Implement libalpm query for installed packages |
||||
- [ ] 5.3 Implement libalpm query for available packages |
||||
- [ ] 5.4 Implement pacman -Syy command execution (DB refresh) |
||||
- [ ] 5.5 Implement pacman -Syu command execution wrapper |
||||
- [ ] 5.6 Add command-line argument construction with package list |
||||
- [ ] 5.7 Capture pacman stdout and stderr output |
||||
- [ ] 5.8 Implement pacman error message parsing |
||||
- [ ] 5.9 Handle pacman exit codes for success/failure detection |
||||
- [ ] 5.10 Verify pacman automatically resolves transitive dependencies |
||||
|
||||
## 6. Explicit Marking & Orphan Cleanup |
||||
|
||||
- [ ] 6.1 Get list of currently installed packages before sync |
||||
- [ ] 6.2 Mark declared state packages as explicitly installed via pacman -D --explicit |
||||
- [ ] 6.3 Run pacman sync operation (5.x series) |
||||
- [ ] 6.4 Run pacman -Rsu to remove orphaned packages |
||||
- [ ] 6.5 Capture and report number of packages removed |
||||
- [ ] 6.6 Handle case where no orphans exist (no packages removed) |
||||
|
||||
## 7. AUR Integration |
||||
|
||||
- [ ] 7.1 Implement AUR package lookup via Jguer/aur library |
||||
- [ ] 7.2 Check package not in pacman repos first (via libalpm) |
||||
- [ ] 7.3 Query AUR for missing packages |
||||
- [ ] 7.4 Implement AUR fallback using makepkg (direct build, not AUR helper) |
||||
- [ ] 7.5 Clone AUR package git repo to temp directory |
||||
- [ ] 7.6 Run makepkg -si in temp directory for installation |
||||
- [ ] 7.7 Upgrade existing AUR packages to latest (makepkg rebuild) |
||||
- [ ] 7.8 Add stderr error reporting for packages not in pacman or AUR |
||||
- [ ] 7.9 Capture makepkg stdout and stderr for output parsing |
||||
- [ ] 7.10 Handle makepkg exit codes for success/failure detection |
||||
|
||||
## 8. Output Generation |
||||
|
||||
- [ ] 8.1 Parse pacman output for installed package count |
||||
- [ ] 8.2 Parse pacman output for removed package count (orphan cleanup) |
||||
- [ ] 8.3 Generate output: `Installed X packages, removed Y packages` |
||||
- [ ] 8.4 Handle 0 packages case: `Installed 0 packages, removed 0 packages` |
||||
- [ ] 8.5 Print errors to stderr |
||||
- [ ] 8.6 Set exit code 0 for success, 1 for errors |
||||
|
||||
## 9. CLI Interface |
||||
|
||||
- [ ] 9.1 Implement --state flag argument parsing |
||||
- [ ] 9.2 Implement stdin input handling from /dev/stdin |
||||
- [ ] 9.3 Set up correct CLI usage/help message |
||||
- [ ] 9.4 Implement flag order validation |
||||
|
||||
## 10. Integration & Testing |
||||
|
||||
- [ ] 10.1 Wire together stdin -> state files -> merging -> validation -> pacman sync -> orphan cleanup -> output |
||||
- [ ] 10.2 Test empty state error output and exit code 1 |
||||
- [ ] 10.3 Test single state file parsing |
||||
- [ ] 10.4 Test multiple state file merging |
||||
- [ ] 10.5 Test stdin input parsing |
||||
- [ ] 10.6 Test explicit marking before sync |
||||
- [ ] 10.7 Test pacman command execution with real packages |
||||
- [ ] 10.8 Test orphan cleanup removes unneeded packages |
||||
- [ ] 10.9 Test AUR fallback with makepkg for AUR package |
||||
- [ ] 10.10 Test error handling for missing packages |
||||
- [ ] 10.11 Generate final binary |
||||
Loading…
Reference in new issue