samagotchi 0.170.0 → 0.172.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 +61 -1
- data/bin/chi +6 -4
- data/docs/architecture.md +26 -9
- data/docs/bundles.md +4 -21
- data/docs/cli.md +81 -97
- data/docs/configuration.md +12 -14
- data/docs/context.md +5 -6
- data/docs/guardrails.md +57 -96
- data/docs/hooks.md +3 -4
- data/docs/internals/attached-context.md +6 -7
- data/docs/internals/background-tasks.md +4 -3
- data/docs/internals/block-renderers.md +2 -2
- data/docs/internals/bridge.md +34 -7
- data/docs/internals/context-telemetry.md +13 -1
- data/docs/internals/engine.md +25 -13
- data/docs/internals/inline-widgets.md +1 -1
- data/docs/internals/objectives.md +4 -6
- data/docs/internals/participants.md +340 -249
- data/docs/internals/prompt-caching.md +4 -5
- data/docs/internals/web-frontend.md +185 -35
- data/docs/internals/working-set.md +71 -5
- data/docs/memory.md +1 -1
- data/docs/plugins.md +2 -16
- data/docs/releasing.md +2 -1
- data/docs/scheduling.md +1 -1
- data/docs/sessions.md +17 -48
- data/docs/sub-agent.md +2 -2
- data/docs/system-one.md +2 -2
- data/docs/testing.md +56 -7
- data/lib/samagotchi/bridge/card_store.rb +1 -0
- data/lib/samagotchi/bridge/sse_writer.rb +1 -0
- data/lib/samagotchi/bridge/turn_accumulator.rb +8 -5
- data/lib/samagotchi/bridge.rb +64 -20
- data/lib/samagotchi/bridge_client/event_stream.rb +2 -0
- data/lib/samagotchi/bundle_command/test_run.rb +1 -0
- data/lib/samagotchi/bundle_command/try/run.rb +1 -0
- data/lib/samagotchi/bundles/coordinator/manifest.yml +4 -5
- data/lib/samagotchi/bundles/coordinator/plugin.rb +6 -79
- data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +1 -16
- data/lib/samagotchi/bundles/github-pr/manifest.yml +2 -2
- data/lib/samagotchi/bundles/github-pr/plugin.rb +0 -1
- data/lib/samagotchi/bundles/inline-widgets/manifest.yml +2 -2
- data/lib/samagotchi/bundles/inline-widgets/plugin.rb +4 -5
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/client_id.rb +126 -67
- data/lib/samagotchi/command_intake.rb +15 -3
- data/lib/samagotchi/compat.rb +6 -1
- data/lib/samagotchi/context_candidate_choice.rb +1 -3
- data/lib/samagotchi/context_candidates.rb +3 -4
- data/lib/samagotchi/continue_offer.rb +9 -2
- data/lib/samagotchi/delivery.rb +36 -12
- data/lib/samagotchi/empty_answer_error.rb +5 -0
- data/lib/samagotchi/engine/cards.rb +3 -0
- data/lib/samagotchi/engine/context_judge.rb +5 -3
- data/lib/samagotchi/engine/events.rb +4 -0
- data/lib/samagotchi/engine/hooks.rb +3 -0
- data/lib/samagotchi/engine/messages.rb +5 -0
- data/lib/samagotchi/engine/model_settings.rb +2 -0
- data/lib/samagotchi/engine/models.rb +10 -0
- data/lib/samagotchi/engine/objectives.rb +6 -0
- data/lib/samagotchi/engine/participants.rb +18 -14
- data/lib/samagotchi/engine/plugins.rb +8 -0
- data/lib/samagotchi/engine/questions.rb +3 -0
- data/lib/samagotchi/engine/recap.rb +1 -0
- data/lib/samagotchi/engine/session.rb +4 -0
- data/lib/samagotchi/engine/side_requests.rb +9 -0
- data/lib/samagotchi/engine/steering.rb +2 -0
- data/lib/samagotchi/engine/toolkit.rb +5 -0
- data/lib/samagotchi/engine/turn_end.rb +7 -0
- data/lib/samagotchi/engine/turn_helpers.rb +8 -0
- data/lib/samagotchi/engine/verify.rb +2 -0
- data/lib/samagotchi/engine.rb +8 -3
- data/lib/samagotchi/event_fanout.rb +22 -1
- data/lib/samagotchi/grants.rb +33 -22
- data/lib/samagotchi/guardrail_wiring.rb +23 -18
- data/lib/samagotchi/guardrails/approval_use.rb +59 -0
- data/lib/samagotchi/guardrails/approvals.rb +9 -11
- data/lib/samagotchi/guardrails/child_boundary.rb +1 -0
- data/lib/samagotchi/guardrails/gate.rb +10 -5
- data/lib/samagotchi/guardrails/implicit_writers.rb +1 -0
- data/lib/samagotchi/guardrails/pair_boundary.rb +6 -6
- data/lib/samagotchi/guardrails/participant_refusal.rb +33 -0
- data/lib/samagotchi/guardrails/review_paths.rb +2 -3
- data/lib/samagotchi/guardrails.rb +1 -1
- data/lib/samagotchi/image_store.rb +51 -12
- data/lib/samagotchi/kernel_loop.rb +7 -1
- data/lib/samagotchi/llm/stray_tool_call.rb +7 -4
- data/lib/samagotchi/llm_context_stale.rb +4 -1
- data/lib/samagotchi/llm_context_strategy.rb +2 -0
- data/lib/samagotchi/objectives.rb +1 -4
- data/lib/samagotchi/objectives_audit.rb +1 -1
- data/lib/samagotchi/objectives_track.rb +1 -1
- data/lib/samagotchi/owner_prompt.rb +3 -6
- data/lib/samagotchi/parent_report.rb +1 -0
- data/lib/samagotchi/participant_messages.rb +48 -4
- data/lib/samagotchi/participant_revise.rb +61 -0
- data/lib/samagotchi/participant_turn_mode.rb +50 -0
- data/lib/samagotchi/participant_uploads.rb +98 -0
- data/lib/samagotchi/participants.rb +21 -12
- data/lib/samagotchi/participants_watch.rb +2 -2
- data/lib/samagotchi/plugin/api.rb +2 -2
- data/lib/samagotchi/plugin/attached_context.rb +1 -1
- data/lib/samagotchi/plugin/context.rb +0 -4
- data/lib/samagotchi/plugin/sessions.rb +1 -25
- data/lib/samagotchi/reply_wait/poll.rb +5 -1
- data/lib/samagotchi/revise_anchor.rb +9 -0
- data/lib/samagotchi/run_options.rb +2 -3
- data/lib/samagotchi/send_command.rb +15 -10
- data/lib/samagotchi/session.rb +0 -3
- data/lib/samagotchi/session_access/contract.rb +1 -10
- data/lib/samagotchi/session_access/local.rb +10 -23
- data/lib/samagotchi/session_access/remote.rb +9 -20
- data/lib/samagotchi/session_access.rb +12 -16
- data/lib/samagotchi/session_chain.rb +4 -6
- data/lib/samagotchi/session_commands.rb +6 -3
- data/lib/samagotchi/session_continue.rb +1 -2
- data/lib/samagotchi/session_inbox.rb +20 -12
- data/lib/samagotchi/session_manager/delivery.rb +32 -5
- data/lib/samagotchi/session_manager/lifecycle.rb +12 -0
- data/lib/samagotchi/session_manager/listing.rb +5 -0
- data/lib/samagotchi/session_manager/spawn.rb +2 -2
- data/lib/samagotchi/session_manager/worker_command.rb +9 -0
- data/lib/samagotchi/session_participants.rb +12 -8
- data/lib/samagotchi/session_review.rb +5 -7
- data/lib/samagotchi/session_stores.rb +3 -1
- data/lib/samagotchi/share_command.rb +10 -12
- data/lib/samagotchi/share_terms.rb +41 -0
- data/lib/samagotchi/steer.rb +8 -14
- data/lib/samagotchi/system_prompt.rb +16 -25
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +2 -1
- data/lib/samagotchi/terminal_ui/attached_loop/exit_commands.rb +1 -0
- data/lib/samagotchi/terminal_ui/attached_loop/queueing.rb +1 -0
- data/lib/samagotchi/terminal_ui/attached_loop/sending.rb +2 -0
- data/lib/samagotchi/terminal_ui/formatting.rb +15 -17
- data/lib/samagotchi/terminal_ui/participant_commands.rb +2 -2
- data/lib/samagotchi/terminal_ui/status_row.rb +2 -2
- data/lib/samagotchi/terminal_ui.rb +1 -2
- data/lib/samagotchi/testing/sessions.rb +2 -10
- data/lib/samagotchi/tool_runner.rb +42 -9
- data/lib/samagotchi/toolkit.rb +4 -22
- data/lib/samagotchi/toolkit_suggest.rb +3 -3
- data/lib/samagotchi/tools/deferred_tools.rb +1 -0
- data/lib/samagotchi/tools/execute.rb +11 -45
- data/lib/samagotchi/tools/leftovers.rb +122 -0
- data/lib/samagotchi/tools/memory.rb +88 -25
- data/lib/samagotchi/tools/task_get.rb +1 -0
- data/lib/samagotchi/tools/task_list.rb +3 -2
- data/lib/samagotchi/tools/task_record.rb +6 -4
- data/lib/samagotchi/tools/task_runtime.rb +199 -20
- data/lib/samagotchi/tools/task_wait.rb +4 -3
- data/lib/samagotchi/turn_anchors.rb +0 -3
- data/lib/samagotchi/turn_context.rb +1 -1
- data/lib/samagotchi/turn_origin.rb +1 -1
- data/lib/samagotchi/turn_stages/context_judge.rb +4 -4
- data/lib/samagotchi/turn_stages/objectives.rb +2 -2
- data/lib/samagotchi/turn_stages/toolkit_suggestion.rb +2 -2
- data/lib/samagotchi/turn_stages/verify_anchors.rb +13 -1
- data/lib/samagotchi/update_hint.rb +3 -1
- data/lib/samagotchi/verify_anchor.rb +6 -0
- data/lib/samagotchi/verify_fresh.rb +1 -1
- data/lib/samagotchi/verify_fresh_origin.rb +13 -11
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +45 -82
- data/lib/samagotchi/web/participant_access.rb +139 -40
- data/lib/samagotchi/web/participant_images.rb +185 -0
- data/lib/samagotchi/web/participant_review.rb +22 -142
- data/lib/samagotchi/web/participant_show.rb +241 -0
- data/lib/samagotchi/web/participant_stream_filter.rb +25 -2
- data/lib/samagotchi/web/participant_view.rb +334 -27
- data/lib/samagotchi/web/participants_admin.rb +21 -40
- data/lib/samagotchi/web/public/annotate_bar.css +1 -2
- data/lib/samagotchi/web/public/annotate_bar.js +1 -2
- data/lib/samagotchi/web/public/app.js +126 -132
- data/lib/samagotchi/web/public/block_host.js +7 -4
- data/lib/samagotchi/web/public/bubbles.js +9 -1
- data/lib/samagotchi/web/public/cards_offscreen.js +69 -0
- data/lib/samagotchi/web/public/chip_popover.js +5 -4
- data/lib/samagotchi/web/public/claim_link.js +4 -4
- data/lib/samagotchi/web/public/composer.css +4 -6
- data/lib/samagotchi/web/public/composer_mode.js +11 -6
- data/lib/samagotchi/web/public/composer_mount.js +4 -4
- data/lib/samagotchi/web/public/ctx.js +12 -3
- data/lib/samagotchi/web/public/data.js +2 -10
- data/lib/samagotchi/web/public/delivery_line.js +49 -63
- data/lib/samagotchi/web/public/history_shape.js +5 -1
- data/lib/samagotchi/web/public/images.js +7 -1
- data/lib/samagotchi/web/public/index.html +50 -34
- data/lib/samagotchi/web/public/info_bar_model.js +2 -1
- data/lib/samagotchi/web/public/live_turn.js +1 -1
- data/lib/samagotchi/web/public/markdown_place.js +5 -4
- data/lib/samagotchi/web/public/owner_claim.js +5 -5
- data/lib/samagotchi/web/public/owner_verify.js +0 -2
- data/lib/samagotchi/web/public/participant_bar.js +107 -0
- data/lib/samagotchi/web/public/participant_main.js +289 -0
- data/lib/samagotchi/web/public/participant_model.js +5 -292
- data/lib/samagotchi/web/public/participant_names.js +17 -8
- data/lib/samagotchi/web/public/participant_revise.js +66 -0
- data/lib/samagotchi/web/public/participants_panel.js +32 -74
- data/lib/samagotchi/web/public/question_cards.js +14 -3
- data/lib/samagotchi/web/public/refs.js +53 -36
- data/lib/samagotchi/web/public/reload_check.js +70 -14
- data/lib/samagotchi/web/public/revise_stack.js +21 -10
- data/lib/samagotchi/web/public/send_turn.js +28 -29
- data/lib/samagotchi/web/public/session_actions.js +4 -45
- data/lib/samagotchi/web/public/session_fields.js +1 -2
- data/lib/samagotchi/web/public/session_state.js +12 -7
- data/lib/samagotchi/web/public/session_sync.js +9 -2
- data/lib/samagotchi/web/public/session_view.js +14 -5
- data/lib/samagotchi/web/public/settings_panel.js +4 -18
- data/lib/samagotchi/web/public/stage_answer.js +56 -0
- data/lib/samagotchi/web/public/stage_asking.js +7 -5
- data/lib/samagotchi/web/public/stage_cloud.js +93 -0
- data/lib/samagotchi/web/public/stage_dom.js +100 -0
- data/lib/samagotchi/web/public/stage_handoff.js +154 -0
- data/lib/samagotchi/web/public/stage_owner_wait.js +35 -0
- data/lib/samagotchi/web/public/stage_pager.js +59 -0
- data/lib/samagotchi/web/public/stage_quiet_clock.js +52 -0
- data/lib/samagotchi/web/public/stage_view.js +103 -410
- data/lib/samagotchi/web/public/stage_waiting.js +74 -6
- data/lib/samagotchi/web/public/start_page.js +12 -33
- data/lib/samagotchi/web/public/start_settings.js +24 -78
- data/lib/samagotchi/web/public/start_toolkit.js +6 -10
- data/lib/samagotchi/web/public/storage.js +22 -0
- data/lib/samagotchi/web/public/stream_handlers.js +3 -10
- data/lib/samagotchi/web/public/tokens.css +1 -1
- data/lib/samagotchi/web/public/turn_block.js +2 -5
- data/lib/samagotchi/web/public/turn_events.js +30 -12
- data/lib/samagotchi/web/public/turn_html.js +9 -2
- data/lib/samagotchi/web/public/turn_pieces.js +3 -4
- data/lib/samagotchi/web/public/turn_range.js +1 -2
- data/lib/samagotchi/web/public/verify_target.js +2 -4
- data/lib/samagotchi/web/public/viewer.js +59 -0
- data/lib/samagotchi/web/public/viewer_self.js +59 -0
- data/lib/samagotchi/web/public/working_set.js +11 -5
- data/lib/samagotchi/web/public/working_set_view.js +53 -8
- data/lib/samagotchi/web/public/ws_cards.js +89 -0
- data/lib/samagotchi/web/public/ws_peek.js +106 -0
- data/lib/samagotchi/web/public/ws_preview.css +126 -0
- data/lib/samagotchi/web/public/ws_reader.js +319 -0
- data/lib/samagotchi/web/public/ws_timeline.js +200 -0
- data/lib/samagotchi/web/public/ws_way_in.js +25 -0
- data/lib/samagotchi/web/qr.rb +1 -1
- data/lib/samagotchi/web/session_control.rb +42 -15
- data/lib/samagotchi/web/session_create.rb +6 -72
- data/lib/samagotchi/web/session_show.rb +75 -28
- data/lib/samagotchi/web/session_summary.rb +1 -4
- data/lib/samagotchi/web/verify_fresh_routes.rb +8 -7
- data/lib/samagotchi/web/viewer.rb +70 -0
- data/lib/samagotchi/web/working_set_routes.rb +132 -0
- data/lib/samagotchi/worker.rb +35 -28
- data/lib/samagotchi/worker_inbound.rb +4 -3
- data/lib/samagotchi/worker_link.rb +17 -0
- data/lib/samagotchi/working_set.rb +322 -11
- metadata +32 -13
- data/lib/samagotchi/guardrails/review_boundary.rb +0 -99
- data/lib/samagotchi/participant_mode.rb +0 -86
- data/lib/samagotchi/review_apply.rb +0 -131
- data/lib/samagotchi/review_command.rb +0 -123
- data/lib/samagotchi/review_start.rb +0 -196
- data/lib/samagotchi/web/public/participant.html +0 -218
- data/lib/samagotchi/web/public/participant.js +0 -719
- data/lib/samagotchi/web/public/participant_annotate.js +0 -76
- data/lib/samagotchi/web/public/review_apply.js +0 -34
- data/lib/samagotchi/web/public/review_history.js +0 -72
- data/lib/samagotchi/web/public/review_start.js +0 -55
- data/lib/samagotchi/web/public/tools_overview.js +0 -42
data/lib/samagotchi/bridge.rb
CHANGED
|
@@ -118,6 +118,11 @@ module Samagotchi
|
|
|
118
118
|
MAX_BODY_BYTES = 1_000_000
|
|
119
119
|
# A request's deadline (see #handle_post_turn) that isn't epoch seconds.
|
|
120
120
|
BAD_DEADLINE = [{ "Allow" => "POST" }, 400, { error: "bad_deadline", detail: "deadline must be epoch seconds" }].freeze
|
|
121
|
+
# A POST /command that names no sender: every sender names itself
|
|
122
|
+
# (ClientId::NONE is never the owner's), so it runs nothing.
|
|
123
|
+
UNNAMED_COMMAND = "a session command must name its sender: send client_id (a web tab's web:<id>, a chi TUI's " \
|
|
124
|
+
"tui:<pid>, chi send's cli:send)"
|
|
125
|
+
UNNAMED_COMMAND_REPLY = [{ "Allow" => "POST" }, 400, { error: "missing_client_id", detail: UNNAMED_COMMAND }].freeze
|
|
121
126
|
# The request header that names the Bridge's secret, lowercased as #read_request keeps it.
|
|
122
127
|
SECRET_HEADER = BridgeSecret::HEADER.downcase
|
|
123
128
|
# Bytes of randomness in a Bridge's secret (hex in bridge.json: twice as many characters).
|
|
@@ -773,18 +778,32 @@ module Samagotchi
|
|
|
773
778
|
# Stop's last_turn carry the turn's enqueued_id (ReplyWait.own_turn).
|
|
774
779
|
# unqueue: POST turn/dequeue (#handle_dequeue_turn) takes a queued
|
|
775
780
|
# message back before it runs.
|
|
776
|
-
# review_turns: a participant's turn runs as its own, inside
|
|
777
|
-
# boundary
|
|
778
|
-
#
|
|
779
|
-
# pair_turns: a participant's turn
|
|
780
|
-
#
|
|
781
|
-
#
|
|
781
|
+
# review_turns: a participant's turn runs as its own, inside a
|
|
782
|
+
# boundary; kept for an older chi web, which sends no participant's turn
|
|
783
|
+
# to a worker without it (Delivery::REVIEW_FEATURE).
|
|
784
|
+
# pair_turns: a participant's turn runs under the owner's guardrails
|
|
785
|
+
# (Guardrails::PairBoundary); chi web sends no participant's turn to a
|
|
786
|
+
# worker without it, nor invites anyone to its session (Delivery::PAIR_FEATURE).
|
|
787
|
+
# participant_steer: a participant's message sent while their own turn
|
|
788
|
+
# runs goes in at its next step (a worker without it queues it); only
|
|
789
|
+
# what the page's delivery line and chi web's ack say depends on it
|
|
790
|
+
# (Delivery::OWN_TURN_STEER_FEATURE).
|
|
791
|
+
# cancel_turn_id: POST cancel with a turn_id cancels that turn only
|
|
792
|
+
# (Delivery::CANCEL_TURN_ID_FEATURE), what chi web needs to relay a
|
|
793
|
+
# participant's cancel.
|
|
794
|
+
# participant_revise: a participant's Revise draft is kept, and the
|
|
795
|
+
# Engine checks it at the stamp (ParticipantRevise): what chi web needs
|
|
796
|
+
# to pass one on (ReviseAnchor::PARTICIPANT_FEATURE).
|
|
782
797
|
# activity: GET /activity answers with Worker#activity_snapshot, so
|
|
783
798
|
# `chi schedule tick` can ask a live worker what it is busy with.
|
|
799
|
+
# participant_client_id: it reads a participant's client id as
|
|
800
|
+
# participant:<id>; chi web sends a worker without it review:<id>
|
|
801
|
+
# (Delivery::PARTICIPANT_ID_FEATURE).
|
|
784
802
|
FEATURES = ["restart", "task_stop", "reparent", Delivery::QUEUE_FEATURE, ReplyWait::TURN_IDS_FEATURE,
|
|
785
803
|
VerifyAnchor::FEATURE, ReviseAnchor::FEATURE,
|
|
786
804
|
SessionInbox::UNQUEUE_FEATURE, Delivery::REVIEW_FEATURE, Delivery::PAIR_FEATURE, TurnDrawings::FEATURE,
|
|
787
|
-
WorkerLink::ACTIVITY_FEATURE, ObjectivesTrack::FEATURE
|
|
805
|
+
WorkerLink::ACTIVITY_FEATURE, ObjectivesTrack::FEATURE, Delivery::OWN_TURN_STEER_FEATURE,
|
|
806
|
+
Delivery::CANCEL_TURN_ID_FEATURE, ReviseAnchor::PARTICIPANT_FEATURE, Delivery::PARTICIPANT_ID_FEATURE].freeze
|
|
788
807
|
|
|
789
808
|
# The routes, by method and what follows /session/:id/: a handler takes
|
|
790
809
|
# the session id and the request body and returns [headers, status, body].
|
|
@@ -1062,11 +1081,20 @@ module Samagotchi
|
|
|
1062
1081
|
return [{ "Allow" => "POST" }, 400, { error: "unknown_command", detail: detail }]
|
|
1063
1082
|
end
|
|
1064
1083
|
|
|
1084
|
+
client_id = fetched(parsed, "client_id")
|
|
1085
|
+
return UNNAMED_COMMAND_REPLY if client_id.to_s.strip.empty?
|
|
1086
|
+
|
|
1087
|
+
# Only the owner's senders and chi answer's (CommandIntake.allowed?),
|
|
1088
|
+
# as for a command sent as a message.
|
|
1089
|
+
unless CommandIntake.allowed?(client_id)
|
|
1090
|
+
Log.warn(:bridge, "command_refused", client_id: client_id)
|
|
1091
|
+
return [{}, 403, { error: CommandIntake::REFUSED_ERROR, detail: CommandIntake.refusal(line) }]
|
|
1092
|
+
end
|
|
1093
|
+
|
|
1065
1094
|
deadline = fetched(parsed, "deadline")
|
|
1066
1095
|
return BAD_DEADLINE unless deadline_valid?(deadline)
|
|
1067
1096
|
|
|
1068
|
-
queue_command_request(session_id, line, client_id: fetched(parsed, "
|
|
1069
|
-
card: fetched(parsed, "card") == true)
|
|
1097
|
+
queue_command_request(session_id, line, client_id: client_id, deadline: deadline, card: fetched(parsed, "card") == true)
|
|
1070
1098
|
end
|
|
1071
1099
|
|
|
1072
1100
|
# Queues +line+ (a session command) for the worker and announces its
|
|
@@ -1249,10 +1277,10 @@ module Samagotchi
|
|
|
1249
1277
|
# request's principal; the Bridge is loopback and trusts its caller).
|
|
1250
1278
|
author = fetched(parsed, "author")
|
|
1251
1279
|
author = nil unless author.is_a?(String) && !author.empty?
|
|
1252
|
-
# A Verify turn's claim, a Revise turn's draft
|
|
1253
|
-
#
|
|
1280
|
+
# A Verify turn's claim, a Revise turn's draft. A participant's draft
|
|
1281
|
+
# is checked by chi web at the send and by the Engine at the stamp
|
|
1282
|
+
# (TurnStages::VerifyAnchors#revision_target, ParticipantRevise).
|
|
1254
1283
|
anchors = TurnAnchors.from(parsed)
|
|
1255
|
-
anchors = anchors.without_revises if Steer.participant_author?(author)
|
|
1256
1284
|
if sid.to_s.strip.empty? || prompt.to_s.strip.empty?
|
|
1257
1285
|
return [{ "Allow" => "POST" }, 400,
|
|
1258
1286
|
{ error: "missing_fields", detail: "session_id and prompt are required" }]
|
|
@@ -1275,12 +1303,14 @@ module Samagotchi
|
|
|
1275
1303
|
# (chi web's, from their grant: its queue limit plus the running one).
|
|
1276
1304
|
pending_limit = nil
|
|
1277
1305
|
if Steer.participant_author?(author)
|
|
1278
|
-
# A participant's message
|
|
1279
|
-
#
|
|
1280
|
-
#
|
|
1306
|
+
# A participant's message never cuts, nor is a command or a shell
|
|
1307
|
+
# line: chi web refuses those first, and this is the worker's own
|
|
1308
|
+
# layer. It goes into a running turn only when that turn is theirs
|
|
1309
|
+
# (#enqueue_post_turn, under the event log), else it is a turn of
|
|
1310
|
+
# its own (D6).
|
|
1281
1311
|
return participant_refused(sid, author, "command") if command_registry.command?(prompt.to_s)
|
|
1282
1312
|
|
|
1283
|
-
delivery = Delivery::
|
|
1313
|
+
delivery = Delivery::NEXT_STEP if Delivery.cut?(delivery)
|
|
1284
1314
|
pending_limit = fetched(parsed, "pending_limit")
|
|
1285
1315
|
pending_limit = nil unless pending_limit.is_a?(Integer) && pending_limit.positive?
|
|
1286
1316
|
end
|
|
@@ -1336,10 +1366,11 @@ module Samagotchi
|
|
|
1336
1366
|
next :too_many if pending_limit && pending_turns(author) >= pending_limit
|
|
1337
1367
|
next :duplicate unless @engine.reserve_enqueued_id(enqueued_id)
|
|
1338
1368
|
|
|
1339
|
-
#
|
|
1340
|
-
#
|
|
1341
|
-
#
|
|
1342
|
-
|
|
1369
|
+
# Input goes into a running turn only of its own author: the
|
|
1370
|
+
# owner's never into a participant's turn (a steer, a cut), a
|
|
1371
|
+
# participant's only into their own; else it queues behind it as
|
|
1372
|
+
# a turn of its own, and the ack and :turn_enqueued say so.
|
|
1373
|
+
delivery = Delivery::QUEUE unless same_author_steer?(author)
|
|
1343
1374
|
queued_behind_turn = Delivery.queue?(delivery) && !@accumulator.current_turn.nil?
|
|
1344
1375
|
unless enqueue_turn(prompt: prompt, client_id: client_id, enqueued_id: enqueued_id,
|
|
1345
1376
|
no_interrupt: no_interrupt, images: images, delivery: delivery, author: author, anchors: anchors)
|
|
@@ -1430,6 +1461,19 @@ module Samagotchi
|
|
|
1430
1461
|
dequeue_reply(taken, id, input)
|
|
1431
1462
|
end
|
|
1432
1463
|
|
|
1464
|
+
# Whether input from +author+ may go into the running turn: the owner's
|
|
1465
|
+
# into the owner's (or none running), a participant's into their own
|
|
1466
|
+
# only (none running: theirs runs as the next turn, a queue). Read with
|
|
1467
|
+
# the event log held.
|
|
1468
|
+
def same_author_steer?(author)
|
|
1469
|
+
sender = Steer.sender_author(author)
|
|
1470
|
+
running = @accumulator.participant_author
|
|
1471
|
+
return running.nil? if sender.nil?
|
|
1472
|
+
return false if @accumulator.current_turn.nil?
|
|
1473
|
+
|
|
1474
|
+
running == sender
|
|
1475
|
+
end
|
|
1476
|
+
|
|
1433
1477
|
# +author+'s turns running or waiting: the running turn when it is
|
|
1434
1478
|
# theirs, and their queued ones. Read with the event log held.
|
|
1435
1479
|
def pending_turns(author)
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: coordinator
|
|
3
|
-
version: 0.
|
|
3
|
+
version: 0.9.0
|
|
4
4
|
scope: system
|
|
5
|
-
description: "Coordinate parallel work: the coordinator skill (split the work, one worktree and child session per task, check each report, merges under a guardrail approval (the git-merge rule) or a question, a handoff memory to resume from), /coordinate <goal>, /coordinate resume, /coordinate end
|
|
5
|
+
description: "Coordinate parallel work: the coordinator skill (split the work, one worktree and child session per task, check each report, merges under a guardrail approval (the git-merge rule) or a question, a handoff memory to resume from), /coordinate <goal>, /coordinate resume, /coordinate end and /children; the coordinator toolkit (lean + delegate, delegate_result, list_sessions, objectives) and the coding toolkit for build children (child + be concise)"
|
|
6
6
|
trust_level: reviewed
|
|
7
7
|
files:
|
|
8
8
|
skill_coordinator.md:
|
|
9
|
-
sha256: sha256:
|
|
9
|
+
sha256: sha256:21a56711f4ac1252ff6012a6ed0a743cb90732939abed406a9b8753a755c8d0c
|
|
10
10
|
description: "Coordinate parallel work: split it, delegate each task wait:false in its own worktree (cwd:), check each report, merge under the git-merge approval or ask the user; resume from a handoff_* memory"
|
|
11
11
|
plugin:
|
|
12
12
|
file: plugin.rb
|
|
13
|
-
sha256: sha256:
|
|
13
|
+
sha256: sha256:406b9827485535a8be17d4f1b291997ebf5c3f7d5616d20812c53b4ea153f601
|
|
14
14
|
# the coordinator toolkit needs chi.toolkit and ctx.use_toolkit (0.66.0); the
|
|
15
15
|
# coding toolkit (chi.toolkit prompt:) and the skill's delegate toolkit: need
|
|
16
16
|
# the next chi.
|
|
17
17
|
requires_chi: ">= 0.107.0"
|
|
18
|
-
# /coordinate review uses ctx.sessions.review (the next chi).
|
|
19
18
|
# No requires_chi_next for guardrails/merge.yml: its keys are long supported, and first-ever too-new rules would make a
|
|
20
19
|
# live older worker deny every call. A chi without `chi guardrails rule` gives a usage error, and the skill then asks.
|
|
21
20
|
# Nor for the objectives tool in the kit and the skill: on an older chi the kit's add names nothing (it declares only what
|
|
@@ -27,14 +27,6 @@
|
|
|
27
27
|
# (/coordinate resume <name>); none: says so. It reads the project's
|
|
28
28
|
# memories folder, nothing else.
|
|
29
29
|
#
|
|
30
|
-
# /coordinate review [handoff] (experimental) opens a sprint review: a review
|
|
31
|
-
# session of this one (ctx.sessions.review: its recap, never its transcript;
|
|
32
|
-
# this session keeps running), seeded with the open handoff's body (the one
|
|
33
|
-
# named, the only one open, or a card with a Review action each when several
|
|
34
|
-
# are), for participants (chi share): its model answers their new context
|
|
35
|
-
# with a hand-off diff and the owner applies it (the skill's Sprint review).
|
|
36
|
-
# With none open it starts from the recap alone and says so.
|
|
37
|
-
#
|
|
38
30
|
# /coordinate end ends the day: the model is asked to follow the skill's End
|
|
39
31
|
# of day (bring its handoff up to date, keep it OPEN unless all is done, give
|
|
40
32
|
# a short report). It reads nothing itself; "end" with more words is a goal.
|
|
@@ -64,21 +56,9 @@ class Plugin
|
|
|
64
56
|
TEXT_CHARS = 80
|
|
65
57
|
USAGE = "usage: /children [all] | /children stop <id>"
|
|
66
58
|
COORDINATE_USAGE = "usage: /coordinate <goal> — chi splits it into tasks, one child session and worktree each; " \
|
|
67
|
-
"/coordinate resume [name] — pick up an open handoff; /coordinate end — save the handoff, end-of-day report
|
|
68
|
-
"/coordinate review [name] — a sprint review session to share (experimental)"
|
|
59
|
+
"/coordinate resume [name] — pick up an open handoff; /coordinate end — save the handoff, end-of-day report"
|
|
69
60
|
RESUME_CARD_ID = "coordinate-resume"
|
|
70
|
-
|
|
71
|
-
# The seed's note: what to do (the skill's Sprint review section, copied:
|
|
72
|
-
# a participant's turn may read project memories only, and the skill is
|
|
73
|
-
# where its bundle was installed, usually system) and the handoff's body.
|
|
74
|
-
REVIEW_SEED = "This is a sprint review of the coordinator session %<source>s (experimental). The " \
|
|
75
|
-
"skill_coordinator memory's Sprint review section, which you follow here:"
|
|
76
|
-
SKILL = "skill_coordinator"
|
|
77
|
-
SPRINT_REVIEW_HEADING = /^## Sprint review\b.*$/
|
|
78
|
-
# The section's gist when the skill's file can't be read.
|
|
79
|
-
SPRINT_REVIEW_FALLBACK = "A participant's turn may only read. Answer new context with a hand-off diff (the " \
|
|
80
|
-
"handoff's lines as they would change, in a diff block) and what it means per branch. When " \
|
|
81
|
-
"the owner applies it, update the handoff and re-plan in words; start, stop or merge nothing here."
|
|
61
|
+
REVIEW_GONE = "/coordinate review is gone (coordinator 0.9.0): chi has no review sessions; invite someone with chi share"
|
|
82
62
|
# A card takes 6 actions.
|
|
83
63
|
MAX_RESUMES = 6
|
|
84
64
|
HANDOFF_LINE = /^- \*\*(handoff_[^*\s]+)\*\*(.*)$/
|
|
@@ -98,8 +78,7 @@ class Plugin
|
|
|
98
78
|
children_command(args.to_s.strip, ctx)
|
|
99
79
|
end
|
|
100
80
|
chi.command "/coordinate", "run work in parallel: chi splits <goal> into tasks, each in a child session and worktree; " \
|
|
101
|
-
"resume: pick up an open handoff; end: save the handoff, end-of-day report
|
|
102
|
-
"review: a sprint review session to share (experimental)",
|
|
81
|
+
"resume: pick up an open handoff; end: save the handoff, end-of-day report",
|
|
103
82
|
anytime: true do |args, ctx|
|
|
104
83
|
coordinate(args.to_s.strip, ctx)
|
|
105
84
|
end
|
|
@@ -163,8 +142,9 @@ class Plugin
|
|
|
163
142
|
verb, rest = goal.split(/\s+/, 2)
|
|
164
143
|
# "resume" and at most a name; "resume the old work" is a goal.
|
|
165
144
|
return resume(rest.to_s.strip, ctx) if verb == "resume" && !rest.to_s.strip.match?(/\s/)
|
|
166
|
-
# "review" and at most a name
|
|
167
|
-
|
|
145
|
+
# "review" and at most a name (an old card's action, a habit): gone, said
|
|
146
|
+
# once rather than run as a goal; "review the specs" is a goal.
|
|
147
|
+
return REVIEW_GONE if verb == "review" && !rest.to_s.strip.match?(/\s/)
|
|
168
148
|
# A bare "end" only; "end the flaky specs" is a goal.
|
|
169
149
|
return end_of_day(ctx) if verb == "end" && rest.to_s.strip.empty?
|
|
170
150
|
|
|
@@ -198,59 +178,6 @@ class Plugin
|
|
|
198
178
|
"asked chi to end the day; a running turn gets it at its next step")
|
|
199
179
|
end
|
|
200
180
|
|
|
201
|
-
# /coordinate review [name]
|
|
202
|
-
def review(name, ctx)
|
|
203
|
-
open = open_handoffs(ctx)
|
|
204
|
-
if name.empty?
|
|
205
|
-
return handoff_card(open, ctx, verb: "review", id: REVIEW_CARD_ID) if open.size > 1
|
|
206
|
-
|
|
207
|
-
name = open.first&.dig(:name)
|
|
208
|
-
else
|
|
209
|
-
name = "handoff_#{name}" unless name.start_with?("handoff_")
|
|
210
|
-
unless open.any? { |handoff| handoff[:name] == name }
|
|
211
|
-
return "/coordinate review: no open handoff #{name} in this project (#{open.empty? ? "none is open" : "open: #{open.map { |h| h[:name] }.join(", ")}"})"
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
start_review(name, ctx)
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
def start_review(name, ctx)
|
|
218
|
-
seed = "#{format(REVIEW_SEED, source: ctx.session_id.to_s[0, 8])}\n\n#{sprint_review_section(ctx)}"
|
|
219
|
-
seed += "\n\nThe coordinator's handoff #{name} as of now (memory_read it, scope: project, for the latest):\n\n#{handoff_body(name, ctx)}" if name
|
|
220
|
-
id = ctx.sessions.review(seed: seed)
|
|
221
|
-
short = id.to_s[0, 8]
|
|
222
|
-
["sprint review #{short} started from this session (experimental), #{name ? "seeded with #{name}" : "from its recap alone: no open handoff"}; " \
|
|
223
|
-
"this session keeps running.",
|
|
224
|
-
"invite someone: chi share #{short} --name NAME (or the participants chip on its page); their new context comes " \
|
|
225
|
-
"back as a hand-off diff; Apply under it (on its page) puts the change in your composer there."].join("\n")
|
|
226
|
-
rescue Samagotchi::Plugin::Sessions::Error => e
|
|
227
|
-
"/coordinate review: #{e.message}"
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
# The skill's Sprint review section as installed (system scope, else the
|
|
231
|
-
# project's), heading to the next heading; the fallback without one.
|
|
232
|
-
def sprint_review_section(ctx)
|
|
233
|
-
%w[system project].each do |scope|
|
|
234
|
-
file = File.join(Samagotchi::MemoryPaths.scope_dir(scope, cwd: ctx.cwd).to_s, "#{SKILL}.md")
|
|
235
|
-
next unless File.file?(file)
|
|
236
|
-
|
|
237
|
-
text = File.read(file, encoding: "UTF-8")
|
|
238
|
-
start = text.index(SPRINT_REVIEW_HEADING) or next
|
|
239
|
-
rest = text[start..]
|
|
240
|
-
stop = rest.index(/^## /, 1)
|
|
241
|
-
return (stop ? rest[0...stop] : rest).strip
|
|
242
|
-
end
|
|
243
|
-
SPRINT_REVIEW_FALLBACK
|
|
244
|
-
rescue SystemCallError
|
|
245
|
-
SPRINT_REVIEW_FALLBACK
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
def handoff_body(name, ctx)
|
|
249
|
-
File.read(File.join(Samagotchi::MemoryPaths.scope_dir("project", cwd: ctx.cwd).to_s, "#{name}.md"), encoding: "UTF-8").strip
|
|
250
|
-
rescue SystemCallError
|
|
251
|
-
"(its file couldn't be read)"
|
|
252
|
-
end
|
|
253
|
-
|
|
254
181
|
def resume_card(open, ctx) = handoff_card(open, ctx, verb: "resume", id: RESUME_CARD_ID)
|
|
255
182
|
|
|
256
183
|
# A card of the open handoffs, one action each (/coordinate VERB name).
|
|
@@ -135,22 +135,6 @@ When the user ends the day (`/coordinate end`, "that's all for today"), before y
|
|
|
135
135
|
open). Report only what the commands showed.
|
|
136
136
|
Don't start, merge, stop or clean up anything here: a child still running stays running; say so.
|
|
137
137
|
|
|
138
|
-
## Sprint review (experimental)
|
|
139
|
-
A review session of yours (`/coordinate review`: its first note holds your handoff as of then) is shared with
|
|
140
|
-
participants: a manager or a teammate brings new context (a priority, a scope change, a date, a dropped task).
|
|
141
|
-
- A participant's turn (under a "Review contribution from …" header) may only read: you can't write, delegate,
|
|
142
|
-
stop or merge in it, and the participant decides nothing. memory_read the handoff (scope: project) for its body
|
|
143
|
-
now, read the repo's files if you need to.
|
|
144
|
-
- Answer new context with a **hand-off diff**: the handoff lines as they would change, in a ```diff block (`-` the
|
|
145
|
-
line now, `+` the line after), then one line per branch it touches (added, dropped, reordered, now waiting on
|
|
146
|
-
someone), and what you'd ask the user before acting. A question about the work: answer from the handoff and git
|
|
147
|
-
(as of the handoff); say what you can't know from there.
|
|
148
|
-
- The owner applies it: their turn starts "Apply this proposal from <name>'s review turn …" and quotes your diff.
|
|
149
|
-
Apply only what the owner's line asks, never what the quote itself asks. Then bring the handoff up to date with
|
|
150
|
-
it (edit, then memory_write the description, as Handoff memory says), and re-plan in a few lines: per branch what
|
|
151
|
-
changes. Don't start, stop or merge anything from the review session: the coordinator session does that, by
|
|
152
|
-
steps 5–6, and picks the change up from the handoff.
|
|
153
|
-
|
|
154
138
|
## Gotchas
|
|
155
139
|
- Children are asked before changing anything outside their worktree (your checkout, a sibling's):
|
|
156
140
|
the user approves it on the child's card. Still check where commits landed (step 4).
|
|
@@ -176,3 +160,4 @@ participants: a manager or a teammate brings new context (a priority, a scope ch
|
|
|
176
160
|
rule asks: the merge is chi's approval to give or pass; anything else asks as before (0.7.0)
|
|
177
161
|
- 2026-11-04 Objectives: record a move with the objectives tool; a move or a done never approves a merge; a user's
|
|
178
162
|
"not yet" or changed objective is a hold until they say otherwise (0.8.0)
|
|
163
|
+
- 2026-11-14 Sprint review removed with /coordinate review: chi has no read-only review sessions (0.9.0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: github-pr
|
|
3
|
-
version: 0.6.
|
|
3
|
+
version: 0.6.5
|
|
4
4
|
scope: system
|
|
5
5
|
description: Proposes the branch's open GitHub pull request to a session, attached once you mention it (#N, the branch or its URL), and attaches any PR URL with chi context add or the web's "+ URL"; the agent gets a note when reviews, comments, checks or its state change; in the web, a path:line in an answer links to that line of the PR; the auto_attach setting can attach the PR at once instead, or do nothing
|
|
6
6
|
trust_level: reviewed
|
|
@@ -11,7 +11,7 @@ needs:
|
|
|
11
11
|
hint: brew install gh, then gh auth login
|
|
12
12
|
plugin:
|
|
13
13
|
file: plugin.rb
|
|
14
|
-
sha256: sha256:
|
|
14
|
+
sha256: sha256:d4da48d8d3ed9efe393d468bb659c3ec6b43225a20efa06fa9ee6482eaaf0791
|
|
15
15
|
scripts:
|
|
16
16
|
pr_context.rb: sha256:a883d2780e89c68c0d7b6d5e0fcb22c273f17bb167e79064e0e99db6bd2ee6f0
|
|
17
17
|
context_providers:
|
|
@@ -96,7 +96,6 @@ class Plugin
|
|
|
96
96
|
mode = auto_attach_mode(ctx)
|
|
97
97
|
return "auto_attach: off" if mode == :off
|
|
98
98
|
return "skipped: a delegate child" if mode == :attach && ctx.delegate?
|
|
99
|
-
return "skipped: a review session" if mode == :propose && ctx.review?
|
|
100
99
|
|
|
101
100
|
branch = run(ctx, "git", "branch", "--show-current").to_s.strip
|
|
102
101
|
return "not on a branch" if branch.empty?
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: inline-widgets
|
|
3
|
-
version: 0.1.
|
|
3
|
+
version: 0.1.2
|
|
4
4
|
scope: system
|
|
5
5
|
description: "Teaches the model the chi-ui blocks chi web draws: picks (rows of options that fill your reply) and walk (a scenario stepped through)"
|
|
6
6
|
trust_level: reviewed
|
|
7
7
|
plugin:
|
|
8
8
|
file: plugin.rb
|
|
9
|
-
sha256: sha256:
|
|
9
|
+
sha256: sha256:b68599ba9e61004b8090ec0d317f6b4a5ba0042ca54a9b35fbe1a39539e1f03f
|
|
10
10
|
# chi.prompt_section is 0.132.0's; the web draws chi-ui blocks only from the next release
|
|
11
11
|
requires_chi: ">= 0.155.0"
|
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
# The text is eval 0013's round-2 hint, split in two. It is static, so the
|
|
11
11
|
# prompt cache keeps: same text at every build. A delegate child's answer is
|
|
12
12
|
# read by its parent, not drawn for a user, a one-shot (-p --non-interactive)
|
|
13
|
-
# prints to a terminal
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
# and a participant invited later mustn't change the prompt (the cache).
|
|
13
|
+
# prints to a terminal: neither gets a section. A session with participants
|
|
14
|
+
# keeps them: its pages draw them, and a participant invited later mustn't
|
|
15
|
+
# change the prompt (the cache).
|
|
17
16
|
class Plugin
|
|
18
17
|
PICKS = <<~TEXT
|
|
19
18
|
The web UI draws fenced ```chi-ui code blocks (YAML inside) as interactive widgets; the terminal shows their source. Use one whenever it helps the user more than prose: a widget replaces the long explanation, it doesn't sit beside one. Never use one for what markdown shows well (tables, lists, key-value). At most one widget per answer; keep the prose around it to a few sentences and don't repeat the widget's content.
|
|
@@ -76,5 +75,5 @@ class Plugin
|
|
|
76
75
|
|
|
77
76
|
# Whether the session's answers reach a web page that draws them. Decided by
|
|
78
77
|
# the session's kind, so the same at every build.
|
|
79
|
-
def drawn?(ctx) = ctx.frontend != :one_shot && !ctx.delegate?
|
|
78
|
+
def drawn?(ctx) = ctx.frontend != :one_shot && !ctx.delegate?
|
|
80
79
|
end
|