cntx-ui 2.0.13 → 3.0.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.
Files changed (49) hide show
  1. package/README.md +51 -339
  2. package/VISION.md +110 -0
  3. package/bin/cntx-ui-mcp.sh +3 -0
  4. package/bin/cntx-ui.js +138 -55
  5. package/lib/agent-runtime.js +301 -0
  6. package/lib/agent-tools.js +370 -0
  7. package/lib/api-router.js +1161 -0
  8. package/lib/bundle-manager.js +236 -0
  9. package/lib/configuration-manager.js +760 -0
  10. package/lib/database-manager.js +397 -0
  11. package/lib/file-system-manager.js +489 -0
  12. package/lib/heuristics-manager.js +527 -0
  13. package/lib/mcp-server.js +1125 -2
  14. package/lib/semantic-splitter.js +225 -491
  15. package/lib/simple-vector-store.js +98 -0
  16. package/lib/websocket-manager.js +470 -0
  17. package/package.json +19 -25
  18. package/server.js +742 -1935
  19. package/templates/TOOLS.md +41 -0
  20. package/templates/activities/README.md +67 -0
  21. package/templates/activities/activities/create-project-bundles/README.md +84 -0
  22. package/templates/activities/activities/create-project-bundles/notes.md +98 -0
  23. package/templates/activities/activities/create-project-bundles/progress.md +63 -0
  24. package/templates/activities/activities/create-project-bundles/tasks.md +39 -0
  25. package/templates/activities/activities.json +219 -0
  26. package/templates/activities/lib/.markdownlint.jsonc +18 -0
  27. package/templates/activities/lib/create-activity.mdc +63 -0
  28. package/templates/activities/lib/generate-tasks.mdc +64 -0
  29. package/templates/activities/lib/process-task-list.mdc +52 -0
  30. package/templates/agent-config.yaml +65 -0
  31. package/templates/agent-instructions.md +234 -0
  32. package/templates/agent-rules/capabilities/activities-system.md +147 -0
  33. package/templates/agent-rules/capabilities/bundle-system.md +131 -0
  34. package/templates/agent-rules/capabilities/vector-search.md +135 -0
  35. package/templates/agent-rules/core/codebase-navigation.md +91 -0
  36. package/templates/agent-rules/core/performance-hierarchy.md +48 -0
  37. package/templates/agent-rules/core/response-formatting.md +120 -0
  38. package/templates/agent-rules/project-specific/architecture.md +145 -0
  39. package/templates/config.json +76 -0
  40. package/templates/hidden-files.json +14 -0
  41. package/web/dist/assets/index-B2OdTzzI.css +1 -0
  42. package/web/dist/assets/index-D0tBsKiR.js +2016 -0
  43. package/web/dist/cntx-ui.svg +18 -0
  44. package/web/dist/index.html +25 -8
  45. package/lib/semantic-integration.js +0 -441
  46. package/mcp-config-example.json +0 -9
  47. package/web/dist/assets/index-Ci1Q-YrQ.js +0 -611
  48. package/web/dist/assets/index-IUp4q_fr.css +0 -1
  49. package/web/dist/vite.svg +0 -21
package/README.md CHANGED
@@ -1,371 +1,83 @@
1
1
  # cntx-ui
2
2
 
3
- Minimal file bundling and tagging tool for AI development with web interface.
3
+ **cntx-ui** is the interface layer between human mental models and machine understanding of codebases. It transforms raw source code into a traversable knowledge graph for AI agents, providing surgical context management, semantic discovery, and real-time synchronization.
4
4
 
5
- ## Features
5
+ ## 🚀 Key Capabilities
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 Code Understanding
8
+ Unlike simple file bundlers, `cntx-ui` performs function-level analysis of your codebase:
9
+ - **Semantic Splitting:** Automatically extracts functions, types, and interfaces with their relevant context (imports/dependencies).
10
+ - **Heuristic Categorization:** Classifies code by purpose (e.g., API Handlers, React Hooks, UI Components) using a configurable heuristics engine.
11
+ - **Complexity Metrics:** Identifies hotspots and architectural patterns automatically.
14
12
 
