dino-spec 13.4.0 → 13.5.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/README.md +29 -2
- package/bin/dino-hud.js +0 -0
- package/bin/dino.js +0 -0
- package/dist/core/generator/claude-md.js +1 -1
- package/dist/hooks/post-edit.js +73 -0
- package/dist/hooks/post-edit.js.map +1 -1
- package/dist/hooks/session-start.js +115 -0
- package/dist/hooks/session-start.js.map +1 -1
- package/dist/hooks/types.js +1 -1
- package/dist/hooks/user-prompt-submit.js +100 -0
- package/dist/hooks/user-prompt-submit.js.map +1 -1
- package/dist/mcp/tools/auto-inject.d.ts +36 -0
- package/dist/mcp/tools/auto-inject.d.ts.map +1 -0
- package/dist/mcp/tools/auto-inject.js +143 -0
- package/dist/mcp/tools/auto-inject.js.map +1 -0
- package/dist/mcp/tools/auto-unload.d.ts +29 -0
- package/dist/mcp/tools/auto-unload.d.ts.map +1 -0
- package/dist/mcp/tools/auto-unload.js +151 -0
- package/dist/mcp/tools/auto-unload.js.map +1 -0
- package/dist/mcp/tools/health.d.ts +29 -0
- package/dist/mcp/tools/health.d.ts.map +1 -0
- package/dist/mcp/tools/health.js +171 -0
- package/dist/mcp/tools/health.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +6 -2
- package/dist/mcp/tools/index.d.ts.map +1 -1
- package/dist/mcp/tools/index.js +17 -2
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/rules/index.js +2 -2
- package/dist/utils/gitignore.d.ts.map +1 -1
- package/dist/utils/gitignore.js +5 -0
- package/dist/utils/gitignore.js.map +1 -1
- package/package.json +76 -76
package/README.md
CHANGED
|
@@ -16,6 +16,33 @@
|
|
|
16
16
|
|
|
17
17
|
## Features
|
|
18
18
|
|
|
19
|
+
### v13.5.0 - Context Engineering Engines Operational
|
|
20
|
+
|
|
21
|
+
- **Context Engineering Hook Wiring** - All orphaned engines now wired and operational
|
|
22
|
+
- **Auto-Injection** - Context automatically injected based on prompt demand signals
|
|
23
|
+
- New MCP tool: `dino_auto_inject` - Manual context injection trigger
|
|
24
|
+
- Wired to user-prompt-submit hook for automatic execution
|
|
25
|
+
- Detects memory, decision, pattern, and failure queries
|
|
26
|
+
- Respects `autoContextInjection` feature flag
|
|
27
|
+
- **Health Monitoring** - Context health checked on session start
|
|
28
|
+
- New MCP tool: `dino_health_check` - Get context health report
|
|
29
|
+
- Reports rot index (0-100), health status, recommendations
|
|
30
|
+
- Includes v13.4.0 focus fragmentation metrics
|
|
31
|
+
- Outputs warnings when rot > 40%, critical when rot > 70%
|
|
32
|
+
- Respects `contextHealthMonitor` feature flag
|
|
33
|
+
- **Auto-Unload** - Cold resources automatically evicted at budget thresholds
|
|
34
|
+
- New MCP tool: `dino_auto_unload` - Manual resource unload trigger
|
|
35
|
+
- Wired to session-start at 70%/80%/90% budget thresholds
|
|
36
|
+
- Light/medium/aggressive aggressiveness based on budget pressure
|
|
37
|
+
- Evicts files not accessed in 10+ min (cold) or 30+ min (stale)
|
|
38
|
+
- Respects `autoUnload` feature flag
|
|
39
|
+
- **Auto-Prefetch Suggestions** - Focus changes trigger prefetch recommendations
|
|
40
|
+
- Detects focus changes from edit clustering
|
|
41
|
+
- Suggests @dino://focus resource when focus shifts and budget < 70%
|
|
42
|
+
- Integrated into post-edit hook
|
|
43
|
+
- **Combined Impact** - **70-95% total context savings** (up from 60-85%)
|
|
44
|
+
- **124 New Tests** - Comprehensive integration and tool coverage
|
|
45
|
+
|
|
19
46
|
### v13.4.0 - Focus-Aware Context Engineering
|
|
20
47
|
|
|
21
48
|
- **Focus-Based Context Optimization** - Context management adapts to current focus area
|
|
@@ -190,9 +217,9 @@ bun build-binary.js --target bun-windows-x64 # Windows only
|
|
|
190
217
|
bun add -g dino-spec
|
|
191
218
|
```
|
|
192
219
|
|
|
193
|
-
**With npm:**
|
|
220
|
+
**With npm (alternative):**
|
|
194
221
|
```bash
|
|
195
|
-
|
|
222
|
+
bun add -g dino-spec
|
|
196
223
|
```
|
|
197
224
|
|
|
198
225
|
## Quick Start
|
package/bin/dino-hud.js
CHANGED
|
File without changes
|
package/bin/dino.js
CHANGED
|
File without changes
|
|
@@ -246,7 +246,7 @@ export function generateMinimalClaudeMd(analysis) {
|
|
|
246
246
|
cmdParts.push(`\`${cmdMap.test}\``);
|
|
247
247
|
if (cmdMap.lint)
|
|
248
248
|
cmdParts.push(`\`${cmdMap.lint}\``);
|
|
249
|
-
const commandsLine = cmdParts.length > 0 ? cmdParts.join(' | ') : '`
|
|
249
|
+
const commandsLine = cmdParts.length > 0 ? cmdParts.join(' | ') : '`bun run build` | `bun test`';
|
|
250
250
|
return `# ${project.name}
|
|
251
251
|
|
|
252
252
|
${project.description || `${project.type.toUpperCase()} project`}
|
package/dist/hooks/post-edit.js
CHANGED
|
@@ -223,9 +223,47 @@ if ($focusDir) {
|
|
|
223
223
|
$confidence = if ($maxCount -ge 5) { "high" } elseif ($maxCount -ge 3) { "medium" } else { "low" }
|
|
224
224
|
$focusText = "$focusDir [directory-cluster, $confidence]"
|
|
225
225
|
|
|
226
|
+
# v13.5.0: Track previous focus for auto-prefetch
|
|
227
|
+
$previousFocus = $null
|
|
228
|
+
if ($content -match "## Focus\\s*\\n\\*\\*([^*]+)\\*\\*") {
|
|
229
|
+
$previousFocus = $matches[1].Trim()
|
|
230
|
+
}
|
|
231
|
+
|
|
226
232
|
if ($content -match "(## Focus\\s*\\n)([^#]*)") {
|
|
227
233
|
$content = $content -replace "(## Focus\\s*\\n)[^#]*", ("\$1$focusText\\n\\n")
|
|
228
234
|
}
|
|
235
|
+
|
|
236
|
+
# v13.5.0: Auto-prefetch on focus change (when budget has headroom)
|
|
237
|
+
if ($previousFocus -and $previousFocus -ne $focusDir) {
|
|
238
|
+
$prefetchEnabled = $true
|
|
239
|
+
$configPath = Join-Path $dinoDir "config.json"
|
|
240
|
+
if (Test-Path $configPath) {
|
|
241
|
+
try {
|
|
242
|
+
$config = Get-Content $configPath -Raw | ConvertFrom-Json
|
|
243
|
+
if ($config.features.autoPrefetch -eq $false) {
|
|
244
|
+
$prefetchEnabled = $false
|
|
245
|
+
}
|
|
246
|
+
} catch {}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if ($prefetchEnabled) {
|
|
250
|
+
# Check budget before prefetching
|
|
251
|
+
$budgetPath = Join-Path $dinoDir "context-budget.json"
|
|
252
|
+
$budgetPercent = 50
|
|
253
|
+
if (Test-Path $budgetPath) {
|
|
254
|
+
try {
|
|
255
|
+
$budgetData = Get-Content $budgetPath -Raw | ConvertFrom-Json
|
|
256
|
+
$budgetPercent = [math]::Round(($budgetData.estimated / $budgetData.limit) * 100)
|
|
257
|
+
} catch {}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if ($budgetPercent -lt 70) {
|
|
261
|
+
# Prefetch in-focus files (output suggestion)
|
|
262
|
+
Write-Host "[dino] Focus changed: $previousFocus -> $focusDir"
|
|
263
|
+
Write-Host "[dino] Tip: Use @dino://focus to load context for $focusDir"
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
229
267
|
}
|
|
230
268
|
|
|
231
269
|
# Write back session.md
|
|
@@ -536,6 +574,12 @@ if [ -n "$FOCUS_DIR" ]; then
|
|
|
536
574
|
CONFIDENCE="high"
|
|
537
575
|
fi
|
|
538
576
|
|
|
577
|
+
# v13.5.0: Track previous focus for auto-prefetch
|
|
578
|
+
PREVIOUS_FOCUS=""
|
|
579
|
+
if grep -q "^## Focus" "$SESSION_PATH"; then
|
|
580
|
+
PREVIOUS_FOCUS=$(grep -A1 "^## Focus" "$SESSION_PATH" | tail -1 | sed 's/\\[.*//' | xargs)
|
|
581
|
+
fi
|
|
582
|
+
|
|
539
583
|
FOCUS_TEXT="$FOCUS_DIR [directory-cluster, $CONFIDENCE]"
|
|
540
584
|
|
|
541
585
|
TEMP_FILE2=$(mktemp)
|
|
@@ -550,6 +594,35 @@ if [ -n "$FOCUS_DIR" ]; then
|
|
|
550
594
|
} > "$TEMP_FILE2"
|
|
551
595
|
|
|
552
596
|
mv "$TEMP_FILE2" "$SESSION_PATH"
|
|
597
|
+
|
|
598
|
+
# v13.5.0: Auto-prefetch on focus change (when budget has headroom)
|
|
599
|
+
if [ -n "$PREVIOUS_FOCUS" ] && [ "$PREVIOUS_FOCUS" != "$FOCUS_DIR" ]; then
|
|
600
|
+
PREFETCH_ENABLED="true"
|
|
601
|
+
CONFIG_PATH="$DINO_DIR/config.json"
|
|
602
|
+
if [ -f "$CONFIG_PATH" ]; then
|
|
603
|
+
if grep -q '"autoPrefetch"[[:space:]]*:[[:space:]]*false' "$CONFIG_PATH" 2>/dev/null; then
|
|
604
|
+
PREFETCH_ENABLED="false"
|
|
605
|
+
fi
|
|
606
|
+
fi
|
|
607
|
+
|
|
608
|
+
if [ "$PREFETCH_ENABLED" = "true" ]; then
|
|
609
|
+
# Check budget before prefetching
|
|
610
|
+
BUDGET_PATH="$DINO_DIR/context-budget.json"
|
|
611
|
+
BUDGET_PERCENT=50
|
|
612
|
+
if [ -f "$BUDGET_PATH" ]; then
|
|
613
|
+
ESTIMATED=$(grep -o '"estimated"[[:space:]]*:[[:space:]]*[0-9]*' "$BUDGET_PATH" 2>/dev/null | grep -o '[0-9]*' || echo "0")
|
|
614
|
+
LIMIT=$(grep -o '"limit"[[:space:]]*:[[:space:]]*[0-9]*' "$BUDGET_PATH" 2>/dev/null | grep -o '[0-9]*' || echo "200000")
|
|
615
|
+
if [ "$LIMIT" -gt 0 ]; then
|
|
616
|
+
BUDGET_PERCENT=$((ESTIMATED * 100 / LIMIT))
|
|
617
|
+
fi
|
|
618
|
+
fi
|
|
619
|
+
|
|
620
|
+
if [ "$BUDGET_PERCENT" -lt 70 ]; then
|
|
621
|
+
echo "[dino] Focus changed: $PREVIOUS_FOCUS -> $FOCUS_DIR"
|
|
622
|
+
echo "[dino] Tip: Use @dino://focus to load context for $FOCUS_DIR"
|
|
623
|
+
fi
|
|
624
|
+
fi
|
|
625
|
+
fi
|
|
553
626
|
fi
|
|
554
627
|
|
|
555
628
|
# === Add Pending Action for High-Significance Changes ===
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-edit.js","sourceRoot":"","sources":["../../src/hooks/post-edit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAElG;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA+B;IACpE,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,wBAAwB,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,kBAAkB,EAAE,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,SAAS,wBAAwB;IAC/B,MAAM,QAAQ,GAAG,OAAgB,CAAC;IAElC,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,gBAAgB,CAAC;;;EAGjE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;;;EAG9B,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC;;;;;;;;;EAS/B,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;EAC1B,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+DlC,kBAAkB,CAAC,QAAQ,CAAC;;;EAG5B,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;EAC9B,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"post-edit.js","sourceRoot":"","sources":["../../src/hooks/post-edit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,O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,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB;IACzB,MAAM,QAAQ,GAAG,OAAgB,CAAC;IAElC,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,gBAAgB,CAAC;;;EAGjE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;;;EAG9B,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC;;;;;;;;;EAS/B,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;EAC1B,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyElC,kBAAkB,CAAC,QAAQ,CAAC;;;EAG5B,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;EAC9B,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmKlC,2BAA2B,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiGtC,CAAC;AACF,CAAC"}
|
|
@@ -154,6 +154,71 @@ if (Test-Path $budgetPath) {
|
|
|
154
154
|
} catch {}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
# v13.5.0: Context health check on session start
|
|
158
|
+
$healthEnabled = $true
|
|
159
|
+
if (Test-Path $configPath) {
|
|
160
|
+
try {
|
|
161
|
+
$config = Get-Content $configPath -Raw | ConvertFrom-Json
|
|
162
|
+
if ($config.features.contextHealthMonitor -eq $false) {
|
|
163
|
+
$healthEnabled = $false
|
|
164
|
+
}
|
|
165
|
+
} catch {}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if ($healthEnabled) {
|
|
169
|
+
try {
|
|
170
|
+
# Get budget percentage for health check
|
|
171
|
+
$healthBudget = 50
|
|
172
|
+
if (Test-Path $budgetPath) {
|
|
173
|
+
try {
|
|
174
|
+
$budgetData = Get-Content $budgetPath -Raw | ConvertFrom-Json
|
|
175
|
+
$healthBudget = [math]::Round(($budgetData.estimated / $budgetData.limit) * 100)
|
|
176
|
+
} catch {}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
$healthResult = & npx dino mcp call dino_health_check --budgetPercentage $healthBudget 2>$null
|
|
180
|
+
if ($healthResult -and $healthResult -match "Status:.*\\[(WARNING|CRITICAL)\\]") {
|
|
181
|
+
# Extract rot index
|
|
182
|
+
$rotMatch = [regex]::Match($healthResult, "Rot Index:\\s*(\\d+)%")
|
|
183
|
+
if ($rotMatch.Success) {
|
|
184
|
+
$rotIndex = $rotMatch.Groups[1].Value
|
|
185
|
+
Write-Host "[dino] Context health: $($matches[1].ToLower()) (\$rotIndex% rot)"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} catch {}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
# v13.5.0: Auto-unload at budget thresholds (70%, 80%, 90%)
|
|
192
|
+
$unloadEnabled = $true
|
|
193
|
+
if (Test-Path $configPath) {
|
|
194
|
+
try {
|
|
195
|
+
$config = Get-Content $configPath -Raw | ConvertFrom-Json
|
|
196
|
+
if ($config.features.autoUnload -eq $false) {
|
|
197
|
+
$unloadEnabled = $false
|
|
198
|
+
}
|
|
199
|
+
} catch {}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if ($unloadEnabled -and $budgetPercent -ge 70) {
|
|
203
|
+
try {
|
|
204
|
+
# Determine aggressiveness based on budget level
|
|
205
|
+
$aggressiveness = "light"
|
|
206
|
+
if ($budgetPercent -ge 90) {
|
|
207
|
+
$aggressiveness = "aggressive"
|
|
208
|
+
} elseif ($budgetPercent -ge 80) {
|
|
209
|
+
$aggressiveness = "medium"
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
$unloadResult = & npx dino mcp call dino_auto_unload --budgetPercentage $budgetPercent --aggressiveness $aggressiveness 2>$null
|
|
213
|
+
if ($unloadResult -and $unloadResult -match "Tokens freed:\\s*~(\\d+)") {
|
|
214
|
+
$tokensFreed = $matches[1]
|
|
215
|
+
if ([int]$tokensFreed -gt 0) {
|
|
216
|
+
Write-Host "[dino] Auto-unload: ~\$tokensFreed tokens freed (budget was \$budgetPercent%)"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
} catch {}
|
|
220
|
+
}
|
|
221
|
+
|
|
157
222
|
# v13.2.1: Clean up completed Ralph loops on session start (more reliable than SessionEnd)
|
|
158
223
|
$ralphProgressPath = Join-Path $dinoDir "ralph-progress.md"
|
|
159
224
|
if (Test-Path $ralphProgressPath) {
|
|
@@ -349,6 +414,56 @@ if [ -f "\$BUDGET_PATH" ]; then
|
|
|
349
414
|
fi
|
|
350
415
|
fi
|
|
351
416
|
|
|
417
|
+
# v13.5.0: Context health check on session start
|
|
418
|
+
HEALTH_ENABLED="true"
|
|
419
|
+
CONFIG_PATH="\$DINO_DIR/config.json"
|
|
420
|
+
if [ -f "\$CONFIG_PATH" ]; then
|
|
421
|
+
if grep -q '"contextHealthMonitor"[[:space:]]*:[[:space:]]*false' "\$CONFIG_PATH" 2>/dev/null; then
|
|
422
|
+
HEALTH_ENABLED="false"
|
|
423
|
+
fi
|
|
424
|
+
fi
|
|
425
|
+
|
|
426
|
+
if [ "\$HEALTH_ENABLED" = "true" ]; then
|
|
427
|
+
# Get budget percentage for health check
|
|
428
|
+
HEALTH_BUDGET=50
|
|
429
|
+
if [ -f "\$BUDGET_PATH" ]; then
|
|
430
|
+
HEALTH_BUDGET=\$BUDGET_PERCENT
|
|
431
|
+
fi
|
|
432
|
+
|
|
433
|
+
HEALTH_RESULT=\$(npx dino mcp call dino_health_check --budgetPercentage "\$HEALTH_BUDGET" 2>/dev/null)
|
|
434
|
+
if echo "\$HEALTH_RESULT" | grep -qE "Status:.*\\[(WARNING|CRITICAL)\\]"; then
|
|
435
|
+
HEALTH_STATUS=\$(echo "\$HEALTH_RESULT" | grep -oE "\\[(WARNING|CRITICAL)\\]" | tr -d '[]' | tr '[:upper:]' '[:lower:]')
|
|
436
|
+
ROT_INDEX=\$(echo "\$HEALTH_RESULT" | grep -oE "Rot Index:\\s*[0-9]+%" | grep -oE "[0-9]+")
|
|
437
|
+
if [ -n "\$ROT_INDEX" ]; then
|
|
438
|
+
echo "[dino] Context health: \$HEALTH_STATUS (\$ROT_INDEX% rot)"
|
|
439
|
+
fi
|
|
440
|
+
fi
|
|
441
|
+
fi
|
|
442
|
+
|
|
443
|
+
# v13.5.0: Auto-unload at budget thresholds (70%, 80%, 90%)
|
|
444
|
+
UNLOAD_ENABLED="true"
|
|
445
|
+
if [ -f "\$CONFIG_PATH" ]; then
|
|
446
|
+
if grep -q '"autoUnload"[[:space:]]*:[[:space:]]*false' "\$CONFIG_PATH" 2>/dev/null; then
|
|
447
|
+
UNLOAD_ENABLED="false"
|
|
448
|
+
fi
|
|
449
|
+
fi
|
|
450
|
+
|
|
451
|
+
if [ "\$UNLOAD_ENABLED" = "true" ] && [ "\$BUDGET_PERCENT" -ge 70 ] 2>/dev/null; then
|
|
452
|
+
# Determine aggressiveness based on budget level
|
|
453
|
+
AGGRESSIVENESS="light"
|
|
454
|
+
if [ "\$BUDGET_PERCENT" -ge 90 ]; then
|
|
455
|
+
AGGRESSIVENESS="aggressive"
|
|
456
|
+
elif [ "\$BUDGET_PERCENT" -ge 80 ]; then
|
|
457
|
+
AGGRESSIVENESS="medium"
|
|
458
|
+
fi
|
|
459
|
+
|
|
460
|
+
UNLOAD_RESULT=\$(npx dino mcp call dino_auto_unload --budgetPercentage "\$BUDGET_PERCENT" --aggressiveness "\$AGGRESSIVENESS" 2>/dev/null)
|
|
461
|
+
TOKENS_FREED=\$(echo "\$UNLOAD_RESULT" | grep -oE "Tokens freed:\\s*~[0-9]+" | grep -oE "[0-9]+")
|
|
462
|
+
if [ -n "\$TOKENS_FREED" ] && [ "\$TOKENS_FREED" -gt 0 ]; then
|
|
463
|
+
echo "[dino] Auto-unload: ~\$TOKENS_FREED tokens freed (budget was \$BUDGET_PERCENT%)"
|
|
464
|
+
fi
|
|
465
|
+
fi
|
|
466
|
+
|
|
352
467
|
# v13.2.1: Clean up completed Ralph loops on session start (more reliable than SessionEnd)
|
|
353
468
|
RALPH_PROGRESS_PATH="\$DINO_DIR/ralph-progress.md"
|
|
354
469
|
if [ -f "\$RALPH_PROGRESS_PATH" ]; then
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-start.js","sourceRoot":"","sources":["../../src/hooks/session-start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAA+B;IACxE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAClE,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,wBAAwB,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,kBAAkB,EAAE,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,SAAS,wBAAwB;IAC/B,MAAM,QAAQ,GAAG,OAAgB,CAAC;IAElC,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,oBAAoB,CAAC;;;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,CAAC"}
|
package/dist/hooks/types.js
CHANGED
|
@@ -107,7 +107,7 @@ export const DOC_PATTERNS = [
|
|
|
107
107
|
* Pending actions for different change types
|
|
108
108
|
*/
|
|
109
109
|
export const PENDING_ACTIONS = {
|
|
110
|
-
dependency: 'Run `
|
|
110
|
+
dependency: 'Run `bun install` (or equivalent) after dependency changes',
|
|
111
111
|
structural: null,
|
|
112
112
|
config: null,
|
|
113
113
|
test: null,
|
|
@@ -137,6 +137,58 @@ if ($memoryQuery) {
|
|
|
137
137
|
$suggestions += "@dino://memories/summary"
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
# v13.5.0: Auto-context injection based on prompt demand signals
|
|
141
|
+
$autoInjectConfigPath = Join-Path $dinoDir "config.json"
|
|
142
|
+
$autoInjectEnabled = $true
|
|
143
|
+
if (Test-Path $autoInjectConfigPath) {
|
|
144
|
+
try {
|
|
145
|
+
$config = Get-Content $autoInjectConfigPath -Raw | ConvertFrom-Json
|
|
146
|
+
if ($config.features.PSObject.Properties['autoContextInjection']) {
|
|
147
|
+
$autoInjectEnabled = $config.features.autoContextInjection
|
|
148
|
+
}
|
|
149
|
+
} catch {}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if ($autoInjectEnabled) {
|
|
153
|
+
# Check for demand signals in prompt (questions about past decisions, patterns, failures)
|
|
154
|
+
$hasDemand = $false
|
|
155
|
+
if ($promptLower -match "\\b(what|why|how)\\b.*\\b(decide|chose|previous|before|earlier|did we)\\b") {
|
|
156
|
+
$hasDemand = $true
|
|
157
|
+
}
|
|
158
|
+
if ($promptLower -match "\\b(usually|normally|pattern|convention|prefer)\\b") {
|
|
159
|
+
$hasDemand = $true
|
|
160
|
+
}
|
|
161
|
+
if ($promptLower -match "\\b(fail|broke|error|issue)\\b.*\\b(earlier|before|last time)\\b") {
|
|
162
|
+
$hasDemand = $true
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if ($hasDemand) {
|
|
166
|
+
try {
|
|
167
|
+
# Get current budget percentage (approximate)
|
|
168
|
+
$budgetPercent = 50
|
|
169
|
+
$sessionState = Join-Path $dinoDir "session.md"
|
|
170
|
+
if (Test-Path $sessionState) {
|
|
171
|
+
$sessionContent = Get-Content $sessionState -Raw
|
|
172
|
+
if ($sessionContent -match "Budget.*?(\d+)%") {
|
|
173
|
+
$budgetPercent = [int]$matches[1]
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
# Only inject if budget has headroom
|
|
178
|
+
if ($budgetPercent -lt 90) {
|
|
179
|
+
$injectResult = & npx dino mcp call dino_auto_inject --prompt "$userPrompt" --budgetPercentage $budgetPercent 2>$null
|
|
180
|
+
if ($injectResult -and $injectResult -match "executed.*true") {
|
|
181
|
+
# Extract tokens injected
|
|
182
|
+
if ($injectResult -match "~(\d+) tokens") {
|
|
183
|
+
$tokensInjected = $matches[1]
|
|
184
|
+
$contextInjections += "Auto-injected ~$tokensInjected tokens of relevant context"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} catch {}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
140
192
|
# Only check session state if we have alerts to give
|
|
141
193
|
if (Test-Path $sessionPath) {
|
|
142
194
|
$content = Get-Content $sessionPath -Raw
|
|
@@ -594,6 +646,54 @@ if [ -n "\$MEMORY_QUERY" ]; then
|
|
|
594
646
|
SUGGESTIONS="\${SUGGESTIONS}@dino://memories/summary"
|
|
595
647
|
fi
|
|
596
648
|
|
|
649
|
+
# v13.5.0: Auto-context injection based on prompt demand signals
|
|
650
|
+
AUTO_INJECT_ENABLED="true"
|
|
651
|
+
CONFIG_PATH="\$DINO_DIR/config.json"
|
|
652
|
+
if [ -f "\$CONFIG_PATH" ]; then
|
|
653
|
+
if grep -q '"autoContextInjection"[[:space:]]*:[[:space:]]*false' "\$CONFIG_PATH" 2>/dev/null; then
|
|
654
|
+
AUTO_INJECT_ENABLED="false"
|
|
655
|
+
fi
|
|
656
|
+
fi
|
|
657
|
+
|
|
658
|
+
if [ "\$AUTO_INJECT_ENABLED" = "true" ]; then
|
|
659
|
+
# Check for demand signals in prompt
|
|
660
|
+
HAS_DEMAND="false"
|
|
661
|
+
if echo "\$PROMPT_LOWER" | grep -qE "(what|why|how).*(decide|chose|previous|before|earlier|did we)"; then
|
|
662
|
+
HAS_DEMAND="true"
|
|
663
|
+
fi
|
|
664
|
+
if echo "\$PROMPT_LOWER" | grep -qE "(usually|normally|pattern|convention|prefer)"; then
|
|
665
|
+
HAS_DEMAND="true"
|
|
666
|
+
fi
|
|
667
|
+
if echo "\$PROMPT_LOWER" | grep -qE "(fail|broke|error|issue).*(earlier|before|last time)"; then
|
|
668
|
+
HAS_DEMAND="true"
|
|
669
|
+
fi
|
|
670
|
+
|
|
671
|
+
if [ "\$HAS_DEMAND" = "true" ]; then
|
|
672
|
+
# Get current budget percentage (approximate)
|
|
673
|
+
BUDGET_PERCENT=50
|
|
674
|
+
if [ -f "\$SESSION_PATH" ]; then
|
|
675
|
+
BUDGET_MATCH=\$(grep -oE "Budget.*[0-9]+%" "\$SESSION_PATH" 2>/dev/null | grep -oE "[0-9]+" | head -1)
|
|
676
|
+
if [ -n "\$BUDGET_MATCH" ]; then
|
|
677
|
+
BUDGET_PERCENT="\$BUDGET_MATCH"
|
|
678
|
+
fi
|
|
679
|
+
fi
|
|
680
|
+
|
|
681
|
+
# Only inject if budget has headroom
|
|
682
|
+
if [ "\$BUDGET_PERCENT" -lt 90 ]; then
|
|
683
|
+
INJECT_RESULT=\$(npx dino mcp call dino_auto_inject --prompt "\$USER_PROMPT" --budgetPercentage "\$BUDGET_PERCENT" 2>/dev/null)
|
|
684
|
+
if echo "\$INJECT_RESULT" | grep -q "executed.*true"; then
|
|
685
|
+
TOKENS_MATCH=\$(echo "\$INJECT_RESULT" | grep -oE "~[0-9]+ tokens" | grep -oE "[0-9]+")
|
|
686
|
+
if [ -n "\$TOKENS_MATCH" ]; then
|
|
687
|
+
if [ -n "\$CONTEXT_INJECTIONS" ]; then
|
|
688
|
+
CONTEXT_INJECTIONS="\$CONTEXT_INJECTIONS; "
|
|
689
|
+
fi
|
|
690
|
+
CONTEXT_INJECTIONS="\${CONTEXT_INJECTIONS}Auto-injected ~\$TOKENS_MATCH tokens of relevant context"
|
|
691
|
+
fi
|
|
692
|
+
fi
|
|
693
|
+
fi
|
|
694
|
+
fi
|
|
695
|
+
fi
|
|
696
|
+
|
|
597
697
|
# Only check session state if we have alerts to give
|
|
598
698
|
if [ -f "\$SESSION_PATH" ]; then
|
|
599
699
|
CONTENT=\$(cat "\$SESSION_PATH")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-prompt-submit.js","sourceRoot":"","sources":["../../src/hooks/user-prompt-submit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAuB,MAAM,mBAAmB,CAAC;AAEzF;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAAC,OAA+B;IAC5E,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,wBAAwB,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,kBAAkB,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,wBAAwB;IAC/B,MAAM,QAAQ,GAAG,OAAgB,CAAC;IAElC,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,yBAAyB,CAAC;;;;;;;;;;EAU1E,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;EAC1B,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC;;;;;;;;EAQlC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;;;EAG9B,iBAAiB,CAAC,QAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"user-prompt-submit.js","sourceRo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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAud5B,CAAC;AACF,CAAC;AAED,SAAS,kBAAkB;IACzB,MAAM,QAAQ,GAAG,OAAgB,CAAC;IAElC,uFAAuF;IACvF,OAAO;uCAC8B,OAAO;;;;;;;;;;;EAW5C,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;EAC1B,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC;;;;;;;EAOlC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;;;EAG9B,iBAAiB,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkb5B,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-Inject Tools Module - v13.5.0
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for automatic context injection based on prompt analysis.
|
|
5
|
+
* Wires the auto-injection-engine to be callable from hooks and manually.
|
|
6
|
+
*
|
|
7
|
+
* Tools:
|
|
8
|
+
* - dino_auto_inject - Analyze prompt and inject relevant context
|
|
9
|
+
*/
|
|
10
|
+
import { type ToolDefinition } from '../registry.js';
|
|
11
|
+
interface AutoInjectInput {
|
|
12
|
+
prompt: string;
|
|
13
|
+
budgetPercentage?: number;
|
|
14
|
+
minRelevance?: number;
|
|
15
|
+
maxTokens?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Auto-inject tool definition
|
|
19
|
+
*/
|
|
20
|
+
export declare const autoInjectTool: ToolDefinition<AutoInjectInput>;
|
|
21
|
+
/**
|
|
22
|
+
* Demand check tool definition - lightweight check without injection
|
|
23
|
+
*/
|
|
24
|
+
export declare const demandCheckTool: ToolDefinition<{
|
|
25
|
+
prompt: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* All auto-inject tools
|
|
29
|
+
*/
|
|
30
|
+
export declare const autoInjectTools: ToolDefinition[];
|
|
31
|
+
/**
|
|
32
|
+
* Register all auto-inject tools with the registry
|
|
33
|
+
*/
|
|
34
|
+
export declare function registerAutoInjectTools(): void;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=auto-inject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-inject.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/auto-inject.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAcxB,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAkFD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,eAAe,CA8BzD,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAkB7D,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,EAG3C,CAAC;AAEF;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-Inject Tools Module - v13.5.0
|
|
3
|
+
*
|
|
4
|
+
* MCP tool for automatic context injection based on prompt analysis.
|
|
5
|
+
* Wires the auto-injection-engine to be callable from hooks and manually.
|
|
6
|
+
*
|
|
7
|
+
* Tools:
|
|
8
|
+
* - dino_auto_inject - Analyze prompt and inject relevant context
|
|
9
|
+
*/
|
|
10
|
+
import { defineTool, registry, } from '../registry.js';
|
|
11
|
+
import { executeAutoInjection, formatAutoInjectionResult, hasDemandSignals, getDemandSummary, } from '../../core/context/auto-injection-engine.js';
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// Tool Handlers
|
|
14
|
+
// =============================================================================
|
|
15
|
+
/**
|
|
16
|
+
* Auto-inject handler
|
|
17
|
+
* Analyzes prompt and injects relevant context based on demand signals
|
|
18
|
+
*/
|
|
19
|
+
async function handleAutoInject(params, projectDir) {
|
|
20
|
+
const result = await executeAutoInjection(params.prompt, projectDir, {
|
|
21
|
+
budgetPercentage: params.budgetPercentage ?? 50,
|
|
22
|
+
minRelevance: params.minRelevance ?? 0.3,
|
|
23
|
+
maxTokens: params.maxTokens ?? 500,
|
|
24
|
+
includeFailures: true,
|
|
25
|
+
});
|
|
26
|
+
const lines = [];
|
|
27
|
+
lines.push('# Auto-Injection Result');
|
|
28
|
+
lines.push('');
|
|
29
|
+
lines.push(formatAutoInjectionResult(result));
|
|
30
|
+
lines.push('');
|
|
31
|
+
if (result.executed) {
|
|
32
|
+
lines.push('## Demand Signals Detected');
|
|
33
|
+
for (const signal of result.signals) {
|
|
34
|
+
lines.push(`- **${signal.type}** (${signal.confidence}): "${signal.trigger}"`);
|
|
35
|
+
}
|
|
36
|
+
lines.push('');
|
|
37
|
+
if (result.injectedContext) {
|
|
38
|
+
lines.push('## Injected Context');
|
|
39
|
+
lines.push('```');
|
|
40
|
+
lines.push(result.injectedContext);
|
|
41
|
+
lines.push('```');
|
|
42
|
+
}
|
|
43
|
+
lines.push('');
|
|
44
|
+
lines.push(`**Tokens injected:** ~${result.tokensInjected}`);
|
|
45
|
+
lines.push(`**Relevance score:** ${(result.relevanceScore * 100).toFixed(0)}%`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
lines.push(`**Reason:** ${result.reason}`);
|
|
49
|
+
// Show demand summary even if not executed
|
|
50
|
+
const summary = getDemandSummary(params.prompt);
|
|
51
|
+
lines.push(`**Demand summary:** ${summary}`);
|
|
52
|
+
}
|
|
53
|
+
return lines.join('\n');
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Quick check handler - just detects demand signals without injection
|
|
57
|
+
*/
|
|
58
|
+
async function handleDemandCheck(params, projectDir) {
|
|
59
|
+
const hasSignals = hasDemandSignals(params.prompt);
|
|
60
|
+
const summary = getDemandSummary(params.prompt);
|
|
61
|
+
const lines = [];
|
|
62
|
+
lines.push('# Demand Signal Check');
|
|
63
|
+
lines.push('');
|
|
64
|
+
lines.push(`**Has demand signals:** ${hasSignals ? 'Yes' : 'No'}`);
|
|
65
|
+
lines.push(`**Summary:** ${summary}`);
|
|
66
|
+
return lines.join('\n');
|
|
67
|
+
}
|
|
68
|
+
// =============================================================================
|
|
69
|
+
// Tool Definitions
|
|
70
|
+
// =============================================================================
|
|
71
|
+
/**
|
|
72
|
+
* Auto-inject tool definition
|
|
73
|
+
*/
|
|
74
|
+
export const autoInjectTool = defineTool({
|
|
75
|
+
name: 'dino_auto_inject',
|
|
76
|
+
description: 'Analyze prompt and automatically inject relevant context based on demand signals (v13.5.0). Part of auto context engineering.',
|
|
77
|
+
category: 'retrieval',
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: {
|
|
81
|
+
prompt: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
description: 'User prompt to analyze for context demand',
|
|
84
|
+
},
|
|
85
|
+
budgetPercentage: {
|
|
86
|
+
type: 'number',
|
|
87
|
+
description: 'Current budget percentage 0-100 (default: 50). Above 90% skips injection.',
|
|
88
|
+
},
|
|
89
|
+
minRelevance: {
|
|
90
|
+
type: 'number',
|
|
91
|
+
description: 'Minimum relevance score 0-1 (default: 0.3)',
|
|
92
|
+
},
|
|
93
|
+
maxTokens: {
|
|
94
|
+
type: 'number',
|
|
95
|
+
description: 'Maximum tokens to inject (default: 500)',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
required: ['prompt'],
|
|
99
|
+
},
|
|
100
|
+
handler: handleAutoInject,
|
|
101
|
+
whenToUse: 'Use to automatically analyze a prompt and inject relevant context. Called by user-prompt-submit hook. Respects autoContextInjection feature flag.',
|
|
102
|
+
relatedTools: ['dino_memory_recall', 'dino_expand'],
|
|
103
|
+
version: '13.5.0',
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* Demand check tool definition - lightweight check without injection
|
|
107
|
+
*/
|
|
108
|
+
export const demandCheckTool = defineTool({
|
|
109
|
+
name: 'dino_demand_check',
|
|
110
|
+
description: 'Quick check for context demand signals in a prompt without performing injection (v13.5.0)',
|
|
111
|
+
category: 'retrieval',
|
|
112
|
+
inputSchema: {
|
|
113
|
+
type: 'object',
|
|
114
|
+
properties: {
|
|
115
|
+
prompt: {
|
|
116
|
+
type: 'string',
|
|
117
|
+
description: 'User prompt to analyze for demand signals',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
required: ['prompt'],
|
|
121
|
+
},
|
|
122
|
+
handler: handleDemandCheck,
|
|
123
|
+
whenToUse: 'Use for a lightweight check of whether a prompt has context demand signals. Faster than full auto-inject.',
|
|
124
|
+
relatedTools: ['dino_auto_inject'],
|
|
125
|
+
version: '13.5.0',
|
|
126
|
+
});
|
|
127
|
+
// =============================================================================
|
|
128
|
+
// Exports
|
|
129
|
+
// =============================================================================
|
|
130
|
+
/**
|
|
131
|
+
* All auto-inject tools
|
|
132
|
+
*/
|
|
133
|
+
export const autoInjectTools = [
|
|
134
|
+
autoInjectTool,
|
|
135
|
+
demandCheckTool,
|
|
136
|
+
];
|
|
137
|
+
/**
|
|
138
|
+
* Register all auto-inject tools with the registry
|
|
139
|
+
*/
|
|
140
|
+
export function registerAutoInjectTools() {
|
|
141
|
+
registry.registerTools(autoInjectTools);
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=auto-inject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-inject.js","sourceRoot":"","sources":["../../../src/mcp/tools/auto-inject.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EACV,QAAQ,GAET,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,GAEjB,MAAM,6CAA6C,CAAC;AAarD,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF;;;GAGG;AACH,KAAK,UAAU,gBAAgB,CAC7B,MAAuB,EACvB,UAAkB;IAElB,MAAM,MAAM,GAAG,MAAM,oBAAoB,CACvC,MAAM,CAAC,MAAM,EACb,UAAU,EACV;QACE,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,IAAI,EAAE;QAC/C,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,GAAG;QACxC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,GAAG;QAClC,eAAe,EAAE,IAAI;KACtB,CACF,CAAC;IAEF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACtC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,IAAI,MAAM,CAAC,QAAQ,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