@exaudeus/workrail 0.1.1 โ 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -189
- package/dist/application/services/classification-engine.d.ts +33 -0
- package/dist/application/services/classification-engine.js +258 -0
- package/dist/application/services/compression-service.d.ts +20 -0
- package/dist/application/services/compression-service.js +312 -0
- package/dist/application/services/context-management-service.d.ts +38 -0
- package/dist/application/services/context-management-service.js +301 -0
- package/dist/application/services/context-persistence-service.d.ts +45 -0
- package/dist/application/services/context-persistence-service.js +273 -0
- package/dist/cli/migrate-workflow.js +3 -2
- package/dist/infrastructure/storage/context-storage.d.ts +150 -0
- package/dist/infrastructure/storage/context-storage.js +40 -0
- package/dist/infrastructure/storage/filesystem-blob-storage.d.ts +27 -0
- package/dist/infrastructure/storage/filesystem-blob-storage.js +363 -0
- package/dist/infrastructure/storage/hybrid-context-storage.d.ts +29 -0
- package/dist/infrastructure/storage/hybrid-context-storage.js +400 -0
- package/dist/infrastructure/storage/migrations/001_initial_schema.sql +38 -0
- package/dist/infrastructure/storage/migrations/002_context_concurrency_enhancements.sql +234 -0
- package/dist/infrastructure/storage/migrations/003_classification_overrides.sql +20 -0
- package/dist/infrastructure/storage/sqlite-metadata-storage.d.ts +35 -0
- package/dist/infrastructure/storage/sqlite-metadata-storage.js +410 -0
- package/dist/infrastructure/storage/sqlite-migrator.d.ts +46 -0
- package/dist/infrastructure/storage/sqlite-migrator.js +293 -0
- package/dist/types/context-types.d.ts +236 -0
- package/dist/types/context-types.js +10 -0
- package/dist/utils/storage-security.js +1 -1
- package/package.json +3 -1
- package/workflows/coding-task-workflow-with-loops.json +84 -49
- package/workflows/mr-review-workflow.json +75 -26
- package/workflows/systemic-bug-investigation-with-loops.json +596 -0
- package/workflows/workflow-for-workflows.json +197 -27
package/README.md
CHANGED
|
@@ -1,270 +1,234 @@
|
|
|
1
|
-
# WorkRail:
|
|
1
|
+
# WorkRail: Guided Workflow Orchestration for AI Agents
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **Transform chaotic AI interactions into structured, reliable workflows**
|
|
4
4
|
|
|
5
|
-
[]()
|
|
6
|
-
[]()
|
|
7
5
|
[](https://modelcontextprotocol.org)
|
|
6
|
+
[]()
|
|
8
7
|
|
|
9
8
|
---
|
|
10
9
|
|
|
11
|
-
##
|
|
10
|
+
## ๐ค The Problem
|
|
12
11
|
|
|
13
|
-
Large
|
|
14
|
-
This server provides **structured, step-by-step workflows** (defined as JSON documents) that guide an AI assistant through safe, repeatable tasks.
|
|
15
|
-
It follows [Model Context Protocol (MCP)](https://modelcontextprotocol.org) conventions and exposes a **JSON-RPC 2.0** interface on `stdin/stdout`.
|
|
12
|
+
Large Language Models are incredibly powerful but suffer from well-documented limitations:
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
- **Hallucination** - They confidently generate plausible-sounding but incorrect information
|
|
15
|
+
- **Scope Creep** - Given a complex task, they often try to do too much at once, leading to half-baked solutions
|
|
16
|
+
- **Context Loss** - They struggle to maintain focus across long conversations
|
|
17
|
+
- **Inconsistency** - The same prompt can yield wildly different results based on minor variations
|
|
18
|
+
- **Missing Prerequisites** - They often start implementing before gathering necessary context
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
WorkRail now supports powerful iteration patterns with four loop types:
|
|
21
|
-
- **while**: Continue while a condition is true
|
|
22
|
-
- **until**: Continue until a condition is met
|
|
23
|
-
- **for**: Execute a fixed number of times
|
|
24
|
-
- **forEach**: Process items in an array
|
|
20
|
+
Traditional approaches try to solve these through better prompting or more powerful models. WorkRail takes a different approach.
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
## ๐ก The Solution
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## ๐ Quick Start
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
# Install globally
|
|
34
|
-
npm install -g @exaudeus/workrail
|
|
35
|
-
|
|
36
|
-
# Initialize your personal workflow directory
|
|
37
|
-
workrail init
|
|
24
|
+
WorkRail guides LLMs through **proven software engineering best practices** via structured workflows, making it much more difficult for the LLM to go off track.
|
|
38
25
|
|
|
39
|
-
|
|
40
|
-
workrail list
|
|
26
|
+
Instead of hoping an LLM will follow best practices, this system **guides them toward** best practices through structured, machine-readable workflows.
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
workrail sources
|
|
44
|
-
|
|
45
|
-
# Validate a workflow file
|
|
46
|
-
workrail validate my-workflow.json
|
|
47
|
-
|
|
48
|
-
# Start the MCP server
|
|
49
|
-
workrail start
|
|
28
|
+
**Traditional Approach:**
|
|
50
29
|
```
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
- **Bundled workflows** (included with the package)
|
|
54
|
-
- **User workflows** (`~/.workrail/workflows/`)
|
|
55
|
-
- **Project workflows** (`./workflows/`)
|
|
56
|
-
- **Custom directories** (via `WORKFLOW_STORAGE_PATH` environment variable)
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## โจ Key Features
|
|
61
|
-
|
|
62
|
-
* **Clean Architecture** โ clear separation of **Domain โ Application โ Infrastructure** layers.
|
|
63
|
-
* **MCP Protocol Support** โ Full MCP SDK integration with proper tool definitions and stdio transport.
|
|
64
|
-
* **Workflow Orchestration Tools** โ 5 core tools for workflow management:
|
|
65
|
-
- `workflow_list` - List all available workflows
|
|
66
|
-
- `workflow_get` - Get detailed workflow information
|
|
67
|
-
- `workflow_next` - Get the next step in a workflow
|
|
68
|
-
- `workflow_validate` - Advanced validation of step outputs with schema, context-aware, and composition rules
|
|
69
|
-
- `workflow_validate_json` - Direct JSON workflow validation with comprehensive error reporting and actionable suggestions
|
|
70
|
-
* **Loop Support (v0.1.0)** โ Four loop types for powerful iteration patterns:
|
|
71
|
-
- `while` loops - Continue while a condition is true
|
|
72
|
-
- `until` loops - Continue until a condition is met
|
|
73
|
-
- `for` loops - Execute a fixed number of times
|
|
74
|
-
- `forEach` loops - Process items in an array
|
|
75
|
-
* **Dependency Injection** โ pluggable components are wired by `src/container.ts` (Inversify-style, no runtime reflection).
|
|
76
|
-
* **Async, Secure Storage** โ interchangeable back-ends: in-memory (default for tests) and file-based storage with path-traversal safeguards.
|
|
77
|
-
* **Advanced ValidationEngine** โ Three-tier validation system with JSON Schema validation (AJV), Context-Aware Validation (conditional rules), and Logical Composition (and/or/not operators) for comprehensive step output quality assurance.
|
|
78
|
-
* **Typed Error Mapping** โ domain errors (`WorkflowNotFoundError`, `ValidationError`, โฆ) automatically translate to proper JSON-RPC codes.
|
|
79
|
-
* **CLI Tools** โ
|
|
80
|
-
- `validate` - Test workflow files locally with comprehensive error reporting
|
|
81
|
-
- `migrate` - Automatically migrate workflows from v0.0.1 to v0.1.0
|
|
82
|
-
* **Comprehensive Test Coverage** โ 81 tests passing, 7 failing (performance optimizations in progress), 88 total tests covering storage, validation, error mapping, CLI, and server logic.
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
## โก Quick Start
|
|
87
|
-
|
|
88
|
-
### Prerequisites
|
|
89
|
-
* Node 18+
|
|
90
|
-
* `npm install`
|
|
91
|
-
|
|
92
|
-
### Development mode
|
|
93
|
-
```bash
|
|
94
|
-
npm run dev
|
|
30
|
+
User: "Help me implement this feature"
|
|
31
|
+
AI: [May or may not ask for context, may or may not plan, may or may not test]
|
|
95
32
|
```
|
|
96
|
-
The MCP server listens for JSON-RPC requests on **stdin/stdout**.
|
|
97
33
|
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
npm run build
|
|
101
|
-
node dist/mcp-server.js
|
|
34
|
+
**WorkRail Approach:**
|
|
102
35
|
```
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
npx ts-node src/cli.ts validate <workflow-file.json>
|
|
36
|
+
Workflow guides: Context โ Clarification โ Planning โ Implementation โ Verification
|
|
37
|
+
AI: [Cannot skip steps, must follow proven patterns]
|
|
107
38
|
```
|
|
108
39
|
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
docker-compose up
|
|
112
|
-
```
|
|
40
|
+
This creates an enhanced experience where developers are guided through optimal workflows, missing fewer critical steps, while LLMs work within their strengths following proven patterns.
|
|
113
41
|
|
|
114
42
|
---
|
|
115
43
|
|
|
116
|
-
##
|
|
44
|
+
## ๐ ๏ธ MCP Tools
|
|
117
45
|
|
|
118
|
-
|
|
46
|
+
WorkRail exposes 6 core tools through the Model Context Protocol:
|
|
47
|
+
|
|
48
|
+
- **`workflow_list`** - Browse available workflows for different task types
|
|
49
|
+
- **`workflow_get`** - Get complete workflow details and requirements
|
|
50
|
+
- **`workflow_next`** - Get the next step in an active workflow
|
|
51
|
+
- **`workflow_validate`** - Validate step outputs against quality criteria
|
|
52
|
+
- **`workflow_validate_json`** - Validate and lint workflow JSON files
|
|
53
|
+
- **`workflow_get_schema`** - Get the complete workflow JSON schema for workflow creation
|
|
54
|
+
|
|
55
|
+
---
|
|
119
56
|
|
|
120
|
-
|
|
57
|
+
## โ๏ธ Installation
|
|
121
58
|
|
|
122
|
-
|
|
59
|
+
Add WorkRail to your AI agent by configuring the MCP server:
|
|
123
60
|
|
|
61
|
+
### NPX (Recommended)
|
|
62
|
+
Add to your agent's `config.json`:
|
|
124
63
|
```json
|
|
125
64
|
{
|
|
126
65
|
"mcpServers": {
|
|
127
66
|
"workrail": {
|
|
128
67
|
"command": "npx",
|
|
129
|
-
"args": [
|
|
130
|
-
"-y",
|
|
131
|
-
"@exaudeus/workrail"
|
|
132
|
-
]
|
|
68
|
+
"args": ["-y", "@exaudeus/workrail"]
|
|
133
69
|
}
|
|
134
70
|
}
|
|
135
71
|
}
|
|
136
72
|
```
|
|
137
73
|
|
|
138
|
-
|
|
139
|
-
|
|
74
|
+
### Docker
|
|
75
|
+
Add to your agent's `config.json`:
|
|
140
76
|
```json
|
|
141
77
|
{
|
|
142
78
|
"mcpServers": {
|
|
143
79
|
"workrail": {
|
|
144
|
-
"command": "
|
|
145
|
-
"args": [
|
|
146
|
-
"/path/to/your/mcp/packages/workrail/dist/mcp-server.js"
|
|
147
|
-
]
|
|
80
|
+
"command": "docker",
|
|
81
|
+
"args": ["run", "--rm", "-i", "workrail-mcp"]
|
|
148
82
|
}
|
|
149
83
|
}
|
|
150
84
|
}
|
|
151
85
|
```
|
|
152
86
|
|
|
153
|
-
|
|
87
|
+
---
|
|
154
88
|
|
|
155
|
-
|
|
89
|
+
## ๐ Available Workflows
|
|
156
90
|
|
|
157
|
-
|
|
91
|
+
WorkRail comes with battle-tested workflows for common development tasks:
|
|
158
92
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
93
|
+
### ๐ง **Development Workflows**
|
|
94
|
+
- **`coding-task-workflow`** - Comprehensive coding workflow with analysis, planning, implementation, and review
|
|
95
|
+
- **`coding-task-workflow-with-loops`** - Enhanced version with iterative refinement loops
|
|
96
|
+
- **`systematic-bug-investigation`** - Systematic debugging methodology that prevents jumping to conclusions
|
|
97
|
+
- **`systemic-bug-investigation-with-loops`** - Enhanced debugging with iterative analysis loops
|
|
98
|
+
|
|
99
|
+
### ๐ **Project Management**
|
|
100
|
+
- **`adaptive-ticket-creation`** - Create well-structured tickets with proper requirements
|
|
101
|
+
- **`mr-review-workflow`** - Thorough merge request review process
|
|
102
|
+
|
|
103
|
+
### ๐ **Content & Documentation**
|
|
104
|
+
- **`document-creation-workflow`** - Structured approach to creating comprehensive documentation
|
|
105
|
+
- **`presentation-creation`** - Build engaging presentations with clear narrative flow
|
|
106
|
+
- **`personal-learning-course-design`** - Design educational content with learning objectives
|
|
107
|
+
- **`personal-learning-materials-creation-branched`** - Create comprehensive learning materials with adaptive complexity
|
|
108
|
+
|
|
109
|
+
### ๐ **Discovery & Analysis**
|
|
110
|
+
- **`exploration-workflow`** - Systematic codebase or domain exploration
|
|
111
|
+
- **`workflow-for-workflows`** - Meta-workflow for designing new workflows
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## ๐ Loop Support
|
|
116
|
+
|
|
117
|
+
WorkRail supports powerful iteration patterns for complex tasks:
|
|
118
|
+
|
|
119
|
+
- **`while`** - Continue while a condition is true
|
|
120
|
+
- **`until`** - Continue until a condition is met
|
|
121
|
+
- **`for`** - Execute a fixed number of times
|
|
122
|
+
- **`forEach`** - Process items in an array
|
|
123
|
+
|
|
124
|
+
Perfect for batch operations, retries, polling, and iterative refinement.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## ๐ Quick Example
|
|
174
129
|
|
|
175
|
-
|
|
130
|
+
Here's what a workflow step looks like:
|
|
176
131
|
|
|
177
132
|
```json
|
|
178
133
|
{
|
|
179
|
-
"
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
134
|
+
"id": "analyze-codebase",
|
|
135
|
+
"name": "Deep Codebase Analysis",
|
|
136
|
+
"description": "Understand the codebase structure before making changes",
|
|
137
|
+
"agentRole": "You are a senior engineer performing careful code analysis",
|
|
138
|
+
"runCondition": {
|
|
139
|
+
"type": "context",
|
|
140
|
+
"key": "taskComplexity",
|
|
141
|
+
"operator": "in",
|
|
142
|
+
"values": ["Medium", "Large"]
|
|
143
|
+
},
|
|
144
|
+
"validationCriteria": {
|
|
145
|
+
"outputLength": {"min": 200, "max": 2000},
|
|
146
|
+
"mustContain": ["file structure", "key components", "dependencies"]
|
|
188
147
|
}
|
|
189
148
|
}
|
|
190
149
|
```
|
|
191
150
|
|
|
151
|
+
The agent receives structured guidance on **what to do**, **how to do it**, and **quality standards to meet**.
|
|
152
|
+
|
|
192
153
|
---
|
|
193
154
|
|
|
194
|
-
##
|
|
155
|
+
## ๐ Why Choose WorkRail?
|
|
195
156
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
โโ src/
|
|
199
|
-
โ โโ domain/ # Pure entities & errors (no dependencies)
|
|
200
|
-
โ โโ application/ # Use-cases, services, ValidationEngine (depends on domain)
|
|
201
|
-
โ โโ infrastructure/
|
|
202
|
-
โ โ โโ rpc/ # JSON-RPC server adapter
|
|
203
|
-
โ โ โโ storage/ # File, in-memory, caching, schema-validating adapters
|
|
204
|
-
โ โโ mcp-server.ts # MCP server implementation (main entry point)
|
|
205
|
-
โ โโ cli.ts # CLI utility for workflow validation
|
|
206
|
-
โ โโ container.ts # DI registrations
|
|
207
|
-
โ โโ index.ts # Library entrypoint (exports container)
|
|
208
|
-
โโ tests/ # Jest test suites (unit & integration)
|
|
209
|
-
โโ docs/ # Guides, reference, advanced topics
|
|
210
|
-
```
|
|
157
|
+
### Consistency & Reproducibility
|
|
158
|
+
One of the biggest challenges with AI-assisted development is inconsistency. The same request can yield wildly different approaches depending on how the prompt is phrased, the LLM's randomness, or the developer's prompting expertise.
|
|
211
159
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
โผ calls
|
|
218
|
-
Application โโ use-cases (pure biz logic)
|
|
219
|
-
โผ operates on
|
|
220
|
-
Domain โโ entities & value objects
|
|
221
|
-
```
|
|
160
|
+
WorkRail reduces these variables:
|
|
161
|
+
- **Same Process** - Every developer follows the same workflow
|
|
162
|
+
- **Same Quality** - Helps junior developers produce work closer to senior-level quality
|
|
163
|
+
- **Same Standards** - Code style and patterns are guided by workflows
|
|
164
|
+
- **Audit Trail** - Every decision is logged and reviewable
|
|
222
165
|
|
|
223
|
-
|
|
166
|
+
| Without WorkRail | With WorkRail |
|
|
167
|
+
|------------------|---------------|
|
|
168
|
+
| "Just fix this bug" โ agent makes random changes | Systematic investigation โ evidence-based diagnosis โ targeted fix |
|
|
169
|
+
| "Add a feature" โ incomplete implementation | Analysis โ planning โ implementation โ testing โ review |
|
|
170
|
+
| Inconsistent quality across tasks | Repeatable, high-quality processes |
|
|
171
|
+
| Outcome depends on prompting skills | Guided best practices regardless of experience |
|
|
224
172
|
|
|
225
|
-
|
|
173
|
+
---
|
|
226
174
|
|
|
227
|
-
|
|
228
|
-
|---------|---------|-------------|
|
|
229
|
-
| `WORKFLOW_DIR` | `spec/examples` | Path where workflow JSON files are loaded (file storage) |
|
|
230
|
-
| `CACHE_TTL` | `300000` | Cache TTL in ms for `CachingWorkflowStorage` |
|
|
231
|
-
| `PORT` | _n/a_ | Not used (stdin/stdout transport) |
|
|
175
|
+
## ๐ Getting Started
|
|
232
176
|
|
|
233
|
-
|
|
177
|
+
1. **Install** WorkRail as an MCP server (see installation above)
|
|
178
|
+
2. **Browse workflows** - Use `workflow_list` to see available options
|
|
179
|
+
3. **Start a workflow** - Use `workflow_get` to load a workflow for your task
|
|
180
|
+
4. **Follow the steps** - Use `workflow_next` to get guided, step-by-step instructions
|
|
181
|
+
5. **Validate progress** - Use `workflow_validate` to ensure quality at each step
|
|
234
182
|
|
|
235
183
|
---
|
|
236
184
|
|
|
237
|
-
##
|
|
185
|
+
## ๐ Planned Features
|
|
238
186
|
|
|
239
|
-
|
|
240
|
-
npm test
|
|
241
|
-
```
|
|
242
|
-
Current status: 81 tests passing, 7 failing (performance optimizations in progress), 88 total tests.
|
|
187
|
+
WorkRail is actively evolving. Here are key enhancements on the roadmap:
|
|
243
188
|
|
|
244
|
-
|
|
189
|
+
### **Workflow State Management**
|
|
190
|
+
- **Save & Resume** - Generate workflow state summaries for resuming complex workflows in new chat sessions
|
|
191
|
+
- **Context Preservation** - Maintain workflow progress across conversation boundaries
|
|
192
|
+
- **Checkpoint System** - Save progress at key milestones for easy recovery
|
|
193
|
+
|
|
194
|
+
### **Model Switching Guidance**
|
|
195
|
+
Workflows could recommend optimal models for specific steps:
|
|
196
|
+
- **Analysis steps** โ Tool-use heavy models (Claude) for codebase exploration
|
|
197
|
+
- **Planning/design** โ Smartest available models for strategic thinking
|
|
198
|
+
- **Implementation** โ Cost-effective models once requirements are clear
|
|
245
199
|
|
|
246
|
-
|
|
200
|
+
*Note: WorkRail provides text recommendations to users, not automatic model switching*
|
|
247
201
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
202
|
+
### **Enhanced Workflow Management**
|
|
203
|
+
- **Dynamic Workflow Loading** - Add/edit workflows without republishing the server
|
|
204
|
+
- **Workflow Categories** - Organize workflows by domain (debugging, planning, review, etc.)
|
|
205
|
+
- **Reusable Components** - Plugin system for common workflow patterns (codebase analysis, document creation, etc.)
|
|
206
|
+
- **Schema Versioning** - Backwards-compatible workflow schema evolution
|
|
207
|
+
|
|
208
|
+
### **Advanced Validation & Quality**
|
|
209
|
+
- **Custom Validation Functions** - Domain-specific output validation beyond basic schema checks
|
|
210
|
+
- **Integration Hooks** - Connect with external quality tools and linters
|
|
211
|
+
- **Performance Validation** - Ensure workflow outputs meet performance criteria
|
|
212
|
+
- **Length Validation Optimization** - Faster validation using terminal commands vs. full content rewrite
|
|
213
|
+
|
|
214
|
+
### **Workflow Discovery & Intelligence**
|
|
215
|
+
- **Smart Workflow Suggestions** - Recommend workflows based on task context
|
|
216
|
+
- **Pattern Recognition** - Identify when existing codebase patterns should inform workflow steps
|
|
254
217
|
|
|
255
218
|
---
|
|
219
|
+
*Have ideas for WorkRail? The planned features list helps guide development priorities.*
|
|
256
220
|
|
|
257
|
-
|
|
221
|
+
---
|
|
258
222
|
|
|
259
|
-
|
|
260
|
-
2. **Follow the Architecture** โ domain logic must remain framework-free; side effects live in infrastructure.
|
|
261
|
-
3. **Add Tests** โ no code is accepted without unit tests.
|
|
262
|
-
4. **Run `npm run lint:fix`** before pushing.
|
|
223
|
+
## ๐ Learn More
|
|
263
224
|
|
|
264
|
-
|
|
225
|
+
- **[Complete Overview](workrail-mcp-overview.md)** - Deep dive into architecture, philosophy, and detailed examples
|
|
226
|
+
- **[Loop Documentation](docs/features/loops.md)** - Advanced iteration patterns
|
|
227
|
+
- **[API Specification](spec/mcp-api-v1.0.md)** - Complete MCP API reference
|
|
228
|
+
- **[Internal Documentation](docs/README.md)** - Development and architecture guides
|
|
265
229
|
|
|
266
230
|
---
|
|
267
231
|
|
|
268
232
|
## ๐ License
|
|
269
233
|
|
|
270
|
-
MIT
|
|
234
|
+
MIT License - see [LICENSE](LICENSE)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ContextLayer, ClassificationRules, ClassifiedContext, RawContext } from '../../types/context-types';
|
|
2
|
+
export interface IClassificationEngine {
|
|
3
|
+
classify(context: RawContext, rules?: ClassificationRules): Promise<ClassifiedContext>;
|
|
4
|
+
loadRules(config?: Partial<ClassificationRules>): Promise<void>;
|
|
5
|
+
addOverride(sessionId: string, contextKey: string, layer: ContextLayer): void;
|
|
6
|
+
removeOverride(sessionId: string, contextKey: string): void;
|
|
7
|
+
markCritical(sessionId: string, contextKey: string): Promise<void>;
|
|
8
|
+
getStats(): ClassificationStats;
|
|
9
|
+
}
|
|
10
|
+
export interface ClassificationStats {
|
|
11
|
+
totalClassifications: number;
|
|
12
|
+
layerDistribution: Record<ContextLayer, number>;
|
|
13
|
+
overrideCount: number;
|
|
14
|
+
averageProcessingTime: number;
|
|
15
|
+
}
|
|
16
|
+
export declare class ClassificationEngine implements IClassificationEngine {
|
|
17
|
+
private rules;
|
|
18
|
+
private overrides;
|
|
19
|
+
private stats;
|
|
20
|
+
constructor(initialRules?: ClassificationRules);
|
|
21
|
+
classify(context: RawContext, rules?: ClassificationRules): Promise<ClassifiedContext>;
|
|
22
|
+
loadRules(config?: Partial<ClassificationRules>): Promise<void>;
|
|
23
|
+
addOverride(sessionId: string, contextKey: string, layer: ContextLayer): void;
|
|
24
|
+
removeOverride(sessionId: string, contextKey: string): void;
|
|
25
|
+
markCritical(sessionId: string, contextKey: string): Promise<void>;
|
|
26
|
+
getStats(): ClassificationStats;
|
|
27
|
+
private classifyKeyValue;
|
|
28
|
+
private applyPatternMatching;
|
|
29
|
+
private matchesPattern;
|
|
30
|
+
private applyHeuristics;
|
|
31
|
+
private updateStats;
|
|
32
|
+
private getDefaultRules;
|
|
33
|
+
}
|