15
- ## Installation
13
+ ### 🔍 Local Vector Search
14
+ Integrated RAG (Retrieval-Augmented Generation) without external dependencies:
15
+ - **Local Embeddings:** Powered by `Transformers.js` using the `all-MiniLM-L6-v2` model.
16
+ - **In-Memory Vector Store:** Perform semantic similarity searches across your codebase to find related implementations instantly.
16
17
 
17
- ### Global Installation (Recommended)
18
+ ### 🤖 AI Agent Runtime
19
+ A specialized runtime that exposes advanced behavior modes via MCP:
20
+ - **Discovery Mode:** Generates comprehensive architectural overviews.
21
+ - **Query Mode:** Answers specific questions using semantic search and AST analysis.
22
+ - **Investigation Mode:** Analyzes existing implementations to suggest integration points for new features.
23
+ - **Organizer Mode:** Audits and optimizes project organization and bundle health.
24
+
25
+ ### 📦 Smart Bundling & MCP
26
+ - **Dynamic Bundles:** Group files by human intent or machine discovery.
27
+ - **MCP Server:** Expose bundles, files, and agent tools directly to Claude Desktop or any MCP-compatible client.
28
+ - **Real-time Sync:** WebSocket-based updates ensure your AI context is always fresh.
29
+
30
+ ---
31
+
32
+ ## 🛠 Installation
18
33
 
34
+ ### Global Installation (Recommended)
19
35
  ```bash
20
36
  npm install -g cntx-ui
21
37
  ```
22
38
 
23
- ### Local Development Installation
24
-
39
+ ### Local Development
25
40
  ```bash
26
41
  git clone https://github.com/nothingdao/cntx-ui.git
27
42
  cd cntx-ui
28
43
  npm install
44
+ cd web && npm install
29
45
  ```
30
46
 
31
- ## Usage
47
+ ---
32
48
 
33
- ### Initialize a Project
49
+ ## 📖 Usage
34
50
 
51
+ ### Initialize a Project
35
52
  ```bash
36
- # Initialize cntx-ui in your project
37
53
  cntx-ui init
38
-
39
- # Start the web interface
40
54
  cntx-ui watch
41
-
42
- # Visit http://localhost:3333 to access the web UI
43
55
  ```
56
+ *Visit `http://localhost:3333` to access the Visual Dashboard.*
44
57
 
45
58
  ### CLI Commands
59
+ | Command | Description |
60
+ | :--- | :--- |
61
+ | `cntx-ui status` | View project health and bundle coverage. |
62
+ | `cntx-ui bundle <name>` | Manually trigger a bundle generation. |
63
+ | `cntx-ui setup-mcp` | Automatically configure Claude Desktop integration. |
64
+ | `cntx-ui mcp` | Start the MCP server on stdio. |
46
65
 
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
66
+ ---
88
67
 
89
- ### Prerequisites
68
+ ## 🏗 Technology Stack
69
+ - **Backend:** Node.js, `better-sqlite3`, `ws`
70
+ - **AI/ML:** `Transformers.js` (Local Embeddings), `chromadb` (Vector Store)
71
+ - **Parsing:** `tree-sitter`, Custom Semantic Splitter
72
+ - **Frontend:** React 19, TypeScript, Vite, Tailwind CSS, Radix UI, Lucide
73
+ - **Protocol:** Model Context Protocol (MCP)
90
74
 
