@mindmux/cli 0.0.0-stage → 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 ADDED
@@ -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.
package/README.md CHANGED
@@ -1,3 +1,56 @@
1
- # Temporary Holding Version
1
+ # MindMux CLI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `mmx` gives your coding agent a project Brain: persistent knowledge it can read while working and update as decisions settle. Connect Claude Code or Codex to a Cloud or local Brain with one setup command.
4
+
5
+ ## Install
6
+
7
+ Requires **Node.js 22+** and **macOS or Linux**. Install from source with pnpm:
8
+
9
+ ```bash
10
+ git clone https://github.com/mindmuxai/mindmux-cli.git
11
+ cd mindmux-cli
12
+ pnpm install
13
+ pnpm add -g "$PWD"
14
+ ```
15
+
16
+ Prefer npm? See [installation options](docs/installation.md).
17
+
18
+ ## Get started
19
+
20
+ Inside the project you want to connect, run:
21
+
22
+ ```bash
23
+ cd /path/to/your/project
24
+ mmx setup
25
+ ```
26
+
27
+ Use the arrow keys and Enter to choose your agent, Workspace and Project, or create a new Project. Setup handles browser login, project MCP configuration, instructions and hooks, then checks the connection.
28
+
29
+ **Restart your agent and approve its trust prompts.** In Codex, also review the installed hooks with `/hooks`. You can then work as usual: the agent receives relevant Brain context and is guided to save confirmed decisions. You do not need to mention Brain in every request.
30
+
31
+ Want a local Brain without Cloud login? Run `mmx setup --local` instead.
32
+
33
+ ## Everyday commands
34
+
35
+ | Command | Purpose |
36
+ | --- | --- |
37
+ | `mmx` | Open the interactive menu |
38
+ | `mmx status --online` | Check the connection |
39
+ | `mmx doctor --fix` | Diagnose and repair setup |
40
+ | `mmx switch` | Choose another Brain |
41
+ | `mmx --help` | Show command help |
42
+
43
+ To start setup again, `mmx clean` resets local integration, binding, local Brain data and CLI login after confirmation. **Cloud data is kept.** Use `mmx clean --keep-login` to stay signed in. See [cleanup details](docs/setup.md#reset-for-testing).
44
+
45
+ ## Documentation
46
+
47
+ - [Installation](docs/installation.md) — npm, pnpm and requirements.
48
+ - [Setup and maintenance](docs/setup.md) — agent trust, upgrades, repair and cleanup.
49
+ - [Brain commands](docs/brain.md) — query, write and index operations.
50
+ - [Cloud login](docs/cloud.md) — authentication and binding.
51
+ - [Agent behavior](docs/agents.md) — hooks, memory reviews and limits.
52
+ - [Development](docs/development.md) — tests and verification.
53
+
54
+ ## License
55
+
56
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ // Keep existing absolute-path host configurations working after the command rename.
3
+ import './mmx.mjs';
package/bin/mmx.mjs ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { main } from '../src/cli.mjs';
3
+ await main().catch(error => {
4
+ console.error(`mmx: ${error.message}`);
5
+ process.exitCode = 1;
6
+ });
package/docs/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # Documentation
2
+
3
+ [Back to README](../README.md)
4
+
5
+ Start with `mmx setup` in your project. Use these guides when you need more detail.
6
+
7
+ | Guide | What you will find |
8
+ | --- | --- |
9
+ | [Installation](installation.md) | Requirements, pnpm/npm source installation, path changes |
10
+ | [Setup and maintenance](setup.md) | Setup options, Codex trust, status, repair, switching, migration and reset |
11
+ | [Cloud login](cloud.md) | Authentication, Workspaces, Projects and explicit binding |
12
+ | [Brain commands](brain.md) | Reading, writing, indexing, concurrency and low-level MCP access |
13
+ | [Agent behavior](agents.md) | Retrieval, language, hooks, Codex reviews and known limits |
14
+ | [Development](development.md) | Automated checks, demos and opt-in Cloud verification |
package/docs/agents.md ADDED
@@ -0,0 +1,61 @@
1
+ # Agent behavior and limits
2
+
3
+ [Back to README](../README.md) · [Documentation](README.md)
4
+
5
+ | Agent | Session start | User request | End of turn |
6
+ | --- | --- | --- | --- |
7
+ | Claude Code | SessionStart context, including supported resume/compaction boundaries | UserPromptSubmit retrieval and injection | One Stop review, with recursion protection |
8
+ | Codex | SessionStart hook + AGENTS.md; restores active review after compaction | UserPromptSubmit recall and pre-answer review | Stop allows a registered review; otherwise requests one recovery |
9
+ | Cursor local agent | sessionStart base context | beforeSubmitPrompt retrieval; first preToolUse delivers relevant context | One stop follow-up, with `loop_limit=1` |
10
+
11
+ Unified `setup` supports Claude Code and Codex. To install Cursor rules and hooks separately, first bind or initialize a Brain, then run:
12
+
13
+ ```bash
14
+ mmx connect --agent cursor
15
+ mmx disconnect --agent cursor
16
+ ```
17
+
18
+ Cursor's beforeSubmitPrompt hook is used for retrieval, not context injection. Its sessionStart hook is fire-and-forget, and preToolUse may run after the first tool's arguments have already been constructed. A turn with no tool calls depends on startup context and persistent rules. Cloud agent VMs are outside the supported scope of this local integration.
19
+
20
+ Hooks and rules encourage relevant reads and confirmed writes; configuration alone does not prove that an agent has used the knowledge. Claude Code and Codex both use startup, prompt, and Stop hooks alongside project instructions. The CLI does not run an additional LLM, read conversation transcripts, or automatically turn discussion into facts. Claude Code and Cursor may add one end-of-turn model continuation. Codex reviews memory before the final answer and registers the result locally; normal registered turns do not require a Stop continuation. A missing or failed review may still add one visible recovery and repeat the final answer. No extra LLM is run by the CLI, and these mechanisms do not guarantee that every durable fact is captured.
21
+
22
+ Brain knowledge follows the user's working language: Chinese conversations produce Chinese Page titles, knowledge and human-authored timeline descriptions; English conversations produce English knowledge, unless the user requests otherwise. English CLI prompts and repository documentation do not set the knowledge language. IDs, commands, code, URLs and verbatim evidence are preserved.
23
+
24
+ Start each Page's current knowledge with one or two plain prose sentences stating what it records, the core conclusion and when to read it, before headings, dates, provenance or lists. Put the conclusion in the first sentence and keep it current when updating the body. The existing index extracts this opening; no summary field is added. This writing guidance is delivered through installed agent rules, hook recall context and the CLI MCP service. Existing installations receive updated hook context when running the new CLI; rerun `mmx connect --agent codex` or `mmx connect --agent claude-code` to refresh the installed rules, and restart the MCP service to refresh its instructions. CLI writes preserve submitted text and do not translate or rewrite it automatically.
25
+
26
+ Codex hooks supply a review token scoped to the project, bound Brain, session and turn. The agent passes `--review-token TOKEN` to `brain create`, `update`, `append`, `archive` and `update-root`, then registers the final review:
27
+
28
+ ```bash
29
+ mmx brain review --review-token TOKEN --outcome saved --reason "Saved and verified the confirmed decision"
30
+ mmx brain review --review-token TOKEN --outcome no-changes --reason "No new durable knowledge"
31
+ mmx brain review --review-token TOKEN --outcome already-covered --id PAGE_ID --reason "The existing Page covers this decision"
32
+ mmx brain review --review-token TOKEN --outcome deferred --reason "The Brain service is unavailable"
33
+ ```
34
+
35
+ Use the actual token provided by the current hook. `saved` requires a successful mutation executed with that token and matching read-back versions of all recorded resources. Reading an arbitrary existing Page does not qualify as a saved write. `already-covered` checks that the referenced Page is readable; the agent remains responsible for assessing its relevance. `deferred` records a retryable failure and does not authorize Stop as a completed review. Later token-bearing writes invalidate a registered review. Direct Cloud tool calls and writes without a token cannot supply verified-write evidence; use the CLI or `mindmux_brain` facade for this workflow.
36
+
37
+ The MCP equivalent uses `mindmux_brain` with `reviewToken` on mutations, followed by `operation: "review"`, `reviewToken`, `outcome`, `reason`, and `id` for `already-covered`. Review records are local metadata, never Brain Pages. Even a no-changes turn normally needs one local tool call. The review proves workflow completion, not that the agent's knowledge judgment is complete.
38
+
39
+ Review tokens expire after 24 hours and are invalidated when the active turn or binding changes, on interruption, and when Stop closes the turn. Exact completed-review retries are idempotent until the next turn or expiry. Missing session/turn identifiers disable enforcement with `review-unavailable` diagnostics rather than reusing a default session. Compaction restores the active token and registration state. Session locks serialize state updates and write verification; a busy or abandoned lock fails with a diagnostic rather than being removed while another process may be using it. After confirming a crashed process is gone, remove its `.mindmux/cli/reviews/*.lock` directory to retry. Review state is ignored by Git and removed by `mmx clean`.
40
+
41
+ Upgrade existing Codex installations with `mmx connect --agent codex` or `mmx doctor --fix`, restart Codex and review `/hooks`. The managed installation also handles interruption to invalidate the active review. Claude Code and Cursor retain their existing Stop behavior.
42
+
43
+ `doctor` checks files, executable paths, and recent hook receipts:
44
+
45
+ - `retrieved`: retrieval completed, awaiting delivery.
46
+ - `emitted`: context returned through the hook protocol; adoption by the model is not established.
47
+ - `review-requested`: one recovery requested for an unregistered Codex review, or the regular end-of-turn review for other agents.
48
+ - `review-registered` / `review-completed`: a local review was registered / accepted by Stop.
49
+ - `review-failed` / `recovery-exhausted`: review or persistence failed; one recovery could not complete it. No claim of saved memory is made.
50
+ - `review-unavailable` / `review-expired` / `review-aborted`: enforcement lacks a valid active turn, the token expired, or the turn was interrupted.
51
+ - `error` / `timeout`: a failure or the eight-second hook budget was exceeded. The task continues without switching Brains.
52
+
53
+ Retrieval starts with the Brain index: Page IDs, titles, summaries, categories, lifecycle states and tags, plus root-page navigation. The hook receives a bounded preview of complete index rows, with an explicit `brain index` instruction when rows are omitted; there is no fixed 20-page cutoff. Keyword retrieval supplements this directory with up to three active Page bodies and two core roots within an 8 KiB UTF-8 budget. A zero-length `pageIds` means no Page body was selected, not that the index is empty. The agent should read relevant Pages identified from the index even when keyword matching returns nothing. Local and Cloud full-text matches remain candidates even when their short summaries do not repeat the query. Vector retrieval and semantic reranking are not implemented.
54
+
55
+ `brain index` returns a current active-page navigation view as `body`, structured `pages`, `rootPages`, and `count`. Local reads report whether the actual `brain/index.md` file is present. That canonical brain.md file may contain explicitly labeled draft/archived entries; its raw contents are not exposed through the active index API or hooks. Local `brain reindex` uses brain.md's generator to rebuild that file. Page writes continue to maintain the local index through brain.md.
56
+
57
+ Cloud reads use `read_brain_index`; `reindex_brain` regenerates and persists a derived Markdown snapshot. Reads expose saved snapshot cursor/staleness metadata, never obsolete snapshot text. The main `body` is generated from current source Pages so a saved snapshot never overrides current truth. Indexes are generated documents: edit source Pages, then regenerate rather than supplying arbitrary index text. The Cloud service needs migration `0028_brain_indexes.sql` and the updated MCP server before the new Cloud index tools are available. For an older Cloud server without `read_brain_index`, the CLI builds the same navigation view from Cloud `list_pages` and `list_root_pages`, retaining summaries and marking `source: page-list-compatibility`. A failed supported index read is propagated; no local Brain fallback occurs.
58
+
59
+ Raw user prompts are not persisted. Session retrieval caches under `.mindmux/cli/sessions/` contain Brain content and are ignored by Git, with mode `0600`. Pending Cursor delivery expires after ten minutes; changing a binding invalidates reuse. Historical cache cleanup is manual.
60
+
61
+ Managed instruction blocks and hook registration are idempotent. Disconnect removes owned entries while preserving user content, Brain data, other hooks, and skills. Malformed configuration or markers cause an error rather than being overwritten. `doctor` reports recognized duplicate brain.md integrations; use the original installer to remove older hooks or global skills when replacing them.
package/docs/brain.md ADDED
@@ -0,0 +1,54 @@
1
+ # Brain and MCP commands
2
+
3
+ [Back to README](../README.md) · [Documentation](README.md)
4
+
5
+ Brain commands return JSON by default.
6
+
7
+ ```bash
8
+ mmx brain status
9
+ mmx brain index # Read the generated active-page index and root navigation.
10
+ mmx brain reindex # Rebuild the derived index; requires write access.
11
+ mmx brain list
12
+ mmx brain search 'authentication'
13
+ mmx brain recall 'implement authentication'
14
+ mmx brain read auth-pkce
15
+
16
+ cat decision.md | mmx brain create \
17
+ --id auth-pkce --title 'Use OAuth PKCE for authentication' \
18
+ --category decision --source 'Confirmed in the design review'
19
+
20
+ cat revised.md | mmx brain update auth-pkce \
21
+ --expected-version <version-from-read> \
22
+ --summary 'Restrict the callback to loopback' --source 'Design review'
23
+
24
+ mmx brain append auth-pkce --kind evidence --summary 'Interoperability verified' --source 'Test report'
25
+ mmx brain archive auth-pkce
26
+ mmx brain roots
27
+ mmx brain read-root architecture
28
+ cat architecture.md | mmx brain update-root architecture --expected-version <version-from-read>
29
+ ```
30
+
31
+ Read the current version before updating. Local versions are file SHA-256 hashes; Cloud versions are positive server-side integers. Conflicts are not overwritten or retried automatically. For a new root, pass `--expected-version new`; existing roots require their current version.
32
+
33
+ Local creation reuses brain.md's `create-page` and `update-truth` steps. An interruption between them may leave an empty page; read it and complete it with `update`. Atomic truth/timeline updates are provided by brain.md. The CLI's local write lock coordinates only this CLI, not other programs invoking `brain` directly.
34
+
35
+ Choose local mode explicitly:
36
+
37
+ ```bash
38
+ mmx init --local
39
+ mmx brain bind --local
40
+ ```
41
+
42
+ ### Low-level MCP access
43
+
44
+ ```bash
45
+ mmx mcp tools
46
+ mmx mcp call TOOL --args '{"key":"value"}'
47
+ mmx mcp serve
48
+ ```
49
+
50
+ `mcp call` exposes the full Cloud MCP tool surface, including destructive tools. Supply all arguments, including the correct Brain ID: this low-level command does not inject the project binding. Use `brain` commands for ordinary operations against the selected Brain.
51
+
52
+ `mcp serve` is a stdio service launched by the host, with no network listener. It shares CLI authentication and refresh locks. In Cloud mode it proxies the account's tools and results. Tools that accept `brainId` are pinned to the project binding and reject a different ID. Account-level tools such as Workspace discovery and Project creation retain their original arguments and server-side permissions; project binding is not an account permission sandbox.
53
+
54
+ The additional `mindmux_brain` tool supports local and Cloud status, index, reindex, list, search, recall, read, create, update, append, archive, roots, read-root, update-root, and review operations. Bodies pass through stdin without shell interpolation. Cloud `isError`, content, and structured content are preserved. Restart the MCP service after changing a binding.
package/docs/cloud.md ADDED
@@ -0,0 +1,29 @@
1
+ # Cloud login and binding
2
+
3
+ [Back to README](../README.md) · [Documentation](README.md)
4
+
5
+ ```bash
6
+ mmx login
7
+ mmx workspace list
8
+ mmx project list
9
+ mmx brain discover
10
+
11
+ mmx brain bind --brain-id <brain-id>
12
+ mmx connect --agent claude-code
13
+ mmx doctor --online
14
+ ```
15
+
16
+ To create a Project explicitly:
17
+
18
+ ```bash
19
+ mmx project create --workspace-id <workspace-id> --name 'My Project' --confirm
20
+ mmx brain bind --brain-id <returned-brain-id>
21
+ ```
22
+
23
+ New Projects are visible to all Workspace members and require the server's owner/admin permissions. The CLI never infers a Workspace or Brain from the directory name. Binding is saved only after access is verified.
24
+
25
+ Login uses OAuth discovery, dynamic client registration, a loopback callback, state validation, and PKCE. The default server is `https://mcp.mindmux.ai/mcp`. `--server URL` accepts HTTPS or loopback HTTP for test deployments.
26
+
27
+ The CLI maintains its own credentials rather than reading agent credentials. Credentials are isolated by server and stored in `~/.mindmux-cli/auth/` with mode `0600`. Set `MINDMUX_HOME` to use another directory. System keychain integration is not implemented. Calls and refreshes use a process lock; writes are not automatically replayed. Normal exits and SIGINT/SIGTERM release locks. After SIGKILL, an error identifies the lock directory that needs inspection.
28
+
29
+ `mmx logout` removes this CLI's local credentials for the selected server. It does not revoke other clients' authorization. Binding uses `.mindmux/preferences.json`; unknown preference fields are preserved. Cloud failures never silently switch writes to a local Brain.
@@ -0,0 +1,24 @@
1
+ # Development and verification
2
+
3
+ [Back to README](../README.md) · [Documentation](README.md)
4
+
5
+ ```bash
6
+ npm ci
7
+ npm run check
8
+ npm run demo
9
+ npm pack --dry-run
10
+ ```
11
+
12
+ The automated suite uses temporary projects, real MCP SDK transports, and a mock OAuth server. It covers local lifecycle operations, optimistic concurrency, binding isolation, setup rollback, configuration preservation, hook schemas, caching, PKCE, process interruption, and the `mmx` compatibility entry point. Chinese fixture text intentionally tests multilingual retrieval and byte preservation.
13
+
14
+ The local demo writes `.demo/report.md` and `.demo/latest.json`. It simulates hook delivery without production access or launching an agent model.
15
+
16
+ An opt-in integration script is available after login:
17
+
18
+ ```bash
19
+ node scripts/verify-live.mjs --workspace-id <workspace-id> --confirm --output artifacts/live-run
20
+ ```
21
+
22
+ This script writes to a dedicated test Project in the explicitly selected Workspace. It reuses a saved manifest, creates fresh test pages on each run, exercises Cloud operations and installed hook commands, and preserves reports and project data. A disposable page is deleted as part of the test. It does not launch a real agent model and never runs under `npm test`.
23
+
24
+ Production test reports, credentials, local project configuration, demo output, and generated artifacts are excluded from this repository. Hook protocol tests do not establish model adoption; assess that separately with actual agent sessions. Cursor model sessions and additional provider configurations remain future validation work.
@@ -0,0 +1,41 @@
1
+ # Installation
2
+
3
+ [Back to README](../README.md) · [Documentation](README.md)
4
+
5
+ ## Requirements
6
+
7
+ - Node.js 22 or later.
8
+ - macOS or Linux. Generated hook commands use POSIX shell quoting; native Windows shells are not supported yet.
9
+ - A supported agent installed locally. Unified setup supports Claude Code and Codex. Cursor integration is available separately through `connect`.
10
+
11
+ ## Install from source
12
+
13
+ Use Node.js 22 or later. With pnpm:
14
+
15
+ ```bash
16
+ git clone https://github.com/mindmuxai/mindmux-cli.git
17
+ cd mindmux-cli
18
+ pnpm install
19
+ pnpm add -g "$PWD"
20
+
21
+ cd /path/to/your/project
22
+ mmx setup
23
+ ```
24
+
25
+ If pnpm reports that its global bin directory is missing, run `pnpm setup`, reopen your terminal, and retry `pnpm add -g "$PWD"`. Source installation does not require a published `@mindmux/cli` package. Keep the source directory available for the installed command.
26
+
27
+ With npm:
28
+
29
+ ```bash
30
+ git clone https://github.com/mindmuxai/mindmux-cli.git
31
+ cd mindmux-cli
32
+ npm ci
33
+ npm install -g .
34
+
35
+ cd /path/to/your/project
36
+ mmx setup
37
+ ```
38
+
39
+ `npm ci` installs dependencies but does not install the global command. Keep the CLI installation and Node executable available: generated integrations use absolute paths. After moving the CLI, moving a project, or changing Node, rerun `mmx setup` to refresh those paths. Set up each new worktree separately.
40
+
41
+ The old `bin/mindmux.mjs` script remains as a compatibility entry point for existing integrations. New installations use `bin/mmx.mjs`.
package/docs/setup.md ADDED
@@ -0,0 +1,116 @@
1
+ # Project setup and maintenance
2
+
3
+ [Back to README](../README.md) · [Documentation](README.md)
4
+
5
+ Run `mmx setup` inside the project you want to connect.
6
+
7
+ Use the Up/Down arrow keys and Enter to select agents, Workspaces, Projects, and confirmations. Select **+ Create a new Project** to create a Project; only its name requires typing. Empty, overlong, and duplicate names are validated in place so you can correct them without restarting. Cancelling creation returns to the Project menu; Ctrl+C exits setup.
8
+
9
+ The wizard also handles browser login. It installs project-level MCP configuration and agent instructions/hooks, then performs a real stdio MCP handshake and a read-only recall check.
10
+
11
+ Setup prints progress for login, discovery, validation, installation, and the MCP check. Progress goes to stderr and is suppressed with `--json`. Setup finishes with a short confirmation and instructions to restart your agent. For scripts or troubleshooting, use `mmx setup --json` to return the full structured result, including diagnostics and the backup path.
12
+
13
+ Existing valid credentials and project bindings are reused. Repeating setup updates managed entries without registering duplicates. Browser authorization and the agent's own project, MCP, and hook trust prompts still require user interaction.
14
+
15
+ Explicit options are available for automation:
16
+
17
+ ```bash
18
+ # Connect an existing Cloud Brain.
19
+ mmx setup --agent claude-code,codex --brain-id <brain-id> --yes
20
+
21
+ # Create a Project visible to all members of the selected Workspace.
22
+ mmx setup --agent codex --workspace-id <workspace-id> --name 'My Project' --confirm --yes
23
+
24
+ # Use a local Brain without Cloud login.
25
+ mmx setup --local --agent codex --yes
26
+
27
+ mmx doctor --online
28
+ mmx remove
29
+ mmx remove --agent codex
30
+ ```
31
+
32
+ `--yes` disables terminal questions. It does not bypass OAuth, agent trust prompts, or the `--confirm` requirement for Project creation. Non-interactive Cloud setup requires explicit agents and either an existing Cloud binding, a Brain ID, or Project creation options. `--no-open` prints the authorization URL instead of opening a browser.
33
+
34
+ Claude Code uses the `mindmux` entry in `.mcp.json`, plus `CLAUDE.md` and hooks. Codex uses `mindmux_cli` in `.codex/config.toml`, plus `AGENTS.md` instructions and native hooks in `.codex/hooks.json`. These MCP identifiers remain unchanged by the executable rename. Generated MCP configuration contains executable paths and `MINDMUX_HOME`, rather than copied OAuth tokens. Restart the agent after setup and approve the applicable trust prompts.
35
+
36
+ ## Codex hook setup and upgrades
37
+
38
+ The [official Codex hooks documentation](https://learn.chatgpt.com/docs/hooks) describes the host protocol and trust controls. Codex hooks require a compatible Codex installation with the `hooks` feature enabled. Setup checks `codex features list` and warns if support cannot be verified or hooks are disabled; it does not change global Codex settings. Doctor reports unsupported or disabled hooks as errors and unavailable capability checks as warnings. If needed, update Codex or run `codex features enable hooks`.
39
+
40
+ For an existing instructions-only installation, rerun `mmx setup --agent codex` (add `--local` for a local Brain), or use `mmx doctor --fix`. Setup installs SessionStart, UserPromptSubmit, Stop, and Interrupt handlers in `.codex/hooks.json`, preserves unrelated hooks, and keeps `AGENTS.md` as workflow guidance. It does not change the brain.md storage implementation. Status and doctor detect older instructions-only installs as missing hooks. Setup adds `.codex/hooks.json` to the project's `.gitignore`; run setup in each worktree that needs these hooks.
41
+
42
+ Restart Codex, trust the project, and open `/hooks` to review new or changed definitions. Codex skips untrusted hooks; the CLI does not approve hooks or alter Codex's trust records. Hooks may also exist in global or inline TOML configuration, so inspect `/hooks` for duplicates. `mmx remove --agent codex` removes the hooks installed by setup while preserving unrelated hook definitions; `mmx clean` also removes the managed hooks as part of its local reset.
43
+
44
+ SessionStart injects base Brain context (including after resume/compaction); UserPromptSubmit retrieves relevant project knowledge. UserPromptSubmit supplies a token for the agent to register its memory review before answering. Stop silently accepts a registered review; otherwise it requests at most one recovery, and continuation prompts do not reset this guard. Interrupt invalidates the active review token. See [Agent behavior](agents.md) for the review protocol and failure limits. Writes still require the agent to identify confirmed durable knowledge and call the CLI/MCP. Hook failures are recorded and allow the task to proceed; no automatic Cloud-to-local fallback occurs. Use `mmx status` to inspect observed hook delivery, or `mmx doctor` to check installation and Codex hook capability; neither can verify that Codex trusted a definition or used the returned context.
45
+
46
+ ## Interactive menu
47
+
48
+ Run `mmx` without arguments in a terminal to open the arrow-key menu. An unconfigured project offers setup first. Configured projects offer status, live connection checks, diagnosis and repair, Brain switching, and agent configuration. More options include removing selected agent connections and resetting local setup. Removal requires confirmation; local reset retains its own scope preview and confirmation. Actions return to the menu, and Ctrl+C or Exit closes it.
49
+
50
+ `mmx --help` always prints command help. Running without arguments in a non-interactive environment, or with `--json` or `--yes`, prints help without waiting for input. Explicit subcommands remain available for scripts.
51
+
52
+ ## Diagnose and repair
53
+
54
+ ```bash
55
+ mmx doctor # Readable local diagnostics; no network calls.
56
+ mmx doctor --online # Also check Brain access and MCP recall.
57
+ mmx doctor --fix # Review the repair plan and confirm with arrow keys.
58
+ mmx doctor --json # Structured report, including the repair plan.
59
+ mmx doctor --fix --yes --json # Explicit non-interactive repair approval.
60
+ ```
61
+
62
+ Doctor explains each problem and the suggested next action. Repair restores missing setup-managed entries and instructions/hooks, refreshes stale executable paths, and preserves unrelated configuration, the Brain binding, login, and Brain data. It backs up project configuration and runs an MCP recall check; a failed check rolls back configuration. Cloud repair can require browser login. Restart the configured agents after successful repair.
63
+
64
+ Modified MCP entries, malformed configuration, unsafe paths, and conflicting integrations are not overwritten. If project files change after the repair plan is shown, repair stops so you can review a new plan. Connect-only integrations are diagnosed, but automatic repair requires a setup-managed installation. Use `mmx setup` for initial configuration. Diagnostics return a nonzero exit status while errors remain; warnings alone do not fail the command. Doctor output now defaults to text, so scripts should explicitly pass `--json`.
65
+
66
+ ## Check status and switch Brains
67
+
68
+ ```bash
69
+ mmx status # Local configuration and observed activity; no network calls.
70
+ mmx status --online # Also check Brain access and the configured MCP launcher.
71
+ mmx status --json # Structured details for scripts.
72
+ mmx switch # Choose a Workspace and Project with arrow keys.
73
+ mmx switch --brain-id <brain-id> --yes
74
+ mmx switch --local --yes
75
+ ```
76
+
77
+ `status` distinguishes saved credentials, agent configuration, live read-only checks, successful MCP client tool calls, and hook context delivery. Successful setup is described as **Configured for**, because it does not establish that the agent has connected. Codex uses native lifecycle hooks alongside project instructions. Project-local hooks require a trusted project and review of each hook definition through `/hooks`. Neither a tool call nor delivered context proves that the model used the knowledge in its answer.
78
+
79
+ Usage receipts are bounded to the most recent successful MCP tool call and each hook event. They record timestamps, client/tool/operation names and a binding fingerprint, without tool arguments or results. Setup and status probes do not count as agent activity. Status ignores receipts from a different binding or before the latest successful setup; it cannot observe calls made directly to a separate remote MCP connection or CLI.
80
+
81
+ `switch` requires an existing `setup` installation and reuses all setup-managed agents. It keeps login credentials and Brain data. The selected Brain must pass validation and the MCP recall check; failures restore the previous binding and project configuration. Ctrl+C at a selection prompt cancels without changing the binding. Restart the agent after switching so its MCP server uses the new Brain.
82
+
83
+ If Cloud Project creation succeeds but a later setup step fails, the error provides a command with that Brain ID to resume installation. The Cloud Project is retained. A local creation journal prevents a known creation from being replayed. If a creation request loses its response, inspect `mmx project list` before trying again; writes are never automatically retried.
84
+
85
+ ## Existing integrations and migration
86
+
87
+ Codex merges global and project entries with the same name. The local transport therefore uses a separate name. Recognized global MindMux remote entries are disabled only in the current project through an `enabled = false` override; global configuration remains intact. Setup stops if a global `mindmux_cli` entry would conflict with the project transport.
88
+
89
+ Use `mmx setup --migrate` to replace an existing project-level remote MCP entry. The original value is backed up and restored by `remove`. Initial TOML migration may reorder content or move comments; the complete original file is retained in the backup. Subsequent ordinary installs preserve unmanaged content. User-modified managed MCP entries are protected from replacement and removal.
90
+
91
+ Migration also invokes the official brain.md project hook uninstaller for recognized legacy SessionStart hooks. Global brain.md skills and other global settings are reported but are not removed. Inspect custom aliases and higher-priority Claude local-scope entries in the agent itself.
92
+
93
+ Configuration backups are stored under `~/.mindmux-cli/backups/` or `MINDMUX_HOME/backups/`, outside the project, with mode `0600`. Failed installation or self-check restores project configuration. Brain data and successfully created remote Projects survive rollback. A creation journal prevents blindly repeating a remote creation whose outcome is unknown; inspect `mmx project list` before retrying when instructed.
94
+
95
+ `remove` removes setup-managed project integrations while retaining Brain data, binding, login, and unrelated configuration. For integrations installed only with `connect`, use `disconnect`.
96
+
97
+ ## Reset for testing
98
+
99
+ Run `mmx clean` in the project to reset its local MindMux state. The arrow-key confirmation lists the cleanup scope before anything is removed.
100
+
101
+ ```bash
102
+ mmx clean
103
+ mmx setup
104
+
105
+ # Reset the project while keeping CLI login.
106
+ mmx clean --keep-login
107
+
108
+ # Explicit confirmation for non-interactive scripts.
109
+ mmx clean --yes --json
110
+ ```
111
+
112
+ Cleanup removes managed MCP entries, instructions and hooks, project binding, session caches, local Brain data, and this project's configuration backups. By default, it also removes **all CLI login credentials and the saved server setting** from the current `MINDMUX_HOME`, which signs out other projects sharing that CLI login. `--keep-login` retains both. This removes local credentials; it does not revoke server grants or end a browser session.
113
+
114
+ **Cloud Projects and Brains are always kept.** Existing cloud Projects can be selected in the next setup. Unrelated agent configuration, custom instructions, unknown preference fields, and other projects' backups are preserved. Empty generated files are removed, and an unchanged brain.md scaffold is removed with local Brain data. Git ignore rules are retained.
115
+
116
+ Cleanup refuses modified managed MCP entries, unsafe paths, symbolic links, and active setup/write/authentication locks. Stop active agents before resetting. A configured local Brain outside the project requires `--include-external-data`; its path is shown in the confirmation. Local data deletion cannot be undone by `remove`.