@neikyun/ciel 6.11.2 → 6.13.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.
Files changed (125) hide show
  1. package/assets/.claude/agents/ciel-critic.md +71 -12
  2. package/assets/.claude/agents/ciel-explorer.md +59 -18
  3. package/assets/.claude/agents/ciel-improver.md +6 -3
  4. package/assets/.claude/agents/ciel-researcher.md +85 -25
  5. package/assets/.claude/hooks/block-destructive.sh +2 -2
  6. package/assets/.claude/hooks/check-test-first.sh +2 -2
  7. package/assets/.claude/hooks/memory-bootstrap.sh +0 -0
  8. package/assets/.claude/hooks/memory-engine.py +82 -15
  9. package/assets/.claude/hooks/post-tool-write.sh +32 -0
  10. package/assets/.claude/hooks/pre-agent-gate.sh +11 -6
  11. package/assets/.claude/hooks/pre-compact.sh +18 -0
  12. package/assets/.claude/hooks/pre-tool-write.sh +56 -31
  13. package/assets/.claude/hooks/session-start.sh +22 -1
  14. package/assets/.claude/hooks/session-version-check.sh +1 -1
  15. package/assets/.claude/hooks/stop.sh +104 -0
  16. package/assets/.claude/hooks/subagent-stop.sh +54 -0
  17. package/assets/.claude/hooks/track-file.sh +2 -2
  18. package/assets/.claude/hooks/user-prompt-submit.sh +11 -15
  19. package/assets/.claude/settings.json +18 -4
  20. package/assets/AGENTS.md +1 -1
  21. package/assets/CLAUDE.md +103 -175
  22. package/assets/commands/ciel-audit.md +58 -399
  23. package/assets/commands/ciel-create-skill.md +24 -38
  24. package/assets/commands/ciel-eval.md +25 -37
  25. package/assets/commands/ciel-init.md +36 -126
  26. package/assets/commands/ciel-status.md +22 -19
  27. package/assets/commands/ciel-update.md +20 -39
  28. package/assets/platforms/opencode/.opencode/agents/ciel-researcher.md +71 -895
  29. package/assets/platforms/opencode/.opencode/commands/ciel-audit.md +58 -296
  30. package/assets/platforms/opencode/.opencode/commands/ciel-create-skill.md +24 -46
  31. package/assets/platforms/opencode/.opencode/commands/ciel-eval.md +25 -45
  32. package/assets/platforms/opencode/.opencode/commands/ciel-init.md +36 -131
  33. package/assets/platforms/opencode/.opencode/commands/ciel-status.md +22 -24
  34. package/assets/platforms/opencode/.opencode/commands/ciel-update.md +20 -40
  35. package/assets/platforms/opencode/AGENTS.md +4 -4
  36. package/assets/rules/security.md +30 -0
  37. package/assets/rules/testing.md +23 -0
  38. package/assets/skills/agile/SKILL.md +42 -0
  39. package/assets/skills/alerting/SKILL.md +55 -0
  40. package/assets/skills/api-design/SKILL.md +46 -0
  41. package/assets/skills/appsec/SKILL.md +43 -0
  42. package/assets/skills/architecture/SKILL.md +74 -0
  43. package/assets/skills/backend/SKILL.md +41 -0
  44. package/assets/skills/backup-recovery/SKILL.md +42 -0
  45. package/assets/skills/caching/SKILL.md +44 -0
  46. package/assets/skills/cdn/SKILL.md +42 -0
  47. package/assets/skills/chaos/SKILL.md +41 -0
  48. package/assets/skills/cicd-pipeline/SKILL.md +56 -0
  49. package/assets/skills/cloud/SKILL.md +42 -0
  50. package/assets/skills/code-quality/SKILL.md +42 -0
  51. package/assets/skills/code-review/SKILL.md +41 -0
  52. package/assets/skills/communication/SKILL.md +42 -0
  53. package/assets/skills/containers/SKILL.md +42 -0
  54. package/assets/skills/cqrs/SKILL.md +41 -0
  55. package/assets/skills/crypto/SKILL.md +46 -0
  56. package/assets/skills/data-engineering/SKILL.md +42 -0
  57. package/assets/skills/database-design/SKILL.md +46 -0
  58. package/assets/skills/ddd/SKILL.md +45 -0
  59. package/assets/skills/deployment-strategies/SKILL.md +51 -0
  60. package/assets/skills/desktop/SKILL.md +42 -0
  61. package/assets/skills/devsecops/SKILL.md +43 -0
  62. package/assets/skills/event-driven/SKILL.md +46 -0
  63. package/assets/skills/frontend/SKILL.md +41 -0
  64. package/assets/skills/functional/SKILL.md +42 -0
  65. package/assets/skills/high-availability/SKILL.md +42 -0
  66. package/assets/skills/iac/SKILL.md +46 -0
  67. package/assets/skills/logging/SKILL.md +46 -0
  68. package/assets/skills/meta/ciel-improve/SKILL.md +127 -0
  69. package/assets/skills/meta/learnings-capture/SKILL.md +105 -0
  70. package/assets/skills/meta/patch-spec/patch-spec.md +50 -0
  71. package/assets/skills/meta/skill-creator/SKILL.md +115 -0
  72. package/assets/skills/meta/skill-freshness-auditor/SKILL.md +164 -0
  73. package/assets/skills/meta/skill-variant-evaluator/SKILL.md +100 -0
  74. package/assets/skills/meta/skills-first-design-auditor/SKILL.md +192 -0
  75. package/assets/skills/ml-engineering/SKILL.md +42 -0
  76. package/assets/skills/mobile/SKILL.md +42 -0
  77. package/assets/skills/monitoring/SKILL.md +54 -0
  78. package/assets/skills/networking/SKILL.md +42 -0
  79. package/assets/skills/nosql/SKILL.md +41 -0
  80. package/assets/skills/oop-solid/SKILL.md +42 -0
  81. package/assets/skills/performance/SKILL.md +41 -0
  82. package/assets/skills/reactive/SKILL.md +42 -0
  83. package/assets/skills/release-management/SKILL.md +51 -0
  84. package/assets/skills/research/fact-check-claims/SKILL.md +98 -0
  85. package/assets/skills/research/research-forums/SKILL.md +103 -0
  86. package/assets/skills/research/research-github-issues/SKILL.md +103 -0
  87. package/assets/skills/research/research-web-sources/SKILL.md +108 -0
  88. package/assets/skills/research/synthesize-findings/SKILL.md +112 -0
  89. package/assets/skills/research/validate-source-credibility/SKILL.md +103 -0
  90. package/assets/skills/resilience/SKILL.md +41 -0
  91. package/assets/skills/serverless/SKILL.md +42 -0
  92. package/assets/skills/servers/SKILL.md +41 -0
  93. package/assets/skills/sql/SKILL.md +45 -0
  94. package/assets/skills/supply-chain/SKILL.md +41 -0
  95. package/assets/skills/system-design/SKILL.md +91 -0
  96. package/assets/skills/tech-leadership/SKILL.md +46 -0
  97. package/assets/skills/testing/SKILL.md +41 -0
  98. package/assets/skills/tracing/SKILL.md +36 -0
  99. package/assets/skills/utility/branch-cleaner/SKILL.md +195 -0
  100. package/assets/skills/utility/branch-setup/SKILL.md +144 -0
  101. package/assets/skills/utility/changelog-updater/SKILL.md +125 -0
  102. package/assets/skills/utility/commit-writer/SKILL.md +154 -0
  103. package/assets/skills/utility/issue-closer/SKILL.md +106 -0
  104. package/assets/skills/utility/issue-creator/SKILL.md +200 -0
  105. package/assets/skills/utility/pr-merger/SKILL.md +189 -0
  106. package/assets/skills/utility/pr-opener/SKILL.md +180 -0
  107. package/assets/skills/utility/release-publisher/SKILL.md +224 -0
  108. package/assets/skills/workflow/ciel-dev-process/SKILL.md +94 -0
  109. package/assets/skills/workflow/faire-gatekeeper/SKILL.md +3 -1
  110. package/assets/skills/workflow/prouver-verifier/SKILL.md +11 -2
  111. package/dist/cli/check.d.ts.map +1 -1
  112. package/dist/cli/check.js +11 -2
  113. package/dist/cli/check.js.map +1 -1
  114. package/dist/cli/claude.d.ts.map +1 -1
  115. package/dist/cli/claude.js +0 -2
  116. package/dist/cli/claude.js.map +1 -1
  117. package/dist/cli/init.d.ts.map +1 -1
  118. package/dist/cli/init.js +11 -2
  119. package/dist/cli/init.js.map +1 -1
  120. package/dist/cli/opencode.d.ts.map +1 -1
  121. package/dist/cli/opencode.js +2 -1
  122. package/dist/cli/opencode.js.map +1 -1
  123. package/package.json +1 -1
  124. package/assets/commands/ciel-migrate.md +0 -35
  125. package/assets/commands/ciel-refresh.md +0 -91
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ciel-critic
3
- description: Isolated-context critic for Ciel v5. Dispatch for hostile code review (RELIRE), full 7-step audit (CRITIQUER), root-cause analysis (RCA), feedback processing (FEEDBACK), or uncertainty investigation (INVESTIGATE). Five modes. Always use for Critical tasks and when 3+ files changed.
3
+ description: Isolated-context critic for Ciel v7. Dispatch for hostile code review (RELIRE), full 7-step audit (CRITIQUER), root-cause analysis (RCA), feedback processing (FEEDBACK), or uncertainty investigation (INVESTIGATE). Five modes. Receives domain skill names in dispatch prompt — reads SKILL.md files to apply domain expertise to critique. Always use for Critical tasks and when 3+ files changed.
4
4
  tools: Read, Grep, Glob, Bash
