loki-mode 7.40.0 → 7.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/autonomy/loki CHANGED
@@ -77,6 +77,35 @@ if [ -f "$_LOKI_SCRIPT_DIR/provider-offer.sh" ]; then
77
77
  source "$_LOKI_SCRIPT_DIR/provider-offer.sh"
78
78
  fi
79
79
 
80
+ # caveman ACTIVATION level for FREE-FORM (narration) claude subcalls in this CLI
81
+ # (migration phase exec, migration docs-gen, heal execution). Prints the level to
82
+ # pass as CAVEMAN_DEFAULT_MODE when activation is warranted, else nothing. autonomy/
83
+ # loki does NOT source claude-flags.sh globally, so this lazily sources it on demand
84
+ # (same pattern as the ultrareview/workflows gates and autonomy/lib/voter-agents.sh).
85
+ # The gate (provider==claude, claude on PATH, opt-in, no legacy-completion-match,
86
+ # no-raise of a user's lower global level) lives entirely in loki_caveman_activate_env;
87
+ # this is just the lazy-source wrapper. Degrades to empty (bare invocation, byte-
88
+ # identical to pre-caveman) when the lib is missing or the helper is unavailable.
89
+ # NEVER use this for captured-output / parsed subcalls -- those HARD-SUPPRESS with
90
+ # CAVEMAN_DEFAULT_MODE=off (see _docs_invoke_provider and run.sh:3286).
91
+ _loki_caveman_narration_level() {
92
+ if ! declare -F loki_caveman_activate_env >/dev/null 2>&1; then
93
+ local _cm_lib=""
94
+ if [ -f "${_LOKI_SCRIPT_DIR}/lib/claude-flags.sh" ]; then
95
+ _cm_lib="${_LOKI_SCRIPT_DIR}/lib/claude-flags.sh"
96
+ elif [ -f "$(dirname "$0")/lib/claude-flags.sh" ]; then
97
+ _cm_lib="$(dirname "$0")/lib/claude-flags.sh"
98
+ fi
99
+ if [ -n "$_cm_lib" ]; then
100
+ # shellcheck source=autonomy/lib/claude-flags.sh
101
+ . "$_cm_lib" 2>/dev/null || true
102
+ fi
103
+ fi
104
+ if declare -F loki_caveman_activate_env >/dev/null 2>&1; then
105
+ loki_caveman_activate_env
106
+ fi
107
+ }
108
+
80
109
  # Quickstart guided interview (v7.29.0): provides cmd_quickstart and its
81
110
  # deterministic offline template matcher. Functions-only file (no top-level
82
111
  # command), sourced here so the dispatch case can call cmd_quickstart. Composes
@@ -11499,9 +11528,19 @@ Tasks:
11499
11528
  local phase_exit=0
11500
11529
  if [ -n "$phase_prompt" ]; then
11501
11530
  local provider_name="${LOKI_PROVIDER:-claude}"
11531
+ # caveman ACTIVATION (free-form narration): the phase exec writes its
11532
+ # deliverables via tools; stdout is piped to python and only DISPLAYED,
11533
+ # never captured/parsed for a verdict. So compress the narration tokens
11534
+ # at the configured level when warranted (mirrors run.sh:13167 main loop).
11535
+ # An EMPTY CAVEMAN_DEFAULT_MODE is NOT inert (caveman falls back to the
11536
+ # user global default), so when activation is not warranted we must NOT
11537
+ # set the var at all (bare branch), keeping the call byte-identical to
11538
+ # pre-caveman. No-op when caveman is absent.
11539
+ local _loki_mig_cm=""
11540
+ _loki_mig_cm="$(_loki_caveman_narration_level)"
11502
11541
  case "$provider_name" in
11503
11542
  claude)
