cairnmap 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 (75) hide show
  1. cairnmap-0.1.0/.gitignore +29 -0
  2. cairnmap-0.1.0/CHANGELOG.md +49 -0
  3. cairnmap-0.1.0/LICENSE +202 -0
  4. cairnmap-0.1.0/NOTICE +6 -0
  5. cairnmap-0.1.0/PKG-INFO +352 -0
  6. cairnmap-0.1.0/README.md +319 -0
  7. cairnmap-0.1.0/pyproject.toml +82 -0
  8. cairnmap-0.1.0/src/cairn/__init__.py +3 -0
  9. cairnmap-0.1.0/src/cairn/__main__.py +3 -0
  10. cairnmap-0.1.0/src/cairn/authored_store.py +135 -0
  11. cairnmap-0.1.0/src/cairn/bench/__init__.py +0 -0
  12. cairnmap-0.1.0/src/cairn/bench/conditions.py +60 -0
  13. cairnmap-0.1.0/src/cairn/bench/grading.py +119 -0
  14. cairnmap-0.1.0/src/cairn/bench/report.py +76 -0
  15. cairnmap-0.1.0/src/cairn/bench/run.py +77 -0
  16. cairnmap-0.1.0/src/cairn/bench/runner.py +176 -0
  17. cairnmap-0.1.0/src/cairn/bench/suite.py +34 -0
  18. cairnmap-0.1.0/src/cairn/bench/workspace.py +29 -0
  19. cairnmap-0.1.0/src/cairn/cli.py +445 -0
  20. cairnmap-0.1.0/src/cairn/config.py +16 -0
  21. cairnmap-0.1.0/src/cairn/detectors/__init__.py +21 -0
  22. cairnmap-0.1.0/src/cairn/detectors/base.py +120 -0
  23. cairnmap-0.1.0/src/cairn/detectors/database.py +304 -0
  24. cairnmap-0.1.0/src/cairn/detectors/docs.py +74 -0
  25. cairnmap-0.1.0/src/cairn/detectors/identity.py +147 -0
  26. cairnmap-0.1.0/src/cairn/detectors/manifests.py +124 -0
  27. cairnmap-0.1.0/src/cairn/detectors/packages.py +102 -0
  28. cairnmap-0.1.0/src/cairn/detectors/pathrefs.py +54 -0
  29. cairnmap-0.1.0/src/cairn/detectors/profile.py +215 -0
  30. cairnmap-0.1.0/src/cairn/discover/__init__.py +0 -0
  31. cairnmap-0.1.0/src/cairn/discover/files.py +162 -0
  32. cairnmap-0.1.0/src/cairn/discover/git.py +173 -0
  33. cairnmap-0.1.0/src/cairn/discover/proc.py +69 -0
  34. cairnmap-0.1.0/src/cairn/discover/repos.py +143 -0
  35. cairnmap-0.1.0/src/cairn/emit.py +43 -0
  36. cairnmap-0.1.0/src/cairn/errors.py +18 -0
  37. cairnmap-0.1.0/src/cairn/integrations/__init__.py +0 -0
  38. cairnmap-0.1.0/src/cairn/integrations/claude.py +84 -0
  39. cairnmap-0.1.0/src/cairn/integrations/config_files.py +187 -0
  40. cairnmap-0.1.0/src/cairn/integrations/content.py +54 -0
  41. cairnmap-0.1.0/src/cairn/integrations/git_hooks.py +153 -0
  42. cairnmap-0.1.0/src/cairn/integrations/harnesses.py +230 -0
  43. cairnmap-0.1.0/src/cairn/integrations/homes.py +31 -0
  44. cairnmap-0.1.0/src/cairn/integrations/registry.py +65 -0
  45. cairnmap-0.1.0/src/cairn/integrations/server_command.py +48 -0
  46. cairnmap-0.1.0/src/cairn/load.py +54 -0
  47. cairnmap-0.1.0/src/cairn/match/__init__.py +0 -0
  48. cairnmap-0.1.0/src/cairn/match/matcher.py +323 -0
  49. cairnmap-0.1.0/src/cairn/match/overrides.py +106 -0
  50. cairnmap-0.1.0/src/cairn/match/scoring.py +47 -0
  51. cairnmap-0.1.0/src/cairn/mcp_server/__init__.py +0 -0
  52. cairnmap-0.1.0/src/cairn/mcp_server/server.py +113 -0
  53. cairnmap-0.1.0/src/cairn/mcp_server/tools.py +190 -0
  54. cairnmap-0.1.0/src/cairn/model/__init__.py +0 -0
  55. cairnmap-0.1.0/src/cairn/model/graph.py +163 -0
  56. cairnmap-0.1.0/src/cairn/model/overrides.py +38 -0
  57. cairnmap-0.1.0/src/cairn/paths.py +45 -0
  58. cairnmap-0.1.0/src/cairn/py.typed +0 -0
  59. cairnmap-0.1.0/src/cairn/render/__init__.py +0 -0
  60. cairnmap-0.1.0/src/cairn/render/card.py +176 -0
  61. cairnmap-0.1.0/src/cairn/render/index.py +113 -0
  62. cairnmap-0.1.0/src/cairn/render/markers.py +58 -0
  63. cairnmap-0.1.0/src/cairn/render/tokens.py +7 -0
  64. cairnmap-0.1.0/src/cairn/resolve.py +102 -0
  65. cairnmap-0.1.0/src/cairn/scan.py +253 -0
  66. cairnmap-0.1.0/src/cairn/scan_cache.py +99 -0
  67. cairnmap-0.1.0/src/cairn/scan_log.py +24 -0
  68. cairnmap-0.1.0/src/cairn/security/__init__.py +0 -0
  69. cairnmap-0.1.0/src/cairn/security/policy.py +52 -0
  70. cairnmap-0.1.0/src/cairn/security/redact.py +78 -0
  71. cairnmap-0.1.0/src/cairn/security/text.py +29 -0
  72. cairnmap-0.1.0/src/cairn/store/__init__.py +0 -0
  73. cairnmap-0.1.0/src/cairn/store/atomic.py +68 -0
  74. cairnmap-0.1.0/src/cairn/store/lock.py +115 -0
  75. cairnmap-0.1.0/src/cairn/store/workspace_store.py +29 -0
