@buyong/pi-codex-auto-review 0.0.0-stage → 0.2.2

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 (133) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +12 -0
  3. package/README.ko.md +85 -0
  4. package/README.md +84 -2
  5. package/dist/approval-commands.d.ts +4 -0
  6. package/dist/approval-commands.js +230 -0
  7. package/dist/approval-commands.js.map +1 -0
  8. package/dist/approval-settings.d.ts +9 -0
  9. package/dist/approval-settings.js +47 -0
  10. package/dist/approval-settings.js.map +1 -0
  11. package/dist/approvals.d.ts +73 -0
  12. package/dist/approvals.js +288 -0
  13. package/dist/approvals.js.map +1 -0
  14. package/dist/audit.d.ts +28 -0
  15. package/dist/audit.js +64 -0
  16. package/dist/audit.js.map +1 -0
  17. package/dist/cli.d.ts +2 -0
  18. package/dist/cli.js +99 -0
  19. package/dist/cli.js.map +1 -0
  20. package/dist/context-files.d.ts +14 -0
  21. package/dist/context-files.js +134 -0
  22. package/dist/context-files.js.map +1 -0
  23. package/dist/contracts.d.ts +260 -0
  24. package/dist/contracts.js +168 -0
  25. package/dist/contracts.js.map +1 -0
  26. package/dist/index.d.ts +28 -0
  27. package/dist/index.js +191 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/pi-host.d.ts +2 -0
  30. package/dist/pi-host.js +7 -0
  31. package/dist/pi-host.js.map +1 -0
  32. package/dist/policy/domains.d.ts +5 -0
  33. package/dist/policy/domains.js +28 -0
  34. package/dist/policy/domains.js.map +1 -0
  35. package/dist/policy/index.d.ts +55 -0
  36. package/dist/policy/index.js +521 -0
  37. package/dist/policy/index.js.map +1 -0
  38. package/dist/policy/paths.d.ts +5 -0
  39. package/dist/policy/paths.js +67 -0
  40. package/dist/policy/paths.js.map +1 -0
  41. package/dist/policy/rule-engine.d.ts +2 -0
  42. package/dist/policy/rule-engine.js +283 -0
  43. package/dist/policy/rule-engine.js.map +1 -0
  44. package/dist/policy/rule-types.d.ts +30 -0
  45. package/dist/policy/rule-types.js +2 -0
  46. package/dist/policy/rule-types.js.map +1 -0
  47. package/dist/policy/rules-sync.d.ts +1 -0
  48. package/dist/policy/rules-sync.js +14 -0
  49. package/dist/policy/rules-sync.js.map +1 -0
  50. package/dist/policy/rules-worker.d.ts +1 -0
  51. package/dist/policy/rules-worker.js +14 -0
  52. package/dist/policy/rules-worker.js.map +1 -0
  53. package/dist/policy/rules.d.ts +9 -0
  54. package/dist/policy/rules.js +149 -0
  55. package/dist/policy/rules.js.map +1 -0
  56. package/dist/policy/shell.d.ts +14 -0
  57. package/dist/policy/shell.js +151 -0
  58. package/dist/policy/shell.js.map +1 -0
  59. package/dist/policy/starlark/builtins.d.ts +6 -0
  60. package/dist/policy/starlark/builtins.js +764 -0
  61. package/dist/policy/starlark/builtins.js.map +1 -0
  62. package/dist/policy/starlark/evaluator.d.ts +18 -0
  63. package/dist/policy/starlark/evaluator.js +518 -0
  64. package/dist/policy/starlark/evaluator.js.map +1 -0
  65. package/dist/policy/starlark/lexer.d.ts +14 -0
  66. package/dist/policy/starlark/lexer.js +189 -0
  67. package/dist/policy/starlark/lexer.js.map +1 -0
  68. package/dist/policy/starlark/parser.d.ts +140 -0
  69. package/dist/policy/starlark/parser.js +508 -0
  70. package/dist/policy/starlark/parser.js.map +1 -0
  71. package/dist/policy/starlark/validation.d.ts +4 -0
  72. package/dist/policy/starlark/validation.js +183 -0
  73. package/dist/policy/starlark/validation.js.map +1 -0
  74. package/dist/policy/starlark/values.d.ts +46 -0
  75. package/dist/policy/starlark/values.js +363 -0
  76. package/dist/policy/starlark/values.js.map +1 -0
  77. package/dist/reports.d.ts +21 -0
  78. package/dist/reports.js +78 -0
  79. package/dist/reports.js.map +1 -0
  80. package/dist/review/context.d.ts +38 -0
  81. package/dist/review/context.js +314 -0
  82. package/dist/review/context.js.map +1 -0
  83. package/dist/review/investigation.d.ts +39 -0
  84. package/dist/review/investigation.js +77 -0
  85. package/dist/review/investigation.js.map +1 -0
  86. package/dist/review/lifecycle.d.ts +29 -0
  87. package/dist/review/lifecycle.js +114 -0
  88. package/dist/review/lifecycle.js.map +1 -0
  89. package/dist/review/policy.d.ts +4 -0
  90. package/dist/review/policy.js +37 -0
  91. package/dist/review/policy.js.map +1 -0
  92. package/dist/review/upstream-policy.d.ts +2 -0
  93. package/dist/review/upstream-policy.js +210 -0
  94. package/dist/review/upstream-policy.js.map +1 -0
  95. package/dist/review/user-input.d.ts +5 -0
  96. package/dist/review/user-input.js +54 -0
  97. package/dist/review/user-input.js.map +1 -0
  98. package/dist/reviewer.d.ts +55 -0
  99. package/dist/reviewer.js +336 -0
  100. package/dist/reviewer.js.map +1 -0
  101. package/dist/signals.d.ts +10 -0
  102. package/dist/signals.js +36 -0
  103. package/dist/signals.js.map +1 -0
  104. package/dist/startup.d.ts +22 -0
  105. package/dist/startup.js +198 -0
  106. package/dist/startup.js.map +1 -0
  107. package/dist/tools/controller.d.ts +72 -0
  108. package/dist/tools/controller.js +644 -0
  109. package/dist/tools/controller.js.map +1 -0
  110. package/dist/tools/environment.d.ts +2 -0
  111. package/dist/tools/environment.js +11 -0
  112. package/dist/tools/environment.js.map +1 -0
  113. package/dist/tools/executor.d.ts +14 -0
  114. package/dist/tools/executor.js +92 -0
  115. package/dist/tools/executor.js.map +1 -0
  116. package/dist/tools/external.d.ts +31 -0
  117. package/dist/tools/external.js +35 -0
  118. package/dist/tools/external.js.map +1 -0
  119. package/dist/tools/mcp.d.ts +17 -0
  120. package/dist/tools/mcp.js +317 -0
  121. package/dist/tools/mcp.js.map +1 -0
  122. package/dist/tools/mutation-queue.d.ts +1 -0
  123. package/dist/tools/mutation-queue.js +16 -0
  124. package/dist/tools/mutation-queue.js.map +1 -0
  125. package/docs/publishing.ko.md +127 -0
  126. package/docs/publishing.md +127 -0
  127. package/docs/security/dependencies.ko.md +54 -0
  128. package/docs/security/dependencies.md +54 -0
  129. package/docs/testing/auto-review-protection.ko.md +158 -0
  130. package/docs/testing/auto-review-protection.md +158 -0
  131. package/docs/usage.ko.md +242 -0
  132. package/docs/usage.md +242 -0
  133. package/package.json +76 -5
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 2025 OpenAI
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.
package/NOTICE ADDED
@@ -0,0 +1,12 @@
1
+ pi-codex-auto-review includes a TypeScript port of the execution policy
2
+ contracts and the guardian policy from OpenAI Codex, revision
3
+ a956835d020762cb2b570053af06f643a11c0ecc. The rule interpreter and evaluator
4
+ run as JavaScript; the upstream Rust library and binaries are not bundled.
5
+ The upstream attribution notice is reproduced below.
6
+
7
+ OpenAI Codex
8
+ Copyright 2025 OpenAI
9
+
10
+ This project includes code derived from [Ratatui](https://github.com/ratatui/ratatui), licensed under the MIT license.
11
+ Copyright (c) 2016-2022 Florian Dehau
12
+ Copyright (c) 2023-2025 The Ratatui Developers
package/README.ko.md ADDED
@@ -0,0 +1,85 @@
1
+ # pi-codex-auto-review
2
+
3
+ [English](README.md) | **한국어**
4
+
5
+ Codex의 ‘Approve for me’에서 영감을 받은 Pi 자동 실행 승인 검토 확장입니다. 승인 요청을 규칙과 보조 모델로 검토하거나 사용자가 직접 승인하도록 설정합니다. 승인된 도구는 Pi의 원래 실행기로 실행합니다. OS 샌드박스나 파일·네트워크 격리를 구성하지 않습니다. Codex 공개 소스 [`rust-v0.160.0`](https://github.com/openai/codex/tree/a956835d020762cb2b570053af06f643a11c0ecc)의 공개 승인 정책을 참고했습니다.
6
+
7
+ ## 설치
8
+
9
+ `0.2.0`은 네이티브 규칙 실행 파일을 TypeScript 엔진으로 교체해 JavaScript로 배포하고, `vendor`의 재포장 Pi SDK를 제거합니다. 이 확장에는 Rust 컴파일러나 플랫폼별 규칙 바이너리가 필요하지 않습니다. Node.js와 Pi 호스트는 계속 필요하며, Pi 자체의 네이티브 모듈은 별개입니다.
10
+
11
+ ```sh
12
+ pi install npm:@buyong/pi-codex-auto-review@0.2.2
13
+ pi list
14
+ ```
15
+
16
+ 확장 로딩 실패를 Pi가 무시할 수 있으므로 보호 시작이 필수인 실행은 [사용법](docs/usage.ko.md)의 CLI·SDK 진입점을 사용합니다.
17
+
18
+ ## 동작 흐름
19
+
20
+ 1. **정책 판단** — 절대 차단 경로와 `commandRules`를 먼저 평가합니다. 차단 경로는 모델 검토나 저장 승인으로 해제하지 않습니다.
21
+ 2. **자동 검토** — 남은 작업은 검토 모델이 위험 등급과 결과를 판정합니다.
22
+ 3. **승인** — 남은 범위는 사용자가 확정합니다.
23
+ 4. **Pi 실행** — 승인된 작업을 원래 SDK 도구로 실행하며 취소 신호와 호출자 옵션을 전달합니다.
24
+
25
+ ## 승인 설정
26
+
27
+ - `/approve`: **Approve for me**(보조 모델 검토) 또는 **Ask for approval**(사용자 승인)을 선택합니다.
28
+ - `/approve-model`: Pi의 현재 `/scoped-models` 범위에서 등록된 모델을 검색해 보조 검토 모델을 선택합니다. **Use current Pi model**로 현재 주 모델을 사용하도록 되돌릴 수 있습니다.
29
+
30
+ 선택은 `<agentDir>/guard/settings.json`에 저장되고 다음 실행에도 적용됩니다. 주 대화 모델은 바뀌지 않습니다. 취소하면 기존 설정을 유지합니다.
31
+
32
+ ## 요구 사항
33
+
34
+ | 항목 | 요구 |
35
+ | --- | --- |
36
+ | Node.js | 22.19 이상 |
37
+ | Pi | 0.99.1 또는 1.0.0 |
38
+ | 현재 소스 빌드 | TypeScript 사용. Rust 컴파일러와 플랫폼별 규칙 실행 파일 불필요 |
39
+ | 규칙 실행 | 비동기 평가는 Node.js 작업 스레드, 동기 API는 Node.js 자식 프로세스 |
40
+
41
+ ## 보호 경계
42
+
43
+ - 모드는 `workspace-write`(작업 공간과 기본 임시 경로 쓰기 허용)와 `read-only`입니다.
44
+ - 제어·인증 경로와 프로젝트의 `.pi` 설정·확장 코드, 신뢰한 확장의 코드 디렉터리는 모델 쓰기를 절대 차단합니다.
45
+ - 일반 범위를 넘는 파일 접근, 검토 규칙, 해석하지 못하는 명령은 실행 전에 검토합니다. 읽기와 기존 범위 안의 일반 작업은 정책에 따라 실행합니다.
46
+ - 승인은 한 번, 세션, 규칙 저장 중 선택하며, 저장 승인은 정확한 도구·입력·정책에 묶입니다.
47
+ - 자동 검토는 기본적으로 현재 모델로 수행하고, 반복 거부되면 실제 작업을 중단합니다. 검토 오류는 승인으로 바뀌지 않습니다.
48
+ - MCP 도구 승인과 프로젝트 지침 탐색도 같은 신뢰·검토 경계 안에 둡니다.
49
+
50
+ 각 결합 조건과 설정은 [사용법](docs/usage.ko.md) 문서에 있습니다.
51
+
52
+ ## 한계와 비보장
53
+
54
+ - 승인된 셸과 인터프리터는 호스트 권한으로 실행합니다. 검토에 표시한 파일·도메인 범위는 OS가 강제하는 접근 제한이 아닙니다.
55
+ - 재귀 디렉터리 탐색·하드링크 전수 검사·네트워크 프록시를 구성하지 않습니다. 간접 파일 접근과 실행 중 목적지 변경을 격리하지 않습니다.
56
+ - Pi, 신뢰한 확장 코드와 외부 MCP 서버의 내부 실행은 신뢰 경계에 포함됩니다.
57
+ - 이미 MCP 서버에 전달한 요청의 취소 효과는 외부 공급자의 구현에 달려 있습니다.
58
+ - 공개 정책·흐름의 호환성 검증은 독점 Codex 모델과 모든 판단이 같다는 뜻이 아닙니다.
59
+ - 별도로 설치한 Pi 호스트의 의존성을 자동으로 교체하지 않습니다. 이 저장소의 조치 근거는 [의존성 보안](docs/security/dependencies.ko.md) 문서에 있습니다.
60
+
61
+ ## 검증
62
+
63
+ ```sh
64
+ npm run verify:guard
65
+ ```
66
+
67
+ `verify:guard`는 빌드와 현재 운영체제의 전체 로컬 검증을 실행합니다. 다른 운영체제와 실모델의 결과는 별도 실행 근거로 기록하며 로컬 통과로 대신하지 않습니다.
68
+
69
+ - `npm run test:*` 단일 검증은 실제 자격 증명이나 유료 모델을 사용하지 않습니다. 환경 제한·의존성 부재는 통과로 처리하지 않습니다.
70
+ - `npm run verify:platform`은 현재 운영체제의 전체 검증을 실행합니다.
71
+ - GitHub Actions의 `자동 검토 운영체제 검증`은 실제 Linux x64 검사와 Docker 이미지·결과 반출을 수행합니다. workflow에는 Ollama 키를 전달하지 않습니다.
72
+ - Windows의 `verify:windows`는 규칙 엔진·승인 정책·파일 실행과 취소를 검증합니다. 전체 셸 실행 지원을 검증하는 명령은 아닙니다.
73
+ - Docker 컨테이너 검증 활용은 [사용법의 Docker 절](docs/usage.ko.md#docker에서-ollama-cloud-검증)에 있습니다.
74
+ - 각 실행은 `.reports/pi-guard/runs/<실행 ID>/<플랫폼>/`에 저장되고, 보호·허용·차단 사례는 [보호 경계 검증표](docs/testing/auto-review-protection.ko.md)에 있습니다.
75
+
76
+ ## 문서
77
+
78
+ - [사용법](docs/usage.ko.md) · [English](docs/usage.md) — 설치, 소스 빌드, CLI·SDK, 정책, Docker 검증
79
+ - [배포 안내](docs/publishing.ko.md) · [English](docs/publishing.md) — `pnpm release`, npm Trusted Publishing, GitHub Actions
80
+ - [의존성 보안](docs/security/dependencies.ko.md) · [English](docs/security/dependencies.md) — 감사 항목, 수정 근거와 적용 범위
81
+ - [보호 경계 검증](docs/testing/auto-review-protection.ko.md) · [English](docs/testing/auto-review-protection.md) — 허용·차단 사례, 실패, 취소와 미검증 범위
82
+
83
+ ## 라이선스
84
+
85
+ [Apache-2.0](LICENSE). Codex 규칙 계약의 TypeScript 이식과 포함된 정책의 출처 표시는 [NOTICE](NOTICE)에 유지합니다.
package/README.md CHANGED
@@ -1,3 +1,85 @@
1
- # Temporary Holding Version
1
+ # pi-codex-auto-review
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **English** | [한국어](README.ko.md)
4
+
5
+ A Pi extension for automatic execution approval review, inspired by Codex's “Approve for me”. Review approval requests with rules and a secondary model, or ask the user to approve them. Approved tools run through Pi's original executor. The extension does not configure an OS sandbox or file and network isolation. It draws on the public approval policies in Codex [`rust-v0.160.0`](https://github.com/openai/codex/tree/a956835d020762cb2b570053af06f643a11c0ecc).
6
+
7
+ ## Installation
8
+
9
+ Version `0.2.0` replaces the native rule executables with a TypeScript engine distributed as JavaScript and removes the repackaged Pi SDK under `vendor`. The extension requires no Rust compiler or platform-specific rule binary. Node.js and the Pi host are still required; Pi's own native modules are separate.
10
+
11
+ ```sh
12
+ pi install npm:@buyong/pi-codex-auto-review@0.2.2
13
+ pi list
14
+ ```
15
+
16
+ Pi can ignore extension loading failures. If approval protection must be ready before execution starts, use the CLI or SDK entry points in the [usage guide](docs/usage.md).
17
+
18
+ ## How it works
19
+
20
+ 1. **Policy evaluation** — Evaluate protected paths and `commandRules` first. Model review and saved approvals cannot override protected paths.
21
+ 2. **Automatic review** — The review model assesses the risk and outcome of remaining operations.
22
+ 3. **Approval** — The user confirms operations that still require approval.
23
+ 4. **Pi execution** — Run approved operations through the original SDK tools, preserving cancellation signals and caller options.
24
+
25
+ ## Approval settings
26
+
27
+ - `/approve`: Choose **Approve for me** (secondary model review) or **Ask for approval** (user approval).
28
+ - `/approve-model`: Search registered models and choose a secondary review model within Pi's current `/scoped-models` scope. Choose **Use current Pi model** to return to the main model.
29
+
30
+ Selections are saved to `<agentDir>/guard/settings.json` and persist across runs. The main conversation model stays unchanged. Cancelling preserves the existing settings.
31
+
32
+ ## Requirements
33
+
34
+ | Component | Requirement |
35
+ | --- | --- |
36
+ | Node.js | 22.19 or later |
37
+ | Pi | 0.99.1 or 1.0.0 |
38
+ | Current source build | TypeScript; no Rust compiler or platform-specific rule executable |
39
+ | Rule runtime | Node.js worker for asynchronous evaluation; Node.js child process for the synchronous API |
40
+
41
+ ## Protection boundaries
42
+
43
+ - Modes are `workspace-write` (writes to the workspace and default temporary paths) and `read-only`.
44
+ - Model writes to control and authentication paths, project `.pi` settings and extension code, and trusted extension code directories are always blocked.
45
+ - File access outside the normal scope, review rules, and commands that cannot be interpreted are reviewed before execution. Reads and ordinary operations within scope follow the policy.
46
+ - Approvals can apply once, for the session, or as a saved rule. Saved approvals are bound to the exact tool, input, and policy.
47
+ - Automatic review uses the current model by default and stops the actual task after repeated denials. Review errors never become approvals.
48
+ - MCP tool approvals and project instruction discovery follow the same trust and review boundaries.
49
+
50
+ See the [usage guide](docs/usage.md) for configuration and the exact conditions that bind approvals.
51
+
52
+ ## Limitations
53
+
54
+ - Approved shells and interpreters run with host permissions. The file and domain scope shown during review is not an OS-enforced access restriction.
55
+ - The extension does not configure recursive directory scans, exhaustive hard-link checks, or network proxies. It does not isolate indirect file access or destination changes during execution.
56
+ - Pi, trusted extension code, and execution inside external MCP servers are part of the trust boundary.
57
+ - Cancellation of requests already sent to an MCP server depends on the external provider's implementation.
58
+ - Compatibility checks for public policies and flows do not establish identical decisions to the proprietary Codex model.
59
+ - The extension does not automatically replace dependencies in a separately installed Pi host. See [dependency security](docs/security/dependencies.md) for this repository's remediation evidence.
60
+
61
+ ## Verification
62
+
63
+ ```sh
64
+ npm run verify:guard
65
+ ```
66
+
67
+ `verify:guard` builds the project and runs all local checks for the current operating system. Results for other operating systems and live models require separate execution evidence.
68
+
69
+ - Individual `npm run test:*` checks do not use real credentials or paid models. Environment restrictions and missing dependencies are not treated as passes.
70
+ - `npm run verify:platform` runs the full checks for the current operating system.
71
+ - The GitHub Actions workflow `자동 검토 운영체제 검증` runs on Linux x64 and exports the Docker image and results. It receives no Ollama key.
72
+ - Windows `verify:windows` checks the rule engine, approval policy, file execution, and cancellation. It does not verify full shell execution support.
73
+ - See the [Docker section](docs/usage.md#ollama-cloud-verification-in-docker) for container verification.
74
+ - Each run is stored under `.reports/pi-guard/runs/<run ID>/<platform>/`. See the [protection verification matrix](docs/testing/auto-review-protection.md) for allowed, blocked, and failure cases.
75
+
76
+ ## Documentation
77
+
78
+ - [Usage](docs/usage.md) · [한국어](docs/usage.ko.md) — Installation, source builds, CLI, SDK, policies, and Docker verification.
79
+ - [Publishing](docs/publishing.md) · [한국어](docs/publishing.ko.md) — `pnpm release`, npm Trusted Publishing, and GitHub Actions.
80
+ - [Dependency security](docs/security/dependencies.md) · [한국어](docs/security/dependencies.ko.md) — Audit findings, fixes, and their scope.
81
+ - [Protection verification](docs/testing/auto-review-protection.md) · [한국어](docs/testing/auto-review-protection.ko.md) — Allowed and blocked cases, failures, cancellation, and unverified boundaries.
82
+
83
+ ## License
84
+
85
+ [Apache-2.0](LICENSE). Attribution for the TypeScript port of Codex rule contracts and the included policies is preserved in [NOTICE](NOTICE).
@@ -0,0 +1,4 @@
1
+ import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import type { ApprovalSettingsStore } from "./approval-settings.js";
3
+ import type { GuardController } from "./tools/controller.js";
4
+ export declare function registerApprovalCommands(pi: ExtensionAPI, guard: GuardController, store: ApprovalSettingsStore): void;
@@ -0,0 +1,230 @@
1
+ import { getSelectListTheme, } from "@earendil-works/pi-coding-agent";
2
+ import { Container, fuzzyFilter, Input, Key, matchesKey, SelectList, Spacer, Text, } from "@earendil-works/pi-tui";
3
+ import { redact } from "./audit.js";
4
+ import { canonicalJson, GuardError } from "./contracts.js";
5
+ import { validateSettings } from "./policy/index.js";
6
+ const CURRENT_MODEL = "current";
7
+ const modeNames = {
8
+ auto_review: "Approve for me",
9
+ user: "Ask for approval",
10
+ };
11
+ // Match the public Codex permission picker: https://learn.chatgpt.com/docs/security-administration
12
+ const approvalModes = [
13
+ {
14
+ value: "auto_review",
15
+ label: modeNames.auto_review,
16
+ description: "Only ask for actions detected as potentially unsafe",
17
+ },
18
+ {
19
+ value: "user",
20
+ label: modeNames.user,
21
+ description: "Always ask to edit external files and use the internet",
22
+ },
23
+ ];
24
+ class ApprovalModePicker extends Container {
25
+ list;
26
+ constructor(current, finish) {
27
+ super();
28
+ this.addChild(new Text(`Approval mode — Current: ${modeNames[current]}`, 0, 0));
29
+ this.addChild(new Spacer(1));
30
+ this.list = new SelectList(approvalModes, approvalModes.length, getSelectListTheme(), { maxPrimaryColumnWidth: 22 });
31
+ this.list.setSelectedIndex(approvalModes.findIndex((item) => item.value === current));
32
+ this.list.onSelect = (item) => finish(item.value);
33
+ this.list.onCancel = () => finish(undefined);
34
+ this.addChild(this.list);
35
+ this.addChild(new Spacer(1));
36
+ const description = new Text(this.list.getSelectedItem()?.description ?? "", 0, 0);
37
+ this.list.onSelectionChange = (item) => description.setText(item.description ?? "");
38
+ this.addChild(description);
39
+ this.addChild(new Spacer(1));
40
+ this.addChild(new Text("↑↓ Select · Enter Apply · Esc Cancel", 0, 0));
41
+ }
42
+ handleInput(data) {
43
+ this.list.handleInput(data);
44
+ }
45
+ }
46
+ function availableReviewModels(context) {
47
+ const available = context.modelRegistry.getAvailable();
48
+ const scoped = context.scopedModels ?? [];
49
+ if (!scoped.length)
50
+ return available;
51
+ const key = (model) => canonicalJson({ provider: model.provider, id: model.id });
52
+ const byIdentity = new Map(available.map((model) => [key(model), model]));
53
+ const seen = new Set();
54
+ return scoped.flatMap(({ model }) => {
55
+ const identity = key(model), registered = byIdentity.get(identity);
56
+ if (!registered || seen.has(identity))
57
+ return [];
58
+ seen.add(identity);
59
+ return [registered];
60
+ });
61
+ }
62
+ class ApprovalModelPicker extends Container {
63
+ items;
64
+ finish;
65
+ input = new Input();
66
+ list;
67
+ results = new Container();
68
+ filtered;
69
+ get focused() {
70
+ return this.input.focused;
71
+ }
72
+ set focused(value) {
73
+ this.input.focused = value;
74
+ }
75
+ constructor(items, selected, finish, search) {
76
+ super();
77
+ this.items = items;
78
+ this.finish = finish;
79
+ this.addChild(new Text("Approval review model", 0, 0));
80
+ this.addChild(new Spacer(1));
81
+ this.addChild(this.input);
82
+ this.addChild(new Spacer(1));
83
+ this.addChild(this.results);
84
+ this.addChild(new Text("Search · ↑↓ Select · Enter Apply · Esc Cancel", 0, 0));
85
+ this.filtered = items;
86
+ this.input.setValue(search);
87
+ this.filter(search);
88
+ const index = this.filtered.findIndex((item) => item.value === selected);
89
+ if (index >= 0)
90
+ this.list.setSelectedIndex(index);
91
+ }
92
+ filter(query) {
93
+ this.filtered = query
94
+ ? fuzzyFilter(this.items, query, (item) => `${item.label} ${item.description ?? ""}`)
95
+ : this.items;
96
+ this.list = new SelectList(this.filtered, 12, getSelectListTheme());
97
+ this.list.onSelect = (item) => this.finish(item.value);
98
+ this.list.onCancel = () => this.finish(undefined);
99
+ this.results.clear();
100
+ this.results.addChild(this.filtered.length
101
+ ? this.list
102
+ : new Text("No matching models.", 0, 0));
103
+ }
104
+ handleInput(data) {
105
+ if (matchesKey(data, Key.escape))
106
+ this.finish(undefined);
107
+ else if (matchesKey(data, Key.enter) ||
108
+ matchesKey(data, Key.up) ||
109
+ matchesKey(data, Key.down))
110
+ this.list.handleInput(data);
111
+ else {
112
+ const before = this.input.getValue();
113
+ this.input.handleInput(data);
114
+ if (this.input.getValue() !== before)
115
+ this.filter(this.input.getValue());
116
+ }
117
+ }
118
+ }
119
+ async function chooseReviewModel(context, current, search) {
120
+ const models = availableReviewModels(context);
121
+ const items = [
122
+ {
123
+ value: CURRENT_MODEL,
124
+ label: "Use current Pi model",
125
+ description: "Follow the model selected for the main task.",
126
+ },
127
+ ...models.map((model) => ({
128
+ value: canonicalJson({ provider: model.provider, id: model.id }),
129
+ label: model.name || model.id,
130
+ description: `${model.provider}/${model.id}`,
131
+ })),
132
+ ];
133
+ const selected = current ? canonicalJson(current) : CURRENT_MODEL;
134
+ const result = context.mode === "rpc"
135
+ ? await context.ui
136
+ .select("Approval review model", items.map((item) => `${item.label} — ${item.description}`))
137
+ .then((value) => value === undefined
138
+ ? undefined
139
+ : items[items.findIndex((item) => `${item.label} — ${item.description}` ===
140
+ value)]?.value)
141
+ : await context.ui.custom((_tui, _theme, _keys, done) => new ApprovalModelPicker(items, selected, done, search));
142
+ if (result === undefined)
143
+ return undefined;
144
+ return result === CURRENT_MODEL
145
+ ? null
146
+ : JSON.parse(result);
147
+ }
148
+ async function retryDeniedAction(pi, guard, context) {
149
+ const denials = [...guard.approvals.lifecycle.recentDenials].reverse();
150
+ if (!denials.length) {
151
+ context.ui.notify("No recent denied actions to review again.", "info");
152
+ return;
153
+ }
154
+ const choices = denials.map((item) => `${item.action.tool} | ${redact(canonicalJson(item.action.args))} | ${item.assessment.rationale} | ${item.id}`);
155
+ const selected = await context.ui.select("Choose a denied action to review again once", choices);
156
+ const index = choices.indexOf(selected ?? "");
157
+ const denial = denials[index];
158
+ if (!denial)
159
+ return;
160
+ const retry = await guard.authorizeRetry(denial.id, context);
161
+ if (retry.denial.action.source === "user-bash") {
162
+ await guard.retryUserBash(retry.denial.action, context);
163
+ context.ui.notify("The selected command was reviewed again and executed.", "info");
164
+ return;
165
+ }
166
+ const instruction = retry.denial.action.source === "nested"
167
+ ? "Invoke only this exact tool through codemode to preserve the original nested source."
168
+ : "Retry only this exact tool action.";
169
+ pi.sendUserMessage(`${instruction}\nTool: ${retry.denial.action.tool}\nArguments: ${canonicalJson(retry.args)}\nThe user selected denial ${retry.denial.id} for one retry. The controller holds a one-use exact-action marker; automatic review and policy still apply. Do not repeat unrelated earlier side effects.`, { expandPromptTemplates: false });
170
+ }
171
+ export function registerApprovalCommands(pi, guard, store) {
172
+ const requireUI = (context) => {
173
+ if (!context.hasUI)
174
+ throw new GuardError("APPROVAL_UI_UNAVAILABLE", "Approval settings require an interactive Pi session");
175
+ };
176
+ const apply = async (patch, context) => {
177
+ await guard.updateSettings((current) => validateSettings({ ...current, ...patch }), context.cwd, (settings) => store.save(settings));
178
+ context.ui.setStatus("auto-review", undefined);
179
+ };
180
+ pi.registerCommand("approve", {
181
+ description: "Choose an approval mode, or use /approve retry to review a denied action again once.",
182
+ handler: async (args, context) => {
183
+ requireUI(context);
184
+ await context.waitForIdle();
185
+ if (args.trim() === "retry") {
186
+ await retryDeniedAction(pi, guard, context);
187
+ return;
188
+ }
189
+ if (args.trim())
190
+ throw new GuardError("INVALID_APPROVAL_COMMAND", "Use /approve to choose a mode or /approve retry to review a denied action again.");
191
+ const current = guard.options.settings;
192
+ const choices = approvalModes.map((item) => `${item.label} — ${item.description}`);
193
+ const choice = context.mode === "rpc"
194
+ ? await context.ui
195
+ .select(`Approval mode — Current: ${modeNames[current.approvalsReviewer]}`, choices)
196
+ .then((selected) => approvalModes[choices.indexOf(selected ?? "")]
197
+ ?.value)
198
+ : await context.ui.custom((_tui, _theme, _keys, done) => new ApprovalModePicker(current.approvalsReviewer, done));
199
+ if (choice === undefined)
200
+ return;
201
+ const reviewer = choice === "auto_review"
202
+ ? "auto_review"
203
+ : choice === "user"
204
+ ? "user"
205
+ : undefined;
206
+ if (!reviewer)
207
+ return;
208
+ await apply({ approvalsReviewer: reviewer }, context);
209
+ context.ui.notify(`Approval mode: ${modeNames[reviewer]}`, "info");
210
+ },
211
+ });
212
+ pi.registerCommand("approve-model", {
213
+ description: "Choose an approval review model from /scoped-models.",
214
+ handler: async (args, context) => {
215
+ requireUI(context);
216
+ await context.waitForIdle();
217
+ const current = guard.options.settings;
218
+ const model = await chooseReviewModel(context, current.reviewModel, args.trim());
219
+ if (model === undefined)
220
+ return;
221
+ if (model &&
222
+ !availableReviewModels(context).some((candidate) => candidate.provider === model.provider &&
223
+ candidate.id === model.id))
224
+ throw new GuardError("MODEL_UNAVAILABLE", "Selected review model is no longer available in the current model scope");
225
+ await apply({ reviewModel: model }, context);
226
+ context.ui.notify(`Approval review model: ${model ? `${model.provider}/${model.id}` : "Use current Pi model"}`, "info");
227
+ },
228
+ });
229
+ }
230
+ //# sourceMappingURL=approval-commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-commands.js","sourceRoot":"","sources":["../src/approval-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,kBAAkB,GACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EAET,WAAW,EACX,KAAK,EACL,GAAG,EACH,UAAU,EAEV,UAAU,EACV,MAAM,EACN,IAAI,GACP,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAsB,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AA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