cntx-ui 2.0.15 → 3.0.1

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 (32) hide show
  1. package/README.md +40 -344
  2. package/bin/cntx-ui-mcp.sh +3 -0
  3. package/bin/cntx-ui.js +2 -1
  4. package/lib/agent-runtime.js +161 -1340
  5. package/lib/agent-tools.js +9 -7
  6. package/lib/api-router.js +262 -79
  7. package/lib/bundle-manager.js +172 -407
  8. package/lib/configuration-manager.js +94 -59
  9. package/lib/database-manager.js +397 -0
  10. package/lib/file-system-manager.js +17 -0
  11. package/lib/heuristics-manager.js +119 -17
  12. package/lib/mcp-server.js +125 -55
  13. package/lib/semantic-splitter.js +222 -481
  14. package/lib/simple-vector-store.js +69 -300
  15. package/package.json +18 -31
  16. package/server.js +151 -73
  17. package/templates/TOOLS.md +41 -0
  18. package/templates/activities/activities/create-project-bundles/README.md +4 -3
  19. package/templates/activities/activities/create-project-bundles/notes.md +15 -19
  20. package/templates/activities/activities/create-project-bundles/tasks.md +4 -4
  21. package/templates/activities/activities.json +1 -1
  22. package/templates/agent-config.yaml +0 -13
  23. package/templates/agent-instructions.md +22 -6
  24. package/templates/agent-rules/capabilities/bundle-system.md +1 -1
  25. package/templates/agent-rules/project-specific/architecture.md +1 -1
  26. package/web/dist/assets/index-B2OdTzzI.css +1 -0
  27. package/web/dist/assets/index-D0tBsKiR.js +2016 -0
  28. package/web/dist/index.html +2 -2
  29. package/mcp-config-example.json +0 -9
  30. package/web/dist/assets/heuristics-manager-browser-DfonOP5I.js +0 -1
  31. package/web/dist/assets/index-dF3qg-y_.js +0 -2486
  32. package/web/dist/assets/index-h5FGSg_P.css +0 -1
package/README.md CHANGED
@@ -1,371 +1,67 @@
1
1
  # cntx-ui
2
2
 
3
- Minimal file bundling and tagging tool for AI development with web interface.
3
+ Semantic code analysis and context management for AI agents. Turns a codebase into searchable, structured context that agents can navigate efficiently.
4
4
 
5
- ## Features
5
+ ## What it does
6
6
 
7
- - File bundling and organization for AI development workflows
8
- - Web-based UI for managing bundles and configurations
9
- - **Model Context Protocol (MCP) server** for AI integration
10
- - Hidden files management
11
- - Cursor rules integration
12
- - WebSocket-based real-time updates
13
- - CLI tools for automation
7
+ - **Semantic analysis** parses your code at the function level using tree-sitter, extracts purpose, complexity, and relationships
8
+ - **Local vector search** — embeds code chunks locally (all-MiniLM-L6-v2 via Transformers.js) for semantic similarity search with no external API calls
9
+ - **Bundle system** group files into logical bundles (by feature, layer, or pattern) for structured context delivery
10
+ - **MCP server** — exposes 28+ tools to Claude Code, Claude Desktop, or any MCP-compatible client
11
+ - **Web dashboard** — visual interface at localhost:3333 for managing bundles, browsing semantic analysis, and editing agent rules
12
+ - **Real-time sync** — watches for file changes and keeps analysis, bundles, and embeddings current
14
13
 
15
- ## Installation
16
-
17
- ### Global Installation (Recommended)
14
+ ## Install
18
15
 
19
16
  ```bash
20
17
  npm install -g cntx-ui
21
18
  ```
22
19
 
23
- ### Local Development Installation
24
-
25
- ```bash
26
- git clone https://github.com/nothingdao/cntx-ui.git
27
- cd cntx-ui
28
- npm install
29
- ```
30
-
31
20
  ## Usage
32
21
 
