@namch/agent-assistant 1.0.3 → 1.1.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 (86) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +1 -1
  3. package/agents/planner.md +59 -11
  4. package/agents/reporter.md +1 -1
  5. package/cli/install.js +514 -169
  6. package/code-assistants/antigravity-assistant/AntigravityGlobal.agent.md +38 -135
  7. package/code-assistants/antigravity-assistant/GEMINI.md +37 -137
  8. package/code-assistants/claude-assistant/CLAUDE.md +60 -38
  9. package/code-assistants/copilot-assistant/agent-assistant.agent.md +44 -125
  10. package/code-assistants/cursor-assistant/.cursorrules +42 -84
  11. package/code-assistants/cursor-assistant/rules/agent-assistant.mdc +37 -135
  12. package/commands/ask/fast.md +6 -4
  13. package/commands/ask/hard.md +6 -4
  14. package/commands/ask.md +3 -3
  15. package/commands/auto.md +3 -3
  16. package/commands/brainstorm/fast.md +6 -4
  17. package/commands/brainstorm/hard.md +6 -4
  18. package/commands/brainstorm.md +3 -3
  19. package/commands/code/fast.md +6 -4
  20. package/commands/code/focus.md +42 -46
  21. package/commands/code/hard.md +43 -48
  22. package/commands/code.md +6 -3
  23. package/commands/cook/fast.md +5 -3
  24. package/commands/cook/focus.md +22 -51
  25. package/commands/cook/hard.md +23 -55
  26. package/commands/cook.md +3 -3
  27. package/commands/debug/fast.md +5 -3
  28. package/commands/debug/focus.md +35 -40
  29. package/commands/debug/hard.md +38 -16
  30. package/commands/debug.md +3 -3
  31. package/commands/deploy/check.md +4 -4
  32. package/commands/deploy/preview.md +4 -4
  33. package/commands/deploy/production.md +4 -4
  34. package/commands/deploy/rollback.md +4 -4
  35. package/commands/deploy.md +3 -3
  36. package/commands/design/fast.md +6 -4
  37. package/commands/design/focus.md +28 -44
  38. package/commands/design/hard.md +53 -17
  39. package/commands/design.md +3 -3
  40. package/commands/docs/audit.md +5 -5
  41. package/commands/docs/business.md +5 -5
  42. package/commands/docs/core.md +5 -5
  43. package/commands/docs.md +3 -3
  44. package/commands/fix/fast.md +5 -3
  45. package/commands/fix/focus.md +36 -44
  46. package/commands/fix/hard.md +23 -37
  47. package/commands/fix.md +3 -3
  48. package/commands/plan/fast.md +6 -4
  49. package/commands/plan/focus.md +6 -4
  50. package/commands/plan/hard.md +6 -4
  51. package/commands/plan.md +3 -3
  52. package/commands/report/fast.md +6 -4
  53. package/commands/report/focus.md +6 -4
  54. package/commands/report/hard.md +6 -4
  55. package/commands/report.md +3 -3
  56. package/commands/review/fast.md +5 -3
  57. package/commands/review/hard.md +5 -3
  58. package/commands/review.md +3 -3
  59. package/commands/test/fast.md +5 -3
  60. package/commands/test/focus.md +24 -43
  61. package/commands/test/hard.md +24 -16
  62. package/commands/test.md +3 -3
  63. package/documents/HSOL-ASSESSMENT.md +121 -0
  64. package/documents/SMART-SKILL-ORCHESTRATION-BLUEPRINT.md +1341 -0
  65. package/documents/business/business-glossary.md +6 -6
  66. package/documents/knowledge-architecture.md +81 -1
  67. package/documents/knowledge-domain.md +4 -3
  68. package/documents/knowledge-overview.md +1 -1
  69. package/documents/knowledge-source-base.md +15 -10
  70. package/package.json +5 -3
  71. package/rules/AGENTS.md +187 -0
  72. package/rules/CONTEXT-GATE.md +362 -0
  73. package/rules/CORE.md +175 -0
  74. package/rules/ERRORS.md +127 -0
  75. package/rules/PHASES.md +156 -0
  76. package/rules/REFERENCE.md +179 -0
  77. package/rules/SKILLS.md +167 -0
  78. package/skills/find-skills/SKILL.md +137 -0
  79. package/rules/ADAPTIVE-EXECUTION.md +0 -271
  80. package/rules/AGENT-RULES.md +0 -285
  81. package/rules/BOOTSTRAP.md +0 -301
  82. package/rules/ERROR-RECOVERY.md +0 -201
  83. package/rules/EXECUTION-PROTOCOL.md +0 -485
  84. package/rules/ORCHESTRATION-LAWS.md +0 -218
  85. package/rules/QUICK-REFERENCE.md +0 -204
  86. package/rules/SKILL-DISCOVERY.md +0 -370
