cogsession 0.1.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.
Files changed (44) hide show
  1. cogsession-0.1.0/.cogsession.json.example +35 -0
  2. cogsession-0.1.0/.env.example +2 -0
  3. cogsession-0.1.0/.github/workflows/ci.yml +98 -0
  4. cogsession-0.1.0/.github/workflows/publish.yml +114 -0
  5. cogsession-0.1.0/.gitignore +41 -0
  6. cogsession-0.1.0/LICENSE +201 -0
  7. cogsession-0.1.0/PKG-INFO +542 -0
  8. cogsession-0.1.0/README.md +517 -0
  9. cogsession-0.1.0/claude_hooks/post_tool_use.sh +98 -0
  10. cogsession-0.1.0/claude_hooks/pre_compact.sh +46 -0
  11. cogsession-0.1.0/claude_hooks/pre_tool_use.sh +148 -0
  12. cogsession-0.1.0/claude_hooks/session_end.sh +44 -0
  13. cogsession-0.1.0/claude_hooks/statusline.sh +93 -0
  14. cogsession-0.1.0/claude_settings_template.json +57 -0
  15. cogsession-0.1.0/cogsession/__init__.py +2 -0
  16. cogsession-0.1.0/cogsession/claims.py +276 -0
  17. cogsession-0.1.0/cogsession/cli.py +142 -0
  18. cogsession-0.1.0/cogsession/config.py +102 -0
  19. cogsession-0.1.0/cogsession/distiller.py +96 -0
  20. cogsession-0.1.0/cogsession/hook_entry.py +354 -0
  21. cogsession-0.1.0/cogsession/injector.py +203 -0
  22. cogsession-0.1.0/cogsession/installer.py +126 -0
  23. cogsession-0.1.0/cogsession/journal.py +279 -0
  24. cogsession-0.1.0/cogsession/mcp/__init__.py +2 -0
  25. cogsession-0.1.0/cogsession/mcp/server.py +993 -0
  26. cogsession-0.1.0/cogsession/sensor.py +142 -0
  27. cogsession-0.1.0/cogsession/session/__init__.py +9 -0
  28. cogsession-0.1.0/cogsession/session/loader.py +339 -0
  29. cogsession-0.1.0/cogsession/session/models.py +316 -0
  30. cogsession-0.1.0/cogsession/session/writer.py +466 -0
  31. cogsession-0.1.0/docs/README.md +5 -0
  32. cogsession-0.1.0/docs/V2_DESIGN_NOTES.md +411 -0
  33. cogsession-0.1.0/docs/superpowers/specs/2026-08-13-cogsession-intelligent-memory-design.md +313 -0
  34. cogsession-0.1.0/pyproject.toml +58 -0
  35. cogsession-0.1.0/scripts/install.sh +43 -0
  36. cogsession-0.1.0/server.json +21 -0
  37. cogsession-0.1.0/tests/test_claims.py +186 -0
  38. cogsession-0.1.0/tests/test_cogsession_redesign.py +91 -0
  39. cogsession-0.1.0/tests/test_edge_cases.py +173 -0
  40. cogsession-0.1.0/tests/test_installer.py +147 -0
  41. cogsession-0.1.0/tests/test_journal.py +222 -0
  42. cogsession-0.1.0/tests/test_session_lifecycle.py +150 -0
  43. cogsession-0.1.0/tests/test_v2_foundations.py +194 -0
  44. cogsession-0.1.0/uv.lock +767 -0