33
- ### Initialize a Project
34
-
35
- ```bash
36
- # Initialize cntx-ui in your project
37
- cntx-ui init
38
-
39
- # Start the web interface
40
- cntx-ui watch
41
-
42
- # Visit http://localhost:3333 to access the web UI
43
- ```
44
-
45
- ### CLI Commands
46
-
47
- ```bash
48
- # Generate bundles
49
- cntx-ui bundle <name>
50
-
51
- # Check project status
52
- cntx-ui status
53
-
54
- # Start web server on custom port
55
- cntx-ui watch [port]
56
-
57
- # Start web server with MCP status tracking
58
- cntx-ui watch --with-mcp
59
-
60
- # Start MCP server for AI integration
61
- cntx-ui mcp
62
-
63
- # Add project to Claude Desktop MCP configuration
64
- cntx-ui setup-mcp
65
- ```
66
-
67
- ### MCP Integration
68
-
69
- cntx-ui can function as an MCP (Model Context Protocol) server, providing AI tools with direct access to your project bundles:
70
-
71
- ```bash
72
- # Start MCP server
73
- cntx-ui mcp
74
- ```
75
-
76
- **Available MCP Resources:**
77
- - `cntx://bundle/<name>` - Access any bundle as XML content
78
- - `cntx://file/<path>` - Access individual project files
79
-
80
- **Available MCP Tools:**
81
- - `list_bundles` - List all available bundles
82
- - `get_bundle` - Retrieve specific bundle content
83
- - `generate_bundle` - Regenerate a bundle
84
- - `get_file_tree` - Get project file structure
85
- - `get_project_status` - Get current project status
86
-
87
- ## Development
88
-
89
- ### Prerequisites
90
-
91
- - Node.js >= 18.0.0
92
- - npm
93
-
94
- ### Setup Development Environment
95
-
96
- 1. **Clone and install dependencies:**
97
- ```bash
98
- git clone https://github.com/nothingdao/cntx-ui.git
99
- cd cntx-ui
100
- npm install
101
- ```
102
-
103
- 2. **Install web dependencies:**
104
- ```bash
105
- cd web
106
- npm install
107
- cd ..
108
- ```
109
-
110
- ### Development Workflow
111
-
112
- #### Running in Development Mode
113
-
114
- 1. **Start the backend server:**
115
- ```bash
116
- npm run dev
117
- ```
118
-
119
- 2. **Start the frontend development server:**
120
- ```bash
121
- npm run dev:web
122
- ```
123
-
124
- The web interface will be available at `http://localhost:5173` (Vite dev server)
125
-
126
- #### Building the Project
127
-
128
- 1. **Build web interface only:**
129
- ```bash
130
- npm run build:web
131
- ```
132
-
133
- 2. **Build entire project:**
134
- ```bash
135
- npm run build
136
- ```
137
-
138
- 3. **Automated build with validation:**
139
- ```bash
140
- ./build.sh
141
- ```
142
-
143
- ### Project Structure
144
-
145
- ```
146
- cntx-ui/
147
- ├── bin/ # CLI executable
148
- ├── web/ # React frontend
149
- │ ├── src/
150
- │ │ ├── components/ # React components
151
- │ │ ├── hooks/ # Custom hooks
152
- │ │ ├── utils/ # Utility functions
153
- │ │ └── lib/ # Libraries and configurations
154
- │ ├── dist/ # Built frontend (generated)
155
- │ └── package.json # Frontend dependencies
156
- ├── server.js # WebSocket server
157
- ├── package.json # Main package configuration
158
- ├── build.sh # Build automation script
159
- └── test-local.sh # Local testing script
160
- ```
161
-
162
- ### Available Scripts
163
-
164
- | Script | Description |
165
- |--------|-------------|
166
- | `npm run dev` | Start backend server |
167
- | `npm run dev:web` | Start frontend dev server |
168
- | `npm run build` | Build entire project |
169
- | `npm run build:web` | Build frontend only |
170
- | `npm test:local` | Install and test package locally |
171
-
172
- ## MCP Server Setup
173
-
174
- ### Quick Setup with setup-mcp Command
175
-
176
- The easiest way to configure cntx-ui for Claude Desktop:
177
-
178
- ```bash
179
- # Navigate to your project directory
180
- cd /path/to/your/project
181
-
182
- # Initialize cntx-ui if not already done
183
- cntx-ui init
184
-
185
- # Add this project to Claude Desktop MCP configuration
186
- cntx-ui setup-mcp
187
- ```
188
-
189
- This automatically adds your project to Claude Desktop's configuration file and allows you to work with multiple projects simultaneously.
190
-
191
- ### Claude Desktop Integration
192
-
193
- #### Multi-Project Setup (Recommended)
194
-
195
- You can use cntx-ui across multiple projects by running `setup-mcp` in each project directory:
196
-
197
- ```bash
198
- # Project 1
199
- cd /Users/you/project1
200
- cntx-ui setup-mcp
201
-
202
- # Project 2
203
- cd /Users/you/project2
204
- cntx-ui setup-mcp
205
- ```
206
-
207
- This creates entries in your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json`):
208
-
209
- ```json
210
- {
211
- "mcpServers": {
212
- "cntx-ui-project1": {
213
- "command": "sh",
214
- "args": ["-c", "cd /Users/you/project1 && node /path/to/cntx-ui/bin/cntx-ui.js mcp"],
215
- "cwd": "/Users/you/project1"
216
- },
217
- "cntx-ui-project2": {
218
- "command": "sh",
219
- "args": ["-c", "cd /Users/you/project2 && node /path/to/cntx-ui/bin/cntx-ui.js mcp"],
220
- "cwd": "/Users/you/project2"
221
- }
222
- }
223
- }
224
- ```
225
-
226
- #### Manual Configuration
227
-
228
- For manual setup, add to your Claude Desktop configuration:
229
-
230
- ```json
231
- {
232
- "mcpServers": {
233
- "cntx-ui-projectname": {
234
- "command": "sh",
235
- "args": ["-c", "cd /path/to/your/project && cntx-ui mcp"],
236
- "cwd": "/path/to/your/project"
237
- }
238
- }
239
- }
240
- ```
241
-
242
- ### Other MCP Clients
243
-
244
- For other MCP-compatible clients, use:
245
- - **Command**: `cntx-ui mcp`
246
- - **Transport**: stdio
247
- - **Working Directory**: Your project root
248
-
249
- ### MCP Workflow
250
-
251
- 1. **Setup**: Run `cntx-ui setup-mcp` in each project you want to use with Claude Desktop
252
- 2. **Visual Configuration**: Use `cntx-ui watch` to configure bundles via web UI
253
- 3. **AI Integration**: AI clients connect via MCP to access bundles across all configured projects
254
- 4. **Real-time Updates**: Changes in web UI immediately available to AI tools
255
- 5. **Multi-Project**: Claude Desktop can access bundles from all configured projects simultaneously
256
-
257
- ## Testing
258
-
259
- ### Local Testing
260
-
261
- 1. **Run automated test suite:**
262
- ```bash
263
- ./test-local.sh
264
- ```
265
-
266
- 2. **Manual testing:**
267
- ```bash
268
- # Build and pack
269
- npm run build
270
- npm pack
271
-
272
- # Install globally for testing
273
- npm install -g ./cntx-ui-*.tgz
274
-
275
- # Test in a new project
276
- mkdir test-project && cd test-project
277
- cntx-ui init
278
- cntx-ui watch
279
- ```
280
-
281
- ### Test Coverage
282
-
283
- The test suite covers:
284
- - Project initialization
285
- - Bundle generation
286
- - Web server functionality
287
- - API endpoints
288
- - File management operations
289
-
290
- ## Publishing
291
-
292
- ### Prerequisites for Publishing
293
-
294
- - npm account with publish permissions
295
- - Clean git working directory
296
- - All tests passing
297
-
298
- ### Publishing Steps
299
-
300
- 1. **Update version:**
301
- ```bash
302
- npm version patch # or minor/major
303
- ```
304
-
305
- 2. **Build and validate:**
306
- ```bash
307
- ./build.sh
308
- ```
309
-
310
- 3. **Test locally:**
311
- ```bash
312
- ./test-local.sh
313
- ```
314
-
315
- 4. **Publish to npm:**
316
- ```bash
317
- # Stable release
318
- npm publish
319
-
320
- # Beta release
321
- npm publish --tag beta
322
- ```
323
-
324
- ### Automated Publishing Workflow
325
-
326
- Use the build script for a complete workflow:
327
-
328
22
  ```bash
