tui: feed /ask-* second opinion back to primary generated-code (v0.1.1)
ober
6cf6e068cd0f02392cf8037e6e8543d29d10772c
--- a/src/jcode/core/config.ss +++ b/src/jcode/core/config.ss @@ -8,13 +8,15 @@ config-provider config-get-provider-key config-default-model - *config*) + *config* + *version*) (import :std/text/json :std/os/path :jcode/core/models) (def *config* (make-parameter #f)) +(def *version* "0.1.1") (def (jcode-home) "Return ~/.jcode, creating it if needed." --- a/src/jcode/ui/cli.ss +++ b/src/jcode/ui/cli.ss @@ -35,7 +35,6 @@ (make-mutex chez-make-mutex))) (def logger (make-logger "cli")) -(def *version* "0.1.0") (def *cli-mcp-disabled* #f) (def (cli-main args) --- a/src/jcode/ui/tui.ss +++ b/src/jcode/ui/tui.ss @@ -43,7 +43,6 @@ :jerboa/runtime) (def logger (make-logger "tui")) -(def *version* "0.1.0") ;; ---- TUI verbose logging ---- ;; When --verbose is passed, logs to ~/jcode.log for debugging input/events. @@ -863,7 +862,23 @@ (format "[~a second opinion]\n~a" provider result))) (app-state-agent-busy?-set! state #f) (app-state-scroll-offset-set! state 0) - (app-state-dirty?-set! state #t)) + (app-state-dirty?-set! state #t) + ;; Feed the critique back to the primary LLM so it can revise its + ;; previous answer instead of leaving the second opinion as a + ;; human-only side-channel. Skip on subprocess errors — there's + ;; nothing useful to reconsider. + (unless (string-prefix? "ERROR:" result) + (run-agent! state + (format + (string-append + "A second opinion on your most recent answer was requested " + "from ~a. Its review is below.\n\n--- ~a ---\n~a\n--- end ---\n\n" + "Reconsider your previous answer in light of this critique. " + "If you agree, revise the answer (and, if appropriate, apply " + "the change). If you partially agree, say which parts you " + "accept and which you reject. If you disagree, briefly " + "explain why.") + provider provider result)))) ((list 'compact-result summary kept-blocks dropped-count) (tui-log "apply-agent-event: compact-result kept=~a dropped=~a" (length kept-blocks) dropped-count)