11504
- { (cd "$codebase_path" && claude --dangerously-skip-permissions -p "$phase_prompt" --output-format stream-json --verbose 2>&1) | \
11543
+ { (cd "$codebase_path" && if [ -n "$_loki_mig_cm" ]; then CAVEMAN_DEFAULT_MODE="$_loki_mig_cm" claude --dangerously-skip-permissions -p "$phase_prompt" --output-format stream-json --verbose 2>&1; else claude --dangerously-skip-permissions -p "$phase_prompt" --output-format stream-json --verbose 2>&1; fi) | \
11505
11544
  while IFS= read -r line; do
11506
11545
  # Extract text from stream-json
11507
11546
  if echo "$line" | python3 -c "
@@ -11667,9 +11706,15 @@ IMPORTANT RULES:
11667
11706
 
11668
11707
  local doc_exit=0
11669
11708
  local provider_name="${LOKI_PROVIDER:-claude}"
11709
+ # caveman ACTIVATION (free-form narration): docs-gen writes the docs via
11710
+ # tools; stdout is piped to python and only DISPLAYED, never captured/parsed.
11711
+ # Compress narration at the configured level when warranted; empty -> bare
11712
+ # branch, byte-identical to pre-caveman (empty mode is NOT inert). No-op absent.
11713
+ local _loki_doc_cm=""
11714
+ _loki_doc_cm="$(_loki_caveman_narration_level)"
11670
11715
  case "$provider_name" in
11671
11716
  claude)
11672
- { (cd "$codebase_path" && claude --dangerously-skip-permissions -p "$doc_prompt" --output-format stream-json --verbose 2>&1) | \
11717
+ { (cd "$codebase_path" && if [ -n "$_loki_doc_cm" ]; then CAVEMAN_DEFAULT_MODE="$_loki_doc_cm" claude --dangerously-skip-permissions -p "$doc_prompt" --output-format stream-json --verbose 2>&1; else claude --dangerously-skip-permissions -p "$doc_prompt" --output-format stream-json --verbose 2>&1; fi) | \
11673
11718
  while IFS= read -r line; do
11674
11719
  if echo "$line" | python3 -c "
11675
11720
  import sys, json
@@ -12290,10 +12335,17 @@ Begin healing now. Follow the RARV cycle for each action."
12290
12335
 
12291
12336
  # Execute with the appropriate provider
12292
12337
  local heal_exit=0
12338
+ # caveman ACTIVATION (free-form narration): heal execution writes its artifacts
12339
+ # (.loki/healing/*, characterization tests) via tools; stdout is piped to python
12340
+ # and only DISPLAYED, never captured/parsed for a verdict. Compress narration at
12341
+ # the configured level when warranted; empty -> bare branch, byte-identical to
12342
+ # pre-caveman (empty mode is NOT inert). No-op when caveman is absent.
12343
+ local _loki_heal_cm=""
12344
+ _loki_heal_cm="$(_loki_caveman_narration_level)"
12293
12345
  case "$provider" in
12294
12346
  claude)
12295
12347
  local run_args=(--dangerously-skip-permissions -p "$heal_prompt" --output-format stream-json --verbose)
12296
- (cd "$codebase_path" && claude "${run_args[@]}" 2>&1) | \
12348
+ (cd "$codebase_path" && if [ -n "$_loki_heal_cm" ]; then CAVEMAN_DEFAULT_MODE="$_loki_heal_cm" claude "${run_args[@]}" 2>&1; else claude "${run_args[@]}" 2>&1; fi) | \
12297
12349
  while IFS= read -r line; do
12298
12350
  if echo "$line" | python3 -c "
12299
12351
  import sys, json
@@ -13719,8 +13771,11 @@ tokens_per_tier = {
13719
13771
  # row from a stale \$0.25/\$1.25 (Haiku 3.5) to the published Claude Haiku 4.5
13720
13772
  # price of \$1/\$5 (anthropic.com/news/claude-haiku-4-5), so all four rows now
13721
13773
  # match the three canonical model-keyed tables (run.sh pricing.json, run.sh
13722
- # check_budget_limit, dashboard _DEFAULT_PRICING) and a fable-forced quote
13723
- # honestly shows MORE than Opus, not less.
13774
+ # check_budget_limit, dashboard _DEFAULT_PRICING). The Fable row (\$10/\$50) is
13775
+ # kept as the reference price, but since v7.39.1 fable is unavailable at the API
13776
+ # and a fable pin RESOLVES to Opus everywhere -- so a fable-pinned run both
13777
+ # dispatches AND quotes Opus (\$5/\$25), matching the runner. The Fable price row
13778
+ # is only reachable as an explicit advisory reference, not via a session pin.
13724
13779
  pricing = {
13725
13780
  'Fable': {'input': 10.00, 'output': 50.00},
13726
13781
  'Opus': {'input': 5.00, 'output': 25.00},
@@ -23691,7 +23746,16 @@ _docs_invoke_provider() {
23691
23746
 
23692
23747
  case "$provider" in
23693
23748
  claude)
23694
- result=$($t_prefix claude -p "$prompt" 2>/dev/null) || exit_code=$?
23749
+ # caveman HARD-SUPPRESS (captured deliverable): the claude stdout IS
23750
+ # the generated doc -- it is captured here and written verbatim to a
23751
+ # markdown file by both callers (loki:23869, loki:24239). A globally
23752
+ # active caveman would compress this stdout, corrupting the generated
23753
+ # CLAUDE.md / DECISIONS.md / README into caveman-speak. So disable
23754
+ # caveman unconditionally on this site (mirrors run.sh:3286, the
23755
+ # structurally identical captured `claude -p` resolution subcall).
23756
+ # env-prefix form because of the optional $t_prefix timeout wrapper.
23757
+ # No-op when caveman is absent.
23758
+ result=$($t_prefix env CAVEMAN_DEFAULT_MODE=off claude -p "$prompt" 2>/dev/null) || exit_code=$?
23695
23759
  ;;
23696
23760
  codex)
23697
23761
  result=$($t_prefix codex exec --full-auto "$prompt" 2>/dev/null) || exit_code=$?