zettcode 0.1.6__tar.gz → 0.1.8__tar.gz
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.
- {zettcode-0.1.6 → zettcode-0.1.8}/.gitignore +5 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/PKG-INFO +6 -2
- {zettcode-0.1.6 → zettcode-0.1.8}/pyproject.toml +8 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/__init__.py +1 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/agent/__init__.py +2 -1
- zettcode-0.1.8/src/zettcode/app/agent/agent/base.py +54 -0
- zettcode-0.1.8/src/zettcode/app/agent/agent/commands.py +214 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/agent/context.py +2 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/agent/prompt.py +26 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/agent/sessions.py +19 -2
- zettcode-0.1.8/src/zettcode/app/agent/agent/settings.py +327 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/agent/turns.py +101 -12
- zettcode-0.1.8/src/zettcode/app/agent/conversation/effort_gauge.py +126 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/entries.py +56 -3
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/presenters.py +291 -62
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/projection.py +27 -2
- zettcode-0.1.8/src/zettcode/app/agent/conversation/pulse.py +116 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/rendering.py +48 -9
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/replay.py +14 -3
- zettcode-0.1.8/src/zettcode/app/agent/conversation/shimmer.py +256 -0
- zettcode-0.1.8/src/zettcode/app/agent/conversation/stops.py +57 -0
- zettcode-0.1.8/src/zettcode/app/agent/conversation/text.py +230 -0
- zettcode-0.1.8/src/zettcode/app/agent/conversation/tips.py +76 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/transcript/__init__.py +5 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/transcript/stream.py +1 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/transcript/turn.py +77 -5
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/dialogue/mentions.py +117 -2
- zettcode-0.1.8/src/zettcode/app/agent/dialogue/relay.py +153 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/dialogue/side.py +1 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/dialogue/title.py +10 -2
- zettcode-0.1.8/src/zettcode/app/agent/errors.py +217 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/export/__init__.py +9 -2
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/extensions/capabilities.py +8 -2
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/extensions/compaction.py +44 -2
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/extensions/context.py +7 -2
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/extensions/mcp.py +66 -3
- zettcode-0.1.8/src/zettcode/app/agent/extensions/messaging.py +131 -0
- zettcode-0.1.8/src/zettcode/app/agent/extensions/messenger.py +184 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/extensions/subagents.py +111 -13
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/extensions/usage.py +32 -13
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/permission/__init__.py +2 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/runtime.py +179 -124
- zettcode-0.1.8/src/zettcode/app/agent/storage/__init__.py +51 -0
- zettcode-0.1.8/src/zettcode/app/agent/storage/layout.py +161 -0
- zettcode-0.1.8/src/zettcode/app/agent/storage/ledger.py +651 -0
- zettcode-0.1.8/src/zettcode/app/agent/storage/locks.py +182 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/storage/metadata.py +4 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/storage/records.py +1 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/storage/store.py +112 -35
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/brand.py +15 -5
- zettcode-0.1.8/src/zettcode/app/commandline/__init__.py +47 -0
- zettcode-0.1.8/src/zettcode/app/commandline/arguments.py +169 -0
- zettcode-0.1.8/src/zettcode/app/commandline/completion.py +262 -0
- zettcode-0.1.8/src/zettcode/app/commandline/history.py +305 -0
- zettcode-0.1.8/src/zettcode/app/commandline/runner.py +365 -0
- zettcode-0.1.8/src/zettcode/app/commands.py +277 -0
- zettcode-0.1.8/src/zettcode/app/pets/__init__.py +62 -0
- zettcode-0.1.8/src/zettcode/app/pets/cat.py +52 -0
- zettcode-0.1.8/src/zettcode/app/pets/chibi.py +55 -0
- zettcode-0.1.8/src/zettcode/app/pets/dog.py +52 -0
- zettcode-0.1.8/src/zettcode/app/pets/kangaroo.py +58 -0
- zettcode-0.1.8/src/zettcode/app/pets/model.py +191 -0
- zettcode-0.1.8/src/zettcode/app/pets/penguin.py +60 -0
- zettcode-0.1.8/src/zettcode/app/pets/polarbear.py +50 -0
- zettcode-0.1.8/src/zettcode/app/pets/scarfy.py +61 -0
- zettcode-0.1.8/src/zettcode/app/pets/seagull.py +63 -0
- zettcode-0.1.8/src/zettcode/app/pets/slime.py +56 -0
- zettcode-0.1.8/src/zettcode/app/pets/snowbear.py +55 -0
- zettcode-0.1.8/src/zettcode/app/pets/sprout.py +64 -0
- zettcode-0.1.8/src/zettcode/app/pets/tiger.py +52 -0
- zettcode-0.1.8/src/zettcode/app/pets/whale.py +54 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/app.py +228 -37
- zettcode-0.1.8/src/zettcode/app/ui/bars.py +286 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/boot.py +18 -4
- zettcode-0.1.8/src/zettcode/app/ui/commands.py +282 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/config_form.py +88 -3
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/demo.py +7 -6
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/followups.py +12 -8
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/gc_policy.py +1 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/keys.py +76 -7
- zettcode-0.1.8/src/zettcode/app/ui/labels.py +210 -0
- zettcode-0.1.8/src/zettcode/app/ui/messaging.py +246 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/notices.py +2 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/providers.py +128 -31
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/sessions.py +94 -4
- zettcode-0.1.8/src/zettcode/app/ui/settings.py +160 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/shell.py +49 -10
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/updating.py +4 -3
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/__init__.py +29 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/approval_page.py +4 -3
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/ask_page.py +4 -4
- zettcode-0.1.8/src/zettcode/app/ui/widgets/bash_page.py +91 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/completer.py +41 -8
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/composer.py +138 -4
- zettcode-0.1.8/src/zettcode/app/ui/widgets/context_charts.py +283 -0
- zettcode-0.1.8/src/zettcode/app/ui/widgets/context_page.py +418 -0
- zettcode-0.1.8/src/zettcode/app/ui/widgets/effort_page.py +295 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/follow_up.py +3 -3
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/input_page.py +3 -3
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/model_page.py +3 -3
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/panel.py +1 -1
- zettcode-0.1.8/src/zettcode/app/ui/widgets/pet.py +222 -0
- zettcode-0.1.8/src/zettcode/app/ui/widgets/pet_page.py +347 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/root.py +14 -7
- zettcode-0.1.8/src/zettcode/app/ui/widgets/self_compact_page.py +409 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/send_kind_page.py +4 -3
- zettcode-0.1.8/src/zettcode/app/ui/widgets/sessions_page.py +268 -0
- zettcode-0.1.8/src/zettcode/app/ui/widgets/statusline_page.py +437 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/steering.py +4 -3
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/transcript.py +8 -7
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/update_page.py +2 -2
- zettcode-0.1.8/src/zettcode/app/ui/widgets/usage_charts.py +464 -0
- zettcode-0.1.8/src/zettcode/app/ui/widgets/usage_page.py +273 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/widgets/welcome.py +5 -2
- zettcode-0.1.8/src/zettcode/broker/__init__.py +22 -0
- zettcode-0.1.8/src/zettcode/broker/__main__.py +10 -0
- zettcode-0.1.8/src/zettcode/broker/client.py +533 -0
- zettcode-0.1.8/src/zettcode/broker/files.py +131 -0
- zettcode-0.1.8/src/zettcode/broker/finder.py +190 -0
- zettcode-0.1.8/src/zettcode/broker/hub.py +275 -0
- zettcode-0.1.8/src/zettcode/broker/log.py +11 -0
- zettcode-0.1.8/src/zettcode/broker/models.py +77 -0
- zettcode-0.1.8/src/zettcode/broker/process.py +117 -0
- zettcode-0.1.8/src/zettcode/broker/protocol.py +282 -0
- zettcode-0.1.8/src/zettcode/broker/roster.py +176 -0
- zettcode-0.1.8/src/zettcode/broker/runner.py +131 -0
- zettcode-0.1.8/src/zettcode/broker/server.py +184 -0
- zettcode-0.1.8/src/zettcode/broker/text.py +81 -0
- zettcode-0.1.8/src/zettcode/broker/web.py +192 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/cli.py +116 -25
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/config.py +247 -22
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/config_edit.py +88 -0
- zettcode-0.1.8/src/zettcode/doctor.py +167 -0
- zettcode-0.1.8/src/zettcode/filelock.py +125 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/paths.py +9 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/plugins/__init__.py +14 -0
- zettcode-0.1.8/src/zettcode/plugins/builtin_agent.py +383 -0
- zettcode-0.1.8/src/zettcode/plugins/builtin_commands.py +420 -0
- zettcode-0.1.8/src/zettcode/plugins/builtins.py +187 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/plugins/container.py +279 -6
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/plugins/extension.py +4 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/plugins/loader.py +68 -6
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/plugins/plugin.py +68 -3
- zettcode-0.1.8/src/zettcode/plugins/services.py +97 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/plugins/state.py +66 -4
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/providers.py +15 -8
- zettcode-0.1.8/src/zettcode/py.typed +1 -0
- zettcode-0.1.8/src/zettcode/sdk/__init__.py +128 -0
- zettcode-0.1.8/src/zettcode/sdk/_translate.py +179 -0
- zettcode-0.1.8/src/zettcode/sdk/client.py +730 -0
- zettcode-0.1.8/src/zettcode/sdk/errors.py +104 -0
- zettcode-0.1.8/src/zettcode/sdk/events.py +345 -0
- zettcode-0.1.8/src/zettcode/sdk/handlers.py +124 -0
- zettcode-0.1.8/src/zettcode/sdk/session.py +875 -0
- zettcode-0.1.8/src/zettcode/sdk/types.py +337 -0
- zettcode-0.1.8/src/zettcode/statusline.py +141 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/__init__.py +30 -2
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/core/events.py +1 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/core/theme.py +53 -18
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/core/widget.py +8 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/input/events.py +2 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/layout/scroll.py +41 -37
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/layout/spacing.py +2 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/render/__init__.py +6 -0
- zettcode-0.1.8/src/zettcode/tui/render/ansi.py +371 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/render/text.py +56 -1
- zettcode-0.1.8/src/zettcode/tui/theme_file.py +290 -0
- zettcode-0.1.8/src/zettcode/tui/themes/ayu-mirage.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/catppuccin-latte.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/catppuccin-mocha.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/dracula.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/github-dimmed.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/github-light.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/gruvbox-dark.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/gruvbox-light.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/kanagawa.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/nord.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/one-dark.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/rose-pine-dawn.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/rose-pine.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/solarized-dark.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/solarized-light.toml +44 -0
- zettcode-0.1.8/src/zettcode/tui/themes/tokyo-night.toml +44 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/__init__.py +3 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/collapsible.py +2 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/completion.py +6 -0
- zettcode-0.1.8/src/zettcode/tui/widgets/console.py +442 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/list.py +52 -10
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/list_page.py +11 -3
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/markdown.py +2 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/status.py +20 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/tasks.py +2 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/text.py +2 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/textarea.py +25 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/toast.py +2 -1
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/update.py +78 -0
- zettcode-0.1.6/src/zettcode/app/agent/agent/base.py +0 -29
- zettcode-0.1.6/src/zettcode/app/agent/agent/commands.py +0 -86
- zettcode-0.1.6/src/zettcode/app/agent/agent/settings.py +0 -164
- zettcode-0.1.6/src/zettcode/app/agent/conversation/rows.py +0 -424
- zettcode-0.1.6/src/zettcode/app/agent/errors.py +0 -39
- zettcode-0.1.6/src/zettcode/app/agent/storage/__init__.py +0 -31
- zettcode-0.1.6/src/zettcode/app/commands.py +0 -151
- zettcode-0.1.6/src/zettcode/app/ui/commands.py +0 -307
- zettcode-0.1.6/src/zettcode/app/ui/labels.py +0 -108
- zettcode-0.1.6/src/zettcode/app/ui/rows.py +0 -169
- zettcode-0.1.6/src/zettcode/app/ui/settings.py +0 -102
- zettcode-0.1.6/src/zettcode/app/ui/widgets/context_page.py +0 -114
- zettcode-0.1.6/src/zettcode/app/ui/widgets/sessions_page.py +0 -84
- zettcode-0.1.6/src/zettcode/plugins/builtins.py +0 -82
- zettcode-0.1.6/src/zettcode/tui/theme_file.py +0 -101
- {zettcode-0.1.6 → zettcode-0.1.8}/LICENSE +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/README.md +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/README.zh-CN.md +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/_compat.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/__init__.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/__init__.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/agent/exports.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/agent/interaction.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/__init__.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/changes.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/transcript/fold.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/transcript/log.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/conversation/transcript/oneoff.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/dialogue/__init__.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/dialogue/ask.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/export/trace/script.js +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/export/trace/style.css +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/export/trace/template.html +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/extensions/__init__.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/extensions/mcp_notice.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/extensions/tool_output.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/permission/approval.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/agent/permission/readonly.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/pipeline.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/registry.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/__init__.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/app/ui/clipboard.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/collector.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/plugins/mixins.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/capabilities.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/clipboard.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/console.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/core/__init__.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/core/app.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/core/focus.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/core/geometry.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/core/host.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/core/keymap.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/core/scheduler.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/core/screen.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/gallery.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/glyphs.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/input/__init__.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/input/bridge.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/input/decoder.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/input/keys.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/input/reader.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/layout/__init__.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/layout/box.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/layout/overlay.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/layout/solver.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/render/canvas.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/render/code.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/render/color.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/render/renderer.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/render/rich_text.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/render/style.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/render/sweep.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/runner.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/terminal.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/testing/__init__.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/testing/harness.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/testing/snapshot.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/dialog.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/diff.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/progress.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/rich_text.py +0 -0
- {zettcode-0.1.6 → zettcode-0.1.8}/src/zettcode/tui/widgets/table.py +0 -0
|
@@ -20,3 +20,8 @@ node_modules/
|
|
|
20
20
|
docs/.vitepress/dist/
|
|
21
21
|
docs/.vitepress/cache/
|
|
22
22
|
docs/.vitepress/.temp/
|
|
23
|
+
|
|
24
|
+
# The palette gallery is generated by `make palettes`: every widget painted in
|
|
25
|
+
# every palette, written by docs/scripts/palette_gallery.py. Regenerate it
|
|
26
|
+
# rather than committing a 2 MB copy that goes stale the moment a colour moves.
|
|
27
|
+
docs/internal/palettes.html
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: zettcode
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: A focused terminal coding agent powered by zett-agent
|
|
5
5
|
Project-URL: Repository, https://github.com/Chang-LeHung/zettcode
|
|
6
6
|
Project-URL: Issues, https://github.com/Chang-LeHung/zettcode/issues
|
|
@@ -21,14 +21,18 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
21
21
|
Classifier: Typing :: Typed
|
|
22
22
|
Requires-Python: >=3.10
|
|
23
23
|
Requires-Dist: exceptiongroup<2,>=1.2; python_version < '3.11'
|
|
24
|
+
Requires-Dist: httpx<1,>=0.27
|
|
24
25
|
Requires-Dist: pydantic<3,>=2
|
|
25
26
|
Requires-Dist: pyperclip<2,>=1.9
|
|
26
27
|
Requires-Dist: setproctitle<2,>=1.3.7; os_name == 'posix'
|
|
28
|
+
Requires-Dist: starlette<2,>=0.48
|
|
27
29
|
Requires-Dist: tiktoken<1,>=0.12
|
|
28
30
|
Requires-Dist: tomli<3,>=2; python_version < '3.11'
|
|
29
31
|
Requires-Dist: truststore<1,>=0.10
|
|
32
|
+
Requires-Dist: uvicorn<1,>=0.35
|
|
30
33
|
Requires-Dist: wcwidth<1,>=0.2
|
|
31
|
-
Requires-Dist:
|
|
34
|
+
Requires-Dist: websockets<17,>=15
|
|
35
|
+
Requires-Dist: zett-agent<0.2,>=0.1.17
|
|
32
36
|
Description-Content-Type: text/markdown
|
|
33
37
|
|
|
34
38
|
<p align="center">
|
|
@@ -29,6 +29,13 @@ dependencies = [
|
|
|
29
29
|
"pydantic>=2,<3",
|
|
30
30
|
"pyperclip>=1.9,<2",
|
|
31
31
|
"setproctitle>=1.3.7,<2; os_name == 'posix'",
|
|
32
|
+
# The session broker is an ordinary web server: a Starlette application served by uvicorn. A session reaches it
|
|
33
|
+
# with httpx (to send) and websockets (to be reachable). The floors are the oldest versions the broker's tests
|
|
34
|
+
# were run against; all of them arrive through the runtime today and are declared so that is not luck.
|
|
35
|
+
"starlette>=0.48,<2",
|
|
36
|
+
"uvicorn>=0.35,<1",
|
|
37
|
+
"httpx>=0.27,<1",
|
|
38
|
+
"websockets>=15,<17",
|
|
32
39
|
# The counter behind ``/context`` measures a request with it, and imports it
|
|
33
40
|
# itself: the floor matches the runtime's, so neither resolver has to fight.
|
|
34
41
|
"tiktoken>=0.12,<1",
|
|
@@ -46,7 +53,7 @@ dependencies = [
|
|
|
46
53
|
# than it did. An exact pin would make zettcode fight every other tool that
|
|
47
54
|
# shares the dependency — including an upgrade of zett-agent itself, which pip
|
|
48
55
|
# would downgrade to satisfy it.
|
|
49
|
-
"zett-agent>=0.1.
|
|
56
|
+
"zett-agent>=0.1.17,<0.2",
|
|
50
57
|
]
|
|
51
58
|
|
|
52
59
|
[project.scripts]
|
|
@@ -7,7 +7,7 @@ from typing import TYPE_CHECKING
|
|
|
7
7
|
|
|
8
8
|
#: The one place the version is written. ``pyproject.toml`` reads it from here
|
|
9
9
|
#: and the release workflow checks the tag against it, so a bump is one edit.
|
|
10
|
-
__version__ = "0.1.
|
|
10
|
+
__version__ = "0.1.8"
|
|
11
11
|
|
|
12
12
|
#: Where each public name lives; read by :func:`__getattr__` on first use.
|
|
13
13
|
_EXPORTS = {
|
|
@@ -22,7 +22,8 @@ is the composition and the lifecycle — building the runtime, and closing it.
|
|
|
22
22
|
|
|
23
23
|
from __future__ import annotations
|
|
24
24
|
|
|
25
|
-
from
|
|
25
|
+
from zettcode.config import ZettCodeConfig
|
|
26
|
+
|
|
26
27
|
from ..runtime import ZettCodeRuntime
|
|
27
28
|
from .commands import CommandsMixin
|
|
28
29
|
from .context import ContextMixin
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""What every part of the agent shares: the runtime it speaks to, and who and where it is.
|
|
2
|
+
|
|
3
|
+
The mixins in this package are split by what they are responsible for, and each one
|
|
4
|
+
inherits this class only to be type-checked against what the others rely on. The two
|
|
5
|
+
properties here are read by nearly all of them, which is why they live below all of them.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from ..runtime import ZettCodeRuntime
|
|
13
|
+
from ..storage import SessionLocked
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AgentBase:
|
|
17
|
+
"""The runtime, the workspace it works in, and the session the next turn belongs to."""
|
|
18
|
+
|
|
19
|
+
#: The runtime this agent speaks to; the one thing the application agent holds.
|
|
20
|
+
runtime: ZettCodeRuntime
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def workspace(self) -> Path:
|
|
24
|
+
"""Return the workspace displayed in the header."""
|
|
25
|
+
return self.runtime.config.workspace
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def session_id(self) -> str:
|
|
29
|
+
"""Return the session used for the next turn."""
|
|
30
|
+
return self.runtime.session_id
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def session_locked(self) -> bool:
|
|
34
|
+
"""Return whether another process has the active session open, so that this one may only read it.
|
|
35
|
+
|
|
36
|
+
Every session is locked by the process that has it open (see :mod:`..storage.locks`). A session this
|
|
37
|
+
process started is always its own; one it resumed may be somebody else's, and then it is shown and
|
|
38
|
+
nothing is written to it: no turn, no title, no compaction.
|
|
39
|
+
"""
|
|
40
|
+
return self.runtime.session_locked
|
|
41
|
+
|
|
42
|
+
def retake_session(self) -> bool:
|
|
43
|
+
"""Try again to lock the active session; return whether this process holds it now."""
|
|
44
|
+
return self.runtime.retake_session()
|
|
45
|
+
|
|
46
|
+
def require_session(self) -> None:
|
|
47
|
+
"""Refuse to go on when the active session is another process's.
|
|
48
|
+
|
|
49
|
+
Raises:
|
|
50
|
+
SessionLocked: The lock is not held. A ``ValueError``, which the shell shows as a line in the
|
|
51
|
+
conversation.
|
|
52
|
+
"""
|
|
53
|
+
if self.session_locked:
|
|
54
|
+
raise SessionLocked()
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"""What the agent offers the shell to run and to show: its own commands, and what plugins added.
|
|
2
|
+
|
|
3
|
+
The commands report through transcript Markdown; commands that present a widget belong to
|
|
4
|
+
the shell, which owns the widgets. The plugin contributions are listed here because the
|
|
5
|
+
agent is where the shell asks for everything the runtime loaded.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from zettcode.app.commands import Command, CommandContext, CommandHost, CommandResult
|
|
11
|
+
from zettcode.app.pets import PetCatalog, bundled_pets
|
|
12
|
+
from zettcode.plugins import UiRow
|
|
13
|
+
from zettcode.plugins.services import HOST_LINK, HostLink
|
|
14
|
+
from zettcode.providers import BUILTIN_PROVIDERS, Provider, merge_providers
|
|
15
|
+
from zettcode.statusline import NAMES, unknown
|
|
16
|
+
from zettcode.tui import ThemeCatalog
|
|
17
|
+
|
|
18
|
+
from ..conversation.presenters import Presenters
|
|
19
|
+
from ..dialogue.mentions import MentionProvider
|
|
20
|
+
from .exports import ExportsMixin
|
|
21
|
+
|
|
22
|
+
#: The words ``/self-compact`` takes after it, or after ``global``.
|
|
23
|
+
_SELF_COMPACT_WORDS = frozenset({"on", "off", "default"})
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class CommandsMixin(ExportsMixin):
|
|
27
|
+
"""The ``/new``, ``/compact``, and ``/export`` commands, and the plugins' commands, mentions, and rows."""
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def commands(self) -> tuple[Command, ...]:
|
|
31
|
+
"""Return the conversation commands the agent owns.
|
|
32
|
+
|
|
33
|
+
They report through transcript Markdown; commands that present a widget
|
|
34
|
+
(such as the model picker) belong to the shell, which owns the widgets.
|
|
35
|
+
"""
|
|
36
|
+
return (
|
|
37
|
+
Command("/new", "start a fresh session", "agent", self._command_new),
|
|
38
|
+
Command("/compact", "summarize the context now", "agent", self._command_compact),
|
|
39
|
+
Command("/export", "write this session to an HTML file: /export [path]", "agent", self._command_export),
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
def attach_host(self, host: CommandHost) -> None:
|
|
43
|
+
"""Tell the plugins where the shell is, so the words their commands offer can follow the session."""
|
|
44
|
+
link = self.runtime.plugins.find(HOST_LINK, HostLink)
|
|
45
|
+
if link is not None:
|
|
46
|
+
link.attach(host)
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def plugin_commands(self) -> tuple[Command, ...]:
|
|
50
|
+
"""Return the commands the installed plugins registered, not counting the built-in ones.
|
|
51
|
+
|
|
52
|
+
The shell keeps them after everything built in, so a plugin cannot take over a built-in name;
|
|
53
|
+
plugin-versus-plugin duplicates are rejected when the plugins load.
|
|
54
|
+
"""
|
|
55
|
+
return self.runtime.plugins.installed_commands
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def builtin_plugin_commands(self) -> tuple[Command, ...]:
|
|
59
|
+
"""Return the commands the program's own plugins registered: ``/resume``, ``/model``, ``/usage`` and the rest."""
|
|
60
|
+
return self.runtime.plugins.builtin_commands
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def plugin_mentions(self) -> tuple[MentionProvider, ...]:
|
|
64
|
+
"""Return the ``@`` resource providers the installed plugins registered."""
|
|
65
|
+
return self.runtime.plugins.mentions
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def providers(self) -> tuple[Provider, ...]:
|
|
69
|
+
"""Return the hosts ``/config`` can offer: the built-in ones, then the plugins' own."""
|
|
70
|
+
return merge_providers(BUILTIN_PROVIDERS, self.runtime.plugins.providers)
|
|
71
|
+
|
|
72
|
+
@property
|
|
73
|
+
def themes(self) -> ThemeCatalog:
|
|
74
|
+
"""Return every palette that can be asked for by name: the plugins', then the reader's own files.
|
|
75
|
+
|
|
76
|
+
Built fresh each time it is asked: it lists names and builds nothing, and the reader's directory may have
|
|
77
|
+
gained a file since the last look.
|
|
78
|
+
"""
|
|
79
|
+
return ThemeCatalog(self.runtime.plugins.themes, self.runtime.config.themes_dir)
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def pets(self) -> PetCatalog:
|
|
83
|
+
"""Return every pet that can be asked for by name: the built-in plugin's, then any other plugin's.
|
|
84
|
+
|
|
85
|
+
A plugin bundle that offers none (one built by hand, without the built-in plugin) gets the program's own.
|
|
86
|
+
"""
|
|
87
|
+
sources = self.runtime.plugins.pets
|
|
88
|
+
return PetCatalog(sources or bundled_pets())
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def plugin_failures(self) -> tuple[str, ...]:
|
|
92
|
+
"""Return one message per plugin that could not be loaded or activated."""
|
|
93
|
+
return self.runtime.plugins.failures
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def presenters(self) -> Presenters:
|
|
97
|
+
"""Return how this run draws entries: the built-in presenters, and any a plugin outranks them with.
|
|
98
|
+
|
|
99
|
+
Built from the bundle rather than from a module-level default for the same reason the palettes are: the
|
|
100
|
+
program's own rows are registered through the plugin route, so a plugin that draws a kind or a family of
|
|
101
|
+
rows reaches the transcript without a second path only plugins could not take.
|
|
102
|
+
"""
|
|
103
|
+
return Presenters(self.runtime.plugins.presenters)
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def plugin_rows(self) -> tuple[UiRow, ...]:
|
|
107
|
+
"""Return the header and status rows plugins asked the shell to draw."""
|
|
108
|
+
return self.runtime.plugins.rows
|
|
109
|
+
|
|
110
|
+
async def _command_new(self, context: CommandContext) -> CommandResult:
|
|
111
|
+
"""Start a fresh session."""
|
|
112
|
+
session_id = self.new_session()
|
|
113
|
+
return CommandResult(notification=f"started session {session_id[:8]}")
|
|
114
|
+
|
|
115
|
+
async def _command_export(self, context: CommandContext) -> CommandResult:
|
|
116
|
+
"""Write the session and its context to one HTML file.
|
|
117
|
+
|
|
118
|
+
The path argument is optional; without it the file lands in the
|
|
119
|
+
workspace, named after the session, and the result says where.
|
|
120
|
+
"""
|
|
121
|
+
path = await self.export_session(context.argument.strip() or None)
|
|
122
|
+
return CommandResult(message=f"Exported to `{path}`")
|
|
123
|
+
|
|
124
|
+
def self_compaction_summary(self) -> str:
|
|
125
|
+
"""Say in one line whether self-compaction is on here, where that comes from, and what the default is."""
|
|
126
|
+
state = "on" if self.self_compaction else "off"
|
|
127
|
+
default = "on" if self.self_compaction_default else "off"
|
|
128
|
+
if self.self_compaction_choice is None:
|
|
129
|
+
return f"Self-compaction is {state}: this session follows the default ({default})"
|
|
130
|
+
return f"Self-compaction is {state}: this session chose it; the default is {default}"
|
|
131
|
+
|
|
132
|
+
def self_compact_report(self) -> str:
|
|
133
|
+
"""Say what self-compaction is, whether it is on here, and where that comes from."""
|
|
134
|
+
choice = self.self_compaction_choice
|
|
135
|
+
default = "on" if self.self_compaction_default else "off"
|
|
136
|
+
state = "on" if self.self_compaction else "off"
|
|
137
|
+
source = (
|
|
138
|
+
f"this session chose it; the config default is **{default}**"
|
|
139
|
+
if choice is not None
|
|
140
|
+
else "following the config default (`[compaction] self`)"
|
|
141
|
+
)
|
|
142
|
+
return (
|
|
143
|
+
f"Self-compaction is **{state}** ({source}).\n\n"
|
|
144
|
+
"When on, the model gets a `compact_context` tool and can summarize its own earlier conversation "
|
|
145
|
+
"when it judges the detail is no longer needed. The current turn is always kept. "
|
|
146
|
+
"`/compact` and the automatic threshold work either way.\n\n"
|
|
147
|
+
"`/self-compact on|off` sets this session; `default` hands it back to the config; "
|
|
148
|
+
"`global on|off` changes the default for every session that has not chosen."
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
def change_self_compaction(self, argument: str) -> str:
|
|
152
|
+
"""Read or change self-compaction from the words ``/self-compact`` takes, and say what now applies.
|
|
153
|
+
|
|
154
|
+
``on``, ``off`` and ``default`` set this session's own choice; ``global on`` and ``global off``
|
|
155
|
+
write the default for every session into the config file. A failed write is never reported as saved.
|
|
156
|
+
|
|
157
|
+
Raises:
|
|
158
|
+
ValueError: The words are not ones the command takes, or the change could not be saved.
|
|
159
|
+
"""
|
|
160
|
+
words = argument.lower().split()
|
|
161
|
+
scope = "session"
|
|
162
|
+
if words[:1] == ["global"]:
|
|
163
|
+
scope, words = "global", words[1:]
|
|
164
|
+
usage = ValueError("Usage: /self-compact [on|off|default] or /self-compact global on|off")
|
|
165
|
+
if len(words) > 1 or (scope == "global" and not words) or (words and words[0] not in _SELF_COMPACT_WORDS):
|
|
166
|
+
raise usage
|
|
167
|
+
if scope == "global":
|
|
168
|
+
if words[0] == "default":
|
|
169
|
+
raise usage
|
|
170
|
+
self.remember_self_compaction(words[0] == "on")
|
|
171
|
+
elif words:
|
|
172
|
+
self.use_self_compaction({"on": True, "off": False, "default": None}[words[0]])
|
|
173
|
+
return self.self_compact_report()
|
|
174
|
+
|
|
175
|
+
def statusline_summary(self) -> str:
|
|
176
|
+
"""Say in one line which parts of the header and the status line are hidden."""
|
|
177
|
+
hidden = [name for name in NAMES if name in self.statusline_hidden]
|
|
178
|
+
if not hidden:
|
|
179
|
+
return "Status line: every part is shown"
|
|
180
|
+
return f"Status line: {len(hidden)} of {len(NAMES)} parts hidden ({', '.join(hidden)})"
|
|
181
|
+
|
|
182
|
+
def change_statusline(self, argument: str) -> str:
|
|
183
|
+
"""Hide or show parts of the header and status line from the words ``/statusline`` takes.
|
|
184
|
+
|
|
185
|
+
``hide <name>...`` and ``show <name>...`` change the named parts, and ``show all`` brings every one
|
|
186
|
+
back. The change is written to ``[statusline]`` in the config file, and nothing is changed when any
|
|
187
|
+
name is not a part.
|
|
188
|
+
|
|
189
|
+
Raises:
|
|
190
|
+
ValueError: The words are not ones the command takes, or the change could not be saved.
|
|
191
|
+
"""
|
|
192
|
+
words = argument.lower().split()
|
|
193
|
+
usage = ValueError(
|
|
194
|
+
f"Usage: /statusline [hide|show] <part>... or /statusline show all; parts: {', '.join(NAMES)}"
|
|
195
|
+
)
|
|
196
|
+
if len(words) < 2 or words[0] not in {"hide", "show"}:
|
|
197
|
+
raise usage
|
|
198
|
+
visible = words[0] == "show"
|
|
199
|
+
names = list(NAMES) if visible and words[1:] == ["all"] else words[1:]
|
|
200
|
+
if stray := unknown(names):
|
|
201
|
+
raise ValueError(f"No such part: {', '.join(stray)}. Parts: {', '.join(NAMES)}")
|
|
202
|
+
self.remember_statusline({name: visible for name in names})
|
|
203
|
+
return self.statusline_summary()
|
|
204
|
+
|
|
205
|
+
async def _command_compact(self, context: CommandContext) -> CommandResult:
|
|
206
|
+
"""Summarize the conversation now, whatever its size.
|
|
207
|
+
|
|
208
|
+
The row and the outcome notice arrive while this await runs: the pass
|
|
209
|
+
dispatches through the same event dispatcher a turn does, so the
|
|
210
|
+
transcript animates ``Compacting`` and ends with ``Context compaction
|
|
211
|
+
applied`` (or ``skipped`` when the summary would not be smaller).
|
|
212
|
+
"""
|
|
213
|
+
await self.compact()
|
|
214
|
+
return CommandResult()
|
|
@@ -80,9 +80,11 @@ class ContextMixin(AgentBase):
|
|
|
80
80
|
worth replacing.
|
|
81
81
|
|
|
82
82
|
Raises:
|
|
83
|
+
SessionLocked: Another process has this session open, and a checkpoint is a write.
|
|
83
84
|
ValueError: When the newest checkpoint already covers the branch —
|
|
84
85
|
a second pass would summarize nothing but the checkpoint.
|
|
85
86
|
"""
|
|
87
|
+
self.require_session()
|
|
86
88
|
if self._compacted_at_the_head():
|
|
87
89
|
raise ValueError("Already compacted; send a message before compacting again")
|
|
88
90
|
await self.runtime.start()
|
|
@@ -23,6 +23,9 @@ class MentionPart:
|
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
25
|
token: str
|
|
26
|
+
#: The words the model reads in the token's place, when it is not to see the token itself. ``None``
|
|
27
|
+
#: leaves the token as typed; the typed text is what the transcript and the store keep either way.
|
|
28
|
+
says: str | None = None
|
|
26
29
|
|
|
27
30
|
|
|
28
31
|
#: One piece of a user turn, in the order it was written: a run of text, or the
|
|
@@ -39,6 +42,29 @@ def plain_text_part(part: PromptPart) -> str:
|
|
|
39
42
|
return ""
|
|
40
43
|
|
|
41
44
|
|
|
45
|
+
def model_text_part(part: PromptPart) -> str:
|
|
46
|
+
"""Return the text one part is to the model: a reference that was resolved reads as what it says."""
|
|
47
|
+
if isinstance(part, MentionPart) and part.says is not None:
|
|
48
|
+
return part.says
|
|
49
|
+
return plain_text_part(part)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def mention_parts(parts: Sequence[PromptPart], mentions: MentionRegistry) -> tuple[PromptPart, ...]:
|
|
53
|
+
"""Return a turn with each reference that has words of its own carrying them.
|
|
54
|
+
|
|
55
|
+
``@work`` typed for a session that is running is not a word the model knows, so it is put in the
|
|
56
|
+
model's reading as ``session "work"`` and :func:`mention_hint` explains it. Anything else — a skill, a
|
|
57
|
+
file, a name nobody has — keeps the token as it was typed.
|
|
58
|
+
"""
|
|
59
|
+
if not mentions.providers:
|
|
60
|
+
return tuple(parts)
|
|
61
|
+
resolved: list[PromptPart] = []
|
|
62
|
+
for part in parts:
|
|
63
|
+
says = mentions.rename_token(part.token) if isinstance(part, MentionPart) else None
|
|
64
|
+
resolved.append(MentionPart(part.token, says) if says is not None and isinstance(part, MentionPart) else part)
|
|
65
|
+
return tuple(resolved)
|
|
66
|
+
|
|
67
|
+
|
|
42
68
|
def plain_text(parts: Sequence[PromptPart]) -> str:
|
|
43
69
|
"""Return a turn as the reader typed it, with its ``@`` tokens back in place."""
|
|
44
70
|
return "".join(plain_text_part(part) for part in parts)
|
|
@@ -8,15 +8,17 @@ the rest of the shell does.
|
|
|
8
8
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
|
+
from collections.abc import Sequence
|
|
11
12
|
from dataclasses import dataclass
|
|
12
13
|
from pathlib import Path
|
|
13
14
|
|
|
14
15
|
from zett_agent.messages import AssistantMessage, UserMessage
|
|
16
|
+
from zett_agent.model import ReasoningEffort
|
|
15
17
|
|
|
16
18
|
from ..conversation.replay import Replayed, replay
|
|
17
19
|
from ..conversation.transcript import Transcript
|
|
18
20
|
from ..dialogue.title import summarize_title
|
|
19
|
-
from ..storage import Session, SessionInfo
|
|
21
|
+
from ..storage import Session, SessionInfo, SessionStats
|
|
20
22
|
from .context import ContextMixin
|
|
21
23
|
|
|
22
24
|
#: The name a session shows before the agent has given it a title.
|
|
@@ -170,6 +172,13 @@ class SessionsMixin(ContextMixin):
|
|
|
170
172
|
"""List persisted session metadata by recent activity."""
|
|
171
173
|
return await self.runtime.persistence.list_sessions(limit=limit)
|
|
172
174
|
|
|
175
|
+
async def session_stats(self, sessions: Sequence[SessionInfo]) -> dict[str, SessionStats]:
|
|
176
|
+
"""Return the entry count and token totals of listed sessions, keyed by session id.
|
|
177
|
+
|
|
178
|
+
A session missing from the answer has no totals to show.
|
|
179
|
+
"""
|
|
180
|
+
return await self.runtime.persistence.session_stats([session.session_id for session in sessions])
|
|
181
|
+
|
|
173
182
|
async def rename_session(self, title: str) -> str:
|
|
174
183
|
"""Store a display title for the active session and return it cleaned.
|
|
175
184
|
|
|
@@ -180,7 +189,11 @@ class SessionsMixin(ContextMixin):
|
|
|
180
189
|
Args:
|
|
181
190
|
title: Name to store; surrounding space is trimmed, and a blank or
|
|
182
191
|
over-long name is rejected by the store.
|
|
192
|
+
|
|
193
|
+
Raises:
|
|
194
|
+
SessionLocked: Another process has this session open.
|
|
183
195
|
"""
|
|
196
|
+
self.require_session()
|
|
184
197
|
await self.runtime.persistence.set_title(self.session_id, title)
|
|
185
198
|
return title.strip()
|
|
186
199
|
|
|
@@ -199,6 +212,8 @@ class SessionsMixin(ContextMixin):
|
|
|
199
212
|
"""
|
|
200
213
|
if self.runtime.persistence.session_title(session_id) is not None:
|
|
201
214
|
return None
|
|
215
|
+
if session_id == self.session_id and self.session_locked:
|
|
216
|
+
return None # a nicety, and not one that is worth writing into a session that is not ours
|
|
202
217
|
session = self.runtime.persistence.read(session_id)
|
|
203
218
|
branch = session.branch()
|
|
204
219
|
question = next(
|
|
@@ -212,7 +227,9 @@ class SessionsMixin(ContextMixin):
|
|
|
212
227
|
if not question or not answer:
|
|
213
228
|
return None
|
|
214
229
|
await self.runtime.start()
|
|
215
|
-
|
|
230
|
+
# A level the model takes, so naming the session cannot be what fails on an endpoint that lacks `low`.
|
|
231
|
+
effort = self.runtime.active_model.accepted_effort(ReasoningEffort.LOW)
|
|
232
|
+
title = await summarize_title(self.runtime.provider, question=question, answer=answer, effort=effort)
|
|
216
233
|
if title is None:
|
|
217
234
|
return None
|
|
218
235
|
await self.runtime.persistence.set_title(session_id, title)
|