@tekmidian/pai 0.9.6 → 0.9.7

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.
@@ -7,6 +7,15 @@ description: "Manage budget-aware advisor mode — control model tiering for sub
7
7
 
8
8
  USE WHEN user says 'advisor', 'budget mode', 'set advisor', 'save budget', '/advisor', 'how much budget', OR wants to control model tiering for subagents.
9
9
 
10
+ ALSO USE WHEN user says plain-language budget/mode phrases like:
11
+ - "go easy on the budget", "save tokens", "be conservative" → set mode to conservative
12
+ - "use haiku only", "strict mode", "budget is tight" → set mode to strict
13
+ - "lock it down", "critical mode", "almost out of budget" → set mode to critical
14
+ - "go full power", "use whatever model", "no budget constraints", "normal mode", "unrestricted" → set mode to normal
15
+ - "back to auto", "reset advisor", "let the budget decide" → set mode to auto
16
+
17
+ When you detect these, write the appropriate mode to `~/.claude/advisor-mode.json` and confirm what you did.
18
+
10
19
  Advisor mode controls which models subagents use, based on weekly budget consumption.
11
20
 
12
21
  ### Configuration
@@ -27,15 +36,16 @@ The config file is at `~/.claude/advisor-mode.json`:
27
36
  - `/advisor auto` — reset to auto mode (derives from weeklyBudgetPercent)
28
37
  - `/advisor force <model>` — force all subagents to use a specific model (haiku/sonnet/opus)
29
38
  - `/advisor reset` — remove the config file (no advisor guidance injected)
39
+ - Or just say it in plain language — see triggers above
30
40
 
31
41
  ### Mode Thresholds (auto mode)
32
42
 
33
43
  | Budget Used | Mode | Subagent Model | Behavior |
34
44
  |-------------|------|----------------|----------|
35
- | < 70% | normal | Any | No constraints |
36
- | 70-85% | conservative | Haiku preferred | Escalate to sonnet only if haiku insufficient |
37
- | 85-95% | strict | Haiku only | Minimize spawning, no opus subagents |
38
- | > 95% | critical | Haiku or none | Essential work only, minimize all token usage |
45
+ | < 60% | normal | Any | No constraints |
46
+ | 60-80% | conservative | Haiku preferred | Escalate to sonnet only if haiku insufficient |
47
+ | 80-92% | strict | Haiku only | Minimize spawning, no opus subagents |
48
+ | > 92% | critical | Haiku or none | Essential work only, minimize all token usage |
39
49
 
40
50
  ### Workflow
41
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekmidian/pai",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "description": "PAI Knowledge OS — Personal AI Infrastructure with federated memory and project management",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -428,15 +428,53 @@ if [ -f "$usage_cache" ]; then
428
428
  fi
429
429
 
430
430
  # Write weekly budget to advisor-mode.json for the whisper hook
431
+ # Preserve existing mode if manually set — only update weeklyBudgetPercent
431
432
  _advisor_file="${HOME}/.claude/advisor-mode.json"
432
433
  if [ -n "$seven_day_int" ] 2>/dev/null; then
433
- printf '{"weeklyBudgetPercent":%d,"mode":"auto"}\n' "$seven_day_int" > "$_advisor_file" 2>/dev/null
434
+ _existing_mode="auto"
435
+ _existing_force=""
436
+ if [ -f "$_advisor_file" ]; then
437
+ _existing_mode=$(jq -r '.mode // "auto"' "$_advisor_file" 2>/dev/null)
438
+ _existing_force=$(jq -r '.forceModel // empty' "$_advisor_file" 2>/dev/null)
439
+ fi
440
+ if [ -n "$_existing_force" ]; then
441
+ printf '{"weeklyBudgetPercent":%d,"mode":"%s","forceModel":"%s"}\n' "$seven_day_int" "$_existing_mode" "$_existing_force" > "$_advisor_file" 2>/dev/null
442
+ else
443
+ printf '{"weeklyBudgetPercent":%d,"mode":"%s"}\n' "$seven_day_int" "$_existing_mode" > "$_advisor_file" 2>/dev/null
444
+ fi
445
+ fi
446
+
447
+ # Compute advisor mode label (mirrors thresholds in whisper-rules.ts)
448
+ # If mode is manually set (not "auto"), show that instead of auto-calculated
449
+ advisor_label=""
450
+ advisor_label_color=""
451
+ _display_mode="$_existing_mode"
452
+ if [ "$_display_mode" = "auto" ]; then
453
+ if [ "$seven_day_int" -ge 92 ] 2>/dev/null; then
454
+ _display_mode="critical"
455
+ elif [ "$seven_day_int" -ge 80 ] 2>/dev/null; then
456
+ _display_mode="strict"
457
+ elif [ "$seven_day_int" -ge 60 ] 2>/dev/null; then
458
+ _display_mode="conservative"
459
+ fi
460
+ fi
461
+ case "$_display_mode" in
462
+ "critical") advisor_label="critical"; advisor_label_color="$BRIGHT_RED" ;;
463
+ "strict") advisor_label="strict"; advisor_label_color="$BRIGHT_ORANGE" ;;
464
+ "conservative") advisor_label="conserve"; advisor_label_color="$BRIGHT_YELLOW" ;;
465
+ "normal") advisor_label="normal"; advisor_label_color="$BRIGHT_GREEN" ;;
466
+ esac
467
+ # Mark forced modes with a pin symbol so user knows it's not auto
468
+ if [ "$_existing_mode" != "auto" ] && [ -n "$advisor_label" ]; then
469
+ advisor_label="📌${advisor_label}"
434
470
  fi
435
471
 
436
- # Build usage suffix: 5h: 8% → 00:59 │ 1d: ● 29% / 36% │ 7d: 29% → Fr. 08:00
472
+ # Build usage suffix: 5h: 8% → 00:59 │ 1d: ● 29% / 36% │ 7d: ⚡strict 91% → Fr. 08:00
437
473
  five_label="5h: ${five_hour_int}%%"
438
474
  [ -n "$five_reset_fmt" ] && five_label="${five_label} → ${five_reset_fmt}"
439
- seven_label="7d: ${seven_day_int}%%"
475
+ seven_label="7d: "
476
+ [ -n "$advisor_label" ] && seven_label="${seven_label}${advisor_label_color}${advisor_label}${RESET} "
477
+ seven_label="${seven_label}${seven_day_int}%%"
440
478
  [ -n "$seven_reset_fmt" ] && seven_label="${seven_label} → ${seven_reset_fmt}"
441
479
 
442
480
  usage_suffix=" ${SEPARATOR_COLOR}│${RESET} ${five_color}${five_label}${RESET}"