cortex-agents 4.1.1 → 5.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.
- package/.opencode/skills/ui-design/SKILL.md +104 -1
- package/README.md +85 -16
- package/dist/cli.js +146 -13
- package/dist/engine/agents.d.ts +19 -0
- package/dist/engine/agents.d.ts.map +1 -0
- package/dist/engine/agents.js +69 -0
- package/dist/engine/db.d.ts +13 -0
- package/dist/engine/db.d.ts.map +1 -0
- package/dist/engine/db.js +28 -0
- package/dist/engine/index.d.ts +50 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +135 -0
- package/dist/engine/models.d.ts +12 -0
- package/dist/engine/models.d.ts.map +1 -0
- package/dist/engine/models.js +23 -0
- package/dist/engine/renderers/claude.d.ts +18 -0
- package/dist/engine/renderers/claude.d.ts.map +1 -0
- package/dist/engine/renderers/claude.js +226 -0
- package/dist/engine/renderers/codex.d.ts +22 -0
- package/dist/engine/renderers/codex.d.ts.map +1 -0
- package/dist/engine/renderers/codex.js +115 -0
- package/dist/engine/renderers/gemini.d.ts +18 -0
- package/dist/engine/renderers/gemini.d.ts.map +1 -0
- package/dist/engine/renderers/gemini.js +203 -0
- package/dist/engine/renderers/index.d.ts +21 -0
- package/dist/engine/renderers/index.d.ts.map +1 -0
- package/dist/engine/renderers/index.js +13 -0
- package/dist/engine/renderers/opencode.d.ts +18 -0
- package/dist/engine/renderers/opencode.d.ts.map +1 -0
- package/dist/engine/renderers/opencode.js +119 -0
- package/dist/engine/schema.d.ts +13 -0
- package/dist/engine/schema.d.ts.map +1 -0
- package/dist/engine/schema.js +125 -0
- package/dist/engine/seed.d.ts +14 -0
- package/dist/engine/seed.d.ts.map +1 -0
- package/dist/engine/seed.js +398 -0
- package/dist/engine/skills.d.ts +11 -0
- package/dist/engine/skills.d.ts.map +1 -0
- package/dist/engine/skills.js +24 -0
- package/dist/engine/targets.d.ts +17 -0
- package/dist/engine/targets.d.ts.map +1 -0
- package/dist/engine/targets.js +79 -0
- package/dist/engine/types.d.ts +100 -0
- package/dist/engine/types.d.ts.map +1 -0
- package/dist/engine/types.js +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -0
- package/dist/tools/engine.d.ts +22 -0
- package/dist/tools/engine.d.ts.map +1 -0
- package/dist/tools/engine.js +56 -0
- package/dist/utils/cortex-code-bridge.d.ts +21 -0
- package/dist/utils/cortex-code-bridge.d.ts.map +1 -0
- package/dist/utils/cortex-code-bridge.js +104 -0
- package/package.json +4 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ui-design
|
|
3
|
-
description: Visual design principles, UI patterns, spacing systems, typography, color, motion, and professional polish for web interfaces
|
|
3
|
+
description: Visual design principles, UI patterns, spacing systems, typography, color, motion, and professional polish for web interfaces. Emphasizes distinctive, non-generic aesthetics that avoid "AI slop" through bold creative choices.
|
|
4
4
|
license: Apache-2.0
|
|
5
5
|
compatibility: opencode
|
|
6
6
|
---
|
|
@@ -9,6 +9,22 @@ compatibility: opencode
|
|
|
9
9
|
|
|
10
10
|
This skill provides visual design patterns and aesthetic guidelines for building professionally designed web interfaces. It complements the `frontend-development` skill which covers engineering implementation.
|
|
11
11
|
|
|
12
|
+
## Design Thinking
|
|
13
|
+
|
|
14
|
+
Before coding, understand the context and commit to a BOLD aesthetic direction:
|
|
15
|
+
- **Purpose**: What problem does this interface solve? Who uses it?
|
|
16
|
+
- **Tone**: Pick an extreme: brutally minimal, maximalist chaos, retro-futuristic, organic/natural, luxury/refined, playful/toy-like, editorial/magazine, brutalist/raw, art deco/geometric, soft/pastel, industrial/utilitarian, etc. There are so many flavors to choose from. Use these for inspiration but design one that is true to the aesthetic direction.
|
|
17
|
+
- **Constraints**: Technical requirements (framework, performance, accessibility).
|
|
18
|
+
- **Differentiation**: What makes this UNFORGETTABLE? What's the one thing someone will remember?
|
|
19
|
+
|
|
20
|
+
**CRITICAL**: Choose a clear conceptual direction and execute it with precision. Bold maximalism and refined minimalism both work — the key is intentionality, not intensity.
|
|
21
|
+
|
|
22
|
+
Then implement working code (HTML/CSS/JS, React, Vue, etc.) that is:
|
|
23
|
+
- Production-grade and functional
|
|
24
|
+
- Visually striking and memorable
|
|
25
|
+
- Cohesive with a clear aesthetic point-of-view
|
|
26
|
+
- Meticulously refined in every detail
|
|
27
|
+
|
|
12
28
|
## When to Use
|
|
13
29
|
|
|
14
30
|
Use this skill when:
|
|
@@ -274,6 +290,17 @@ Generous whitespace signals professionalism. Cramped layouts signal amateur work
|
|
|
274
290
|
| Marketing / Brand | System font stack | `font-sans` (default Tailwind) |
|
|
275
291
|
| Editorial / Blog | Serif pairing (e.g., Lora + Inter) | Custom `font-serif` in Tailwind config |
|
|
276
292
|
|
|
293
|
+
### Font Selection Philosophy
|
|
294
|
+
|
|
295
|
+
Choose distinctive, unexpected, characterful fonts that elevate the interface beyond generic defaults. The font is often the single most impactful aesthetic decision — treat it as a creative choice, not a checkbox.
|
|
296
|
+
|
|
297
|
+
- **Avoid generic fonts** (Inter, Roboto, Arial, system fonts) unless the project specifically requires them or the design spec mandates them
|
|
298
|
+
- **Pair a distinctive display font with a refined body font** — the contrast between an expressive heading typeface and a clean reading typeface creates visual interest and hierarchy
|
|
299
|
+
- **Seek out characterful options** — explore foundries, Google Fonts beyond page 1, and variable fonts that offer expressive range
|
|
300
|
+
- **Match the font to the tone** — a brutalist interface demands a different typeface than a luxury brand; let the Design Thinking direction guide your choice
|
|
301
|
+
|
|
302
|
+
> The Font Recommendations table above provides safe defaults for common project types. When the design direction calls for something bolder, use those as a starting point and explore beyond them.
|
|
303
|
+
|
|
277
304
|
### Rules
|
|
278
305
|
- **Max 2 font families** — one for headings (optional), one for body
|
|
279
306
|
- **Max 3 weights** — Regular (400), Medium (500), Bold (700)
|
|
@@ -282,6 +309,82 @@ Generous whitespace signals professionalism. Cramped layouts signal amateur work
|
|
|
282
309
|
|
|
283
310
|
> **When to deviate:** Branding may require specific fonts. Always test readability at 16px body size. Never go below 14px for body text.
|
|
284
311
|
|
|
312
|
+
## Aesthetic Philosophy
|
|
313
|
+
|
|
314
|
+
This section provides creative direction for building interfaces that feel genuinely designed — not generated. Use these guidelines alongside the systematic design spec to create UIs with a clear point-of-view.
|
|
315
|
+
|
|
316
|
+
### Typography as Identity
|
|
317
|
+
|
|
318
|
+
Typography is the most powerful tool for establishing visual identity. Choose fonts that are beautiful, unique, and interesting — fonts that someone would notice and remember.
|
|
319
|
+
|
|
320
|
+
- **Distinctive over safe** — opt for characterful choices that elevate the interface's aesthetics; unexpected, memorable font pairings
|
|
321
|
+
- **Pair intentionally** — a distinctive display font with a refined body font creates contrast and hierarchy
|
|
322
|
+
- **Vary across projects** — NEVER converge on the same "safe" choices (e.g., Space Grotesk) across different designs. Each project deserves its own typographic identity
|
|
323
|
+
|
|
324
|
+
### Color & Theme
|
|
325
|
+
|
|
326
|
+
Commit to a cohesive aesthetic rather than a timid, evenly-distributed palette.
|
|
327
|
+
|
|
328
|
+
- **Use CSS variables** for consistency across the entire interface
|
|
329
|
+
- **Dominant colors with sharp accents** outperform safe, evenly-balanced palettes — pick a strong primary and let accents punctuate, not compete
|
|
330
|
+
- **Dark vs. light is a creative choice** — vary between light and dark themes based on the design direction, not habit
|
|
331
|
+
- **Color should reinforce tone** — a luxury interface uses restrained, rich tones; a playful interface uses saturated, energetic ones
|
|
332
|
+
|
|
333
|
+
### Motion & Micro-Interactions
|
|
334
|
+
|
|
335
|
+
Use animations to create delight and communicate state, not to fill space.
|
|
336
|
+
|
|
337
|
+
- **Prioritize CSS-only solutions** for HTML/vanilla projects
|
|
338
|
+
- **Use Motion library** (Framer Motion) for React when available
|
|
339
|
+
- **Focus on high-impact moments** — one well-orchestrated page load with staggered reveals (`animation-delay`) creates more delight than scattered micro-interactions
|
|
340
|
+
- **Scroll-triggered animations** and hover states that surprise add personality
|
|
341
|
+
- **Entrance choreography** — stagger elements on page load to create a sense of intentional reveal rather than everything appearing at once
|
|
342
|
+
|
|
343
|
+
### Spatial Composition
|
|
344
|
+
|
|
345
|
+
Break free from predictable grid layouts when the design direction calls for it.
|
|
346
|
+
|
|
347
|
+
- **Unexpected layouts** — asymmetry, overlap, diagonal flow, grid-breaking elements
|
|
348
|
+
- **Generous negative space OR controlled density** — both are valid, but choose deliberately
|
|
349
|
+
- **Overlap and layering** — elements that break out of their containers create depth and visual interest
|
|
350
|
+
- **Diagonal and non-linear flow** — guide the eye through unexpected paths when appropriate
|
|
351
|
+
- **Scale contrast** — pair very large elements with very small ones for dramatic hierarchy
|
|
352
|
+
|
|
353
|
+
### Backgrounds & Visual Details
|
|
354
|
+
|
|
355
|
+
Create atmosphere and depth rather than defaulting to solid colors.
|
|
356
|
+
|
|
357
|
+
- **Gradient meshes** — multi-point gradients that create organic, flowing color transitions
|
|
358
|
+
- **Noise textures** — subtle grain overlays that add tactile quality to flat surfaces
|
|
359
|
+
- **Geometric patterns** — repeating shapes that create rhythm and visual texture
|
|
360
|
+
- **Layered transparencies** — overlapping semi-transparent elements for depth
|
|
361
|
+
- **Dramatic shadows** — shadows as a design element, not just elevation
|
|
362
|
+
- **Decorative borders** — borders that contribute to the aesthetic, not just separate content
|
|
363
|
+
- **Custom cursors** — cursor changes that reinforce the interface's personality
|
|
364
|
+
- **Grain overlays** — film-grain effects that add warmth and analog character
|
|
365
|
+
|
|
366
|
+
### Anti-AI-Slop Guidelines
|
|
367
|
+
|
|
368
|
+
NEVER produce generic AI-generated aesthetics. Specifically avoid:
|
|
369
|
+
|
|
370
|
+
- **Overused font families** — Inter, Roboto, Arial, system fonts as a default choice (they're fine when the design spec requires them, but never as a lazy default)
|
|
371
|
+
- **Cliché color schemes** — particularly purple gradients on white backgrounds, the "AI startup" palette
|
|
372
|
+
- **Predictable layouts** — cookie-cutter hero + 3-column features + testimonials without any creative interpretation
|
|
373
|
+
- **Component patterns without character** — every card, button, and section looking like a UI kit demo
|
|
374
|
+
- **Sameness across projects** — if two different projects look like they could be the same site, something went wrong
|
|
375
|
+
|
|
376
|
+
Interpret creatively and make unexpected choices that feel genuinely designed for the context. No two designs should look the same.
|
|
377
|
+
|
|
378
|
+
### Execution Complexity
|
|
379
|
+
|
|
380
|
+
Match implementation complexity to the aesthetic vision:
|
|
381
|
+
|
|
382
|
+
- **Maximalist designs** need elaborate code with extensive animations, layered effects, rich textures, and detailed interactions. Don't hold back — commit fully to the vision with the code to back it up.
|
|
383
|
+
- **Minimalist or refined designs** need restraint, precision, and careful attention to spacing, typography, and subtle details. Elegance comes from what you leave out and how perfectly you execute what remains.
|
|
384
|
+
- **The key is intentionality** — every CSS property, every animation, every color choice should serve the design direction. Random complexity is worse than simplicity.
|
|
385
|
+
|
|
386
|
+
> Remember: extraordinary creative work is possible. Don't default to safe choices — commit fully to a distinctive vision and execute it with precision.
|
|
387
|
+
|
|
285
388
|
## Color System
|
|
286
389
|
|
|
287
390
|
### Default Palette Structure
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img src="https://img.shields.io/badge/cortex-agents-111?style=for-the-badge&labelColor=111&color=4d96ff" alt="cortex-agents" height="40">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
<h3 align="center">Structured AI development workflows for <a href="https://opencode.ai">OpenCode</a>.<br>Plan. Build. Ship. With discipline.</h3>
|
|
5
|
+
<h3 align="center">Structured AI development workflows for <a href="https://opencode.ai">OpenCode</a>, <a href="https://claude.ai">Claude Code</a>, <a href="https://github.com/openai/codex">Codex CLI</a>, and <a href="https://github.com/google-gemini/gemini-cli">Gemini CLI</a>.<br>Plan. Build. Ship. With discipline.</h3>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="https://www.npmjs.com/package/cortex-agents"><img src="https://img.shields.io/npm/v/cortex-agents.svg?style=flat-square&color=4d96ff" alt="npm version"></a>
|
|
@@ -52,12 +52,28 @@ This ensures you get plans that actually solve the right problem — not AI hall
|
|
|
52
52
|
## Quick Start
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
|
|
56
|
-
npx cortex-agents
|
|
57
|
-
#
|
|
55
|
+
# OpenCode (default)
|
|
56
|
+
npx cortex-agents install # Add plugin + agents + skills
|
|
57
|
+
npx cortex-agents configure # Pick your models interactively
|
|
58
|
+
|
|
59
|
+
# Claude Code
|
|
60
|
+
npx cortex-agents install --target claude # Render agents + CLAUDE.md
|
|
61
|
+
npx cortex-agents sync --target claude # Re-sync after DB changes
|
|
62
|
+
|
|
63
|
+
# Codex CLI
|
|
64
|
+
npx cortex-agents install --target codex # Render AGENTS.md instructions
|
|
65
|
+
|
|
66
|
+
# Gemini CLI
|
|
67
|
+
npx cortex-agents install --target gemini # Render agents + GEMINI.md
|
|
68
|
+
|
|
69
|
+
# Multiple targets
|
|
70
|
+
npx cortex-agents install --target opencode
|
|
71
|
+
npx cortex-agents install --target claude
|
|
72
|
+
npx cortex-agents install --target codex
|
|
73
|
+
npx cortex-agents install --target gemini
|
|
58
74
|
```
|
|
59
75
|
|
|
60
|
-
Your
|
|
76
|
+
Your sessions now have **12 specialized agents**, **35 tools**, and **17 domain skills**.
|
|
61
77
|
|
|
62
78
|
> **Built-in Agent Replacement** — Cortex automatically disables OpenCode's native `build` and `plan` agents (replaced by `implement` and `architect`). The `architect` agent becomes the default, promoting a planning-first workflow. Native agents are fully restored on `uninstall`.
|
|
63
79
|
|
|
@@ -125,6 +141,35 @@ Not every change needs a full audit. The quality gate scales with risk:
|
|
|
125
141
|
|
|
126
142
|
---
|
|
127
143
|
|
|
144
|
+
## Cortex Engine
|
|
145
|
+
|
|
146
|
+
Cortex Agents is backed by a **SQLite data model** at `~/.config/cortex-agents/cortex.db`. Agents, skills, and model configurations are stored in a single source of truth. Target-specific **renderers** transform DB records into each CLI's native format on `install` or `sync`.
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
150
|
+
│ CortexEngine │
|
|
151
|
+
│ AgentStore │ SkillStore │ Models │ Targets │
|
|
152
|
+
│ SQLite (cortex.db) │
|
|
153
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
|
|
154
|
+
│ │ Claude │ │ OpenCode │ │ Codex │ │ Gemini │ │
|
|
155
|
+
│ │ Renderer │ │ Renderer │ │ Renderer │ │ Renderer │ │
|
|
156
|
+
│ └──────────┘ └──────────┘ └──────────┘ └──────────────┘ │
|
|
157
|
+
└──────────────────────────────────────────────────────────────┘
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
This means you can install once, then render to as many targets as you need. Four renderers ship out of the box:
|
|
161
|
+
|
|
162
|
+
| Target | Config Dir | Agent Format | Instructions File |
|
|
163
|
+
|--------|-----------|--------------|-------------------|
|
|
164
|
+
| **Claude Code** | `~/.claude` | Per-agent `.md` with Claude frontmatter | `CLAUDE.md` |
|
|
165
|
+
| **OpenCode** | `~/.config/opencode` | Per-agent `.md` with tools/permission YAML | — |
|
|
166
|
+
| **Codex CLI** | `~/.codex` | Single `agents/AGENTS.md` | `agents/AGENTS.md` |
|
|
167
|
+
| **Gemini CLI** | `~/.gemini` | Per-agent `.md` with Gemini frontmatter | `GEMINI.md` |
|
|
168
|
+
|
|
169
|
+
Changes to agents or skills in the DB are picked up by `sync` without re-downloading anything.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
128
173
|
## Agents
|
|
129
174
|
|
|
130
175
|
### Primary Agents (3)
|
|
@@ -181,7 +226,7 @@ This ensures visual consistency across all agents and sessions — no more one-o
|
|
|
181
226
|
|
|
182
227
|
## Tools
|
|
183
228
|
|
|
184
|
-
|
|
229
|
+
35 tools bundled and auto-registered. No configuration needed.
|
|
185
230
|
|
|
186
231
|
<table>
|
|
187
232
|
<tr><td width="50%">
|
|
@@ -241,6 +286,13 @@ The architect uses these to browse your backlog and seed plans from real issues.
|
|
|
241
286
|
|
|
242
287
|
State persists to `.cortex/repl-state.json` — survives context compaction, session restarts, and agent switches.
|
|
243
288
|
|
|
289
|
+
</td></tr>
|
|
290
|
+
<tr><td colspan="2">
|
|
291
|
+
|
|
292
|
+
**Engine (NEW)**
|
|
293
|
+
- `cortex_get_skill` — Retrieve domain skill content from DB
|
|
294
|
+
- `cortex_list_agents` — List all registered agents with tools
|
|
295
|
+
|
|
244
296
|
</td></tr>
|
|
245
297
|
</table>
|
|
246
298
|
|
|
@@ -410,20 +462,22 @@ your-project/
|
|
|
410
462
|
## CLI Reference
|
|
411
463
|
|
|
412
464
|
```bash
|
|
413
|
-
npx cortex-agents install
|
|
414
|
-
npx cortex-agents
|
|
415
|
-
npx cortex-agents
|
|
416
|
-
npx cortex-agents configure
|
|
417
|
-
npx cortex-agents configure --project
|
|
418
|
-
npx cortex-agents
|
|
419
|
-
npx cortex-agents
|
|
465
|
+
npx cortex-agents install # Install plugin, agents, and skills (OpenCode default)
|
|
466
|
+
npx cortex-agents install --target claude|opencode|codex|gemini # Install to specific CLI target
|
|
467
|
+
npx cortex-agents sync --target claude|opencode|codex|gemini # Re-render from DB to target
|
|
468
|
+
npx cortex-agents configure # Global model selection
|
|
469
|
+
npx cortex-agents configure --project # Per-project model selection
|
|
470
|
+
npx cortex-agents configure --reset # Reset global models
|
|
471
|
+
npx cortex-agents configure --project --reset # Reset per-project models
|
|
472
|
+
npx cortex-agents uninstall # Clean removal of everything
|
|
473
|
+
npx cortex-agents status # Show installation, model, and DB stats
|
|
420
474
|
```
|
|
421
475
|
|
|
422
476
|
---
|
|
423
477
|
|
|
424
478
|
## Requirements
|
|
425
479
|
|
|
426
|
-
- [OpenCode](https://opencode.ai) >= 1.0.0
|
|
480
|
+
- [OpenCode](https://opencode.ai) >= 1.0.0, [Claude Code](https://claude.ai), [Codex CLI](https://github.com/openai/codex), or [Gemini CLI](https://github.com/google-gemini/gemini-cli)
|
|
427
481
|
- Node.js >= 18.0.0
|
|
428
482
|
- Git (for branch/worktree features)
|
|
429
483
|
- [GitHub CLI](https://cli.github.com/) (optional — for PR creation and issue integration)
|
|
@@ -441,7 +495,7 @@ git clone https://github.com/ps-carvalho/cortex-agents.git
|
|
|
441
495
|
cd cortex-agents
|
|
442
496
|
npm install
|
|
443
497
|
npm run build
|
|
444
|
-
npm test #
|
|
498
|
+
npm test # All tests should pass
|
|
445
499
|
```
|
|
446
500
|
|
|
447
501
|
### Local Development
|
|
@@ -465,7 +519,22 @@ src/
|
|
|
465
519
|
index.ts Plugin entry point, tool registration, event hooks
|
|
466
520
|
registry.ts Agent/model registry constants
|
|
467
521
|
cli.ts CLI (install, configure, uninstall, status)
|
|
522
|
+
engine/
|
|
523
|
+
index.ts CortexEngine facade
|
|
524
|
+
db.ts SQLite connection factory
|
|
525
|
+
schema.ts DDL, migrations
|
|
526
|
+
types.ts TypeScript interfaces
|
|
527
|
+
agents.ts / skills.ts Data stores
|
|
528
|
+
models.ts / targets.ts
|
|
529
|
+
seed.ts Import .opencode/ → DB
|
|
530
|
+
renderers/
|
|
531
|
+
index.ts Renderer interface + registry
|
|
532
|
+
claude.ts Claude Code renderer
|
|
533
|
+
opencode.ts OpenCode renderer
|
|
534
|
+
codex.ts Codex CLI renderer
|
|
535
|
+
gemini.ts Gemini CLI renderer
|
|
468
536
|
tools/
|
|
537
|
+
engine.ts Engine-backed MCP tools
|
|
469
538
|
repl.ts REPL loop tools (init, status, report, resume, summary)
|
|
470
539
|
quality-gate.ts Quality gate aggregation tool
|
|
471
540
|
cortex.ts Project initialization tools
|
|
@@ -545,5 +614,5 @@ test: add or update tests
|
|
|
545
614
|
|
|
546
615
|
<p align="center">
|
|
547
616
|
<br>
|
|
548
|
-
<sub>Built for the <a href="https://opencode.ai">OpenCode</a>
|
|
617
|
+
<sub>Built for the <a href="https://opencode.ai">OpenCode</a>, <a href="https://claude.ai">Claude Code</a>, <a href="https://github.com/openai/codex">Codex CLI</a>, and <a href="https://github.com/google-gemini/gemini-cli">Gemini CLI</a> communities</sub>
|
|
549
618
|
</p>
|
package/dist/cli.js
CHANGED
|
@@ -4,6 +4,7 @@ import * as path from "path";
|
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import prompts from "prompts";
|
|
6
6
|
import { PRIMARY_AGENTS, SUBAGENTS, ALL_AGENTS, DISABLED_BUILTIN_AGENTS, STALE_AGENT_FILES, getPrimaryChoices, getSubagentChoices, } from "./registry.js";
|
|
7
|
+
import { CortexEngine } from "./engine/index.js";
|
|
7
8
|
const PLUGIN_NAME = "cortex-agents";
|
|
8
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
10
|
const __dirname = path.dirname(__filename);
|
|
@@ -179,8 +180,96 @@ function removeAgentsAndSkills(targetDir) {
|
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
182
|
}
|
|
183
|
+
// ─── Target flag parsing ─────────────────────────────────────────────────────
|
|
184
|
+
function parseTargetFlag() {
|
|
185
|
+
const args = process.argv.slice(3);
|
|
186
|
+
const idx = args.indexOf("--target");
|
|
187
|
+
if (idx === -1 || idx + 1 >= args.length)
|
|
188
|
+
return null;
|
|
189
|
+
return args[idx + 1];
|
|
190
|
+
}
|
|
191
|
+
function parseScopeFlag() {
|
|
192
|
+
const args = process.argv.slice(3);
|
|
193
|
+
if (args.includes("--project"))
|
|
194
|
+
return "project";
|
|
195
|
+
return "global";
|
|
196
|
+
}
|
|
197
|
+
// ─── Engine-backed sync command ─────────────────────────────────────────────
|
|
198
|
+
function sync() {
|
|
199
|
+
const target = parseTargetFlag();
|
|
200
|
+
if (!target) {
|
|
201
|
+
console.error("Error: --target flag is required for sync.");
|
|
202
|
+
console.error("Usage: npx cortex-agents sync --target claude|opencode|codex|gemini");
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
console.log(`\nSyncing to ${target}...\n`);
|
|
206
|
+
const engine = new CortexEngine();
|
|
207
|
+
engine.initialize();
|
|
208
|
+
try {
|
|
209
|
+
const result = engine.syncTarget(target);
|
|
210
|
+
console.log(` Agents written: ${result.agentsWritten.length}`);
|
|
211
|
+
for (const id of result.agentsWritten) {
|
|
212
|
+
console.log(` - ${id}`);
|
|
213
|
+
}
|
|
214
|
+
if (result.skillsWritten.length > 0) {
|
|
215
|
+
console.log(` Skills written: ${result.skillsWritten.length}`);
|
|
216
|
+
}
|
|
217
|
+
if (result.instructionsWritten) {
|
|
218
|
+
console.log(` Instructions file: written`);
|
|
219
|
+
}
|
|
220
|
+
if (result.errors.length > 0) {
|
|
221
|
+
console.log(`\n Errors:`);
|
|
222
|
+
for (const err of result.errors) {
|
|
223
|
+
console.log(` - ${err}`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
console.log(`\nDone! Sync complete for ${target}.\n`);
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
engine.close();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// ─── Engine-backed install for specific targets ─────────────────────────────
|
|
233
|
+
function installTarget(target) {
|
|
234
|
+
console.log(`\nInstalling ${PLUGIN_NAME} v${VERSION} for ${target}...\n`);
|
|
235
|
+
const engine = new CortexEngine();
|
|
236
|
+
const seedResult = engine.initialize();
|
|
237
|
+
if (seedResult) {
|
|
238
|
+
console.log(` Database seeded: ${seedResult.agents} agents, ${seedResult.skills} skills, ${seedResult.models} models`);
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
const scope = parseScopeFlag();
|
|
242
|
+
const result = engine.syncTarget(target, { scope });
|
|
243
|
+
console.log(` Agents written: ${result.agentsWritten.length}`);
|
|
244
|
+
if (result.skillsWritten.length > 0) {
|
|
245
|
+
console.log(` Skills written: ${result.skillsWritten.length}`);
|
|
246
|
+
}
|
|
247
|
+
if (result.instructionsWritten) {
|
|
248
|
+
console.log(` Instructions file: written`);
|
|
249
|
+
}
|
|
250
|
+
// Record installation
|
|
251
|
+
const installPath = scope === "project" ? process.cwd() : "global";
|
|
252
|
+
engine.recordInstallation(target, scope, installPath, VERSION);
|
|
253
|
+
if (result.errors.length > 0) {
|
|
254
|
+
console.log(`\n Errors:`);
|
|
255
|
+
for (const err of result.errors) {
|
|
256
|
+
console.log(` - ${err}`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
console.log(`\nDone! ${target} target installed.\n`);
|
|
260
|
+
}
|
|
261
|
+
finally {
|
|
262
|
+
engine.close();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
182
265
|
// ─── Commands ────────────────────────────────────────────────────────────────
|
|
183
266
|
function install() {
|
|
267
|
+
// Check for --target flag: use engine-backed install
|
|
268
|
+
const target = parseTargetFlag();
|
|
269
|
+
if (target) {
|
|
270
|
+
return installTarget(target);
|
|
271
|
+
}
|
|
272
|
+
// Default: original opencode install behavior
|
|
184
273
|
console.log(`\nInstalling ${PLUGIN_NAME} v${VERSION}...\n`);
|
|
185
274
|
const globalDir = getGlobalDir();
|
|
186
275
|
const configInfo = findOpencodeConfig();
|
|
@@ -598,6 +687,43 @@ function status() {
|
|
|
598
687
|
console.log(` Run 'npx ${PLUGIN_NAME} configure' for global config`);
|
|
599
688
|
console.log(` Run 'npx ${PLUGIN_NAME} configure --project' for per-project config`);
|
|
600
689
|
}
|
|
690
|
+
// Engine database status
|
|
691
|
+
try {
|
|
692
|
+
const engine = new CortexEngine();
|
|
693
|
+
engine.initialize();
|
|
694
|
+
const dbAgents = engine.listAgents();
|
|
695
|
+
const dbSkills = engine.listSkills();
|
|
696
|
+
const dbModels = engine.listModels();
|
|
697
|
+
const dbTargets = engine.listTargets();
|
|
698
|
+
const installations = engine.getInstallations();
|
|
699
|
+
console.log("\nEngine Database:");
|
|
700
|
+
console.log(` Agents: ${dbAgents.length} (${dbAgents.filter(a => a.mode === 'primary').length} primary, ${dbAgents.filter(a => a.mode === 'subagent').length} subagent)`);
|
|
701
|
+
console.log(` Skills: ${dbSkills.length}`);
|
|
702
|
+
console.log(` Models: ${dbModels.length}`);
|
|
703
|
+
console.log(` Targets: ${dbTargets.map(t => t.id).join(", ")}`);
|
|
704
|
+
if (installations.length > 0) {
|
|
705
|
+
console.log(` Installations:`);
|
|
706
|
+
for (const inst of installations) {
|
|
707
|
+
console.log(` - ${inst.target_id} (${inst.scope}) v${inst.version} at ${inst.path}`);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
engine.close();
|
|
711
|
+
}
|
|
712
|
+
catch {
|
|
713
|
+
// Engine not yet initialized — skip silently
|
|
714
|
+
}
|
|
715
|
+
// Cortex Code integration detection
|
|
716
|
+
const cortexEventUrl = process.env.CORTEX_EVENT_URL;
|
|
717
|
+
const cortexTaskId = process.env.CORTEX_TASK_ID;
|
|
718
|
+
const cortexCode = process.env.CORTEX_CODE;
|
|
719
|
+
if (cortexEventUrl && cortexTaskId && cortexCode) {
|
|
720
|
+
console.log("\nCortex Code: DETECTED");
|
|
721
|
+
console.log(` Event URL: ${cortexEventUrl}`);
|
|
722
|
+
console.log(` Task ID: ${cortexTaskId}`);
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
console.log("\nCortex Code: Not detected");
|
|
726
|
+
}
|
|
601
727
|
if (!isInstalled) {
|
|
602
728
|
console.log(`\nRun 'npx ${PLUGIN_NAME} install' to add to config.`);
|
|
603
729
|
}
|
|
@@ -613,22 +739,26 @@ USAGE:
|
|
|
613
739
|
npx ${PLUGIN_NAME} <command> [options]
|
|
614
740
|
|
|
615
741
|
COMMANDS:
|
|
616
|
-
install
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
configure
|
|
620
|
-
configure --project
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
742
|
+
install Install plugin, agents, and skills into OpenCode config
|
|
743
|
+
install --target <target> Install to a specific CLI target (engine-backed)
|
|
744
|
+
sync --target <target> Re-render agents from DB to target config dir
|
|
745
|
+
configure Interactive model selection (global)
|
|
746
|
+
configure --project Interactive model selection (per-project)
|
|
747
|
+
configure --reset Reset model configuration to defaults
|
|
748
|
+
uninstall Remove plugin, agents, skills, and model config
|
|
749
|
+
status Show installation, DB stats, and model configuration
|
|
750
|
+
help Show this help message
|
|
624
751
|
|
|
625
752
|
EXAMPLES:
|
|
626
|
-
npx ${PLUGIN_NAME} install # Install plugin
|
|
753
|
+
npx ${PLUGIN_NAME} install # Install plugin (OpenCode default)
|
|
754
|
+
npx ${PLUGIN_NAME} install --target claude # Install to Claude Code
|
|
755
|
+
npx ${PLUGIN_NAME} install --target opencode # Install to OpenCode
|
|
756
|
+
npx ${PLUGIN_NAME} install --target codex # Install to Codex CLI
|
|
757
|
+
npx ${PLUGIN_NAME} install --target gemini # Install to Gemini CLI
|
|
758
|
+
npx ${PLUGIN_NAME} sync --target claude # Re-sync agents to Claude Code
|
|
627
759
|
npx ${PLUGIN_NAME} configure # Global model selection
|
|
628
|
-
npx ${PLUGIN_NAME} configure --project # Per-project models
|
|
629
|
-
npx ${PLUGIN_NAME}
|
|
630
|
-
npx ${PLUGIN_NAME} configure --project --reset # Reset per-project models
|
|
631
|
-
npx ${PLUGIN_NAME} status # Check status
|
|
760
|
+
npx ${PLUGIN_NAME} configure --project # Per-project models
|
|
761
|
+
npx ${PLUGIN_NAME} status # Check status + DB stats
|
|
632
762
|
|
|
633
763
|
AGENTS:
|
|
634
764
|
Primary (architect, implement, fix):
|
|
@@ -670,6 +800,9 @@ switch (command) {
|
|
|
670
800
|
case "install":
|
|
671
801
|
install();
|
|
672
802
|
break;
|
|
803
|
+
case "sync":
|
|
804
|
+
sync();
|
|
805
|
+
break;
|
|
673
806
|
case "configure":
|
|
674
807
|
configure().catch((err) => {
|
|
675
808
|
console.error("Configuration failed:", err.message);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type BetterSqlite3 from "better-sqlite3";
|
|
2
|
+
import type { Agent, AgentInput, AgentTool, BashPermission, AgentSkill } from "./types.js";
|
|
3
|
+
export declare class AgentStore {
|
|
4
|
+
private db;
|
|
5
|
+
constructor(db: BetterSqlite3.Database);
|
|
6
|
+
get(id: string): Agent | null;
|
|
7
|
+
list(filter?: {
|
|
8
|
+
mode?: string;
|
|
9
|
+
}): Agent[];
|
|
10
|
+
upsert(agent: AgentInput): void;
|
|
11
|
+
getTools(agentId: string): AgentTool[];
|
|
12
|
+
setTool(agentId: string, toolName: string, allowed: boolean): void;
|
|
13
|
+
setTools(agentId: string, tools: Record<string, boolean>): void;
|
|
14
|
+
getBashPermissions(agentId: string): BashPermission[];
|
|
15
|
+
setBashPermission(agentId: string, pattern: string, permission: string): void;
|
|
16
|
+
setBashPermissions(agentId: string, permissions: Record<string, string>): void;
|
|
17
|
+
getSkills(agentId: string): AgentSkill[];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/engine/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EACV,SAAS,EACT,cAAc,EACd,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,qBAAa,UAAU;IACT,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,aAAa,CAAC,QAAQ;IAE9C,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI;IAK7B,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,KAAK,EAAE;IAWzC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAc/B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE;IAOtC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAQlE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAmB/D,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE;IAOrD,iBAAiB,CACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,IAAI;IAQP,kBAAkB,CAChB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,IAAI;IAmBP,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,EAAE;CAMzC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export class AgentStore {
|
|
2
|
+
db;
|
|
3
|
+
constructor(db) {
|
|
4
|
+
this.db = db;
|
|
5
|
+
}
|
|
6
|
+
get(id) {
|
|
7
|
+
const stmt = this.db.prepare("SELECT * FROM agents WHERE id = ?");
|
|
8
|
+
return stmt.get(id) ?? null;
|
|
9
|
+
}
|
|
10
|
+
list(filter) {
|
|
11
|
+
if (filter?.mode) {
|
|
12
|
+
const stmt = this.db.prepare("SELECT * FROM agents WHERE mode = ? ORDER BY id");
|
|
13
|
+
return stmt.all(filter.mode);
|
|
14
|
+
}
|
|
15
|
+
const stmt = this.db.prepare("SELECT * FROM agents ORDER BY id");
|
|
16
|
+
return stmt.all();
|
|
17
|
+
}
|
|
18
|
+
upsert(agent) {
|
|
19
|
+
const stmt = this.db.prepare(`INSERT OR REPLACE INTO agents (id, description, mode, temperature, system_prompt, updated_at)
|
|
20
|
+
VALUES (?, ?, ?, ?, ?, datetime('now'))`);
|
|
21
|
+
stmt.run(agent.id, agent.description, agent.mode, agent.temperature ?? 0, agent.system_prompt);
|
|
22
|
+
}
|
|
23
|
+
getTools(agentId) {
|
|
24
|
+
const stmt = this.db.prepare("SELECT * FROM agent_tools WHERE agent_id = ?");
|
|
25
|
+
return stmt.all(agentId);
|
|
26
|
+
}
|
|
27
|
+
setTool(agentId, toolName, allowed) {
|
|
28
|
+
const stmt = this.db.prepare(`INSERT OR REPLACE INTO agent_tools (agent_id, tool_name, allowed)
|
|
29
|
+
VALUES (?, ?, ?)`);
|
|
30
|
+
stmt.run(agentId, toolName, allowed ? 1 : 0);
|
|
31
|
+
}
|
|
32
|
+
setTools(agentId, tools) {
|
|
33
|
+
const deleteStmt = this.db.prepare("DELETE FROM agent_tools WHERE agent_id = ?");
|
|
34
|
+
const insertStmt = this.db.prepare(`INSERT INTO agent_tools (agent_id, tool_name, allowed)
|
|
35
|
+
VALUES (?, ?, ?)`);
|
|
36
|
+
const batch = this.db.transaction(() => {
|
|
37
|
+
deleteStmt.run(agentId);
|
|
38
|
+
for (const [toolName, allowed] of Object.entries(tools)) {
|
|
39
|
+
insertStmt.run(agentId, toolName, allowed ? 1 : 0);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
batch();
|
|
43
|
+
}
|
|
44
|
+
getBashPermissions(agentId) {
|
|
45
|
+
const stmt = this.db.prepare("SELECT * FROM agent_bash_permissions WHERE agent_id = ?");
|
|
46
|
+
return stmt.all(agentId);
|
|
47
|
+
}
|
|
48
|
+
setBashPermission(agentId, pattern, permission) {
|
|
49
|
+
const stmt = this.db.prepare(`INSERT OR REPLACE INTO agent_bash_permissions (agent_id, pattern, permission)
|
|
50
|
+
VALUES (?, ?, ?)`);
|
|
51
|
+
stmt.run(agentId, pattern, permission);
|
|
52
|
+
}
|
|
53
|
+
setBashPermissions(agentId, permissions) {
|
|
54
|
+
const deleteStmt = this.db.prepare("DELETE FROM agent_bash_permissions WHERE agent_id = ?");
|
|
55
|
+
const insertStmt = this.db.prepare(`INSERT INTO agent_bash_permissions (agent_id, pattern, permission)
|
|
56
|
+
VALUES (?, ?, ?)`);
|
|
57
|
+
const batch = this.db.transaction(() => {
|
|
58
|
+
deleteStmt.run(agentId);
|
|
59
|
+
for (const [pattern, permission] of Object.entries(permissions)) {
|
|
60
|
+
insertStmt.run(agentId, pattern, permission);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
batch();
|
|
64
|
+
}
|
|
65
|
+
getSkills(agentId) {
|
|
66
|
+
const stmt = this.db.prepare("SELECT * FROM agent_skills WHERE agent_id = ?");
|
|
67
|
+
return stmt.all(agentId);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the default database path: ~/.config/cortex-agents/cortex.db
|
|
4
|
+
*/
|
|
5
|
+
export declare function getDefaultDbPath(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Creates (or opens) a better-sqlite3 database with WAL mode and foreign keys enabled.
|
|
8
|
+
*
|
|
9
|
+
* @param dbPath - Absolute path to the SQLite file. Defaults to ~/.config/cortex-agents/cortex.db
|
|
10
|
+
* @returns The configured Database instance
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDatabase(dbPath?: string): Database.Database;
|
|
13
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/engine/db.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAKtC;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAgBjE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the default database path: ~/.config/cortex-agents/cortex.db
|
|
7
|
+
*/
|
|
8
|
+
export function getDefaultDbPath() {
|
|
9
|
+
return path.join(os.homedir(), ".config", "cortex-agents", "cortex.db");
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates (or opens) a better-sqlite3 database with WAL mode and foreign keys enabled.
|
|
13
|
+
*
|
|
14
|
+
* @param dbPath - Absolute path to the SQLite file. Defaults to ~/.config/cortex-agents/cortex.db
|
|
15
|
+
* @returns The configured Database instance
|
|
16
|
+
*/
|
|
17
|
+
export function createDatabase(dbPath) {
|
|
18
|
+
const resolvedPath = dbPath ?? getDefaultDbPath();
|
|
19
|
+
// Ensure the parent directory exists
|
|
20
|
+
const dir = path.dirname(resolvedPath);
|
|
21
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
22
|
+
const db = new Database(resolvedPath);
|
|
23
|
+
// Enable WAL mode for better concurrent read performance
|
|
24
|
+
db.pragma("journal_mode = WAL");
|
|
25
|
+
// Enforce foreign key constraints
|
|
26
|
+
db.pragma("foreign_keys = ON");
|
|
27
|
+
return db;
|
|
28
|
+
}
|