tempest-rb 0.1.2 → 0.1.3

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: b397a067ca8e4f637036351fd8d3f29f41dc7ef6a96d809c8f793993f34c940d
4
- data.tar.gz: 83435fddf2631e5d16afdc8d185ae3b3ba5666c1a5bb6b838705e5ee4fc526f2
3
+ metadata.gz: a4e5235014794e4ae27f0b7b7ed337f902a3c85460d43e1acb4ad30f4288a49d
4
+ data.tar.gz: 64bba834d40398b2e31c3d565e496ff250f8e56609538077116bd79d941cda05
5
5
  SHA512:
6
- metadata.gz: c770fedb069f714b7a280535efe1c5984001bfcad6cce6a1ab4cc0e6ee8ee579fec9402659578b1573572c98d40fd089fe82f5469c0e040f0cc33b1dfeda39a0
7
- data.tar.gz: 3cba24306fa9a90c00f44c77bd768753b1ab26f3420be6fb3706b275bdbaa426e869ce791248e3c0be7a8dfc27e673610f7286b60ffb416806c4b01b26ccf724
6
+ metadata.gz: 10544f474bcb54edb082f30cbf9dff2ab5be77633020fd30df854eefa94e8d14efc7cba39adfc2d9a80e1c300738570db7c9cb86669ab0f5d8f51f51400e1b4d
7
+ data.tar.gz: 90b14c9abb826525ebcc1106bae8863aeca5cfd6234994e65e8bd46d28aa851890eec233bc277c882a61942af32c055c24bfc07e6cd1684c35b11fec3e7e66ec
data/README.md CHANGED
@@ -73,6 +73,25 @@ Each post in the timeline is prefixed with a short `$XX` id, and URLs found insi
73
73
  | `--no-stream` | Disable the auto-started Jetstream feed |
74
74
  | `--feed=MODE` | `home` (default, your follows + your own posts) or `self` (only your own posts) |
75
75
 
76
+ ### Non-interactive CLI
77
+
78
+ Once you have signed in once with `tempest tui`, you can call the CLI from scripts and tools:
79
+
80
+ ```sh
81
+ tempest whoami --json
82
+ tempest post "今日もよろしくお願いします"
83
+ tempest feed me --since today --format json | jq '.text'
84
+ tempest feed author asonas.bsky.social --limit 20
85
+ ```
86
+
87
+ `--format=json` emits newline-delimited JSON; one post per line. The schema is documented in `lib/tempest/post_view.rb`.
88
+
89
+ `--format=raw` emits the underlying `getAuthorFeed`/`getTimeline` response pretty-printed; do not rely on its shape.
90
+
91
+ `--format=line` (default when stdout is a TTY) prints the same single-line representation as the TUI scroll buffer.
92
+
93
+ The non-interactive subcommands require a cached session on disk. If your cache is missing or expired, run `tempest tui` once to refresh it.
94
+
76
95
  ### Environment variables
77
96
 
78
97
  | Variable | Purpose |
@@ -101,25 +120,6 @@ A built-in watchdog runs alongside the Jetstream consumer regardless of logging:
101
120
 
102
121
  To inspect the log, grep by component tag: `grep '\[stream\]' ~/tempest-debug.log` shows connect, reconnect, gap, and disconnect events, while `grep '\[watchdog\]' ~/tempest-debug.log` shows forced reconnects.
103
122
 
104
- ## Non-interactive CLI
105
-
106
- Once you have signed in once with `tempest tui`, you can call the CLI from scripts and tools:
107
-
108
- ```sh
109
- tempest whoami --json
110
- tempest post "今日もよろしくお願いします"
111
- tempest feed me --since today --format json | jq '.text'
112
- tempest feed author asonas.bsky.social --limit 20
113
- ```
114
-
115
- `--format=json` emits newline-delimited JSON; one post per line. The schema is documented in `lib/tempest/post_view.rb`.
116
-
117
- `--format=raw` emits the underlying `getAuthorFeed`/`getTimeline` response pretty-printed; do not rely on its shape.
118
-
119
- `--format=line` (default when stdout is a TTY) prints the same single-line representation as the TUI scroll buffer.
120
-
121
- The non-interactive subcommands require a cached session on disk. If your cache is missing or expired, run `tempest tui` once to refresh it.
122
-
123
123
  ## Development