329
- ./build.sh
330
- # Follow prompts for local testing
331
- # If tests pass, run: npm publish
23
+ cntx-ui init # scaffold .cntx directory, generate .mcp.json
24
+ cntx-ui watch # start web server on port 3333
25
+ cntx-ui mcp # start MCP server on stdio
26
+ cntx-ui bundle <name> # regenerate a specific bundle
27
+ cntx-ui status # show project health and bundle state
28
+ cntx-ui setup-mcp # configure Claude Desktop integration
332
29
  ```
333
30
 
334
- ## Configuration
31
+ After `cntx-ui init`, agents discover tools automatically via `.mcp.json`. The `.cntx/AGENT.md` file provides an onboarding handshake with tool reference and project overview.
335
32
 
336
- ### Environment Variables
33
+ ## Agent interface
337
34
 
338
- - `PORT` - Override default server port (default: 3333)
339
- - `NODE_ENV` - Set environment (development/production)
35
+ Agents interact through MCP tools or the HTTP API:
340
36
 
341
- ### Project Configuration
37
+ | MCP Tool | What it does |
38
+ | :--- | :--- |
39
+ | `agent/discover` | Architectural overview of the codebase |
40
+ | `agent/query` | Semantic search — "where is auth handled?" |
41
+ | `agent/investigate` | Find integration points for a new feature |
42
+ | `agent/organize` | Audit and optimize bundle structure |
43
+ | `list_bundles` | List all bundles with metadata |
44
+ | `get_bundle` | Get full bundle content as XML |
45
+ | `get_semantic_chunks` | Get all analyzed code chunks |
46
+ | `read_file` / `write_file` | File operations with bundle context |
342
47
 
343
- cntx-ui creates these files in your project:
344
- - `.cntx/config.json` - Main configuration
345
- - `.cntxignore` - Files to ignore
346
- - `.cursorrules` - Cursor editor rules
48
+ Full tool reference with parameters is generated in `.cntx/AGENT.md` and `.cntx/TOOLS.md`.
347
49
 
348
- ## Contributing
50
+ ## How it works
349
51
 
350
- 1. Fork the repository
351
- 2. Create a feature branch
352
- 3. Make changes following the existing code style
353
- 4. Run tests: `./test-local.sh`
354
- 5. Submit a pull request
52
+ 1. **tree-sitter** parses source files into AST, extracts functions/types/interfaces
53
+ 2. **Heuristics engine** classifies each chunk by purpose, business domain, and technical patterns based on file paths, imports, and naming conventions
54
+ 3. **Embeddings** are generated locally and stored in SQLite for persistent vector search
55
+ 4. **Bundles** group files by glob patterns — auto-suggested on init based on project structure
56
+ 5. **MCP server** and **HTTP API** expose everything to agents with consistent response shapes
355
57
 
356
- ## Technology Stack
58
+ ## Tech stack
357
59
 
358
- - **Backend:** Node.js, WebSocket (ws)
359
- - **Frontend:** React 19, TypeScript, Vite
360
- - **UI:** Tailwind CSS, Radix UI
361
- - **State Management:** TanStack Query
362
- - **Build Tools:** Vite, TypeScript compiler
60
+ - Node.js, better-sqlite3, ws (WebSocket)
61
+ - tree-sitter (AST parsing), Transformers.js (local embeddings)
62
+ - React 19, TypeScript, Vite, Tailwind CSS (web dashboard)
63
+ - Model Context Protocol (MCP) via JSON-RPC 2.0
363
64
 
364
65
  ## License
365
66
 
366
67
  MIT
367
-
368
- ## Support
369
-
370
- - GitHub Issues: [Report bugs or request features](https://github.com/nothingdao/cntx-ui/issues)
371
- - Documentation: Check the web interface for detailed usage guides
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ # Wrapper script to run cntx-ui MCP server in current directory
3
+ cd "$(pwd)" && npx cntx-ui mcp
package/bin/cntx-ui.js CHANGED
@@ -103,7 +103,8 @@ async function main() {
103
103
  case 'watch':
104
104
  case 'w':
105
105
  const port = parseInt(args[1]) || 3333;
106
- const withMcp = args.includes('--with-mcp');
106
+ // Enable MCP status tracking by default for the web dashboard
107
+ const withMcp = !args.includes('--no-mcp');
107
108
  await startServer({ port, withMcp, verbose: isVerbose });
108
109
  break;
109
110