@@ -0,0 +1,35 @@
1
+ {
2
+ "_comment": "CogSession project configuration. Place at project root.",
3
+
4
+ "enabled": true,
5
+
6
+ "features": {
7
+ "dead_ends": true,
8
+ "assumptions": true,
9
+ "token_map": true,
10
+ "error_graveyard": true,
11
+ "environment": true,
12
+ "file_cache": true,
13
+ "danger_zones": true,
14
+ "auto_diagram": true,
15
+ "auto_handoff": true,
16
+ "session_search": true
17
+ },
18
+
19
+ "thresholds": {
20
+ "warn_at": 65,
21
+ "alert_at": 75,
22
+ "checkpoint_at": 80
23
+ },
24
+
25
+ "autosave_every_n_tools": 10,
26
+
27
+ "exclude": [
28
+ "*.log", ".env", ".env.*",
29
+ "node_modules/", "__pycache__/",
30
+ ".git/", "*.pyc", "dist/", "build/",
31
+ "*.lock"
32
+ ],
33
+
34
+ "session_dir": ".cogsessions"
35
+ }
@@ -0,0 +1,2 @@
1
+ # Optional: disable CogSession for this environment when set to any value.
2
+ # COGSESSION_DISABLED=1
@@ -0,0 +1,98 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ # A second push to the same branch cancels the first. Nobody needs the result
9
+ # of a run for code that has already been replaced.
10
+ concurrency:
11
+ group: ci-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
14
+ jobs:
15
+ test:
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ # The floor and the ceiling. The floor is what pyproject promises to
21
+ # support, so it is the one that actually catches a regression; the
22
+ # ceiling catches deprecations before they become breakage.
23
+ python-version: ["3.11", "3.13"]
24
+
25
+ steps:
26
+ - uses: actions/checkout@v5
27
+
28
+ - name: Install uv
29
+ uses: astral-sh/setup-uv@v5
30
+ with:
31
+ enable-cache: true
32
+ python-version: ${{ matrix.python-version }}
33
+
34
+ - name: Install dependencies
35
+ run: uv sync --group dev
36
+
37
+ - name: Run tests
38
+ run: uv run pytest -q
39
+
40
+ package:
41
+ # Building here rather than only at release time. A packaging mistake that
42
+ # surfaces during a tagged release is the worst moment to find it, because
43
+ # a PyPI version can never be re-uploaded once taken.
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - uses: actions/checkout@v5
47
+
48
+ - name: Install uv
49
+ uses: astral-sh/setup-uv@v5
50
+ with:
51
+ enable-cache: true
52
+
53
+ - name: Build the distributions
54
+ run: uv build
55
+
56
+ - name: Check the package metadata
57
+ run: |
58
+ set -euo pipefail
59
+ python3 - <<'PY'
60
+ import glob, re, zipfile, sys
61
+
62
+ wheel = sorted(glob.glob("dist/*.whl"))[-1]
63
+ with zipfile.ZipFile(wheel) as z:
64
+ name = next(n for n in z.namelist() if n.endswith("METADATA"))
65
+ meta = z.read(name).decode()
66
+
67
+ problems = []
68
+
69
+ # The MCP Registry verifies ownership of a PyPI package by finding
70
+ # this marker in the package description. No marker, no listing —
71
+ # and the failure only shows up at publish time, which is far too
72
+ # late to be discovering it.
73
+ if "mcp-name: io.github.premanand8800/cogsession" not in meta:
74
+ problems.append("the mcp-name marker is missing from the package description")
75
+
76
+ if "Description-Content-Type" not in meta:
77
+ problems.append("the README is not in the package metadata")
78
+
79
+ # pytest was once a runtime dependency, so installing this dragged a
80
+ # test framework into the user's environment.
81
+ for banned in ("pytest", "pytest-asyncio"):
82
+ if re.search(rf"^Requires-Dist: {banned}\b", meta, re.M):
83
+ problems.append(f"{banned} is a runtime dependency and should not be")
84
+
85
+ if problems:
86
+ print("Package metadata is not publishable:")
87
+ for p in problems:
88
+ print(f" - {p}")
89
+ sys.exit(1)
90
+
91
+ print("Package metadata looks publishable.")
92
+ PY
93
+
94
+ - name: Keep the built distributions
95
+ uses: actions/upload-artifact@v4
96
+ with:
97
+ name: dist
98
+ path: dist/
@@ -0,0 +1,114 @@
1
+ name: Publish
2
+
3
+ # Publishing is triggered by a version tag and nothing else. Not by a push to
4
+ # main, because a PyPI version can never be re-uploaded once taken, and an
5
+ # accidental release is not something you can undo.
6
+ on:
7
+ push:
8
+ tags: ["v*"]
9
+
10
+ jobs:
11
+ # Never publish something that has not passed. A tag is not a promise that
12
+ # the code works; the tests are.
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v5
17
+ - uses: astral-sh/setup-uv@v5
18
+ with:
19
+ enable-cache: true
20
+ python-version: "3.11"
21
+ - run: uv sync --group dev
22
+ - run: uv run pytest -q
23
+
24
+ pypi:
25
+ needs: test
26
+ runs-on: ubuntu-latest
27
+ environment:
28
+ name: pypi
29
+ url: https://pypi.org/p/cogsession
30
+ permissions:
31
+ # The whole point: PyPI Trusted Publishing exchanges this short-lived
32
+ # OIDC token for upload rights. There is no API token to create, store,
33
+ # leak or rotate — the repository itself is the credential.
34
+ id-token: write
35
+ contents: read
36
+
37
+ steps:
38
+ - uses: actions/checkout@v5
39
+
40
+ - uses: astral-sh/setup-uv@v5
41
+ with:
42
+ enable-cache: true
43
+ python-version: "3.11"
44
+
45
+ - name: Refuse to publish if the tag disagrees with the package
46
+ run: |
47
+ set -euo pipefail
48
+ TAG="${GITHUB_REF#refs/tags/v}"
49
+ PKG=$(grep -m1 '^version' pyproject.toml | cut -d'"' -f2)
50
+ SRV=$(python3 -c "import json;print(json.load(open('server.json'))['version'])")
51
+ echo "tag=$TAG pyproject=$PKG server.json=$SRV"
52
+ if [ "$TAG" != "$PKG" ] || [ "$TAG" != "$SRV" ]; then
53
+ echo "::error::Version mismatch. Tag, pyproject.toml and server.json must agree."
54
+ echo "Publishing a mismatched version is unrecoverable: PyPI never lets that"
55
+ echo "version be re-uploaded, and the registry would point at a package that"
56
+ echo "does not exist."
57
+ exit 1
58
+ fi
59
+
60
+ - name: Build
61
+ run: uv build
62
+
63
+ - name: Publish to PyPI
64
+ uses: pypa/gh-action-pypi-publish@release/v1
65
+
66
+ registry:
67
+ # Strictly after PyPI. The registry validates that the package it is being
68
+ # told about actually exists and carries the ownership marker, so the
69
+ # order is a requirement rather than a preference.
70
+ needs: pypi
71
+ runs-on: ubuntu-latest
72
+ permissions:
73
+ id-token: write # OIDC again — no PAT, no stored secret
74
+ contents: read
75
+
76
+ steps:
77
+ - uses: actions/checkout@v5
78
+
79
+ - name: Install mcp-publisher
80
+ run: |
81
+ set -euo pipefail
82
+ curl -fsSL "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" \
83
+ | tar xz mcp-publisher
84
+
85
+ - name: Wait for PyPI to serve the new version
86
+ # PyPI's index is not instantaneous, and the registry's validation
87
+ # fetches the package. Publishing straight after upload can fail on a
88
+ # version that is genuinely there, which reads as a real error and is not.
89
+ run: |
90
+ set -euo pipefail
91
+ VERSION="${GITHUB_REF#refs/tags/v}"
92
+ for attempt in $(seq 1 10); do
93
+ if curl -fsS "https://pypi.org/pypi/cogsession/$VERSION/json" > /dev/null; then
94
+ echo "cogsession $VERSION is live on PyPI"
95
+ exit 0
96
+ fi
97
+ echo "attempt $attempt: not visible yet, waiting"
98
+ sleep 15
99
+ done
100
+ echo "::error::cogsession $VERSION never appeared on PyPI"
101
+ exit 1
102
+
103
+ - name: Authenticate to the MCP Registry
104
+ run: ./mcp-publisher login github-oidc
105
+
106
+ - name: Publish to the MCP Registry
107
+ run: ./mcp-publisher publish
108
+
109
+ - name: Confirm it is listed
110
+ run: |
111
+ set -euo pipefail
112
+ sleep 5
113
+ curl -fsS "https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.premanand8800/cogsession" \
114
+ | tee /dev/stderr | grep -q "cogsession"
@@ -0,0 +1,41 @@
1
+ # Environment
2
+ .env
3
+ .env.*
4
+ !.env.example
5
+ !.cogsession.json.example
6
+ .cogsession.json
7
+
8
+ # Python
9
+ __pycache__/
10
+ *.pyc
11
+ *.pyo
12
+ .pytest_cache/
13
+ .ruff_cache/
14
+ .mypy_cache/
15
+ .venv/
16
+ venv/
17
+ *.egg-info/
18
+ dist/
19
+ build/
20
+
21
+ # CogMem specific
22
+ cogmem.db
23
+ *.db
24
+ *.db-shm
25
+ *.db-wal
26
+ *.sqlite
27
+ *.sqlite3
28
+
29
+ # CogSession specific
30
+ .cogsessions/
31
+
32
+ # IDE
33
+ .idea/
34
+ /.vscode/
35
+ *.swp
36
+ .codex/
37
+ .agents/
38
+
39
+ # OS
40
+ .DS_Store
41
+ Thumbs.db
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.