Imported from AganFebro/fhast (
AGENTS.md). Install upstream withnpx skills add AganFebro/fhast. Copyright stays with the author.
AGENTS.md
- Do not commit into GitHub without asking.
- Scope: build the Rust CLI/TUI download manager, daemon, native host, and Chrome link-grabber extension described in
project.md. - Architecture rule:
fhast-daemonowns state and downloads; CLI/TUI are clients; Chrome extension captures links; native host only bridges to daemon. - Do not add DRM bypass, anti-bot bypass, credential scraping, proxy/VPN evasion, telemetry, or hidden network calls.
- Prefer reliability over speed: never risk corrupted files for acceleration; fall back cleanly to single-connection downloads.
- Keep crates focused:
fhast-corehas engine logic,fhast-ipchas schemas, UI crates must not duplicate downloader logic. - Rust style: use
rustfmtdefaults and optimize for readability, scan-ability, accessible diffs, and non-misleading formatting. - Rust naming: crates/files/modules/functions/vars use
snake_case; types/traits/enums useUpperCamelCase; constants/statics useSCREAMING_SNAKE_CASE. - Rust errors: avoid
unwrap/expectoutside tests and impossible invariants; return typed errors and preserve context at boundaries. - Rust async: use Tokio with bounded concurrency; never block async tasks; use
spawn_blockingfor CPU-heavy or blocking filesystem work. - Rust performance: avoid unnecessary
clone,collect, locks, and allocation; prefer borrowing, streaming, iterators, and clear ownership. - Rust APIs: public items need
///docs; internal comments should explain why, not restate what the code says. - Downloader tests must cover range math, resume validation, retry/backoff, file merge, checksum, cancellation, and crash recovery.
- Network code must verify HTTP
206 Partial Contentbefore segmented mode and handle200,403,416,429, and5xxsafely. - Persist job/segment metadata before risky state changes; use atomic temp-file writes and never leave ambiguous completion state.
- TypeScript style: enable
strict; avoidany; usecamelCasefor values/functions,PascalCasefor types/classes, andCONSTANT_CASEfor constants. - Extension code should request minimal permissions first; context-menu capture is MVP;
webRequest/cookies are optional and user-visible. - Native messaging host must validate schema and caller origin, redact sensitive data, and forward only necessary fields to the daemon.
- JSON/IPC/config keys use
snake_caseunless a platform API requires otherwise; include aversionfield in every cross-process message. - SQL uses lowercase
snake_casetable/column names, explicit migrations, prepared queries, and no string-concatenated user input. - Shell scripts should be POSIX
shunless Bash is required; Bash scripts useset -euo pipefailand quote variables. - Markdown docs should contain copy-pasteable commands, ASCII diagrams, and updates whenever behavior, flags, or architecture changes.
- Keep
roadmap.mdcurrent: use[x]for implemented features,[X]plus a clear description for skipped or removed features, and mark the roadmap complete only when every non-skipped item is finished. - Formatting/linting gate: run
cargo fmt,cargo clippy --all-targets --all-features -- -D warnings, and extension lint/format before PRs. - Add
.editorconfigand keep LF endings, final newlines, UTF-8 text, and no trailing whitespace across Rust, TS, JSON, SQL, shell, and docs. - Security: sanitize filenames, reject path traversal, protect save directories, and never log cookies, auth headers, signed URLs, or tokens.
- Privacy: capture browser headers only with explicit user intent; store sensitive headers only until completion or encrypted if persistence is required.
- Observability: use
tracingwith structured fields; logs should identify job IDs and domains without exposing secrets. - CLI naming: subcommands and flags use
kebab-case; environment variables usefhast_SCREAMING_SNAKE_CASE. - TUI UX: quitting the TUI must not stop the daemon; destructive actions need confirmation; errors must be visible and actionable.
- Commits should follow Conventional Commits, e.g.
feat(core): add segmented range plannerorfix(extension): redact cookie header. - PRs should be small, tested, documented, and include migration notes when schemas, configs, or IPC messages change.
- References: https://doc.rust-lang.org/style-guide/ and https://doc.rust-lang.org/style-guide/principles.html
- References: https://rust-lang.github.io/api-guidelines/naming.html and https://microsoft.github.io/rust-guidelines/
- References: https://github.com/apollographql/rust-best-practices and https://google.github.io/styleguide/tsguide.html
- References: https://developer.chrome.com/docs/extensions/develop/concepts/native-messaging and https://developer.chrome.com/docs/extensions/reference/api/contextMenus
- References: https://www.conventionalcommits.org/en/v1.0.0/ and https://editorconfig.org/