@nick848/ft 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +259 -0
- package/dist/index.js +968 -0
- package/dist/index.js.map +1 -0
- package/locales/en.json +45 -0
- package/locales/zh-CN.json +45 -0
- package/package.json +65 -0
- package/rules-templates/codex.md +10 -0
- package/rules-templates/cursor.mdc +16 -0
- package/rules-templates/opencode.md +10 -0
- package/templates/AGENTS.md.en.hbs +46 -0
- package/templates/AGENTS.md.zh.hbs +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 nick848
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# FT(Frontend Toolkit)
|
|
2
|
+
|
|
3
|
+
FT 是一个**前端开发工具编排层**。它以 [Comet](https://www.npmjs.com/package/@rpamis/comet) 为工作流基座,将 [andrej-karpathy-skills](https://github.com/multica-ai/andrej-karpathy-skills) 作为 AI 行为的强制约束,并可选择性接入 [GitNexus](https://www.npmjs.com/package/gitnexus) 代码图谱。
|
|
4
|
+
|
|
5
|
+
FT **不内置任何 LLM**。它的职责是通过 CLI 命令和 IDE Slash 命令,引导 Cursor、Codex、OpenCode 中的 LLM 完成开发任务。
|
|
6
|
+
|
|
7
|
+
## 核心特性
|
|
8
|
+
|
|
9
|
+
| 特性 | 说明 |
|
|
10
|
+
|------|------|
|
|
11
|
+
| **零 LLM** | FT 不做推理、不生成代码,所有智能行为由 IDE 内 LLM 完成 |
|
|
12
|
+
| **Comet 透传** | `/ft-open`、`/ft-build` 等命令透传 Comet 工作流,保持原生能力 |
|
|
13
|
+
| **RTK 压缩** | 子进程长输出自动中间截断,降低 Token 消耗;`--json` 等结构化输出自动放行 |
|
|
14
|
+
| **Karpathy 约束** | 初始化时向三平台注入四条行为准则规则文件 |
|
|
15
|
+
| **GitNexus 可选** | 安装后自动配置 MCP;未安装时能力优雅降级 |
|
|
16
|
+
| **双语支持** | CLI 输出与 AGENTS.md 模板支持 `zh-CN` / `en` |
|
|
17
|
+
|
|
18
|
+
## 环境依赖
|
|
19
|
+
|
|
20
|
+
### 必需
|
|
21
|
+
|
|
22
|
+
| 依赖 | 版本 | 说明 |
|
|
23
|
+
|------|------|------|
|
|
24
|
+
| **Node.js** | `>= 18` | FT 运行时 |
|
|
25
|
+
| **npm** | 任意较新版本 | 安装与更新 FT、Comet |
|
|
26
|
+
| **Comet** | 全局安装 | `npm install -g @rpamis/comet` — `ft init` 的强制依赖 |
|
|
27
|
+
|
|
28
|
+
### 可选
|
|
29
|
+
|
|
30
|
+
| 依赖 | 安装方式 | 说明 |
|
|
31
|
+
|------|----------|------|
|
|
32
|
+
| **GitNexus** | `npm install -g gitnexus` | 代码图谱与 MCP 符号查询 |
|
|
33
|
+
| **Cursor / Codex / OpenCode** | 各工具官网 | Slash 命令与规则注入的目标 IDE |
|
|
34
|
+
|
|
35
|
+
### 支持平台
|
|
36
|
+
|
|
37
|
+
当前版本支持以下 IDE / 开发工具:
|
|
38
|
+
|
|
39
|
+
- **Cursor**
|
|
40
|
+
- **Codex**
|
|
41
|
+
- **OpenCode**
|
|
42
|
+
|
|
43
|
+
初始化时可将 Karpathy 规则注入到对应平台,并在已安装 GitNexus 时自动配置 MCP。
|
|
44
|
+
|
|
45
|
+
## 安装
|
|
46
|
+
|
|
47
|
+
### 全局安装
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install -g @nick848/ft
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
验证安装:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
ft version
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 快速开始
|
|
60
|
+
|
|
61
|
+
### 1. 安装前置依赖
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm install -g @rpamis/comet
|
|
65
|
+
# 可选
|
|
66
|
+
npm install -g gitnexus
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 2. 在目标项目中初始化
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cd your-frontend-project
|
|
73
|
+
ft init
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`ft init` 将依次执行:
|
|
77
|
+
|
|
78
|
+
1. 检测 Comet(缺失则阻塞退出)
|
|
79
|
+
2. 检测 Karpathy 规则(内置模板可用则通过)
|
|
80
|
+
3. 交互选择注入目标(Cursor / Codex / OpenCode)
|
|
81
|
+
4. 复制 Karpathy 规则到对应平台目录
|
|
82
|
+
5. 若已安装 GitNexus,自动写入 MCP 配置
|
|
83
|
+
6. 生成 `AGENTS.md`(旧文件备份为 `AGENTS-BAK.md`)
|
|
84
|
+
7. 执行 `comet init`
|
|
85
|
+
8. 提示下一步执行 `/ft-fill-context`
|
|
86
|
+
|
|
87
|
+
英文初始化:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
ft init --lang en
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 3. 填充项目上下文
|
|
94
|
+
|
|
95
|
+
在 IDE 聊天框执行 `/ft-fill-context`,将输出的 Prompt 粘贴给 LLM,由 LLM 编辑 `AGENTS.md` 中的 `[NEEDS LLM INPUT]` 占位符。
|
|
96
|
+
|
|
97
|
+
### 4. 使用 Comet 工作流
|
|
98
|
+
|
|
99
|
+
上下文填充完成后,在 IDE 中使用 Slash 命令驱动 Comet 流程,例如:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
/ft-design
|
|
103
|
+
/ft-build
|
|
104
|
+
/ft-verify
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## CLI 命令
|
|
108
|
+
|
|
109
|
+
| 命令 | 说明 |
|
|
110
|
+
|------|------|
|
|
111
|
+
| `ft init [--lang en\|zh-CN]` | 全流程初始化(依赖检测 → 规则注入 → MCP → AGENTS.md → Comet init) |
|
|
112
|
+
| `ft update` | 更新 FT 自身(`npm update -g @nick848/ft`),不更新 Comet / GitNexus |
|
|
113
|
+
| `ft version` | 打印 FT、Comet、GitNexus 版本号 |
|
|
114
|
+
| `ft help` | 显示帮助信息 |
|
|
115
|
+
|
|
116
|
+
## Slash 命令
|
|
117
|
+
|
|
118
|
+
所有 `/ft-xxx` 命令在 IDE 中触发,并自动继承 RTK 输出压缩能力。
|
|
119
|
+
|
|
120
|
+
### 上下文
|
|
121
|
+
|
|
122
|
+
| Slash 命令 | 说明 |
|
|
123
|
+
|------------|------|
|
|
124
|
+
| `/ft-fill-context` | 输出结构化 Prompt,引导 LLM 填充 `AGENTS.md` |
|
|
125
|
+
|
|
126
|
+
> **门禁**:`AGENTS.md` 中仍存在 `[NEEDS LLM INPUT]` 时,Comet 透传类命令会被拦截,须先完成 `/ft-fill-context`。
|
|
127
|
+
|
|
128
|
+
### Comet 工作流(透传)
|
|
129
|
+
|
|
130
|
+
| Slash 命令 | 说明 |
|
|
131
|
+
|------------|------|
|
|
132
|
+
| `/ft-open` | Comet `open` |
|
|
133
|
+
| `/ft-design` | Comet `design` |
|
|
134
|
+
| `/ft-build` | Comet `build` |
|
|
135
|
+
| `/ft-verify` | Comet `verify` |
|
|
136
|
+
| `/ft-archive` | Comet `archive` |
|
|
137
|
+
| `/ft-hotfix` | Comet `hotfix` |
|
|
138
|
+
| `/ft-tweak` | Comet `tweak` |
|
|
139
|
+
|
|
140
|
+
**TTY 处理**:在系统终端中保持 Comet 原生交互;在 IDE 非 TTY 环境中尝试注入 `--non-interactive`,若 Comet 不支持则提示转至系统终端执行。
|
|
141
|
+
|
|
142
|
+
### GitNexus 图谱
|
|
143
|
+
|
|
144
|
+
| Slash 命令 | 说明 |
|
|
145
|
+
|------------|------|
|
|
146
|
+
| `/ft-graph-setup` | 安装引导 + MCP 配置重试 |
|
|
147
|
+
| `/ft-graph-init` | 首次构建图谱(`gitnexus analyze`) |
|
|
148
|
+
| `/ft-graph-refresh` | 强制刷新图谱(`gitnexus analyze --force`) |
|
|
149
|
+
| `/ft-graph-handoff` | 图谱摘要 + 引导词 + 更新 AGENTS.md 时间戳 |
|
|
150
|
+
| `/ft-graph-status` | 检查 GitNexus 与图谱索引状态 |
|
|
151
|
+
|
|
152
|
+
## IDE Slash 配置
|
|
153
|
+
|
|
154
|
+
FT 不直接修改 IDE,需在各平台中配置自定义命令,统一调用 `ft slash <subcommand>`。
|
|
155
|
+
|
|
156
|
+
### Cursor
|
|
157
|
+
|
|
158
|
+
在项目 `.cursor/commands/` 下创建命令文件,例如 `ft-fill-context.md`:
|
|
159
|
+
|
|
160
|
+
```markdown
|
|
161
|
+
---
|
|
162
|
+
description: Fill AGENTS.md context via FT prompt recipe
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
Run: ft slash fill-context
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
或在 Cursor Settings → Commands 中添加,命令内容为:
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
ft slash fill-context
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
其他 Slash 同理,将 `fill-context` 替换为对应子命令名(`open`、`design`、`build` 等)。
|
|
175
|
+
|
|
176
|
+
### Codex / OpenCode
|
|
177
|
+
|
|
178
|
+
参考各平台自定义 Slash / Command 机制,将触发动作配置为:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
ft slash <subcommand>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
确保 `ft` 在 IDE 子进程的 `PATH` 中可用(全局安装后一般即可)。
|
|
185
|
+
|
|
186
|
+
## 配置文件
|
|
187
|
+
|
|
188
|
+
初始化后会在项目根目录生成 `.ft/config.yaml`:
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
# 语言:zh-CN 或 en
|
|
192
|
+
language: zh-CN
|
|
193
|
+
|
|
194
|
+
# RTK 压缩层
|
|
195
|
+
rtk:
|
|
196
|
+
enabled: true
|
|
197
|
+
auto_trigger_lines: 500 # 超过此行数强制压缩(即使全局关闭)
|
|
198
|
+
exclude_patterns: # 匹配则跳过压缩,保留原始输出
|
|
199
|
+
- "--json"
|
|
200
|
+
- "--format json"
|
|
201
|
+
- "--xml"
|
|
202
|
+
|
|
203
|
+
# 已注入规则的目标工具
|
|
204
|
+
tools:
|
|
205
|
+
- cursor
|
|
206
|
+
- codex
|
|
207
|
+
- opencode
|
|
208
|
+
|
|
209
|
+
# GitNexus
|
|
210
|
+
gitnexus:
|
|
211
|
+
graph_path: ".gitnexus/"
|
|
212
|
+
auto_prompt_in_agents: true
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**语言优先级**:CLI 参数(`--lang`)> 配置文件 > 默认 `zh-CN`。
|
|
216
|
+
|
|
217
|
+
也可使用 `ft.config.json` 等同名配置文件。
|
|
218
|
+
|
|
219
|
+
## 典型工作流
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
ft init
|
|
223
|
+
↓
|
|
224
|
+
/ft-fill-context → LLM 填充 AGENTS.md
|
|
225
|
+
↓
|
|
226
|
+
/ft-graph-setup → (可选)安装并配置 GitNexus MCP
|
|
227
|
+
/ft-graph-init → (可选)构建代码图谱
|
|
228
|
+
↓
|
|
229
|
+
/ft-design → Comet 设计阶段
|
|
230
|
+
/ft-build → Comet 构建阶段
|
|
231
|
+
/ft-verify → Comet 验证阶段
|
|
232
|
+
↓
|
|
233
|
+
/ft-graph-handoff → (可选)交接图谱上下文给 LLM
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## RTK 输出压缩
|
|
237
|
+
|
|
238
|
+
FT 拦截子进程 `stdout` / `stderr`,对长文本采用**中间截断**策略:
|
|
239
|
+
|
|
240
|
+
- 保留前 **200** 行 + 后 **100** 行
|
|
241
|
+
- 中间以 `...... (已省略 X 行) ......` 替换
|
|
242
|
+
- 命令参数含 `--json`、`--format json`、`--xml` 时完全旁路
|
|
243
|
+
- Comet 透传且处于 TTY 交互模式时自动禁用,避免破坏 TUI
|
|
244
|
+
|
|
245
|
+
## 已知限制
|
|
246
|
+
|
|
247
|
+
- **AGENTS-BAK 合并**依赖 LLM 判断,超模板章节迁移可能存在轻微随机性
|
|
248
|
+
- **IDE 内 Comet 透传**:若 Comet 不支持 `--non-interactive`,须在系统终端执行对应 `comet` 命令
|
|
249
|
+
- **平台范围**:当前仅支持 Cursor、Codex、OpenCode
|
|
250
|
+
|
|
251
|
+
## 相关链接
|
|
252
|
+
|
|
253
|
+
- Comet:`npm install -g @rpamis/comet`
|
|
254
|
+
- Karpathy Skills:https://github.com/multica-ai/andrej-karpathy-skills
|
|
255
|
+
- GitNexus:`npm install -g gitnexus`
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
MIT
|