samagotchi 0.179.0 → 0.180.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 +31 -1
- data/docs/bundles.md +32 -1
- data/docs/configuration.md +1 -1
- data/docs/context.md +7 -0
- data/docs/internals/background-tasks.md +2 -1
- data/docs/internals/block-renderers.md +2 -1
- data/docs/internals/bundles.md +12 -10
- data/docs/internals/web-frontend.md +63 -2
- data/docs/plugins.md +6 -2
- data/docs/testing.md +4 -0
- data/lib/samagotchi/block_renderers.rb +22 -3
- data/lib/samagotchi/bundle_command.rb +5 -1
- data/lib/samagotchi/bundle_needs.rb +1 -1
- data/lib/samagotchi/bundle_settings_check.rb +5 -2
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/context_providers.rb +6 -8
- data/lib/samagotchi/installed_bundles/dir.rb +17 -55
- data/lib/samagotchi/installed_bundles/standing.rb +23 -3
- data/lib/samagotchi/installed_bundles.rb +26 -11
- data/lib/samagotchi/memory_bundle/status.rb +8 -5
- data/lib/samagotchi/session_config.rb +15 -9
- data/lib/samagotchi/terminal_ui/attached_loop.rb +1 -1
- data/lib/samagotchi/terminal_ui/formatting.rb +13 -3
- data/lib/samagotchi/terminal_ui/join_replay.rb +1 -1
- data/lib/samagotchi/tools/task_runtime.rb +12 -3
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/public/app.js +13 -1
- data/lib/samagotchi/web/public/context_chips.js +184 -49
- data/lib/samagotchi/web/public/history_shape.js +5 -3
- data/lib/samagotchi/web/public/index.html +66 -0
- data/lib/samagotchi/web/public/peer_chip.js +171 -0
- data/lib/samagotchi/web/public/peer_data.js +119 -0
- data/lib/samagotchi/web/public/peer_exchange.js +83 -0
- data/lib/samagotchi/web/public/peer_links.js +161 -0
- data/lib/samagotchi/web/public/peer_note.js +49 -0
- data/lib/samagotchi/web/public/session_view.js +6 -1
- data/lib/samagotchi/web/public/stream_handlers.js +17 -4
- data/lib/samagotchi/web/public/turn_html.js +11 -2
- 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: '056860037a4db0a4c2ec4fb0fa92aa022024dd344e13786bdb55d7947999c572'
|
|
4
|
+
data.tar.gz: 8a3bb8f657b9b05ad682abd3e708be26ee70e8759a4e5df01a212e5fc715c292
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af64aaac919f8722c9b274984a82712d0f3c7464d78f3c6428ffb74c47f4ac3158e7fc11b21ad46df24c7452f581d5bbee9e8d97f782b5640802f7bd60037452
|
|
7
|
+
data.tar.gz: ed980f2025a4b03c1e868008f828bec79f185b6fa2682d05808a83cb94243d6b09802bfddf751a822c110582ce5849aba6aedebbc20d27746c76d3eb8011be27
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,35 @@ and commands may change between minor versions. How releases are made:
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.180.0] - 2026-11-20
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- In the web, a send to a paired peer (Claude, Codex) and its answer link to each other: the send's row says
|
|
16
|
+
"waiting 2m", "changes · answered after 6m" or "not sent" and jumps down to the answer; the answer is a bubble
|
|
17
|
+
from the peer with its verdict and summary that jumps back up to the send, chi's instruction to the model folded
|
|
18
|
+
away.
|
|
19
|
+
- In the web, a paired peer is one chip in the session bar instead of its two `-inbox`/`-outbox` chips: it says
|
|
20
|
+
paired, waiting 2m, answered (with the unread dot), can't send or answers only, and opens a popover with the
|
|
21
|
+
last exchanges (a tap jumps to the send), View latest answer, the status card and Unpair (a bottom sheet on a
|
|
22
|
+
phone).
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- The terminal shows a peer's answer note as `Claude answered · <summary>` (`Codex answered · …`) instead of `note from context claude-outbox: …`.
|
|
27
|
+
- A bundle that needs a newer chi now gets a warning for its `bundles:` section in config.yml, and
|
|
28
|
+
`--set` refuses its settings saying so, whether or not it has a plugin.
|
|
29
|
+
- A bundle's plugin, rule or script that isn't as installed is refused in one wording and one order everywhere (the
|
|
30
|
+
log, the load failures, the web's errors): "bundle NAME's plugin/FILE isn't recorded / is missing / differs from
|
|
31
|
+
the installed one (reinstall the bundle)". A rule with no recorded sha256 now says so instead of "differs", and
|
|
32
|
+
`chi bundle status NAME` shows such a plugin `[unrecorded]` instead of `[modified]`.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- A background task whose shell ends just as chi exits no longer stays marked running with its leftover process left behind.
|
|
37
|
+
- A context source from a bundle whose manifest.json doesn't read, or isn't an object, now fails its fetch with a clear
|
|
38
|
+
reason, instead of an internal error or running its command unchecked.
|
|
39
|
+
|
|
11
40
|
## [0.179.0] - 2026-11-20
|
|
12
41
|
|
|
13
42
|
### Added
|
|
@@ -6547,7 +6576,8 @@ and long-lived sessions.
|
|
|
6547
6576
|
- A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
|
|
6548
6577
|
hotkey panel that send selected text or the clipboard to your sessions.
|
|
6549
6578
|
|
|
6550
|
-
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.
|
|
6579
|
+
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.180.0...HEAD
|
|
6580
|
+
[0.180.0]: https://github.com/dm1try/samagotchi/compare/v0.179.0...v0.180.0
|
|
6551
6581
|
[0.179.0]: https://github.com/dm1try/samagotchi/compare/v0.178.0...v0.179.0
|
|
6552
6582
|
[0.178.0]: https://github.com/dm1try/samagotchi/compare/v0.177.1...v0.178.0
|
|
6553
6583
|
[0.177.1]: https://github.com/dm1try/samagotchi/compare/v0.177.0...v0.177.1
|
data/docs/bundles.md
CHANGED
|
@@ -1015,6 +1015,37 @@ Claude pairs; without one the bundle costs one tool declaration.
|
|
|
1015
1015
|
answer's note names the send (`re`); an older skill's answer has none and
|
|
1016
1016
|
works as before. The session's peer exchange log keeps sends and answer
|
|
1017
1017
|
summaries, not answer texts; a new pairing starts a new log.
|
|
1018
|
+
- **In the web** (the owner's page), a send and its answer link to each
|
|
1019
|
+
other. The send's row ("sent to Claude · validate: title") says where the
|
|
1020
|
+
exchange is: `waiting 2m`, `changes · answered after 6m` (the verdict's
|
|
1021
|
+
word: `ok`, `changes`, `unsure`), `answered after 6m`, or `not sent` (the
|
|
1022
|
+
send didn't go out); a tap on an answered one jumps down to the answer. The
|
|
1023
|
+
row's line of advice to the model is its hover instead. The answer stays
|
|
1024
|
+
where it arrived, as a bubble from Claude: "Claude answered", the send it
|
|
1025
|
+
answers (a tap jumps back up to that row, opening a folded turn), its
|
|
1026
|
+
verdict (`VERDICT OK` with "round closed" when Claude agreed), its summary,
|
|
1027
|
+
and chi's instruction to the model folded under "what chi told the agent".
|
|
1028
|
+
The newest answer also has "Read the full answer", which opens the
|
|
1029
|
+
Claude chip on the outbox's text (the outbox keeps one text, so older
|
|
1030
|
+
answers have only their summary). An answer from an older skill (no `re`)
|
|
1031
|
+
links to the last waiting validate or question; one that answers no send
|
|
1032
|
+
has no link back. A `/claude validate …` you type gets no link in the
|
|
1033
|
+
conversation (command bubbles aren't kept), its answer still names it.
|
|
1034
|
+
- **The session bar** has one chip for the pairing, `Claude · …`, first among
|
|
1035
|
+
the context chips, in place of `claude-inbox` and `claude-outbox`: `paired`;
|
|
1036
|
+
`waiting 2m` (a validate or question has no answer yet, its age the send's);
|
|
1037
|
+
`answered 3m` with the unread dot (an answer the agent hasn't read);
|
|
1038
|
+
`can't send` (the last send didn't go through: the Claude session ended or
|
|
1039
|
+
restarted, pair again from Claude, which ends it; chi web can't probe the
|
|
1040
|
+
socket, so a dead inbox shows only after a send hits it); `answers only`, dashed (no inbox: a
|
|
1041
|
+
pairing through a remote). Its popover (a bottom sheet on a phone) says how
|
|
1042
|
+
chi sends and where it answers, lists the last exchanges (time, kind ·
|
|
1043
|
+
title, `waiting 2m` / `changes · 11m` / `ok · 4m` / `answered · 4m` / `no
|
|
1044
|
+
answer expected` / `not sent`; a tap jumps to that send's row when it is in
|
|
1045
|
+
the conversation), and has View latest answer, Status card (runs `/claude`)
|
|
1046
|
+
and Unpair (detaches both sources after one confirm; if one can't be
|
|
1047
|
+
detached it stops there and says which). codex-peer's is the
|
|
1048
|
+
same, `Codex · …`.
|
|
1018
1049
|
- **The tool `claude_send(kind, title, text)`**, `kind` being `validate`,
|
|
1019
1050
|
`context` or `question`, writes one JSON line to that socket. The message
|
|
1020
1051
|
starts with a header, `chi <id> · <kind> · <title>`, and a second line,
|
|
@@ -1153,7 +1184,7 @@ session: chi sends the Codex session you work with a part of the work to
|
|
|
1153
1184
|
validate or as context, and Codex's answer comes back into chi. It is a copy
|
|
1154
1185
|
of claude-peer with the transport swapped; what differs is below, the rest
|
|
1155
1186
|
(kinds, payload files, the last send, `/codex last`, the status card, the
|
|
1156
|
-
skill install card) works the same.
|
|
1187
|
+
skill install card, the web's linked send and answer: "Codex answered") works the same.
|
|
1157
1188
|
|
|
1158
1189
|
- **Sending is `codex queue`.** `codex_send(kind, title, text)` and
|
|
1159
1190
|
`/codex validate|context <text>` run
|
data/docs/configuration.md
CHANGED
|
@@ -127,7 +127,7 @@ own subsystems: `hosts:` (below), `models:` (see "Prompt profile" and
|
|
|
127
127
|
`guardrails:` (see [Guardrails](guardrails.md)), `bundles:` (a bundle's
|
|
128
128
|
settings for its hooks, see [Hooks: Settings](hooks.md#settings); a session's own
|
|
129
129
|
`--set BUNDLE.KEY=VALUE`, for a key the bundle's manifest lists in `session_settings:`, lays over them, see
|
|
130
|
-
[Per-session settings](plugins.md#per-session-settings); a name no installed bundle has,
|
|
130
|
+
[Per-session settings](plugins.md#per-session-settings); a name no installed bundle has, a key its manifest's `settings:` rules out, or a bundle this chi is too old for (its `requires_chi`), warns at the start of the first session to find it and again only when the findings change or come back (a digest of the lines shown is stamped in `$XDG_STATE_HOME/samagotchi/bundles_warned`; the log has them from every session); `--set KEY=VALUE` does the same for a few core keys,
|
|
131
131
|
see "Per-session settings" below),
|
|
132
132
|
`memories:` and `append_system_prompt:` (see "Appended prompt files"). Their entry names (host names, model ids, aliases) are yours to
|
|
133
133
|
choose. The `memories:` list is the persistent baseline for preloaded memory entries —
|
data/docs/context.md
CHANGED
|
@@ -238,6 +238,13 @@ The web's session bar shows a chip per source (name · age; a dot when the
|
|
|
238
238
|
agent hasn't read a change, red after a failed refresh). A chip opens the
|
|
239
239
|
summary, the hint's link, the text and detach (or mute here, for a project
|
|
240
240
|
source). The web attaches nothing itself: `chi context add <URL>` does.
|
|
241
|
+
A paired peer's two sources (`claude-inbox`, `claude-outbox`) are one chip,
|
|
242
|
+
drawn first: it says how the pairing stands (paired, waiting, answered,
|
|
243
|
+
can't send, answers only) and opens the last exchanges, the outbox's text and
|
|
244
|
+
Unpair ([bundles.md](bundles.md#the-claude-peer-bundle), The session bar).
|
|
245
|
+
A peer's answer (a note with `peer`, [Peer sources](#peer-sources-the-peer-loop)) is not drawn as a context note but
|
|
246
|
+
as a bubble from the peer, linked to the send it answers
|
|
247
|
+
([bundles.md](bundles.md#the-claude-peer-bundle), In the web).
|
|
241
248
|
|
|
242
249
|
## Waking
|
|
243
250
|
|
|
@@ -36,7 +36,8 @@ Behavior:
|
|
|
36
36
|
- The exit code: the command runs after an EXIT trap that writes the shell's status to the `exit_code` file (`TaskRuntime.wrapped_shell_command`, shared with `task_create`), so `exit N`, a `set -e` failure and a trailing `\` or `|` in the command all record what the shell exited with. The trap runs wherever the shell is when it exits (a `task_create` `cwd`, or a `cd` in the command), so `task_create`'s `exit_code_path` is absolute; its `output_path` stays relative (`tmp/tasks/<id>/output.log`, opened by chi in the worker's cwd before the spawn). A command that sets its own EXIT trap replaces it, and a shell killed by a signal skips it (zsh's sh mode, on TERM, INT and KILL): `execute` still reports the shell's status, and a `task_create` task or a handed-over execute gets its code from chi's waiter while the chi that started it runs (`TaskRuntime.record_exit_status`): the exit status, or `128 + the signal` (TERM → 143), with no new `stop_reason`. A record a refresh already finished without a code in between (`failed`, `process_ended_without_exit_code` or the not-chi's-process reason) is corrected, its `finished_at` kept; a stopped task (its stop flag on disk) is never touched. `process_ended_without_exit_code` is left only when the shell wrote nothing and the chi that started it was gone too.
|
|
37
37
|
- `task_create` applies `execute`'s leftover rule (`Tools::Leftovers`, one implementation: `held?`, the grace, the group stop, the hint wording): `create_task` holds `output.log` with a shared `flock` across the spawn, and a handed-over execute's two logs are already held. When the task's shell exits and a process it started still holds the log (`yes >/dev/null &` with no `wait`), the task stays `running` (so the finish wake's watch and `task_wait` keep waiting) while the waiter of the chi that started it (`TaskRuntime.record_exit_status`) gives it 1.5 s (`LEFTOVER_GRACE_SEC`), then stops the group (TERM, 1 s, KILL; `Leftovers.stop_group`, only while the group still has members: a pgid isn't reused while it has any) and finishes the record in one write: the shell's status and exit code (the leftovers don't make it a failure) and `leftovers: "stopped"`. A holder outside the group with the group empty (a setsid'd `cmd &`, or a backgrounded `timeout N cmd &`: GNU `timeout` without `--foreground` moves itself and its command to a group of its own) is signalled nothing: `leftovers: "detached"`, left running, and the hint says so (`task_stop` can't reach it: kill it if it shouldn't run). A process holding no log (`nohup cmd >f 2>&1 &`) is left alone. `task_get`, `task_wait` (so the finish note too) and `task_list` add the hint line (`Leftovers.task_hint`), ``(a background process kept the task's log open and was stopped; to keep one running, run it in the foreground or end the command with `wait`)`` (or `was left running`), built from the same `Leftovers.hint` as execute's. One settler per task: while that waiter thread lives (`TaskRuntime.waiter_for`, in memory, this process only), a refresh here only reads a held record. With no waiter here (the chi that started it is gone, a worker that exited mid-grace, or another process reading), the next refresh that finds the shell dead and the log held settles it itself: a second look after 0.05 s (two `held?` probes at once read each other as holders), then the stop with a 0.5 s TERM grace and 0.5 s KILL wait (only of a group that still had members at the first look; one gone by the stop with nothing holding the log records no `leftovers`), so that read blocks up to ~1 s plus a `ps`. With no later reader of that cwd's tasks the leftovers run on; records already finished (an older chi's) are never revisited, and an older chi's record (its log never `flock`'d) reads as not held and settles as before. A `task_stop` during the grace stops the group (`Leftovers.stop_group`) and the record ends `stopped` (its stop flag wins over the waiter's write; in one process the two writes share a lock). Cost: one non-blocking `flock` try per log at shell exit (~0.2 ms), the grace only when something holds the log; a refresh of a running record whose shell is dead adds one `flock` try, and one `ps` only when the log is held.
|
|
38
38
|
- On a clean exit (worker teardown or a one-shot), `Engine#shutdown` calls `TaskRuntime.settle_pending!`: this process's
|
|
39
|
-
waiters whose shells are already reaped
|
|
39
|
+
waiters whose shells are already reaped (the detach thread ended, the waiter settling, or the pid gone: the detach
|
|
40
|
+
thread runs a moment after its reap) get time to finish their leftover grace and stop before chi exits. The wait
|
|
40
41
|
shares one deadline with the anytime-command joins (the later of their 3 s and ~4 s), and logs a warning if a selected waiter
|
|
41
42
|
remains. A shell still running at the snapshot, including one that exits during the join, is not waited on; a crash
|
|
42
43
|
or SIGKILL cannot wait either. With no later reader of that cwd, such leftovers can still run on.
|
|
@@ -17,7 +17,8 @@ model. The TUI is untouched: it shows a fence as source.
|
|
|
17
17
|
the URL's names go through `BlockRenderers.script_path` (membership in a listed renderer's `load` before any path is
|
|
18
18
|
made), then `InstalledBundles::Dir#file_refusal(:scripts, …)` (the check a context provider's scripts get too); a file with no recorded sha, a missing one or a changed one is 409
|
|
19
19
|
`renderer_changed`, each with its own reason. ETag + `no-cache`, as static files. A `block_renderers:` list that
|
|
20
|
-
doesn't parse is logged once per bundle and problem (each list request and file fetch reads it)
|
|
20
|
+
doesn't parse is logged once per bundle and problem (each list request and file fetch reads it); a bundle this chi is
|
|
21
|
+
too old for (`requires_chi`) draws nothing, logged once per bundle and version (`block_renderers_too_new`).
|
|
21
22
|
3. `block_watch.js` (`createBlockWatch`, made by `block_host.js`'s `createBlockHost`, wired in `app.js`; a participant's page
|
|
22
23
|
gets the core drawers only, no bundle's renderers: `block_renderers`) finds and watches the blocks; `block_host.js` is its frame drawer (`createFrameDrawer`). The watcher asks an
|
|
23
24
|
ordered list of drawers, core ones first (`inline_widgets.js` for `chi-ui`: [inline-widgets.md](inline-widgets.md)), then the frame drawer, which waits for `/api/block_renderers`;
|
data/docs/internals/bundles.md
CHANGED
|
@@ -41,8 +41,8 @@ read side, never the reverse.
|
|
|
41
41
|
| Piece | Role |
|
|
42
42
|
|---|---|
|
|
43
43
|
| `InstalledBundles` (`installed_bundles.rb`) | `.each(holding:, dir:)` (each installed bundle by name, its `Record`; one whose `manifest.json` doesn't read with `error` set, and with `holding:` only those with that key, or that dir when it doesn't read), `.claimants` (which bundles own a memory file), `.dir` (`MemoryPaths.bundles_dir`) |
|
|
44
|
-
| `InstalledBundles::Dir` (installed_bundles/dir.rb) | one bundle's `.bundles/<name>/` as the runtime reads it: `Dir.new(name:, dir:)`, `#record`, `#plugin_dir`, `#plugin_path`, `#scripts_dir`, `#guardrails_dir`, `#kept_manifest_path`, `#file_refusal(kind, file, recorded)` (the one "is this installed file as installed" check: `:plugin`, `:scripts`, `:guardrails`,
|
|
45
|
-
| `InstalledBundles::Standing`, `Refusal` (installed_bundles/standing.rb) | the usability verdict: `.standings(holding:, dir:)` (the walk, each bundle's `Standing`), `.standing(name, dir:)` (one record; a `manifest.json` that doesn't parse
|
|
44
|
+
| `InstalledBundles::Dir` (installed_bundles/dir.rb) | one bundle's `.bundles/<name>/` as the runtime reads it: `Dir.new(name:, dir:)`, `#record`, `#plugin_dir`, `#plugin_path`, `#scripts_dir`, `#guardrails_dir`, `#kept_manifest_path`, `#file_refusal(kind, file, recorded)` (the one "is this installed file as installed" check: `:plugin`, `:scripts`, `:guardrails`, one order (no sha recorded, missing, changed) and one wording, `bundle X's <folder>/<file> isn't recorded / is missing / differs from the installed one (reinstall the bundle)`, a `Refusal`). Its only state is the name and the folder; `Provenance` is one |
|
|
45
|
+
| `InstalledBundles::Standing`, `Refusal` (installed_bundles/standing.rb) | the usability verdict: `.standings(holding:, dir:)` (the walk, each bundle's `Standing`), `.standing(name, dir:)` (one record; a `manifest.json` that doesn't parse is `:unreadable`, in the walk's words), `Standing.of(name, record)`: `#refusal` is `:unreadable` (the record; `Standing.warn_unreadable` logs `bundle_unreadable` once per process per bundle and reason, whichever reader came across it, `.claimants` too) or `:too_new` (requires_chi), nil when chi may use it; none of the bundle's own files is hashed (a manifest cache miss hashes the kept `manifest.yml`, as `Manifest.of` does). A `Refusal` has `kind`, `text` and, for `:file_changed`, the `actual` and `expected` shas. Each reader keeps only its reaction (below) |
|
|
46
46
|
| `InstalledBundles::Sha` (installed_bundles/sha.rb) | the record's shas: `.recorded` (either format, `""` for none), `.of_file`, `DEV` (a dev install's `sha256:dev`), `.unchecked?`, `.matches?` |
|
|
47
47
|
| `BundleCommand` (`lib/samagotchi/bundle_command.rb`) | `chi bundle install/upgrade/uninstall/status/diff/list/build/trash/new/test/check/try` (`install --dev`: the Installer's `dev:`, links and `InstalledBundles::Sha::DEV`); runs the Installer, prints its summary, runs the conflict agent step; refuses a source already installed under another name (`installed_under_another_name?`: a git URL bundle recorded under its repo's name before the manifest named it). `upgrade` resolves its argument by `upgrade_source`: a git URL or an existing path, then a shipped name, then the bare name of an installed bundle — whose record's source it then uses (a git URL with its `#ref`, a dir or an archive that is still there), printed as `Upgrading NAME from SOURCE`; a dev record is refused with `Installer.dev_install_line`, a recorded source that is relative, empty or gone says so and asks for the path or URL of a copy (`Installer.source_gone_line`, the words `ManifestStanding` uses too). After an upgrade or uninstall that changed the bundle's plugin (or brought one in), one line names the sessions still running its old code (`LiveVersions.workers`, the ones whose worker takes a restart) and `chi sessions restart ID` for each: only the plugin stays in memory, since a bundle's rules reload by their stamp and its scripts run from the replaced files. |
|
|
48
48
|
| `BundleCommand::Check` (bundle_command/check.rb) | `chi bundle check [PATH] [--fix] [--set K=V]`: a bundle being written, checked as an install takes it (docs/cli.md lists the codes); parses the manifest from `Shas.parseable` (a placeholder sha is a `sha` finding, not a YAML error), reads the user's installed bundles only for `clash`, and installs and loads through `Testing::Install` in a `Testing::Sandbox` with `force: true`, the log's echoes swallowed |
|
|
@@ -95,7 +95,7 @@ Readers of the installed state ask one verdict and keep only their reaction. The
|
|
|
95
95
|
`InstalledBundles.standings` (the walk) or `.standing(name)` (one record): a `Standing` whose `refusal` is
|
|
96
96
|
`:unreadable` (the record doesn't read) or `:too_new` (requires_chi), then, for a file chi loads, runs, serves or
|
|
97
97
|
reads, `InstalledBundles::Dir#file_refusal(:plugin | :scripts | :guardrails, file, recorded)` (`:file_missing`,
|
|
98
|
-
`:file_unrecorded`, `:file_changed`;
|
|
98
|
+
`:file_unrecorded`, `:file_changed`; checked not recorded, then missing, then changed, for every kind).
|
|
99
99
|
What each does with a refusal stays its own:
|
|
100
100
|
|
|
101
101
|
| Reader | `:unreadable` | `:too_new` | a file's refusal |
|
|
@@ -103,15 +103,17 @@ What each does with a refusal stays its own:
|
|
|
103
103
|
| `Plugin::Loader.load_bundle` | a failure that fails closed (required) unless its kept `manifest.yml` reads and names no required plugin (`#unreadable_required?`) | a failure (required for a guardrail plugin) | a failure, the refusal's text |
|
|
104
104
|
| `GuardrailWiring#bundle_rules` | a required failure | `#too_new_bundle_rules` (the rules loaded before stay) | a required failure per rule file |
|
|
105
105
|
| `ContextProviders.resolve` / `.any?` | skipped | skipped, `providers_too_new` logged once (only when it declares providers) | n/a |
|
|
106
|
-
| `ContextProviders.command_for` |
|
|
107
|
-
| `BlockRenderers.for_installed` / `.script_path` | lists none | skipped | `Invalid` |
|
|
108
|
-
| `SessionConfig.availability` | left out | a note,
|
|
109
|
-
| `BundleSettingsCheck.warnings
|
|
110
|
-
| `
|
|
106
|
+
| `ContextProviders.command_for` | `Invalid` | `Invalid` | `Invalid`, per recorded script |
|
|
107
|
+
| `BlockRenderers.for_installed` / `.script_path` | lists none | skipped, `block_renderers_too_new` logged once (only when it declares renderers) | `Invalid` |
|
|
108
|
+
| `SessionConfig.availability` | left out | a note, plugin or not (`SessionConfig.unusable`) | a note |
|
|
109
|
+
| `BundleSettingsCheck.warnings` | skipped | one warning (`SessionConfig.unusable`), its keys unchecked | n/a |
|
|
110
|
+
| `BundleNeeds.entry_markers`, `MemoryCommand.entries` | skipped | still read (its memories are) | n/a |
|
|
111
|
+
| `MemoryBundle::Status.plugin_status` | n/a | `requires_failure` | `unrecorded`, `missing` or `modified` |
|
|
111
112
|
|
|
112
113
|
`InstalledBundles.claimants` skips an unreadable record off the record itself (`Record#error?`), so a claimant
|
|
113
|
-
check reads no manifest.
|
|
114
|
-
|
|
114
|
+
check reads no manifest. Each skip is also logged once per process: an unreadable record by the verdict
|
|
115
|
+
(`bundle_unreadable`), a too-new bundle by the reader that skips it; every once-per-process log is a Set under a Mutex,
|
|
116
|
+
like `GuardrailWiring`'s kept-rules notice.
|
|
115
117
|
They read shas and state off the record, and
|
|
116
118
|
manifest data (requires_chi, needs, providers, renderers, settings) through `InstalledBundles::Record#manifest`
|
|
117
119
|
(`InstalledBundles::Manifest`: the kept `manifest.yml` when its sha holds, else the record's mirror), as do `SessionConfig`, `BundleSettingsCheck`, `BlockRenderers`, `Status`, `BundleCommand`'s
|
|
@@ -31,7 +31,7 @@ page. A factory dep a new version stops passing is the same hazard the other way
|
|
|
31
31
|
out of `send_turn.js`, `session_actions.js` and `lists_view.js`); a page loaded before keeps all its old modules
|
|
32
32
|
until a reload, so the risk is a mixed cache, not an open tab. `answer_fold.js`, `details_motion.js`,
|
|
33
33
|
`turn_range.js`, `history_reveal.js`, `latest.js`, `session_payload.js`, `method_api.js`, `session_store.js`,
|
|
34
|
-
`session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (Deleting a chained session, below), `running_tasks.js` (a delete's or archive's 409 `tasks_running`: the tasks' line, the second confirm, the toast's suffix; DOM-free, so `stop_sheet.js` and `delete_sheet.js` share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
|
|
34
|
+
`session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (Deleting a chained session, below), `running_tasks.js` (a delete's or archive's 409 `tasks_running`: the tasks' line, the second confirm, the toast's suffix; DOM-free, so `stop_sheet.js` and `delete_sheet.js` share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
|
|
35
35
|
|
|
36
36
|
## One page, every viewer
|
|
37
37
|
|
|
@@ -675,6 +675,67 @@ forgetSession` (a switch, the start page, + New, a deleted or archived session)
|
|
|
675
675
|
`#center` is never left inert, whatever the next session's GET does; close gives focus back to where it was at the
|
|
676
676
|
open (not after a jump or a reset). Styles: `ws_preview.css`.
|
|
677
677
|
|
|
678
|
+
## The peer exchange
|
|
679
|
+
|
|
680
|
+
A send to a paired peer (claude-peer's `claude_send`, codex-peer's) and the peer's answer, linked in the owner's
|
|
681
|
+
conversation ([bundles.md](../bundles.md#the-claude-peer-bundle), In the web). The data is the server's: `GET
|
|
682
|
+
/api/sessions/:id/peers` (owner only, read from the session's files: `PeerExchanges.joined` over
|
|
683
|
+
`peer_exchanges.jsonl`, the peers from its pushed sources) gives each peer's last exchanges, newest first, with their
|
|
684
|
+
`state` (waiting, answered, none_expected, failed) and an answer's `serial` and `verdict`; a send row carries the
|
|
685
|
+
send's id as its `peer` ref, a peer's answer note its `peer` hash (`peer`, `label`, `re`, `summary`, `serial`,
|
|
686
|
+
`verdict`, `agreed`). The page joins and parses nothing.
|
|
687
|
+
|
|
688
|
+
- `peer_data.js` (state): `listPeers` (an older chi web's 404 is an empty list) and `createPeers`, the page's one model
|
|
689
|
+
of the open session's peers (app.js `peers`, made only with the `context` capability, so a participant's page has
|
|
690
|
+
none): its own closure holds the last read for the open session (`createLatest`: an older read, or one for a
|
|
691
|
+
session left, is dropped); `exchange(id)` (a resend's newest), `answer(name, serial, re)`. It reads only when the
|
|
692
|
+
session has a peer (a context row with `peer`, a drawn send or answer), so a session without one makes no request.
|
|
693
|
+
Read again on: the session drawn (`session_view.js renderSessionView`, through `peerLinks.drawn()`), a
|
|
694
|
+
`context_added` with `peer`, a `tool_call_completed` with a peer ref, `command_ran` (a `/claude validate`), window
|
|
695
|
+
focus, and a 60 s tick while an exchange waits; a `turn_completed` redraws without a fetch (`touch()`) (one interval, cleared with the session: `forgetSession` →
|
|
696
|
+
`peerLinks.reset()`). The peer chips read the same model: its `onChange` also calls `contextChips.peersChanged()`, and
|
|
697
|
+
the chips' own load (a session opened: `session_sync.js` empties the chips first, so the conversation's `hasPeer`
|
|
698
|
+
may find no peer yet) or a peer new among their rows calls `peers.refresh()`.
|
|
699
|
+
- `peer_exchange.js` (pure): `peerRef(row)`, `stateText` (long and the phone's short words, both drawn; CSS picks),
|
|
700
|
+
`pillTemplate` (a button with ↓ once answered, a span otherwise; its title the row's output text).
|
|
701
|
+
- `peer_note.js`: `peerNoteTemplate`, which `turn_html.js noteBubbleTemplate` draws a note with `peer` as. It keeps
|
|
702
|
+
what an opening note has (`bubble note`, `turn-start`, `data-opening-id`, the time title), so `TURN_PROMPT`,
|
|
703
|
+
`card_stamps.js`, `stage_handoff.js OPENING`, `reload_check.js` and `revise_stack.js` (its `.note-text` is the
|
|
704
|
+
summary) read it as any wake note.
|
|
705
|
+
- **The slot idiom.** Finished rows are never drawn again and a reload makes them anew, so what arrives later is
|
|
706
|
+
drawn into empty slots the templates leave: a send row's `<span class="peer-slot" data-peer-ref>` after its params
|
|
707
|
+
(`turn_html.js toolRowInnerTemplate`; the row's output line isn't drawn on a send that didn't fail, its text the
|
|
708
|
+
slot's title), an answer's ↑ (`.peer-up-slot`) and "Read the full answer" (`.peer-full-slot`), each marked
|
|
709
|
+
`data-peer-slot`, which `history_shape.js` leaves out (an offscreen reload has no model). `peer_links.js` is the
|
|
710
|
+
controller: on the model's `onChange` and after each session draw it renders, with lit, the pill into every slot in
|
|
711
|
+
the history and the stage (two rows of one id show the same newest exchange; an id the read doesn't have reads "not
|
|
712
|
+
sent" when its row failed, or once its turn has ended when its peer's list is under the server's cap of 20
|
|
713
|
+
(`EXCHANGES_CAP`) or holds a send drawn before it; else it is unknown and gets no pill, as are the sends of a peer
|
|
714
|
+
the read doesn't name), the ↑ into each answer (none for an answer no send claims) and "Read the full
|
|
715
|
+
answer" into the last answer of each source only. Its one delegated click handler on the turn roots does the jumps,
|
|
716
|
+
buttons, never an `href` (the page routes by its hash): ↓ `revealInHistory` + `scrollIntoView` on the answer; ↑
|
|
717
|
+
`refs.js showRow` on the last row of that id before the answer (its `ref:reveal` opens a folded step or the stage's
|
|
718
|
+
cloud); focus moves to the target (`tabindex="-1"`). "Read the full answer" calls `context_chips.js showText(name)`,
|
|
719
|
+
which opens that source's chip popover on its text in a task of its own (the click's way to the document would close
|
|
720
|
+
it); a peer's outbox opens its peer chip.
|
|
721
|
+
- `peer_chip.js` (pure): a paired peer in the session bar. `peerGroups(rows)` splits GET …/context's rows into the
|
|
722
|
+
peers (rows with `peer` and `leg`, per peer `{key: "peer:<name>", name, label, inbox, outbox}`; a muted leg stays in
|
|
723
|
+
its group but counts as absent; a group with no live leg isn't drawn) and the ordinary rows. `peerChipModel` is the
|
|
724
|
+
chip, the first state that applies: answers only (no inbox), can't send (the newest send `failed`, and the inbox not pushed since: pairing again pushes it, so its row's
|
|
725
|
+
`fetched_at` past the failed send's time ends it, `cantSend`), waiting (the
|
|
726
|
+
newest validate/question `waiting`, its age the send's), answered (the outbox unread, with the dot), paired. A peer
|
|
727
|
+
the read doesn't name, an older chi web or a send not in the list is never "can't send": only the server's `failed`
|
|
728
|
+
is. `peerPopoverTemplate` is its popover (scene 2 of the design): the two ways, the last 8 sends with
|
|
729
|
+
`exchangeState`'s words, View latest answer, Status card (`peerStatusCommand`: `/<name>` when the session lists it)
|
|
730
|
+
and Unpair. `context_chips.js` draws it: its chips are keyed (`data-name`: a source's name, a peer's
|
|
731
|
+
`peer:<name>`), peer chips first; an open popover stays while its key is among the drawn chips; View latest answer
|
|
732
|
+
reads the outbox, Unpair confirms once and detaches the outbox, then the inbox (a leg that fails names itself in a toast and stops
|
|
733
|
+
it, so a half unpair never reads "answers only"); after a detach or Unpair that took the focused chip, focus goes to
|
|
734
|
+
the strip's first chip, else the composer (`focusAway`); an
|
|
735
|
+
exchange row is a button only when its send's row is drawn (`peerLinks.hasSend`) and jumps there
|
|
736
|
+
(`peerLinks.showSend`) after closing the popover. Under 600 px the peer popover is a bottom sheet (`sheetPlace`);
|
|
737
|
+
ordinary chips' popovers stay at their chip.
|
|
738
|
+
|
|
678
739
|
## Stale answers
|
|
679
740
|
|
|
680
741
|
The page switches sessions, reopens a popover or asks again while a fetch is out. An answer for the old ask must be
|
|
@@ -685,7 +746,7 @@ dropped. **`latest.js`** is the guard:
|
|
|
685
746
|
- `createLatest(get)`: `begin()` gives a guard that also goes stale when a newer ask begins; `drop()` makes every
|
|
686
747
|
ask out stale (a close, a reset). For a list that is re-read.
|
|
687
748
|
|
|
688
|
-
On it: `context_chips.js`, `project_picker.js`, `participants_panel.js` (`load`), `cards_place.js`
|
|
749
|
+
On it: `context_chips.js`, `peer_data.js`, `project_picker.js`, `participants_panel.js` (`load`), `cards_place.js`
|
|
689
750
|
(`refreshCardBodies`), `stream_handlers.js` (`answer_display`), `working_set_view.js` (`fetchServer`), `ws_peek.js` and `ws_reader.js` (an item's timeline), the
|
|
690
751
|
turn-end re-reads (`session_view.js` `readTurnEnd`, app.js's `refreshTimingFromSession`, `mergeTurnTiming`) and app.js's init-row timers. Still by hand
|
|
691
752
|
(the id decides more than "drop it"): `session_sync.js` `resync`/`retryResync` (the re-read budget, `resyncAgain`), the stream's
|
data/docs/plugins.md
CHANGED
|
@@ -927,7 +927,7 @@ A bundle's settings are config.yml's, for every session. A setting a session may
|
|
|
927
927
|
say) is one the manifest lists in `session_settings:`; `chi --set BUNDLE.KEY=VALUE` and `chi send --new --set …`
|
|
928
928
|
(which also take a few core keys, `--set recap.enabled=false`: see
|
|
929
929
|
[Per-session settings](configuration.md#per-session-settings)) then give it to a new session, saved with it (a respawn, a fork and a continued link keep it; a delegate child
|
|
930
|
-
doesn't). chi refuses a bundle that isn't installed (or whose plugin doesn't load) and a key the manifest doesn't
|
|
930
|
+
doesn't). chi refuses a bundle that isn't installed (or that needs a newer chi, or whose plugin doesn't load) and a key the manifest doesn't
|
|
931
931
|
list, so a typo isn't saved. A manifest that types a key (`session_settings: {cap: number}`: `number`, which
|
|
932
932
|
takes off too, `boolean`, `string`, or `any`) gets only a value of that type: `--set my-bundle.cap=five` is refused,
|
|
933
933
|
exit 2, as a key it doesn't list is (a mapping needs a chi newer than 0.91.0). Values are typed simply: an integer (`3`, `-1`) or a decimal (`2.5`, `.5`, `1e1`)
|
|
@@ -1678,7 +1678,11 @@ A plugin is Ruby code that runs inside chi with your permissions.
|
|
|
1678
1678
|
gem.
|
|
1679
1679
|
|
|
1680
1680
|
- The sha256 is an integrity check, not proof of who wrote the file. A file
|
|
1681
|
-
edited after install is not loaded until you reinstall the bundle
|
|
1681
|
+
edited after install is not loaded until you reinstall the bundle: the plugin,
|
|
1682
|
+
a rule or a script that isn't recorded, is missing or changed is refused in one
|
|
1683
|
+
wording, checked in that order (`bundle NAME's plugin/plugin.rb differs from
|
|
1684
|
+
the installed one (reinstall the bundle)`), and `chi bundle status NAME` shows
|
|
1685
|
+
the plugin `[unrecorded]`, `[missing]` or `[modified]`. A
|
|
1682
1686
|
`--dev` install skips that check for its own bundle: its files are the
|
|
1683
1687
|
source directory's, and an edit loads at the next start.
|
|
1684
1688
|
- Install only copies the file (`--dev` links it). The code first runs at the
|
data/docs/testing.md
CHANGED
|
@@ -308,6 +308,10 @@ group and also answers them as module calls (`SpecWaiting.pop!`, for a stubbed l
|
|
|
308
308
|
- `time_bound(seconds, below: nil)`: a wall-clock upper bound, scaled and kept under `below:` (rule 5).
|
|
309
309
|
- `eventually(timeout: 5) { expect(…) }` (spec only) retries until the expectations hold, then re-raises the last
|
|
310
310
|
failure prefixed `still failing after 5 s:`, so the matcher's own expected/got is in the message.
|
|
311
|
+
- `gone_soon?(pid, group: false, timeout: 2)` (spec only): "stopped" after a stop returned, a pid (or with
|
|
312
|
+
`group: true` its group) gone within 2 s. Never an immediate `kill(0)`: a stopped process can answer it for a
|
|
313
|
+
moment (on Linux a dying process drops its `flock` before it is reaped, and `Leftovers.stop_group` returns on the
|
|
314
|
+
log's release).
|
|
311
315
|
|
|
312
316
|
One formatter builds the failure text of `wait_for`, `join!` (which adds "to finish") and `pop!`:
|
|
313
317
|
|
|
@@ -36,7 +36,8 @@ module Samagotchi
|
|
|
36
36
|
# Languages core draws itself: a bundle's renderer for one would be a
|
|
37
37
|
# second drawer for the same block.
|
|
38
38
|
RESERVED = [InlineWidgets::LANG].freeze
|
|
39
|
-
#
|
|
39
|
+
# What .renderers and .too_new? have logged in this process: [bundle,
|
|
40
|
+
# problem] pairs, and [bundle, version, refusal] for a bundle too new.
|
|
40
41
|
WARNED = Set.new
|
|
41
42
|
WARNED_LOCK = Mutex.new
|
|
42
43
|
|
|
@@ -77,12 +78,13 @@ module Samagotchi
|
|
|
77
78
|
|
|
78
79
|
# What the installed bundles draw: the first bundle by name wins a
|
|
79
80
|
# language. A bundle whose requires_chi this chi doesn't meet, or whose list
|
|
80
|
-
# doesn't parse
|
|
81
|
+
# doesn't parse, is skipped (each logged once); a record that doesn't read
|
|
82
|
+
# lists none.
|
|
81
83
|
# @return [Array<Installed>]
|
|
82
84
|
def for_installed
|
|
83
85
|
taken = {}
|
|
84
86
|
InstalledBundles.standings do |standing|
|
|
85
|
-
next if
|
|
87
|
+
next if too_new?(standing)
|
|
86
88
|
|
|
87
89
|
bundle = standing.name
|
|
88
90
|
renderers(bundle, standing.record.manifest).each do |renderer|
|
|
@@ -109,6 +111,23 @@ module Samagotchi
|
|
|
109
111
|
File.join(installed.scripts_dir, file)
|
|
110
112
|
end
|
|
111
113
|
|
|
114
|
+
# A bundle this chi is too old for (the verdict's :too_new) draws
|
|
115
|
+
# nothing: skip it, and say so once per process per bundle and version,
|
|
116
|
+
# only when it declares renderers (as ContextProviders.too_new? does).
|
|
117
|
+
# @param standing [InstalledBundles::Standing]
|
|
118
|
+
def too_new?(standing)
|
|
119
|
+
return false unless standing.too_new?
|
|
120
|
+
|
|
121
|
+
manifest = standing.record.manifest
|
|
122
|
+
if manifest.block_renderers? &&
|
|
123
|
+
WARNED_LOCK.synchronize { WARNED.add?([standing.name, manifest.version.to_s, standing.refusal.text]) }
|
|
124
|
+
Log.warn(:web, "block_renderers_too_new", bundle: standing.name, version: manifest.version.to_s,
|
|
125
|
+
requires_chi: manifest.requires_chi.to_s, msg: standing.refusal.text)
|
|
126
|
+
end
|
|
127
|
+
true
|
|
128
|
+
end
|
|
129
|
+
private_class_method :too_new?
|
|
130
|
+
|
|
112
131
|
# Its parsed renderers; a kept list that doesn't parse is the record's
|
|
113
132
|
# mirror, else none. Logged once per bundle and problem: this runs on each
|
|
114
133
|
# list request and each renderer file fetch.
|
|
@@ -109,6 +109,10 @@ module Samagotchi
|
|
|
109
109
|
STATUS_HELP = "Usage: chi bundle status [<bundle>]"
|
|
110
110
|
DIFF_HELP = "Usage: chi bundle diff <bundle> [file]"
|
|
111
111
|
LIST_HELP = "Usage: chi bundle list"
|
|
112
|
+
# What `chi bundle status NAME` says after a plugin's state
|
|
113
|
+
# (MemoryBundle::Status.plugin_status) that keeps it from loading.
|
|
114
|
+
PLUGIN_NOTES = { "modified" => " (edited after install: not loaded; reinstall the bundle)",
|
|
115
|
+
"unrecorded" => " (no sha256 recorded: not loaded; reinstall the bundle)" }.freeze
|
|
112
116
|
|
|
113
117
|
# The subcommands' flags: --help only; a word not starting with -- is
|
|
114
118
|
# a positional (install's source, -h included). --scope takes whatever
|
|
@@ -584,7 +588,7 @@ module Samagotchi
|
|
|
584
588
|
print_assets("Rules", st.rules, " (edited after install: not loaded; reinstall the bundle)")
|
|
585
589
|
print_assets("Scripts", st.scripts, " (edited after install: the next install replaces it, a copy kept in the trash)")
|
|
586
590
|
if (plugin = st.plugin)
|
|
587
|
-
note = plugin[:state]
|
|
591
|
+
note = PLUGIN_NOTES.fetch(plugin[:state], "")
|
|
588
592
|
@stdout.puts " Plugin: #{plugin[:file]} [#{plugin[:state]}]#{note}"
|
|
589
593
|
@stdout.puts " requires_chi: #{plugin[:requires_chi]}" if plugin[:requires_chi]
|
|
590
594
|
@stdout.puts " not loaded: #{plugin[:requires_failure]}" if plugin[:requires_failure]
|
|
@@ -66,7 +66,7 @@ module Samagotchi
|
|
|
66
66
|
def self.entry_markers(scope, path:, bundles_dir:)
|
|
67
67
|
InstalledBundles.standings(dir: bundles_dir).each_with_object({}) do |standing, acc|
|
|
68
68
|
bundle = standing.record
|
|
69
|
-
# A bundle too new for this chi keeps its markers: its memories are read
|
|
69
|
+
# A bundle too new for this chi keeps its markers: its memories are read.
|
|
70
70
|
next if standing.unreadable? || bundle.effective_scope != scope.to_s
|
|
71
71
|
|
|
72
72
|
needs = bundle.manifest.needs
|
|
@@ -14,7 +14,8 @@ module Samagotchi
|
|
|
14
14
|
# value's type a manifest's settings: rules out. A config file only warns:
|
|
15
15
|
# the rest of it still runs, and `chi --set` is what refuses
|
|
16
16
|
# (SessionConfig.check!, in the same words). A manifest with no settings:
|
|
17
|
-
# (a record from before them too) has its keys left alone
|
|
17
|
+
# (a record from before them too) has its keys left alone; one this chi is
|
|
18
|
+
# too old for (requires_chi) gets one line saying why. A digest of the
|
|
18
19
|
# lines last shown is stamped in $XDG_STATE_HOME/samagotchi/bundles_warned.
|
|
19
20
|
module BundleSettingsCheck
|
|
20
21
|
STAMP_FILE = "bundles_warned"
|
|
@@ -30,8 +31,10 @@ module Samagotchi
|
|
|
30
31
|
section.flat_map do |name, values|
|
|
31
32
|
standing = installed[name]
|
|
32
33
|
next ["config.yml bundles: #{name}: #{SessionConfig.no_installed_bundle(name)}#{near(name, installed.keys)}"] unless standing
|
|
33
|
-
# A bundle too new for this chi is still checked (the plan's D1).
|
|
34
34
|
next [] if standing.unreadable?
|
|
35
|
+
# One this chi is too old for isn't used: its keys aren't checked
|
|
36
|
+
# against a manifest this chi may not read right.
|
|
37
|
+
next ["config.yml bundles: #{name}: #{SessionConfig.unusable(name, standing.refusal.text)}"] if standing.too_new?
|
|
35
38
|
|
|
36
39
|
record_warnings(standing.record.manifest, values)
|
|
37
40
|
end
|
|
@@ -151,21 +151,19 @@ module Samagotchi
|
|
|
151
151
|
# installed (they run outside the guardrails gate, as a plugin loads:
|
|
152
152
|
# checked the same way).
|
|
153
153
|
# @return [String]
|
|
154
|
-
# @raise [Invalid] the bundle is gone,
|
|
155
|
-
#
|
|
156
|
-
#
|
|
157
|
-
# @raise [JSON::ParserError] the bundle's manifest.json doesn't parse (the
|
|
158
|
-
# plan's D7: kept as it is). One that parses but isn't an object reads
|
|
159
|
-
# as a record with no scripts, and the command runs (D8: kept too)
|
|
154
|
+
# @raise [Invalid] the bundle is gone, its manifest.json doesn't read,
|
|
155
|
+
# this chi doesn't meet its requires_chi, or a script is unrecorded,
|
|
156
|
+
# gone or changed (InstalledBundles::Dir#file_refusal)
|
|
160
157
|
def command_for(source)
|
|
161
158
|
return source.cmd unless source.provider
|
|
162
159
|
|
|
163
160
|
standing = InstalledBundles.standing(source.provider)
|
|
164
161
|
raise Invalid, "bundle #{source.provider} isn't installed" unless standing
|
|
165
162
|
|
|
166
|
-
# Its
|
|
163
|
+
# Its record doesn't read (nothing to check its scripts against), or
|
|
164
|
+
# its bundle is too new for this chi (installed with --force, or chi
|
|
167
165
|
# was downgraded): its script won't run, as its plugin wouldn't load.
|
|
168
|
-
raise Invalid, "bundle #{source.provider}: #{standing.refusal.text}"
|
|
166
|
+
raise Invalid, "bundle #{source.provider}: #{standing.refusal.text}" unless standing.usable?
|
|
169
167
|
|
|
170
168
|
installed = InstalledBundles::Dir.new(name: source.provider)
|
|
171
169
|
standing.record.scripts.each do |file, sha|
|
|
@@ -12,6 +12,9 @@ module Samagotchi
|
|
|
12
12
|
# manifest.yml are. Its only state is the name and the folder; writing
|
|
13
13
|
# the record is MemoryBundle::Provenance's (a Dir too).
|
|
14
14
|
class Dir
|
|
15
|
+
# Each kind of file Dir#file_refusal checks, and its folder.
|
|
16
|
+
FOLDERS = { plugin: "plugin", scripts: "scripts", guardrails: "guardrails" }.freeze
|
|
17
|
+
|
|
15
18
|
attr_reader :name, :bundle_dir
|
|
16
19
|
|
|
17
20
|
# @param dir [String] the bundles dir (InstalledBundles.dir by default)
|
|
@@ -52,77 +55,36 @@ module Samagotchi
|
|
|
52
55
|
# installed: the one "is this file as installed" check of what chi loads
|
|
53
56
|
# (the plugin), runs (a provider's scripts), serves (a renderer's
|
|
54
57
|
# scripts) or reads (the rules). A --dev install's links pass. Hashes
|
|
55
|
-
# only the file asked about.
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
# :scripts no sha recorded, then missing, then changed
|
|
59
|
-
# :guardrails missing, then changed (no sha recorded reads as changed)
|
|
58
|
+
# only the file asked about. One order and one wording for every kind:
|
|
59
|
+
# no sha recorded, then missing, then changed, each "bundle X's
|
|
60
|
+
# <folder>/<file> … (reinstall the bundle)".
|
|
60
61
|
# @param kind [Symbol] :plugin, :scripts or :guardrails
|
|
61
62
|
# @param file [String, nil] its name in that folder (nil: a plugin the
|
|
62
63
|
# record names no file of, which is missing)
|
|
63
64
|
# @param recorded [String, nil] the record's sha256 for it
|
|
64
65
|
# @return [Refusal, nil]
|
|
65
66
|
def file_refusal(kind, file, recorded)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
when :scripts then script_refusal(file, recorded)
|
|
69
|
-
when :guardrails then rules_refusal(file, recorded)
|
|
70
|
-
else raise ArgumentError, "no installed files of kind #{kind.inspect}"
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
# The installed bundle's record, nil when it isn't installed.
|
|
75
|
-
# @return [Record, nil]
|
|
76
|
-
# @raise [JSON::ParserError] manifest.json doesn't parse
|
|
77
|
-
def record
|
|
78
|
-
Record.read(@name, File.join(@bundle_dir, "manifest.json"))
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
private
|
|
82
|
-
|
|
83
|
-
def plugin_refusal(file, recorded)
|
|
84
|
-
path = file && File.join(plugin_dir, file)
|
|
85
|
-
return Refusal.new(kind: :file_missing, text: "the file is missing") unless path && File.file?(path)
|
|
86
|
-
return nil if Sha.unchecked?(recorded)
|
|
87
|
-
|
|
67
|
+
folder = FOLDERS.fetch(kind) { raise ArgumentError, "no installed files of kind #{kind.inspect}" }
|
|
68
|
+
what = "bundle #{@name}'s #{folder}#{"/#{file}" if file}"
|
|
88
69
|
expected = Sha.recorded(recorded)
|
|
89
|
-
return Refusal.new(kind: :file_unrecorded, text: "
|
|
70
|
+
return Refusal.new(kind: :file_unrecorded, text: "#{what} isn't recorded (reinstall the bundle)") if expected.empty?
|
|
90
71
|
|
|
91
|
-
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
Refusal.new(kind: :file_changed, actual: actual, expected: expected,
|
|
95
|
-
text: "its sha256 #{actual[0, 12]}… differs from the installed #{expected[0, 12]}… " \
|
|
96
|
-
"(edited after install? reinstall the bundle)")
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def script_refusal(file, recorded)
|
|
100
|
-
path = File.join(scripts_dir, file)
|
|
101
|
-
expected = Sha.recorded(recorded)
|
|
102
|
-
if expected.empty?
|
|
103
|
-
return Refusal.new(kind: :file_unrecorded,
|
|
104
|
-
text: "bundle #{@name}'s scripts/#{file} isn't among its installed scripts (reinstall the bundle)")
|
|
105
|
-
end
|
|
106
|
-
return Refusal.new(kind: :file_missing, text: "bundle #{@name}'s scripts/#{file} is missing (reinstall the bundle)") unless File.file?(path)
|
|
72
|
+
path = file && File.join(@bundle_dir, folder, file)
|
|
73
|
+
return Refusal.new(kind: :file_missing, text: "#{what} is missing (reinstall the bundle)") unless path && File.file?(path)
|
|
107
74
|
return nil if Sha.unchecked?(recorded)
|
|
108
75
|
|
|
109
76
|
actual = Sha.of_file(path)
|
|
110
77
|
return nil if actual == expected
|
|
111
78
|
|
|
112
79
|
Refusal.new(kind: :file_changed, actual: actual, expected: expected,
|
|
113
|
-
text: "
|
|
80
|
+
text: "#{what} differs from the installed one (reinstall the bundle)")
|
|
114
81
|
end
|
|
115
82
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
actual = Sha.of_file(path)
|
|
122
|
-
return nil if actual == Sha.recorded(recorded)
|
|
123
|
-
|
|
124
|
-
Refusal.new(kind: :file_changed, actual: actual, expected: Sha.recorded(recorded),
|
|
125
|
-
text: "its sha256 differs from the installed one (edited after install? reinstall the bundle)")
|
|
83
|
+
# The installed bundle's record, nil when it isn't installed.
|
|
84
|
+
# @return [Record, nil]
|
|
85
|
+
# @raise [JSON::ParserError] manifest.json doesn't parse
|
|
86
|
+
def record
|
|
87
|
+
Record.read(@name, File.join(@bundle_dir, "manifest.json"))
|
|
126
88
|
end
|
|
127
89
|
end
|
|
128
90
|
end
|