samagotchi 0.2.0 → 0.4.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 +198 -1
- data/README.md +56 -4
- data/bin/chi +118 -50
- data/docs/cli.md +184 -9
- data/docs/configuration.md +333 -47
- data/docs/desktop.md +45 -4
- data/docs/guardrails.md +11 -0
- data/docs/hooks.md +208 -5
- data/docs/plugins.md +68 -2
- data/docs/releasing.md +23 -13
- data/docs/sessions.md +45 -17
- data/lib/samagotchi/answer_display.rb +95 -0
- data/lib/samagotchi/archive_store.rb +90 -0
- data/lib/samagotchi/bootstrap/config_writer.rb +342 -0
- data/lib/samagotchi/bootstrap/probe.rb +262 -0
- data/lib/samagotchi/bootstrap_command.rb +347 -0
- data/lib/samagotchi/bridge/pending_card.rb +89 -0
- data/lib/samagotchi/bridge/turn_accumulator.rb +15 -3
- data/lib/samagotchi/bridge.rb +13 -1
- data/lib/samagotchi/bridge_client.rb +6 -2
- data/lib/samagotchi/bundles/check-in/manifest.yml +10 -0
- data/lib/samagotchi/bundles/check-in/plugin.rb +244 -0
- data/lib/samagotchi/bundles/source-links/hooks/source_links.rb +531 -0
- data/lib/samagotchi/bundles/source-links/manifest.yml +14 -0
- data/lib/samagotchi/bundles/source-links/source_links.md +5 -0
- data/lib/samagotchi/bundles/system/config_modification_protocol.md +10 -6
- data/lib/samagotchi/bundles/system/delegated.md +6 -7
- data/lib/samagotchi/bundles/system/manifest.yml +4 -4
- data/lib/samagotchi/bundles/system/self_map.md +8 -2
- data/lib/samagotchi/client.rb +81 -19
- data/lib/samagotchi/commands/registry.rb +8 -0
- data/lib/samagotchi/config.rb +252 -48
- data/lib/samagotchi/desktop/macos/App.swift +12 -8
- data/lib/samagotchi/desktop/macos/ChiRunner.swift +17 -9
- data/lib/samagotchi/desktop/macos/Images.swift +113 -0
- data/lib/samagotchi/desktop/macos/Info.plist.erb +6 -0
- data/lib/samagotchi/desktop/macos/Panel.swift +180 -25
- data/lib/samagotchi/desktop/macos.rb +59 -8
- data/lib/samagotchi/desktop_command.rb +6 -3
- data/lib/samagotchi/edit_preview.rb +82 -0
- data/lib/samagotchi/empty_answer_retry.rb +43 -0
- data/lib/samagotchi/engine.rb +434 -140
- data/lib/samagotchi/gem_update.rb +89 -0
- data/lib/samagotchi/guardrails/approval.rb +35 -4
- data/lib/samagotchi/guardrails/load_failures.rb +9 -3
- data/lib/samagotchi/guardrails/scratch_writes.rb +40 -0
- data/lib/samagotchi/guardrails.rb +1 -0
- data/lib/samagotchi/hooks/registry.rb +24 -5
- data/lib/samagotchi/host_registry.rb +9 -12
- data/lib/samagotchi/idle_client.rb +24 -15
- data/lib/samagotchi/idle_recap.rb +5 -1
- data/lib/samagotchi/idle_reminders.rb +2 -2
- data/lib/samagotchi/image_store.rb +10 -6
- data/lib/samagotchi/kernel_loop.rb +73 -94
- data/lib/samagotchi/live_versions.rb +59 -0
- data/lib/samagotchi/llm/api_key.rb +41 -0
- data/lib/samagotchi/llm/chat_loop.rb +132 -29
- data/lib/samagotchi/llm/errors.rb +41 -9
- data/lib/samagotchi/llm/http.rb +57 -17
- data/lib/samagotchi/llm/openai_chat.rb +17 -30
- data/lib/samagotchi/log_subscriber.rb +18 -3
- data/lib/samagotchi/memory_bundle/installer.rb +65 -63
- data/lib/samagotchi/memory_bundle/provenance.rb +51 -12
- data/lib/samagotchi/memory_bundle/shipped_update.rb +157 -0
- data/lib/samagotchi/memory_bundle/status.rb +4 -1
- data/lib/samagotchi/memory_bundle/system_bundle.rb +81 -53
- data/lib/samagotchi/model_profile.rb +24 -1
- data/lib/samagotchi/plugin/context.rb +22 -1
- data/lib/samagotchi/plugin/sessions.rb +3 -1
- data/lib/samagotchi/prompt.rb +4 -2
- data/lib/samagotchi/reminder_store.rb +1 -9
- data/lib/samagotchi/reply_wait.rb +126 -0
- data/lib/samagotchi/sampling_settings.rb +58 -0
- data/lib/samagotchi/self_report.rb +18 -3
- data/lib/samagotchi/send_command.rb +252 -11
- data/lib/samagotchi/session.rb +52 -11
- data/lib/samagotchi/session_archive_command.rb +107 -0
- data/lib/samagotchi/session_commands.rb +46 -7
- data/lib/samagotchi/session_manager.rb +115 -25
- data/lib/samagotchi/session_metrics.rb +222 -106
- data/lib/samagotchi/steer.rb +72 -0
- data/lib/samagotchi/terminal_ui/attached_loop.rb +57 -28
- data/lib/samagotchi/terminal_ui/event_renderer.rb +21 -11
- data/lib/samagotchi/terminal_ui/formatting.rb +40 -8
- data/lib/samagotchi/terminal_ui/input_support.rb +7 -19
- data/lib/samagotchi/terminal_ui/question_prompt.rb +35 -0
- data/lib/samagotchi/terminal_ui.rb +134 -247
- data/lib/samagotchi/text_diff.rb +181 -0
- data/lib/samagotchi/thinking.rb +115 -0
- data/lib/samagotchi/tool_activity.rb +3 -1
- data/lib/samagotchi/tool_runner.rb +34 -1
- data/lib/samagotchi/tools/ask_user_question.rb +41 -33
- data/lib/samagotchi/tools/builtins.rb +15 -4
- data/lib/samagotchi/tools/delegate_wait.rb +26 -69
- data/lib/samagotchi/tools/edit.rb +23 -9
- data/lib/samagotchi/tools/execute.rb +52 -14
- data/lib/samagotchi/tools/task_runtime.rb +19 -0
- data/lib/samagotchi/tools/task_wait.rb +27 -3
- data/lib/samagotchi/tools/write.rb +4 -0
- data/lib/samagotchi/turn_flow.rb +12 -2
- data/lib/samagotchi/turn_note.rb +60 -6
- data/lib/samagotchi/update_command.rb +308 -0
- data/lib/samagotchi/update_hint.rb +59 -0
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/vision_support.rb +7 -9
- data/lib/samagotchi/web/app.rb +91 -7
- data/lib/samagotchi/web/message_parts.rb +8 -3
- data/lib/samagotchi/web/public/activity.js +13 -1
- data/lib/samagotchi/web/public/annotate_presets.js +26 -0
- data/lib/samagotchi/web/public/annotations.js +13 -0
- data/lib/samagotchi/web/public/app.js +472 -111
- data/lib/samagotchi/web/public/card.js +5 -3
- data/lib/samagotchi/web/public/chat_view.js +13 -1
- data/lib/samagotchi/web/public/copy.js +20 -4
- data/lib/samagotchi/web/public/ctx.js +15 -0
- data/lib/samagotchi/web/public/data.js +23 -6
- data/lib/samagotchi/web/public/diff_view.js +58 -0
- data/lib/samagotchi/web/public/format.js +9 -0
- data/lib/samagotchi/web/public/index.html +60 -3
- data/lib/samagotchi/web/public/notify.js +175 -0
- data/lib/samagotchi/web/public/question_card.js +5 -2
- data/lib/samagotchi/web/public/sessions_list.js +7 -0
- data/lib/samagotchi/web/public/timing.js +39 -14
- data/lib/samagotchi/web/public/turn_events.js +75 -5
- data/lib/samagotchi/web/public/turn_view.js +49 -8
- data/lib/samagotchi/web/server.rb +8 -4
- data/lib/samagotchi/web/session_hub.rb +2 -1
- data/lib/samagotchi/web/session_summary.rb +24 -1
- data/lib/samagotchi/worker.rb +16 -4
- metadata +31 -1
|
@@ -10,6 +10,8 @@ export const ROW_STATUS = Object.freeze({
|
|
|
10
10
|
RUNNING: "running",
|
|
11
11
|
OK: "ok",
|
|
12
12
|
ERROR: "error",
|
|
13
|
+
// A task_wait the user's Stop ended (the task itself runs on).
|
|
14
|
+
STOPPED: "stopped",
|
|
13
15
|
});
|
|
14
16
|
|
|
15
17
|
// What a row shows for its tool: a plugin tool's label ("chrome:
|
|
@@ -79,16 +81,26 @@ export function addCompleted(model, event = {}) {
|
|
|
79
81
|
});
|
|
80
82
|
row = synthesized.row;
|
|
81
83
|
}
|
|
82
|
-
row.status = event.activity?.status
|
|
84
|
+
row.status = completedStatus(event.activity?.status);
|
|
83
85
|
row.output = event.output || "";
|
|
84
86
|
row.output_truncated = !!event.output_truncated;
|
|
85
87
|
if (event.activity?.params) row.params = event.activity.params;
|
|
86
88
|
// The images the tool returned (a reload in the turn view draws them from
|
|
87
89
|
// the saved parts, turn_view.js reloadRowHtml).
|
|
88
90
|
if (event.images?.length) row.images = event.images;
|
|
91
|
+
// What an edit/write changed in its file (a reload draws it from the
|
|
92
|
+
// saved parts, turn_view.js reloadRowHtml).
|
|
93
|
+
if (event.diff) row.diff = event.diff;
|
|
89
94
|
return row;
|
|
90
95
|
}
|
|
91
96
|
|
|
97
|
+
// A completed call's row status from the server's: error, stopped, else ok.
|
|
98
|
+
export function completedStatus(status) {
|
|
99
|
+
if (status === "error") return ROW_STATUS.ERROR;
|
|
100
|
+
if (status === "stopped") return ROW_STATUS.STOPPED;
|
|
101
|
+
return ROW_STATUS.OK;
|
|
102
|
+
}
|
|
103
|
+
|
|
92
104
|
// Mark a turn's activity model as finalized (rows stay; rendering collapses).
|
|
93
105
|
export function finalizeActivity(model) {
|
|
94
106
|
if (model) model.finalized = true;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Annotate presets: quick replies next to "Annotate" in the selection bubble
|
|
2
|
+
// (web.annotate_presets, "Agreed|Could you please elaborate?"). A preset
|
|
3
|
+
// fills the composer with the quote and its text as the note; it never
|
|
4
|
+
// sends. Its own module, not more exports on annotations.js: static files
|
|
5
|
+
// are cached at unversioned URLs, and a fresh app.js importing a missing
|
|
6
|
+
// export from a cached annotations.js would fail to link.
|
|
7
|
+
|
|
8
|
+
export const MAX_PRESETS = 5;
|
|
9
|
+
|
|
10
|
+
// The presets in +raw+ ("a|b|c"): trimmed, blanks and repeats dropped, at
|
|
11
|
+
// most MAX_PRESETS. A preset can't hold "|".
|
|
12
|
+
export function parsePresets(raw) {
|
|
13
|
+
const out = [];
|
|
14
|
+
for (const part of String(raw ?? "").split("|")) {
|
|
15
|
+
const text = part.trim();
|
|
16
|
+
if (text && !out.includes(text)) out.push(text);
|
|
17
|
+
if (out.length === MAX_PRESETS) break;
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// The quote +block+ (from quoteBlock, ending in a blank line) with +text+
|
|
23
|
+
// as its note.
|
|
24
|
+
export function presetNote(block, text) {
|
|
25
|
+
return `${block}${text}`;
|
|
26
|
+
}
|
|
@@ -65,3 +65,16 @@ export function appendQuote(value, block) {
|
|
|
65
65
|
const before = String(value ?? "").replace(/\s+$/, "");
|
|
66
66
|
return before ? `${before}\n\n${block}` : block;
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
// The Annotate bar's left edge (fixed position, px) under the selection's
|
|
70
|
+
// last line (+rect+: its {left, right}): right-aligned to where the
|
|
71
|
+
// selection ends; where that would clamp to the page gutter (a selection
|
|
72
|
+
// ending near the bubble's left edge), left-aligned to where the selection
|
|
73
|
+
// starts on that line instead, so the bar stays by the text.
|
|
74
|
+
// @param width the bar's width; @param viewport the window's inner width
|
|
75
|
+
export function annotateBarLeft(rect, width, viewport, gutter = 8) {
|
|
76
|
+
const max = viewport - width - gutter;
|
|
77
|
+
const right = rect.right - width;
|
|
78
|
+
const left = right < gutter ? rect.left : right;
|
|
79
|
+
return Math.max(Math.min(left, max), gutter);
|
|
80
|
+
}
|