@@ -48,6 +48,20 @@ Minimal operating guide for AI coding agents in this repo.
4848- Use ` inferFillText ` and ` uniqueStrings ` from ` src/daemon/action-utils.ts ` . Do not duplicate.
4949- Use ` evaluateIsPredicate ` from ` src/daemon/is-predicates.ts ` for assertion logic. Do not inline.
5050
51+ ## Diagnostics & Errors
52+
53+ - Use ` src/utils/diagnostics.ts ` as the diagnostics source of truth:
54+ - ` withDiagnosticsScope `
55+ - ` emitDiagnostic `
56+ - ` withDiagnosticTimer `
57+ - ` flushDiagnosticsToSessionFile `
58+ - Do not add ad-hoc stderr/file logging in handlers/platform modules when diagnostics helpers can be used.
59+ - Normalize user-facing failures through ` src/utils/errors.ts ` (` normalizeError ` ).
60+ - Failure payload contract should include: ` code ` , ` message ` , ` hint ` , ` diagnosticId ` , ` logPath ` , ` details ` .
61+ - When wrapping/rethrowing daemon errors (batch/replay/handler wrappers), preserve ` hint ` , ` diagnosticId ` , and ` logPath ` from inner errors.
62+ - ` --debug ` is canonical; ` --verbose ` remains backward-compatible alias.
63+ - Keep redaction centralized in ` src/utils/diagnostics.ts ` ; do not duplicate redaction logic in handlers/CLI.
64+
5165## Key Files
5266- CLI parse + formatting: ` src/bin.ts ` , ` src/cli.ts ` , ` src/utils/args.ts `
5367- Daemon client transport: ` src/daemon-client.ts `
@@ -56,7 +70,7 @@ Minimal operating guide for AI coding agents in this repo.
5670- ` is ` predicate evaluation: ` src/daemon/is-predicates.ts `
5771- Shared action helpers: ` src/daemon/action-utils.ts `
5872- Snapshot shaping + labels: ` src/daemon/snapshot-processing.ts `
59- - Handler context helpers: ` src/daemon/context.ts ` , ` src/daemon/device-ready.ts ` , ` src/daemon/app-state.ts `
73+ - Handler context helpers: ` src/daemon/context.ts ` , ` src/daemon/device-ready.ts `
6074- Dispatcher and capability source of truth: ` src/core/dispatch.ts ` , ` src/core/capabilities.ts `
6175- Platform backends: ` src/platforms/ios/* ` , ` ios-runner/* ` , ` src/platforms/android/* `
6276
@@ -93,16 +107,12 @@ Run integration tests when behavior crosses platform boundaries:
93107- ` pnpm test:integration `
94108
95109## Measurement
96- - Use ` docs/daemon-refactor-impact.md ` .
97110- Track files touched per fix, cycle time, and iOS/Android regressions.
98111
99112## Local Commands
100113
101114- Run CLI: ` pnpm ad <command> `
102- - Typecheck: ` pnpm typecheck `
103- - Unit tests: ` pnpm test:unit `
104- - Smoke tests: ` pnpm test:smoke `
105- - Integration tests: ` pnpm test:integration `
115+ - For verification commands, use the ** Testing** section above.
106116
107117## Pull Requests
108118- Before opening PR: ensure no conflict markers and no unmerged paths.
0 commit comments