Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions template/docs/guides/agent-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,24 @@ After replacing placeholders, customize these files:
| `src/main.rs` | Replace the `Hello` command dispatch with your own commands |
| `cliff.toml` | Verify the `repo` field matches your GitHub repo name |

### 1d. Verify Initialization
### 1d. Initialize Development Environment

```bash
just init # Installs prek pre-commit hooks
just pre-commit # Verify all checks pass
```

### 1e. Verify Initialization

```bash
cargo check # Must compile without errors
cargo test # Baseline tests pass
cargo run -- --help # CLI shows your project name
cargo run -- hello world # Example command works
cargo run -- --agent-describe # Agent schema outputs valid JSON
```

### 1e. Clean Up Example Code
### 1f. Clean Up Example Code

Once your first real command is in place, remove the scaffolding:

Expand All @@ -99,8 +107,8 @@ src/
├── cli/
│ └── mod.rs # Clap definitions: Cli struct, Command enum, subcommand enums
├── error.rs # AppError enum (snafu) — add variants for new error sources
├── app_config.rs # TOML config: AppConfig struct + load()/save()
├── paths.rs # ~/.{project-name}/ data directory resolution
├── app_config.rs # TOML config: AppConfig struct + init()/get()/save()
├── paths.rs # ~/.{project-name}/ data directory — init_data_dir()/data_dir()
├── http.rs # Shared reqwest clients (client() + download_client())
└── agent/ # AI agent CLI integration (usually don't need to modify)
├── mod.rs # Re-exports
Expand All @@ -118,15 +126,19 @@ User input
Cli::parse() ← src/cli/mod.rs (clap derive)
paths::init_data_dir() ← src/paths.rs (validates + caches data dir)
app_config::init() ← src/app_config.rs (loads + caches config)
match cli.command ← src/main.rs (dispatch)
├─▶ Your module logic ← src/yourmodule/mod.rs
│ ├── reads config ← app_config::load()
│ ├── reads config ← app_config::get()
│ ├── makes HTTP ← http::client()
│ └── returns data
JSON output to stdout ← serde_json::json!({"ok": true, ...})
JSON output to stdout ← AgentResponse::ok(data).print()
Logs/errors to stderr ← eprintln!() / tracing
```

Expand Down Expand Up @@ -459,12 +471,12 @@ let resp = http::client()
```rust
use crate::app_config;

// Read (cached, returns &'static AppConfig)
let cfg = app_config::load();
// Read (cached, returns &'static AppConfig — init() must have been called in main)
let cfg = app_config::get();
let dir = &cfg.download.output_dir;

// Write
let mut cfg = app_config::load().clone();
let mut cfg = app_config::get().clone();
cfg.download.max_concurrent = 8;
app_config::save(&cfg).context(IoSnafu)?;
```
Expand Down
12 changes: 10 additions & 2 deletions template/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,17 @@ build-release:
# Run all pre-commit checks
pre-commit: fmt-check lint test

# Install git hooks via prek
setup-hooks:
# Initialize prek pre-commit hooks (first-time setup)
prek-init:
prek install
@echo "Pre-commit hooks installed. Run 'just pre-commit' to verify."

# Install git hooks via prek (alias for prek-init)
setup-hooks: prek-init

# Initialize full development environment
init: prek-init
@echo "Development environment ready."

# ─── Changelog & Release ─────────────────────────────────────────────

Expand Down
Loading
Loading