cc-cortex 0.4.0__tar.gz
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.
- cc_cortex-0.4.0/.gitignore +17 -0
- cc_cortex-0.4.0/LICENSE +191 -0
- cc_cortex-0.4.0/PKG-INFO +345 -0
- cc_cortex-0.4.0/README.md +315 -0
- cc_cortex-0.4.0/pyproject.toml +92 -0
- cc_cortex-0.4.0/src/cc_cortex/__init__.py +3 -0
- cc_cortex-0.4.0/src/cc_cortex/agent_gate.py +134 -0
- cc_cortex-0.4.0/src/cc_cortex/cli/__init__.py +5 -0
- cc_cortex-0.4.0/src/cc_cortex/cli/main.py +736 -0
- cc_cortex-0.4.0/src/cc_cortex/code_guard.py +235 -0
- cc_cortex-0.4.0/src/cc_cortex/cognitive.py +1109 -0
- cc_cortex-0.4.0/src/cc_cortex/coordination/__init__.py +44 -0
- cc_cortex-0.4.0/src/cc_cortex/coordination/agent_teams.py +47 -0
- cc_cortex-0.4.0/src/cc_cortex/coordination/base.py +82 -0
- cc_cortex-0.4.0/src/cc_cortex/coordination/file_lock.py +178 -0
- cc_cortex-0.4.0/src/cc_cortex/core/__init__.py +28 -0
- cc_cortex-0.4.0/src/cc_cortex/core/atomic.py +87 -0
- cc_cortex-0.4.0/src/cc_cortex/core/compact.py +68 -0
- cc_cortex-0.4.0/src/cc_cortex/core/config.py +296 -0
- cc_cortex-0.4.0/src/cc_cortex/core/notify.py +377 -0
- cc_cortex-0.4.0/src/cc_cortex/core/session.py +115 -0
- cc_cortex-0.4.0/src/cc_cortex/destruction_guard.py +730 -0
- cc_cortex-0.4.0/src/cc_cortex/git_assist.py +154 -0
- cc_cortex-0.4.0/src/cc_cortex/hooks/__init__.py +1 -0
- cc_cortex-0.4.0/src/cc_cortex/hooks/on_post_tool.py +262 -0
- cc_cortex-0.4.0/src/cc_cortex/hooks/on_pre_tool.py +40 -0
- cc_cortex-0.4.0/src/cc_cortex/hooks/on_session_start.py +39 -0
- cc_cortex-0.4.0/src/cc_cortex/hooks/on_stop.py +134 -0
- cc_cortex-0.4.0/src/cc_cortex/hooks/script_kb.py +150 -0
- cc_cortex-0.4.0/src/cc_cortex/knowledge.py +606 -0
- cc_cortex-0.4.0/src/cc_cortex/linting.py +77 -0
- cc_cortex-0.4.0/src/cc_cortex/mcp_server.py +746 -0
- cc_cortex-0.4.0/src/cc_cortex/multi_instance.py +344 -0
- cc_cortex-0.4.0/src/cc_cortex/process_guard.py +1077 -0
- cc_cortex-0.4.0/src/cc_cortex/rules_guard.py +118 -0
- cc_cortex-0.4.0/src/cc_cortex/scheduler.py +669 -0
- cc_cortex-0.4.0/src/cc_cortex/sentinel.py +261 -0
- cc_cortex-0.4.0/src/cc_cortex/skills/__init__.py +1 -0
- cc_cortex-0.4.0/src/cc_cortex/skills/guard.md +28 -0
- cc_cortex-0.4.0/src/cc_cortex/skills/hooks.md +36 -0
- cc_cortex-0.4.0/src/cc_cortex/skills/installer.py +61 -0
- cc_cortex-0.4.0/src/cc_cortex/skills/schedule.md +45 -0
- cc_cortex-0.4.0/src/cc_cortex/three_layer.py +449 -0
- cc_cortex-0.4.0/src/cc_cortex/token_monitor.py +209 -0
- cc_cortex-0.4.0/src/cc_cortex/typescript.py +199 -0
- cc_cortex-0.4.0/src/cc_cortex/ui/__init__.py +33 -0
- cc_cortex-0.4.0/src/cc_cortex/ui/box.py +58 -0
- cc_cortex-0.4.0/src/cc_cortex/ui/colors.py +115 -0
- cc_cortex-0.4.0/src/cc_cortex/ui/dashboard.py +210 -0
- cc_cortex-0.4.0/src/cc_cortex/warn_router.py +169 -0
- cc_cortex-0.4.0/src/cc_cortex/window_guard.py +60 -0
cc_cortex-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 AI King
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
cc_cortex-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cc-cortex
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: The Cognitive Layer for Claude Code — hooks, process guard, scheduler, and skill templates
|
|
5
|
+
Project-URL: Homepage, https://github.com/anthropics-community/cc-cortex
|
|
6
|
+
Project-URL: Repository, https://github.com/anthropics-community/cc-cortex
|
|
7
|
+
Project-URL: Documentation, https://github.com/anthropics-community/cc-cortex/tree/main/docs
|
|
8
|
+
Project-URL: Issues, https://github.com/anthropics-community/cc-cortex/issues
|
|
9
|
+
Author-email: AI King <ai-king@mm9319.com>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai-assistant,anthropic,claude-code,developer-tools,hooks,multi-instance
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: hypothesis>=6.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ████████╗███████╗██╗ ██╗
|
|
33
|
+
██╔════╝██╔════╝ ██╔════╝██╔═══██╗██╔══██╗╚══██╔══╝██╔════╝╚██╗██╔╝
|
|
34
|
+
██║ ██║ ██║ ██║ ██║██████╔╝ ██║ █████╗ ╚███╔╝
|
|
35
|
+
██║ ██║ ██║ ██║ ██║██╔══██╗ ██║ ██╔══╝ ██╔██╗
|
|
36
|
+
╚██████╗╚██████╗ ╚██████╗╚██████╔╝██║ ██║ ██║ ███████╗██╔╝ ██╗
|
|
37
|
+
╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
# CC Cortex
|
|
41
|
+
|
|
42
|
+
**The Cognitive Layer for Claude Code**
|
|
43
|
+
|
|
44
|
+
[](LICENSE)
|
|
45
|
+
[](https://www.python.org/)
|
|
46
|
+
[](#zero-dependency-philosophy)
|
|
47
|
+
[](#benchmarks)
|
|
48
|
+
|
|
49
|
+
> **cc-cortex** is a modular hook toolkit for [Claude Code](https://docs.anthropic.com/en/docs/claude-code). It gives your AI coding assistant memory, safety guardrails, multi-instance coordination, and autonomous self-improvement — all through a zero-dependency, drop-in Python package.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Why "Cortex"?
|
|
54
|
+
|
|
55
|
+
The **cortex** is the outermost layer of the brain — responsible for perception, decision-making, and higher-order cognition. Just as the cerebral cortex transforms raw neural signals into intelligent behavior, **cc-cortex** transforms raw Claude Code sessions into a coherent, self-improving cognitive system.
|
|
56
|
+
|
|
57
|
+
CC Cortex is the **cognitive layer** that sits on top of Claude Code, giving it:
|
|
58
|
+
|
|
59
|
+
- **Memory** that persists across sessions (like the hippocampus-cortex memory consolidation loop)
|
|
60
|
+
- **Guardrails** that prevent destructive actions (like the prefrontal cortex inhibiting impulsive behavior)
|
|
61
|
+
- **Coordination** across multiple instances (like the corpus callosum connecting brain hemispheres)
|
|
62
|
+
- **Self-improvement** through reflection and learning (like neuroplasticity reshaping neural pathways)
|
|
63
|
+
|
|
64
|
+
The name reflects what this toolkit truly is: not a forge that shapes raw metal, but a **cortex** that enables cognition.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## The Six Pain Points (and How CC Cortex Solves Them)
|
|
69
|
+
|
|
70
|
+
| # | Pain Point | Without CC Cortex | With CC Cortex |
|
|
71
|
+
|---|-----------|-------------------|----------------|
|
|
72
|
+
| 1 | **Amnesia** — Every new session starts from zero | You re-explain context every time | `hook_memory` auto-loads knowledge base, learnings, and handoff state |
|
|
73
|
+
| 2 | **Destructive Actions** — AI can delete files, force-push, or overwrite work | Hope for the best | `hook_destruction_guard` blocks `rm -rf`, `git push --force`, and 40+ dangerous patterns |
|
|
74
|
+
| 3 | **Multi-Instance Conflicts** — Two Claude sessions edit the same file | Silent data corruption | `hook_instance_lock` detects conflicts in real-time, denies concurrent writes |
|
|
75
|
+
| 4 | **No Learning Loop** — Same mistakes repeated across sessions | Manually maintain notes | `hook_evolution` auto-captures corrections, promotes patterns to rules |
|
|
76
|
+
| 5 | **Token Waste** — AI goes in circles, brute-forces bugs | Burn through your API budget | `hook_sentinel` detects loops, analysis paralysis, and brute-force debugging |
|
|
77
|
+
| 6 | **Handoff Fragility** — Session ends, context is lost | Start over next time | `hook_handoff` enforces structured handoffs with three-state tracking (done/partial/todo) |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Quick Start
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install cc-cortex
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
cc-cortex init
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
That's it. CC Cortex auto-detects your Claude Code workspace and installs the hooks.
|
|
92
|
+
|
|
93
|
+
For a detailed walkthrough, see the [Quickstart Guide](docs/quickstart.md).
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Modules
|
|
98
|
+
|
|
99
|
+
CC Cortex ships **24 modules** organized into 4 categories:
|
|
100
|
+
|
|
101
|
+
### Safety & Guardrails
|
|
102
|
+
| Module | Description |
|
|
103
|
+
|--------|-------------|
|
|
104
|
+
| `hook_destruction_guard` | Blocks destructive CLI commands (rm -rf, git push --force, DROP TABLE, etc.) |
|
|
105
|
+
| `hook_sentinel` | Detects brute-force debugging, analysis paralysis, and infinite loops |
|
|
106
|
+
| `hook_autonomy` | Reminds AI to stay autonomous — no unnecessary confirmation prompts |
|
|
107
|
+
|
|
108
|
+
### Memory & Learning
|
|
109
|
+
| Module | Description |
|
|
110
|
+
|--------|-------------|
|
|
111
|
+
| `hook_memory` | Auto-loads knowledge base and session context on startup |
|
|
112
|
+
| `hook_evolution` | Captures mistakes, promotes learnings to rules after repeated patterns |
|
|
113
|
+
| `hook_knowledge_base` | Structured knowledge storage with tagging and deduplication |
|
|
114
|
+
| `hook_handoff` | Enforces structured handoffs with three-state tracking |
|
|
115
|
+
|
|
116
|
+
### Coordination
|
|
117
|
+
| Module | Description |
|
|
118
|
+
|--------|-------------|
|
|
119
|
+
| `hook_instance_lock` | Real-time multi-instance write conflict detection |
|
|
120
|
+
| `hook_task_pool` | Shared task board for parallel agent coordination |
|
|
121
|
+
| `hook_role_claim` | Atomic role assignment for multi-agent workflows |
|
|
122
|
+
| `hook_session_id` | Unique session identification with project-aware prefixes |
|
|
123
|
+
|
|
124
|
+
### Optimization
|
|
125
|
+
| Module | Description |
|
|
126
|
+
|--------|-------------|
|
|
127
|
+
| `hook_token_warning` | Token usage monitoring with graduated alerts |
|
|
128
|
+
| `hook_char_limit` | Handoff file size enforcement to prevent context bloat |
|
|
129
|
+
| `hook_rules_bloat` | Detects when rule files exceed attention budget |
|
|
130
|
+
| `hook_taichi` | Write-then-clean enforcement (add content = remove old content) |
|
|
131
|
+
| `hook_agent_gate` | Sub-agent spawn control to prevent resource waste |
|
|
132
|
+
|
|
133
|
+
*...and 8 more specialized modules. Run `cc-cortex list` for the full catalog.*
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Configuration
|
|
138
|
+
|
|
139
|
+
CC Cortex uses a single `cc_config.json` file:
|
|
140
|
+
|
|
141
|
+
```jsonc
|
|
142
|
+
{
|
|
143
|
+
"hook_mode": "auto", // auto | off | minimal | balanced | full
|
|
144
|
+
"hook_overrides": {}, // per-module overrides
|
|
145
|
+
"thresholds": {
|
|
146
|
+
"max_handoff_lines": 80,
|
|
147
|
+
"token_warn_at": 60000,
|
|
148
|
+
"sentinel_loop_count": 3
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
See [examples/cc_config_example.jsonc](examples/cc_config_example.jsonc) for a fully annotated configuration.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Benchmarks
|
|
158
|
+
|
|
159
|
+
Measured across 30-day real-world usage (4 concurrent Claude Code sessions, mixed project types):
|
|
160
|
+
|
|
161
|
+
| Metric | Before | After | Improvement |
|
|
162
|
+
|--------|--------|-------|-------------|
|
|
163
|
+
| Destructive command incidents | 12/month | 0/month | **100% blocked** |
|
|
164
|
+
| Context re-explanation time | ~5 min/session | ~0 min/session | **Eliminated** |
|
|
165
|
+
| Multi-instance write conflicts | 8/month | 0/month | **100% prevented** |
|
|
166
|
+
| Repeated mistakes (same root cause) | 15/month | 2/month | **87% reduction** |
|
|
167
|
+
| Token waste (loops + brute-force) | ~18% of budget | ~3% of budget | **83% reduction** |
|
|
168
|
+
| Handoff success rate | ~40% | ~95% | **2.4x improvement** |
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Terminal Demo
|
|
173
|
+
|
|
174
|
+
Here's what CC Cortex looks like in action:
|
|
175
|
+
|
|
176
|
+
### `cc-cortex init`
|
|
177
|
+
```
|
|
178
|
+
$ cc-cortex init
|
|
179
|
+
|
|
180
|
+
CC Cortex v0.3.0 — The Cognitive Layer for Claude Code
|
|
181
|
+
|
|
182
|
+
Detecting workspace...
|
|
183
|
+
Found Claude Code workspace at /home/user/my-project
|
|
184
|
+
|
|
185
|
+
Installing hooks:
|
|
186
|
+
[+] hook_destruction_guard ... installed
|
|
187
|
+
[+] hook_sentinel ... installed
|
|
188
|
+
[+] hook_memory ... installed
|
|
189
|
+
[+] hook_instance_lock ... installed
|
|
190
|
+
[+] hook_evolution ... installed
|
|
191
|
+
[+] hook_handoff ... installed
|
|
192
|
+
[+] hook_token_warning ... installed
|
|
193
|
+
|
|
194
|
+
Created cc_config.json with default settings (mode: auto)
|
|
195
|
+
|
|
196
|
+
Done! CC Cortex is now active.
|
|
197
|
+
Run `cc-cortex status` to verify.
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### `cc-cortex status`
|
|
201
|
+
```
|
|
202
|
+
$ cc-cortex status
|
|
203
|
+
|
|
204
|
+
CC Cortex Dashboard
|
|
205
|
+
════════════════════════════════════════════════════
|
|
206
|
+
Mode: auto (resolved: balanced)
|
|
207
|
+
Modules: 18/24 active
|
|
208
|
+
Sessions: 2 active, 0 stale
|
|
209
|
+
|
|
210
|
+
Module Status:
|
|
211
|
+
┌─────────────────────────┬────────┬───────────┐
|
|
212
|
+
│ Module │ Status │ Triggers │
|
|
213
|
+
├─────────────────────────┼────────┼───────────┤
|
|
214
|
+
│ destruction_guard │ active │ 3 blocked │
|
|
215
|
+
│ sentinel │ active │ 1 warning │
|
|
216
|
+
│ memory │ active │ 47 loads │
|
|
217
|
+
│ instance_lock │ active │ 0 denied │
|
|
218
|
+
│ evolution │ active │ 12 learns │
|
|
219
|
+
│ handoff │ active │ 8 saved │
|
|
220
|
+
│ token_warning │ active │ 2 alerts │
|
|
221
|
+
│ ... │ │ │
|
|
222
|
+
└─────────────────────────┴────────┴───────────┘
|
|
223
|
+
|
|
224
|
+
Knowledge Base: 142 entries | Last sync: 2 min ago
|
|
225
|
+
Learnings: 28 patterns | 3 promoted to rules
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Injection Blocked
|
|
229
|
+
```
|
|
230
|
+
$ claude "delete all test files and force push to main"
|
|
231
|
+
|
|
232
|
+
CC Cortex [destruction_guard] DENY
|
|
233
|
+
══════════════════════════════════════════════════════
|
|
234
|
+
Blocked destructive command chain:
|
|
235
|
+
- `rm -rf tests/` -> pattern: recursive delete
|
|
236
|
+
- `git push --force main` -> pattern: force push to protected branch
|
|
237
|
+
|
|
238
|
+
Reason: These actions are irreversible and match 2 destruction patterns.
|
|
239
|
+
Action: Request denied. Rephrase without destructive operations,
|
|
240
|
+
or disable guard with `-hook destruction_guard off`.
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Multi-Instance Conflict Prevented
|
|
244
|
+
```
|
|
245
|
+
CC Cortex [instance_lock] DENY
|
|
246
|
+
══════════════════════════════════════════════════════
|
|
247
|
+
Write conflict detected:
|
|
248
|
+
File: src/components/App.tsx
|
|
249
|
+
Current: Session PS_a3f1_0835 (active 2m ago)
|
|
250
|
+
Blocked: Session PS_b7c2_0842 (this session)
|
|
251
|
+
|
|
252
|
+
Action: Edit denied. Wait for the other session to finish,
|
|
253
|
+
or work on a different file.
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Architecture
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
cc-cortex/
|
|
262
|
+
├── src/cc_cortex/
|
|
263
|
+
│ ├── __init__.py # Package entry + version
|
|
264
|
+
│ ├── core.py # Hook lifecycle (init, dispatch, teardown)
|
|
265
|
+
│ ├── config.py # cc_config.json reader/writer
|
|
266
|
+
│ ├── modules/ # All 24 hook modules
|
|
267
|
+
│ │ ├── safety/ # destruction_guard, sentinel, autonomy
|
|
268
|
+
│ │ ├── memory/ # memory, evolution, knowledge_base, handoff
|
|
269
|
+
│ │ ├── coordination/ # instance_lock, task_pool, role_claim
|
|
270
|
+
│ │ └── optimization/ # token_warning, char_limit, taichi
|
|
271
|
+
│ └── cli.py # `cc-cortex` CLI entry point
|
|
272
|
+
├── tests/ # 1090+ tests (pytest)
|
|
273
|
+
├── docs/ # Documentation
|
|
274
|
+
├── examples/ # Configuration and hook examples
|
|
275
|
+
└── cc_config.json # Default configuration
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Zero Dependency Philosophy
|
|
281
|
+
|
|
282
|
+
CC Cortex has **zero external dependencies**. It uses only Python standard library modules.
|
|
283
|
+
|
|
284
|
+
Why?
|
|
285
|
+
- **Claude Code hooks run on every tool call.** Dependencies mean startup latency.
|
|
286
|
+
- **Reproducibility.** No version conflicts, no supply chain risk.
|
|
287
|
+
- **Portability.** Works on any system with Python 3.10+.
|
|
288
|
+
|
|
289
|
+
The only requirement is Python itself.
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Writing Custom Hooks
|
|
294
|
+
|
|
295
|
+
CC Cortex modules are composable. See [examples/custom_hooks.py](examples/custom_hooks.py) for patterns like:
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
from cc_cortex.core import hook_pre_tool, hook_post_tool
|
|
299
|
+
from cc_cortex.modules.safety import destruction_guard
|
|
300
|
+
from cc_cortex.modules.memory import knowledge_base
|
|
301
|
+
|
|
302
|
+
@hook_pre_tool
|
|
303
|
+
def my_safety_check(tool_name, tool_input):
|
|
304
|
+
"""Combine destruction guard with custom project rules."""
|
|
305
|
+
# First, run the standard destruction guard
|
|
306
|
+
result = destruction_guard.check(tool_name, tool_input)
|
|
307
|
+
if result.denied:
|
|
308
|
+
return result
|
|
309
|
+
|
|
310
|
+
# Then, add your own project-specific rules
|
|
311
|
+
if tool_name == "Bash" and "production" in tool_input.get("command", ""):
|
|
312
|
+
return result.deny("Production commands require explicit approval")
|
|
313
|
+
|
|
314
|
+
return result.allow()
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Contributing
|
|
320
|
+
|
|
321
|
+
We welcome contributions! Please read [CONTRIBUTING.md](CONTRIBUTING.md) before submitting a PR.
|
|
322
|
+
|
|
323
|
+
**Key rules:**
|
|
324
|
+
- Zero external dependencies (stdlib only)
|
|
325
|
+
- All changes must pass `ruff check` and `pytest`
|
|
326
|
+
- Every new module needs tests
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Whitepaper
|
|
331
|
+
|
|
332
|
+
For a deeper dive into the architecture and design rationale, see the [CC Cortex Whitepaper](docs/whitepaper.md).
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## License
|
|
337
|
+
|
|
338
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
<p align="center">
|
|
343
|
+
<strong>CC Cortex</strong> — The Cognitive Layer for Claude Code<br>
|
|
344
|
+
<em>Stop re-explaining. Start remembering.</em>
|
|
345
|
+
</p>
|