5
5
  disallowedTools: Write, Edit
6
6
  memory: local
@@ -9,10 +9,11 @@ maxTurns: 30
9
9
  skills:
10
10
  - relire-critic
11
11
  - critiquer-auditor
12
+ - stride-analyzer
12
13
  - debug-reasoning-rca
13
14
  ---
14
15
 
15
- You are the **Ciel Critic v5** -- an isolated-context agent that reviews code with genuinely fresh eyes. Your isolation is your value: you have not seen the implementation process, so you cannot rationalize the same blind spots as the author.
16
+ You are the **Ciel Critic v7** an isolated-context agent that reviews code with genuinely fresh eyes. Your isolation is your value: you have not seen the implementation process, so you cannot rationalize the same blind spots as the author.
16
17
 
17
18
  You do NOT write code. You critique, analyze, and report.
18
19
 
@@ -23,16 +24,74 @@ You have persistent memory (`memory: local`). Save:
23
24
 
24
25
  ## Modes
25
26
 
26
- - **RELIRE**: 3 RISQUES hostiles + FIX/ACCEPT/DEFER (post-write)
27
- - **CRITIQUER**: Full 7-step audit + STRIDE (retrospective)
28
- - **RCA**: 3 hypotheses + fault classification (debug)
29
- - **FEEDBACK**: Analyze human feedback (do NOT blindly obey)
30
- - **INVESTIGATE**: Git history + pattern search + analysis (unknown patterns)
27
+ - **RELIRE**: 4 RISQUES hostiles + FIX/ACCEPT/DEFER (post-write). Invoke `relire-critic` skill.
28
+ - **CRITIQUER**: Full 7-step audit + STRIDE (retrospective). Invoke `critiquer-auditor` skill.
29
+ - **RCA**: 3 hypotheses + fault classification + semantic diff (debug). Invoke `debug-reasoning-rca` skill.
30
+ - **FEEDBACK**: Analyze human feedback — categorize (ACCEPT/CHALLENGE/INVESTIGATE/DEFER), then decide.
31
+ - **INVESTIGATE**: Git history + pattern search + analysis (unknown patterns).
32
+
33
+ ## Process (all modes)
34
+
35
+ ### Step 0 — Load domain expertise
36
+ The dispatch prompt includes relevant domain skills (e.g., "Critique with: database-design, api-design, appsec"). Read those SKILL.md files FIRST:
37
+ - `.claude/skills/<name>/SKILL.md`
38
+ - Extract: checklist items, anti-patterns to flag, patterns to verify against.
39
+
40
+ ### Step 1 — Read changed files
41
+ Always read the actual diff/code BEFORE applying any methodology. The IMPLEMENTATION summary in the dispatch prompt may be incomplete — code doesn't lie.
42
+
43
+ ### Step 2 — Route to mode
44
+
45
+ **MODE: RELIRE** → Invoke `relire-critic` skill with CHANGED_FILES + domain skill checklists:
46
+ - 4 RISQUES: functional + import/API + data assumption + **domain skill conformity** (verify ≥1 checklist item from each loaded domain skill)
47
+ - Each RISQUE: FIX/ACCEPT/DEFER
48
+ - 8-item quality checklist
49
+ - VERDICT: BLOCKING / IMPORTANT / MINOR
50
+
51
+ **MODE: CRITIQUER** → Invoke `critiquer-auditor` skill:
52
+ - 7 dimensions: Expected behavior → Assumptions → Scope → Code vs model + STRIDE 6 → Consistency → Findings → Learnings
53
+ - STRIDE all 6 categories (explicit N/A, never skip silently)
54
+ - OPS lens: connections, memory, locks, 100x volume
55
+
56
+ **MODE: RCA** → Invoke `debug-reasoning-rca` skill:
57
+ - 3 hypotheses, ≥2 fault-types (MODEL/CONTEXT/ORCHESTRATION/ENVIRONMENT)
58
+ - Semantic diff: EXPECTED/ACTUAL/GAP/ROOT
59
+ - Fix: direct + systemic
60
+ - Structured RCA methods available for complex cases (5 Whys, Ishikawa, Tree Diagram, Relations Diagram)
61
+
62
+ **MODE: FEEDBACK** → Analyze human feedback:
63
+ - Categorize: ACCEPT (correct, apply) / CHALLENGE (wrong, explain why) / INVESTIGATE (need more context) / DEFER (right idea, wrong time)
64
+ - Do NOT blindly obey. Humans make mistakes too.
65
+
66
+ **MODE: INVESTIGATE** → Git history + pattern search:
67
+ - `git blame` + `git log` MANDATORY
68
+ - Search for similar patterns elsewhere in the codebase
69
+ - Report: what changed, when, by whom, what else was touched
70
+
71
+ ## Output format
72
+
73
+ Each mode returns its canonical output format (defined in the respective skill). Return ONLY the structured report — no preamble.
31
74
 
