@nick848/fet 1.0.5 → 1.0.6

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
@@ -131,6 +131,32 @@ $env:FET_REAL_OPENSPEC='1'; npm run test:real-openspec
131
131
 
132
132
  MIT
133
133
 
134
+ ### 可选 GitNexus 图谱支持
135
+
136
+ FET 会在 `fet init` 时检测可选的 `gitnexus` 可执行文件,并把结果记录到 `openspec/fet-state.json`。如果没有安装 GitNexus,初始化只会给出一次推荐提示,主流程会继续执行;`fet doctor` 也会把缺失 GitNexus 作为提示性 warning,而不是阻断问题。
137
+
138
+ 二阶段图谱命令统一放在 `fet graph` 下:
139
+
140
+ - `fet graph status`:检查 GitNexus、图谱路径和当前状态,并更新 FET 状态。
141
+ - `fet graph setup`:生成 `.fet/graph-setup.md`,用于安装和 IDE 辅助配置引导;FET 不会自动安装 GitNexus。
142
+ - `fet graph init`:执行 `gitnexus analyze`,用于首次构建图谱。
143
+ - `fet graph refresh`:再次执行 `gitnexus analyze`,用于刷新图谱。
144
+ - `fet graph doctor`:检查图谱集成健康状态,缺失只提示,不阻断 FET/OpenSpec 命令。
145
+ - `fet graph handoff`:生成 `.fet/graph-handoff.md`,供 Cursor、Codex、OpenCode 等 IDE AI 在大范围扫描前优先参考图谱上下文。
146
+
147
+ 默认情况下,FET 会从 `PATH` 查找 `gitnexus`,并认为图谱目录是 `.gitnexus`。高级用户可以通过 `FET_GITNEXUS_EXECUTABLE`、`FET_GITNEXUS_COMMAND`、`FET_GITNEXUS_GRAPH_PATH` 覆盖默认行为。
148
+
149
+ ### Andrej Karpathy Skills
150
+
151
+ `fet init` 和 `fet update-context` 会为当前工程加入一份 FET 管理的 Andrej Karpathy 风格编码指南。FET 不假设 Codex 或 OpenCode 会主动读取 `CLAUDE.md`,因此会把指南同步到 FET 自己的上下文文件中:
152
+
153
+ - `CLAUDE.md`:追加或刷新 `FET:BEGIN ANDREJ-KARPATHY-SKILLS` 管理块,供 Claude Code、Codex、OpenCode 等能读取项目根文档的 AI 工具使用。
154
+ - `.cursor/rules/karpathy-guidelines.mdc`:为 Cursor 生成项目规则。若该文件已存在且不是 FET 管理文件,FET 会保留原文件并给出 warning。
155
+ - `.fet/karpathy-guidelines.md`:通用 IDE handoff,供 OpenCode 或其他不读取 `CLAUDE.md` 的工具显式读取。
156
+ - `.codex/fet/karpathy-guidelines.md`:Codex 专用上下文;FET 生成的 Codex context、command guide 和 slash prompt 会明确要求读取该文件。
157
+
158
+ 这份指南不会复制第三方仓库全文,而是基于 `andrej-karpathy-skills` 的使用目标生成项目级精简规则:先思考、保持简单、精准修改、按目标验证。来源项目:<https://github.com/forrestchang/andrej-karpathy-skills>。
159
+
134
160
  ## English
135
161
 
136
162
  FET is a frontend development workflow orchestration CLI built around OpenSpec. It does not generate business code directly. Instead, it proxies OpenSpec commands, maintains local workflow state, generates auditable project context, and helps AI coding tools such as Cursor and Codex load the right files.
@@ -199,6 +225,17 @@ FET can detect an optional `gitnexus` executable during `fet init` and records t
199
225
 
200
226
  Generated Cursor and Codex instructions tell the IDE AI to prefer GitNexus graph context before broad repository scans when that context is available. FET does not install GitNexus, generate graphs, or require graph support for any command.