@@ -0,0 +1,29 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ dist/
5
+ .coverage
6
+ coverage.xml
7
+ htmlcov/
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ /.cairn/
11
+ .superpowers/
12
+ bench/results/
13
+
14
+ # OS and editor files
15
+ .DS_Store
16
+ Thumbs.db
17
+ .idea/
18
+ .vscode/
19
+
20
+ # Build output
21
+ build/
22
+ *.egg-info/
23
+ .mypy_cache/
24
+
25
+ # Never commit secrets
26
+ .env
27
+
28
+ # Internal planning docs (kept locally, not published)
29
+ docs/superpowers/
@@ -0,0 +1,49 @@
1
+ # Changelog
2
+
3
+ All notable changes to cairn are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and cairn uses
5
+ [Semantic Versioning](https://semver.org/). Until 1.0, minor versions may change the map format;
6
+ `.cairn/authored/` and `.cairn/relations.yaml` (what you write) stay compatible.
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0]
11
+
12
+ First public release.
13
+
14
+ ### Added
15
+ - **The map.** `cairn scan` maps every git repo under a folder into `.cairn/`:
16
+ - `INDEX.md` lists every repo in about 30 tokens per repo and is always loaded;
17
+ - each repo gets a card under `cards/<repo>.md`, read on demand;
18
+ - `workspace.json` holds the full graph.
19
+ - **Relationships.** cairn finds links from shared packages, shared database tables, `../` path
20
+ references, and documentation mentions. Each link is tagged `extracted`, `inferred`, or
21
+ `ambiguous`.
22
+ - **Settling links.** `cairn status` lists unconfirmed links. `cairn annotate-edge` confirms or
23
+ rejects them, and `cairn set-summary` saves a summary for a repo; both decisions survive
24
+ re-scans.
25
+ - **Agent integrations.** `cairn install claude|codex|gemini|cursor|all` sets up each harness: the
26
+ index, a `/cairn` skill or command, and the cairn MCP server.
27
+ - The MCP server's tools are `resolve_repo`, `repo_card`, `related`, `find_across`, `query`, and
28
+ `refresh`.
29
+ - **Freshness.**
30
+ - `cairn refresh` re-reads only the repos that changed.
31
+ - `cairn scan --full` re-reads everything.
32
+ - Opt-in git hooks (`cairn hooks install`) refresh the map after commits and merges.
33
+ - Summaries that may be stale are flagged.
34
+ - **Benchmarks.** `cairn bench` runs headless Claude Code under five conditions, from no map to the
35
+ map plus MCP, and grades the answers deterministically. It ships with two suites:
36
+ - `shopverse` (6 repos);
37
+ - `fleetline` (15 repos).
38
+ - `cairn --version` prints the cairn, Python, platform, and mcp versions.
39
+
40
+ ### Security
41
+ - Text from scanned repos is treated as data:
42
+ - README text stays out of always-loaded context;
43
+ - folder and package names are flattened, capped, and stripped of markers, so they can't break
44
+ cairn's marked blocks.
45
+ - cairn never reads through symlinks or junctions inside a repo, never opens `.env` files or
46
+ credential files, and redacts common secret formats from every snippet it stores.
47
+ - Git calls disable `core.fsmonitor`, hooks, and the repo's own filters, and take no optional
48
+ locks.
49
+ - A map committed inside a repo is never served.
cairnmap-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
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 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 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 those 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
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
cairnmap-0.1.0/NOTICE ADDED
@@ -0,0 +1,6 @@
1
+ cairn
2
+ Copyright 2026 The cairn authors
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+ No third-party source code is vendored at this time. Any future vendored code
6
+ will be listed here with its original copyright and license notice.
@@ -0,0 +1,352 @@
1
+ Metadata-Version: 2.5
2
+ Name: cairnmap
3
+ Version: 0.1.0
4
+ Summary: A workspace map for coding agents: every repo in a folder, how they connect, and where to look.
5
+ Project-URL: Homepage, https://github.com/Moe1177/cairn
6
+ Project-URL: Source, https://github.com/Moe1177/cairn
7
+ Project-URL: Issues, https://github.com/Moe1177/cairn/issues
8
+ Project-URL: Changelog, https://github.com/Moe1177/cairn/blob/main/CHANGELOG.md
9
+ Author: The cairn authors
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: ai-agents,claude-code,codex,cursor,knowledge-graph,mcp,microservices,monorepo
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Environment :: Console
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Software Development
24
+ Classifier: Topic :: Software Development :: Documentation
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.11
27
+ Requires-Dist: mcp<3,>=2.3
28
+ Requires-Dist: pathspec>=0.12
29
+ Requires-Dist: pydantic>=2.11
30
+ Requires-Dist: pyyaml>=6.0.2
31
+ Requires-Dist: typer>=0.16
32
+ Description-Content-Type: text/markdown
33
+
34
+ # cairn
35
+
36
+ [![CI](https://github.com/Moe1177/cairn/actions/workflows/ci.yml/badge.svg)](https://github.com/Moe1177/cairn/actions/workflows/ci.yml)
37
+ [![PyPI](https://img.shields.io/pypi/v/cairnmap)](https://pypi.org/project/cairnmap/)
38
+ [![Python](https://img.shields.io/pypi/pyversions/cairnmap)](https://pypi.org/project/cairnmap/)
39
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/Moe1177/cairn/blob/main/LICENSE)
40
+
41
+ **A map of all your repos for coding agents.** cairn scans every git repo in a folder once, works
42
+ out how they connect, and gives your agent:
43
+ - a tiny always-loaded index;
44
+ - a short card per repo.
45
+
46
+ The agent knows where things live without re-exploring.
47
+
48
+ > Cairns are the stacked-stone markers that guide hikers along a trail. cairn leaves small, cheap
49
+ > markers that guide coding agents to the right repo, and then to the right file.
50
+
51
+ Works with **Claude Code, Codex, Gemini CLI, and Cursor**, on **Windows, macOS, and Linux**.
52
+
53
+ ---
54
+
55
+ ## Why
56
+
57
+ Coding agents work inside one repo. Real work spans many: a web app, an API, a shared types
58
+ package, a payments service, a reporting job. Say *"add a tip amount to trips end to end"* and the
59
+ agent has to:
60
+ 1. discover that sibling repos exist;
61
+ 2. grep through all of them;
62
+ 3. read a pile of files;
63
+ 4. guess which service owns the `trips` table.
64
+
65
+ That costs tokens and turns, and weaker models guess wrong.
66
+
67
+ Hand-maintained "related repos" docs help until they go stale. cairn builds that map from the code
68
+ itself and keeps it fresh:
69
+
70
+ ```
71
+ ~/code/ ~/code/.cairn/
72
+ ├── rider-web/ cairn ├── INDEX.md ← ~25 tokens per repo, always loaded
73
+ ├── trips-svc/ ─────▶ ├── cards/trips-svc.md ← read on demand (≤ 800 tokens)
74
+ ├── payments-svc/ scan ├── workspace.json ← the full graph
75
+ ├── analytics-etl/ └── authored/ ← your summaries and decisions
76
+ └── …
77
+ ```
78
+
79
+ ## What your agent sees
80
+
81
+ The **index** is a few lines, loaded into every session through `CLAUDE.md` or an equivalent:
82
+
83
+ ```markdown
84
+ # Workspace repos (cairn)
85
+ - admin-console (@fleetline/admin-console): Next.js back-office for ops staff; queries trips… · nextjs
86
+ - analytics-etl: Nightly SQL reporting jobs over trips, payments, drivers… · python
87
+ - payments-svc (payments): Go service that charges completed trips and records weekly payouts · go
88
+ - trips-svc: FastAPI service owning the trip lifecycle and the trips/trip_events tables · fastapi
89
+ - ui-kit (@fleetline/ui-kit): Shared React components (Button, Card) · react
90
+ ```
91
+
92
+ A **card** is read only when the agent needs that repo:
93
+
94
+ ```markdown
95
+ # trips-svc
96
+ > FastAPI service owning the trip lifecycle and the trips/trip_events tables.
97
+ `./trips-svc` · python, fastapi · HEAD 1fee22d
98
+
99
+ ## Relates
100
+ ← infra: references path trips-svc (extracted · infra/docker-compose.dev.yml:3)
101
+ → admin-console: shares tables trips (inferred · admin-console/lib/db.ts:4)
102
+ → analytics-etl: shares tables trips (inferred · analytics-etl/jobs/daily_revenue.sql:2)
103
+ → payments-svc: shares tables trips (inferred · payments-svc/internal/charge/charge.go:3)
104
+
105
+ ## Run
106
+ test `pytest`
107
+
108
+ ## Layout
109
+ app/ → routes/pages
110
+ migrations/ → DB migrations
111
+ ```
112
+
113
+ Every relationship comes with evidence (file and line) and a trust level:
114
+ - `extracted`: found directly, such as a package dependency or a path reference;
115
+ - `inferred`: strong signals, such as a table that only one repo creates;
116
+ - `ambiguous`: hidden until you confirm it.
117
+
118
+ ## Install
119
+
120
+ You need Python 3.11+ and git.
121
+
122
+ | Tool | Command |
123
+ |---|---|
124
+ | [uv](https://docs.astral.sh/uv/) (recommended) | `uv tool install cairnmap` |
125
+ | pipx | `pipx install cairnmap` |
126
+ | run once, no install | `uvx --from cairnmap cairn init` |
127
+ | pip | `pip install cairnmap` |
128
+
129
+ The package is called `cairnmap`; the command is `cairn`.
130
+
131
+ ## Quick start
132
+
133
+ ```bash
134
+ cd ~/code # the folder that CONTAINS your repos
135
+ cairn init # scan, then add the index to ./CLAUDE.md (asks first)
136
+ cairn install all # optional: Codex, Gemini CLI, Cursor, the /cairn skill, the MCP server
137
+ ```
138
+
139
+ Open your agent in any repo under that folder. It now knows about every sibling repo.
140
+
141
+ To give each repo a good one-line summary, run `/cairn` inside your agent. It writes the summaries
142
+ with `cairn set-summary` and settles uncertain links. Until then, the index says "no summary yet"
143
+ for that repo. README text is deliberately kept out of always-loaded context.
144
+
145
+ ## How to use it
146
+
147
+ ### Day to day
148
+
149
+ ```bash
150
+ cairn status # repos, relationships, unconfirmed links, missing/stale summaries
151
+ cairn refresh # re-read only repos that changed (fast)
152
+ cairn hooks install # optional: refresh automatically after each commit/merge
153
+ ```
154
+
155
+ ### Settle uncertain links once
156
+
157
+ ```bash
158
+ cairn annotate-edge "web->api:shares_db" --confirm
159
+ cairn annotate-edge "shop->blog:shares_db" --reject --why "different databases"
160
+ cairn set-summary payments-svc "Charges completed trips and pays drivers weekly." --alias payments
161
+ ```
162
+
163
+ These decisions live in `.cairn/authored/` and `.cairn/relations.yaml`. They survive every re-scan,
164
+ and you can commit them so your team shares them.
165
+
166
+ ### From your agent (MCP)
167
+
168
+ `cairn install <harness>` registers cairn's MCP server. Agents can call these tools:
169
+
170
+ | Tool | What it answers |
171
+ |---|---|
172
+ | `resolve_repo` | "Which repo is 'the payments service'?" |
173
+ | `repo_card` | The card for a repo (re-scanned first if its HEAD moved) |
174
+ | `related` | Everything connected to a repo, with evidence |
175
+ | `find_across` | Which repos expose or use a table, package, or path |
176
+ | `query` | Where to start looking inside a repo |
177
+ | `refresh` | Update the map now |
178
+
179
+ ### What cairn detects
180
+
181
+ | Signal | Examples |
182
+ |---|---|
183
+ | Package dependencies | npm (`workspace:*`, scoped packages), PyPI, Go modules, Cargo |
184
+ | Shared database tables | SQL migrations and queries, Prisma, Drizzle, Supabase |
185
+ | Path references | `../trips-svc` in docker-compose, tsconfig, and other config files |
186
+ | Documentation | READMEs and docs that mention a sibling repo |
187
+
188
+ Coming next: HTTP calls between services, infrastructure links, shared environment variables, and
189
+ packages inside monorepos.
190
+
191
+ ## Benchmarks
192
+
193
+ cairn ships a benchmark harness (`cairn bench`). It runs real tasks through headless Claude Code
194
+ under five conditions, each in a fresh, isolated copy of a multi-repo workspace:
195
+
196
+ | | Condition |
197
+ |---|---|
198
+ | **A** | No map (the agent explores) |
199
+ | **B** | A hand-written "related repos" doc |
200
+ | **C** | cairn's index only |
201
+ | **D** | Index + repo cards |
202
+ | **E** | D + cairn's MCP server |
203
+
204
+ Tasks cover:
205
+ - **orientation:** "who owns the trips table?";
206
+ - **localization:** "which files change to add a tip amount end to end?";
207
+ - **cross-repo impact:** "what breaks if `drivers.license_no` is renamed?";
208
+ - **control:** questions answerable within one repo.
209
+
210
+ Answers are graded deterministically on the files and facts they must name.
211
+
212
+ **First results** on two synthetic workspaces, `shopverse` (6 repos) and `fleetline` (15 repos):
213
+
214
+ | | Haiku 4.5 | Sonnet 5.5 | Opus 5.5 |
215
+ |---|---|---|---|
216
+ | Success, no map (A) | 89–96% | 100% | 100% |
217
+ | Success, cairn index (C) | **100%** | **100%** | **100%** |
218
+ | Best cairn cost vs no map | **−42%** (D) | **−24%** (C) | **−7%** (C) |
219
+
220
+ What this shows so far:
221
+ - **Weaker models gain accuracy.** Haiku went from missing 4–11% of tasks to 100%.
222
+ - **The index alone is the most reliable condition** on every model and suite.
223
+ - **Cost savings are modest on small workspaces.** Strong models with grep explore 6–15 small repos
224
+ in about 4 turns, and cairn's savings should grow with workspace size. These are first results:
225
+ 3 runs per cell, no significance testing yet. The Opus runs cover shopverse only.
226
+
227
+ Full tables, model ids, and caveats:
228
+ [bench/published](https://github.com/Moe1177/cairn/blob/main/bench/published/2026-10-05-shopverse-fleetline.md).
229
+
230
+ Run the benchmarks yourself from a source checkout. They use your Claude usage.
231
+
232
+ ```bash
233
+ cairn bench bench/suites/fleetline --runs 3 --model haiku
234
+ cairn bench bench/suites/shopverse --conditions A,C --tasks gift-message
235
+ ```
236
+
237
+ ## Safety and privacy
238
+
239
+ cairn treats every scanned repo as untrusted input. It:
240
+ - **never** modifies your repos, apart from the opt-in hooks and Cursor's `--per-repo` rule (both
241
+ marked blocks, removed cleanly);
242
+ - **never** opens `.env` files, private keys, or credential files, and never reads through a symlink
243
+ or junction inside a repo;
244
+ - **never** runs code from a repo: its git calls turn off fsmonitor, hooks, and the repo's own
245
+ filters.
246
+
247
+ It also:
248
+ - **redacts** common secret formats from every stored snippet, and stores git remotes without
249
+ credentials;
250
+ - **keeps README text out** of always-loaded context. Repo names that do appear are flattened and
251
+ capped, so they can't inject instructions or break cairn's blocks.
252
+
253
+ cairn makes **no network calls and collects no telemetry**. `cairn bench` is the only feature that
254
+ runs another program that does (the `claude` CLI).
255
+
256
+ See [SECURITY.md](https://github.com/Moe1177/cairn/blob/main/SECURITY.md) for the threat model and
257
+ how to report a vulnerability.
258
+
259
+ ## Reference
260
+
261
+ ### Commands
262
+
263
+ | Command | What it does |
264
+ |---|---|
265
+ | `cairn init` | Scan, then offer to add the index to Claude Code |
266
+ | `cairn scan [--full] [--verbose]` | Map every repo under the folder into `.cairn/` |
267
+ | `cairn refresh` | Re-read only repos whose HEAD or working tree changed |
268
+ | `cairn status` | What cairn knows, unconfirmed links, missing or stale summaries |
269
+ | `cairn annotate-edge KEY --confirm\|--reject [--why TEXT]` | Settle a relationship |
270
+ | `cairn set-summary REPO TEXT [--alias NAME]` | Save a summary (`-` reads stdin) |
271
+ | `cairn install <claude\|codex\|gemini\|cursor\|all>` | Load cairn into an agent harness |
272
+ | `cairn uninstall <name\|all>` | Remove it again |
273
+ | `cairn hooks install\|uninstall` | Opt-in git hooks that refresh after commits and merges |
274
+ | `cairn serve` | The MCP server (harnesses start it for you) |
275
+ | `cairn bench SUITE` | Run the benchmark harness |
276
+ | `cairn --version` | Versions of cairn, Python, the platform, and mcp |
277
+
278
+ **Exit codes:** `0` means success, `1` an error (one line on stderr), and `2` a usage error.
279
+
280
+ ### What cairn writes, and where
281
+
282
+ | Path | What it is |
283
+ |---|---|
284
+ | `<folder>/.cairn/INDEX.md` | One line per repo: name, aliases, summary, stack |
285
+ | `<folder>/.cairn/cards/<repo>.md` | One card per repo |
286
+ | `<folder>/.cairn/workspace.json` | The full graph |
287
+ | `<folder>/.cairn/cache/`, `logs/`, `.lock` | Scan cache, last scan log, lock file |
288
+ | `<folder>/.cairn/relations.yaml`, `authored/` | **Yours:** aliases, manual links, summaries, decisions |
289
+ | `<folder>/CLAUDE.md` | A marked block holding the index (`cairn install claude`) |
290
+ | `~/.claude/skills/cairn/` and Claude's user MCP config | `/cairn` skill and MCP server |
291
+ | `~/.codex/AGENTS.md`, `config.toml`, `skills/cairn/` | Codex pointer, MCP server, skill |
292
+ | `~/.gemini/GEMINI.md`, `settings.json`, `commands/cairn.toml` | Gemini CLI pointer, MCP server, command |
293
+ | `~/.cursor/mcp.json`, `commands/cairn.md` | Cursor MCP server and command |
294
+ | `<repo>/.git/hooks/post-commit`, `post-merge` | Only with `cairn hooks install` |
295
+ | `~/.cairn/registry.json`, `backups/` | Mapped workspaces; one private backup of each config file cairn first edited |
296
+
297
+ cairn only edits its own key or marked block in other tools' files, and refuses to touch a file it
298
+ can't parse.
299
+
300
+ ### Uninstall
301
+
302
+ ```bash
303
+ cairn uninstall all # harness entries, skills, commands, Cursor rules
304
+ cairn hooks uninstall # if you installed hooks
305
+ uv tool uninstall cairnmap # or: pipx uninstall cairnmap
306
+ ```
307
+
308
+ Then delete `<folder>/.cairn/` and `~/.cairn/`.
309
+
310
+ ### Troubleshooting
311
+
312
+ | Symptom | Fix |
313
+ |---|---|
314
+ | "No git repos found under …" | Run cairn from the folder that *contains* your repos |
315
+ | "… is inside the git repository …" | Same: run from the parent folder, not inside a repo |
316
+ | "git not found on PATH" warning | Install git; without it, remotes, HEAD and caching are off |
317
+ | "another cairn process is still updating this workspace" | A scan or hook refresh is running; retry in a moment |
318
+ | An agent says it can't find the workspace | Run `cairn init` in the workspace folder, then restart the agent session |
319
+ | `cairn install codex/gemini/cursor` refuses a config | That file isn't valid TOML/JSON; fix it and re-run (cairn never guesses) |
320
+ | Hooks did nothing | `cairn hooks install` lists the repos it skipped and why |
321
+
322
+ ## Roadmap
323
+
324
+ 1. ✅ Core map, precision pass, MCP server, harness integrations, freshness, benchmarks, release
325
+ hardening (0.1).
326
+ 2. HTTP, infrastructure and environment-variable relationships; packages inside monorepos.
327
+ 3. Deep per-repo queries via [graphify](https://github.com/Graphify-Labs/graphify).
328
+ 4. Larger benchmark suites (real open-source workspaces), significance testing, and more harnesses.
329
+
330
+ ## Contributing
331
+
332
+ Issues and pull requests are welcome. See
333
+ [CONTRIBUTING.md](https://github.com/Moe1177/cairn/blob/main/CONTRIBUTING.md) for setup and checks,
334
+ and the [changelog](https://github.com/Moe1177/cairn/blob/main/CHANGELOG.md) for what's new. By
335
+ participating you agree to the
336
+ [code of conduct](https://github.com/Moe1177/cairn/blob/main/CODE_OF_CONDUCT.md).
337
+
338
+ ## License
339
+
340
+ cairn is licensed under the **Apache License 2.0**: use it, modify it, and ship it, commercially
341
+ too. Keep the license and the [NOTICE](https://github.com/Moe1177/cairn/blob/main/NOTICE) file
342
+ with any redistribution. Full text: [LICENSE](https://github.com/Moe1177/cairn/blob/main/LICENSE).
343
+
344
+ Runtime dependencies and their licenses:
345
+
346
+ | Package | License |
347
+ |---|---|
348
+ | [typer](https://github.com/fastapi/typer) | MIT |
349
+ | [pydantic](https://github.com/pydantic/pydantic) | MIT |
350
+ | [PyYAML](https://github.com/yaml/pyyaml) | MIT |
351
+ | [pathspec](https://github.com/cpburnz/python-pathspec) | MPL-2.0 (used unmodified as a library) |
352
+ | [mcp](https://github.com/modelcontextprotocol/python-sdk) | MIT |