consolidate-concepts
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConsolidate Concepts
概念整合
Always use the skill to retrieve the ***plain syntax rules — but only if you haven't done so yet.
load-plain-reference请始终使用技能来获取***plain语法规则——前提是你尚未执行过此操作。
load-plain-referenceWhen to Use
使用场景
- Multiple modules define the same or closely related concepts independently.
- A chain uses long
requireslists to share definitions that would be simpler as an import.exported_concepts - After a split, shared concepts ended up duplicated or awkwardly exported.
refactor-module - The user wants a single source of truth for domain concepts used across modules.
- 多个模块独立定义了相同或密切相关的概念。
- 依赖链使用冗长的
requires列表来共享定义,而通过导入方式实现会更简洁。exported_concepts - 在拆分操作后,共享概念出现重复或导出方式不合理的情况。
refactor-module - 用户希望将跨模块使用的领域概念统一到单一可信源中。
Guiding Principle
指导原则
This is a structural refactoring. The behavior of every affected module must remain identical. No functional spec, implementation req, or test req is changed. Only concept definitions move — from scattered locations into one shared import module — and the modules' lists are updated to reference it.
import这是一种结构性重构。所有受影响模块的行为必须保持完全一致。不得修改任何功能规范(functional spec)、实现要求(implementation req)或测试要求(test req)。仅迁移概念定义——从分散的位置移至单个共享导入模块——并更新模块的列表以引用该模块。
importInput
输入
The set of modules to consolidate from, plus optionally the name for the new (or existing) import module. If not specified, ask the user.
需要整合的模块集合,以及可选的新(或现有)导入模块名称。如果未指定名称,请询问用户。
Phase 1 — Analyze Concepts Across Modules
阶段1:跨模块分析概念
- Read all source modules. For each file involved, read the full file including frontmatter, definitions, implementation reqs, test reqs, and functional specs. Also read their
.plainandimportchains.requires - Build a concept inventory. For each concept defined across all source modules, record:
- Where it is defined (which file, which line)
- Which modules reference it (in definitions, functional specs, implementation reqs, or test reqs)
- Whether it is currently in an list
exported_concepts - Which other concepts it references in its definition (dependency graph)
- Identify consolidation candidates. A concept should be consolidated if:
- It is defined in one module but referenced by specs in another module (currently shared via )
exported_concepts - It is duplicated across multiple modules
- It is a foundational domain concept that logically belongs in a shared vocabulary
- It is defined in one module but referenced by specs in another module (currently shared via
- Identify concepts that should stay local. A concept should remain in its module if:
- It is only used within that single module's specs and definitions
- It is an internal implementation detail not meaningful outside that module
- 读取所有源模块:对于所有涉及的文件,读取完整文件内容,包括前置元数据、定义、实现要求、测试要求和功能规范。同时读取它们的
.plain和import依赖链。requires - 构建概念清单:针对所有源模块中定义的每个概念,记录:
- 定义位置(哪个文件、哪一行)
- 哪些模块引用了该概念(在定义、功能规范、实现要求或测试要求中)
- 该概念当前是否在列表中
exported_concepts - 其定义中引用了哪些其他概念(依赖关系图)
- 确定整合候选概念:满足以下条件的概念应被整合:
- 在一个模块中定义,但被另一个模块的规范引用(当前通过共享)
exported_concepts - 在多个模块中重复定义
- 是基础领域概念,逻辑上属于共享词汇表的一部分
- 在一个模块中定义,但被另一个模块的规范引用(当前通过
- 确定应保留在本地的概念:满足以下条件的概念应保留在原模块中:
- 仅在该模块的规范和定义中使用
- 是内部实现细节,对其他模块无意义
Phase 2 — Plan the Consolidation
阶段2:规划整合方案
Present the plan to the user and get explicit confirmation before making changes.
在进行修改前,向用户展示规划方案并获得明确确认。
2a. Choose the target import module
2a. 选择目标导入模块
- New import module — create a new file in
.plain. Choose a name that reflects the shared domain (e.g.,template/).template/myapp-concepts.plain - Existing import module — add the concepts to an import module that is already used by the affected modules. This avoids adding another import reference.
If the target is an existing import module, read it fully to understand what it already contains.
- 新建导入模块:在目录下创建一个新的
template/文件。选择一个能体现共享领域的名称(例如:.plain)。template/myapp-concepts.plain - 现有导入模块:将概念添加到已被受影响模块使用的导入模块中。这样可以避免添加额外的导入引用。
如果目标是现有导入模块,请完整读取该文件以了解其现有内容。
2b. Determine which concepts move
2b. 确定需要迁移的概念
For each consolidation candidate, confirm:
- The concept will be removed from its current module's section.
***definitions*** - The concept will be added to the target import module's section.
***definitions*** - The concept's full definition text (including all sub-bullets for attributes and constraints) is moved verbatim.
针对每个整合候选概念,确认:
- 该概念将从当前模块的部分移除。
***definitions*** - 该概念将被添加到目标导入模块的部分。
***definitions*** - 概念的完整定义文本(包括属性和约束的所有子项目符号)将原封不动地迁移。
2c. Determine concept ordering in the target
2c. 确定目标模块中的概念顺序
Concepts in the import module must be ordered so that every concept is defined after any concepts it references. Use the dependency graph from Phase 1 to establish a valid topological order.
导入模块中的概念必须按以下顺序排列:每个概念必须在其引用的所有概念之后定义。使用阶段1构建的依赖关系图来建立有效的拓扑顺序。
2d. Determine import and export changes
2d. 确定导入和导出的变更
For each affected module, determine the frontmatter changes:
| Change | When |
|---|---|
Add the new import to | Module does not already import the target |
Remove concepts from | Concepts that were exported only to share definitions — now handled by the import |
Keep concepts in | Concepts that downstream |
Important: provides definitions to the importing module. on a module provides concepts to downstream modules in the build chain. If a downstream module will now the shared template directly, the concept can be removed from . If a downstream module does not import the template, the concept must remain exported.
importexported_conceptsrequiresimportexported_concepts针对每个受影响的模块,确定前置元数据的变更:
| 变更内容 | 适用场景 |
|---|---|
将新导入添加到 | 模块尚未导入目标模块 |
从 | 仅为共享定义而导出的概念——现在通过导入方式处理 |
保留 | 下游 |
重要提示:为导入模块提供定义。模块上的为构建链中的下游模块提供概念。如果下游模块现在将直接共享模板,则可以从中移除该概念。如果下游模块未导入该模板,则必须保留该概念的导出。
importrequiresexported_conceptsimportexported_concepts2e. Present the plan
2e. 展示规划方案
Summarize for the user:
- Target import module (new or existing) and its path
- List of concepts being moved, with source module for each
- List of concepts staying local (and why)
- Frontmatter changes per module (additions,
importremovals)exported_concepts - Confirmation that no functional specs, implementation reqs, or test reqs are changing
Get explicit user confirmation before proceeding.
向用户总结以下内容:
- 目标导入模块(新建或现有)及其路径
- 待迁移概念列表,以及每个概念的源模块
- 保留在本地的概念列表(及原因)
- 每个模块的前置元数据变更(添加、移除
import中的概念)exported_concepts - 确认未修改任何功能规范、实现要求或测试要求
在继续执行前获得用户的明确确认。
Phase 3 — Execute
阶段3:执行整合
3a. Create or update the import module
3a. 创建或更新导入模块
If creating a new import module:
- Create with YAML frontmatter. If it needs concepts from another import, add that to its own
template/<name>.plainlist.import - Add a section with all consolidated concepts in dependency order.
***definitions*** - Do not add — import modules must not contain them.
***functional specs***
If updating an existing import module:
- Read the current file.
- Insert the new concepts into the section, respecting dependency order relative to existing concepts.
***definitions*** - Verify no concept name collisions with concepts already in the file or its own imports.
如果创建新导入模块:
- 创建文件并添加YAML前置元数据。如果它需要从其他导入模块获取概念,请将该模块添加到其自身的
template/<name>.plain列表中。import - 添加部分,按依赖顺序添加所有整合后的概念。
***definitions*** - 请勿添加——导入模块不得包含功能规范。
***functional specs***
如果更新现有导入模块:
- 读取当前文件内容。
- 将新概念插入到部分,确保相对于现有概念的依赖顺序正确。
***definitions*** - 验证与文件中已有的概念或其自身导入的概念不存在名称冲突。
3b. Update each source module
3b. 更新每个源模块
For each module that had concepts moved out:
- Remove the concept definitions from the module's section. Remove the full definition including all sub-bullets.
***definitions*** - Add the import to the module's YAML frontmatter list (if not already present).
import - Update — remove concepts that no longer need to be exported (see 2d).
exported_concepts - Do not touch ,
***functional specs***, or***implementation reqs***— concept references (***test reqs***) in these sections remain unchanged since the concept is now provided by the import.:ConceptName:
针对每个有概念移出的模块:
- 移除概念定义:从模块的部分移除概念定义。移除完整的定义内容,包括所有子项目符号。
***definitions*** - 添加导入:在模块的YAML前置元数据列表中添加导入(如果尚未存在)。
import - 更新——移除不再需要导出的概念(参见2d部分)。
exported_concepts - 请勿修改、
***functional specs***或***implementation reqs***——这些部分中的概念引用(***test reqs***)保持不变,因为概念现在由导入模块提供。:ConceptName:
3c. Update downstream modules (if applicable)
3c. 更新下游模块(如适用)
If concepts were removed from a module's and downstream modules relied on them:
exported_conceptsrequires- Add the new import to the downstream module's list so it gets the concepts directly.
import - Verify the downstream module's specs can still resolve all concept references.
如果从模块的中移除了概念,且下游模块依赖这些概念:
exported_conceptsrequires- 将新导入添加到下游模块的列表中,使其直接获取概念。
import - 验证下游模块的规范仍能解析所有概念引用。
Phase 4 — Verify
阶段4:验证
4a. Concept availability check
4a. 概念可用性检查
For every affected module (source modules, downstream modules, and the import module itself):
- Every referenced in functional specs is resolvable (defined locally, via import, or via exported concepts from requires)
:Concept: - Every referenced in definitions is defined before the concept that references it
:Concept: - Every referenced in implementation reqs and test reqs is resolvable
:Concept:
针对所有受影响的模块(源模块、下游模块和导入模块本身):
- 功能规范中引用的每个都可解析(本地定义、通过导入或通过requires模块的导出概念)
:Concept: - 定义中引用的每个都在引用它的概念之前定义
:Concept: - 实现要求和测试要求中引用的每个都可解析
:Concept:
4b. No duplicates check
4b. 无重复检查
- No concept is defined in both the import module and a source module
- No concept is defined in both the import module and another import that a source module uses
- Concept names are globally unique across each module's full resolution scope (local + imports + requires exports)
- 没有概念同时在导入模块和源模块中定义
- 没有概念同时在导入模块和源模块使用的其他导入模块中定义
- 概念名称在每个模块的完整解析范围(本地+导入+requires导出)内全局唯一
4c. Definition integrity check
4c. 定义完整性检查
- Each moved concept's definition text is identical to the original — no rewording, no lost sub-bullets
- Concept ordering in the import module respects the dependency graph (no forward references)
- 每个迁移概念的定义文本与原始文本完全一致——未重写、未丢失子项目符号
- 导入模块中的概念顺序符合依赖关系图(无前置引用)
4d. No behavioral change check
4d. 无行为变更检查
- No were modified in any module
***functional specs*** - No were modified in any module
***implementation reqs*** - No were modified in any module
***test reqs*** - No were modified in any module
***acceptance tests***
- 未修改任何模块的
***functional specs*** - 未修改任何模块的
***implementation reqs*** - 未修改任何模块的
***test reqs*** - 未修改任何模块的
***acceptance tests***
4e. Structural validation
4e. 结构验证
For the import module:
- File is in the directory
template/ - Does not contain
***functional specs*** - Does not use
requires - YAML frontmatter is correctly formatted
For each source module:
- YAML frontmatter list includes the target import module
import - is correct (no over-export, no missing exports)
exported_concepts - Module still has at least one functional spec and one implementation req
针对导入模块:
- 文件位于目录下
template/ - 不包含
***functional specs*** - 未使用
requires - YAML前置元数据格式正确
针对每个源模块:
- YAML前置元数据列表包含目标导入模块
import - 内容正确(无过度导出、无缺失导出)
exported_concepts - 模块仍至少包含一个功能规范和一个实现要求
4f. Read all modified files
4f. 读取所有修改后的文件
Read each modified file in full and present the changes to the user for approval. If the user requests changes, apply them and re-verify.
.plain完整读取每个修改后的文件,并向用户展示变更内容以获得批准。如果用户要求变更,应用变更后重新验证。
.plainCommon Pitfalls
常见陷阱
Moving a concept that is only used locally
迁移仅在本地使用的概念
If a concept is only referenced within a single module, consolidating it into a shared import adds unnecessary coupling. Keep it local.
如果一个概念仅在单个模块内被引用,将其整合到共享导入模块会增加不必要的耦合。应保留在本地。
Forgetting to update downstream requires modules
忘记更新下游requires模块
When a concept is removed from , any module that the source module and references that concept will break — unless it now imports the shared template. Always trace the full dependency chain.
exported_conceptsrequires当从中移除概念时,任何该源模块并引用该概念的模块都会失效——除非它现在导入了共享模板。务必追踪完整的依赖链。
exported_conceptsrequiresBreaking concept ordering
破坏概念顺序
Concepts in the import module must be topologically ordered. If references in its definition, then must appear first. The source modules may have had them in the right order locally, but merging concepts from different modules requires re-establishing a valid order.
:Meal::MealType::MealType:导入模块中的概念必须按拓扑顺序排列。如果在其定义中引用了,则必须排在前面。源模块中可能已在本地保持正确顺序,但合并来自不同模块的概念需要重新建立有效顺序。
:Meal::MealType::MealType:Creating circular imports
创建循环导入
An import module cannot a module that directly or indirectly imports it back. If the shared concepts reference concepts from an existing template, the new import module should itself import that template — not the other way around.
import导入模块不能直接或间接导入它的模块。如果共享概念引用了现有模板中的概念,新导入模块应该现有模板——而不是反过来。
importimportRemoving concepts from exported_concepts prematurely
过早从exported_concepts中移除概念
Only remove a concept from if every downstream module that needs it will now get it via . If even one downstream module does not import the shared template, the export must stay.
exported_conceptsrequiresimport仅当所有需要该概念的下游模块现在都通过获取它时,才能从中移除该概念。如果有任何一个下游模块未导入共享模板,则必须保留该导出。
requiresimportexported_conceptsValidation Checklist
验证清单
- User confirmed the consolidation plan before execution
- All moved concepts are defined in the import module with identical text
- Concepts are in valid dependency order in the import module
- No concept is defined in both the import module and a source module
- Every affected module's list includes the target import module
import - updated correctly — no missing exports, no unnecessary exports
exported_concepts - All concept references in all affected modules resolve correctly
- No functional specs, implementation reqs, test reqs, or acceptance tests were modified
- Import module is in and has no functional specs or requires
template/ - No circular imports introduced
- Downstream requires modules updated if needed
- User approved the final result
- 执行前用户已确认整合方案
- 所有迁移的概念在导入模块中的定义文本与原始完全一致
- 导入模块中的概念顺序符合依赖关系
- 没有概念同时在导入模块和源模块中定义
- 所有受影响模块的列表包含目标导入模块
import - 已正确更新——无缺失导出、无不必要导出
exported_concepts - 所有受影响模块中的概念引用均可正确解析
- 未修改任何功能规范、实现要求、测试要求或验收测试
- 导入模块位于目录下,且无功能规范或requires
template/ - 未引入循环导入
- 已按需更新下游requires模块
- 用户已批准最终结果