201
227
 
228
+ ### Andrej Karpathy Skills
229
+
230
+ `fet init` and `fet update-context` add FET-managed Andrej Karpathy inspired coding guidelines. FET does not assume Codex, OpenCode, or other IDE agents will read `CLAUDE.md` automatically, so the guidelines are also written into FET-owned context files:
231
+
232
+ - `CLAUDE.md` receives a managed `FET:BEGIN ANDREJ-KARPATHY-SKILLS` block for tools that do read root-level Claude guidance.
233
+ - `.fet/karpathy-guidelines.md` is the generic handoff for OpenCode or other IDEs.
234
+ - `.codex/fet/karpathy-guidelines.md` is the Codex-specific copy; generated Codex context, command guides, and slash prompts explicitly ask Codex to read it.
235
+ - `.cursor/rules/karpathy-guidelines.mdc` is the Cursor project rule.
236
+
237
+ The generated guidance is a concise project-level adaptation of `andrej-karpathy-skills`: think before coding, keep changes simple, edit precisely, and verify against concrete goals.
238
+
202
239
  Phase-two graph commands are available under `fet graph`:
203
240
 
204
241
  - `fet graph status` checks GitNexus, the configured graph path, and records the result.
@@ -262,9 +299,13 @@ FET may create or update:
262
299
  - `CHANGELOG.md`
263
300
  - `.fet/graph-setup.md`
264
301
  - `.fet/graph-handoff.md`
302
+ - `.fet/karpathy-guidelines.md`
303
+ - `CLAUDE.md`
265
304
  - `.cursor/skills/fet-*/SKILL.md`
266
305
  - `.cursor/rules/fet-context.mdc`
306
+ - `.cursor/rules/karpathy-guidelines.mdc`
267
307
  - `.codex/fet/context.md`
308
+ - `.codex/fet/karpathy-guidelines.md`
268
309
  - `.codex/fet/commands/*.md`
269
310
  - `$CODEX_HOME/prompts/fet-*.md` for Codex native slash commands. If `CODEX_HOME` is not set, FET uses `~/.codex`.
270
311
  - `.fet/fill-context.md` as a generic IDE handoff for tools without native command support.
package/dist/cli/index.js CHANGED
@@ -368,6 +368,12 @@ ${routes || "| [NEEDS LLM INPUT] | [NEEDS LLM INPUT] | low |"}
368
368
 
369
369
  [NEEDS LLM INPUT]
370
370
 
371
+ ## AI Work Guidelines
372
+
373
+ - Prefer the project-level Andrej Karpathy inspired guidelines in .fet/karpathy-guidelines.md when using FET-managed IDE workflows.
374
+ - For Codex, also read .codex/fet/karpathy-guidelines.md when present.
375
+ - Treat those guidelines as secondary to the user's latest request and explicit OpenSpec artifacts.
376
+
371
377
  ## Scanner Metadata
372
378
 
373
379
  - Generated At: ${scan.generatedAt}
@@ -415,6 +421,97 @@ function renderFetConfig(scan) {
415
421
  });
416
422
  }
417
423
 