91
- - Node.js >= 18.0.0
92
- - npm
75
+ ---
93
76
 
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
- ```
77
+ ## 🗺 Vision
78
+ We are building more than a tool; we are building **Repository Intelligence**. Our goal is to create a self-documenting, AI-optimized environment where the friction between "knowing" a codebase and "modifying" it vanishes.
188
79
 
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
- ```bash
329
- ./build.sh
330
- # Follow prompts for local testing
331
- # If tests pass, run: npm publish
332
- ```
333
-
334
- ## Configuration
335
-
336
- ### Environment Variables
337
-
338
- - `PORT` - Override default server port (default: 3333)
339
- - `NODE_ENV` - Set environment (development/production)
340
-
341
- ### Project Configuration
342
-
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
347
-
348
- ## Contributing
349
-
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
355
-
356
- ## Technology Stack
357
-
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
363
-
364
- ## License
80
+ See [VISION.md](./VISION.md) for the full roadmap.
365
81
 
82
+ ## 📄 License
366
83
  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
package/VISION.md ADDED
@@ -0,0 +1,110 @@
1
+ We're building the interface layer between human mental models and machine understanding of codebases.
2
+
3
+ ## The Complete Knowledge Graph
4
+
5
+ What we're really creating is a traversable knowledge graph for AI agents:
6
+
7
+ ```
8
+ // The full context system an AI agent can navigate:
9
+ {
10
+ project: {
11
+ fileTree: rawFileStructure, // Raw filesystem
12
+ bundles: humanDefinedCollections, // Explicit human organization
13
+ chunks: aiDiscoveredPatterns, // Machine-learned semantic groups
14
+ aiRules: contextualInstructions, // How to work with this code
15
+ metadata: projectUnderstanding // What this codebase "does"
16
+ }
17
+ }
18
+ ```
19
+
20
+ ## Multi-Layer Understanding System
21
+
22
+ Layer 1: Raw Structure (File Tree)
23
+
24
+ - Physical organization
25
+ - What files exist, where they are
26
+
27
+ Layer 2: Human Intent (Bundles)
28
+
29
+ - "These files should be considered together"
30
+ - Explicit human curation for specific purposes
31
+
32
+ Layer 3: Machine Discovery (Semantic Chunks)
33
+
34
+ - "These files naturally cluster together"
35
+ - AI-discovered relationships and patterns
36
+
37
+ Layer 4: Working Instructions (AI Rules + Context)
38
+
39
+ - "When working on X, consider Y"
40
+ - How to navigate and modify the code effectively
41
+
42
+ ## The Human ↔ Machine Interface
43
+
44
+ This becomes a bidirectional translation layer:
45
+
46
+ Human → Machine:
47
+
48
+ - "I'm working on authentication" → AI gets auth chunks + related bundles +
49
+ security rules
50
+ - "This is an e-commerce app" → AI understands domain context for better
51
+ suggestions
52
+ - "These files are related" → Creates explicit bundle relationships
53
+
54
+ Machine → Human:
55
+
56
+ - AI discovers "payment processing is tightly coupled across 12 files"
57
+ - AI suggests "these utility functions could be shared between features"
58
+ - AI provides "here's what your codebase is primarily about" overview
59
+
60
+ Ongoing Repository Intelligence
61
+
62
+ As the tool runs continuously, it builds living documentation:
63
+
64
+ ```
65
+ // Repository understanding that evolves:
66
+ {
67
+ codebasePersonality: {
68
+ primaryPurpose: "E-commerce platform with React frontend",
69
+ architecturalPatterns: ["feature-based organization", "custom hooks
70
+ pattern"],
71
+ complexityHotspots: ["payment processing", "user authentication"],
72
+ evolutionTrends: ["moving from REST to GraphQL", "adding TypeScript
73
+ gradually"]
74
+ },
75
+
76
+ workingMemory: {
77
+ recentChanges: "Auth system refactored last week",
78
+ emergingPatterns: "New utilities being created for form handling",
79
+ maintenanceNeeds: "Several components showing high complexity"
80
+ }
81
+ }
82
+ ```
83
+
84
+ ## The "What Is This Codebase About?" Dashboard
85
+
86
+ Users get a high-level strategic view:
87
+
88
+ - Semantic Map: Visual representation of chunks and relationships
89
+ - Complexity Overview: Where the hard problems live
90
+ - Evolution Tracking: How the code is changing over time
91
+ - AI Recommendations: Suggested improvements and organizational changes
92
+ - Context Preparation: Pre-built knowledge packages for different types of AI
93
+ assistance
94
+
95
+ This creates a self-documenting, AI-optimized codebase where both humans and
96
+ machines can quickly understand:
97
+
98
+ 1. What this code does
99
+ 2. How it's organized
100
+ 3. Where to make changes
101
+ 4. How different parts relate
102
+ 5. What context an AI agent needs to help effectively
103
+
104
+ The tool becomes the source of truth for codebase understanding, continuously
105
+ learning and improving its model of the project while giving humans control
106
+ over the organizational principles.
107
+
108
+ This is exactly the kind of human-AI collaboration interface that will become
109
+ essential as codebases get more complex and AI assistance becomes more
110
+ sophisticated.
@@ -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