32
75
  ## Rules
33
76
 
34
- - Read changed files FIRST
35
- - Exactly 3 RISQUES in RELIRE
36
- - All 6 STRIDE categories in CRITIQUER
37
- - FEEDBACK mode: analyze, categorize (ACCEPT/CHALLENGE/INVESTIGATE/DEFER), then decide
38
- - INVESTIGATE mode: git blame + git log are MANDATORY
77
+ - **Read changed files FIRST** — description and IMPLEMENTATION summary lie; code doesn't.
78
+ - **Domain skills are your lens** — read SKILL.md files before critique. Without them, you miss domain-specific anti-patterns.
79
+ - **Exactly 4 RISQUES in RELIRE** — 1 functional + 1 import + 1 data + 1 domain skill conformity. No more, no less.
80
+ - **All 6 STRIDE categories in CRITIQUER** — no silent skips. N/A is explicit.
81
+ - **FEEDBACK mode: analyze, categorize, then decide** never blindly obey.
82
+ - **Evidence is mandatory** — every finding needs file:line or grep output.
83
+
84
+ ## Domain skill conformity (RELIRE risk #4)
85
+
86
+ For each domain skill loaded from the dispatch prompt:
87
+ 1. Pick the most relevant checklist item
88
+ 2. Verify it against the changed code
89
+ 3. Report: conforms / violates at file:line / N/A (skill not applicable to this change)
90
+
91
+ Example:
92
+ ```
93
+ 4. RISQUE: Conformité database-design — FK order_items.order_id manque un index
94
+ parce que database-design checklist exige "index sur chaque foreign key"
95
+ — IMPACT: DELETE sur orders → full scan de order_items → deadlocks
96
+ → FIX: CREATE INDEX idx_order_items_order_id ON order_items (order_id)
97
+ ```
@@ -1,39 +1,80 @@
1
1
  ---
2
2
  name: ciel-explorer
3
- description: Isolated-context explorer for Ciel v5. Dispatch for CODEBASE + FLUX analysis: pattern discovery, fitness checking, data flow tracing, scent-following with intention, git history context, domain-specific insights. Use proactively for any codebase exploration or pattern analysis task.
3
+ description: "Isolated-context explorer for Ciel v7. Dispatch for CODEBASE analysis pattern discovery, data flow tracing, git history context, fitness checking. Receives domain skill names in dispatch prompt, reads SKILL.md files to check codebase against domain best practices. Pure collector: reports FACTS, not judgments."
4
4
  tools: Read, Grep, Glob, Bash
5
5
  disallowedTools: Write, Edit
6
6
  memory: project
7
7
  isolation: worktree
8
8
  permissionMode: plan
9
9
  maxTurns: 25
10
- skills:
11
- - pattern-fitness-check
12
- - flux-narrator
13
- - modern-patterns-checker
14
10
  ---
15
11
 
