samagotchi 0.59.0 → 0.60.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +49 -1
- data/README.md +3 -2
- data/bin/chi +23 -2
- data/docs/architecture.md +4 -2
- data/docs/cli.md +9 -3
- data/docs/configuration.md +62 -12
- data/docs/hooks.md +10 -4
- data/docs/internals/engine.md +16 -8
- data/docs/internals/gemma4-contract.md +1 -0
- data/docs/internals/prompt-caching.md +3 -2
- data/docs/memory.md +1 -1
- data/docs/plugins.md +50 -1
- data/docs/sessions.md +1 -1
- data/docs/sub-agent.md +2 -2
- data/docs/testing.md +4 -2
- data/lib/samagotchi/bootstrap_command.rb +2 -1
- data/lib/samagotchi/bridge/turn_accumulator.rb +2 -0
- data/lib/samagotchi/bundles/agents-md/manifest.yml +11 -0
- data/lib/samagotchi/bundles/agents-md/plugin.rb +198 -0
- data/lib/samagotchi/bundles/core/manifest.yml +2 -1
- data/lib/samagotchi/bundles/system/config_modification_protocol.md +1 -1
- data/lib/samagotchi/bundles/system/manifest.yml +2 -2
- data/lib/samagotchi/config.rb +33 -5
- data/lib/samagotchi/continue_offer.rb +5 -2
- data/lib/samagotchi/engine.rb +63 -14
- data/lib/samagotchi/iteration_limit.rb +3 -2
- data/lib/samagotchi/kernel_loop.rb +35 -9
- data/lib/samagotchi/llm/backend.rb +6 -1
- data/lib/samagotchi/llm/chat_loop.rb +11 -6
- data/lib/samagotchi/llm/model_result.rb +11 -2
- data/lib/samagotchi/llm/native_backend.rb +3 -2
- data/lib/samagotchi/log_subscriber.rb +2 -1
- data/lib/samagotchi/plugin/context.rb +16 -3
- data/lib/samagotchi/prompt_files.rb +127 -0
- data/lib/samagotchi/ref.rb +124 -0
- data/lib/samagotchi/session.rb +15 -3
- data/lib/samagotchi/session_metrics.rb +8 -2
- data/lib/samagotchi/session_setup.rb +11 -5
- data/lib/samagotchi/system_prompt.rb +71 -15
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +18 -9
- data/lib/samagotchi/terminal_ui/formatting.rb +14 -0
- data/lib/samagotchi/terminal_ui.rb +17 -5
- data/lib/samagotchi/turn_flow.rb +22 -3
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/public/favicon.svg +1 -0
- data/lib/samagotchi/web/public/index.html +1 -0
- data/lib/samagotchi/web/public/refs.js +107 -15
- data/lib/samagotchi/worker.rb +1 -0
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ee2aa2b12b6482c02486b2382cc1c287c394d0a323e3bbf851948e49d0ebb2b9
|
|
4
|
+
data.tar.gz: 7bddba2fddfbcc05dfccba0777a6163963f8e238a26d14b6fbfb49b3d0bc0827
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb47d9df8beac57e413f22b01efdf8bbec31c7c9a5be400976b818d8e6dbe6931081b223568cbb3f345dee39c7f1ffc7a6b39def9e01b4033bdcf7ccda017cdd
|
|
7
|
+
data.tar.gz: 95b1879ed0ee9d093140d2dddaa9cc21c30031d45f7114b1c3311134d2f1082ad1f81480421a8da7f9cd61eb76d4d4aae65b8b29c08c0dd377dcbdab50c98f6d
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,53 @@ and commands may change between minor versions. How releases are made:
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.60.0] - 2026-10-11
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- chi web has a favicon: χ on a blue-to-violet rounded square. Safari showed a "1" monogram before.
|
|
16
|
+
- `chi --append-system-prompt FILE` (repeatable) and a config.yml `append_system_prompt:` list: a file's text goes
|
|
17
|
+
into the system prompt after AGENTS.md, in the cached part. A relative config entry is looked up where chi runs
|
|
18
|
+
(`append_system_prompt: [CLAUDE.md]`); the flag's files are saved in the session and kept by forks and continues.
|
|
19
|
+
`/stats` names the prompt's files on a `prompt files:` line.
|
|
20
|
+
- An analytics `resumed` mark on the turn record of a step-limit Continue (`resumed: true`; every other turn has
|
|
21
|
+
`resumed: false`). `continue` also marks a reminder's and a wake's turn, so `script/model_notes_report` now counts
|
|
22
|
+
Continues from `resumed`, falling back to `continue` record by record for older files. `:turn_started` and the
|
|
23
|
+
`before_turn` hook payload carry `resumed` too.
|
|
24
|
+
- A hook's or plugin's notice can be marked `fallback_for: :editor`: a line naming a file the viewer could open from
|
|
25
|
+
a ref. The web leaves it out for a viewer on this machine with `web.editor` set; a phone and the terminals show it.
|
|
26
|
+
- `ctx.prompt_files` for plugins: the files whose text is in the session's system prompt now — the AGENTS.md chain
|
|
27
|
+
and the appended files — as absolute paths in prompt order.
|
|
28
|
+
- The `agents-md` bundle, in the `core` profile (core 0.3.0: `chi update` installs it for existing core users):
|
|
29
|
+
a nested `AGENTS.md` of the session's checkout — one in a directory the session doesn't run in, which the
|
|
30
|
+
system prompt never sees — is steered into the conversation the first time a tool (`read`, `write` or
|
|
31
|
+
`edit`) touches a file under its directory, outermost first, once per session, and never re-injected after a
|
|
32
|
+
resume or a woken worker. It never stops generation or thinking, and leaves the chain's and appended
|
|
33
|
+
`AGENTS.md` files alone (`ctx.prompt_files`). Files in another repository, a nested repository or a
|
|
34
|
+
submodule are ignored. Opt out with `skip_agents_md: true`, as with the chain; `bundles: agents-md:`
|
|
35
|
+
settings: `tools`, `max_chars`. See "The agents-md bundle" in docs/plugins.md.
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
- The default step limit (`turn.max_iterations`) is 300, up from 100: most long build turns now finish in one turn
|
|
40
|
+
instead of stopping at the step-limit question. Loops are caught by the loop-guard bundle, and check-in's card
|
|
41
|
+
(at 50 tool calls, then every 50) still says a turn is long without stopping it. `--no-interrupt` stays 1000.
|
|
42
|
+
- Started in a subdirectory, chi loads every `AGENTS.md` from the top of the git work tree down to the current
|
|
43
|
+
directory, outermost first, instead of the subdirectory's replacing the root's. A further file is headed with its
|
|
44
|
+
directory ("Project specific description for pkg/:"); a session with one `AGENTS.md` gets the same prompt as before.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- A step-limit Continue no longer drops the turn's reasoning: on a chat host (`reasoning_history: turn`) the
|
|
49
|
+
continued turn sends the earlier replies' reasoning back as before the limit, and on a native host
|
|
50
|
+
(`/completion`) the prompt keeps the run's thought blocks, those before a mid-turn steer too. The model keeps its
|
|
51
|
+
thinking, and the first request after the Continue matches the last one before the limit (before the fix, a local
|
|
52
|
+
27B read most of a 17k prompt again: 24.9 s to the first token instead of 4.0 s). Continue's text is a steer, and on a chat host still starts
|
|
53
|
+
the reasoning afresh from it. After a `/model` change while the question stands, the Continue starts afresh.
|
|
54
|
+
|
|
55
|
+
Update with `chi update`: the system bundle 0.60.0, the core profile 0.3.0 (now with agents-md) and the new
|
|
56
|
+
agents-md 0.1.0 bundle.
|
|
57
|
+
|
|
11
58
|
## [0.59.0] - 2026-10-11
|
|
12
59
|
|
|
13
60
|
### Added
|
|
@@ -2576,7 +2623,8 @@ and long-lived sessions.
|
|
|
2576
2623
|
- A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
|
|
2577
2624
|
hotkey panel that send selected text or the clipboard to your sessions.
|
|
2578
2625
|
|
|
2579
|
-
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.
|
|
2626
|
+
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.60.0...HEAD
|
|
2627
|
+
[0.60.0]: https://github.com/dm1try/samagotchi/compare/v0.59.0...v0.60.0
|
|
2580
2628
|
[0.59.0]: https://github.com/dm1try/samagotchi/compare/v0.58.0...v0.59.0
|
|
2581
2629
|
[0.58.0]: https://github.com/dm1try/samagotchi/compare/v0.57.0...v0.58.0
|
|
2582
2630
|
[0.57.0]: https://github.com/dm1try/samagotchi/compare/v0.56.0...v0.57.0
|
data/README.md
CHANGED
|
@@ -76,8 +76,9 @@ It finds out whether the server is llama.cpp or OpenAI-compatible, picks the
|
|
|
76
76
|
model (or asks, when there are several), sends one test request and writes
|
|
77
77
|
the config. With a config already there, it adds a `hosts:` entry and keeps
|
|
78
78
|
the rest of the file. Then it installs the `core` bundles (loop-guard,
|
|
79
|
-
check-in, guardrails, slow-commands: the safety set for a small
|
|
80
|
-
terminal, offers `dev` (known-names, mcp, btw, skills,
|
|
79
|
+
check-in, guardrails, slow-commands, agents-md: the safety set for a small
|
|
80
|
+
local model) and, on a terminal, offers `dev` (known-names, mcp, btw, skills,
|
|
81
|
+
source-links). Edit the
|
|
81
82
|
file later as in [Configure](#configure); `chi bootstrap --help` has the
|
|
82
83
|
options.
|
|
83
84
|
|
data/bin/chi
CHANGED
|
@@ -82,7 +82,7 @@ ARGV.each do |arg|
|
|
|
82
82
|
base = arg.split("=", 2).first
|
|
83
83
|
# If dashed version is a known flag (registry or hardcoded), reject underscore variant
|
|
84
84
|
dashed = base.tr("_", "-")
|
|
85
|
-
known = %w[--prompt --resume --attach --shared --no-shared --model --thinking --memory --mute --llm-context --llm-context-apply --llm-context-budget --no-interrupt --non-interactive --verbose --no-default-input --port --open --new-token] + Samagotchi::Config.cli_entries.map(&:cli_flag)
|
|
85
|
+
known = %w[--prompt --resume --attach --shared --no-shared --model --thinking --memory --mute --append-system-prompt --llm-context --llm-context-apply --llm-context-budget --no-interrupt --non-interactive --verbose --no-default-input --port --open --new-token] + Samagotchi::Config.cli_entries.map(&:cli_flag)
|
|
86
86
|
if known.include?(dashed) || known.include?(base)
|
|
87
87
|
warn "Unknown option: #{arg} (did you mean #{dashed}?)"
|
|
88
88
|
exit 1
|
|
@@ -120,6 +120,8 @@ parser = OptionParser.new do |opts|
|
|
|
120
120
|
"before the model's; default unsets it; /thinking changes it). With chi web: the default for the sessions " \
|
|
121
121
|
"its workers run, below a session's own [env SAMAGOTCHI_THINKING_LEVEL]") { |l| options[:thinking] = l }
|
|
122
122
|
opts.on("--memory NAME", "Preload a memory entry into the system prompt (repeatable; a comma list too)") { |m| (options[:memories] ||= []) << m }
|
|
123
|
+
opts.on("--append-system-prompt FILE", "Put FILE's text into the system prompt, after AGENTS.md (repeatable; saved in the session; " \
|
|
124
|
+
"config append_system_prompt: is the baseline)") { |f| (options[:append_system_prompt] ||= []) << f }
|
|
123
125
|
opts.on("--mute NAME", "Hide a memory from this session: not in the prompt, refused by memory_read (repeatable; a comma list too)") { |m| (options[:muted] ||= []) << m }
|
|
124
126
|
opts.on("--llm-context LAYERS", "This session's own LLM context strategy: none, or layers such as stale,forget (saved in the session, " \
|
|
125
127
|
"before the model's; /llm-context changes it)") { |v| (options[:llm_context] ||= {})[:strategy] = v }
|
|
@@ -308,6 +310,23 @@ if options[:llm_context]
|
|
|
308
310
|
end
|
|
309
311
|
end
|
|
310
312
|
|
|
313
|
+
# --append-system-prompt: each file is checked here, before anything starts
|
|
314
|
+
# (the user named it, so a missing one is an error), and made absolute
|
|
315
|
+
# against this shell's cwd.
|
|
316
|
+
if options[:append_system_prompt]
|
|
317
|
+
require "samagotchi/prompt_files"
|
|
318
|
+
options[:appended_prompt_files] = options[:append_system_prompt].map do |value|
|
|
319
|
+
path, reason = Samagotchi::PromptFiles.check_cli_file(value)
|
|
320
|
+
if reason
|
|
321
|
+
warn "Error: --append-system-prompt #{value}: #{reason}"
|
|
322
|
+
exit 1
|
|
323
|
+
end
|
|
324
|
+
chars = Samagotchi::PromptFiles.large_size(path)
|
|
325
|
+
warn "Warning: --append-system-prompt #{value} is #{chars} chars; it is in every request" if chars
|
|
326
|
+
path
|
|
327
|
+
end.uniq
|
|
328
|
+
end
|
|
329
|
+
|
|
311
330
|
chi_update_hint.call
|
|
312
331
|
require "samagotchi/launch_mode"
|
|
313
332
|
launch, launch_note = if scratch
|
|
@@ -341,7 +360,8 @@ if launch == :attached
|
|
|
341
360
|
memories: options[:memories] || [],
|
|
342
361
|
muted_memories: options[:muted] || [],
|
|
343
362
|
llm_context: options[:llm_context] || {},
|
|
344
|
-
thinking: options[:thinking]
|
|
363
|
+
thinking: options[:thinking],
|
|
364
|
+
appended_prompt_files: options[:appended_prompt_files] || [])
|
|
345
365
|
rescue Samagotchi::TerminalUI::AttachLauncher::Error => e
|
|
346
366
|
warn "Error: #{e.message}"
|
|
347
367
|
exit 1
|
|
@@ -360,6 +380,7 @@ begin
|
|
|
360
380
|
muted_memories: options[:muted] || [],
|
|
361
381
|
llm_context: options[:llm_context] || {},
|
|
362
382
|
thinking: options[:thinking],
|
|
383
|
+
appended_prompt_files: options[:appended_prompt_files] || [],
|
|
363
384
|
non_interactive: options[:non_interactive],
|
|
364
385
|
model_name: options[:model],
|
|
365
386
|
scratch: scratch
|
data/docs/architecture.md
CHANGED
|
@@ -177,7 +177,8 @@ forwards the raw `KernelLoop` events unchanged (the low-level contract) and adds
|
|
|
177
177
|
higher-level events so UIs get clean turn boundaries without inferring them:
|
|
178
178
|
|
|
179
179
|
- `:turn_started` — `{ session_id:, prompt:, turn_id:, cut_after: }` (`cut_after`: the seconds a cut waits for this
|
|
180
|
-
model's thinking, `0` = never; plus `continue: true` for a continue turn, `
|
|
180
|
+
model's thinking, `0` = never; plus `continue: true` for a continue turn, `resumed: true` for a step-limit Continue,
|
|
181
|
+
`images:` with the prompt's image refs)
|
|
181
182
|
- `:turn_completed` — `{ result:, turn_summary:, display_pending: }` (`result`: the final
|
|
182
183
|
`LLM::ModelResult`; `display_pending`: `after_turn` hooks may still present the answer)
|
|
183
184
|
- `:turn_canceled` — `{ cancellation_reason:, cancelled_by:, duration_ms: }` (`cancelled_by`: the bundle or hook label that
|
|
@@ -394,7 +395,8 @@ stream with a fresh `ThoughtStreamSplitter` (Qwen's `<think>` and Gemma's
|
|
|
394
395
|
`<|channel>thought … <channel|>` are thinking, tool-call bodies are dropped
|
|
395
396
|
from `text:`). The chat loop's model turns keep their `tool_calls` and tool results their `tool_call_id`,
|
|
396
397
|
so later requests and resumed sessions pair them, and their reasoning (`thinking:`), which goes back as
|
|
397
|
-
`reasoning_content` on the running turn's replies (`reasoning_history
|
|
398
|
+
`reasoning_content` on the running turn's replies (`reasoning_history`; a step-limit Continue's
|
|
399
|
+
turn goes on from the run it resumes, `reasoning_since:`). It has its own system prompt
|
|
398
400
|
(no raw-prompt tool declarations; the tools go as JSON schemas).
|
|
399
401
|
|
|
400
402
|
`Engine#build_stream_event_handler` is the one seam both loops' streams pass
|
data/docs/cli.md
CHANGED
|
@@ -189,6 +189,7 @@ controls exit behavior (`--non-interactive`); `--resume` composes with both.
|
|
|
189
189
|
| `--thinking LEVEL` | This session's own thinking level: `off`, `low`, `medium` or `high`, saved in the session and first in the order (`default` unsets it). On `--resume` or `--attach` it is set at once, through a `/thinking` on an attached worker. With `chi web` it is instead the default for the sessions its workers run, below a session's own (as env `SAMAGOTCHI_THINKING_LEVEL` is). See "Thinking" in configuration.md. |
|
|
190
190
|
| `--profile NAME` | Prompt profile (`qwen36` or `gemma4`) for every model in this run, over config and the server's template (same as `--model-profile`, env `SAMAGOTCHI_MODEL_PROFILE`). See "Prompt profile" in configuration.md. |
|
|
191
191
|
| `--memory NAME` | Preload a memory entry into the system prompt (repeatable; a comma list too). Merged under the config.yml `memories:` baseline. Works attached: the list is stored on the session, so its worker builds the same prompt on every respawn. |
|
|
192
|
+
| `--append-system-prompt FILE` | Put `FILE`'s text into the system prompt, after AGENTS.md and before the memory indexes (repeatable; relative to the shell's directory). Added after the config.yml `append_system_prompt:` list. A missing or unreadable file is an error, exit 1. Saved in the session, so a respawned worker, a fork and a continue keep it; ignored with `--attach`/`--resume` (one line, as `--memory`). See [Appended prompt files](configuration.md#appended-prompt-files). |
|
|
192
193
|
| `--mute NAME` | Hide a memory from this session (repeatable; a comma list too): its index line is not in the prompt, `memory_read` refuses it, the identity auto-load skips it, and it is dropped from the preloads (config baseline or `--memory`). A name matches in both scopes (`gh-helper`, `project/gh-helper` and `gh-helper.md` all hide `gh-helper`). Nothing on disk changes. See [Muting a memory](#muting-a-memory). |
|
|
193
194
|
| `--llm-context LAYERS` | This session's own LLM context strategy: `none`, or layers such as `stale` or `stale,forget` (comma, space or `\|` separated). Saved in the session, before the model's `llm_context_strategy`. With `--resume` it is set on the resumed session; on an attached or resumed worker it runs as `/llm-context` before the first prompt (after `--model`'s `/model`). A value that isn't one is an error before anything starts. See "LLM context: a session's own strategy" in configuration.md. |
|
|
194
195
|
| `--llm-context-apply RULE` | This session's own apply rule: `payoff`, `next_request` or `turn_end`. |
|
|
@@ -504,7 +505,8 @@ back from the next turn on, and where that came from (`session`,
|
|
|
504
505
|
comes first; `/reasoning-history default` unsets it. It is saved and carried as
|
|
505
506
|
`/thinking`'s is, and a native host ignores it (the reply says so). A change to
|
|
506
507
|
or from `all` once an earlier reply has thinking rewrites the earlier replies;
|
|
507
|
-
`drop` ↔ `turn` costs nothing.
|
|
508
|
+
`drop` ↔ `turn` costs nothing. Under `turn` a step-limit Continue keeps the
|
|
509
|
+
reasoning of the turn it continues. `/stats` shows it on its `reasoning history:`
|
|
508
510
|
line, the web as the `reasoning` chip. See "Reasoning history" in
|
|
509
511
|
[configuration.md](configuration.md).
|
|
510
512
|
|
|
@@ -997,7 +999,7 @@ Behavior notes:
|
|
|
997
999
|
## Iteration Limit Behavior
|
|
998
1000
|
|
|
999
1001
|
- A turn's step limit (model ↔ tool rounds) is `turn.max_iterations` in config.yml (env
|
|
1000
|
-
`SAMAGOTCHI_TURN_MAX_ITERATIONS`, default `
|
|
1002
|
+
`SAMAGOTCHI_TURN_MAX_ITERATIONS`, default `300`, an integer of 1 or more). `--no-interrupt` and
|
|
1001
1003
|
`--non-interactive` turns get the larger of 1000 and it. Reminder turns follow it too.
|
|
1002
1004
|
- Tool side effects that already ran before the limit are not rolled back.
|
|
1003
1005
|
- `Samagotchi::KernelLoop#run` returns a resumable result object with the visible output plus the accumulated
|
|
@@ -1016,9 +1018,13 @@ Behavior notes:
|
|
|
1016
1018
|
- In the plain REPL (`--no-shared`) the CLI asks at the `? ` prompt, with the choices listed under it: `yes` (Enter
|
|
1017
1019
|
alone, or `/continue`) resumes, `no` stops, and `no, <explanation>` stops while keeping the reason in conversation
|
|
1018
1020
|
context. Once answered, one line stays: `? The turn ran out of iterations. Continue it? → no, too slow`.
|
|
1021
|
+
- Continue goes on with the same turn: the model keeps the reasoning (thinking) of the run it continues, on chat and
|
|
1022
|
+
native hosts, so a local server's prompt cache stays warm. Continue's text is a steer: on a chat host the reasoning
|
|
1023
|
+
starts again from it. See "Reasoning history" in [configuration.md](configuration.md).
|
|
1019
1024
|
- Stop keeps the interrupted turn's work in the conversation, as a Ctrl-C or a new prompt does, with a note for the
|
|
1020
1025
|
model that it wasn't continued (or your reason); `!rollback` still erases it.
|
|
1021
1026
|
- `--non-interactive` (`chi -p`) has nobody to ask: the turn ends there. A `chi send --wait` on a session nobody can
|
|
1022
1027
|
answer (an older worker) reports `limit` (exit 1) with how to continue it: `chi send ID -m '/continue yes'`.
|
|
1023
1028
|
- The check-in bundle's card closes as the turn ends, before the step-limit question opens, so the two never stand
|
|
1024
|
-
together; with check-in's default `after: 50` and the limit of
|
|
1029
|
+
together; with check-in's default `after: 50` and the limit of 300 a long turn shows check-in cards (at 50, 100, …)
|
|
1030
|
+
well before it.
|
data/docs/configuration.md
CHANGED
|
@@ -81,6 +81,13 @@ session:
|
|
|
81
81
|
memories:
|
|
82
82
|
# - system/user_preferences
|
|
83
83
|
# - project/feature-env-template
|
|
84
|
+
|
|
85
|
+
# Files whose text goes into the system prompt after AGENTS.md (same as
|
|
86
|
+
# --append-system-prompt, which adds to these). A relative entry is looked up
|
|
87
|
+
# in the directory chi runs in; a missing one is skipped.
|
|
88
|
+
append_system_prompt:
|
|
89
|
+
# - CLAUDE.md
|
|
90
|
+
# - ~/notes/house-rules.md
|
|
84
91
|
```
|
|
85
92
|
|
|
86
93
|
Behavior:
|
|
@@ -108,8 +115,8 @@ Besides the settings sections, the file holds maps that are read by their
|
|
|
108
115
|
own subsystems: `hosts:` (below), `models:` (see "Prompt profile" and
|
|
109
116
|
"Images"), `model_aliases:`, `hooks:` (see [Hooks](hooks.md)),
|
|
110
117
|
`guardrails:` (see [Guardrails](guardrails.md)), `bundles:` (a bundle's
|
|
111
|
-
settings for its hooks, see [Hooks: Settings](hooks.md#settings))
|
|
112
|
-
`memories
|
|
118
|
+
settings for its hooks, see [Hooks: Settings](hooks.md#settings)),
|
|
119
|
+
`memories:` and `append_system_prompt:` (see "Appended prompt files"). Their entry names (host names, model ids, aliases) are yours to
|
|
113
120
|
choose. The `memories:` list is the persistent baseline for preloaded memory entries —
|
|
114
121
|
the same name shape as `--memory` (bare name or `scope/name`), merged under
|
|
115
122
|
any per-run `--memory` values (config baseline first, deduped). A per-run
|
|
@@ -561,8 +568,13 @@ models:
|
|
|
561
568
|
reasoning as `reasoning_content`, which is what Qwen's, Gemma 4's and DeepSeek's chat templates and the hosted APIs
|
|
562
569
|
(OpenRouter takes it for DeepSeek, Qwen and other text-reasoning models) expect. The running turn starts at the
|
|
563
570
|
last message you sent (a prompt, or a steer: as the chat template counts it) and never before the turn's own start,
|
|
564
|
-
so a turn that goes on by itself (a reminder, a context wake, a
|
|
565
|
-
before it, an interrupted reply's partial thought included.
|
|
571
|
+
so a turn that goes on by itself (a reminder, a context wake, a delegate report's wake) sends nothing of the one
|
|
572
|
+
before it, an interrupted reply's partial thought included. A **step-limit Continue** is the same turn going on: it
|
|
573
|
+
keeps the reasoning of the run it continues (back to the first run of a chain of Continues), so its first request
|
|
574
|
+
matches the last one before the limit and the server's prompt cache stays warm. Continue's text, or a `!cmd` run
|
|
575
|
+
while the step-limit question stands, is a user message: the reasoning before it goes, as for any steer, and that
|
|
576
|
+
Continue reads the conversation again once (a re-prefill on a local server). After a `/model` change while the
|
|
577
|
+
question stands the Continue starts afresh (no other model's reasoning is sent).
|
|
566
578
|
- `drop` sends none (what chi did before this setting).
|
|
567
579
|
- `all` sends every reply's reasoning, earlier turns too. It sends only the field: a local template that leaves out
|
|
568
580
|
earlier turns' reasoning (Qwen's) needs `sampling: {chat_template_kwargs: {preserve_thinking: true}}` as well.
|
|
@@ -586,7 +598,8 @@ models:
|
|
|
586
598
|
| nothing thought yet, the same level, or a native host | none |
|
|
587
599
|
|
|
588
600
|
- The native loop (`/completion`) ignores it: it always keeps the running turn's reasoning, a mid-turn steer included
|
|
589
|
-
(the chat loop starts again after a steer)
|
|
601
|
+
(the chat loop starts again after a steer), and a step-limit Continue keeps the thoughts of the run it continues,
|
|
602
|
+
a mid-turn steer's earlier ones included.
|
|
590
603
|
- When a host answers a request that sent reasoning back with an HTTP 400 about reasoning, chi asks again without it,
|
|
591
604
|
sends none to that model from then on (until the worker restarts) and says so once. If the request without it is
|
|
592
605
|
refused too, the thinking fields get the same fallback ("Thinking") and the reasoning goes back on the next step.
|
|
@@ -1074,13 +1087,50 @@ The helper reads these from its launch file: after editing them run
|
|
|
1074
1087
|
If an AGENTS.md file is present in the project root, samagotchi injects its
|
|
1075
1088
|
contents into the system prompt under a "Project specific description:" section.
|
|
1076
1089
|
The project root is the top of the git work tree chi runs in (a linked
|
|
1077
|
-
worktree's own checkout), or the current directory outside a repository.
|
|
1078
|
-
|
|
1079
|
-
|
|
1090
|
+
worktree's own checkout), or the current directory outside a repository.
|
|
1091
|
+
|
|
1092
|
+
Started in a subdirectory, chi loads the chain: every AGENTS.md from the work
|
|
1093
|
+
tree top down to the current directory, outermost first. The first keeps the
|
|
1094
|
+
plain header; each further one is headed with its directory, e.g. "Project
|
|
1095
|
+
specific description for pkg/:". Outside a repository only the current
|
|
1096
|
+
directory's AGENTS.md is read. Edits are picked up by a new process or a
|
|
1097
|
+
prompt rebuild (`/model`).
|
|
1080
1098
|
|
|
1081
|
-
To skip loading AGENTS.md, set `skip_agents_md: true` at the top level of
|
|
1099
|
+
To skip loading AGENTS.md (all of the chain), set `skip_agents_md: true` at the top level of
|
|
1082
1100
|
`config.yml` (env `SAMAGOTCHI_SKIP_AGENTS_MD=true`).
|
|
1083
1101
|
|
|
1102
|
+
Nested `AGENTS.md` files (in directories the session doesn't run in) are
|
|
1103
|
+
steered into the conversation on first touch by the `agents-md` bundle
|
|
1104
|
+
([The agents-md bundle](plugins.md#the-agents-md-bundle)); `skip_agents_md`
|
|
1105
|
+
disables that steering too.
|
|
1106
|
+
|
|
1107
|
+
## Appended prompt files
|
|
1108
|
+
|
|
1109
|
+
`append_system_prompt:` (a top-level list) and `chi --append-system-prompt FILE`
|
|
1110
|
+
(repeatable) put a file's text into the system prompt right after the AGENTS.md
|
|
1111
|
+
chain and before the memory indexes, in the stable part a prompt cache keeps.
|
|
1112
|
+
Each file is one section, `Appended from <path>:`, the path relative to the
|
|
1113
|
+
work tree top when inside it, else with `~`.
|
|
1114
|
+
|
|
1115
|
+
- The config list comes first, then the flag's files; a repeat, or a file the
|
|
1116
|
+
AGENTS.md chain already holds, is left out, and so is an empty file.
|
|
1117
|
+
- A config entry: `~` is expanded, and a relative one is looked up in the
|
|
1118
|
+
directory chi runs in, so `append_system_prompt: [CLAUDE.md]` loads a
|
|
1119
|
+
project's `CLAUDE.md` wherever there is one. A missing entry is skipped
|
|
1120
|
+
without a warning. The list is read when the session's engine starts (a new
|
|
1121
|
+
process picks up an edit).
|
|
1122
|
+
- `--append-system-prompt FILE`: relative to the shell's directory. A missing,
|
|
1123
|
+
unreadable or non-file `FILE` stops chi (`Error: --append-system-prompt FILE:
|
|
1124
|
+
no such file`); above 32,000 chars it warns once (`… is N chars; it is in
|
|
1125
|
+
every request`). The files are saved in the session (`appended_prompt_files`),
|
|
1126
|
+
so a respawned worker builds the same prompt, and a fork or a continue keeps
|
|
1127
|
+
them; a delegate child doesn't. With `--attach` or `--resume` the flag is
|
|
1128
|
+
ignored with one line, as `--memory` is; a REPL `--resume` (`--no-shared`)
|
|
1129
|
+
adds them for that run only.
|
|
1130
|
+
- The files' text is read at each prompt build, as AGENTS.md's is: an edit is
|
|
1131
|
+
picked up by a new process or a rebuild (`/model`). `/stats` lists the files
|
|
1132
|
+
in the prompt on its `prompt files:` line.
|
|
1133
|
+
|
|
1084
1134
|
## LLM context: the forget layer
|
|
1085
1135
|
|
|
1086
1136
|
Experimental, off by default. With `forget` in a model's `llm_context.strategy` (next to `stale`), chi offers that
|
|
@@ -1219,8 +1269,8 @@ Every setting below takes the three forms described in
|
|
|
1219
1269
|
`config.yml`, `SAMAGOTCHI_<DOTTED_NAME>` in the environment (not for one
|
|
1220
1270
|
marked config.yml only) and, where the CLI
|
|
1221
1271
|
column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
|
|
1222
|
-
`model_aliases:`, `hooks:`, `guardrails:` rules, `bundles:`, `memories
|
|
1223
|
-
described in their own sections.
|
|
1272
|
+
`model_aliases:`, `hooks:`, `guardrails:` rules, `bundles:`, `memories:`,
|
|
1273
|
+
`append_system_prompt:`) are described in their own sections.
|
|
1224
1274
|
|
|
1225
1275
|
| Setting | Default | CLI | What it does |
|
|
1226
1276
|
|---|---|---|---|
|
|
@@ -1306,7 +1356,7 @@ described in their own sections.
|
|
|
1306
1356
|
| `retry.empty_answer` | `1` | | Times a turn asks again after an empty answer (at most 3, `0` = off). See "Llama Network Retry Behavior". |
|
|
1307
1357
|
| `steer.cut_after` | `20` | | Seconds a generation must have streamed only thinking before a message sent as a cut (`/cut TEXT`, `chi send --cut`) cuts it; other messages go in at the next step; `0` = never. `models.<key>.steer_cut_after` and `hosts.<name>.steer_cut_after` come first; see [Messages during a running turn](#messages-during-a-running-turn-steer-and-cut). |
|
|
1308
1358
|
| `models.<key>.steer_cut_after`, `hosts.<name>.steer_cut_after` | none | | A model's or host's seconds a cut waits for its thinking: whole seconds, `0` = never (e.g. a slow local thinker). `/model` shows the resolved one. See [Messages during a running turn](#messages-during-a-running-turn-steer-and-cut). |
|
|
1309
|
-
| `turn.max_iterations` | `
|
|
1359
|
+
| `turn.max_iterations` | `300` | | A turn's step limit: model ↔ tool rounds before it stops and asks to continue (an integer ≥ 1). `--no-interrupt` turns get the larger of 1000 and this. See [CLI: Iteration Limit Behavior](cli.md#iteration-limit-behavior). |
|
|
1310
1360
|
| `turn.parent_continue` | `true` | | Whether a parent agent (`chi answer`) may answer Continue to a session's step-limit question; `false`: Stop only. config.yml only: no environment variable. See [Sub-agent](sub-agent.md) and [Guardrails](guardrails.md#approvals-from-a-parent-agent). |
|
|
1311
1361
|
| `update.gem` | `true` | | `false`: `chi update` never installs a newer gem (`--no-gem` for one run). See [CLI: Updating](cli.md#updating). |
|
|
1312
1362
|
| `update.bundles` | `true` | | `false`: `chi update` leaves the shipped bundles to `chi bundle upgrade` (`--no-bundles`). |
|
data/docs/hooks.md
CHANGED
|
@@ -50,7 +50,7 @@ The plugin class must respond to `#call(event)` — duck-typed, no base class re
|
|
|
50
50
|
| Event | When it fires | Event payload |
|
|
51
51
|
|-------|--------------|---------------|
|
|
52
52
|
| `:session_start` | The first turn this chi process runs for the session (so again after `--resume`, a worker that idle-exited and woke, or a restart) | `{ type: :session_start, session_id: "..." }` |
|
|
53
|
-
| `:before_turn` | Before each turn starts | `{ type: :before_turn, session_id: "...", prompt: "..." (nil on a continue), messages: [...] (the history before this turn) }` |
|
|
53
|
+
| `:before_turn` | Before each turn starts | `{ type: :before_turn, session_id: "...", prompt: "..." (nil on a continue), resumed: true \| false (true on a step-limit Continue, which resumes the run before it; false on every other turn, a reminder's or a wake's too), messages: [...] (the history before this turn) }` |
|
|
54
54
|
| `:after_turn` | After a turn completed or was stopped once the model was asked (not after one that failed, was cut short by an interrupt signal (SIGINT), or was stopped before its `:before_turn` hooks) | `{ type: :after_turn, status: "completed" \| "canceled", present: (see [Presenting the answer](#presenting-the-answer-display-only)), messages: [...] (the conversation the turn stored; a cancelled or empty turn ends it with a `kind: turn_note` system message, and a context line is `kind: context`, see [sessions.md](sessions.md#notes-a-turn-leaves-for-the-model)) }` |
|
|
55
55
|
| `:before_generation` | Before each LLM API call (both loops) | `{ type: :before_generation, iteration: N }` |
|
|
56
56
|
| `:after_generation` | After LLM returns (both loops); not after a generation a hook cut (`stop_generation`) | `{ type: :after_generation, iteration: N, response: "...", messages: [...] (the conversation as sent) }` |
|
|
@@ -117,7 +117,7 @@ known-names)` for a bundle hook, `audit.rb (config)` for a config hook,
|
|
|
117
117
|
`turn hook` for one registered at runtime.
|
|
118
118
|
|
|
119
119
|
`event[:notify]` also takes `fallback_for:`, what the line stands in for, so
|
|
120
|
-
that a UI that already shows it can leave the line out. The
|
|
120
|
+
that a UI that already shows it can leave the line out. The main value is
|
|
121
121
|
`:display`: the line repeats what the hook's
|
|
122
122
|
[`event[:present]`](#presenting-the-answer-display-only) display shows (its
|
|
123
123
|
links), for a UI that doesn't render that display. The hook never names a UI;
|
|
@@ -125,7 +125,13 @@ each decides by what it renders. The web with markdown on (`web.markdown` and
|
|
|
125
125
|
the commonmarker gem) leaves such a line out, live and after a reload; with
|
|
126
126
|
markdown off it shows, as it does in the REPL, the attached TUI and
|
|
127
127
|
`chi -p`, which print the answer as text. The log keeps the line with
|
|
128
|
-
`fallback_for=display`.
|
|
128
|
+
`fallback_for=display`. `:editor` marks a line that names a file the viewer
|
|
129
|
+
could open from a ref in its editor: the web leaves it out for a viewer on
|
|
130
|
+
this machine with `web.editor` set, and every other UI and viewer (a phone,
|
|
131
|
+
the terminals) shows it. Name only a file the page shows as a ref (one a
|
|
132
|
+
tool row touched): a loopback viewer with `web.editor` set never sees the
|
|
133
|
+
line, so a file it can't open from a ref would be lost to it. Another value,
|
|
134
|
+
or none, shows the line everywhere.
|
|
129
135
|
Mark a line only when the display really shows all of it (source-links marks
|
|
130
136
|
its note only when the answer links every URL the note names). It needs chi
|
|
131
137
|
0.35.0: an older chi's `event[:notify]` raises `ArgumentError` on the keyword,
|
|
@@ -507,7 +513,7 @@ Notes:
|
|
|
507
513
|
- Ordering: bundle hooks fire by `(priority, bundle_name, hook_name)` (lower priority first), then plain `config.yml` hooks in registration order.
|
|
508
514
|
- Settings: a hook class with `initialize(settings = {})` gets the bundle's section of `config.yml` `bundles:` (see [Settings](#settings)).
|
|
509
515
|
- A bundle can also ship a `plugin.rb` whose `chi.on(event)` blocks are bundle hooks too, next to commands and tools; see [Plugins](plugins.md). There `ctx.notify`, `ctx.steer` and the other `ctx` helpers act as this page's `event[:notify]`… do for the event the block runs for.
|
|
510
|
-
- Shipped bundles (each in a profile: `core` or `dev`, see [Bundle profiles](memory.md#bundle-profiles-core-and-dev)): `chi bundle install guardrails` (rules, see [Guardrails](guardrails.md#the-guardrails-bundle)) and `chi bundle install known-names` (a hook, see [Guardrails](guardrails.md#the-known-names-bundle)), `chi bundle install source-links` (a hook: announces source refs, see [The source-links bundle](#the-source-links-bundle)), `chi bundle install btw` (a plugin: `/btw`, see [Plugins](plugins.md#the-btw-bundle)), `chi bundle install mcp` (a plugin: tools from MCP servers, see [Plugins](plugins.md#the-mcp-bundle)) `chi bundle install loop-guard` (a plugin: breaks tool-call loops, see [Plugins](plugins.md#the-loop-guard-bundle)), `chi bundle install check-in` (a plugin: checks on a long turn, see [Plugins](plugins.md#the-check-in-bundle)), `chi bundle install slow-commands` (a plugin: commands that ran past the execute limit are run as tasks next time, see [Plugins](plugins.md#the-slow-commands-bundle)) and `chi bundle install skills` (a plugin: `/skill`, versions of skills, see [Plugins](plugins.md#the-skills-bundle)).
|
|
516
|
+
- Shipped bundles (each in a profile: `core` or `dev`, see [Bundle profiles](memory.md#bundle-profiles-core-and-dev)): `chi bundle install guardrails` (rules, see [Guardrails](guardrails.md#the-guardrails-bundle)) and `chi bundle install known-names` (a hook, see [Guardrails](guardrails.md#the-known-names-bundle)), `chi bundle install source-links` (a hook: announces source refs, see [The source-links bundle](#the-source-links-bundle)), `chi bundle install btw` (a plugin: `/btw`, see [Plugins](plugins.md#the-btw-bundle)), `chi bundle install mcp` (a plugin: tools from MCP servers, see [Plugins](plugins.md#the-mcp-bundle)) `chi bundle install loop-guard` (a plugin: breaks tool-call loops, see [Plugins](plugins.md#the-loop-guard-bundle)), `chi bundle install check-in` (a plugin: checks on a long turn, see [Plugins](plugins.md#the-check-in-bundle)), `chi bundle install slow-commands` (a plugin: commands that ran past the execute limit are run as tasks next time, see [Plugins](plugins.md#the-slow-commands-bundle)), `chi bundle install agents-md` (a plugin: a nested AGENTS.md is steered into the conversation on the first touch under its directory, see [Plugins](plugins.md#the-agents-md-bundle)) and `chi bundle install skills` (a plugin: `/skill`, versions of skills, see [Plugins](plugins.md#the-skills-bundle)).
|
|
511
517
|
- Installing a bundle executes its hook code at `Engine` startup. Only install bundles you trust, as you would a gem. Hooks are **not** executed at install time (copy-only); they are `module_eval`'d at `Engine.new` inside per-bundle `Samagotchi::Bundles::<name>` namespaces (no top-level `require` collisions). Keep hook files side-effect-free at load time; do work in `#call` — top-level side effects (require, IO, `at_exit`, global assignment) run once per `Engine.new` (class redefinition is idempotent).
|
|
512
518
|
|
|
513
519
|
Lifecycle:
|
data/docs/internals/engine.md
CHANGED
|
@@ -16,25 +16,28 @@ Engine#run_turn → backend.complete(...) → KernelLoop#run (native) or ChatLoo
|
|
|
16
16
|
|
|
17
17
|
```
|
|
18
18
|
Engine#run_turn(session, prompt, on_event:, max_iterations:, cancel_controller:, max_tool_output_chars:,
|
|
19
|
-
pending_input:, continue:, origin:, images:, id:)
|
|
19
|
+
pending_input:, continue:, origin:, images:, id:, resumed:, resume_from:)
|
|
20
20
|
│
|
|
21
21
|
├── begin_turn(session, prompt, on_event:, cancel_controller:, origin:, continue:, id:)
|
|
22
|
+
│ # (then, on a continue, turn.resumed = resumed (a step-limit Continue) and
|
|
23
|
+
│ # turn.resume_from = resume_from (its run's start; nil: it starts cold))
|
|
22
24
|
│ # @session = session, session.status = RUNNING, used memories absorbed,
|
|
23
25
|
│ # TurnState#begin!(controller:, sink:) (a new CancellationController when none is given),
|
|
24
26
|
│ # a recap in flight invalidated, GuardrailWiring#begin_turn(origin)
|
|
25
27
|
│ # Returns a Turn {session, prompt (nil on a continue), continue, on_event, controller,
|
|
26
|
-
│ # origin, started_at, id (the caller's id:, else a new uuid)}
|
|
28
|
+
│ # origin, started_at, id (the caller's id:, else a new uuid), resumed, resume_from}
|
|
27
29
|
│
|
|
28
30
|
├── Client.swap_probe_cancel(turn.controller) # a Stop cuts this turn's /props probes
|
|
29
31
|
│
|
|
30
32
|
├── prepare_turn(turn, images)
|
|
31
33
|
│ # Emits :turn_started {session_id, prompt, turn_id, continue: true (only on a continue),
|
|
34
|
+
│ # resumed: true (only on a step-limit Continue: resumed: given),
|
|
32
35
|
│ # images (only when there are any), cut_after (the model's cut wait, s)}
|
|
33
36
|
│ # refresh_profile! (may ask the server's /props once)
|
|
34
37
|
│ # turn.settings = LLM::TurnSettings (vision, sampling, thinking; model_name is set in generate)
|
|
35
38
|
│ # announces guardrail load failures, starts and awaits plugin init tasks, applies staged tools
|
|
36
39
|
│ # fires the :session_start hook on the Engine's first turn, then the :before_turn hook
|
|
37
|
-
│ # (a frozen copy of the history,
|
|
40
|
+
│ # (a frozen copy of the history, the prompt, and resumed)
|
|
38
41
|
│ # turn_messages: system head + history + due reminders (:reminder_injected) + the user message
|
|
39
42
|
│ # Returns false when a Stop came during the probes or the init wait, else true
|
|
40
43
|
│
|
|
@@ -128,10 +131,13 @@ parses tool calls out of the generated text.
|
|
|
128
131
|
|
|
129
132
|
```
|
|
130
133
|
KernelLoop#run(messages, max_iterations:, on_stream_event:, cancel_controller:,
|
|
131
|
-
model_name:, max_tool_output_chars:, pending_input:)
|
|
134
|
+
model_name:, max_tool_output_chars:, pending_input:, reasoning_since:)
|
|
132
135
|
│
|
|
133
136
|
│ turn = start_turn(...) # turn.conversation = prepare_conversation(messages): a copy,
|
|
134
|
-
│ # old model messages without their thought blocks
|
|
137
|
+
│ # old model messages without their thought blocks, but a resumed
|
|
138
|
+
│ # run's (a step-limit Continue's reasoning_since:, #thought_floor:
|
|
139
|
+
│ # all of them, a steer merged mid-run included; only a user entry
|
|
140
|
+
│ # added after the run's last reply starts them past itself)
|
|
135
141
|
│ each iteration:
|
|
136
142
|
│ 1. Queued input (user lines, plugin steers) goes in at the boundary (Steer.inject!)
|
|
137
143
|
│ 2. Format the conversation as prompt text (Prompt.format_with_images); a context
|
|
@@ -179,8 +185,10 @@ The differences from the native loop:
|
|
|
179
185
|
`Session#reasoning_history`, `/reasoning-history`): `all` on every model message, `turn` past
|
|
180
186
|
`ChatLoop#reasoning_boundary`: the later of the last query (a `role: "user"` entry: a prompt, a steer, merged input,
|
|
181
187
|
the chat template's `last_query_index`; or a `turn_start` entry) and the Run's start (`Run`'s `@start`, the
|
|
182
|
-
conversation length at `#complete`), so a continue turn (reminder, context wake,
|
|
183
|
-
nothing of the run before.
|
|
188
|
+
conversation length at `#complete`), so a continue turn (reminder, context wake, delegate report wake) replays
|
|
189
|
+
nothing of the run before. A step-limit Continue's Run starts where the run it resumes did: `#complete`'s
|
|
190
|
+
`reasoning_since:` (the Engine's `resume_from`, checked against the messages' length in `#resumed_run_start`) is
|
|
191
|
+
the Run's `@start`. `Run#prompt_chars` counts it (`#reasoning_chars`). The native loop differs on a steer:
|
|
184
192
|
`KernelLoop#inject_pending_input!` doesn't re-sanitize, so native keeps the turn's reasoning across a mid-turn
|
|
185
193
|
steer, where the chat loop starts again (as the template does).
|
|
186
194
|
- A 400 about reasoning (`BadRequest#reasoning_refused?`) for a request that sent reasoning back asks the step again
|
|
@@ -322,7 +330,7 @@ Turn events (the main ones; `Events` in `events.rb` keeps the shared sets):
|
|
|
322
330
|
|
|
323
331
|
| Event | When | Payload |
|
|
324
332
|
|---|---|---|
|
|
325
|
-
| `:turn_started` | `prepare_turn` | `{session_id, prompt, turn_id, continue?, images?, cut_after}` |
|
|
333
|
+
| `:turn_started` | `prepare_turn` | `{session_id, prompt, turn_id, continue?, resumed?, images?, cut_after}` (`resumed`: a step-limit Continue) |
|
|
326
334
|
| `:reminder_injected` | due reminders went into the turn | `{reminders}` |
|
|
327
335
|
| `:context_status` | every request (unless `context.status` is off), the current estimate before it | `{iteration, status, usage, bucket, source}` (internals/context-telemetry.md) |
|
|
328
336
|
| `:generation_started` | a request begins | `{iteration, context_window_tokens, context_window_source, price}` (`price`: the turn's `ModelPrice#to_h`, nil without one; native adds `profile`, `profile_source`) |
|
|
@@ -18,6 +18,7 @@ Thought handling follows the Gemma guidance:
|
|
|
18
18
|
- When thinking mode is active, the model may emit internal reasoning as `<|channel>thought ... <channel|>`.
|
|
19
19
|
- Standard multi-turn: prior model thoughts are stripped from conversation history before the next turn.
|
|
20
20
|
- Function/tool-calling exception: during a single turn that includes tool calls, thoughts are not stripped between those tool-call rounds.
|
|
21
|
+
- A step-limit Continue is that same turn going on: the run it resumes keeps its thoughts (`KernelLoop#run`'s `reasoning_since:`, from the Engine's `resume_from`), from its start, a steer merged inside that run included (nothing re-sanitizes within a run, so the prompt before the limit had them); only a user entry added after the run's last reply (a `!cmd`'s output) starts them past itself. Every other turn (a prompt, a reminder, a wake) strips them as above.
|
|
21
22
|
- Final model output returned to the caller is thought-stripped.
|
|
22
23
|
- While a generation streams, the thought channel goes to the stream's `thinking:` lane, not `text:` (`ThoughtStreamSplitter.for_profile`, fresh per generation), so the UIs show it as thinking and `:generation_progress` hooks count it in `thinking_chars`.
|
|
23
24
|
|
|
@@ -31,8 +31,9 @@ right-hand column happens.
|
|
|
31
31
|
│ system identity (+ model overlay) │ /model, editing a
|
|
32
32
|
│ model notes (model_notes_* matching the model) │ memory / AGENTS.md
|
|
33
33
|
│ explicit (preloaded) memories │
|
|
34
|
-
│ AGENTS.md
|
|
35
|
-
│
|
|
34
|
+
│ AGENTS.md (root → cwd) │ (picked up by a new
|
|
35
|
+
│ appended files (append_system_prompt:, --append-system-prompt) │ process or a rebuild)
|
|
36
|
+
│ project + system memory indexes │
|
|
36
37
|
│ ◄── remote Claude: cache_control breakpoint #1 │
|
|
37
38
|
├──────────────────────────────────────────────────────────────────────────┤
|
|
38
39
|
│ SYSTEM, volatile tail (per session, least → most changing) │
|
data/docs/memory.md
CHANGED
|
@@ -269,7 +269,7 @@ profiles, meta bundles that install a set of them:
|
|
|
269
269
|
|
|
270
270
|
| profile | bundles |
|
|
271
271
|
|---|---|
|
|
272
|
-
| `core` | loop-guard, check-in, guardrails, slow-commands: the recommended safety set |
|
|
272
|
+
| `core` | loop-guard, check-in, guardrails, slow-commands, agents-md: the recommended safety set |
|
|
273
273
|
| `dev` | known-names, mcp, btw, skills, source-links, github-pr, coordinator |
|
|
274
274
|
|
|
275
275
|
`chi bootstrap` installs `core` and, on a terminal, offers `dev`. An existing
|
data/docs/plugins.md
CHANGED
|
@@ -515,7 +515,8 @@ full label, `plugin.rb (bundle my-bundle)`.
|
|
|
515
515
|
| `ctx.log` | `ctx.log.info(:event, key: value)`: debug-log records tagged `plugins`, with `bundle=<bundle>` |
|
|
516
516
|
| `ctx.messages` | the conversation, as a frozen copy, without the system prompt. While a turn runs, a session worker's (attached, web) adds that turn so far: its prompt, the model's text and the lines merged into it (no tool calls or thinking); the REPL's is the conversation before that turn |
|
|
517
517
|
| `ctx.messages_partial?` | whether `ctx.messages` leaves out a running turn (the REPL mid-turn), so a plugin can say what its answer is about |
|
|
518
|
-
| `ctx.
|
|
518
|
+
| `ctx.prompt_files` | the files whose text is in the session's system prompt now: the AGENTS.md chain (the work tree top down to the cwd) and the appended files (`append_system_prompt:`, `--append-system-prompt`); absolute paths, in prompt order, `[]` before the first build |
|
|
519
|
+
| `ctx.notify(text, level: :info, fallback_for: nil)` | one line to the user, labelled by the bundle (`my-bundle> …`). Every UI shows it, during a turn (a tool, a hook) or between turns (a command). `fallback_for: :display` marks a line that repeats the answer's display (`event[:present]`), which a UI that renders the display leaves out (`fallback_for: :editor`: a file the viewer could open from a ref in its editor): see [Hooks](hooks.md#what-a-hook-can-do-the-runtime). The keyword needs chi 0.35.0 (it raises on an older chi) |
|
|
519
520
|
| `ctx.card(title:, body: "", actions: [], level: :info, id: nil)` | a card in every UI, returning its id: see [Cards](#cards) |
|
|
520
521
|
| `ctx.ask_user(question:, options:, header: nil, allow_freeform: false)` | a single-select question through the question flow: `{selected:, freeform:, selected_indices:}`, or nil (no one to ask, cancelled, bad options) |
|
|
521
522
|
| `ctx.cancelled?` | whether the running turn was cancelled (a long tool should stop) |
|
|
@@ -1254,6 +1255,54 @@ bundles:
|
|
|
1254
1255
|
| `/slow-commands` | this project's slow commands, numbered |
|
|
1255
1256
|
| `/slow-commands forget 2` / `forget all` | drop one (a wrong entry) or all of them |
|
|
1256
1257
|
|
|
1258
|
+
## The agents-md bundle
|
|
1259
|
+
|
|
1260
|
+
`chi bundle install agents-md` (or the `core` profile) installs the bundle shipped
|
|
1261
|
+
with chi (`lib/samagotchi/bundles/agents-md/plugin.rb`): two `chi.on` hooks
|
|
1262
|
+
(`:before_turn` rebuilds the steered set, `:after_tool_call` steers), and no memory file.
|
|
1263
|
+
|
|
1264
|
+
chi's system prompt holds only the `AGENTS.md` chain from the checkout top down
|
|
1265
|
+
to the session's cwd, so an `AGENTS.md` in a directory the session doesn't run
|
|
1266
|
+
in (say `pkg/inner/` while the session runs in `pkg/`) is never seen. The
|
|
1267
|
+
bundle closes that gap in history, not in the system prompt: the first `read`,
|
|
1268
|
+
`write` or `edit` (its `tools` setting) of a file under a directory with an
|
|
1269
|
+
`AGENTS.md` steers that file into the running turn, at the loop's next
|
|
1270
|
+
boundary, as its own user message — with a first line that says which
|
|
1271
|
+
directory it belongs to:
|
|
1272
|
+
|
|
1273
|
+
```
|
|
1274
|
+
AGENTS.md for pkg/inner/ (applies to work under pkg/inner/):
|
|
1275
|
+
<content>
|
|
1276
|
+
```
|
|
1277
|
+
|
|
1278
|
+
- It steers the **outermost candidates first** (each directory from the
|
|
1279
|
+
touched file's directory up to, but not including, the checkout top), so a
|
|
1280
|
+
deep file can bring in several `AGENTS.md`s at once, outermost to nearest.
|
|
1281
|
+
- It **never re-injects**: each directory steers once per session, and a
|
|
1282
|
+
`before_turn` pass over the conversation rebuilds that set from the steers
|
|
1283
|
+
already there. A steer the model answered past (never injected) is absent,
|
|
1284
|
+
so it fires again on the next touch; a resume, a woken worker or a fork
|
|
1285
|
+
pick the set up from their messages. It never stops generation or thinking.
|
|
1286
|
+
- **Scope:** the touched file's own git root must be the session's checkout:
|
|
1287
|
+
a file in another repository, a nested repository or a submodule is
|
|
1288
|
+
ignored. Paths compare by `File.realpath`, so a symlinked cwd (a macOS
|
|
1289
|
+
`/tmp`) still matches.
|
|
1290
|
+
- Directories whose `AGENTS.md` is already in the system prompt (`ctx.prompt_files`:
|
|
1291
|
+
the chain and appended files) are skipped, as is a file at the checkout top
|
|
1292
|
+
(its `AGENTS.md` is the chain's first).
|
|
1293
|
+
|
|
1294
|
+
```yaml
|
|
1295
|
+
# config.yml
|
|
1296
|
+
bundles:
|
|
1297
|
+
agents-md:
|
|
1298
|
+
tools: [read, write, edit] # the calls that count as a touch
|
|
1299
|
+
max_chars: 16000 # the content is cut here, with a "[cut at N
|
|
1300
|
+
# of M chars: read <absolute path> for the rest]" last line
|
|
1301
|
+
```
|
|
1302
|
+
|
|
1303
|
+
`skip_agents_md: true` disables the bundle, as it does the chain's loading
|
|
1304
|
+
(see [Configuration](configuration.md#project-specific-description)).
|
|
1305
|
+
|
|
1257
1306
|
## The skills bundle
|
|
1258
1307
|
|
|
1259
1308
|
`chi bundle install skills` (or the `dev` profile) installs the bundle shipped with chi
|