@akagilnc/pi-workflow-roles 0.1.1751
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.
- package/LICENSE +202 -0
- package/README.md +104 -0
- package/README.zh-CN.md +133 -0
- package/THIRD_PARTY_NOTICES.md +60 -0
- package/dist/activation-ledger-git.js +68 -0
- package/dist/activation-ledger-session.js +120 -0
- package/dist/activation-ledger-topology.js +239 -0
- package/dist/activation-reconciliation.js +61 -0
- package/dist/audit-escalation.js +108 -0
- package/dist/auditor-dossier-tool.js +35 -0
- package/dist/canonical-json.js +78 -0
- package/dist/compliance-transport.js +77 -0
- package/dist/doctor-contracts.js +172 -0
- package/dist/dossier-resolution.js +103 -0
- package/dist/evidence-child-executor.js +661 -0
- package/dist/exact-utf8.js +12 -0
- package/dist/git-object-id.js +7 -0
- package/dist/in-process-session.js +50 -0
- package/dist/merger-contracts.js +76 -0
- package/dist/navigator-attendance.js +995 -0
- package/dist/navigator-invocation-identity.js +220 -0
- package/dist/open-tool-schema.js +39 -0
- package/dist/package-contracts/collector-output.js +50 -0
- package/dist/package-contracts/fixer-output.js +72 -0
- package/dist/package-contracts/fixer-packet.js +77 -0
- package/dist/package-contracts/judge-output.js +17 -0
- package/dist/package-contracts/reviewer-output.js +82 -0
- package/dist/package-contracts/terminating-tools.js +173 -0
- package/dist/package-contracts/worker-output.js +13 -0
- package/dist/package-owned-tool-idle.js +104 -0
- package/dist/packaged-role-registry.js +34 -0
- package/dist/public-cli/main.js +23867 -0
- package/dist/public-command-renderer.js +20 -0
- package/dist/reviewer-agent.js +93 -0
- package/dist/reviewer-child-executor.js +23 -0
- package/dist/reviewer-construction.js +95 -0
- package/dist/reviewer-dispatch.js +77 -0
- package/dist/reviewer-execution-ledger.js +160 -0
- package/dist/reviewer-failure-diagnostic.js +17 -0
- package/dist/reviewer-git-snapshot.js +38 -0
- package/dist/reviewer-pinned-git.js +146 -0
- package/dist/reviewer-preflight-error.js +15 -0
- package/dist/reviewer-prompt-identity.js +10 -0
- package/dist/reviewer-scope-prompt.js +21 -0
- package/dist/reviewer-workspace.js +151 -0
- package/dist/sha256.js +5 -0
- package/dist/sitian-record-entry.js +33 -0
- package/dist/stderr-jsonl.js +26 -0
- package/dist/stream-idle-guard.js +75 -0
- package/dist/tool-execution-observation.js +141 -0
- package/dist/uuidv7.js +21 -0
- package/dist/work-subject-identity.js +53 -0
- package/extensions/role-runtime.ts +303 -0
- package/package.json +69 -0
- package/packets/fixer-prerequisites.json +6 -0
- package/packets/fixer-repair.md +5 -0
- package/packets/judge-apply.md +77 -0
- package/packets/judge-authority.md +64 -0
- package/packets/judge-plan.md +55 -0
- package/packets/judge-review.md +49 -0
- package/packets/judge-submission.md +34 -0
- package/resources/methods/code-review/SKILL.md +92 -0
- package/resources/methods/code-review/agents/openai.yaml +3 -0
- package/resources/methods/code-review/provenance.json +26 -0
- package/resources/methods/diagnosing-bugs/SKILL.md +134 -0
- package/resources/methods/diagnosing-bugs/agents/openai.yaml +3 -0
- package/resources/methods/diagnosing-bugs/provenance.json +31 -0
- package/resources/methods/diagnosing-bugs/scripts/hitl-loop.template.sh +41 -0
- package/resources/methods/resolving-merge-conflicts/SKILL.md +14 -0
- package/resources/methods/resolving-merge-conflicts/agents/openai.yaml +3 -0
- package/resources/methods/resolving-merge-conflicts/provenance.json +26 -0
- package/resources/methods/tdd/SKILL.md +38 -0
- package/resources/methods/tdd/agents/openai.yaml +3 -0
- package/resources/methods/tdd/mocking.md +59 -0
- package/resources/methods/tdd/provenance.json +36 -0
- package/resources/methods/tdd/tests.md +77 -0
- package/resources/navigator-route-playbook.md +32 -0
- package/schemas/tool-execution-observation.schema.json +107 -0
- package/scripts/build-package.mjs +65 -0
- package/scripts/generate-tool-execution-observation-schema.ts +7 -0
- package/souls/coder.md +10 -0
- package/souls/collector.md +11 -0
- package/souls/doctor-auditor.md +23 -0
- package/souls/doctor.md +8 -0
- package/souls/fixer-auditor.md +33 -0
- package/souls/fixer.md +13 -0
- package/souls/judge-auditor.md +33 -0
- package/souls/judge.md +74 -0
- package/souls/merger.md +5 -0
- package/souls/navigator.md +5 -0
- package/souls/reviewer-auditor.md +25 -0
- package/souls/reviewer.md +11 -0
- package/src/activation-ledger-git.ts +96 -0
- package/src/activation-ledger-session.ts +188 -0
- package/src/activation-ledger-topology.ts +301 -0
- package/src/activation-ledger.ts +240 -0
- package/src/activation-reconciliation.ts +163 -0
- package/src/activation-trace.ts +38 -0
- package/src/audit-escalation.ts +177 -0
- package/src/auditor-dossier-tool.ts +48 -0
- package/src/auditor-soul.ts +28 -0
- package/src/canonical-json.ts +74 -0
- package/src/canonical-skill-binding.ts +107 -0
- package/src/collector-config.ts +89 -0
- package/src/collector-evidence.ts +461 -0
- package/src/collector-github.ts +656 -0
- package/src/collector-identity.ts +161 -0
- package/src/collector-ledger.ts +827 -0
- package/src/collector-receipt.ts +87 -0
- package/src/collector-role.ts +592 -0
- package/src/collector-tool-schemas.ts +19 -0
- package/src/compliance-transport.ts +130 -0
- package/src/doctor-auditor.ts +53 -0
- package/src/doctor-contracts.ts +166 -0
- package/src/doctor-evidence.ts +47 -0
- package/src/doctor-role.ts +18 -0
- package/src/dossier-resolution.ts +137 -0
- package/src/evidence-child-executor.ts +775 -0
- package/src/exact-utf8.ts +9 -0
- package/src/factory-board.ts +1822 -0
- package/src/git-object-id.ts +11 -0
- package/src/human-format.ts +65 -0
- package/src/in-process-session.ts +78 -0
- package/src/judge-auditor.ts +55 -0
- package/src/judge-recording-anti-forge.ts +53 -0
- package/src/judge-role.ts +160 -0
- package/src/merger-contracts.ts +71 -0
- package/src/merger-git-state.ts +76 -0
- package/src/merger-role.ts +60 -0
- package/src/navigator-attendance.ts +1254 -0
- package/src/navigator-invocation-identity.ts +446 -0
- package/src/open-tool-schema.ts +46 -0
- package/src/package-contracts/collector-output.ts +109 -0
- package/src/package-contracts/fixer-output.ts +81 -0
- package/src/package-contracts/fixer-packet.ts +93 -0
- package/src/package-contracts/judge-output.ts +39 -0
- package/src/package-contracts/reviewer-output.ts +115 -0
- package/src/package-contracts/terminating-tools.ts +259 -0
- package/src/package-contracts/worker-output.ts +36 -0
- package/src/package-owned-tool-idle.ts +134 -0
- package/src/package-resources/method-skill-binding.ts +87 -0
- package/src/package-resources/method-skill.ts +358 -0
- package/src/packaged-role-registry.ts +36 -0
- package/src/public-cli/cli-errors.ts +11 -0
- package/src/public-cli/cli-io.ts +4 -0
- package/src/public-cli/cli.ts +912 -0
- package/src/public-cli/coder-run.ts +575 -0
- package/src/public-cli/collector-run.ts +375 -0
- package/src/public-cli/command-renderer.ts +8 -0
- package/src/public-cli/config.ts +346 -0
- package/src/public-cli/doctor-run.ts +355 -0
- package/src/public-cli/explicit-internal.ts +274 -0
- package/src/public-cli/fixer-run.ts +587 -0
- package/src/public-cli/host-pi-runtime.ts +112 -0
- package/src/public-cli/invocation.ts +1958 -0
- package/src/public-cli/judge-run.ts +507 -0
- package/src/public-cli/main.ts +15 -0
- package/src/public-cli/merger-run.ts +681 -0
- package/src/public-cli/public-run-credentials.ts +71 -0
- package/src/public-cli/registry.ts +153 -0
- package/src/public-cli/reviewer-run.ts +561 -0
- package/src/public-cli/run-lifecycle.ts +884 -0
- package/src/public-cli/settlement.ts +3765 -0
- package/src/public-cli/terminal.ts +325 -0
- package/src/public-command-renderer.ts +43 -0
- package/src/reviewer-agent.ts +94 -0
- package/src/reviewer-auditor.ts +53 -0
- package/src/reviewer-child-executor.ts +31 -0
- package/src/reviewer-construction.ts +137 -0
- package/src/reviewer-dispatch.ts +94 -0
- package/src/reviewer-execution-ledger.ts +206 -0
- package/src/reviewer-failure-diagnostic.ts +18 -0
- package/src/reviewer-git-snapshot.ts +53 -0
- package/src/reviewer-pinned-git.ts +144 -0
- package/src/reviewer-preflight-error.ts +14 -0
- package/src/reviewer-prompt-identity.ts +17 -0
- package/src/reviewer-role.ts +193 -0
- package/src/reviewer-scope-prompt.ts +24 -0
- package/src/reviewer-settlement.ts +63 -0
- package/src/reviewer-workspace.ts +111 -0
- package/src/role-runtime.ts +884 -0
- package/src/sha256.ts +6 -0
- package/src/sitian-record-entry.ts +57 -0
- package/src/stderr-jsonl.ts +28 -0
- package/src/stream-idle-guard.ts +98 -0
- package/src/ticket-snapshot.ts +662 -0
- package/src/ticket-trajectory.ts +1000 -0
- package/src/tool-execution-observation.ts +168 -0
- package/src/uuidv7.ts +1 -0
- package/src/work-subject-identity.ts +94 -0
- package/src/worker-role.ts +434 -0
- package/src/worker-submission-gates.ts +225 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# @akagilnc/pi-workflow-roles
|
|
2
|
+
|
|
3
|
+
Packaged workflow roles for [Pi](https://pi.dev): `judge`, `fixer`, `coder`, `reviewer`, `collector`, `doctor`, `merger`. 中文说明见 [README.zh-CN.md](README.zh-CN.md)。
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Install through Pi so the CLI and runtime come from the same package copy, and add Pi’s private npm bin to `PATH` once:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pi install npm:@akagilnc/pi-workflow-roles
|
|
11
|
+
export PATH="$HOME/.pi/agent/npm/node_modules/.bin:$PATH"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Update with `pi update npm:@akagilnc/pi-workflow-roles`—never a second global `npm install -g`. Inspect with `ak-role roles` and `ak-role help <role>`; set per-seat defaults with `ak-role config set judge openai-codex/gpt-5.6-sol:high`.
|
|
15
|
+
|
|
16
|
+
## Reading results
|
|
17
|
+
|
|
18
|
+
`ak-role` is the only supported way to call the package. Every run writes its complete Terminal result to stdout—read or redirect it there, never scrape Pi session files:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
ak-role judge --attach ./plan.md "Review this plan." > result.txt
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Exit status reports lifecycle honesty, not business success: every lawful typed result (including `audit_escalation`) exits zero; a failure without a lawful result exits nonzero, and its Terminal carries the Error Artifact ref and original cause instead of a fabricated receipt.
|
|
25
|
+
|
|
26
|
+
A run interrupted by a typed Codex/xAI HTTP 429 with no lawful result prints a complete `ak-role resume <runId>` command in its failure Terminal. Resume reopens the exact session; override the model for one run with the global flags. The package never auto-switches providers, only a typed 429 makes a run resumable, and unknown, terminal, or concurrently-resumed run IDs are rejected. Collector and Doctor are one-shot.
|
|
27
|
+
|
|
28
|
+
Global overrides work before or after the role: `ak-role --model xai/grok-4.5:high resume <runId>`.
|
|
29
|
+
|
|
30
|
+
Every run also prepares Navigator advice in the same Terminal. Configure it like any other seat:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
ak-role config set navigator openai-codex/gpt-5.6-luna:medium
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Receipts are typed, so callers compose roles without parsing prose; ordering and stopping stay caller-owned. Programmatic consumers derive contracts from the exported schemas in `src/package-contracts/`, not from this guide.
|
|
37
|
+
|
|
38
|
+
## Call the roles
|
|
39
|
+
|
|
40
|
+
Most roles accept `--attach <file>` (repeatable, frozen at admission), but Reviewer does not. Reviewer requires `--base <revision>` to select the fixed point, and its review materials are acquired through the package-owned bundle mechanism rather than caller attachments. All roles accept `--project <path>`. An instruction is optional for judge, collector, and doctor, and required nonblank for coder, fixer, reviewer, and merger.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# judge — adjudicate the supplied materials; infers its burden, no burden flag
|
|
44
|
+
ak-role judge --attach ./findings.md --attach ./adr.md "Adjudicate every finding."
|
|
45
|
+
|
|
46
|
+
# coder — first implementation; phase defaults to apply, or pass plan
|
|
47
|
+
ak-role coder plan "Propose the first implementation plan."
|
|
48
|
+
ak-role coder apply --attach ./plan.md "Implement the approved slice."
|
|
49
|
+
# apply binds the package-owned TDD method; do not bind a home Skill as a substitute
|
|
50
|
+
|
|
51
|
+
# reviewer — fixed-target two-axis review (Standards + Spec)
|
|
52
|
+
ak-role reviewer --base main "Review the branch against the governing issue and repository authority."
|
|
53
|
+
# --base is required and pins the fixed point; Reviewer does not accept --attach
|
|
54
|
+
# completed ≠ approved — read the findings in the Terminal
|
|
55
|
+
|
|
56
|
+
# collector — GitHub PR review evidence; github.com only, needs gh auth; one-shot
|
|
57
|
+
ak-role collector --pr 42 --repo owner/repository
|
|
58
|
+
# repo defaults from origin; --repo owner/repo overrides
|
|
59
|
+
|
|
60
|
+
# fixer — repair the assigned findings; phase defaults to apply, or pass plan
|
|
61
|
+
ak-role fixer --attach ./findings.md --prerequisites ./prereqs.json "Repair the findings."
|
|
62
|
+
# --prerequisites is a JSON array of {id, requirement}; malformed grammar exits 2
|
|
63
|
+
# apply/resume mount the package-owned diagnosis and TDD methods from the install; neither is forced into the prompt
|
|
64
|
+
|
|
65
|
+
# doctor — diagnose one retained case; one-shot
|
|
66
|
+
ak-role doctor --issue 115 "Diagnose this retained case."
|
|
67
|
+
# --runs must stay project-relative: .ak-roles/books/<book>/issues/<n>/runs matching --issue
|
|
68
|
+
|
|
69
|
+
# merger — resolve one merge already in conflict (start it first with Git’s ort)
|
|
70
|
+
ak-role merger --project /path/to/worktree "Reconcile the active merge."
|
|
71
|
+
# hands new intent/authority questions back instead of inventing authority
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Names
|
|
75
|
+
|
|
76
|
+
Roles are named after Tang/Song offices; the full roster and naming rule live in [README.zh-CN.md](README.zh-CN.md).
|
|
77
|
+
|
|
78
|
+
## Developer seam: raw session invocation (advanced)
|
|
79
|
+
|
|
80
|
+
Most callers never need this. The source tree retains an explicitly loadable raw-Pi seam for package development and low-level diagnosis; it is not a supported invocation recipe—external callers use `ak-role`.
|
|
81
|
+
|
|
82
|
+
A raw run loads the role runtime explicitly and selects the role through the internal flag. This is the real argv shape, taken from the CLI’s own builders and recorded runs under the ledger book:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
run=~/.ak-roles/books/<book>/issues/<issue>/runs/<invocation>@<source-tree>
|
|
86
|
+
pi --no-extensions \
|
|
87
|
+
-e <packageRoot>/extensions/role-runtime.ts \
|
|
88
|
+
--no-skills --no-prompt-templates --no-themes --no-context-files \
|
|
89
|
+
--session "$run/session/session.jsonl" \
|
|
90
|
+
--session-dir "$run/session" \
|
|
91
|
+
--ak-role judge --mode json \
|
|
92
|
+
"Adjudicate the attached materials." \
|
|
93
|
+
</dev/null >/dev/null 2>"$run/stderr.log"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`--session` names the exact session file principal (never directory-latest); `--session-dir` is its directory. Judge takes the instruction as the prompt; other roles pass durable payload files through their own internal flags (`--ak-coder-task`, `--ak-fix-packet`, and siblings), assembled by each role’s builder in `src/public-cli/*-run.ts` through the load boundary in `src/public-cli/explicit-internal.ts`. Derive flags from that source—and from recorded runs under the ledger book—never from prose.
|
|
97
|
+
|
|
98
|
+
Discipline:
|
|
99
|
+
|
|
100
|
+
- seal stdin with `</dev/null`—Pi reads a non-TTY stdin to EOF before starting, so an open background pipe parks the run forever;
|
|
101
|
+
- send stdout to `/dev/null`—the session file is the authoritative record and stdout is an unbounded copy surface; attach dashboards to `stderr.log` and the session file;
|
|
102
|
+
- keep `stderr.log` and `invocation.json` in the same `runs/` directory, as in the example above.
|
|
103
|
+
|
|
104
|
+
Codex fast tier: enable fast tier with `echo "fast_mode = on" > ~/.pi-codex-fast`; disable it with `echo "fast_mode = off" > ~/.pi-codex-fast` (or delete the file). The change takes effect on the next request without a restart. Fast tier costs more than the default tier.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @akagilnc/pi-workflow-roles
|
|
2
|
+
|
|
3
|
+
为 [Pi](https://pi.dev) 打包的工作流角色:大理寺(judge)、修内司(fixer)、将作监(coder)、御史台(reviewer)、门下省(collector)、太医署(doctor)、校书郎(merger)。English: [README.md](README.md)。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
经 Pi 安装,令 CLI 与运行时同出一份包副本;把 Pi 私有 npm bin 加进 `PATH`(一次):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pi install npm:@akagilnc/pi-workflow-roles
|
|
11
|
+
export PATH="$HOME/.pi/agent/npm/node_modules/.bin:$PATH"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
更新用 `pi update npm:@akagilnc/pi-workflow-roles`——勿另起全局 `npm install -g`。查看能力:`ak-role roles`、`ak-role help <role>`;设席位默认:`ak-role config set judge openai-codex/gpt-5.6-sol:high`。
|
|
15
|
+
|
|
16
|
+
## 读结果
|
|
17
|
+
|
|
18
|
+
`ak-role` 是唯一受支持的调用方式。每次运行的完整 Terminal 结果写在 stdout——从那里读或正常重定向,不要刮 Pi session 文件:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
ak-role judge --attach ./plan.md "Review this plan." > result.txt
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
退出码报的是生命周期诚实,不是业务成败:一切合法 typed 终态(含 `audit_escalation`)退出零;无合法终态的失败退出非零,其 Terminal 携带 Error Artifact 引用与原始原因,不伪造回执。
|
|
25
|
+
|
|
26
|
+
被 Codex/xAI typed HTTP 429 打断且无合法终态的运行,其失败 Terminal 内含完整 `ak-role resume <runId>` 命令。resume 重开同一 session;临时换模型用全局旗标。包绝不自动换 provider;只有 typed 429 可恢复;未知、已终结、并发重复的 run ID 一律拒绝。门下省、太医署为一次性,无 resume。
|
|
27
|
+
|
|
28
|
+
全局覆盖前后皆可:`ak-role --model xai/grok-4.5:high resume <runId>`。
|
|
29
|
+
|
|
30
|
+
每次运行游奕使自动出席,建议随同一 Terminal 给出。配置:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
ak-role config set navigator openai-codex/gpt-5.6-luna:medium
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
回执是 typed 的,调用者不必解析散文即可组合角色;顺序与停止归调用者。编程消费者从 `src/package-contracts/` 导出推导契约,不从本文。
|
|
37
|
+
|
|
38
|
+
## 调用百官
|
|
39
|
+
|
|
40
|
+
多数角色支持 `--attach <文件>`(可重复,受理即冻结),但御史台不接受该旗标。御史台必须用 `--base <revision>` 选定 fixed point,审查材料由包内 bundle 机制取得,而非由调用者附加。所有角色都支持 `--project <路径>`。指令对大理寺、门下省、太医署可省略,对将作监、修内司、御史台、校书郎必须非空。
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# 大理寺——审断所供材料;自行推断举证责任,无 burden 旗标
|
|
44
|
+
ak-role judge --attach ./findings.md --attach ./adr.md "Adjudicate every finding."
|
|
45
|
+
|
|
46
|
+
# 将作监——营造新作;phase 默认 apply,或显式 plan
|
|
47
|
+
ak-role coder plan "Propose the first implementation plan."
|
|
48
|
+
ak-role coder apply --attach ./plan.md "Implement the approved slice."
|
|
49
|
+
# apply 强制包内 TDD 方法;勿绑 home Skill 顶替
|
|
50
|
+
|
|
51
|
+
# 御史台——固定目标双轴察举(Standards + Spec)
|
|
52
|
+
ak-role reviewer --base main "Review the branch."
|
|
53
|
+
# --base 为必填并钉住 fixed point;御史台不接受 --attach
|
|
54
|
+
# completed ≠ 准行——findings 在 Terminal 里
|
|
55
|
+
|
|
56
|
+
# 门下省——GitHub PR 收证;仅 github.com,需 gh 已认证;一次性
|
|
57
|
+
ak-role collector --pr 42 --repo owner/repository
|
|
58
|
+
ak-role collector --pr 42 --request-manifest ./requests.json
|
|
59
|
+
# 无配置时仅观察;可选 request manifest 为 {requests:[{id,body}]};repo 默认取 origin
|
|
60
|
+
|
|
61
|
+
# 修内司——缮修所指 findings;phase 默认 apply,或显式 plan
|
|
62
|
+
ak-role fixer --attach ./findings.md --prerequisites ./prereqs.json "Repair the findings."
|
|
63
|
+
# --prerequisites 为 {id, requirement} JSON 数组;语法畸形退出 2
|
|
64
|
+
|
|
65
|
+
# 太医署——单案诊断;一次性
|
|
66
|
+
ak-role doctor --issue 115 "Diagnose this retained case."
|
|
67
|
+
# --runs 须为项目相对的 .ak-roles/books/<book>/issues/<n>/runs 且匹配 --issue
|
|
68
|
+
|
|
69
|
+
# 校书郎——雠校一个已在冲突的 merge(先用 Git ort 起动)
|
|
70
|
+
ak-role merger --project /path/to/worktree "Reconcile the active merge."
|
|
71
|
+
# 遇新意图/权限问题交回调用者,不捏造 authority
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 班子(唐宋官署命名)
|
|
75
|
+
|
|
76
|
+
角色按唐宋官署/官职命名,判据与被否方案见 [ADR 0051](docs/adr/0051-roles-are-named-after-tang-song-offices.md)。**朝廷对应:皇帝=陛下,宰相=调用者,百官=各角色。** 工厂没有政事堂——中枢是陛下。百官各司其职,彼此制衡,共同完成从谋划、建设、审查到收敛的完整流程。
|
|
77
|
+
|
|
78
|
+
**只是名字。** `ak-role <name>` 的角色标识符以及工具名与 schema 字段一律使用下表席位列的英文名;中文名只是呈现层称谓。
|
|
79
|
+
|
|
80
|
+
| 名号 | 席位 | 职掌 |
|
|
81
|
+
| --- | --- | --- |
|
|
82
|
+
| **将作监** | coder | **营造新作。** 承接新的谋划与需求,从一片空白开始设计、建造,直到形成可供使用的新成果。讲究先明其意,再定其形,不妄增枝节,只做当下所需之事。 |
|
|
83
|
+
| **修内司** | fixer | **缮修旧物。** 面对已有问题,不急于表面修补,而是追寻问题根源,找到真正需要修整之处。既要修复眼前缺漏,也要防止同类问题再次出现。 |
|
|
84
|
+
| **御史台** | reviewer | **察举百弊。** 置身事外,以旁观之眼审视成果,寻找其中的不妥、遗漏与隐患。只负责指出问题、陈明依据,不参与修改,也不替人作最终判断。 |
|
|
85
|
+
| **大理寺** | judge | **审理定谳。** 承接各方意见与材料,依照既定规则逐项判断,辨明是非曲直。可以准行、退回或请示更高决定,但自身不参与建设与修改。 |
|
|
86
|
+
| **审刑院** | judge-auditor/reviewer-auditor(无 CLI,共享内部接缝) | **复核成案。** 不重新争论事情本身,而是检查整个办理过程是否合乎规矩。关注是否有人越过职责、是否遗漏必要步骤、是否以错误方式得出正确结果。 |
|
|
87
|
+
| **门下省** | collector | **承接百议。** 位于决策之前,收集各方反馈与意见,确认事情是否已经具备继续推进的条件。它不替人裁决,只负责让信息完整、状态清楚。 |
|
|
88
|
+
| **校书郎** | merger | **雠校异文。** 面对不同来源的修改,负责整理、校合与调和。保留双方有价值的部分,解决彼此冲突;遇到无法自行决定之处,则留待重新裁量。 |
|
|
89
|
+
| **游奕使** | navigator(无 CLI,自动出席) | **巡行问路。** 不掌具体事务,而是观察全局变化,结合当前局面提醒下一步方向。它提供建议与路径参考,但最终选择仍由执掌之人决定。 |
|
|
90
|
+
|
|
91
|
+
其余席位:
|
|
92
|
+
|
|
93
|
+
| 席位 | 名 | 职掌 | 状态 |
|
|
94
|
+
| --- | --- | --- | --- |
|
|
95
|
+
| doctor | **太医署** | 单案诊断工厂机制,开 `keep|thin|delete` 方 | 已建 |
|
|
96
|
+
| — | **司天台** | 记候簿——只打点、只指针,不分析不执法 | **一期不是角色**([ADR 0047](docs/adr/0047-sitian-phase-one-mechanism-not-role.md):零 LLM 双面对账);席位形态属 [#67](https://github.com/Akagilnc/ak-pi-workflow-roles/issues/67) 素材,未定 |
|
|
97
|
+
| — | **兰台** | 读档议制——耗时/缺口/冗余三条,上奏不执法 | 未建([#67](https://github.com/Akagilnc/ak-pi-workflow-roles/issues/67) 两席之一) |
|
|
98
|
+
| — | **考功司** | 考具体效率——角色与档位的升档率、一次通过率、每票成本 | 留档,不属 #67,需要时另立票 |
|
|
99
|
+
| — | **主簿** | 合并后勾稽销案:核实确已合上、清理残留、报到达 | 未建 |
|
|
100
|
+
|
|
101
|
+
**merge 按钮归调用者**,没有任何角色握不可逆权限:门下省把收证这件苦活做完并报收集终态,人(或 AI)自己判断、自己点,点完想调主簿就调、不调也可以。
|
|
102
|
+
|
|
103
|
+
上表**不规定调用顺序**——组合、顺序、重复次数归调用者([ADR 0010](docs/adr/0010-callers-own-role-composition-and-repetition.md))。御史台/大理寺/审刑院是**职责分立的类比,不是必经链**;审刑院也并非只跟在大理寺之后,大理寺、御史台、太医署各自都有一次。
|
|
104
|
+
|
|
105
|
+
`拾遗补阙` 成对留档,待将来出现第二个进言席再启用。
|
|
106
|
+
|
|
107
|
+
## 开发者接缝:手拼 session(高级)
|
|
108
|
+
|
|
109
|
+
多数调用者不需要本节。源码树保留一条可显式装载的 raw-Pi 接缝,供包开发与底层诊断;它不是受支持的调用配方——外部调用者用 `ak-role`。
|
|
110
|
+
|
|
111
|
+
原始运行显式装载角色运行时,经内部旗标选角色。以下 argv 全形取自 CLI 自身 builder 与卷宗实记:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
run=~/.ak-roles/books/<book>/issues/<issue>/runs/<invocation>@<源树>
|
|
115
|
+
pi --no-extensions \
|
|
116
|
+
-e <packageRoot>/extensions/role-runtime.ts \
|
|
117
|
+
--no-skills --no-prompt-templates --no-themes --no-context-files \
|
|
118
|
+
--session "$run/session/session.jsonl" \
|
|
119
|
+
--session-dir "$run/session" \
|
|
120
|
+
--ak-role judge --mode json \
|
|
121
|
+
"Adjudicate the attached materials." \
|
|
122
|
+
</dev/null >/dev/null 2>"$run/stderr.log"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`--session` 指精确 session 文件正本(非 directory-latest);`--session-dir` 为其目录。大理寺的指令走 prompt;其余角色经各自内部旗标传持久 payload 文件(`--ak-coder-task`、`--ak-fix-packet` 等),由各角色 builder(`src/public-cli/*-run.ts`)经装载边界 `src/public-cli/explicit-internal.ts` 装配。旗标从源码与卷宗实记推导,勿从散文推导。
|
|
126
|
+
|
|
127
|
+
纪律:
|
|
128
|
+
|
|
129
|
+
- stdin 须以 `</dev/null` 封死——Pi 会将非 TTY stdin 读到 EOF 才开工,未封死的后台管道=永久停车;
|
|
130
|
+
- stdout 丢 `/dev/null`——session 文件才是正本,stdout 是无上限副本面;仪表挂 `stderr.log` 与 session 文件;
|
|
131
|
+
- `stderr.log` 与 `invocation.json` 落在同次 `runs/` 目录,如上例。
|
|
132
|
+
|
|
133
|
+
Codex fast 档:开启:`echo "fast_mode = on" > ~/.pi-codex-fast`;关闭:`echo "fast_mode = off" > ~/.pi-codex-fast`(或删文件)。修改后无需重启,下一个请求即生效。Fast 档价格高于默认档。
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
This project (`@akagilnc/pi-workflow-roles`) is licensed under **Apache-2.0**.
|
|
4
|
+
The notices below are **third-party** licenses and are **not** the project
|
|
5
|
+
license authority. Do not treat them as dual-licensing the package.
|
|
6
|
+
|
|
7
|
+
## mattpocock/skills (MIT)
|
|
8
|
+
|
|
9
|
+
Upstream provenance: [mattpocock/skills](https://github.com/mattpocock/skills).
|
|
10
|
+
|
|
11
|
+
This package ships or will ship pinned snapshots of the following skills from
|
|
12
|
+
that upstream repository. Each shipped method records immutable upstream
|
|
13
|
+
commit/tag identity, per-file digests and git blob OIDs, and attribution under
|
|
14
|
+
`resources/methods/<name>/provenance.json`.
|
|
15
|
+
|
|
16
|
+
- `tdd` — shipped unchanged under `resources/methods/tdd/` from upstream
|
|
17
|
+
`skills/engineering/tdd` at commit `8b36d4fb2635b3c21998dcd8144439c9e5ba7302`
|
|
18
|
+
(tag `v1.2.2`) (#109)
|
|
19
|
+
- `diagnosing-bugs` — shipped under `resources/methods/diagnosing-bugs/` from
|
|
20
|
+
upstream `skills/engineering/diagnosing-bugs` at the same commit/tag, with
|
|
21
|
+
package adaptation `fixer-boundary-no-external-skill-chain` so the Fixer
|
|
22
|
+
method cannot automatically launch architecture Grill or other role-external
|
|
23
|
+
Skill chains (#110)
|
|
24
|
+
- `code-review` — shipped under `resources/methods/code-review/` from
|
|
25
|
+
upstream `skills/engineering/code-review` at the same commit/tag, with
|
|
26
|
+
package adaptation `reviewer-no-setup-fixed-target-two-axis` so Reviewer
|
|
27
|
+
remains usable without Matt setup files, does not modify project governance
|
|
28
|
+
as setup, preserves Standards/Spec axes, and never turns scratch probes into
|
|
29
|
+
product repairs (#111)
|
|
30
|
+
- `resolving-merge-conflicts` — shipped under `resources/methods/resolving-merge-conflicts/` from
|
|
31
|
+
upstream `skills/engineering/resolving-merge-conflicts` at the same commit/tag, with
|
|
32
|
+
package adaptation `merger-merge-only-escalate-new-intent` so Merger stays merge-only,
|
|
33
|
+
escalates new intent/authority instead of guessing, and does not inherit upstream
|
|
34
|
+
unconditional-resolution or rebase workflow (#114)
|
|
35
|
+
|
|
36
|
+
The complete upstream MIT license text follows.
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
MIT License
|
|
40
|
+
|
|
41
|
+
Copyright (c) 2026 Matt Pocock
|
|
42
|
+
|
|
43
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
44
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
45
|
+
in the Software without restriction, including without limitation the rights
|
|
46
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
47
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
48
|
+
furnished to do so, subject to the following conditions:
|
|
49
|
+
|
|
50
|
+
The above copyright notice and this permission notice shall be included in all
|
|
51
|
+
copies or substantial portions of the Software.
|
|
52
|
+
|
|
53
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
54
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
55
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
56
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
57
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
58
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
59
|
+
SOFTWARE.
|
|
60
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { basename, dirname, isAbsolute, resolve } from "node:path";
|
|
3
|
+
const GIT_DISCOVERY_ENV_KEYS = [
|
|
4
|
+
"GIT_DIR",
|
|
5
|
+
"GIT_COMMON_DIR",
|
|
6
|
+
"GIT_WORK_TREE",
|
|
7
|
+
"GIT_CEILING_DIRECTORIES",
|
|
8
|
+
"GIT_DISCOVERY_ACROSS_FILESYSTEM"
|
|
9
|
+
];
|
|
10
|
+
function envWithoutGitDiscovery(base = process.env) {
|
|
11
|
+
const env = { ...base };
|
|
12
|
+
for (const key of GIT_DISCOVERY_ENV_KEYS) {
|
|
13
|
+
delete env[key];
|
|
14
|
+
}
|
|
15
|
+
return env;
|
|
16
|
+
}
|
|
17
|
+
class ActivationGitRepositoryRequiredError extends Error {
|
|
18
|
+
code = "AK_ACTIVATION_GIT_REPOSITORY_REQUIRED";
|
|
19
|
+
constructor(detail, options) {
|
|
20
|
+
super(
|
|
21
|
+
`Workflow role activation requires a git repository cwd (git rev-parse --git-common-dir failed): ${detail || "unknown git error"}`,
|
|
22
|
+
options?.cause === void 0 ? void 0 : { cause: options.cause }
|
|
23
|
+
);
|
|
24
|
+
this.name = "ActivationGitRepositoryRequiredError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function isGitSpawnInfrastructureError(error) {
|
|
28
|
+
if (error === null || typeof error !== "object" || !("code" in error)) return false;
|
|
29
|
+
const code = error.code;
|
|
30
|
+
return code === "ENOENT" || code === "EACCES" || code === "EPERM";
|
|
31
|
+
}
|
|
32
|
+
function gitChildExitedNonzero(error) {
|
|
33
|
+
if (error === null || typeof error !== "object" || !("status" in error)) return false;
|
|
34
|
+
const status = error.status;
|
|
35
|
+
return typeof status === "number" && status !== 0;
|
|
36
|
+
}
|
|
37
|
+
function resolveBookKeyFromGit(cwd) {
|
|
38
|
+
let commonDir;
|
|
39
|
+
try {
|
|
40
|
+
commonDir = execFileSync("git", ["rev-parse", "--git-common-dir"], {
|
|
41
|
+
cwd,
|
|
42
|
+
encoding: "utf8",
|
|
43
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
44
|
+
env: envWithoutGitDiscovery()
|
|
45
|
+
}).trim();
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (isGitSpawnInfrastructureError(error) || !gitChildExitedNonzero(error)) {
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
const err = error;
|
|
51
|
+
const detail = typeof err.stderr === "string" ? err.stderr.trim() : Buffer.isBuffer(err.stderr) ? err.stderr.toString("utf8").trim() : typeof err.message === "string" ? err.message : "";
|
|
52
|
+
throw new ActivationGitRepositoryRequiredError(detail || "unknown git error", { cause: error });
|
|
53
|
+
}
|
|
54
|
+
if (commonDir.length === 0) {
|
|
55
|
+
throw new Error("git rev-parse --git-common-dir returned an empty path");
|
|
56
|
+
}
|
|
57
|
+
const absoluteCommon = isAbsolute(commonDir) ? commonDir : resolve(cwd, commonDir);
|
|
58
|
+
const hostDirectory = basename(absoluteCommon) === ".git" ? dirname(absoluteCommon) : absoluteCommon;
|
|
59
|
+
const bookKey = basename(hostDirectory);
|
|
60
|
+
if (bookKey.length === 0 || bookKey === "." || bookKey === "/") {
|
|
61
|
+
throw new Error(`Unable to derive activation book key from git common dir: ${absoluteCommon}`);
|
|
62
|
+
}
|
|
63
|
+
return bookKey;
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
ActivationGitRepositoryRequiredError,
|
|
67
|
+
resolveBookKeyFromGit
|
|
68
|
+
};
|