contextos-agents 1.5.0 → 1.6.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.
- package/.agents/adapters/cursor/export.js +34 -37
- package/.agents/core/profiles/mvp.yaml +1 -0
- package/.agents/ctx.js +37 -5
- package/.agents/doctor.js +269 -0
- package/.agents/mcp/runtime.py +17 -1
- package/.agents/mcp/server.mjs +43 -145
- package/.agents/plugins.js +21 -11
- package/.agents/resolver.js +112 -1
- package/.agents/stats.js +133 -0
- package/.agents/validate.js +53 -0
- package/.agents/watch.js +161 -0
- package/README.md +123 -53
- package/bin/index.js +186 -60
- package/package.json +10 -5
package/.agents/validate.js
CHANGED
|
@@ -414,6 +414,58 @@ function checkValidationJson(sourceSkills) {
|
|
|
414
414
|
info(`[validation] ${pass} VALIDATION.json files are valid`);
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
+
// ═════════════════════════════════════════════════════════════════════════════
|
|
418
|
+
// CHECK 9 — MCP Bundle Synchronization
|
|
419
|
+
// ═════════════════════════════════════════════════════════════════════════════
|
|
420
|
+
function checkMcpBundleSync() {
|
|
421
|
+
const mcpSrcDir = path.join(ROOT, 'contextos-mcp', 'src');
|
|
422
|
+
const bundlePath = path.join(AGENTS_DIR, 'mcp', 'server.mjs');
|
|
423
|
+
|
|
424
|
+
if (!fs.existsSync(mcpSrcDir)) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (!fs.existsSync(bundlePath)) {
|
|
429
|
+
warn(`[mcp-sync] Missing compiled MCP server bundle at .agents/mcp/server.mjs. Run: cd contextos-mcp && npm run build:bundle`);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const bundleStat = fs.statSync(bundlePath);
|
|
434
|
+
const bundleMtime = bundleStat.mtimeMs;
|
|
435
|
+
|
|
436
|
+
let newestSrcFile = null;
|
|
437
|
+
let newestSrcMtime = 0;
|
|
438
|
+
|
|
439
|
+
function walk(dir) {
|
|
440
|
+
let entries;
|
|
441
|
+
try {
|
|
442
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
443
|
+
} catch {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
for (const entry of entries) {
|
|
447
|
+
const full = path.join(dir, entry.name);
|
|
448
|
+
if (entry.isDirectory()) {
|
|
449
|
+
walk(full);
|
|
450
|
+
} else if (entry.isFile()) {
|
|
451
|
+
const stat = fs.statSync(full);
|
|
452
|
+
if (stat.mtimeMs > newestSrcMtime) {
|
|
453
|
+
newestSrcMtime = stat.mtimeMs;
|
|
454
|
+
newestSrcFile = path.relative(ROOT, full);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
walk(mcpSrcDir);
|
|
461
|
+
|
|
462
|
+
if (newestSrcMtime > bundleMtime) {
|
|
463
|
+
warn(`[mcp-sync] Compiled MCP bundle (.agents/mcp/server.mjs) is older than source file ${newestSrcFile}. Run: cd contextos-mcp && npm run build:bundle`);
|
|
464
|
+
} else {
|
|
465
|
+
info(`[mcp-sync] Compiled MCP bundle (.agents/mcp/server.mjs) is up to date with contextos-mcp/src/`);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
417
469
|
// ═════════════════════════════════════════════════════════════════════════════
|
|
418
470
|
// REPORT
|
|
419
471
|
// ═════════════════════════════════════════════════════════════════════════════
|
|
@@ -487,6 +539,7 @@ function run() {
|
|
|
487
539
|
checkContentQuality(sourceSkills);
|
|
488
540
|
checkCostarHeaders(sourceSkills);
|
|
489
541
|
checkValidationJson(sourceSkills);
|
|
542
|
+
checkMcpBundleSync();
|
|
490
543
|
|
|
491
544
|
const passed = printReport();
|
|
492
545
|
process.exit(passed ? 0 : 1);
|
package/.agents/watch.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .agents/watch.js
|
|
3
|
+
* ContextOS — Continuous Context Sync & File Watcher Daemon
|
|
4
|
+
*
|
|
5
|
+
* Watches:
|
|
6
|
+
* 1. .agents/core/skills/ — regenerates agent configs on skill markdown edits
|
|
7
|
+
* 2. package.json & manifests — detects tech stack drift and recommends profile adjustments
|
|
8
|
+
*
|
|
9
|
+
* Provides instant feedback during local development without manual re-exports.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const { execFileSync } = require('child_process');
|
|
17
|
+
const profiles = require('./profiles.js');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Runs the ContextOS watch daemon.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} [projectDir=process.cwd()] - Target project directory
|
|
23
|
+
* @param {Object} [options={}] - Watcher configuration options
|
|
24
|
+
* @param {number} [options.debounceMs=300] - Debounce delay in milliseconds
|
|
25
|
+
* @param {Function} [options.onSync] - Callback after a sync event completes
|
|
26
|
+
* @param {boolean} [options.exitOnSigint=true] - Whether to register process exit handlers
|
|
27
|
+
* @returns {Object} Controller object with a `close()` method
|
|
28
|
+
*/
|
|
29
|
+
function runWatch(projectDir = process.cwd(), options = {}) {
|
|
30
|
+
const debounceMs = options.debounceMs || 300;
|
|
31
|
+
const agentsDir = path.join(projectDir, '.agents');
|
|
32
|
+
const skillsDir = path.join(agentsDir, 'core', 'skills');
|
|
33
|
+
const ctxPath = path.join(agentsDir, 'ctx.js');
|
|
34
|
+
|
|
35
|
+
console.log('\n[ContextOS Watch] Initializing background continuous sync daemon...');
|
|
36
|
+
console.log(`[ContextOS Watch] Project directory: ${projectDir}`);
|
|
37
|
+
|
|
38
|
+
let lastStack = profiles.detectStack(projectDir);
|
|
39
|
+
console.log(`[ContextOS Watch] Initial stack: ${lastStack.detected.join(', ') || 'Generic JS'} (${lastStack.recommendedProfile})`);
|
|
40
|
+
|
|
41
|
+
let debounceTimer = null;
|
|
42
|
+
let isSyncing = false;
|
|
43
|
+
const watchers = [];
|
|
44
|
+
|
|
45
|
+
function triggerRecompile(sourceReason) {
|
|
46
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
47
|
+
|
|
48
|
+
debounceTimer = setTimeout(() => {
|
|
49
|
+
if (isSyncing) return;
|
|
50
|
+
isSyncing = true;
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const time = new Date().toLocaleTimeString();
|
|
54
|
+
console.log(`[${time}] [SYNC] Changes detected in ${sourceReason}. Recompiling agent skills...`);
|
|
55
|
+
|
|
56
|
+
if (fs.existsSync(ctxPath)) {
|
|
57
|
+
execFileSync(process.execPath, [ctxPath, 'export', 'all'], {
|
|
58
|
+
cwd: projectDir,
|
|
59
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
60
|
+
});
|
|
61
|
+
console.log(`[${time}] [OK] Skills exported to all agents (Gemini, Claude, Cursor, Copilot, Aider, Zed).`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (typeof options.onSync === 'function') {
|
|
65
|
+
options.onSync({ type: 'recompile', reason: sourceReason });
|
|
66
|
+
}
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.error(`[WARN] Auto-recompile failed: ${err.message}`);
|
|
69
|
+
} finally {
|
|
70
|
+
isSyncing = false;
|
|
71
|
+
}
|
|
72
|
+
}, debounceMs);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function checkStackChange() {
|
|
76
|
+
try {
|
|
77
|
+
const currentStack = profiles.detectStack(projectDir);
|
|
78
|
+
const prevStr = lastStack.detected.sort().join(',');
|
|
79
|
+
const currStr = currentStack.detected.sort().join(',');
|
|
80
|
+
|
|
81
|
+
if (prevStr !== currStr) {
|
|
82
|
+
const time = new Date().toLocaleTimeString();
|
|
83
|
+
console.log(`\n[${time}] [DETECT] Project dependencies changed!`);
|
|
84
|
+
console.log(` Detected stack : ${currentStack.detected.join(', ')}`);
|
|
85
|
+
console.log(` Recommendation : Profile '${currentStack.recommendedProfile}'`);
|
|
86
|
+
console.log(` Run: contextos profile apply ${currentStack.recommendedProfile}\n`);
|
|
87
|
+
lastStack = currentStack;
|
|
88
|
+
|
|
89
|
+
if (typeof options.onSync === 'function') {
|
|
90
|
+
options.onSync({ type: 'stack_change', stack: currentStack });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
} catch {
|
|
94
|
+
// ignore transient filesystem read errors
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 1. Watch .agents/core/skills/ directory
|
|
99
|
+
if (fs.existsSync(skillsDir)) {
|
|
100
|
+
try {
|
|
101
|
+
const skillsWatcher = fs.watch(skillsDir, { recursive: true }, (eventType, filename) => {
|
|
102
|
+
if (!filename) return;
|
|
103
|
+
const norm = filename.replace(/\\/g, '/');
|
|
104
|
+
if (norm.endsWith('.md') || norm.endsWith('.json') || norm.endsWith('.yaml') || norm.endsWith('.yml')) {
|
|
105
|
+
triggerRecompile(`skills/${filename}`);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
watchers.push(skillsWatcher);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.warn(`[WARN] Could not establish recursive watcher on skills directory: ${e.message}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 2. Watch package.json
|
|
115
|
+
const pkgPath = path.join(projectDir, 'package.json');
|
|
116
|
+
if (fs.existsSync(pkgPath)) {
|
|
117
|
+
try {
|
|
118
|
+
const pkgWatcher = fs.watch(pkgPath, () => {
|
|
119
|
+
checkStackChange();
|
|
120
|
+
});
|
|
121
|
+
watchers.push(pkgWatcher);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
console.warn(`[WARN] Could not watch package.json: ${e.message}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
console.log('[ContextOS Watch] Watching for skill updates and dependency shifts. Press Ctrl+C to stop.\n');
|
|
128
|
+
|
|
129
|
+
function close() {
|
|
130
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
131
|
+
for (const w of watchers) {
|
|
132
|
+
try {
|
|
133
|
+
w.close();
|
|
134
|
+
} catch {}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (options.exitOnSigint !== false) {
|
|
139
|
+
const onExit = () => {
|
|
140
|
+
console.log('\n[ContextOS Watch] Stopping watcher daemon.');
|
|
141
|
+
close();
|
|
142
|
+
process.exit(0);
|
|
143
|
+
};
|
|
144
|
+
process.once('SIGINT', onExit);
|
|
145
|
+
process.once('SIGTERM', onExit);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
close,
|
|
150
|
+
triggerRecompile,
|
|
151
|
+
checkStackChange,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (require.main === module) {
|
|
156
|
+
runWatch();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
module.exports = {
|
|
160
|
+
runWatch,
|
|
161
|
+
};
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/contextos-agents)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](https://nodejs.org/)
|
|
6
6
|
[](#testing)
|
|
7
7
|
|
|
8
8
|
This is an open-source set of skills and behavioral rules for AI assistants. The package automatically installs an `.agents` folder into your project, teaching your AI assistant software development best practices (UI Design, Architecture, Security, and more).
|
|
@@ -12,7 +12,8 @@ This is an open-source set of skills and behavioral rules for AI assistants. The
|
|
|
12
12
|
You do not need to clone anything manually. Just open your terminal in the root of your project and run:
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
npx contextos
|
|
15
|
+
npx contextos
|
|
16
|
+
# or: npx contextos-agents
|
|
16
17
|
```
|
|
17
18
|
|
|
18
19
|
The script will automatically detect your project tech stack, create the `.agents` folder, configure skills, and compile them for your AI agent.
|
|
@@ -20,15 +21,16 @@ The script will automatically detect your project tech stack, create the `.agent
|
|
|
20
21
|
### Options
|
|
21
22
|
|
|
22
23
|
```bash
|
|
23
|
-
npx contextos
|
|
24
|
-
npx contextos
|
|
25
|
-
npx contextos
|
|
26
|
-
npx contextos
|
|
27
|
-
npx contextos
|
|
28
|
-
npx contextos
|
|
29
|
-
npx contextos
|
|
30
|
-
npx contextos
|
|
31
|
-
npx contextos
|
|
24
|
+
npx contextos --help # Show all options
|
|
25
|
+
npx contextos --version # Show version
|
|
26
|
+
npx contextos --minimal # Install only 5 core skills (lightweight footprint)
|
|
27
|
+
npx contextos --profile mvp # Install with specific profile (mvp, startup, enterprise, frontend, backend)
|
|
28
|
+
npx contextos --auto # Auto-detect tech stack and apply recommended profile
|
|
29
|
+
npx contextos --with-mcp # Install with MCP execution server enabled (.agents/mcp/)
|
|
30
|
+
npx contextos setup-mcp # Add MCP server to an existing .agents/ project
|
|
31
|
+
npx contextos --dry-run # Preview what will be installed
|
|
32
|
+
npx contextos --force # Overwrite an existing .agents/ folder
|
|
33
|
+
npx contextos --skip-compile # Skip auto-compilation step
|
|
32
34
|
```
|
|
33
35
|
|
|
34
36
|
## Why ContextOS?
|
|
@@ -49,10 +51,10 @@ Most AI coding assistants suffer from two extremes: they either operate in a vac
|
|
|
49
51
|
|
|
50
52
|
### Key Developer Advantages
|
|
51
53
|
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
54
|
+
- **Zero-Config Onboarding:** Run `npx contextos-agents` in your repository. It auto-detects your stack (React, Node, Python, etc.) and sets up the ideal profile in seconds.
|
|
55
|
+
- **Tailored Project Profiles:** Use `mvp` for lean, rapid prototyping without bloated microservices boilerplate, or `enterprise` for strict TDD, DDD, and security auditing.
|
|
56
|
+
- **Autonomous Multi-Agent Worktrees:** Run parallel tasks safely with the bundled MCP server—subagents work in isolated Git worktrees without corrupting your active workspace.
|
|
57
|
+
- **Verifiable Benchmarks:** Backed by reproducible side-by-side benchmarks demonstrating measurable code quality improvements and reduced token usage.
|
|
56
58
|
|
|
57
59
|
## Project Profiles & Stack Auto-Detection
|
|
58
60
|
|
|
@@ -70,16 +72,17 @@ ContextOS allows you to tailor your AI rules to the project lifecycle and archit
|
|
|
70
72
|
|
|
71
73
|
```bash
|
|
72
74
|
# Auto-detect tech stack in the current project
|
|
73
|
-
|
|
75
|
+
contextos detect
|
|
76
|
+
# or: node .agents/ctx.js detect
|
|
74
77
|
|
|
75
78
|
# List available profiles and current active profile
|
|
76
|
-
|
|
79
|
+
contextos profile list
|
|
77
80
|
|
|
78
81
|
# Apply a profile
|
|
79
|
-
|
|
82
|
+
contextos profile apply mvp
|
|
80
83
|
|
|
81
84
|
# Recompile all agent exports for the active profile
|
|
82
|
-
|
|
85
|
+
contextos export all
|
|
83
86
|
```
|
|
84
87
|
|
|
85
88
|
## What's Inside?
|
|
@@ -146,9 +149,9 @@ ContextOS maps development phases directly to slash commands in your AI chat:
|
|
|
146
149
|
| `/review` | Staff Engineer + Designer | 5-axis quality gate (correctness, architecture, security, performance, design) |
|
|
147
150
|
| `/ship` | Release Engineer | Verify clean CI, lint checks, docs, and rollback plan before merging |
|
|
148
151
|
|
|
149
|
-
## Dynamic Skill Resolution & CLI (`ctx.js`)
|
|
152
|
+
## Dynamic Skill Resolution & Unified CLI (`contextos` / `ctx.js`)
|
|
150
153
|
|
|
151
|
-
|
|
154
|
+
ContextOS provides a unified CLI (`contextos` or `npx contextos`) and local engine (`.agents/ctx.js`) to resolve minimal skills on the fly, run health diagnostics, and compile exports for AI assistants.
|
|
152
155
|
|
|
153
156
|
### Dynamic Skill Resolution (`resolve` & `index`)
|
|
154
157
|
|
|
@@ -156,48 +159,74 @@ To prevent context bloat, ContextOS dynamically resolves the exact 2–4 skills
|
|
|
156
159
|
|
|
157
160
|
```bash
|
|
158
161
|
# Resolve skills for a task description (English):
|
|
159
|
-
|
|
162
|
+
contextos resolve "Build an accessible modal component with React and Tailwind"
|
|
160
163
|
|
|
161
164
|
# Output:
|
|
162
165
|
# [DOMAIN: Frontend] [PHASE: Build] [ROLE: Senior Developer]
|
|
163
166
|
# Skills loaded: ponytail-mindset, engineering-workflow, react, ui-ux-pro, web-accessibility
|
|
164
167
|
|
|
165
168
|
# Multilingual support (Russian):
|
|
166
|
-
|
|
169
|
+
contextos resolve "создай модальное окно авторизации и напиши юнит-тесты"
|
|
167
170
|
|
|
168
171
|
# Output:
|
|
169
172
|
# [DOMAIN: Frontend] [PHASE: Build] [ROLE: Senior Developer]
|
|
170
173
|
# Skills loaded: ponytail-mindset, engineering-workflow, react, ui-ux-pro, security, testing
|
|
171
174
|
|
|
172
|
-
# Resolve skills based on active files:
|
|
173
|
-
|
|
175
|
+
# Resolve skills based on active files (hybrid AST & config analysis):
|
|
176
|
+
contextos resolve --files "app/api/auth/route.ts"
|
|
174
177
|
|
|
175
178
|
# Generate/update progressive lightweight skills index:
|
|
176
|
-
|
|
179
|
+
contextos index
|
|
177
180
|
|
|
178
181
|
# Clean up lingering .swarm-worktrees directories and orphaned swarm/* git branches:
|
|
179
|
-
|
|
182
|
+
contextos clean-worktrees
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Diagnostic Health Check (`contextos doctor`)
|
|
186
|
+
|
|
187
|
+
Run a comprehensive pre-flight verification across your repository to ensure valid skills, profile alignment, symlinks, git worktree status, and compiler synchronization:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
contextos doctor
|
|
191
|
+
# or: npx contextos doctor
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Context Savings Analytics (`contextos stats`)
|
|
195
|
+
|
|
196
|
+
Measure your real token savings. Compares monolithic prompt injection against ContextOS dynamic skill resolution across frontend, backend, security, and full-stack tasks:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
contextos stats
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Continuous Auto-Sync Daemon (`contextos watch`)
|
|
203
|
+
|
|
204
|
+
Watch your source skills in `.agents/core/skills/` and automatically recompile adapter outputs (`.cursorrules`, `.zed/rules.md`, `.github/copilot-instructions.md`, etc.) upon saving:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
contextos watch
|
|
208
|
+
# or: npm run watch
|
|
180
209
|
```
|
|
181
210
|
|
|
182
211
|
### Supported Agents & Compilation
|
|
183
212
|
|
|
184
213
|
| Agent | Command | Output Format |
|
|
185
214
|
|-------|---------|---------------|
|
|
186
|
-
| **Gemini / Antigravity** | `export gemini` | `.agents/generated/gemini/skills/` |
|
|
187
|
-
| **Claude Code** | `export claude` | `.agents/generated/claude/skills/` |
|
|
188
|
-
| **Cursor IDE** | `export cursor` | `.cursor/rules/*.mdc` (modular globs) + `.cursorrules` |
|
|
189
|
-
| **GitHub Copilot** | `export copilot` | `.github/copilot-instructions.md` |
|
|
190
|
-
| **Aider** | `export aider` | `.aider.conf.yml` + `CONVENTIONS.md` |
|
|
191
|
-
| **Zed IDE** | `export zed` | `.zed/rules.md` + `.zed/prompts/*.md` |
|
|
215
|
+
| **Gemini / Antigravity** | `contextos export gemini` | `.agents/generated/gemini/skills/` |
|
|
216
|
+
| **Claude Code** | `contextos export claude` | `.agents/generated/claude/skills/` |
|
|
217
|
+
| **Cursor IDE** | `contextos export cursor` | `.cursor/rules/*.mdc` (modular globs) + `.cursorrules` |
|
|
218
|
+
| **GitHub Copilot** | `contextos export copilot` | `.github/copilot-instructions.md` |
|
|
219
|
+
| **Aider** | `contextos export aider` | `.aider.conf.yml` + `CONVENTIONS.md` |
|
|
220
|
+
| **Zed IDE** | `contextos export zed` | `.zed/rules.md` + `.zed/prompts/*.md` |
|
|
192
221
|
|
|
193
222
|
```bash
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
223
|
+
contextos export all # Compile for all agents (or: node .agents/ctx.js export all)
|
|
224
|
+
contextos export gemini # Compile for Gemini / Antigravity
|
|
225
|
+
contextos export claude # Compile for Claude Code
|
|
226
|
+
contextos export cursor # Compile for Cursor (.cursor/rules/*.mdc)
|
|
227
|
+
contextos export copilot # Compile for GitHub Copilot
|
|
228
|
+
contextos export aider # Compile for Aider
|
|
229
|
+
contextos export zed # Compile for Zed IDE
|
|
201
230
|
```
|
|
202
231
|
|
|
203
232
|
### Pre-Compiled Artifacts & Git Architecture
|
|
@@ -209,19 +238,46 @@ ContextOS commits generated adapter configurations (`.cursorrules`, `.cursor/rul
|
|
|
209
238
|
- **Automated Sync & Drift Prevention:** CI strictly validates that generated exports match source skills (`node .agents/ctx.js validate`). Any uncommitted adapter drift fails CI checks via `git diff --exit-code`.
|
|
210
239
|
- **Contributor Workflow:** Source rules are authored exclusively in `.agents/core/skills/<name>/SKILL.md`. Running `node .agents/ctx.js export all` regenerates all assistant configurations deterministically.
|
|
211
240
|
|
|
241
|
+
### CI Quality Gate Action (`contextos-gate`)
|
|
242
|
+
|
|
243
|
+
You can guard your repository against skill drift, secret leaks, and rule regressions using the official reusable GitHub Composite Action:
|
|
244
|
+
|
|
245
|
+
```yaml
|
|
246
|
+
# .github/workflows/pr-gate.yml
|
|
247
|
+
name: ContextOS Quality Gate
|
|
248
|
+
|
|
249
|
+
on:
|
|
250
|
+
pull_request:
|
|
251
|
+
branches: [main]
|
|
252
|
+
push:
|
|
253
|
+
branches: [main]
|
|
254
|
+
|
|
255
|
+
jobs:
|
|
256
|
+
gate:
|
|
257
|
+
runs-on: ubuntu-latest
|
|
258
|
+
steps:
|
|
259
|
+
- uses: actions/checkout@v4
|
|
260
|
+
- uses: kok-o/contextos-agents/.github/actions/contextos-gate@main
|
|
261
|
+
with:
|
|
262
|
+
node-version: '20'
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
The action validates skill frontmatter integrity, checks for adapter configuration drift, scans for accidental secrets or API keys, and runs your test suite.
|
|
266
|
+
|
|
212
267
|
### Plugin Skills & Validation
|
|
213
268
|
|
|
214
269
|
You can expand your `.agents` folder with community plugins or validate your own custom skills using the top-level commands:
|
|
215
270
|
|
|
216
271
|
```bash
|
|
217
272
|
# Launch the interactive skill installer to browse and install community skills
|
|
218
|
-
|
|
273
|
+
contextos install-skill
|
|
274
|
+
# or: npx contextos install-skill
|
|
219
275
|
|
|
220
276
|
# Or install a specific skill from a GitHub repository automatically
|
|
221
|
-
|
|
277
|
+
contextos install-skill --from-repo kok-o/awesome-skill
|
|
222
278
|
|
|
223
279
|
# Validate your local skills (checks frontmatter, dependencies, and sync)
|
|
224
|
-
|
|
280
|
+
contextos audit
|
|
225
281
|
```
|
|
226
282
|
|
|
227
283
|
## ContextOS MCP Server & Autonomous Multi-Agent Swarm
|
|
@@ -286,39 +342,39 @@ Add ContextOS to your IDE's MCP settings (e.g. in `.agents/mcp_config.json`):
|
|
|
286
342
|
|
|
287
343
|
Tests use the **Node.js built-in test runner** for the core framework and **Vitest** for the MCP engine — zero external test bloat.
|
|
288
344
|
|
|
289
|
-
### 1. Root Test Suite (
|
|
345
|
+
### 1. Root Test Suite (131 tests)
|
|
290
346
|
|
|
291
347
|
```bash
|
|
292
348
|
npm test
|
|
293
349
|
```
|
|
294
350
|
|
|
295
351
|
```text
|
|
296
|
-
# tests
|
|
352
|
+
# tests 131
|
|
297
353
|
# suites 27
|
|
298
|
-
# pass
|
|
354
|
+
# pass 131
|
|
299
355
|
# fail 0
|
|
300
356
|
```
|
|
301
357
|
|
|
302
|
-
### 2. MCP Server Test Suite (
|
|
358
|
+
### 2. MCP Server Test Suite (440 tests)
|
|
303
359
|
|
|
304
360
|
```bash
|
|
305
361
|
cd contextos-mcp && npm test
|
|
306
362
|
```
|
|
307
363
|
|
|
308
364
|
```text
|
|
309
|
-
Test Files
|
|
310
|
-
Tests
|
|
365
|
+
Test Files 25 passed | 1 skipped (26)
|
|
366
|
+
Tests 440 passed | 13 skipped (453)
|
|
311
367
|
```
|
|
312
368
|
|
|
313
369
|
**Test coverage:**
|
|
314
370
|
|
|
315
|
-
- `tests/install.test.js` — installer CLI flags (--help, --dry-run, --force)
|
|
316
|
-
- `tests/export.test.js` — ctx.js export for gemini, claude, cursor (.mdc rules), copilot, aider
|
|
371
|
+
- `tests/install.test.js` — installer CLI flags (--help, --minimal, --dry-run, --force)
|
|
372
|
+
- `tests/export.test.js` — ctx.js export for gemini, claude, cursor (.mdc rules), copilot, aider, zed
|
|
317
373
|
- `tests/skills.test.js` — validates all skill source files and frontmatter
|
|
318
374
|
- `tests/profile.test.js` — profile resolution, stack auto-detection, and skill filtering
|
|
319
375
|
- `tests/validate.test.js` — validator rules, dependency graph, and sync checks
|
|
320
376
|
- `tests/plugins.test.js` — plugin lockfile, registry fetching, and security checks
|
|
321
|
-
- `tests/resolver.test.js` — dynamic skill resolution, progressive index, and bilingual prompt matching
|
|
377
|
+
- `tests/resolver.test.js` — dynamic skill resolution, AST import graph analysis, progressive index, and bilingual prompt matching
|
|
322
378
|
- `tests/benchmark.test.js` — benchmark scoring engine, static AST checks, runtime sandbox, and reporters
|
|
323
379
|
- `contextos-mcp/tests/unit/session-persistence.test.ts` — session disk persistence, thread state tracking, and orphan purge
|
|
324
380
|
- `contextos-mcp/tests/unit/contextos-tools.test.ts` — all 6 MCP tool handlers and validation
|
|
@@ -381,7 +437,7 @@ The runtime sandbox evaluates model outputs against real-world engineering invar
|
|
|
381
437
|
| **DDD Order Aggregate Root** | Architecture & DDD | `ddd`, `system-design`, `decisions` | Immutable `Money` Value Object, state-machine invariants (PENDING → PAID → SHIPPED), explicit Domain Event classes with queue draining. |
|
|
382
438
|
| **Resilient API Client** | Reliability & Async | `typescript`, `system-design`, `performance` | 3-state Circuit Breaker (CLOSED → OPEN → HALF-OPEN), `AbortController` timeouts, typed error taxonomy without credential leakage. |
|
|
383
439
|
|
|
384
|
-
### Running Benchmarks Locally
|
|
440
|
+
### Running Benchmarks Locally & in CI
|
|
385
441
|
|
|
386
442
|
You can run the benchmark suite locally with your own API keys:
|
|
387
443
|
|
|
@@ -393,10 +449,24 @@ npm run benchmark:runtime -- --provider gemini --model gemini-2.5-flash
|
|
|
393
449
|
# Run with OpenAI:
|
|
394
450
|
$env:OPENAI_API_KEY = "sk-..."
|
|
395
451
|
npm run benchmark:runtime -- --provider openai --model gpt-4o
|
|
452
|
+
|
|
453
|
+
# Run complete multi-model runtime matrix (Gemini, OpenRouter, AgentRouter):
|
|
454
|
+
GEMINI_API_KEY=... OPENROUTER_API_KEY=... AGENTROUTER_API_KEY=... node benchmarks/run-multi-runtime.cjs
|
|
396
455
|
```
|
|
397
456
|
|
|
398
457
|
When executed, reports are generated in `benchmarks/results/` (`.html`, `.md`, `.json`) and tracked so results are visible and shareable.
|
|
399
458
|
|
|
459
|
+
> [!NOTE]
|
|
460
|
+
> **Why Runtime Benchmarks Are Dispatch-Only in CI:** Standard CI checks (`validate-skills.yml`) run hermetically without external API calls to avoid flaky network dependencies and API token expenditures on every pull request. Live runtime evaluation is triggered on demand via GitHub Actions **Workflow Dispatch** ([`benchmark-runtime.yml`](.github/workflows/benchmark-runtime.yml)) using secure repository secrets.
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
## Security — Third-Party Skills
|
|
464
|
+
|
|
465
|
+
ContextOS skills are **executable context** — they become part of the system prompt that controls your AI agent's behavior. A malicious skill could instruct the AI agent to exfiltrate environment variables, modify files, or ignore your project's security policies.
|
|
466
|
+
|
|
467
|
+
> [!CAUTION]
|
|
468
|
+
> **Install skills only from repositories you trust as you would trust executable code.** Skills installed via `ctx.js skill add` from npm or GitHub are not sandboxed. ContextOS includes a built-in prompt injection scanner, but it cannot guarantee safety of arbitrary third-party content.
|
|
469
|
+
|
|
400
470
|
## Contributing
|
|
401
471
|
|
|
402
472
|
We are open to pull requests! See [CONTRIBUTING.md](./CONTRIBUTING.md) for a step-by-step guide on how to add a new skill.
|