tensaku 0.0.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19a05003b74ad6d7a4e18d0bf6c838974e619cbb4e5319172b574b363b0cd16b
4
- data.tar.gz: 90fc49efb273155c0a2a6da66586ebce56a0fa0bdf9ca2fbd441f6133d151d70
3
+ metadata.gz: f39d9336417186bd0aa9189918ae75cc0d0697d23bc23b6a0013d6a5570e58f3
4
+ data.tar.gz: 4516a80465641652eccd34a1c050497e4012cc95b7921b2b3db6c8888506484a
5
5
  SHA512:
6
- metadata.gz: 0c51109fc72f7c5c0b50fb90082780a5eb9c4afd30caab6af6c09a6ba7824cb41ea5ca56707b2d4d8e9b5d0dd83fdbd6f10b33e662bf0cd894e600eb07d9a70f
7
- data.tar.gz: 80aa78b84cf8a88415886c6d2ef245aa900446a36dc5effe824905938bd081772b1eeacd3d1f762fd08b5092e51d44ea8f5cd0a0fdc1f7fd8600cc219a24f204
6
+ metadata.gz: 16125703270857712c2f8d10a7924904b9e06c0402b94923373cbd70e0e8d5cb9f8be7bc1fadefcf8a4e79196f7b56b907d2345502332afd7718aa7a406b4301
7
+ data.tar.gz: d1afa738bfc83d439e6d6426643d6485ac41dde8574dfe68630df0e773146e1df22538cc9875c56a46dae203fde39a4412f85f2347b139309634a1b2018f99f0
data/CHANGELOG.md CHANGED
@@ -1,15 +1,222 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 0.2.0 (2026-11-14)
4
+
5
+ Upgrading from 0.1.0: rerun `bin/rails generate tensaku:install` to replace the `.mcp.json` entry with
6
+ `bundle exec tensaku mcp`. Notes from 0.1.0 aren't carried over. `config.notes_path`, `config.shortcut`
7
+ and `config.prune_after` are gone; `config.archive_after` replaces `prune_after`.
8
+
9
+ ### Editing
10
+
11
+ - Undo and redo: every text save in the tab can be undone, newest first or from the edit history, and
12
+ redone, with Cmd/Ctrl+Z and Cmd/Ctrl+Shift+Z (Ctrl+Y) or from the toasts. The history survives a
13
+ reload. A new save clears what can be redone. A translation saved in several locales at once is undone
14
+ in all of them.
15
+ - The editor shows child elements as they look on the page instead of as code. `<br>` breaks the line,
16
+ an element's text keeps its style, dimmed, and opens that element's editor on a click, and an element
17
+ without text is a small mark. Whitespace between elements is no longer an editable field.
18
+ - Escape closes one thing at a time, the innermost first: it leaves a field in Tensaku's panels, then
19
+ closes the popover, the element menu, the note opened from a pin, the settings or notes panel, turns
20
+ select or edit mode off, and last folds the toolbar away. A focused field of the page keeps its own
21
+ Escape.
22
+ - Locked chips have a fixed size, so they stay small in a heading, and long ones are cut off with an
23
+ ellipsis.
24
+
25
+ ### Agents
26
+
27
+ - The MCP server is `bundle exec tensaku mcp`, which the agent starts over stdin and stdout, in place
28
+ of the HTTP endpoint at `/__tensaku/mcp`. It doesn't load the app, so the dev server doesn't have to
29
+ be running and no port is configured. It serves the app that contains the agent's directory, or the
30
+ apps below it that list tensaku in `Gemfile.lock`, or those given with `--app`. Rerun the generator
31
+ to replace the old `.mcp.json` entry.
32
+ - The Agents popover shows each agent's mark when its client is known (Claude Code, Cursor, Gemini CLI,
33
+ OpenCode, GitHub Copilot, Windsurf, Zed, Cline), from Simple Icons. Codex and other clients show a
34
+ paper plane.
35
+ - `bundle exec tensaku notes` does what the MCP tools do, from a shell, for agents without MCP.
36
+ - Notes are kept in a SQLite database, `tensaku.sqlite3` in your user data folder (`TENSAKU_HOME` to
37
+ change it), for every app and checkout on the machine, instead of JSON files in `tmp/tensaku/notes`.
38
+ Notes from 0.1.0 aren't carried over. The `sqlite3` gem is a new dependency, loaded in development
39
+ only. `config.notes_path` is gone.
40
+ - Notes have a `sent_at`, set when you save, edit, answer or reopen them from the page, and record the
41
+ commit checked out when they were written. `watch_notes` returns notes sent after `since`, and a card
42
+ says when it delivered one (`delivered_at`, `delivered_to`). A cancelled `watch_notes` stops waiting.
43
+ - Nothing polls. The page gets change events from the dev server (`GET /__tensaku/events`), and a
44
+ process waiting for notes is woken over a Unix socket when a change is saved. The page polls only
45
+ while its event stream is down.
46
+ - A note belongs to one `tensaku mcp` session: the one you assign it to with the note form's
47
+ **Assign to** menu, the one `watch_notes` hands it to, or the one that starts it. Unassigned notes go
48
+ to the first session that checks. Other sessions leave a note alone while its session's process
49
+ runs, and a request for changes goes back to it. A card can assign an open note to another session,
50
+ or take a note in progress back from a session that was stopped mid-work. A note whose session
51
+ ended mid-work says so on the page and in `list_notes`. A session busy with a note leaves new ones to an idle listening session.
52
+ `list_notes` marks each note as the session's own or nobody's yet, and `resolve_note` refuses a note
53
+ that wasn't started. A session counts as running while its process holds a lock in the data folder,
54
+ so a crashed agent's notes are free at once.
55
+ - Once an agent has listened, any Tensaku tool answer includes and claims the notes sent since it last
56
+ looked, so a busy agent gets them at its next call. Other agents get the ids.
57
+ - Each session has a two-word handle, such as amber-fox, unique among the app's connected sessions,
58
+ shown with the agent's name on the page and given to the agent to tell you.
59
+ - An Agents button in the toolbar replaces the green light: its popover lists each agent's folder,
60
+ start time, the note it works on or its last call, listening sessions first, and what to ask an agent
61
+ so it listens.
62
+ - Notes carry a screenshot of what they point at, taken by the page when the note form opens, without
63
+ a browser permission. Agents get it with `get_screenshot` or `tensaku notes screenshot ID`.
64
+ **Screenshot** in the form turns it off. The overlay bundles modern-screenshot 4.7.0 for this.
65
+ - `decline_note` closes a note without a change, with the reason in its thread. Declined notes have a
66
+ grey pin.
67
+ - Resolved and declined notes move to an archive after `config.archive_after` (was
68
+ `config.prune_after`, which deleted them) or with **Archive done**. `list_notes` takes
69
+ `status: archived`, and a reopened note comes back.
70
+ - Long threads show the agent's latest message and what came after it, on the cards and in `list_notes`
71
+ and `watch_notes`. `get_note` has the whole thread.
72
+ - Each browser tab keeps its own selection; `current_selection` returns the newest.
73
+ - The page says to restart the dev server when Tensaku's code changed since it started, and the Agents
74
+ popover marks an agent that runs older Tensaku code.
75
+ - The notes panel has an **Archive** tab.
76
+ - Changes made on a note card show at once and go back if the server refuses them. An open card
77
+ follows the agent's changes to its note.
78
+ - When an agent resolves a note, the page fetches itself again and morphs the change in, with changed
79
+ stylesheets.
80
+ - Claude Code channel: in a session started with
81
+ `claude --dangerously-load-development-channels server:tensaku`, each note you save is pushed into
82
+ the chat and Claude starts on it without being asked. The new `channel_ready` tool confirms the
83
+ channel works; the Agents popover shows the session as **Live**.
84
+ - `tensaku mcp` logs each tool call to `tmp/tensaku/mcp.log`: tool, duration, answer size and the
85
+ notes handed over.
86
+ - Note links in the MCP answers and copied Markdown use the address the page was opened at.
87
+ - Note targets carry the element's `classes`, and the Markdown lists them.
88
+ - The generator sets up more agents, and no longer takes `--port`: the skill also goes in
89
+ `.agents/skills/tensaku/` (Codex, Cursor, Gemini CLI, OpenCode and Copilot read it), `--agents`
90
+ writes `.codex/config.toml`, `.cursor/mcp.json`, `.gemini/settings.json` and `opencode.json`, and by
91
+ default it writes them for the agents already configured in the project.
92
+ - MCP tool answers are text only: `structuredContent` is gone, the tools that change a note answer
93
+ with one line, and `watch_notes` ends its text with a `checked_at` line.
94
+ - The skill, the MCP instructions and the tool descriptions tell the agent to start a note before
95
+ changing anything and to resolve it as soon as its change is made, before starting the next.
96
+ - `GET /notes.md` no longer takes `id`. The overlay's copy button was its only user.
97
+ - Notes no longer have a `reply` field, and `PATCH /notes/:id` no longer takes one. What the agent
98
+ says is in `thread`. `resolve_note` still takes its text as `reply`.
99
+
100
+ ### Install
101
+
102
+ - The generator is optional and only connects a coding agent. It no longer writes
103
+ `config/initializers/reactionview.rb`: Tensaku turns off Herb's debug mode itself, and an app's
104
+ initializer can still turn it on.
105
+
106
+ ### Rendering
107
+
108
+ - Tensaku no longer turns on Herb's `action_view_helpers` option. With it on, Herb 0.11.2 dropped
109
+ attributes passed as `tag.div(**attrs)` in development. Helpers such as `link_to` now render as they
110
+ do in production and have no source stamp of their own, so a note on one points at the nearest
111
+ stamped ancestor. The safety page shows how to turn the option back on.
112
+
113
+ ### Overlay
114
+
115
+ - Note cards are simpler. The message box is gone (edit the note instead, and a question still takes an answer), and so is the copy button. The actions are unoutlined icons at the top of the card with tooltips. Source lines are grouped by file under the note, and the agent's replies sit under a ruled line.
116
+ - Notes can no longer be moved to another element, and `PATCH /notes/:id` no longer takes `targets`. A card whose element is gone says so; delete it and write a new note.
117
+ - A note card's buttons are **Mark as done** (or **Reopen**), **Edit** and **Delete**, in that order.
118
+ - The bottom of the notes panel says which agent your notes go to. With none, **Connect one** lists the commands that start one, each with a copy button. **Copy page notes** and **Copy all open** are now **Copy page** and **Copy all**.
119
+ - The toolbar's buttons are in three groups: select and edit, notes, then pause, history and settings. The settings button has a sliders icon.
120
+ - Settings open in a side panel in place of the notes panel. Every toolbar button can have a keyboard shortcut, changed or removed in the panel for this browser: Select is Alt+Shift+T, Edit is Alt+Shift+E and Notes is Alt+Shift+N. Escape closes the panel.
121
+ - `config.shortcut` is gone. Set the shortcuts in the settings panel.
122
+ - The Compact button setting is gone.
123
+ - On a phone the toolbar's buttons are smaller, and on a screen too narrow for all of them they scroll sideways.
124
+ - The toolbar pauses the page's CSS animations and transitions, Web Animations and playing media, so you can note an element mid-animation. JavaScript timers and `requestAnimationFrame` loops keep running.
125
+ - Agent toasts appear one at a time, at most three at once. More than three waiting become one toast that counts the changes, with a button that opens the notes panel. Browser notifications follow the same rule.
126
+ - The notes panel lists resolved and declined notes in a **Done** section with an **Archive done** button. Its copy buttons are in a bar at the bottom right that stays in view while the notes scroll, and the bar is hidden when there is nothing open to copy.
127
+ - Post-its have a folded corner that joins the paper.
128
+ - Alt+Shift-click (Option+Shift-click) opens the note form on an element, in any mode.
129
+ - A note's pin sits where you clicked to write it, kept as a `point` on the target, and follows the
130
+ element when the layout changes. Area notes, notes on several elements and notes written from the
131
+ keyboard keep the pin at the top right.
132
+ - The corner button shows a pointer cursor, and a grabbing cursor only once a drag starts.
133
+ - The corner button and the toolbar are one pill. The button stays where it is, the logo spins and the tools unroll to its left. Clicking the button closes the toolbar, the notes panel and the current mode, so there is no separate close button. Notes moved next to the page actions, and the selected tool's circle stays centered in the bar.
134
+ - Alt-click (Option-click) opens the actions menu on any element, in any mode, instead of going straight to the editor. Edit text comes first in the menu, so Alt-click then E or Enter edits. A click outside the menu closes it and doesn't reach the page.
135
+ - Alt-drag (Option-drag) draws an area for a note, in any mode.
136
+ - Holding Alt (Option) shows the select cursor and highlights the element under the pointer until the key is released. It does nothing while you type in a field.
137
+ - A note's pin finds its element by tag and text when the file's lines have moved. Before, it showed on
138
+ whatever was now at the old line, or on nothing.
139
+ - The corner button shows the new logo, a hanamaru, instead of the character 添.
140
+ - The message after a save shows the file, the line, and the old and new text of the lines that changed.
141
+ Save replies carry these lines as `diff`.
142
+ - Shortcut labels follow the platform: `⌥⇧T` on Apple platforms and `Alt+Shift+T` elsewhere, and the
143
+ note form says `⌘↵ saves` or `Ctrl+Enter saves`.
144
+
145
+ ## 0.1.0 (2026-11-08)
146
+
147
+ ### Editing
148
+
149
+ - Herb stamps every ERB element with its source position in development, through ReActionView's ERB
150
+ interception and Herb's `SourceAttributionVisitor`. Production keeps Erubi.
151
+ - In-place editing of template text and attributes, translations (with other locales) and Markdown
152
+ blocks from producers. Writes are byte splices with a stale-file check and one-step undo.
153
+ - Whole Markdown lists can be edited as source.
154
+ - Markdown blocks are read from `data-md-source="path:line:col-line:col"`, the attribute Kiln 0.1.3
155
+ writes. Paragraphs, headings, list items, quotes and whole lists are editable; code blocks, tables and
156
+ rules only get notes. Kiln's content directory isn't writable automatically: add it to
157
+ `writable_paths`.
158
+ - Edit mode outlines only elements with text written in the template, asked once from `POST /editable`.
159
+ Text that comes entirely from Ruby (`<%= %>`) isn't outlined.
160
+ - The editor takes the page's background, text colour and type and sits over the element. Its status
161
+ bar floats below it.
162
+ - After a save, the page updates every node with the same source right away, then fetches the page
163
+ again and morphs it in with idiomorph.
164
+ - Edit history lists the saves made since the page loaded.
165
+ - Open in editor (`GET /editor`), through Rails' `ActiveSupport::Editor` and `RAILS_EDITOR`.
166
+
167
+ ### Notes
4
168
 