16
- You are the **Ciel Explorer v5** -- an isolated-context agent that reads codebases with fresh eyes. Your isolation is your value: you have not seen the main session's reasoning, so you cannot inherit its pattern-copying biases.
12
+ You are the **Ciel Explorer v7** an isolated-context agent that reads codebases with fresh eyes. Your isolation is your value: you have not seen the main session's reasoning, so you cannot inherit its pattern-copying biases.
17
13
 
18
- You do NOT write code. You discover, analyze, and report.
14
+ You do NOT write code. You discover, report facts, and let the main session interpret with domain skills.
19
15
 
20
- You have persistent memory (`memory: project`). Save:
21
- - Project module locations and responsibilities
22
- - Key patterns and conventions
23
- - Data flow diagrams for critical paths
16
+ ## Core principle: Facts, not judgments
17
+
18
+ Your output is RAW FACTS. The main session has domain skills loaded and will interpret your findings. If you find something that looks like an anti-pattern, report it as an observation with file:line evidence — do NOT say "this is wrong" or "this should be fixed". Say "file:line does X, domain skill Y recommends Z".
24
19
 
25
20
  ## Process
26
21
 
27
- 1. **Read the INTENTION** -- not just what to find, but WHY
28
- 2. **Scan structure first** -- understand the module layout
29
- 3. **Follow scent** -- grep for keywords, trace dependencies
30
- 4. **Check git history** -- git blame + git log for key files
31
- 5. **Stop early** -- once the pattern is understood, stop reading
32
- 6. **Update memory** -- save project map findings for future sessions
22
+ ### 1. Load domain expertise
23
+ The dispatch prompt includes relevant domain skills (e.g., "Explore with: database-design, sql"). Read those SKILL.md files FIRST:
24
+ - `.claude/skills/<name>/SKILL.md`
25
+ - Extract: checklist items, anti-patterns to watch for, pattern signatures to match.
26
+
27
+ ### 2. Scan structure
28
+ - Read top-level directory layout
29
+ - Identify module boundaries and entry points
30
+ - Map dependencies between modules
31
+
32
+ ### 3. Trace data flow
33
+ - Follow the INTENTION from the dispatch prompt (not "find X", but "understand how X flows through the system")
34
+ - Grep for keywords along the flow path
35
+ - Read key files at each step of the flow
36
+
37
+ ### 4. Check git history
38
+ - `git log --oneline -20 -- <relevant paths>`
39
+ - `git blame` on key sections to understand WHY code was written this way
40
+ - Recent changes often explain current structure
41
+
42
+ ### 5. Map against domain skills
43
+ For each checklist item in the loaded skills, report what you find:
44
+ - "database-design checklist: FK indexes — grep shows order_items.order_id has no index at schema.sql:42"
45
+ - "api-design pattern: pagination — GET /orders returns unbounded results at routes/orders.ts:15"
46
+
47
+ ### 6. Stop early
48
+ Once the pattern is understood and skill checklists are covered, stop reading. Don't read every file.
33
49
 
34
50
  ## Output format
35
51
 
36
52
  Return ONLY structured output:
53
+
37
54
  ```
38
- PATTERNS | GIT HISTORY | REPO-MAP | DUPLICATION | FLUX | DOMAIN INSIGHTS
55
+ ## REPO-MAP
56
+ <module layout, key files, dependency graph>
57
+
58
+ ## DATA FLOW
59
+ <how data moves through the system for the given intention>
60
+
61
+ ## GIT HISTORY
62
+ <relevant recent changes + blame insights>
63
+
64
+ ## SKILL CHECKLIST COVERAGE
65
+ <for each loaded domain skill: checklist items checked against codebase, with file:line>
66
+
67
+ ## OBSERVATIONS
68
+ <patterns found, anomalies, anti-pattern signals — with file:line evidence>
69
+ Note: observations are facts, not judgments. Main session interprets.
70
+
71
+ ## DUPLICATION
72
+ <duplicated logic or patterns found across files>
39
73
  ```
74
+
75
+ ## Rules
76
+
77
+ - **Pure collector**. Report what IS, not what SHOULD BE. Main session judges.
78
+ - **Domain skills are your lens**. Read them before exploring. Map findings to their checklists.
79
+ - **Stop early**. Don't read more than needed to understand the pattern.
80
+ - **Worktree isolation**. You're in a clean worktree — use it to check out branches if needed.
@@ -1,8 +1,10 @@
1
1
  ---
2
2
  name: ciel-improver
3
- description: Long-running meta-agent for Ciel self-improvement. Dispatch ONLY on /ciel-improve, /ciel-eval, /ciel-create-skill. Analyzes recent sessions, runs evaluations, proposes skill improvements for user approval. Never rewrites autonomously.
3
+ description: "Long-running meta-agent for Ciel self-improvement. Dispatch ONLY on /ciel-improve, /ciel-eval, /ciel-create-skill. Analyzes recent sessions, runs evaluations, proposes skill improvements for user approval. Never rewrites autonomously."
4
4
  tools: Read, Write, Edit, Grep, Glob, Bash
5
-
5
+ memory: project
6
+ permissionMode: plan
7
+ maxTurns: 30
6
8
  ---
7
9
 
8
10
  You are the **Ciel Improver** -- a long-running meta-agent that analyzes Ciel's own performance and proposes concrete improvements. Your isolation is your value: you bring fresh, metric-driven eyes to Ciel itself.
@@ -17,6 +19,7 @@ You do NOT apply changes autonomously. You analyze, propose, and report.
17
19
 
18
20
  ## Rules
19
21
 
20
- - Never apply changes autonomously
22
+ - Never apply changes autonomously — `permissionMode: plan` enforces this
21
23
  - Warn if projected cost > 500k tokens
22
24
  - Preserve Ciel's core principles
25
+ - Keep proposals under 1000 tokens — concise analysis, not exhaustive reports
@@ -1,41 +1,101 @@
1
1
  ---
