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/server.js CHANGED
@@ -12,10 +12,12 @@ import { homedir } from 'os';
12
12
 
13
13
  // Import our modular components
14
14
  import ConfigurationManager from './lib/configuration-manager.js';
15
+ import DatabaseManager from './lib/database-manager.js';
15
16
  import FileSystemManager from './lib/file-system-manager.js';
16
17
  import BundleManager from './lib/bundle-manager.js';
17
18
  import APIRouter from './lib/api-router.js';
18
19
  import WebSocketManager from './lib/websocket-manager.js';
20
+ import { AgentRuntime } from './lib/agent-runtime.js';
19
21
 
20
22
  // Import existing lib modules
21
23
  import { startMCPTransport } from './lib/mcp-transport.js';
@@ -51,8 +53,12 @@ export class CntxServer {
51
53
  this.mcpServer = null;
52
54
  this.initMessages = []; // Track initialization messages
53
55
 
56
+ // Ensure directory exists early
57
+ if (!existsSync(this.CNTX_DIR)) mkdirSync(this.CNTX_DIR, { recursive: true });
58
+
54
59
  // Initialize modular components
55
60
  this.configManager = new ConfigurationManager(cwd, { verbose: this.verbose });
61
+ this.databaseManager = new DatabaseManager(this.CNTX_DIR, { verbose: this.verbose });
56
62
  this.fileSystemManager = new FileSystemManager(cwd, { verbose: this.verbose });
57
63
  this.bundleManager = new BundleManager(this.configManager, this.fileSystemManager, this.verbose);
58
64
  this.webSocketManager = new WebSocketManager(this.bundleManager, this.configManager, { verbose: this.verbose });
@@ -61,19 +67,20 @@ export class CntxServer {
61
67
  this.semanticSplitter = new SemanticSplitter({
62
68
  maxChunkSize: 2000,
63
69
  includeContext: true,
64
- groupRelated: true,
65
70
  minFunctionSize: 50
66
71
  });
67
72
 
68
- this.vectorStore = new SimpleVectorStore({
69
- modelName: 'Xenova/all-MiniLM-L6-v2',
70
- collectionName: 'code-chunks'
73
+ this.vectorStore = new SimpleVectorStore(this.databaseManager, {
74
+ modelName: 'Xenova/all-MiniLM-L6-v2'
71
75
  });
72
76
 
73
77
  this.semanticCache = null;
74
78
  this.lastSemanticAnalysis = null;
75
79
  this.vectorStoreInitialized = false;
76
80
 
81
+ // Initialize Agent Runtime
82
+ this.agentRuntime = new AgentRuntime(this);
83
+
77
84
  // Create semantic analysis manager object for API router
78
85
  this.semanticAnalysisManager = {
79
86
  getSemanticAnalysis: () => this.getSemanticAnalysis(),
@@ -91,6 +98,7 @@ export class CntxServer {
91
98
 
92
99
  // Initialize API router with all managers
93
100
  this.apiRouter = new APIRouter(
101
+ this,
94
102
  this.configManager,
95
103
  this.bundleManager,
96
104
  this.fileSystemManager,
@@ -102,7 +110,6 @@ export class CntxServer {
102
110
  // Add references for cross-module communication
103
111
  this.bundleManager.fileSystemManager = this.fileSystemManager;
104
112
  this.bundleManager.webSocketManager = this.webSocketManager;
105
- this.apiRouter.mcpServerStarted = this.mcpServerStarted;
106
113
  }
107
114
 
108
115
  // Progress bar utility
@@ -227,6 +234,11 @@ export class CntxServer {
227
234
  this.startWatching();
228
235
  await progress.next(steps[3], 600);
229
236
 
237
+ // Trigger initial semantic analysis in background if no cache
238
+ if (!this.semanticCache) {
239
+ this.getSemanticAnalysis().catch(err => console.error('Initial semantic analysis failed:', err.message));
240
+ }
241
+
230
242
  // Step 5: Generating bundles
231
243
  if (!skipBundleGeneration) {
232
244
  this.bundleManager.generateAllBundles();
@@ -236,6 +248,9 @@ export class CntxServer {
236
248
 
237
249
  // Complete progress bar
238
250
  progress.complete();
251
+
252
+ // Generate Agent Manifest
253
+ await this.agentRuntime.generateAgentManifest();
239
254
  }
240
255
 
241
256
  // Display initialization summary
@@ -402,73 +417,78 @@ export class CntxServer {
402
417
  // === Semantic Analysis (Legacy methods for compatibility) ===
403
418
 
404
419
  async getSemanticAnalysis() {
405
- // First, try to load from cache
406
- if (!this.semanticCache) {
407
- const cacheData = this.configManager.loadSemanticCache();
408
- if (cacheData) {
409
- this.semanticCache = cacheData.analysis;
410
- this.lastSemanticAnalysis = cacheData.timestamp;
411
- return cacheData.analysis;
420
+ // 1. Try to load from SQLite first
421
+ try {
422
+ const dbChunks = this.databaseManager.db.prepare('SELECT * FROM semantic_chunks').all();
423
+ if (dbChunks.length > 0) {
424
+ if (!this.semanticCache) {
425
+ this.semanticCache = {
426
+ chunks: dbChunks.map(row => this.databaseManager.mapChunkRow(row)),
427
+ summary: { totalChunks: dbChunks.length }
428
+ };
429
+ }
430
+ return this.semanticCache;
412
431
  }
432
+ } catch (e) {
433
+ console.warn('Failed to load chunks from SQLite, performing fresh analysis...');
413
434
  }
414
435
 
415
- // Check if we need to refresh the semantic analysis
416
- const shouldRefresh = !this.semanticCache || !this.lastSemanticAnalysis;
417
-
418
- if (shouldRefresh) {
419
- try {
420
- // Auto-discover JavaScript/TypeScript files in the entire project
421
- const patterns = ['**/*.{js,jsx,ts,tsx,mjs}'];
422
-
423
- // Load bundle configuration for chunk grouping
424
- let bundleConfig = null;
425
- if (existsSync(this.configManager.CONFIG_FILE)) {
426
- bundleConfig = JSON.parse(readFileSync(this.configManager.CONFIG_FILE, 'utf8'));
427
- }
436
+ // 2. Perform fresh analysis if DB is empty
437
+ try {
438
+ const patterns = ['**/*.{js,jsx,ts,tsx,mjs}'];
439
+ let bundleConfig = null;
440
+ if (existsSync(this.configManager.CONFIG_FILE)) {
441
+ bundleConfig = JSON.parse(readFileSync(this.configManager.CONFIG_FILE, 'utf8'));
442
+ }
428
443
 
429
- this.semanticCache = await this.semanticSplitter.extractSemanticChunks(this.CWD, patterns, bundleConfig);
430
- this.lastSemanticAnalysis = Date.now();
444
+ this.semanticCache = await this.semanticSplitter.extractSemanticChunks(this.CWD, patterns, bundleConfig);
445
+ this.lastSemanticAnalysis = Date.now();
431
446
 
432
- // Only enhance chunks with embeddings if they don't already have them
433
- await this.enhanceSemanticChunksIfNeeded(this.semanticCache);
447
+ // 3. Persist chunks to SQLite immediately
448
+ if (this.semanticCache.chunks.length > 0) {
449
+ this.databaseManager.saveChunks(this.semanticCache.chunks);
450
+ }
434
451
 
435
- // Save to disk cache
436
- this.configManager.saveSemanticCache(this.semanticCache);
452
+ // 4. Trigger background embedding enhancement
453
+ this.enhanceSemanticChunksIfNeeded(this.semanticCache);
437
454
 
438
- console.log('🔍 Semantic analysis complete');
439
- } catch (error) {
440
- console.error('Semantic analysis failed:', error.message);
441
- throw new Error(`Semantic analysis failed: ${error.message}`);
442
- }
455
+ return this.semanticCache;
456
+ } catch (error) {
457
+ console.error('Semantic analysis failed:', error.message);
458
+ throw new Error(`Semantic analysis failed: ${error.message}`);
443
459
  }
444
-
445
- return this.semanticCache;
446
460
  }
447
461
 
448
462
  async refreshSemanticAnalysis() {
449
- console.log('🔄 Forcing semantic analysis refresh...');
450
-
451
- // Clear memory cache
463
+ console.log('🔄 Refreshing semantic analysis and database...');
464
+
465
+ // Clear the database table but keep other data
466
+ this.databaseManager.db.prepare('DELETE FROM semantic_chunks').run();
467
+ this.databaseManager.db.prepare('DELETE FROM vector_embeddings').run();
468
+
452
469
  this.semanticCache = null;
453
470
  this.lastSemanticAnalysis = null;
454
471
 
455
- // Remove disk cache file
456
- this.configManager.invalidateSemanticCache();
457
-
458
472
  return this.getSemanticAnalysis();
459
473
  }
460
474
 
461
475
  async enhanceSemanticChunksIfNeeded(analysis) {
462
476
  if (!analysis || !analysis.chunks) return;
463
477
 
464
- const chunksNeedingEmbeddings = analysis.chunks.filter(chunk => !chunk.embedding);
478
+ // Check DB for existing embeddings to find only what's missing
479
+ const chunksNeedingEmbeddings = [];
480
+ for (const chunk of analysis.chunks) {
481
+ if (!this.databaseManager.getEmbedding(chunk.id)) {
482
+ chunksNeedingEmbeddings.push(chunk);
483
+ }
484
+ }
465
485
 
466
486
  if (chunksNeedingEmbeddings.length === 0) {
467
- console.log('✅ All chunks already have embeddings');
487
+ console.log('✅ All chunks already have persistent embeddings');
468
488
  return;
469
489
  }
470
490
 
471
- console.log(`🔧 Enhancing ${chunksNeedingEmbeddings.length} chunks with embeddings...`);
491
+ console.log(`🔧 Enhancing ${chunksNeedingEmbeddings.length} chunks with persistent embeddings...`);
472
492
 
473
493
  // Initialize vector store if needed
474
494
  if (!this.vectorStoreInitialized) {
@@ -476,29 +496,20 @@ export class CntxServer {
476
496
  this.vectorStoreInitialized = true;
477
497
  }
478
498
 
479
- // Add embeddings to chunks that need them
499
+ // Add embeddings to chunks that need them and persist
480
500
  for (const chunk of chunksNeedingEmbeddings) {
481
501
  try {
482
- const content = this.getChunkContentForEmbedding(chunk);
483
- chunk.embedding = await this.vectorStore.generateEmbedding(content);
502
+ await this.vectorStore.upsertChunk(chunk);
484
503
  } catch (error) {
485
- console.error(`Failed to generate embedding for chunk ${chunk.id}:`, error.message);
504
+ console.error(`Failed to generate/persist embedding for chunk ${chunk.id}:`, error.message);
486
505
  }
487
506
  }
507
+ console.log('✅ Background embedding enhancement complete');
488
508
  }
489
509
 
490
- getChunkContentForEmbedding(chunk) {
491
- let content = chunk.content || '';
492
-
493
- if (chunk.businessDomains?.length > 0) {
494
- content += ' ' + chunk.businessDomains.join(' ');
495
- }
496
-
497
- if (chunk.technicalPatterns?.length > 0) {
498
- content += ' ' + chunk.technicalPatterns.join(' ');
499
- }
500
-
501
- return content.trim();
510
+ invalidateSemanticCache() {
511
+ this.semanticCache = null;
512
+ this.lastSemanticAnalysis = null;
502
513
  }
503
514
 
504
515
  async exportSemanticChunk(chunkName) {
@@ -633,7 +644,6 @@ export class CntxServer {
633
644
  if (!this.mcpServer) {
634
645
  this.mcpServer = new MCPServer(this);
635
646
  this.mcpServerStarted = true;
636
- this.apiRouter.mcpServerStarted = true;
637
647
 
638
648
  if (this.verbose) {
639
649
  console.log('🔗 MCP server started');
@@ -726,26 +736,94 @@ export async function generateBundle(bundleName = 'master') {
726
736
  return bundleInfo;
727
737
  }
728
738
 
729
- export async function initConfig() {
730
- const server = new CntxServer(process.cwd(), { verbose: false });
731
- const templateDir = join(__dirname, 'templates');
732
-
733
- // Initialize directory structure
739
+ // Initialize project configuration
740
+ export async function initConfig(cwd = process.cwd()) {
741
+ const server = new CntxServer(cwd);
742
+
743
+ // 1. Initialize directory structure
734
744
  if (!existsSync(server.CNTX_DIR)) {
735
745
  mkdirSync(server.CNTX_DIR, { recursive: true });
736
746
  console.log('📁 Created .cntx directory');
737
747
  }
738
748
 
739
- // Initialize basic configuration
749
+ // 2. Create .mcp.json for Claude Code discovery
750
+ const mcpConfigPath = join(cwd, '.mcp.json');
751
+ const mcpConfig = {
752
+ mcpServers: {
753
+ "cntx-ui": {
754
+ command: "cntx-ui",
755
+ args: ["mcp"],
756
+ cwd: "."
757
+ }
758
+ }
759
+ };
760
+ writeFileSync(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), 'utf8');
761
+ console.log('📄 Created .mcp.json for agent auto-discovery');
762
+
763
+ // 3. Initialize basic configuration with better defaults and auto-suggestions
740
764
  server.configManager.loadConfig();
741
- server.configManager.saveConfig({
742
- bundles: {
743
- master: ['**/*']
765
+
766
+ const suggestedBundles = {
767
+ master: ['**/*']
768
+ };
769
+
770
+ // Directory-based auto-suggestions
771
+ const commonDirs = [
772
+ { dir: 'src/components', name: 'ui-components' },
773
+ { dir: 'src/services', name: 'services' },
774
+ { dir: 'src/lib', name: 'libraries' },
775
+ { dir: 'src/hooks', name: 'react-hooks' },
776
+ { dir: 'server', name: 'backend-api' },
777
+ { dir: 'tests', name: 'test-suite' }
778
+ ];
779
+
780
+ commonDirs.forEach(d => {
781
+ if (existsSync(join(cwd, d.dir))) {
782
+ suggestedBundles[d.name] = [`${d.dir}/**`];
783
+ console.log(`💡 Suggested bundle: ${d.name} (${d.dir}/**)`);
744
784
  }
745
785
  });
746
786
 
787
+ server.configManager.saveConfig({
788
+ bundles: suggestedBundles
789
+ });
790
+
791
+ // 4. Create robust default .cntxignore
792
+ const ignorePath = join(cwd, '.cntxignore');
793
+ if (!existsSync(ignorePath)) {
794
+ const defaultIgnore = `# Binary files
795
+ *.db
796
+ *.db-journal
797
+ *.png
798
+ *.jpg
799
+ *.jpeg
800
+ *.ico
801
+ *.icns
802
+ *.gif
803
+ *.zip
804
+ *.tar.gz
805
+
806
+ # Generated files
807
+ **/gen/**
808
+ **/dist/**
809
+ **/build/**
810
+ **/node_modules/**
811
+ **/.next/**
812
+ **/.cache/**
813
+
814
+ # cntx-ui internals
815
+ .cntx/**
816
+ .mcp.json
817
+ `;
818
+ writeFileSync(ignorePath, defaultIgnore, 'utf8');
819
+ console.log('📄 Created .cntxignore with smart defaults');
820
+ }
821
+
747
822
  console.log('⚙️ Basic configuration initialized');
748
823
 
824
+ // ... (rest of the file remains same)
825
+ const templateDir = join(__dirname, 'templates');
826
+
749
827
  // Copy agent configuration files
750
828
  const agentFiles = [
751
829
  'agent-config.yaml',
@@ -0,0 +1,41 @@
1
+ # cntx-ui Tool Reference
2
+
3
+ This document maps the **Model Context Protocol (MCP)** tools to their **HTTP API** equivalents.
4
+
5
+ ## Core Agent Tools
6
+
7
+ | MCP Tool | HTTP Endpoint | Parameters | Description |
8
+ | :--- | :--- | :--- | :--- |
9
+ | `agent/discover` | `GET /api/status` | `scope?: string` | Architectural overview and health check. |
10
+ | `agent/query` | `POST /api/semantic-search` | `question: string` | Semantic search across the entire codebase. |
11
+ | `agent/investigate` | `POST /api/vector-db/search` | `feature: string` | Suggest integration points for new features. |
12
+ | `agent/organize` | `GET /api/bundles` | `activity: string` | Audit and optimize project bundle health. |
13
+
14
+ ## Bundle Management
15
+
16
+ | MCP Tool | HTTP Endpoint | Parameters | Description |
17
+ | :--- | :--- | :--- | :--- |
18
+ | `list_bundles` | `GET /api/bundles` | *None* | List all manual and smart bundles. |
19
+ | `get_bundle` | `GET /api/bundles/:name` | `name: string` | Get full XML content of a specific bundle. |
20
+
21
+ ## Semantic Analysis
22
+
23
+ | MCP Tool | HTTP Endpoint | Parameters | Description |
24
+ | :--- | :--- | :--- | :--- |
25
+ | `get_semantic_chunks`| `GET /api/semantic-chunks` | `refresh?: bool` | Get all surgically extracted code chunks. |
26
+ | `search_by_type` | `POST /api/vector-db/search-by-type` | `type: string` | Find chunks by AST type (e.g. arrow_function). |
27
+ | `search_by_domain` | `POST /api/vector-db/search-by-domain`| `domain: string` | Find chunks by business domain (e.g. auth). |
28
+
29
+ ## File Operations
30
+
31
+ | MCP Tool | HTTP Endpoint | Parameters | Description |
32
+ | :--- | :--- | :--- | :--- |
33
+ | `read_file` | `GET /api/files/:path` | `path: string` | Read file with injected semantic metadata. |
34
+ | `write_file` | `POST /api/files` | `path, content` | Write file with automatic backup. |
35
+
36
+ ## Activities
37
+
38
+ | MCP Tool | HTTP Endpoint | Parameters | Description |
39
+ | :--- | :--- | :--- | :--- |
40
+ | `list_activities` | `GET /api/activities` | *None* | List all ongoing agent missions. |
41
+ | `get_reasoning` | `GET /api/activities/:id/reasoning` | `id: string` | Recall agent interaction history for a task. |
@@ -24,7 +24,7 @@ Set up organized bundles for a new codebase using agent assistance to analyze pr
24
24
  1. The system must analyze the existing project structure and file types
25
25
  2. The system must suggest logical bundle groupings based on project architecture
26
26
  3. The system must create bundle configuration files with clear naming and descriptions
27
- 4. **CRITICAL**: The system must update both .cntx/bundles.json (metadata) AND .cntx/config.json (tracking patterns)
27
+ 4. **CRITICAL**: The system must update .cntx/bundle-states.json as the single source of truth for bundle definitions
28
28
  5. The system must establish rules for automatic file categorization
29
29
  6. The system must generate documentation explaining each bundle's purpose
30
30
  7. The system must allow iterative refinement of bundle structure based on user feedback
@@ -77,7 +77,8 @@ Set up organized bundles for a new codebase using agent assistance to analyze pr
77
77
 
78
78
  ## Related Files
79
79
 
80
- - `.cntx/config.json` - Main cntx-ui configuration
81
- - `.cntx/bundles.json` - Bundle definitions and rules
80
+ - `.cntx/config.json` - Non-bundle configuration settings (editor, etc.)
81
+ - `.cntx/bundle-states.json` - Single source of truth for all bundle definitions
82
82
  - `lib/bundle-manager.js` - Bundle management logic
83
+ - `lib/configuration-manager.js` - Configuration and bundle state management
83
84
  - `web/src/components/BundleList.tsx` - Bundle UI components
@@ -47,33 +47,29 @@ _Consider how bundle structure should accommodate project expansion_
47
47
 
48
48
  ### Sample Bundle Configurations
49
49
 
50
- **bundles.json** (detailed metadata):
50
+ **bundle-states.json** (single source of truth):
51
51
  ```json
52
- {
53
- "name": "ui-components",
54
- "description": "Reusable UI components and design system elements",
55
- "patterns": ["src/components/**/*.tsx", "src/ui/**/*.tsx"],
56
- "exclude": ["**/*.test.tsx", "**/*.stories.tsx"],
57
- "tags": ["ui", "components"],
58
- "priority": 1
59
- }
52
+ [
53
+ {
54
+ "name": "ui-components",
55
+ "patterns": ["src/components/**/*.tsx", "src/ui/**/*.tsx"],
56
+ "files": ["src/components/Button.tsx", "src/ui/Card.tsx"],
57
+ "content": "",
58
+ "size": 45231,
59
+ "changed": false,
60
+ "generated": "2025-06-30T08:00:00.000Z"
61
+ }
62
+ ]
60
63
  ```
61
64
 
62
- **config.json** (tracking patterns):
65
+ **config.json** (non-bundle settings only):
63
66
  ```json
64
67
  {
65
- "bundles": {
66
- "ui-components": [
67
- "src/components/**/*.tsx",
68
- "src/ui/**/*.tsx",
69
- "!**/*.test.tsx",
70
- "!**/*.stories.tsx"
71
- ]
72
- }
68
+ "editor": "cursor"
73
69
  }
74
70
  ```
75
71
 
76
- ⚠️ **CRITICAL**: Both files must be updated for bundles to appear in the UI!
72
+ ⚠️ **CRITICAL**: Use .cntx/bundle-states.json as the single source of truth for all bundle data!
77
73
 
78
74
  ### File Organization Patterns
79
75
  - Component files: Component.tsx, Component.test.tsx, Component.stories.tsx
@@ -1,7 +1,7 @@
1
1
  ## Relevant Files
2
2
 
3
- - `.cntx/config.json` - Main configuration file that will be updated with bundle settings
4
- - `.cntx/bundles.json` - Bundle definitions file that will contain all bundle configurations
3
+ - `.cntx/config.json` - Non-bundle configuration settings (editor preferences, etc.)
4
+ - `.cntx/bundle-states.json` - Single source of truth for all bundle definitions and metadata
5
5
  - `lib/bundle-manager.js` - Core bundle management logic for processing and applying bundle rules
6
6
  - `web/src/components/BundleList.tsx` - UI component for displaying and managing bundles
7
7
  - `web/src/components/BundleDetails.tsx` - UI component for viewing individual bundle contents
@@ -27,8 +27,8 @@
27
27
  - [ ] 2.3 Create bundle descriptions that explain their purpose and contents
28
28
  - [ ] 2.4 Validate bundle strategy with user and refine based on feedback
29
29
  - [ ] 3.0 Bundle Configuration Implementation
30
- - [ ] 3.1 Create bundle definitions in .cntx/bundles.json with detailed metadata
31
- - [ ] 3.2 **CRITICAL**: Update .cntx/config.json with bundle patterns for tracking
30
+ - [ ] 3.1 Create bundle definitions in .cntx/bundle-states.json with patterns and metadata
31
+ - [ ] 3.2 **CRITICAL**: Use .cntx/bundle-states.json as single source of truth (no config.json bundle data)
32
32
  - [ ] 3.3 Set up automatic file categorization rules
33
33
  - [ ] 3.4 Configure bundle metadata (descriptions, tags, priorities)
34
34
  - [ ] 3.5 Test bundle rules with sample files to ensure proper categorization
@@ -23,7 +23,7 @@
23
23
  },
24
24
  {
25
25
  "title": "Bundle Configuration Implementation",
26
- "description": "Create bundle definitions in .cntx/bundles.json and set up automatic file categorization rules.",
26
+ "description": "Create bundle definitions in .cntx/bundle-states.json and set up automatic file categorization rules.",
27
27
  "status": "todo"
28
28
  },
29
29
  {
@@ -31,8 +31,6 @@ capabilities:
31
31
  # Project-specific context
32
32
  project_context:
33
33
  - "project-specific/architecture.md"
34
- - "project-specific/patterns.md"
35
- - "project-specific/conventions.md"
36
34
 
37
35
  # Tool-specific optimizations
38
36
  tools:
@@ -40,22 +38,11 @@ tools:
40
38
  include: ["core_rules", "capabilities", "project_context"]
41
39
  output_file: ".cursorrules"
42
40
  format: "markdown"
43
- additional:
44
- - "tools/cursor-specific.md"
45
41
 
46
42
  claude_code:
47
43
  include: ["core_rules", "capabilities", "project_context"]
48
44
  output_file: ".cntx/agent-instructions.md"
49
45
  format: "markdown"
50
- additional:
51
- - "tools/claude-specific.md"
52
-
53
- github_copilot:
54
- include: ["core_rules", "capabilities"]
55
- output_file: ".github/copilot-instructions.md"
56
- format: "markdown"
57
- additional:
58
- - "tools/copilot-specific.md"
59
46
 
60
47
  # Performance metrics and validation
61
48
  validation:
@@ -25,15 +25,31 @@ These files contain the complete workflow for creating and managing activities w
25
25
 
26
26
  ## Your Role
27
27
 
28
- You are an AI agent with access to semantic code analysis, bundle organization, and vector search capabilities. Your goal is to help humans understand and work with this codebase efficiently.
28
+ You are an AI agent with access to a specialized "Repository Intelligence" engine. Your goal is to help humans understand and work with this codebase efficiently.
29
29
 
30
30
  ## Available Capabilities
31
31
 
32
- - **Vector Database** (PRIMARY): Real-time semantic search across 315+ code chunks with ~20ms response time
33
- - **Semantic Analysis**: Pre-analyzed code chunks with purpose, complexity, and relationships
34
- - **Bundle System**: Logical file groupings (frontend, backend, ui-components, etc.)
35
- - **Activities System**: Agent task definitions and progress tracking
36
- - **AST Parsing**: Precise symbol and dependency information (fallback only)
32
+ ### 1. Model Context Protocol (MCP) - PRIMARY
33
+ You have direct access to surgical intelligence tools. Refer to the **Intelligence Interface** section in `.cntx/AGENT.md` for full parameter schemas.
34
+
35
+ ### 2. HTTP API - FALLBACK
36
+ If MCP is unavailable, use the HTTP endpoints documented in `.cntx/AGENT.md`.
37
+
38
+ ## Performance Hierarchy (Use in this order):
39
+
40
+ 1. **Semantic Search** (20ms, 90% token savings) - `agent/query` (MCP) or `POST /api/semantic-search` (HTTP)
41
+ - Use for: code discovery, pattern matching, "find functions that..."
42
+
43
+ 2. **Bundle System** (50ms) - `list_bundles` (MCP) or `GET /api/bundles` (HTTP)
44
+ - Use for: project structure, file organization, high-level overview
45
+
46
+ 3. **Discovery Mode** - `agent/discover` (MCP) or `GET /api/status` (HTTP)
47
+ - Use for: architectural overview and health check.
48
+
49
+ 4. **Traditional Search** (100ms+, high token cost) - `grep/rg/Read`
50
+ - Use ONLY when: exact string matching needed, semantic search fails.
51
+
52
+ ---
37
53
 
38
54
  ## Operating Modes
39
55
 
@@ -5,7 +5,7 @@ The bundle system provides logical organization of project files into meaningful
5
5
 
6
6
  ## When Available
7
7
  - Check for bundle endpoint: `GET /api/bundles`
8
- - Look for bundle configuration files: `.cntx/bundles.json`
8
+ - Look for bundle configuration files: `.cntx/bundle-states.json`
9
9
  - Verify bundle status and organization
10
10
 
11
11
  ## Core Capabilities
@@ -61,7 +61,7 @@ cntx-ui/
61
61
  ├── .cntx/ # Configuration and cache
62
62
  │ ├── activities/ # Agent task definitions
63
63
  │ ├── agent-rules/ # Modular agent instructions
64
- │ ├── bundles.json # Bundle configuration
64
+ │ ├── bundle-states.json # Bundle configuration and metadata
65
65
  │ └── semantic-cache.json # Analysis cache
66
66
  └── server.js # Main HTTP server and API
67
67
  ```