oops-cli 0.5.0 → 0.6.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: 6e78b65166ce70966491bfbda8f353c458cdcd3bdf21a082e1aef7abaaee872e
4
- data.tar.gz: 043bcf8229c508f00e5b331f00396dbcd170e899afacc3e6e0b41ca43b1b22d6
3
+ metadata.gz: 4ed6df7dbb48f2a4e9b8674e2cf787b7fbccdc8367384d13cce77c37be7eacda
4
+ data.tar.gz: 5088e40547ff5e638ecb58795f31829e8ce7eb845834bff1b8a6117eae986144
5
5
  SHA512:
6
- metadata.gz: b4ccbb6e8210f8a0427befc7618a04e0c061ec8e59130473ba2be87d72d2a739c5197121a23de1f52e9b43e15a51d9569f91accc2c224ab49429bbe0519fdd9d
7
- data.tar.gz: a61a54bb2f9911212a6d632ef3c7f65f632a4042830f428d643842c9b3379d256e2ad76014f2a9a693a56a981958fe4755f43b4821a9d882494d21814defe045
6
+ metadata.gz: a6a1600cc3030eacb11c1b6931ad730a1d17870651eb92359b008c6fe4292dea8c00248093e5347729eb5b833d5955fe834fe8c078ef62025be8611a036d75ee
7
+ data.tar.gz: c4c069c81d9188d769e6dfcae78a1ec19273fe6f512dec9b0b321230c23c855e60442d773bb2af7212eaaf1e026d73328a02ebcd10289a59e71fbcf6c7c4000e
data/CHANGELOG.ja.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  [English](CHANGELOG.md) | 日本語
4
4
 