2
2
  name: ciel-researcher
3
- description: Isolated-context researcher for Ciel v5. Dispatch for RECHERCHE: official docs verification, anti-pattern detection, framework philosophy, version changelog, source credibility checks, anti-hallucination API validation. Use proactively for any documentation lookup or external knowledge task.
4
- tools: Read, Grep, Glob, Bash
3
+ description: "Isolated-context researcher for Ciel v7. Dispatch for RECHERCHE official docs verification, anti-pattern detection, framework philosophy, version changelog, source credibility checks. Receives domain skill names in dispatch prompt, reads SKILL.md files to apply domain expertise. Use for any documentation lookup or external knowledge task."
4
+ tools: Read, Grep, Glob, Bash, WebFetch, WebSearch
5
5
  disallowedTools: Write, Edit
6
- memory: user
7
- permissionMode: acceptEdits
6
+ memory: project
7
+ permissionMode: acceptEdits # read-only — do NOT remove Write/Edit from disallowedTools
8
8
  maxTurns: 20
9
- skills:
10
- - research-web-sources
11
- - research-github-issues
12
- - fact-check-claims
13
- - synthesize-findings
14
9
  ---
15
10
 
16
- You are the **Ciel Researcher v5** -- an isolated-context agent that gathers external knowledge with fresh eyes. Your isolation is your value: you have not seen the main session's reasoning, so you cannot inherit its assumptions.
11
+ You are the **Ciel Researcher v7** an isolated-context agent that gathers external knowledge with domain expertise. Your isolation is your value: you have not seen the main session's reasoning, so you cannot inherit its assumptions.
17
12
 
18
13
  You do NOT write code. You research, verify, and report.
19
14
 
20
- You have persistent memory (`memory: user`). Save:
21
- - API knowledge and patterns
22
- - Library version-specific caveats
23
- - Common anti-patterns you discover
15
+ ## Search strategy (MANDATORY — do not skip)
24
16
 
25
- ## Process (waterfall)
17
+ **The first search result is a clue, not an answer.** Research in 3 phases:
26
18
 
27
- 1. **Search official docs** via Bash `curl` or Read for the specific library+version
28
- 2. **Check version changelog** for breaking changes between versions:
29
- - npm: `npm view <pkg> versions --json`
30
- - Go: `go list -m -versions <module>`
31
- - Rust: `cargo search <crate>`
32
- - Python: `pip index versions <pkg>`
33
- 3. **Search GitHub issues** for known problems with the specific API
34
- 4. **Synthesize findings** into a structured report
19
+ ### Phase 1 Multi-angle queries (minimum 3 WebSearch calls)
20
+ Before synthesizing ANYTHING, search the same topic from at least 3 different angles:
21
+
22
+ | Question type | Required angles |
23
+ |---------------|----------------|
24
+ | **How-to** (implement X with Y) | 1. Official docs: `[library] [topic] official docs` 2. Version-specific: `[library] [version] [topic]` 3. Pitfalls: `[library] [topic] breaking changes OR migration` |
25
+ | **Bug** (error X with Y) | 1. Exact error: `"[error message]" [library]` 2. GitHub issues: `[library] [error keyword] issues` 3. Workaround: `[library] [topic] workaround OR fix` |
26
+ | **Version migration** (X Y) | 1. Changelog: `[library] [vX] to [vY] changelog` 2. Migration guide: `[library] migration guide [vX] [vY]` 3. Breaking changes: `[library] [vY] breaking changes` |
27
+ | **Pattern** (best way to X) | 1. Official recommendation: `[library] best practice [topic]` 2. Anti-patterns: `[library] [topic] anti-pattern OR avoid` 3. Real-world: `[library] [topic] production example` |
28
+ | **Security** (vulnerability X) | 1. CVE/advisory: `[library] [topic] CVE OR security advisory` 2. OWASP mapping: `[topic] OWASP` 3. Fix: `[library] [topic] patch OR mitigation` |
29
+
30
+ ### Phase 2 — Deep-read (minimum 2 WebFetch calls)
31
+ Search snippets are SEO summaries — they lie, omit caveats, or are outdated. For every factual claim you plan to report:
32
+ 1. WebFetch the most authoritative source found in Phase 1 (official docs first, then source repository)
33
+ 2. WebFetch a SECOND source that confirms or contradicts (community, changelog, issues)
34
+ 3. If both sources agree → report as fact. If they disagree → report both, flag as `[CONFLICT]`
35
+
36
+ ### Phase 3 — Iterative refinement
37
+ If Phase 1 returns poor results (irrelevant, outdated, or all from the same domain):
38
+ - Reformulate queries with different keywords (not just reordering)
39
+ - Remove version numbers to find foundational docs, then add them back to verify
40
+ - Search the library's GitHub issues directly: `site:github.com/[org]/[repo]/issues [topic]`
41
+
42
+ ## Process
43
+
44
+ ### 1. Load domain expertise
45
+ The dispatch prompt includes relevant domain skills (e.g., "Apply: database-design, sql"). Read those SKILL.md files FIRST:
46
+ - `.claude/skills/<name>/SKILL.md`
47
+ - Use their checklists + anti-patterns to focus your research on what matters.
48
+ - Skill anti-patterns tell you what to look for — use them as search angles.
49
+
50
+ ### 2. Execute search strategy
51
+ Follow the 3-phase strategy above. DO NOT skip phases. Every claim in your output must trace back to a WebFetch'd page, not a search snippet.
52
+
53
+ ### 3. Verify claims (anti-hallucination)
54
+ - Every API name, option, or parameter you report MUST appear in a WebFetch'd official doc page
55
+ - If you cannot verify a claim via WebFetch, mark it `[INCERTAIN: <reason>]`
56
+ - Distinguish between: official docs, community patterns, and your inference
57
+ - **Snippet rule**: WebSearch result snippets are DISCOVERY tools, not SOURCES. Never cite a snippet.
58
+
59
+ ### 4. Synthesize with domain lens
60
+ Apply the domain skill checklists to your findings:
61
+ - If `database-design` loaded → check: migration safety, indexing, FK constraints
62
+ - If `api-design` loaded → check: pagination, versioning, idempotency, rate limiting
63
+ - If `appsec` loaded → check: OWASP relevance, auth pattern, secret handling
35
64
 
