[
  {
    "path": ".gitignore",
    "content": "/.bundle/\n/.yardoc\n/_yardoc/\n/coverage/\n/doc/\n/pkg/\n/spec/reports/\n/tmp/\n\n# rspec failure tracking\n.rspec_status\n"
  },
  {
    "path": ".rspec",
    "content": "--format documentation\n--color\n--require spec_helper\n"
  },
  {
    "path": ".rubocop.yml",
    "content": "AllCops:\n  NewCops: enable\n  TargetRubyVersion: 3.2\n\nStyle/StringLiterals:\n  Enabled: true\n  EnforcedStyle: double_quotes\n\nStyle/StringLiteralsInInterpolation:\n  Enabled: true\n  EnforcedStyle: double_quotes\n\nLayout/LineLength:\n  Max: 120\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "## [Unreleased]\n\n## [0.1.0] - 2022-12-23\n\n- Initial release\n"
  },
  {
    "path": "Gemfile",
    "content": "# frozen_string_literal: true\n\nsource \"https://rubygems.org\"\n\n# Specify your gem's dependencies in openai_pipe.gemspec\ngemspec\n\ngem \"rake\", \"~> 13.0\"\n\ngem \"rspec\", \"~> 3.0\"\n\ngem \"rubocop\", \"~> 1.21\"\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2022 John DeSilva\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# OpenAIPipe\n\nThis library provides a UNIX-ey interface to OpenAI.\nSee [Installation](#installation) and [Setup](#setup) below, but first, some examples.\n\n## Examples\n\n```console\n$ ai what is two plus two\nTwo plus two is equal to four.\n```\n\n```console\n$ uptime | ai convert this to json\n{\n        \"time_of_measurement\": \"13:48:26\",\n        \"up_time\": \"30 days, 18:07\",\n        \"users\": 3,\n        \"load_average\": [\n                0.46,\n                0.61,\n                0.79\n        ]\n}\n```\n\n```console\n$ ai list the nine planets as JSON | ai convert this to XML but in French | tee planets.fr.xml\n<Planètes>\n   <Planète>Mercure</Planète>\n   <Planète>Vénus</Planète>\n   <Planète>La Terre</Planète>\n   <Planète>Mars</Planète>\n   <Planète>Jupiter</Planète>\n   <Planète>Saturne</Planète>\n   <Planète>Uranus</Planète>\n   <Planète>Neptune</Planète>\n   <Planète>Pluton</Planète>\n</Planètes>\n```\n\n```console\n$ curl -sL \"https://en.wikipedia.org/wiki/cats\" | head -n 5 | ai extract just the title of this webpage | figlet\n  ____      _            __        ___ _    _                _ _\n / ___|__ _| |_          \\ \\      / (_) | _(_)_ __   ___  __| (_) __ _\n| |   / _` | __|  _____   \\ \\ /\\ / /| | |/ / | '_ \\ / _ \\/ _` | |/ _` |\n| |__| (_| | |_  |_____|   \\ V  V / | |   <| | |_) |  __/ (_| | | (_| |\n \\____\\__,_|\\__|            \\_/\\_/  |_|_|\\_\\_| .__/ \\___|\\__,_|_|\\__,_|\n                                             |_|\n```\n\n```console\n$ ls | ai What is this directory for?\nThis directory contains the source code for a Ruby-based project called openai_pipe. It includes files related to the project's license (LICENSE.txt), changelog (CHANGELOG.md), dependencies (Gemfile and Gemfile.lock), executables (bin and exe), libraries (lib), signature (sig) and tests (spec). There is also a Rakefile and a README.md file which provide information about how to build and install the project, as well as its features and usage. Finally, it includes the openai_pipe-0.1.0.gem and openai_pipe.gemspec files which are used to build the gem which can be installed on other systems.\n```\n\n```console\n$ ls -l | ai which of these are directories?\nbin, exe, lib, sig, spec\n```\n\n```console\n$ ls | ai \"For each of these files, provide a description of what is likely to be their contents?\"\nbin - Likely contains compiled binary executable files.\nCHANGELOG.md - Likely contains a log of changes/modifications, such as bug fixes and new features, that have been made to the project.\nexe - Likely contains executable files.\nfrench_planets.xml - Likely contains an XML file containing data related to planets, likely in French.\nGemfile - Likely contains Ruby code for the project's dependencies.\nGemfile.lock - Likely contains a snapshot of the dependencies of the project and versions of those dependencies.\nlib - Likely contains the Ruby source code (e.g. classes and modules) for the project.\nLICENSE.txt - Likely contains the terms of use/license for the project.\nopenai_pipe-0.1.0.gem - Likely contains a gem that gathers information from the OpenAI API.\nopenai_pipe.gemspec - Likely contains configuration details for the gem.\nplanets.lst - Likely contains a list of planets.\npoem.txt - Likely contains a text file containing a poem.\nRakefile - Likely contains Ruby tasks and dependencies that can be used in projects.\nREADME.md - Likely contains general information about the project and usage instructions.\nreverse.lst - Likely contains a list of words or items that are in reverse order.\nsig - Likely contains digital signatures to validate individual files.\nspec - Likely contains Ruby specs (i.e. tests) for the project.\nuptime.json - Likely contains a file with information regarding system uptime of a computer.\n```\n\n```console\n$ git commit -m \"$(git status | ai write me a commit message for these changes)\"\n[master 7d0271f] Add new files and modify README.md\n```\n\n```console\n$ git status | tee /dev/tty | ai write me a sonnet about the status of this git repository\nOn branch master\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n        openai_pipe-0.1.0.gem\n\nnothing added to commit but untracked files present (use \"git add\" to track)\n\nMy master branch may lack to thee its kin\nFor change it holds the only force within\nThé untracked files, they still remain unnamed\n‘Tis fervent hope thé change will soon be claimed\n\nFraught with the choice to leave or to persist\nThe repository wavers ‘tween future and past\nThe openai_pipe-0.1.0 gem stands out\nWaiting to be added, not yet about\n\nThe commit awaits for brave new changes bold\nWhile time’s old force is ever unfurled\nCommit forth young mind, furrow not to crawl\nFrom untracked files, a future stands tall.\n```\n\n```console\n% history | ai what was the last thing I did\nThe last command you entered was 'history'.\n```\nn.b. somehow it sees history-esque output and determines that history was typed -- the history command does not itself include the history command in the output.\n\n```console\n$ history | ai what was the last thing I did before typing history\nThe last thing you did was amend a README.md file.\n```\nn.b. here it determines the amend was for README.md not from the previous command but from ones prior that edited README.md.\n\n```console\n$ cat lib/openai_pipe/version.rb | ai rewrite this file with just the minor version incremented | sponge > lib/openai_pipe/version.rb\n$ git diff\ndiff --git a/lib/openai_pipe/version.rb b/lib/openai_pipe/version.rb\nindex 0f82357..cc57fab 100644\n--- a/lib/openai_pipe/version.rb\n+++ b/lib/openai_pipe/version.rb\n@@ -1,5 +1,5 @@\n # frozen_string_literal: true\n\n module OpenAIPipe\n-  VERSION = \"0.1.0\"\n+  VERSION = \"0.1.1\"\n end\n```\n\n```console\n$ ruby -e \"$(ai write me a python script that prints the current month | ai translate this into ruby)\" | ai translate this into French\nLe mois courant est Décembre.\n```\n\n## Installation\n\nInstall the gem by executing:\n\n    $ gem install openai_pipe\n\n## Setup\n\nThis library uses [quick_openai](https://github.com/Aesthetikx/quick_openai) which itself uses [ruby-openai](https://github.com/alexrudall/ruby-openai), so you may want to familiarise yourself with those projects first.\n\nThis library uses OpenAI GPT3 to generate responses, so you will need to have your access token available in ENV. In .bashrc or equivalent,\n```bash\nexport OPENAI_ACCESS_TOKEN=mytoken\n```\n\nBy default the executable is called `openai_pipe`. It is reccommended to alias this command to something shorter in .bashrc or equivalent, e.g.\n```bash\nalias ai=\"openai_pipe\"\n```\n\n## Notes\n\nBe aware that there is a cost associated every time GPT3 is invoked, so be mindful of your account usage. Also be wary of sending sensitive data to OpenAI, and also wary of arbitrarily executing scripts or programs that GPT3 generates.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/Aesthetikx/openai_pipe.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n"
  },
  {
    "path": "Rakefile",
    "content": "# frozen_string_literal: true\n\nrequire \"bundler/gem_tasks\"\nrequire \"rspec/core/rake_task\"\n\nRSpec::Core::RakeTask.new(:spec)\n\nrequire \"rubocop/rake_task\"\n\nRuboCop::RakeTask.new\n\ntask default: %i[spec rubocop]\n"
  },
  {
    "path": "bin/console",
    "content": "#!/usr/bin/env ruby\n# frozen_string_literal: true\n\nrequire \"bundler/setup\"\nrequire \"openai_pipe\"\n\n# You can add fixtures and/or initialization code here to make experimenting\n# with your gem easier. You can also use a different console, if you like.\n\n# (If you use this, don't forget to add pry to your Gemfile!)\n# require \"pry\"\n# Pry.start\n\nrequire \"irb\"\nIRB.start(__FILE__)\n"
  },
  {
    "path": "bin/setup",
    "content": "#!/usr/bin/env bash\nset -euo pipefail\nIFS=$'\\n\\t'\nset -vx\n\nbundle install\n\n# Do any other automated setup that you need to do here\n"
  },
  {
    "path": "exe/openai_pipe",
    "content": "#!/usr/bin/env ruby\n\nrequire \"openai_pipe\"\n\nOpenAIPipe.exe\n"
  },
  {
    "path": "lib/openai_pipe/version.rb",
    "content": "# frozen_string_literal: true\n\nmodule OpenAIPipe\n  VERSION = \"0.2.0\"\nend\n"
  },
  {
    "path": "lib/openai_pipe.rb",
    "content": "# frozen_string_literal: true\n\nrequire_relative \"openai_pipe/version\"\n\nrequire \"quick_openai\"\n\nmodule OpenAIPipe\n  class Error < StandardError; end\n\n  def self.exe\n    input_from_pipe = $stdin.read if $stdin.stat.pipe?\n\n    input_from_arguments = ARGV.join(\" \") if ARGV.any?\n\n    prompt = [input_from_arguments, input_from_pipe].compact.join(\"\\n\\n\")\n\n    puts prompt.gpt\n  rescue QuickOpenAI::Error => e\n    warn e.message\n    exit 1\n  end\nend\n"
  },
  {
    "path": "openai_pipe.gemspec",
    "content": "# frozen_string_literal: true\n\nrequire_relative \"lib/openai_pipe/version\"\n\nGem::Specification.new do |spec|\n  spec.name = \"openai_pipe\"\n  spec.version = OpenAIPipe::VERSION\n  spec.authors = [\"John DeSilva\"]\n  spec.email = [\"desilvjo@umich.edu\"]\n\n  spec.summary = \"A UNIX-ey interface to OpenAI\"\n  spec.description = \"Provides pipe and redirect functionality to quick_openai\"\n  spec.homepage = \"https://www.github.com/Aesthetikx/openai_pipe\"\n  spec.license = \"MIT\"\n  spec.required_ruby_version = \">= 3.2\"\n\n  spec.metadata[\"homepage_uri\"] = spec.homepage\n  spec.metadata[\"source_code_uri\"] = \"https://www.github.com/Aesthetikx/openai_pipe\"\n  spec.metadata[\"changelog_uri\"] = \"https://www.github.com/Aesthetikx/openai_pipe/blob/master/CHANGELOG.md\"\n  spec.metadata[\"rubygems_mfa_required\"] = \"true\"\n\n  # Specify which files should be added to the gem when it is released.\n  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.\n  spec.files = Dir.chdir(__dir__) do\n    `git ls-files -z`.split(\"\\x0\").reject do |f|\n      (f == __FILE__) || f.match(%r{\\A(?:(?:bin|test|spec|features)/|\\.(?:git|travis|circleci)|appveyor)})\n    end\n  end\n  spec.bindir = \"exe\"\n  spec.executables = spec.files.grep(%r{\\Aexe/}) { |f| File.basename(f) }\n  spec.require_paths = [\"lib\"]\n\n  spec.add_dependency \"quick_openai\", \"~> 0.3\"\n\n  # For more information and examples about making a new gem, check out our\n  # guide at: https://bundler.io/guides/creating_gem.html\nend\n"
  },
  {
    "path": "sig/openai_pipe.rbs",
    "content": "module OpenaiPipe\n  VERSION: String\n  # See the writing guide of rbs: https://github.com/ruby/rbs#guides\nend\n"
  },
  {
    "path": "spec/openai_pipe_spec.rb",
    "content": "# frozen_string_literal: true\n\nRSpec.describe OpenAIPipe do\n  it \"has a version number\" do\n    expect(OpenAIPipe::VERSION).not_to be nil\n  end\n\n  it \"does something useful\" do\n    expect(true).to eq(true)\n  end\nend\n"
  },
  {
    "path": "spec/spec_helper.rb",
    "content": "# frozen_string_literal: true\n\nrequire \"openai_pipe\"\n\nRSpec.configure do |config|\n  # Enable flags like --only-failures and --next-failure\n  config.example_status_persistence_file_path = \".rspec_status\"\n\n  # Disable RSpec exposing methods globally on `Module` and `main`\n  config.disable_monkey_patching!\n\n  config.expect_with :rspec do |c|\n    c.syntax = :expect\n  end\nend\n"
  }
]