124
124
 
125
125
  ```sh
data/lib/tempest/post.rb CHANGED
@@ -58,6 +58,26 @@ module Tempest
58
58
  )
59
59
  end
60
60
 
61
+ # Compose an app.bsky.feed.like record referencing the subject post and
62
+ # send it via com.atproto.repo.createRecord. The AppView surfaces this in
63
+ # like counts and notifications for the target post.
64
+ def self.like(client, did:, subject_uri:, subject_cid:,
65
+ created_at: Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%LZ"))
66
+ record = {
67
+ "$type" => "app.bsky.feed.like",
68
+ "subject" => { "uri" => subject_uri, "cid" => subject_cid },
69
+ "createdAt" => created_at,
70
+ }
71
+ client.post(
72
+ "com.atproto.repo.createRecord",
73
+ body: {
74
+ repo: did,
75
+ collection: "app.bsky.feed.like",
76
+ record: record,
77
+ },
78
+ )
79
+ end
80
+
61
81
  # Scans `text` for bare URLs and builds AT Protocol link facets pointing
62
82
  # at each match. Without this, the AppView treats URLs as plain text and
63
83
  # does not render them as clickable links.
@@ -5,7 +5,7 @@ module Tempest
5
5
  Command = Data.define(:name, :args)
6
6
 
7
7
  class Dispatcher
8
- KNOWN_COMMANDS = %i[timeline quit help stream open relogin].freeze
8
+ KNOWN_COMMANDS = %i[timeline quit help stream open relogin fav].freeze
9
9
  DOLLAR_ID = /\A\$[A-Z]{2}\z/.freeze
10
10
 
11
11
  def dispatch(input)
@@ -18,6 +18,7 @@ module Tempest
18
18
  :timeline Fetch and print the home timeline
19
19
  :stream on|off Toggle the Jetstream live feed
20
20
  :open $LX Open the URL with id $LX in the browser
21
+ :fav $XX Like the post with id $XX
21
22
  :relogin Re-authenticate when the cached session is dead
22
23
  :help Show this help
23
24
  :quit Exit tempest (or Ctrl-D)
@@ -108,6 +109,8 @@ module Tempest
108
109
  handle_reply(command.args[0], command.args[1])
109
110
  when :open
110
111
  handle_open(command.args.first)
112
+ when :fav
113
+ handle_fav(command.args.first)
111
114
  when :relogin
112
115
  handle_relogin
113
116
  when :unknown
@@ -182,6 +185,29 @@ module Tempest
182
185
  @output.puts "error: #{e.message}"
183
186
  end
184
187
 
188
+ def handle_fav(var)
189
+ if var.nil? || var.empty?
190
+ @output.puts "usage: :fav $XX"
191
+ return
192
+ end
193
+ target = @registry.find_post(var)
194
+ if target.nil?
195
+ @output.puts "unknown id: #{var}"
196
+ return
197
+ end
198
+ response = Post.like(
199
+ @client,
200
+ did: @session.did,
201
+ subject_uri: reply_uri_for(target),
202
+ subject_cid: target.cid,
203
+ )
204
+ @output.puts "liked: #{response["uri"]}"
205
+ rescue Tempest::AuthenticationError => e
206
+ @output.puts "error: #{e.message} (#{RELOGIN_HINT})"
207
+ rescue Tempest::Error => e
208
+ @output.puts "error: #{e.message}"
209
+ end
210
+
185
211
  def handle_open(var)
186
212
  if var.nil? || var.empty?
187
213
  @output.puts "usage: :open $LX"
@@ -1,3 +1,3 @@
1
1
  module Tempest
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tempest-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuya Fujiwara