@@ -0,0 +1,1341 @@
1
+ # Smart Skill Orchestration Mechanism — Technical Blueprint
2
+
3
+ > **Version**: 1.1
4
+ > **Author**: Senior AI System Architect
5
+ > **Date**: 2026-01-30
6
+ > **Status**: Production-Ready Design
7
+
8
+ ---
9
+
10
+ ## Executive Summary
11
+
12
+ This blueprint addresses the **Scalability Paradox** in AI agent skill management: the tension between maintaining a stable, low-latency static skill library (`matrix-skills/`) and the need for dynamic, on-demand skill discovery via the **find-skills** skill.
13
+
14
+ The solution is a **Hybrid Skill Orchestration Layer** (HSOL) that:
15
+ 1. Preserves the reliability of matrix-skills as the primary execution tier
16
+ 2. Introduces intelligent decision logic for dynamic skill acquisition via find-skills
17
+ 3. Enables autonomous skill evolution without manual maintenance burden
18
+ 4. Ensures consistency through versioned skill registries and conflict resolution
19
+
20
+ **Key Integration:** The `find-skills` skill (`{SKILLS_PATH}/find-skills/SKILL.md`) provides the dynamic discovery interface via `npx skills find` and `npx skills add` commands. Browse at https://skills.sh/
21
+
22
+ ---
23
+
24
+ ## Table of Contents
25
+
26
+ 1. [Problem Analysis](#1-problem-analysis)
27
+ 2. [First-Principles Architecture](#2-first-principles-architecture)
28
+ 3. [Hybrid Synergy Model](#3-hybrid-synergy-model)
29
+ 4. [Intelligent Decision Logic](#4-intelligent-decision-logic)
30
+ 5. [Autonomous Evolution Framework](#5-autonomous-evolution-framework)
31
+ 6. [Consistency & Versioning Strategy](#6-consistency--versioning-strategy)
32
+ 7. [Production-Grade Edge Cases](#7-production-grade-edge-cases)
33
+ 8. [Implementation Roadmap](#8-implementation-roadmap)
34
+ 9. [System Integration](#9-system-integration)
35
+
36
+ ---
37
+
38
+ ## Prerequisites
39
+
40
+ Before HSOL can function, the **find-skills** skill must exist at `{SKILLS_PATH}/find-skills/SKILL.md`, where **{SKILLS_PATH}** is the skills path for the **tool the user is currently using** (e.g. Cursor: `~/.cursor/skills/`, Copilot: `~/.copilot/skills/`, Antigravity: `~/.gemini/antigravity/skills/`). All verify and install actions apply **only to the current tool**; do not verify or install for all tools unless the user explicitly runs `install --all`.
41
+
42
+ **Installation (current tool only, skip confirmation when using npx):**
43
+
44
+ ```bash
45
+ # Option 1: Automatic when user installs agent-assistant for a tool
46
+ # User runs: npm run install:cursor (or install:copilot, install:antigravity)
47
+ # The CLI copies skills/ (including find-skills) to that tool's path only.
48
+
49
+ # Option 2: Manual copy to CURRENT TOOL's path only
50
+ # For Cursor:
51
+ cp -r skills/find-skills ~/.cursor/skills/
52
+ # For Copilot:
53
+ cp -r skills/find-skills ~/.copilot/skills/
54
+ # For Antigravity:
55
+ cp -r skills/find-skills ~/.gemini/antigravity/skills/
56
+ # Do not copy to all tools unless the user explicitly wants that.
57
+
58
+ # Option 3: Install from Vercel ecosystem (-g -y = global, skip confirmation)
59
+ # Installs to current environment's global path only.
60
+ npx skills add vercel-labs/skills@find-skills -g -y
61
+ ```
62
+
63
+ **Verification (current tool only):**
64
+ ```bash
65
+ # Check at the current tool's SKILLS_PATH (resolve from context)
66
+ ls "{SKILLS_PATH}/find-skills/SKILL.md"
67
+ # Examples: ~/.cursor/skills/find-skills/SKILL.md (Cursor)
68
+ # ~/.copilot/skills/find-skills/SKILL.md (Copilot)
69
+ ```
70
+
71
+ ---
72
+
73
+ ## 1. Problem Analysis
74
+
75
+ ### 1.1 Current State Assessment
76
+
77
+ **Static Layer (`matrix-skills/`):**
78
+ ```
79
+ Strengths:
80
+ ├── Low latency (< 1ms skill resolution)
81
+ ├── Predictable behavior (deterministic mapping)
82
+ ├── Offline-capable (no network dependency)
83
+ ├── Type-safe (YAML schema validation)
84
+ └── Agent-profile inheritance model
85
+
86
+ Weaknesses:
87
+ ├── Manual update cycle (labor-intensive)
88
+ ├── Skill obsolescence risk (stale skills)
89
+ ├── Discovery gap (unknown capabilities)
90
+ ├── Scaling limit (~310 skills practical ceiling)
91
+ └── No feedback loop for skill quality
92
+ ```
93
+
94
+ **Dynamic Layer (`find-skills` skill):**
95
+ ```
96
+ Location: {SKILLS_PATH}/find-skills/SKILL.md
97
+ Browse: https://skills.sh/
98
+
99
+ Commands:
100
+ ├── npx skills find [query] → Search for skills
101
+ ├── npx skills add <pkg> -g -y → Install globally
102
+ ├── npx skills check → Check for updates
103
+ └── npx skills update → Update all skills
104
+
105
+ Strengths:
106
+ ├── Infinite skill pool (community ecosystem)
107
+ ├── Real-time discovery (always current)
108
+ ├── Domain experts contribute directly
109
+ ├── Reduces "Capability Gap" perception
110
+ └── Supports skill versioning/updates
111
+
112
+ Weaknesses:
113
+ ├── Network latency (100-500ms per search)
114
+ ├── Availability risk (network dependency)
115
+ ├── Quality uncertainty (untested skills)
116
+ ├── Integration friction (install + configure)
117
+ └── Security surface (untrusted code)
118
+
119
+ When to Trigger:
120
+ ├── User asks "how do I do X" (might exist as skill)
121
+ ├── User says "find a skill for X"
122
+ ├── Matrix fitness < 0.75 (capability gap)
123
+ └── Enhancement mode enabled
124
+ ```
125
+
126
+ ### 1.2 Core Tensions Identified
127
+
128
+ | Tension | Static Priority | Dynamic Priority | Resolution Principle |
129
+ |---------|-----------------|------------------|---------------------|
130
+ | **Speed vs Coverage** | Sub-second | Comprehensive | Tiered fallback |
131
+ | **Reliability vs Freshness** | Battle-tested | Cutting-edge | Trust scoring |
132
+ | **Simplicity vs Flexibility** | Fixed profiles | Any request | Context-aware routing |
133
+ | **Security vs Openness** | Vetted skills | Community skills | Sandboxed evaluation |
134
+
135
+ ### 1.3 The Scalability Paradox — Root Cause
136
+
137
+ ```
138
+ ┌─────────────────────────────────────────────────────────────────┐
139
+ │ THE PARADOX CYCLE │
140
+ ├─────────────────────────────────────────────────────────────────┤
141
+ │ │
142
+ │ [More Skills Needed] ─────────────────────────────────────┐ │
143
+ │ │ │ │
144
+ │ ▼ │ │
145
+ │ [Manual Addition to Matrix] │ │
146
+ │ │ │ │
147
+ │ ▼ │ │
148
+ │ [Increased Maintenance Debt] ──────────────────┐ │ │
149
+ │ │ │ │ │
150
+ │ ▼ ▼ │ │
151
+ │ [Skills Become Stale] ◄──────────── [Update Fatigue] │ │
152
+ │ │ │ │
153
+ │ ▼ │ │
154
+ │ [Capability Gaps Appear] ──────────────────────────────────┘ │
155
+ │ │
156
+ └─────────────────────────────────────────────────────────────────┘
157
+
158
+ ROOT CAUSE: No automated feedback loop between:
159
+ 1. Skill usage patterns
160
+ 2. Skill quality metrics
161
+ 3. Skill currency status
162
+ 4. Dynamic discovery results
163
+ ```
164
+
165
+ ---
166
+
167
+ ## 2. First-Principles Architecture
168
+
169
+ ### 2.1 Design Axioms
170
+
171
+ **Axiom 1: Skill Resolution is a Search Problem**
172
+ > Every user request maps to a capability need. Skills are candidates. The system must rank and select the best match.
173
+
174
+ **Axiom 2: Latency Budget is Finite**
175
+ > User tolerance: < 2 seconds for initial response. Skill resolution must complete within 200ms for perceived instant response.
176
+
177
+ **Axiom 3: Trust is Earned, Not Assumed**
178
+ > Matrix skills have earned trust through curation. Dynamic skills must prove themselves through evaluation.
179
+
180
+ **Axiom 4: The System Must Self-Correct**
181
+ > Manual maintenance doesn't scale. The system must learn from usage patterns and self-optimize.
182
+
183
+ ### 2.2 Architectural Layers
184
+
185
+ ```
186
+ ┌─────────────────────────────────────────────────────────────────────────────┐
187
+ │ USER REQUEST │
188
+ └─────────────────────────────────────────────────────────────────────────────┘
189
+
190
+
191
+ ┌─────────────────────────────────────────────────────────────────────────────┐
192
+ │ LAYER 1: SEMANTIC INTENT CLASSIFIER │
193
+ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │
194
+ │ • Extract capability requirements from natural language │
195
+ │ • Map to skill domains and categories │
196
+ │ • Generate skill search vector │
197
+ │ • Estimate complexity and specificity │
198
+ └─────────────────────────────────────────────────────────────────────────────┘
199
+
200
+ ┌───────────────┼───────────────┐
201
+ ▼ │ ▼
202
+ ┌──────────────────────────┐ │ ┌──────────────────────────┐
203
+ │ LAYER 2A: MATRIX LOOKUP │ │ │ LAYER 2B: DYNAMIC │
204
+ │ ━━━━━━━━━━━━━━━━━━━━━━ │ │ │ DISCOVERY (ASYNC) │
205
+ │ • Profile-based match │ │ │ ━━━━━━━━━━━━━━━━━━━━━━ │
206
+ │ • Priority scoring │ │ │ • find-skills query │
207
+ │ • O(D×S) resolution │ │ │ • Community search │
208
+ │ • Immediate return │ │ │ • Speculative prefetch │
209
+ │ • LATENCY: < 10ms │ │ │ • LATENCY: 100-500ms │
210
+ └──────────────────────────┘ │ └──────────────────────────┘
211
+ │ │ │
212
+ ▼ ▼ ▼
213
+ ┌─────────────────────────────────────────────────────────────────────────────┐
214
+ │ LAYER 3: SKILL FITNESS EVALUATOR │
215
+ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │
216
+ │ • Multi-factor scoring (coverage, freshness, trust, specificity) │
217
+ │ • Gap detection (matrix can't satisfy request) │
218
+ │ • Superiority detection (dynamic skill outperforms matrix) │
219
+ │ • Recommendation generation │
220
+ └─────────────────────────────────────────────────────────────────────────────┘
221
+
222
+
223
+ ┌─────────────────────────────────────────────────────────────────────────────┐
224
+ │ LAYER 4: ORCHESTRATION DECISION ENGINE │
225
+ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │
226
+ │ Decision Matrix: │
227
+ │ ┌─────────────────┬────────────────┬───────────────────────────────────┐ │
228
+ │ │ Matrix Score │ Dynamic Score │ Action │ │
229
+ │ ├─────────────────┼────────────────┼───────────────────────────────────┤ │
230
+ │ │ HIGH (≥0.8) │ Any │ Execute matrix skill │ │
231
+ │ │ MEDIUM (0.75-0.8)│ HIGH (≥0.9) │ Suggest dynamic, execute matrix │ │
232
+ │ │ MEDIUM │ MEDIUM │ Execute matrix skill │ │
233
+ │ │ LOW (<0.75) │ HIGH (≥0.8) │ Prompt for dynamic installation │ │
234
+ │ │ LOW │ LOW │ Report capability gap │ │
235
+ │ │ NONE │ HIGH │ Install and execute dynamic │ │
236
+ │ │ NONE │ NONE │ Fallback to general capabilities │ │
237
+ │ └─────────────────┴────────────────┴───────────────────────────────────┘ │
238
+ └─────────────────────────────────────────────────────────────────────────────┘
239
+
240
+
241
+ ┌─────────────────────────────────────────────────────────────────────────────┐
242
+ │ LAYER 5: SKILL EXECUTION & FEEDBACK │
243
+ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │
244
+ │ • Execute selected skill │
245
+ │ • Capture execution metrics (success, latency, output quality) │
246
+ │ • Feed metrics to Autonomous Evolution system │
247
+ │ • Update skill usage statistics │
248
+ └─────────────────────────────────────────────────────────────────────────────┘
249
+ ```
250
+
251
+ ---
252
+
253
+ ## 3. Hybrid Synergy Model
254
+
255
+ ### 3.1 Synergy Principles
256
+
257
+ **Principle 1: Matrix-First, Dynamic-Enhanced**
258
+ > Matrix skills execute immediately. Dynamic discovery runs in parallel as "enhancement check."
259
+
260
+ **Principle 2: Blocking vs Async Discovery**
261
+ > **Blocking** (matrix fitness &lt; 0.75): Wait for discovery → install → re-inject → **then** execute. Purpose: new skill is **used for the current task** — best completion for this request. **Async** (fitness 0.75–0.8): Do not wait; execute with matrix; when discovery returns only surface recommendation for **next time**. Async does not improve accuracy for the current task.
262
+
263
+ **Principle 2b: Conditional Discovery (Variant + Fitness)**
264
+ > Dynamic discovery (find-skills, steps 8–10) runs **only** when: (1) command variant is **`hard`** or **`focus`** — **`fast`** skips discovery so fast stays fast; (2) best matrix fitness **&lt; 0.8** — if matrix already has a highly suitable skill (e.g. 9–10), skip discovery. So: fast flow → steps 1–7 + execute; hard/focus + matrix sufficient → same; hard/focus + matrix &lt; 0.8 → full flow including discovery.
265
+
266
+ **Principle 3: Graduated Trust**
267
+ > Newly discovered skills start in "evaluation mode" with limited scope. Trust increases with successful executions.
268
+
269
+ ### 3.2 Execution Flow
270
+
271
+ ```
272
+ USER REQUEST: "Implement OAuth with Clerk"
273
+
274
+
275
+ ┌───────────────────────────────────────────────────────────────┐
276
+ │ SEMANTIC INTENT CLASSIFIER │
277
+ │ │
278
+ │ Extracted: │
279
+ │ • Domain: authentication │
280
+ │ • Specificity: HIGH (Clerk is specific provider) │
281
+ │ • Capability: OAuth implementation │
282
+ │ • Keywords: ["clerk", "oauth", "authentication"] │
283
+ └───────────────────────────────────────────────────────────────┘
284
+
285
+ ├──────────────────────────────────────┐
286
+ │ │
287
+ ▼ (SYNC, <10ms) ▼ (ASYNC)
288
+ ┌─────────────────────────┐ ┌─────────────────────────┐
289
+ │ MATRIX LOOKUP │ │ DYNAMIC DISCOVERY │
290
+ │ │ │ │
291
+ │ Candidates: │ │ Query: "clerk oauth │
292
+ │ • better-auth (0.75) │ │ authentication" │
293
+ │ • api-security (0.60) │ │ │
294
+ │ • backend-dev (0.55) │ │ [Searching...] │
295
+ │ │ │ │
296
+ │ Best Match: │ │ │
297
+ │ better-auth @ 0.75 │ │ │
298
+ └─────────────────────────┘ └─────────────────────────┘
299
+ │ │
300
+ │ │ (200-500ms later)
301
+ │ ▼
302
+ │ ┌─────────────────────────┐
303
+ │ │ DISCOVERY RESULT │
304
+ │ │ │
305
+ │ │ Found: clerk-auth-skill │
306
+ │ │ Score: 0.95 │
307
+ │ │ Source: vercel-labs │
308
+ │ └─────────────────────────┘
309
+ │ │
310
+ ▼ ▼
311
+ ┌───────────────────────────────────────────────────────────────┐
312
+ │ SKILL FITNESS EVALUATOR │
313
+ │ │
314
+ │ Matrix best: better-auth @ 0.75 (generic OAuth) │
315
+ │ Dynamic best: clerk-auth @ 0.95 (Clerk-specific) │
316
+ │ │
317
+ │ DECISION: Matrix skill is ADEQUATE but not OPTIMAL │
318
+ │ Dynamic skill is SUPERIOR for this specific request │
319
+ └───────────────────────────────────────────────────────────────┘
320
+
321
+
322
+ ┌───────────────────────────────────────────────────────────────┐
323
+ │ ORCHESTRATION DECISION │
324
+ │ │
325
+ │ Option A (IMMEDIATE): Execute better-auth now │
326
+ │ → User gets working solution in < 1 second │
327
+ │ │
328
+ │ Option B (ENHANCED): Suggest clerk-auth installation │
329
+ │ → "I found a Clerk-specific skill that may give better │
330
+ │ results. Install with: npx skills add clerk-auth-skill" │
331
+ │ │
332
+ │ SELECTED: Execute A, Surface B as recommendation │
333
+ └───────────────────────────────────────────────────────────────┘
334
+ ```
335
+
336
+ ### 3.3 Cognitive Load Management
337
+
338
+ **Problem**: Agent must not be overwhelmed with skill decisions.
339
+
340
+ **Solution**: Skill Orchestration Layer (SOL) handles all skill logic transparently.
341
+
342
+ ```yaml
343
+ orchestrator_perspective:
344
+ before_HSOL:
345
+ - "Which skill do I need?"
346
+ - "Is there a better skill available?"
347
+ - "Should I search for skills?"
348
+ - "How do I install new skills?"
349
+
350
+ after_HSOL:
351
+ - "Execute task with injected skills"
352
+ - "(Recommendations surface automatically)"
353
+ ```
354
+
355
+ The agent sees only:
356
+ 1. Injected skills (already resolved)
357
+ 2. Optional enhancement recommendations (non-blocking)
358
+ 3. Capability gap alerts (when no skill can satisfy request)
359
+
360
+ ---
361
+
362
+ ## 4. Intelligent Decision Logic
363
+
364
+ ### 4.1 Skill Fitness Scoring
365
+
366
+ **Multi-Factor Fitness Model:**
367
+
368
+ ```
369
+ SKILL_FITNESS = (
370
+ w₁ × SEMANTIC_MATCH +
371
+ w₂ × SPECIFICITY_SCORE +
372
+ w₃ × TRUST_LEVEL +
373
+ w₄ × FRESHNESS_SCORE +
374
+ w₅ × SUCCESS_RATE
375
+ ) / Σwᵢ
376
+
377
+ where:
378
+ w₁ = 0.35 (semantic match is primary)
379
+ w₂ = 0.25 (specificity matters for specialized requests)
380
+ w₃ = 0.20 (trust prevents quality issues)
381
+ w₄ = 0.10 (freshness for evolving domains)
382
+ w₅ = 0.10 (historical success rate)
383
+ ```
384
+
385
+ **Factor Definitions:**
386
+
387
+ | Factor | Matrix Skill Calculation | Dynamic Skill Calculation |
388
+ |--------|--------------------------|---------------------------|
389
+ | **SEMANTIC_MATCH** | Keyword overlap + domain alignment | Search relevance score |
390
+ | **SPECIFICITY_SCORE** | Generic (0.5) to Specialized (1.0) | Query specificity alignment |
391
+ | **TRUST_LEVEL** | 1.0 (pre-vetted) | 0.3 (new) → 1.0 (proven) |
392
+ | **FRESHNESS_SCORE** | Last update recency | Always 1.0 (community-current) |
393
+ | **SUCCESS_RATE** | Historical execution success | Community rating / reviews |
394
+
395
+ ### 4.2 Self-Correction Heuristics
396
+
397
+ **Heuristic 1: Gap Detection**
398
+ ```python
399
+ def detect_capability_gap(request, matrix_skills):
400
+ """
401
+ Detect when matrix cannot adequately serve a request.
402
+ """
403
+ best_match = find_best_matrix_skill(request)
404
+
405
+ # Gap conditions:
406
+ # 1. No skill found at all
407
+ if best_match is None:
408
+ return GapType.COMPLETE_GAP
409
+
410
+ # 2. Best match is too generic
411
+ if best_match.specificity < 0.4 and request.specificity > 0.7:
412
+ return GapType.SPECIFICITY_GAP
413
+
414
+ # 3. Best match is stale for evolving domain
415
+ if best_match.last_updated < (now - 180_days) and request.domain in FAST_EVOLVING_DOMAINS:
416
+ return GapType.FRESHNESS_GAP
417
+
418
+ # 4. Best match has low success rate
419
+ if best_match.success_rate < 0.6:
420
+ return GapType.QUALITY_GAP
421
+
422
+ return GapType.NO_GAP
423
+ ```
424
+
425
+ **Heuristic 2: Superiority Detection**
426
+ ```python
427
+ def detect_superior_dynamic_skill(matrix_skill, dynamic_skill, request):
428
+ """
429
+ Determine if dynamic skill meaningfully outperforms matrix skill.
430
+ """
431
+ SUPERIORITY_THRESHOLD = 0.15 # 15% improvement required
432
+
433
+ matrix_fitness = calculate_fitness(matrix_skill, request)
434
+ dynamic_fitness = calculate_fitness(dynamic_skill, request)
435
+
436
+ fitness_delta = dynamic_fitness - matrix_fitness
437
+
438
+ # Superior if:
439
+ # 1. Significantly higher fitness
440
+ if fitness_delta >= SUPERIORITY_THRESHOLD:
441
+ return SuperiorityResult(
442
+ is_superior=True,
443
+ reason="HIGHER_FITNESS",
444
+ recommendation="Consider installing for better results"
445
+ )
446
+
447
+ # 2. Domain-specific when matrix is generic
448
+ if dynamic_skill.specificity > 0.8 and matrix_skill.specificity < 0.5:
449
+ return SuperiorityResult(
450
+ is_superior=True,
451
+ reason="DOMAIN_SPECIFIC",
452
+ recommendation="Specialized skill available"
453
+ )
454
+
455
+ return SuperiorityResult(is_superior=False)
456
+ ```
457
+
458
+ **Heuristic 3: Automatic Promotion**
459
+ ```python
460
+ def evaluate_skill_for_promotion(dynamic_skill):
461
+ """
462
+ Determine if a dynamic skill should be promoted to matrix-skills.
463
+ """
464
+ PROMOTION_CRITERIA = {
465
+ 'min_executions': 10,
466
+ 'min_success_rate': 0.85,
467
+ 'min_satisfaction': 0.8, # User ratings
468
+ 'max_age_days': 90, # Must be actively used recently
469
+ }
470
+
471
+ if (
472
+ dynamic_skill.execution_count >= PROMOTION_CRITERIA['min_executions'] and
473
+ dynamic_skill.success_rate >= PROMOTION_CRITERIA['min_success_rate'] and
474
+ dynamic_skill.user_satisfaction >= PROMOTION_CRITERIA['min_satisfaction'] and
475
+ dynamic_skill.last_used_days_ago <= PROMOTION_CRITERIA['max_age_days']
476
+ ):
477
+ return PromotionRecommendation(
478
+ skill=dynamic_skill,
479
+ action="ADD_TO_MATRIX",
480
+ domain=infer_domain(dynamic_skill),
481
+ priority_score=calculate_priority(dynamic_skill)
482
+ )
483
+
484
+ return None
485
+ ```
486
+
487
+ ### 4.3 Decision Tree
488
+
489
+ ```
490
+ ┌─────────────────┐
491
+ │ User Request │
492
+ │ Arrives │
493
+ └────────┬────────┘
494
+
495
+
496
+ ┌────────────────────────┐
497
+ │ Extract Skill │
498
+ │ Requirements │
499
+ └────────────┬───────────┘
500
+
501
+
502
+ ┌──────────────────────────────────┐
503
+ │ Matrix Lookup │
504
+ │ (returns best_match, fitness) │
505
+ └──────────────────┬───────────────┘
506
+
507
+ ┌─────────────────┼─────────────────┐
508
+ │ │ │
509
+ ▼ ▼ ▼
510
+ ┌───────────┐ ┌───────────┐ ┌───────────┐
511
+ │ FITNESS │ │ FITNESS │ │ FITNESS │
512
+ │ ≥ 0.8 │ │ 0.75-0.8 │ │ < 0.75 │
513
+ │ (HIGH) │ │ (MEDIUM) │ │ (LOW/NONE)│
514
+ └─────┬─────┘ └─────┬─────┘ └─────┬─────┘
515
+ │ │ │
516
+ ▼ ▼ ▼
517
+ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
518
+ │ EXECUTE │ │ EXECUTE + │ │ TRIGGER DYNAMIC │
519
+ │ Matrix Skill │ │ Async Discovery │ │ Discovery │
520
+ │ │ │ for Enhancement │ │ (Blocking) │
521
+ └──────────────────┘ └────────┬─────────┘ └────────┬─────────┘
522
+ │ │
523
+ ▼ ▼
524
+ ┌──────────────────┐ ┌──────────────────┐
525
+ │ Discovery Found │ │ Discovery Result │
526
+ │ Superior Skill? │ │ │
527
+ └────────┬─────────┘ └────────┬─────────┘
528
+ │ │
529
+ ┌─────────┴─────────┐ │
530
+ ▼ ▼ │
531
+ ┌───────────┐ ┌───────────┐ │
532
+ │ YES │ │ NO │ │
533
+ └─────┬─────┘ └─────┬─────┘ │
534
+ │ │ │
535
+ ▼ ▼ ▼
536
+ ┌──────────────────┐ ┌───────────┐ ┌──────────────────┐
537
+ │ SURFACE │ │ Continue │ │ PROMPT: │
538
+ │ Recommendation │ │ (no │ │ "No matrix skill.│
539
+ │ for Future Use │ │ change) │ │ Install X?" │
540
+ └──────────────────┘ └───────────┘ └──────────────────┘
541
+ ```
542
+
543
+ ---
544
+
545
+ ## 5. Autonomous Evolution Framework
546
+
547
+ ### 5.1 Feedback Loop Architecture
548
+
549
+ ```
550
+ ┌─────────────────────────────────────────────────────────────────────────────┐
551
+ │ AUTONOMOUS EVOLUTION LOOP │
552
+ └─────────────────────────────────────────────────────────────────────────────┘
553
+
554
+ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
555
+ │ EXECUTION │ ──▶ │ TELEMETRY │ ──▶ │ ANALYSIS │ ──▶ │ ACTION │
556
+ │ LAYER │ │ COLLECTOR │ │ ENGINE │ │ EXECUTOR │
557
+ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘
558
+ ▲ │
559
+ │ │
560
+ └──────────────────────────────────────────────────────────────┘
561
+ CONTINUOUS IMPROVEMENT
562
+
563
+ EXECUTION LAYER captures:
564
+ • Skill used
565
+ • Execution time
566
+ • Success/failure
567
+ • User satisfaction (implicit: continued use, explicit: feedback)
568
+ • Request characteristics
569
+
570
+ TELEMETRY COLLECTOR aggregates:
571
+ • Per-skill metrics
572
+ • Domain usage patterns
573
+ • Gap occurrence frequency
574
+ • Dynamic skill adoption rates
575
+
576
+ ANALYSIS ENGINE computes:
577
+ • Skill health scores
578
+ • Promotion candidates
579
+ • Deprecation candidates
580
+ • Domain coverage gaps
581
+ • Trend detection
582
+
583
+ ACTION EXECUTOR triggers:
584
+ • Matrix skill additions (auto-generated PR)
585
+ • Matrix skill deprecations (flag for review)
586
+ • Priority score adjustments
587
+ • Domain file reorganization
588
+ • Alert on quality degradation
589
+ ```
590
+
591
+ ### 5.2 Skill Lifecycle States
592
+
593
+ ```
594
+ ┌─────────────────┐
595
+ │ DISCOVERED │
596
+ │ (Dynamic) │
597
+ └────────┬────────┘
598
+
599
+ First successful execution
600
+
601
+
602
+ ┌─────────────────┐
603
+ │ EVALUATING │
604
+ │ (Probation) │
605
+ └────────┬────────┘
606
+
607
+ ┌─────────────┼─────────────┐
608
+ │ │ │
609
+ Success > 85% Abandoned Failure > 30%
610
+ │ │ │
611
+ ▼ ▼ ▼
612
+ ┌─────────────┐ ┌───────────┐ ┌─────────────┐
613
+ │ VALIDATED │ │ DORMANT │ │ REJECTED │
614
+ │ (Trusted) │ │ │ │ │
615
+ └──────┬──────┘ └───────────┘ └─────────────┘
616
+
617
+ High usage + team approval
618
+
619
+
620
+ ┌─────────────┐
621
+ │ PROMOTED │
622
+ │ (Matrix) │
623
+ └──────┬──────┘
624
+
625
+ ┌────────┴────────┐
626
+ │ │
627
+ ▼ ▼
628
+ ┌──────────┐ ┌──────────────┐
629
+ │ ACTIVE │ │ DEPRECATED │
630
+ │ (Core) │ │ (Phase out) │
631
+ └──────────┘ └──────────────┘
632
+ ```
633
+
634
+ ### 5.3 Global Installation Protocol
635
+
636
+ **Challenge**: When a dynamic skill is installed, it must be immediately available across the global environment.
637
+
638
+ **Solution**: Tiered Installation Model
639
+
640
+ ```yaml
641
+ installation_tiers:
642
+
643
+ tier_1_session_local:
644
+ scope: "Current session only"
645
+ persistence: "None (ephemeral)"
646
+ use_case: "Testing, one-off requests"
647
+ command: "npx skills add <skill>"
648
+ effect: |
649
+ Skill loaded into current agent context.
650
+ No file system changes.
651
+ Lost on session end.
652
+
653
+ tier_2_user_global:
654
+ scope: "All sessions for current user"
655
+ persistence: "User config directory"
656
+ use_case: "Personal productivity skills"
657
+ command: "npx skills add <skill> -g"
658
+ effect: |
659
+ Skill installed to ~/.{TOOL}/skills/{skill-id}/
660
+ Automatically loaded in future sessions.
661
+ User-specific, not shared with team.
662
+
663
+ tier_3_project_local:
664
+ scope: "All users working on project"
665
+ persistence: "Project repository"
666
+ use_case: "Project-specific skills"
667
+ command: "npx skills add <skill> --project"
668
+ effect: |
669
+ Skill reference added to project config.
670
+ Skill fetched on project clone/setup.
671
+ Version-locked for consistency.
672
+
673
+ tier_4_matrix_promoted:
674
+ scope: "All agents, all projects"
675
+ persistence: "Matrix skill system"
676
+ use_case: "Battle-tested, widely useful skills"
677
+ process: |
678
+ 1. When promotion criteria met (executions, success_rate, recency), skill is auto-promoted
679
+ 2. System adds skill entry to matrix-skills/{domain}.yaml (no promotion queue, no human review)
680
+ 3. Write target: the GLOBAL tool path the main agent already reads from
681
+ (e.g. ~/.cursor/skills/agent-assistant/matrix-skills/ for Cursor)
682
+ 4. Same files the orchestrator loaded at session start — we update those on disk
683
+ 5. Next resolution cycle (or cache invalidation / hot-reload) picks up the new skill
684
+ — no tool restart required; available to all agents on next request
685
+ ```
686
+
687
+ ### 5.4 Environment Synchronization
688
+
689
+ ```
690
+ ┌─────────────────────────────────────────────────────────────────┐
691
+ │ GLOBAL ENVIRONMENT SYNC │
692
+ ├─────────────────────────────────────────────────────────────────┤
693
+ │ │
694
+ │ USER INSTALLS NEW SKILL │
695
+ │ │ │
696
+ │ ▼ │
697
+ │ ┌──────────────────────────────────────────┐ │
698
+ │ │ 1. DOWNLOAD & VALIDATE │ │
699
+ │ │ • Fetch SKILL.md from source │ │
700
+ │ │ • Validate schema compliance │ │
701
+ │ │ • Check for conflicts with existing │ │
702
+ │ └──────────────────┬───────────────────────┘ │
703
+ │ │ │
704
+ │ ▼ │
705
+ │ ┌──────────────────────────────────────────┐ │
706
+ │ │ 2. INSTALL TO PATH │ │
707
+ │ │ • ~/.{TOOL}/skills/{skill-id}/SKILL.md │ │
708
+ │ │ • Update skill manifest │ │
709
+ │ └──────────────────┬───────────────────────┘ │
710
+ │ │ │
711
+ │ ▼ │
712
+ │ ┌──────────────────────────────────────────┐ │
713
+ │ │ 3. INVALIDATE CACHES │ │
714
+ │ │ • Clear skill resolution cache │ │
715
+ │ │ • Signal active sessions to reload │ │
716
+ │ └──────────────────┬───────────────────────┘ │
717
+ │ │ │
718
+ │ ▼ │
719
+ │ ┌──────────────────────────────────────────┐ │
720
+ │ │ 4. REGISTER IN DYNAMIC SKILL INDEX │ │
721
+ │ │ • Add to ~/.{TOOL}/skills/_dynamic.yaml│ │
722
+ │ │ • Include metadata for resolution │ │
723
+ │ └──────────────────┬───────────────────────┘ │
724
+ │ │ │
725
+ │ ▼ │
726
+ │ ┌──────────────────────────────────────────┐ │
727
+ │ │ 5. AVAILABLE FOR NEXT RESOLUTION CALL │ │
728
+ │ │ • No session restart required │ │
729
+ │ │ • Immediate use on next request │ │
730
+ │ └──────────────────────────────────────────┘ │
731
+ │ │
732
+ └─────────────────────────────────────────────────────────────────┘
733
+ ```
734
+
735
+ ---
736
+
737
+ ## 6. Consistency & Versioning Strategy
738
+
739
+ ### 6.1 Conflict Detection
740
+
741
+ **Conflict Types:**
742
+
743
+ | Conflict Type | Description | Resolution Strategy |
744
+ |--------------|-------------|---------------------|
745
+ | **ID Collision** | Dynamic skill has same ID as matrix skill | Prefix dynamic with `ext-` |
746
+ | **Domain Overlap** | Dynamic skill claims same domain coverage | Matrix takes precedence unless dynamic is superior |
747
+ | **Capability Duplication** | Both skills do the same thing | Fitness scoring determines winner |
748
+ | **Version Incompatibility** | Skill requires newer agent version | Block installation, notify user |
749
+
750
+ ### 6.2 Versioning Model
751
+
752
+ ```yaml
753
+ # Matrix Skill Version Format
754
+ skill_version:
755
+ format: "MAJOR.MINOR.PATCH"
756
+ example: "1.2.3"
757
+
758
+ semantics:
759
+ MAJOR: "Breaking changes to skill interface"
760
+ MINOR: "New capabilities, backward compatible"
761
+ PATCH: "Bug fixes, no capability change"
762
+
763
+ # Dynamic Skill Source Tracking
764
+ dynamic_skill_reference:
765
+ format: "{source}/{owner}/{repo}@{skill}#{version}"
766
+ example: "github/vercel-labs/skills@clerk-auth#v1.2.0"
767
+
768
+ components:
769
+ source: "github | npm | custom"
770
+ owner: "Repository owner"
771
+ repo: "Repository name"
772
+ skill: "Skill ID within repo"
773
+ version: "Pinned version or 'latest'"
774
+
775
+ # Lock File for Project Consistency
776
+ # File: ./skills.lock.yaml
777
+ locked_skills:
778
+ matrix_version: "1.0"
779
+ dynamic_skills:
780
+ - id: "clerk-auth"
781
+ source: "github/vercel-labs/skills@clerk-auth"
782
+ version: "v1.2.0"
783
+ installed_at: "2026-01-30T12:00:00Z"
784
+ checksum: "sha256:abc123..."
785
+ ```
786
+
787
+ ### 6.3 Conflict Resolution Protocol
788
+
789
+ ```
790
+ ┌─────────────────────────────────────────────────────────────────┐
791
+ │ CONFLICT RESOLUTION PROTOCOL │
792
+ ├─────────────────────────────────────────────────────────────────┤
793
+ │ │
794
+ │ STEP 1: DETECT CONFLICT TYPE │
795
+ │ ───────────────────────── │
796
+ │ • ID collision check │
797
+ │ • Domain overlap analysis │
798
+ │ • Capability fingerprint comparison │
799
+ │ │
800
+ │ STEP 2: APPLY RESOLUTION RULES │
801
+ │ ───────────────────────────── │
802
+ │ Rule 1: Matrix skills ALWAYS take their IDs │
803
+ │ Rule 2: Dynamic skills get prefixed if collision │
804
+ │ Rule 3: Higher fitness wins for capability overlap │
805
+ │ Rule 4: User explicit preference overrides all │
806
+ │ │
807
+ │ STEP 3: DOCUMENT RESOLUTION │
808
+ │ ───────────────────────── │
809
+ │ • Log conflict occurrence │
810
+ │ • Record resolution decision │
811
+ │ • Notify user if dynamic skill was renamed/shadowed │
812
+ │ │
813
+ │ STEP 4: VALIDATE CONSISTENCY │
814
+ │ ─────────────────────────── │
815
+ │ • Ensure no duplicate IDs in unified index │
816
+ │ • Verify all agent profiles can still resolve │
817
+ │ • Check for orphaned skill references │
818
+ │ │
819
+ └─────────────────────────────────────────────────────────────────┘
820
+ ```
821
+
822
+ ### 6.4 Unified Skill Index
823
+
824
+ **Runtime Data Structure:**
825
+
826
+ ```yaml
827
+ # Unified Skill Index (in-memory structure)
828
+ unified_skill_index:
829
+ version: "1.0"
830
+ generated_at: "2026-01-30T12:00:00Z"
831
+
832
+ # Matrix skills (pre-loaded)
833
+ matrix_skills:
834
+ - skill_id: "better-auth"
835
+ source: "matrix"
836
+ domain: "backend"
837
+ priority: 8
838
+ trust_level: 1.0
839
+ path: "~/.{TOOL}/skills/agent-assistant/matrix-skills/backend.yaml"
840
+
841
+ # Dynamic skills (user-installed)
842
+ dynamic_skills:
843
+ - skill_id: "clerk-auth"
844
+ source: "github/vercel-labs/skills"
845
+ domain: "backend"
846
+ priority: 7 # Starts lower than matrix
847
+ trust_level: 0.6 # Earned through usage
848
+ path: "~/.{TOOL}/skills/clerk-auth/SKILL.md"
849
+ version: "v1.2.0"
850
+
851
+ # Resolution priority (matrix > dynamic by default)
852
+ resolution_order:
853
+ - source: "matrix"
854
+ weight: 1.0
855
+ - source: "dynamic"
856
+ weight: 0.9 # Slight preference for matrix
857
+ ```
858
+
859
+ ---
860
+
861
+ ## 7. Production-Grade Edge Cases
862
+
863
+ ### 7.1 Network Failure Handling
864
+
865
+ ```yaml
866
+ network_failure_scenarios:
867
+
868
+ scenario_1_discovery_timeout:
869
+ trigger: "find-skills search exceeds 5 second timeout"
870
+ impact: "Cannot retrieve dynamic skill candidates"
871
+ resolution:
872
+ immediate: "Proceed with matrix skills only"
873
+ notification: "Notify user that discovery was unavailable"
874
+ retry: "Queue background retry for later"
875
+
876
+ scenario_2_installation_failure:
877
+ trigger: "Dynamic skill download fails mid-transfer"
878
+ impact: "Skill partially installed, corrupted state"
879
+ resolution:
880
+ immediate: "Rollback partial installation"
881
+ cleanup: "Remove incomplete skill directory"
882
+ notification: "Notify user of failure with retry option"
883
+
884
+ scenario_3_intermittent_connectivity:
885
+ trigger: "Network flaps during skill execution"
886
+ impact: "Skill that requires network may fail"
887
+ resolution:
888
+ detection: "Pre-flight check for network-dependent skills"
889
+ fallback: "Use local-only skill alternative if available"
890
+ caching: "Cache skill assets for offline resilience"
891
+ ```
892
+
893
+ ### 7.2 Installation Failure Recovery
894
+
895
+ ```
896
+ ┌─────────────────────────────────────────────────────────────────┐
897
+ │ INSTALLATION FAILURE RECOVERY │
898
+ ├─────────────────────────────────────────────────────────────────┤
899
+ │ │
900
+ │ FAILURE TYPES: │
901
+ │ │
902
+ │ ┌─────────────────────────────────────────────────────────┐ │
903
+ │ │ TYPE: DOWNLOAD_FAILURE │ │
904
+ │ │ Cause: Network error, invalid URL, auth required │ │
905
+ │ │ State: No files written │ │
906
+ │ │ Recovery: Retry with exponential backoff, then abort │ │
907
+ │ └─────────────────────────────────────────────────────────┘ │
908
+ │ │
909
+ │ ┌─────────────────────────────────────────────────────────┐ │
910
+ │ │ TYPE: VALIDATION_FAILURE │ │
911
+ │ │ Cause: Invalid SKILL.md schema, missing required fields │ │
912
+ │ │ State: File downloaded but not registered │ │
913
+ │ │ Recovery: Delete file, report error to user │ │
914
+ │ └─────────────────────────────────────────────────────────┘ │
915
+ │ │
916
+ │ ┌─────────────────────────────────────────────────────────┐ │
917
+ │ │ TYPE: CONFLICT_FAILURE │ │
918
+ │ │ Cause: ID collision that cannot be auto-resolved │ │
919
+ │ │ State: Validation passed, conflict detected │ │
920
+ │ │ Recovery: Prompt user to choose resolution strategy │ │
921
+ │ └─────────────────────────────────────────────────────────┘ │
922
+ │ │
923
+ │ ┌─────────────────────────────────────────────────────────┐ │
924
+ │ │ TYPE: REGISTRATION_FAILURE │ │
925
+ │ │ Cause: Index write failed (disk full, permissions) │ │
926
+ │ │ State: Skill files exist but not indexed │ │
927
+ │ │ Recovery: Cleanup files, report system error │ │
928
+ │ └─────────────────────────────────────────────────────────┘ │
929
+ │ │
930
+ │ RECOVERY PROTOCOL: │
931
+ │ │
932
+ │ 1. Detect failure type │
933
+ │ 2. Execute type-specific rollback │
934
+ │ 3. Log failure for telemetry │
935
+ │ 4. Notify user with actionable guidance │
936
+ │ 5. Offer retry option if transient failure │
937
+ │ │
938
+ └─────────────────────────────────────────────────────────────────┘
939
+ ```
940
+
941
+ ### 7.3 Environment Path Updates
942
+
943
+ **Challenge**: Newly installed skills must be discoverable without session restart.
944
+
945
+ **Solution**: Hot-Reload Mechanism
946
+
947
+ ```yaml
948
+ hot_reload_mechanism:
949
+
950
+ trigger_events:
951
+ - skill_installed
952
+ - skill_updated
953
+ - skill_removed
954
+ - config_changed
955
+
956
+ reload_sequence:
957
+ 1. FILE_WATCH:
958
+ path: "~/.{TOOL}/skills/"
959
+ events: [create, modify, delete]
960
+ debounce: 500ms # Prevent rapid-fire reloads
961
+
962
+ 2. INDEX_REBUILD:
963
+ action: "Rebuild unified skill index"
964
+ scope: "Changed domain only (incremental)"
965
+ duration: "< 50ms for single skill change"
966
+
967
+ 3. CACHE_INVALIDATE:
968
+ action: "Clear resolution cache for affected domains"
969
+ scope: "Targeted, not full cache flush"
970
+
971
+ 4. SESSION_NOTIFY:
972
+ action: "Signal active sessions"
973
+ method: "File-based IPC via lock file mtime"
974
+ response: "Sessions poll for changes on next resolution"
975
+
976
+ 5. VERIFICATION:
977
+ action: "Confirm skill accessible"
978
+ test: "Attempt resolution with new skill ID"
979
+ ```
980
+
981
+ ### 7.4 Security Considerations
982
+
983
+ ```yaml
984
+ security_model:
985
+
986
+ threat_1_malicious_skill:
987
+ vector: "Dynamic skill contains harmful instructions"
988
+ mitigation:
989
+ - "Skills are Markdown/YAML only (no executable code)"
990
+ - "Skill content is guidance, not direct execution"
991
+ - "Agent interprets skill, doesn't run it blindly"
992
+ - "Community reporting for malicious skills"
993
+
994
+ threat_2_skill_impersonation:
995
+ vector: "Attacker creates skill with trusted name"
996
+ mitigation:
997
+ - "Source verification (GitHub org, npm scope)"
998
+ - "Checksum validation on download"
999
+ - "Warning on unofficial sources"
1000
+
1001
+ threat_3_data_exfiltration:
1002
+ vector: "Skill instructs agent to send data externally"
1003
+ mitigation:
1004
+ - "Network operations require explicit user approval"
1005
+ - "Sandboxed skill evaluation mode for new skills"
1006
+ - "Audit logging of skill-triggered actions"
1007
+
1008
+ trust_progression:
1009
+ new_skill:
1010
+ trust_level: 0.3
1011
+ restrictions:
1012
+ - "Cannot suggest network operations"
1013
+ - "Limited to read-only file access patterns"
1014
+ - "User confirmation required for actions"
1015
+
1016
+ validated_skill:
1017
+ trust_level: 0.7
1018
+ unlock_after: "5 successful executions"
1019
+ restrictions:
1020
+ - "Standard agent capabilities"
1021
+ - "Still logged for audit"
1022
+
1023
+ promoted_skill:
1024
+ trust_level: 1.0
1025
+ unlock_after: "Matrix inclusion (auto-promote when criteria met)"
1026
+ restrictions:
1027
+ - "None (same as native agent skills)"
1028
+ ```
1029
+
1030
+ ---
1031
+
1032
+ ## 8. Implementation Roadmap
1033
+
1034
+ ### 8.1 Phase Overview
1035
+
1036
+ ```
1037
+ ┌─────────────────────────────────────────────────────────────────────────────┐
1038
+ │ IMPLEMENTATION PHASES │
1039
+ ├─────────────────────────────────────────────────────────────────────────────┤
1040
+ │ │
1041
+ │ PHASE 1: Foundation │
1042
+ │ ════════════════════ │
1043
+ │ • Unified Skill Index data structure │
1044
+ │ • Dynamic skill manifest (dynamic_skills.yaml) │
1045
+ │ • Hot-reload file watcher │
1046
+ │ • Basic conflict detection │
1047
+ │ │
1048
+ │ PHASE 2: Discovery Integration │
1049
+ │ ══════════════════════════════ │
1050
+ │ • find-skills CLI wrapper │
1051
+ │ • Async discovery during matrix resolution │
1052
+ │ • Fitness scoring engine │
1053
+ │ • Recommendation surfacing UI │
1054
+ │ │
1055
+ │ PHASE 3: Intelligent Decisions │
1056
+ │ ══════════════════════════════ │
1057
+ │ • Gap detection heuristics │
1058
+ │ • Superiority detection │
1059
+ │ • Decision tree implementation │
1060
+ │ • User preference persistence │
1061
+ │ │
1062
+ │ PHASE 4: Autonomous Evolution │
1063
+ │ ═════════════════════════════ │
1064
+ │ • Telemetry collection │
1065
+ │ • Usage analytics engine │
1066
+ │ • Automatic promotion recommendations │
1067
+ │ • Matrix update PR generation │
1068
+ │ │
1069
+ │ PHASE 5: Production Hardening │
1070
+ │ ═════════════════════════════ │
1071
+ │ • Network failure resilience │
1072
+ │ • Security audit and hardening │
1073
+ │ • Performance optimization │
1074
+ │ • Comprehensive testing │
1075
+ │ │
1076
+ └─────────────────────────────────────────────────────────────────────────────┘
1077
+ ```
1078
+
1079
+ ### 8.2 Deliverables Per Phase
1080
+
1081
+ | Phase | Key Deliverables |
1082
+ |-------|------------------|
1083
+ | **Phase 1** | `_dynamic.yaml`, `unified_skill_resolver.ts`, file watcher, conflict detector |
1084
+ | **Phase 2** | `discovery_client.ts`, `fitness_scorer.ts`, recommendation UI component |
1085
+ | **Phase 3** | `decision_engine.ts`, gap/superiority detectors, preference store |
1086
+ | **Phase 4** | `telemetry_collector.ts`, `analytics_engine.ts`, PR generator |
1087
+ | **Phase 5** | Resilience tests, security hardening, performance benchmarks |
1088
+
1089
+ ### 8.3 Success Criteria
1090
+
1091
+ ```yaml
1092
+ success_metrics:
1093
+
1094
+ scalability:
1095
+ metric: "Skills manageable without proportional maintenance increase"
1096
+ target: "Support 500+ skills with same maintenance effort as 100"
1097
+ measurement: "Maintenance hours per skill per month"
1098
+
1099
+ reliability:
1100
+ metric: "Skill resolution success rate"
1101
+ target: "> 99.9% resolution success"
1102
+ measurement: "Failed resolutions / total resolutions"
1103
+
1104
+ autonomy:
1105
+ metric: "Skills auto-promoted vs manually added"
1106
+ target: "> 50% of new matrix skills from auto-promotion"
1107
+ measurement: "Auto-promoted skills / total new skills (monthly)"
1108
+
1109
+ latency:
1110
+ metric: "Skill resolution time"
1111
+ target: "< 50ms for matrix, < 500ms for dynamic discovery"
1112
+ measurement: "P95 resolution latency"
1113
+
1114
+ user_satisfaction:
1115
+ metric: "Skill relevance ratings"
1116
+ target: "> 4.2/5.0 average rating"
1117
+ measurement: "Post-execution skill relevance survey"
1118
+ ```
1119
+
1120
+ ---
1121
+
1122
+ ## 9. System Integration
1123
+
1124
+ ### 9.1 Integration with Existing Components
1125
+
1126
+ ```
1127
+ ┌─────────────────────────────────────────────────────────────────────────────┐
1128
+ │ SMART SKILL ORCHESTRATION INTEGRATION │
1129
+ ├─────────────────────────────────────────────────────────────────────────────┤
1130
+ │ │
1131
+ │ ORCHESTRATOR │
1132
+ │ ════════════ │
1133
+ │ Integration Point: Skill Resolution call │
1134
+ │ Change: Call HSOL instead of direct matrix lookup │
1135
+ │ │
1136
+ │ BEFORE: resolve_skills(agent_profile) → matrix_skills[] │
1137
+ │ AFTER: resolve_skills(agent_profile, request) → unified_skills[] │
1138
+ │ │
1139
+ │ ───────────────────────────────────────────────────────────────────────── │
1140
+ │ │
1141
+ │ AGENT FILES │
1142
+ │ ═══════════ │
1143
+ │ Integration Point: Skills section │
1144
+ │ Change: Add dynamic skill awareness │
1145
+ │ │
1146
+ │ ## ⚡ Skills │
1147
+ │ > **MATRIX DISCOVERY**: Auto-injected from matrix-skills/ │
1148
+ │ > **DYNAMIC ENHANCEMENT**: Additional skills may be suggested │
1149
+ │ > Profile: `{profile}` | Domains: `{domains}` │
1150
+ │ │
1151
+ │ ───────────────────────────────────────────────────────────────────────── │
1152
+ │ │
1153
+ │ SKILL-DISCOVERY.md │
1154
+ │ ══════════════════ │
1155
+ │ Integration Point: Resolution Algorithm │
1156
+ │ Change: Add Step 7 (Dynamic Enhancement Check) │
1157
+ │ │
1158
+ │ Step 6: Return Skill Set (existing) │
1159
+ │ Step 7: Async Dynamic Discovery (NEW) │
1160
+ │ → Query find-skills with request keywords │
1161
+ │ → Compare fitness scores │
1162
+ │ → Surface recommendations if superior │
1163
+ │ │
1164
+ │ ───────────────────────────────────────────────────────────────────────── │
1165
+ │ │
1166
+ │ _index.yaml │
1167
+ │ ═══════════ │
1168
+ │ Integration Point: Skill registry │
1169
+ │ Change: Add dynamic skill registry section │
1170
+ │ │
1171
+ │ dynamic_registry: │
1172
+ │ enabled: true │
1173
+ │ manifest_path: "_dynamic.yaml" │
1174
+ │ discovery_endpoint: "npx skills find" │
1175
+ │ cache_ttl: 3600 # seconds │
1176
+ │ │
1177
+ │ ───────────────────────────────────────────────────────────────────────── │
1178
+ │ │
1179
+ │ EXECUTION-PROTOCOL.md │
1180
+ │ ═════════════════════ │
1181
+ │ Integration Point: Phase execution │
1182
+ │ Change: Add skill enhancement checkpoint │
1183
+ │ │
1184
+ │ STEP 2.5: SKILL ENHANCEMENT CHECK │
1185
+ │ If HSOL recommends superior skill: │
1186
+ │ → Surface recommendation to user │
1187
+ │ → "A specialized skill for {domain} is available..." │
1188
+ │ → Continue with current skills unless user installs │
1189
+ │ │
1190
+ └─────────────────────────────────────────────────────────────────────────────┘
1191
+ ```
1192
+
1193
+ ### 9.2 New Files Required
1194
+
1195
+ ```
1196
+ agent-assistant/
1197
+ ├── matrix-skills/
1198
+ │ ├── _index.yaml # ← Add dynamic_registry section
1199
+ │ ├── _dynamic.yaml # ← NEW: Dynamic skill manifest
1200
+ │ └── {domain}.yaml # Existing domain files
1201
+
1202
+ ├── rules/
1203
+ │ ├── SKILL-DISCOVERY.md # ← Update with HSOL integration
1204
+ │ ├── SKILL-ORCHESTRATION.md # ← NEW: HSOL decision logic
1205
+ │ └── ...
1206
+
1207
+ ├── lib/ # ← NEW: Shared libraries
1208
+ │ ├── skill-resolver/
1209
+ │ │ ├── unified-index.ts
1210
+ │ │ ├── fitness-scorer.ts
1211
+ │ │ ├── discovery-client.ts
1212
+ │ │ └── conflict-resolver.ts
1213
+ │ │
1214
+ │ ├── telemetry/
1215
+ │ │ ├── collector.ts
1216
+ │ │ └── analytics.ts
1217
+ │ │
1218
+ │ └── evolution/
1219
+ │ ├── promotion-engine.ts
1220
+ │ └── pr-generator.ts
1221
+
1222
+ └── documents/
1223
+ └── SMART-SKILL-ORCHESTRATION-BLUEPRINT.md # This document
1224
+ ```
1225
+
1226
+ ### 9.3 Migration Path
1227
+
1228
+ ```yaml
1229
+ migration_strategy:
1230
+
1231
+ stage_1_parallel_operation:
1232
+ description: "Run HSOL alongside existing system"
1233
+ approach:
1234
+ - "HSOL runs in shadow mode"
1235
+ - "Logs recommendations but doesn't affect execution"
1236
+ - "Compare HSOL decisions with actual usage"
1237
+
1238
+ stage_2_soft_launch:
1239
+ description: "Enable HSOL recommendations"
1240
+ approach:
1241
+ - "HSOL recommendations shown to users"
1242
+ - "Users can opt-in to install recommended skills"
1243
+ - "Track adoption rate and feedback"
1244
+
1245
+ stage_3_default_enabled:
1246
+ description: "HSOL becomes primary resolver"
1247
+ approach:
1248
+ - "All skill resolution goes through HSOL"
1249
+ - "Matrix-first with dynamic enhancement"
1250
+ - "Automatic promotion pipeline active"
1251
+
1252
+ rollback_plan:
1253
+ trigger: "Critical failure or regression"
1254
+ action: "Disable HSOL, revert to direct matrix resolution"
1255
+ data_preservation: "All telemetry and dynamic skills preserved"
1256
+ ```
1257
+
1258
+ ---
1259
+
1260
+ ## Appendix A: Glossary
1261
+
1262
+ | Term | Definition |
1263
+ |------|------------|
1264
+ | **HSOL** | Hybrid Skill Orchestration Layer — the core system designed in this blueprint |
1265
+ | **Matrix Skills** | Pre-curated skills in `matrix-skills/*.yaml` |
1266
+ | **Dynamic Skills** | Skills discovered/installed via `find-skills` CLI |
1267
+ | **Skill Fitness** | Computed score representing how well a skill matches a request |
1268
+ | **Gap Detection** | Identifying when matrix skills cannot satisfy a request |
1269
+ | **Skill Promotion** | Process of elevating a validated dynamic skill to matrix-skills |
1270
+
1271
+ ---
1272
+
1273
+ ## Appendix B: Decision Matrix Quick Reference
1274
+
1275
+ ```
1276
+ ┌─────────────────────────────────────────────────────────────────┐
1277
+ │ SKILL SELECTION QUICK REFERENCE │
1278
+ ├─────────────────────────────────────────────────────────────────┤
1279
+ │ │
1280
+ │ MATRIX FITNESS │ DYNAMIC FITNESS │ ACTION │
1281
+ │ ───────────────┼─────────────────┼────────────────────────── │
1282
+ │ ≥ 0.8 │ Any │ Execute matrix │
1283
+ │ 0.75-0.8 │ ≥ 0.9 │ Execute matrix + suggest │
1284
+ │ 0.75-0.8 │ < 0.9 │ Execute matrix │
1285
+ │ < 0.75 │ ≥ 0.8 │ Prompt to install dynamic │
1286
+ │ < 0.75 │ < 0.8 │ Report capability gap │
1287
+ │ None │ ≥ 0.7 │ Install and execute dynamic │
1288
+ │ None │ None │ Use general capabilities │
1289
+ │ │
1290
+ └─────────────────────────────────────────────────────────────────┘
1291
+ ```
1292
+
1293
+ ---
1294
+
1295
+ ## Appendix C: File Templates
1296
+
1297
+ ### C.1 _dynamic.yaml Template
1298
+
1299
+ ```yaml
1300
+ # Dynamic Skill Manifest
1301
+ # Auto-managed by HSOL — updated when agents run npx skills add ... -g -y
1302
+
1303
+ version: "1.1"
1304
+ last_updated: "2026-01-30T12:00:00Z"
1305
+
1306
+ skills: []
1307
+ # Entries added automatically on skill installation
1308
+ # Format:
1309
+ # - skill_id: "clerk-auth"
1310
+ # source: "github/vercel-labs/skills@clerk-auth"
1311
+ # version: "v1.2.0"
1312
+ # installed_at: "2026-01-30T12:00:00Z"
1313
+ # checksum: "sha256:abc123..."
1314
+ # trust_level: 0.3
1315
+ # execution_count: 0
1316
+ # success_rate: null
1317
+ # domains: ["backend", "security"]
1318
+ ```
1319
+
1320
+ ### C.2 Skill Telemetry Schema
1321
+
1322
+ ```yaml
1323
+ # Skill Execution Telemetry Entry
1324
+ telemetry_entry:
1325
+ timestamp: "2026-01-30T12:00:00Z"
1326
+ skill_id: "better-auth"
1327
+ source: "matrix" # or "dynamic"
1328
+ agent_id: "backend-engineer"
1329
+ request_hash: "sha256:xyz..." # Anonymized request fingerprint
1330
+ execution_time_ms: 150
1331
+ success: true
1332
+ user_satisfaction: null # Populated if feedback provided
1333
+ gap_detected: false
1334
+ dynamic_alternative_suggested: null
1335
+ ```
1336
+
1337
+ ---
1338
+
1339
+ **Document End**
1340
+
1341
+ *This blueprint provides the architectural foundation for implementing the Smart Skill Orchestration Mechanism. All recommendations are based on first-principles analysis and production-grade considerations.*