kenaz 0.3.18 → 0.3.20
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/core/.claude/commands/agent-worker.md +1 -1
- package/core/.claude/commands/architect.md +1 -2
- package/core/.claude/commands/spec.md +1 -1
- package/core/.claude/commands//347/224/242/345/223/201.md +1 -1
- package/core/.claude/hooks/__tests__/task-1977-dedupe-guard.test.js +8 -8
- package/core/.claude/skills/architect_agent/SKILL.md +11 -92
- package/core/.claude/skills/assessment_agent/SKILL.md +0 -1
- package/core/.claude/skills/backend_engineer/SKILL.md +3 -6
- package/core/.claude/skills/code_reviewer/SKILL.md +1 -1
- package/core/.claude/skills/code_reviewer/patterns.yaml +1 -1
- package/core/.claude/skills/designer/SKILL.md +3 -6
- package/core/.claude/skills/dev_agent/SKILL.md +30 -491
- package/core/.claude/skills/developer/SKILL.md +3 -6
- package/core/.claude/skills/feature_agent/SKILL.md +3 -17
- package/core/.claude/skills/product_manager/SKILL.md +29 -1064
- package/core/.claude/skills/qa_engineer/SKILL.md +12 -17
- package/core/.claude/skills/spec_optimizer/SKILL.md +25 -275
- package/core/.claude/skills/sre_agent/SKILL.md +3 -6
- package/core/.collaboration/README.md +2 -3
- package/core/.collaboration/core/task-api.js +5 -138
- package/core/.collaboration/docs/CLI.md +0 -2
- package/core/.failure/INDEX.yaml +6 -40
- package/core/.failure/agent-execution/FAIL-013-search-cwd-drift-and-case-mismatch.yaml +1 -1
- package/core/.failure/tools/README.md +9 -227
- package/core/.formation/bifrost/launch.js +1 -6
- package/core/.formation/bifrost/launch.test.js +1 -1
- package/core/.formation/bifrost/shared/ansuz-boot-policy.js +3 -3
- package/core/.formation/bifrost/shared/ansuz-boot-policy.test.js +1 -2
- package/core/.formation/tools/__tests__/arms.test.js +41 -0
- package/core/.formation/tools/__tests__/diagnose-bug.test.js +10 -0
- package/core/.formation/tools/__tests__/m1-hmap-convid.test.js +1 -124
- package/core/.formation/tools/arms.js +48 -0
- package/core/.formation/tools/dispatch.js +24 -15
- package/core/.formation/tools/kenaz-stats.js +32 -8
- package/core/.formation/tools/kenaz-stats.test.js +15 -2
- package/core/.formation/tools/loader.js +17 -140
- package/core/.formation/tools/post-complete.js +0 -31
- package/core/.formation/tools/prompt.js +16 -1
- package/core/.formation/tools/prompt.test.js +20 -0
- package/core/.rule/INDEX.yaml +0 -18
- package/core/.rule/general/agent-workflow.yaml +14 -164
- package/core/.rule/general/project-self-containment.yaml +8 -19
- package/core/.rule/general/rust-verify-target.yaml +6 -5
- package/core/.rule/general/synapse-code-intelligence.yaml +3 -3
- package/core/.specialist/Amelia/capability.yaml +12 -12
- package/core/.specialist/Amelia/workflow.yaml +2 -2
- package/core/.specialist/Ansuz/SYSTEM_DOC.md +20 -578
- package/core/.specialist/Ansuz/cognitive_principles.yaml +2 -3
- package/core/.specialist/Ansuz/concepts/boot_rules_summary.yaml +0 -1
- package/core/.specialist/Ansuz/concepts/deep_knowledge_pointers.yaml +1 -2
- package/core/.specialist/Ansuz/core.yaml +6 -108
- package/core/.specialist/Ansuz/guards/lesson_guards.yaml +0 -3
- package/core/.specialist/Ansuz/identity_contract.yaml +0 -1
- package/core/.specialist/Ansuz/knowledge.yaml +0 -4
- package/core/.specialist/Ansuz/rule.yaml +0 -1
- package/core/.specialist/Ansuz/tools/handoff-session-identity.test.js +6 -150
- package/core/.specialist/tests/runtime-discovery/README.md +1 -1
- package/core/.specialist/tools/__tests__/task-2374-usage-counter.test.js +1 -12
- package/core/.specialist/tools/ansuz-boot-fast.js +7 -4
- package/core/.specialist/tools/ansuz-boot-fast.test.js +10 -3
- package/core/.specialist/tools/prompt-files.test.js +1 -0
- package/core/.specialist/tools/task-bridge.js +1 -66
- package/core/.system/README.md +11 -552
- package/core/.system/collaboration/README.md +10 -174
- package/core/CLAUDE.md +1 -6
- package/core/KENAZ_CORE_VERSION +1 -1
- package/core/dev/scripts/js-yaml-resolution.test.js +1 -1
- package/core/dev/scripts/peer-identity-e2e.js +402 -0
- package/core/dev/scripts/peer-identity-e2e.md +47 -0
- package/core/dev/scripts/relay-admin.js +94 -0
- package/core/dev/scripts/relay-admin.test.js +131 -0
- package/core/dev/scripts/run-rust-tests.js +9 -45
- package/core/dev/scripts/rust-verify-worktree.js +4 -4
- package/core/dev/scripts/verify-target-dir.js +6 -6
- package/core/plugins/kenaz/INVENTORY.md +8 -8
- package/core/plugins/kenaz/README.md +10 -0
- package/core/plugins/kenaz/commands/architect.md +1 -2
- package/core/plugins/kenaz/commands/spec.md +1 -1
- package/core/plugins/kenaz/commands//347/224/242/345/223/201.md +1 -1
- package/core/plugins/kenaz/guidance.md +1 -1
- package/core/plugins/kenaz/hooks/kenaz-hook.js +2 -1
- package/core/plugins/kenaz/hooks/sdk-gate.js +9 -0
- package/core/plugins/kenaz/scripts/kenaz.test.js +15 -3
- package/core/plugins/kenaz/scripts/sync.js +1 -1
- package/core/plugins/kenaz/scripts/ygg.js +8 -0
- package/core/plugins/kenaz/scripts/ygg.test.js +72 -0
- package/core/plugins/kenaz/skills/architect_agent/SKILL.md +11 -92
- package/core/plugins/kenaz/skills/assessment_agent/SKILL.md +0 -1
- package/core/plugins/kenaz/skills/backend_engineer/SKILL.md +3 -6
- package/core/plugins/kenaz/skills/code_reviewer/SKILL.md +1 -1
- package/core/plugins/kenaz/skills/code_reviewer/patterns.yaml +1 -1
- package/core/plugins/kenaz/skills/designer/SKILL.md +3 -6
- package/core/plugins/kenaz/skills/dev_agent/SKILL.md +30 -491
- package/core/plugins/kenaz/skills/developer/SKILL.md +3 -6
- package/core/plugins/kenaz/skills/feature_agent/SKILL.md +3 -17
- package/core/plugins/kenaz/skills/product_manager/SKILL.md +29 -1064
- package/core/plugins/kenaz/skills/qa_engineer/SKILL.md +12 -17
- package/core/plugins/kenaz/skills/spec_optimizer/SKILL.md +25 -275
- package/core/plugins/kenaz/skills/sre_agent/SKILL.md +3 -6
- package/core/plugins/kenaz-peer/hooks/register.test.ts +32 -0
- package/core/plugins/kenaz-peer/hooks/register.ts +9 -0
- package/package.json +6 -6
- package/core/.claude/commands/archive.md +0 -24
- package/core/.claude/commands/init.md +0 -112
- package/core/.claude/commands/legacy_dev.md +0 -18
- package/core/.claude/commands/product-review.md +0 -131
- package/core/.claude/commands/strategy.md +0 -141
- package/core/.claude/commands/sunny.md +0 -1
- package/core/.claude/commands//347/224/242/345/223/201/346/252/242/350/246/226.md +0 -129
- package/core/.claude/commands//351/200/262/345/272/246.md +0 -15
- package/core/.claude/hooks/__tests__/substrate.test.js +0 -122
- package/core/.claude/hooks/_substrate-paths.js +0 -95
- package/core/.claude/hooks/context-check.js +0 -51
- package/core/.claude/hooks/fatigue-check.js +0 -52
- package/core/.claude/hooks/handoff-snapshot-on-commit.js +0 -154
- package/core/.claude/hooks/handoff-snapshot-on-question.js +0 -158
- package/core/.claude/hooks/handoff-staleness.js +0 -197
- package/core/.claude/hooks/jev-thalamus-context.js +0 -17
- package/core/.claude/hooks/jev-thalamus-context.test.js +0 -41
- package/core/.claude/hooks/lease-release.js +0 -119
- package/core/.claude/hooks/lease-touch.js +0 -96
- package/core/.claude/hooks/reflex-feedback.js +0 -5
- package/core/.claude/hooks/session-init.ps1 +0 -49
- package/core/.claude/hooks/sound-event.js +0 -70
- package/core/.claude/hooks/sound-event.sh +0 -37
- package/core/.claude/hooks/stream-delta.js +0 -169
- package/core/.claude/no-hooks.settings.json +0 -3
- package/core/.claude/skills/legacy_dev/SKILL.md +0 -202
- package/core/.claude/skills/sunny/SKILL.md +0 -74
- package/core/.collaboration/cli/commands/assign.js +0 -39
- package/core/.collaboration/cli/commands/claim.js +0 -33
- package/core/.collaboration/cli/commands/complete.js +0 -44
- package/core/.collaboration/cli/commands/create.js +0 -110
- package/core/.collaboration/cli/commands/get.js +0 -83
- package/core/.collaboration/cli/commands/index.js +0 -52
- package/core/.collaboration/cli/commands/list.js +0 -51
- package/core/.collaboration/cli/commands/lock.js +0 -45
- package/core/.collaboration/cli/commands/rebuild.js +0 -39
- package/core/.collaboration/cli/commands/search.js +0 -61
- package/core/.collaboration/cli/commands/stats.js +0 -61
- package/core/.collaboration/cli/commands/transfer.js +0 -41
- package/core/.collaboration/cli/commands/unlock.js +0 -48
- package/core/.collaboration/cli/formatters/help-formatter.js +0 -70
- package/core/.collaboration/cli/formatters/index.js +0 -7
- package/core/.collaboration/cli/task-cli.js +0 -46
- package/core/.collaboration/cli/utils/arg-parser.js +0 -74
- package/core/.collaboration/cli/utils/git-user.js +0 -25
- package/core/.collaboration/cli/utils/index.js +0 -9
- package/core/.collaboration/cli/utils/output.js +0 -10
- package/core/.collaboration/config/default.yaml +0 -189
- package/core/.collaboration/core/conflict-resolver.js +0 -461
- package/core/.collaboration/core/conflict-resolver.test.js +0 -389
- package/core/.collaboration/core/migrate-legacy.js +0 -260
- package/core/.collaboration/docs/API.md +0 -787
- package/core/.collaboration/docs/ARCHITECTURE.md +0 -596
- package/core/.collaboration/docs/FAQ.md +0 -695
- package/core/.collaboration/docs/MIGRATION.md +0 -804
- package/core/.collaboration/docs/examples/README.md +0 -320
- package/core/.collaboration/docs/examples/advanced-queries.js +0 -261
- package/core/.collaboration/docs/examples/basic-usage.js +0 -184
- package/core/.collaboration/docs/examples/team-workflow.js +0 -352
- package/core/.failure/agent-execution/FAIL-001-agent-no-output.yaml +0 -391
- package/core/.failure/agent-execution/FAIL-007-pm-lead-wrong-team-invocation.yaml +0 -0
- package/core/.failure/agent-execution/FAIL-010-phase0-poem-format-skipped.yaml +0 -28
- package/core/.failure/agent-execution/FAIL-010-skipping-cognitive-checkpoint-after-verification.yaml +0 -59
- package/core/.failure/agent-execution/FAIL-012-grep-shortcut-during-investigation.yaml +0 -85
- package/core/.failure/architecture/FAIL-006-python-version-compatibility.yaml +0 -445
- package/core/.failure/pipeline/FAIL-003-queue-pollution.yaml +0 -335
- package/core/.failure/pipeline/README.md +0 -95
- package/core/.failure/retired/FAIL-009-skipping-synapse-pulse-before-code-change.yaml +0 -49
- package/core/.failure/tools/USAGE_GUIDE.md +0 -323
- package/core/.failure/tools/check_failures.ps1 +0 -387
- package/core/.failure/tools/log_failure.ps1 +0 -474
- package/core/.formation/.episode-input.json +0 -10
- package/core/.formation/.merge-lock +0 -1
- package/core/.formation/lead.yaml +0 -118
- package/core/.formation/legacy.bak/designer.yaml +0 -57
- package/core/.formation/legacy.bak/pm.yaml +0 -57
- package/core/.formation/legacy.bak/qa.yaml +0 -57
- package/core/.formation/legacy.bak/review.yaml +0 -62
- package/core/.formation/legacy.bak/scheduler.yaml +0 -129
- package/core/.formation/legacy.bak/sre.yaml +0 -57
- package/core/.formation/role-map.yaml +0 -274
- package/core/.formation/roles/_shared/modules/code_review.yaml +0 -98
- package/core/.formation/roles/_shared/modules/security.yaml +0 -103
- package/core/.formation/roles/_shared/modules/testing.yaml +0 -14
- package/core/.formation/roles/backend/role.yaml +0 -93
- package/core/.formation/roles/code_reviewer/role.yaml +0 -102
- package/core/.formation/roles/database_optimizer/role.yaml +0 -107
- package/core/.formation/roles/designer/role.yaml +0 -66
- package/core/.formation/roles/developer/role.yaml +0 -75
- package/core/.formation/roles/frontend/role.yaml +0 -134
- package/core/.formation/roles/incident_response/role.yaml +0 -89
- package/core/.formation/roles/qa/role.yaml +0 -89
- package/core/.formation/roles/security/role.yaml +0 -87
- package/core/.formation/roles/sre/role.yaml +0 -66
- package/core/.formation/skills/coordinator.yaml +0 -52
- package/core/.formation/solo/diagnosis.yaml +0 -78
- package/core/.formation/solo/strategy.yaml +0 -121
- package/core/.formation/tests/hello.txt +0 -2
- package/core/.formation/tools/coordinator.js +0 -350
- package/core/.formation/tools/jev-correction.js +0 -214
- package/core/.formation/tools/jev-correction.test.js +0 -178
- package/core/.formation/tools/log-reader.js +0 -232
- package/core/.formation/tools/revert-daemon-state.js +0 -162
- package/core/.formation/tools/test-drift.js +0 -148
- package/core/.formation/unit/heimdall.yaml +0 -96
- package/core/.formation/unit/plan.yaml +0 -67
- package/core/.formation/unit/think.yaml +0 -58
- package/core/.kenaz/MUNINN_SNAPSHOT9_EPISODE.json +0 -32
- package/core/.kenaz/MUNINN_SNAPSHOT9_RUNE.json +0 -23
- package/core/.kenaz/MUNINN_SNAPSHOT9_SUMMARY.md +0 -89
- package/core/.kenaz/ash_TASK_1428-20260507.json +0 -14
- package/core/.kenaz/muninn_episode_write.ps1 +0 -17
- package/core/.kenaz/muninn_snapshot11_rune_candidates.md +0 -63
- package/core/.kenaz/muninn_snapshot1_rune_candidates.md +0 -49
- package/core/.kenaz/runes_TASK_1428.json +0 -57
- package/core/.kenaz/tmp_heimdall_proposal_8d3e392.json +0 -13
- package/core/.kenaz/tmp_props.json +0 -1
- package/core/.kenaz/tmp_sounddrop_t1_prompt.txt +0 -371
- package/core/.rule/MECHANIZED.md +0 -61
- package/core/.rule/general/cortex-memory-recall.yaml +0 -446
- package/core/.rule/general/pipeline.yaml +0 -246
- package/core/.rule/general/sunny-access-control.yaml +0 -60
- package/core/.rule/general/system-invariants.yaml +0 -231
- package/core/.rule/pipeline/PPL-002-completed-task-archival.yaml +0 -528
- package/core/.rule/pipeline/auto-update.yaml +0 -282
- package/core/.rule/pipeline/task-execution.yaml +0 -365
- package/core/.specialist/Ansuz/concepts/phase_protocol.yaml +0 -65
- package/core/.specialist/Ansuz/experiments/boot_ablation_replay.js +0 -197
- package/core/.specialist/Ansuz/tools/bootstrap-anchors.js +0 -289
- package/core/.specialist/Ansuz/workflow.yaml +0 -1225
- package/core/.specialist/experiments/rg_benchmark.js +0 -523
- package/core/.specialist/experiments/rg_benchmark_results.json +0 -27
- package/core/.specialist/tools/jev-optional-context.js +0 -107
- package/core/.specialist/tools/jev-optional-context.test.js +0 -152
- package/core/.specialist/tools/memory-action-log.js +0 -839
- package/core/.specialist/tools/phase-gate.js +0 -3534
- package/core/.specialist/tools/phase-gate.test.js +0 -85
- package/core/.specialist/tools/precompute-runner.js +0 -444
- package/core/.specialist/tools/rule-engine.js +0 -621
- package/core/.specialist/tools/task-bridge-jev.test.js +0 -170
- package/core/.synapse/memory-shared.json.sync +0 -1
- package/core/.system/agent-skills/README.md +0 -724
- package/core/.system/cli-tools/README.md +0 -724
- package/core/.system/cortex/MODULES.md +0 -1046
- package/core/.system/dashboard/FRONTEND.md +0 -812
- package/core/.system/dashboard/README.md +0 -737
- package/core/.system/failure/README.md +0 -723
- package/core/.system/formation/LEGACY_SKILLS.md +0 -974
- package/core/.system/formation/POST_COMPLETE.md +0 -602
- package/core/.system/formation/README.md +0 -1094
- package/core/.system/formation/TOOLS_REFERENCE.md +0 -1145
- package/core/.system/kenaz/README.md +0 -787
- package/core/.system/memory/README.md +0 -719
- package/core/.system/pipeline/README.md +0 -712
- package/core/.system/rule/README.md +0 -794
- package/core/.system/sunny/README.md +0 -476
- package/core/.system/sunny/RULES.json +0 -89
- package/core/.system/sunny/knowledge/INDEX.md +0 -37
- package/core/.system/sunny/knowledge/agent-teams-api.md +0 -0
- package/core/.system/sunny/knowledge/ansuz-specialist.md +0 -500
- package/core/.system/sunny/knowledge/claude-cli-spawn.md +0 -177
- package/core/.system/sunny/knowledge/collaboration-api.md +0 -925
- package/core/.system/sunny/teammates/README.md +0 -107
- package/core/.system/sunny/teammates/how_to_use.yaml +0 -101
- package/core/.system/sunny/teammates/tools/headless/launcher.js +0 -318
- package/core/.system/sunny/teammates/tools/powershell/launcher.js +0 -241
- package/core/.system/sunny/teammates/tools/powershell/start.bat +0 -50
- package/core/.system/sunny/teammates/tools/utils/env.js +0 -96
- package/core/.system/sunny/teammates/tools/utils/format-output.js +0 -329
- package/core/.system/sunny/tools.json +0 -101
- package/core/dev/scripts/cleanup-queue.js +0 -184
- package/core/dev/scripts/cleanup_queue.js +0 -86
- package/core/dev/scripts/legacy/README.md +0 -39
- package/core/dev/scripts/legacy/dev_agent_scheduler.ps1.bak +0 -536
- package/core/dev/scripts/legacy/multi_agent_scheduler.ps1.bak +0 -1978
- package/core/dev/scripts/matrix/CLI_README.md +0 -214
- package/core/dev/scripts/matrix/README.md +0 -310
- package/core/dev/scripts/matrix/package-lock.json +0 -4266
- package/core/dev/scripts/matrix/package.json +0 -55
- package/core/dev/scripts/matrix/src/abbreviations.ts +0 -295
- package/core/dev/scripts/matrix/src/cli/commands/convert.ts +0 -211
- package/core/dev/scripts/matrix/src/cli/commands/create.ts +0 -95
- package/core/dev/scripts/matrix/src/cli/commands/delete.ts +0 -102
- package/core/dev/scripts/matrix/src/cli/commands/list-tags.ts.wip +0 -140
- package/core/dev/scripts/matrix/src/cli/commands/manage-tags.ts.wip +0 -173
- package/core/dev/scripts/matrix/src/cli/commands/query.ts +0 -261
- package/core/dev/scripts/matrix/src/cli/commands/read.ts +0 -77
- package/core/dev/scripts/matrix/src/cli/commands/stats.ts.wip +0 -168
- package/core/dev/scripts/matrix/src/cli/commands/tokens.ts.wip +0 -126
- package/core/dev/scripts/matrix/src/cli/commands/update.ts +0 -147
- package/core/dev/scripts/matrix/src/cli/commands/validate.ts +0 -275
- package/core/dev/scripts/matrix/src/cli/index.ts +0 -350
- package/core/dev/scripts/matrix/src/cli/utils/file-handler.ts +0 -72
- package/core/dev/scripts/matrix/src/cli/utils/logger.ts +0 -65
- package/core/dev/scripts/matrix/src/index.ts +0 -62
- package/core/dev/scripts/matrix/src/indexer/tag-indexer.ts +0 -165
- package/core/dev/scripts/matrix/src/parser.ts +0 -281
- package/core/dev/scripts/matrix/src/serializer.ts +0 -151
- package/core/dev/scripts/matrix/src/validator.ts +0 -301
- package/core/dev/scripts/matrix/tests/abbreviations.test.ts +0 -122
- package/core/dev/scripts/matrix/tests/cli.test.ts +0 -177
- package/core/dev/scripts/matrix/tests/convert.test.ts +0 -143
- package/core/dev/scripts/matrix/tests/parser.test.ts +0 -203
- package/core/dev/scripts/matrix/tests/query.test.ts +0 -85
- package/core/dev/scripts/matrix/tests/serializer.test.ts +0 -197
- package/core/dev/scripts/matrix/tests/validate.test.ts +0 -141
- package/core/dev/scripts/matrix/tests/validator.test.ts +0 -167
- package/core/dev/scripts/matrix/tsconfig.json +0 -20
- package/core/dev/scripts/matrix/types/index.d.ts +0 -111
- package/core/dev/scripts/matrix/types/index.d.ts.map +0 -1
- package/core/dev/scripts/matrix/types/index.js +0 -8
- package/core/dev/scripts/matrix/types/index.js.map +0 -1
- package/core/dev/scripts/matrix/types/index.ts +0 -124
- package/core/dev/scripts/memory-usage-report.js +0 -152
- package/core/dev/scripts/probe/ansuz-scaffold-ablation.js +0 -579
- package/core/dev/scripts/probe/ansuz-scaffold-ablation.test.js +0 -244
- package/core/dev/scripts/probe/hook-latency-probe.js +0 -315
- package/core/dev/scripts/probe/hook-latency-probe.test.js +0 -105
- package/core/dev/scripts/probe/prediction-signal-auc.js +0 -483
- package/core/dev/scripts/probe/prediction-signal-auc.test.js +0 -200
- package/core/dev/scripts/test-pty-ws-tunnel.js +0 -229
- package/core/dev/scripts/validate_pipeline.js +0 -197
- package/core/dev/spikes/task2145-evidence-20261004/backend-log-excerpt.txt +0 -56
- package/core/dev/spikes/task2145-evidence-20261004/graph.shadow +0 -0
- package/core/dev/spikes/task2145-evidence-20261004/graph.wal +0 -0
- package/core/dev/spikes/task2145-evidence-20261004/graph_corrupt_suspect.marker +0 -1
- package/core/plugins/kenaz/commands/strategy.md +0 -141
|
@@ -1,794 +0,0 @@
|
|
|
1
|
-
# .rule - 規則系統
|
|
2
|
-
|
|
3
|
-
## 系統概述
|
|
4
|
-
|
|
5
|
-
`.rule/` 是 Kenaz AI 專案的**最高優先級規則庫**,定義所有 AI Agent 和人類開發者必須遵守的核心約束與標準。
|
|
6
|
-
|
|
7
|
-
**設計理念**:
|
|
8
|
-
- **規則優先**:凌駕於 `CLAUDE.md`、`.claude/skills/` 之上
|
|
9
|
-
- **模塊化組織**:按領域分類(general、code、design、pipeline 等)
|
|
10
|
-
- **層級式載入**:從核心原則到具體實踐,由上至下載入
|
|
11
|
-
- **嚴重程度分級**:MUST(必須)、SHOULD(應該)、MAY(建議)
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## 規則優先級
|
|
16
|
-
|
|
17
|
-
當規則發生衝突時,按以下優先級順序執行:
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
1. .rule/* ← 最高優先級(所有人必須遵守)
|
|
21
|
-
2. CLAUDE.md ← 專案級指令與工作流程
|
|
22
|
-
3. .claude/skills/ ← Agent 行為定義
|
|
23
|
-
4. .agents/skills/ ← 外部安裝的最佳實踐
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**範例衝突場景**:
|
|
27
|
-
- `.rule/general/project-self-containment.yaml` (GEN-007) 禁止在專案目錄外操作
|
|
28
|
-
- 即使 `CLAUDE.md` 或某個 Skill 要求安裝全局工具,也必須遵守 GEN-007,改為專案內解決方案
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
## 目錄結構
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
.rule/
|
|
36
|
-
├── INDEX.yaml # 規則索引與載入順序(核心入口點)
|
|
37
|
-
├── general/ # 通用規則(所有 Agent 適用)
|
|
38
|
-
│ ├── principles.yaml # 核心原則(最優先載入)
|
|
39
|
-
│ ├── project-self-containment.yaml # GEN-007: 專案自包含原則
|
|
40
|
-
│ ├── agent-workflow.yaml # AGT-001~008: Agent 工作流程規範
|
|
41
|
-
│ ├── sunny-access-control.yaml # SEC-010: Sunny 存取控制
|
|
42
|
-
│ ├── cortex-memory-recall.yaml # CTX-001~004: Cortex 記憶回想規則
|
|
43
|
-
│ └── pipeline.yaml # Pipeline 系統規則
|
|
44
|
-
├── pipeline/ # Pipeline 專用規則
|
|
45
|
-
│ ├── task-execution.yaml # PPL-101~112: 任務執行規範(拆分、依賴、並行等)
|
|
46
|
-
│ ├── PPL-002-completed-task-archival.yaml # 已完成任務封存規則
|
|
47
|
-
│ └── auto-update.yaml # PPL-003: Pipeline 自動更新規則
|
|
48
|
-
├── code/ # 代碼規範(按層級組織)
|
|
49
|
-
│ ├── principles.yaml # 代碼核心原則(模塊化、複用性、可維護性)
|
|
50
|
-
│ ├── naming.yaml # 命名規則
|
|
51
|
-
│ ├── structure.yaml # 結構規則(目錄組織、模塊化設計)
|
|
52
|
-
│ ├── reusability.yaml # 複用性規則(組件/Hook/邏輯複用)
|
|
53
|
-
│ ├── maintainability.yaml # 可維護性規則(狀態管理、錯誤處理)
|
|
54
|
-
│ ├── style.yaml # 風格規則(TypeScript、格式化、註釋)
|
|
55
|
-
│ ├── backend.yaml # 後端規範(API 設計、資料庫、架構分層)
|
|
56
|
-
│ ├── checklist.yaml # 代碼提交前檢查清單
|
|
57
|
-
│ └── README.md # 代碼規範說明文檔
|
|
58
|
-
├── design/ # 設計規範
|
|
59
|
-
│ ├── ui.yaml # UI 標準
|
|
60
|
-
│ ├── ux.yaml # UX 原則
|
|
61
|
-
│ └── colors.yaml # 色彩系統
|
|
62
|
-
├── architecture/ # 架構決策(未來擴展)
|
|
63
|
-
│ └── decisions.yaml # ADR 記錄
|
|
64
|
-
└── business/ # 業務邏輯約束(未來擴展)
|
|
65
|
-
└── constraints.yaml
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## 核心規則索引(INDEX.yaml)
|
|
71
|
-
|
|
72
|
-
所有規則通過 `INDEX.yaml` 統一管理,定義載入順序與優先級。
|
|
73
|
-
|
|
74
|
-
### 載入順序
|
|
75
|
-
|
|
76
|
-
規則按以下順序載入(由上至下):
|
|
77
|
-
|
|
78
|
-
1. **核心原則** → `general/principles.yaml`
|
|
79
|
-
2. **專案自包含** → `general/project-self-containment.yaml` (GEN-007)
|
|
80
|
-
3. **Agent 工作流程** → `general/agent-workflow.yaml` (AGT-001~008)
|
|
81
|
-
4. **存取控制** → `general/sunny-access-control.yaml` (SEC-010)
|
|
82
|
-
5. **Cortex 記憶回想** → `general/cortex-memory-recall.yaml` (CTX-001~004)
|
|
83
|
-
6. **Pipeline 系統** → `general/pipeline.yaml`
|
|
84
|
-
7. **已完成任務封存** → `pipeline/PPL-002-completed-task-archival.yaml`
|
|
85
|
-
8. **Pipeline 自動更新** → `pipeline/auto-update.yaml` (PPL-003)
|
|
86
|
-
9. **任務執行規範** → `pipeline/task-execution.yaml` (PPL-101~112)
|
|
87
|
-
10. **代碼核心原則** → `code/principles.yaml`
|
|
88
|
-
11. **代碼命名** → `code/naming.yaml`
|
|
89
|
-
12. **代碼結構** → `code/structure.yaml`
|
|
90
|
-
13. **代碼複用性** → `code/reusability.yaml`
|
|
91
|
-
14. **代碼可維護性** → `code/maintainability.yaml`
|
|
92
|
-
15. **代碼風格** → `code/style.yaml`
|
|
93
|
-
16. **後端規範** → `code/backend.yaml`
|
|
94
|
-
17. **代碼檢查清單** → `code/checklist.yaml`
|
|
95
|
-
18. **設計規範** → `design/ui.yaml`, `design/ux.yaml`, `design/colors.yaml`
|
|
96
|
-
19. **架構決策** → `architecture/decisions.yaml`(未來)
|
|
97
|
-
20. **業務約束** → `business/constraints.yaml`(未來)
|
|
98
|
-
|
|
99
|
-
**重要**:載入順序從最通用的原則開始,逐步深入到具體實踐,確保基礎規則優先於細節規則。
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
## 嚴重程度定義
|
|
104
|
-
|
|
105
|
-
每條規則都標記了嚴重程度(severity),指導 Agent 和開發者的行為:
|
|
106
|
-
|
|
107
|
-
| 級別 | 說明 | 圖標 | 行為要求 |
|
|
108
|
-
|------|------|------|---------|
|
|
109
|
-
| **MUST** | 必須遵守,違反將導致拒絕合併 | 🔴 | 強制執行,無例外 |
|
|
110
|
-
| **SHOULD** | 應該遵守,除非有合理理由 | 🟡 | 優先遵守,需註明偏離原因 |
|
|
111
|
-
| **MAY** | 建議遵守,可依情況調整 | 🟢 | 參考建議,自由選擇 |
|
|
112
|
-
|
|
113
|
-
**範例**:
|
|
114
|
-
```yaml
|
|
115
|
-
rules:
|
|
116
|
-
- id: "GEN-007"
|
|
117
|
-
severity: "must" # 🔴 必須遵守
|
|
118
|
-
title: "專案自包含原則"
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
---
|
|
122
|
-
|
|
123
|
-
## 適用對象
|
|
124
|
-
|
|
125
|
-
規則定義了 `applies_to` 字段,指定規則適用範圍:
|
|
126
|
-
|
|
127
|
-
| 對象 | 說明 |
|
|
128
|
-
|------|------|
|
|
129
|
-
| `ai_agent` | AI Agent(Claude Code、Dev Agent 等) |
|
|
130
|
-
| `human_developer` | 人類開發者 |
|
|
131
|
-
| `ci_cd` | CI/CD Pipeline |
|
|
132
|
-
| `code_review` | Code Review 階段 |
|
|
133
|
-
|
|
134
|
-
**範例**:
|
|
135
|
-
```yaml
|
|
136
|
-
rules:
|
|
137
|
-
- id: "PPL-101"
|
|
138
|
-
applies_to: ["ai_agent", "human_developer"] # 所有開發者都適用
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
## 規則 ID 編號系統
|
|
144
|
-
|
|
145
|
-
所有規則遵循統一的 ID 編號格式:`<PREFIX>-<NUMBER>`
|
|
146
|
-
|
|
147
|
-
### 前綴定義(Prefix)
|
|
148
|
-
|
|
149
|
-
| 前綴 | 領域 | 範圍 | 範例 |
|
|
150
|
-
|------|------|------|------|
|
|
151
|
-
| **GEN** | General | 通用原則(001-099) | GEN-001, GEN-007 |
|
|
152
|
-
| **AGT** | Agent | Agent 工作流程(001-099) | AGT-001, AGT-005, AGT-007 |
|
|
153
|
-
| **PPL** | Pipeline | Pipeline 任務管理(001-199) | PPL-002, PPL-101, PPL-107 |
|
|
154
|
-
| **SEC** | Security | 安全與存取控制(001-099) | SEC-010 |
|
|
155
|
-
| **CTX** | Cortex | Cortex/RAG 系統(001-099) | CTX-001, CTX-002 |
|
|
156
|
-
| **CD** | Code | 代碼規範(001-199) | CD-001, CD-002 |
|
|
157
|
-
| **UI** | UI/UX | 設計規範(001-099) | UI-001(未來) |
|
|
158
|
-
| **DATA** | Data | 數據完整性(001-099) | DATA-001(未來) |
|
|
159
|
-
|
|
160
|
-
### 編號邏輯
|
|
161
|
-
|
|
162
|
-
**範圍分配**:
|
|
163
|
-
- **001-099**:基礎規則(核心原則、通用約束)
|
|
164
|
-
- **100-199**:進階規則(具體實踐、細節規範)
|
|
165
|
-
- **200-299**:擴展規則(未來預留)
|
|
166
|
-
|
|
167
|
-
**範例**:
|
|
168
|
-
```yaml
|
|
169
|
-
# Pipeline 基礎規則(001-099)
|
|
170
|
-
- id: "PPL-002" # 已完成任務封存
|
|
171
|
-
- id: "PPL-003" # Pipeline 自動更新
|
|
172
|
-
|
|
173
|
-
# Pipeline 進階規則(100-199)
|
|
174
|
-
- id: "PPL-101" # 任務拆分粒度
|
|
175
|
-
- id: "PPL-107" # 工作啟動前展示計劃
|
|
176
|
-
- id: "PPL-111" # scope_paths 衝突檢測
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### 新增規則 ID 選擇策略
|
|
180
|
-
|
|
181
|
-
1. **選擇前綴**:根據規則領域選擇對應前綴(GEN/AGT/PPL 等)
|
|
182
|
-
2. **選擇編號範圍**:
|
|
183
|
-
- 核心原則 → 001-099
|
|
184
|
-
- 具體實踐 → 100-199
|
|
185
|
-
3. **檢查衝突**:搜尋現有規則避免 ID 重複
|
|
186
|
-
```bash
|
|
187
|
-
grep -r "id: \"PPL-" .rule/
|
|
188
|
-
```
|
|
189
|
-
4. **填補空缺**:優先使用空缺的編號(如 PPL-004、AGT-006)
|
|
190
|
-
5. **連續編號**:同類規則使用連續編號(PPL-101, PPL-102, PPL-103)
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## 規則優先級邏輯
|
|
195
|
-
|
|
196
|
-
### 層級式優先級
|
|
197
|
-
|
|
198
|
-
規則優先級由 **3 個維度** 決定:
|
|
199
|
-
|
|
200
|
-
```
|
|
201
|
-
優先級 = severity(嚴重程度)× priority(meta 優先級)× load_order(載入順序)
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
#### 1. Severity(嚴重程度)
|
|
205
|
-
|
|
206
|
-
| 級別 | 說明 | 權重 | 行為 |
|
|
207
|
-
|------|------|------|------|
|
|
208
|
-
| **MUST** | 必須遵守 | 🔴 最高 | 強制執行,無例外 |
|
|
209
|
-
| **SHOULD** | 應該遵守 | 🟡 中等 | 優先遵守,需註明偏離原因 |
|
|
210
|
-
| **MAY** | 建議遵守 | 🟢 最低 | 參考建議,自由選擇 |
|
|
211
|
-
|
|
212
|
-
#### 2. Priority(Meta 優先級)
|
|
213
|
-
|
|
214
|
-
定義於規則檔案的 `_meta.priority` 字段:
|
|
215
|
-
|
|
216
|
-
```yaml
|
|
217
|
-
_meta:
|
|
218
|
-
priority: 0 # 0=最高, 1=高, 2=中, 3=低
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
| 數值 | 說明 | 適用規則 |
|
|
222
|
-
|------|------|---------|
|
|
223
|
-
| **0** | 最高優先 | 核心原則(GEN-001~007) |
|
|
224
|
-
| **1** | 高優先 | Agent 工作流程(AGT-001~008)、Pipeline 規則(PPL-101~112) |
|
|
225
|
-
| **2** | 中優先 | 代碼規範(CD-001~099)、設計規範(UI-001~099) |
|
|
226
|
-
| **3** | 低優先 | 業務邏輯約束(未來) |
|
|
227
|
-
|
|
228
|
-
#### 3. Load Order(載入順序)
|
|
229
|
-
|
|
230
|
-
定義於 `INDEX.yaml` 的 `load_order` 列表,**越早載入優先級越高**。
|
|
231
|
-
|
|
232
|
-
**範例**:
|
|
233
|
-
```yaml
|
|
234
|
-
load_order:
|
|
235
|
-
- path: "general/principles.yaml" # 第 1 順位(優先級最高)
|
|
236
|
-
- path: "general/agent-workflow.yaml" # 第 2 順位
|
|
237
|
-
- path: "pipeline/task-execution.yaml" # 第 N 順位
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
### 衝突解決範例
|
|
241
|
-
|
|
242
|
-
**場景**:兩條規則衝突時如何決定?
|
|
243
|
-
|
|
244
|
-
```yaml
|
|
245
|
-
# 規則 A: GEN-007(專案自包含原則)
|
|
246
|
-
_meta:
|
|
247
|
-
priority: 0
|
|
248
|
-
severity: must
|
|
249
|
-
load_order: 2
|
|
250
|
-
|
|
251
|
-
# 規則 B: 某個 Skill 要求全局安裝工具
|
|
252
|
-
severity: should
|
|
253
|
-
load_order: N/A(不在 .rule/ 中)
|
|
254
|
-
|
|
255
|
-
# 結果:GEN-007 優先(.rule/ > .claude/skills/)
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
---
|
|
259
|
-
|
|
260
|
-
## 重要規則速查
|
|
261
|
-
|
|
262
|
-
### 通用規則(General)
|
|
263
|
-
|
|
264
|
-
| 規則 ID | 標題 | 嚴重程度 | 說明 |
|
|
265
|
-
|---------|------|---------|------|
|
|
266
|
-
| **GEN-001** | 規格優先原則 | 🔴 MUST | 開發工作必須以 PRODUCT_SPEC.md 為依據 |
|
|
267
|
-
| **GEN-002** | 簡單優於複雜 | 🟡 SHOULD | 選擇最簡單的解決方案 |
|
|
268
|
-
| **GEN-007** | 專案自包含原則 | 🔴 MUST | 所有操作必須在專案目錄內進行 |
|
|
269
|
-
| **AGT-001** | 記憶點優先 | 🔴 MUST | 任務開始前檢查 .memory/ |
|
|
270
|
-
| **AGT-005** | 失敗經驗查閱 | 🔴 MUST | 失敗時必須查閱 .failure/ |
|
|
271
|
-
| **AGT-007** | 禁止訪問私有配置 | 🔴 MUST | 禁止訪問 ~/.claude/ 等用戶私有目錄 |
|
|
272
|
-
| **AGT-008** | 完成即停止原則 | 🟡 SHOULD | 任務完成後立即停止,不做額外步驟 |
|
|
273
|
-
| **SEC-010** | Sunny 存取控制 | 🔴 MUST | 禁止非 Sunny Agent 存取 .system/sunny/ |
|
|
274
|
-
| **CTX-001** | Cortex 優先 | 🔴 MUST | 「怎麼運作」類問題直接用 Cortex |
|
|
275
|
-
|
|
276
|
-
### Pipeline 規則
|
|
277
|
-
|
|
278
|
-
| 規則 ID | 標題 | 嚴重程度 | 說明 |
|
|
279
|
-
|---------|------|---------|------|
|
|
280
|
-
| **PPL-002** | 已完成任務封存 | 🔴 MUST | 任務完成後封存到 .memory/ |
|
|
281
|
-
| **PPL-003** | Pipeline 自動更新 | 🔴 MUST | 任務完成後更新 TASK_QUEUE.json |
|
|
282
|
-
| **PPL-101** | 任務拆分粒度 | 🔴 MUST | 每個任務 15-20 分鐘可完成 |
|
|
283
|
-
| **PPL-102** | 依賴管理規則 | 🔴 MUST | 明確定義 dependencies 字段 |
|
|
284
|
-
| **PPL-103** | 並行執行策略 | 🟡 SHOULD | 無依賴 + 無衝突 → 可並行 |
|
|
285
|
-
| **PPL-105** | agent_type 命名規則 | 🔴 MUST | 使用 Agent 名稱(developer, strategy) |
|
|
286
|
-
| **PPL-106** | Feature ID 自動分配 | 🔴 MUST | 為同功能任務分配 F-XXX ID |
|
|
287
|
-
| **PPL-107** | 工作啟動前展示計劃 | 🔴 MUST | 必須向用戶展示計劃並等待確認 |
|
|
288
|
-
| **PPL-108** | 任務失敗立即報告 | 🔴 MUST | 失敗時立即停止並通知 |
|
|
289
|
-
| **PPL-109** | 階段性 Git Commit | 🔴 MUST | 每個階段建立 commit |
|
|
290
|
-
| **PPL-110** | 任務完成後續動作 | 🔴 MUST | 自動更新 TASK_QUEUE.json 並解除阻塞 |
|
|
291
|
-
| **PPL-111** | scope_paths 衝突檢測 | 🔴 MUST | 並行任務不可有路徑衝突 |
|
|
292
|
-
| **PPL-112** | 驗收標準驗證 | 🔴 MUST | 任務完成後驗證驗收標準 |
|
|
293
|
-
|
|
294
|
-
### 代碼規則(Code)
|
|
295
|
-
|
|
296
|
-
| 規則 ID | 標題 | 嚴重程度 | 說明 |
|
|
297
|
-
|---------|------|---------|------|
|
|
298
|
-
| **CD-001** | 模塊化設計 | 🔴 MUST | 單一職責、低耦合 |
|
|
299
|
-
| **CD-002** | 代碼複用優先 | 🟡 SHOULD | 複用現有代碼,避免重複實現 |
|
|
300
|
-
| **CD-003** | 可維護性優先 | 🔴 MUST | 清晰命名、錯誤處理、調試支援 |
|
|
301
|
-
|
|
302
|
-
完整規則請參閱各分類目錄下的 YAML 檔案。
|
|
303
|
-
|
|
304
|
-
---
|
|
305
|
-
|
|
306
|
-
## Agent 使用指南
|
|
307
|
-
|
|
308
|
-
### 任務開始前
|
|
309
|
-
|
|
310
|
-
1. **讀取規則索引**:
|
|
311
|
-
```bash
|
|
312
|
-
cat .rule/INDEX.yaml
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
2. **檢查相關規則**:
|
|
316
|
-
```bash
|
|
317
|
-
# 根據任務類型檢查對應規則
|
|
318
|
-
cat .rule/general/agent-workflow.yaml # 所有 Agent 必讀
|
|
319
|
-
cat .rule/pipeline/task-execution.yaml # Pipeline 任務必讀
|
|
320
|
-
cat .rule/code/checklist.yaml # 代碼提交前必讀
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
3. **檢查失敗經驗**(AGT-005):
|
|
324
|
-
```powershell
|
|
325
|
-
.\.failure\tools\check_failures.ps1 -TaskID "TASK_XXX"
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
### 任務執行中
|
|
329
|
-
|
|
330
|
-
- **遵守核心規則**:所有 🔴 MUST 規則必須嚴格遵守
|
|
331
|
-
- **路徑衝突檢測**(PPL-111):並行任務前檢查 scope_paths
|
|
332
|
-
- **自包含原則**(GEN-007):所有操作在專案目錄內進行
|
|
333
|
-
|
|
334
|
-
### 任務完成後
|
|
335
|
-
|
|
336
|
-
- **Pipeline 自動更新**(PPL-003):更新 TASK_QUEUE.json
|
|
337
|
-
- **任務封存**(PPL-002):移動已完成任務到 .memory/
|
|
338
|
-
- **記憶點新增**(AGT-001):記錄重要決策與經驗
|
|
339
|
-
|
|
340
|
-
---
|
|
341
|
-
|
|
342
|
-
## 規則版本與更新
|
|
343
|
-
|
|
344
|
-
**元資料**(定義於 `INDEX.yaml`):
|
|
345
|
-
- **版本**:v1.0.0
|
|
346
|
-
- **最後更新**:2026-02-06T22:10:00+08:00
|
|
347
|
-
|
|
348
|
-
**更新流程**:
|
|
349
|
-
1. 修改對應規則檔案(如 `code/naming.yaml`)
|
|
350
|
-
2. 更新 `INDEX.yaml` 中的 `last_updated` 時間戳
|
|
351
|
-
3. 如有新規則檔案,加入到 `load_order` 列表
|
|
352
|
-
4. 建立 Git commit:`[RULE] 簡短描述`
|
|
353
|
-
|
|
354
|
-
---
|
|
355
|
-
|
|
356
|
-
## 與其他系統的關係
|
|
357
|
-
|
|
358
|
-
### 規則優先級體系
|
|
359
|
-
|
|
360
|
-
```
|
|
361
|
-
┌─────────────────────────────────────────────────────────┐
|
|
362
|
-
│ 規則優先級體系 │
|
|
363
|
-
│ │
|
|
364
|
-
│ 1️⃣ .rule/* ← 最高優先級(強制約束) │
|
|
365
|
-
│ ├─ general/ ← 所有人必須遵守 │
|
|
366
|
-
│ ├─ code/ ← 代碼開發必須遵守 │
|
|
367
|
-
│ └─ pipeline/ ← Pipeline 任務必須遵守 │
|
|
368
|
-
│ │
|
|
369
|
-
│ 2️⃣ CLAUDE.md ← 專案級指令與工作流程 │
|
|
370
|
-
│ │
|
|
371
|
-
│ 3️⃣ .claude/skills/ ← Agent 行為定義 │
|
|
372
|
-
│ │
|
|
373
|
-
│ 4️⃣ .agents/skills/ ← 外部最佳實踐(參考) │
|
|
374
|
-
│ │
|
|
375
|
-
└─────────────────────────────────────────────────────────┘
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
### 與 .failure/ 的關係
|
|
379
|
-
|
|
380
|
-
**失敗學習系統** (`.failure/`) 記錄已發生的失敗經驗:
|
|
381
|
-
|
|
382
|
-
```
|
|
383
|
-
失敗 → 記錄到 .failure/ → 分析根因 → 重複發生(>2 次)→ 提升為 .rule/
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
**範例**:
|
|
387
|
-
- FAIL-003(TASK_QUEUE 污染)→ 提升為 PPL-002(已完成任務封存規則)
|
|
388
|
-
|
|
389
|
-
### 與 .memory/ 的關係
|
|
390
|
-
|
|
391
|
-
**記憶系統** (`.memory/`) 儲存開發經驗與決策:
|
|
392
|
-
|
|
393
|
-
```
|
|
394
|
-
.rule/ (強制約束) > .failure/ (應避免模式) > .memory/ (經驗記錄)
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
**使用流程**:
|
|
398
|
-
1. 檢查 `.rule/`(必須遵守)
|
|
399
|
-
2. 檢查 `.failure/`(避免重複錯誤)
|
|
400
|
-
3. 查詢 `.memory/`(參考歷史經驗)
|
|
401
|
-
|
|
402
|
-
---
|
|
403
|
-
|
|
404
|
-
## 常見問題(FAQ)
|
|
405
|
-
|
|
406
|
-
### Q1: 規則衝突時怎麼辦?
|
|
407
|
-
|
|
408
|
-
**A**: 遵循優先級順序。`.rule/` 優先於 `CLAUDE.md`,`CLAUDE.md` 優先於 `.claude/skills/`。
|
|
409
|
-
|
|
410
|
-
### Q2: 如何新增規則?
|
|
411
|
-
|
|
412
|
-
**A**: 參考下方「新增規則完整流程」章節。
|
|
413
|
-
|
|
414
|
-
### Q3: MUST 規則可以違反嗎?
|
|
415
|
-
|
|
416
|
-
**A**: 不可以。🔴 MUST 規則是強制約束,違反將導致任務失敗或 Pull Request 被拒絕。
|
|
417
|
-
|
|
418
|
-
### Q4: 規則適用於哪些對象?
|
|
419
|
-
|
|
420
|
-
**A**: 根據 `applies_to` 字段決定:
|
|
421
|
-
- `ai_agent`:所有 AI Agent
|
|
422
|
-
- `human_developer`:人類開發者
|
|
423
|
-
- `ci_cd`:CI/CD Pipeline
|
|
424
|
-
- `code_review`:Code Review 階段
|
|
425
|
-
|
|
426
|
-
### Q5: 規則如何與 Cortex 整合?
|
|
427
|
-
|
|
428
|
-
**A**: Agent 在任務開始前會透過 Cortex 系統載入相關規則:
|
|
429
|
-
```bash
|
|
430
|
-
# Cortex 自動載入高優先級規則
|
|
431
|
-
node .cortex/api/context.js --task-id TASK_XXX
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
---
|
|
435
|
-
|
|
436
|
-
## 新增規則完整流程
|
|
437
|
-
|
|
438
|
-
### 流程概覽
|
|
439
|
-
|
|
440
|
-
```
|
|
441
|
-
識別需求 → 選擇分類 → 分配 ID → 撰寫規則 → 更新索引 → 測試驗證 → 提交 Commit
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
### 詳細步驟
|
|
445
|
-
|
|
446
|
-
#### 1. 識別需求
|
|
447
|
-
|
|
448
|
-
**確認是否需要新增規則**:
|
|
449
|
-
- 是否為重複出現的問題(>2 次)?
|
|
450
|
-
- 是否需要強制約束所有 Agent/開發者?
|
|
451
|
-
- 是否已在 `.failure/` 中記錄為失敗模式?
|
|
452
|
-
|
|
453
|
-
**範例**:
|
|
454
|
-
```
|
|
455
|
-
問題:Multi-Agent 並行開發時,多個 Agent 同時修改同一檔案導致 Git 衝突
|
|
456
|
-
結論:需要新增規則(PPL-111: scope_paths 衝突檢測)
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
#### 2. 選擇分類與 ID
|
|
460
|
-
|
|
461
|
-
**步驟 A:選擇分類目錄**
|
|
462
|
-
|
|
463
|
-
根據規則性質選擇目錄:
|
|
464
|
-
- 通用原則 → `general/`
|
|
465
|
-
- Agent 工作流程 → `general/agent-workflow.yaml`
|
|
466
|
-
- Pipeline 任務 → `pipeline/`
|
|
467
|
-
- 代碼規範 → `code/`
|
|
468
|
-
- 設計規範 → `design/`
|
|
469
|
-
|
|
470
|
-
**步驟 B:分配規則 ID**
|
|
471
|
-
|
|
472
|
-
1. 選擇前綴(GEN/AGT/PPL/SEC/CTX/CD/UI/DATA)
|
|
473
|
-
2. 選擇編號範圍(001-099 基礎,100-199 進階)
|
|
474
|
-
3. 檢查現有 ID,避免衝突:
|
|
475
|
-
```bash
|
|
476
|
-
grep -r "id: \"PPL-" .rule/
|
|
477
|
-
```
|
|
478
|
-
4. 填補空缺或使用連續編號
|
|
479
|
-
|
|
480
|
-
**範例**:
|
|
481
|
-
```yaml
|
|
482
|
-
# 新增 Pipeline 進階規則
|
|
483
|
-
id: "PPL-111" # scope_paths 衝突檢測
|
|
484
|
-
```
|
|
485
|
-
|
|
486
|
-
#### 3. 撰寫規則檔案
|
|
487
|
-
|
|
488
|
-
**模板**:
|
|
489
|
-
```yaml
|
|
490
|
-
# .rule/<category>/<file-name>.yaml
|
|
491
|
-
# <規則簡短描述>
|
|
492
|
-
|
|
493
|
-
_meta:
|
|
494
|
-
category: "<category>" # general/pipeline/code/design
|
|
495
|
-
priority: 1 # 0=最高, 1=高, 2=中, 3=低
|
|
496
|
-
applies_to:
|
|
497
|
-
- "ai_agent" # ai_agent/human_developer/ci_cd/code_review
|
|
498
|
-
last_updated: "YYYY-MM-DD"
|
|
499
|
-
description: |
|
|
500
|
-
規則集的總體描述
|
|
501
|
-
|
|
502
|
-
rules:
|
|
503
|
-
- id: "<PREFIX>-<NUMBER>"
|
|
504
|
-
title: "規則標題"
|
|
505
|
-
description: |
|
|
506
|
-
詳細描述規則內容、適用場景、具體要求
|
|
507
|
-
severity: "must" # must/should/may
|
|
508
|
-
rationale: "為什麼需要這條規則(理由與效益)"
|
|
509
|
-
|
|
510
|
-
# 可選字段
|
|
511
|
-
examples:
|
|
512
|
-
- good: "正確做法範例"
|
|
513
|
-
- bad: "錯誤做法範例"
|
|
514
|
-
|
|
515
|
-
workflow:
|
|
516
|
-
- step: 1
|
|
517
|
-
action: "具體步驟"
|
|
518
|
-
required: true
|
|
519
|
-
|
|
520
|
-
anti_patterns:
|
|
521
|
-
- "應避免的模式"
|
|
522
|
-
|
|
523
|
-
checklist:
|
|
524
|
-
- item: "檢查項目"
|
|
525
|
-
importance: "critical"
|
|
526
|
-
```
|
|
527
|
-
|
|
528
|
-
**實際範例**(PPL-111):
|
|
529
|
-
```yaml
|
|
530
|
-
# .rule/pipeline/task-execution.yaml
|
|
531
|
-
|
|
532
|
-
rules:
|
|
533
|
-
- id: "PPL-111"
|
|
534
|
-
title: "scope_paths 衝突檢測"
|
|
535
|
-
description: |
|
|
536
|
-
Lead Agent 啟動任務前必須檢測:
|
|
537
|
-
- 讀取所有 in_progress 任務的 scope_paths
|
|
538
|
-
- 檢查新任務的 scope_paths 是否衝突
|
|
539
|
-
- 衝突定義:路徑重疊(包含或被包含)
|
|
540
|
-
|
|
541
|
-
衝突處理:
|
|
542
|
-
- 有衝突 → 等待衝突任務完成
|
|
543
|
-
- 無衝突 → 啟動新任務
|
|
544
|
-
severity: "must"
|
|
545
|
-
rationale: "防止多個 Agent 同時修改相同文件,避免 Git 衝突"
|
|
546
|
-
examples:
|
|
547
|
-
- conflict: |
|
|
548
|
-
- TASK_A: scope_paths: [".rule/pipeline/"]
|
|
549
|
-
- TASK_B: scope_paths: [".rule/pipeline/task-execution.yaml"]
|
|
550
|
-
→ 衝突(B 包含在 A 中)
|
|
551
|
-
- no_conflict: |
|
|
552
|
-
- TASK_A: scope_paths: [".rule/pipeline/"]
|
|
553
|
-
- TASK_B: scope_paths: [".rule/general/"]
|
|
554
|
-
→ 無衝突(路徑不重疊)
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
#### 4. 更新 INDEX.yaml
|
|
558
|
-
|
|
559
|
-
在 `load_order` 列表中加入新規則:
|
|
560
|
-
|
|
561
|
-
```yaml
|
|
562
|
-
load_order:
|
|
563
|
-
# 現有規則...
|
|
564
|
-
|
|
565
|
-
- path: "pipeline/task-execution.yaml"
|
|
566
|
-
description: "PPL-101 至 PPL-112 - Pipeline 任務執行規範(拆分、依賴、並行等)"
|
|
567
|
-
|
|
568
|
-
# 新增規則在此加入
|
|
569
|
-
```
|
|
570
|
-
|
|
571
|
-
**注意載入順序**:
|
|
572
|
-
- 核心原則在最前面
|
|
573
|
-
- 依賴性規則按依賴關係排序
|
|
574
|
-
- 同類規則放在一起
|
|
575
|
-
|
|
576
|
-
#### 5. 測試驗證
|
|
577
|
-
|
|
578
|
-
**檢查清單**:
|
|
579
|
-
- [ ] YAML 語法正確(無縮進錯誤)
|
|
580
|
-
- [ ] 規則 ID 無衝突(唯一性)
|
|
581
|
-
- [ ] `severity` 字段正確(must/should/may)
|
|
582
|
-
- [ ] `applies_to` 字段明確
|
|
583
|
-
- [ ] `INDEX.yaml` 載入順序合理
|
|
584
|
-
- [ ] 範例清晰易懂
|
|
585
|
-
|
|
586
|
-
**驗證命令**:
|
|
587
|
-
```bash
|
|
588
|
-
# YAML 語法檢查
|
|
589
|
-
node -e "const yaml = require('yaml'); const fs = require('fs'); yaml.parse(fs.readFileSync('.rule/pipeline/task-execution.yaml', 'utf8'))"
|
|
590
|
-
|
|
591
|
-
# 檢查規則 ID 唯一性
|
|
592
|
-
grep -r "id: \"PPL-111\"" .rule/
|
|
593
|
-
```
|
|
594
|
-
|
|
595
|
-
#### 6. 提交 Git Commit
|
|
596
|
-
|
|
597
|
-
```bash
|
|
598
|
-
git add .rule/
|
|
599
|
-
git commit -m "[RULE] 新增 PPL-111: scope_paths 衝突檢測規則
|
|
600
|
-
|
|
601
|
-
- 防止並行任務修改相同文件
|
|
602
|
-
- 新增衝突檢測邏輯與範例
|
|
603
|
-
- 更新 INDEX.yaml 載入順序
|
|
604
|
-
"
|
|
605
|
-
```
|
|
606
|
-
|
|
607
|
-
### 新增規則檢查清單
|
|
608
|
-
|
|
609
|
-
**必填字段**:
|
|
610
|
-
- [ ] `id` - 規則 ID(格式正確,無衝突)
|
|
611
|
-
- [ ] `title` - 規則標題(簡短明確)
|
|
612
|
-
- [ ] `description` - 規則描述(詳細清晰)
|
|
613
|
-
- [ ] `severity` - 嚴重程度(must/should/may)
|
|
614
|
-
- [ ] `rationale` - 理由說明(為什麼需要)
|
|
615
|
-
- [ ] `_meta.category` - 分類(general/pipeline/code/design)
|
|
616
|
-
- [ ] `_meta.priority` - 優先級(0-3)
|
|
617
|
-
- [ ] `_meta.applies_to` - 適用對象(ai_agent/human_developer 等)
|
|
618
|
-
|
|
619
|
-
**推薦字段**:
|
|
620
|
-
- [ ] `examples` - 範例(good/bad)
|
|
621
|
-
- [ ] `workflow` - 操作流程(step-by-step)
|
|
622
|
-
- [ ] `checklist` - 檢查清單
|
|
623
|
-
- [ ] `anti_patterns` - 反模式(應避免的做法)
|
|
624
|
-
|
|
625
|
-
---
|
|
626
|
-
|
|
627
|
-
## 規則與 .failure 的升級機制
|
|
628
|
-
|
|
629
|
-
### 系統關係
|
|
630
|
-
|
|
631
|
-
```
|
|
632
|
-
.failure/ (失敗記錄) → 重複發生 (>2 次) → .rule/ (強制規則)
|
|
633
|
-
```
|
|
634
|
-
|
|
635
|
-
**設計理念**:
|
|
636
|
-
- **失敗經驗** (`.failure/`):記錄已發生的錯誤,提供解決方案
|
|
637
|
-
- **強制規則** (`.rule/`):將重複失敗模式提升為約束,防止再次發生
|
|
638
|
-
|
|
639
|
-
### 升級流程
|
|
640
|
-
|
|
641
|
-
#### 階段 1:記錄失敗(Agent 執行)
|
|
642
|
-
|
|
643
|
-
當任務失敗時,Agent 必須:
|
|
644
|
-
1. 記錄失敗到 `.failure/<category>/FAIL-XXX_*.md`
|
|
645
|
-
2. 填寫失敗模板(描述、根因、解決方案、預防措施)
|
|
646
|
-
3. 在「規則建議」章節提出潛在規則
|
|
647
|
-
|
|
648
|
-
**範例**(FAIL-003):
|
|
649
|
-
```markdown
|
|
650
|
-
# [FAIL-003] TASK_QUEUE 污染問題
|
|
651
|
-
|
|
652
|
-
## 規則建議
|
|
653
|
-
如果此失敗模式重複出現,建議建立 .rule/ 規則:
|
|
654
|
-
- 規則 ID: PPL-002
|
|
655
|
-
- 規則描述: 已完成任務必須封存到 .memory/
|
|
656
|
-
- 嚴重程度: must
|
|
657
|
-
```
|
|
658
|
-
|
|
659
|
-
#### 階段 2:追蹤重複發生(Product Manager)
|
|
660
|
-
|
|
661
|
-
**觸發條件**:
|
|
662
|
-
- 相同失敗模式出現 **>2 次**
|
|
663
|
-
- 影響範圍廣(多個 Agent 或任務)
|
|
664
|
-
- 修復成本高(>1 小時)
|
|
665
|
-
|
|
666
|
-
**檢查方式**:
|
|
667
|
-
```bash
|
|
668
|
-
# 檢查失敗記錄統計
|
|
669
|
-
cat .failure/INDEX.yaml | grep "total_failures"
|
|
670
|
-
|
|
671
|
-
# 搜尋相同根因的失敗
|
|
672
|
-
grep -r "TASK_QUEUE 污染" .failure/
|
|
673
|
-
```
|
|
674
|
-
|
|
675
|
-
#### 階段 3:建立規則(Product Manager)
|
|
676
|
-
|
|
677
|
-
**步驟**:
|
|
678
|
-
1. 從失敗記錄中提取「規則建議」章節
|
|
679
|
-
2. 依照「新增規則完整流程」建立規則
|
|
680
|
-
3. 引用失敗記錄作為背景
|
|
681
|
-
|
|
682
|
-
**範例**(PPL-002):
|
|
683
|
-
```yaml
|
|
684
|
-
# .rule/pipeline/PPL-002-completed-task-archival.yaml
|
|
685
|
-
|
|
686
|
-
rules:
|
|
687
|
-
- id: "PPL-002"
|
|
688
|
-
title: "已完成任務必須封存"
|
|
689
|
-
description: |
|
|
690
|
-
所有 completed 狀態的任務必須封存到 .memory/completed/
|
|
691
|
-
不可留在 dev/pipeline/completed/ 或 TASK_QUEUE.json 中
|
|
692
|
-
severity: "must"
|
|
693
|
-
rationale: |
|
|
694
|
-
防止 TASK_QUEUE 被歷史任務污染(參考 FAIL-003)
|
|
695
|
-
確保 Multi-Agent Scheduler 只處理當前任務
|
|
696
|
-
|
|
697
|
-
background:
|
|
698
|
-
failure_record: "FAIL-003: TASK_QUEUE 污染問題"
|
|
699
|
-
occurrence_count: 3
|
|
700
|
-
last_occurred: "2026-02-06"
|
|
701
|
-
```
|
|
702
|
-
|
|
703
|
-
#### 階段 4:更新失敗記錄(標記已升級)
|
|
704
|
-
|
|
705
|
-
在失敗記錄中標記已轉化為規則:
|
|
706
|
-
|
|
707
|
-
```markdown
|
|
708
|
-
# [FAIL-003] TASK_QUEUE 污染問題
|
|
709
|
-
|
|
710
|
-
_meta:
|
|
711
|
-
converted_to_rule: true
|
|
712
|
-
rule_id: "PPL-002"
|
|
713
|
-
converted_at: "2026-02-06"
|
|
714
|
-
|
|
715
|
-
## 規則建議
|
|
716
|
-
✅ **已轉化為規則**:PPL-002(已完成任務必須封存)
|
|
717
|
-
```
|
|
718
|
-
|
|
719
|
-
#### 階段 5:監控規則效果
|
|
720
|
-
|
|
721
|
-
**檢查項目**:
|
|
722
|
-
- [ ] 新規則是否防止了失敗重複發生?
|
|
723
|
-
- [ ] Agent 是否正確遵守規則?
|
|
724
|
-
- [ ] 規則是否需要調整(severity/description)?
|
|
725
|
-
|
|
726
|
-
**監控週期**:規則建立後 1 週內每日檢查
|
|
727
|
-
|
|
728
|
-
### 升級統計
|
|
729
|
-
|
|
730
|
-
在 `.failure/INDEX.yaml` 中記錄轉化統計:
|
|
731
|
-
|
|
732
|
-
```yaml
|
|
733
|
-
statistics:
|
|
734
|
-
total_failures: 6
|
|
735
|
-
converted_to_rules: 2 # 已轉化為 .rule/ 規則
|
|
736
|
-
|
|
737
|
-
conversions:
|
|
738
|
-
- failure_id: "FAIL-003"
|
|
739
|
-
rule_id: "PPL-002"
|
|
740
|
-
converted_at: "2026-02-06"
|
|
741
|
-
- failure_id: "FAIL-001"
|
|
742
|
-
rule_id: "AGT-006"
|
|
743
|
-
converted_at: "2026-02-05"
|
|
744
|
-
```
|
|
745
|
-
|
|
746
|
-
### 升級決策矩陣
|
|
747
|
-
|
|
748
|
-
| 失敗次數 | 影響範圍 | 修復成本 | 行動 |
|
|
749
|
-
|---------|---------|---------|------|
|
|
750
|
-
| 1 次 | 單一任務 | <30 分鐘 | 記錄到 .failure/,觀察 |
|
|
751
|
-
| 2 次 | 單一 Agent | <1 小時 | 記錄,考慮建立規則 |
|
|
752
|
-
| >2 次 | 多個 Agent | >1 小時 | **必須建立規則** |
|
|
753
|
-
| >3 次 | 系統級 | >2 小時 | **Critical 規則,立即建立** |
|
|
754
|
-
|
|
755
|
-
### 範例:完整升級流程
|
|
756
|
-
|
|
757
|
-
**背景**:Multi-Agent 並行開發時,3 次因路徑衝突導致 Git 衝突
|
|
758
|
-
|
|
759
|
-
```
|
|
760
|
-
2026-02-01: FAIL-XXX 記錄第 1 次路徑衝突
|
|
761
|
-
2026-02-03: FAIL-XXX 更新(第 2 次發生)
|
|
762
|
-
2026-02-05: FAIL-XXX 更新(第 3 次發生)→ 觸發升級
|
|
763
|
-
↓
|
|
764
|
-
2026-02-06: 建立 PPL-111 規則(scope_paths 衝突檢測)
|
|
765
|
-
↓
|
|
766
|
-
2026-02-07: 更新 FAIL-XXX(標記已轉化)
|
|
767
|
-
↓
|
|
768
|
-
2026-02-08~14: 監控規則效果(無新衝突)→ 規則有效 ✅
|
|
769
|
-
```
|
|
770
|
-
|
|
771
|
-
---
|
|
772
|
-
|
|
773
|
-
## 相關文檔
|
|
774
|
-
|
|
775
|
-
| 文檔 | 路徑 | 說明 |
|
|
776
|
-
|------|------|------|
|
|
777
|
-
| **規則索引** | `.rule/INDEX.yaml` | 所有規則的載入順序與元資料 |
|
|
778
|
-
| **代碼規範** | `.rule/code/README.md` | 代碼規則詳細說明 |
|
|
779
|
-
| **失敗學習系統** | `.system/failure/README.md` | 失敗經驗記錄與工具 |
|
|
780
|
-
| **記憶系統** | `.memory/CORTEX_GUIDE.md` | Cortex 整合指南 |
|
|
781
|
-
| **CLAUDE.md** | `CLAUDE.md` | 專案級指令與工作流程 |
|
|
782
|
-
|
|
783
|
-
---
|
|
784
|
-
|
|
785
|
-
## 更新記錄
|
|
786
|
-
|
|
787
|
-
| 日期 | 版本 | 更新內容 |
|
|
788
|
-
|------|------|---------|
|
|
789
|
-
| 2026-02-20 | v1.1.0 | 新增規則 ID 編號系統、規則優先級邏輯、新增規則完整流程、規則與 .failure 升級機制 |
|
|
790
|
-
| 2026-02-19 | v1.0.0 | 初始版本,建立規則系統基礎文檔 |
|
|
791
|
-
|
|
792
|
-
---
|
|
793
|
-
|
|
794
|
-
*建立日期: 2026-02-19 | 當前版本: v1.1.0 | 最後更新: 2026-02-20*
|