openclacky 1.5.25 → 1.5.26
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 -0
- data/lib/clacky/agent/chunk_index.rb +2 -1
- data/lib/clacky/agent/message_compressor_helper.rb +20 -2
- data/lib/clacky/agent/session_serializer.rb +28 -1
- data/lib/clacky/agent/skill_manager.rb +2 -8
- data/lib/clacky/agent/time_machine.rb +108 -127
- data/lib/clacky/agent/tool_executor.rb +2 -11
- data/lib/clacky/agent.rb +15 -19
- data/lib/clacky/agent_config.rb +14 -4
- data/lib/clacky/billing/media_usage.rb +69 -0
- data/lib/clacky/billing/platform_billing.rb +5 -0
- data/lib/clacky/brand_config.rb +16 -215
- data/lib/clacky/default_extensions/ext-studio/agents/ext-developer/system_prompt.md +2 -80
- data/lib/clacky/default_extensions/ext-studio/panels/studio/view.js +1 -1
- data/lib/clacky/default_extensions/ext-studio/skills/ext-develop/SKILL.md +10 -96
- data/lib/clacky/default_extensions/git/panels/git/view.js +208 -69
- data/lib/clacky/default_extensions/knowledge/README.md +1 -1
- data/lib/clacky/default_extensions/knowledge/README.zh.md +1 -1
- data/lib/clacky/default_extensions/knowledge/lib/importer.rb +1 -1
- data/lib/clacky/default_extensions/knowledge/panels/kb/view.js +3 -3
- data/lib/clacky/default_extensions/meeting/api/handler.rb +23 -2
- data/lib/clacky/default_extensions/meeting/panels/meeting/view.js +194 -36
- data/lib/clacky/default_extensions/preview/icon.svg +3 -2
- data/lib/clacky/default_extensions/secretary/panels/work/view.js +108 -33
- data/lib/clacky/default_extensions/side-chat/README.md +40 -0
- data/lib/clacky/default_extensions/side-chat/README.zh.md +40 -0
- data/lib/clacky/default_extensions/side-chat/api/handler.rb +90 -0
- data/lib/clacky/default_extensions/side-chat/api/runtime.rb +411 -0
- data/lib/clacky/default_extensions/side-chat/ext.yml +16 -0
- data/lib/clacky/default_extensions/side-chat/icon.svg +14 -0
- data/lib/clacky/default_extensions/side-chat/panels/side-chat/view.js +779 -0
- data/lib/clacky/default_extensions/terminal/README.md +36 -0
- data/lib/clacky/default_extensions/terminal/README.zh.md +36 -0
- data/lib/clacky/default_extensions/terminal/api/handler.rb +121 -0
- data/lib/clacky/default_extensions/terminal/api/runtime.rb +397 -0
- data/lib/clacky/default_extensions/terminal/ext.yml +16 -0
- data/lib/clacky/default_extensions/terminal/icon.svg +13 -0
- data/lib/clacky/default_extensions/terminal/panels/terminal/view.js +351 -0
- data/lib/clacky/default_extensions/terminal/vendor/LICENSE +21 -0
- data/lib/clacky/default_extensions/terminal/vendor/addon-fit.js +2 -0
- data/lib/clacky/default_extensions/terminal/vendor/xterm.css +218 -0
- data/lib/clacky/default_extensions/terminal/vendor/xterm.js +2 -0
- data/lib/clacky/default_skills/media-gen/SKILL.md +30 -9
- data/lib/clacky/extension/api_extension.rb +12 -0
- data/lib/clacky/locales/en.rb +14 -11
- data/lib/clacky/locales/i18n.rb +25 -0
- data/lib/clacky/locales/zh.rb +14 -11
- data/lib/clacky/media/base.rb +11 -1
- data/lib/clacky/media/openai_compat.rb +271 -3
- data/lib/clacky/message_format/open_ai.rb +17 -0
- data/lib/clacky/prompts/base.md +3 -0
- data/lib/clacky/providers.rb +33 -20
- data/lib/clacky/reasoning_levels.rb +75 -0
- data/lib/clacky/server/channel/channel_ui_controller.rb +12 -5
- data/lib/clacky/server/git_panel.rb +40 -18
- data/lib/clacky/server/http_server.rb +62 -71
- data/lib/clacky/server/session_registry.rb +3 -0
- data/lib/clacky/ui2/markdown_renderer.rb +153 -0
- data/lib/clacky/ui2/strings_cjk_patch.rb +134 -124
- data/lib/clacky/utils/file_link_normalizer.rb +30 -3
- data/lib/clacky/utils/frontmatter.rb +63 -0
- data/lib/clacky/utils/model_pricing.rb +67 -9
- data/lib/clacky/version.rb +1 -1
- data/lib/clacky/web/app.css +722 -274
- data/lib/clacky/web/app.js +2 -0
- data/lib/clacky/web/components/chat-composer.js +504 -0
- data/lib/clacky/web/components/chat-navigator.js +1 -1
- data/lib/clacky/web/components/model-picker.js +319 -20
- data/lib/clacky/web/components/quote-select.js +97 -39
- data/lib/clacky/web/core/aside.js +137 -27
- data/lib/clacky/web/core/ext.js +658 -81
- data/lib/clacky/web/features/brand/store.js +0 -4
- data/lib/clacky/web/features/brand/view.js +2 -99
- data/lib/clacky/web/features/extensions/store.js +3 -1
- data/lib/clacky/web/features/extensions/view.js +14 -15
- data/lib/clacky/web/features/new-session/store.js +4 -0
- data/lib/clacky/web/features/new-session/view.js +27 -4
- data/lib/clacky/web/features/skills/store.js +7 -5
- data/lib/clacky/web/features/skills/view.js +65 -16
- data/lib/clacky/web/features/version/view.js +1 -1
- data/lib/clacky/web/features/workspace/store.js +7 -3
- data/lib/clacky/web/features/workspace/view.js +46 -5
- data/lib/clacky/web/i18n.js +104 -58
- data/lib/clacky/web/index.html +21 -22
- data/lib/clacky/web/lib/box-diagram.js +239 -0
- data/lib/clacky/web/sessions.js +117 -151
- data/lib/clacky/web/settings.js +23 -16
- data/lib/clacky/web/ws-dispatcher.js +4 -1
- data/lib/clacky.rb +2 -0
- metadata +24 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 32f7ab3c944b0d29c9a93c5723ec39d545a6c30eb2689fe556ed346afebfad7e
|
|
4
|
+
data.tar.gz: 3b412ba1c37d2eff9b6887d37f25cc50ede7fcffa2cd3b0b09d904e7b18d76b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f659b2ef70871f649e01ba21fb1531d4654549a578694571a9225b2e0ce73120086e69fca799888f4414c17413d0f190ac58081ecab2999bcddccfbf05bdd1d
|
|
7
|
+
data.tar.gz: 8112ba69362fd897ce5568c698889b7cacbd2e8f7100709863ee6fbdc10309ca4bfeb98074333534d1fb362b32c39b9656b106e8f4922fe6a31937507a713cf7
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,67 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
|
|
7
|
+
## [1.5.26] - 2026-11-27
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Add a read-only side chat to the session side panel for quick questions that stay out of the main thread
|
|
11
|
+
- Add a terminal panel to the session side panel
|
|
12
|
+
- Turn the side panel into a per-session tab strip with a picker, so a closed panel stops fetching
|
|
13
|
+
- Open a context menu from a side panel tab
|
|
14
|
+
- Synthesize speech through DeepSeek's own endpoint, about six times faster than Gemini
|
|
15
|
+
- Default transcription to DeepSeek ASR and bill every transcription path by usage
|
|
16
|
+
- Tell you when no speech-to-text model is configured, with a link straight to the settings row
|
|
17
|
+
- Add Gemini 4 Hydrogen and retire Neon and Carbon
|
|
18
|
+
- Regroup the sidebar navigation into General and More
|
|
19
|
+
- Offer only the reasoning stops a model actually supports
|
|
20
|
+
- Offer reasoning stops when starting a session from the new-session page
|
|
21
|
+
- Localize tool progress phrases for the terminal, the web UI and IM cards
|
|
22
|
+
- Add status badges and a card layout to the secretary work panel
|
|
23
|
+
- Prefer tables over ASCII box art when the model answers
|
|
24
|
+
|
|
25
|
+
### Improved
|
|
26
|
+
- Let each promo surface be dismissed on its own, and outline the media settings row when the meeting panel links to it
|
|
27
|
+
- Show one separator line under the side tab strip
|
|
28
|
+
- Drop the brand licence banners and soften the skills degradation notice
|
|
29
|
+
- Stop auto-syncing brand skills
|
|
30
|
+
- Stop auto-installing brand extensions
|
|
31
|
+
- Widen the side panel minimum from 256px to 296px
|
|
32
|
+
- Narrow the working-directory pill
|
|
33
|
+
- Loosen chat message font size and line height
|
|
34
|
+
- Rename the permission pill to question mode
|
|
35
|
+
- Tighten the chat navigator ticks
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
- Keep a Time Machine restore inside the active-to-target path and the working directory (#757)
|
|
39
|
+
- Keep switched-off extensions reachable in the installed tab
|
|
40
|
+
- Ignore stale transcription results after a meeting is cancelled (#755)
|
|
41
|
+
- Make meeting voice detection work across microphone gains and hidden tabs
|
|
42
|
+
- Keep the git scope pills whole when the tool bar wraps (#756)
|
|
43
|
+
- Fall back to the file name as a knowledge entry source (#754)
|
|
44
|
+
- Keep non-file angle-bracket links intact in outbound IM text
|
|
45
|
+
- Turn bare paths containing spaces or parentheses into clickable file links (#753)
|
|
46
|
+
- Reset the files panel when the working directory changes (#752)
|
|
47
|
+
- Keep the git panel tool row flush left when the bar wraps (#751)
|
|
48
|
+
- Order git branches by their most recent commit (#747)
|
|
49
|
+
- Use neutral copy for unloaded diff placeholders (#749)
|
|
50
|
+
- Review the picked branch instead of everything since its fork (#745)
|
|
51
|
+
- Mount git file sections in batches so large reviews stay responsive (#744)
|
|
52
|
+
- Keep memory frontmatter when a value parses as a date
|
|
53
|
+
- Share the memory-inject toggle across live sessions (#742)
|
|
54
|
+
- Keep reference chips after a conversation is compressed (#743)
|
|
55
|
+
- Launch agent-pinned skills under their agent
|
|
56
|
+
- Collapse the side column when its last tab closes
|
|
57
|
+
- Align box-drawing diagrams by display width in chat code blocks and the terminal
|
|
58
|
+
- Wrap coloured terminal text by tokens instead of character offsets
|
|
59
|
+
- Keep terminal connector labels out of the frame padding
|
|
60
|
+
- Show the changelog link in the upgrade popover of branded builds
|
|
61
|
+
- Clarify the GPT Image 2 model hint (#746)
|
|
62
|
+
|
|
63
|
+
### More
|
|
64
|
+
- Trim the extension developer prompt and skill to one source of truth
|
|
65
|
+
- Shorten the side picker group titles to Official and Mine
|
|
66
|
+
- Weight the side panel group titles at 500
|
|
67
|
+
|
|
7
68
|
## [1.5.25] - 2026-11-20
|
|
8
69
|
|
|
9
70
|
### Added
|
|
@@ -70,7 +70,8 @@ module Clacky
|
|
|
70
70
|
# retaining the rest of the user message or any assistant text.
|
|
71
71
|
visible, events = extract_ext_events_from_text(text)
|
|
72
72
|
visible, files = extract_display_files_from_text(visible)
|
|
73
|
-
|
|
73
|
+
visible, references = extract_display_references_from_text(visible)
|
|
74
|
+
next if visible.empty? && events.empty? && files.empty? && references.empty?
|
|
74
75
|
|
|
75
76
|
rounds.last[:length] = user_start - rounds.last[:start] if rounds.any?
|
|
76
77
|
rounds << { start: user_start, task_id: user_task_id }
|
|
@@ -51,7 +51,7 @@ module Clacky
|
|
|
51
51
|
rescue Clacky::AgentInterrupted => e
|
|
52
52
|
# User cancelled the idle compression — finish the quiet progress
|
|
53
53
|
# slot in place so the user sees exactly what happened (rather
|
|
54
|
-
# than the "
|
|
54
|
+
# than the "compressing" line being silently removed).
|
|
55
55
|
final = "Idle compression cancelled: #{e.message}"
|
|
56
56
|
if handle
|
|
57
57
|
handle.finish(final_message: final)
|
|
@@ -92,7 +92,7 @@ module Clacky
|
|
|
92
92
|
if @ui
|
|
93
93
|
result = nil
|
|
94
94
|
@ui.with_progress(
|
|
95
|
-
message: "
|
|
95
|
+
message: Clacky::I18n.t("progress.compressing_idle"),
|
|
96
96
|
style: :quiet
|
|
97
97
|
) do |handle|
|
|
98
98
|
result = run_compression.call(handle)
|
|
@@ -656,6 +656,7 @@ module Clacky
|
|
|
656
656
|
lines << format_archived_user_content(content, display_files)
|
|
657
657
|
lines << ""
|
|
658
658
|
append_display_files_line(lines, display_files)
|
|
659
|
+
append_display_references_line(lines, msg)
|
|
659
660
|
append_ext_events_line(lines, msg)
|
|
660
661
|
when "assistant"
|
|
661
662
|
# If this message is itself a compressed summary, annotate the header
|
|
@@ -760,6 +761,23 @@ module Clacky
|
|
|
760
761
|
lines << ""
|
|
761
762
|
end
|
|
762
763
|
|
|
764
|
+
# Serialize reference chips (@mention, quoted excerpt) so they survive
|
|
765
|
+
# compression — the bubble keeps the badge it had before archiving. The
|
|
766
|
+
# model-facing `context` is dropped here: it is re-derivable from the
|
|
767
|
+
# message body it belongs to, and the archive is a UI replay source, not a
|
|
768
|
+
# second copy of the prompt payload.
|
|
769
|
+
def append_display_references_line(lines, msg)
|
|
770
|
+
references = Array(msg[:display_references]).filter_map do |ref|
|
|
771
|
+
next unless ref.is_a?(Hash)
|
|
772
|
+
|
|
773
|
+
ref.reject { |key, _| key.to_s == "context" }
|
|
774
|
+
end
|
|
775
|
+
return if references.empty?
|
|
776
|
+
|
|
777
|
+
lines << "_Display references: #{references.to_json}_"
|
|
778
|
+
lines << ""
|
|
779
|
+
end
|
|
780
|
+
|
|
763
781
|
def append_created_at_line(lines, msg)
|
|
764
782
|
return unless msg[:created_at].is_a?(Numeric)
|
|
765
783
|
|
|
@@ -521,6 +521,7 @@ module Clacky
|
|
|
521
521
|
text = sec[:lines].join.strip
|
|
522
522
|
text, sec_ext_events = extract_ext_events_from_text(text)
|
|
523
523
|
text, sec_display_files = extract_display_files_from_text(text)
|
|
524
|
+
text, sec_display_references = extract_display_references_from_text(text)
|
|
524
525
|
|
|
525
526
|
# Nested chunk: expand it recursively, prepend before current rounds
|
|
526
527
|
if sec[:nested_chunk]
|
|
@@ -537,7 +538,7 @@ module Clacky
|
|
|
537
538
|
next
|
|
538
539
|
end
|
|
539
540
|
|
|
540
|
-
next if text.empty? && sec_ext_events.empty? && sec_display_files.empty?
|
|
541
|
+
next if text.empty? && sec_ext_events.empty? && sec_display_files.empty? && sec_display_references.empty?
|
|
541
542
|
|
|
542
543
|
if sec[:role] == "user"
|
|
543
544
|
round_index += 1
|
|
@@ -552,6 +553,7 @@ module Clacky
|
|
|
552
553
|
}
|
|
553
554
|
user_msg[:task_id] = sec[:task_id] if sec[:task_id]
|
|
554
555
|
user_msg[:display_files] = sec_display_files unless sec_display_files.empty?
|
|
556
|
+
user_msg[:display_references] = sec_display_references unless sec_display_references.empty?
|
|
555
557
|
current_round = {
|
|
556
558
|
user_msg: user_msg,
|
|
557
559
|
events: [],
|
|
@@ -656,6 +658,31 @@ module Clacky
|
|
|
656
658
|
[kept.join.strip, files]
|
|
657
659
|
end
|
|
658
660
|
|
|
661
|
+
# Pull the "_Display references: [...]_" line out of a chunk section,
|
|
662
|
+
# returning the remaining text plus the reference chips. Counterpart to
|
|
663
|
+
# MessageCompressorHelper#append_display_references_line. Keys are
|
|
664
|
+
# symbolized because replay passes the chips straight to the UI.
|
|
665
|
+
def extract_display_references_from_text(text)
|
|
666
|
+
return [text, []] unless text.include?("_Display references:")
|
|
667
|
+
|
|
668
|
+
references = []
|
|
669
|
+
kept = text.each_line.reject do |line|
|
|
670
|
+
match = line.strip.match(/\A_Display references:\s*(\[.*\])_?\z/i)
|
|
671
|
+
next false unless match
|
|
672
|
+
|
|
673
|
+
parsed = JSON.parse(match[1], symbolize_names: true) rescue []
|
|
674
|
+
Array(parsed).each do |ref|
|
|
675
|
+
next unless ref.is_a?(Hash)
|
|
676
|
+
next if (ref[:type] || ref["type"]).to_s.empty?
|
|
677
|
+
|
|
678
|
+
references << ref
|
|
679
|
+
end
|
|
680
|
+
true
|
|
681
|
+
end
|
|
682
|
+
|
|
683
|
+
[kept.join.strip, references]
|
|
684
|
+
end
|
|
685
|
+
|
|
659
686
|
|
|
660
687
|
# Pull the "_Ext events: type | {json}; ..._" line out of a chunk section,
|
|
661
688
|
# returning the remaining text plus the parsed events. Counterpart to
|
|
@@ -554,14 +554,8 @@ module Clacky
|
|
|
554
554
|
# @param path [String] Absolute path to the .md file
|
|
555
555
|
# @return [Hash]
|
|
556
556
|
def parse_memory_frontmatter(path)
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
match = content.match(/\A---\n(.*?)\n---/m)
|
|
561
|
-
return {} unless match
|
|
562
|
-
|
|
563
|
-
YAML.safe_load(match[1]) || {}
|
|
564
|
-
rescue => e
|
|
557
|
+
Utils::Frontmatter.parse(File.read(path))
|
|
558
|
+
rescue StandardError
|
|
565
559
|
{}
|
|
566
560
|
end
|
|
567
561
|
|
|
@@ -108,8 +108,14 @@ module Clacky
|
|
|
108
108
|
def record_file_before_change(file_path)
|
|
109
109
|
return if @current_task_id.to_i <= 0
|
|
110
110
|
|
|
111
|
+
# Only the working dir is restorable. A file outside it has no relative
|
|
112
|
+
# path to key a snapshot, and its basename alone would alias it onto an
|
|
113
|
+
# unrelated file at the working-dir root when the snapshot is replayed.
|
|
114
|
+
root = File.expand_path(@working_dir)
|
|
111
115
|
full_path = File.expand_path(file_path.to_s, @working_dir)
|
|
112
|
-
|
|
116
|
+
return unless full_path.start_with?(root + "/")
|
|
117
|
+
|
|
118
|
+
rel = full_path.sub(root + "/", "")
|
|
113
119
|
before_dir = File.join(TimeMachine.session_dir(@session_id), "task-#{@current_task_id}", "before")
|
|
114
120
|
snapshot_file = File.join(before_dir, rel)
|
|
115
121
|
marker_file = "#{snapshot_file}.#{ABSENT_MARKER}"
|
|
@@ -170,18 +176,11 @@ module Clacky
|
|
|
170
176
|
|
|
171
177
|
# Restore files to the on-disk state at the END of the given task.
|
|
172
178
|
#
|
|
173
|
-
# History is a TREE (undo + a new message forks a sibling branch), so
|
|
174
|
-
#
|
|
175
|
-
#
|
|
176
|
-
#
|
|
177
|
-
#
|
|
178
|
-
# * Each task owns an AFTER snapshot = the content of the files it
|
|
179
|
-
# touched, as they looked when that task finished.
|
|
180
|
-
# * To rebuild "end of task T", walk T's ancestor chain (T -> root).
|
|
181
|
-
# For every file ever touched in the whole session, the winning
|
|
182
|
-
# content is the closest ancestor (starting at T) whose AFTER holds
|
|
183
|
-
# that file. If no ancestor on the chain ever touched it, the file
|
|
184
|
-
# did not exist at T and is removed.
|
|
179
|
+
# History is a TREE (undo + a new message forks a sibling branch), so the
|
|
180
|
+
# move goes through the common ancestor of the active task and T: the
|
|
181
|
+
# active branch's tasks are unwound and T's branch is replayed. Only the
|
|
182
|
+
# files those tasks touched are rewritten; everything else on disk may
|
|
183
|
+
# have changed outside the Time Machine since and is left alone.
|
|
185
184
|
#
|
|
186
185
|
# @param task_id [Integer] Target task ID
|
|
187
186
|
# Made public for testing
|
|
@@ -203,67 +202,80 @@ module Clacky
|
|
|
203
202
|
raise
|
|
204
203
|
end
|
|
205
204
|
|
|
206
|
-
# Decide, for every file
|
|
207
|
-
#
|
|
208
|
-
# function over the snapshot tree — does not touch the working dir.
|
|
205
|
+
# Decide, for every file touched between the active task and `task_id`,
|
|
206
|
+
# whether restoring should overwrite it with a snapshot or delete it.
|
|
207
|
+
# Pure function over the snapshot tree — does not touch the working dir.
|
|
209
208
|
# @return [Hash{String => Hash}] rel_path => { action: :delete | :restore, source: String|nil }
|
|
210
209
|
private def build_restore_plan(task_id)
|
|
211
210
|
session_root = TimeMachine.session_dir(@session_id)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
all_rels = Set.new
|
|
221
|
-
Dir.glob(File.join(session_root, "task-*", "before", "**", "*"), File::FNM_DOTMATCH).each do |path|
|
|
222
|
-
next if File.directory?(path)
|
|
223
|
-
rel = path.sub(%r{\A.*/before/}, "")
|
|
224
|
-
rel = rel.sub(/\.#{Regexp.escape(ABSENT_MARKER)}\z/, "")
|
|
225
|
-
all_rels << rel
|
|
226
|
-
end
|
|
211
|
+
from_chain = task_ancestors(@active_task_id)
|
|
212
|
+
target_chain = task_ancestors(task_id)
|
|
213
|
+
from_set = from_chain.to_set
|
|
214
|
+
target_set = target_chain.to_set
|
|
215
|
+
replay = target_chain.take_while { |tid| !from_set.include?(tid) }
|
|
216
|
+
unwind = from_chain.take_while { |tid| !target_set.include?(tid) }
|
|
227
217
|
|
|
228
218
|
plan = {}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
action = :delete
|
|
246
|
-
matched = true
|
|
247
|
-
break
|
|
219
|
+
decided = Set.new
|
|
220
|
+
|
|
221
|
+
# A file the target branch touched ends as its nearest toucher left it.
|
|
222
|
+
# Without that AFTER there is no evidence, so the file is left alone.
|
|
223
|
+
replay.each do |tid|
|
|
224
|
+
before_dir = File.join(session_root, "task-#{tid}", "before")
|
|
225
|
+
after_dir = File.join(session_root, "task-#{tid}", "after")
|
|
226
|
+
snapshot_rels(before_dir).each do |rel|
|
|
227
|
+
next unless decided.add?(rel)
|
|
228
|
+
|
|
229
|
+
case file_change_status(before_dir, after_dir, rel)
|
|
230
|
+
when "deleted"
|
|
231
|
+
plan[rel] = { action: :delete, source: nil }
|
|
232
|
+
when "added", "modified"
|
|
233
|
+
content, = snapshot_paths(after_dir, rel)
|
|
234
|
+
plan[rel] = { action: :restore, source: content } if content
|
|
248
235
|
end
|
|
249
236
|
end
|
|
237
|
+
end
|
|
250
238
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
239
|
+
# Otherwise it is back to the common ancestor's end state, which is the
|
|
240
|
+
# BEFORE of the unwound task closest to that ancestor.
|
|
241
|
+
unwind.reverse_each do |tid|
|
|
242
|
+
before_dir = File.join(session_root, "task-#{tid}", "before")
|
|
243
|
+
snapshot_rels(before_dir).each do |rel|
|
|
244
|
+
next unless decided.add?(rel)
|
|
245
|
+
|
|
246
|
+
content, absent = snapshot_paths(before_dir, rel)
|
|
247
|
+
if content
|
|
248
|
+
plan[rel] = { action: :restore, source: content }
|
|
249
|
+
elsif absent
|
|
250
|
+
plan[rel] = { action: :delete, source: nil }
|
|
258
251
|
end
|
|
259
252
|
end
|
|
260
|
-
|
|
261
|
-
plan[rel] = { action: action, source: source }
|
|
262
253
|
end
|
|
263
254
|
|
|
264
255
|
plan
|
|
265
256
|
end
|
|
266
257
|
|
|
258
|
+
# Task IDs from `task_id` up to (excluding) the root task 0.
|
|
259
|
+
private def task_ancestors(task_id)
|
|
260
|
+
chain = []
|
|
261
|
+
tid = task_id
|
|
262
|
+
until tid.nil? || tid <= 0 || chain.include?(tid)
|
|
263
|
+
chain << tid
|
|
264
|
+
tid = @task_parents[tid]
|
|
265
|
+
end
|
|
266
|
+
chain
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
private def snapshot_rels(dir)
|
|
270
|
+
return [] unless Dir.exist?(dir)
|
|
271
|
+
|
|
272
|
+
Dir.glob(File.join(dir, "**", "*"), File::FNM_DOTMATCH).filter_map do |path|
|
|
273
|
+
next if File.directory?(path)
|
|
274
|
+
|
|
275
|
+
path.sub(dir + "/", "").sub(/\.#{Regexp.escape(ABSENT_MARKER)}\z/, "")
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
267
279
|
# Preview the file-level effect of restore_to_task_state(task_id) without
|
|
268
280
|
# touching disk. Compares the resolved restore plan against the current
|
|
269
281
|
# working-dir state and returns only files that would actually change.
|
|
@@ -303,35 +315,8 @@ module Clacky
|
|
|
303
315
|
false
|
|
304
316
|
end
|
|
305
317
|
|
|
306
|
-
#
|
|
307
|
-
#
|
|
308
|
-
# path to copy back, or nil if the earliest record is an absent marker
|
|
309
|
-
# (file did not exist at the session start).
|
|
310
|
-
private def earliest_before_snapshot(session_root, rel)
|
|
311
|
-
task_ids = Dir.glob(File.join(session_root, "task-*")).filter_map do |dir|
|
|
312
|
-
m = File.basename(dir).match(/\Atask-(\d+)\z/)
|
|
313
|
-
m && m[1].to_i
|
|
314
|
-
end.sort
|
|
315
|
-
|
|
316
|
-
task_ids.each do |tid|
|
|
317
|
-
before_dir = File.join(session_root, "task-#{tid}", "before")
|
|
318
|
-
content_path = File.join(before_dir, rel)
|
|
319
|
-
absent_path = "#{content_path}.#{ABSENT_MARKER}"
|
|
320
|
-
return content_path if File.exist?(content_path)
|
|
321
|
-
return nil if File.exist?(absent_path)
|
|
322
|
-
end
|
|
323
|
-
nil
|
|
324
|
-
end
|
|
325
|
-
|
|
326
|
-
# Relative path used to key a snapshot. Files inside the working dir keep
|
|
327
|
-
# their relative path; anything else falls back to its basename.
|
|
328
|
-
private def snapshot_relative_path(full_path)
|
|
329
|
-
if full_path.start_with?(@working_dir + "/")
|
|
330
|
-
full_path.sub(@working_dir + "/", "")
|
|
331
|
-
else
|
|
332
|
-
File.basename(full_path)
|
|
333
|
-
end
|
|
334
|
-
end
|
|
318
|
+
# Files inside the working dir keep their relative path; anything else is
|
|
319
|
+
# not snapshotted at all (see record_file_before_change).
|
|
335
320
|
|
|
336
321
|
# Filter messages to only the active task's ancestor chain.
|
|
337
322
|
# After an undo (and especially after sending a NEW message post-undo,
|
|
@@ -406,9 +391,9 @@ module Clacky
|
|
|
406
391
|
@task_parents.select { |_, parent| parent == task_id }.keys
|
|
407
392
|
end
|
|
408
393
|
|
|
409
|
-
# Cheap version of task_diff_files: just count how many
|
|
410
|
-
#
|
|
411
|
-
# paying for a full diff walk per row.
|
|
394
|
+
# Cheap version of task_diff_files: just count how many files this task
|
|
395
|
+
# actually changed, so the timeline can grey out no-op tasks without
|
|
396
|
+
# paying for a full diff walk (no file content is read) per row.
|
|
412
397
|
def task_change_count(task_id)
|
|
413
398
|
return 0 unless task_id.is_a?(Integer) && task_id > 0
|
|
414
399
|
|
|
@@ -418,16 +403,9 @@ module Clacky
|
|
|
418
403
|
return 0 unless Dir.exist?(before_dir)
|
|
419
404
|
return 0 if task_id == @current_task_id && @latest_after_dirty == true && !Dir.exist?(after_dir)
|
|
420
405
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
next unless Dir.exist?(root)
|
|
424
|
-
Dir.glob(File.join(root, "**", "*"), File::FNM_DOTMATCH).each do |path|
|
|
425
|
-
next if File.directory?(path)
|
|
426
|
-
rel = path.sub(root + "/", "").sub(/\.#{Regexp.escape(ABSENT_MARKER)}\z/, "")
|
|
427
|
-
rels << rel
|
|
428
|
-
end
|
|
406
|
+
task_snapshot_rels(before_dir, after_dir).count do |rel|
|
|
407
|
+
file_change_status(before_dir, after_dir, rel)
|
|
429
408
|
end
|
|
430
|
-
rels.size
|
|
431
409
|
end
|
|
432
410
|
|
|
433
411
|
# File-level summary of changes a task introduced. Diff is task-N/before
|
|
@@ -444,39 +422,42 @@ module Clacky
|
|
|
444
422
|
return [] unless Dir.exist?(before_dir)
|
|
445
423
|
return [] if task_id == @current_task_id && @latest_after_dirty == true && !Dir.exist?(after_dir)
|
|
446
424
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
next unless
|
|
450
|
-
Dir.glob(File.join(root, "**", "*"), File::FNM_DOTMATCH).each do |path|
|
|
451
|
-
next if File.directory?(path)
|
|
452
|
-
rel = path.sub(root + "/", "").sub(/\.#{Regexp.escape(ABSENT_MARKER)}\z/, "")
|
|
453
|
-
rels << rel
|
|
454
|
-
end
|
|
455
|
-
end
|
|
456
|
-
|
|
457
|
-
rels.sort.map do |rel|
|
|
458
|
-
before_file, before_absent = snapshot_paths(before_dir, rel)
|
|
459
|
-
after_file, after_absent = snapshot_paths(after_dir, rel)
|
|
460
|
-
|
|
461
|
-
status = if before_absent && after_file
|
|
462
|
-
"added"
|
|
463
|
-
elsif before_file && after_absent
|
|
464
|
-
"deleted"
|
|
465
|
-
elsif before_file && after_file
|
|
466
|
-
"modified"
|
|
467
|
-
elsif before_file && !File.exist?(after_dir)
|
|
468
|
-
# No AFTER captured (e.g. the very latest task) — still surface
|
|
469
|
-
# what was touched as "modified" so the UI can list the file.
|
|
470
|
-
"modified"
|
|
471
|
-
else
|
|
472
|
-
"modified"
|
|
473
|
-
end
|
|
425
|
+
task_snapshot_rels(before_dir, after_dir).sort.filter_map do |rel|
|
|
426
|
+
status = file_change_status(before_dir, after_dir, rel)
|
|
427
|
+
next unless status
|
|
474
428
|
|
|
429
|
+
before_file, = snapshot_paths(before_dir, rel)
|
|
430
|
+
after_file, = snapshot_paths(after_dir, rel)
|
|
475
431
|
binary = looks_binary?(before_file) || looks_binary?(after_file)
|
|
476
432
|
{ path: rel, status: status, binary: binary }
|
|
477
433
|
end
|
|
478
434
|
end
|
|
479
435
|
|
|
436
|
+
# Every file path mentioned by either side of a task's snapshots.
|
|
437
|
+
private def task_snapshot_rels(before_dir, after_dir)
|
|
438
|
+
snapshot_rels(before_dir) | snapshot_rels(after_dir)
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
# Status of one file between its BEFORE and AFTER snapshots, or nil when
|
|
442
|
+
# the task left no net change — both sides say the file was absent, e.g.
|
|
443
|
+
# it created a scratch file and removed it within the same task.
|
|
444
|
+
private def file_change_status(before_dir, after_dir, rel)
|
|
445
|
+
before_file, before_absent = snapshot_paths(before_dir, rel)
|
|
446
|
+
after_file, after_absent = snapshot_paths(after_dir, rel)
|
|
447
|
+
|
|
448
|
+
if before_absent && after_file
|
|
449
|
+
"added"
|
|
450
|
+
elsif before_file && after_absent
|
|
451
|
+
"deleted"
|
|
452
|
+
elsif before_file && after_file
|
|
453
|
+
"modified"
|
|
454
|
+
elsif before_file
|
|
455
|
+
# No AFTER captured yet (the task is still the latest) — still
|
|
456
|
+
# surface what was touched so the UI can list the file.
|
|
457
|
+
"modified"
|
|
458
|
+
end
|
|
459
|
+
end
|
|
460
|
+
|
|
480
461
|
# Unified diff of a single file for a task. Returns nil if either side
|
|
481
462
|
# is missing or binary. text format = "@@ ... @@" patch (3-context),
|
|
482
463
|
# ready for the UI to render with a diff renderer.
|
|
@@ -287,17 +287,8 @@ module Clacky
|
|
|
287
287
|
end
|
|
288
288
|
end
|
|
289
289
|
|
|
290
|
-
private def build_tool_progress_message(tool_name
|
|
291
|
-
|
|
292
|
-
when 'terminal'
|
|
293
|
-
"Running command"
|
|
294
|
-
when 'web_fetch'
|
|
295
|
-
"Fetching web page"
|
|
296
|
-
when 'web_search'
|
|
297
|
-
"Searching web"
|
|
298
|
-
else
|
|
299
|
-
"Executing #{tool_name}"
|
|
300
|
-
end
|
|
290
|
+
private def build_tool_progress_message(tool_name)
|
|
291
|
+
Clacky::I18n.tool_progress(tool_name)
|
|
301
292
|
end
|
|
302
293
|
|
|
303
294
|
# Inject TODO reminder into tool results for non-todo_manager tools
|
data/lib/clacky/agent.rb
CHANGED
|
@@ -16,6 +16,7 @@ require_relative "agent/message_compressor"
|
|
|
16
16
|
require_relative "agent/message_compressor_helper"
|
|
17
17
|
require_relative "agent/tool_executor"
|
|
18
18
|
require_relative "agent/cost_tracker"
|
|
19
|
+
require_relative "billing/media_usage"
|
|
19
20
|
require_relative "agent/session_serializer"
|
|
20
21
|
require_relative "agent/skill_manager"
|
|
21
22
|
require_relative "agent/system_prompt_builder"
|
|
@@ -177,15 +178,6 @@ module Clacky
|
|
|
177
178
|
# invoke those endpoints via curl, so MCP behaves like any other skill.
|
|
178
179
|
@skill_loader.attach_virtual_skill_provider(Mcp::SkillProvider.new(working_dir: @working_dir))
|
|
179
180
|
|
|
180
|
-
# Background sync: compare remote skill versions and download updates quietly.
|
|
181
|
-
# Runs in a daemon thread so Agent startup is never blocked.
|
|
182
|
-
@brand_config.sync_brand_skills_async!
|
|
183
|
-
# Free-mode counterpart: branded but not activated → fetch unencrypted skills
|
|
184
|
-
# via the public endpoint so users get a working install with no serial number.
|
|
185
|
-
@brand_config.sync_free_skills_async!
|
|
186
|
-
# Brand extensions bundled into the activated license's distribution.
|
|
187
|
-
@brand_config.sync_brand_extensions_async!
|
|
188
|
-
|
|
189
181
|
# Initialize Time Machine
|
|
190
182
|
init_time_machine
|
|
191
183
|
|
|
@@ -1445,7 +1437,7 @@ module Clacky
|
|
|
1445
1437
|
# run even when @ui is nil (e.g. in tests), so branch explicitly.
|
|
1446
1438
|
begin
|
|
1447
1439
|
if @ui
|
|
1448
|
-
@ui.with_progress(message: "
|
|
1440
|
+
@ui.with_progress(message: Clacky::I18n.t("progress.compressing"), style: :quiet) do |handle|
|
|
1449
1441
|
response = call_llm
|
|
1450
1442
|
handle_compression_response(response, compression_context, progress: handle)
|
|
1451
1443
|
compression_handled = true
|
|
@@ -1772,7 +1764,7 @@ module Clacky
|
|
|
1772
1764
|
|
|
1773
1765
|
result = nil
|
|
1774
1766
|
if @ui
|
|
1775
|
-
progress_message = build_tool_progress_message(call[:name]
|
|
1767
|
+
progress_message = build_tool_progress_message(call[:name])
|
|
1776
1768
|
@ui.with_progress(
|
|
1777
1769
|
message: progress_message,
|
|
1778
1770
|
style: :quiet,
|
|
@@ -2729,6 +2721,8 @@ module Clacky
|
|
|
2729
2721
|
error_type: result["error_type"], error: result["error"])
|
|
2730
2722
|
return [nil, entry["model"], :stt_call_failed]
|
|
2731
2723
|
end
|
|
2724
|
+
Clacky::Billing::MediaUsage.record(result, prompt: AUDIO_TRANSCRIPTION_PROMPT,
|
|
2725
|
+
session_id: @session_id, kind: "stt")
|
|
2732
2726
|
|
|
2733
2727
|
# Verbatim speech, not a summary — never truncated. The 20 MB input cap
|
|
2734
2728
|
# is what bounds the transcript length.
|
|
@@ -3050,14 +3044,12 @@ module Clacky
|
|
|
3050
3044
|
private def parse_file_links(content)
|
|
3051
3045
|
return { text: content, files: [] } if content.nil? || content.empty?
|
|
3052
3046
|
|
|
3053
|
-
files =
|
|
3054
|
-
|
|
3055
|
-
inline = $1 == "!"
|
|
3047
|
+
files = Utils::FileLinkNormalizer.extract_file_links(content).map do |link|
|
|
3048
|
+
raw = link[:path]
|
|
3056
3049
|
# Resolve the AI-emitted path: decode, WSL drive-letter normalize, expand.
|
|
3057
|
-
path
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
files << { name: name, path: path, inline: inline }
|
|
3050
|
+
path = Clacky::Utils::EnvironmentDetector.resolve_local_path(raw)
|
|
3051
|
+
Clacky::Logger.info("[parse_file_links] raw=#{raw.inspect} resolved=#{path.inspect} exist=#{File.exist?(path)}")
|
|
3052
|
+
{ name: File.basename(path), path: path, inline: link[:inline] }
|
|
3061
3053
|
end
|
|
3062
3054
|
{ text: content, files: files }
|
|
3063
3055
|
end
|
|
@@ -3075,8 +3067,12 @@ module Clacky
|
|
|
3075
3067
|
# Prepend reasoning/thinking content (from thinking-mode providers like
|
|
3076
3068
|
# DeepSeek V4, Kimi K2) wrapped in <think> tags so the Web UI renders it
|
|
3077
3069
|
# as a collapsible thinking block (see sessions.js _renderMarkdown).
|
|
3070
|
+
# Reasoning is markdown-rendered too, so its file links get the same
|
|
3071
|
+
# rewrite; only the answer feeds parse_file_links below, so a path the
|
|
3072
|
+
# model merely mentions while thinking is never attached as a file.
|
|
3078
3073
|
if reasoning_content && !reasoning_content.to_s.strip.empty?
|
|
3079
|
-
|
|
3074
|
+
reasoning = Utils::FileLinkNormalizer.normalize(reasoning_content)
|
|
3075
|
+
full_content = "<think>\n#{reasoning}\n</think>\n#{content}"
|
|
3080
3076
|
else
|
|
3081
3077
|
full_content = content
|
|
3082
3078
|
end
|