@double-codeing/flow2spec 3.0.12 → 3.0.13

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/cli.js CHANGED
@@ -50,11 +50,11 @@ init 会:
50
50
  传 --yes 时所有缺失字段使用默认值(均为 false)。
51
51
  3. 默认仅补齐 .Knowledge 缺失模板,并对路由清单做包级/结构增量对齐(manifest-routing + matcherPath 分片;关键词仅写在 matchers/*.json);不替代 f2s-* 对业务文档与路由内容的写入。
52
52
  传 --reset-knowledge 时才会强制用模板覆盖 .Knowledge 中模板承载部分。
53
- 4. 在各 agent 配置根写入 rules、skills(Claude 规则自动转 .md;Codex 生成 AGENTS.md 汇总)。
53
+ 4. 在各 agent 配置根写入 rules、skills(Claude 规则自动转 .md;Codex 在仓库根写入完整 AGENTS.md,.codex/ 写入指针)。
54
54
  Claude 额外写入 .claude/hooks/f2s-config-inject.js 与 .claude/settings.json(PreToolUse hook),
55
55
  在调用 f2s-* Skill 时注入配置摘要;配置缺失、JSON 无效或 hook 异常时也会注入默认语义说明,避免静默。
56
56
  Cursor 额外写入 f2s-config-check.mdc(alwaysApply),强制在技能首步读取配置文件。
57
- Codex AGENTS.md 顶部包含强制前置步骤说明。
57
+ Codex:仓库根 AGENTS.md(CLI 自动发现,完整条令);.codex/AGENTS.md 为指针。
58
58
  5. 每次 init 将包内 templates/knowledge/index.md 复制到 .Knowledge/template/index.template.md,供 f2s-kb-upgrade 技能与 .Knowledge/index.md 对照;不自动改写 index.md。(「知识库升级」指 f2s-kb-upgrade 技能,init 本身不是升级命令。)
59
59
  6. 规则与技能在各 agent 配置根加载;其他模版类文件在 .Knowledge/template/ 等目录。
60
60
 
@@ -293,7 +293,7 @@ if (sub === "init") {
293
293
  const lines = ids.map((id) => {
294
294
  const { root, label } = AGENTS[id];
295
295
  if (id === "codex")
296
- return ` - ${root}/:(${label})AGENTS.md、skills/`;
296
+ return ` - ${root}/:(${label})skills/、topics/、AGENTS.md(指针);仓库根 AGENTS.md(完整)`;
297
297
  if (id === "claude") {
298
298
  const hookLine = claudeHooksResult?.settingsChanged
299
299
  ? "rules/、skills/、hooks/f2s-config-inject.js、settings.json(已写入 f2s PreToolUse hook)"
@@ -67,4 +67,16 @@ function buildCodexAgentsMd(templatesDir, projectConfig) {
67
67
  return renderCodexAgents(templateBody, skillLines, projectConfig);
68
68
  }
69
69
 
70
- module.exports = { buildCodexAgentsMd, renderProjectConfigBlock };
70
+ function buildCodexAgentsStubMd(templatesDir) {
71
+ const stubPath = path.join(templatesDir, "AGENTS.codex-stub.md");
72
+ if (!fs.existsSync(stubPath)) {
73
+ throw new Error(`缺少 Codex 指针模板:${stubPath}`);
74
+ }
75
+ return fs.readFileSync(stubPath, "utf8");
76
+ }
77
+
78
+ module.exports = {
79
+ buildCodexAgentsMd,
80
+ buildCodexAgentsStubMd,
81
+ renderProjectConfigBlock,
82
+ };
package/lib/init.js CHANGED
@@ -11,7 +11,10 @@ const {
11
11
  adaptRuleMdcToClaudeMd,
12
12
  shouldWriteClaudeStyleRules,
13
13
  } = require("./claudeRulesAdapter");
14
- const { buildCodexAgentsMd } = require("./codexAgentsAdapter");
14
+ const {
15
+ buildCodexAgentsMd,
16
+ buildCodexAgentsStubMd,
17
+ } = require("./codexAgentsAdapter");
15
18
  const {
16
19
  loadFlow2specConfig,
17
20
  ensureFlow2specProjectConfig,
@@ -700,9 +703,15 @@ function writeCodexTopicMirrors(cwd, templatesDir) {
700
703
  }
701
704
  }
702
705
 
706
+ /**
707
+ * Codex 官方从仓库根向下扫描 AGENTS.md(见 developers.openai.com/codex/guides/agents-md)。
708
+ * 完整条令写仓库根;.codex/AGENTS.md 仅为指针,避免双份全文重复与 cwd 在 .codex 时双倍拼接。
709
+ */
703
710
  function writeCodexEntry(cwd, templatesDir, projectConfig) {
704
- const out = buildCodexAgentsMd(templatesDir, projectConfig);
705
- fs.writeFileSync(path.join(cwd, ".codex", "AGENTS.md"), out, "utf8");
711
+ const full = buildCodexAgentsMd(templatesDir, projectConfig);
712
+ const stub = buildCodexAgentsStubMd(templatesDir);
713
+ fs.writeFileSync(path.join(cwd, "AGENTS.md"), full, "utf8");
714
+ fs.writeFileSync(path.join(cwd, ".codex", "AGENTS.md"), stub, "utf8");
706
715
  writeCodexTopicMirrors(cwd, templatesDir);
707
716
  }
708
717
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@double-codeing/flow2spec",
3
- "version": "3.0.12",
3
+ "version": "3.0.13",
4
4
  "description": "在业务仓库初始化「文档驱动、可写回知识库」的 AI 协作骨架:项目根 .Knowledge 承载 stock-docs/req-docs 与机读路由,.cursor/.claude/.codex 写入 f2s-* 规则与技能(含 Karpathy 式编码行为准则 f2s-karpathy-guidelines,init 同步 rules / Codex topics / skills);init 只落结构与模板,业务内容由各 f2s-* 技能在对话中维护。",
5
5
  "homepage": "https://github.com/Lands-1203/Flow2Spec#readme",
6
6
  "repository": {
@@ -0,0 +1,19 @@
1
+ # Flow2Spec(`.codex/` 目录说明)
2
+
3
+ > 本文件为 **指针**,非完整条令。`flow2spec init` 写入;**请勿只读本文件**。
4
+
5
+ ## 完整条令
6
+
7
+ 仓库根 **[`AGENTS.md`](../AGENTS.md)** 为 Flow2Spec 完整项目说明。在仓库根启动 Codex 时会 [自动加载](https://developers.openai.com/codex/guides/agents-md) 该文件。
8
+
9
+ 若当前会话未包含根 `AGENTS.md` 全文,**必须先 Read 仓库根 `AGENTS.md`**,再执行 `f2s-*` 或改动 `.Knowledge/`。
10
+
11
+ ## 本目录用途
12
+
13
+ | 路径 | 说明 |
14
+ | --- | --- |
15
+ | `skills/` | Flow2Spec 技能(`f2s-*`) |
16
+ | `topics/` | 规则长文镜像(与 Cursor/Claude `rules` 同源) |
17
+ | `config.toml` | 项目级 Codex 配置(若已创建) |
18
+
19
+ 配置真值:仓库根 **`flow2spec.config.json`**(须 Read);init 快照表见根 **`AGENTS.md`**。
@@ -1,6 +1,6 @@
1
1
  # Flow2Spec 项目入口
2
2
 
3
- 本文件由 `flow2spec init` 写入 **`./.codex/AGENTS.md`**(相对仓库根)。你正在使用 Flow2Spec 的项目中工作;知识库在 **`./.Knowledge/`**,请渐进式读取,避免一次性加载大量无关文档。
3
+ 本文件由 `flow2spec init` 写入仓库根 **`./AGENTS.md`**(完整条令,供 [Codex 自动发现](https://developers.openai.com/codex/guides/agents-md))。**`./.codex/AGENTS.md`** 仅为指向本文件的短说明,不含完整规则。你正在使用 Flow2Spec 的项目中工作;知识库在 **`./.Knowledge/`**,请渐进式读取,避免一次性加载大量无关文档。
4
4
 
5
5
  ## ⚠️ f2s-* 技能前置强制步骤
6
6
 
@@ -14,7 +14,7 @@
14
14
 
15
15
  ## Flow2Spec 项目开关(`./flow2spec.config.json`;缺失时由 `flow2spec init` 从 npm 包模板补齐)
16
16
 
17
- **`flow2spec init` 的定位**:把 Flow2Spec **包内模板**落到当前仓库——包括 **`./.Knowledge/`**(含路由结构、快照等)与 **`./.codex/`**(本文件 **`./.codex/AGENTS.md`**、**`./.codex/skills/`**、经 init 写入的 **`./.codex/topics/*.md`**),**不负责**撰写业务 **`./.Knowledge/stock-docs/`**、**`./.Knowledge/topics/`** 正文或替代 **`f2s-*` 技能**;即 **模板与目录落盘 / 形态对齐**,不是「知识库升级命令」(升级见 **`f2s-kb-upgrade`** 技能)。
17
+ **`flow2spec init` 的定位**:把 Flow2Spec **包内模板**落到当前仓库——包括 **`./.Knowledge/`**(含路由结构、快照等)、仓库根 **`./AGENTS.md`**(完整)、**`.codex/AGENTS.md`**(指针)及 **`./.codex/`**(**`./.codex/skills/`**、经 init 写入的 **`./.codex/topics/*.md`** 等),**不负责**撰写业务 **`./.Knowledge/stock-docs/`**、**`./.Knowledge/topics/`** 正文或替代 **`f2s-*` 技能**;即 **模板与目录落盘 / 形态对齐**,不是「知识库升级命令」(升级见 **`f2s-kb-upgrade`** 技能)。
18
18
 
19
19
  执行任意 **`f2s-*` 技能**前,必须读取 `./flow2spec.config.json` 中的布尔字段(缺省或文件不存在均视为 `false`)。下表由 **最近一次 `flow2spec init`** 根据当时配置写入,**以磁盘上的文件为准**。
20
20
 
@@ -51,7 +51,7 @@
51
51
  - 禁止跳过 **`./.Knowledge/manifest-routing.json`**、按需 `matcherPath` 分片与 **`./.Knowledge/topics/`** 直接全仓检索或直接编码;**`./.Knowledge/index.md`** 按需读取,不可替代上述机读链。
52
52
  - 同一任务线内避免重复全文读取 **`./.Knowledge/manifest-routing.json`**(除非用户说明已通过 `f2s-ctx-build` / `f2s-kb-sync` / `f2s-doc-add` 等更新路由或知识、或手动改了 manifest;**勿将**仅执行 `flow2spec init` 当作业务知识库已更新);禁止为枚举而遍历整个 **`./.Knowledge/matchers/`**;禁止 **`./.Knowledge/index.md`** 与 routing 交替「刷清单」。
53
53
  - 禁止把 **`./.Knowledge/stock-docs/`** 作为“按方案实现代码”的直接输入文档。
54
- - Flow2Spec 执行条令仅以 **`./.codex/AGENTS.md`**(本文件)、**`./.codex/topics/f2s-*.md`** 与 **`./.codex/skills/`** 为准;勿使用仓库内 **非上述路径** 的同名条令文件作为执行依据,以免口径分叉。
54
+ - Flow2Spec 执行条令以 **`./AGENTS.md`**(完整)、**`./.codex/topics/f2s-*.md`** 与 **`./.codex/skills/`** 为准;**`.codex/AGENTS.md`** 仅为目录指针,不可替代根 `AGENTS.md`;勿使用仓库内 **非上述路径** 的同名条令文件作为执行依据,以免口径分叉。
55
55
  - 禁止把 `fallbackTopic` 当作最终命中直接实施改动;`fallbackTopic` 仅作安全兜底与澄清前置上下文。
56
56
  - 禁止在不满足触发门槛时做跨 matcher 全量补检索。
57
57
  10. **检索与作答节奏**:在 KB 已形成可答结论时,控制 `grep`/读盘范围与轮次;优先按 topic 给出的目录做单点 `Read`。用户未要求「全仓 / 通读依赖」时,允许**先短答再按需下钻**。细则见 **`./.codex/topics/f2s-knowledge-preflight.md`** 中 **「检索体积与作答节奏」**。
@@ -91,7 +91,7 @@
91
91
  - **`./.codex/topics/f2s-config-check.md`**:内容与上文「先 Read **`./flow2spec.config.json`**」一致并含 **changeTracking** 细表;**仅**在需核对细表时按需打开,不必与上列三条并列必读。
92
92
  - **`./.codex/topics/f2s-karpathy-guidelines.md`**:通用编码行为准则(先澄清、极简、手术式修改、可验证目标);与 f2s 路由/任务条令**并行**,硬冲突时以 **f2s 条令**为准。
93
93
 
94
- 执行 Flow2Spec 相关任务时,先读本 **`./.codex/AGENTS.md`** **`./.Knowledge/manifest-routing.json`**,再按需打开上列 **`./.codex/topics/*.md`** 文件。
94
+ 执行 Flow2Spec 相关任务时,先读本文件(**`./AGENTS.md`**)与 **`./.Knowledge/manifest-routing.json`**,再按需打开上列 **`./.codex/topics/*.md`** 文件。
95
95
 
96
96
  ## 可用 Flow2Spec 技能(自动生成)
97
97