ctxfile 0.1.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.
- package/LICENSE +202 -0
- package/README.md +164 -0
- package/behaviors/canonical.md +54 -0
- package/behaviors/render/agents-md/SECTION.md +58 -0
- package/behaviors/render/claude-code/SKILL.md +59 -0
- package/behaviors/render/codex/instructions.md +58 -0
- package/behaviors/render/cursor/ctxfile.mdc +59 -0
- package/behaviors/render/generic/system-prompt.md +58 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +4181 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +3142 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +942 -0
- package/dist/index.d.ts +942 -0
- package/dist/index.js +3028 -0
- package/dist/index.js.map +1 -0
- package/manifest.json +36 -0
- package/package.json +73 -0
- package/ui-dist/assets/archivo-var-latin-BEIDiHaE.woff2 +0 -0
- package/ui-dist/assets/doto-var-latin-Y-BORX9o.woff2 +0 -0
- package/ui-dist/assets/index-CAydkgHR.css +1 -0
- package/ui-dist/assets/index-Do7dvee8.js +19 -0
- package/ui-dist/assets/plex-mono-400-latin-BJoXLJYV.woff2 +0 -0
- package/ui-dist/assets/plex-mono-500-latin-C820gu2e.woff2 +0 -0
- package/ui-dist/assets/plex-mono-600-latin-DpGnXj3s.woff2 +0 -0
- package/ui-dist/index.html +18 -0
package/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.
|
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# ctxfile
|
|
2
|
+
|
|
3
|
+
**Give any AI agent your project's full working state in one call — without your code ever leaving your machine.**
|
|
4
|
+
|
|
5
|
+
ctxfile is a local-first [MCP](https://modelcontextprotocol.io) server that snapshots a project's working state — plan documents, key files, git state, and optionally Notion pages and a local-LLM summary — into one structured context object, served over stdio to Claude Code, Cursor, Claude Desktop, or any MCP client.
|
|
6
|
+
|
|
7
|
+
## 30-second install
|
|
8
|
+
|
|
9
|
+
**Claude Code**
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
claude mcp add ctxfile -- npx -y ctxfile
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Cursor** — add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"ctxfile": {
|
|
21
|
+
"command": "npx",
|
|
22
|
+
"args": ["-y", "ctxfile"]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or click: [Add to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=ctxfile&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImN0eGZpbGUiXX0=)
|
|
29
|
+
|
|
30
|
+
**Claude Desktop** — download `ctxfile.mcpb` from the releases page and drag it into Settings → Extensions, or add the JSON above to `claude_desktop_config.json`.
|
|
31
|
+
|
|
32
|
+
## What you get
|
|
33
|
+
|
|
34
|
+
| Surface | What it returns |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `context://current` resource | Full `ContextObject` (JSON) |
|
|
37
|
+
| `context://plan` resource | Just the plan document |
|
|
38
|
+
| `context://git` resource | Just the git state |
|
|
39
|
+
| `get_context` tool | Same data, model-pullable, with optional `scope`: `full` \| `plan` \| `files` \| `git` |
|
|
40
|
+
| `save_session` tool | The agent summarizes *this* conversation and stores it, optionally on a named **thread**; `handoff: true` enforces a complete takeover package ([threads & handoff](https://ctxfile.dev/docs/threads)) |
|
|
41
|
+
| `continue_thread` tool | Merged, chronological, provenance-labeled history of a thread — resume work started on any other agent |
|
|
42
|
+
| `list_threads` tool | The user's threads with session counts and last-active times |
|
|
43
|
+
| `ingest_context` tool | Enveloped bulk door, same schema family — universal session capture for harnesses without a parser ([schema + prompt snippets](https://ctxfile.dev/docs/ingest)) |
|
|
44
|
+
| `load-context` prompt | Injects the snapshot into the conversation |
|
|
45
|
+
| `ctx-save` / `ctx-continue` prompts | One-tap save/resume on clients that surface MCP prompts |
|
|
46
|
+
|
|
47
|
+
The `ContextObject`:
|
|
48
|
+
|
|
49
|
+
```jsonc
|
|
50
|
+
{
|
|
51
|
+
"meta": { "version": "0.1.0", "root": "...", "tokenBudget": 50000, "tokensUsed": 12345, "connectors": [...] },
|
|
52
|
+
"plan": "# The Plan ...", // from PLAN.md / TODO.md / docs/plan*.md
|
|
53
|
+
"keyFiles": [{ "path": "src/index.ts", "tokens": 812, "truncated": false, "redactions": 0, "content": "..." }],
|
|
54
|
+
"gitState": { "branch": "main", "staged": [], "modified": [], "untracked": [], "commits": [...], "diffSummary": "..." },
|
|
55
|
+
"notionPages": [], // opt-in
|
|
56
|
+
"sessionSummary": null // opt-in (local Ollama)
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Files are selected by rank (plan docs → README → manifests → entry points → recently modified), `.gitignore`-aware, capped per-file, and greedily fitted to a token budget.
|
|
61
|
+
|
|
62
|
+
With an active [Pro](https://ctxfile.dev/pricing) license the server also registers `remember` / `recall` / `forget` (AES-256-GCM encrypted cross-session memory, key in the OS keychain), `consult` (ask several providers the same question over live context), and `transcribe_voice` (local whisper.cpp) — each gated on its licensed feature, and the snapshot gains `sessions`: redacted digests of your recent sessions from **Claude Code, Cursor, Codex CLI, OpenCode, Gemini CLI, Aider, OpenClaw, and Hermes Agent**, so an agent in one tool picks up where an agent in another left off. Licensing is an Ed25519-signed key verified offline (`ctxfile activate <key>`); no phone-home, ever.
|
|
63
|
+
|
|
64
|
+
On any *other* harness (or when a parser breaks), the free fallback is `ingest_context`: paste a short prompt, the agent digests its own session and pushes it in — strict schema, redacted, provenance-stamped `reported_by: agent`, reviewable via `ctxfile ingest list` / `rm <id>`. Parsers win on conflicts. The prompt is the adapter, so every MCP-speaking harness is supported, including ones that don't exist yet.
|
|
65
|
+
|
|
66
|
+
**Threads** make that portable across providers: save a session to a named thread ("Q3 campaign") from one agent, and `continue_thread` hands the merged, provenance-labeled history to the next one — different harness, different model provider, cold start. When the user hands work to another agent or person, `handoff: true` makes validation require the full takeover package (state, decisions with rationale, ordered open items, gotchas, artifacts with roles, a suggested first prompt), so any agent produces the same artifact. Pro also gets `ctxfile serve`: the same five tools over Streamable HTTP with scoped bearer tokens — the local door of the [Sync & roaming](https://ctxfile.dev/docs/sync) lane.
|
|
67
|
+
|
|
68
|
+
## Cloud agents: `ctxfile export`
|
|
69
|
+
|
|
70
|
+
Agents that don't run on your machine (hosted coding agents, CI bots) read a static artifact instead of MCP:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
ctxfile export # writes .ctxfile/context.json + context.md (repo-safe profile)
|
|
74
|
+
ctxfile export --stdout # pipe the JSON envelope anywhere
|
|
75
|
+
ctxfile hooks install # pre-commit: refresh + stage the artifact on every commit
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The default **repo-safe** profile ships plan, git state, and a key-file manifest only — no file bodies, Notion content, or session digests (those need an explicit `--profile full`, which warns loudly). Every profile re-runs secret redaction, and your absolute local path never appears in an export. The versioned file format is a public spec: [the .ctxfile convention](https://ctxfile.dev/convention).
|
|
79
|
+
|
|
80
|
+
## Local dashboard
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
ctxfile ui
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
A cockpit bound to `127.0.0.1` (token-gated URL, strict CSP, never network-exposed): run snapshots and watch connectors live, browse the captured context, inspect git state, manage Pro memory, and activate licenses. Press `R` to snapshot, `⌘K` for the command palette.
|
|
87
|
+
|
|
88
|
+
## Privacy
|
|
89
|
+
|
|
90
|
+
**Nothing leaves your machine by default.**
|
|
91
|
+
|
|
92
|
+
- The default path (files + git) makes **zero network calls**.
|
|
93
|
+
- Secret-looking content (AWS keys, GitHub/Notion/Slack tokens, private keys, JWTs, quoted `password=`/`api_key=` assignments) is **redacted** before it enters the snapshot; `.env*`, key files, and credential files are **never read at all**.
|
|
94
|
+
- The Notion connector activates only when you set `NOTION_TOKEN` **and** list page IDs in config.
|
|
95
|
+
- Summarization activates only when you set `ollama.summarize: true`, and it talks to your **local** Ollama.
|
|
96
|
+
- **No telemetry by default.** An anonymous weekly ping (random install UUID, version, OS platform name — never code, paths, or content) exists solely to count active installs, and only runs if you explicitly set `telemetry.enabled: true`.
|
|
97
|
+
|
|
98
|
+
## Configuration
|
|
99
|
+
|
|
100
|
+
Optional `.ctxfile.json` in your project root:
|
|
101
|
+
|
|
102
|
+
```jsonc
|
|
103
|
+
{
|
|
104
|
+
"tokenBudget": 50000, // total token budget for the snapshot
|
|
105
|
+
"maxFileTokens": 4000, // per-file cap (head+tail truncation beyond it)
|
|
106
|
+
"exclude": ["fixtures/"], // extra gitignore-style excludes
|
|
107
|
+
"cacheMaxAgeMs": 30000, // serve a cached snapshot younger than this
|
|
108
|
+
"notion": { "pageIds": ["<page-id>"] }, // requires NOTION_TOKEN env var
|
|
109
|
+
"ollama": { "summarize": true, "model": "qwen3:4b" }, // OLLAMA_BASE_URL overrides endpoint
|
|
110
|
+
"export": { "profile": "repo-safe" }, // default profile for `ctxfile export`
|
|
111
|
+
"telemetry": { "enabled": false } // opt-in anonymous weekly install ping; off by default
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
CLI:
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
ctxfile [--root <dir>] [--config <path>] # the MCP server (stdio)
|
|
119
|
+
ctxfile serve [--port <n>] [--host <h>] # the HTTP door (Pro): same tools over Streamable HTTP
|
|
120
|
+
ctxfile ui [--port <n>] [--no-open] # local dashboard on 127.0.0.1
|
|
121
|
+
ctxfile export [--profile <p>] [--stdout] # write the .ctxfile convention artifact
|
|
122
|
+
ctxfile hooks install|uninstall # managed pre-commit export refresh
|
|
123
|
+
ctxfile ingest list|rm <id> # review agent-reported sessions
|
|
124
|
+
ctxfile threads # list threads (durable, resumable work identities)
|
|
125
|
+
ctxfile vault create|join|status # encrypted Sync vault on a relay (passphrase via env)
|
|
126
|
+
ctxfile sync # push/pull sessions + threads through the vault
|
|
127
|
+
ctxfile activate <license-key> # store + verify a Pro license (offline)
|
|
128
|
+
ctxfile --version | --help
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Sync is client-side encrypted (Argon2id key derivation, XChaCha20-Poly1305 per blob, opaque blob ids): the relay — hosted at sync.ctxfile.dev, or self-hosted from the open-source [`@ctxfile/relay`](https://ctxfile.dev/docs/sync) — stores ciphertext only. Standard-mode vaults let chat surfaces save and resume threads through the relay's MCP endpoint; Strict-mode vaults trade that roaming for true end-to-end encryption.
|
|
132
|
+
|
|
133
|
+
Full reference: [ctxfile.dev/docs](https://ctxfile.dev/docs) (CLI, MCP surface, configuration, connectors, dashboard, privacy).
|
|
134
|
+
|
|
135
|
+
## Supported clients
|
|
136
|
+
|
|
137
|
+
| Client | Status |
|
|
138
|
+
|---|---|
|
|
139
|
+
| Claude Code | ✅ tested |
|
|
140
|
+
| Cursor | ✅ (2 core tools, 7 with full Pro — far under the 40-tool cap) |
|
|
141
|
+
| Claude Desktop | ✅ via `.mcpb` or JSON config |
|
|
142
|
+
| Cline / Windsurf / custom SDK clients | ✅ generic stdio MCP |
|
|
143
|
+
|
|
144
|
+
## Security notes
|
|
145
|
+
|
|
146
|
+
- Content from files and Notion is **untrusted data**. The tool description and prompt explicitly tell models not to follow instructions embedded in it, but downstream agents vary — see [SECURITY.md](https://github.com/ctxfile/ctxfile/blob/main/SECURITY.md).
|
|
147
|
+
- File access is scoped to the single configured root; the server never writes to your repo, Notion, or git state.
|
|
148
|
+
- Verify with the MCP Inspector: `npx @modelcontextprotocol/inspector npx -y ctxfile` (use Inspector ≥ 0.14.1).
|
|
149
|
+
|
|
150
|
+
## Development
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npm install
|
|
154
|
+
npm run build # tsup → dist/
|
|
155
|
+
npm test # vitest
|
|
156
|
+
npm run typecheck && npm run lint
|
|
157
|
+
npm run mcpb:pack # build ctxfile.mcpb (platform-specific: bundles native sqlite)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Architecture: `src/server.ts` is the only module that imports the MCP SDK (spec-churn isolation); connectors in `src/connectors/` are independently failable — a broken connector degrades to an `error` entry in `meta.connectors`, never a crashed snapshot.
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
[Apache-2.0](LICENSE). "ctxfile" and the ctxfile logo are trademarks of ctxfile; the Apache-2.0 license covers the code, not the name.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# ctxfile behaviors (v1)
|
|
2
|
+
|
|
3
|
+
You have access to the ctxfile MCP tools (`get_context`, `save_session`, `continue_thread`, `list_threads`, `ingest_context`). These behaviors make context capture automatic. The user consented to ambient capture when they installed this; your side of that bargain is the visibility rule (B4).
|
|
4
|
+
|
|
5
|
+
## B1 — Session start
|
|
6
|
+
|
|
7
|
+
At the start of work, call `get_context`. If a thread matches this project or the user's request, load it with `continue_thread` and briefly acknowledge what you now know, in one line, e.g. "Resuming Q3 campaign: last session ended mid-refactor of the export module." Do not recite the whole digest back.
|
|
8
|
+
|
|
9
|
+
## B2 — Checkpoint on significance, not on time
|
|
10
|
+
|
|
11
|
+
Call `save_session` with `trigger: "auto"` when ANY of these happens:
|
|
12
|
+
|
|
13
|
+
- a task or subtask completes;
|
|
14
|
+
- a decision with rationale is made;
|
|
15
|
+
- the user says anything implying an ending: "thanks", "that's all", "see you", "gtg", switching topics;
|
|
16
|
+
- roughly 30+ minutes of substantive work have passed since the last checkpoint;
|
|
17
|
+
- the user mentions switching tools, models, or machines.
|
|
18
|
+
|
|
19
|
+
Do NOT checkpoint trivial exchanges, single question-answer turns, or unchanged state. Include `thread` when the work has a name; include what changed since the last checkpoint, not the whole history.
|
|
20
|
+
|
|
21
|
+
If the tool answers `stored: false` (debounced, paused, or a private thread), accept it silently and move on. Never retry an automatic checkpoint, and never argue with a pause.
|
|
22
|
+
|
|
23
|
+
## B3 — Handoff detection
|
|
24
|
+
|
|
25
|
+
If the user implies someone or something else will continue ("hand this off", "my teammate will pick this up", "I'll continue on my phone"), produce a FULL handoff digest with `handoff: true` and all six sections: state (done / in progress / not started), key_decisions with the rationale, ordered open_items with blockers named, gotchas, artifacts (each with a one-line role), and suggested_first_prompt for whoever resumes. If validation rejects it, fix exactly the listed fields and call once more.
|
|
26
|
+
|
|
27
|
+
## B4 — Visibility (non-negotiable)
|
|
28
|
+
|
|
29
|
+
Every automatic save must be announced in the conversation in one short line:
|
|
30
|
+
|
|
31
|
+
✓ Checkpointed to ctxfile (thread: Q3 campaign)
|
|
32
|
+
|
|
33
|
+
Never save silently. If you saved without a thread, say so: "✓ Checkpointed to ctxfile". This single line is the whole announcement; do not elaborate unless asked.
|
|
34
|
+
|
|
35
|
+
## B5 — Thread hygiene
|
|
36
|
+
|
|
37
|
+
A new project or a clearly distinct workstream gets a new thread name; do not append unrelated work to an existing thread. When genuinely uncertain which thread applies, ask the user once, briefly, and remember the answer for the rest of the session.
|
|
38
|
+
|
|
39
|
+
## B6 — The CLI (harnesses with a shell)
|
|
40
|
+
|
|
41
|
+
If you can run shell commands, the `ctxfile` CLI is available for the admin actions the MCP tools deliberately do not expose. Run these ONLY when the user explicitly asks, never on your own initiative, and state the command you ran:
|
|
42
|
+
|
|
43
|
+
- "stop auto-saving" / "pause ctxfile" → `ctxfile pause` (resume with `ctxfile resume`)
|
|
44
|
+
- "make this thread private" → `ctxfile threads` to find the id, then `ctxfile threads private <id>` (`--off` reverses it)
|
|
45
|
+
- "what has been captured?" → `ctxfile ingest list`; "delete that one" → `ctxfile ingest rm <id>`
|
|
46
|
+
- "what threads do I have here?" → `ctxfile threads`
|
|
47
|
+
- "export context for the repo / CI" → `ctxfile export`
|
|
48
|
+
- "sync now" → `ctxfile sync` (works only if the user's vault passphrase env var is already set; if the command reports it is missing, tell the user to run it themselves — NEVER ask for, echo, or handle the passphrase)
|
|
49
|
+
|
|
50
|
+
Never run `ctxfile vault create|join` or `ctxfile activate` yourself; those are the user's own setup steps. On hosted surfaces without a shell, the five MCP tools are the whole interface.
|
|
51
|
+
|
|
52
|
+
## Manual override
|
|
53
|
+
|
|
54
|
+
All of this coexists with explicit requests: "save this session", "pick up my X thread", and "hand this off" always work and take priority. Explicit user requests are `trigger: "manual"` (the default) and are never debounced.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<!-- ctxfile:behaviors:begin (managed; do not edit inside) -->
|
|
2
|
+
## ctxfile: automatic context checkpointing
|
|
3
|
+
|
|
4
|
+
# ctxfile behaviors (v1)
|
|
5
|
+
|
|
6
|
+
You have access to the ctxfile MCP tools (`get_context`, `save_session`, `continue_thread`, `list_threads`, `ingest_context`). These behaviors make context capture automatic. The user consented to ambient capture when they installed this; your side of that bargain is the visibility rule (B4).
|
|
7
|
+
|
|
8
|
+
## B1 — Session start
|
|
9
|
+
|
|
10
|
+
At the start of work, call `get_context`. If a thread matches this project or the user's request, load it with `continue_thread` and briefly acknowledge what you now know, in one line, e.g. "Resuming Q3 campaign: last session ended mid-refactor of the export module." Do not recite the whole digest back.
|
|
11
|
+
|
|
12
|
+
## B2 — Checkpoint on significance, not on time
|
|
13
|
+
|
|
14
|
+
Call `save_session` with `trigger: "auto"` when ANY of these happens:
|
|
15
|
+
|
|
16
|
+
- a task or subtask completes;
|
|
17
|
+
- a decision with rationale is made;
|
|
18
|
+
- the user says anything implying an ending: "thanks", "that's all", "see you", "gtg", switching topics;
|
|
19
|
+
- roughly 30+ minutes of substantive work have passed since the last checkpoint;
|
|
20
|
+
- the user mentions switching tools, models, or machines.
|
|
21
|
+
|
|
22
|
+
Do NOT checkpoint trivial exchanges, single question-answer turns, or unchanged state. Include `thread` when the work has a name; include what changed since the last checkpoint, not the whole history.
|
|
23
|
+
|
|
24
|
+
If the tool answers `stored: false` (debounced, paused, or a private thread), accept it silently and move on. Never retry an automatic checkpoint, and never argue with a pause.
|
|
25
|
+
|
|
26
|
+
## B3 — Handoff detection
|
|
27
|
+
|
|
28
|
+
If the user implies someone or something else will continue ("hand this off", "my teammate will pick this up", "I'll continue on my phone"), produce a FULL handoff digest with `handoff: true` and all six sections: state (done / in progress / not started), key_decisions with the rationale, ordered open_items with blockers named, gotchas, artifacts (each with a one-line role), and suggested_first_prompt for whoever resumes. If validation rejects it, fix exactly the listed fields and call once more.
|
|
29
|
+
|
|
30
|
+
## B4 — Visibility (non-negotiable)
|
|
31
|
+
|
|
32
|
+
Every automatic save must be announced in the conversation in one short line:
|
|
33
|
+
|
|
34
|
+
✓ Checkpointed to ctxfile (thread: Q3 campaign)
|
|
35
|
+
|
|
36
|
+
Never save silently. If you saved without a thread, say so: "✓ Checkpointed to ctxfile". This single line is the whole announcement; do not elaborate unless asked.
|
|
37
|
+
|
|
38
|
+
## B5 — Thread hygiene
|
|
39
|
+
|
|
40
|
+
A new project or a clearly distinct workstream gets a new thread name; do not append unrelated work to an existing thread. When genuinely uncertain which thread applies, ask the user once, briefly, and remember the answer for the rest of the session.
|
|
41
|
+
|
|
42
|
+
## B6 — The CLI (harnesses with a shell)
|
|
43
|
+
|
|
44
|
+
If you can run shell commands, the `ctxfile` CLI is available for the admin actions the MCP tools deliberately do not expose. Run these ONLY when the user explicitly asks, never on your own initiative, and state the command you ran:
|
|
45
|
+
|
|
46
|
+
- "stop auto-saving" / "pause ctxfile" → `ctxfile pause` (resume with `ctxfile resume`)
|
|
47
|
+
- "make this thread private" → `ctxfile threads` to find the id, then `ctxfile threads private <id>` (`--off` reverses it)
|
|
48
|
+
- "what has been captured?" → `ctxfile ingest list`; "delete that one" → `ctxfile ingest rm <id>`
|
|
49
|
+
- "what threads do I have here?" → `ctxfile threads`
|
|
50
|
+
- "export context for the repo / CI" → `ctxfile export`
|
|
51
|
+
- "sync now" → `ctxfile sync` (works only if the user's vault passphrase env var is already set; if the command reports it is missing, tell the user to run it themselves — NEVER ask for, echo, or handle the passphrase)
|
|
52
|
+
|
|
53
|
+
Never run `ctxfile vault create|join` or `ctxfile activate` yourself; those are the user's own setup steps. On hosted surfaces without a shell, the five MCP tools are the whole interface.
|
|
54
|
+
|
|
55
|
+
## Manual override
|
|
56
|
+
|
|
57
|
+
All of this coexists with explicit requests: "save this session", "pick up my X thread", and "hand this off" always work and take priority. Explicit user requests are `trigger: "manual"` (the default) and are never debounced.
|
|
58
|
+
<!-- ctxfile:behaviors:end -->
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ctxfile
|
|
3
|
+
description: Automatic context checkpointing via the ctxfile MCP tools. Use throughout every session - at session start (load context), when tasks complete or decisions are made (checkpoint), and when the user hands work off or says goodbye.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ctxfile behaviors (v1)
|
|
7
|
+
|
|
8
|
+
You have access to the ctxfile MCP tools (`get_context`, `save_session`, `continue_thread`, `list_threads`, `ingest_context`). These behaviors make context capture automatic. The user consented to ambient capture when they installed this; your side of that bargain is the visibility rule (B4).
|
|
9
|
+
|
|
10
|
+
## B1 — Session start
|
|
11
|
+
|
|
12
|
+
At the start of work, call `get_context`. If a thread matches this project or the user's request, load it with `continue_thread` and briefly acknowledge what you now know, in one line, e.g. "Resuming Q3 campaign: last session ended mid-refactor of the export module." Do not recite the whole digest back.
|
|
13
|
+
|
|
14
|
+
## B2 — Checkpoint on significance, not on time
|
|
15
|
+
|
|
16
|
+
Call `save_session` with `trigger: "auto"` when ANY of these happens:
|
|
17
|
+
|
|
18
|
+
- a task or subtask completes;
|
|
19
|
+
- a decision with rationale is made;
|
|
20
|
+
- the user says anything implying an ending: "thanks", "that's all", "see you", "gtg", switching topics;
|
|
21
|
+
- roughly 30+ minutes of substantive work have passed since the last checkpoint;
|
|
22
|
+
- the user mentions switching tools, models, or machines.
|
|
23
|
+
|
|
24
|
+
Do NOT checkpoint trivial exchanges, single question-answer turns, or unchanged state. Include `thread` when the work has a name; include what changed since the last checkpoint, not the whole history.
|
|
25
|
+
|
|
26
|
+
If the tool answers `stored: false` (debounced, paused, or a private thread), accept it silently and move on. Never retry an automatic checkpoint, and never argue with a pause.
|
|
27
|
+
|
|
28
|
+
## B3 — Handoff detection
|
|
29
|
+
|
|
30
|
+
If the user implies someone or something else will continue ("hand this off", "my teammate will pick this up", "I'll continue on my phone"), produce a FULL handoff digest with `handoff: true` and all six sections: state (done / in progress / not started), key_decisions with the rationale, ordered open_items with blockers named, gotchas, artifacts (each with a one-line role), and suggested_first_prompt for whoever resumes. If validation rejects it, fix exactly the listed fields and call once more.
|
|
31
|
+
|
|
32
|
+
## B4 — Visibility (non-negotiable)
|
|
33
|
+
|
|
34
|
+
Every automatic save must be announced in the conversation in one short line:
|
|
35
|
+
|
|
36
|
+
✓ Checkpointed to ctxfile (thread: Q3 campaign)
|
|
37
|
+
|
|
38
|
+
Never save silently. If you saved without a thread, say so: "✓ Checkpointed to ctxfile". This single line is the whole announcement; do not elaborate unless asked.
|
|
39
|
+
|
|
40
|
+
## B5 — Thread hygiene
|
|
41
|
+
|
|
42
|
+
A new project or a clearly distinct workstream gets a new thread name; do not append unrelated work to an existing thread. When genuinely uncertain which thread applies, ask the user once, briefly, and remember the answer for the rest of the session.
|
|
43
|
+
|
|
44
|
+
## B6 — The CLI (harnesses with a shell)
|
|
45
|
+
|
|
46
|
+
If you can run shell commands, the `ctxfile` CLI is available for the admin actions the MCP tools deliberately do not expose. Run these ONLY when the user explicitly asks, never on your own initiative, and state the command you ran:
|
|
47
|
+
|
|
48
|
+
- "stop auto-saving" / "pause ctxfile" → `ctxfile pause` (resume with `ctxfile resume`)
|
|
49
|
+
- "make this thread private" → `ctxfile threads` to find the id, then `ctxfile threads private <id>` (`--off` reverses it)
|
|
50
|
+
- "what has been captured?" → `ctxfile ingest list`; "delete that one" → `ctxfile ingest rm <id>`
|
|
51
|
+
- "what threads do I have here?" → `ctxfile threads`
|
|
52
|
+
- "export context for the repo / CI" → `ctxfile export`
|
|
53
|
+
- "sync now" → `ctxfile sync` (works only if the user's vault passphrase env var is already set; if the command reports it is missing, tell the user to run it themselves — NEVER ask for, echo, or handle the passphrase)
|
|
54
|
+
|
|
55
|
+
Never run `ctxfile vault create|join` or `ctxfile activate` yourself; those are the user's own setup steps. On hosted surfaces without a shell, the five MCP tools are the whole interface.
|
|
56
|
+
|
|
57
|
+
## Manual override
|
|
58
|
+
|
|
59
|
+
All of this coexists with explicit requests: "save this session", "pick up my X thread", and "hand this off" always work and take priority. Explicit user requests are `trigger: "manual"` (the default) and are never debounced.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# ctxfile behaviors for Codex
|
|
2
|
+
|
|
3
|
+
Add this to your Codex instructions (global `~/.codex/AGENTS.md` or per-project AGENTS.md).
|
|
4
|
+
|
|
5
|
+
# ctxfile behaviors (v1)
|
|
6
|
+
|
|
7
|
+
You have access to the ctxfile MCP tools (`get_context`, `save_session`, `continue_thread`, `list_threads`, `ingest_context`). These behaviors make context capture automatic. The user consented to ambient capture when they installed this; your side of that bargain is the visibility rule (B4).
|
|
8
|
+
|
|
9
|
+
## B1 — Session start
|
|
10
|
+
|
|
11
|
+
At the start of work, call `get_context`. If a thread matches this project or the user's request, load it with `continue_thread` and briefly acknowledge what you now know, in one line, e.g. "Resuming Q3 campaign: last session ended mid-refactor of the export module." Do not recite the whole digest back.
|
|
12
|
+
|
|
13
|
+
## B2 — Checkpoint on significance, not on time
|
|
14
|
+
|
|
15
|
+
Call `save_session` with `trigger: "auto"` when ANY of these happens:
|
|
16
|
+
|
|
17
|
+
- a task or subtask completes;
|
|
18
|
+
- a decision with rationale is made;
|
|
19
|
+
- the user says anything implying an ending: "thanks", "that's all", "see you", "gtg", switching topics;
|
|
20
|
+
- roughly 30+ minutes of substantive work have passed since the last checkpoint;
|
|
21
|
+
- the user mentions switching tools, models, or machines.
|
|
22
|
+
|
|
23
|
+
Do NOT checkpoint trivial exchanges, single question-answer turns, or unchanged state. Include `thread` when the work has a name; include what changed since the last checkpoint, not the whole history.
|
|
24
|
+
|
|
25
|
+
If the tool answers `stored: false` (debounced, paused, or a private thread), accept it silently and move on. Never retry an automatic checkpoint, and never argue with a pause.
|
|
26
|
+
|
|
27
|
+
## B3 — Handoff detection
|
|
28
|
+
|
|
29
|
+
If the user implies someone or something else will continue ("hand this off", "my teammate will pick this up", "I'll continue on my phone"), produce a FULL handoff digest with `handoff: true` and all six sections: state (done / in progress / not started), key_decisions with the rationale, ordered open_items with blockers named, gotchas, artifacts (each with a one-line role), and suggested_first_prompt for whoever resumes. If validation rejects it, fix exactly the listed fields and call once more.
|
|
30
|
+
|
|
31
|
+
## B4 — Visibility (non-negotiable)
|
|
32
|
+
|
|
33
|
+
Every automatic save must be announced in the conversation in one short line:
|
|
34
|
+
|
|
35
|
+
✓ Checkpointed to ctxfile (thread: Q3 campaign)
|
|
36
|
+
|
|
37
|
+
Never save silently. If you saved without a thread, say so: "✓ Checkpointed to ctxfile". This single line is the whole announcement; do not elaborate unless asked.
|
|
38
|
+
|
|
39
|
+
## B5 — Thread hygiene
|
|
40
|
+
|
|
41
|
+
A new project or a clearly distinct workstream gets a new thread name; do not append unrelated work to an existing thread. When genuinely uncertain which thread applies, ask the user once, briefly, and remember the answer for the rest of the session.
|
|
42
|
+
|
|
43
|
+
## B6 — The CLI (harnesses with a shell)
|
|
44
|
+
|
|
45
|
+
If you can run shell commands, the `ctxfile` CLI is available for the admin actions the MCP tools deliberately do not expose. Run these ONLY when the user explicitly asks, never on your own initiative, and state the command you ran:
|
|
46
|
+
|
|
47
|
+
- "stop auto-saving" / "pause ctxfile" → `ctxfile pause` (resume with `ctxfile resume`)
|
|
48
|
+
- "make this thread private" → `ctxfile threads` to find the id, then `ctxfile threads private <id>` (`--off` reverses it)
|
|
49
|
+
- "what has been captured?" → `ctxfile ingest list`; "delete that one" → `ctxfile ingest rm <id>`
|
|
50
|
+
- "what threads do I have here?" → `ctxfile threads`
|
|
51
|
+
- "export context for the repo / CI" → `ctxfile export`
|
|
52
|
+
- "sync now" → `ctxfile sync` (works only if the user's vault passphrase env var is already set; if the command reports it is missing, tell the user to run it themselves — NEVER ask for, echo, or handle the passphrase)
|
|
53
|
+
|
|
54
|
+
Never run `ctxfile vault create|join` or `ctxfile activate` yourself; those are the user's own setup steps. On hosted surfaces without a shell, the five MCP tools are the whole interface.
|
|
55
|
+
|
|
56
|
+
## Manual override
|
|
57
|
+
|
|
58
|
+
All of this coexists with explicit requests: "save this session", "pick up my X thread", and "hand this off" always work and take priority. Explicit user requests are `trigger: "manual"` (the default) and are never debounced.
|