elelem-ratatui 0.1.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 +7 -0
- data/.agents/backlog/001-run-without-dev-tty.md +57 -0
- data/.agents/backlog/002-manual-scrollback.md +46 -0
- data/.agents/backlog/003-quit-from-any-thread.md +49 -0
- data/.agents/backlog/004-readme.md +41 -0
- data/.agents/backlog/005-gem-metadata-links.md +65 -0
- data/.github/workflows/release.yml +73 -0
- data/.release-please-manifest.json +3 -0
- data/.rspec +1 -0
- data/.rubocop.yml +62 -0
- data/CHANGELOG.md +22 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +13 -0
- data/exe/elelem-ratatui +9 -0
- data/ext/elelem/ratatui/extconf.rb +36 -0
- data/lib/elelem/ratatui/input.rb +20 -0
- data/lib/elelem/ratatui/output.rb +47 -0
- data/lib/elelem/ratatui/session.rb +56 -0
- data/lib/elelem/ratatui/version.rb +7 -0
- data/lib/elelem/ratatui.rb +15 -0
- data/release-please-config.json +12 -0
- data/rust/Cargo.lock +662 -0
- data/rust/Cargo.toml +17 -0
- data/rust/src/app.rs +264 -0
- data/rust/src/main.rs +181 -0
- data/rust/src/protocol.rs +34 -0
- data/spec/elelem/ratatui/output_spec.rb +28 -0
- data/spec/elelem/ratatui/session_spec.rb +36 -0
- data/spec/spec_helper.rb +11 -0
- metadata +122 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: bdc732830d3934611535d43d516a91b2470ce4ed560a4d4bf262654679328768
|
|
4
|
+
data.tar.gz: 7675705e3d3674c9ce9986cbfe988ad3308040ece8f47458a13b522f5b52e498
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5fd9f984c13f602956c15ae5fd381c9cb1e8688845b95700e89897938f7db1d083ae9cf6341d2a0ef8c25b51e7e9514a932b2f39547149a6c075f4141a0d4c8d
|
|
7
|
+
data.tar.gz: d06e9eed4d90eb08445bde71f8ad1eb683e2cd50942cff16931468185d903ba50961c8d22dc08d7584c8eb2ff24266c870dc97a39634f36962502483c2ab7fb4
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
As a `user who loads elelem-ratatui where there is no terminal`, I
|
|
2
|
+
`want elelem to fall back to plain output or fail with a clear
|
|
3
|
+
message`, so that `a pipe, CI job or service does not end silently`.
|
|
4
|
+
|
|
5
|
+
# SYNOPSIS
|
|
6
|
+
|
|
7
|
+
Handle a missing /dev/tty instead of exiting without a word.
|
|
8
|
+
|
|
9
|
+
# DESCRIPTION
|
|
10
|
+
|
|
11
|
+
The Rust UI draws to and reads keys from `/dev/tty`, not from its own
|
|
12
|
+
stdin and stdout, which carry the JSON protocol (main.rs:28-30, :54).
|
|
13
|
+
When there is no controlling terminal (a CI job, a service, `elelem ask`
|
|
14
|
+
from a cron job, a container without `-t`) `open_tty()` fails and the
|
|
15
|
+
binary exits. The Ruby side then gets `EPIPE` on its next `emit` and
|
|
16
|
+
calls `quit` (session.rb:29-30), which ends the process with status 0
|
|
17
|
+
and no message.
|
|
18
|
+
|
|
19
|
+
Since the plugin replaces elelem's input and output for every command
|
|
20
|
+
once it is loaded (ratatui.rb:12-15), loading it in
|
|
21
|
+
`~/.agents/plugins` breaks every non-interactive use of elelem.
|
|
22
|
+
|
|
23
|
+
Proposed (choose in design):
|
|
24
|
+
|
|
25
|
+
* Before starting the binary, check that `/dev/tty` can be opened. If
|
|
26
|
+
not, do not register the ratatui input and output, so elelem keeps
|
|
27
|
+
its plain terminal, and log why.
|
|
28
|
+
* If the binary still fails to start, print its stderr and exit
|
|
29
|
+
non-zero.
|
|
30
|
+
|
|
31
|
+
Already fixed on main, from the same issue: the log pane follows new
|
|
32
|
+
output (main.rs:138-141, app.rs:136), Ctrl-C at a prompt quits instead
|
|
33
|
+
of typing "c" (app.rs:150-153), the `as` field is honored
|
|
34
|
+
(protocol.rs:9), Ruby sends `oops` and `display_file` (output.rb:12,
|
|
35
|
+
:35-37), and there are specs (spec/elelem/ratatui/).
|
|
36
|
+
|
|
37
|
+
# SEE ALSO
|
|
38
|
+
|
|
39
|
+
* [ ] rust/src/main.rs:28-30 - open_tty
|
|
40
|
+
* [ ] rust/src/main.rs:54 - `?` exits when /dev/tty is missing
|
|
41
|
+
* [ ] lib/elelem/ratatui/session.rb:12-19 - starts the binary
|
|
42
|
+
* [ ] lib/elelem/ratatui/session.rb:29-30 - EPIPE quits silently
|
|
43
|
+
* [ ] lib/elelem/ratatui.rb:12-15 - replaces input and output
|
|
44
|
+
* [ ] Formerly elelem-sh/elelem.sh#34
|
|
45
|
+
|
|
46
|
+
# Tasks
|
|
47
|
+
|
|
48
|
+
* [ ] TBD (filled in design mode)
|
|
49
|
+
|
|
50
|
+
# Acceptance Criteria
|
|
51
|
+
|
|
52
|
+
* [ ] With the plugin loaded and no controlling terminal,
|
|
53
|
+
`elelem ask -p stub "hi"` prints a reply and exits 0
|
|
54
|
+
* [ ] When the UI cannot start for another reason, elelem prints why
|
|
55
|
+
and exits non-zero
|
|
56
|
+
* [ ] Interactive use in a terminal is unchanged
|
|
57
|
+
* [ ] Specs cover the missing terminal case
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
As a `user reading a long session in elelem-ratatui`, I `want to
|
|
2
|
+
scroll back through earlier output`, so that `I can reread a reply or
|
|
3
|
+
tool result that has moved off screen`.
|
|
4
|
+
|
|
5
|
+
# SYNOPSIS
|
|
6
|
+
|
|
7
|
+
Add keys (and optionally the mouse wheel) to scroll the log pane.
|
|
8
|
+
|
|
9
|
+
# DESCRIPTION
|
|
10
|
+
|
|
11
|
+
The log pane now follows the newest output: `draw` computes
|
|
12
|
+
`scroll_to_bottom` on every frame (main.rs:138-141). There is no way
|
|
13
|
+
to scroll up. The program uses the alternate screen (main.rs:56), so
|
|
14
|
+
the terminal's own scrollback does not hold the output either. Anything
|
|
15
|
+
taller than the pane is out of reach until the session ends, and then
|
|
16
|
+
it is gone.
|
|
17
|
+
|
|
18
|
+
Proposed:
|
|
19
|
+
|
|
20
|
+
* Page Up and Page Down (and Shift+Up and Shift+Down for single lines)
|
|
21
|
+
scroll the log pane, in and out of a prompt.
|
|
22
|
+
* While scrolled up, new output does not jump the view; the title shows
|
|
23
|
+
that the view is not at the bottom. End, or scrolling to the bottom,
|
|
24
|
+
resumes following.
|
|
25
|
+
* Optionally, mouse wheel scrolling.
|
|
26
|
+
* Decide in design whether to cap the stored rows.
|
|
27
|
+
|
|
28
|
+
# SEE ALSO
|
|
29
|
+
|
|
30
|
+
* [ ] rust/src/main.rs:126-142 - draw, scroll offset
|
|
31
|
+
* [ ] rust/src/app.rs:135-148 - scroll_to_bottom
|
|
32
|
+
* [ ] rust/src/app.rs:150 - prompt_key
|
|
33
|
+
* [ ] Formerly elelem-sh/elelem.sh#34
|
|
34
|
+
|
|
35
|
+
# Tasks
|
|
36
|
+
|
|
37
|
+
* [ ] TBD (filled in design mode)
|
|
38
|
+
|
|
39
|
+
# Acceptance Criteria
|
|
40
|
+
|
|
41
|
+
* [ ] Page Up shows earlier output, and Page Down returns toward the
|
|
42
|
+
newest
|
|
43
|
+
* [ ] New output does not move the view while scrolled up
|
|
44
|
+
* [ ] Returning to the bottom resumes following new output
|
|
45
|
+
* [ ] Scroll keys do not type into the prompt
|
|
46
|
+
* [ ] Rust unit tests cover the scroll offset rules
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
As a `user who quits the elelem-ratatui UI`, I `want the process to
|
|
2
|
+
end however the quit was noticed`, so that `elelem does not keep
|
|
3
|
+
running unseen after the UI has closed`.
|
|
4
|
+
|
|
5
|
+
# SYNOPSIS
|
|
6
|
+
|
|
7
|
+
Make `quit` signal the main thread instead of calling `exit` in the
|
|
8
|
+
caller's thread.
|
|
9
|
+
|
|
10
|
+
# DESCRIPTION
|
|
11
|
+
|
|
12
|
+
`Session#emit` calls `quit` when the UI has closed or the pipe is
|
|
13
|
+
broken (session.rb:23-31), and `quit` calls `exit` (session.rb:43-45).
|
|
14
|
+
`exit` raises `SystemExit` in the current thread only. Any plugin may
|
|
15
|
+
produce output from a thread of its own, and `emit` runs on that
|
|
16
|
+
thread. When such a thread is the first to notice the closed UI,
|
|
17
|
+
`SystemExit` ends just that thread and the process keeps running with
|
|
18
|
+
no UI. The original report named the MCP loader threads and the
|
|
19
|
+
waiting dots. On main, elelem-mcp's loader threads
|
|
20
|
+
(elelem-mcp lib/elelem/mcp.rb:42) write errors to `$stderr` rather
|
|
21
|
+
than through `emit`, and ratatui's `waiting` emits once from the
|
|
22
|
+
caller (output.rb:31-32). The bug holds for any caller off the main
|
|
23
|
+
thread; list the real ones in design.
|
|
24
|
+
|
|
25
|
+
Expected: `quit` tells the main thread to shut down (for example
|
|
26
|
+
`Thread.main.raise(SystemExit)`, or a flag the main loop checks, or
|
|
27
|
+
`Process.kill` of its own pid with an interrupt), runs the `at_exit`
|
|
28
|
+
close (session.rb:9), and returns. Pick the approach in design.
|
|
29
|
+
|
|
30
|
+
# SEE ALSO
|
|
31
|
+
|
|
32
|
+
* [ ] lib/elelem/ratatui/session.rb:23-31 - emit
|
|
33
|
+
* [ ] lib/elelem/ratatui/session.rb:43-45 - quit calls exit
|
|
34
|
+
* [ ] lib/elelem/ratatui/session.rb:8-10 - at_exit close
|
|
35
|
+
* [ ] spec/elelem/ratatui/session_spec.rb
|
|
36
|
+
* [ ] Formerly elelem-sh/elelem.sh#53
|
|
37
|
+
|
|
38
|
+
# Tasks
|
|
39
|
+
|
|
40
|
+
* [ ] TBD (filled in design mode)
|
|
41
|
+
|
|
42
|
+
# Acceptance Criteria
|
|
43
|
+
|
|
44
|
+
* [ ] When `emit` hits a closed UI on a background thread, the process
|
|
45
|
+
exits
|
|
46
|
+
* [ ] When it happens on the main thread, behavior is as today
|
|
47
|
+
* [ ] The UI binary is closed in both cases
|
|
48
|
+
* [ ] A spec calls `emit` on a closed session from a background thread
|
|
49
|
+
and checks that the main thread is told to exit
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
As a `person who wants a full-screen terminal UI for elelem`, I `want
|
|
2
|
+
a README in the elelem-ratatui repository`, so that `I can build and
|
|
3
|
+
enable it and know its limits`.
|
|
4
|
+
|
|
5
|
+
# SYNOPSIS
|
|
6
|
+
|
|
7
|
+
Add a short README.
|
|
8
|
+
|
|
9
|
+
# DESCRIPTION
|
|
10
|
+
|
|
11
|
+
The repository has no README. It should cover:
|
|
12
|
+
|
|
13
|
+
* Install, and that the gem builds a Rust binary (cargo is required;
|
|
14
|
+
bin/setup).
|
|
15
|
+
* How to enable it: it replaces elelem's input and output when loaded,
|
|
16
|
+
so it needs the loader file `~/.agents/plugins/ratatui.rb` containing
|
|
17
|
+
`require "elelem/ratatui"`, or `exe/elelem-ratatui`.
|
|
18
|
+
* Keys: Enter, Ctrl-C and Ctrl-D at a prompt, and scroll keys once the
|
|
19
|
+
scrollback story ships.
|
|
20
|
+
* Limits: it needs a terminal (/dev/tty) until the no-terminal story
|
|
21
|
+
ships.
|
|
22
|
+
* A link to https://elelem.sh/plugins/ratatui/.
|
|
23
|
+
|
|
24
|
+
Show commands without a leading `$`.
|
|
25
|
+
|
|
26
|
+
# SEE ALSO
|
|
27
|
+
|
|
28
|
+
* [ ] lib/elelem/ratatui.rb - what the plugin replaces
|
|
29
|
+
* [ ] exe/elelem-ratatui
|
|
30
|
+
* [ ] bin/setup
|
|
31
|
+
* [ ] https://elelem.sh/plugins/ratatui/
|
|
32
|
+
* [ ] Formerly elelem-sh/elelem.sh#23
|
|
33
|
+
|
|
34
|
+
# Tasks
|
|
35
|
+
|
|
36
|
+
* [ ] TBD (filled in design mode)
|
|
37
|
+
|
|
38
|
+
# Acceptance Criteria
|
|
39
|
+
|
|
40
|
+
* [ ] README.md exists and covers install, enabling, keys and limits
|
|
41
|
+
* [ ] Commands have no leading `$`
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
As a `person who finds elelem-ratatui on RubyGems`, I `want the
|
|
2
|
+
gem page to link to the plugin's documentation, backlog and
|
|
3
|
+
changelog`, so that `I can learn how to use it and see known
|
|
4
|
+
problems without GitHub Issues`.
|
|
5
|
+
|
|
6
|
+
# SYNOPSIS
|
|
7
|
+
|
|
8
|
+
Point the gemspec homepage at elelem.sh and add the standard links.
|
|
9
|
+
|
|
10
|
+
# DESCRIPTION
|
|
11
|
+
|
|
12
|
+
RubyGems shows `homepage_uri` and the other `metadata` links on every
|
|
13
|
+
gem page. Today `elelem-ratatui.gemspec` sets `spec.homepage`
|
|
14
|
+
to the site root (https://elelem.sh) and sets only `homepage_uri`,
|
|
15
|
+
`source_code_uri`, `allowed_push_host` and
|
|
16
|
+
`rubygems_mfa_required`.
|
|
17
|
+
There is no documentation, bug tracker or changelog link.
|
|
18
|
+
|
|
19
|
+
Proposed change:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
spec.homepage = "https://elelem.sh/plugins/ratatui/"
|
|
23
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
24
|
+
spec.metadata["source_code_uri"] = "https://github.com/elelem-sh/ratatui"
|
|
25
|
+
spec.metadata["documentation_uri"] = spec.homepage
|
|
26
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/elelem-sh/ratatui/tree/main/.agents/backlog"
|
|
27
|
+
spec.metadata["changelog_uri"] = "https://github.com/elelem-sh/ratatui/blob/main/CHANGELOG.md"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The original proposal pointed `bug_tracker_uri` at GitHub Issues on
|
|
31
|
+
elelem-sh/elelem.sh, filtered by label. That no longer fits: the
|
|
32
|
+
project is moving its backlog out of GitHub Issues and into
|
|
33
|
+
`.agents/backlog` story files in each repository, so the bug tracker
|
|
34
|
+
link points at this repository's backlog directory instead.
|
|
35
|
+
|
|
36
|
+
/man/ratatui/ redirects to /plugins/ratatui/ on elelem.sh, so a
|
|
37
|
+
separate documentation_uri adds nothing. Point both at the plugin page.
|
|
38
|
+
|
|
39
|
+
There is no CHANGELOG.md on main yet. release-please writes one
|
|
40
|
+
on the first release, so ship the link with or after that release.
|
|
41
|
+
|
|
42
|
+
Keep `allowed_push_host` and `rubygems_mfa_required` as they are.
|
|
43
|
+
RubyGems only shows the new links after the next release.
|
|
44
|
+
|
|
45
|
+
# SEE ALSO
|
|
46
|
+
|
|
47
|
+
* [ ] elelem-ratatui.gemspec:13 - spec.homepage
|
|
48
|
+
* [ ] elelem-ratatui.gemspec:18 - source_code_uri
|
|
49
|
+
* [ ] .agents/backlog/ - where bug_tracker_uri will point
|
|
50
|
+
* [ ] Formerly elelem-sh/elelem.sh#41
|
|
51
|
+
|
|
52
|
+
# Tasks
|
|
53
|
+
|
|
54
|
+
* [ ] TBD (filled in design mode)
|
|
55
|
+
|
|
56
|
+
# Acceptance Criteria
|
|
57
|
+
|
|
58
|
+
* [ ] `spec.homepage` and `homepage_uri` are https://elelem.sh/plugins/ratatui/
|
|
59
|
+
* [ ] `bug_tracker_uri` points at this repository's `.agents/backlog`,
|
|
60
|
+
not at GitHub Issues
|
|
61
|
+
* [ ] `changelog_uri` and `source_code_uri` point at this repository
|
|
62
|
+
* [ ] `allowed_push_host` and `rubygems_mfa_required` are unchanged
|
|
63
|
+
* [ ] `gem build` succeeds and `gem spec` on the built gem shows every
|
|
64
|
+
link
|
|
65
|
+
* [ ] Every link resolves (no 404) at release time
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions: {}
|
|
9
|
+
|
|
10
|
+
concurrency:
|
|
11
|
+
group: release
|
|
12
|
+
cancel-in-progress: false
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
test:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
21
|
+
with:
|
|
22
|
+
persist-credentials: false
|
|
23
|
+
- uses: ruby/setup-ruby@3ff19f5e2baf30647122352b96108b1fbe250c64 # v1.299.0
|
|
24
|
+
with:
|
|
25
|
+
ruby-version: "4.0"
|
|
26
|
+
bundler-cache: true
|
|
27
|
+
- run: bin/test
|
|
28
|
+
- run: bin/lint
|
|
29
|
+
|
|
30
|
+
release-please:
|
|
31
|
+
needs: test
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
permissions:
|
|
34
|
+
contents: write
|
|
35
|
+
issues: write
|
|
36
|
+
pull-requests: write
|
|
37
|
+
outputs:
|
|
38
|
+
release_created: ${{ steps.release.outputs.release_created }}
|
|
39
|
+
steps:
|
|
40
|
+
- id: release
|
|
41
|
+
uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
|
|
42
|
+
with:
|
|
43
|
+
config-file: release-please-config.json
|
|
44
|
+
manifest-file: .release-please-manifest.json
|
|
45
|
+
|
|
46
|
+
publish:
|
|
47
|
+
needs: release-please
|
|
48
|
+
if: needs.release-please.outputs.release_created == 'true' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
|
|
49
|
+
runs-on: ubuntu-latest
|
|
50
|
+
permissions:
|
|
51
|
+
contents: write
|
|
52
|
+
id-token: write
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
55
|
+
with:
|
|
56
|
+
persist-credentials: false
|
|
57
|
+
- uses: ruby/setup-ruby@3ff19f5e2baf30647122352b96108b1fbe250c64 # v1.299.0
|
|
58
|
+
with:
|
|
59
|
+
ruby-version: "4.0"
|
|
60
|
+
bundler-cache: true
|
|
61
|
+
- shell: bash
|
|
62
|
+
run: |
|
|
63
|
+
set -euo pipefail
|
|
64
|
+
jwt=$(curl -sS --fail-with-body -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=rubygems.org" | jq -r .value)
|
|
65
|
+
echo "::add-mask::$jwt"
|
|
66
|
+
key=$(jq -n --arg jwt "$jwt" '{jwt: $jwt, owner: "66898"}' | curl -sS --fail-with-body -H "content-type: application/json" -d @- https://rubygems.org/api/v1/oidc/trusted_publisher/exchange_token | jq -r .rubygems_api_key)
|
|
67
|
+
test -n "$key" -a "$key" != null
|
|
68
|
+
echo "::add-mask::$key"
|
|
69
|
+
printf 'GEM_HOST_API_KEY=%s\nBUNDLE_GEM__PUSH_KEY=%s\nRUBYGEMS_API_KEY=%s\n' "$key" "$key" "$key" >> "$GITHUB_ENV"
|
|
70
|
+
- uses: rubygems/release-gem@7f9650160c1a4e7989fdc9855807bdbd421d8b6b # v1.4.1
|
|
71
|
+
with:
|
|
72
|
+
await-release: false
|
|
73
|
+
setup-trusted-publisher: false
|
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
NewCops: enable
|
|
3
|
+
TargetRubyVersion: 4.0
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
Exclude:
|
|
6
|
+
- "pkg/**/*"
|
|
7
|
+
- "bin/**/*"
|
|
8
|
+
- "vendor/**/*"
|
|
9
|
+
- "fixtures/**/*"
|
|
10
|
+
|
|
11
|
+
Metrics:
|
|
12
|
+
Enabled: false
|
|
13
|
+
|
|
14
|
+
Naming/PredicateMethod:
|
|
15
|
+
AllowedMethods:
|
|
16
|
+
- call
|
|
17
|
+
- run
|
|
18
|
+
- summarize
|
|
19
|
+
- prompt
|
|
20
|
+
|
|
21
|
+
Naming/MethodParameterName:
|
|
22
|
+
AllowedNames:
|
|
23
|
+
- me
|
|
24
|
+
- id
|
|
25
|
+
- as
|
|
26
|
+
- io
|
|
27
|
+
|
|
28
|
+
Style/GlobalVars:
|
|
29
|
+
Exclude:
|
|
30
|
+
- "spec/**/*"
|
|
31
|
+
|
|
32
|
+
Lint/EmptyBlock:
|
|
33
|
+
Exclude:
|
|
34
|
+
- "spec/**/*"
|
|
35
|
+
|
|
36
|
+
Lint/UselessDefaultValueArgument:
|
|
37
|
+
Enabled: false
|
|
38
|
+
|
|
39
|
+
Lint/RedundantRequireStatement:
|
|
40
|
+
Enabled: false
|
|
41
|
+
|
|
42
|
+
Lint/UnusedBlockArgument:
|
|
43
|
+
IgnoreEmptyBlocks: true
|
|
44
|
+
AllowUnusedKeywordArguments: true
|
|
45
|
+
|
|
46
|
+
Style/Documentation:
|
|
47
|
+
Enabled: false
|
|
48
|
+
|
|
49
|
+
Style/FormatStringToken:
|
|
50
|
+
Enabled: false
|
|
51
|
+
|
|
52
|
+
Style/FrozenStringLiteralComment:
|
|
53
|
+
Enabled: true
|
|
54
|
+
|
|
55
|
+
Style/StringLiterals:
|
|
56
|
+
EnforcedStyle: double_quotes
|
|
57
|
+
|
|
58
|
+
Style/StringLiteralsInInterpolation:
|
|
59
|
+
EnforcedStyle: double_quotes
|
|
60
|
+
|
|
61
|
+
Layout/LineLength:
|
|
62
|
+
Max: 120
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (2026-11-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add exe/elelem-ratatui and bin/run for standalone use ([05c47e7](https://github.com/elelem-sh/ratatui/commit/05c47e700381c60133c1766aa0b6108c906e4c6e))
|
|
9
|
+
* build the Rust binary via ext/extconf.rb, not bin/setup ([da92b6b](https://github.com/elelem-sh/ratatui/commit/da92b6bed07ed1626208786b65b86a9b8e5788bc))
|
|
10
|
+
* ratatui-based TUI for elelem, backed by Output/Input plugin API ([7a61433](https://github.com/elelem-sh/ratatui/commit/7a6143336ab4d810173f75b49e3cef034ed7e57f))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* migrate to Output#doing's new (name, args, state:) signature ([15608bf](https://github.com/elelem-sh/ratatui/commit/15608bfba14ef333d4028b919b10f9740b794a9e))
|
|
16
|
+
* quitting ratatui at a prompt ends the session instead of crashing on the closed pipe ([0f180a5](https://github.com/elelem-sh/ratatui/commit/0f180a5a1ccc04be9da8adef44b3501a79150351))
|
|
17
|
+
* ratatui shows at most the start of a regular file, and expands ~ in its path ([d241b34](https://github.com/elelem-sh/ratatui/commit/d241b347b011d09b58515420a18eecfb04f28429))
|
|
18
|
+
* ratatui shows errors as errors and displays written files (elelem-sh/elelem.sh[#34](https://github.com/elelem-sh/ratatui/issues/34)) ([b786191](https://github.com/elelem-sh/ratatui/commit/b786191b2f6e7edaaa8b565eb9b9d6532a82c4b4))
|
|
19
|
+
* relock elelem to 0.11.0, a real published version ([6edc421](https://github.com/elelem-sh/ratatui/commit/6edc4219419ece3d078dc38343a456dc2ff9822f))
|
|
20
|
+
* require elelem ~> 0.12, the floor builtins/skills actually need ([ccdd396](https://github.com/elelem-sh/ratatui/commit/ccdd396b14193936914eae5b8ee53b834fa9e343))
|
|
21
|
+
* require elelem 0.13 or later, which ships the builtins ([0f03174](https://github.com/elelem-sh/ratatui/commit/0f03174321a6e733df75caddb16469c46e813f6a))
|
|
22
|
+
* the log pane follows new output, and Ctrl-C at a prompt quits instead of typing c (elelem-sh/elelem.sh[#34](https://github.com/elelem-sh/ratatui/issues/34)) ([fd2ba57](https://github.com/elelem-sh/ratatui/commit/fd2ba57a9e0069243acf640633a405aae03ed73a))
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mo khan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rspec/core/rake_task"
|
|
5
|
+
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
7
|
+
|
|
8
|
+
desc "Build the Rust binary (the same build `gem install` runs)"
|
|
9
|
+
task :compile do
|
|
10
|
+
ruby "ext/elelem/ratatui/extconf.rb"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
task default: %i[spec]
|
data/exe/elelem-ratatui
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "fileutils"
|
|
4
|
+
|
|
5
|
+
EXT_DIR = __dir__
|
|
6
|
+
GEM_ROOT = File.expand_path("../../..", EXT_DIR)
|
|
7
|
+
RUST_DIR = File.join(GEM_ROOT, "rust")
|
|
8
|
+
NATIVE = File.join(EXT_DIR, "native")
|
|
9
|
+
|
|
10
|
+
def run(*cmd)
|
|
11
|
+
warn "elelem-ratatui: + #{cmd.join(" ")}"
|
|
12
|
+
system(*cmd) || abort("elelem-ratatui: build step failed: #{cmd.join(" ")}")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def which(cmd)
|
|
16
|
+
ENV["PATH"].to_s.split(File::PATH_SEPARATOR).any? do |dir|
|
|
17
|
+
path = File.join(dir, cmd)
|
|
18
|
+
File.executable?(path) && !File.directory?(path)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
abort "elelem-ratatui: cargo not found. Install Rust: https://rustup.rs" unless which("cargo")
|
|
23
|
+
|
|
24
|
+
run("cargo", "build", "--release", "--manifest-path", File.join(RUST_DIR, "Cargo.toml"))
|
|
25
|
+
|
|
26
|
+
FileUtils.mkdir_p(NATIVE)
|
|
27
|
+
FileUtils.cp(File.join(RUST_DIR, "target", "release", "elelem-ratatui"), File.join(NATIVE, "elelem-ratatui"))
|
|
28
|
+
|
|
29
|
+
File.write(File.join(EXT_DIR, "Makefile"), <<~MAKE)
|
|
30
|
+
all:
|
|
31
|
+
clean:
|
|
32
|
+
install:
|
|
33
|
+
.PHONY: all clean install
|
|
34
|
+
MAKE
|
|
35
|
+
|
|
36
|
+
warn "elelem-ratatui: built binary into #{NATIVE}"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Elelem
|
|
4
|
+
module Ratatui
|
|
5
|
+
class Input
|
|
6
|
+
def initialize(session: Session.memoized, commands: nil)
|
|
7
|
+
@session = session
|
|
8
|
+
@commands = commands
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def ask(prompt)
|
|
12
|
+
@session.ask(prompt)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def interactive?
|
|
16
|
+
true
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Elelem
|
|
4
|
+
module Ratatui
|
|
5
|
+
class Output
|
|
6
|
+
def initialize(session: Session.memoized)
|
|
7
|
+
@session = session
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def say(text, as: nil)
|
|
11
|
+
return if blank?(text)
|
|
12
|
+
return @session.emit(type: "oops", message: text.to_s) if as == :error
|
|
13
|
+
|
|
14
|
+
@session.emit(type: "say", text: text.to_s, as: as&.to_s)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def print(text)
|
|
18
|
+
return if blank?(text)
|
|
19
|
+
|
|
20
|
+
@session.emit(type: "print", text: text.to_s)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def thinking(text)
|
|
24
|
+
@session.emit(type: "thinking", text: text.to_s)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def doing(name, args, state: "+")
|
|
28
|
+
@session.emit(type: "doing", header: "#{state} #{name}(#{args})")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def waiting
|
|
32
|
+
@session.emit(type: "waiting")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def display_file(path, fallback: nil)
|
|
36
|
+
# Tools pass the path as the model wrote it; the UI cannot expand ~.
|
|
37
|
+
@session.emit(type: "display_file", path: File.expand_path(path.to_s), fallback: fallback)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def blank?(text)
|
|
43
|
+
text.nil? || text.to_s.strip.empty?
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Elelem
|
|
4
|
+
module Ratatui
|
|
5
|
+
class Session
|
|
6
|
+
BINARY = File.expand_path("../../../ext/elelem/ratatui/native/elelem-ratatui", __dir__)
|
|
7
|
+
|
|
8
|
+
def self.memoized
|
|
9
|
+
@memoized ||= new.tap { |session| at_exit { session.close } }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
unless File.executable?(BINARY)
|
|
14
|
+
raise "elelem-ratatui binary missing at #{BINARY}. Run: bin/setup (requires cargo)"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
@stdin, @stdout, @wait = Open3.popen2(BINARY)
|
|
18
|
+
@mutex = Mutex.new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Once the person quits the UI, nothing more should run unseen: the next
|
|
22
|
+
# output ends the process instead of writing to a closed pipe.
|
|
23
|
+
def emit(payload)
|
|
24
|
+
quit if @closed
|
|
25
|
+
@mutex.synchronize do
|
|
26
|
+
@stdin.puts(payload.to_json)
|
|
27
|
+
@stdin.flush
|
|
28
|
+
end
|
|
29
|
+
rescue Errno::EPIPE, IOError
|
|
30
|
+
quit
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# nil means the UI quit (Ctrl+C or Ctrl+D). The caller gets nil, which
|
|
34
|
+
# refuses a permission prompt, and the session is closed.
|
|
35
|
+
def ask(prompt)
|
|
36
|
+
emit(type: "ask", prompt: prompt)
|
|
37
|
+
line = @stdout.gets
|
|
38
|
+
answer = line && JSON.parse(line)["line"]
|
|
39
|
+
@closed = true if answer.nil?
|
|
40
|
+
answer
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def quit
|
|
44
|
+
exit
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def close
|
|
48
|
+
@stdin.close
|
|
49
|
+
rescue IOError
|
|
50
|
+
nil
|
|
51
|
+
ensure
|
|
52
|
+
@wait&.kill
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "elelem"
|
|
4
|
+
require "json"
|
|
5
|
+
require "open3"
|
|
6
|
+
|
|
7
|
+
require_relative "ratatui/version"
|
|
8
|
+
require_relative "ratatui/session"
|
|
9
|
+
require_relative "ratatui/output"
|
|
10
|
+
require_relative "ratatui/input"
|
|
11
|
+
|
|
12
|
+
Elelem.configure do |config|
|
|
13
|
+
config.output { Elelem::Ratatui::Output.new }
|
|
14
|
+
config.input { |commands: nil| Elelem::Ratatui::Input.new(commands: commands) }
|
|
15
|
+
end
|