@nick848/ft 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # FT(Frontend Toolkit)
2
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) 代码图谱。
3
+ FT 是一个**前端开发工具编排层**。它以 [Comet](https://www.npmjs.com/package/@rpamis/comet) 为工作流基座,将 [andrej-karpathy-skills](https://github.com/multica-ai/andrej-karpathy-skills) 作为 AI 行为的强制约束。
4
4
 
5
- FT **不内置任何 LLM**。它的职责是通过 CLI 命令和 IDE Slash 命令,引导 Cursor、Codex、OpenCode 中的 LLM 完成开发任务。
5
+ FT **不内置任何 LLM**。它的职责是通过 CLI 命令和 IDE Slash 命令,引导 Cursor、Codex、OpenCode 中的 LLM 完成开发任务。代码图谱能力由 Comet 生态(如 CodeGraph)提供,由 `comet init` 引导安装。
6
6
 
7
7
  ## 核心特性
8
8
 
@@ -12,7 +12,6 @@ FT **不内置任何 LLM**。它的职责是通过 CLI 命令和 IDE Slash 命
12
12
  | **Comet 透传** | `/ft-open`、`/ft-build` 等命令透传 Comet 工作流,保持原生能力 |
13
13
  | **RTK 压缩** | 子进程长输出自动中间截断,降低 Token 消耗;`--json` 等结构化输出自动放行 |
14
14
  | **Karpathy 约束** | 初始化时向三平台注入四条行为准则规则文件 |
15
- | **GitNexus 可选** | 安装后自动配置 MCP;未安装时能力优雅降级 |
16
15
  | **双语支持** | CLI 输出与 AGENTS.md 模板支持 `zh-CN` / `en` |
17
16
 
18
17
  ## 环境依赖
@@ -27,43 +26,31 @@ FT **不内置任何 LLM**。它的职责是通过 CLI 命令和 IDE Slash 命
27
26
 
28
27
  ### 可选
29
28
 
30
- | 依赖 | 安装方式 | 说明 |
31
- |------|----------|------|
32
- | **GitNexus** | `npm install -g gitnexus` | 代码图谱与 MCP 符号查询 |
33
- | **Cursor / Codex / OpenCode** | 各工具官网 | Slash 命令与规则注入的目标 IDE |
29
+ | 依赖 | 说明 |
30
+ |------|------|
31
+ | **Cursor / Codex / OpenCode** | Slash 命令与规则注入的目标 IDE |
34
32
 
35
33
  ### 支持平台
36
34
 
37
- 当前版本支持以下 IDE / 开发工具:
38
-
39
35
  - **Cursor**
40
36
  - **Codex**
41
37
  - **OpenCode**
42
38
 
43
- 初始化时可将 Karpathy 规则注入到对应平台,并在已安装 GitNexus 时自动配置 MCP。
39
+ 初始化时可将 Karpathy 规则注入到对应平台,并安装 Cursor Slash 命令。
44
40
 
45
41
  ## 安装
46
42
 
47
- ### 全局安装
48
-
49
43
  ```bash
50
44
  npm install -g @nick848/ft
51
- ```
52
-
53
- 验证安装:
54
-
55
- ```bash
56
45
  ft version
57
46
  ```
58
47
 
59
48
  ## 快速开始
60
49
 
61
- ### 1. 安装前置依赖
50
+ ### 1. 安装 Comet
62
51
 
63
52
  ```bash
64
53
  npm install -g @rpamis/comet
65
- # 可选
66
- npm install -g gitnexus
67
54
  ```
68
55
 
69
56
  ### 2. 在目标项目中初始化
@@ -79,25 +66,21 @@ ft init
79
66
  2. 检测 Karpathy 规则(内置模板可用则通过)
80
67
  3. 交互选择注入目标(Cursor / Codex / OpenCode)
81
68
  4. 复制 Karpathy 规则到对应平台目录
82
- 5. 若已安装 GitNexus,自动写入 MCP 配置
69
+ 5. 若选择 Cursor,安装 `.cursor/commands/` Slash 命令
83
70
  6. 生成 `AGENTS.md`(旧文件备份为 `AGENTS-BAK.md`)
84
- 7. 执行 `comet init`
71
+ 7. 执行 `comet init`(含 CodeGraph 等 Comet 生态引导)
85
72
  8. 提示下一步执行 `/ft-fill-context`
86
73
 
87
- 英文初始化:
88
-
89
74
  ```bash
90
- ft init --lang en
75
+ ft init --lang en # 英文初始化
91
76
  ```
92
77
 
93
78
  ### 3. 填充项目上下文
94
79
 
95
- 在 IDE 聊天框执行 `/ft-fill-context`,将输出的 Prompt 粘贴给 LLM,由 LLM 编辑 `AGENTS.md` 中的 `[NEEDS LLM INPUT]` 占位符。
80
+ 在 IDE 中执行 `/ft-fill-context`,由 Agent 根据终端输出的 Prompt 配方编辑 `AGENTS.md`。
96
81
 
97
82
  ### 4. 使用 Comet 工作流
98
83
 
99
- 上下文填充完成后,在 IDE 中使用 Slash 命令驱动 Comet 流程,例如:
100
-
101
84
  ```
102
85
  /ft-design
103
86
  /ft-build
@@ -108,22 +91,20 @@ ft init --lang en
108
91
 
109
92
  | 命令 | 说明 |
110
93
  |------|------|
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` | 打印 FTComet、GitNexus 版本号 |
94
+ | `ft init [--lang en\|zh-CN]` | 全流程初始化 |
95
+ | `ft update` | 更新 FT 自身,不更新 Comet |
96
+ | `ft version` | 打印 FTComet 版本号 |
114
97
  | `ft help` | 显示帮助信息 |
115
98
 
116
99
  ## Slash 命令
117
100
 
118
- 所有 `/ft-xxx` 命令在 IDE 中触发,并自动继承 RTK 输出压缩能力。
119
-
120
101
  ### 上下文
121
102
 
122
103
  | Slash 命令 | 说明 |
123
104
  |------------|------|
124
105
  | `/ft-fill-context` | 输出结构化 Prompt,引导 LLM 填充 `AGENTS.md` |
125
106
 
126
- > **门禁**:`AGENTS.md` 中仍存在 `[NEEDS LLM INPUT]` 时,Comet 透传类命令会被拦截,须先完成 `/ft-fill-context`。
107
+ > **门禁**:`AGENTS.md` 中仍存在 `[NEEDS LLM INPUT]` 时,Comet 透传类命令会被拦截。
127
108
 
128
109
  ### Comet 工作流(透传)
129
110
 
@@ -136,123 +117,78 @@ ft init --lang en
136
117
  | `/ft-archive` | Comet `archive` |
137
118
  | `/ft-hotfix` | Comet `hotfix` |
138
119
  | `/ft-tweak` | Comet `tweak` |
120
+ | `/ft-sync-cursor-commands` | 重新安装 Cursor Slash 命令到 `.cursor/commands/` |
139
121
 
140
- **TTY 处理**:在系统终端中保持 Comet 原生交互;在 IDE TTY 环境中尝试注入 `--non-interactive`,若 Comet 不支持则提示转至系统终端执行。
122
+ > **门禁**:`AGENTS.md` 中仍存在 `[NEEDS LLM INPUT]` 时,Comet 透传类命令会被拦截。
141
123
 
142
- ### GitNexus 图谱
124
+ **TTY 处理**:终端中保持 Comet 原生交互;IDE 非 TTY 环境尝试 `--non-interactive`,失败则提示在系统终端执行 `comet <command>`。
143
125
 
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
126
+ ## Cursor Slash 命令
157
127
 
158
- 在项目 `.cursor/commands/` 下创建命令文件,例如 `ft-fill-context.md`:
128
+ `ft init` 选择 Cursor 时会自动安装 `.cursor/commands/`。在 **Agent 聊天框**输入 `/` 即可调用。
159
129
 
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 机制,将触发动作配置为:
130
+ 修复命令列表:
179
131
 
180
132
  ```bash
181
- ft slash <subcommand>
133
+ ft slash sync-cursor-commands
182
134
  ```
183
135
 
184
- 确保 `ft` 在 IDE 子进程的 `PATH` 中可用(全局安装后一般即可)。
185
-
186
136
  ## 配置文件
187
137
 
188
- 初始化后会在项目根目录生成 `.ft/config.yaml`:
138
+ `.ft/config.yaml` 示例:
189
139
 
190
140
  ```yaml
191
- # 语言:zh-CN 或 en
192
141
  language: zh-CN
193
142
 
194
- # RTK 压缩层
195
143
  rtk:
196
144
  enabled: true
197
- auto_trigger_lines: 500 # 超过此行数强制压缩(即使全局关闭)
198
- exclude_patterns: # 匹配则跳过压缩,保留原始输出
145
+ auto_trigger_lines: 500
146
+ exclude_patterns:
199
147
  - "--json"
200
148
  - "--format json"
201
149
  - "--xml"
202
150
 
203
- # 已注入规则的目标工具
204
151
  tools:
205
152
  - cursor
206
153
  - codex
207
154
  - opencode
208
-
209
- # GitNexus
210
- gitnexus:
211
- graph_path: ".gitnexus/"
212
- auto_prompt_in_agents: true
213
155
  ```
214
156
 
215
- **语言优先级**:CLI 参数(`--lang`)> 配置文件 > 默认 `zh-CN`。
216
-
217
- 也可使用 `ft.config.json` 等同名配置文件。
218
-
219
157
  ## 典型工作流
220
158
 
221
159
  ```
222
- ft init
160
+ ft init → comet init(CodeGraph 等)
223
161
 
224
162
  /ft-fill-context → LLM 填充 AGENTS.md
225
163
 
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
164
+ /ft-design → /ft-build /ft-verify
234
165
  ```
235
166
 
236
- ## RTK 输出压缩
167
+ 或在 Cursor 中执行 `/ft-sync-cursor-commands`。
237
168
 
238
- FT 拦截子进程 `stdout` / `stderr`,对长文本采用**中间截断**策略:
169
+ ### Codex / OpenCode
239
170
 
240
- - 保留前 **200** + 后 **100** 行
241
- - 中间以 `...... (已省略 X 行) ......` 替换
242
- - 命令参数含 `--json`、`--format json`、`--xml` 时完全旁路
243
- - Comet 透传且处于 TTY 交互模式时自动禁用,避免破坏 TUI
171
+ 参考各平台自定义 Command 机制,在终端执行 `ft slash <subcommand>`。
172
+
173
+ ## RTK 输出压缩
174
+
175
+ 子进程长输出采用中间截断(前 200 行 + 后 100 行),`--json` 等结构化参数自动旁路,TTY 交互时不压缩。
244
176
 
245
177
  ## 已知限制
246
178
 
247
- - **AGENTS-BAK 合并**依赖 LLM 判断,超模板章节迁移可能存在轻微随机性
248
- - **IDE 内 Comet 透传**:若 Comet 不支持 `--non-interactive`,须在系统终端执行对应 `comet` 命令
249
- - **平台范围**:当前仅支持 Cursor、Codex、OpenCode
179
+ - AGENTS-BAK 合并依赖 LLM 判断
180
+ - IDE 内 Comet 透传可能需在系统终端执行
181
+ - 当前仅支持 Cursor、Codex、OpenCode
182
+
183
+ ## 文档
184
+
185
+ - [DESIGN.md](./DESIGN.md) — 设计说明
186
+ - [DEVELOPMENT_PLAN.md](./DEVELOPMENT_PLAN.md) — 开发计划与实现状态
250
187
 
251
188
  ## 相关链接
252
189
 
253
190
  - Comet:`npm install -g @rpamis/comet`
254
191
  - Karpathy Skills:https://github.com/multica-ai/andrej-karpathy-skills
255
- - GitNexus:`npm install -g gitnexus`
256
192
 
257
193
  ## License
258
194
 
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: Comet archive workflow via FT
3
+ ---
4
+
5
+ Execute in the project terminal:
6
+
7
+ ```bash
8
+ ft slash archive
9
+ ```
10
+
11
+ Wait for the command to finish and report the result. If it fails in the IDE non-interactive environment, tell the user to run `comet archive` in a system terminal.
@@ -0,0 +1,44 @@
1
+ ---
2
+ description: Comet build workflow via FT — strict visual design fidelity
3
+ ---
4
+
5
+ ## Mandatory: read visual-fidelity skill first
6
+
7
+ **Before any UI code**, read and follow `.cursor/skills/visual-fidelity/SKILL.md`.
8
+
9
+ ## Step 1 — Run build prep
10
+
11
+ Execute in the project terminal:
12
+
13
+ ```bash
14
+ ft slash build
15
+ ```
16
+
17
+ Read the **full terminal output**. It scaffolds/updates:
18
+
19
+ - `.ft/visual-spec.md` — design tokens and component map
20
+ - `.ft/visual-checklist.json` — acceptance items (auto-filled from Figma API when available)
21
+
22
+ ## Step 2 — Fetch designs (if not auto-filled)
23
+
24
+ 1. **Figma Developer MCP** (`get_figma_data`, `download_figma_images`)
25
+ 2. **`AGENTS.md` → Visual Design / 视觉稿** links
26
+ 3. User-provided links in chat
27
+
28
+ Update `.ft/visual-spec.md` with extracted tokens. Mark unknowns as `TBD` — never guess.
29
+
30
+ ## Step 3 — If fetch fails, ask the user (do NOT stop)
31
+
32
+ Present options in chat:
33
+
34
+ 1. Supplement Figma API Key → `ft init` or configure `.cursor/mcp.json`
35
+ 2. Supplement design link → record and suggest AGENTS.md update
36
+ 3. Skip for now → continue without blocking
37
+
38
+ ## Step 4 — Implement with acceptance gate
39
+
40
+ 1. Code using tokens from visual-spec (no hardcoded colors/spacing)
41
+ 2. After coding, output **Visual Acceptance Report** (see skill template)
42
+ 3. Update `.ft/visual-checklist.json` — only mark `passed` when verified
43
+
44
+ Wait for `ft slash build` (including Comet build) to finish. If Comet fails in IDE, tell the user to run `comet build` in a system terminal.
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: Comet design workflow via FT
3
+ ---
4
+
5
+ Execute in the project terminal:
6
+
7
+ ```bash
8
+ ft slash design
9
+ ```
10
+
11
+ Wait for the command to finish and report the result. If it fails in the IDE non-interactive environment, tell the user to run `comet design` in a system terminal.
@@ -0,0 +1,13 @@
1
+ ---
2
+ description: Fill AGENTS.md project context via FT prompt recipe
3
+ ---
4
+
5
+ Execute in the project terminal:
6
+
7
+ ```bash
8
+ ft slash fill-context
9
+ ```
10
+
11
+ Read the full terminal output. It contains a structured prompt recipe.
12
+
13
+ **Directly edit `AGENTS.md`** in the workspace: replace every `[NEEDS LLM INPUT]` with accurate project-specific content. Follow the language constraint in the output. If `AGENTS-BAK.md` exists, follow the backup merge rules shown in the terminal output.
@@ -0,0 +1,33 @@
1
+ ---
2
+ description: Comet hotfix workflow via FT — visual regression-safe emergency fixes
3
+ ---
4
+
5
+ ## Mandatory: regression-safe hotfix
6
+
7
+ **Before any hotfix**, read `.cursor/skills/visual-fidelity/SKILL.md` (Tweak / hotfix section).
8
+
9
+ ## Step 1 — Run hotfix prep
10
+
11
+ Execute in the project terminal:
12
+
13
+ ```bash
14
+ ft slash hotfix
15
+ ```
16
+
17
+ Read the **full terminal output**. Note locked (`passed`) checklist items — they must not regress.
18
+
19
+ ## Step 2 — Minimal, scoped fix
20
+
21
+ - Fix only the reported production issue
22
+ - One dimension at a time (spacing / color / typography)
23
+ - Do not rewrite unrelated layout or remove verified CSS variables
24
+
25
+ ## Step 3 — Full regression re-check
26
+
27
+ After the fix:
28
+
29
+ 1. Re-verify **every** checklist item
30
+ 2. Output **Visual Acceptance Report** with regression table
31
+ 3. If a locked item regressed → revert before shipping
32
+
33
+ Wait for `ft slash hotfix` (including Comet hotfix) to finish. If Comet fails in IDE, tell the user to run `comet hotfix` in a system terminal.
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: Comet open workflow via FT
3
+ ---
4
+
5
+ Execute in the project terminal:
6
+
7
+ ```bash
8
+ ft slash open
9
+ ```
10
+
11
+ Wait for the command to finish and report the result. If it fails in the IDE non-interactive environment, tell the user to run `comet open` in a system terminal.
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: Reinstall FT slash commands into .cursor/commands/
3
+ ---
4
+
5
+ Execute in the project terminal:
6
+
7
+ ```bash
8
+ ft slash sync-cursor-commands
9
+ ```
10
+
11
+ This copies all FT slash command definitions into `.cursor/commands/`. Tell the user they can now type `/` in Cursor Agent chat to see commands like `/ft-fill-context`.
@@ -0,0 +1,36 @@
1
+ ---
2
+ description: Comet tweak workflow via FT — visual regression-safe fixes
3
+ ---
4
+
5
+ ## Mandatory: regression-safe visual tweaks
6
+
7
+ **Before fixing any visual issue**, read `.cursor/skills/visual-fidelity/SKILL.md` (Tweak / hotfix section).
8
+
9
+ ## Step 1 — Run tweak prep
10
+
11
+ Execute in the project terminal:
12
+
13
+ ```bash
14
+ ft slash tweak
15
+ ```
16
+
17
+ Read the **full terminal output**. Note:
18
+
19
+ - Items with `status: "passed"` in `.ft/visual-checklist.json` are **locked** — must not regress
20
+ - Current locked items are listed in the terminal output
21
+
22
+ ## Step 2 — Fix one dimension at a time
23
+
24
+ - Fix spacing OR color OR typography — not all at once
25
+ - Do not rewrite layout or remove CSS variables for local fixes
26
+ - Only edit files necessary for the reported issue
27
+
28
+ ## Step 3 — Full regression re-check
29
+
30
+ After the fix:
31
+
32
+ 1. Re-verify **every** checklist item (not just the one you fixed)
33
+ 2. Output **Visual Acceptance Report** with regression table (see skill)
34
+ 3. If a previously `passed` item regressed → revert before continuing
35
+
36
+ Wait for `ft slash tweak` (including Comet tweak) to finish. If Comet fails in IDE, tell the user to run `comet tweak` in a system terminal.
@@ -0,0 +1,43 @@
1
+ ---
2
+ description: Comet verify workflow via FT — checklist gate and Playwright pixel diff
3
+ ---
4
+
5
+ ## Mandatory: visual verification before sign-off
6
+
7
+ Read `.cursor/skills/visual-fidelity/SKILL.md` acceptance sections before verify.
8
+
9
+ ## Step 1 — Run verify prep
10
+
11
+ Execute in the project terminal:
12
+
13
+ ```bash
14
+ ft slash verify
15
+ ```
16
+
17
+ Read the **full terminal output**. It reports:
18
+
19
+ 1. **Checklist status** from `.ft/visual-checklist.json`
20
+ 2. **Pixel diff** (if enabled in `.ft/visual-verify.json`)
21
+
22
+ ## Step 2 — Enable pixel diff (first time)
23
+
24
+ 1. Edit `.ft/visual-verify.json`: set `enabled: true`, `baseUrl`, and `screens`
25
+ 2. Install tools (one command):
26
+ ```bash
27
+ ft slash visual-tools-install
28
+ ```
29
+ Or in IDE: `/ft-visual-tools-install`
30
+ 3. Capture baselines (first run):
31
+ ```bash
32
+ node node_modules/@nick848/ft/scripts/visual-diff.mjs --update
33
+ ```
34
+ Or use the path printed by `ft slash verify`.
35
+
36
+ ## Step 3 — If diff fails
37
+
38
+ - Inspect diff images in `.ft/visual-diffs/`
39
+ - Fix UI to match baselines
40
+ - Update checklist items to `passed` only when verified
41
+ - Re-run `/ft-verify`
42
+
43
+ Wait for `ft slash verify` (including Comet verify) to finish. Exit code is non-zero if pixel diff fails. If Comet fails in IDE, tell the user to run `comet verify` in a system terminal.
@@ -0,0 +1,26 @@
1
+ ---
2
+ description: Install Playwright, pixelmatch, pngjs for FT visual pixel diff
3
+ ---
4
+
5
+ Install all dependencies required for `/ft-verify` pixel diff in one step.
6
+
7
+ Execute in the project terminal:
8
+
9
+ ```bash
10
+ ft slash visual-tools-install
11
+ ```
12
+
13
+ This will:
14
+
15
+ 1. Detect your package manager (npm / pnpm / yarn / bun)
16
+ 2. Install devDependencies: `playwright`, `pixelmatch`, `pngjs`
17
+ 3. Run `playwright install chromium` for headless screenshots
18
+
19
+ Wait for the command to finish and report the result.
20
+
21
+ **Next steps after success:**
22
+
23
+ 1. Set `enabled: true` in `.ft/visual-verify.json`
24
+ 2. Configure `baseUrl` and `screens`
25
+ 3. Capture baselines: `node node_modules/@nick848/ft/scripts/visual-diff.mjs --update`
26
+ 4. Run `/ft-verify`