5
- - Herb source stamps on every ERB element in development, through ReActionView's ERB interception and
6
- Herb's `SourceAttributionVisitor`. Production keeps Erubi.
7
- - Overlay with a corner button and Alt+Shift+T: hover to see sources, copy references with the
8
- partial chain, Stimulus controller and Turbo Frame.
9
169
  - Notes on elements, text selections and areas, stored in `tmp/tensaku/notes/`, with pins and a notes
10
170
  panel. Agents read them as files, through the MCP endpoint, from the clipboard or with the Claude
11
171
  Code skill.
12
- - In-place editing of template text and attributes, translations (with other locales) and Markdown
13
- blocks from producers, written back as byte splices with a stale-file check and one-step undo.
14
- - Page update after a save: same-source nodes right away, then refetch and idiomorph.
15
- - `bin/rails generate tensaku:install`.
172
+ - Notes can be edited from their card. An edited note goes back to `open` and keeps its thread.
173
+ - A `working` status and the `start_note` MCP tool show when an agent picks a note up. `GET /notes`
174
+ returns `agent.connected`, true for 20 seconds after any MCP call, and the toolbar shows it as a
175
+ green light. The overlay polls the notes every four seconds while the tab is visible.
176
+ - Notes keep a thread (`thread`, with `from` and the agent's name). `reply_to_note` adds an agent
177
+ message, and answering a question from the page adds yours.
178
+ - Notes can move to another element (`PATCH /notes/:id` with `targets`). The card says when a note's
179
+ element is gone.
180
+ - MCP `initialize` returns an `Mcp-Session-Id`. The page names connected agents from `clientInfo`.
181
+ - The notes panel shows every page's notes. `GET /notes.md?format=short` gives one line per note.
182
+ - A note on selected text keeps the phrase marked on the page.
183
+ - Toasts, and optional browser notifications, when an agent answers or resolves a note. A note the agent has started on shows only on its pin.
184
+
185
+ ### Overlay
186
+
187
+ - A corner button and Alt+Shift+T open select mode. Hover to see sources, and copy references with
188
+ the partial chain, the Stimulus controller and the Turbo Frame.
189
+ - Arrow keys move the select-mode highlight through stamped elements. Enter opens the menu, and
190
+ Cmd/Ctrl+C copies the highlighted element's reference.
191
+ - Shift-click in select mode picks several elements for one note.
192
+ - Toolbar buttons hide the pins and delete the page's notes after a second click.
193
+ - Settings for the copy format, notifications and a compact corner button.
194
+ - One look on light and dark pages: a dark toolbar of drawn tools (highlighter to select, red pen to
195
+ edit, sticky-note pad for notes) with tooltips, a dark element menu, notes on Post-it paper, and round
196
+ pins that turn green with a drawn check when resolved. The page cursor shows the selected tool.
197
+ Motion is off with `prefers-reduced-motion`.
198
+
199
+ ### Safety and fixes
200
+
201
+ - `writable_paths` takes single files as well as directories. A file allows only that file, such as
202
+ `../CONTRIBUTING.md` outside the app.
203
+ - The endpoints check the `Host` and `Origin` headers and refuse requests a proxy forwarded from
204
+ another machine, so DNS rebinding or a tunnel can't reach them.
205
+ - The token goes only into successful pages and 422 form errors requested with a local `Host`, never
206
+ into error pages or HTML fragments that scripts fetch. It's kept in `tmp/tensaku/token`, shared by
207
+ Puma workers and across restarts.
208
+ - The script carries the page's CSP nonce and respects `SCRIPT_NAME`.
209
+ - Saves and note changes take a shared lock, so concurrent saves don't lose each other's changes.
210
+ - Apps that use `I18n::Backend::Chain` no longer fail on every `t()` call in development.
211
+ - An untouched `&nbsp;` stays `&nbsp;` after a nearby edit. CRLF files keep CRLF line endings. YAML
212
+ anchors and tags survive an edit, and a value in a flow mapping is quoted when it needs to be.
213
+ - `watch_notes` no longer misses notes saved in the same second as its `since`. Malformed note files
214
+ are skipped. Bad request bodies get a 422 instead of a server error.
215
+ - The toast's Undo reverts the save it belongs to. Enter while composing with an IME doesn't save.
216
+ Values typed into the page's forms survive the refresh after a save. Translations stay editable after
217
+ Back and Forward. A second copy of the script adds nothing.
218
+ - Select mode leaves keys in the page's own inputs alone. Every changed piece of an attribute is saved.
219
+ Pins and outlines follow scrolling containers. A note on a repeated element pins to the matching copy.
220
+ - Herb, ReActionView and Rails are pinned to the versions Tensaku is tested with.
221
+ - The generator (`bin/rails generate tensaku:install`) reads the Gemfile through Bundler, reports an
222
+ invalid `.mcp.json` instead of crashing, honors `--pretend` and uses the configured mount path.
data/README.md CHANGED
@@ -1,17 +1,29 @@
1
- # Tensaku
1
+ <p align="center">
2
+ <img src="docs/app/assets/images/hanamaru.svg" width="96" height="96" alt="">
3
+ </p>
2
4
 
3
- Tensaku (添削, correcting a draft) lets you fix a running Rails app from the page itself, in
4
- development. Click a piece of text and edit it in place, and Tensaku writes the change back to the ERB
5
- template, the locale YAML or the Markdown source. Or leave a note on an element or an area of the page,
6
- and your coding agent reads it with the exact file and line attached.
5
+ <h1 align="center">Tensaku</h1>
7
6
 
8
- Tensaku is built on [Herb](https://github.com/marcoroth/herb) through
9
- [ReActionView](https://github.com/marcoroth/reactionview), and only runs in development. Production
10
- doesn't change: it keeps rendering with Erubi and never loads Tensaku, ReActionView or Herb.
7
+ <p align="center">
8
+ <a href="https://rubyonrails.org"><img src="https://img.shields.io/badge/Rails-8.1-b45d3c?logo=rubyonrails&amp;logoColor=white" alt="Rails 8.1"></a>
9
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-57966f" alt="License: MIT"></a>
10
+ </p>
11
11
 
12
- Status: 0.0.1, unreleased. Requires Ruby 4.0+ and Rails 8.1+.
12
+ <p align="center">
13
+ Fix your Rails app without leaving the browser.
14
+ </p>
13
15
 
14
- ## Install
16
+ <p align="center">
17
+ <a href="https://tensaku.lostcoords.com">Documentation</a> ·
18
+ <a href="https://tensaku.lostcoords.com/installation">Installation</a> ·
19
+ <a href="https://tensaku.lostcoords.com/safety">Safety and limits</a>
20
+ </p>
21
+
22
+ Tensaku (添削, correcting a draft) lets you click text on a running Rails page and edit it. It writes the change back to the ERB template, the locale YAML or the Markdown file. For anything that isn't a text edit, leave a note on the page, and your coding agent reads it with the file and line of each element.
23
+
24
+ It needs Ruby 4.0 or later and Rails 8.1. It runs only in development, on [Herb](https://github.com/marcoroth/herb) through [ReActionView](https://github.com/marcoroth/reactionview). Test and production keep rendering with Erubi and never load Tensaku, ReActionView or Herb.
25
+
26
+ ## Install it in a Rails app
15
27
 
16
28
  ```ruby
17
29
  # Gemfile
@@ -22,175 +34,37 @@ end
22
34
 
23
35
  ```sh
24
36
  bundle install
25
- bin/rails generate tensaku:install
26
37
  ```
27
38
 
28
- The generator checks the Gemfile group, writes `config/initializers/reactionview.rb`, installs the
29
- Claude Code skill in `.claude/skills/tensaku/`, adds the MCP endpoint to `.mcp.json`, and makes sure
30
- `tmp/` is ignored. It prints what it changed. No JavaScript setup is needed: the middleware injects one
31
- prebuilt script, which works with importmap, jsbundling or no JavaScript at all.
32
-
33
- ## Use
34
-
35
- Start the server and open a page. A small round button sits in the bottom right corner (drag it
36
- anywhere). Click it for the toolbar, or press **Alt+Shift+T** to go straight to select mode.
37
-
38
- - **Select**: hover to see where an element comes from (`h1 app/views/pages/about.html.erb:1`), click
39
- it for a menu:
40
- - **Copy reference**: `GET /about → app/views/pages/_hero.html.erb:4:3`, the text, the partial
41
- chain, the Stimulus controller, the Turbo Frame and the translation key.
42
- - **Add note**: write what should change. Select some text first to note just that text.
43
- - **Edit text** / **Edit attributes**.
44
- - **Drag** in select mode to note an area. The note collects every stamped element inside it.
45
- - **Alt/Option-click** any text to edit it right away, in any mode.
46
- - **Edit**: outlines every editable text on the page. A normal click edits.
47
- - **Notes**: the notes on this page, copy them as Markdown, resolve, delete or answer questions.
48
-
49
- The editor shows the source, never the rendered text. In `Hello <%= user.name %>!` you edit `Hello ` and
50
- `!`; the Ruby shows as a locked chip. Translations show `%{name}` interpolations as chips, and
51
- "Other locales" lets you update the same key in every locale at once. Enter or leaving the editor
52
- saves, Shift+Enter adds a line break in Markdown, Escape cancels. After a save, a toast offers Undo.
53
-
54
- ## What can be edited
55
-
56
- | Source | How Tensaku finds it | Written to |
57
- |---|---|---|
58
- | Static text in ERB views, partials, layouts, ViewComponent sidecar templates, mailer templates | `data-herb-source="path:line:col"`, stamped by Herb's `SourceAttributionVisitor` | The template, only the bytes of that text |
59
- | `alt`, `title`, `placeholder`, `aria-label`, button `value` | The same stamp | The attribute value, keeping its quotes |
60
- | `t()` translations, in text and attributes | An invisible marker the I18n backend adds in development | The locale YAML, only the value's bytes |
61
- | Markdown blocks (`p`, headings, `li`, `blockquote`) | `data-tensaku-md="path:line:col-line:col"` from a producer such as Kiln's content layer | The Markdown file, inside the block's range |
62
-
63
- Everything else on the page (text from Ruby data like `@post.title`, output of `form_with` or custom
64
- helpers, DOM built by JavaScript) can still get notes, placed through the nearest stamped element.
65
-
66
- Every write is a splice: Tensaku re-reads the file, checks that the bytes it's about to replace are
67
- still what the page was rendered from, and replaces exactly those bytes through a temp file and a
68
- rename. YAML is never loaded and dumped, so comments, ordering and quoting stay. If the file changed
69
- since the page rendered, the edit is refused and nothing is merged or guessed.
70
-
71
- After a save, Tensaku clears Action View's template cache (and ViewComponent's, and reloads I18n),
72
- updates every copy of the text on the page right away, then fetches the page again and morphs it in
73
- with [idiomorph](https://github.com/bigskysoftware/idiomorph). Stimulus controllers stay connected,
74
- no Turbo visit fires, and elements marked `data-turbo-permanent` or `data-tensaku-permanent` are left
75
- alone. On a page reached by a POST (a form that rendered errors) Tensaku updates the text it knows and
76
- asks you to reload.
77
-
78
- Elements rendered in a loop share one stamp: the editor says "this edits all 3 copies".
79
-
80
- ## Notes for agents
81
-
82
- Notes are JSON files in `tmp/tensaku/notes/`, one per note: local, ignored by git, cleared by
83
- `bin/rails tmp:clear`. Resolved notes are deleted after three days.
84
-
85
- ```json
86
- {
87
- "id": "a7f3",
88
- "url": "/about",
89
- "comment": "tighten this, and the heading is wrong",
90
- "targets": [
91
- { "kind": "element", "file": "app/views/pages/_hero.html.erb", "range": "4:3-4:40", "tag": "h1", "text": "About me" }
92
- ],
93
- "status": "open",
94
- "reply": null
95
- }
96
- ```
97
-
98
- An agent gets them four ways:
99
-
100
- - **Files**: read `tmp/tensaku/notes/*.json`.
101
- - **MCP**: `http://localhost:3000/__tensaku/mcp` (Streamable HTTP). Tools: `list_notes`, `get_note`,
102
- `resolve_note`, `ask_question`, `watch_notes` (waits for new notes) and `current_selection`. The
103
- generator adds it to `.mcp.json`.
104
- - **Clipboard**: copy one note or all open notes as Markdown from the page, for any chat.
105
- - **Claude Code skill**: `.claude/skills/tensaku/SKILL.md` explains how to find, act on and resolve notes.
39
+ To connect a coding agent, also run `bin/rails generate tensaku:install`. This optional generator installs the skill, and adds `bundle exec tensaku mcp`, an MCP server the agent starts itself, to `.mcp.json` and to the config of Codex, Cursor, Gemini CLI or OpenCode. It prints every file it changes. You don't set up any JavaScript. The middleware injects one prebuilt script into HTML pages.
106
40
 
107
- A note is `open`, `question` (the agent asked something back; the question shows on the page) or
108
- `resolved` (with a reply; the pin turns green so you can check the change, then dismiss it).
41
+ Start the server and open a page. A round button with a red flower sits in the bottom right corner. Press **Alt+Shift+T** to select an element and see the file and line it came from.
109
42
 
110
- ## Producers and attributes
43
+ ## Edit text where you see it
111
44
 
112
- The overlay only reads attributes, so it doesn't care what rendered the page.
45
+ Alt-click (Option-click) any text and press E, or choose **Edit text** in the menu. The editor shows the source, so in `Hello <%= user.name %>!` you edit `Hello ` and `!` and the Ruby stays a locked chip. Enter saves, Escape cancels, and a toast offers Undo.
113
46
 
114
- | Attribute | Set by | Meaning |
115
- |---|---|---|
116
- | `data-herb-source="path:line:col"` | Herb | Element's open tag position (1-based) |
117
- | Marker inside translated strings | Tensaku's I18n backend | Locale and key. Stripped by the overlay. |
118
- | `data-tensaku-group` | The app | Widen the highlight and the edit target to this element |
119
- | `data-tensaku-md="path:line:col-line:col"` | A Markdown producer, development only | Block's Markdown source range (byte columns, end inclusive) |
120
- | `data-tensaku-permanent` | The app | The morph after a save leaves this element alone (client-rendered islands) |
121
- | `<meta name="tensaku" data-tensaku-request="GET">` | Tensaku | Request method, so the overlay knows whether it can fetch the page again |
122
-
123
- [Kiln](https://github.com/davafons/kiln)'s content layer emits `data-tensaku-md` in development when
124
- Tensaku is loaded, and Kiln's content directory is writable automatically. Kiln builds fail if any
125
- `data-herb-*` or `data-tensaku-*` attribute reaches the output.
126
-
127
- ## Configuration
128
-
129
- ```ruby
130
- # config/initializers/tensaku.rb
131
- if defined?(Tensaku)
132
- Tensaku.configure do |config|
133
- config.writable_paths << "content" # default: app/views app/components config/locales
134
- config.shortcut = "alt+shift+KeyT" # modifiers and a KeyboardEvent#code
135
- config.prune_after = 7 * 24 * 60 * 60 # seconds before resolved notes are deleted
136
- end
137
- end
138
- ```
47
+ Tensaku edits static template text, attributes such as `alt` and `placeholder`, `t()` translations in every locale, and Markdown blocks. Each save replaces only the bytes of the edited text, and refuses if the file changed since the page rendered. The page then updates in place, with no reload.
139
48
 
140
- Other gems can call `Tensaku.register_writable_path("their/dir")`.
49
+ ## Leave notes for your agent
141
50
 
142
- ## Safety
51
+ Alt+Shift-click (Option+Shift-click) an element, or in select mode click an element, select some text, or drag over an area, and choose **Add note**. Notes are kept in a SQLite database in your user data folder, outside your project. Your agent gets them through `tensaku mcp` and the skill, through the `tensaku notes` command, or from Markdown you copy from the page.
143
52
 
144
- - Development only. The railtie, middleware and I18n markers check `Rails.env.development?`, so nothing
145
- loads in test or production even if the gem is in the wrong Gemfile group.
146
- - Every endpoint answers loopback addresses only. Everything the overlay calls needs a per-boot token
147
- embedded in the page. The MCP endpoint can't receive that token from an MCP client, so it also
148
- refuses requests with a foreign `Origin` or a non-local `Host` (browsers can't reach it from another
149
- site). It reads and updates notes; it never writes source files.
150
- - Writes are limited to the writable paths, checked after resolving symlinks.
53
+ Ask your agent to do your Tensaku notes, and it works through the open ones. Ask it to watch your Tensaku notes, and it waits for them: each note you save reaches it as you write it.
151
54
 
152
- ## Limits
153
-
154
- - Text from Ruby data, rich text (bold, links, splitting paragraphs), Phlex views and inline
155
- ViewComponent templates (`erb_template`) are out of scope. They get notes.
156
- - Pluralized translations (`count:`) aren't marked, so they aren't edited in the page.
157
- - Translation markers are part of the string while Ruby handles it, in development. A comparison like
158
- `t(".title") == "Welcome"` inside a controller action or view is false in development.
159
- - Fragment caching in development (`bin/rails dev:cache`) keeps showing the old text from cached
160
- fragments. Tensaku warns when it's on.
161
- - One person editing at a time. No undo history beyond one step: version control is the history.
162
- - Herb's dev server patches template changes itself when it runs (ReActionView's `slots` option), and
163
- Tensaku then skips its own refetch for template edits.
164
-
165
- ## Development
166
-
167
- ```sh
168
- bundle install
169
- bun install # only to change the overlay
170
- bin/test # unit and browser tests (Cuprite, needs Chrome)
171
- bin/lint # RuboCop, house rules, TypeScript, compiled overlay up to date
172
- bun run build # app/javascript/tensaku/*.ts -> app/assets/tensaku.js (committed)
173
- ```
174
-
175
- The documentation site is a Rails app in `docs/`, rendered to static files by Kiln and styled with
176
- lostcoords-ui. Tensaku runs on it in development, so it's also where Tensaku is tried on a real site:
177
-
178
- ```sh
179
- cd docs
180
- bundle install
181
- bin/rails tailwindcss:build
182
- bin/rails server # edit the docs from the page
183
- RAILS_ENV=production bin/rails kiln:build # static site in docs/dist
184
- ```
55
+ The agent marks a note `working`, asks a question back, declines it, or resolves it with a reply. Each change shows on the note's pin. A green pin means the change is ready for you to check.
185
56
 
186
- With [Parcela](https://parcela.run), `parcela up --detach` runs the docs server and the Tailwind watcher at
187
- https://tensaku.localhost.
57
+ ## Documentation
188
58
 
189
- CI builds the docs with `kiln:build` on every push.
59
+ The documentation site is [tensaku.lostcoords.com](https://tensaku.lostcoords.com). Its pages are Markdown files in `docs/app/views/pages/`.
190
60
 
191
- The test suite runs `test/dummy` in the development environment, since that's the only place Tensaku
192
- switches on. Browser tests write to the dummy app's files and restore them afterwards.
61
+ - [Install Tensaku](docs/app/views/pages/installation.html.md) and see [connect a coding agent](docs/app/views/pages/installation.html.md#connect-a-coding-agent).
62
+ - Read [what can be edited](docs/app/views/pages/editing.html.md) and [how a save works](docs/app/views/pages/editing.html.md#how-a-save-works).
63
+ - Leave [notes](docs/app/views/pages/notes.html.md), and see [how agents read them](docs/app/views/pages/notes.html.md#how-agents-read-notes).
64
+ - Look up the [configuration options](docs/app/views/pages/configuration.html.md) and the [attributes the overlay reads](docs/app/views/pages/producers.html.md).
65
+ - Read [safety and limits](docs/app/views/pages/safety.html.md) before you use it on a real app.
66
+ - [Contribute](CONTRIBUTING.md) or read the [changelog](CHANGELOG.md).
193
67
 
194
68
  ## License
195
69
 
196
- MIT
70
+ Tensaku is licensed under the [MIT License](LICENSE).