36
65
  ## Output format
37
66
 
38
- Return ONLY structured output:
67
+ Return ONLY structured output. Budget by task depth (strict — the main session needs signal, not volume):
68
+
69
+ | Depth | Budget | Scope |
70
+ |-------|--------|-------|
71
+ | Trivial | 500 tokens | 1 section (FINDINGS only), 2-3 bullets |
72
+ | Standard | 1000 tokens | 3 sections max, 3-5 bullets each |
73
+ | Critical | 2000 tokens | All 5 sections, full detail |
74
+
39
75
  ```
40
- FINDINGS | VERSION CHANGELOG | ANTI-PATTERNS | API SURFACE | INCERTITUDES
76
+ ## FINDINGS
77
+ <key facts discovered, with source URLs (WebFetch'd pages, not search result links)>
78
+
79
+ ## VERSION CHANGELOG
80
+ <relevant breaking changes between installed and latest>
81
+
82
+ ## ANTI-PATTERNS
83
+ <domain-specific pitfalls found in research, mapped to skill anti-patterns if applicable>
84
+
85
+ ## API SURFACE
86
+ <verified API signatures, options, parameters — with doc references (page + section)>
87
+
88
+ ## INCERTITUDES
89
+ <claims that could not be verified + reason + what would be needed to verify>
41
90
  ```
91
+
92
+ ## Rules
93
+
94
+ - **Snippets are not sources.** WebFetch before you cite. No WebFetch = mark as UNCERTAIN.
95
+ - **3 angles minimum.** One search query = one perspective. Three queries = triangulation.
96
+ - **No citation = you don't know.** Every factual claim needs a URL to a fetched page.
97
+ - **Version first.** Always verify the installed version before researching.
98
+ - **Anti-patterns are your primary output.** Finding what NOT to do is more valuable than what to do.
99
+ - **Domain skills guide focus.** Don't research everything — research what the skill checklists flag.
100
+ - **Bad search results → reformulate.** Don't settle for poor results. Change keywords, change angle, change domain.
101
+ - **Output budget is a hard cap.** If you can't fit everything, prioritize: anti-patterns > findings > API surface > changelog > incertitudes.
@@ -2,8 +2,8 @@
2
2
  # CIEL SECURITY GATE: block destructive bash commands
3
3
  # exit 2 = block, exit 0 = allow
4
4
 
5
- INPUT=$(cat)
6
- COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // ""')
5
+ INPUT=$(cat 2>/dev/null || echo "{}")
6
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // ""' 2>/dev/null || echo "")
7
7
 
8
8
  if echo "$COMMAND" | grep -qiE 'rm\s+(-rf|--recursive|/-f)'; then
9
9
  echo "[CIEL SECURITY] Destructive command blocked: rm -rf" >&2
@@ -5,8 +5,8 @@
5
5
  # Remove or disable this hook if you find it intrusive:
6
6
  # jq 'del(.hooks.PreToolUse[0])' .claude/settings.json > tmp && mv tmp .claude/settings.json
7
7
 
8
- INPUT=$(cat)
9
- FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.filePath // ""')
8
+ INPUT=$(cat 2>/dev/null || echo "{}")
9
+ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.filePath // ""' 2>/dev/null || echo "")
10
10
 
11
11
  [ -z "$FILE_PATH" ] && exit 0
12
12
 
File without changes
@@ -302,27 +302,35 @@ def score_memory(mem, paths, symbols, intents, langs, prompt_lower="") -> int:
302
302
 
303
303
 
304
304
  def mark_stale_inplace(memories: dict, now: datetime) -> int:
305
- """Flag stale=True for memories past their stale_after_days threshold.
305
+ """Flag stale=True for memories past their Ebbinghaus-adjusted threshold.
306
306
 
307
307
  Returns count newly marked. Active memories that have never been triggered
308
308
  decay from captured_at; triggered memories from last_triggered.
309
309
 
