@anureo/code-review 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/LICENSE +201 -0
  2. package/bin/anureo-review.d.ts +2 -0
  3. package/bin/anureo-review.js +3 -0
  4. package/package.json +43 -4
  5. package/src/angles.d.ts +19 -0
  6. package/src/angles.js +217 -0
  7. package/src/cli.d.ts +27 -0
  8. package/src/cli.js +157 -0
  9. package/src/client.d.ts +18 -0
  10. package/src/client.js +54 -0
  11. package/src/errors.d.ts +27 -0
  12. package/src/errors.js +44 -0
  13. package/src/file-state.d.ts +13 -0
  14. package/src/file-state.js +24 -0
  15. package/src/fix-patch.d.ts +13 -0
  16. package/src/fix-patch.js +86 -0
  17. package/src/fix-tree.d.ts +25 -0
  18. package/src/fix-tree.js +43 -0
  19. package/src/fix.d.ts +37 -0
  20. package/src/fix.js +110 -0
  21. package/src/git-state.d.ts +9 -0
  22. package/src/git-state.js +23 -0
  23. package/src/git.d.ts +15 -0
  24. package/src/git.js +36 -0
  25. package/src/index.d.ts +36 -0
  26. package/src/index.js +30 -0
  27. package/src/options.d.ts +61 -0
  28. package/src/options.js +56 -0
  29. package/src/paths.d.ts +22 -0
  30. package/src/paths.js +46 -0
  31. package/src/progress.d.ts +30 -0
  32. package/src/progress.js +0 -0
  33. package/src/prompts.d.ts +42 -0
  34. package/src/prompts.js +104 -0
  35. package/src/report.d.ts +5 -0
  36. package/src/report.js +80 -0
  37. package/src/results.d.ts +69 -0
  38. package/src/results.js +0 -0
  39. package/src/review-execution.d.ts +52 -0
  40. package/src/review-execution.js +81 -0
  41. package/src/review-report.d.ts +21 -0
  42. package/src/review-report.js +30 -0
  43. package/src/review.d.ts +16 -0
  44. package/src/review.js +184 -0
  45. package/src/schema.d.ts +77 -0
  46. package/src/schema.js +47 -0
  47. package/src/validation.d.ts +21 -0
  48. package/src/validation.js +105 -0
  49. package/src/worktree.d.ts +23 -0
  50. package/src/worktree.js +117 -0
  51. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Yoichi
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bun
2
+ export {};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+ import { runCli } from "../src/cli.js";
3
+ process.exitCode = await runCli(process.argv.slice(2));
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "@anureo/code-review",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "Module-based parallel code review powered by Anureo workflows",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/hi-youichi/anureo-sdk.git",
9
+ "directory": "apps/code-review"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "type": "module",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./src/index.d.ts",
18
+ "import": "./src/index.js",
19
+ "default": "./src/index.js"
20
+ }
21
+ },
22
+ "bin": {
23
+ "anureo-review": "./bin/anureo-review.js"
24
+ },
25
+ "dependencies": {
26
+ "@anureo/adapter-claude": "0.3.0",
27
+ "@anureo/adapter-codex": "0.3.0",
28
+ "@anureo/adapter-hermes": "0.3.0",
29
+ "@anureo/adapter-pi": "0.3.0",
30
+ "@anureo/sdk": "0.3.0",
31
+ "@anureo/workflow": "0.3.0",
32
+ "zod": "4.6.7"
33
+ },
34
+ "engines": {
35
+ "node": ">=22",
36
+ "bun": ">=1.4.2"
37
+ },
38
+ "files": [
39
+ "src",
40
+ "bin",
41
+ "schema",
42
+ "protocol",
43
+ "examples"
44
+ ]
45
+ }
@@ -0,0 +1,19 @@
1
+ /** Supply a review perspective through ReviewOptions.angles; reviewCode copies and validates
2
+ * the selection before analysis and retains its order in each module's angle results. */
3
+ export interface ReviewAngle {
4
+ /** Stable identity, unique within the selection, nonblank and at most 256 UTF-8 bytes. */
5
+ id: string;
6
+ /** Nonblank display label included in prompts and reports. */
7
+ title: string;
8
+ /** Nonblank guidance included verbatim in both review and verification tasks. */
9
+ instructions: string;
10
+ }
11
+ /** Review concrete behavior, contract violations and lifecycle failures. */
12
+ export declare const correctnessAngle: ReviewAngle;
13
+ /** Review obstacles to understanding and safely changing the implementation. */
14
+ export declare const codeQualityAngle: ReviewAngle;
15
+ /** Review responsibility, contract, state and dependency ownership. */
16
+ export declare const designAngle: ReviewAngle;
17
+ /** Default perspectives when ReviewOptions.angles is omitted, in report order. Preflight
18
+ * copies the angle records before dispatch. The CLI also uses these IDs for --angle selection. */
19
+ export declare const defaultAngles: readonly ReviewAngle[];
package/src/angles.js ADDED
@@ -0,0 +1,217 @@
1
+ /** Review concrete behavior, contract violations and lifecycle failures. */
2
+ export const correctnessAngle = {
3
+ id: 'correctness',
4
+ title: 'Correctness',
5
+ instructions: `Goal: find concrete incorrect behavior, broken contracts, reachable
6
+ edge cases, races, and resource lifecycle failures.
7
+
8
+ Investigation:
9
+ Trace an actual entry point through its callers, dependencies, state mutations,
10
+ outputs, and tests. Inspect the dependency implementation or declared contract
11
+ when behavior depends on return values, cancellation, error propagation, or replay.
12
+ Compare equivalent paths across commands, backends, and library versus CLI entry
13
+ points. Follow failure paths as carefully as successful execution.
14
+
15
+ Checks:
16
+ - State and concurrency: inspect mutations before and after each await, admission
17
+ and dispatch ordering, shared stop flags, partial effects, deterministic output
18
+ where required, and cleanup after failure or cancellation. A sibling's failure
19
+ must not be mistaken for this task's execution outcome.
20
+ - Error propagation: trace null results, rejected tasks, empty catches, and broad
21
+ fallback handlers. Check that causes survive aggregation, systemic failures stop
22
+ unsafe or futile dispatch, and programming errors are not treated as correctable
23
+ user or model input. Trace error codes, retryability, fatality, and outcome
24
+ certainty through wrappers, persisted records, reports, and consumers; retaining
25
+ a message alone may discard information needed for a correct decision.
26
+ Check existing retry and partial-success contracts.
27
+ - Trust boundaries: follow external data through parsing, authorization, and
28
+ rendering. Type assertions and prompt instructions do not enforce a contract.
29
+ Check actual read/write scope controls, context-sensitive output encoding, and
30
+ whether validators establish their advertised guarantees. An incomplete index
31
+ cannot prove a real symbol absent; a substring match alone may not establish an
32
+ exact source location. Check consistent path and LF/CRLF handling end to end.
33
+ Compare granted tools and readable/writable resources with the task's needs and
34
+ stated restrictions. Check whether claimed restrictions are enforceable and
35
+ violations observable; audit records do not replace access control.
36
+ - Completion and reporting: follow required fields, coverage gaps, skipped work,
37
+ and errors into summaries, status, exit codes, and user-visible reports. Check
38
+ for information discarded while success is still claimed. Separate host facts,
39
+ model assertions, confirmed effects, and unknown execution outcomes.
40
+ - Capacity and time: inspect the entire encoded input, auxiliary metadata, final
41
+ aggregation, subprocess buffers, and fallback payloads against actual limits.
42
+ Check known constraints before expensive dispatch. Distinguish an operation or
43
+ observation timeout from a deadline that actually bounds external execution.
44
+ - Recovery and side effects: trace both writers and restart readers. Check cache
45
+ misses versus corruption, stale dependencies, repeatability, and attribution of
46
+ observed changes. Inspect whether generated artifacts can enter normal source
47
+ discovery or version control under the tool's default behavior.
48
+
49
+ Findings:
50
+ Explain the reachable preconditions, causal code path, actual versus expected
51
+ behavior, violated invariant, and impact. A complete static trace is sufficient;
52
+ do not claim a reproduction, incident, or measured cost that was not observed.
53
+ Do not report style preferences, unsupported risks, or feature requests. Return
54
+ no findings when the inspected paths support no correctness defect.`,
55
+ };
56
+ /** Review obstacles to understanding and safely changing the implementation. */
57
+ export const codeQualityAngle = {
58
+ id: 'code-quality',
59
+ title: 'Code Quality',
60
+ instructions: `Goal: find concrete obstacles to understanding and safely changing
61
+ the implementation. Demonstrated reading or editing costs are valid findings even
62
+ without a runtime bug; use the maintenance task as the triggering scenario.
63
+
64
+ Investigation:
65
+ Read complete functions, relevant callers, sibling implementations, tests, and
66
+ public usage documentation. Choose a task such as changing a default, understanding
67
+ a failure, adding a result state, or locating a reported artifact. Follow the
68
+ actual reading path and identify what must be remembered or edited together.
69
+
70
+ Checks:
71
+ - Expression: dense multi-statement lines, unnamed compound conditions, positional
72
+ booleans, deep nesting, and large closures that obscure distinct steps or failure
73
+ decisions. Explain the hidden meaning, not just a line count.
74
+ - Intent and terminology: inconsistent names for the same concept, one name for
75
+ different concepts, outdated public wording, misleading optional access, and
76
+ missing explanations of invariants, status transitions, compatibility choices,
77
+ timeout relationships, preconditions, return semantics, or thrown errors.
78
+ - Rules and constants: compare path checks, defaults, budget formulas, version
79
+ markers, error classification, and serialization helpers across all relevant
80
+ entry points. Identify shared semantics, actual divergence, and the places a
81
+ change must update. Check unexplained magic values and repeated normalization.
82
+ - Local data flow: hidden mutation inside map/filter callbacks, successive field
83
+ overwrites, non-null assertions whose justification is distant, and public
84
+ inferred types that force consumers to inspect an implementation. Explain the
85
+ specific reasoning burden rather than banning a language construct.
86
+ - Redundancy: repeated validation of already established facts, unused fields or
87
+ exports, write-only data, constant placeholders, no-op catches/rethrows, and
88
+ repeated conversion of immutable schemas. Search production, generated, public,
89
+ and compatibility uses before declaring code dead; test-only use is a clue.
90
+ - Test feedback: inspect whether pure rules can only be exercised through a full
91
+ process, fixtures omit relevant failure/state combinations, message assertions
92
+ couple tests to wording, or real sleeps make ordering assumptions. Identify the
93
+ behavior a missing or weak assertion would fail to distinguish; do not infer a
94
+ production bug merely from missing coverage.
95
+ - Automated safeguards: when concrete recurring formatting, complexity, import,
96
+ or unused-code problems are demonstrated, inspect whether maintained local and
97
+ CI checks detect them. Explain the recurrence and prevention gap before proposing
98
+ a guardrail; an absent tool or a preferred tool choice alone is not a defect.
99
+ - Validation feedback: inspect whether independent input or response issues can
100
+ be reported together instead of consuming one correction round per issue. Check
101
+ field locations, actual versus expected values, and useful repair guidance.
102
+ Respect checks that depend on earlier parsing or must stop for safety.
103
+ - User-facing clarity and engineering claims: compare help, defaults, dry-run
104
+ estimates, scripts, package exports, runtime declarations, and emitted artifacts
105
+ with their implementations. Check actionable errors, failure-time artifact
106
+ locations, consistent naming/language, and reports organized for decisions rather
107
+ than raw internal records. Passing on one runtime does not prove full support.
108
+ - Published usability: follow the declared package entry points, executable paths,
109
+ included files, and documentation from a consumer's installed-package context.
110
+ Check that necessary usage guidance and referenced resources are shipped or
111
+ discoverable, rather than available only in the repository. Judge build scripts
112
+ against the declared source or compiled distribution strategy; do not require
113
+ transpilation or a particular documentation filename without a consumer need.
114
+
115
+ Findings:
116
+ Explain the maintenance task, exact obstacle and affected locations, resulting
117
+ cost, and smallest behavior-preserving improvement. Describe how the proposed
118
+ change reduces tracing, edit locations, or ambiguity. Share code only when its
119
+ semantics and reasons to change match; similar syntax alone is insufficient.
120
+ Missing comments, formatting tools, JSDoc, or a preferred style are not standalone
121
+ defects. Do not prescribe abstractions just to shorten code or tests that mirror
122
+ implementation. Focus on local clarity and consistency; structural ownership
123
+ changes belong to design, and concrete behavior failures belong to correctness.
124
+ Return no findings when the actual maintenance tasks are already clear.`,
125
+ };
126
+ /** Review responsibility, contract, state and dependency ownership. */
127
+ export const designAngle = {
128
+ id: 'design',
129
+ title: 'Design',
130
+ instructions: `Goal: find structural problems in responsibility, contract, state,
131
+ and dependency ownership. Concrete maintenance or change-propagation costs are
132
+ valid findings without a runtime bug. Use a supported change scenario rather than
133
+ an invented future requirement.
134
+
135
+ Investigation:
136
+ Map a real operation from entry point through application coordination, domain
137
+ decisions, state/effects, external adapters, persistence, and result consumers.
138
+ Identify participants, authoritative rules, and state owners before recommending
139
+ boundaries. Inspect callers and sibling flows across modules as context; do not
140
+ infer missing collaboration from a directory listing or an incomplete index.
141
+
142
+ Checks:
143
+ - Responsibilities and dependencies: look for orchestration, model interaction,
144
+ validation, domain decisions, I/O, prompts, and rendering changing for unrelated
145
+ reasons inside one owner. Check misplaced shared helpers, infrastructure that
146
+ knows presentation policy, configuration/dependencies/control callbacks mixed
147
+ together, and CLI-specific restrictions embedded in general library primitives.
148
+ Distinguish source dependency direction from the runtime call direction.
149
+ - Contracts and domain rules: trace each producer to its consumers. Check parallel
150
+ schema/type definitions, copied upstream policies, and domain invariants spread
151
+ across validators, aggregators, and repair code. Identify who should own the
152
+ rule, its versioning, and the consumer-specific subset or projection.
153
+ - State and lifecycle: check representable contradictory states, redundant fields
154
+ encoding the same fact, bag objects accumulating unrelated lifecycle data, and
155
+ shared closures acting as an implicit stateful object. Distinguish immutable
156
+ configuration/plans from mutable progress, task outcomes, and global control.
157
+ - Failure policy: distinguish expected branches, correctable responses, programming
158
+ errors, local failures, systemic failures, and unknown outcomes. Check whether
159
+ failure scope matches its cause, partial work survives, and concurrent results
160
+ carry their own causes instead of relying on side-channel variables. Follow
161
+ structured error metadata across layer boundaries and persisted projections;
162
+ identify the consumer that needs codes, retryability, fatality, or outcome
163
+ certainty. Check whether correction protocols collect independent validation
164
+ issues and preserve actionable diagnostics within their correction budget.
165
+ - Trust and normalization: establish the owner of boundary parsing, permissions,
166
+ evidence validation, output encoding, and text/path normalization. Check redundant
167
+ defensive validation without a trusted representation or a clear guarantee.
168
+ Preserve necessary integrity and freshness checks when data crosses a new
169
+ boundary or can change; do not simply remove all repeated checks.
170
+ Compare necessary capabilities with granted tools and resource access. Identify
171
+ who enforces restrictions and who records violations or verifies claimed checks;
172
+ least privilege, enforcement, and auditability are separate responsibilities.
173
+ - Persistence and identity: follow both writes and actual restart loads. Separate
174
+ authoritative records from reports and diagnostic projections. Check duplicate
175
+ full payloads, ambiguous copies, competing locks/fingerprints, and whether cache
176
+ keys identify immutable content or incidental reads. Account for repeated reads
177
+ and resumes, not only one successful execution.
178
+ - Recovery: distinguish cache miss, missing material, integrity mismatch, stale
179
+ dependencies, and uncertain side effects. Check whether defaults match the
180
+ operation's repeatability and whether one stale item unnecessarily invalidates
181
+ unrelated work. Explain when re-execution is safe rather than prescribing it.
182
+ Trace which source, configuration, prompt, schema, model, and backend changes
183
+ invalidate saved results under the declared reuse contract. Distinguish storage
184
+ format versions from behavior revisions, and identify the coverage of each
185
+ fingerprint. Check both accidental stale reuse and unnecessary invalidation;
186
+ do not reject intentionally compatible reuse solely because a version changed.
187
+ - Capacity and resources: account separately for primary input, auxiliary indexes,
188
+ encoding overhead, retries, stored copies, and final aggregation. Check that
189
+ scope limits expensive preparation, fixed-size calls have a feasible batching
190
+ strategy, and degradation paths themselves fit the limits. Identify the actual
191
+ growth variable and bottleneck; do not invent thresholds or measured costs.
192
+ Check ownership of execution deadlines, cancellation, and resource release.
193
+ - Protocols and observability: trace every required field to a consumer, including
194
+ gaps and partial results. Check completion semantics and whether progress shows
195
+ work remaining rather than an incidental queue. For model protocols, inspect
196
+ remaining budgets, predictable dependency context, actionable correction
197
+ feedback, short references, and unnecessary nested encoding. Keep deterministic
198
+ identity resolution and verification with the host where appropriate.
199
+ - Testability: inspect whether pure decisions can be tested without infrastructure
200
+ and whether external services, environment, clocks, and identifiers are explicit
201
+ and controllable where needed. Connect a boundary change to a concrete test or
202
+ maintenance scenario; dependency injection is not an end in itself.
203
+
204
+ Findings:
205
+ Name the current owners and collaboration, the affected consumer or supported
206
+ change scenario, the invariant or propagation cost, and a focused alternative.
207
+ Compare local simplification with introducing a new boundary, including added
208
+ indirection, compatibility, and the guarantee that must be preserved.
209
+ Do not infer defects from missing classes, interfaces, patterns, layers, or folder
210
+ names. Preserve sound existing designs; do not fill a quota or demand broad rewrites.
211
+ Keep expression issues in code quality and runtime defects in correctness. Report
212
+ a related structural cause here only when it warrants a distinct design change.
213
+ Return no findings when there is no supported structural improvement.`,
214
+ };
215
+ /** Default perspectives when ReviewOptions.angles is omitted, in report order. Preflight
216
+ * copies the angle records before dispatch. The CLI also uses these IDs for --angle selection. */
217
+ export const defaultAngles = [correctnessAngle, codeQualityAngle, designAngle];
package/src/cli.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import type { Client } from '@anureo/sdk';
2
+ import { type ReviewHarness } from "./client.js";
3
+ /** Run the CLI with arguments following the executable name. The bin entry point awaits the result
4
+ * and assigns it to process.exitCode. Returns 0 for help or a complete review without findings,
5
+ * 1 for a complete review with findings, and 2 for incomplete coverage or reported errors.
6
+ * Help and CLI parsing failures acquire no backend. When a report is available, it is written
7
+ * before client disposal. The command awaits disposal before settling once a client is acquired.
8
+ * A failure to emit the final diagnostic can reject.
9
+ */
10
+ export declare function runCli(args: string[], dependencies?: CliDependencies): Promise<number>;
11
+ /** Internal execution seams for runCli; omitted hooks use the production client and process streams. */
12
+ interface CliDependencies {
13
+ /** Receives the canonical directory and selected backend after preflight. runCli owns the returned
14
+ * initialized client and awaits its disposal, including after review or report-output failure. */
15
+ createClient?: (cwd: string, harness: ReviewHarness) => Promise<Client>;
16
+ /** Synchronously consume help or the final report. Throws become CLI errors. */
17
+ stdout?: (text: string) => void;
18
+ /** Synchronously consume progress and diagnostics. Progress throws are retained in the report;
19
+ * diagnostic throws can reject runCli. */
20
+ stderr?: (text: string) => void;
21
+ /** Fallback when no positional directory is supplied; defaults to process.cwd(). Does not chdir. */
22
+ cwd?: string;
23
+ /** Supplies only the CODEX_MODEL fallback when --model is omitted; defaults to process.env.
24
+ * Built-in adapter factories still read process.env. */
25
+ env?: Record<string, string | undefined>;
26
+ }
27
+ export {};