@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
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# 安全、性能与国际化
|
|
2
|
-
|
|
3
|
-
## 输入安全
|
|
4
|
-
|
|
5
|
-
所有外部输入必须验证,包括 API、IPC、消息、配置、文件、URL 和用户输入。
|
|
6
|
-
|
|
7
|
-
- 路径防止目录穿越。
|
|
8
|
-
- SQL 使用参数化查询。
|
|
9
|
-
- Shell 使用参数数组并正确转义。
|
|
10
|
-
- HTML 默认转义,谨慎使用原始 HTML。
|
|
11
|
-
- URL、重定向和文件类型需要校验。
|
|
12
|
-
- 跨窗口、跨进程消息校验来源和结构。
|
|
13
|
-
|
|
14
|
-
## 敏感信息
|
|
15
|
-
|
|
16
|
-
禁止:
|
|
17
|
-
|
|
18
|
-
- 日志记录密码、Token、Cookie、私钥。
|
|
19
|
-
- 将秘密打包到浏览器代码。
|
|
20
|
-
- 提交 `.env`、证书或生产配置。
|
|
21
|
-
- 向最终用户泄露内部堆栈、路径和未脱敏请求。
|
|
22
|
-
- 把用户输入直接作为命令、查询或文件路径执行。
|
|
23
|
-
|
|
24
|
-
日志应使用结构化字段并在边界脱敏。
|
|
25
|
-
|
|
26
|
-
## 权限
|
|
27
|
-
|
|
28
|
-
- 默认最小权限。
|
|
29
|
-
- 权限判断集中在策略或 Guard 中。
|
|
30
|
-
- UI 隐藏按钮不能替代服务端鉴权。
|
|
31
|
-
- 高风险操作有确认、审计和幂等保护。
|
|
32
|
-
- 不依赖客户端可篡改字段作最终安全决策。
|
|
33
|
-
|
|
34
|
-
## 性能原则
|
|
35
|
-
|
|
36
|
-
- 优化以前先测量。
|
|
37
|
-
- 优先改进算法复杂度、I/O 次数和数据复制。
|
|
38
|
-
- 大文件、日志和列表使用流式、分页、窗口化或虚拟化。
|
|
39
|
-
- 避免热路径重复解析配置、创建正则、序列化大型对象或读取磁盘。
|
|
40
|
-
- 定时器、监听器、队列和缓存必须有上限和清理。
|
|
41
|
-
|
|
42
|
-
## 缓存
|
|
43
|
-
|
|
44
|
-
缓存需要明确:
|
|
45
|
-
|
|
46
|
-
- 键和命名空间。
|
|
47
|
-
- 容量上限。
|
|
48
|
-
- 淘汰策略。
|
|
49
|
-
- 过期和主动失效。
|
|
50
|
-
- 一致性要求。
|
|
51
|
-
- 是否缓存错误或空结果。
|
|
52
|
-
|
|
53
|
-
非直观优化应有基准、回归测试或简短原因说明。
|
|
54
|
-
|
|
55
|
-
## 国际化
|
|
56
|
-
|
|
57
|
-
有多语言需求时:
|
|
58
|
-
|
|
59
|
-
- 用户可见文本不散落为硬编码字符串。
|
|
60
|
-
- 文案键按领域语义命名,不按屏幕位置命名。
|
|
61
|
-
- 插值使用具名参数。
|
|
62
|
-
- 不拼接自然语言句子。
|
|
63
|
-
- 日期、数字、货币和复数使用国际化 API。
|
|
64
|
-
- 用户提示和开发日志分离。
|
|
65
|
-
- CI 检查缺失键、未使用键和占位符不一致。
|
package/template/skills/typescript-engineering-standards/references/13-git-review-and-delivery.md
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# Git、代码评审与交付
|
|
2
|
-
|
|
3
|
-
## 分支命名
|
|
4
|
-
|
|
5
|
-
推荐:
|
|
6
|
-
|
|
7
|
-
- `feat/workspace-search`
|
|
8
|
-
- `fix/session-timeout-race`
|
|
9
|
-
- `refactor/terminal-state-split`
|
|
10
|
-
- `perf/large-log-rendering`
|
|
11
|
-
- `test/payment-retry-policy`
|
|
12
|
-
- `docs/typescript-style-guide`
|
|
13
|
-
- `chore/upgrade-vitest`
|
|
14
|
-
|
|
15
|
-
避免 `update`、`changes`、`fix-stuff` 等无语义名称。
|
|
16
|
-
|
|
17
|
-
## 提交信息
|
|
18
|
-
|
|
19
|
-
可采用 Conventional Commits:
|
|
20
|
-
|
|
21
|
-
```text
|
|
22
|
-
feat(auth): add device authorization flow
|
|
23
|
-
fix(terminal): prevent duplicate process cleanup
|
|
24
|
-
refactor(store): split workspace selectors
|
|
25
|
-
test(cli): cover empty shell argument
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
提交应:
|
|
29
|
-
|
|
30
|
-
- 聚焦一个逻辑变化。
|
|
31
|
-
- 不混入无关格式化。
|
|
32
|
-
- 能通过基本检查。
|
|
33
|
-
- 不包含秘密、构建产物和本地配置。
|
|
34
|
-
- 说明改变的目的,而不仅是文件列表。
|
|
35
|
-
|
|
36
|
-
## Pull Request
|
|
37
|
-
|
|
38
|
-
PR 应包含:
|
|
39
|
-
|
|
40
|
-
- 背景和问题。
|
|
41
|
-
- 方案和关键取舍。
|
|
42
|
-
- 风险、兼容性和迁移影响。
|
|
43
|
-
- 验证方式。
|
|
44
|
-
- UI 变化的截图或录屏。
|
|
45
|
-
- 缺陷修复的回归测试。
|
|
46
|
-
- 未完成项和后续工作。
|
|
47
|
-
|
|
48
|
-
## 审查优先级
|
|
49
|
-
|
|
50
|
-
1. 正确性、安全、数据完整性。
|
|
51
|
-
2. 类型边界和运行时验证。
|
|
52
|
-
3. 资源生命周期、并发、错误处理。
|
|
53
|
-
4. 架构边界和公共 API。
|
|
54
|
-
5. 测试缺口。
|
|
55
|
-
6. 可维护性与命名。
|
|
56
|
-
7. 风格。
|
|
57
|
-
|
|
58
|
-
## 审查意见格式
|
|
59
|
-
|
|
60
|
-
一条有效意见应尽量说明:
|
|
61
|
-
|
|
62
|
-
- 具体位置。
|
|
63
|
-
- 真实风险。
|
|
64
|
-
- 触发条件。
|
|
65
|
-
- 建议修复方向。
|
|
66
|
-
- 是否阻塞合并。
|
|
67
|
-
|
|
68
|
-
不要只写“这里不好”“建议重构”。
|
|
69
|
-
|
|
70
|
-
## 交付检查
|
|
71
|
-
|
|
72
|
-
- 格式检查通过。
|
|
73
|
-
- Lint 通过。
|
|
74
|
-
- 类型检查通过。
|
|
75
|
-
- 相关测试通过。
|
|
76
|
-
- 构建通过。
|
|
77
|
-
- 文档和配置同步。
|
|
78
|
-
- 没有无关改动。
|
|
79
|
-
- 已评估跨平台、安全、性能和兼容性。
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# 落地、例外与迁移
|
|
2
|
-
|
|
3
|
-
## 例外原则
|
|
4
|
-
|
|
5
|
-
规范允许例外,但不允许无记录的例外。例外必须:
|
|
6
|
-
|
|
7
|
-
1. 有具体技术原因。
|
|
8
|
-
2. 范围尽可能小。
|
|
9
|
-
3. 在代码、配置或 PR 中说明。
|
|
10
|
-
4. 不破坏核心安全与类型边界。
|
|
11
|
-
5. 临时例外有退出条件和跟踪任务。
|
|
12
|
-
6. 经代码评审确认。
|
|
13
|
-
|
|
14
|
-
## 例外示例
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
// Why: Vendor callback type is incorrect; remove after SDK-481 is fixed.
|
|
19
|
-
function normalizeVendorPayload(payload: any): NormalizedPayload {
|
|
20
|
-
return vendorPayloadSchema.parse(payload)
|
|
21
|
-
}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
该例外仍在边界进行运行时验证,不让 `any` 传播。
|
|
25
|
-
|
|
26
|
-
## 遗留项目迁移
|
|
27
|
-
|
|
28
|
-
不要一次性重写全部代码。推荐阶段:
|
|
29
|
-
|
|
30
|
-
### 阶段 1:建立事实和门禁
|
|
31
|
-
|
|
32
|
-
- 固定包管理器和锁文件。
|
|
33
|
-
- 增加稳定的 `format:check`、`lint`、`typecheck`、`test`、`build` 命令。
|
|
34
|
-
- CI 先报告问题,再逐步改为阻塞。
|
|
35
|
-
|
|
36
|
-
### 阶段 2:阻止新增债务
|
|
37
|
-
|
|
38
|
-
- 新文件遵守命名和大小规则。
|
|
39
|
-
- 新 API 不使用 `any`。
|
|
40
|
-
- 新外部输入必须验证。
|
|
41
|
-
- 新缺陷修复补回归测试。
|
|
42
|
-
|
|
43
|
-
### 阶段 3:按触及范围治理
|
|
44
|
-
|
|
45
|
-
- 修改旧文件时降低复杂度。
|
|
46
|
-
- 拆出纯逻辑并补测试。
|
|
47
|
-
- 清理循环依赖和万能工具文件。
|
|
48
|
-
- 缩小公共 API。
|
|
49
|
-
|
|
50
|
-
### 阶段 4:专项迁移
|
|
51
|
-
|
|
52
|
-
- 分模块开启更严格的 TypeScript 选项。
|
|
53
|
-
- 按领域迁移目录。
|
|
54
|
-
- 引入项目引用和依赖边界检查。
|
|
55
|
-
- 清理临时规则禁用和类型断言。
|
|
56
|
-
|
|
57
|
-
## Ratchet 策略
|
|
58
|
-
|
|
59
|
-
对无法立即达标的指标采用“只降不升”:
|
|
60
|
-
|
|
61
|
-
- 文件行数不能继续增长。
|
|
62
|
-
- `any` 数量不能增加。
|
|
63
|
-
- 循环依赖数量不能增加。
|
|
64
|
-
- 被跳过测试数量不能增加。
|
|
65
|
-
- Lint 警告基线只能下降。
|
|
66
|
-
|
|
67
|
-
## 自动生成代码
|
|
68
|
-
|
|
69
|
-
生成代码可以豁免部分格式、大小和命名规则,但必须:
|
|
70
|
-
|
|
71
|
-
- 明确标识生成来源。
|
|
72
|
-
- 不手工修改。
|
|
73
|
-
- 将生成目录排除在不适用检查外。
|
|
74
|
-
- 对生成器本身进行测试和审查。
|
|
75
|
-
|
|
76
|
-
## 大规模重命名
|
|
77
|
-
|
|
78
|
-
只有在用户明确要求或迁移收益充分时进行。应:
|
|
79
|
-
|
|
80
|
-
- 单独 PR。
|
|
81
|
-
- 不混入功能变化。
|
|
82
|
-
- 使用自动化重构工具。
|
|
83
|
-
- 检查大小写敏感文件系统和 Git 重命名。
|
|
84
|
-
- 验证导入、测试、文档和构建。
|
package/template/skills/typescript-engineering-standards/references/15-orca-derived-observations.md
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# 从 Orca 项目提炼的工程习惯
|
|
2
|
-
|
|
3
|
-
本文件记录从 Orca 类型项目实践中抽象出的可迁移经验。它不是要求其他项目复制 Electron 目录,也不是 Orca 上游规范的逐字镜像。
|
|
4
|
-
|
|
5
|
-
## 1. 运行环境边界优先
|
|
6
|
-
|
|
7
|
-
Orca 一类 Electron 项目天然包含主进程、预加载、渲染器、共享代码和命令行等不同运行环境。可迁移经验是:
|
|
8
|
-
|
|
9
|
-
- 运行能力不同的代码应物理隔离。
|
|
10
|
-
- 每个环境使用适合自己的 TypeScript 配置和依赖范围。
|
|
11
|
-
- 跨边界接口显式化,而不是随意互相导入。
|
|
12
|
-
|
|
13
|
-
## 2. 领域内部局部平铺
|
|
14
|
-
|
|
15
|
-
Orca 的工程习惯体现出:同一明确职责区域不必为每个实现再加一层目录。可迁移经验是:
|
|
16
|
-
|
|
17
|
-
- 小型领域优先平铺。
|
|
18
|
-
- 文件名承担定位职责。
|
|
19
|
-
- 只有形成稳定子域后再增加目录。
|
|
20
|
-
|
|
21
|
-
## 3. 文件名具体
|
|
22
|
-
|
|
23
|
-
相较 `utils.ts`、`helpers.ts`,具体动作和领域名称更利于搜索、审查和拆分。例如清理、解析、引用、状态选择、平台适配等职责可以直接进入文件名。
|
|
24
|
-
|
|
25
|
-
## 4. 控制文件体积
|
|
26
|
-
|
|
27
|
-
对普通 TypeScript、React 文件和测试设置不同的大小预算,可以提前暴露职责混合。数字应视为审查触发器,而非机械规则。
|
|
28
|
-
|
|
29
|
-
## 5. 注释关注 WHY
|
|
30
|
-
|
|
31
|
-
简短解释兼容性、性能、安全和平台差异,比逐行描述实现更有价值。注释不能替代清晰命名和模块拆分。
|
|
32
|
-
|
|
33
|
-
## 6. 工具链形成门禁
|
|
34
|
-
|
|
35
|
-
Orca 类现代项目通常将格式化、Lint、类型检查、测试和 Git/CI 检查组合起来。可迁移经验是:
|
|
36
|
-
|
|
37
|
-
- 规范应尽量机器可执行。
|
|
38
|
-
- 命令名保持稳定,底层工具可替换。
|
|
39
|
-
- 不允许通过关闭规则或删除测试绕过门禁。
|
|
40
|
-
|
|
41
|
-
## 7. 测试靠近实现
|
|
42
|
-
|
|
43
|
-
单元测试和实现共置,便于发现、移动和维护;集成和 E2E 测试则按跨模块边界集中管理。
|
|
44
|
-
|
|
45
|
-
## 8. 不机械复制
|
|
46
|
-
|
|
47
|
-
不应直接复制:
|
|
48
|
-
|
|
49
|
-
- Electron 专属目录到普通 Node 或 Web 项目。
|
|
50
|
-
- 某个具体格式工具的全部选项。
|
|
51
|
-
- 某个仓库的行数阈值作为绝对标准。
|
|
52
|
-
- 某个框架生成目录的特殊命名。
|
|
53
|
-
|
|
54
|
-
应复制的是背后的目的:边界清晰、职责具体、类型严格、质量自动化、修改可验证。
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# Reference Index
|
|
2
|
-
|
|
3
|
-
本目录保存 TypeScript 工程规范的详细知识模块。`SKILL.md` 是唯一主入口;执行具体任务时只读取必要模块。
|
|
4
|
-
|
|
5
|
-
## 分类
|
|
6
|
-
|
|
7
|
-
### 治理与决策
|
|
8
|
-
|
|
9
|
-
- `00-standard-levels-and-precedence.md`:规则级别、冲突处理、事实优先。
|
|
10
|
-
- `14-adoption-exceptions-and-migration.md`:例外、遗留项目、渐进迁移。
|
|
11
|
-
- `15-orca-derived-observations.md`:从 Orca 工程实践中抽象出的可迁移经验。
|
|
12
|
-
|
|
13
|
-
### 架构与代码组织
|
|
14
|
-
|
|
15
|
-
- `01-project-architecture-and-directory-layout.md`
|
|
16
|
-
- `02-file-directory-and-symbol-naming.md`
|
|
17
|
-
- `03-modules-imports-exports-and-dependencies.md`
|
|
18
|
-
|
|
19
|
-
### 语言与实现
|
|
20
|
-
|
|
21
|
-
- `04-typescript-type-system.md`
|
|
22
|
-
- `05-functions-async-errors-and-resources.md`
|
|
23
|
-
- `06-comments-jsdoc-and-documentation.md`
|
|
24
|
-
|
|
25
|
-
### 平台与测试
|
|
26
|
-
|
|
27
|
-
- `07-testing-strategy.md`
|
|
28
|
-
- `08-react-and-frontend.md`
|
|
29
|
-
- `09-node-cli-and-cross-platform.md`
|
|
30
|
-
|
|
31
|
-
### 工程化与交付
|
|
32
|
-
|
|
33
|
-
- `10-formatting-lint-and-complexity.md`
|
|
34
|
-
- `11-configuration-dependencies-and-ci.md`
|
|
35
|
-
- `12-security-performance-and-i18n.md`
|
|
36
|
-
- `13-git-review-and-delivery.md`
|
|
37
|
-
|
|
38
|
-
## 读取原则
|
|
39
|
-
|
|
40
|
-
- 单文件命名问题:读取 `02`,通常无需读取其他文件。
|
|
41
|
-
- 类型错误或 API 设计:读取 `04`,涉及异步时再读 `05`。
|
|
42
|
-
- 新领域目录设计:读取 `01`、`02`、`03`。
|
|
43
|
-
- React 组件重构:读取 `08`,并按需补充 `04`、`05`、`07`。
|
|
44
|
-
- 全仓库审计:从 `00` 开始,再按仓库技术栈选择相关模块。
|
|
45
|
-
- 制定团队规范:先读 `00`、`01`、`02`、`04`、`10`、`11`、`13`,其余按技术栈补充。
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# TypeScript Project Rules
|
|
2
|
-
|
|
3
|
-
- 先按运行环境和业务领域组织代码,领域内部优先局部平铺。
|
|
4
|
-
- 目录与普通 TypeScript 文件使用 `kebab-case`;组件文件沿用项目统一规则。
|
|
5
|
-
- 文件名必须表达具体领域和职责,避免 `utils`、`helpers`、`common`、`misc`。
|
|
6
|
-
- 一个文件只有一个主要职责;不要为单个普通文件创建目录。
|
|
7
|
-
- 默认使用命名导出;仅在框架约定入口使用默认导出。
|
|
8
|
-
- 禁止无意义全局 Barrel 和循环依赖。
|
|
9
|
-
- TypeScript 必须开启严格模式;禁止无说明的 `any`、双重断言和 `@ts-ignore`。
|
|
10
|
-
- 外部输入先作为 `unknown`,在系统边界运行时验证。
|
|
11
|
-
- 优先使用可辨识联合表达互斥状态,并进行穷尽检查。
|
|
12
|
-
- 导出函数和公共 API 写明确返回类型。
|
|
13
|
-
- 所有 Promise 必须 `await`、`return` 或显式处理。
|
|
14
|
-
- 监听器、Timer、连接、Worker 和进程必须有清理路径。
|
|
15
|
-
- 注释解释 WHY、约束和权衡,不逐行翻译代码。
|
|
16
|
-
- 单元测试与源码共置;集成和 E2E 测试放在根级 `tests/`。
|
|
17
|
-
- 修复缺陷时添加回归测试。
|
|
18
|
-
- 不引入未经要求的新框架或依赖。
|
|
19
|
-
- 不通过关闭核心规则、删除测试或扩大 `any` 来绕过检查。
|
|
20
|
-
- 合并前运行格式检查、Lint、类型检查、测试和构建。
|
|
21
|
-
- 修改现有项目时优先遵守仓库已生效配置,避免无关重命名和格式噪声。
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# TypeScript Code Review Checklist
|
|
2
|
-
|
|
3
|
-
## 正确性与安全
|
|
4
|
-
|
|
5
|
-
- [ ] 外部输入已验证。
|
|
6
|
-
- [ ] 权限、安全和敏感信息处理正确。
|
|
7
|
-
- [ ] 错误路径不会造成数据损坏或状态不一致。
|
|
8
|
-
|
|
9
|
-
## 类型与 API
|
|
10
|
-
|
|
11
|
-
- [ ] 没有无说明的 `any`、双重断言或 `@ts-ignore`。
|
|
12
|
-
- [ ] 公共 API 输入、输出和错误契约明确。
|
|
13
|
-
- [ ] 互斥状态使用可靠模型,分支穷尽。
|
|
14
|
-
- [ ] 空值和可选语义清晰。
|
|
15
|
-
|
|
16
|
-
## 异步与资源
|
|
17
|
-
|
|
18
|
-
- [ ] Promise 已等待、返回或显式处理。
|
|
19
|
-
- [ ] 超时、取消和重试策略合理。
|
|
20
|
-
- [ ] 监听器、Timer、连接和进程已清理。
|
|
21
|
-
- [ ] 无明显竞态或过期响应覆盖问题。
|
|
22
|
-
|
|
23
|
-
## 架构与维护
|
|
24
|
-
|
|
25
|
-
- [ ] 文件位于正确领域和运行环境。
|
|
26
|
-
- [ ] 文件名具体,职责单一。
|
|
27
|
-
- [ ] 依赖方向正确,无循环依赖。
|
|
28
|
-
- [ ] 没有无意义共享抽象和 Barrel。
|
|
29
|
-
- [ ] 文件、函数和状态复杂度合理。
|
|
30
|
-
|
|
31
|
-
## 测试与交付
|
|
32
|
-
|
|
33
|
-
- [ ] 新行为有适当测试。
|
|
34
|
-
- [ ] 缺陷修复有回归测试。
|
|
35
|
-
- [ ] 测试确定、可诊断且不过度 Mock。
|
|
36
|
-
- [ ] 格式、Lint、类型检查、测试和构建通过。
|
|
37
|
-
- [ ] 无无关格式化、重命名或生成文件变化。
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"scripts": {
|
|
3
|
-
"format": "prettier --write .",
|
|
4
|
-
"format:check": "prettier --check .",
|
|
5
|
-
"lint": "eslint .",
|
|
6
|
-
"typecheck": "tsc --noEmit",
|
|
7
|
-
"test": "vitest run",
|
|
8
|
-
"build": "tsc -b",
|
|
9
|
-
"check": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build"
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
## 背景
|
|
2
|
-
|
|
3
|
-
<!-- 这个变更解决什么问题? -->
|
|
4
|
-
|
|
5
|
-
## 方案
|
|
6
|
-
|
|
7
|
-
<!-- 核心实现、边界和主要取舍。 -->
|
|
8
|
-
|
|
9
|
-
## 影响范围
|
|
10
|
-
|
|
11
|
-
- [ ] 公共 API
|
|
12
|
-
- [ ] 数据或配置迁移
|
|
13
|
-
- [ ] 跨平台行为
|
|
14
|
-
- [ ] 安全或权限
|
|
15
|
-
- [ ] 性能
|
|
16
|
-
- [ ] UI / 可访问性
|
|
17
|
-
|
|
18
|
-
## 验证
|
|
19
|
-
|
|
20
|
-
- [ ] 格式检查
|
|
21
|
-
- [ ] Lint
|
|
22
|
-
- [ ] TypeScript 类型检查
|
|
23
|
-
- [ ] 单元测试
|
|
24
|
-
- [ ] 集成 / E2E 测试
|
|
25
|
-
- [ ] 构建
|
|
26
|
-
|
|
27
|
-
## 证据
|
|
28
|
-
|
|
29
|
-
<!-- 截图、录屏、日志、基准或测试结果。 -->
|
|
30
|
-
|
|
31
|
-
## 风险与回滚
|
|
32
|
-
|
|
33
|
-
<!-- 已知风险、兼容性和回滚方式。 -->
|
|
34
|
-
|
|
35
|
-
## 后续工作
|
|
36
|
-
|
|
37
|
-
<!-- 不属于本 PR 的工作,附任务编号。 -->
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "ES2022",
|
|
5
|
-
"strict": true,
|
|
6
|
-
"noUncheckedIndexedAccess": true,
|
|
7
|
-
"exactOptionalPropertyTypes": true,
|
|
8
|
-
"noImplicitOverride": true,
|
|
9
|
-
"noImplicitReturns": true,
|
|
10
|
-
"noFallthroughCasesInSwitch": true,
|
|
11
|
-
"useUnknownInCatchVariables": true,
|
|
12
|
-
"verbatimModuleSyntax": true,
|
|
13
|
-
"isolatedModules": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"skipLibCheck": true
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# 代码库设计术语
|
|
2
|
-
|
|
3
|
-
- **模块**:隐藏复杂度并提供稳定接口的单元,不等于目录或类。
|
|
4
|
-
- **深度**:接口简单度相对于模块内部承载复杂度的杠杆。
|
|
5
|
-
- **接口**:调用者必须知道的全部,包括类型、不变量、顺序、错误和性能语义。
|
|
6
|
-
- **接缝**:可以替换、观察或验证行为的位置。
|
|
7
|
-
- **适配器**:把外部变化隔离在稳定接缝外的实现。
|
|
8
|
-
- **信息隐藏**:设计决定只存在于一个权威位置。
|
|
9
|
-
- **局部性**:完成一个行为所需理解和修改的范围尽可能集中。
|
|
10
|
-
- **时间耦合**:调用必须按隐含顺序发生;应显式化或封装。
|
|
11
|
-
|
|
12
|
-
检查目标:减少调用者认知,而不是单纯减少行数或文件数。
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# 深化与依赖策略
|
|
2
|
-
|
|
3
|
-
## 依赖分类
|
|
4
|
-
|
|
5
|
-
1. 进程内稳定依赖:直接调用通常足够。
|
|
6
|
-
2. 本地可替换依赖:在真实替换/测试需要处建立接缝。
|
|
7
|
-
3. 远程但自有:封装协议、超时、重试、幂等和可观测性。
|
|
8
|
-
4. 真正外部:适配器隔离版本、失败、限流和不可控变化。
|
|
9
|
-
|
|
10
|
-
不要为了“可测试”给每个类加接口。接缝应服务真实变化轴或高价值验证。
|
|
11
|
-
|
|
12
|
-
## 深化问题
|
|
13
|
-
|
|
14
|
-
- 能否让调用者少知道一个状态、顺序或错误分支?
|
|
15
|
-
- 能否把重复策略收进单一模块?
|
|
16
|
-
- 是否把外部 SDK 类型泄漏到领域层?
|
|
17
|
-
- 是否有至少两个真实消费者/适配器证明抽象成立?
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|