5
+ ## 0.6.0 - 2026-11-10
6
+
7
+ - 追加: `--gist` で、整えた文字列を GitHub CLI(`gh gist create`)経由で secret gist に上げ、その URL をコピーします。秘密情報は必ずマスクし、`--show-secrets`・`--print`・`--json` との併用は使い方の誤りになります([#44](https://github.com/ysb3996-blip/oops/issues/44))。
8
+ - ドキュメント: README にトラブルシューティングの節を足しました。`oops doctor` のよく出る行の意味と、それぞれの対処を書いています([#92](https://github.com/ysb3996-blip/oops/issues/92))。[@wolf4032](https://github.com/wolf4032) さんによる貢献([#93](https://github.com/ysb3996-blip/oops/pull/93))。
9
+ - ドキュメント: README に Codex CLI から oops を使う方法を書きました。`AGENTS.md` に足す数行があれば、名指ししなくても Codex が失敗したコマンドを読みます。
10
+
5
11
  ## 0.5.0 - 2026-11-07
6
12
 
7
13
  - 追加: `--json` で、選んだコマンドを JSON の配列(コマンド・ディレクトリ・終了コード・開始と終了の時刻・出力)として標準出力へ書き出せるようにしました。クリップボードと同じように整えてマスクします。スクリプトやエージェント向けです([#43](https://github.com/ysb3996-blip/oops/issues/43))。
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  English | [日本語](CHANGELOG.ja.md)
4
4
 
5
+ ## 0.6.0 - 2026-11-10
6
+
7
+ - Added: `--gist` uploads the formatted text as a secret gist through the GitHub CLI (`gh gist create`) and copies the gist's URL. Secrets are always masked; `--show-secrets`, `--print` and `--json` are a usage error with it ([#44](https://github.com/ysb3996-blip/oops/issues/44)).
8
+ - Docs: the README has a Troubleshooting section that explains the common `oops doctor` lines and what to do about each ([#92](https://github.com/ysb3996-blip/oops/issues/92)). Contributed by [@wolf4032](https://github.com/wolf4032) in [#93](https://github.com/ysb3996-blip/oops/pull/93).
9
+ - Docs: the README shows how to use oops from Codex CLI, with an `AGENTS.md` snippet so Codex reads the failed command without being told.
10
+
5
11
  ## 0.5.0 - 2026-11-07
6
12
 
7
13
  - Added: `--json` writes the selected commands to stdout as a JSON array (command, directory, exit code, start and end times, output), cleaned and masked as on the clipboard, for scripts and agents ([#43](https://github.com/ysb3996-blip/oops/issues/43)).
data/README.ja.md CHANGED
@@ -124,13 +124,14 @@ oops init fish | source
124
124
  | `--output-only` | `$ コマンド` の行を省き、出力だけをコピーする |
125
125
  | `-p`, `--print` | クリップボードの代わりに標準出力へ書き出す(`copied:` 行は出さない) |
126
126
  | `--json` | コマンドを JSON で標準出力へ書き出す(スクリプトやエージェント向け) |
127
+ | `--gist` | [GitHub CLI](https://cli.github.com) で secret gist に上げ、その URL をコピーする([下記](#--gist)) |
127
128
  | `--show-secrets` | 秘密情報をマスクせず、置換テーブルも適用しない |
128
129
 
129
130
  `N` は正の整数で指定します。件数は位置引数の `N` または `-n N` のどちらかで 1 回だけ指定でき、併用や `-n` の繰り返しは使い方の誤りになります。対象のコマンドが指定件数より少なければ、見つかった分をコピーします。`-n` は上記の書式オプションと併用できます。
130
131
 
131
132
  `oops` 自身はコピー対象になりません。直前のコマンドが `oops` だった場合は、その前のコマンドがコピーされます。
132
133
 
133
- 終了コード: `0` コピーした(または `--print`・`--json` で出力した)、`1` コピーしなかった(記録していない、まだコマンドがない、失敗したコマンドがない、一時停止中、クリップボードのコマンドが失敗)、`2` 使い方の誤り。
134
+ 終了コード: `0` コピーした(または `--print`・`--json` で出力した、`--gist` で上げた)、`1` コピーしなかった(記録していない、まだコマンドがない、失敗したコマンドがない、一時停止中、クリップボードのコマンドが失敗、`--gist` で `gh` が失敗)、`2` 使い方の誤り。
134
135
 
135
136
  ### 標準の出力
136
137
 
@@ -206,6 +207,19 @@ $ bundle exec rspec
206
207
  ]
207
208
  ```
208
209
 
210
+ ### `--gist`
211
+
212
+ 長い出力は、チャットや issue に貼りにくいものです。`oops --gist` は、整えた文字列を secret gist に上げ、文字列の代わりに gist の URL をコピーして表示します。
213
+
214
+ ```console
215
+ $ oops err --gist
216
+ gist: https://gist.github.com/you/4f1e8c0b2d9a7e6f5c3b1a0d9e8f7c6b (1 lines)
217
+ ```
218
+
219
+ oops 自身は GitHub とやり取りしません。[GitHub CLI](https://cli.github.com) の `gh gist create` を呼ぶので、`gh` を入れて、一度 `gh auth login` でログインしておく必要があります。gist の中身は `oops.md` という1ファイルで、説明欄には1つ目のコマンドの行が入ります。`N`・`err`・`-n`・`--github`・`--time`・`--output-only` と併用できます。
220
+
221
+ secret gist は一覧にも検索にも出ませんが、URL を知っていれば誰でも開けます。そのため秘密情報は必ずマスクします。`--show-secrets` を `--gist` と併用すると使い方の誤りになり、`--print`・`--json` との併用も同じです。要らなくなった gist は、gist.github.com か `gh gist delete` で消してください。クリップボードのツールが見つからないときも URL は表示し、コピーできなかったことを警告します。
222
+
209
223
  ### `oops status`
210
224
 
211
225
  `oops status` は `recording`・`paused`・`off`(このシェルが記録されていない、またはログが削除された)のどれかを出力し、記録中のときだけ終了コード `0` を返します。エラーは出さないので、プロンプトやスクリプトから呼べます(例: [starship のカスタムモジュール](https://starship.rs/config/#custom-commands))。呼ぶたびに Ruby が起動するため 0.1〜0.2 秒ほどかかります。`off` のときの詳しい理由は `oops doctor` で分かります。
@@ -222,7 +236,7 @@ $ claude
222
236
  > `oops -p err` を実行して、失敗したテストを直して。
223
237
  ```
224
238
 
225
- Claude Code では `! oops -p err` と打って、自分で出力を会話に入れることもできます。直近 3 つのコマンドなら `-n 3` を付けます。スクリプトやエージェントが終了コードと出力を別々に扱いたいときは [`--json`](#--json) を使えます。ほかのターミナルのエージェントも、シェルコマンドに環境変数を引き継ぐものなら同じように使えます。
239
+ Claude Code では `! oops -p err` と打って、自分で出力を会話に入れることもできます。直近 3 つのコマンドなら `-n 3` を付けます。スクリプトやエージェントが終了コードと出力を別々に扱いたいときは [`--json`](#--json) を使えます。ほかのターミナルのエージェントも、シェルコマンドに環境変数を引き継ぐものなら同じように使えます(例: [Codex CLI](#codex-cli))。
226
240
 
227
241
  特に役立つのは、コマンドを実行し直したくないときです。
228
242
 
@@ -259,6 +273,18 @@ $ARGUMENTS
259
273
 
260
274
  まだ何も失敗していないときや、タブが記録されていないときは、代わりに oops のメッセージが表示されます。
261
275
 
276
+ ### Codex CLI
277
+
278
+ 記録中のタブで起動した [Codex CLI](https://github.com/openai/codex) も `oops -p err` を実行できます(例: `codex exec "Run oops -p err and fix the failing test"`)。Codex の `read-only` のサンドボックスでも動きます。名指ししなくても使ってほしいときは、次の内容を `~/.codex/AGENTS.md`(全プロジェクト共通)かプロジェクトの `AGENTS.md` に足します。
279
+
280
+ ```markdown
281
+ ## Failed commands in my terminal
282
+
283
+ This terminal tab is recorded by [oops](https://github.com/ysb3996-blip/oops). When I ask about a command I ran that failed, run `oops -p err` to read its command line, output and exit code (secrets are masked) instead of asking me to paste it or running it again. `oops -p -n 3` shows the last 3 commands.
284
+ ```
285
+
286
+ これがあれば「さっきのコマンド、なんで失敗したの?」だけで足ります。無いと、Codex は「端末は見えない」と答えます。
287
+
262
288
  ## 設定
263
289
 
264
290
  任意の設定ファイルは `${XDG_CONFIG_HOME:-~/.config}/oops/config.yml` です。
@@ -315,6 +341,22 @@ retention_days: 7 # この日数より古いコマンドを削除する。fals
315
341
  - macOS: `pbcopy` は文字エンコーディングを `LANG` / `LC_*` から決めます。日本語などの非 ASCII 文字が文字化けして届くときは、UTF-8 のロケール(例: `LANG=en_US.UTF-8`)が設定されているか確認してください。SSH 越しで起動したシェルでは設定されていないことがあります。
316
342
  - ネイティブ Windows にはまだ対応していません。
317
343
 
344
+ ## トラブルシューティング
345
+
346
+ `oops doctor` は確認ごとに `label: value` の行を 1 つ出力します。おかしい行があれば、下から探してください。例のパスは仮のものです。
347
+
348
+ - `recording: no`: このタブは記録されていません(シェルの行も `hooks: missing` になりますが、この場合はそれで正常です)。rc ファイルに `oops init` の行があり、oops の入った Ruby を `PATH` に通す設定より後ろにあるか確認し(「シェルの設定」を参照)、新しいタブを開いてください。powerlevel10k では、instant prompt のブロックより上に置く必要があります。
349
+ - `recording: yes (/Users/you/.local/state/oops/sessions/... - log file missing)`: このタブのログがありません。後の行が `log writable: no (no status file)` なら、タブを開いたときにログを作れませんでした(そのときタブに `oops: warning: session log unavailable (...)` が出ています)。たいていは状態ディレクトリ(既定は `~/.local/state/oops`)が別のユーザーの持ち物になっている(`sudo` で oops を動かした後など)か、書き込めないのが原因です。自分の持ち物に戻して書き込めるようにしてから、新しいタブを開いてください。直すまでは、新しいタブでも同じ表示になります。そうでなければ、タブを開いたままログが削除されました(`rm -rf ~/.local/state/oops` など)。新しいタブを開いてください。
350
+ - `this terminal: not the recorded tty (this: ..., recorded: ...)`: このシェルは、起動元の記録中のタブとは別の端末(tmux のペインや、記録中のタブから開いた端末ウィンドウ)で動いていて、自分では記録されていません。そのため、ここでの `oops` は起動元のタブのログを読みます。こうしたシェルは通常それ自身で記録されるので、そこでも `oops init` の行が実行されているか、`OOPS_DISABLE` が設定されていないかを確認してください。`this: unknown` のときは、`oops doctor` が端末から実行されていない(記録中のタブで AI コーディングエージェントが実行した場合など)ので、どの端末か判定できていません。プロンプトで自分で `oops doctor` を実行してください。
351
+ - `log writable: no (log-error: ...)`: ログへの書き込みに失敗しました。理由は `log-error:` の後に出ます(ディスクの空き不足など)。原因を直して、新しいタブを開いてください。
352
+ - `paused: yes`: `oops pause` で記録が一時停止しています。`oops resume` を実行してください。
353
+ - 最初の行が `recording: yes` なのに `shell: zsh, hooks: missing`: シェルは記録されていますが、フックが読み込まれていないので、コマンドはログに残りません。行を rc ファイルに書かず、プロンプトで入力した可能性があります。記録される側のシェルは rc ファイルを読み直すので、行が rc ファイルに必要です。足したら新しいタブを開いてください。
354
+ - `pbcopy`・`wl-copy`・`xclip`・`xsel` のつもりが `clipboard: osc52` になる: そのツールが `PATH` にありません(または `DISPLAY` / `WAYLAND_DISPLAY` が設定されていません)。インストールするか、設定ファイルで `clipboard:` を指定してください。SSH 越しなら `osc52` で正常です。
355
+ - `config: /Users/you/.config/oops/config.yml (unknown key: clipbord)`: キーの綴りの誤りです。そのキーは無視されます。`(could not parse /Users/you/.config/oops/config.yml: ...)` は YAML が壊れていて、oops が設定なしで動いていることを表します。`(missing)` は設定ファイルがないだけで、問題ありません。
356
+ - `warning: ~/.bashrc sets a DEBUG trap ...` または `warning: ~/.bashrc assigns PROMPT_COMMAND without appending ...`(bash のみ): `oops init bash` の行より下の行が、oops のフックを置き換えることがあります。その行を oops の行より上に移してください。`PROMPT_COMMAND` の代入なら、今の値を残す形にしてもかまいません(`PROMPT_COMMAND="...;$PROMPT_COMMAND"`)。
357
+
358
+ どれにも当てはまらないときは、`oops doctor` の出力全体を付けて[バグ報告](https://github.com/ysb3996-blip/oops/issues/new?template=bug_report.md)を出してください(セッションログは貼らないでください)。
359
+
318
360
  ## 開発
319
361
 
320
362
  ### 手元の環境を整える
@@ -353,11 +395,11 @@ bundle exec exe/oops doctor
353
395
 
354
396
  ```sh
355
397
  gem build oops-cli.gemspec
356
- gem install ./oops-cli-0.5.0.gem # ファイル名は lib/oops/version.rb に合わせる
398
+ gem install ./oops-cli-0.6.0.gem # ファイル名は lib/oops/version.rb に合わせる
357
399
  rbenv rehash # rbenv を使う場合のみ
358
400
  ```
359
401
 
360
- - gem は Ruby のバージョンごとに入ります。新しいタブが、インストールした Ruby とは別の Ruby を使っていると(たとえばリポジトリは 4.0.9 を指定しているのに、標準の Ruby が 3.3.5 の場合)、シェルの起動時に oops が見つからなくなります(bash では `bash: oops: command not found`、zsh では `command not found: oops` と出ます)。その Ruby でも `gem install` を実行してください(例: `RBENV_VERSION=3.3.5 gem install ./oops-cli-0.5.0.gem`)。
402
+ - gem は Ruby のバージョンごとに入ります。新しいタブが、インストールした Ruby とは別の Ruby を使っていると(たとえばリポジトリは 4.0.9 を指定しているのに、標準の Ruby が 3.3.5 の場合)、シェルの起動時に oops が見つからなくなります(bash では `bash: oops: command not found`、zsh では `command not found: oops` と出ます)。その Ruby でも `gem install` を実行してください(例: `RBENV_VERSION=3.3.5 gem install ./oops-cli-0.6.0.gem`)。
361
403
  - 変更のたびに入れ直してください。インストールされた gem はコピーで、チェックアウトへのリンクではありません。
362
404
  - 削除するには `gem uninstall oops-cli` です。
363
405
  - `eval "$(oops init zsh)"` は、プロンプトで打つだけでなく rc ファイルに書いてください。記録されるシェルは rc ファイルを読み直すため、行がないとフックが入りません(`oops doctor` に `hooks: missing` と出ます)。
@@ -391,6 +433,7 @@ rbenv rehash # rbenv を使う場合のみ
391
433
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/ricky9408"><img src="https://avatars.githubusercontent.com/u/49530170?v=4?s=80" width="80px;" alt="Sanghyuk Lee"/><br /><sub><b>Sanghyuk Lee</b></sub></a><br /><a href="https://github.com/ysb3996-blip/oops/commits?author=ricky9408" title="Code">💻</a></td>
392
434
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/agenticsymphony-tech"><img src="https://avatars.githubusercontent.com/u/326739730?v=4?s=80" width="80px;" alt="agenticsymphony-tech"/><br /><sub><b>agenticsymphony-tech</b></sub></a><br /><a href="https://github.com/ysb3996-blip/oops/commits?author=agenticsymphony-tech" title="Documentation">📖</a></td>
393
435
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/ShahadatTest"><img src="https://avatars.githubusercontent.com/u/179203101?v=4?s=80" width="80px;" alt="ShahadatTest"/><br /><sub><b>ShahadatTest</b></sub></a><br /><a href="https://github.com/ysb3996-blip/oops/commits?author=ShahadatTest" title="Code">💻</a></td>
436
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/wolf4032"><img src="https://avatars.githubusercontent.com/u/144633223?v=4?s=80" width="80px;" alt="wolf4032"/><br /><sub><b>wolf4032</b></sub></a><br /><a href="https://github.com/ysb3996-blip/oops/commits?author=wolf4032" title="Documentation">📖</a></td>
394
437
  </tr>
395
438
  </tbody>
396
439
  </table>
data/README.md CHANGED
@@ -124,13 +124,14 @@ Options for `oops`, `oops N` and `oops err`:
124
124
  | `--output-only` | Leave out the `$ command` line and copy only the output |
125
125
  | `-p`, `--print` | Write the text to stdout instead of the clipboard (no `copied:` line) |
126
126
  | `--json` | Write the commands as JSON to stdout, for scripts and agents |
127
+ | `--gist` | Upload the text as a secret gist with the [GitHub CLI](https://cli.github.com) and copy its URL ([below](#--gist)) |
127
128
  | `--show-secrets` | Do not mask secrets and do not apply the replace table |
128
129
 
129
130
  `N` must be a positive integer. Specify the command count once, either as a positional `N` or with `-n N`; combining them or repeating `-n` is a usage error. If fewer matching commands are available, oops copies those it finds. `-n` can be combined with the formatting options above.
130
131
 
131
132
  `oops` never copies itself: if the previous command was `oops`, you get the command before it.
132
133
 
133
- Exit codes: `0` copied (or printed with `--print` or `--json`), `1` nothing copied (not recording, no command yet, no failed command, paused, or the clipboard command failed), `2` usage error.
134
+ Exit codes: `0` copied (or printed with `--print` or `--json`, or uploaded with `--gist`), `1` nothing copied (not recording, no command yet, no failed command, paused, the clipboard command failed, or `gh` failed with `--gist`), `2` usage error.
134
135
 
135
136
  ### Default output
136
137
 
@@ -206,6 +207,19 @@ $ bundle exec rspec
206
207
  ]
207
208
  ```
208
209
 
210
+ ### `--gist`
211
+
212
+ A long output is awkward to paste into a chat or an issue. `oops --gist` uploads the formatted text as a secret gist and copies the gist's URL instead, then prints it:
213
+
214
+ ```console
215
+ $ oops err --gist
216
+ gist: https://gist.github.com/you/4f1e8c0b2d9a7e6f5c3b1a0d9e8f7c6b (1 lines)
217
+ ```
218
+
219
+ oops does not talk to GitHub itself: it runs `gh gist create` from the [GitHub CLI](https://cli.github.com), so you need `gh` installed and logged in once with `gh auth login`. The gist holds one file, `oops.md`, and its description is the first command line. It works with `N`, `err`, `-n`, `--github`, `--time` and `--output-only`.
220
+
221
+ A secret gist is not listed or searchable, but anyone who has the URL can open it, so secrets are always masked: `--show-secrets` is a usage error with `--gist`, and so are `--print` and `--json`. Delete a gist you no longer need on gist.github.com or with `gh gist delete`. If no clipboard tool is found, the URL is still printed and oops warns that it was not copied.
222
+
209
223
  ### `oops status`
210
224
 
211
225
  `oops status` prints `recording`, `paused` or `off` (this shell is not recorded, or its log was deleted) and exits `0` only when recording. It prints no error, so a prompt or script can call it, for example with a [starship custom module](https://starship.rs/config/#custom-commands). Each call starts Ruby, which takes roughly 0.1 to 0.2 seconds; `oops doctor` tells more when the answer is `off`.
@@ -222,7 +236,7 @@ $ claude
222
236
  > Run `oops -p err` and fix the failing test.
223
237
  ```
224
238
 
225
- In Claude Code you can also type `! oops -p err` to put the output into the conversation yourself. Add `-n 3` for the last 3 commands, or use [`--json`](#--json) when a script or agent wants the exit code and output as separate fields. Other terminal agents work the same way when they pass your environment to their shell commands.
239
+ In Claude Code you can also type `! oops -p err` to put the output into the conversation yourself. Add `-n 3` for the last 3 commands, or use [`--json`](#--json) when a script or agent wants the exit code and output as separate fields. Other terminal agents work the same way when they pass your environment to their shell commands; see [Codex CLI](#codex-cli) for one.
226
240
 
227
241
  This helps most when running the command again is a bad idea:
228
242
 
@@ -259,6 +273,18 @@ $ARGUMENTS
259
273
 
260
274
  When nothing has failed yet, or the tab is not recorded, Claude Code shows oops's message instead.
261
275
 
276
+ ### Codex CLI
277
+
278
+ [Codex CLI](https://github.com/openai/codex) started in a recorded tab can run `oops -p err` too, for example `codex exec "Run oops -p err and fix the failing test"`. It works in Codex's `read-only` sandbox as well. To have it look there without being told, add this to `~/.codex/AGENTS.md` (all projects) or to the project's `AGENTS.md`:
279
+
280
+ ```markdown
281
+ ## Failed commands in my terminal
282
+
283
+ This terminal tab is recorded by [oops](https://github.com/ysb3996-blip/oops). When I ask about a command I ran that failed, run `oops -p err` to read its command line, output and exit code (secrets are masked) instead of asking me to paste it or running it again. `oops -p -n 3` shows the last 3 commands.
284
+ ```
285
+
286
+ With that in place, "my last command failed, why?" is enough. Without it, Codex answers that it cannot see your terminal.
287
+
262
288
  ## Configuration
263
289
 
264
290
  Optional file at `${XDG_CONFIG_HOME:-~/.config}/oops/config.yml`:
@@ -315,6 +341,22 @@ Masking is pattern based, so it is a safety net, not a guarantee: a secret in a
315
341
  - macOS: `pbcopy` chooses its text encoding from `LANG` / `LC_*`. If Japanese or other non-ASCII text arrives garbled, check that a UTF-8 locale is set (for example `LANG=en_US.UTF-8`), which can be missing in shells started over SSH.
316
342
  - Native Windows is not supported yet.
317
343
 
344
+ ## Troubleshooting
345
+
346
+ `oops doctor` prints one `label: value` line per check. When a line looks wrong, find it below. Paths in the examples are placeholders.
347
+
348
+ - `recording: no`: this tab is not recorded (the shell line then shows `hooks: missing` too, which is expected). Check that the `oops init` line is in your rc file and comes after whatever puts oops's Ruby on your `PATH` (see "Set up your shell"), then open a new tab. With powerlevel10k, the line must be above the instant prompt block.
349
+ - `recording: yes (/Users/you/.local/state/oops/sessions/... - log file missing)`: this tab's log does not exist. If a later line says `log writable: no (no status file)`, the recorder could not create the log when the tab opened (the tab then printed `oops: warning: session log unavailable (...)`), usually because the state directory (`~/.local/state/oops` by default) belongs to another user, for example after running oops with `sudo`, or cannot be written. Make it yours and writable again, then open a new tab; until then every new tab shows the same. Otherwise the log was deleted while the tab was open (for example with `rm -rf ~/.local/state/oops`); open a new tab.
350
+ - `this terminal: not the recorded tty (this: ..., recorded: ...)`: this shell runs on another terminal than the recorded tab it was started from (a tmux pane, or a terminal window opened from a recorded tab) and was not recorded on its own, so `oops` here reads the other tab's log. Such a shell is normally recorded on its own; check that the `oops init` line runs there too and that `OOPS_DISABLE` is not set. With `this: unknown`, `oops doctor` was not run from a terminal (for example an AI coding agent ran it in a recorded tab), so it cannot tell which terminal it is on; run `oops doctor` yourself at the prompt.
351
+ - `log writable: no (log-error: ...)`: writing the log failed; the message after `log-error:` says why (for example a full disk). Fix that and open a new tab.
352
+ - `paused: yes`: recording was paused with `oops pause`. Run `oops resume`.
353
+ - `shell: zsh, hooks: missing` while the first line says `recording: yes`: the shell is recorded but its hooks did not load, so commands are not logged. The line was probably typed at the prompt instead of being in the rc file; the recorded shell reads the rc file again and needs the line there. Open a new tab after adding it.
354
+ - `clipboard: osc52` when you expected `pbcopy`, `wl-copy`, `xclip` or `xsel`: that tool is not on `PATH` (or `DISPLAY` / `WAYLAND_DISPLAY` is not set). Install it, or set `clipboard:` in the config. Over SSH, `osc52` is expected.
355
+ - `config: /Users/you/.config/oops/config.yml (unknown key: clipbord)`: a misspelled key; it is ignored. `(could not parse /Users/you/.config/oops/config.yml: ...)` means the YAML is broken and oops runs without a config. `(missing)` only means there is no config file, which is fine.
356
+ - `warning: ~/.bashrc sets a DEBUG trap ...` or `warning: ~/.bashrc assigns PROMPT_COMMAND without appending ...` (bash only): a line below the `oops init bash` line can replace oops's hooks. Move it above the oops line. A `PROMPT_COMMAND` assignment can instead keep what is there: `PROMPT_COMMAND="...;$PROMPT_COMMAND"`.
357
+
358
+ If none of these help, open a [bug report](https://github.com/ysb3996-blip/oops/issues/new?template=bug_report.md) with the full `oops doctor` output (never a session log).
359
+
318
360
  ## Development
319
361
 
320
362
  ### Set up your machine
@@ -353,11 +395,11 @@ To try it as your shell does, build and install the gem into the Ruby you are us
353
395
 
354
396
  ```sh
355
397
  gem build oops-cli.gemspec
356
- gem install ./oops-cli-0.5.0.gem # the file name follows lib/oops/version.rb
398
+ gem install ./oops-cli-0.6.0.gem # the file name follows lib/oops/version.rb
357
399
  rbenv rehash # only with rbenv
358
400
  ```
359
401
 
360
- - A gem is installed per Ruby version. If a new tab uses another Ruby than the one you installed into (for example the repository pins 4.0.9, but your global Ruby is 3.3.5), the shell cannot find oops when it starts (bash prints `bash: oops: command not found`, zsh prints `command not found: oops`). Run `gem install` again under that Ruby, e.g. `RBENV_VERSION=3.3.5 gem install ./oops-cli-0.5.0.gem`.
402
+ - A gem is installed per Ruby version. If a new tab uses another Ruby than the one you installed into (for example the repository pins 4.0.9, but your global Ruby is 3.3.5), the shell cannot find oops when it starts (bash prints `bash: oops: command not found`, zsh prints `command not found: oops`). Run `gem install` again under that Ruby, e.g. `RBENV_VERSION=3.3.5 gem install ./oops-cli-0.6.0.gem`.
361
403
  - Reinstall after every change. The installed gem is a copy, not a link to your checkout.
362
404
  - To remove it: `gem uninstall oops-cli`.
363
405
  - Put `eval "$(oops init zsh)"` in your rc file, not just at the prompt: the recorded shell reads the rc file again, and without the line it has no hooks (`oops doctor` shows `hooks: missing`).
@@ -391,6 +433,7 @@ Thanks to everyone who has helped ([emoji key](https://allcontributors.org/docs/
391
433
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/ricky9408"><img src="https://avatars.githubusercontent.com/u/49530170?v=4?s=80" width="80px;" alt="Sanghyuk Lee"/><br /><sub><b>Sanghyuk Lee</b></sub></a><br /><a href="https://github.com/ysb3996-blip/oops/commits?author=ricky9408" title="Code">💻</a></td>
392
434
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/agenticsymphony-tech"><img src="https://avatars.githubusercontent.com/u/326739730?v=4?s=80" width="80px;" alt="agenticsymphony-tech"/><br /><sub><b>agenticsymphony-tech</b></sub></a><br /><a href="https://github.com/ysb3996-blip/oops/commits?author=agenticsymphony-tech" title="Documentation">📖</a></td>
393
435
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/ShahadatTest"><img src="https://avatars.githubusercontent.com/u/179203101?v=4?s=80" width="80px;" alt="ShahadatTest"/><br /><sub><b>ShahadatTest</b></sub></a><br /><a href="https://github.com/ysb3996-blip/oops/commits?author=ShahadatTest" title="Code">💻</a></td>
436
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/wolf4032"><img src="https://avatars.githubusercontent.com/u/144633223?v=4?s=80" width="80px;" alt="wolf4032"/><br /><sub><b>wolf4032</b></sub></a><br /><a href="https://github.com/ysb3996-blip/oops/commits?author=wolf4032" title="Documentation">📖</a></td>
394
437
  </tr>
395
438
  </tbody>
396
439
  </table>
data/lib/oops/cli.rb CHANGED
@@ -26,7 +26,7 @@ module Oops
26
26
  end
27
27
 
28
28
  options = { github: false, show_secrets: false, time: false, output_only: false, print: false,
29
- json: false }
29
+ json: false, gist: false }
30
30
  count = nil
31
31
  parser = OptionParser.new do |o|
32
32
  o.banner = "Usage: oops [N | err] [-n N] [options]\n " \
@@ -42,6 +42,7 @@ module Oops
42
42
  o.on("--show-secrets", "Do not mask secrets or apply the replace table") { options[:show_secrets] = true }
43
43
  o.on("-p", "--print", "Write the text to stdout instead of the clipboard") { options[:print] = true }
44
44
  o.on("--json", "Write the commands as JSON to stdout") { options[:json] = true }
45
+ o.on("--gist", "Upload as a secret gist (needs gh) and copy its URL") { options[:gist] = true }
45
46
  o.on("-v", "--version", "Print version and exit") do
46
47
  stdout.puts "oops #{VERSION}"
47
48
  return 0
@@ -52,7 +53,7 @@ module Oops
52
53
  end
53
54
  end
54
55
  copy_target = target(parser.parse(argv), count: count)
55
- check_json(options)
56
+ check_conflicts(options)
56
57
  copy(copy_target, options, env: env, stdout: stdout, stderr: stderr)
57
58
  rescue OptionParser::ParseError, UsageError => e
58
59
  stderr.puts "oops: #{e.message}"
@@ -69,14 +70,23 @@ module Oops
69
70
  end
70
71
 
71
72
  # --json has its own shape, so the Markdown formatting options make no
72
- # sense with it.
73
- def self.check_json(options)
74
- return unless options[:json]
75
-
76
- conflict = %i[github time output_only].find { |key| options[key] }
77
- raise UsageError, "--json cannot be combined with --#{conflict.to_s.tr('_', '-')}" if conflict
73
+ # sense with it. --gist sends the text somewhere other than -p and --json
74
+ # do, and anyone with a secret gist's URL can read it, so it never carries
75
+ # unmasked secrets.
76
+ CONFLICTS = { json: %i[github time output_only], gist: %i[show_secrets print json] }.freeze
77
+ private_constant :CONFLICTS
78
+
79
+ def self.check_conflicts(options)
80
+ CONFLICTS.each do |option, others|
81
+ next unless options[option]
82
+
83
+ conflict = others.find { |key| options[key] }
84
+ raise UsageError, "--#{option} cannot be combined with #{flag(conflict)}" if conflict
85
+ end
78
86
  end
79
87
 
88
+ def self.flag(key) = "--#{key.to_s.tr('_', '-')}"
89
+
80
90
  # Count comes from either a positional N or -n N. "err" filters the
81
91
  # selection to failed commands; without a count, one command is copied.
82
92
  def self.target(args, count:)
@@ -101,13 +111,15 @@ module Oops
101
111
  raise Failure, (target.failed_only ? "no failed command found." : "no command found yet.") if records.empty?
102
112
 
103
113
  home = env["HOME"].to_s.empty? ? Dir.home : env["HOME"]
104
- formatter = Formatter.new(config: config, home: home, **options.except(:print, :json))
114
+ formatter = Formatter.new(config: config, home: home, **options.except(:print, :json, :gist))
105
115
  if options[:json]
106
116
  stdout.write formatter.json(records)
107
117
  return 0
108
118
  end
109
119
 
110
120
  result = formatter.format(records)
121
+ return gist(result, config: config, env: env, stdout: stdout, stderr: stderr) if options[:gist]
122
+
111
123
  if options[:print]
112
124
  stdout.write result.text
113
125
  return 0
@@ -125,6 +137,26 @@ module Oops
125
137
  0
126
138
  end
127
139
 
140
+ # The gist is made before the clipboard is tried, so a missing or failing
141
+ # clipboard only costs a warning: the URL is on stdout either way.
142
+ def self.gist(result, config:, env:, stdout:, stderr:)
143
+ url = begin
144
+ Gist.create(result.text, description: "oops: $ #{report_command(result.command_line)}", env: env)
145
+ rescue Gist::Error => e
146
+ raise Failure, e.message
147
+ end
148
+ stdout.puts "gist: #{url} (#{report_counts(result)})"
149
+ begin
150
+ backend = Clipboard.detect(config.clipboard, env: env)
151
+ raise Clipboard::Error, NO_CLIPBOARD if backend.nil?
152
+
153
+ backend.copy(url)
154
+ rescue Clipboard::Error => e
155
+ stderr.puts "oops: warning: the URL was not copied: #{e.message}"
156
+ end
157
+ 0
158
+ end
159
+
128
160
  def self.report_command(command_line)
129
161
  first, rest = command_line.to_s.split("\n", 2)
130
162
  rest ? "#{first} ..." : first.to_s
@@ -259,7 +291,7 @@ module Oops
259
291
  0
260
292
  end
261
293
 
262
- private_class_method :positive, :check_json, :target, :copy, :report_command, :report_counts, :recording_log,
263
- :toggle, :write_marker, :status, :clear, :doctor
294
+ private_class_method :positive, :check_conflicts, :flag, :target, :copy, :gist, :report_command, :report_counts,
295
+ :recording_log, :toggle, :write_marker, :status, :clear, :doctor
264
296
  end
265
297
  end
data/lib/oops/gist.rb ADDED
@@ -0,0 +1,72 @@
1
+ require "open3"
2
+
3
+ module Oops
4
+ # Uploads text as a secret gist through the GitHub CLI and returns its URL.
5
+ # oops never talks to GitHub or touches a token itself; gh does both.
6
+ module Gist
7
+ class Error < StandardError; end
8
+
9
+ FILENAME = "oops.md".freeze
10
+ # Seconds to wait for gh; it has to reach GitHub, so this is longer than
11
+ # the clipboard timeout.
12
+ TIMEOUT = 30
13
+ NO_GH = "--gist needs the GitHub CLI (gh). Install it from https://cli.github.com " \
14
+ "and run gh auth login once.".freeze
15
+ NOT_LOGGED_IN = "gh is not logged in to GitHub. Run gh auth login first.".freeze
16
+
17
+ module_function
18
+
19
+ # Returns the gist URL. Raises Error when gh is missing, not logged in,
20
+ # fails, times out or prints no URL. env supplies PATH for finding gh.
21
+ def create(text, description:, env: ENV, timeout: TIMEOUT)
22
+ argv = ["gh", "gist", "create", "-", "--filename", FILENAME, "--desc", description]
23
+ out, err, status = capture(argv, text, env, timeout)
24
+ raise Error, failure_message(err) unless status.success?
25
+
26
+ url = out.lines.map(&:strip).reverse.find { |line| line.start_with?("https://") }
27
+ raise Error, "gh gist create printed no URL" if url.nil?
28
+
29
+ url
30
+ end
31
+
32
+ def capture(argv, text, env, timeout)
33
+ spawn_env = env["PATH"] ? { "PATH" => env["PATH"] } : {}
34
+ Open3.popen3(spawn_env, *argv, pgroup: true) do |stdin, stdout, stderr, wait|
35
+ readers = [Thread.new { stdout.read }, Thread.new { stderr.read }]
36
+ begin
37
+ stdin.write(text)
38
+ rescue Errno::EPIPE
39
+ nil
40
+ end
41
+ stdin.close
42
+ unless wait.join(timeout)
43
+ kill_group(wait.pid)
44
+ readers.each(&:kill)
45
+ raise Error, "gh timed out after #{timeout}s"
46
+ end
47
+ [readers[0].value.to_s, readers[1].value.to_s, wait.value]
48
+ end
49
+ rescue Errno::ENOENT
50
+ raise Error, NO_GH
51
+ rescue SystemCallError, IOError => e
52
+ raise Error, "gh: #{e.message}"
53
+ end
54
+
55
+ def kill_group(pid)
56
+ Process.kill("KILL", -pid)
57
+ rescue SystemCallError
58
+ nil
59
+ end
60
+
61
+ # gh asks for `gh auth login` when it has no usable token. Otherwise the
62
+ # last line of its stderr holds the error; earlier lines are progress.
63
+ def failure_message(err)
64
+ return NOT_LOGGED_IN if err.match?(/gh auth login/)
65
+
66
+ last = err.lines.map(&:strip).reject(&:empty?).last
67
+ last ? "gh gist create failed: #{last}" : "gh gist create failed"
68
+ end
69
+
70
+ private_class_method :capture, :kill_group, :failure_message
71
+ end
72
+ end
data/lib/oops/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Oops
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.6.0".freeze
3
3
  end
data/lib/oops.rb CHANGED
@@ -13,5 +13,6 @@ require_relative "oops/stream_parser"
13
13
  require_relative "oops/recorder"
14
14
  require_relative "oops/shell_init"
15
15
  require_relative "oops/clipboard"
16
+ require_relative "oops/gist"
16
17
  require_relative "oops/doctor"
17
18
  require_relative "oops/cli"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oops-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ysb3996-blip
@@ -32,6 +32,7 @@ files:
32
32
  - lib/oops/config.rb
33
33
  - lib/oops/doctor.rb
34
34
  - lib/oops/formatter.rb
35
+ - lib/oops/gist.rb
35
36
  - lib/oops/marker.rb
36
37
  - lib/oops/paths.rb
37
38
  - lib/oops/prompt_sp.rb