-
Notifications
You must be signed in to change notification settings - Fork 0
feat(tui): command history recall + tmux/stdout fire targets #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
210e51e
feat(tui): command history recall + tmux/stdout fire targets
jessengolab 00b7e2b
fix(tui,history,fire): address CodeRabbit review on #9
jessengolab 714e276
docs: revamp README (problem hook, comparison, demo); wire CodeRabbit
jessengolab 6b918d4
ci(security): add gitleaks secret scan, extend CodeQL to develop
jessengolab 1e49398
fix(history): set only the DACL on Windows, not owner
jessengolab 47b76d5
build: add make verify (scripts/dev-check.sh) full CI mirror
jessengolab 4446e86
fix(history): apply owner-only DACL at creation, re-tighten best-effort
jessengolab 7c0f6b8
fix(scripts): make verify fail without golangci-lint; cross-lint all …
jessengolab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json | ||
| # | ||
| # CodeRabbit configuration for nock. | ||
| # Reviews are scoped to the git-flow integration branches: pull requests INTO | ||
| # `develop` (feature -> develop) and INTO `main` (develop -> main). On those PRs a | ||
| # review can be (re)triggered any time by commenting `@coderabbitai review`. | ||
| language: en-US | ||
| early_access: false | ||
|
|
||
| reviews: | ||
| # CHILL keeps the signal high — fewer, higher-confidence findings — matching how | ||
| # this repo reviews (correctness + security over nitpicks). | ||
| profile: chill | ||
| request_changes_workflow: false | ||
| high_level_summary: true | ||
| poem: false | ||
| review_status: true | ||
|
|
||
| auto_review: | ||
| enabled: true | ||
| drafts: false | ||
| # Only PRs targeting these branches are reviewed: feature -> develop, and the | ||
| # develop -> main release PR. PRs to other bases are left alone. | ||
| base_branches: | ||
| - develop | ||
| - main | ||
|
|
||
| chat: | ||
| auto_reply: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: gitleaks | ||
|
|
||
| # Secret scanning — mechanically enforces nock's hard rule that API keys never | ||
| # land in commits, logs, or history. Gitleaks is the de-facto OSS secret scanner | ||
| # and is free for public repositories. | ||
| # | ||
| # Scoped to both git-flow merge hops: PRs into develop (feature -> develop) and | ||
| # into main (develop -> main), plus a weekly sweep that catches a secret pattern | ||
| # disclosed after it was committed. Report-only for now: this check is intentionally | ||
| # NOT a required status check yet — let it run and annotate while false positives | ||
| # are tuned, then promote it to required in branch protection. | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, develop] | ||
| pull_request: | ||
| branches: [main, develop] | ||
| schedule: | ||
| - cron: "13 6 * * 1" # weekly, Monday 06:13 UTC | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write # post the findings summary on the PR | ||
| security-events: write # upload SARIF to the Security tab | ||
|
|
||
| jobs: | ||
| scan: | ||
| name: scan | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| fetch-depth: 0 # full history so PR-range and push diffs are scanned | ||
| - name: gitleaks | ||
| uses: gitleaks/gitleaks-action@v2 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // Package fire delivers a confirmed, fully resolved command out of nock to the | ||
| // operator's chosen target. It is the concrete edge of show-before-fire (ADR 009/ | ||
| // 015): nothing here resolves or expands anything — the string passed in is | ||
| // exactly what the confirm screen displayed. | ||
| // | ||
| // nock never executes the command itself: | ||
| // - stdout prints it for the operator's shell to capture (the default; ADR 015). | ||
| // - tmux prefills it into the current pane's command line via `send-keys -l` | ||
| // with NO trailing newline, so the operator still presses Enter to run it. | ||
| // | ||
| // Both are explicit, operator-driven acts. Displayed == emitted; no auto-run. | ||
| package fire | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "io" | ||
| "os" | ||
| "os/exec" | ||
| ) | ||
|
|
||
| // Target is where a confirmed command is delivered. | ||
| type Target string | ||
|
|
||
| const ( | ||
| // Stdout prints the command to standard output (default). | ||
| Stdout Target = "stdout" | ||
| // Tmux prefills the command into the current tmux pane without running it. | ||
| Tmux Target = "tmux" | ||
| ) | ||
|
|
||
| // ErrUnknownTarget is returned by Parse for an unrecognised target name. | ||
| var ErrUnknownTarget = errors.New("fire: unknown target") | ||
|
|
||
| // Parse converts a flag value to a Target. Empty string defaults to Stdout. | ||
| func Parse(s string) (Target, error) { | ||
| switch Target(s) { | ||
| case "", Stdout: | ||
| return Stdout, nil | ||
| case Tmux: | ||
| return Tmux, nil | ||
| default: | ||
| return "", fmt.Errorf("%w %q (want stdout|tmux)", ErrUnknownTarget, s) | ||
| } | ||
| } | ||
|
|
||
| // Available reports whether the target can be used in the current environment. | ||
| // Tmux requires running inside a tmux session ($TMUX set); Stdout is always | ||
| // available. The TUI uses this to avoid offering a tmux fire that would fail. | ||
| func (t Target) Available() bool { | ||
| switch t { | ||
| case Tmux: | ||
| return os.Getenv("TMUX") != "" | ||
| default: | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| // Emit delivers cmd to the target. Stdout writes to the package's Stdout writer | ||
| // (a trailing newline, so a shell reads a complete line). Tmux shells out to | ||
| // `tmux send-keys -l` — literal, no Enter — leaving cmd on the pane's prompt for | ||
| // the operator to fire. | ||
| func Emit(t Target, cmd string) error { | ||
| switch t { | ||
| case Tmux: | ||
| if !t.Available() { | ||
| return errors.New("fire: not inside a tmux session ($TMUX unset)") | ||
| } | ||
| // -l sends the argument literally; the absence of a following Enter is | ||
| // what makes this a prefill, not an auto-run. | ||
| c := exec.Command("tmux", "send-keys", "-l", cmd) | ||
| if out, err := c.CombinedOutput(); err != nil { | ||
| return fmt.Errorf("fire: tmux send-keys: %w: %s", err, out) | ||
| } | ||
| return nil | ||
| case "", Stdout: | ||
| if _, err := fmt.Fprintln(Out, cmd); err != nil { | ||
| return fmt.Errorf("fire: stdout: %w", err) | ||
| } | ||
| return nil | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| default: | ||
| // An unknown target must fail loudly, not silently fall back to stdout — | ||
| // that would deliver a command somewhere the operator did not choose. | ||
| return fmt.Errorf("%w %q (want stdout|tmux)", ErrUnknownTarget, t) | ||
| } | ||
| } | ||
|
|
||
| // Out is the writer the Stdout target prints to. It is a package variable so | ||
| // tests can capture emitted commands without a real terminal. | ||
| var Out io.Writer = os.Stdout | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.