@xcompiler/cli 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.
- package/LICENSE +201 -0
- package/NOTICE +10 -0
- package/README.CN.md +272 -0
- package/README.md +274 -0
- package/dist/acp/index.d.ts +1135 -0
- package/dist/acp/index.js +13452 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/cli/xcompiler.d.ts +2 -0
- package/dist/cli/xcompiler.js +14815 -0
- package/dist/cli/xcompiler.js.map +1 -0
- package/dist/cli/xcompiler_build.d.ts +2 -0
- package/dist/cli/xcompiler_build.js +8009 -0
- package/dist/cli/xcompiler_build.js.map +1 -0
- package/dist/cli/xcompiler_run.d.ts +2 -0
- package/dist/cli/xcompiler_run.js +10736 -0
- package/dist/cli/xcompiler_run.js.map +1 -0
- package/dist/plugins/index.d.ts +809 -0
- package/dist/plugins/index.js +1829 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/runtime/runtime.d.ts +1217 -0
- package/dist/runtime/runtime.js +13397 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/docs/acp.md +64 -0
- package/docs/plugin_api.md +106 -0
- package/docs/self_bootstrap.md +88 -0
- package/docs/versioning.md +33 -0
- package/package.json +108 -0
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 describing the origin of the Work and
|
|
141
|
+
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 Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
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 The XCompiler Authors
|
|
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
|
|
200
|
+
implied. See the License for the specific language governing permissions
|
|
201
|
+
and limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
XCompiler — Extensible Compiler
|
|
2
|
+
Copyright 2026 The XCompiler Authors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by The XCompiler Authors.
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License.
|
|
8
|
+
You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
package/README.CN.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# XCompiler — Extensible Compiler
|
|
2
|
+
|
|
3
|
+
> 多 LLM 协同 + V 模型驱动的 AI 软件工厂 / Software Factory CLI
|
|
4
|
+
> 输入一段自然语言需求 → 自动产出可运行、可测试、可交付的 Python 或 TypeScript 工程
|
|
5
|
+
> Apache License 2.0
|
|
6
|
+
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
|
|
10
|
+
🌐 **语言**: [EN](README.md) (默认) · **简体中文**
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 这是什么
|
|
15
|
+
|
|
16
|
+
XCompiler 把"写代码"这件事按"编译 → 执行"两阶段拆分,对标传统编译器的 `cc` / `a.out`:
|
|
17
|
+
|
|
18
|
+
| 命令 | 定位 | 输入 | 输出 |
|
|
19
|
+
|---|---|---|---|
|
|
20
|
+
| **`xcompiler build`** | **AI 编译器** —— 把自然语言需求"翻译"成可执行的阶段步骤(plan) | 一段需求文本(`-i req.md` 或交互输入) | `plan.json`(拓扑有序的 Step DAG)+ `topic.md` + `plan.md` |
|
|
21
|
+
| **`xcompiler run`** | **AI 执行器** —— 按拓扑顺序依次执行编译输出的阶段步骤 | `plan.json` | 可运行 Python/TypeScript 工程 + 绿色测试 + `docs/05-delivery.md` |
|
|
22
|
+
|
|
23
|
+
> 类比:`xcompiler build` ≈ 编译器把 C 源码翻译成机器指令;`xcompiler run` ≈ CPU 顺次执行这些指令。
|
|
24
|
+
> 区别:XCompiler 的"指令"是 V 模型阶段(REQUIREMENT / ARCH / CODE / TEST / REFACTOR / DELIVERY),"执行单元"是受沙盒约束的多 Agent 循环。
|
|
25
|
+
|
|
26
|
+
每个 Step 都有 git 快照与审计日志,失败自动进入 DEBUG 闭环重试(≤ 3 次)。
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 内置 V 模型流程
|
|
31
|
+
|
|
32
|
+
XCompiler 把软件工程的 **V 模型** 直接编码为 `xcompiler build` 的拆解骨架与 `xcompiler run` 的执行调度。每个阶段都有强制产物、强制工具白名单、强制质量门:
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
┌────────── xcompiler build (AI 编译器) ──────────┐
|
|
36
|
+
│ │
|
|
37
|
+
需求 (NL) ───► Intake ──► Clarify ──► Decompose ──► plan.json
|
|
38
|
+
│ │
|
|
39
|
+
└─ Gate 1 ───┘ Gate 2 (人工双确认门)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
┌─────────── xcompiler run (AI 执行器) ──────────────┐
|
|
43
|
+
│ 按 V 模型左→右→回环 拓扑执行 │
|
|
44
|
+
|
|
45
|
+
REQUIREMENT ◄──────── verify ─────────► DELIVERY
|
|
46
|
+
│ ▲
|
|
47
|
+
▼ │
|
|
48
|
+
ARCH ◄───── refactor / docs ─────► REFACTOR
|
|
49
|
+
│ ▲
|
|
50
|
+
▼ │
|
|
51
|
+
CODE ◄────── test gate ──────────► TEST
|
|
52
|
+
│ ▲
|
|
53
|
+
└─────────────► DEBUG (≤3 retries) ──────┘
|
|
54
|
+
(失败自动闭环)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
| 阶段 | 主导 Agent / Skill | 强制产物 | 质量门 |
|
|
58
|
+
|---|---|---|---|
|
|
59
|
+
| REQUIREMENT | Planner | `topic.md` | Gate 1 人工确认 |
|
|
60
|
+
| ARCH | Architect | `architecture.md` + 语言清单(`requirements.txt` / `package.json`) | plan lint |
|
|
61
|
+
| CODE | Coder (`patcher` / `author`) | `src/**.{py,ts}` | EditGuard 行数上限 |
|
|
62
|
+
| TEST | Tester (`tester`) | `tests/**.{py,ts}` | **测试 exit=0** |
|
|
63
|
+
| DEBUG | Debugger (`debugger`) | 修复 patch | ≤ `max_debug_retries` |
|
|
64
|
+
| REFACTOR | Refactorer | 优化后的 `src/` | 测试不退化 |
|
|
65
|
+
| DELIVERY | Author | `docs/05-delivery.md` | 全 Step DONE |
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 系统结构 / 层次
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
73
|
+
│ CLI 入口层 │
|
|
74
|
+
│ xcompiler ─┬─ xcompiler build (= xcompiler_build) AI 编译器 │
|
|
75
|
+
│ └─ xcompiler run (= xcompiler_run) AI 执行器 │
|
|
76
|
+
│ + xcompiler ls / show │
|
|
77
|
+
└──────────────────┬───────────────────────────────┬──────────────┘
|
|
78
|
+
│ │
|
|
79
|
+
▼ ▼
|
|
80
|
+
┌────────────────────┐ ┌──────────────────────┐
|
|
81
|
+
│ Planner (compile) │ │ PhaseEngine (run) │
|
|
82
|
+
│ - intake/clarify │ │ - 拓扑调度 │
|
|
83
|
+
│ - decompose (V) │ │ - DEBUG 闭环 │
|
|
84
|
+
│ - plan lint │ │ - 断点续跑 │
|
|
85
|
+
└─────────┬──────────┘ └──────────┬───────────┘
|
|
86
|
+
│ │
|
|
87
|
+
▼ ▼
|
|
88
|
+
┌──────────────────────────────────────────────┐
|
|
89
|
+
│ Agent / Skill 层 │
|
|
90
|
+
│ Architect · Coder · Tester · Debugger · │
|
|
91
|
+
│ Refactorer · Author │
|
|
92
|
+
│ Skills: patcher / author / tester / │
|
|
93
|
+
│ dep_resolver / debugger / refactor │
|
|
94
|
+
└──────────────────┬───────────────────────────┘
|
|
95
|
+
│
|
|
96
|
+
▼
|
|
97
|
+
┌─────────────────────────────────────────────────────┐
|
|
98
|
+
│ Tool 层(白名单 + EditGuard) │
|
|
99
|
+
│ read_file · write_file · append_file · │
|
|
100
|
+
│ replace_in_file · run_program · run_tests · git_* │
|
|
101
|
+
└──────────────────┬──────────────────────────────────┘
|
|
102
|
+
│
|
|
103
|
+
┌──────────────┼──────────────────┐
|
|
104
|
+
▼ ▼ ▼
|
|
105
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────────┐
|
|
106
|
+
│ LLM Router │ │ Sandbox │ │ Workspace │
|
|
107
|
+
│ chain + │ │ subprocess │ │ git + audit │
|
|
108
|
+
│ fallback │ │ / docker │ │ + .xcompiler/ │
|
|
109
|
+
│ (ollama, │ │ venv 隔离 │ │ plan.json │
|
|
110
|
+
│ openai) │ │ │ │ │
|
|
111
|
+
└──────────────┘ └──────────────┘ └──────────────────┘
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
运行时还提供类型安全的 PluginHost,覆盖 compile、LLM、run、step、attempt 和 tool
|
|
115
|
+
等关键边界。插件可以注册 Tool / Skill,但仍受原有工具白名单与 EditGuard 安全模型约束。
|
|
116
|
+
|
|
117
|
+
各层职责:
|
|
118
|
+
|
|
119
|
+
- **CLI 层**:参数解析、workspace 锁、`--force` / `--from` / `--phase` 等运行模式。
|
|
120
|
+
- **Planner / PhaseEngine**:分别对应"编译"与"执行"的总调度。
|
|
121
|
+
- **Agent / Skill**:每个 Skill 是一组「角色 + System Prompt + 工具白名单」,绑定到 V 模型的某个阶段。
|
|
122
|
+
- **Tool**:原子操作,全部经 EditGuard / 白名单审查;写入只允许落在 Step 声明的 outputs 内。
|
|
123
|
+
- **LLM Router**:多 provider 链式回退(chain + fallbacks)+ 全量审计。
|
|
124
|
+
- **Sandbox**:Python 走 venv/pip/pytest;TypeScript 走 npm/tsx/vitest,可选 subprocess 或 docker。
|
|
125
|
+
- **Workspace**:git 快照 + `.xcompiler/audit.jsonl` + `.xcompiler/.lock`,可断点续跑。
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 快速开始
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# 1. 安装依赖
|
|
133
|
+
npm ci
|
|
134
|
+
cp .env.example .env # 填入 OLLAMA_BASE_URL 等
|
|
135
|
+
cp config.example.yaml config.yaml
|
|
136
|
+
|
|
137
|
+
# 2. 构建并安装为全局命令
|
|
138
|
+
npm run build
|
|
139
|
+
npm link # 或 npm install -g .
|
|
140
|
+
xcompiler --help
|
|
141
|
+
|
|
142
|
+
# 3. 写需求 → 编译 plan
|
|
143
|
+
echo "把 DBC 文件解析为 Excel 报表" > req.md
|
|
144
|
+
xcompiler build -i req.md --yes
|
|
145
|
+
|
|
146
|
+
# 4. 执行 plan
|
|
147
|
+
xcompiler run /tmp/xcompiler-<时间戳>/plan.json
|
|
148
|
+
|
|
149
|
+
# 5. 之后从生成的工程文件恢复
|
|
150
|
+
xcompiler load /tmp/xcompiler-<时间戳>/xcompiler-<时间戳>.xc
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
开发模式(无需构建):
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npm run dev -- build
|
|
157
|
+
npm run dev -- run path/to/plan.json
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
基于已有工程做增量开发:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# 在当前 workspace 基线之上新增 feature
|
|
164
|
+
xcompiler build -w path/to/workspace -i feature_req.md --intent feature --yes
|
|
165
|
+
|
|
166
|
+
# 或一条命令完成 compile + run
|
|
167
|
+
xcompiler evolve -w path/to/workspace -i refactor_req.md --intent refactor --yes
|
|
168
|
+
|
|
169
|
+
# 在同一个工程上追加新需求,仍走澄清 + V 模型
|
|
170
|
+
xcompiler append path/to/workspace/<name>.xc -i feature_req.md --yes
|
|
171
|
+
|
|
172
|
+
# 在隔离 worktree 中让稳定版本构建、验证下一代 XCompiler
|
|
173
|
+
xcompiler bootstrap -r path/to/XCompiler -i self_req.md --yes
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 常用选项
|
|
177
|
+
|
|
178
|
+
| 命令 | 选项 | 用途 |
|
|
179
|
+
|---|---|---|
|
|
180
|
+
| `xcompiler build` | `-i <file>` | 使用需求文件,跳过交互输入 |
|
|
181
|
+
| `xcompiler build` | `-t <file>` | 复用已有 `topic.md`,跳过 Gate 1 |
|
|
182
|
+
| `xcompiler build` | `--intent <greenfield\|feature\|refactor\|self>` | 选择新建、增量或隔离自举规划 |
|
|
183
|
+
| `xcompiler build` | `--baseline-plan <file>` | 为增量规划显式指定已有 `plan.json` |
|
|
184
|
+
| `xcompiler build` / `xcompiler run` | `--project-file <file>` | 创建/更新指定的 `XXX.xc` 工程文件 |
|
|
185
|
+
| `xcompiler build` | `--force` | 覆写 workspace 锁,强制重新生成 plan |
|
|
186
|
+
| `xcompiler evolve` | `...` | 先编译增量 plan,再在同一 workspace 内立即执行 |
|
|
187
|
+
| `xcompiler load <XXX.xc>` | — | 读取工程配置/进度并继续当前 plan |
|
|
188
|
+
| `xcompiler append <XXX.xc>` | `-i <file>` | 在已有工程上澄清并执行新的增量需求 |
|
|
189
|
+
| `xcompiler bootstrap` | `--promote` | 质量门全部通过后显式快进晋级候选版本;默认只生成候选和报告 |
|
|
190
|
+
| `xcompiler bootstrap` | `--docker-qualification` | 显式启用实验性 Docker 质量门;默认使用 subprocess 沙箱 |
|
|
191
|
+
| `xcompiler run` | `--reset` | 重置所有 Step 为 PENDING |
|
|
192
|
+
| `xcompiler run` | `--force` | 等价于 `--reset` + 覆写锁 |
|
|
193
|
+
| `xcompiler run` | `--from <stepId>` / `--phase <phase>` | 断点续跑 / 仅跑某阶段 |
|
|
194
|
+
| `xcompiler run` | `--dry-run` | 仅打印拓扑顺序 |
|
|
195
|
+
| `xcompiler ls` | — | 扫描 workspace 列出所有 plan 状态 |
|
|
196
|
+
| `xcompiler show <stepId>` | — | 查看单 Step 定义 / 产物 / 最近审计 |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 默认运行时
|
|
201
|
+
|
|
202
|
+
- **LLM**:本地 ollama(`gemma4:31b` Planner/Architect,`qwen3-coder:30b` Coder/Tester/Debugger)。
|
|
203
|
+
在 `config.yaml` 中 `fallbacks: [openai]` 让主链失败时自动回落 OpenAI 兼容 endpoint。
|
|
204
|
+
- **i18n**:在 `config.yaml` 顶层设置 `locale: en` 或 `locale: zh`,控制 CLI 与 prompt 语言。
|
|
205
|
+
- **Sandbox**:默认 `subprocess`(在 `<workspace>/.sandbox/<project>/` 建独立 venv);可切到 `docker` 走 bind-mount + 网络/资源限制。
|
|
206
|
+
- **Audit**:每次运行生成 `<workspace>/.xcompiler/audit.jsonl` 与 `docs/process_log.md`,记录全部 LLM 输入输出、工具调用、Step 状态变更。
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## 文档
|
|
211
|
+
|
|
212
|
+
| 路径 | 内容 |
|
|
213
|
+
|---|---|
|
|
214
|
+
| [docs/XCompiler_design.md](docs/XCompiler_design.md) | 总体设计:V 模型阶段、Agent / Skill / Tool 抽象、Sandbox 与 Workspace |
|
|
215
|
+
| [docs/implementation_plan.md](docs/implementation_plan.md) | M1 → M6 里程碑与落地步骤 |
|
|
216
|
+
| [docs/deploy.md](docs/deploy.md) | 部署指南(本地 + Docker) |
|
|
217
|
+
| [docs/plugin_api.md](docs/plugin_api.md) | 插件 API、生命周期 Hooks、执行顺序与失败策略 |
|
|
218
|
+
| [docs/versioning.md](docs/versioning.md) | 核心版本、Plugin API 版本、同步命令与发版校验 |
|
|
219
|
+
| [docs/self_bootstrap.md](docs/self_bootstrap.md) | 代际自举、worktree 隔离、质量门与晋级协议 |
|
|
220
|
+
| [docs/dev_audit_log.md](docs/dev_audit_log.md) | XCompiler 自身开发交付日志(每次需求 / 决策 / 产物 / 验证) |
|
|
221
|
+
|
|
222
|
+
> 文档分层:
|
|
223
|
+
> - `docs/` 是唯一文档根目录;设计文档使用语义化名称,V 模型运行产物使用 `01-`~`05-` 阶段前缀。
|
|
224
|
+
> - `docs/dev_audit_log.md` 记录"我们如何建造 XCompiler",是 XCompiler 项目的交付物之一。
|
|
225
|
+
> - `<workspace>/docs/process_log.md` 由运行时 `AuditLogger` 自动生成,记录"用户用 XCompiler 开发某 Python 项目"的全部交互,作为该产品的交付汇总。
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## 运行期调优(`config.yaml → agent.*`)
|
|
230
|
+
|
|
231
|
+
| 字段 | 默认 | 作用 |
|
|
232
|
+
|---|---|---|
|
|
233
|
+
| `max_rounds_per_step` | 6 | 单 Step 中 LLM 多轮对话上限 |
|
|
234
|
+
| `max_debug_rounds_per_step` | `max(8, 2 × max_rounds_per_step)` | DEBUG 重试轮数上限 |
|
|
235
|
+
| `max_debug_retries` | 3 | DEBUG 重试最大次数 |
|
|
236
|
+
| `max_edit_lines_per_step` | `auto` | EditGuard 单 Step 累计写入行数;`auto` 按 phase/tools/outputs/prompt 上下文自适应,数字值表示固定硬上限 |
|
|
237
|
+
| `max_write_chunk_bytes` | `auto` | `write_file` / `append_file` 单次 content 字节预算;`auto` 按 phase/context 自适应,复杂工程仍应按模块/函数/类边界拆分 |
|
|
238
|
+
| `sandbox_limits.network` | `pypi-only` | docker 模式下;`off` 走 `--network none` |
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 测试
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
npm run typecheck
|
|
246
|
+
npm test # vitest,~80 项
|
|
247
|
+
npm run smoke:ollama # 真实 ollama 端到端冒烟
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## 部署
|
|
253
|
+
|
|
254
|
+
完整步骤见 [docs/deploy.md](docs/deploy.md):
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# A. 本地(Node 24 + Python 3)
|
|
258
|
+
npm ci && npm run build && npm link
|
|
259
|
+
xcompiler --help
|
|
260
|
+
|
|
261
|
+
# B. Docker(多阶段镜像 + compose)
|
|
262
|
+
docker build -t xcompiler:latest .
|
|
263
|
+
docker compose run --rm xcompiler --help
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
镜像内置 `python3 / git / docker.io / tini`,沙盒可选 `subprocess`(默认)或 `docker`(DooD,需挂 `/var/run/docker.sock`)。
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## License
|
|
271
|
+
|
|
272
|
+
[Apache License 2.0](LICENSE) © 2026 The XCompiler Authors. 详见 [NOTICE](NOTICE)。
|