310
- Future-dated anchors (clock skew, manual edit) are clamped to now → those
311
- memories are immune to staling, which matches user expectation that a
312
- just-captured memory shouldn't decay regardless of timestamp source.
310
+ Threshold scales with trigger_count using an Ebbinghaus-style forgetting
311
+ curve: well-triggered memories decay slower (stronger engrams). A memory
312
+ triggered 15+ times gets ~5x the base threshold (450 days vs 90).
313
+
314
+ Future-dated anchors (clock skew, manual edit) are clamped to now, making
315
+ those memories immune to staling regardless of timestamp source.
313
316
  """
314
317
  newly_stale = 0
315
318
  for mid, m in memories.items():
316
319
  if m.get('stale'):
317
320
  continue
318
321
  anchor = m.get('last_triggered') or m.get('captured_at')
319
- threshold = m.get('stale_after_days', 90)
322
+ base_threshold = m.get('stale_after_days', 90)
320
323
  if not anchor:
321
324
  continue
322
325
  try:
323
326
  then = datetime.fromisoformat(anchor.replace('Z', '+00:00'))
324
327
  age_days = max(0, (now - then).days)
325
- if age_days > threshold:
328
+ # Ebbinghaus-style strength factor: more triggers = slower decay.
329
+ # log2(1+count) gives: 0→1x, 1→2x, 3→3x, 7→4x, 15→5x
330
+ tc = max(0, m.get('trigger_count') or 0)
331
+ strength = 1.0 + math.log2(1 + tc)
332
+ effective_threshold = base_threshold * strength
333
+ if age_days > effective_threshold:
326
334
  m['stale'] = True
327
335
  newly_stale += 1
328
336
  except (ValueError, TypeError):
@@ -437,12 +445,28 @@ def cmd_query(args):
437
445
  mark_stale_inplace(mems, now)
438
446
 
439
447
  scored = []
440
- for mid, m in mems.items():
441
- if m.get('stale'):
442
- continue
443
- s = score_memory(m, paths, symbols, intents, langs, prompt_lower=prompt_lower)
444
- if s > 0:
445
- scored.append((s, mid, m))
448
+ # Language pre-filter: when prompt has language cues (e.g. ".ts" →
449
+ # "typescript"), skip memories tagged with non-matching languages.
450
+ # Language-agnostic memories (no language tags) always included.
451
+ # This is safe because score_memory's hard language gate would return 0
452
+ # for these memories anyway — we skip the path/symbol/intent scoring.
453
+ if langs:
454
+ langs_lower = {l.lower() for l in langs}
455
+ for mid, m in mems.items():
456
+ if m.get('stale'):
457
+ continue
458
+ mem_langs = m.get('languages') or []
459
+ if not mem_langs or any(l.lower() in langs_lower for l in mem_langs):
460
+ s = score_memory(m, paths, symbols, intents, langs, prompt_lower=prompt_lower)
461
+ if s > 0:
462
+ scored.append((s, mid, m))
463
+ else:
464
+ for mid, m in mems.items():
465
+ if m.get('stale'):
466
+ continue
467
+ s = score_memory(m, paths, symbols, intents, langs, prompt_lower=prompt_lower)
468
+ if s > 0:
469
+ scored.append((s, mid, m))
446
470
 
447
471
  if not scored:
448
472
  return idx
@@ -570,6 +594,19 @@ def cmd_rebuild_index(args):
570
594
  print(f"No memory directory at {base}", file=sys.stderr)
571
595
  sys.exit(1)
572
596
 
597
+ # Preserve trigger counts from existing index. cmd_query updates counts
598
+ # in the index but does not write back to episode frontmatter; rebuilding
599
+ # from scratch would lose all accumulated trigger history.
600
+ old_index = base / 'index.json'
601
+ old_mems = {}
602
+ if old_index.exists():
603
+ try:
604
+ with open(old_index) as f:
605
+ old_data = json.load(f)
606
+ old_mems = old_data.get('memories') or {}
607
+ except (json.JSONDecodeError, OSError):
608
+ pass
609
+
573
610
  idx = {
574
611
  "version": 2,
575
612
  "memories": {},
@@ -581,7 +618,7 @@ def cmd_rebuild_index(args):
581
618
 
582
619
  parsed = 0
583
620
  for mdfile in base.rglob('*.md'):
584
- if mdfile.name.lower() in ('readme.md', 'review-queue.md'):
621
+ if mdfile.name.lower() in ('readme.md', 'review-queue.md', 'insights.md'):
585
622
  continue
586
623
  try:
587
624
  content = mdfile.read_text(encoding='utf-8')
@@ -592,6 +629,15 @@ def cmd_rebuild_index(args):
592
629
  mid = fm.get('id')
593
630
  if not mid:
594
631
  continue
632
+ # Merge: keep the higher trigger_count between old index and file frontmatter
633
+ old = old_mems.get(mid) if old_mems else None
634
+ if old:
635
+ old_tc = old.get('trigger_count') or 0
636
+ file_tc = fm.get('trigger_count') or 0
637
+ fm['trigger_count'] = max(old_tc, file_tc)
638
+ old_lt = old.get('last_triggered')
639
+ if old_lt and not fm.get('last_triggered'):
640
+ fm['last_triggered'] = old_lt
595
641
  fm['file'] = str(mdfile.relative_to(base))
596
642
  idx['memories'][mid] = fm
597
643
  for path in fm.get('path_patterns') or []:
@@ -657,11 +703,11 @@ def cmd_capture(args):
657
703
  "symbols": symbols,
658
704
  "intents": intents,
659
705
  "captured_at": iso_now,
660
- "captured_from": "runtime",
706
+ "captured_from": args.captured_from or 'runtime',
661
707
  "source": args.source or 'manual capture',
662
708
  "trigger_count": 0,
663
709
  "last_triggered": None,
664
- "stale_after_days": "90",
710
+ "stale_after_days": 90,
665
711
  "stale": False,
666
712
  }
667
713
 
@@ -940,6 +986,26 @@ def cmd_analyze(args):
940
986
  insights_md = base / 'INSIGHTS.md'
941
987
  insights_md.write_text('\n'.join(lines), encoding='utf-8')
942
988
 
989
+ # Write review-queue.md when dead anchors exist so the memoire-consolidator
990
+ # skill has a concrete file to reference. Timestamped so re-runs don't wipe
991
+ # manual triage notes.
992
+ if dead_anchors:
993
+ rq = base / 'review-queue.md'
994
+ rq_lines = [
995
+ f"# Dead Anchor Review Queue",
996
+ f"",
997
+ f"_Generated {insights['generated_at']} by `memory-engine.py analyze`._",
998
+ f"",
999
+ f"Memories whose every `path_patterns` entry resolves to no file on disk.",
1000
+ f"Triage each entry: **promote** (update patterns), **demote** (set stale), or **delete**.",
1001
+ f"",
1002
+ ]
1003
+ for mid in dead_anchors:
1004
+ m = memories[mid]
1005
+ patterns = ", ".join(m.get('path_patterns') or [])
1006
+ rq_lines.append(f"- [ ] `{mid}` — {m.get('title', '?')} (patterns: {patterns})")
1007
+ rq.write_text('\n'.join(rq_lines) + '\n', encoding='utf-8')
1008
+
943
1009
  print(f"Insights written: {insights_json.relative_to(cwd)}, {insights_md.relative_to(cwd)}")
944
1010
  print(f" promotion_candidates: {len(promotion_candidates)}")
945
1011
  print(f" dead_anchors: {len(dead_anchors)}")
@@ -979,6 +1045,7 @@ def main():
979
1045
  cp.add_argument('--symbols', default=None, help='Comma-separated symbol names')
980
1046
  cp.add_argument('--languages', default=None, help='Comma-separated language tags')
981
1047
  cp.add_argument('--content', default=None, help='Memory body text (defaults to title)')
1048
+ cp.add_argument('--captured-from', default='runtime', help='Capture source (user-intervention, agent-observed, etc.)')
982
1049
  cp.add_argument('--type', default='episode', choices=['episode', 'concept', 'guard'], help='Memory type')
983
1050
  cp.add_argument('--cwd', default=None)
984
1051
  cp.set_defaults(func=cmd_capture)
@@ -0,0 +1,32 @@
1
+ #!/bin/bash
2
+ # Ciel — PostToolUse hook for Write/Edit
3
+ # Trigger: PostToolUse on Write|Edit
4
+ # Purpose: inject relire-critic dispatch instruction after code write
5
+ # Never blocks (exit 0 always)
6
+
7
+ INPUT=$(cat 2>/dev/null || echo "{}")
8
+
9
+ FILE_PATH=$(echo "$INPUT" | python3 -c "
10
+ import sys, json
11
+ try:
12
+ d = json.load(sys.stdin)
13
+ tip = d.get('tool_input', {})
14
+ print(tip.get('file_path', tip.get('path', '')))
15
+ except:
16
+ print('')
17
+ " 2>/dev/null || echo "")
18
+
19
+ [ -z "$FILE_PATH" ] && exit 0
20
+
21
+ # Skip non-code files
22
+ if ! echo "$FILE_PATH" | grep -qE '\.(kt|java|ts|tsx|js|jsx|py|go|rs|rb|php|cs|cpp|c|swift|scala|vue|svelte|sql)$'; then
23
+ exit 0
24
+ fi
25
+
26
+ # JSON-escape the file path (backslash and double-quote are the dangerous chars)
27
+ ESCAPED_PATH=$(echo "$FILE_PATH" | sed 's/\\/\\\\/g; s/"/\\"/g')
28
+
29
+ MSG="CIEL RELIRE OBLIGATOIRE — ${ESCAPED_PATH} vient d'etre ecrit. Invoke relire-critic skill now (inline for Trivial, or dispatch critic agent MODE=RELIRE for Standard/Critical with 3+ files). Required: 4 RISQUES (functional + imports + data assumptions + domain skill conformity) + FIX/ACCEPT/DEFER + 8-item checklist. Ne pas continuer avant le verdict."
30
+
31
+ echo "{\"hookSpecificOutput\": {\"hookEventName\": \"PostToolUse\", \"additionalContext\": \"$MSG\"}}"
32
+ exit 0
@@ -8,15 +8,14 @@
8
8
  # Escape hatch: include [CIEL_GATE_BYPASS] anywhere in the prompt to allow
9
9
  # a non-ciel agent through (e.g. legitimate one-off native dispatch).
10
10
 
11
- set -euo pipefail
11
+ set -uo pipefail
12
12
 
13
- input_json=""
14
- if [ ! -t 0 ]; then
15
- input_json=$(cat)
16
- fi
13
+ input_json=$(cat 2>/dev/null || echo "{}")
17
14
  [ -z "$input_json" ] && exit 0
18
15
 
19
- parsed=$(echo "$input_json" | python3 -c "
16
+ # Parse subagent_type and prompt head — prefer python3, fall back to grep
17
+ if command -v python3 &>/dev/null; then
18
+ parsed=$(echo "$input_json" | python3 -c "
20
19
  import json, sys
21
20
  try:
22
21
  d = json.load(sys.stdin)
@@ -27,6 +26,12 @@ try:
27
26
  except Exception:
28
27
  print('\t')
29
28
  " 2>/dev/null)
29
+ else
30
+ # Fallback: grep-based extraction (no python3 available)
31
+ subagent_type=$(echo "$input_json" | grep -o '"subagent_type"\s*:\s*"[^"]*"' | head -1 | sed 's/.*"subagent_type"\s*:\s*"\([^"]*\)".*/\1/' 2>/dev/null || echo "")
32
+ prompt_head=$(echo "$input_json" | grep -o '"prompt"\s*:\s*"[^"]*"' | head -1 | cut -c1-200 2>/dev/null || echo "")
33
+ parsed="${subagent_type}\t${prompt_head}"
34
+ fi
30
35
 
31
36
  subagent_type="${parsed%%$'\t'*}"
32
37
  prompt_head="${parsed#*$'\t'}"
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+ # Ciel — PreCompact hook
3
+ # Trigger: before context compaction
4
+ # Purpose: write .claude/session-progress.md + invoke learnings-capture skill
5
+ # Never blocks (exit 0 always)
6
+
7
+ INPUT=$(cat 2>/dev/null || echo "{}")
8
+ CWD=$(echo "$INPUT" | python3 -c "import sys, json; print(json.load(sys.stdin).get('cwd', ''))" 2>/dev/null || pwd)
9
+
10
+ MSG="CIEL PRE-COMPACT — Invoke memoire skill NOW to persist any user corrections + failure modes from this session to .ciel/memory/episodes/. Then write .claude/session-progress.md with: current status, completed tasks, **failed approaches + why they failed**, known limitations, next steps. Failed approaches field is critical — prevents dead-end loops in next session."
11
+
12
+ # PreCompact has no documented context-injection field. Use top-level
13
+ # systemMessage — valid for every hook, surfaces the reminder to the user.
14
+ python3 -c "
15
+ import json, sys
16
+ print(json.dumps({'systemMessage': sys.argv[1]}))
17
+ " "$MSG"
18
+ exit 0