|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file is the canonical contributor guide for this repository. |
| 4 | + |
| 5 | +If another assistant-specific file exists, it should defer to this document for repo workflow, quality gates, and architecture constraints. |
| 6 | + |
| 7 | +## Mission |
| 8 | + |
| 9 | +Keep this Electron video app production-ready while preserving: |
| 10 | + |
| 11 | +- clear module boundaries |
| 12 | +- deterministic tests |
| 13 | +- stable user-facing behavior |
| 14 | +- release integrity |
| 15 | + |
| 16 | +Do not optimize for "quickly making tests pass." Optimize for making the codebase more robust. |
| 17 | + |
| 18 | +## Required Workflow |
| 19 | + |
| 20 | +For any non-trivial change, follow this order: |
| 21 | + |
| 22 | +1. Identify the affected feature and expected behavior. |
| 23 | +2. Define or update acceptance criteria before implementation. |
| 24 | +3. Add or update tests first for the intended behavior. |
| 25 | +4. Implement the code change. |
| 26 | +5. Run the full verification suite. |
| 27 | +6. Fix code defects if tests fail. Do not weaken assertions unless the product requirement itself changed. |
| 28 | + |
| 29 | +## Change Policy |
| 30 | + |
| 31 | +- Prefer small, isolated changes over broad rewrites. |
| 32 | +- Preserve behavior unless the task explicitly changes product behavior. |
| 33 | +- Do not introduce duplicate business logic across renderer and main. |
| 34 | +- Shared normalization/domain logic belongs in `src/shared/`. |
| 35 | +- Main-process business logic belongs in `src/main/services/`, not in IPC registration or app bootstrap. |
| 36 | +- Renderer feature logic belongs in `src/renderer/features/`, not inline in `src/index.html`. |
| 37 | +- `src/preload.js` should remain a narrow bridge and not gain business logic. |
| 38 | + |
| 39 | +## Architecture Guardrails |
| 40 | + |
| 41 | +Current intended structure: |
| 42 | + |
| 43 | +- `src/main/` |
| 44 | + - Electron runtime bootstrapping, IPC registration, services, infra |
| 45 | +- `src/shared/` |
| 46 | + - domain rules, normalization, data-shape helpers shared across layers |
| 47 | +- `src/renderer/` |
| 48 | + - renderer entrypoint and feature utilities |
| 49 | +- `tests/unit/` |
| 50 | + - pure logic and isolated helper tests |
| 51 | +- `tests/integration/` |
| 52 | + - service/integration tests with controlled fakes |
| 53 | +- `tests/e2e/` |
| 54 | + - Electron smoke and workflow checks |
| 55 | + |
| 56 | +When adding new code: |
| 57 | + |
| 58 | +- Put pure data logic in a testable module first. |
| 59 | +- Keep side effects at the edges. |
| 60 | +- Inject dependencies where practical for testability. |
| 61 | +- Favor explicit validation and errors over silent fallback when data is invalid. |
| 62 | + |
| 63 | +## Test-First Requirements |
| 64 | + |
| 65 | +Before implementing behavior changes: |
| 66 | + |
| 67 | +- Add unit tests for pure logic. |
| 68 | +- Add integration tests for filesystem, IPC, or service coordination. |
| 69 | +- Add or extend e2e coverage for critical user flows if the change affects runtime behavior. |
| 70 | + |
| 71 | +Minimum expectation by change type: |
| 72 | + |
| 73 | +- Pure helper/domain change: unit tests |
| 74 | +- Main-process service or IPC change: unit + integration tests |
| 75 | +- Renderer feature change: utility tests and, if behaviorally important, e2e or smoke coverage |
| 76 | +- Release/build/packaging change: verification via packaging smoke and relevant CI updates |
| 77 | + |
| 78 | +## Testing Rules |
| 79 | + |
| 80 | +- Never "fix" a test by removing meaningful assertions just to get green CI. |
| 81 | +- If a test reveals a bug, fix the underlying code. |
| 82 | +- Prefer deterministic tests using mocks, fakes, fixtures, and temp directories. |
| 83 | +- Avoid live external dependencies in tests. |
| 84 | +- Keep tests readable and behavior-focused. |
| 85 | + |
| 86 | +## Required Commands |
| 87 | + |
| 88 | +Use npm only in this repo. |
| 89 | + |
| 90 | +Primary commands: |
| 91 | + |
| 92 | +- `npm run build:styles` |
| 93 | +- `npm run lint` |
| 94 | +- `npm run typecheck` |
| 95 | +- `npm run test` |
| 96 | +- `npm run test:e2e` |
| 97 | +- `npm run package:smoke` |
| 98 | +- `npm run check` |
| 99 | + |
| 100 | +Before finishing a substantive change, run: |
| 101 | + |
| 102 | +- `npm run check` |
| 103 | + |
| 104 | +## Build And Runtime Notes |
| 105 | + |
| 106 | +- Start the app with `npm run dev` or `npm start`, not raw `electron .` |
| 107 | + - this ensures renderer styles are rebuilt first |
| 108 | +- Tailwind output is generated into `src/renderer/styles/main.css` |
| 109 | +- Do not reintroduce Tailwind CDN loading |
| 110 | +- Keep the stricter CSP in `src/index.html` |
| 111 | + |
| 112 | +## Environment Rules |
| 113 | + |
| 114 | +- Required env vars must be documented in `.env.example` |
| 115 | +- Validate required env at runtime before using it |
| 116 | +- Do not hardcode secrets |
| 117 | +- Do not commit `.env` |
| 118 | + |
| 119 | +## Release Integrity |
| 120 | + |
| 121 | +Any change that affects build, packaging, or runtime startup must keep these green: |
| 122 | + |
| 123 | +- lint |
| 124 | +- typecheck |
| 125 | +- unit/integration tests |
| 126 | +- Electron smoke test |
| 127 | +- packaging smoke |
| 128 | + |
| 129 | +Update `.github/workflows/ci.yml` if the required validation steps change. |
| 130 | + |
| 131 | +## Code Quality Expectations |
| 132 | + |
| 133 | +- Prefer composition over large monoliths. |
| 134 | +- Keep files focused. |
| 135 | +- Name modules by responsibility. |
| 136 | +- Write defensive normalization around persisted project/timeline data. |
| 137 | +- Add comments only where the logic is non-obvious. |
| 138 | +- Avoid dead code and stale compatibility layers unless intentionally retained. |
| 139 | + |
| 140 | +## Documentation Expectations |
| 141 | + |
| 142 | +Update docs when behavior or contributor workflow changes: |
| 143 | + |
| 144 | +- `docs/production/feature-inventory.md` |
| 145 | +- `docs/production/target-architecture.md` |
| 146 | +- `docs/production/runbook.md` |
| 147 | +- this file |
| 148 | + |
| 149 | +## If You Are Unsure |
| 150 | + |
| 151 | +Default to: |
| 152 | + |
| 153 | +- tests first |
| 154 | +- smaller modules |
| 155 | +- stricter validation |
| 156 | +- shared domain logic |
| 157 | +- full `npm run check` before completion |
0 commit comments