424
+ // src/templates/karpathy-skills.ts
425
+ var KARPATHY_SKILLS_SOURCE = "https://github.com/forrestchang/andrej-karpathy-skills";
426
+ var BEGIN = "<!-- FET:BEGIN ANDREJ-KARPATHY-SKILLS -->";
427
+ var END = "<!-- FET:END ANDREJ-KARPATHY-SKILLS -->";
428
+ function mergeKarpathyClaudeMd(existing) {
429
+ const block = renderManagedBlock(renderKarpathyClaudeGuidelines());
430
+ if (!existing || !existing.trim()) {
431
+ return `${block}
432
+ `;
433
+ }
434
+ const start = existing.indexOf(BEGIN);
435
+ const end = existing.indexOf(END);
436
+ if (start !== -1 && end !== -1 && end > start) {
437
+ return `${existing.slice(0, start)}${block}${existing.slice(end + END.length)}`;
438
+ }
439
+ return `${existing.replace(/\s*$/, "")}
440
+
441
+ ${block}
442
+ `;
443
+ }
444
+ function renderKarpathyCursorRule() {
445
+ return `<!-- FET:MANAGED
446
+ schemaVersion: 1
447
+ generator: karpathy-skills
448
+ FET:END -->
449
+
450
+ ---
451
+ description: Andrej Karpathy inspired coding guidelines
452
+ alwaysApply: true
453
+ ---
454
+
455
+ ${renderKarpathyGuidelinesBody()}
456
+ `;
457
+ }
458
+ function renderKarpathyFetHandoff() {
459
+ return `<!-- FET:MANAGED
460
+ schemaVersion: 1
461
+ generator: karpathy-skills
462
+ FET:END -->
463
+
464
+ # Andrej Karpathy Inspired Coding Guidelines
465
+
466
+ ${renderKarpathyGuidelinesBody()}
467
+ `;
468
+ }
469
+ function renderManagedBlock(content) {
470
+ return `${BEGIN}
471
+ ${content}
472
+ ${END}`;
473
+ }
474
+ function renderKarpathyClaudeGuidelines() {
475
+ return `# Andrej Karpathy Inspired Coding Guidelines
476
+
477
+ ${renderKarpathyGuidelinesBody()}`;
478
+ }
479
+ function renderKarpathyGuidelinesBody() {
480
+ return `Source: ${KARPATHY_SKILLS_SOURCE}
481
+
482
+ Use these project-level guidelines together with AGENTS.md, OpenSpec artifacts, and the user's latest request.
483
+
484
+ ## Think Before Coding
485
+
486
+ - State important assumptions before editing.
487
+ - Ask for clarification when ambiguity would change the implementation.
488
+ - Surface tradeoffs instead of silently choosing a risky path.
489
+ - Push back when a simpler approach better fits the request.
490
+
491
+ ## Simplicity First
492
+
493
+ - Solve the requested problem with the smallest clear change.
494
+ - Avoid speculative features, configuration, or abstraction.
495
+ - Do not create abstractions for one-off code.
496
+ - Prefer deleting complexity introduced by your own change over adding more structure.
497
+
498
+ ## Precise Edits
499
+
500
+ - Touch only files and lines that directly serve the task.
501
+ - Preserve existing style even when you personally prefer another pattern.
502
+ - Do not refactor nearby code, comments, or formatting unless the task requires it.
503
+ - Remove only dead imports, variables, or helpers made obsolete by your own change.
504
+
505
+ ## Goal-Driven Execution
506
+
507
+ - Convert vague work into concrete success criteria.
508
+ - For bugs, prefer a reproducing test or clear verification before the fix.
509
+ - For multi-step work, keep a short plan and verify each meaningful step.
510
+ - Continue iterating until the success criteria are met or a blocker is explicit.
511
+
512
+ These guidelines intentionally favor caution over speed for non-trivial work. For obvious one-line fixes, use judgment and stay lightweight.`;
513
+ }
514
+
418
515
  // src/templates/verify-instructions.ts
