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
@@ -0,0 +1,63 @@
1
+ ---
2
+ description:
3
+ globs:
4
+ alwaysApply: false
5
+ ---
6
+ # Rule: Generating an Activity Definition
7
+
8
+ ## Goal
9
+
10
+ To guide an AI assistant in creating a detailed Activity Definition in Markdown format, based on an initial user prompt. The Activity should be clear, actionable, and suitable for a junior developer to understand and implement the feature or improvement for the cntx-ui project.
11
+
12
+ ## Process
13
+
14
+ 1. **Receive Initial Prompt:** The user provides a brief description or request for a new feature, improvement, or functionality for cntx-ui.
15
+ 2. **Ask Clarifying Questions:** Before writing the Activity, the AI *must* ask clarifying questions to gather sufficient detail. The goal is to understand the "what" and "why" of the activity, not necessarily the "how" (which the developer will figure out). Make sure to provide options in letter/number lists so I can respond easily with my selections.
16
+ 3. **Generate Activity:** Based on the initial prompt and the user's answers to the clarifying questions, generate an Activity using the structure outlined below.
17
+ 4. **Save Activity:** Save the generated document as `activity-[feature-name].md` inside the `.cntx/activities/[activity-name]/` directory.
18
+
19
+ ## Clarifying Questions (Examples)
20
+
21
+ The AI should adapt its questions based on the prompt, but here are some common areas to explore:
22
+
23
+ * **Problem/Goal:** "What problem does this activity solve for cntx-ui users?" or "What is the main goal we want to achieve with this activity?"
24
+ * **Target User:** "Who is the primary user of this feature? (e.g., developers using cntx-ui, AI assistants, end users of bundled applications)"
25
+ * **Core Functionality:** "Can you describe the key actions a user should be able to perform with this feature?"
26
+ * **User Stories:** "Could you provide a few user stories? (e.g., As a [type of user], I want to [perform an action] so that [benefit].)"
27
+ * **Acceptance Criteria:** "How will we know when this activity is successfully implemented? What are the key success criteria?"
28
+ * **Scope/Boundaries:** "Are there any specific things this activity *should not* do (non-goals)?"
29
+ * **Data Requirements:** "What kind of data does this feature need to display or manipulate? (e.g., bundle configurations, file metadata, semantic chunks)"
30
+ * **Design/UI:** "Are there any existing design patterns in cntx-ui to follow?" or "Can you describe the desired look and feel?"
31
+ * **Edge Cases:** "Are there any potential edge cases or error conditions we should consider?"
32
+
33
+ ## Activity Structure
34
+
35
+ The generated Activity should include the following sections:
36
+
37
+ 1. **Introduction/Overview:** Briefly describe the activity and the problem it solves for cntx-ui. State the goal.
38
+ 2. **Goals:** List the specific, measurable objectives for this activity.
39
+ 3. **User Stories:** Detail the user narratives describing activity usage and benefits.
40
+ 4. **Functional Requirements:** List the specific functionalities the activity must have. Use clear, concise language (e.g., "The system must allow users to configure bundle rules."). Number these requirements.
41
+ 5. **Non-Goals (Out of Scope):** Clearly state what this activity will *not* include to manage scope.
42
+ 6. **Design Considerations (Optional):** Link to existing UI components, describe UI/UX requirements, or mention relevant cntx-ui components/styles if applicable.
43
+ 7. **Technical Considerations (Optional):** Mention any known technical constraints, dependencies, or suggestions (e.g., "Should integrate with the existing bundle management system").
44
+ 8. **Success Metrics:** How will the success of this activity be measured? (e.g., "Improve bundle generation speed by 20%", "Reduce configuration errors by 50%").
45
+ 9. **Open Questions:** List any remaining questions or areas needing further clarification.
46
+
47
+ ## Target Audience
48
+
49
+ Assume the primary reader of the Activity is a **junior developer** working on cntx-ui. Therefore, requirements should be explicit, unambiguous, and avoid jargon where possible. Provide enough detail for them to understand the activity's purpose and core logic.
50
+
51
+ ## Output
52
+
53
+ * **Format:** Markdown (`.md`)
54
+ * **Location:** `.cntx/activities/activities/[activity-name]/`
55
+ * **Filename:** `README.md`
56
+
57
+ ## Final instructions
58
+
59
+ 1. Do NOT start implementing the Activity
60
+ 2. Make sure to ask the user clarifying questions
61
+ 3. Take the user's answers to the clarifying questions and improve the Activity
62
+ 4. Consider how this activity fits into the broader cntx-ui ecosystem of file bundling and AI development tools
63
+ 5. **REQUIRED**: After creating the activity README.md, update `.cntx/activities/activities.json` to register the new activity with proper title, description, desired_outcome, references, status, and tasks
@@ -0,0 +1,64 @@
1
+ ---
2
+ description:
3
+ globs:
4
+ alwaysApply: false
5
+ ---
6
+ # Rule: Generating a Task List from a PRD
7
+
8
+ ## Goal
9
+
10
+ To guide an AI assistant in creating a detailed, step-by-step task list in Markdown format based on an existing Product Requirements Document (PRD). The task list should guide a developer through implementation.
11
+
12
+ ## Output
13
+
14
+ - **Format:** Markdown (`.md`)
15
+ - **Location:** `/tasks/`
16
+ - **Filename:** `tasks-[prd-file-name].md` (e.g., `tasks-prd-user-profile-editing.md`)
17
+
18
+ ## Process
19
+
20
+ 1. **Receive PRD Reference:** The user points the AI to a specific PRD file
21
+ 2. **Analyze PRD:** The AI reads and analyzes the functional requirements, user stories, and other sections of the specified PRD.
22
+ 3. **Phase 1: Generate Parent Tasks:** Based on the PRD analysis, create the file and generate the main, high-level tasks required to implement the feature. Use your judgement on how many high-level tasks to use. It's likely to be about 5. Present these tasks to the user in the specified format (without sub-tasks yet). Inform the user: "I have generated the high-level tasks based on the PRD. Ready to generate the sub-tasks? Respond with 'Go' to proceed."
23
+ 4. **Wait for Confirmation:** Pause and wait for the user to respond with "Go".
24
+ 5. **Phase 2: Generate Sub-Tasks:** Once the user confirms, break down each parent task into smaller, actionable sub-tasks necessary to complete the parent task. Ensure sub-tasks logically follow from the parent task and cover the implementation details implied by the PRD.
25
+ 6. **Identify Relevant Files:** Based on the tasks and PRD, identify potential files that will need to be created or modified. List these under the `Relevant Files` section, including corresponding test files if applicable.
26
+ 7. **Generate Final Output:** Combine the parent tasks, sub-tasks, relevant files, and notes into the final Markdown structure.
27
+ 8. **Save Task List:** Save the generated document in the `/tasks/` directory with the filename `tasks-[prd-file-name].md`, where `[prd-file-name]` matches the base name of the input PRD file (e.g., if the input was `prd-user-profile-editing.md`, the output is `tasks-prd-user-profile-editing.md`).
28
+
29
+ ## Output Format
30
+
31
+ The generated task list _must_ follow this structure:
32
+
33
+ ```markdown
34
+ ## Relevant Files
35
+
36
+ - `path/to/potential/file1.ts` - Brief description of why this file is relevant (e.g., Contains the main component for this feature).
37
+ - `path/to/file1.test.ts` - Unit tests for `file1.ts`.
38
+ - `path/to/another/file.tsx` - Brief description (e.g., API route handler for data submission).
39
+ - `path/to/another/file.test.tsx` - Unit tests for `another/file.tsx`.
40
+ - `lib/utils/helpers.ts` - Brief description (e.g., Utility functions needed for calculations).
41
+ - `lib/utils/helpers.test.ts` - Unit tests for `helpers.ts`.
42
+
43
+ ### Notes
44
+
45
+ - Unit tests should typically be placed alongside the code files they are testing (e.g., `MyComponent.tsx` and `MyComponent.test.tsx` in the same directory).
46
+ - Use `npx jest [optional/path/to/test/file]` to run tests. Running without a path executes all tests found by the Jest configuration.
47
+
48
+ ## Tasks
49
+
50
+ - [ ] 1.0 Parent Task Title
51
+ - [ ] 1.1 [Sub-task description 1.1]
52
+ - [ ] 1.2 [Sub-task description 1.2]
53
+ - [ ] 2.0 Parent Task Title
54
+ - [ ] 2.1 [Sub-task description 2.1]
55
+ - [ ] 3.0 Parent Task Title (may not require sub-tasks if purely structural or configuration)
56
+ ```
57
+
58
+ ## Interaction Model
59
+
60
+ The process explicitly requires a pause after generating parent tasks to get user confirmation ("Go") before proceeding to generate the detailed sub-tasks. This ensures the high-level plan aligns with user expectations before diving into details.
61
+
62
+ ## Target Audience
63
+
64
+ Assume the primary reader of the task list is a **junior developer** who will implement the feature.
@@ -0,0 +1,52 @@
1
+ ---
2
+ description:
3
+ globs:
4
+ alwaysApply: false
5
+ ---
6
+ # Task List Management
7
+
8
+ Guidelines for managing task lists in markdown files to track progress on completing a PRD
9
+
10
+ ## Task Implementation
11
+ - **One sub-task at a time:** Do **NOT** start the next sub‑task until you ask the user for permission and they say "yes" or "y"
12
+ - **Completion protocol:**
13
+ 1. When you finish a **sub‑task**, immediately mark it as completed by changing `[ ]` to `[x]`.
14
+ 2. If **all** subtasks underneath a parent task are now `[x]`, follow this sequence:
15
+ - **First**: Run the full test suite (`pytest`, `npm test`, `bin/rails test`, etc.)
16
+ - **Only if all tests pass**: Stage changes (`git add .`)
17
+ - **Clean up**: Remove any temporary files and temporary code before committing
18
+ - **Commit**: Use a descriptive commit message that:
19
+ - Uses conventional commit format (`feat:`, `fix:`, `refactor:`, etc.)
20
+ - Summarizes what was accomplished in the parent task
21
+ - Lists key changes and additions
22
+ - References the task number and PRD context
23
+ - **Formats the message as a single-line command using `-m` flags**, e.g.:
24
+
25
+ ```
26
+ git commit -m "feat: add payment validation logic" -m "- Validates card type and expiry" -m "- Adds unit tests for edge cases" -m "Related to T123 in PRD"
27
+ ```
28
+ 3. Once all the subtasks are marked completed and changes have been committed, mark the **parent task** as completed.
29
+ - Stop after each sub‑task and wait for the user's go‑ahead.
30
+
31
+ ## Task List Maintenance
32
+
33
+ 1. **Update the task list as you work:**
34
+ - Mark tasks and subtasks as completed (`[x]`) per the protocol above.
35
+ - Add new tasks as they emerge.
36
+
37
+ 2. **Maintain the "Relevant Files" section:**
38
+ - List every file created or modified.
39
+ - Give each file a one‑line description of its purpose.
40
+
41
+ ## AI Instructions
42
+
43
+ When working with task lists, the AI must:
44
+
45
+ 1. Regularly update the task list file after finishing any significant work.
46
+ 2. Follow the completion protocol:
47
+ - Mark each finished **sub‑task** `[x]`.
48
+ - Mark the **parent task** `[x]` once **all** its subtasks are `[x]`.
49
+ 3. Add newly discovered tasks.
50
+ 4. Keep "Relevant Files" accurate and up to date.
51
+ 5. Before starting work, check which sub‑task is next.
52
+ 6. After implementing a sub‑task, update the file and then pause for user approval.
@@ -0,0 +1,65 @@
1
+ # Agent Rules Configuration - cntx-ui
2
+ # Modular agent instruction system for composable rule sets
3
+
4
+ version: "1.0.0"
5
+ project: "cntx-ui"
6
+ description: "Semantic code analysis and bundle management system"
7
+
8
+ # Core rule sets (universal across all agents)
9
+ core_rules:
10
+ - "core/performance-hierarchy.md"
11
+ - "core/codebase-navigation.md"
12
+ - "core/response-formatting.md"
13
+
14
+ # Capability modules (include if available in project)
15
+ capabilities:
16
+ vector_search:
17
+ file: "capabilities/vector-search.md"
18
+ required: true
19
+ endpoint_check: "/api/vector-db/status"
20
+
21
+ bundle_system:
22
+ file: "capabilities/bundle-system.md"
23
+ required: true
24
+ endpoint_check: "/api/bundles"
25
+
26
+ activities_system:
27
+ file: "capabilities/activities-system.md"
28
+ required: false
29
+ endpoint_check: "/api/activities"
30
+
31
+ # Project-specific context
32
+ project_context:
33
+ - "project-specific/architecture.md"
34
+
35
+ # Tool-specific optimizations
36
+ tools:
37
+ cursor:
38
+ include: ["core_rules", "capabilities", "project_context"]
39
+ output_file: ".cursorrules"
40
+ format: "markdown"
41
+
42
+ claude_code:
43
+ include: ["core_rules", "capabilities", "project_context"]
44
+ output_file: ".cntx/agent-instructions.md"
45
+ format: "markdown"
46
+
47
+ # Performance metrics and validation
48
+ validation:
49
+ vector_db_chunks: ">= 300"
50
+ response_time_target: "< 50ms"
51
+ token_efficiency_target: "> 80% vs traditional search"
52
+
53
+ # Rule precedence (later rules override earlier ones)
54
+ precedence:
55
+ 1. "core_rules" # Universal principles
56
+ 2. "capabilities" # Available system features
57
+ 3. "project_context" # Project-specific patterns
58
+ 4. "tool_specific" # Tool optimizations
59
+
60
+ # Composition metadata
61
+ metadata:
62
+ generated_by: "cntx-ui modular agent rules system"
63
+ last_updated: "2025-01-28"
64
+ schema_version: "1.0.0"
65
+ total_modules: 7
@@ -0,0 +1,234 @@
1
+ # Agent Instructions for Codebase Exploration
2
+
3
+ ## Project Overview
4
+
5
+ This repository has been analyzed by cntx-ui and is ready for intelligent agent exploration.
6
+
7
+ ## Quick Start for External Agents
8
+
9
+ If you're an agent without MCP server access, use this prompt to get up to speed:
10
+
11
+ ```
12
+ I'm working in a project that uses cntx-ui for file organization and AI collaboration. Please read these files to understand the project structure and help me with activities:
13
+
14
+ @.cntx/agent-instructions.md
15
+ @.cntx/activities/README.md
16
+ @.cntx/activities/activities.json
17
+
18
+ After reading those, please also examine:
19
+ @.cntx/activities/lib/create-activity.mdc
20
+ @.cntx/activities/lib/generate-tasks.mdc
21
+ @.cntx/activities/lib/process-task-list.mdc
22
+
23
+ These files contain the complete workflow for creating and managing activities with agent assistance.
24
+ ```
25
+
26
+ ## Your Role
27
+
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
+
30
+ ## Available Capabilities
31
+
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
+ ---
53
+
54
+ ## Operating Modes
55
+
56
+ ### Discovery Mode
57
+
58
+ _"Tell me about this codebase"_
59
+
60
+ - Start with bundle overview and purposes
61
+ - Identify architectural patterns and frameworks
62
+ - Report on code organization and key components
63
+ - Provide file counts, complexity metrics, and structure insights
64
+
65
+ ### Query Mode
66
+
67
+ _"Where is the user authentication handled?"_
68
+
69
+ - **ALWAYS use vector database first** for semantic discovery (`POST /api/vector-db/search`)
70
+ - Use precise queries like "user authentication login session"
71
+ - Fallback to traditional search only if vector DB fails
72
+ - Always provide specific file paths and line numbers from results
73
+ - Explain relationships between components
74
+
75
+ ### Feature Investigation Mode
76
+
77
+ _"I want to add dark mode—what already exists?"_
78
+
79
+ - **Vector search for related patterns** first: "theme dark mode styling colors"
80
+ - Use the format: ✅ Existing, ⚠️ Partial, ❌ Missing
81
+ - Cross-reference vector results with bundle organization
82
+ - Identify integration points and patterns to follow
83
+ - Recommend extend vs. create approaches
84
+
85
+ ### Passive Mode
86
+
87
+ _"Let's discuss the architecture before I make changes"_
88
+
89
+ - Engage in thoughtful conversation about design decisions
90
+ - Ask clarifying questions about requirements and constraints
91
+ - Suggest alternatives and trade-offs
92
+ - Plan implementation approaches collaboratively
93
+
94
+ ### Project Organizer Mode
95
+
96
+ _"Help me set up this project" or "Optimize my bundle organization"_
97
+
98
+ - **Fresh Projects**: Detect project state → Generate semantic analysis → Plan bundles → Create bundles
99
+ - **Established Projects**: Audit organization → Optimize bundles → Suggest improvements
100
+ - **Maintenance**: Cleanup stale patterns → Validate health → Recommend optimizations
101
+ - **Activities**: detect, analyze, bundle (plan), create (execute), optimize, audit, cleanup, validate
102
+
103
+ ## Response Guidelines
104
+
105
+ ### Always Include:
106
+
107
+ - **Specific file references**: `path/to/file.js:23-67`
108
+ - **Evidence level**: Based on semantic analysis, AST parsing, or heuristics
109
+ - **Confidence indicators**: "I found 3 definitive matches" vs "This appears to be related"
110
+ - **Next steps**: "Would you like me to dive deeper into X or explore Y?"
111
+
112
+ ### Response Structure:
113
+
114
+ ```
115
+ Based on semantic analysis of your codebase:
116
+
117
+ [Direct answer to the question]
118
+
119
+ Key locations:
120
+ 1. Primary implementation in `file.js:lines`
121
+ 2. Related functionality in `other.js:lines`
122
+ 3. Configuration in `config.js:lines`
123
+
124
+ [Brief explanation of how they work together]
125
+
126
+ Would you like me to [specific follow-up options]?
127
+ ```
128
+
129
+ ## Bundle-Aware Navigation
130
+
131
+ - Start exploration with bundle boundaries
132
+ - Respect existing organization patterns
133
+ - Use bundles to scope queries appropriately
134
+ - Reference bundle relationships in explanations
135
+
136
+ ## Efficiency Principles
137
+
138
+ ### Performance Hierarchy (Use in this order):
139
+
140
+ 1. **Vector Database** (20ms, 90% token savings) - `POST /api/vector-db/search`
141
+ - Use for: code discovery, pattern matching, "find functions that..."
142
+ - Query format: `{"query": "semantic description", "limit": 5, "minSimilarity": 0.2}`
143
+
144
+ 2. **Bundle System** (50ms) - `GET /api/bundles`
145
+ - Use for: project structure, file organization, high-level overview
146
+
147
+ 3. **Activities System** (30ms) - `GET /api/activities`
148
+ - Use for: agent task tracking, progress monitoring
149
+
150
+ 4. **Traditional Search** (100ms+, high token cost) - `grep/rg/Read`
151
+ - Use ONLY when: exact string matching needed, vector search fails
152
+ - Examples: specific error messages, exact function names
153
+
154
+ ### Token Optimization:
155
+ - **Vector search**: ~5k tokens per query vs 50k+ for file reading
156
+ - **Real-time updates**: Vector DB stays current with code changes
157
+ - **Comprehensive coverage**: 315+ indexed code chunks across entire codebase
158
+
159
+ ## Vector Search Examples
160
+
161
+ ### Good Query Patterns:
162
+ ```bash
163
+ # ✅ Semantic discovery
164
+ curl -X POST /api/vector-db/search -d '{"query": "React component state management", "limit": 3}'
165
+
166
+ # ✅ Pattern matching
167
+ curl -X POST /api/vector-db/search -d '{"query": "API endpoint request handling", "limit": 5}'
168
+
169
+ # ✅ Feature investigation
170
+ curl -X POST /api/vector-db/search -d '{"query": "configuration file loading parsing", "limit": 3}'
171
+ ```
172
+
173
+ ### Query by Type:
174
+ ```bash
175
+ # Find specific code types
176
+ curl -X POST /api/vector-db/search-by-type -d '{"type": "react_component", "limit": 5}'
177
+ curl -X POST /api/vector-db/search-by-type -d '{"type": "api_integration", "limit": 3}'
178
+ ```
179
+
180
+ ### Query by Domain:
181
+ ```bash
182
+ # Find by business domain
183
+ curl -X POST /api/vector-db/search-by-domain -d '{"domain": "authentication", "limit": 5}'
184
+ curl -X POST /api/vector-db/search-by-domain -d '{"domain": "user-interface", "limit": 3}'
185
+ ```
186
+
187
+ ## Common Patterns to Look For
188
+
189
+ - **React Components**: Vector search "React component JSX hooks"
190
+ - **API Endpoints**: Vector search "API endpoint route handler"
191
+ - **Configuration**: Vector search "configuration environment setup"
192
+ - **State Management**: Vector search "state management context hooks"
193
+ - **Testing**: Vector search "test suite jest unit testing"
194
+ - **Styling**: Vector search "styling CSS theme colors"
195
+
196
+ ## Project-Specific Guidance
197
+
198
+ _This section will be populated based on the specific codebase you're exploring_
199
+
200
+ ## Error Handling
201
+
202
+ ### Vector Database Fallback Strategy:
203
+
204
+ 1. **If vector search fails** (empty results, 500 error):
205
+ - Try broader/simpler query terms
206
+ - Use search-by-type or search-by-domain endpoints
207
+ - Fall back to bundle-based exploration
208
+ - Last resort: traditional grep/rg search
209
+
210
+ 2. **If vector DB is offline** (404, connection error):
211
+ - Acknowledge limitation: "Vector search unavailable, using traditional methods"
212
+ - Use bundle system for structure discovery
213
+ - Suggest rebuilding vector DB: `POST /api/vector-db/rebuild`
214
+
215
+ 3. **Query Optimization Tips**:
216
+ - Use 3-5 descriptive words for best results
217
+ - Lower minSimilarity (0.1-0.2) for broader results
218
+ - Increase limit (5-10) for more comprehensive search
219
+ - Try different semantic phrasings if first query fails
220
+
221
+ ## Conversation Flow
222
+
223
+ 1. **Listen carefully** to the human's question or request
224
+ 2. **Classify the mode** (Discovery, Query, Investigation, Passive)
225
+ 3. **Start with vector search** for semantic discovery (unless exact string matching needed)
226
+ 4. **Provide structured response** with evidence and confidence
227
+ 5. **Offer specific next steps** or follow-up options
228
+
229
+ ### Optimal Tool Usage Order:
230
+ ```
231
+ Human Query → Vector Search → [Optional: Bundle Context] → [Fallback: Traditional Search] → Response
232
+ ```
233
+
234
+ Remember: **Vector-first approach saves 90% token cost** while providing superior semantic understanding. You're here to make the codebase understandable and navigable efficiently, not to overwhelm with information.
@@ -0,0 +1,147 @@
1
+ # Activities System Capabilities
2
+
3
+ ## Overview
4
+ The activities system provides structured task management for agents, tracking progress on complex development activities through defined workflows and documentation.
5
+
6
+ ## When Available
7
+ - Check for activities endpoint: `GET /api/activities`
8
+ - Look for activities directory: `.cntx/activities/activities/`
9
+ - Verify activity definitions and progress tracking
10
+
11
+ ## Core Capabilities
12
+
13
+ ### Activity Discovery
14
+ **Endpoint**: `GET /api/activities`
15
+
16
+ **Provides**:
17
+ - List of all available activities
18
+ - Activity status and progress percentages
19
+ - Activity metadata (name, description, category)
20
+ - Complete file contents (README, progress, tasks, notes)
21
+
22
+ ### Activity Execution (Future)
23
+ **Endpoints**:
24
+ - `POST /api/activities/{id}/execute` (planned)
25
+ - `POST /api/activities/{id}/stop` (planned)
26
+
27
+ **Will provide**:
28
+ - Programmatic activity execution
29
+ - Progress monitoring and updates
30
+ - Result collection and reporting
31
+
32
+ ## Activity Structure
33
+
34
+ ### Standard Activity Format
35
+ Each activity contains:
36
+ - **README.md**: Activity definition, goals, requirements
37
+ - **progress.md**: Current status, completion tracking
38
+ - **tasks.md**: Detailed task breakdown with priorities
39
+ - **notes.md**: Implementation decisions, technical notes
40
+
41
+ ### Activity Metadata
42
+ - **Status**: pending, in_progress, completed, failed
43
+ - **Progress**: Percentage completion (0-100%)
44
+ - **Category**: Type of activity (refactoring, feature, analysis, etc.)
45
+ - **Priority**: Task importance (high, medium, low)
46
+
47
+ ## Activity Types and Use Cases
48
+
49
+ ### Development Activities
50
+ - **Feature implementation**: Adding new functionality
51
+ - **Refactoring**: Code organization and cleanup
52
+ - **Migration**: Technology or pattern updates
53
+ - **Optimization**: Performance and efficiency improvements
54
+
55
+ ### Analysis Activities
56
+ - **Architecture review**: System design evaluation
57
+ - **Code analysis**: Pattern discovery and documentation
58
+ - **Dependency audit**: Library and framework assessment
59
+ - **Security review**: Vulnerability analysis
60
+
61
+ ### Maintenance Activities
62
+ - **Documentation updates**: Keeping docs current
63
+ - **Test coverage**: Ensuring adequate testing
64
+ - **Cleanup tasks**: Removing deprecated code
65
+ - **Configuration updates**: Settings and environment management
66
+
67
+ ## Progress Tracking
68
+
69
+ ### Status Indicators
70
+ - **✅ Completed**: Task finished successfully
71
+ - **🚧 In Progress**: Currently being worked on
72
+ - **⏳ Pending**: Not yet started
73
+ - **❌ Failed**: Encountered blocking issues
74
+
75
+ ### Progress Calculation
76
+ Based on task completion percentages from tasks.md:
77
+ - Parse task status indicators
78
+ - Calculate completion ratio
79
+ - Update overall activity progress
80
+ - Track progress over time
81
+
82
+ ### Completion Criteria
83
+ Activities are considered complete when:
84
+ - All defined tasks are finished
85
+ - Success criteria are met
86
+ - Documentation is updated
87
+ - Results are validated
88
+
89
+ ## Agent Integration
90
+
91
+ ### Activity-Driven Development
92
+ Agents can use activities to:
93
+ - **Structure complex work**: Break down large tasks into manageable pieces
94
+ - **Track progress**: Monitor completion status and identify blockers
95
+ - **Coordinate effort**: Understand what work is planned vs in progress
96
+ - **Learn from context**: Use existing activities as templates
97
+
98
+ ### Activity Creation Process
99
+ 1. **Define goals**: Clear objectives and success criteria
100
+ 2. **Break down tasks**: Specific, actionable work items
101
+ 3. **Estimate effort**: Time and complexity assessments
102
+ 4. **Track progress**: Regular status updates and milestone tracking
103
+ 5. **Document results**: Lessons learned and outcomes
104
+
105
+ ### Progress Monitoring
106
+ - **Real-time updates**: Activity status reflects current work
107
+ - **Milestone tracking**: Key progress points and deliverables
108
+ - **Blocker identification**: Issues preventing progress
109
+ - **Completion validation**: Ensuring work meets requirements
110
+
111
+ ## Integration with Other Systems
112
+
113
+ ### Vector Search + Activities
114
+ - Use vector search to find activity-related code
115
+ - Reference activities in code discovery and explanation
116
+ - Connect implementation work to activity goals
117
+
118
+ ### Bundle System + Activities
119
+ - Scope activities by bundle boundaries
120
+ - Use bundle organization to plan activity tasks
121
+ - Track activity impact across bundle boundaries
122
+
123
+ ## Performance Characteristics
124
+
125
+ ### Speed
126
+ - **Activity listing**: ~30ms
127
+ - **Activity details**: ~50ms (includes file contents)
128
+ - **Token efficiency**: High (structured, relevant content)
129
+
130
+ ### Use Cases
131
+ - **Project planning**: Understanding planned and ongoing work
132
+ - **Context switching**: Quickly understanding current development state
133
+ - **Progress reporting**: Communicating status to stakeholders
134
+ - **Knowledge transfer**: Sharing implementation context and decisions
135
+
136
+ ## Best Practices
137
+
138
+ ### Activity-Aware Assistance
139
+ - **Check activity context** when helping with development tasks
140
+ - **Reference related activities** when explaining code or suggesting changes
141
+ - **Respect activity boundaries** and existing work in progress
142
+ - **Contribute to activity documentation** when making related changes
143
+
144
+ ### Integration Patterns
145
+ - **Planning**: Activities → Bundle scope → Vector search → Implementation
146
+ - **Execution**: Activity tasks → Code discovery → Implementation → Progress update
147
+ - **Review**: Activity completion → Validation → Documentation → Lessons learned