@namewta/speculo 0.3.4 → 0.5.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/README.md +4 -5
- package/package.json +1 -1
- package/template/canonical/canonical-specdev-engineering-cognitive-mentor.md +5 -0
- package/template/canonical/canonical-specdev-goal-plan.md +366 -59
- package/template/canonical/canonical-specdev-grill-with-docs.md +153 -104
- package/template/canonical/canonical-specdev-spec.md +5 -0
- package/template/canonical/canonical-specdev-tickets.md +5 -0
- package/template/canonical/canonical-specdev-wayfinder.md +171 -249
- package/template/commands/docs-sync.md +3 -3
- package/template/skills/docs-sync/SKILL.md +4 -3
- package/template/skills/docs-sync/assets/report-template.md +1 -0
- package/template/skills/docs-sync/references/agents/agent-writing.md +75 -0
- package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/claude-redirect.md +1 -1
- package/template/skills/docs-sync/references/agents-contract.md +23 -1
- package/template/skills/typescript-standards-builder/README.md +53 -0
- package/template/skills/typescript-standards-builder/SKILL.md +245 -0
- package/template/skills/typescript-standards-builder/examples/sample-generated-tree.md +30 -0
- package/template/skills/typescript-standards-builder/examples/sample-interview-decisions.md +26 -0
- package/template/skills/typescript-standards-builder/manifest.txt +29 -0
- package/template/skills/typescript-standards-builder/references/00-governance-and-fixed-defaults.md +77 -0
- package/template/skills/typescript-standards-builder/references/01-project-discovery.md +100 -0
- package/template/skills/typescript-standards-builder/references/02-interview-workflow.md +129 -0
- package/template/skills/typescript-standards-builder/references/03-project-architecture-and-directory-layout.md +84 -0
- package/template/skills/typescript-standards-builder/references/04-file-directory-and-symbol-naming.md +92 -0
- package/template/skills/typescript-standards-builder/references/05-modules-imports-exports-and-dependencies.md +63 -0
- package/template/skills/typescript-standards-builder/references/06-typescript-type-system.md +64 -0
- package/template/skills/typescript-standards-builder/references/07-functions-async-errors-and-resources.md +42 -0
- package/template/skills/typescript-standards-builder/references/08-comments-jsdoc-and-documentation.md +51 -0
- package/template/skills/typescript-standards-builder/references/09-testing-strategy.md +58 -0
- package/template/skills/typescript-standards-builder/references/10-react-and-frontend.md +39 -0
- package/template/skills/typescript-standards-builder/references/11-node-cli-and-cross-platform.md +31 -0
- package/template/skills/typescript-standards-builder/references/12-formatting-lint-and-complexity.md +58 -0
- package/template/skills/typescript-standards-builder/references/13-configuration-dependencies-and-ci.md +71 -0
- package/template/skills/typescript-standards-builder/references/14-security-performance-and-i18n.md +32 -0
- package/template/skills/typescript-standards-builder/references/15-git-review-and-delivery.md +28 -0
- package/template/skills/typescript-standards-builder/references/16-adoption-exceptions-and-migration.md +61 -0
- package/template/skills/typescript-standards-builder/references/17-generation-contract.md +104 -0
- package/template/skills/typescript-standards-builder/references/README.md +37 -0
- package/template/skills/typescript-standards-builder/templates/agents-compat-skill/SKILL.md +1 -0
- package/template/skills/typescript-standards-builder/templates/claude-skill/SKILL.md +1 -0
- package/template/skills/typescript-standards-builder/templates/project-skill/SKILL.md.template +34 -0
- package/template/skills/typescript-standards-builder/templates/project-skill/references/00-project-profile.md.template +17 -0
- package/template/skills/typescript-standards-builder/templates/project-skill/references/10-review-checklist.md +23 -0
- package/template/skills/typescript-standards-builder/templates/project-skill/references/11-decisions-and-exceptions.md.template +19 -0
- package/template/workflows/specdev/G-grill-with-docs/G-grill-with-docs.md +78 -73
- package/template/workflows/specdev/G-grill-with-docs/design-tree-template.json +9 -0
- package/template/workflows/specdev/G-grill-with-docs/grilling-protocol.md +16 -35
- package/template/workflows/specdev/G-grill-with-docs/log-format.md +2 -0
- package/template/workflows/specdev/I-implement/I-implement.md +12 -10
- package/template/workflows/specdev/I-implement/design-it-twice.md +45 -6
- package/template/workflows/specdev/I-implement/evidence-template.md +7 -0
- package/template/workflows/specdev/I-implement/execution-preflight.md +6 -0
- package/template/workflows/specdev/INDEX.md +11 -4
- package/template/workflows/specdev/P-goal-plan/P-goal-plan.md +23 -10
- package/template/workflows/specdev/P-goal-plan/completion-control.md +20 -7
- package/template/workflows/specdev/P-goal-plan/goal-plan-template.md +55 -3
- package/template/workflows/specdev/P-goal-plan/orchestration-protocol.md +42 -38
- package/template/workflows/specdev/P-goal-plan/planning-modes.md +36 -2
- package/template/workflows/specdev/R-review-architecture/R-review-architecture.md +67 -80
- package/template/workflows/specdev/R-review-architecture/architecture-report-contract.md +123 -0
- package/template/workflows/specdev/R-review-architecture/architecture-review-report-template.html +103 -55
- package/template/workflows/specdev/R-review-architecture/architecture-review-template.md +20 -29
- package/template/workflows/specdev/W-wayfinder/W-wayfinder.md +76 -147
- package/template/workflows/specdev/W-wayfinder/investigation-ticket-template.md +8 -53
- package/template/workflows/specdev/W-wayfinder/local-tracker-contract.md +36 -0
- package/template/workflows/specdev/W-wayfinder/solution-comment-template.md +17 -0
- package/template/workflows/specdev/W-wayfinder/wayfinder-map-template.md +12 -65
- package/template/workflows/specdev/common/README.md +4 -0
- package/template/workflows/specdev/common/rules/artifact-contract.md +5 -0
- package/template/workflows/specdev/common/rules/codebase-design.md +148 -0
- package/template/workflows/specdev/common/schemas/design-tree.schema.json +35 -0
- package/template/workflows/specdev/common/schemas/wayfinder-ticket.schema.json +19 -0
- package/template/workflows/specdev/common/skills/subagent-delivery/SKILL.md +61 -0
- package/template/workflows/specdev/common/skills/subagent-delivery/references/external-web-subagent.md +32 -0
- package/template/workflows/specdev/common/skills/subagent-delivery/references/github-checkpoints.md +24 -0
- package/template/workflows/specdev/common/skills/subagent-delivery/references/native-subagent.md +35 -0
- package/template/workflows/specdev/common/skills/subagent-delivery/references/source-package.md +17 -0
- package/template/workflows/specdev/common/tools/validate-specdev.mjs +226 -5
- package/template/skills/agents-md-builder/SKILL.md +0 -30
- package/template/skills/typescript-engineering-standards/README.md +0 -36
- package/template/skills/typescript-engineering-standards/SKILL.md +0 -158
- package/template/skills/typescript-engineering-standards/examples/comment-patterns.md +0 -47
- package/template/skills/typescript-engineering-standards/examples/naming-patterns.md +0 -42
- package/template/skills/typescript-engineering-standards/examples/project-layouts.md +0 -75
- package/template/skills/typescript-engineering-standards/examples/review-output-example.md +0 -25
- package/template/skills/typescript-engineering-standards/examples/type-modeling-patterns.md +0 -66
- package/template/skills/typescript-engineering-standards/manifest.txt +0 -33
- package/template/skills/typescript-engineering-standards/references/00-standard-levels-and-precedence.md +0 -51
- package/template/skills/typescript-engineering-standards/references/01-project-architecture-and-directory-layout.md +0 -105
- package/template/skills/typescript-engineering-standards/references/02-file-directory-and-symbol-naming.md +0 -117
- package/template/skills/typescript-engineering-standards/references/03-modules-imports-exports-and-dependencies.md +0 -111
- package/template/skills/typescript-engineering-standards/references/04-typescript-type-system.md +0 -150
- package/template/skills/typescript-engineering-standards/references/05-functions-async-errors-and-resources.md +0 -142
- package/template/skills/typescript-engineering-standards/references/06-comments-jsdoc-and-documentation.md +0 -104
- package/template/skills/typescript-engineering-standards/references/07-testing-strategy.md +0 -84
- package/template/skills/typescript-engineering-standards/references/08-react-and-frontend.md +0 -91
- package/template/skills/typescript-engineering-standards/references/09-node-cli-and-cross-platform.md +0 -92
- package/template/skills/typescript-engineering-standards/references/10-formatting-lint-and-complexity.md +0 -107
- package/template/skills/typescript-engineering-standards/references/11-configuration-dependencies-and-ci.md +0 -86
- package/template/skills/typescript-engineering-standards/references/12-security-performance-and-i18n.md +0 -65
- package/template/skills/typescript-engineering-standards/references/13-git-review-and-delivery.md +0 -79
- package/template/skills/typescript-engineering-standards/references/14-adoption-exceptions-and-migration.md +0 -84
- package/template/skills/typescript-engineering-standards/references/15-orca-derived-observations.md +0 -54
- package/template/skills/typescript-engineering-standards/references/README.md +0 -45
- package/template/skills/typescript-engineering-standards/templates/.editorconfig +0 -12
- package/template/skills/typescript-engineering-standards/templates/AGENTS.typescript.md +0 -21
- package/template/skills/typescript-engineering-standards/templates/code-review-checklist.md +0 -37
- package/template/skills/typescript-engineering-standards/templates/package-scripts.json +0 -11
- package/template/skills/typescript-engineering-standards/templates/prettier.json +0 -6
- package/template/skills/typescript-engineering-standards/templates/pull-request-template.md +0 -37
- package/template/skills/typescript-engineering-standards/templates/tsconfig.base.json +0 -17
- package/template/skills/typescript-engineering-standards/templates/tsconfig.project-references.json +0 -8
- package/template/workflows/specdev/I-implement/codebase-design-glossary.md +0 -12
- package/template/workflows/specdev/I-implement/deepening.md +0 -17
- /package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/content-contract.md +0 -0
- /package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/evidence-collection.md +0 -0
- /package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/manifest-discovery.md +0 -0
- /package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/role-classification.md +0 -0
- /package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/templates/aggregator-AGENTS.md +0 -0
- /package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/templates/capability-module-AGENTS.md +0 -0
- /package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/templates/contract-module-AGENTS.md +0 -0
- /package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/templates/repo-root-AGENTS.md +0 -0
- /package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/templates/runnable-app-AGENTS.md +0 -0
- /package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/templates/scripts-docs-AGENTS.md +0 -0
- /package/template/skills/{agents-md-builder/references → docs-sync/references/agents}/writing-style.md +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Agent 文档写作
|
|
2
|
+
|
|
3
|
+
任何由 agent 消费的文档的撰写参考——一份 skill、一个 `AGENTS.md` / `CLAUDE.md`、一份通过指针到达的文档。包装形式不同,撰写之道相同:同样的杠杆让每一份文档都可预测——agent 每次都走相同的*流程*,而不是产出相同的输出。
|
|
4
|
+
|
|
5
|
+
## 上下文指针
|
|
6
|
+
|
|
7
|
+
**上下文指针(context pointer)** 是 agent 上下文中持有的一条引用,它指明某份上下文之外的资料,并编码了到达它的条件。一份 skill 的 description 是指针;`AGENTS.md` 中一行指向某文档的引用,也是同一个东西。决定 agent 何时——以及多可靠地——到达该资料的,是指针的*措辞*,而不是它的目标。一个措辞薄弱的指针指向一份必读资料,就是一个变异 bug:先打磨措辞;只有打磨失败时,才把资料内联进来。
|
|
8
|
+
|
|
9
|
+
指针承担两项工作——说明资料是什么,并列出应触发到达它的**分支**(branch 是文档处理的某个不同情况,因此不同运行会走不同的路径)。一个始终加载的指针,每个字都要在每一轮对话中付出成本,所以它比正文更需要被毫不留情地精简:
|
|
10
|
+
|
|
11
|
+
- **前置引导词**——触发工作是在指针上完成的。
|
|
12
|
+
- **每个分支一个触发器。** 只是给同一分支换了个说法的同义词,等于把同一个分支写了两遍;把它们合并,只保留真正不同的分支。
|
|
13
|
+
- **删掉正文已经承载的身份信息。**
|
|
14
|
+
|
|
15
|
+
## 两种负载
|
|
16
|
+
|
|
17
|
+
你添加的每份文档和每个指针,都要花掉两种预算之一:
|
|
18
|
+
|
|
19
|
+
- **上下文负载(context load)**——始终加载的资料对 agent 窗口的代价:`AGENTS.md` 里的一行、一份 skill 描述、任何每轮对话都待在上下文里的东西,无论是否触发,都在消耗 token 和注意力。
|
|
20
|
+
- **认知负载(cognitive load)**——对人类的代价:存在哪些文档、何时该去取哪一份。人类就是索引。这不是需要最小化的成本——它是人类主动性的价格;在人类判断重要的地方花它,在无关紧要的地方拿掉它。
|
|
21
|
+
|
|
22
|
+
只通过指针到达的资料,免去了上下文负载,代价是指针自身的那一行;完全没有指针的资料,则完全压在认知负载上。
|
|
23
|
+
|
|
24
|
+
## 信息层级
|
|
25
|
+
|
|
26
|
+
一份文档由两种内容类型构成——**步骤**(agent 执行的有序操作)和**参考**(按需查阅的定义、规则、事实)——两者自由混合:全是步骤(一份菜谱)、全是参考(一次 review 的规则、本技能),或两者兼有。核心决策是每一块内容在**信息层级**上所处的位置,这是一把按 agent 需要资料的即时程度排序的梯子:
|
|
27
|
+
|
|
28
|
+
1. **文件内步骤**——第一层级:agent 做什么,按顺序。
|
|
29
|
+
2. **文件内参考**——按需查阅。它常常是一个合理扁平的并列集合(一次 review 的全部规则在同一条横档上)——这没什么不好,不是坏味道。
|
|
30
|
+
3. **外置参考(disclosed reference)**——推到独立文件里,通过上下文指针到达,只在指针触发时加载。从同一文件夹的兄弟文件,一直到住在任何地方、任何文档都能指向的完全外部参考。
|
|
31
|
+
|
|
32
|
+
推得太少,顶层会臃肿;推得太多,你会把 agent 真正需要的资料藏起来。这个张力就是全部决策所在。
|
|
33
|
+
|
|
34
|
+
**渐进式披露(progressive disclosure)** 是沿梯子向下的移动——从主文件中移出、放到指针后面——让顶层保持可读。它首先不是 token 优化:它是保护层级的方式。分支是最干净的披露测试:每个分支都要用到的内容内联保留,只有部分分支会碰到的内容推到指针后面。当一份文档有步骤时,本应披露的文件内参考会埋没这些步骤,让"照做"变成抛硬币——这不只是可读性杠杆,而是变异杠杆。
|
|
35
|
+
|
|
36
|
+
**就近放置(co-location)** 是文件内部的伴侣:梯子决定一块内容*下探多深*,就近放置决定它落到那里后*旁边放着什么*。把一个概念的定义、规则和注意事项放在同一个标题下,而不是散落各处,这样读到一部分时,相邻部分也随之而来。判断标准:文档读起来应该像专门写给 agent 的文档——归组的内容如此,散落的内容则不然。(它与重复不同:重复是在两个地方重述同一层含义;散落是把一层含义打碎到多处。)
|
|
37
|
+
|
|
38
|
+
**臃肿(sprawl)** 是这里的失败模式:一份文档单纯地太长,即使每一行都是活的、独一无二的。注意力在过剩内容中变薄,而每一行额外的内容都是又多一条需要保持相关的东西。解药就是那把梯子:把参考披露到指针后面,并按分支或序列拆分,让每条路径只携带它需要的东西。
|
|
39
|
+
|
|
40
|
+
## 步骤与完成标准
|
|
41
|
+
|
|
42
|
+
每个步骤都以一个**完成标准(completion criterion)** 收尾——告诉 agent 工作已完成的条件。两个属性使它成为杠杆:
|
|
43
|
+
|
|
44
|
+
- **清晰度**——agent 能否区分"完成"与"未完成"?一个模糊的边界("已达成理解")会招致**提前完成(premature completion)**:在步骤真正完成之前就结束它,注意力滑向*看起来完成了*。仍可见的后续步骤——**完成后的步骤(post-completion steps)**——提供拉力;标准的清晰度是阻力。按顺序防御:**先磨利边界**(局部且廉价);只有当边界不可约地模糊*且*你观察到赶工行为时,才通过拆分序列隐藏后续步骤——而隐藏只在真正的上下文边界处有效(一次交接或一个 subagent 派遣;内联调用会让后续步骤留在上下文中,什么也清不掉)。
|
|
45
|
+
- **要求强度(demand)**——它要求多少。"每个修改过的模型都被说明"逼出彻底的工作,而"生成一份变更清单"不会。要求强度驱动**苦功(legwork)**——agent 在工作内部做的挖掘,它藏在措辞里而不是写成独立步骤——并且它不绑定步骤:"每条规则都适用"绑定一整个扁平的参考集合,正如"每个步骤都完成"绑定一条序列,这正是一份纯参考文档仍然带着穷尽性门槛的方式。
|
|
46
|
+
|
|
47
|
+
最强的标准既可核查又穷尽。
|
|
48
|
+
|
|
49
|
+
## 何时拆分
|
|
50
|
+
|
|
51
|
+
把一份文档拆成两份,要花掉两种负载之一,所以只有在切口值得时才拆:
|
|
52
|
+
|
|
53
|
+
- **按序列拆分**——拆分一段步骤序列,此时完成后的步骤会诱使 agent 赶工眼前的步骤。让它们不可见,会驱动当前任务上更多的苦功。当心反向情况:合并序列会让每个步骤都暴露在后续步骤面前,招致提前完成。
|
|
54
|
+
|
|
55
|
+
## 引导词
|
|
56
|
+
|
|
57
|
+
**引导词(leading word)** 是一个早已存在于模型预训练中的紧凑概念,agent 在运行文档时用它思考(_lesson_、_fog of war_、_tracer bullets_)。以 token 形式重复、永不用句子重述,它累积出一个分布式的定义,并以最少的 token 锚定一整个行为区域——通过征用模型已有的先验。自己造词也行,只要定义清楚,但一个生造的词征用不到任何先验——你在定义 token 上付出的,正是预训练词免费给予的;先用已有的词。
|
|
58
|
+
|
|
59
|
+
它双重锚定。在正文里是*执行*:每次该词出现,agent 都伸手取同样的行为;在扁平参考内部,它把注意力聚焦到要找的一类事物上。在指针里是*调用*:当同一个词同时存在于你的 prompts、你的文档和你的代码库时,agent 会把这份共享语言与资料联系起来,更可靠地到达它。
|
|
60
|
+
|
|
61
|
+
寻找用引导词重构的机会。一个在三个地方展开的三件套、一个花一句话指向同一个概念的指针——每一处都是渴望塌缩成单个 token 的段落:
|
|
62
|
+
|
|
63
|
+
- "fast, deterministic, low-overhead" → _tight_(一个 _tight_ 循环)。
|
|
64
|
+
- "a loop you believe in" → _red_——一个模糊的闸门变成二元的可观察状态(遇到 bug 循环变 _red_,或不变)。
|
|
65
|
+
|
|
66
|
+
你赢两次:更少的 token,以及一个更锋利的钩子让 agent 挂上它的思考。假设每份文档都携带着引导词可以退役的重述——去把它们找出来。
|
|
67
|
+
|
|
68
|
+
**否定式表述(negation)** 是这个杠杆旁边的失败模式:用禁止来引导,会把被禁止的行为拖进上下文,让它变得*更容易*被激活,而不是更难。_不要想大象_,然后脑子里就全是大象;否定是一个脆弱的修饰符,会被强激活的概念碾过去,于是禁令有一半读起来像是在指示去做那件事。用**肯定式**提示——陈述目标行为("写一行注释"),让被禁止的行为永远不被说出来。只有当你实在无法用肯定句式表达时,一条禁令才配占有一席之地;即使如此,也要配上肯定的目标,让注意力落在"做什么"上。
|
|
69
|
+
|
|
70
|
+
## 精简
|
|
71
|
+
|
|
72
|
+
- 让每个含义都有**单一事实来源(single source of truth)**:一个权威的位置,这样改变行为就是改一处。**重复(duplication)**——同一含义出现在多个地方——耗费维护成本和 token,并把一个含义在梯子上的显著性抬到超过它实际等级的高度。(它是引导词的意外反面:引导词是有意重复一个 token,从来不是重复含义。)
|
|
73
|
+
- **环境(environment)** 也是事实来源——`package.json` 脚本、配置文件、目录布局、`--help` 输出——而重述环境的文档就是一份**缓存(cache)**:一次查询的副本,只有当查询本身昂贵时才值得负担这份负载。只缓存 agent 无法通过查找得到的东西:不成文的约定、选择背后的原因、任何配置文件都不会招认的坑。把"一个文件一条命令"式的查找留给环境,在那里它们不会过期。
|
|
74
|
+
- 逐行检查**相关性(relevance)**:它是否仍然与文档所做的事有关?一行内容失去相关性,要么因为从未作用于任务(纯叙述,或一个本应披露的分支),要么因为行为或世界变化而过期。更短的文档更容易保持相关。没有精简纪律,默认的归宿是**沉积(sediment)**:一层层过期的内容沉淀下来——因为添加感觉安全、删除感觉冒险——直到你必须钻穿它们才能找到仍然活着的东西。
|
|
75
|
+
- 逐句猎杀**无效指令(no-ops)**:一句模型本来就默认遵守的指令,花了负载却没说出任何东西。判断标准——它是否改变了相对默认的行为?——是模型相对的,不是读者相对的:两个人争论一句无效指令,争论的是默认是什么,而且要靠运行文档来裁决,不是靠辩论。当一句指令不合格时,删除整句,而不是从里面删词。这个判断标准也给引导词打分:一个弱到打不过默认的词(在 agent 已经够"be thorough"的地方写*要彻底*)就是无效指令,修法是换一个更强的词(*毫不留情*),而不是换一种技巧。
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
Speculo agent handbook: see [AGENTS.md](./AGENTS.md).
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
此格式与
|
|
13
|
+
此格式与 [`../agents-contract.md`](../agents-contract.md) 的规定一致(该契约为权威):`AGENTS.md` 始终是唯一的权威代理手册,`CLAUDE.md` 永远只是入口指针。
|
|
14
14
|
|
|
15
15
|
## 设计缘由
|
|
16
16
|
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
# AI 代理手册同步契约
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
本契约用于差量维护或重建已确认范围内的 `AGENTS.md`、`CLAUDE.md` 和工具专属入口。调用方传入 `handbook_mode=incremental|rebuild`;默认使用 `incremental`,仅在用户显式要求、手册缺失或 manifest 拓扑变化时进入 `rebuild`。
|
|
4
|
+
|
|
5
|
+
## 分支路由
|
|
6
|
+
|
|
7
|
+
### Incremental
|
|
8
|
+
|
|
9
|
+
读取当前手册、Git 输入区间和直接事实源,逐段执行下方内容优先级、生命周期和验证规则。不重新分类未受影响目录,也不加载重建模板。
|
|
10
|
+
|
|
11
|
+
**完成标准**:所有被 Git 区间或当前事实命中的手册均已整份审计,未命中手册保持不变。
|
|
12
|
+
|
|
13
|
+
### Rebuild
|
|
14
|
+
|
|
15
|
+
按顺序读取:
|
|
16
|
+
|
|
17
|
+
1. `agents/manifest-discovery.md`,发现 manifest、忽略目录、父子树和孤立手册;
|
|
18
|
+
2. `agents/role-classification.md`,为每个目录判定唯一角色;
|
|
19
|
+
3. `agents/evidence-collection.md`,为每个输出结论收集真实文件证据;
|
|
20
|
+
4. `agents/content-contract.md`、`agents/writing-style.md` 和对应 `agents/templates/*`,自底向上生成 AGENTS.md;
|
|
21
|
+
5. `agents/claude-redirect.md`,生成或修复同层 CLAUDE.md。
|
|
22
|
+
|
|
23
|
+
展示创建、更新和删除候选;整文件删除或把多行 CLAUDE.md 改成重定向前取得明确确认。
|
|
24
|
+
|
|
25
|
+
**完成标准**:扫描范围内每个合法目录恰好一个 AGENTS.md,每个 AGENTS.md 有唯一 CLAUDE.md 重定向,父子 routing 完整,所有处置均有证据和确认状态。
|
|
4
26
|
|
|
5
27
|
## 内容优先级
|
|
6
28
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# TypeScript Standards Builder Skill
|
|
2
|
+
|
|
3
|
+
这是一个“规范生成器”Skill,而不是静态编码规范合集。它会先读取项目事实,再通过用户问答确认决策,最后为当前项目生成专属的 TypeScript Standards Skill。
|
|
4
|
+
|
|
5
|
+
## 生成目标
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
.agents/skills/typescript-standards/ # 唯一正式规范源
|
|
9
|
+
.agents/skills/typescript--standards/ # 双连字符兼容跳转
|
|
10
|
+
.claude/skills/typescript-standards/ # 只有一句强制引用
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 核心特点
|
|
14
|
+
|
|
15
|
+
- 先扫描仓库,再提问,不让用户回答配置中已经明确的事实。
|
|
16
|
+
- 通过自适应问答确认真正有分歧的项目规则。
|
|
17
|
+
- 主 Skill 精简,详细规则拆入项目内 `references/`。
|
|
18
|
+
- 默认采用领域内部局部平铺、具体文件名、文件大小预算、WHY 注释、自动化门禁和测试共置。
|
|
19
|
+
- 不机械复制 Electron、React 或某个工具的专属目录。
|
|
20
|
+
- 对遗留项目采用只降不升的 Ratchet 策略。
|
|
21
|
+
- 同时兼容 `.agents` 与 `.claude` 的 Skill 发现方式。
|
|
22
|
+
|
|
23
|
+
## 包结构
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
typescript-standards-builder/
|
|
27
|
+
├── SKILL.md
|
|
28
|
+
├── README.md
|
|
29
|
+
├── references/
|
|
30
|
+
├── templates/
|
|
31
|
+
├── examples/
|
|
32
|
+
└── manifest.txt
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 使用方式
|
|
36
|
+
|
|
37
|
+
将整个目录安装到支持 Skill 的位置,以 `SKILL.md` 为入口。运行后,Skill 会在当前项目中生成项目专属规范,而不是修改本生成器包本身。
|
|
38
|
+
|
|
39
|
+
## 路径说明
|
|
40
|
+
|
|
41
|
+
正式项目规范使用单连字符:
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
.agents/skills/typescript-standards/SKILL.md
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
为兼容用户指定的 Claude 引用路径,还会创建:
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
.agents/skills/typescript--standards/SKILL.md
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
该兼容文件只跳转到正式规范,避免维护两份内容。
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: typescript-standards-builder
|
|
3
|
+
description: 通过仓库事实分析与用户问答,为当前 TypeScript 项目生成项目专属编码规范 Skill。输出正式 Skill 到 .agents/skills/typescript-standards,并创建 Claude 强制引用入口;适用于 TypeScript、React、Node.js、Electron、CLI、库及 Monorepo。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TypeScript Standards Builder
|
|
7
|
+
|
|
8
|
+
本 Skill 的职责不是直接把一份通用规范复制进项目,而是:
|
|
9
|
+
|
|
10
|
+
1. 分析当前仓库的真实结构、工具链和历史约定。
|
|
11
|
+
2. 使用简短、逐项的用户问答确认仍需决策的规范。
|
|
12
|
+
3. 将确认结果生成当前项目专属的 TypeScript 编码规范 Skill。
|
|
13
|
+
4. 把正式规范写入 `.agents/skills/typescript-standards/`。
|
|
14
|
+
5. 同时创建 `.claude/skills/typescript-standards/SKILL.md`,强制转向 `.agents` 中的唯一规范源。
|
|
15
|
+
|
|
16
|
+
详细规则采用渐进式读取。不要一次读取全部 `references/`。
|
|
17
|
+
|
|
18
|
+
## 最终输出目录
|
|
19
|
+
|
|
20
|
+
完成问答后,必须生成:
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
.agents/
|
|
24
|
+
└── skills/
|
|
25
|
+
├── typescript-standards/
|
|
26
|
+
│ ├── SKILL.md
|
|
27
|
+
│ └── references/
|
|
28
|
+
│ ├── 00-project-profile.md
|
|
29
|
+
│ ├── 01-architecture-and-layout.md
|
|
30
|
+
│ ├── 02-naming-and-files.md
|
|
31
|
+
│ ├── 03-modules-and-dependencies.md
|
|
32
|
+
│ ├── 04-type-system.md
|
|
33
|
+
│ ├── 05-functions-async-errors.md
|
|
34
|
+
│ ├── 06-comments-and-documentation.md
|
|
35
|
+
│ ├── 07-testing.md
|
|
36
|
+
│ ├── 08-framework-specific.md
|
|
37
|
+
│ ├── 09-tooling-and-quality-gates.md
|
|
38
|
+
│ ├── 10-review-checklist.md
|
|
39
|
+
│ └── 11-decisions-and-exceptions.md
|
|
40
|
+
└── typescript--standards/
|
|
41
|
+
└── SKILL.md
|
|
42
|
+
|
|
43
|
+
.claude/
|
|
44
|
+
└── skills/
|
|
45
|
+
└── typescript-standards/
|
|
46
|
+
└── SKILL.md
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`.agents/skills/typescript-standards/` 是唯一正式规范源。
|
|
50
|
+
|
|
51
|
+
由于兼容要求,必须额外生成双连字符入口:
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
.agents/skills/typescript--standards/SKILL.md
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
该文件只负责跳转到正式的单连字符目录。
|
|
58
|
+
|
|
59
|
+
`.claude/skills/typescript-standards/SKILL.md` 必须只有一句话,并强制引用用户指定的双连字符路径:
|
|
60
|
+
|
|
61
|
+
```md
|
|
62
|
+
必须先读取并完整遵循项目根目录下的 `.agents/skills/typescript--standards/SKILL.md`,禁止在未读取该文件时执行任何 TypeScript 相关任务。
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
除这一句话外,不得添加 YAML、标题、空白说明、示例或第二句话。
|
|
66
|
+
|
|
67
|
+
## 已确认的固定默认原则
|
|
68
|
+
|
|
69
|
+
以下规则来自用户已认可的工程实践,应直接作为生成规范的默认基线;除非仓库存在框架、生成器或公共 API 的硬性冲突,不需要再次询问用户是否采用:
|
|
70
|
+
|
|
71
|
+
- **领域内部局部平铺**:明确领域内优先平铺文件,只有形成稳定子域后再增加目录。
|
|
72
|
+
- **文件名具体**:文件名表达领域和职责,禁止用 `utils`、`helpers`、`common`、`misc` 等模糊名称承载不相关能力。
|
|
73
|
+
- **控制文件体积**:为普通 TypeScript、React、测试和脚本设置不同的审查预算;阈值是拆分触发器,不是机械裁决。
|
|
74
|
+
- **注释关注 WHY**:注释解释兼容性、性能、安全、平台差异和非直观约束,不逐行翻译代码。
|
|
75
|
+
- **工具链形成门禁**:格式化、Lint、类型检查、测试和构建形成自动化质量门禁,不得通过关闭核心规则或删除测试绕过。
|
|
76
|
+
- **测试靠近实现**:单元测试与源码共置;跨模块集成、契约和 E2E 测试集中管理。
|
|
77
|
+
- **不机械复制结构**:复制规则背后的目的,不把 Electron、React 或某个工具的专属结构强加给不相关项目。
|
|
78
|
+
|
|
79
|
+
这些原则已分别融入架构、命名、注释、测试、复杂度、CI 和迁移参考文档,不再维护独立的 Orca 附录。
|
|
80
|
+
|
|
81
|
+
## 规则优先级
|
|
82
|
+
|
|
83
|
+
发生冲突时依次遵循:
|
|
84
|
+
|
|
85
|
+
1. 用户在本次问答中明确确认的决定。
|
|
86
|
+
2. 运行平台、框架、协议、生成器和公共 API 的硬性约束。
|
|
87
|
+
3. 当前仓库已经生效的配置和 CI 门禁。
|
|
88
|
+
4. 当前模块一致且可解释的局部惯例。
|
|
89
|
+
5. 本 Skill 的固定默认原则和通用推荐。
|
|
90
|
+
|
|
91
|
+
安全、数据正确性、资源生命周期和外部输入验证不得因为“历史一直如此”而继续弱化。
|
|
92
|
+
|
|
93
|
+
## 执行流程
|
|
94
|
+
|
|
95
|
+
### 阶段 1:确认工作区
|
|
96
|
+
|
|
97
|
+
确定仓库根目录和规范适用范围:
|
|
98
|
+
|
|
99
|
+
- 单一应用、单一包或整个 Monorepo。
|
|
100
|
+
- 是否只覆盖 TypeScript,还是同时覆盖 JavaScript、React、Node.js、Electron、CLI。
|
|
101
|
+
- 是否存在自动生成目录、第三方镜像或不应修改的区域。
|
|
102
|
+
|
|
103
|
+
仓库中可直接判断的事实不得反复询问用户。
|
|
104
|
+
|
|
105
|
+
### 阶段 2:读取仓库事实
|
|
106
|
+
|
|
107
|
+
按 `references/01-project-discovery.md` 检查:
|
|
108
|
+
|
|
109
|
+
- `package.json`、Workspace 配置和锁文件。
|
|
110
|
+
- `tsconfig*.json` 及项目引用。
|
|
111
|
+
- ESLint、Oxlint、Biome、Prettier、Oxfmt 等配置。
|
|
112
|
+
- 测试框架、测试文件命名和覆盖范围。
|
|
113
|
+
- `src/`、`apps/`、`packages/` 的实际结构。
|
|
114
|
+
- 路径别名、导出入口、包边界和运行环境。
|
|
115
|
+
- `AGENTS.md`、`CLAUDE.md`、`CONTRIBUTING.md`、CI 工作流。
|
|
116
|
+
- 文件行数、模糊名称、循环依赖和测试共置情况的代表性样本。
|
|
117
|
+
|
|
118
|
+
输出一份内部项目画像,区分:
|
|
119
|
+
|
|
120
|
+
- 已由仓库事实确定的规则。
|
|
121
|
+
- 存在冲突或不一致的规则。
|
|
122
|
+
- 必须由用户决定的规则。
|
|
123
|
+
|
|
124
|
+
### 阶段 3:进行自适应问答
|
|
125
|
+
|
|
126
|
+
按 `references/02-interview-workflow.md` 执行。
|
|
127
|
+
|
|
128
|
+
要求:
|
|
129
|
+
|
|
130
|
+
- 一次只确认一个决策维度;必要时可把高度关联的两项放在同一轮。
|
|
131
|
+
- 每个问题先给出基于仓库事实的推荐默认值。
|
|
132
|
+
- 提供 2~4 个具体选项,并允许用户自定义。
|
|
133
|
+
- 不询问已经能从配置或代码中确定的事实。
|
|
134
|
+
- 不要求用户重新确认上面的七项固定默认原则,除非仓库存在硬冲突。
|
|
135
|
+
- 新项目通常确认 5~8 个高影响决策;成熟项目通常只确认冲突和缺失项。
|
|
136
|
+
- 每轮记录决定,避免重复提问。
|
|
137
|
+
|
|
138
|
+
至少要解决以下仍然不明确的项目级问题:
|
|
139
|
+
|
|
140
|
+
- 规范覆盖范围与遗留代码执行策略。
|
|
141
|
+
- 目录主轴和运行环境边界。
|
|
142
|
+
- React 组件文件命名(仅 React 项目)。
|
|
143
|
+
- 导出、Barrel 和跨模块导入策略。
|
|
144
|
+
- `type` / `interface` 默认偏好及运行时验证方式。
|
|
145
|
+
- 文件大小预算和超限治理方式。
|
|
146
|
+
- 测试框架、命名、共置及 CI 必跑范围。
|
|
147
|
+
- 格式化、Lint、类型检查、构建和提交前门禁。
|
|
148
|
+
- 例外批准、TODO 与迁移记录方式。
|
|
149
|
+
|
|
150
|
+
### 阶段 4:生成前确认
|
|
151
|
+
|
|
152
|
+
问答结束后,向用户展示一份简洁的“规范决策摘要”,必须包含:
|
|
153
|
+
|
|
154
|
+
- 自动识别的仓库事实。
|
|
155
|
+
- 用户确认的选择。
|
|
156
|
+
- 使用默认值的项目。
|
|
157
|
+
- 需要保留的历史例外。
|
|
158
|
+
- 即将创建或更新的文件列表。
|
|
159
|
+
|
|
160
|
+
只有在用户确认摘要后,才写入项目文件。若用户已经在同一消息中明确要求直接生成,可完成摘要后直接写入,不重复确认。
|
|
161
|
+
|
|
162
|
+
### 阶段 5:生成项目专属 Skill
|
|
163
|
+
|
|
164
|
+
按 `references/17-generation-contract.md` 和 `templates/project-skill/` 生成。
|
|
165
|
+
|
|
166
|
+
生成要求:
|
|
167
|
+
|
|
168
|
+
- 项目 Skill 必须是当前仓库专属内容,不得包含与项目无关的框架章节。
|
|
169
|
+
- `SKILL.md` 保持精简,只包含适用范围、优先级、核心不可违背规则、参考路由和执行要求。
|
|
170
|
+
- 详细规则写入 `references/`,按任务最小化读取。
|
|
171
|
+
- 每条重要规则标记来源:`仓库事实`、`用户确认`、`默认基线` 或 `兼容例外`。
|
|
172
|
+
- 固定默认原则必须进入对应模块,不能只写在总览。
|
|
173
|
+
- 文件大小阈值应结合仓库分布和用户决定,不直接硬编码通用数值。
|
|
174
|
+
- 对遗留项目使用 Ratchet 策略,不强迫一次性重构全部代码。
|
|
175
|
+
- 不覆盖用户已有项目 Skill;若已存在,先读取并合并,保留项目特有条款,并展示变更摘要。
|
|
176
|
+
|
|
177
|
+
### 阶段 6:创建重定向 Skill
|
|
178
|
+
|
|
179
|
+
必须创建以下两个入口。
|
|
180
|
+
|
|
181
|
+
正式兼容入口:
|
|
182
|
+
|
|
183
|
+
```text
|
|
184
|
+
.agents/skills/typescript--standards/SKILL.md
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
内容必须只有一句话:
|
|
188
|
+
|
|
189
|
+
```md
|
|
190
|
+
本文件仅用于路径兼容;必须立即读取并完整遵循项目根目录下的 `.agents/skills/typescript-standards/SKILL.md`。
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Claude 入口:
|
|
194
|
+
|
|
195
|
+
```text
|
|
196
|
+
.claude/skills/typescript-standards/SKILL.md
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
内容必须只有一句话:
|
|
200
|
+
|
|
201
|
+
```md
|
|
202
|
+
必须先读取并完整遵循项目根目录下的 `.agents/skills/typescript--standards/SKILL.md`,禁止在未读取该文件时执行任何 TypeScript 相关任务。
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### 阶段 7:验证
|
|
206
|
+
|
|
207
|
+
生成后必须验证:
|
|
208
|
+
|
|
209
|
+
- 正式 Skill 路径存在。
|
|
210
|
+
- `SKILL.md` YAML Frontmatter 合法,`name` 为 `typescript-standards`。
|
|
211
|
+
- 主 Skill 引用的所有 `references/` 文件都存在。
|
|
212
|
+
- 没有保留孤立的 `15-orca-derived-observations.md`。
|
|
213
|
+
- 七项固定默认原则已分散进入对应模块。
|
|
214
|
+
- `.claude` 的 `SKILL.md` 恰好只有一句话。
|
|
215
|
+
- 双连字符兼容入口存在且只包含一句话。
|
|
216
|
+
- 项目专属规范没有复制不适用的框架或运行环境规则。
|
|
217
|
+
- 用户确认的决定与生成内容一致。
|
|
218
|
+
- 不存在 `typescript--standards` 与 `typescript-standards` 相互循环引用。
|
|
219
|
+
|
|
220
|
+
最后报告:创建、更新、保留和未能验证的文件。
|
|
221
|
+
|
|
222
|
+
## 参考路由
|
|
223
|
+
|
|
224
|
+
| 任务 | 读取文档 |
|
|
225
|
+
|---|---|
|
|
226
|
+
| 规则优先级和固定默认原则 | `references/00-governance-and-fixed-defaults.md` |
|
|
227
|
+
| 仓库扫描与项目画像 | `references/01-project-discovery.md` |
|
|
228
|
+
| 用户问答和决策收敛 | `references/02-interview-workflow.md` |
|
|
229
|
+
| 目录、边界、局部平铺 | `references/03-project-architecture-and-directory-layout.md` |
|
|
230
|
+
| 文件、目录和标识符命名 | `references/04-file-directory-and-symbol-naming.md` |
|
|
231
|
+
| 模块、导入、导出和依赖 | `references/05-modules-imports-exports-and-dependencies.md` |
|
|
232
|
+
| TypeScript 类型系统 | `references/06-typescript-type-system.md` |
|
|
233
|
+
| 函数、异步、错误和资源 | `references/07-functions-async-errors-and-resources.md` |
|
|
234
|
+
| 注释、JSDoc 和文档 | `references/08-comments-jsdoc-and-documentation.md` |
|
|
235
|
+
| 测试策略和共置 | `references/09-testing-strategy.md` |
|
|
236
|
+
| React 和前端 | `references/10-react-and-frontend.md` |
|
|
237
|
+
| Node、CLI 和跨平台 | `references/11-node-cli-and-cross-platform.md` |
|
|
238
|
+
| 格式、Lint、文件大小 | `references/12-formatting-lint-and-complexity.md` |
|
|
239
|
+
| 配置、依赖和质量门禁 | `references/13-configuration-dependencies-and-ci.md` |
|
|
240
|
+
| 安全、性能和国际化 | `references/14-security-performance-and-i18n.md` |
|
|
241
|
+
| Git、PR 和交付 | `references/15-git-review-and-delivery.md` |
|
|
242
|
+
| 遗留迁移和例外 | `references/16-adoption-exceptions-and-migration.md` |
|
|
243
|
+
| 输出目录和文件合同 | `references/17-generation-contract.md` |
|
|
244
|
+
|
|
245
|
+
完整索引见 `references/README.md`。
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# 生成后的项目结构示例
|
|
2
|
+
|
|
3
|
+
```text
|
|
4
|
+
.agents/
|
|
5
|
+
└── skills/
|
|
6
|
+
├── typescript-standards/
|
|
7
|
+
│ ├── SKILL.md
|
|
8
|
+
│ └── references/
|
|
9
|
+
│ ├── 00-project-profile.md
|
|
10
|
+
│ ├── 01-architecture-and-layout.md
|
|
11
|
+
│ ├── 02-naming-and-files.md
|
|
12
|
+
│ ├── 03-modules-and-dependencies.md
|
|
13
|
+
│ ├── 04-type-system.md
|
|
14
|
+
│ ├── 05-functions-async-errors.md
|
|
15
|
+
│ ├── 06-comments-and-documentation.md
|
|
16
|
+
│ ├── 07-testing.md
|
|
17
|
+
│ ├── 08-framework-specific.md
|
|
18
|
+
│ ├── 09-tooling-and-quality-gates.md
|
|
19
|
+
│ ├── 10-review-checklist.md
|
|
20
|
+
│ └── 11-decisions-and-exceptions.md
|
|
21
|
+
└── typescript--standards/
|
|
22
|
+
└── SKILL.md
|
|
23
|
+
|
|
24
|
+
.claude/
|
|
25
|
+
└── skills/
|
|
26
|
+
└── typescript-standards/
|
|
27
|
+
└── SKILL.md
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
实际项目可裁剪不适用的主题文件,但不得删除项目画像、检查清单和决策例外记录。
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# 问答决策示例
|
|
2
|
+
|
|
3
|
+
## 自动识别
|
|
4
|
+
|
|
5
|
+
- pnpm Workspace。
|
|
6
|
+
- ESM。
|
|
7
|
+
- React + Node.js。
|
|
8
|
+
- Vitest 单元测试已与源码共置。
|
|
9
|
+
- ESLint 和 Prettier 已在 CI 中运行。
|
|
10
|
+
|
|
11
|
+
## 用户确认
|
|
12
|
+
|
|
13
|
+
- 运行环境第一层隔离,环境内部按领域组织。
|
|
14
|
+
- React 业务组件使用 `PascalCase.tsx`。
|
|
15
|
+
- 默认命名导出,Barrel 仅用于包公共入口。
|
|
16
|
+
- 默认使用 `type`,扩展契约使用 `interface`。
|
|
17
|
+
- 普通 TS/TSX 文件软上限分别为 320/420 行。
|
|
18
|
+
- 历史超限文件使用 Ratchet,不立即全量整改。
|
|
19
|
+
|
|
20
|
+
## 默认基线
|
|
21
|
+
|
|
22
|
+
- 领域内部局部平铺。
|
|
23
|
+
- 文件名具体。
|
|
24
|
+
- 注释解释 WHY。
|
|
25
|
+
- 单元测试共置。
|
|
26
|
+
- CI 必跑格式、Lint、类型、测试和构建。
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
SKILL.md
|
|
3
|
+
examples/sample-generated-tree.md
|
|
4
|
+
examples/sample-interview-decisions.md
|
|
5
|
+
references/00-governance-and-fixed-defaults.md
|
|
6
|
+
references/01-project-discovery.md
|
|
7
|
+
references/02-interview-workflow.md
|
|
8
|
+
references/03-project-architecture-and-directory-layout.md
|
|
9
|
+
references/04-file-directory-and-symbol-naming.md
|
|
10
|
+
references/05-modules-imports-exports-and-dependencies.md
|
|
11
|
+
references/06-typescript-type-system.md
|
|
12
|
+
references/07-functions-async-errors-and-resources.md
|
|
13
|
+
references/08-comments-jsdoc-and-documentation.md
|
|
14
|
+
references/09-testing-strategy.md
|
|
15
|
+
references/10-react-and-frontend.md
|
|
16
|
+
references/11-node-cli-and-cross-platform.md
|
|
17
|
+
references/12-formatting-lint-and-complexity.md
|
|
18
|
+
references/13-configuration-dependencies-and-ci.md
|
|
19
|
+
references/14-security-performance-and-i18n.md
|
|
20
|
+
references/15-git-review-and-delivery.md
|
|
21
|
+
references/16-adoption-exceptions-and-migration.md
|
|
22
|
+
references/17-generation-contract.md
|
|
23
|
+
references/README.md
|
|
24
|
+
templates/agents-compat-skill/SKILL.md
|
|
25
|
+
templates/claude-skill/SKILL.md
|
|
26
|
+
templates/project-skill/SKILL.md.template
|
|
27
|
+
templates/project-skill/references/00-project-profile.md.template
|
|
28
|
+
templates/project-skill/references/10-review-checklist.md
|
|
29
|
+
templates/project-skill/references/11-decisions-and-exceptions.md.template
|
package/template/skills/typescript-standards-builder/references/00-governance-and-fixed-defaults.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# 治理、优先级与固定默认原则
|
|
2
|
+
|
|
3
|
+
## 规范词义
|
|
4
|
+
|
|
5
|
+
- **必须**:影响正确性、安全、类型边界、资源生命周期或团队一致性的硬要求。
|
|
6
|
+
- **应当**:绝大多数情况下适用;偏离时必须有明确理由。
|
|
7
|
+
- **建议**:默认推荐,可根据规模、框架和团队能力调整。
|
|
8
|
+
- **禁止**:高概率制造缺陷、隐藏风险或降低维护性的做法。
|
|
9
|
+
|
|
10
|
+
## 冲突优先级
|
|
11
|
+
|
|
12
|
+
1. 用户在本次规范问答中确认的决定。
|
|
13
|
+
2. 平台、框架、协议、代码生成器和公共 API 的硬约束。
|
|
14
|
+
3. 仓库已生效配置、CI 与自动检查。
|
|
15
|
+
4. 当前模块一致且可解释的局部惯例。
|
|
16
|
+
5. 本 Skill 的固定默认原则。
|
|
17
|
+
6. 其他通用建议。
|
|
18
|
+
|
|
19
|
+
## 固定默认原则
|
|
20
|
+
|
|
21
|
+
以下原则已得到用户认可,应直接纳入项目规范;只有发现硬冲突时才提问:
|
|
22
|
+
|
|
23
|
+
### 1. 领域内部局部平铺
|
|
24
|
+
|
|
25
|
+
- 小型、职责明确的领域目录优先直接放置实现文件。
|
|
26
|
+
- 不为每个文件创建同名目录。
|
|
27
|
+
- 只有形成稳定子领域、独立生命周期或明显浏览负担时才增加子目录。
|
|
28
|
+
- 平铺不是全仓库无结构,而是在清晰边界内部减少无意义层级。
|
|
29
|
+
|
|
30
|
+
### 2. 文件名具体
|
|
31
|
+
|
|
32
|
+
- 文件名必须表达领域和职责。
|
|
33
|
+
- `utils.ts`、`helpers.ts`、`common.ts`、`misc.ts` 不得作为不相关能力的收容区。
|
|
34
|
+
- 无法给文件起具体名称,通常意味着职责尚未拆清。
|
|
35
|
+
|
|
36
|
+
### 3. 控制文件体积
|
|
37
|
+
|
|
38
|
+
- 普通 TypeScript、React、测试和脚本采用不同的大小预算。
|
|
39
|
+
- 阈值是代码审查与拆分触发器,不是为了满足数字而机械拆文件。
|
|
40
|
+
- 历史超限文件使用 Ratchet:新改动不得继续无边界增长。
|
|
41
|
+
|
|
42
|
+
### 4. 注释关注 WHY
|
|
43
|
+
|
|
44
|
+
- 注释解释兼容性、性能、安全、平台差异、协议约束和非直观业务原因。
|
|
45
|
+
- 不逐行翻译代码,不用注释掩盖模糊命名和职责混合。
|
|
46
|
+
|
|
47
|
+
### 5. 工具链形成门禁
|
|
48
|
+
|
|
49
|
+
- 格式化、Lint、类型检查、测试和构建必须形成稳定命令与 CI 门禁。
|
|
50
|
+
- 底层工具可以替换,但职责名称和检查结果保持稳定。
|
|
51
|
+
- 不得通过关闭核心规则、扩大 `any`、删除或跳过测试来获得表面通过。
|
|
52
|
+
|
|
53
|
+
### 6. 测试靠近实现
|
|
54
|
+
|
|
55
|
+
- 单元测试与源码共置,随实现一起移动和重命名。
|
|
56
|
+
- 跨模块集成、契约和 E2E 测试集中管理。
|
|
57
|
+
- 缺陷修复优先先写可复现的回归测试。
|
|
58
|
+
|
|
59
|
+
### 7. 不机械复制
|
|
60
|
+
|
|
61
|
+
- 不把 Electron 目录强加给普通 Web 或 Node 项目。
|
|
62
|
+
- 不把某个格式化工具的选项当作永恒标准。
|
|
63
|
+
- 不把通用阈值直接作为项目绝对数字。
|
|
64
|
+
- 应保留背后的目标:边界清晰、职责具体、类型严格、质量自动化、修改可验证。
|
|
65
|
+
|
|
66
|
+
## 事实优先但不纵容风险
|
|
67
|
+
|
|
68
|
+
历史一致性不能为以下问题背书:
|
|
69
|
+
|
|
70
|
+
- 不可信输入未经验证。
|
|
71
|
+
- 敏感信息泄漏。
|
|
72
|
+
- 监听器、Timer、连接或进程无法清理。
|
|
73
|
+
- `any` 向公共 API 传播。
|
|
74
|
+
- 循环依赖或跨运行环境非法导入。
|
|
75
|
+
- 删除测试、关闭规则或放宽配置来隐藏失败。
|
|
76
|
+
|
|
77
|
+
对遗留问题采用渐进治理,不要求无关的大规模重写。
|