419
516
  function renderVerifyInstructions(changeId, generatedAt = (/* @__PURE__ */ new Date()).toISOString()) {
420
517
  return `---
@@ -442,8 +539,8 @@ fet verify --done --change ${changeId}
442
539
  }
443
540
 
444
541
  // src/templates/gitignore.ts
445
- var BEGIN = "# FET:BEGIN LOCAL STATE";
446
- var END = "# FET:END LOCAL STATE";
542
+ var BEGIN2 = "# FET:BEGIN LOCAL STATE";
543
+ var END2 = "# FET:END LOCAL STATE";
447
544
  var RULES = [
448
545
  "openspec/fet-state.json",
449
546
  "openspec/.fet.lock",
@@ -453,17 +550,17 @@ var RULES = [
453
550
  ".gitnexus/"
454
551
  ];
455
552
  function mergeGitignore(existing) {
456
- const block = `${BEGIN}
553
+ const block = `${BEGIN2}
457
554
  ${RULES.join("\n")}
458
- ${END}`;
555
+ ${END2}`;
459
556
  if (!existing || !existing.trim()) {
460
557
  return `${block}
461
558
  `;
462
559
  }
463
- const start = existing.indexOf(BEGIN);
464
- const end = existing.indexOf(END);
560
+ const start = existing.indexOf(BEGIN2);
561
+ const end = existing.indexOf(END2);
465
562
  if (start !== -1 && end !== -1 && end > start) {
466
- return `${existing.slice(0, start)}${block}${existing.slice(end + END.length)}`;
563
+ return `${existing.slice(0, start)}${block}${existing.slice(end + END2.length)}`;
467
564
  }
468
565
  return `${existing.replace(/\s*$/, "")}
469
566
 
@@ -529,7 +626,12 @@ async function updateContextFiles(ctx) {
529
626
  const scan = await ctx.scanner.scan(ctx.projectRoot, {});
530
627
  const agentsPath = join7(ctx.projectRoot, "AGENTS.md");
531
628
  const configPath = join7(ctx.projectRoot, "openspec", "config.yaml");
629
+ const claudePath = join7(ctx.projectRoot, "CLAUDE.md");
630
+ const karpathyHandoffPath = join7(ctx.projectRoot, ".fet", "karpathy-guidelines.md");
631
+ const karpathyCursorPath = join7(ctx.projectRoot, ".cursor", "rules", "karpathy-guidelines.mdc");
532
632
  const existingAgents = await readOptional(agentsPath);
633
+ const existingClaude = await readOptional(claudePath);
634
+ const existingKarpathyCursor = await readOptional(karpathyCursorPath);
533
635
  const warnings = [...scan.warnings];
534
636
  if (existingAgents && hasInvalidManagedAutoRegion(existingAgents)) {
535
637
  throw new FetError({
@@ -555,6 +657,13 @@ async function updateContextFiles(ctx) {
555
657
  }
556
658
  await atomicWrite(agentsPath, replaceManagedRegion(existingAgents, renderAgentsMd(scan)));
557
659
  await atomicWrite(configPath, await mergeFetConfig(configPath, renderFetConfig(scan)));
660
+ await atomicWrite(claudePath, mergeKarpathyClaudeMd(existingClaude));
661
+ await atomicWrite(karpathyHandoffPath, renderKarpathyFetHandoff());
662
+ if (!existingKarpathyCursor || existingKarpathyCursor.includes("FET:MANAGED")) {
663
+ await atomicWrite(karpathyCursorPath, renderKarpathyCursorRule());
664
+ } else {
665
+ warnings.push(".cursor/rules/karpathy-guidelines.mdc exists and is not managed by FET; leaving it unchanged.");
666
+ }
558
667
  const placeholderCount = await countAgentsLlmPlaceholders(ctx.projectRoot);
559
668
  if (placeholderCount > 0) {
560
669
  warnings.push(renderAgentsPlaceholderWarning(placeholderCount));
@@ -804,11 +913,12 @@ FET:END -->
804
913
  Use the IDE AI to complete FET-generated placeholders.
805
914
 
806
915
  1. Read AGENTS.md and openspec/config.yaml.
807
- 2. Inspect README files, package scripts, routes, tests, source layout, and project conventions.
808
- 3. Replace every \`[NEEDS LLM INPUT]\` or \`[NEED LLM INPUT]\` placeholder in AGENTS.md with concrete project-specific content.
809
- 4. Preserve FET managed markers.
810
- 5. Do not modify business code.
811
- 6. Run \`fet doctor\` and confirm no AGENTS.md placeholder warning remains.
916
+ 2. Read .fet/karpathy-guidelines.md when it exists. For Codex, also read .codex/fet/karpathy-guidelines.md when it exists.
917
+ 3. Inspect README files, package scripts, routes, tests, source layout, and project conventions.
918
+ 4. Replace every \`[NEEDS LLM INPUT]\` or \`[NEED LLM INPUT]\` placeholder in AGENTS.md with concrete project-specific content.
919
+ 5. Preserve FET managed markers.
920
+ 6. Do not modify business code.
921
+ 7. Run \`fet doctor\` and confirm no AGENTS.md placeholder warning remains.
812
922
  `;
813
923
  }
814
924
 
@@ -1796,6 +1906,7 @@ Before doing FET or OpenSpec work in Codex, read:
1796
1906
 
1797
1907
  - AGENTS.md
1798
1908
  - openspec/config.yaml
1909
+ - .codex/fet/karpathy-guidelines.md
1799
1910
  - the active change files under openspec/changes/<change-id>/, when a change is selected
1800
1911
 
1801
1912
  If GitNexus code graph context is available in the IDE or MCP tools, prefer it before broad repository scans. Use it to identify relevant modules, dependencies, and insertion points, then read only the concrete source files needed. If GitNexus is unavailable, continue with the normal FET/OpenSpec workflow.
@@ -1807,10 +1918,13 @@ Command guides live in .codex/fet/commands/.
1807
1918
  };
1808
1919
  }
1809
1920
  function codexCommandFiles() {
1810
- return FET_ADAPTER_COMMANDS.map((command) => ({
1811
- path: `.codex/fet/commands/${command}.md`,
1812
- content: renderCommand(command)
1813
- }));
1921
+ return [
1922
+ codexKarpathyGuidelinesFile(),
1923
+ ...FET_ADAPTER_COMMANDS.map((command) => ({
1924
+ path: `.codex/fet/commands/${command}.md`,
1925
+ content: renderCommand(command)
1926
+ }))
1927
+ ];
1814
1928
  }
1815
1929
  function codexSlashPromptFiles() {
1816
1930
  return FET_ADAPTER_COMMANDS.map((command) => ({
@@ -1818,6 +1932,22 @@ function codexSlashPromptFiles() {
1818
1932
  content: renderSlashPrompt(command)
1819
1933
  }));
1820
1934
  }
1935
+ function codexKarpathyGuidelinesFile() {
1936
+ return {
1937
+ path: ".codex/fet/karpathy-guidelines.md",
1938
+ content: `<!-- FET:MANAGED
1939
+ schemaVersion: 1
1940
+ fetVersion: ${FET_VERSION}
1941
+ generator: codex-adapter
1942
+ adapterVersion: 1
1943
+ FET:END -->
1944
+
1945
+ # Andrej Karpathy Inspired Coding Guidelines
1946
+
1947
+ ${renderKarpathyGuidelinesBody()}
1948
+ `
1949
+ };
1950
+ }
1821
1951
  function renderCommand(command) {
1822
1952
  if (command === "fill-context") {
1823
1953
  return renderFillContextCommand();
@@ -1843,6 +1973,8 @@ ${renderIdeModelPolicy(command)}
1843
1973
 
1844
1974
  When the user asks Codex to run the FET ${command} workflow, first make sure the project context is loaded from AGENTS.md and openspec/config.yaml.
1845
1975
 
1976
+ Also read .codex/fet/karpathy-guidelines.md and follow it unless it conflicts with the user's latest request or OpenSpec artifacts.
1977
+
1846
1978
  If GitNexus graph context is available, consult it before broad source scans and use it to narrow the files you read. If it is unavailable, continue normally.
1847
1979
 
1848
1980
  Then run:
@@ -1871,6 +2003,8 @@ ${renderIdeModelPolicy("passthrough")}
1871
2003
 
1872
2004
  When the user asks Codex to run an OpenSpec command that FET does not manage as a first-class workflow command, use FET passthrough instead of calling OpenSpec directly.
1873
2005
 
2006
+ Also read .codex/fet/karpathy-guidelines.md and follow it unless it conflicts with the user's latest request or OpenSpec artifacts.
2007
+
1874
2008
  If GitNexus graph context is available, consult it before broad source scans and use it to narrow the files you read. If it is unavailable, continue normally.
1875
2009
 
1876
2010
  Then run:
@@ -1899,6 +2033,8 @@ ${renderIdeModelPolicy(command)}
1899
2033
 
1900
2034
  When the user asks Codex to work with optional GitNexus graph support, use FET as the entry point.
1901
2035
 
2036
+ Also read .codex/fet/karpathy-guidelines.md and follow it unless it conflicts with the user's latest request or OpenSpec artifacts.
2037
+
1902
2038
  If GitNexus graph context is available, consult it before broad source scans and use it to narrow the files you read. If it is unavailable, continue normally.
1903
2039
 
1904
2040
  Run:
@@ -1970,6 +2106,8 @@ Use FET as the entry point for this OpenSpec workflow.
1970
2106
 
1971
2107
  Before running the command, make sure the relevant project context is loaded from AGENTS.md and openspec/config.yaml. If a change id is needed and was not provided, infer it from the active FET/OpenSpec state when unambiguous; otherwise ask the user for the change id.
1972
2108
 
2109
+ Also read .codex/fet/karpathy-guidelines.md and follow it unless it conflicts with the user's latest request or OpenSpec artifacts.
2110
+
1973
2111
  If GitNexus graph context is available, consult it before broad source scans and use it to narrow the files you read. If it is unavailable, continue normally.
1974
2112
 
1975
2113
  Run:
@@ -1996,6 +2134,8 @@ ${renderIdeModelPolicy("fill-context")}
1996
2134
 
1997
2135
  Use this command to complete FET-generated project context placeholders with Codex.
1998
2136
 
2137
+ Also read .codex/fet/karpathy-guidelines.md and follow it unless it conflicts with the user's latest request or OpenSpec artifacts.
2138
+
1999
2139
  If GitNexus graph context is available, consult it before broad source scans and use it to narrow the files you read. If it is unavailable, continue normally.
2000
2140
 
2001
2141
  First run:
@@ -2020,16 +2160,17 @@ Steps:
2020
2160
  fet fill-context
2021
2161
  \`\`\`
2022
2162
  2. Read AGENTS.md and openspec/config.yaml.
2023
- 3. Inspect the project to understand:
2163
+ 3. Read .codex/fet/karpathy-guidelines.md.
2164
+ 4. Inspect the project to understand:
2024
2165
  - source structure and major modules
2025
2166
  - framework and routing conventions
2026
2167
  - scripts, test commands, and build commands
2027
2168
  - coding conventions and project-specific patterns
2028
2169
  - important docs such as README files
2029
- 4. Replace every \`[NEEDS LLM INPUT]\` or \`[NEED LLM INPUT]\` placeholder in AGENTS.md with concrete, concise project-specific content.
2030
- 5. Preserve FET managed markers such as \`FET:BEGIN AUTO\`, \`FET:END AUTO\`, \`FET:BEGIN USER\`, and \`FET:END USER\`.
2031
- 6. Do not modify business code.
2032
- 7. Run:
2170
+ 5. Replace every \`[NEEDS LLM INPUT]\` or \`[NEED LLM INPUT]\` placeholder in AGENTS.md with concrete, concise project-specific content.
2171
+ 6. Preserve FET managed markers such as \`FET:BEGIN AUTO\`, \`FET:END AUTO\`, \`FET:BEGIN USER\`, and \`FET:END USER\`.
2172
+ 7. Do not modify business code.
2173
+ 8. Run:
2033
2174
  \`\`\`sh
2034
2175
  fet doctor
2035
2176
  \`\`\`